From d14e4924c55e3016d1ddf7a38a7e93460ca10ac8 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Mon, 4 Feb 2013 10:38:16 +0100 Subject: Add x86 hardware debugging register support This adds using the x86 hardware debugging registers, either from the kernel through db_set_hw_watchpoint, or from userland through i386_DEBUG_STATE. While the kernel is using the registers, the userland values are ignored. * i386/i386/db_interface.c (kernel_dr, ids): New variables. (db_load_context, db_get_debug_state, db_set_debug_state, db_dr, db_set_hw_watchpoint): New functions. (kdb_trap): Use get_dr* instead of dr_addr[]. * i386/i386/db_interface.h (db_user_to_kernel_address, db_set_hw_watchpoint) (db_dr, db_get_debug_state, db_set_debug_state, db_load_context): Add functions prototypes. (dr0, dr1, dr2, dr3): Remove functions prototypes. * i386/i386/locore.S (dr6, dr0, dr1, dr2, dr3): Remove functions. (dr_msk, dr_addr): Remove variables. * i386/include/mach/i386/thread_status.h (i386_DEBUG_STATE): Add macro. (i386_debug_state): Add structure. (i386_DEBUG_STATE_COUNT): Add macro. * i386/i386/thread.h: Include . (i386_machine_state): Add `struct i386_debug_state ids' field. * i386/i386/pcb.c: Include . (switch_ktss): Call db_load_context. (thread_setstatus, thread_getstatus): Add I386_DEBUG_STATE case. * i386/i386/proc_reg.h (get_dr0, set_dr0, get_dr1, set_dr1, get_dr2, set_dr2, get_dr3, set_dr3, get_dr6, set_dr6, get_dr7, set_dr7): Add macros. --- i386/i386/db_interface.c | 150 +++++++++++++++++++++++++++++++-- i386/i386/db_interface.h | 31 ++++++- i386/i386/locore.S | 122 --------------------------- i386/i386/pcb.c | 32 +++++++ i386/i386/proc_reg.h | 126 +++++++++++++++++++++++++++ i386/i386/thread.h | 2 + i386/include/mach/i386/thread_status.h | 7 ++ 7 files changed, 336 insertions(+), 134 deletions(-) diff --git a/i386/i386/db_interface.c b/i386/i386/db_interface.c index 66cc8b59..c6d7fb41 100644 --- a/i386/i386/db_interface.c +++ b/i386/i386/db_interface.c @@ -27,8 +27,6 @@ * Interface to new debugger. */ -#if MACH_KDB - #include #include @@ -58,12 +56,149 @@ #include #include +#if MACH_KDB +/* Whether the kernel uses any debugging register. */ +static int kernel_dr; +#endif + +void db_load_context(pcb_t pcb) +{ +#if MACH_KDB + int s = splhigh(); + + if (kernel_dr) { + splx(s); + return; + } +#endif + + /* Else set user debug registers */ + set_dr0(pcb->ims.ids.dr[0]); + set_dr1(pcb->ims.ids.dr[1]); + set_dr2(pcb->ims.ids.dr[2]); + set_dr3(pcb->ims.ids.dr[3]); + set_dr7(pcb->ims.ids.dr[7]); +#if MACH_KDB + splx(s); +#endif +} + +void db_get_debug_state( + pcb_t pcb, + struct i386_debug_state *state) +{ + *state = pcb->ims.ids; +} + +kern_return_t db_set_debug_state( + pcb_t pcb, + const struct i386_debug_state *state) +{ + int i; + + for (i = 0; i <= 3; i++) + if (state->dr[i] < VM_MIN_ADDRESS + || state->dr[i] >= VM_MAX_ADDRESS) + return KERN_INVALID_ARGUMENT; + + pcb->ims.ids = *state; + + if (pcb == current_thread()->pcb) + db_load_context(pcb); + + return KERN_SUCCESS; +} + +#if MACH_KDB + struct i386_saved_state *i386_last_saved_statep; struct i386_saved_state i386_nested_saved_state; unsigned i386_last_kdb_sp; extern thread_t db_default_thread; +static struct i386_debug_state ids; + +void db_dr ( + int num, + vm_offset_t linear_addr, + int type, + int len, + int persistence) +{ + int s = splhigh(); + unsigned long dr7; + + if (!kernel_dr) { + if (!linear_addr) { + splx(s); + return; + } + kernel_dr = 1; + /* Clear user debugging registers */ + set_dr7(0); + set_dr0(0); + set_dr1(0); + set_dr2(0); + set_dr3(0); + } + + ids.dr[num] = linear_addr; + switch (num) { + case 0: set_dr0(linear_addr); break; + case 1: set_dr1(linear_addr); break; + case 2: set_dr2(linear_addr); break; + case 3: set_dr3(linear_addr); break; + } + + /* Replace type/len/persistence for DRnum in dr7 */ + dr7 = get_dr7 (); + dr7 &= ~(0xfUL << (4*num+16)) & ~(0x3UL << (2*num)); + dr7 |= (((len << 2) | type) << (4*num+16)) | (persistence << (2*num)); + set_dr7 (dr7); + + if (kernel_dr) { + if (!ids.dr[0] && !ids.dr[1] && !ids.dr[2] && !ids.dr[3]) { + /* Not used any more, switch back to user debugging registers */ + kernel_dr = 0; + db_load_context(current_thread()->pcb); + } + } + splx(s); +} + +void db_set_hw_watchpoint( + int num, + task_t task, + db_addr_t addr, + vm_size_t size) +{ + unsigned int kern_addr; + + if (size != 1 && size != 2 && size != 4) + return; + + if (addr & (size-1)) + /* Unaligned */ + return; + + if (!addr) { + db_dr (num, 0, 0, 0, 0); + db_printf("Hardware watchpoint %d deleted\n", num); + } + + if (task) { + if (db_user_to_kernel_address(task, addr, &kern_addr, 1) < 0) + return; + addr = kern_addr; + } + addr = kvtolin(addr); + + db_dr (num, addr, I386_DB_TYPE_W, size-1, I386_DB_LOCAL|I386_DB_GLOBAL); + + db_printf("Hardware watchpoint %d set for %x\n", num, addr); +} + /* * Print trap reason. */ @@ -96,15 +231,14 @@ kdb_trap( switch (type) { case T_DEBUG: /* single_step */ { - extern int dr_addr[]; int addr; - int status = dr6(); + int status = get_dr6(); if (status & 0xf) { /* hmm hdw break */ - addr = status & 0x8 ? dr_addr[3] : - status & 0x4 ? dr_addr[2] : - status & 0x2 ? dr_addr[1] : - dr_addr[0]; + addr = status & 0x8 ? get_dr3() : + status & 0x4 ? get_dr2() : + status & 0x2 ? get_dr1() : + get_dr0(); regs->efl |= EFL_RF; db_single_step_cmd(addr, 0, 1, "p"); } diff --git a/i386/i386/db_interface.h b/i386/i386/db_interface.h index 10a02e2b..a8dfdce1 100644 --- a/i386/i386/db_interface.h +++ b/i386/i386/db_interface.h @@ -53,6 +53,12 @@ extern boolean_t db_phys_eq ( task_t task2, vm_offset_t addr2); +extern int db_user_to_kernel_address( + task_t task, + vm_offset_t addr, + unsigned int *kaddr, + int flag); + extern void db_task_name (task_t task); #define I386_DB_TYPE_X 0 @@ -67,9 +73,26 @@ extern void db_task_name (task_t task); #define I386_DB_LOCAL 1 #define I386_DB_GLOBAL 2 -extern unsigned long dr0 (vm_offset_t linear_addr, int type, int len, int persistence); -extern unsigned long dr1 (vm_offset_t linear_addr, int type, int len, int persistence); -extern unsigned long dr2 (vm_offset_t linear_addr, int type, int len, int persistence); -extern unsigned long dr3 (vm_offset_t linear_addr, int type, int len, int persistence); +extern void db_set_hw_watchpoint( + int num, + task_t task, + vm_offset_t addr, + vm_size_t size); + +extern void db_dr ( + int num, + vm_offset_t linear_addr, + int type, + int len, + int persistence); + +extern void db_get_debug_state( + pcb_t pcb, + struct i386_debug_state *state); +extern kern_return_t db_set_debug_state( + pcb_t pcb, + const struct i386_debug_state *state); + +extern void db_load_context(pcb_t pcb); #endif /* _I386_DB_INTERFACE_H_ */ diff --git a/i386/i386/locore.S b/i386/i386/locore.S index 9aa84853..e1befa71 100644 --- a/i386/i386/locore.S +++ b/i386/i386/locore.S @@ -1411,128 +1411,6 @@ _inst_fetch_fault: -ENTRY(dr6) -#ifdef MACH_RING1 - pushl %ebx - movl $6, %ebx - call __hyp_get_debugreg - popl %ebx -#else /* MACH_RING1 */ - movl %db6, %eax -#endif /* MACH_RING1 */ - ret - -/* dr(address, type, len, persistence) - */ -ENTRY(dr0) - movl S_ARG0, %eax - movl %eax,EXT(dr_addr) -#ifdef MACH_RING1 - pushl %ebx - movl $0,%ebx - movl %eax,%ecx - call __hyp_set_debugreg -#else /* MACH_RING1 */ - movl %eax, %db0 -#endif /* MACH_RING1 */ - movl $0, %ecx - jmp 0f -ENTRY(dr1) - movl S_ARG0, %eax - movl %eax,EXT(dr_addr)+1*4 -#ifdef MACH_RING1 - pushl %ebx - movl $1,%ebx - movl %eax,%ecx - call __hyp_set_debugreg -#else /* MACH_RING1 */ - movl %eax, %db1 -#endif /* MACH_RING1 */ - movl $2, %ecx - jmp 0f -ENTRY(dr2) - movl S_ARG0, %eax - movl %eax,EXT(dr_addr)+2*4 -#ifdef MACH_RING1 - pushl %ebx - movl $2,%ebx - movl %eax,%ecx - call __hyp_set_debugreg -#else /* MACH_RING1 */ - movl %eax, %db2 -#endif /* MACH_RING1 */ - movl $4, %ecx - jmp 0f - -ENTRY(dr3) - movl S_ARG0, %eax - movl %eax,EXT(dr_addr)+3*4 -#ifdef MACH_RING1 - pushl %ebx - movl $3,%ebx - movl %eax,%ecx - call __hyp_set_debugreg -#else /* MACH_RING1 */ - movl %eax, %db3 -#endif /* MACH_RING1 */ - movl $6, %ecx - -0: - pushl %ebp - movl %esp, %ebp - -#ifdef MACH_RING1 - movl $7,%ebx - call __hyp_get_debugreg - movl %eax, %edx -#else /* MACH_RING1 */ - movl %db7, %edx -#endif /* MACH_RING1 */ - movl %edx,EXT(dr_addr)+4*4 - andl dr_msk(,%ecx,2),%edx /* clear out new entry */ - movl %edx,EXT(dr_addr)+5*4 - movzbl B_ARG3, %eax - andb $3, %al - shll %cl, %eax - orl %eax, %edx - - movzbl B_ARG1, %eax - andb $3, %al - addb %cl, %cl - addb $0x10, %cl - shll %cl, %eax - orl %eax, %edx - - movzbl B_ARG2, %eax - andb $3, %al - addb $0x2, %cl - shll %cl, %eax - orl %eax, %edx - -#ifdef MACH_RING1 - movl $7,%ebx - movl %edx, %ecx - call __hyp_set_debugreg - popl %ebx -#else /* MACH_RING1 */ - movl %edx, %db7 -#endif /* MACH_RING1 */ - movl %edx,EXT(dr_addr)+7*4 - movl %edx, %eax - leave - ret - - .data -dr_msk: - .long ~0x000f0003 - .long ~0x00f0000c - .long ~0x0f000030 - .long ~0xf00000c0 -ENTRY(dr_addr) - .long 0,0,0,0 - .long 0,0,0,0 - .text - /* * cpu_shutdown() * Force reboot diff --git a/i386/i386/pcb.c b/i386/i386/pcb.c index 7d632a6b..97ec00e6 100644 --- a/i386/i386/pcb.c +++ b/i386/i386/pcb.c @@ -46,6 +46,7 @@ #include #include #include +#include #include #include "eflags.h" #include "gdt.h" @@ -215,6 +216,8 @@ void switch_ktss(pcb) pcb->ims.user_gdt, sizeof pcb->ims.user_gdt); #endif /* MACH_PV_DESCRIPTORS */ + db_load_context(pcb); + /* * Load the floating-point context, if necessary. */ @@ -621,6 +624,21 @@ kern_return_t thread_setstatus(thread, flavor, tstate, count) break; } + case i386_DEBUG_STATE: + { + register struct i386_debug_state *state; + kern_return_t ret; + + if (count < i386_DEBUG_STATE_COUNT) + return KERN_INVALID_ARGUMENT; + + state = (struct i386_debug_state *) tstate; + ret = db_set_debug_state(thread->pcb, state); + if (ret) + return ret; + break; + } + default: return(KERN_INVALID_ARGUMENT); } @@ -760,6 +778,20 @@ kern_return_t thread_getstatus(thread, flavor, tstate, count) break; } + case i386_DEBUG_STATE: + { + register struct i386_debug_state *state; + + if (*count < i386_DEBUG_STATE_COUNT) + return KERN_INVALID_ARGUMENT; + + state = (struct i386_debug_state *) tstate; + db_get_debug_state(thread->pcb, state); + + *count = i386_DEBUG_STATE_COUNT; + break; + } + default: return(KERN_INVALID_ARGUMENT); } diff --git a/i386/i386/proc_reg.h b/i386/i386/proc_reg.h index f1b2c89f..80835361 100644 --- a/i386/i386/proc_reg.h +++ b/i386/i386/proc_reg.h @@ -234,6 +234,132 @@ extern unsigned long cr3; asm("jmp 0f\n" \ "0:\n") +#ifdef MACH_RING1 +#define get_dr0() hyp_get_debugreg(0) +#else +#define get_dr0() \ + ({ \ + register unsigned long _temp__; \ + asm volatile("movl %%dr0, %0" : "=r" (_temp__)); \ + _temp__; \ + }) +#endif + +#ifdef MACH_RING1 +#define set_dr0(value) hyp_set_debugreg(0, value) +#else +#define set_dr0(value) \ + ({ \ + register unsigned long _temp__ = (value); \ + asm volatile("movl %0,%%dr0" : : "r" (_temp__)); \ + }) +#endif + +#ifdef MACH_RING1 +#define get_dr1() hyp_get_debugreg(1) +#else +#define get_dr1() \ + ({ \ + register unsigned long _temp__; \ + asm volatile("movl %%dr1, %0" : "=r" (_temp__)); \ + _temp__; \ + }) +#endif + +#ifdef MACH_RING1 +#define set_dr1(value) hyp_set_debugreg(1, value) +#else +#define set_dr1(value) \ + ({ \ + register unsigned long _temp__ = (value); \ + asm volatile("movl %0,%%dr1" : : "r" (_temp__)); \ + }) +#endif + +#ifdef MACH_RING1 +#define get_dr2() hyp_get_debugreg(2) +#else +#define get_dr2() \ + ({ \ + register unsigned long _temp__; \ + asm volatile("movl %%dr2, %0" : "=r" (_temp__)); \ + _temp__; \ + }) +#endif + +#ifdef MACH_RING1 +#define set_dr2(value) hyp_set_debugreg(2, value) +#else +#define set_dr2(value) \ + ({ \ + register unsigned long _temp__ = (value); \ + asm volatile("movl %0,%%dr2" : : "r" (_temp__)); \ + }) +#endif + +#ifdef MACH_RING1 +#define get_dr3() hyp_get_debugreg(3) +#else +#define get_dr3() \ + ({ \ + register unsigned long _temp__; \ + asm volatile("movl %%dr3, %0" : "=r" (_temp__)); \ + _temp__; \ + }) +#endif + +#ifdef MACH_RING1 +#define set_dr3(value) hyp_set_debugreg(3, value) +#else +#define set_dr3(value) \ + ({ \ + register unsigned long _temp__ = (value); \ + asm volatile("movl %0,%%dr3" : : "r" (_temp__)); \ + }) +#endif + +#ifdef MACH_RING1 +#define get_dr6() hyp_get_debugreg(6) +#else +#define get_dr6() \ + ({ \ + register unsigned long _temp__; \ + asm volatile("movl %%dr6, %0" : "=r" (_temp__)); \ + _temp__; \ + }) +#endif + +#ifdef MACH_RING1 +#define set_dr6(value) hyp_set_debugreg(6, value) +#else +#define set_dr6(value) \ + ({ \ + register unsigned long _temp__ = (value); \ + asm volatile("movl %0,%%dr6" : : "r" (_temp__)); \ + }) +#endif + +#ifdef MACH_RING1 +#define get_dr7() hyp_get_debugreg(7) +#else +#define get_dr7() \ + ({ \ + register unsigned long _temp__; \ + asm volatile("movl %%dr7, %0" : "=r" (_temp__)); \ + _temp__; \ + }) +#endif + +#ifdef MACH_RING1 +#define set_dr7(value) hyp_set_debugreg(7, value) +#else +#define set_dr7(value) \ + ({ \ + register unsigned long _temp__ = (value); \ + asm volatile("movl %0,%%dr7" : : "r" (_temp__)); \ + }) +#endif + #endif /* __GNUC__ */ #endif /* __ASSEMBLER__ */ diff --git a/i386/i386/thread.h b/i386/i386/thread.h index eddd25c2..450ec55f 100644 --- a/i386/i386/thread.h +++ b/i386/i386/thread.h @@ -36,6 +36,7 @@ #include #include #include +#include #include @@ -168,6 +169,7 @@ struct i386_machine_state { struct i386_fpsave_state *ifps; struct v86_assist_state v86s; struct real_descriptor user_gdt[USER_GDT_SLOTS]; + struct i386_debug_state ids; }; typedef struct pcb { diff --git a/i386/include/mach/i386/thread_status.h b/i386/include/mach/i386/thread_status.h index 5f20355e..ba1e3dea 100644 --- a/i386/include/mach/i386/thread_status.h +++ b/i386/include/mach/i386/thread_status.h @@ -56,6 +56,7 @@ #define i386_ISA_PORT_MAP_STATE 3 #define i386_V86_ASSIST_STATE 4 #define i386_REGS_SEGS_STATE 5 +#define i386_DEBUG_STATE 6 /* * This structure is used for both @@ -144,4 +145,10 @@ struct v86_interrupt_table { #define i386_V86_ASSIST_STATE_COUNT \ (sizeof(struct i386_v86_assist_state)/sizeof(unsigned int)) +struct i386_debug_state { + unsigned int dr[8]; +}; +#define i386_DEBUG_STATE_COUNT \ + (sizeof(struct i386_debug_state)/sizeof(unsigned int)) + #endif /* _MACH_I386_THREAD_STATUS_H_ */ -- cgit v1.2.3 From 43042e6f6cc483b22694619861eab183364f08f5 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Mon, 4 Feb 2013 11:37:51 +0100 Subject: Document dwatch * doc/mach.texi: Add dwatch documentation. --- doc/mach.texi | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/doc/mach.texi b/doc/mach.texi index e93fdb8b..8f45dfbc 100644 --- a/doc/mach.texi +++ b/doc/mach.texi @@ -7088,6 +7088,15 @@ rejected with an error message. Warning: Attempts to watch wired kernel memory may cause unrecoverable error in some systems such as i386. Watchpoints on user addresses work best. + +@item dwatch[/T] @var{addr} [ @var{task} ] +Clears a watchpoint previously set for a region. +Without @code{T} option, @var{addr} is assumed to be a kernel address. +If you want to clear a watch point in user space, specify @code{T} and +@var{task} parameter where the address belongs to. If the @var{task} +parameter is omitted, a task of the default target thread or a current +task is assumed. If you specify a wrong space address, the request is +rejected with an error message. @end table -- cgit v1.2.3 From 39376ba840a8682082eee9175b6951d4a7ae41f2 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Mon, 4 Feb 2013 11:43:17 +0100 Subject: Plug hw debug register support into kdb Make the `watch' command use hw debug registers whenever possible. * ddb/db_watch.c (db_set_hw_watchpoint, db_clear_hw_watchpoint): Add functions prototypes. (db_set_watchpoints): Try to call db_set_hw_watchpoint. (db_clear_watchpoints): Call db_clear_hw_watchpoint. * i386/i386/db_interface.c: Include (db_set_hw_watchpoint): Take a db_watchpoint_t WATCH parameter instead of its content. Remove support for clearing a debug register. (db_clear_hw_watchpoint): Add function. * i386/i386/db_interface.h: Include . (db_set_hw_watchpoint): Fix function prototype. (db_clear_hw_watchpoint): Add function prototype. * i386/i386/db_machdep.h: Do not include --- ddb/db_watch.c | 13 +++++++++++++ i386/i386/db_interface.c | 43 +++++++++++++++++++++++++++---------------- i386/i386/db_interface.h | 12 +++++++----- i386/i386/db_machdep.h | 1 - 4 files changed, 47 insertions(+), 22 deletions(-) diff --git a/ddb/db_watch.c b/ddb/db_watch.c index 072f474a..7eb99953 100644 --- a/ddb/db_watch.c +++ b/ddb/db_watch.c @@ -55,6 +55,9 @@ boolean_t db_watchpoints_inserted = TRUE; +extern boolean_t db_set_hw_watchpoint(db_watchpoint_t watch, unsigned hw_idx); +extern boolean_t db_clear_hw_watchpoint(unsigned hw_idx); + #define NWATCHPOINTS 100 struct db_watchpoint db_watch_table[NWATCHPOINTS]; db_watchpoint_t db_next_free_watchpoint = &db_watch_table[0]; @@ -264,9 +267,14 @@ db_set_watchpoints(void) { register db_watchpoint_t watch; vm_map_t map; + unsigned hw_idx = 0; if (!db_watchpoints_inserted) { for (watch = db_watchpoint_list; watch != 0; watch = watch->link) { + if (db_set_hw_watchpoint(watch, hw_idx)) { + hw_idx++; + continue; + } map = (watch->task)? watch->task->map: kernel_map; pmap_protect(map->pmap, trunc_page(watch->loaddr), @@ -280,6 +288,11 @@ db_set_watchpoints(void) void db_clear_watchpoints(void) { + unsigned hw_idx = 0; + + while (db_clear_hw_watchpoint(hw_idx)) + hw_idx++; + db_watchpoints_inserted = FALSE; } diff --git a/i386/i386/db_interface.c b/i386/i386/db_interface.c index c6d7fb41..90ca22dc 100644 --- a/i386/i386/db_interface.c +++ b/i386/i386/db_interface.c @@ -53,6 +53,7 @@ #include #include #include +#include #include #include @@ -167,29 +168,27 @@ void db_dr ( splx(s); } -void db_set_hw_watchpoint( - int num, - task_t task, - db_addr_t addr, - vm_size_t size) +boolean_t +db_set_hw_watchpoint( + db_watchpoint_t watch, + unsigned num) { + vm_size_t size = watch->hiaddr - watch->loaddr; + db_addr_t addr = watch->loaddr; unsigned int kern_addr; + if (num >= 4) + return FALSE; if (size != 1 && size != 2 && size != 4) - return; + return FALSE; if (addr & (size-1)) /* Unaligned */ - return; - - if (!addr) { - db_dr (num, 0, 0, 0, 0); - db_printf("Hardware watchpoint %d deleted\n", num); - } + return FALSE; - if (task) { - if (db_user_to_kernel_address(task, addr, &kern_addr, 1) < 0) - return; + if (watch->task) { + if (db_user_to_kernel_address(watch->task, addr, &kern_addr, 1) < 0) + return FALSE; addr = kern_addr; } addr = kvtolin(addr); @@ -197,6 +196,18 @@ void db_set_hw_watchpoint( db_dr (num, addr, I386_DB_TYPE_W, size-1, I386_DB_LOCAL|I386_DB_GLOBAL); db_printf("Hardware watchpoint %d set for %x\n", num, addr); + return TRUE; +} + +boolean_t +db_clear_hw_watchpoint( + unsigned num) +{ + if (num >= 4) + return FALSE; + + db_dr (num, 0, 0, 0, 0); + return TRUE; } /* @@ -577,7 +588,7 @@ db_check_access( register int size, task_t task) { - register n; + int n; vm_offset_t kern_addr; if (addr >= VM_MIN_KERNEL_ADDRESS) { diff --git a/i386/i386/db_interface.h b/i386/i386/db_interface.h index a8dfdce1..e1b2dff7 100644 --- a/i386/i386/db_interface.h +++ b/i386/i386/db_interface.h @@ -24,6 +24,7 @@ #include #include #include +#include extern boolean_t kdb_trap ( int type, @@ -73,11 +74,12 @@ extern void db_task_name (task_t task); #define I386_DB_LOCAL 1 #define I386_DB_GLOBAL 2 -extern void db_set_hw_watchpoint( - int num, - task_t task, - vm_offset_t addr, - vm_size_t size); +extern boolean_t db_set_hw_watchpoint( + db_watchpoint_t watch, + unsigned num); + +extern boolean_t db_clear_hw_watchpoint( + unsigned num); extern void db_dr ( int num, diff --git a/i386/i386/db_machdep.h b/i386/i386/db_machdep.h index 1dba2cd8..c6ea3ca9 100644 --- a/i386/i386/db_machdep.h +++ b/i386/i386/db_machdep.h @@ -34,7 +34,6 @@ #include #include #include -#include #include /* for thread_status */ #include -- cgit v1.2.3 From f34cc6d5a8bad7a6c34f30917c3f137c886d29bf Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Mon, 4 Feb 2013 11:56:51 +0100 Subject: Include machine/db_interface instead of hardcoding function prototypes * ddb/db_access.c: Include . (db_read_bytes, db_write_bytes): Remove functions prototypes. (db_get_task_value): Fix calling db_read_bytes. (db_put_task_value): Fix calling db_write_bytes. * ddb/db_watch.c: Include . (db_set_hw_watchpoint, db_clear_hw_watchpoint): Remove functions prototypes. --- ddb/db_access.c | 8 +++----- ddb/db_watch.c | 4 +--- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/ddb/db_access.c b/ddb/db_access.c index f06f9502..69922557 100644 --- a/ddb/db_access.c +++ b/ddb/db_access.c @@ -32,6 +32,7 @@ #include #include /* type definitions */ +#include /* function definitions */ #include #include #include @@ -43,9 +44,6 @@ * boundaries. */ -extern void db_read_bytes(); /* machine-dependent */ -extern void db_write_bytes(); /* machine-dependent */ - int db_access_level = DB_ACCESS_LEVEL; /* @@ -74,7 +72,7 @@ db_get_task_value(addr, size, is_signed, task) register db_expr_t value; register int i; - db_read_bytes((void*)addr, size, data, task); + db_read_bytes(addr, size, data, task); value = 0; #if BYTE_MSF @@ -113,7 +111,7 @@ db_put_task_value(addr, size, value, task) value >>= 8; } - db_write_bytes((void*)addr, size, data, task); + db_write_bytes(addr, size, data, task); } db_expr_t diff --git a/ddb/db_watch.c b/ddb/db_watch.c index 7eb99953..a2f852bd 100644 --- a/ddb/db_watch.c +++ b/ddb/db_watch.c @@ -37,6 +37,7 @@ #include #include +#include #include #include #include @@ -55,9 +56,6 @@ boolean_t db_watchpoints_inserted = TRUE; -extern boolean_t db_set_hw_watchpoint(db_watchpoint_t watch, unsigned hw_idx); -extern boolean_t db_clear_hw_watchpoint(unsigned hw_idx); - #define NWATCHPOINTS 100 struct db_watchpoint db_watch_table[NWATCHPOINTS]; db_watchpoint_t db_next_free_watchpoint = &db_watch_table[0]; -- cgit v1.2.3 From 6fe36b76f7983ec9a2e8a70420e431d54252442e Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Tue, 5 Mar 2013 00:47:33 +0100 Subject: Do not hardcode maximum priority value * kern/sched_prim.c (do_priority_computation): Replace 31 with NRQS - 1. idle_thread: Likewise. --- kern/sched_prim.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/kern/sched_prim.c b/kern/sched_prim.c index ba2dc8ab..46b5df43 100644 --- a/kern/sched_prim.c +++ b/kern/sched_prim.c @@ -1020,7 +1020,7 @@ shift_data_t wait_shift[32] = { (pri) = (th)->priority /* start with base priority */ \ + ((th)->sched_usage >> (PRI_SHIFT + SCHED_SHIFT)) \ + ((th)->sched_usage >> (PRI_SHIFT_2 + SCHED_SHIFT)); \ - if ((pri) > 31) (pri) = 31; \ + if ((pri) > NRQS - 1) (pri) = NRQS - 1; \ MACRO_END #else /* PRI_SHIFT_2 */ #define do_priority_computation(th, pri) \ @@ -1028,7 +1028,7 @@ shift_data_t wait_shift[32] = { (pri) = (th)->priority /* start with base priority */ \ + ((th)->sched_usage >> (PRI_SHIFT + SCHED_SHIFT)) \ - ((th)->sched_usage >> (SCHED_SHIFT - PRI_SHIFT_2)); \ - if ((pri) > 31) (pri) = 31; \ + if ((pri) > NRQS - 1) (pri) = NRQS - 1; \ MACRO_END #endif /* PRI_SHIFT_2 */ #else /* defined(PRI_SHIFT_2) */ @@ -1036,7 +1036,7 @@ shift_data_t wait_shift[32] = { MACRO_BEGIN \ (pri) = (th)->priority /* start with base priority */ \ + ((th)->sched_usage >> (PRI_SHIFT + SCHED_SHIFT)); \ - if ((pri) > 31) (pri) = 31; \ + if ((pri) > NRQS - 1) (pri) = NRQS - 1; \ MACRO_END #endif /* defined(PRI_SHIFT_2) */ @@ -1803,8 +1803,8 @@ void idle_thread(void) stack_privilege(self); s = splsched(); - self->priority = 31; - self->sched_pri = 31; + self->priority = NRQS-1; + self->sched_pri = NRQS-1; /* * Set the idle flag to indicate that this is an idle thread, -- cgit v1.2.3 From 6a234201081156e6d5742e7eeabb68418b518fad Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Wed, 6 Mar 2013 02:19:55 +0100 Subject: Increase number of priorities * kern/sched.h (NRQS): Increase to 50. --- kern/sched.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kern/sched.h b/kern/sched.h index 434e0228..ff3198dc 100644 --- a/kern/sched.h +++ b/kern/sched.h @@ -60,7 +60,7 @@ #include #endif /* STAT_TIME */ -#define NRQS 32 /* 32 run queues per cpu */ +#define NRQS 50 /* 50 run queues per cpu */ struct run_queue { queue_head_t runq[NRQS]; /* one for each priority */ -- cgit v1.2.3 From df49b22d24dc714b733e4df2e21a200cb134c74a Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Mon, 11 Mar 2013 03:18:59 +0100 Subject: Fix build without kdb * i386/i386/db_interface.h [! MACH_KBD] (db_set_hw_watchpoint, db_clear_hw_watchpoint, db_dr): Do not declare functions. --- i386/i386/db_interface.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/i386/i386/db_interface.h b/i386/i386/db_interface.h index e1b2dff7..3f6821da 100644 --- a/i386/i386/db_interface.h +++ b/i386/i386/db_interface.h @@ -74,6 +74,7 @@ extern void db_task_name (task_t task); #define I386_DB_LOCAL 1 #define I386_DB_GLOBAL 2 +#if MACH_KDB extern boolean_t db_set_hw_watchpoint( db_watchpoint_t watch, unsigned num); @@ -87,6 +88,7 @@ extern void db_dr ( int type, int len, int persistence); +#endif extern void db_get_debug_state( pcb_t pcb, -- cgit v1.2.3 From 727da7816336e95a1658d77d1da4c3974d4eb2b1 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Mon, 11 Mar 2013 19:16:38 +0100 Subject: Update BASEPRI_USER * kern/sched.h (BASEPRI_USER): Increase to 25. --- kern/sched.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kern/sched.h b/kern/sched.h index ff3198dc..942dd80f 100644 --- a/kern/sched.h +++ b/kern/sched.h @@ -118,7 +118,7 @@ extern int min_quantum; /* defines max context switch rate */ * Default base priorities for threads. */ #define BASEPRI_SYSTEM 6 -#define BASEPRI_USER 12 +#define BASEPRI_USER 25 /* * Macro to check for invalid priorities. -- cgit v1.2.3 From 8c8fa10a6146cf3cd0d473b38ced2fc99ad935fe Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Mon, 8 Apr 2013 21:55:07 +0200 Subject: Add -fno-optimize-sibling-calls option for better kdb traces * Makefrag.am (AM_CFLAGS) [enable_kdb]: Add -fno-optimize-sibling-calls option. --- Makefrag.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefrag.am b/Makefrag.am index c0cb8fe0..bb08972c 100644 --- a/Makefrag.am +++ b/Makefrag.am @@ -64,7 +64,7 @@ libkernel_a_SOURCES += \ ddb/tr.h # We need frame pointers for trace to work properly. -AM_CFLAGS += -fno-omit-frame-pointer +AM_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls endif -- cgit v1.2.3 From b54c7e38d8871a0c8b7694e7fd02062cf7ca988a Mon Sep 17 00:00:00 2001 From: Richard Braun Date: Sun, 21 Apr 2013 00:58:54 +0200 Subject: Fix locking error in the slab allocator * kern/slab.c (kmem_cache_free): Lock cache before releasing an object to the slab layer. --- kern/slab.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kern/slab.c b/kern/slab.c index 99d5bca3..3db4db11 100644 --- a/kern/slab.c +++ b/kern/slab.c @@ -1305,7 +1305,9 @@ fast_free: slab_free: #endif /* SLAB_USE_CPU_POOLS */ + simple_lock(&cache->lock); kmem_cache_free_to_slab(cache, (void *)obj); + simple_unlock(&cache->lock); } void slab_collect(void) -- cgit v1.2.3 From 24832de763ad58be6afdcff6c761b54ccee42667 Mon Sep 17 00:00:00 2001 From: Richard Braun Date: Sun, 21 Apr 2013 01:30:27 +0200 Subject: Rework slab lists handling Don't enforce strong ordering of partial slabs. Separating partial slabs from free slabs is already effective against fragmentation, and sorting would sometimes cause pathological scalability issues. In addition, store new slabs (whether free or partial) in LIFO order for better cache usage. * kern/slab.c (kmem_cache_grow): Insert new slab at the head of the slabs list. (kmem_cache_alloc_from_slab): Likewise. In addition, don't sort partial slabs. (kmem_cache_free_to_slab): Likewise. * kern/slab.h: Remove comment about partial slabs sorting. --- kern/slab.c | 82 ++++++------------------------------------------------------- kern/slab.h | 7 ------ 2 files changed, 8 insertions(+), 81 deletions(-) diff --git a/kern/slab.c b/kern/slab.c index 3db4db11..cff80965 100644 --- a/kern/slab.c +++ b/kern/slab.c @@ -878,7 +878,7 @@ static int kmem_cache_grow(struct kmem_cache *cache) simple_lock(&cache->lock); if (slab != NULL) { - list_insert_tail(&cache->free_slabs, &slab->list_node); + list_insert(&cache->free_slabs, &slab->list_node); cache->nr_bufs += cache->bufs_per_slab; cache->nr_slabs++; cache->nr_free_slabs++; @@ -951,49 +951,17 @@ static void * kmem_cache_alloc_from_slab(struct kmem_cache *cache) slab->nr_refs++; cache->nr_objs++; - /* - * The slab has become complete. - */ if (slab->nr_refs == cache->bufs_per_slab) { + /* The slab has become complete */ list_remove(&slab->list_node); if (slab->nr_refs == 1) cache->nr_free_slabs--; } else if (slab->nr_refs == 1) { - /* - * The slab has become partial. - */ + /* The slab has become partial */ list_remove(&slab->list_node); - list_insert_tail(&cache->partial_slabs, &slab->list_node); + list_insert(&cache->partial_slabs, &slab->list_node); cache->nr_free_slabs--; - } else if (!list_singular(&cache->partial_slabs)) { - struct list *node; - struct kmem_slab *tmp; - - /* - * The slab remains partial. If there are more than one partial slabs, - * maintain the list sorted. - */ - - assert(slab->nr_refs > 1); - - for (node = list_prev(&slab->list_node); - !list_end(&cache->partial_slabs, node); - node = list_prev(node)) { - tmp = list_entry(node, struct kmem_slab, list_node); - - if (tmp->nr_refs >= slab->nr_refs) - break; - } - - /* - * If the direct neighbor was found, the list is already sorted. - * If no slab was found, the slab is inserted at the head of the list. - */ - if (node != list_prev(&slab->list_node)) { - list_remove(&slab->list_node); - list_insert_after(node, &slab->list_node); - } } if ((slab->nr_refs == 1) && kmem_slab_use_tree(cache->flags)) @@ -1036,54 +1004,20 @@ static void kmem_cache_free_to_slab(struct kmem_cache *cache, void *buf) slab->nr_refs--; cache->nr_objs--; - /* - * The slab has become free. - */ if (slab->nr_refs == 0) { + /* The slab has become free */ + if (kmem_slab_use_tree(cache->flags)) rbtree_remove(&cache->active_slabs, &slab->tree_node); - /* - * The slab was partial. - */ if (cache->bufs_per_slab > 1) list_remove(&slab->list_node); - list_insert_tail(&cache->free_slabs, &slab->list_node); + list_insert(&cache->free_slabs, &slab->list_node); cache->nr_free_slabs++; } else if (slab->nr_refs == (cache->bufs_per_slab - 1)) { - /* - * The slab has become partial. - */ + /* The slab has become partial */ list_insert(&cache->partial_slabs, &slab->list_node); - } else if (!list_singular(&cache->partial_slabs)) { - struct list *node; - struct kmem_slab *tmp; - - /* - * The slab remains partial. If there are more than one partial slabs, - * maintain the list sorted. - */ - - assert(slab->nr_refs > 0); - - for (node = list_next(&slab->list_node); - !list_end(&cache->partial_slabs, node); - node = list_next(node)) { - tmp = list_entry(node, struct kmem_slab, list_node); - - if (tmp->nr_refs <= slab->nr_refs) - break; - } - - /* - * If the direct neighbor was found, the list is already sorted. - * If no slab was found, the slab is inserted at the tail of the list. - */ - if (node != list_next(&slab->list_node)) { - list_remove(&slab->list_node); - list_insert_before(node, &slab->list_node); - } } } diff --git a/kern/slab.h b/kern/slab.h index 47bef218..b842fb74 100644 --- a/kern/slab.h +++ b/kern/slab.h @@ -155,13 +155,6 @@ typedef void (*kmem_slab_free_fn_t)(vm_offset_t, vm_size_t); * Cache of objects. * * Locking order : cpu_pool -> cache. CPU pools locking is ordered by CPU ID. - * - * The partial slabs list is sorted by slab references. Slabs with a high - * number of references are placed first on the list to reduce fragmentation. - * Sorting occurs at insertion/removal of buffers in a slab. As the list - * is maintained sorted, and the number of references only changes by one, - * this is a very cheap operation in the average case and the worst (linear) - * case is very unlikely. */ struct kmem_cache { #if SLAB_USE_CPU_POOLS -- cgit v1.2.3 From 1af3af1431037f87d29434a46b91e1a059f785c2 Mon Sep 17 00:00:00 2001 From: Richard Braun Date: Sun, 21 Apr 2013 21:17:53 +0200 Subject: Optimize slab reaping Instead of walking the list of free slabs while holding the cache lock, detach the list from the cache and directly compute the final count values, and destroy slabs after releasing the cache lock. * kern/slab.c (kmem_cache_reap): Optimize. --- kern/slab.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/kern/slab.c b/kern/slab.c index cff80965..0f0d4cbe 100644 --- a/kern/slab.c +++ b/kern/slab.c @@ -899,31 +899,28 @@ static void kmem_cache_reap(struct kmem_cache *cache) { struct kmem_slab *slab; struct list dead_slabs; + unsigned long nr_free_slabs; if (cache->flags & KMEM_CF_NO_RECLAIM) return; - list_init(&dead_slabs); - simple_lock(&cache->lock); - - while (!list_empty(&cache->free_slabs)) { - slab = list_first_entry(&cache->free_slabs, struct kmem_slab, - list_node); - list_remove(&slab->list_node); - list_insert(&dead_slabs, &slab->list_node); - cache->nr_bufs -= cache->bufs_per_slab; - cache->nr_slabs--; - cache->nr_free_slabs--; - } - + list_set_head(&dead_slabs, &cache->free_slabs); + list_init(&cache->free_slabs); + nr_free_slabs = cache->nr_free_slabs; + cache->nr_bufs -= cache->bufs_per_slab * nr_free_slabs; + cache->nr_slabs -= nr_free_slabs; + cache->nr_free_slabs = 0; simple_unlock(&cache->lock); while (!list_empty(&dead_slabs)) { slab = list_first_entry(&dead_slabs, struct kmem_slab, list_node); list_remove(&slab->list_node); kmem_slab_destroy(slab, cache); + nr_free_slabs--; } + + assert(nr_free_slabs == 0); } /* -- cgit v1.2.3 From 342cfcb319cad816da5472c8fe5ca82372965088 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Wed, 1 May 2013 23:35:19 +0200 Subject: Fix macro name * linux/dev/glue/block.c (device_get_status): Use DEV_GET_RECORDS_RECORD_SIZE for DEV_GET_RECORDS instead of DEV_GET_SIZE_RECORD_SIZE. --- linux/dev/glue/block.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux/dev/glue/block.c b/linux/dev/glue/block.c index 8c41f088..745e93aa 100644 --- a/linux/dev/glue/block.c +++ b/linux/dev/glue/block.c @@ -1650,7 +1650,7 @@ device_get_status (void *d, dev_flavor_t flavor, dev_status_t status, /* It would be nice to return the block size as reported by the driver, but a lot of user level code assumes the sector size to be 512. */ - status[DEV_GET_SIZE_RECORD_SIZE] = 512; + status[DEV_GET_RECORDS_RECORD_SIZE] = 512; /* Always return DEV_GET_RECORDS_COUNT. This is what all native Mach drivers do, and makes it possible to detect the absence of the call by setting it to a different value on input. MiG -- cgit v1.2.3 From a750e58b21c05cffd81f460a72ed4dd6d27ee5ec Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Thu, 2 May 2013 01:11:31 +0200 Subject: Fix non-block-aligned-offset reads This fixes grave issues when device_read is called with non-block-aligned offset, e.g. when using grub-probe with a non-block-aligned partition table. * linux/dev/glue/block.c (rdwr_full): Use current position instead of base buffer position to check for alignment. --- linux/dev/glue/block.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/linux/dev/glue/block.c b/linux/dev/glue/block.c index 745e93aa..011b6f56 100644 --- a/linux/dev/glue/block.c +++ b/linux/dev/glue/block.c @@ -589,8 +589,8 @@ rdwr_full (int rw, kdev_t dev, loff_t *off, char **buf, int *resid, int bshift) set_bit (BH_Lock, &bh->b_state); if (rw == WRITE) set_bit (BH_Dirty, &bh->b_state); - cc = PAGE_SIZE - (((int) *buf) & PAGE_MASK); - if (cc >= BSIZE && ((int) *buf & 511) == 0) + cc = PAGE_SIZE - (((int) *buf + (nb << bshift)) & PAGE_MASK); + if (cc >= BSIZE && (((int) *buf + (nb << bshift)) & 511) == 0) cc &= ~BMASK; else { -- cgit v1.2.3 From 75c1b0d1133a7ae6a7eb45818470f453700df1a2 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Fri, 10 May 2013 18:56:26 +0200 Subject: Add AHCI driver * linux/dev/glue/kmem.c (vmtophys): New function. * linux/dev/include/linux/mm.h (vmtophys): New prototype. * linux/src/include/linux/pci.h (PCI_CLASS_STORAGE_SATA, PCI_CLASS_STORAGE_SATA_AHCI): New macros. * linux/dev/drivers/block/ahci.c: New file. * linux/dev/include/ahci.h: New file. * linux/Makefrag.am (liblinux_a_SOURCES): Add linux/dev/drivers/block/ahci.c and linux/dev/drivers/block/ahci.h. * linux/src/drivers/block/ide.c: Include . (probe_for_hwifs): Call ahci_probe_pci. --- linux/Makefrag.am | 2 + linux/dev/drivers/block/ahci.c | 854 +++++++++++++++++++++++++++++++++++++++++ linux/dev/glue/kmem.c | 6 + linux/dev/include/ahci.h | 268 +++++++++++++ linux/dev/include/linux/mm.h | 1 + linux/src/drivers/block/ide.c | 3 + linux/src/include/linux/pci.h | 2 + 7 files changed, 1136 insertions(+) create mode 100644 linux/dev/drivers/block/ahci.c create mode 100644 linux/dev/include/ahci.h diff --git a/linux/Makefrag.am b/linux/Makefrag.am index 7c7b432d..2775aa8b 100644 --- a/linux/Makefrag.am +++ b/linux/Makefrag.am @@ -78,6 +78,8 @@ liblinux_a_SOURCES += \ linux/src/drivers/block/ide-cd.c \ linux/src/drivers/block/ide.c \ linux/src/drivers/block/ide.h \ + linux/dev/drivers/block/ahci.c \ + linux/dev/drivers/block/ahci.h \ linux/src/drivers/block/ide_modes.h \ linux/src/drivers/block/rz1000.c \ linux/src/drivers/block/triton.c diff --git a/linux/dev/drivers/block/ahci.c b/linux/dev/drivers/block/ahci.c new file mode 100644 index 00000000..82dea8d2 --- /dev/null +++ b/linux/dev/drivers/block/ahci.c @@ -0,0 +1,854 @@ +/* + * Copyright (C) 2013 Free Software Foundation + * + * This program is free software ; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation ; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY ; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with the program ; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define MAJOR_NR SCSI_DISK_MAJOR +#include + +/* Standard AHCI BAR for mmio */ +#define AHCI_PCI_BAR 5 + +/* minor: 2 bits for device number, 6 bits for partition number. */ + +#define MAX_PORTS 4 +#define PARTN_BITS 6 +#define PARTN_MASK ((1<errors = 0; + if (!uptodate) { + printk("end_request: I/O error, dev %s, sector %lu\n", + kdevname(rq->rq_dev), rq->sector); + assert(0); + } + + for (bh = rq->bh; bh; ) + { + struct buffer_head *next = bh->b_reqnext; + bh->b_reqnext = NULL; + mark_buffer_uptodate (bh, uptodate); + unlock_buffer (bh); + bh = next; + } + + CURRENT = rq->next; + if (rq->sem != NULL) + up(rq->sem); + rq->rq_status = RQ_INACTIVE; + wake_up(&wait_for_request); +} + +/* Push the request to the controler port */ +static void ahci_do_port_request(struct port *port, unsigned sector, struct request *rq) +{ + struct ahci_command *command = port->command; + struct ahci_cmd_tbl *prdtl = port->prdtl; + struct ahci_fis_h2d *fis_h2d; + unsigned slot = 0; + struct buffer_head *bh; + unsigned i; + + rq->rq_status = RQ_SCSI_BUSY; + + /* Shouldn't ever happen: the block glue is limited at 8 blocks */ + assert(rq->nr_sectors < 0x10000); + + fis_h2d = (void*) &prdtl[slot].cfis; + fis_h2d->fis_type = FIS_TYPE_REG_H2D; + fis_h2d->flags = 128; + if (rq->cmd == READ) + fis_h2d->command = WIN_READDMA; + else + fis_h2d->command = WIN_WRITEDMA; + + fis_h2d->device = 1<<6; /* LBA */ + + fis_h2d->lba0 = sector; + fis_h2d->lba1 = sector >> 8; + fis_h2d->lba2 = sector >> 16; + + fis_h2d->lba3 = sector >> 24; + fis_h2d->lba4 = 0; + fis_h2d->lba5 = 0; + + fis_h2d->countl = rq->nr_sectors; + fis_h2d->counth = rq->nr_sectors >> 8; + + command[slot].opts = sizeof(*fis_h2d) / sizeof(u32); + + if (rq->cmd == WRITE) + command[slot].opts |= AHCI_CMD_WRITE; + + for (i = 0, bh = rq->bh; bh; i++, bh = bh->b_reqnext) + { + assert(i < PRDTL_SIZE); + assert((((unsigned long) bh->b_data) & ~PAGE_MASK) == + (((unsigned long) bh->b_data + bh->b_size - 1) & ~PAGE_MASK)); + prdtl[slot].prdtl[i].dbau = 0; + prdtl[slot].prdtl[i].dba = vmtophys(bh->b_data); + prdtl[slot].prdtl[i].dbc = bh->b_size - 1; + } + + command[slot].opts |= i << 16; + + /* Make sure main memory buffers are up to date */ + mb(); + + /* Issue command */ + writel(1 << slot, &port->ahci_port->ci); + + /* TODO: IRQ timeout handler */ +} + +/* Called by block core to push a request */ +/* TODO: ideally, would have one request queue per port */ +/* TODO: ideally, would use tags to process several requests at a time */ +static void ahci_do_request() /* invoked with cli() */ +{ + struct request *rq; + unsigned minor, unit; + unsigned long block, blockend; + struct port *port; + + rq = CURRENT; + if (!rq) + return; + + if (rq->rq_status != RQ_ACTIVE) + /* Current one is already ongoing, let the interrupt handler + * push the new one when the current one is finished. */ + return; + + if (MAJOR(rq->rq_dev) != MAJOR_NR) { + printk("bad ahci major %u\n", MAJOR(rq->rq_dev)); + goto kill_rq; + } + + minor = MINOR(rq->rq_dev); + unit = minor >> PARTN_BITS; + if (unit > MAX_PORTS) { + printk("bad ahci unit %u\n", unit); + goto kill_rq; + } + + port = &ports[unit]; + + /* Compute start sector */ + block = rq->sector; + block += port->part[minor & PARTN_MASK].start_sect; + + /* And check end */ + blockend = block + rq->nr_sectors; + if (blockend < block) { + printk("bad blockend %lu vs %lu\n", blockend, block); + goto kill_rq; + } + if (blockend > port->capacity) { + printk("offset for %u was %lu\n", minor, port->part[minor & PARTN_MASK].start_sect); + printk("bad access: block %lu, count= %u\n", blockend, port->capacity); + goto kill_rq; + } + + /* Push this to the port */ + ahci_do_port_request(port, block, rq); + return; + +kill_rq: + ahci_end_request(0); +} + +/* The given port got an interrupt, terminate the current request if any */ +static void ahci_port_interrupt(struct port *port, u32 status) +{ + unsigned slot = 0; + + if (readl(&port->ahci_port->ci) & (1 << slot)) { + /* Command still pending */ + return; + } + + if (port->identify) { + port->status = status; + wake_up(&port->q); + return; + } + + if (!CURRENT || CURRENT->rq_status != RQ_SCSI_BUSY) { + /* No request currently running */ + return; + } + + if (status & (PORT_IRQ_TF_ERR | PORT_IRQ_HBUS_ERR | PORT_IRQ_HBUS_DATA_ERR | PORT_IRQ_IF_ERR | PORT_IRQ_IF_NONFATAL)) { + printk("ahci error %x %x\n", status, readl(&port->ahci_port->tfd)); + ahci_end_request(0); + return; + } + + ahci_end_request(1); +} + +/* Start of IRQ handler. Iterate over all ports for this host */ +static void ahci_interrupt (int irq, void *host, struct pt_regs *regs) +{ + struct port *port; + struct ahci_host *ahci_host = host; + u32 irq_mask; + u32 status; + + irq_mask = readl(&ahci_host->is); + + if (!irq_mask) + return; + + for (port = &ports[0]; port < &ports[MAX_PORTS]; port++) { + if (port->ahci_host == ahci_host && (irq_mask & (1 << (port->ahci_port - ahci_host->ports)))) { + status = readl(&port->ahci_port->is); + /* Clear interrupt before possibly triggering others */ + writel(status, &port->ahci_port->is); + ahci_port_interrupt (port, status); + } + } + + if (CURRENT) + /* Still some requests, queue another one */ + ahci_do_request(); + + /* Clear host after clearing ports */ + writel(irq_mask, &ahci_host->is); + + /* unlock */ +} + +static int ahci_open (struct inode *inode, struct file *file) +{ + int target; + + if (MAJOR(inode->i_rdev) != MAJOR_NR) + return -ENXIO; + + target = MINOR(inode->i_rdev) >> PARTN_BITS; + if (target >= MAX_PORTS) + return -ENXIO; + + if (!ports[target].ahci_port) + return -ENXIO; + + return 0; +} + +static void ahci_release (struct inode *inode, struct file *file) +{ +} + +static int ahci_fsync (struct inode *inode, struct file *file) +{ + printk("fsync\n"); + return -ENOSYS; +} + +static struct file_operations ahci_fops = { + .lseek = NULL, + .read = block_read, + .write = block_write, + .readdir = NULL, + .select = NULL, + .ioctl = NULL, + .mmap = NULL, + .open = ahci_open, + .release = ahci_release, + .fsync = ahci_fsync, + .fasync = NULL, + .check_media_change = NULL, + .revalidate = NULL, +}; + + +/* Probe one AHCI port */ +static void ahci_probe_port(const volatile struct ahci_host *ahci_host, const volatile struct ahci_port *ahci_port) +{ + struct port *port; + void *mem; + struct hd_driveid id; + unsigned cls = ((readl(&ahci_host->cap) >> 8) & 0x1f) + 1; + struct ahci_command *command; + struct ahci_fis *fis; + struct ahci_cmd_tbl *prdtl; + struct ahci_fis_h2d *fis_h2d; + vm_size_t size = + cls * sizeof(*command) + + sizeof(*fis) + + cls * sizeof(*prdtl); + unsigned i; + unsigned slot; + unsigned long first_part; + unsigned long long timeout; + unsigned long flags; + + for (i = 0; i < MAX_PORTS; i++) { + if (!ports[i].ahci_port) + break; + } + if (i == MAX_PORTS) + return; + port = &ports[i]; + + /* Has to be 1K-aligned */ + mem = vmalloc (size); + if (!mem) + return; + assert (!(((unsigned long) mem) & (1024-1))); + memset (mem, 0, size); + + port->ahci_host = ahci_host; + port->ahci_port = ahci_port; + port->cls = cls; + + port->command = command = mem; + port->fis = fis = (void*) command + cls * sizeof(*command); + port->prdtl = prdtl = (void*) fis + sizeof(*fis); + + /* Stop commands */ + writel(readl(&ahci_port->cmd) & ~PORT_CMD_START, &ahci_port->cmd); + timeout = jiffies + WAIT_MAX; + while (readl(&ahci_port->cmd) & PORT_CMD_LIST_ON) + if (jiffies > timeout) { + printk("sd%u: timeout waiting for list completion\n", port-ports); + port->ahci_host = NULL; + port->ahci_port = NULL; + return; + } + + writel(readl(&ahci_port->cmd) & ~PORT_CMD_FIS_RX, &ahci_port->cmd); + timeout = jiffies + WAIT_MAX; + while (readl(&ahci_port->cmd) & PORT_CMD_FIS_ON) + if (jiffies > timeout) { + printk("sd%u: timeout waiting for FIS completion\n", port-ports); + port->ahci_host = NULL; + port->ahci_port = NULL; + return; + } + + /* We don't support 64bit */ + /* Point controller to our buffers */ + writel(0, &ahci_port->clbu); + writel(vmtophys((void*) command), &ahci_port->clb); + writel(0, &ahci_port->fbu); + writel(vmtophys((void*) fis), &ahci_port->fb); + + /* Clear any previous interrupts */ + writel(readl(&ahci_port->is), &ahci_port->is); + writel(1 << (ahci_port - ahci_host->ports), &ahci_host->is); + + /* And activate them */ + writel(DEF_PORT_IRQ, &ahci_port->ie); + writel(readl(&ahci_host->ghc) | HOST_IRQ_EN, &ahci_host->ghc); + + for (i = 0; i < cls; i++) + { + command[i].ctbau = 0; + command[i].ctba = vmtophys((void*) &prdtl[i]); + } + + /* Start commands */ + timeout = jiffies + WAIT_MAX; + while (readl(&ahci_port->cmd) & PORT_CMD_LIST_ON) + if (jiffies > timeout) { + printk("sd%u: timeout waiting for list completion\n", port-ports); + port->ahci_host = NULL; + port->ahci_port = NULL; + return; + } + + writel(readl(&ahci_port->cmd) | PORT_CMD_FIS_RX | PORT_CMD_START, &ahci_port->cmd); + + /* Identify device */ + /* TODO: make this a request */ + slot = 0; + + fis_h2d = (void*) &prdtl[slot].cfis; + fis_h2d->fis_type = FIS_TYPE_REG_H2D; + fis_h2d->flags = 128; + fis_h2d->command = WIN_IDENTIFY; + fis_h2d->device = 0; + + /* Fetch the 512 identify data */ + memset(&id, 0, sizeof(id)); + + command[slot].opts = sizeof(*fis_h2d) / sizeof(u32); + + first_part = PAGE_ALIGN((unsigned long) &id) - (unsigned long) &id; + + if (first_part && first_part < sizeof(id)) { + /* split over two pages */ + + command[slot].opts |= (2 << 16); + + prdtl[slot].prdtl[0].dbau = 0; + prdtl[slot].prdtl[0].dba = vmtophys((void*) &id); + prdtl[slot].prdtl[0].dbc = first_part - 1; + prdtl[slot].prdtl[1].dbau = 0; + prdtl[slot].prdtl[1].dba = vmtophys((void*) &id + first_part); + prdtl[slot].prdtl[1].dbc = sizeof(id) - first_part - 1; + } + else + { + command[slot].opts |= (1 << 16); + + prdtl[slot].prdtl[0].dbau = 0; + prdtl[slot].prdtl[0].dba = vmtophys((void*) &id); + prdtl[slot].prdtl[0].dbc = sizeof(id) - 1; + } + + timeout = jiffies + WAIT_MAX; + while (readl(&ahci_port->tfd) & (BUSY_STAT | DRQ_STAT)) + if (jiffies > timeout) { + printk("sd%u: timeout waiting for ready\n", port-ports); + port->ahci_host = NULL; + port->ahci_port = NULL; + return; + } + + save_flags(flags); + cli(); + + port->identify = 1; + port->status = 0; + + /* Issue command */ + mb(); + writel(1 << slot, &ahci_port->ci); + + timeout = jiffies + WAIT_MAX; + while (!port->status) { + if (jiffies > timeout) { + printk("sd%u: timeout waiting for ready\n", port-ports); + port->ahci_host = NULL; + port->ahci_port = NULL; + return; + } + sleep_on(&port->q); + } + restore_flags(flags); + + if (readl(&ahci_port->is) & PORT_IRQ_TF_ERR) + { + printk("sd%u: identify error\n", port-ports); + port->capacity = 0; + } else { + ide_fixstring(id.model, sizeof(id.model), 1); + ide_fixstring(id.fw_rev, sizeof(id.fw_rev), 1); + ide_fixstring(id.serial_no, sizeof(id.serial_no), 1); + port->capacity = id.lba_capacity; + printk("sd%u: %s, %uMB w/%dkB Cache\n", port - ports, id.model, port->capacity/2048, id.buf_size/2); + } + port->identify = 0; +} + +/* Probe one AHCI PCI device */ +static void ahci_probe_dev(unsigned char bus, unsigned char device) +{ + unsigned char hdrtype; + unsigned char dev, fun; + const volatile struct ahci_host *ahci_host; + const volatile struct ahci_port *ahci_port; + unsigned nports, n, i; + unsigned port_map; + unsigned bar; + unsigned char irq; + + /* Get configuration */ + if (pcibios_read_config_byte(bus, device, PCI_HEADER_TYPE, &hdrtype) != PCIBIOS_SUCCESSFUL) { + printk("ahci: %02u:%02u.%u: Can not read configuration", bus, dev, fun); + return; + } + + if (hdrtype != 0) { + printk("ahci: %02u:%02u.%u: Unknown hdrtype %d\n", bus, dev, fun, hdrtype); + return; + } + + if (pcibios_read_config_dword(bus, device, PCI_BASE_ADDRESS_5, &bar) != PCIBIOS_SUCCESSFUL) { + printk("ahci: %02u:%02u.%u: Can not read BAR 5", bus, dev, fun); + return; + } + if (bar & 0x01) { + printk("ahci: %02u:%02u.%u: BAR 5 is I/O?!", bus, dev, fun); + return; + } + bar &= ~0x0f; + + if (pcibios_read_config_byte(bus, device, PCI_INTERRUPT_LINE, &irq) != PCIBIOS_SUCCESSFUL) { + printk("ahci: %02u:%02u.%u: Can not read IRQ", bus, dev, fun); + return; + } + + dev = PCI_SLOT(device); + fun = PCI_FUNC(device); + printk("AHCI SATA %02u:%02u.%u BAR 0x%x IRQ %u\n", bus, dev, fun, bar, irq); + + /* Map mmio */ + ahci_host = vremap(bar, 0x2000); + if (!(readl(&ahci_host->cap) & HOST_CAP_ONLY)) { + printk("ahci: %02u:%02u.%u: available as IDE too, skipping it\n"); + return; + } + + /* Request IRQ */ + if (request_irq(irq, &ahci_interrupt, SA_SHIRQ, "ahci", (void*) ahci_host)) { + printk("ahci: %02u:%02u.%u: Can not get irq %u\n", bus, dev, fun, irq); + return; + } + + nports = (readl(&ahci_host->cap) & 0x1f) + 1; + port_map = readl(&ahci_host->pi); + + for (n = 0, i = 0; i < AHCI_MAX_PORTS; i++) + if (port_map & (1U << i)) + n++; + + if (nports != n) { + printk("ahci: %02u:%02u.%u: Odd number of ports, assuming %d is correct\n", bus, dev, fun, nports); + port_map = 0; + } + if (!port_map) { + port_map = (1U << nports) - 1; + } + + for (i = 0; i < AHCI_MAX_PORTS; i++) { + u32 ssts; + + if (!(port_map & (1U << i))) + continue; + + ahci_port = &ahci_host->ports[i]; + + ssts = readl(&ahci_port->ssts); + if ((ssts & 0xf) != 0x3) + /* Device not present */ + continue; + if (((ssts >> 8) & 0xf) != 0x1) + /* Device down */ + continue; + + /* OK! Probe this port */ + ahci_probe_port(ahci_host, ahci_port); + } +} + +/* genhd callback to set size of disks */ +static void ahci_geninit(struct gendisk *gd) +{ + unsigned unit; + struct port *port; + + for (unit = 0; unit < gd->nr_real; unit++) { + port = &ports[unit]; + port->part[0].nr_sects = port->capacity; + } +} + +/* Probe all AHCI PCI devices */ +void ahci_probe_pci(void) +{ + unsigned char bus, device; + unsigned short index; + int ret; + unsigned nports, unit, nminors; + struct port *port; + struct gendisk *gd, **gdp; + int *bs; + + for (index = 0; + (ret = pcibios_find_class(PCI_CLASS_STORAGE_SATA_AHCI, index, &bus, &device)) == PCIBIOS_SUCCESSFUL; + index++) + { + /* Note: this prevents from also having a SCSI controler. + * It shouldn't harm too much until we have proper hardware + * enumeration. + */ + if (register_blkdev(MAJOR_NR, "sd", &ahci_fops) < 0) + printk("could not register ahci\n"); + ahci_probe_dev(bus, device); + } + + for (nports = 0, port = &ports[0]; port < &ports[MAX_PORTS]; port++) + if (port->ahci_port) + nports++; + + nminors = nports * (1<sizes = kmalloc(nminors * sizeof(*gd->sizes), GFP_KERNEL); + gd->part = kmalloc(nminors * sizeof(*gd->part), GFP_KERNEL); + bs = kmalloc(nminors * sizeof(*bs), GFP_KERNEL); + + blksize_size[MAJOR_NR] = bs; + for (unit = 0; unit < nminors; unit++) + /* We prefer to transfer whole pages */ + *bs++ = PAGE_SIZE; + + memset(gd->part, 0, nminors * sizeof(*gd->part)); + + for (unit = 0; unit < nports; unit++) + ports[unit].part = &gd->part[unit << PARTN_BITS]; + + gd->major = MAJOR_NR; + gd->major_name = "sd"; + gd->minor_shift = PARTN_BITS; + gd->max_p = 1<max_nr = nports; + gd->nr_real = nports; + gd->init = ahci_geninit; + gd->next = NULL; + + for (gdp = &gendisk_head; *gdp; gdp = &((*gdp)->next)) + ; + *gdp = gd; + + blk_dev[MAJOR_NR].request_fn = ahci_do_request; +} diff --git a/linux/dev/glue/kmem.c b/linux/dev/glue/kmem.c index 28321711..ff052ffc 100644 --- a/linux/dev/glue/kmem.c +++ b/linux/dev/glue/kmem.c @@ -560,6 +560,12 @@ vfree (void *addr) vmalloc_list_remove (p); } +unsigned long +vmtophys (void *addr) +{ + return kvtophys((vm_offset_t) addr); +} + /* XXX: Quick hacking. */ /* Remap physical address into virtual address. */ void * diff --git a/linux/dev/include/ahci.h b/linux/dev/include/ahci.h new file mode 100644 index 00000000..31977b63 --- /dev/null +++ b/linux/dev/include/ahci.h @@ -0,0 +1,268 @@ +#ifndef _GNUMACH_AHCI_H +#define _GNUMACH_AHCI_H +extern void ahci_probe_pci(void); + +/* From linux 3.9's drivers/ata/ahci.h */ + +/* + * ahci.h - Common AHCI SATA definitions and declarations + * + * Maintained by: Jeff Garzik + * Please ALWAYS copy linux-ide@vger.kernel.org + * on emails. + * + * Copyright 2004-2005 Red Hat, Inc. + * + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * + * + * libata documentation is available via 'make {ps|pdf}docs', + * as Documentation/DocBook/libata.* + * + * AHCI hardware documentation: + * http://www.intel.com/technology/serialata/pdf/rev1_0.pdf + * http://www.intel.com/technology/serialata/pdf/rev1_1.pdf + * + */ + +enum { + AHCI_MAX_PORTS = 32, + AHCI_MAX_SG = 168, /* hardware max is 64K */ + AHCI_DMA_BOUNDARY = 0xffffffff, + AHCI_MAX_CMDS = 32, + AHCI_CMD_SZ = 32, + AHCI_CMD_SLOT_SZ = AHCI_MAX_CMDS * AHCI_CMD_SZ, + AHCI_RX_FIS_SZ = 256, + AHCI_CMD_TBL_CDB = 0x40, + AHCI_CMD_TBL_HDR_SZ = 0x80, + AHCI_CMD_TBL_SZ = AHCI_CMD_TBL_HDR_SZ + (AHCI_MAX_SG * 16), + AHCI_CMD_TBL_AR_SZ = AHCI_CMD_TBL_SZ * AHCI_MAX_CMDS, + AHCI_PORT_PRIV_DMA_SZ = AHCI_CMD_SLOT_SZ + AHCI_CMD_TBL_AR_SZ + + AHCI_RX_FIS_SZ, + AHCI_PORT_PRIV_FBS_DMA_SZ = AHCI_CMD_SLOT_SZ + + AHCI_CMD_TBL_AR_SZ + + (AHCI_RX_FIS_SZ * 16), + AHCI_IRQ_ON_SG = (1 << 31), + AHCI_CMD_ATAPI = (1 << 5), + AHCI_CMD_WRITE = (1 << 6), + AHCI_CMD_PREFETCH = (1 << 7), + AHCI_CMD_RESET = (1 << 8), + AHCI_CMD_CLR_BUSY = (1 << 10), + + RX_FIS_PIO_SETUP = 0x20, /* offset of PIO Setup FIS data */ + RX_FIS_D2H_REG = 0x40, /* offset of D2H Register FIS data */ + RX_FIS_SDB = 0x58, /* offset of SDB FIS data */ + RX_FIS_UNK = 0x60, /* offset of Unknown FIS data */ + + /* global controller registers */ + HOST_CAP = 0x00, /* host capabilities */ + HOST_CTL = 0x04, /* global host control */ + HOST_IRQ_STAT = 0x08, /* interrupt status */ + HOST_PORTS_IMPL = 0x0c, /* bitmap of implemented ports */ + HOST_VERSION = 0x10, /* AHCI spec. version compliancy */ + HOST_EM_LOC = 0x1c, /* Enclosure Management location */ + HOST_EM_CTL = 0x20, /* Enclosure Management Control */ + HOST_CAP2 = 0x24, /* host capabilities, extended */ + + /* HOST_CTL bits */ + HOST_RESET = (1 << 0), /* reset controller; self-clear */ + HOST_IRQ_EN = (1 << 1), /* global IRQ enable */ + HOST_AHCI_EN = (1 << 31), /* AHCI enabled */ + + /* HOST_CAP bits */ + HOST_CAP_SXS = (1 << 5), /* Supports External SATA */ + HOST_CAP_EMS = (1 << 6), /* Enclosure Management support */ + HOST_CAP_CCC = (1 << 7), /* Command Completion Coalescing */ + HOST_CAP_PART = (1 << 13), /* Partial state capable */ + HOST_CAP_SSC = (1 << 14), /* Slumber state capable */ + HOST_CAP_PIO_MULTI = (1 << 15), /* PIO multiple DRQ support */ + HOST_CAP_FBS = (1 << 16), /* FIS-based switching support */ + HOST_CAP_PMP = (1 << 17), /* Port Multiplier support */ + HOST_CAP_ONLY = (1 << 18), /* Supports AHCI mode only */ + HOST_CAP_CLO = (1 << 24), /* Command List Override support */ + HOST_CAP_LED = (1 << 25), /* Supports activity LED */ + HOST_CAP_ALPM = (1 << 26), /* Aggressive Link PM support */ + HOST_CAP_SSS = (1 << 27), /* Staggered Spin-up */ + HOST_CAP_MPS = (1 << 28), /* Mechanical presence switch */ + HOST_CAP_SNTF = (1 << 29), /* SNotification register */ + HOST_CAP_NCQ = (1 << 30), /* Native Command Queueing */ + HOST_CAP_64 = (1 << 31), /* PCI DAC (64-bit DMA) support */ + + /* HOST_CAP2 bits */ + HOST_CAP2_BOH = (1 << 0), /* BIOS/OS handoff supported */ + HOST_CAP2_NVMHCI = (1 << 1), /* NVMHCI supported */ + HOST_CAP2_APST = (1 << 2), /* Automatic partial to slumber */ + HOST_CAP2_SDS = (1 << 3), /* Support device sleep */ + HOST_CAP2_SADM = (1 << 4), /* Support aggressive DevSlp */ + HOST_CAP2_DESO = (1 << 5), /* DevSlp from slumber only */ + + /* registers for each SATA port */ + PORT_LST_ADDR = 0x00, /* command list DMA addr */ + PORT_LST_ADDR_HI = 0x04, /* command list DMA addr hi */ + PORT_FIS_ADDR = 0x08, /* FIS rx buf addr */ + PORT_FIS_ADDR_HI = 0x0c, /* FIS rx buf addr hi */ + PORT_IRQ_STAT = 0x10, /* interrupt status */ + PORT_IRQ_MASK = 0x14, /* interrupt enable/disable mask */ + PORT_CMD = 0x18, /* port command */ + PORT_TFDATA = 0x20, /* taskfile data */ + PORT_SIG = 0x24, /* device TF signature */ + PORT_CMD_ISSUE = 0x38, /* command issue */ + PORT_SCR_STAT = 0x28, /* SATA phy register: SStatus */ + PORT_SCR_CTL = 0x2c, /* SATA phy register: SControl */ + PORT_SCR_ERR = 0x30, /* SATA phy register: SError */ + PORT_SCR_ACT = 0x34, /* SATA phy register: SActive */ + PORT_SCR_NTF = 0x3c, /* SATA phy register: SNotification */ + PORT_FBS = 0x40, /* FIS-based Switching */ + PORT_DEVSLP = 0x44, /* device sleep */ + + /* PORT_IRQ_{STAT,MASK} bits */ + PORT_IRQ_COLD_PRES = (1 << 31), /* cold presence detect */ + PORT_IRQ_TF_ERR = (1 << 30), /* task file error */ + PORT_IRQ_HBUS_ERR = (1 << 29), /* host bus fatal error */ + PORT_IRQ_HBUS_DATA_ERR = (1 << 28), /* host bus data error */ + PORT_IRQ_IF_ERR = (1 << 27), /* interface fatal error */ + PORT_IRQ_IF_NONFATAL = (1 << 26), /* interface non-fatal error */ + PORT_IRQ_OVERFLOW = (1 << 24), /* xfer exhausted available S/G */ + PORT_IRQ_BAD_PMP = (1 << 23), /* incorrect port multiplier */ + + PORT_IRQ_PHYRDY = (1 << 22), /* PhyRdy changed */ + PORT_IRQ_DEV_ILCK = (1 << 7), /* device interlock */ + PORT_IRQ_CONNECT = (1 << 6), /* port connect change status */ + PORT_IRQ_SG_DONE = (1 << 5), /* descriptor processed */ + PORT_IRQ_UNK_FIS = (1 << 4), /* unknown FIS rx'd */ + PORT_IRQ_SDB_FIS = (1 << 3), /* Set Device Bits FIS rx'd */ + PORT_IRQ_DMAS_FIS = (1 << 2), /* DMA Setup FIS rx'd */ + PORT_IRQ_PIOS_FIS = (1 << 1), /* PIO Setup FIS rx'd */ + PORT_IRQ_D2H_REG_FIS = (1 << 0), /* D2H Register FIS rx'd */ + + PORT_IRQ_FREEZE = PORT_IRQ_HBUS_ERR | + PORT_IRQ_IF_ERR | + PORT_IRQ_CONNECT | + PORT_IRQ_PHYRDY | + PORT_IRQ_UNK_FIS | + PORT_IRQ_BAD_PMP, + PORT_IRQ_ERROR = PORT_IRQ_FREEZE | + PORT_IRQ_TF_ERR | + PORT_IRQ_HBUS_DATA_ERR, + DEF_PORT_IRQ = PORT_IRQ_ERROR | PORT_IRQ_SG_DONE | + PORT_IRQ_SDB_FIS | PORT_IRQ_DMAS_FIS | + PORT_IRQ_PIOS_FIS | PORT_IRQ_D2H_REG_FIS, + + /* PORT_CMD bits */ + PORT_CMD_ASP = (1 << 27), /* Aggressive Slumber/Partial */ + PORT_CMD_ALPE = (1 << 26), /* Aggressive Link PM enable */ + PORT_CMD_ATAPI = (1 << 24), /* Device is ATAPI */ + PORT_CMD_FBSCP = (1 << 22), /* FBS Capable Port */ + PORT_CMD_PMP = (1 << 17), /* PMP attached */ + PORT_CMD_LIST_ON = (1 << 15), /* cmd list DMA engine running */ + PORT_CMD_FIS_ON = (1 << 14), /* FIS DMA engine running */ + PORT_CMD_FIS_RX = (1 << 4), /* Enable FIS receive DMA engine */ + PORT_CMD_CLO = (1 << 3), /* Command list override */ + PORT_CMD_POWER_ON = (1 << 2), /* Power up device */ + PORT_CMD_SPIN_UP = (1 << 1), /* Spin up device */ + PORT_CMD_START = (1 << 0), /* Enable port DMA engine */ + + PORT_CMD_ICC_MASK = (0xf << 28), /* i/f ICC state mask */ + PORT_CMD_ICC_ACTIVE = (0x1 << 28), /* Put i/f in active state */ + PORT_CMD_ICC_PARTIAL = (0x2 << 28), /* Put i/f in partial state */ + PORT_CMD_ICC_SLUMBER = (0x6 << 28), /* Put i/f in slumber state */ + + /* PORT_FBS bits */ + PORT_FBS_DWE_OFFSET = 16, /* FBS device with error offset */ + PORT_FBS_ADO_OFFSET = 12, /* FBS active dev optimization offset */ + PORT_FBS_DEV_OFFSET = 8, /* FBS device to issue offset */ + PORT_FBS_DEV_MASK = (0xf << PORT_FBS_DEV_OFFSET), /* FBS.DEV */ + PORT_FBS_SDE = (1 << 2), /* FBS single device error */ + PORT_FBS_DEC = (1 << 1), /* FBS device error clear */ + PORT_FBS_EN = (1 << 0), /* Enable FBS */ + + /* PORT_DEVSLP bits */ + PORT_DEVSLP_DM_OFFSET = 25, /* DITO multiplier offset */ + PORT_DEVSLP_DM_MASK = (0xf << 25), /* DITO multiplier mask */ + PORT_DEVSLP_DITO_OFFSET = 15, /* DITO offset */ + PORT_DEVSLP_MDAT_OFFSET = 10, /* Minimum assertion time */ + PORT_DEVSLP_DETO_OFFSET = 2, /* DevSlp exit timeout */ + PORT_DEVSLP_DSP = (1 << 1), /* DevSlp present */ + PORT_DEVSLP_ADSE = (1 << 0), /* Aggressive DevSlp enable */ + + /* hpriv->flags bits */ + +#define AHCI_HFLAGS(flags) .private_data = (void *)(flags) + + AHCI_HFLAG_NO_NCQ = (1 << 0), + AHCI_HFLAG_IGN_IRQ_IF_ERR = (1 << 1), /* ignore IRQ_IF_ERR */ + AHCI_HFLAG_IGN_SERR_INTERNAL = (1 << 2), /* ignore SERR_INTERNAL */ + AHCI_HFLAG_32BIT_ONLY = (1 << 3), /* force 32bit */ + AHCI_HFLAG_MV_PATA = (1 << 4), /* PATA port */ + AHCI_HFLAG_NO_MSI = (1 << 5), /* no PCI MSI */ + AHCI_HFLAG_NO_PMP = (1 << 6), /* no PMP */ + AHCI_HFLAG_SECT255 = (1 << 8), /* max 255 sectors */ + AHCI_HFLAG_YES_NCQ = (1 << 9), /* force NCQ cap on */ + AHCI_HFLAG_NO_SUSPEND = (1 << 10), /* don't suspend */ + AHCI_HFLAG_SRST_TOUT_IS_OFFLINE = (1 << 11), /* treat SRST timeout as + link offline */ + AHCI_HFLAG_NO_SNTF = (1 << 12), /* no sntf */ + AHCI_HFLAG_NO_FPDMA_AA = (1 << 13), /* no FPDMA AA */ + AHCI_HFLAG_YES_FBS = (1 << 14), /* force FBS cap on */ + AHCI_HFLAG_DELAY_ENGINE = (1 << 15), /* do not start engine on + port start (wait until + error-handling stage) */ + AHCI_HFLAG_MULTI_MSI = (1 << 16), /* multiple PCI MSIs */ + + /* ap->flags bits */ + + /* + AHCI_FLAG_COMMON = ATA_FLAG_SATA | ATA_FLAG_PIO_DMA | + ATA_FLAG_ACPI_SATA | ATA_FLAG_AN, + */ + + ICH_MAP = 0x90, /* ICH MAP register */ + + /* em constants */ + EM_MAX_SLOTS = 8, + EM_MAX_RETRY = 5, + + /* em_ctl bits */ + EM_CTL_RST = (1 << 9), /* Reset */ + EM_CTL_TM = (1 << 8), /* Transmit Message */ + EM_CTL_MR = (1 << 0), /* Message Received */ + EM_CTL_ALHD = (1 << 26), /* Activity LED */ + EM_CTL_XMT = (1 << 25), /* Transmit Only */ + EM_CTL_SMB = (1 << 24), /* Single Message Buffer */ + EM_CTL_SGPIO = (1 << 19), /* SGPIO messages supported */ + EM_CTL_SES = (1 << 18), /* SES-2 messages supported */ + EM_CTL_SAFTE = (1 << 17), /* SAF-TE messages supported */ + EM_CTL_LED = (1 << 16), /* LED messages supported */ + + /* em message type */ + EM_MSG_TYPE_LED = (1 << 0), /* LED */ + EM_MSG_TYPE_SAFTE = (1 << 1), /* SAF-TE */ + EM_MSG_TYPE_SES2 = (1 << 2), /* SES-2 */ + EM_MSG_TYPE_SGPIO = (1 << 3), /* SGPIO */ + + FIS_TYPE_REG_H2D = 0x27, + FIS_TYPE_REG_D2H = 0x34, + FIS_TYPE_DMA_ACT = 0x39, + FIS_TYPE_DMA_SETUP = 0x41, + FIS_TYPE_DATA = 0x46, + FIS_TYPE_BIST = 0x58, + FIS_TYPE_PIO_SETUP = 0x5F, + FIS_TYPE_DEV_BITS = 0xA1, +}; + +/* End from linux 3.9 */ + +#endif /* _GNUMACH_AHCI_H */ diff --git a/linux/dev/include/linux/mm.h b/linux/dev/include/linux/mm.h index 0500e0cf..cd061378 100644 --- a/linux/dev/include/linux/mm.h +++ b/linux/dev/include/linux/mm.h @@ -281,6 +281,7 @@ extern void * vmalloc(unsigned long size); extern void * vremap(unsigned long offset, unsigned long size); extern void vfree(void * addr); extern int vread(char *buf, char *addr, int count); +extern unsigned long vmtophys (void *); /* mmap.c */ extern unsigned long do_mmap(struct file * file, unsigned long addr, unsigned long len, diff --git a/linux/src/drivers/block/ide.c b/linux/src/drivers/block/ide.c index 7ab790d4..0f3fd01f 100644 --- a/linux/src/drivers/block/ide.c +++ b/linux/src/drivers/block/ide.c @@ -302,6 +302,8 @@ #include #include +#include + #include #include #include @@ -3682,6 +3684,7 @@ static void probe_for_hwifs (void) #ifdef CONFIG_BLK_DEV_PROMISE init_dc4030(); #endif + ahci_probe_pci(); } static int hwif_init (int h) diff --git a/linux/src/include/linux/pci.h b/linux/src/include/linux/pci.h index 3508979f..8aad3d59 100644 --- a/linux/src/include/linux/pci.h +++ b/linux/src/include/linux/pci.h @@ -140,6 +140,8 @@ #define PCI_CLASS_STORAGE_FLOPPY 0x0102 #define PCI_CLASS_STORAGE_IPI 0x0103 #define PCI_CLASS_STORAGE_RAID 0x0104 +#define PCI_CLASS_STORAGE_SATA 0x0106 +#define PCI_CLASS_STORAGE_SATA_AHCI 0x010601 #define PCI_CLASS_STORAGE_OTHER 0x0180 #define PCI_BASE_CLASS_NETWORK 0x02 -- cgit v1.2.3 From 1aedf90a3e7eb5ec31f8f18083bb50f72569f787 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Fri, 10 May 2013 20:11:59 +0200 Subject: Fix ahci.h path * linux/Makefrag.am (liblinux_a_SOURCES): Fix path to ahci.h --- linux/Makefrag.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux/Makefrag.am b/linux/Makefrag.am index 2775aa8b..52d91d03 100644 --- a/linux/Makefrag.am +++ b/linux/Makefrag.am @@ -79,7 +79,7 @@ liblinux_a_SOURCES += \ linux/src/drivers/block/ide.c \ linux/src/drivers/block/ide.h \ linux/dev/drivers/block/ahci.c \ - linux/dev/drivers/block/ahci.h \ + linux/dev/include/ahci.h \ linux/src/drivers/block/ide_modes.h \ linux/src/drivers/block/rz1000.c \ linux/src/drivers/block/triton.c -- cgit v1.2.3 From 757bd14f3832e7668d336d570b603ab7dc01cf88 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sat, 11 May 2013 04:29:12 +0200 Subject: Add missing parameters to printf * linux/dev/drivers/block/ahci.c (ahci_probe_dev): Add missing parameters to printf. --- linux/dev/drivers/block/ahci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux/dev/drivers/block/ahci.c b/linux/dev/drivers/block/ahci.c index 82dea8d2..0ea1e3e8 100644 --- a/linux/dev/drivers/block/ahci.c +++ b/linux/dev/drivers/block/ahci.c @@ -734,7 +734,7 @@ static void ahci_probe_dev(unsigned char bus, unsigned char device) /* Map mmio */ ahci_host = vremap(bar, 0x2000); if (!(readl(&ahci_host->cap) & HOST_CAP_ONLY)) { - printk("ahci: %02u:%02u.%u: available as IDE too, skipping it\n"); + printk("ahci: %02u:%02u.%u: available as IDE too, skipping it\n", bus, dev, fun); return; } -- cgit v1.2.3 From 70c363f991a58889eb94c5d965741eb5a26f1cc2 Mon Sep 17 00:00:00 2001 From: Miguel Figueiredo Date: Mon, 13 May 2013 23:08:28 +0200 Subject: Drop unused variables * kern/slab.c (kalloc_init): Remove unused variables. --- kern/slab.c | 1 - 1 file changed, 1 deletion(-) diff --git a/kern/slab.c b/kern/slab.c index 0f0d4cbe..c8a2b7c6 100644 --- a/kern/slab.c +++ b/kern/slab.c @@ -1319,7 +1319,6 @@ void kalloc_init(void) { char name[KMEM_CACHE_NAME_SIZE]; size_t i, size; - vm_offset_t min, max; size = 1 << KALLOC_FIRST_SHIFT; -- cgit v1.2.3 From 1bcdf3c4d9e10541ba479c299124aa31c04f5b6f Mon Sep 17 00:00:00 2001 From: Richard Braun Date: Wed, 15 May 2013 23:57:20 +0200 Subject: Fix itemization errors in the texinfo documentation * doc/mach.texi: Replace @itemx with @item for --enable-tulip and --enable-epic100. --- doc/mach.texi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/mach.texi b/doc/mach.texi index 8f45dfbc..5bfff237 100644 --- a/doc/mach.texi +++ b/doc/mach.texi @@ -842,7 +842,7 @@ AT-LAN-TEC/RealTek pocket adaptor network card device driver for the AMD LANCE and PCnet (AT1500 and NE2100) network card device driver. On @samp{ix86-at} enabled by @samp{default}. -@itemx --enable-tulip +@item --enable-tulip DECchip Tulip (dc21x4x) PCI network card device driver. On @samp{ix86-at} enabled by @samp{default}. @@ -870,7 +870,7 @@ Packet Engines Yellowfin Gigabit-NIC network card device driver. On RealTek 8129/8139 (not 8019/8029!) network card device driver. On @samp{ix86-at} enabled by @samp{default}. -@itemx --enable-epic100 +@item --enable-epic100 SMC 83c170/175 EPIC/100 (EtherPower II) network card device driver. On @samp{ix86-at} enabled by @samp{default}. -- cgit v1.2.3 From 2840e10b3294607268dde98ed247c4badd6735b2 Mon Sep 17 00:00:00 2001 From: Richard Braun Date: Thu, 16 May 2013 00:01:07 +0200 Subject: Rename list_insert to list_insert_head This change increases clarity. * kern/list.h (list_insert): Rename to ... (list_insert_head): ... this. * kern/slab.c: Update calls to list_insert. --- kern/list.h | 2 +- kern/slab.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/kern/list.h b/kern/list.h index 03414718..ad782a8a 100644 --- a/kern/list.h +++ b/kern/list.h @@ -240,7 +240,7 @@ static inline void list_add(struct list *prev, struct list *next, /* * Insert a node at the head of a list. */ -static inline void list_insert(struct list *list, struct list *node) +static inline void list_insert_head(struct list *list, struct list *node) { list_add(list, list->next, node); } diff --git a/kern/slab.c b/kern/slab.c index c8a2b7c6..0a4dbdf8 100644 --- a/kern/slab.c +++ b/kern/slab.c @@ -878,7 +878,7 @@ static int kmem_cache_grow(struct kmem_cache *cache) simple_lock(&cache->lock); if (slab != NULL) { - list_insert(&cache->free_slabs, &slab->list_node); + list_insert_head(&cache->free_slabs, &slab->list_node); cache->nr_bufs += cache->bufs_per_slab; cache->nr_slabs++; cache->nr_free_slabs++; @@ -957,7 +957,7 @@ static void * kmem_cache_alloc_from_slab(struct kmem_cache *cache) } else if (slab->nr_refs == 1) { /* The slab has become partial */ list_remove(&slab->list_node); - list_insert(&cache->partial_slabs, &slab->list_node); + list_insert_head(&cache->partial_slabs, &slab->list_node); cache->nr_free_slabs--; } @@ -1010,11 +1010,11 @@ static void kmem_cache_free_to_slab(struct kmem_cache *cache, void *buf) if (cache->bufs_per_slab > 1) list_remove(&slab->list_node); - list_insert(&cache->free_slabs, &slab->list_node); + list_insert_head(&cache->free_slabs, &slab->list_node); cache->nr_free_slabs++; } else if (slab->nr_refs == (cache->bufs_per_slab - 1)) { /* The slab has become partial */ - list_insert(&cache->partial_slabs, &slab->list_node); + list_insert_head(&cache->partial_slabs, &slab->list_node); } } -- cgit v1.2.3 From c4d56664a22f0c46ec0e81b856860964ea89f420 Mon Sep 17 00:00:00 2001 From: Richard Braun Date: Thu, 16 May 2013 00:04:31 +0200 Subject: Reduce fragmentation in the slab allocator This reverts a change brought when reworking slab lists handling that made the allocator store slabs in LIFO order, whatever their reference count. While it's fine for free slabs, it actually increased fragmentation for partial slabs. * kern/slab.c (kmem_cache_alloc_from_slab): Insert slabs that become partial at the end of the partial slabs list. --- kern/slab.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/kern/slab.c b/kern/slab.c index 0a4dbdf8..d14d07ac 100644 --- a/kern/slab.c +++ b/kern/slab.c @@ -955,9 +955,12 @@ static void * kmem_cache_alloc_from_slab(struct kmem_cache *cache) if (slab->nr_refs == 1) cache->nr_free_slabs--; } else if (slab->nr_refs == 1) { - /* The slab has become partial */ + /* + * The slab has become partial. Insert the new slab at the end of + * the list to reduce fragmentation. + */ list_remove(&slab->list_node); - list_insert_head(&cache->partial_slabs, &slab->list_node); + list_insert_tail(&cache->partial_slabs, &slab->list_node); cache->nr_free_slabs--; } -- cgit v1.2.3 From 35b0af420ce7150533d4bf249b4ddfe9b4231ddd Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 19 May 2013 00:06:43 +0200 Subject: Remove duplicate line Reported by Miguel Figueiredo * kern/thread.c (thread_create): Remove duplicate reset of new_thread->pc_sample.buffer to 0. --- kern/thread.c | 1 - 1 file changed, 1 deletion(-) diff --git a/kern/thread.c b/kern/thread.c index 87be9231..204a7f5f 100644 --- a/kern/thread.c +++ b/kern/thread.c @@ -533,7 +533,6 @@ kern_return_t thread_create( #endif /* HW_FOOTPRINT */ #if MACH_PCSAMPLE - new_thread->pc_sample.buffer = 0; new_thread->pc_sample.seqno = 0; new_thread->pc_sample.sampletypes = 0; #endif /* MACH_PCSAMPLE */ -- cgit v1.2.3 From bc99a4f4a85d1803430d1b4c0d6619d1fba8d9c7 Mon Sep 17 00:00:00 2001 From: Miguel Figueiredo Date: Sun, 19 May 2013 00:10:41 +0200 Subject: Remove unneeded variable initialization * kern/thread.c (thread_force_terminate): Remove unneeded variable initialization. --- kern/thread.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kern/thread.c b/kern/thread.c index 204a7f5f..79f526a2 100644 --- a/kern/thread.c +++ b/kern/thread.c @@ -861,7 +861,7 @@ void thread_force_terminate( register thread_t thread) { - boolean_t deallocate_here = FALSE; + boolean_t deallocate_here; spl_t s; ipc_thread_disable(thread); -- cgit v1.2.3 From 0bd4a8ed0ea5295bd00de63d33253ad05548d71f Mon Sep 17 00:00:00 2001 From: Miguel Figueiredo Date: Mon, 27 May 2013 01:03:41 +0200 Subject: Remove old elevator algorithm function * device/blkio.c (disksort): remove unused function --- device/blkio.c | 129 --------------------------------------------------------- 1 file changed, 129 deletions(-) diff --git a/device/blkio.c b/device/blkio.c index 26d4a75a..27fec0e4 100644 --- a/device/blkio.c +++ b/device/blkio.c @@ -107,132 +107,3 @@ vm_offset_t block_io_mmap() return (0); } -/* - * Disk sort routine. - * - * We order the disk request chain so that the disk head will sweep - * back and forth across the disk. The chain is divided into two - * pieces, with requests ordered in opposite directions. Assume that - * the first part of the chain holds increasing cylinder numbers. - * If a new request has a higher cylinder number than the head of - * the chain, the disk head has not yet reached it; the new request - * can go in the first part of the chain. If the new request has - * a lower cylinder number, the disk head has already passed it and - * must catch it on the way back; so the new request goes in the - * second (descending) part of the chain. - * When all of the requests in the ascending portion are filled, - * the descending chain becomes the first chain, and requests above - * the first now go in the second part of the chain (ascending). - */ - -#define io_cylinder io_residual - /* Disk drivers put cylinder here */ -#define h_head io_next -#define h_tail io_prev - /* IORs are chained here */ - -void disksort(head, ior) - io_req_t head; /* (sort of) */ - io_req_t ior; -{ - register int cylinder = ior->io_cylinder; - register io_req_t next, prev; - - next = head->h_head; - if (next == 0) { - head->h_head = ior; - head->h_tail = ior; - ior->io_next = 0; - return; - } - - do { - prev = next; - next = prev->io_next; - } while (next != 0 && prev->io_cylinder == next->io_cylinder); - - if (next == 0) { - prev->io_next = ior; - head->h_tail = ior; - ior->io_next = 0; - return; - } - - if (prev->io_cylinder < next->io_cylinder) { - /* - * Ascending list first. - */ - if (prev->io_cylinder <= cylinder) { - /* - * Insert in ascending list. - */ - while (next != 0 && - next->io_cylinder <= cylinder && - prev->io_cylinder <= next->io_cylinder) - { - prev = next; - next = prev->io_next; - } - } - else { - /* - * Insert in descending list - */ - do { - prev = next; - next = prev->io_next; - } while (next != 0 && - prev->io_cylinder <= next->io_cylinder); - - while (next != 0 && - next->io_cylinder >= cylinder) - { - prev = next; - next = prev->io_next; - } - } - } - else { - /* - * Descending first. - */ - if (prev->io_cylinder >= cylinder) { - /* - * Insert in descending list. - */ - while (next != 0 && - next->io_cylinder >= cylinder && - prev->io_cylinder >= next->io_cylinder) - { - prev = next; - next = prev->io_next; - } - } - else { - /* - * Insert in ascending list - */ - do { - prev = next; - next = prev->io_next; - } while (next != 0 && - prev->io_cylinder >= next->io_cylinder); - while (next != 0 && - next->io_cylinder <= cylinder) - { - prev = next; - next = prev->io_next; - } - } - } - /* - * Insert between prev and next. - */ - prev->io_next = ior; - ior->io_next = next; - if (next == 0) { - /* At tail of list. */ - head->h_tail = ior; - } -} - -- cgit v1.2.3 From 932d5649e7402a5d46c0bdd5788b96153416af70 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Thu, 30 May 2013 01:17:38 +0200 Subject: Add LBA48 support to AHCI driver * linux/dev/drivers/block/ahci.c (port): Extend `capacity' field type to unsigned long long. Add `lba48' field. Make `identify' field unsigned. (ahci_do_port_request): When `lba48' is true, use WIN_READDMA_EXT and WIN_WRITEDMA_EXT commands. (ahci_probe_port): Test lba48 flag, read capacity and set `lba48' accordingly. Display size in GiB above 10GiB. * linux/src/include/linux/hdreg.h (WIN_READDMA_EXT, WIN_WRITEDMA_EXT): New macros (hd_driveid): Add `command_set_2' and lba_capacity_2' fields. --- linux/dev/drivers/block/ahci.c | 44 ++++++++++++++++++++++++++++++++++------- linux/src/include/linux/hdreg.h | 9 ++++----- 2 files changed, 41 insertions(+), 12 deletions(-) diff --git a/linux/dev/drivers/block/ahci.c b/linux/dev/drivers/block/ahci.c index 0ea1e3e8..3b31e846 100644 --- a/linux/dev/drivers/block/ahci.c +++ b/linux/dev/drivers/block/ahci.c @@ -239,13 +239,14 @@ static struct port { struct ahci_fis *fis; struct ahci_cmd_tbl *prdtl; - unsigned capacity; /* Nr of sectors */ + unsigned long long capacity; /* Nr of sectors */ u32 status; /* interrupt status */ unsigned cls; /* Command list maximum size. We currently only use 1. */ struct wait_queue *q; /* IRQ wait queue */ struct hd_struct *part; /* drive partition table */ - int identify; /* Whether we are just identifying + unsigned lba48; /* Whether LBA48 is supported */ + unsigned identify; /* Whether we are just identifying at boot */ } ports[MAX_PORTS]; @@ -301,10 +302,16 @@ static void ahci_do_port_request(struct port *port, unsigned sector, struct requ fis_h2d = (void*) &prdtl[slot].cfis; fis_h2d->fis_type = FIS_TYPE_REG_H2D; fis_h2d->flags = 128; - if (rq->cmd == READ) - fis_h2d->command = WIN_READDMA; + if (port->lba48) + if (rq->cmd == READ) + fis_h2d->command = WIN_READDMA_EXT; + else + fis_h2d->command = WIN_WRITEDMA_EXT; else - fis_h2d->command = WIN_WRITEDMA; + if (rq->cmd == READ) + fis_h2d->command = WIN_READDMA; + else + fis_h2d->command = WIN_WRITEDMA; fis_h2d->device = 1<<6; /* LBA */ @@ -679,12 +686,35 @@ static void ahci_probe_port(const volatile struct ahci_host *ahci_host, const vo { printk("sd%u: identify error\n", port-ports); port->capacity = 0; + port->lba48 = 0; } else { ide_fixstring(id.model, sizeof(id.model), 1); ide_fixstring(id.fw_rev, sizeof(id.fw_rev), 1); ide_fixstring(id.serial_no, sizeof(id.serial_no), 1); - port->capacity = id.lba_capacity; - printk("sd%u: %s, %uMB w/%dkB Cache\n", port - ports, id.model, port->capacity/2048, id.buf_size/2); + if (id.command_set_2 & (1U<<10)) + { + port->lba48 = 1; + port->capacity = id.lba_capacity_2; + if (port->capacity >= (1ULL << 32)) + { + port->capacity = (1ULL << 32) - 1; + printk("Warning: truncating disk size to 2TiB\n"); + } + } + else + { + port->lba48 = 0; + port->capacity = id.lba_capacity; + if (port->capacity > (1ULL << 24)) + { + port->capacity = (1ULL << 24); + printk("Warning: truncating disk size to 128GiB\n"); + } + } + if (port->capacity/2048 >= 10240) + printk("sd%u: %s, %uGB w/%dkB Cache\n", port - ports, id.model, port->capacity/(2048*1024), id.buf_size/2); + else + printk("sd%u: %s, %uMB w/%dkB Cache\n", port - ports, id.model, port->capacity/2048, id.buf_size/2); } port->identify = 0; } diff --git a/linux/src/include/linux/hdreg.h b/linux/src/include/linux/hdreg.h index e223480d..4a388c5d 100644 --- a/linux/src/include/linux/hdreg.h +++ b/linux/src/include/linux/hdreg.h @@ -62,6 +62,8 @@ #define WIN_SETFEATURES 0xEF /* set special drive features */ #define WIN_READDMA 0xc8 /* read sectors using DMA transfers */ #define WIN_WRITEDMA 0xca /* write sectors using DMA transfers */ +#define WIN_READDMA_EXT 0x25 /* read sectors using LBA48 DMA transfers */ +#define WIN_WRITEDMA_EXT 0x35 /* write sectors using LBA48 DMA transfers */ /* Additional drive command codes used by ATAPI devices. */ #define WIN_PIDENTIFY 0xA1 /* identify ATAPI device */ @@ -168,7 +170,7 @@ struct hd_driveid { unsigned short word80; unsigned short word81; unsigned short command_sets; /* bits 0:Smart 1:Security 2:Removable 3:PM */ - unsigned short word83; /* bits 14:Smart Enabled 13:0 zero */ + unsigned short command_set_2; /* bits 14:Smart Enabled 13:0 zero */ unsigned short word84; unsigned short word85; unsigned short word86; @@ -185,10 +187,7 @@ struct hd_driveid { unsigned short word97; /* reserved (word 97) */ unsigned short word98; /* reserved (word 98) */ unsigned short word99; /* reserved (word 99) */ - unsigned short word100; /* reserved (word 100) */ - unsigned short word101; /* reserved (word 101) */ - unsigned short word102; /* reserved (word 102) */ - unsigned short word103; /* reserved (word 103) */ + unsigned long long lba_capacity_2; /* 48-bit total number of sectors */ unsigned short word104; /* reserved (word 104) */ unsigned short word105; /* reserved (word 105) */ unsigned short word106; /* reserved (word 106) */ -- cgit v1.2.3 From 1855863a892ad28ef681129e57ad375e3805362b Mon Sep 17 00:00:00 2001 From: Miguel Figueiredo Date: Sun, 2 Jun 2013 18:38:34 +0200 Subject: Remove unused variable * ipc/mach_port.c (mach_port_set_syscall_right): Remove unused variable. --- ipc/mach_port.c | 1 - 1 file changed, 1 deletion(-) diff --git a/ipc/mach_port.c b/ipc/mach_port.c index d0310b55..46cb4de4 100644 --- a/ipc/mach_port.c +++ b/ipc/mach_port.c @@ -1543,7 +1543,6 @@ mach_port_set_syscall_right(task, name) mach_port_t name; { ipc_entry_t entry; - ipc_port_t port; kern_return_t kr; if (task == IS_NULL) -- cgit v1.2.3 From b67a79a13ae2a42ed4a64bfd2bd3b4982cfdefca Mon Sep 17 00:00:00 2001 From: Richard Braun Date: Sun, 2 Jun 2013 18:50:56 +0200 Subject: Fix yet another locking error in the slab allocator * kern/slab.c (kmem_cache_free): Relock cache before retrying releasing an object to the CPU pool layer. --- kern/slab.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kern/slab.c b/kern/slab.c index d14d07ac..56fadbfb 100644 --- a/kern/slab.c +++ b/kern/slab.c @@ -1229,6 +1229,7 @@ fast_free: simple_unlock(&cpu_pool->lock); kmem_cache_free(cache->cpu_pool_type->array_cache, (vm_offset_t)array); + simple_lock(&cpu_pool->lock); goto fast_free; } -- cgit v1.2.3 From e124fdce292d027b6b57cd10be41c37624313a90 Mon Sep 17 00:00:00 2001 From: Miguel Figueiredo Date: Sun, 2 Jun 2013 23:36:39 +0200 Subject: Remove unused variable * kern/act.c (act_create): Remove unused variable. --- kern/act.c | 1 - 1 file changed, 1 deletion(-) diff --git a/kern/act.c b/kern/act.c index 36fa79c1..4c3839c6 100644 --- a/kern/act.c +++ b/kern/act.c @@ -97,7 +97,6 @@ kern_return_t act_create(task_t task, vm_offset_t user_stack, struct Act **new_act) { Act *act; - int rc; #ifndef ACT_STATIC_KLUDGE act = (Act*)kmem_cache_alloc(&act_cache); -- cgit v1.2.3 From 21fff41626efc52861648edfe00c6ceecaa3a59c Mon Sep 17 00:00:00 2001 From: Miguel Figueiredo Date: Tue, 4 Jun 2013 19:54:29 +0200 Subject: Fix format warnings * vm/vm_resident.c (pmap_startup): Fix printf format. * xen/block.c (hyp_block_init, device_write): Likewise. * xen/net.c (hyp_net_init): Likewise. --- vm/vm_resident.c | 2 +- xen/block.c | 8 ++++---- xen/net.c | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/vm/vm_resident.c b/vm/vm_resident.c index 7cf4fb16..d2edf5a2 100644 --- a/vm/vm_resident.c +++ b/vm/vm_resident.c @@ -395,7 +395,7 @@ void pmap_startup( while (pmap_next_page(&paddr)) i++; if (i) - printf("%d memory page(s) left away\n", i); + printf("%u memory page(s) left away\n", i); /* * Release pages in reverse order so that physical pages diff --git a/xen/block.c b/xen/block.c index 4253ef04..3e4ce7c6 100644 --- a/xen/block.c +++ b/xen/block.c @@ -214,9 +214,9 @@ void hyp_block_init(void) { continue; } if (partition) - sprintf(device_name, "%s%us%u", prefix, disk, partition); + sprintf(device_name, "%s%ds%d", prefix, disk, partition); else - sprintf(device_name, "%s%u", prefix, disk); + sprintf(device_name, "%s%d", prefix, disk); bd->name = (char*) kalloc(strlen(device_name)); strcpy(bd->name, device_name); @@ -238,7 +238,7 @@ void hyp_block_init(void) { grant = hyp_grant_give(domid, atop(addr), 0); /* and give it to backend. */ - i = sprintf(port_name, "%u", grant); + i = sprintf(port_name, "%d", grant); c = hyp_store_write(t, port_name, 5, VBD_PATH, "/", vbds[n], "/", "ring-ref"); if (!c) panic("%s: couldn't store ring reference (%s)", device_name, hyp_store_error); @@ -670,7 +670,7 @@ device_write(void *d, ipc_port_t reply_port, hyp_grant_takeback(gref[j]); if (err) { - printf("error writing %d bytes at sector %d\n", count, bn); + printf("error writing %u bytes at sector %d\n", count, bn); break; } } diff --git a/xen/net.c b/xen/net.c index 10e4bbef..fb264719 100644 --- a/xen/net.c +++ b/xen/net.c @@ -366,7 +366,7 @@ void hyp_net_init(void) { grant = hyp_grant_give(domid, atop(addr), 0); /* and give it to backend. */ - i = sprintf(port_name, "%u", grant); + i = sprintf(port_name, "%d", grant); c = hyp_store_write(t, port_name, 5, VIF_PATH, "/", vifs[n], "/", "tx-ring-ref"); if (!c) panic("eth: couldn't store tx_ring reference for VIF %s (%s)", vifs[n], hyp_store_error); @@ -381,7 +381,7 @@ void hyp_net_init(void) { grant = hyp_grant_give(domid, atop(addr), 0); /* and give it to backend. */ - i = sprintf(port_name, "%u", grant); + i = sprintf(port_name, "%d", grant); c = hyp_store_write(t, port_name, 5, VIF_PATH, "/", vifs[n], "/", "rx-ring-ref"); if (!c) panic("eth: couldn't store rx_ring reference for VIF %s (%s)", vifs[n], hyp_store_error); -- cgit v1.2.3 From b99130d97a40c8337d152669add0fce6c65e7377 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Tue, 4 Jun 2013 20:00:21 +0200 Subject: Comment unused variable * kern/ipc_mig.c (syscall_device_write_request): Comment unused variable. --- kern/ipc_mig.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/kern/ipc_mig.c b/kern/ipc_mig.c index 3f55da7c..e1532ac8 100644 --- a/kern/ipc_mig.c +++ b/kern/ipc_mig.c @@ -928,7 +928,7 @@ syscall_device_write_request(mach_port_t device_name, vm_size_t data_count) { device_t dev; - ipc_port_t reply_port; + /*ipc_port_t reply_port;*/ io_return_t res; /* @@ -949,9 +949,10 @@ syscall_device_write_request(mach_port_t device_name, /* * Translate reply port. */ - if (reply_name == MACH_PORT_NULL) + /*if (reply_name == MACH_PORT_NULL) reply_port = IP_NULL; - else { + */ + if (reply_name != MACH_PORT_NULL) { /* Homey don't play that. */ device_deallocate(dev); return KERN_INVALID_RIGHT; -- cgit v1.2.3 From cf79b6a9a9d4ceef4f69d0e8c691cd198863cd67 Mon Sep 17 00:00:00 2001 From: Richard Braun Date: Sun, 9 Jun 2013 16:58:51 +0200 Subject: Fix object construction in the slab allocator There is currently no actual use of constructors, which is why this bug has been long overlooked. * kern/slab.c (kmem_cpu_pool_fill): Call constructor on buffers unless verification is enabled for the cache, or the constructor is NULL. --- kern/slab.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/kern/slab.c b/kern/slab.c index 56fadbfb..5c697cd8 100644 --- a/kern/slab.c +++ b/kern/slab.c @@ -615,18 +615,24 @@ static inline void kmem_cpu_pool_push(struct kmem_cpu_pool *cpu_pool, void *obj) static int kmem_cpu_pool_fill(struct kmem_cpu_pool *cpu_pool, struct kmem_cache *cache) { - void *obj; + kmem_cache_ctor_t ctor; + void *buf; int i; + ctor = (cpu_pool->flags & KMEM_CF_VERIFY) ? NULL : cache->ctor; + simple_lock(&cache->lock); for (i = 0; i < cpu_pool->transfer_size; i++) { - obj = kmem_cache_alloc_from_slab(cache); + buf = kmem_cache_alloc_from_slab(cache); - if (obj == NULL) + if (buf == NULL) break; - kmem_cpu_pool_push(cpu_pool, obj); + if (ctor != NULL) + ctor(buf); + + kmem_cpu_pool_push(cpu_pool, buf); } simple_unlock(&cache->lock); -- cgit v1.2.3 From ea45ed1b6cb14af24e817aefbba642e3733e3a88 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 9 Jun 2013 21:44:21 +0200 Subject: Fix format --- linux/dev/drivers/block/ahci.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/linux/dev/drivers/block/ahci.c b/linux/dev/drivers/block/ahci.c index 3b31e846..b7102518 100644 --- a/linux/dev/drivers/block/ahci.c +++ b/linux/dev/drivers/block/ahci.c @@ -397,7 +397,7 @@ static void ahci_do_request() /* invoked with cli() */ } if (blockend > port->capacity) { printk("offset for %u was %lu\n", minor, port->part[minor & PARTN_MASK].start_sect); - printk("bad access: block %lu, count= %u\n", blockend, port->capacity); + printk("bad access: block %lu, count= %llu\n", blockend, port->capacity); goto kill_rq; } @@ -712,9 +712,9 @@ static void ahci_probe_port(const volatile struct ahci_host *ahci_host, const vo } } if (port->capacity/2048 >= 10240) - printk("sd%u: %s, %uGB w/%dkB Cache\n", port - ports, id.model, port->capacity/(2048*1024), id.buf_size/2); + printk("sd%u: %s, %lluGB w/%dkB Cache\n", port - ports, id.model, port->capacity/(2048*1024), id.buf_size/2); else - printk("sd%u: %s, %uMB w/%dkB Cache\n", port - ports, id.model, port->capacity/2048, id.buf_size/2); + printk("sd%u: %s, %lluMB w/%dkB Cache\n", port - ports, id.model, port->capacity/2048, id.buf_size/2); } port->identify = 0; } -- cgit v1.2.3 From b582af37cf8bfd70e6cf9a0e082b26890e8108af Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 9 Jun 2013 21:47:58 +0200 Subject: Fix printf format * linux/dev/drivers/block/ahci.c (ahci_do_request): Cast capacity into unsigned long and use %lu format. (ahci_probe_port): Cast size into unsigned and use %u format. --- linux/dev/drivers/block/ahci.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/linux/dev/drivers/block/ahci.c b/linux/dev/drivers/block/ahci.c index b7102518..88b2ab88 100644 --- a/linux/dev/drivers/block/ahci.c +++ b/linux/dev/drivers/block/ahci.c @@ -397,7 +397,7 @@ static void ahci_do_request() /* invoked with cli() */ } if (blockend > port->capacity) { printk("offset for %u was %lu\n", minor, port->part[minor & PARTN_MASK].start_sect); - printk("bad access: block %lu, count= %llu\n", blockend, port->capacity); + printk("bad access: block %lu, count= %lu\n", blockend, (unsigned long) port->capacity); goto kill_rq; } @@ -712,9 +712,9 @@ static void ahci_probe_port(const volatile struct ahci_host *ahci_host, const vo } } if (port->capacity/2048 >= 10240) - printk("sd%u: %s, %lluGB w/%dkB Cache\n", port - ports, id.model, port->capacity/(2048*1024), id.buf_size/2); + printk("sd%u: %s, %uGB w/%dkB Cache\n", port - ports, id.model, (unsigned) (port->capacity/(2048*1024)), id.buf_size/2); else - printk("sd%u: %s, %lluMB w/%dkB Cache\n", port - ports, id.model, port->capacity/2048, id.buf_size/2); + printk("sd%u: %s, %uMB w/%dkB Cache\n", port - ports, id.model, (unsigned) (port->capacity/2048), id.buf_size/2); } port->identify = 0; } -- cgit v1.2.3 From b6f5f510249eaa3cdc31fd7d001f61b7844dbee0 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 9 Jun 2013 22:05:02 +0200 Subject: Add timeout to ahci IDENTIFY * linux/dev/drivers/block/ahci.c (identify_timeout): New function. (identify_timer): New variable. (ahci_probe_port): Add timer to abandon identify command. --- linux/dev/drivers/block/ahci.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/linux/dev/drivers/block/ahci.c b/linux/dev/drivers/block/ahci.c index 88b2ab88..a9d63357 100644 --- a/linux/dev/drivers/block/ahci.c +++ b/linux/dev/drivers/block/ahci.c @@ -514,6 +514,15 @@ static struct file_operations ahci_fops = { .revalidate = NULL, }; +/* Disk timed out while processing identify, interrupt ahci_probe_port */ +static void identify_timeout(unsigned long data) +{ + struct port *port = (void*) data; + + wake_up(&port->q); +} + +static struct timer_list identify_timer = { .function = identify_timeout }; /* Probe one AHCI port */ static void ahci_probe_port(const volatile struct ahci_host *ahci_host, const volatile struct ahci_port *ahci_port) @@ -671,15 +680,20 @@ static void ahci_probe_port(const volatile struct ahci_host *ahci_host, const vo writel(1 << slot, &ahci_port->ci); timeout = jiffies + WAIT_MAX; + identify_timer.expires = timeout; + identify_timer.data = (unsigned long) port; + add_timer(&identify_timer); while (!port->status) { - if (jiffies > timeout) { + if (jiffies >= timeout) { printk("sd%u: timeout waiting for ready\n", port-ports); port->ahci_host = NULL; port->ahci_port = NULL; + del_timer(&identify_timer); return; } sleep_on(&port->q); } + del_timer(&identify_timer); restore_flags(flags); if (readl(&ahci_port->is) & PORT_IRQ_TF_ERR) -- cgit v1.2.3 From 63e94ea48ad692f506e8db51e64cf3f710d58a71 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 9 Jun 2013 22:06:16 +0200 Subject: Do not skip AHCI controller without HOST_CAP_ONLY We rather rely on the announced PCI type to determine whether to use IDE or AHCI. * linux/dev/drivers/block/ahci.c (ahci_probe_dev): Do not skip AHCI controller without HOST_CAP_ONLY. --- linux/dev/drivers/block/ahci.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/linux/dev/drivers/block/ahci.c b/linux/dev/drivers/block/ahci.c index a9d63357..dbc8fdb6 100644 --- a/linux/dev/drivers/block/ahci.c +++ b/linux/dev/drivers/block/ahci.c @@ -777,10 +777,6 @@ static void ahci_probe_dev(unsigned char bus, unsigned char device) /* Map mmio */ ahci_host = vremap(bar, 0x2000); - if (!(readl(&ahci_host->cap) & HOST_CAP_ONLY)) { - printk("ahci: %02u:%02u.%u: available as IDE too, skipping it\n", bus, dev, fun); - return; - } /* Request IRQ */ if (request_irq(irq, &ahci_interrupt, SA_SHIRQ, "ahci", (void*) ahci_host)) { -- cgit v1.2.3 From 49d0e47087bd60a2ceae246258d803197d105d31 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Mon, 10 Jun 2013 00:33:31 +0200 Subject: Add non-contiguous mmap support * i386/include/mach/i386/multiboot.h (multiboot_mmap): New structure * i386/i386at/model_dep.c (mem_size_init): Parse boot_info.mmap_addr if available. (init_alloc_aligned): Likewise. --- i386/i386at/model_dep.c | 99 ++++++++++++++++++++++++++++++++++---- i386/include/mach/i386/multiboot.h | 10 ++++ 2 files changed, 99 insertions(+), 10 deletions(-) diff --git a/i386/i386at/model_dep.c b/i386/i386at/model_dep.c index 3db03d76..9c532431 100644 --- a/i386/i386at/model_dep.c +++ b/i386/i386at/model_dep.c @@ -274,14 +274,44 @@ mem_size_init(void) } else phys_last_addr = boot_info.nr_pages * 0x1000; #else /* MACH_HYP */ - /* TODO: support mmap */ - vm_size_t phys_last_kb = 0x400 + boot_info.mem_upper; - /* Avoid 4GiB overflow. */ - if (phys_last_kb < 0x400 || phys_last_kb >= 0x400000) { - printf("Truncating memory size to 4GiB\n"); - phys_last_addr = 0xffffffffU; - } else - phys_last_addr = phys_last_kb * 0x400; + vm_size_t phys_last_kb; + + if (boot_info.flags & MULTIBOOT_MEM_MAP) { + struct multiboot_mmap *map, *map_end; + + map = (void*) phystokv(boot_info.mmap_addr); + map_end = (void*) map + boot_info.mmap_count; + + while (map + 1 <= map_end) { + if (map->Type == MB_ARD_MEMORY) { + unsigned long long start = map->BaseAddr, end = map->BaseAddr + map->Length;; + + if (start >= 0x100000000ULL) { + printf("Ignoring %luMiB RAM region above 4GiB\n", (unsigned long) (map->Length >> 20)); + } else { + if (end >= 0x100000000ULL) { + printf("Truncating memory region to 4GiB\n"); + end = 0x0ffffffffU; + } + if (end > phys_last_addr) + phys_last_addr = end; + + printf("AT386 boot: physical memory map from 0x%lx to 0x%lx\n", + (unsigned long) start, + (unsigned long) end); + } + } + map = (void*) map + map->size + sizeof(map->size); + } + } else { + phys_last_kb = 0x400 + boot_info.mem_upper; + /* Avoid 4GiB overflow. */ + if (phys_last_kb < 0x400 || phys_last_kb >= 0x400000) { + printf("Truncating memory size to 4GiB\n"); + phys_last_addr = 0xffffffffU; + } else + phys_last_addr = phys_last_kb * 0x400; + } #endif /* MACH_HYP */ printf("AT386 boot: physical memory from 0x%lx to 0x%lx\n", @@ -292,7 +322,7 @@ mem_size_init(void) max_phys_size = VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS - VM_KERNEL_MAP_SIZE; if (phys_last_addr - phys_first_addr > max_phys_size) { phys_last_addr = phys_first_addr + max_phys_size; - printf("Truncating memory size to %luMiB\n", (phys_last_addr - phys_first_addr) / (1024 * 1024)); + printf("Truncating memory to %luMiB\n", (phys_last_addr - phys_first_addr) / (1024 * 1024)); /* TODO Xen: be nice, free lost memory */ } @@ -710,7 +740,56 @@ init_alloc_aligned(vm_size_t size, vm_offset_t *addrp) #ifndef MACH_HYP /* Skip past the I/O and ROM area. */ - if ((avail_next > (boot_info.mem_lower * 0x400)) && (addr < 0x100000)) + if (boot_info.flags & MULTIBOOT_MEM_MAP) + { + struct multiboot_mmap *map, *map_end, *current = NULL, *next = NULL; + unsigned long long minimum_next = ~0ULL; + + map = (void*) phystokv(boot_info.mmap_addr); + map_end = (void*) map + boot_info.mmap_count; + + /* Find both our current map, and the next one */ + while (map + 1 <= map_end) + { + if (map->Type == MB_ARD_MEMORY) + { + unsigned long long start = map->BaseAddr; + unsigned long long end = start + map->Length;; + + if (start <= addr && avail_next < end) + { + /* Ok, fits in the current map */ + current = map; + break; + } + else if (avail_next <= start && start < minimum_next) + { + /* This map is not far from avail_next */ + next = map; + minimum_next = start; + } + } + map = (void*) map + map->size + sizeof(map->size); + } + + if (!current) { + /* Area does not fit in the current map, switch to next + * map if any */ + if (!next || next->BaseAddr >= phys_last_addr) + { + /* No further reachable map, we have reached + * the end of memory, but possibly wrap around + * 16MiB. */ + avail_next = phys_last_addr; + goto retry; + } + + /* Start from next map */ + avail_next = next->BaseAddr; + goto retry; + } + } + else if ((avail_next > (boot_info.mem_lower * 0x400)) && (addr < 0x100000)) { avail_next = 0x100000; goto retry; diff --git a/i386/include/mach/i386/multiboot.h b/i386/include/mach/i386/multiboot.h index 7aa0b1c4..8f1c47b0 100644 --- a/i386/include/mach/i386/multiboot.h +++ b/i386/include/mach/i386/multiboot.h @@ -175,6 +175,16 @@ struct AddrRangeDesc /* unspecified optional padding... */ }; +struct multiboot_mmap +{ + unsigned long size; + unsigned long long BaseAddr; + unsigned long long Length; + unsigned long Type; + + /* unspecified optional padding... */ +}; + /* usable memory "Type", all others are reserved. */ #define MB_ARD_MEMORY 1 -- cgit v1.2.3 From 670ad9fd106bdb02ba2045198fcaf89960d3ec40 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Mon, 10 Jun 2013 01:33:34 +0200 Subject: Add missing 4KiB memory * i386/i386at/model_dep.c (init_alloc_aligned): Let allocated area last until end of memory map. --- i386/i386at/model_dep.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i386/i386at/model_dep.c b/i386/i386at/model_dep.c index 9c532431..d97f0850 100644 --- a/i386/i386at/model_dep.c +++ b/i386/i386at/model_dep.c @@ -756,7 +756,7 @@ init_alloc_aligned(vm_size_t size, vm_offset_t *addrp) unsigned long long start = map->BaseAddr; unsigned long long end = start + map->Length;; - if (start <= addr && avail_next < end) + if (start <= addr && avail_next <= end) { /* Ok, fits in the current map */ current = map; -- cgit v1.2.3 From eb2dc3e7ed87ef45dc2dafba22bbe7a3fd7ca388 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Mon, 24 Jun 2013 14:47:36 +0200 Subject: Fix printing ahci PCI dev and fun * linux/dev/drivers/block/ahci.c (ahci_probe_dev): Compute `dev' and `fun' earlier so they can be printed. --- linux/dev/drivers/block/ahci.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/linux/dev/drivers/block/ahci.c b/linux/dev/drivers/block/ahci.c index dbc8fdb6..ceded7c0 100644 --- a/linux/dev/drivers/block/ahci.c +++ b/linux/dev/drivers/block/ahci.c @@ -745,6 +745,9 @@ static void ahci_probe_dev(unsigned char bus, unsigned char device) unsigned bar; unsigned char irq; + dev = PCI_SLOT(device); + fun = PCI_FUNC(device); + /* Get configuration */ if (pcibios_read_config_byte(bus, device, PCI_HEADER_TYPE, &hdrtype) != PCIBIOS_SUCCESSFUL) { printk("ahci: %02u:%02u.%u: Can not read configuration", bus, dev, fun); @@ -771,8 +774,6 @@ static void ahci_probe_dev(unsigned char bus, unsigned char device) return; } - dev = PCI_SLOT(device); - fun = PCI_FUNC(device); printk("AHCI SATA %02u:%02u.%u BAR 0x%x IRQ %u\n", bus, dev, fun, bar, irq); /* Map mmio */ -- cgit v1.2.3 From f925d0efa2161aef215f858347a9036f1153c4b2 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Mon, 24 Jun 2013 15:02:09 +0200 Subject: Add partitioning reload support to ahci * linux/dev/drivers/block/ahci.c (port): Add `gd' field. (ahci_ioctl): New function. (ahci_fops): Fill `ioctl' field with `ahci_ioctl'. (ahci_probe_pci): Fill `gd' field with `gd'. --- linux/dev/drivers/block/ahci.c | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/linux/dev/drivers/block/ahci.c b/linux/dev/drivers/block/ahci.c index ceded7c0..2c573acb 100644 --- a/linux/dev/drivers/block/ahci.c +++ b/linux/dev/drivers/block/ahci.c @@ -248,6 +248,7 @@ static struct port { unsigned lba48; /* Whether LBA48 is supported */ unsigned identify; /* Whether we are just identifying at boot */ + struct gendisk *gd; } ports[MAX_PORTS]; @@ -471,6 +472,34 @@ static void ahci_interrupt (int irq, void *host, struct pt_regs *regs) /* unlock */ } +static int ahci_ioctl (struct inode *inode, struct file *file, + unsigned int cmd, unsigned long arg) +{ + int major, unit; + + if (!inode || !inode->i_rdev) + return -EINVAL; + + major = MAJOR(inode->i_rdev); + if (major != MAJOR_NR) + return -ENOTTY; + + unit = DEVICE_NR(inode->i_rdev); + if (unit >= MAX_PORTS) + return -EINVAL; + + switch (cmd) { + case BLKRRPART: + if (!suser()) return -EACCES; + if (!ports[unit].gd) + return -EINVAL; + resetup_one_dev(ports[unit].gd, unit); + return 0; + default: + return -EPERM; + } +} + static int ahci_open (struct inode *inode, struct file *file) { int target; @@ -504,7 +533,7 @@ static struct file_operations ahci_fops = { .write = block_write, .readdir = NULL, .select = NULL, - .ioctl = NULL, + .ioctl = ahci_ioctl, .mmap = NULL, .open = ahci_open, .release = ahci_release, @@ -875,8 +904,10 @@ void ahci_probe_pci(void) memset(gd->part, 0, nminors * sizeof(*gd->part)); - for (unit = 0; unit < nports; unit++) + for (unit = 0; unit < nports; unit++) { + ports[unit].gd = gd; ports[unit].part = &gd->part[unit << PARTN_BITS]; + } gd->major = MAJOR_NR; gd->major_name = "sd"; -- cgit v1.2.3 From 1dc6074b62f8141e9848bbaee7275e5752507e8f Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sat, 29 Jun 2013 20:35:13 +0200 Subject: Fix int/long discrepancy * device/net_io.c (bpf_match): Make the `keys' parameter a pointer to unsigned int instead of unsigned long. (bpf_do_filter): Make `A', `B' and `mem' unsigned ints instead of unsigned longs. Also turn long casts into int casts. --- device/net_io.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/device/net_io.c b/device/net_io.c index 4ebf9964..fd71c024 100644 --- a/device/net_io.c +++ b/device/net_io.c @@ -394,7 +394,7 @@ int net_add_q_info (ipc_port_t rcv_port); int bpf_match ( net_hash_header_t hash, int n_keys, - unsigned long *keys, + unsigned int *keys, net_hash_entry_t **hash_headpp, net_hash_entry_t *entpp); @@ -1636,9 +1636,9 @@ bpf_do_filter(infp, p, wirelen, header, hlen, hash_headpp, entpp) register bpf_insn_t pc, pc_end; register unsigned int buflen; - register unsigned long A, X; + register unsigned int A, X; register int k; - unsigned long mem[BPF_MEMWORDS]; + unsigned int mem[BPF_MEMWORDS]; /* Generic pointer to either HEADER or P according to the specified offset. */ char *data = NULL; @@ -1689,9 +1689,9 @@ bpf_do_filter(infp, p, wirelen, header, hlen, hash_headpp, entpp) k = pc->k; load_word: - if ((u_int)k + sizeof(long) <= hlen) + if ((u_int)k + sizeof(int) <= hlen) data = header; - else if ((u_int)k + sizeof(long) <= buflen) { + else if ((u_int)k + sizeof(int) <= buflen) { k -= hlen; data = p; } else @@ -1702,7 +1702,7 @@ bpf_do_filter(infp, p, wirelen, header, hlen, hash_headpp, entpp) A = EXTRACT_LONG(&data[k]); else #endif - A = ntohl(*(long *)(data + k)); + A = ntohl(*(int *)(data + k)); continue; case BPF_LD|BPF_H|BPF_ABS: @@ -2032,7 +2032,7 @@ int bpf_match (hash, n_keys, keys, hash_headpp, entpp) net_hash_header_t hash; register int n_keys; - register unsigned long *keys; + register unsigned int *keys; net_hash_entry_t **hash_headpp, *entpp; { register net_hash_entry_t head, entp; -- cgit v1.2.3 From 33e22a2836117f1a1098b821875b35c004a717bf Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sat, 29 Jun 2013 20:39:39 +0200 Subject: Add [nh]to[hn][ls] prototypes * device/net_io.h (ntohl, htonl, ntohs, htons): Add prototypes. --- device/net_io.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/device/net_io.h b/device/net_io.h index 073bdca7..5b3a55c6 100644 --- a/device/net_io.h +++ b/device/net_io.h @@ -83,4 +83,9 @@ extern void net_kmsg_collect (void); #define net_kmsg_alloc() ((ipc_kmsg_t) kalloc(net_kmsg_size)) #define net_kmsg_free(kmsg) kfree((vm_offset_t) (kmsg), net_kmsg_size) +extern unsigned int ntohl(unsigned int); +extern unsigned short int ntohs(unsigned short int); +extern unsigned int htonl(unsigned int); +extern unsigned short int htons(unsigned short int); + #endif /* _DEVICE_NET_IO_H_ */ -- cgit v1.2.3 From 3f4b14de254df3fe968fc54e1a3187f5cd8d5def Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sat, 29 Jun 2013 20:46:15 +0200 Subject: Add device_pager_setup prototype * device/ds_routines.h (device_pager_setup): Add prototype. --- device/ds_routines.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/device/ds_routines.h b/device/ds_routines.h index a00a12d5..c4333f48 100644 --- a/device/ds_routines.h +++ b/device/ds_routines.h @@ -58,4 +58,11 @@ boolean_t ds_write_done(io_req_t); void iowait (io_req_t ior); +kern_return_t device_pager_setup( + mach_device_t device, + int prot, + vm_offset_t offset, + vm_size_t size, + mach_port_t *pager); + #endif /* DS_ROUTINES_H */ -- cgit v1.2.3 From d43c5a56a6c181b7b4f8f85998c4b8bc18827777 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sat, 29 Jun 2013 21:12:53 +0200 Subject: (slab_info): fix format warnings * kern/slab.c (slab_info): Fix format for vm_size_t. --- kern/slab.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kern/slab.c b/kern/slab.c index 5c697cd8..47c2c8f9 100644 --- a/kern/slab.c +++ b/kern/slab.c @@ -1450,7 +1450,7 @@ void slab_info(void) mem_usage = (cache->nr_slabs * cache->slab_size) >> 10; mem_reclaimable = (cache->nr_free_slabs * cache->slab_size) >> 10; - printf("%-19s %6lu %3luk %4lu %6lu %6lu %7luk %10luk\n", + printf("%-19s %6lu %3luk %4lu %6lu %6lu %7uk %10uk\n", cache->name, cache->obj_size, cache->slab_size >> 10, cache->bufs_per_slab, cache->nr_objs, cache->nr_bufs, mem_usage, mem_reclaimable); -- cgit v1.2.3 From 69de4284334d34064b4b212734a2aab604acfe29 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 4 Jul 2013 23:12:21 +0200 Subject: ddb: fix implicit declarations * ddb/db_break.c: Include ddb/db_access.h. * ddb/db_examine.h (db_xcdump): Add prototype. * ddb/db_ext_symtab.c: Include vm/vm_user.h. * ddb/db_input.c: Include device/cons.h. * ddb/db_output.c: Likewise. --- ddb/db_break.c | 1 + ddb/db_examine.h | 6 ++++++ ddb/db_ext_symtab.c | 1 + ddb/db_input.c | 1 + ddb/db_output.c | 1 + 5 files changed, 10 insertions(+) diff --git a/ddb/db_break.c b/ddb/db_break.c index 9b1d6049..75253923 100644 --- a/ddb/db_break.c +++ b/ddb/db_break.c @@ -46,6 +46,7 @@ #include #include #include +#include #define NBREAKPOINTS 100 #define NTHREAD_LIST (NBREAKPOINTS*3) diff --git a/ddb/db_examine.h b/ddb/db_examine.h index 96ad7194..197f3973 100644 --- a/ddb/db_examine.h +++ b/ddb/db_examine.h @@ -43,4 +43,10 @@ extern void db_print_loc_and_inst ( db_addr_t loc, task_t task); +int db_xcdump( + db_addr_t addr, + int size, + int count, + task_t task); + #endif /* _DDB_DB_EXAMINE_H_ */ diff --git a/ddb/db_ext_symtab.c b/ddb/db_ext_symtab.c index 24342971..9831a01c 100644 --- a/ddb/db_ext_symtab.c +++ b/ddb/db_ext_symtab.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include diff --git a/ddb/db_input.c b/ddb/db_input.c index ce6a3103..6e7fa00b 100644 --- a/ddb/db_input.c +++ b/ddb/db_input.c @@ -32,6 +32,7 @@ #include #include +#include #include #include #include diff --git a/ddb/db_output.c b/ddb/db_output.c index 3ea2caac..ec73111a 100644 --- a/ddb/db_output.c +++ b/ddb/db_output.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include -- cgit v1.2.3 From 89701c6b02abcdfed54277ed5dd388d954621043 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 5 Jul 2013 00:13:52 +0200 Subject: ddb: use and cleanup db_print.h * ddb/db_command.c: Include db_print.h. Remove extern db_show_regs(). Remove extern db_show_one_task(). Remove extern db_show_port_id(). * ddb/db_print.c: Include db_print.h * ddb/db_print.h (db_show_all_acts): Remove prototype. (db_show_one_act): Likewise. (db_show_shuttle): Likewise. (db_show_one_task_vm): Likewise. (db_show_all_task_vm): Likewise. (db_show_one_space): Likewise. (db_show_all_spaces): Likewise. (db_sys): Likewise. (db_port_kmsg_count): Likewise. (db_show_one_simple_lock): Likewise. (db_show_one_mutex): Likewise. (db_show_subsystem): Likewise. (db_show_runq): Likewise. --- ddb/db_command.c | 4 ++-- ddb/db_print.c | 1 + ddb/db_print.h | 71 -------------------------------------------------------- 3 files changed, 3 insertions(+), 73 deletions(-) diff --git a/ddb/db_command.c b/ddb/db_command.c index 1593e866..bcc507d0 100644 --- a/ddb/db_command.c +++ b/ddb/db_command.c @@ -45,6 +45,7 @@ #include #include #include +#include #include #include @@ -301,14 +302,13 @@ db_command_list(last_cmdp, cmd_table) */ extern void db_listbreak_cmd(); extern void db_listwatch_cmd(); -extern void db_show_regs(), db_show_one_thread(), db_show_one_task(); +extern void db_show_one_thread(); extern void db_show_all_threads(); extern void db_show_macro(); extern void vm_map_print(), vm_object_print(), vm_page_print(); extern void vm_map_copy_print(); extern void ipc_port_print(), ipc_pset_print(), db_show_all_slocks(); extern void ipc_kmsg_print(), ipc_msg_print(); -extern void db_show_port_id(); void db_show_help(); struct db_command db_show_all_cmds[] = { diff --git a/ddb/db_print.c b/ddb/db_print.c index 5d0f150b..4692e4c4 100644 --- a/ddb/db_print.c +++ b/ddb/db_print.c @@ -51,6 +51,7 @@ #include #include #include +#include extern unsigned int db_maxoff; diff --git a/ddb/db_print.h b/ddb/db_print.h index 634c5be4..5f7a146d 100644 --- a/ddb/db_print.h +++ b/ddb/db_print.h @@ -20,91 +20,20 @@ void db_show_regs( db_expr_t count, char *modif); -void db_show_all_acts( - db_expr_t addr, - boolean_t have_addr, - db_expr_t count, - char * modif); - -void db_show_one_act( - db_expr_t addr, - boolean_t have_addr, - db_expr_t count, - char * modif); - void db_show_one_task( db_expr_t addr, boolean_t have_addr, db_expr_t count, char * modif); -void db_show_shuttle( - db_expr_t addr, - boolean_t have_addr, - db_expr_t count, - char * modif); - void db_show_port_id( db_expr_t addr, boolean_t have_addr, db_expr_t count, char * modif); -void db_show_one_task_vm( - db_expr_t addr, - boolean_t have_addr, - db_expr_t count, - char *modif); - -void db_show_all_task_vm( - db_expr_t addr, - boolean_t have_addr, - db_expr_t count, - char *modif); - -void db_show_one_space( - db_expr_t addr, - boolean_t have_addr, - db_expr_t count, - char * modif); - -void db_show_all_spaces( - db_expr_t addr, - boolean_t have_addr, - db_expr_t count, - char * modif); - -void db_sys(void); - -int db_port_kmsg_count( - ipc_port_t port); - db_addr_t db_task_from_space( ipc_space_t space, int *task_id); -void db_show_one_simple_lock( - db_expr_t addr, - boolean_t have_addr, - db_expr_t count, - char * modif); - -void db_show_one_mutex( - db_expr_t addr, - boolean_t have_addr, - db_expr_t count, - char * modif); - -void db_show_subsystem( - db_expr_t addr, - boolean_t have_addr, - db_expr_t count, - char * modif); - -void db_show_runq( - db_expr_t addr, - boolean_t have_addr, - db_expr_t count, - char * modif); - #endif /* !_DDB_DB_PRINT_H_ */ -- cgit v1.2.3 From 681d4080940819dc522e61369f199577c2819367 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sat, 6 Jul 2013 14:11:29 +0200 Subject: ddb: cleanup db_command.c * ddb/db_write_cmd.h: New file. (db_write_cmd): Add prototype. Include . Include . * ddb/db_break.h (db_listbreak_cmd): Add prototype. (db_delete_cmd): Likewise. (db_breakpoint_cmd): Likewise. * ddb/db_watch.h (db_listwatch_cmd): Likewise. (db_deletewatch_cmd): Likewise. (db_watchpoint_cmd): Likewise. * ddb/db_print.h (db_show_one_thread): Likewise. (db_show_all_threads): Likewise. * ddb/db_examine.h (db_print_cmd): Likewise. (db_examine_forward): Likewise. (db_examine_backward): Likewise. (db_search_cmd): Likewise. * ddb/db_variables.h (db_set_cmd): Likewise. * ddb/db_run.h (db_trace_until_call_cmd): Likewise. (db_trace_until_matching_cmd): Likewise. (db_continue_cmd): Likewise. * ddb/db_command.h (db_fncall): Likewise. * ddb/db_command.c: Include . Include . Include . Include . Include . Include . (db_listbreak_cmd): Remove prototype. (db_listwatch_cmd): Likewise. (db_show_one_thread): Likewise. (db_show_all_threads): Likewise. (db_show_macro): Likewise. (db_show_help): Likewise. (db_print_cmd): Likewise. (db_examine_cmd): Likewise. (db_set_cmd): Likewise. (db_examine_forward): Likewise. (db_examine_backward): Likewise. (db_search_cmd): Likewise. (db_write_cmd): Likewise. (db_delete_cmd): Likewise. (db_breakpoint_cmd): Likewise. (db_deletewatch_cmd): Likewise. (db_watchpoint_cmd): Likewise. (db_single_step_cmd): Likewise. (db_trace_until_call_cmd): Likewise. (db_trace_until_matching_cmd): Likewise. (db_continue_cmd): Likewise. (db_cond_cmd): Likewise. (db_help_cmd): Likewise. (db_def_macro_cmd): Likewise. (db_del_macro_cmd): Likewise. (db_fncall): Likewise. --- ddb/db_break.h | 10 ++++++++++ ddb/db_command.c | 37 +++++++------------------------------ ddb/db_command.h | 2 ++ ddb/db_examine.h | 16 ++++++++++++++++ ddb/db_print.h | 12 ++++++++++++ ddb/db_run.h | 18 ++++++++++++++++++ ddb/db_variables.h | 2 ++ ddb/db_watch.h | 14 ++++++++++++++ ddb/db_write_cmd.h | 16 ++++++++++++++++ 9 files changed, 97 insertions(+), 30 deletions(-) create mode 100644 ddb/db_write_cmd.h diff --git a/ddb/db_break.h b/ddb/db_break.h index 20d74d26..89e78894 100644 --- a/ddb/db_break.h +++ b/ddb/db_break.h @@ -88,4 +88,14 @@ extern db_breakpoint_t db_set_breakpoint(task_t task, db_addr_t addr, int count, thread_t thread, boolean_t task_bpt); +void db_listbreak_cmd(); + +void db_delete_cmd(); + +void db_breakpoint_cmd( + db_expr_t addr, + int have_addr, + db_expr_t count, + char * modif); + #endif /* _DDB_DB_BREAK_H_ */ diff --git a/ddb/db_command.c b/ddb/db_command.c index bcc507d0..c0321720 100644 --- a/ddb/db_command.c +++ b/ddb/db_command.c @@ -46,6 +46,12 @@ #include #include #include +#include +#include +#include +#include +#include +#include #include #include @@ -300,16 +306,10 @@ db_command_list(last_cmdp, cmd_table) /* * 'show' commands */ -extern void db_listbreak_cmd(); -extern void db_listwatch_cmd(); -extern void db_show_one_thread(); -extern void db_show_all_threads(); -extern void db_show_macro(); extern void vm_map_print(), vm_object_print(), vm_page_print(); extern void vm_map_copy_print(); extern void ipc_port_print(), ipc_pset_print(), db_show_all_slocks(); extern void ipc_kmsg_print(), ipc_msg_print(); -void db_show_help(); struct db_command db_show_all_cmds[] = { { "threads", db_show_all_threads, 0, 0 }, @@ -337,18 +337,7 @@ struct db_command db_show_cmds[] = { { (char *)0, } }; -extern void db_print_cmd(), db_examine_cmd(), db_set_cmd(); -extern void db_examine_forward(), db_examine_backward(); -extern void db_search_cmd(); -extern void db_write_cmd(); -extern void db_delete_cmd(), db_breakpoint_cmd(); -extern void db_deletewatch_cmd(), db_watchpoint_cmd(); -extern void db_single_step_cmd(), db_trace_until_call_cmd(), - db_trace_until_matching_cmd(), db_continue_cmd(); -extern void db_stack_trace_cmd(), db_cond_cmd(); -void db_help_cmd(); -void db_def_macro_cmd(), db_del_macro_cmd(); -void db_fncall(); +extern void db_stack_trace_cmd(); extern void db_reset_cpu(); struct db_command db_command_table[] = { @@ -404,18 +393,6 @@ struct db_command *ptr; struct db_command *db_last_command = 0; -void -db_help_cmd() -{ - struct db_command *cmd = db_command_table; - - while (cmd->name != 0) { - db_printf("%-12s", cmd->name); - db_end_line(); - cmd++; - } -} - int (*ddb_display)(); void diff --git a/ddb/db_command.h b/ddb/db_command.h index 1c0d106f..3ed1fb90 100644 --- a/ddb/db_command.h +++ b/ddb/db_command.h @@ -68,4 +68,6 @@ struct db_command { extern boolean_t db_exec_cmd_nest(char *cmd, int size); +void db_fncall(); + #endif /* MACH_KDB */ diff --git a/ddb/db_examine.h b/ddb/db_examine.h index 197f3973..e1fb1eee 100644 --- a/ddb/db_examine.h +++ b/ddb/db_examine.h @@ -39,6 +39,18 @@ extern void db_examine ( int count, task_t task); +void db_examine_forward( + db_expr_t addr, + int have_addr, + db_expr_t count, + char * modif); + +void db_examine_backward( + db_expr_t addr, + int have_addr, + db_expr_t count, + char * modif); + extern void db_print_loc_and_inst ( db_addr_t loc, task_t task); @@ -49,4 +61,8 @@ int db_xcdump( int count, task_t task); +void db_print_cmd(); + +void db_search_cmd(); + #endif /* _DDB_DB_EXAMINE_H_ */ diff --git a/ddb/db_print.h b/ddb/db_print.h index 5f7a146d..898014e8 100644 --- a/ddb/db_print.h +++ b/ddb/db_print.h @@ -32,6 +32,18 @@ void db_show_port_id( db_expr_t count, char * modif); +void db_show_one_thread( + db_expr_t addr, + int have_addr, + db_expr_t count, + char * modif); + +void db_show_all_threads( + db_expr_t addr, + int have_addr, + db_expr_t count, + char * modif); + db_addr_t db_task_from_space( ipc_space_t space, int *task_id); diff --git a/ddb/db_run.h b/ddb/db_run.h index 31c0e376..e138f604 100644 --- a/ddb/db_run.h +++ b/ddb/db_run.h @@ -47,4 +47,22 @@ extern void db_single_step_cmd( db_expr_t count, char *modif); +void db_trace_until_call_cmd( + db_expr_t addr, + int have_addr, + db_expr_t count, + char * modif); + +void db_trace_until_matching_cmd( + db_expr_t addr, + int have_addr, + db_expr_t count, + char * modif); + +void db_continue_cmd( + db_expr_t addr, + int have_addr, + db_expr_t count, + char * modif); + extern boolean_t db_in_single_step(void); diff --git a/ddb/db_variables.h b/ddb/db_variables.h index 5249d18c..af7068f5 100644 --- a/ddb/db_variables.h +++ b/ddb/db_variables.h @@ -80,4 +80,6 @@ extern struct db_variable *db_eregs; extern int db_get_variable(db_expr_t *valuep); +void db_set_cmd(); + #endif /* _DB_VARIABLES_H_ */ diff --git a/ddb/db_watch.h b/ddb/db_watch.h index a7acb39e..fb95ae53 100644 --- a/ddb/db_watch.h +++ b/ddb/db_watch.h @@ -57,6 +57,20 @@ extern void db_set_watchpoint(task_t task, db_addr_t addr, vm_size_t size); extern void db_delete_watchpoint(task_t task, db_addr_t addr); extern void db_list_watchpoints(void); +void db_listwatch_cmd(); + +void db_deletewatch_cmd( + db_expr_t addr, + int have_addr, + db_expr_t count, + char * modif); + +void db_watchpoint_cmd( + db_expr_t addr, + int have_addr, + db_expr_t count, + char * modif); + #endif /* _DDB_DB_WATCH_ */ #endif /* MACH_KDB */ diff --git a/ddb/db_write_cmd.h b/ddb/db_write_cmd.h new file mode 100644 index 00000000..74bac54c --- /dev/null +++ b/ddb/db_write_cmd.h @@ -0,0 +1,16 @@ +#ifndef _DDB_DB_WRITE_CMD_H_ +#define _DDB_DB_WRITE_CMD_H_ + +#include +#include + +/* Prototypes for functions exported by this module. + */ + +void db_write_cmd( + db_expr_t address, + boolean_t have_addr, + db_expr_t count, + char * modif); + +#endif /* !_DDB_DB_WRITE_CMD_H_ */ -- cgit v1.2.3 From 0fa7401d334a7771d5c064572083e389b695a54b Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 7 Jul 2013 19:09:23 +0200 Subject: Restore db_help_cmd * ddb/db_command.c (db_help_cmd): Restore function. --- ddb/db_command.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ddb/db_command.c b/ddb/db_command.c index c0321720..5e53b28e 100644 --- a/ddb/db_command.c +++ b/ddb/db_command.c @@ -337,6 +337,7 @@ struct db_command db_show_cmds[] = { { (char *)0, } }; +void db_help_cmd(); extern void db_stack_trace_cmd(); extern void db_reset_cpu(); @@ -393,6 +394,18 @@ struct db_command *ptr; struct db_command *db_last_command = 0; +void +db_help_cmd() +{ + struct db_command *cmd = db_command_table; + + while (cmd->name != 0) { + db_printf("%-12s", cmd->name); + db_end_line(); + cmd++; + } +} + int (*ddb_display)(); void -- cgit v1.2.3 From eb83a43f746c3acbaa908383cdc5822b073ac250 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sat, 6 Jul 2013 22:21:35 +0200 Subject: fix implicit declarations * ddb/db_trap.c: Include . * i386/i386/setjmp.h (_setjmp): Add prototype. --- ddb/db_trap.c | 1 + i386/i386/setjmp.h | 2 ++ 2 files changed, 3 insertions(+) diff --git a/ddb/db_trap.c b/ddb/db_trap.c index 395a9b51..8f59a367 100644 --- a/ddb/db_trap.c +++ b/ddb/db_trap.c @@ -35,6 +35,7 @@ */ #include #include +#include #include #include #include diff --git a/i386/i386/setjmp.h b/i386/i386/setjmp.h index 21c856dc..162217a3 100644 --- a/i386/i386/setjmp.h +++ b/i386/i386/setjmp.h @@ -33,4 +33,6 @@ typedef struct jmp_buf { int jmp_buf[6]; /* ebx, esi, edi, ebp, esp, eip */ } jmp_buf_t; +extern int _setjmp(jmp_buf_t*); + #endif /* _I386_SETJMP_H_ */ -- cgit v1.2.3 From 37a5965ed210cb0672ceae8292393a678a144415 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Wed, 10 Jul 2013 13:32:32 +0200 Subject: ddb: cleanup db_command.c * ddb/db_command.c (_longjmp): Remove prototype. (vm_map_print): Likewise. (vm_object_print): Likewise. (vm_page_print): Likewise. (vm_map_copy_print): Likewise. (ipc_port_print): Likewise. (ipc_pset_print): Likewise. (db_show_all_slocks): Likewise. (ipc_kmsg_print): Likewise. (ipc_msg_print): Likewise. Include . Include . Include . * i386/i386/setjmp.h [__GNUC__] (_longjmp): Add prototype. --- ddb/db_command.c | 16 +++------------- i386/i386/setjmp.h | 4 ++++ 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/ddb/db_command.c b/ddb/db_command.c index 5e53b28e..cb14da82 100644 --- a/ddb/db_command.c +++ b/ddb/db_command.c @@ -59,7 +59,9 @@ #include /* 4proto */ #include /* 4proto */ - +#include +#include +#include /* * Exported global variables @@ -303,14 +305,6 @@ db_command_list(last_cmdp, cmd_table) } while (db_read_token() == tSEMI_COLON && db_cmd_loop_done == 0); } -/* - * 'show' commands - */ -extern void vm_map_print(), vm_object_print(), vm_page_print(); -extern void vm_map_copy_print(); -extern void ipc_port_print(), ipc_pset_print(), db_show_all_slocks(); -extern void ipc_kmsg_print(), ipc_msg_print(); - struct db_command db_show_all_cmds[] = { { "threads", db_show_all_threads, 0, 0 }, { "slocks", db_show_all_slocks, 0, 0 }, @@ -463,10 +457,6 @@ db_exec_cmd_nest(cmd, size) return(db_cmd_loop_done == 0); } -#ifdef __GNUC__ -extern __volatile__ void _longjmp(); -#endif - void db_error(s) char *s; { diff --git a/i386/i386/setjmp.h b/i386/i386/setjmp.h index 162217a3..667eecfa 100644 --- a/i386/i386/setjmp.h +++ b/i386/i386/setjmp.h @@ -35,4 +35,8 @@ typedef struct jmp_buf { extern int _setjmp(jmp_buf_t*); +#ifdef __GNUC__ +extern __volatile__ void _longjmp(jmp_buf_t*, int); +#endif + #endif /* _I386_SETJMP_H_ */ -- cgit v1.2.3 From 91f9da20ad9da24c13b2b87b14752c865454744b Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Wed, 10 Jul 2013 12:42:08 +0200 Subject: vm: organize vm print function prototypes * vm/vm_print.h: New file. Include . Include . (vm_map_print): Add prototype. (vm_map_copy_print): Likewise. (vm_object_print): Likewise. (vm_page_print): Likewise. Include . Include * vm/vm_map.h (vm_map_print): Remove prototype. * vm/vm_map.c [MACH_KDB]: Include . * vm/vm_object.h (vm_object_print): Remove prototype. * vm/vm_object.c [MACH_KDB]: Include . * vm/vm_resident.c [MACH_KDB]: Include . --- vm/vm_map.c | 1 + vm/vm_map.h | 3 --- vm/vm_object.c | 1 + vm/vm_object.h | 2 -- vm/vm_print.h | 22 ++++++++++++++++++++++ vm/vm_resident.c | 1 + 6 files changed, 25 insertions(+), 5 deletions(-) create mode 100644 vm/vm_print.h diff --git a/vm/vm_map.c b/vm/vm_map.c index 47db118f..2be71471 100644 --- a/vm/vm_map.c +++ b/vm/vm_map.c @@ -55,6 +55,7 @@ #if MACH_KDB #include +#include #endif /* MACH_KDB */ diff --git a/vm/vm_map.h b/vm/vm_map.h index a15e681b..5fdac4e6 100644 --- a/vm/vm_map.h +++ b/vm/vm_map.h @@ -397,9 +397,6 @@ extern kern_return_t vm_map_protect(vm_map_t, vm_offset_t, vm_offset_t, extern kern_return_t vm_map_inherit(vm_map_t, vm_offset_t, vm_offset_t, vm_inherit_t); -/* Debugging: print a map */ -extern void vm_map_print(vm_map_t); - /* Look up an address */ extern kern_return_t vm_map_lookup(vm_map_t *, vm_offset_t, vm_prot_t, vm_map_version_t *, vm_object_t *, diff --git a/vm/vm_object.c b/vm/vm_object.c index d83c39fe..18a909f8 100644 --- a/vm/vm_object.c +++ b/vm/vm_object.c @@ -2969,6 +2969,7 @@ vm_object_page_map( #if MACH_KDB +#include #define printf kdbprintf boolean_t vm_object_print_pages = FALSE; diff --git a/vm/vm_object.h b/vm/vm_object.h index 4e4c9498..adeff657 100644 --- a/vm/vm_object.h +++ b/vm/vm_object.h @@ -233,8 +233,6 @@ extern void vm_object_page_map( vm_offset_t (*)(void *, vm_offset_t), void *); -extern void vm_object_print(vm_object_t); - extern vm_object_t vm_object_request_object(struct ipc_port *); extern boolean_t vm_object_coalesce( diff --git a/vm/vm_print.h b/vm/vm_print.h new file mode 100644 index 00000000..69a20ba3 --- /dev/null +++ b/vm/vm_print.h @@ -0,0 +1,22 @@ +#ifndef VM_PRINT_H +#define VM_PRINT_H + +#include +#include + +/* Debugging: print a map */ +extern void vm_map_print(vm_map_t); + +/* Pretty-print a copy object for ddb. */ +extern void vm_map_copy_print(vm_map_copy_t); + +#include + +extern void vm_object_print(vm_object_t); + +#include + +extern void vm_page_print(vm_page_t); + +#endif /* VM_PRINT_H */ + diff --git a/vm/vm_resident.c b/vm/vm_resident.c index d2edf5a2..7906b583 100644 --- a/vm/vm_resident.c +++ b/vm/vm_resident.c @@ -60,6 +60,7 @@ #if MACH_KDB #include +#include #endif /* MACH_KDB */ -- cgit v1.2.3 From 952932ffe39658a19034932ff8a714c52ce772a1 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Wed, 10 Jul 2013 13:14:27 +0200 Subject: ipc: organize ipc print function prototypes * ipc/ipc_print.h: New file. [MACH_KDB] Include . [MACH_KDB] Include . [MACH_KDB] Include . (ipc_port_print): Add prototype. (ipc_pset_print): Likewise. (ipc_kmsg_print): Likewise. (ipc_msg_print): Likewise. * ipc/ipc_port.h (ipc_port_print): Remove prototype. * ipc/ipc_port.c [MACH_KDB]: Include . * ipc/ipc_pset.h (ipc_pset_print): Remove prototype. * ipc/ipc_pset.c [MACH_KDB]: Include . * ipc/ipc_kmsg.c [MACH_KDB]: Include . --- ipc/ipc_kmsg.c | 1 + ipc/ipc_port.c | 1 + ipc/ipc_port.h | 3 --- ipc/ipc_print.h | 20 ++++++++++++++++++++ ipc/ipc_pset.c | 1 + ipc/ipc_pset.h | 3 --- 6 files changed, 23 insertions(+), 6 deletions(-) create mode 100644 ipc/ipc_print.h diff --git a/ipc/ipc_kmsg.c b/ipc/ipc_kmsg.c index c2689a48..3ad274d0 100644 --- a/ipc/ipc_kmsg.c +++ b/ipc/ipc_kmsg.c @@ -66,6 +66,7 @@ #if MACH_KDB #include +#include #endif extern int copyinmap(); diff --git a/ipc/ipc_port.c b/ipc/ipc_port.c index 8e41c3ca..b9607395 100644 --- a/ipc/ipc_port.c +++ b/ipc/ipc_port.c @@ -53,6 +53,7 @@ #if MACH_KDB #include +#include #endif /* MACH_KDB */ diff --git a/ipc/ipc_port.h b/ipc/ipc_port.h index 70ec4946..27d2e496 100644 --- a/ipc/ipc_port.h +++ b/ipc/ipc_port.h @@ -325,7 +325,4 @@ ipc_port_dealloc_special(ipc_port_t, ipc_space_t); #define ipc_port_release(port) \ ipc_object_release(&(port)->ip_object) -extern void -ipc_port_print(ipc_port_t); - #endif /* _IPC_IPC_PORT_H_ */ diff --git a/ipc/ipc_print.h b/ipc/ipc_print.h new file mode 100644 index 00000000..ef676a77 --- /dev/null +++ b/ipc/ipc_print.h @@ -0,0 +1,20 @@ +#ifndef _IPC_PRINT_H_ +#define _IPC_PRINT_H_ + +#if MACH_KDB + +#include +#include +#include + +extern void ipc_port_print(ipc_port_t); + +extern void ipc_pset_print(ipc_pset_t); + +extern void ipc_kmsg_print(ipc_kmsg_t); + +extern void ipc_msg_print(mach_msg_header_t*); + +#endif /* MACH_KDB */ + +#endif /* IPC_PRINT_H */ diff --git a/ipc/ipc_pset.c b/ipc/ipc_pset.c index e2b3c862..c016d276 100644 --- a/ipc/ipc_pset.c +++ b/ipc/ipc_pset.c @@ -48,6 +48,7 @@ #if MACH_KDB #include +#include #endif /* MACH_KDB */ diff --git a/ipc/ipc_pset.h b/ipc/ipc_pset.h index ac984f99..e9936fef 100644 --- a/ipc/ipc_pset.h +++ b/ipc/ipc_pset.h @@ -89,7 +89,4 @@ ipc_pset_destroy(ipc_pset_t); #define ipc_pset_release(pset) \ ipc_object_release(&(pset)->ips_object) -extern void -ipc_pset_print(ipc_pset_t); - #endif /* _IPC_IPC_PSET_H_ */ -- cgit v1.2.3 From 975ca903f548c2b6130aa6a3293aaab45f5481f8 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 18 Jul 2013 00:10:13 +0200 Subject: kern: add missing prototype * kern/lock.h (db_show_all_slocks): Add prototype. --- kern/lock.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kern/lock.h b/kern/lock.h index a8f2fd1c..4f38ea33 100644 --- a/kern/lock.h +++ b/kern/lock.h @@ -171,4 +171,6 @@ extern boolean_t lock_try_read_to_write(lock_t); extern void lock_set_recursive(lock_t); extern void lock_clear_recursive(lock_t); +void db_show_all_slocks(void); + #endif /* _KERN_LOCK_H_ */ -- cgit v1.2.3 From 790fe51dafa1d1423f3a990259a50a4ef3eee0f7 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Wed, 28 Aug 2013 22:47:58 +0200 Subject: Drop FXSR initialization message * i386/i386/fpu.c (init_fpu): Drop FXSR initialization message --- i386/i386/fpu.c | 1 - 1 file changed, 1 deletion(-) diff --git a/i386/i386/fpu.c b/i386/i386/fpu.c index 8efe9e80..d35e3eff 100644 --- a/i386/i386/fpu.c +++ b/i386/i386/fpu.c @@ -158,7 +158,6 @@ init_fpu() unsigned long mask; fp_kind = FP_387X; #ifndef MACH_RING1 - printf("Enabling FXSR\n"); set_cr4(get_cr4() | CR4_OSFXSR); #endif /* MACH_RING1 */ fxsave(&save); -- cgit v1.2.3 From ea3ec09ecc7c080ce7fac7da00f50f0062d511f3 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Mon, 9 Sep 2013 22:12:57 +0200 Subject: Drop luna88k bits * device/tty.h [luna88k]: Remove ifdef and include for nonexistent header files. * kern/debug.c: Remove check for luna88k. --- device/tty.h | 4 ---- kern/debug.c | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/device/tty.h b/device/tty.h index be287083..dcc77119 100644 --- a/device/tty.h +++ b/device/tty.h @@ -42,10 +42,6 @@ #include #include -#ifdef luna88k -#include -#endif - struct tty { decl_simple_lock_data(,t_lock) struct cirbuf t_inq; /* input buffer */ diff --git a/kern/debug.c b/kern/debug.c index 09c8ff48..7f6e5557 100644 --- a/kern/debug.c +++ b/kern/debug.c @@ -96,7 +96,7 @@ void SoftDebugger(message) asm("ta 0x81"); #endif /* sun4 */ -#if defined(mips ) || defined(luna88k) || defined(i860) || defined(alpha) +#if defined(mips ) || defined(i860) || defined(alpha) gimmeabreak(); #endif -- cgit v1.2.3 From 0ba288a09ab5b96f3c0e28f0a0367cc61d9019f2 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Mon, 9 Sep 2013 22:15:29 +0200 Subject: Drop useless forward declaration * device/chario.c (tty_flush): Remove forward declaration (prototype is in tty.h). --- device/chario.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/device/chario.c b/device/chario.c index d7c092e9..d0e93d20 100644 --- a/device/chario.c +++ b/device/chario.c @@ -68,11 +68,9 @@ short ttlowat[NSPEEDS] = void queue_delayed_reply( queue_t, io_req_t, boolean_t (*)(io_req_t)); void tty_output(struct tty *); -void tty_flush(struct tty *, int); boolean_t char_open_done(io_req_t); boolean_t char_read_done(io_req_t); boolean_t char_write_done(io_req_t); -void ttstart(struct tty *tp); /* * Fake 'line discipline' switch for the benefit of old code -- cgit v1.2.3 From ec5f066116c82872043e456e8e01ce715ccdc4e1 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Mon, 9 Sep 2013 22:16:51 +0200 Subject: Add const qualifiers. * device/chario.c (tty_inq_size, tty_outq_size): Qualify constants as const. --- device/chario.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/device/chario.c b/device/chario.c index d0e93d20..c65a4212 100644 --- a/device/chario.c +++ b/device/chario.c @@ -89,8 +89,8 @@ struct ldisc_switch linesw[] = { /* * Sizes for input and output circular buffers. */ -int tty_inq_size = 4096; /* big nuf */ -int tty_outq_size = 2048; /* Must be bigger that tthiwat */ +const int tty_inq_size = 4096; /* big nuf */ +const int tty_outq_size = 2048; /* Must be bigger that tthiwat */ int pdma_default = 1; /* turn pseudo dma on by default */ /* -- cgit v1.2.3 From 72997cf12a75919625bdd8fb80bb5f0f5f3b981b Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Mon, 9 Sep 2013 22:18:10 +0200 Subject: Remove register qualifiers * device/chario.c: Remove register qualifiers. --- device/chario.c | 72 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/device/chario.c b/device/chario.c index c65a4212..c40705e3 100644 --- a/device/chario.c +++ b/device/chario.c @@ -214,7 +214,7 @@ out: boolean_t char_open_done( io_req_t ior) { - register struct tty *tp = (struct tty *)ior->io_dev_ptr; + struct tty *tp = (struct tty *)ior->io_dev_ptr; spl_t s = spltty(); simple_lock(&tp->t_lock); @@ -254,12 +254,12 @@ boolean_t tty_close_open_reply( * device needs to run on master. */ io_return_t char_write( - register struct tty * tp, - register io_req_t ior) + struct tty * tp, + io_req_t ior) { spl_t s; - register int count; - register char *data; + int count; + char *data; vm_offset_t addr; io_return_t rc = D_SUCCESS; @@ -345,10 +345,10 @@ out: * May run on any CPU. */ boolean_t char_write_done( - register io_req_t ior) + io_req_t ior) { - register struct tty *tp = (struct tty *)ior->io_dev_ptr; - register spl_t s = spltty(); + struct tty *tp = (struct tty *)ior->io_dev_ptr; + spl_t s = spltty(); simple_lock(&tp->t_lock); if (tp->t_outq.c_cc > TTHIWAT(tp) || @@ -376,7 +376,7 @@ boolean_t char_write_done( } boolean_t tty_close_write_reply( - register io_req_t ior) + io_req_t ior) { ior->io_residual = ior->io_count; ior->io_error = D_DEVICE_DOWN; @@ -390,8 +390,8 @@ boolean_t tty_close_write_reply( * May run on any CPU - does not talk to device driver. */ io_return_t char_read( - register struct tty *tp, - register io_req_t ior) + struct tty *tp, + io_req_t ior) { spl_t s; kern_return_t rc; @@ -451,10 +451,10 @@ io_return_t char_read( * May run on any CPU - does not talk to device driver. */ boolean_t char_read_done( - register io_req_t ior) + io_req_t ior) { - register struct tty *tp = (struct tty *)ior->io_dev_ptr; - register spl_t s = spltty(); + struct tty *tp = (struct tty *)ior->io_dev_ptr; + spl_t s = spltty(); simple_lock(&tp->t_lock); @@ -483,7 +483,7 @@ boolean_t char_read_done( } boolean_t tty_close_read_reply( - register io_req_t ior) + io_req_t ior) { ior->io_residual = ior->io_count; ior->io_error = D_DEVICE_DOWN; @@ -497,9 +497,9 @@ boolean_t tty_close_read_reply( * Iff modem control should run on master. */ void ttyclose( - register struct tty *tp) + struct tty *tp) { - register io_req_t ior; + io_req_t ior; /* * Flush the read and write queues. Signal @@ -539,7 +539,7 @@ tty_queue_clean( ipc_port_t port, boolean_t (*routine)(io_req_t) ) { - register io_req_t ior; + io_req_t ior; ior = (io_req_t)queue_first(q); while (!queue_end(q, (queue_entry_t)ior)) { @@ -564,8 +564,8 @@ tty_portdeath( struct tty * tp, ipc_port_t port) { - register spl_t spl = spltty(); - register boolean_t result; + spl_t spl = spltty(); + boolean_t result; simple_lock(&tp->t_lock); @@ -596,7 +596,7 @@ tty_portdeath( * May run on any CPU. */ io_return_t tty_get_status( - register struct tty *tp, + struct tty *tp, dev_flavor_t flavor, int * data, /* pointer to OUT array */ natural_t *count) /* out */ @@ -606,7 +606,7 @@ io_return_t tty_get_status( switch (flavor) { case TTY_STATUS: { - register struct tty_status *tsp = + struct tty_status *tsp = (struct tty_status *) data; if (*count < TTY_STATUS_COUNT) @@ -642,7 +642,7 @@ io_return_t tty_get_status( * device needs to run on master. */ io_return_t tty_set_status( - register struct tty *tp, + struct tty *tp, dev_flavor_t flavor, int * data, natural_t count) @@ -652,7 +652,7 @@ io_return_t tty_set_status( switch (flavor) { case TTY_FLUSH: { - register int flags; + int flags; if (count < TTY_FLUSH_COUNT) return D_INVALID_OPERATION; @@ -695,7 +695,7 @@ io_return_t tty_set_status( case TTY_STATUS: /* set special characters and speed */ { - register struct tty_status *tsp; + struct tty_status *tsp; if (count < TTY_STATUS_COUNT) return D_INVALID_OPERATION; @@ -750,9 +750,9 @@ void queue_delayed_reply( * TTY containing queue must be locked (at spltty). */ void tty_queue_completion( - register queue_t qh) + queue_t qh) { - register io_req_t ior; + io_req_t ior; while ((ior = (io_req_t)dequeue_head(qh)) != 0) { iodone(ior); @@ -765,7 +765,7 @@ void tty_queue_completion( * we can initialize the queues here. */ void ttychars( - register struct tty *tp) + struct tty *tp) { if ((tp->t_flags & TS_INIT) == 0) { /* @@ -802,7 +802,7 @@ void ttychars( * device needs to run on master. */ void tty_flush( - register struct tty *tp, + struct tty *tp, int rw) { if (rw & D_READ) { @@ -825,9 +825,9 @@ void tty_flush( * What if device runs on a different CPU? */ void ttrstrt( - register struct tty *tp) + struct tty *tp) { - register spl_t s; + spl_t s; s = spltty(); simple_lock(&tp->t_lock); @@ -849,7 +849,7 @@ void ttrstrt( * Must be on master CPU if device runs on master. */ void ttstart(tp) - register struct tty *tp; + struct tty *tp; { if ((tp->t_state & (TS_TIMEOUT|TS_TTSTOP|TS_BUSY)) == 0) { /* @@ -873,7 +873,7 @@ void ttstart(tp) * Must be on master CPU if device runs on master. */ void tty_output( - register struct tty *tp) + struct tty *tp) { if ((tp->t_state & (TS_TIMEOUT|TS_TTSTOP|TS_BUSY)) == 0) { /* @@ -895,9 +895,9 @@ void tty_output( void ttypush( void * _tp) { - register struct tty *tp = _tp; + struct tty *tp = _tp; spl_t s = spltty(); - register int state; + int state; simple_lock(&tp->t_lock); @@ -983,7 +983,7 @@ void ttyinput( * into the future, but this involves making a timeout/untimeout * call on every character. */ - register int ptime = pdma_timeouts[tp->t_ispeed]; + int ptime = pdma_timeouts[tp->t_ispeed]; if (ptime > 0) { if ((tp->t_state & TS_MIN_TO) == 0) -- cgit v1.2.3 From 67f3956f39046e6d284c8479dc096f297a271dad Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Wed, 11 Sep 2013 12:27:47 +0200 Subject: drop unused CONSMAJOR CONSMAJOR is never used. I'm guessing that in the past it was a part of some problematic code. I don't see a reason to keep it's definition. * device/cons.h (CONSMAJOR): Remove definition. --- device/cons.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/device/cons.h b/device/cons.h index 6a0ae850..8ac796cd 100644 --- a/device/cons.h +++ b/device/cons.h @@ -41,9 +41,6 @@ struct consdev { #define CN_INTERNAL 2 /* "internal" bit-mapped display */ #define CN_REMOTE 3 /* serial interface with remote bit set */ -/* XXX */ -#define CONSMAJOR 0 - #define CONSBUFSIZE 1024 #ifdef KERNEL -- cgit v1.2.3 From cbe805c2122b8b46b1fbe7c6b1d8f69cd22fb901 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Wed, 11 Sep 2013 12:27:48 +0200 Subject: track the console buffer usage with a boolean instead of an int A variable that keeps track of the console buffer usage should never receive values other than 0 and 1, so constrain it's value range to boolean. Plus, it's more readable this way. * device/cons.c (consbufused): Use boolean_t instead of an int. --- device/cons.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/device/cons.c b/device/cons.c index f26f22c5..a2207239 100644 --- a/device/cons.c +++ b/device/cons.c @@ -54,7 +54,7 @@ void (*romputc)() = 0; */ static char consbuf[CONSBUFSIZE] = { 0 }; static char *consbp = consbuf; -static int consbufused = 0; +static boolean_t consbufused = FALSE; #endif void @@ -106,7 +106,7 @@ cninit() if (++cbp == &consbuf[CONSBUFSIZE]) cbp = consbuf; } while (cbp != consbp); - consbufused = 0; + consbufused = FALSE; } #endif cn_inited = 1; @@ -171,9 +171,9 @@ cnputc(c) } #if CONSBUFSIZE > 0 else { - if (consbufused == 0) { + if (consbufused == FALSE) { consbp = consbuf; - consbufused = 1; + consbufused = TRUE; memset(consbuf, 0, CONSBUFSIZE); } *consbp++ = c; -- cgit v1.2.3 From 14a6257ed1dca3a037003f40706eeda7f5a2bbda Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Wed, 11 Sep 2013 12:27:49 +0200 Subject: track the console init with a boolean instead of an int A variable that keeps track if the console init has been called. It should never receive values other than 0 and 1, so constrain it's possible range of values to a boolean. * device/cons.c (cn_inited): Use boolean_t instead of an int. --- device/cons.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/device/cons.c b/device/cons.c index a2207239..ceba7f24 100644 --- a/device/cons.c +++ b/device/cons.c @@ -32,7 +32,7 @@ #include #endif -static int cn_inited = 0; +static boolean_t cn_inited = FALSE; static struct consdev *cn_tab = 0; /* physical console device info */ /* @@ -109,7 +109,7 @@ cninit() consbufused = FALSE; } #endif - cn_inited = 1; + cn_inited = TRUE; return; } /* -- cgit v1.2.3 From 44ed1ef5cd5dad9764e1ab262e905c29cfa1f7a5 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Tue, 10 Sep 2013 10:38:05 +0200 Subject: remove register qualifiers. * device/cirbuf.c: Remove register qualifiers. --- device/cirbuf.c | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/device/cirbuf.c b/device/cirbuf.c index 4fe2d896..7af2d7ad 100644 --- a/device/cirbuf.c +++ b/device/cirbuf.c @@ -46,7 +46,7 @@ int cb_check_enable = 0; #define CB_CHECK(cb) if (cb_check_enable) cb_check(cb) void -cb_check(register struct cirbuf *cb) +cb_check(struct cirbuf *cb) { if (!(cb->c_cf >= cb->c_start && cb->c_cf < cb->c_end)) panic("cf %x out of range [%x..%x)", @@ -78,9 +78,9 @@ cb_check(register struct cirbuf *cb) */ int putc( int c, - register struct cirbuf *cb) + struct cirbuf *cb) { - register char *ow, *nw; + char *ow, *nw; ow = cb->c_cl; nw = ow+1; @@ -101,10 +101,10 @@ int putc( /* * Get one character from circular buffer. */ -int getc(register struct cirbuf *cb) +int getc(struct cirbuf *cb) { - register unsigned char *nr; - register int c; + unsigned char *nr; + int c; nr = (unsigned char *)cb->c_cf; if (nr == (unsigned char *)cb->c_cl) { @@ -129,12 +129,12 @@ int getc(register struct cirbuf *cb) * Return number moved. */ int -q_to_b( register struct cirbuf *cb, - register char *cp, - register int count) +q_to_b( struct cirbuf *cb, + char *cp, + int count) { - char * ocp = cp; - register int i; + char *ocp = cp; + int i; while (count != 0) { if (cb->c_cl == cb->c_cf) @@ -165,12 +165,12 @@ q_to_b( register struct cirbuf *cb, * NOT entered. */ int -b_to_q( register char * cp, +b_to_q( char *cp, int count, - register struct cirbuf *cb) + struct cirbuf *cb) { - register int i; - register char *lim; + int i; + char *lim; while (count != 0) { lim = cb->c_cf - 1; @@ -205,10 +205,10 @@ b_to_q( register char * cp, * that matches the mask. */ int -ndqb( register struct cirbuf *cb, - register int mask) +ndqb( struct cirbuf *cb, + int mask) { - register char *cp, *lim; + char *cp, *lim; if (cb->c_cl < cb->c_cf) lim = cb->c_end; @@ -229,10 +229,10 @@ ndqb( register struct cirbuf *cb, * Flush characters from circular buffer. */ void -ndflush(register struct cirbuf *cb, - register int count) +ndflush(struct cirbuf *cb, + int count) { - register int i; + int i; while (count != 0) { if (cb->c_cl == cb->c_cf) @@ -269,10 +269,10 @@ void cb_clear(struct cirbuf *cb) */ void cb_alloc( - register struct cirbuf *cb, + struct cirbuf *cb, int buf_size) { - register char *buf; + char *buf; buf = (char *)kalloc(buf_size); @@ -290,7 +290,7 @@ cb_alloc( * Free character space for a circular buffer. */ void -cb_free(register struct cirbuf *cb) +cb_free(struct cirbuf *cb) { int size; -- cgit v1.2.3 From 09fe2f14c301cbb9e7ac838b6668f1ff4cb8b479 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 13 Sep 2013 00:27:47 +0200 Subject: remove register qualifiers * device/dev_lookup.c: Remove register qualifiers. --- device/dev_lookup.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/device/dev_lookup.c b/device/dev_lookup.c index 98a2d02c..e156d1a8 100644 --- a/device/dev_lookup.c +++ b/device/dev_lookup.c @@ -70,9 +70,9 @@ struct kmem_cache dev_hdr_cache; */ void dev_number_enter(device) - register mach_device_t device; + mach_device_t device; { - register queue_t q; + queue_t q; q = &dev_number_hash_table[DEV_NUMBER_HASH(device->dev_number)]; queue_enter(q, device, mach_device_t, number_chain); @@ -84,9 +84,9 @@ dev_number_enter(device) */ void dev_number_remove(device) - register mach_device_t device; + mach_device_t device; { - register queue_t q; + queue_t q; q = &dev_number_hash_table[DEV_NUMBER_HASH(device->dev_number)]; queue_remove(q, device, mach_device_t, number_chain); @@ -101,8 +101,8 @@ dev_number_lookup(ops, devnum) dev_ops_t ops; int devnum; { - register queue_t q; - register mach_device_t device; + queue_t q; + mach_device_t device; q = &dev_number_hash_table[DEV_NUMBER_HASH(devnum)]; queue_iterate(q, device, mach_device_t, number_chain) { @@ -124,8 +124,8 @@ device_lookup(name) { dev_ops_t dev_ops; int dev_minor; - register mach_device_t device; - register mach_device_t new_device; + mach_device_t device; + mach_device_t new_device; /* * Get the device and unit number from the name. @@ -198,7 +198,7 @@ device_lookup(name) */ void mach_device_reference(device) - register mach_device_t device; + mach_device_t device; { simple_lock(&device->ref_lock); device->ref_count++; @@ -211,7 +211,7 @@ mach_device_reference(device) */ void mach_device_deallocate(device) - register mach_device_t device; + mach_device_t device; { simple_lock(&device->ref_lock); if (--device->ref_count > 0) { @@ -250,7 +250,7 @@ decl_simple_lock_data(, */ void dev_port_enter(device) - register mach_device_t device; + mach_device_t device; { mach_device_reference(device); @@ -269,7 +269,7 @@ dev_port_enter(device) */ void dev_port_remove(device) - register mach_device_t device; + mach_device_t device; { ipc_kobject_set(device->port, IKO_NULL, IKOT_NONE); mach_device_deallocate(device); @@ -283,7 +283,7 @@ device_t dev_port_lookup(port) ipc_port_t port; { - register device_t device; + device_t device; if (!IP_VALID(port)) return (DEVICE_NULL); @@ -307,7 +307,7 @@ dev_port_lookup(port) */ ipc_port_t convert_device_to_port(device) - register device_t device; + device_t device; { if (device == DEVICE_NULL) return IP_NULL; @@ -326,9 +326,9 @@ dev_map(routine, port) boolean_t (*routine)(); mach_port_t port; { - register int i; - register queue_t q; - register mach_device_t dev, prev_dev; + int i; + queue_t q; + mach_device_t dev, prev_dev; for (i = 0, q = &dev_number_hash_table[0]; i < NDEVHASH; @@ -367,7 +367,7 @@ dev_map(routine, port) void dev_lookup_init() { - register int i; + int i; simple_lock_init(&dev_number_lock); -- cgit v1.2.3 From 2442268ad5b0bd3d5b014c2723d4d91706d8c24a Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 13 Sep 2013 00:27:48 +0200 Subject: remove definition of NDEVICES NDEVICES is never used. Judging by the position and the comments it was once used in initialization, but it's not anymore. I think it's safe to remove it. * device/dev_lookup.c (NDEVICES): Remove definition. --- device/dev_lookup.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/device/dev_lookup.c b/device/dev_lookup.c index e156d1a8..01317b9b 100644 --- a/device/dev_lookup.c +++ b/device/dev_lookup.c @@ -362,8 +362,6 @@ dev_map(routine, port) /* * Initialization */ -#define NDEVICES 256 - void dev_lookup_init() { -- cgit v1.2.3 From c129b44be2e942674087f05238fcff55a4efdbcc Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 13 Sep 2013 13:31:51 +0200 Subject: remove register qualifiers * device/dev_name.c: Remove register qualifiers. --- device/dev_name.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/device/dev_name.c b/device/dev_name.c index cef1efd5..98a0e278 100644 --- a/device/dev_name.c +++ b/device/dev_name.c @@ -65,9 +65,9 @@ nomap() */ boolean_t name_equal(src, len, target) - register char * src; - register int len; - register char * target; + char * src; + int len; + char * target; { while (--len >= 0) if (*src++ != *target++) @@ -95,12 +95,12 @@ boolean_t dev_name_lookup(name, ops, unit) * is a letter in [a-h] (disks only?) */ - register char * cp = name; + char * cp = name; int len; - register int j = 0; - register int c; + int j = 0; + int c; dev_ops_t dev; - register boolean_t found; + boolean_t found; int slice_num=0; @@ -136,7 +136,7 @@ boolean_t dev_name_lookup(name, ops, unit) } if (!found) { /* name not found - try indirection list */ - register dev_indirect_t di; + dev_indirect_t di; dev_indirect_search(di) { if (name_equal(name, len, di->d_name)) { @@ -202,7 +202,7 @@ dev_set_indirection(name, ops, unit) dev_ops_t ops; int unit; { - register dev_indirect_t di; + dev_indirect_t di; dev_indirect_search(di) { if (!strcmp(di->d_name, name)) { -- cgit v1.2.3 From 9b1f22d5318181a9d8a1ed2b0351f783baf3cd42 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 13 Sep 2013 13:31:52 +0200 Subject: small style changes for consistency * device/dev_name: Changes in coding style. --- device/dev_name.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/device/dev_name.c b/device/dev_name.c index 98a0e278..bf541df4 100644 --- a/device/dev_name.c +++ b/device/dev_name.c @@ -65,9 +65,9 @@ nomap() */ boolean_t name_equal(src, len, target) - char * src; + char *src; int len; - char * target; + char *target; { while (--len >= 0) if (*src++ != *target++) @@ -79,7 +79,7 @@ name_equal(src, len, target) * device name lookup */ boolean_t dev_name_lookup(name, ops, unit) - char * name; + char *name; dev_ops_t *ops; /* out */ int *unit; /* out */ { @@ -95,14 +95,14 @@ boolean_t dev_name_lookup(name, ops, unit) * is a letter in [a-h] (disks only?) */ - char * cp = name; + char *cp = name; int len; int j = 0; int c; dev_ops_t dev; boolean_t found; - int slice_num=0; + int slice_num = 0; #if 0 printf("lookup on name %s\n",name); @@ -214,8 +214,9 @@ dev_set_indirection(name, ops, unit) } boolean_t dev_change_indirect(iname, dname, unit) -char *iname,*dname; -int unit; + char *iname; + char *dname; + int unit; { struct dev_ops *dp; struct dev_indirect *di; -- cgit v1.2.3 From deb4207e2f4d1cab2f59318e22e70964ab1f42a4 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 13 Sep 2013 13:31:54 +0200 Subject: another small change in style for consistency * device/dev_name.c: Change in coding style. --- device/dev_name.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/device/dev_name.c b/device/dev_name.c index bf541df4..f970cf68 100644 --- a/device/dev_name.c +++ b/device/dev_name.c @@ -167,7 +167,7 @@ boolean_t dev_name_lookup(name, ops, unit) *unit *= j; /* find slice ? */ - if (c=='s') { + if (c == 's') { cp++; while ((c = *cp) != '\0' && c >= '0' && c <= '9') { @@ -176,7 +176,7 @@ boolean_t dev_name_lookup(name, ops, unit) } } - *unit += (slice_num <<4); + *unit += (slice_num << 4); /* if slice==0, it is either compatability or whole device */ if (c >= 'a' && c < 'a' + j) { /* note: w/o this -> whole slice */ -- cgit v1.2.3 From 51eb43efdaa323eca92b47be2b0b4ecec07bedb5 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 13 Sep 2013 13:31:55 +0200 Subject: remove preprocessor comments The first one is a message that name lookup has been called, which I think is safe to remove, or maybe add #if DEBUG. Second one is a alternate calculation that I doubt it will ever be used, so I think it's safe to remove it. * device/dev_name.c: Remove preprocessor comments. --- device/dev_name.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/device/dev_name.c b/device/dev_name.c index f970cf68..b560b0a6 100644 --- a/device/dev_name.c +++ b/device/dev_name.c @@ -104,10 +104,6 @@ boolean_t dev_name_lookup(name, ops, unit) int slice_num = 0; -#if 0 - printf("lookup on name %s\n",name); -#endif /* 0 */ - /* * Find device type name (characters before digit) */ @@ -184,9 +180,6 @@ boolean_t dev_name_lookup(name, ops, unit) * Minor number is *unit + letter. * NOW it is slice result + letter */ -#if 0 - *unit = *unit * j + (c - 'a' +1); /* +1 to start 'a' at 1 */ -#endif /* 0 */ *unit += (c - 'a' +1); } } -- cgit v1.2.3 From 29837925f757278c80cda79daf16e241d53dfde0 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 13 Sep 2013 13:31:56 +0200 Subject: use boolean_t instead of an int Variable 'found' already receives values TRUE and FALSE, so why not make it a boolean. * device/dev_name.c: Use boolean_t instead of an int. --- device/dev_name.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/device/dev_name.c b/device/dev_name.c index b560b0a6..24d08850 100644 --- a/device/dev_name.c +++ b/device/dev_name.c @@ -213,7 +213,7 @@ boolean_t dev_change_indirect(iname, dname, unit) { struct dev_ops *dp; struct dev_indirect *di; - int found = FALSE; + boolean_t found = FALSE; dev_search(dp) { if (!strcmp(dp->d_name,dname)) { -- cgit v1.2.3 From 0cf57acc9729b7a8b697d9da140cafe3d1919697 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 13 Sep 2013 13:31:57 +0200 Subject: another small change in style for consistency * device/dev_name.c: Change in coding style. --- device/dev_name.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/device/dev_name.c b/device/dev_name.c index 24d08850..de9e360b 100644 --- a/device/dev_name.c +++ b/device/dev_name.c @@ -216,14 +216,14 @@ boolean_t dev_change_indirect(iname, dname, unit) boolean_t found = FALSE; dev_search(dp) { - if (!strcmp(dp->d_name,dname)) { + if (!strcmp(dp->d_name, dname)) { found = TRUE; break; } } if (!found) return FALSE; dev_indirect_search(di) { - if (!strcmp(di->d_name,iname)) { + if (!strcmp(di->d_name, iname)) { di->d_ops = dp; di->d_unit = unit; return TRUE; -- cgit v1.2.3 From 3c680426e1e5e07837b8dd988ee7b6e2eb94e989 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Tue, 17 Sep 2013 04:44:46 +0200 Subject: remove register qualifiers * device/dev_pager.c: Remove register qualifiers. --- device/dev_pager.c | 58 +++++++++++++++++++++++++++--------------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/device/dev_pager.c b/device/dev_pager.c index e0ca2c76..7f498057 100644 --- a/device/dev_pager.c +++ b/device/dev_pager.c @@ -127,14 +127,14 @@ typedef struct dev_pager *dev_pager_t; struct kmem_cache dev_pager_cache; -void dev_pager_reference(register dev_pager_t ds) +void dev_pager_reference(dev_pager_t ds) { simple_lock(&ds->lock); ds->ref_count++; simple_unlock(&ds->lock); } -void dev_pager_deallocate(register dev_pager_t ds) +void dev_pager_deallocate(dev_pager_t ds) { simple_lock(&ds->lock); if (--ds->ref_count > 0) { @@ -169,8 +169,8 @@ decl_simple_lock_data(, void dev_pager_hash_init(void) { - register int i; - register vm_size_t size; + int i; + vm_size_t size; size = sizeof(struct dev_pager_entry); kmem_cache_init(&dev_pager_hash_cache, "dev_pager_entry", size, 0, @@ -184,7 +184,7 @@ void dev_pager_hash_insert( ipc_port_t name_port, dev_pager_t rec) { - register dev_pager_entry_t new_entry; + dev_pager_entry_t new_entry; new_entry = (dev_pager_entry_t) kmem_cache_alloc(&dev_pager_hash_cache); new_entry->name = name_port; @@ -198,8 +198,8 @@ void dev_pager_hash_insert( void dev_pager_hash_delete(ipc_port_t name_port) { - register queue_t bucket; - register dev_pager_entry_t entry; + queue_t bucket; + dev_pager_entry_t entry; bucket = &dev_pager_hashtable[dev_pager_hash(name_port)]; @@ -219,9 +219,9 @@ void dev_pager_hash_delete(ipc_port_t name_port) dev_pager_t dev_pager_hash_lookup(ipc_port_t name_port) { - register queue_t bucket; - register dev_pager_entry_t entry; - register dev_pager_t pager; + queue_t bucket; + dev_pager_entry_t entry; + dev_pager_t pager; bucket = &dev_pager_hashtable[dev_pager_hash(name_port)]; @@ -247,7 +247,7 @@ kern_return_t device_pager_setup( vm_size_t size, mach_port_t *pager) { - register dev_pager_t d; + dev_pager_t d; /* * Verify the device is indeed mappable @@ -329,7 +329,7 @@ kern_return_t device_pager_data_request( vm_size_t length, vm_prot_t protection_required) { - register dev_pager_t ds; + dev_pager_t ds; #ifdef lint protection_required++; @@ -347,7 +347,7 @@ kern_return_t device_pager_data_request( panic("(device_pager)data_request: bad pager_request"); if (ds->type == CHAR_PAGER_TYPE) { - register vm_object_t object; + vm_object_t object; vm_offset_t device_map_page(void *,vm_offset_t); object = vm_object_lookup(pager_request); @@ -366,8 +366,8 @@ kern_return_t device_pager_data_request( vm_object_deallocate(object); } else { - register io_req_t ior; - register mach_device_t device; + io_req_t ior; + mach_device_t device; io_return_t result; panic("(device_pager)data_request: dev pager"); @@ -415,7 +415,7 @@ kern_return_t device_pager_data_request( /* * Always called by io_done thread. */ -boolean_t device_pager_data_request_done(register io_req_t ior) +boolean_t device_pager_data_request_done(io_req_t ior) { vm_offset_t start_alloc, end_alloc; vm_size_t size_read; @@ -469,13 +469,13 @@ boolean_t device_pager_data_request_done(register io_req_t ior) kern_return_t device_pager_data_write( ipc_port_t pager, ipc_port_t pager_request, - register vm_offset_t offset, - register pointer_t addr, + vm_offset_t offset, + pointer_t addr, vm_size_t data_count) { - register dev_pager_t ds; - register mach_device_t device; - register io_req_t ior; + dev_pager_t ds; + mach_device_t device; + io_req_t ior; kern_return_t result; panic("(device_pager)data_write: called"); @@ -524,7 +524,7 @@ kern_return_t device_pager_data_write( } boolean_t device_pager_data_write_done(ior) - register io_req_t ior; + io_req_t ior; { device_write_dealloc(ior); mach_device_deallocate(ior->io_device); @@ -535,8 +535,8 @@ boolean_t device_pager_data_write_done(ior) kern_return_t device_pager_copy( ipc_port_t pager, ipc_port_t pager_request, - register vm_offset_t offset, - register vm_size_t length, + vm_offset_t offset, + vm_size_t length, ipc_port_t new_pager) { panic("(device_pager)copy: called"); @@ -559,7 +559,7 @@ device_pager_data_return( ipc_port_t pager, ipc_port_t pager_request, vm_offset_t offset, - register pointer_t addr, + pointer_t addr, vm_size_t data_cnt, boolean_t dirty, boolean_t kernel_copy) @@ -586,7 +586,7 @@ vm_offset_t device_map_page( void *dsp, vm_offset_t offset) { - register dev_pager_t ds = (dev_pager_t) dsp; + dev_pager_t ds = (dev_pager_t) dsp; return pmap_phys_address( (*(ds->device->dev_ops->d_mmap)) @@ -599,7 +599,7 @@ kern_return_t device_pager_init_pager( ipc_port_t pager_name, vm_size_t pager_page_size) { - register dev_pager_t ds; + dev_pager_t ds; if (device_pager_debug) printf("(device_pager)init: pager=%p, request=%p, name=%p\n", @@ -649,7 +649,7 @@ kern_return_t device_pager_terminate( ipc_port_t pager_request, ipc_port_t pager_name) { - register dev_pager_t ds; + dev_pager_t ds; assert(IP_VALID(pager_request)); assert(IP_VALID(pager_name)); @@ -717,7 +717,7 @@ kern_return_t device_pager_lock_completed( void device_pager_init(void) { - register vm_size_t size; + vm_size_t size; /* * Initialize cache of paging structures. -- cgit v1.2.3 From 933a6b5db9a1823668ba17d496423c74c4c2bee8 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sat, 21 Sep 2013 16:10:26 +0200 Subject: Coding style trivial fixes --- device/dev_pager.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/device/dev_pager.c b/device/dev_pager.c index 7f498057..2c33d02c 100644 --- a/device/dev_pager.c +++ b/device/dev_pager.c @@ -348,7 +348,7 @@ kern_return_t device_pager_data_request( if (ds->type == CHAR_PAGER_TYPE) { vm_object_t object; - vm_offset_t device_map_page(void *,vm_offset_t); + vm_offset_t device_map_page(void *, vm_offset_t); object = vm_object_lookup(pager_request); if (object == VM_OBJECT_NULL) { @@ -424,7 +424,7 @@ boolean_t device_pager_data_request_done(io_req_t ior) size_read = ior->io_count; if (ior->io_residual) { if (device_pager_debug) - printf("(device_pager)data_request_done: r: 0x%lx\n",ior->io_residual); + printf("(device_pager)data_request_done: r: 0x%lx\n", ior->io_residual); memset((&ior->io_data[ior->io_count - ior->io_residual]), 0, (unsigned) ior->io_residual); } -- cgit v1.2.3 From 8a4a549aa44df339f31042d4200d874e897bce8d Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Tue, 17 Sep 2013 04:44:48 +0200 Subject: remove lint code * device/dev_pager.c [lint]: Remove ifdefs and associated code. --- device/dev_pager.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/device/dev_pager.c b/device/dev_pager.c index 2c33d02c..1a60045c 100644 --- a/device/dev_pager.c +++ b/device/dev_pager.c @@ -331,10 +331,6 @@ kern_return_t device_pager_data_request( { dev_pager_t ds; -#ifdef lint - protection_required++; -#endif /* lint */ - if (device_pager_debug) printf("(device_pager)data_request: pager=%p, offset=0x%lx, length=0x%x\n", pager, offset, length); @@ -693,10 +689,6 @@ kern_return_t device_pager_data_unlock( vm_size_t length, vm_prot_t desired_access) { -#ifdef lint - memory_object++; memory_control_port++; offset++; length++; desired_access++; -#endif /* lint */ - panic("(device_pager)data_unlock: called"); return (KERN_FAILURE); } @@ -707,10 +699,6 @@ kern_return_t device_pager_lock_completed( vm_offset_t offset, vm_size_t length) { -#ifdef lint - memory_object++; pager_request_port++; offset++; length++; -#endif /* lint */ - panic("(device_pager)lock_completed: called"); return (KERN_FAILURE); } -- cgit v1.2.3 From 4a728608cb8430d1404dce33357cab13c4befc68 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Tue, 17 Sep 2013 19:35:02 +0200 Subject: remove register qualifiers * device/ds_routines.c: Remove register qualifiers. --- device/ds_routines.c | 65 ++++++++++++++++++++++++++-------------------------- 1 file changed, 32 insertions(+), 33 deletions(-) diff --git a/device/ds_routines.c b/device/ds_routines.c index 68589dee..73571dce 100644 --- a/device/ds_routines.c +++ b/device/ds_routines.c @@ -424,9 +424,9 @@ device_open(reply_port, reply_port_type, mode, name, device_p) char * name; device_t *device_p; /* out */ { - register mach_device_t device; - register kern_return_t result; - register io_req_t ior; + mach_device_t device; + kern_return_t result; + io_req_t ior; ipc_port_t notify; /* @@ -538,10 +538,10 @@ device_open(reply_port, reply_port_type, mode, name, device_p) boolean_t ds_open_done(ior) - register io_req_t ior; + io_req_t ior; { kern_return_t result; - register mach_device_t device; + mach_device_t device; device = ior->io_device; result = ior->io_error; @@ -598,7 +598,7 @@ ds_open_done(ior) static io_return_t device_close(device) - register mach_device_t device; + mach_device_t device; { device_lock(device); @@ -671,8 +671,8 @@ device_write(device, reply_port, reply_port_type, mode, recnum, unsigned int data_count; int *bytes_written; /* out */ { - register io_req_t ior; - register io_return_t result; + io_req_t ior; + io_return_t result; if (device->state != DEV_STATE_OPEN) return (D_NO_SUCH_DEVICE); @@ -762,8 +762,8 @@ device_write_inband(device, reply_port, reply_port_type, mode, recnum, unsigned int data_count; int *bytes_written; /* out */ { - register io_req_t ior; - register io_return_t result; + io_req_t ior; + io_return_t result; if (device->state != DEV_STATE_OPEN) return (D_NO_SUCH_DEVICE); @@ -825,12 +825,12 @@ device_write_inband(device, reply_port, reply_port_type, mode, recnum, */ kern_return_t device_write_get(ior, wait) - register io_req_t ior; + io_req_t ior; boolean_t *wait; { vm_map_copy_t io_copy; vm_offset_t new_addr; - register kern_return_t result; + kern_return_t result; int bsize; vm_size_t min_size; @@ -920,10 +920,9 @@ device_write_get(ior, wait) */ boolean_t device_write_dealloc(ior) - register io_req_t ior; + io_req_t ior; { vm_map_copy_t new_copy = VM_MAP_COPY_NULL; - register vm_map_copy_t io_copy; kern_return_t result; vm_offset_t size_to_do; @@ -971,7 +970,7 @@ device_write_dealloc(ior) } if (result == KERN_SUCCESS && new_copy != VM_MAP_COPY_NULL) { - register int res; + int res; /* * We have a new continuation, reset the ior to @@ -1022,15 +1021,15 @@ device_write_dealloc(ior) */ boolean_t ds_write_done(ior) - register io_req_t ior; + io_req_t ior; { /* * device_write_dealloc discards the data that has been * written, but may decide that there is more to write. */ while (!device_write_dealloc(ior)) { - register io_return_t result; - register mach_device_t device; + io_return_t result; + mach_device_t device; /* * More IO to do -- invoke it. @@ -1078,8 +1077,8 @@ device_read(device, reply_port, reply_port_type, mode, recnum, io_buf_ptr_t *data; /* out */ unsigned int *data_count; /* out */ { - register io_req_t ior; - register io_return_t result; + io_req_t ior; + io_return_t result; #ifdef lint *data = *data; @@ -1160,8 +1159,8 @@ device_read_inband(device, reply_port, reply_port_type, mode, recnum, char *data; /* pointer to OUT array */ unsigned int *data_count; /* out */ { - register io_req_t ior; - register io_return_t result; + io_req_t ior; + io_return_t result; #ifdef lint *data = *data; @@ -1233,8 +1232,8 @@ device_read_inband(device, reply_port, reply_port_type, mode, recnum, * Allocate wired-down memory for device read. */ kern_return_t device_read_alloc(ior, size) - register io_req_t ior; - register vm_size_t size; + io_req_t ior; + vm_size_t size; { vm_offset_t addr; kern_return_t kr; @@ -1266,7 +1265,7 @@ boolean_t ds_read_done(ior) { vm_offset_t start_data, end_data; vm_offset_t start_sent, end_sent; - register vm_size_t size_read; + vm_size_t size_read; if (ior->io_error) size_read = 0; @@ -1296,8 +1295,8 @@ boolean_t ds_read_done(ior) * may think that they are clean. */ { - register vm_offset_t touch; - register int c; + vm_offset_t touch; + int c; for (touch = start_sent; touch < end_sent; touch += PAGE_SIZE) { c = *(volatile char *)touch; @@ -1341,7 +1340,7 @@ boolean_t ds_read_done(ior) if (ior->io_alloc_size > 0) kmem_cache_free(&io_inband_cache, (vm_offset_t)ior->io_data); } else { - register vm_offset_t end_alloc; + vm_offset_t end_alloc; end_alloc = start_sent + round_page(ior->io_alloc_size); if (end_alloc > end_sent) @@ -1460,9 +1459,9 @@ decl_simple_lock_data(, io_done_list_lock) #define splio splsched /* XXX must block ALL io devices */ void iodone(ior) - register io_req_t ior; + io_req_t ior; { - register spl_t s; + spl_t s; /* * If this ior was loaned to us, return it directly. @@ -1496,8 +1495,8 @@ void iodone(ior) void io_done_thread_continue() { for (;;) { - register spl_t s; - register io_req_t ior; + spl_t s; + io_req_t ior; #if defined (LINUX_DEV) && defined (CONFIG_INET) free_skbuffs (); @@ -1642,7 +1641,7 @@ ds_trap_req_alloc(mach_device_t device, vm_size_t data_size) boolean_t ds_trap_write_done(io_req_t ior) { - register mach_device_t dev; + mach_device_t dev; dev = ior->io_device; -- cgit v1.2.3 From 364aca401a5643267bdf895aa4ce48f1b14f9d9f Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Tue, 17 Sep 2013 19:35:04 +0200 Subject: remove lint code * device/ds_routines.c [lint]: Remove ifdefs and associated code. --- device/ds_routines.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/device/ds_routines.c b/device/ds_routines.c index 73571dce..028e700b 100644 --- a/device/ds_routines.c +++ b/device/ds_routines.c @@ -1080,11 +1080,6 @@ device_read(device, reply_port, reply_port_type, mode, recnum, io_req_t ior; io_return_t result; -#ifdef lint - *data = *data; - *data_count = *data_count; -#endif /* lint */ - if (device->state != DEV_STATE_OPEN) return (D_NO_SUCH_DEVICE); @@ -1162,11 +1157,6 @@ device_read_inband(device, reply_port, reply_port_type, mode, recnum, io_req_t ior; io_return_t result; -#ifdef lint - *data = *data; - *data_count = *data_count; -#endif /* lint */ - if (device->state != DEV_STATE_OPEN) return (D_NO_SUCH_DEVICE); @@ -1426,9 +1416,6 @@ device_map(device, protection, offset, size, pager, unmap) ipc_port_t *pager; /* out */ boolean_t unmap; /* ? */ { -#ifdef lint - unmap = unmap; -#endif /* lint */ if (protection & ~VM_PROT_ALL) return (KERN_INVALID_ARGUMENT); -- cgit v1.2.3 From ec3bce94d9540442f47176858bdde1251f8768cc Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Tue, 17 Sep 2013 19:35:05 +0200 Subject: add comments after endifs * device/ds_routines.c [CONFIG_PCMCIA, CONFIG_INET, LINUX_DEV, MACH_HYP]: Add comments after endifs. --- device/ds_routines.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/device/ds_routines.c b/device/ds_routines.c index 028e700b..ee575e5b 100644 --- a/device/ds_routines.c +++ b/device/ds_routines.c @@ -102,13 +102,13 @@ extern struct device_emulation_ops linux_net_emulation_ops; extern void free_skbuffs (); #ifdef CONFIG_PCMCIA extern struct device_emulation_ops linux_pcmcia_emulation_ops; -#endif -#endif -#endif +#endif /* CONFIG_PCMCIA */ +#endif /* CONFIG_INET */ +#endif /* LINUX_DEV */ #ifdef MACH_HYP extern struct device_emulation_ops hyp_block_emulation_ops; extern struct device_emulation_ops hyp_net_emulation_ops; -#endif +#endif /* MACH_HYP */ extern struct device_emulation_ops mach_device_emulation_ops; /* List of emulations. */ @@ -120,13 +120,13 @@ static struct device_emulation_ops *emulation_list[] = &linux_net_emulation_ops, #ifdef CONFIG_PCMCIA &linux_pcmcia_emulation_ops, -#endif -#endif -#endif +#endif /* CONFIG_PCMCIA */ +#endif /* CONFIG_INET */ +#endif /* LINUX_DEV */ #ifdef MACH_HYP &hyp_block_emulation_ops, &hyp_net_emulation_ops, -#endif +#endif /* MACH_HYP */ &mach_device_emulation_ops, }; -- cgit v1.2.3 From a6304541efd15e04646eff9a173ea7a292f13887 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Tue, 17 Sep 2013 05:59:55 +0200 Subject: device: remove unused file dk_label.c * device/dk_label.c: Remove file. --- device/dk_label.c | 99 ------------------------------------------------------- 1 file changed, 99 deletions(-) delete mode 100644 device/dk_label.c diff --git a/device/dk_label.c b/device/dk_label.c deleted file mode 100644 index c7d459bd..00000000 --- a/device/dk_label.c +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1993,1991,1990 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - */ -/* - * File: rz_disk.c - * Author: Alessandro Forin, Carnegie Mellon University - * Date: 10/90 - * - */ - -#include -#include -#include -#include -#include - -/* Checksum a disk label */ -unsigned -dkcksum(lp) - struct disklabel *lp; -{ - register unsigned short *start, *end, sum = 0; - - start = (unsigned short *)lp; - end = (unsigned short*)&lp->d_partitions[lp->d_npartitions]; - while (start < end) sum ^= *start++; - return sum; -} - -/* Perform some checks and then copy a disk label */ -setdisklabel(lp, nlp) - struct disklabel *lp, *nlp; -{ - if (nlp->d_magic != DISKMAGIC || nlp->d_magic2 != DISKMAGIC || - (dkcksum(nlp) != 0)) - return D_INVALID_OPERATION; - *lp = *nlp; - return D_SUCCESS; -} - -dkgetlabel(lp, flavor, data, count) - struct disklabel *lp; - int flavor; - int * data; /* pointer to OUT array */ - unsigned int *count; /* OUT */ -{ - - switch (flavor) { - /* get */ - case DIOCGDINFO: - *(struct disklabel *)data = *lp; - *count = sizeof(struct disklabel)/sizeof(int); - break; - case DIOCGDINFO - (0x10<<16): - *(struct disklabel *)data = *lp; - *count = sizeof(struct disklabel)/sizeof(int) - 4; - break; - } -} - -print_bsd_label(lp, str) -struct disklabel *lp; -char *str; -{ -int i; - printf("%s sectors %d, tracks %d, cylinders %d\n", - str, lp->d_nsectors, lp->d_ntracks, lp->d_ncylinders); - printf("%s secpercyl %d, secperunit %d, npartitions %d\n", - str, lp->d_secpercyl, lp->d_secperunit, lp->d_npartitions); - - for (i = 0; i < lp->d_npartitions; i++) { - printf("%s %c: size = %d, offset = %d\n", - str, 'a'+i, - lp->d_partitions[i].p_size, - lp->d_partitions[i].p_offset); - } -} -- cgit v1.2.3 From 31c3142b83c7c9ce1cab98c5edf1e5743dfa20db Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Tue, 24 Sep 2013 23:23:23 +0200 Subject: Drop Invariant, Front-Cover and Back-Cover references The referenced Invariant sections does not exist, and the front and back covers do not hold much information. --- doc/mach.texi | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/doc/mach.texi b/doc/mach.texi index 5bfff237..9ad9e70b 100644 --- a/doc/mach.texi +++ b/doc/mach.texi @@ -38,22 +38,10 @@ Foundation, Inc. @quotation Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or -any later version published by the Free Software Foundation; with the -Invariant Sections being ``Free Software Needs Free Documentation'' and -``GNU Lesser General Public License'', the Front-Cover texts being (a) -(see below), and with the Back-Cover Texts being (b) (see below). A -copy of the license is included in the section entitled ``GNU Free -Documentation License''. - -(a) The FSF's Front-Cover Text is: - - A GNU Manual - -(b) The FSF's Back-Cover Text is: - - You have freedom to copy and modify this GNU Manual, like GNU - software. Copies published by the Free Software Foundation raise - funds for GNU development. +any later version published by the Free Software Foundation; with no +Invariant Section, with no Front-Cover Texts, and with no Back-Cover +Texts. A copy of the license is included in the section entitled +``GNU Free Documentation License''. This work is based on manual pages under the following copyright and license: -- cgit v1.2.3 From 471e5b080f7790c2cf95e3069d9fed1173c9ec17 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Thu, 26 Sep 2013 01:28:45 +0200 Subject: Update README * README: Update default drivers notice. Mention cross-compilation flags for 64bit systems. --- README | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/README b/README index dcedb7ee..4e5e9dcf 100644 --- a/README +++ b/README @@ -17,14 +17,9 @@ The interface generator `MiG' is no longer part of this distribution. Generic installation instructions may be found in the file INSTALL. -By default, you get a kernel with no device drivers for disks and -network devices. This is not what you want! Examine the file -`README-Drivers' in the directory for the machine type your kernel is -on (e.g., `i386/README-Drivers') for a list of configure --enable -switches. Give the appropriate set for your hardware. It is -generally safe to specify switches for hardware you don't have; in -this way you can build kernels that work on different physical machine -set ups. +By default, you get a kernel with no device drivers for network devices, +because the Hurd has its own drivers running in userland. Drivers for +IDE and AHCI disks are however included by default. If you want the in-kernel debugger compiled in, specify --enable-kdb to configure. This is only useful if you actually anticipate @@ -36,6 +31,17 @@ The specific switches you give to configure are always recorded in the file `config.status'. So you can always tell what options you used to build a particular kernel. +The gnumach kernel can be cross-built. No specific options need +to be given when building from a 32bit x86 ELF userland such as +Linux. When running on a 64bit x86 ELF userland, one has to specify +cross-compilation variables, typically: + +export CPP='gcc -m32 -E -x c -undef -ansi' +export CC='gcc -m32' +export LD='ld -melf_i386' + +and give the --host=i686-unknown-gnu option to ./configure + Bug reports relating to this distribution should be sent to bug-hurd@gnu.org. Requests for assistance should be made on help-hurd@gnu.org. -- cgit v1.2.3 From 9fbbb4de17883a6b148a6dd098c726bef01a5c1b Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Thu, 26 Sep 2013 01:31:36 +0200 Subject: Really update README * README: Network drivers are actually enabled by default. --- README | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README b/README index 4e5e9dcf..95a58a56 100644 --- a/README +++ b/README @@ -17,9 +17,8 @@ The interface generator `MiG' is no longer part of this distribution. Generic installation instructions may be found in the file INSTALL. -By default, you get a kernel with no device drivers for network devices, -because the Hurd has its own drivers running in userland. Drivers for -IDE and AHCI disks are however included by default. +By default, most drivers for network boards are included, as well as +drivers for IDE, SCSI and AHCI disks. If you want the in-kernel debugger compiled in, specify --enable-kdb to configure. This is only useful if you actually anticipate -- cgit v1.2.3 From 7958fdaae2f342a6ffe4c54ebc8c1b76bf80b490 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Thu, 26 Sep 2013 02:24:35 +0200 Subject: Fix gpl.texi build texinfo does not support @heading/@center in the middle of an enumerate. * doc/gpl.texi: Move "NO WARRANTY" to item heading. --- doc/gpl.texi | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/doc/gpl.texi b/doc/gpl.texi index 1a4dfcb3..c1f025e7 100644 --- a/doc/gpl.texi +++ b/doc/gpl.texi @@ -283,15 +283,8 @@ make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. -@iftex -@heading NO WARRANTY -@end iftex -@ifinfo -@center NO WARRANTY +@item NO WARRANTY -@end ifinfo - -@item BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -- cgit v1.2.3 From 2166b4cd592c64bb3ea44406b57b7d426d89654b Mon Sep 17 00:00:00 2001 From: Svante Signell Date: Fri, 27 Sep 2013 17:11:40 +0200 Subject: Fix typo * README: Fix typo. --- README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README b/README index 95a58a56..9d332044 100644 --- a/README +++ b/README @@ -22,7 +22,7 @@ drivers for IDE, SCSI and AHCI disks. If you want the in-kernel debugger compiled in, specify --enable-kdb to configure. This is only useful if you actually anticipate -debugging the kernel, of course. We don't turn it on be default +debugging the kernel, of course. We don't turn it on by default because it adds considerably to the unpageable memory footprint of the kernel. -- cgit v1.2.3 From 0069c83fadda450442e4681d3b821c60ad491337 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Fri, 27 Sep 2013 16:20:46 +0200 Subject: * README: Simplify build instructions. Follow-up to commit 471e5b080f7790c2cf95e3069d9fed1173c9ec17. --- README | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/README b/README index 95a58a56..38d2ccab 100644 --- a/README +++ b/README @@ -26,20 +26,12 @@ debugging the kernel, of course. We don't turn it on be default because it adds considerably to the unpageable memory footprint of the kernel. -The specific switches you give to configure are always recorded in the -file `config.status'. So you can always tell what options you used to -build a particular kernel. +GNU Mach can be cross-built. No specific options need to be given when +building on a 32-bit x86 ELF userland such as GNU/Linux. Manually switch the +compiler to 32-bit mode when using a 64-bit x86 (x86_64) ELF toolchain: -The gnumach kernel can be cross-built. No specific options need -to be given when building from a 32bit x86 ELF userland such as -Linux. When running on a 64bit x86 ELF userland, one has to specify -cross-compilation variables, typically: + $ [...]/configure --host=i686-gnu CC='gcc -m32' LD='ld -melf_i386' -export CPP='gcc -m32 -E -x c -undef -ansi' -export CC='gcc -m32' -export LD='ld -melf_i386' - -and give the --host=i686-unknown-gnu option to ./configure Bug reports relating to this distribution should be sent to bug-hurd@gnu.org. Requests for assistance should be made on -- cgit v1.2.3 From 1b773f28b1c108391b02c714ab345c56dc03ebae Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Fri, 27 Sep 2013 16:00:59 +0200 Subject: dist-hook extensibility. * Makefile.am (dist-hook): Rename to... (dist-rm-CVS): ... this new target. (dist-hook): Depend on it. --- Makefile.am | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Makefile.am b/Makefile.am index 319b7e80..5f02b4de 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,6 +1,6 @@ # Makefile for GNU Mach. -# Copyright (C) 2006, 2007, 2008, 2009 Free Software Foundation, Inc. +# Copyright (C) 2006, 2007, 2008, 2009, 2013 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the @@ -196,7 +196,10 @@ EXTRA_DIST += \ EXTRA_DIST += \ DEVELOPMENT -dist-hook: +dist-hook: dist-rm-CVS + +.PHONY: dist-rm-CVS +dist-rm-CVS: # Try to be very safe with respect to spuriously removing various directories # in case of an error. find $(distdir)/ -type d -name CVS | while read d; do \ -- cgit v1.2.3 From a379640997753a1a84e667ef9f993f95b25c2ca9 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Fri, 27 Sep 2013 16:03:38 +0200 Subject: Generate ChangeLog files for distributions. * gitlog-to-changelog: New file; import from gnulib's 9fc81090f6c5590bd1b0e0fa5087577a2ee43a3e:build-aux/gitlog-to-changelog. * Makefile.am (gen-ChangeLog): New target. (dist-hook): Depend on it. --- Makefile.am | 20 ++- gitlog-to-changelog | 432 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 451 insertions(+), 1 deletion(-) create mode 100755 gitlog-to-changelog diff --git a/Makefile.am b/Makefile.am index 5f02b4de..918cdc39 100644 --- a/Makefile.am +++ b/Makefile.am @@ -196,7 +196,7 @@ EXTRA_DIST += \ EXTRA_DIST += \ DEVELOPMENT -dist-hook: dist-rm-CVS +dist-hook: dist-rm-CVS gen-ChangeLog .PHONY: dist-rm-CVS dist-rm-CVS: @@ -207,6 +207,24 @@ dist-rm-CVS: rmdir "$$d"; \ done +gen_start_commit = e227045b06d62ee7d2fbab9d5ade9030ff43170b +ChangeLog_files = ChangeLog ChangeLog.0 ChangeLog.00 +.PHONY: gen-ChangeLog +gen-ChangeLog: + $(AM_V_GEN)if test -d $(top_srcdir)/.git; then \ + (cd $(top_srcdir)/ && \ + ./gitlog-to-changelog --strip-tab \ + $(gen_start_commit).. && \ + echo) >> $(distdir)/cl-t && \ + for f in $(ChangeLog_files); do \ + (cd $(top_srcdir)/ && \ + git show $(gen_start_commit):$$f) >> $(distdir)/cl-t && \ + rm -f $(distdir)/$$f && \ + mv $(distdir)/cl-t $(distdir)/$$f \ + || exit $$?; \ + done; \ + fi + DISTCLEANFILES += \ Makefile.orig \ config.status.orig diff --git a/gitlog-to-changelog b/gitlog-to-changelog new file mode 100755 index 00000000..e02d34c2 --- /dev/null +++ b/gitlog-to-changelog @@ -0,0 +1,432 @@ +eval '(exit $?0)' && eval 'exec perl -wS "$0" ${1+"$@"}' + & eval 'exec perl -wS "$0" $argv:q' + if 0; +# Convert git log output to ChangeLog format. + +my $VERSION = '2012-07-29 06:11'; # UTC +# The definition above must lie within the first 8 lines in order +# for the Emacs time-stamp write hook (at end) to update it. +# If you change this file with Emacs, please let the write hook +# do its job. Otherwise, update this string manually. + +# Copyright (C) 2008-2013 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Written by Jim Meyering + +use strict; +use warnings; +use Getopt::Long; +use POSIX qw(strftime); + +(my $ME = $0) =~ s|.*/||; + +# use File::Coda; # http://meyering.net/code/Coda/ +END { + defined fileno STDOUT or return; + close STDOUT and return; + warn "$ME: failed to close standard output: $!\n"; + $? ||= 1; +} + +sub usage ($) +{ + my ($exit_code) = @_; + my $STREAM = ($exit_code == 0 ? *STDOUT : *STDERR); + if ($exit_code != 0) + { + print $STREAM "Try '$ME --help' for more information.\n"; + } + else + { + print $STREAM < ChangeLog + $ME -- -n 5 foo > last-5-commits-to-branch-foo + +SPECIAL SYNTAX: + +The following types of strings are interpreted specially when they appear +at the beginning of a log message line. They are not copied to the output. + + Copyright-paperwork-exempt: Yes + Append the "(tiny change)" notation to the usual "date name email" + ChangeLog header to mark a change that does not require a copyright + assignment. + Co-authored-by: Joe User + List the specified name and email address on a second + ChangeLog header, denoting a co-author. + Signed-off-by: Joe User + These lines are simply elided. + +In a FILE specified via --amend, comment lines (starting with "#") are ignored. +FILE must consist of pairs where SHA is a 40-byte SHA1 (alone on +a line) referring to a commit in the current project, and CODE refers to one +or more consecutive lines of Perl code. Pairs must be separated by one or +more blank line. + +Here is sample input for use with --amend=FILE, from coreutils: + +3a169f4c5d9159283548178668d2fae6fced3030 +# fix typo in title: +s/all tile types/all file types/ + +1379ed974f1fa39b12e2ffab18b3f7a607082202 +# Due to a bug in vc-dwim, I mis-attributed a patch by Paul to myself. +# Change the author to be Paul. Note the escaped "@": +s,Jim .*>,Paul Eggert , + +EOF + } + exit $exit_code; +} + +# If the string $S is a well-behaved file name, simply return it. +# If it contains white space, quotes, etc., quote it, and return the new string. +sub shell_quote($) +{ + my ($s) = @_; + if ($s =~ m![^\w+/.,-]!) + { + # Convert each single quote to '\'' + $s =~ s/\'/\'\\\'\'/g; + # Then single quote the string. + $s = "'$s'"; + } + return $s; +} + +sub quoted_cmd(@) +{ + return join (' ', map {shell_quote $_} @_); +} + +# Parse file F. +# Comment lines (starting with "#") are ignored. +# F must consist of pairs where SHA is a 40-byte SHA1 +# (alone on a line) referring to a commit in the current project, and +# CODE refers to one or more consecutive lines of Perl code. +# Pairs must be separated by one or more blank line. +sub parse_amend_file($) +{ + my ($f) = @_; + + open F, '<', $f + or die "$ME: $f: failed to open for reading: $!\n"; + + my $fail; + my $h = {}; + my $in_code = 0; + my $sha; + while (defined (my $line = )) + { + $line =~ /^\#/ + and next; + chomp $line; + $line eq '' + and $in_code = 0, next; + + if (!$in_code) + { + $line =~ /^([0-9a-fA-F]{40})$/ + or (warn "$ME: $f:$.: invalid line; expected an SHA1\n"), + $fail = 1, next; + $sha = lc $1; + $in_code = 1; + exists $h->{$sha} + and (warn "$ME: $f:$.: duplicate SHA1\n"), + $fail = 1, next; + } + else + { + $h->{$sha} ||= ''; + $h->{$sha} .= "$line\n"; + } + } + close F; + + $fail + and exit 1; + + return $h; +} + +# git_dir_option $SRCDIR +# +# From $SRCDIR, the --git-dir option to pass to git (none if $SRCDIR +# is undef). Return as a list (0 or 1 element). +sub git_dir_option($) +{ + my ($srcdir) = @_; + my @res = (); + if (defined $srcdir) + { + my $qdir = shell_quote $srcdir; + my $cmd = "cd $qdir && git rev-parse --show-toplevel"; + my $qcmd = shell_quote $cmd; + my $git_dir = qx($cmd); + defined $git_dir + or die "$ME: cannot run $qcmd: $!\n"; + $? == 0 + or die "$ME: $qcmd had unexpected exit code or signal ($?)\n"; + chomp $git_dir; + push @res, "--git-dir=$git_dir/.git"; + } + @res; +} + +{ + my $since_date; + my $format_string = '%s%n%b%n'; + my $amend_file; + my $append_dot = 0; + my $cluster = 1; + my $strip_tab = 0; + my $strip_cherry_pick = 0; + my $srcdir; + GetOptions + ( + help => sub { usage 0 }, + version => sub { print "$ME version $VERSION\n"; exit }, + 'since=s' => \$since_date, + 'format=s' => \$format_string, + 'amend=s' => \$amend_file, + 'append-dot' => \$append_dot, + 'cluster!' => \$cluster, + 'strip-tab' => \$strip_tab, + 'strip-cherry-pick' => \$strip_cherry_pick, + 'srcdir=s' => \$srcdir, + ) or usage 1; + + defined $since_date + and unshift @ARGV, "--since=$since_date"; + + # This is a hash that maps an SHA1 to perl code (i.e., s/old/new/) + # that makes a correction in the log or attribution of that commit. + my $amend_code = defined $amend_file ? parse_amend_file $amend_file : {}; + + my @cmd = ('git', + git_dir_option $srcdir, + qw(log --log-size), + '--pretty=format:%H:%ct %an <%ae>%n%n'.$format_string, @ARGV); + open PIPE, '-|', @cmd + or die ("$ME: failed to run '". quoted_cmd (@cmd) ."': $!\n" + . "(Is your Git too old? Version 1.5.1 or later is required.)\n"); + + my $prev_multi_paragraph; + my $prev_date_line = ''; + my @prev_coauthors = (); + while (1) + { + defined (my $in = ) + or last; + $in =~ /^log size (\d+)$/ + or die "$ME:$.: Invalid line (expected log size):\n$in"; + my $log_nbytes = $1; + + my $log; + my $n_read = read PIPE, $log, $log_nbytes; + $n_read == $log_nbytes + or die "$ME:$.: unexpected EOF\n"; + + # Extract leading hash. + my ($sha, $rest) = split ':', $log, 2; + defined $sha + or die "$ME:$.: malformed log entry\n"; + $sha =~ /^[0-9a-fA-F]{40}$/ + or die "$ME:$.: invalid SHA1: $sha\n"; + + # If this commit's log requires any transformation, do it now. + my $code = $amend_code->{$sha}; + if (defined $code) + { + eval 'use Safe'; + my $s = new Safe; + # Put the unpreprocessed entry into "$_". + $_ = $rest; + + # Let $code operate on it, safely. + my $r = $s->reval("$code") + or die "$ME:$.:$sha: failed to eval \"$code\":\n$@\n"; + + # Note that we've used this entry. + delete $amend_code->{$sha}; + + # Update $rest upon success. + $rest = $_; + } + + # Remove lines inserted by "git cherry-pick". + if ($strip_cherry_pick) + { + $rest =~ s/^\s*Conflicts:\n.*//sm; + $rest =~ s/^\s*\(cherry picked from commit [\da-f]+\)\n//m; + } + + my @line = split "\n", $rest; + my $author_line = shift @line; + defined $author_line + or die "$ME:$.: unexpected EOF\n"; + $author_line =~ /^(\d+) (.*>)$/ + or die "$ME:$.: Invalid line " + . "(expected date/author/email):\n$author_line\n"; + + # Format 'Copyright-paperwork-exempt: Yes' as a standard ChangeLog + # `(tiny change)' annotation. + my $tiny = (grep (/^Copyright-paperwork-exempt:\s+[Yy]es$/, @line) + ? ' (tiny change)' : ''); + + my $date_line = sprintf "%s %s$tiny\n", + strftime ("%F", localtime ($1)), $2; + + my @coauthors = grep /^Co-authored-by:.*$/, @line; + # Omit meta-data lines we've already interpreted. + @line = grep !/^(?:Signed-off-by:[ ].*>$ + |Co-authored-by:[ ] + |Copyright-paperwork-exempt:[ ] + )/x, @line; + + # Remove leading and trailing blank lines. + if (@line) + { + while ($line[0] =~ /^\s*$/) { shift @line; } + while ($line[$#line] =~ /^\s*$/) { pop @line; } + } + + # Record whether there are two or more paragraphs. + my $multi_paragraph = grep /^\s*$/, @line; + + # Format 'Co-authored-by: A U Thor ' lines in + # standard multi-author ChangeLog format. + for (@coauthors) + { + s/^Co-authored-by:\s*/\t /; + s/\s*/ + or warn "$ME: warning: missing email address for " + . substr ($_, 5) . "\n"; + } + + # If clustering of commit messages has been disabled, if this header + # would be different from the previous date/name/email/coauthors header, + # or if this or the previous entry consists of two or more paragraphs, + # then print the header. + if ( ! $cluster + || $date_line ne $prev_date_line + || "@coauthors" ne "@prev_coauthors" + || $multi_paragraph + || $prev_multi_paragraph) + { + $prev_date_line eq '' + or print "\n"; + print $date_line; + @coauthors + and print join ("\n", @coauthors), "\n"; + } + $prev_date_line = $date_line; + @prev_coauthors = @coauthors; + $prev_multi_paragraph = $multi_paragraph; + + # If there were any lines + if (@line == 0) + { + warn "$ME: warning: empty commit message:\n $date_line\n"; + } + else + { + if ($append_dot) + { + # If the first line of the message has enough room, then + if (length $line[0] < 72) + { + # append a dot if there is no other punctuation or blank + # at the end. + $line[0] =~ /[[:punct:]\s]$/ + or $line[0] .= '.'; + } + } + + # Remove one additional leading TAB from each line. + $strip_tab + and map { s/^\t// } @line; + + # Prefix each non-empty line with a TAB. + @line = map { length $_ ? "\t$_" : '' } @line; + + print "\n", join ("\n", @line), "\n"; + } + + defined ($in = ) + or last; + $in ne "\n" + and die "$ME:$.: unexpected line:\n$in"; + } + + close PIPE + or die "$ME: error closing pipe from " . quoted_cmd (@cmd) . "\n"; + # FIXME-someday: include $PROCESS_STATUS in the diagnostic + + # Complain about any unused entry in the --amend=F specified file. + my $fail = 0; + foreach my $sha (keys %$amend_code) + { + warn "$ME:$amend_file: unused entry: $sha\n"; + $fail = 1; + } + + exit $fail; +} + +# Local Variables: +# mode: perl +# indent-tabs-mode: nil +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "my $VERSION = '" +# time-stamp-format: "%:y-%02m-%02d %02H:%02M" +# time-stamp-time-zone: "UTC" +# time-stamp-end: "'; # UTC" +# End: -- cgit v1.2.3 From 00b80166a4750b57af0a1b2552dfeeea41d4e256 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Fri, 27 Sep 2013 16:07:10 +0200 Subject: * configure.ac (AM_INIT_AUTOMAKE): Add dist-bzip2. --- configure.ac | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 3a7d3be6..40e78a04 100644 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,7 @@ dnl Configure script for GNU Mach. -dnl Copyright (C) 1997, 1998, 1999, 2004, 2006, 2007, 2008, 2010 Free Software -dnl Foundation, Inc. +dnl Copyright (C) 1997, 1998, 1999, 2004, 2006, 2007, 2008, 2010, 2013 Free +dnl Software Foundation, Inc. dnl Permission to use, copy, modify and distribute this software and its dnl documentation is hereby granted, provided that both the copyright @@ -25,6 +25,7 @@ AC_CONFIG_AUX_DIR([build-aux]) AM_INIT_AUTOMAKE( [1.10.2] + [dist-bzip2] dnl Don't define `PACKAGE' and `VERSION'. [no-define] dnl Do not clutter the main build directory. -- cgit v1.2.3 From 788e7f6cd448c013d49eed1b8da90f645833639d Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Fri, 27 Sep 2013 21:37:08 +0200 Subject: GNU Mach 1.4. * version.m4 (AC_PACKAGE_VERSION): Set to 1.4. * NEWS: Finalize changes for 1.4. * README: Update. --- NEWS | 29 ++++++++++++----------------- README | 31 ++++++++++++++++++++----------- version.m4 | 2 +- 3 files changed, 33 insertions(+), 29 deletions(-) diff --git a/NEWS b/NEWS index 98eae891..55d75ccf 100644 --- a/NEWS +++ b/NEWS @@ -1,17 +1,14 @@ --*- Text -*- - -Changes between version 1.3 and unreleased - -The calculation of the number of blocks for the floppy drives has been -fixed. - -The check for BSD labels in impossible situations has been removed. -This removes a spurious warning at boot time for extended partitions. - -The keyboard LEDs can be set. - +2013-09-27 +Version 1.4 + +Really too many to list them individually. Highlight include numerous bug and +stability fixes, a Xen port for 32-bit x86 including basic support for Physical +Address Extension (PAE), an initial AHCI driver (SATA hard disks), a new SLAB +memory allocator to replace the previous zone allocator, support for memory +object proxies, access restrictions for x86 I/O ports, support for some PCMCIA +devices based on the pcmcia-cs package. -Changes between version 1.2 and version 1.3 +Version 1.3 The kernel now directly supports "boot scripts" in the form of multiboot module names with the same syntax as the Hurd's `serverboot' program. @@ -31,9 +28,8 @@ it perform better on today's machines. The console supports ANSI escape sequences for colors and attributes. Support for the terminal speeds B57600 and B115200 has been added. - -Changes between version 1.1 and version 1.2 +Version 1.2 Many bug fixes. @@ -57,9 +53,8 @@ former will install only the kernel, and the latter will install only the header files. Print out Mach device names instead of Linux ones. - -Changes between versions 1.0 and 1.1: +Version 1.1 Cross-compilation support is much improved. Any of various popular libc's is now sufficient for building clib-routines.o. diff --git a/README b/README index 38d2ccab..2d7724a9 100644 --- a/README +++ b/README @@ -1,19 +1,25 @@ --*- Text -*- -This is the GNU Mach 1.2 distribution. +This is GNU Mach, the GNU distribution of the Mach microkernel, +. Welcome. -This kernel is derived from the Utah kernel source. We use it to run -the Hurd on. It is being distributed by us so that we can more easily -modify the source, and so that it will work with the normal GNU coding -standards and Makefile conventions. +GNU Mach is the microkernel upon which a GNU Hurd system is based. It +provides an Inter Process Communication (IPC) mechanism that the Hurd +uses to define interfaces for implementing in a distributed multi-server +fashion the services a traditional operating system kernel provides. + +GNU Mach runs on 32-bit x86 machines. A version running on 64-bit x86 +(x86_64) machines is in progress. Volunteers interested in ports to +other architectures are sought; please contact us (see below) if you'd +like to help. libmach, bootloaders, default pagers, and the like are not part of -this distribution. For libraries, we refer you to the GNU C library, +this distribution. For libraries, we refer you to the GNU C Library, which has Mach support. For bootloaders, we refer you to GRUB. (This kernel can be loaded by any bootloader that uses the multiboot standard.) For default pagers, we refer you to your particular system that you will run on top of Mach. -The interface generator `MiG' is no longer part of this distribution. +The Mach Interface Generator (MIG) is no longer part of this distribution, and +instead is packaged separately: GNU MIG. Generic installation instructions may be found in the file INSTALL. @@ -33,6 +39,9 @@ compiler to 32-bit mode when using a 64-bit x86 (x86_64) ELF toolchain: $ [...]/configure --host=i686-gnu CC='gcc -m32' LD='ld -melf_i386' -Bug reports relating to this distribution should be sent to -bug-hurd@gnu.org. Requests for assistance should be made on -help-hurd@gnu.org. +Please read the FAQ at . +Bug reports should be sent to or filed on +. Requests for assistance +should be sent to or filed on +. You can also find us on +the Freenode IRC network in the #hurd channel. diff --git a/version.m4 b/version.m4 index 3bf4275f..4e1a2fd9 100644 --- a/version.m4 +++ b/version.m4 @@ -1,4 +1,4 @@ m4_define([AC_PACKAGE_NAME],[GNU Mach]) -m4_define([AC_PACKAGE_VERSION],[1.3.99]) +m4_define([AC_PACKAGE_VERSION],[1.4]) m4_define([AC_PACKAGE_BUGREPORT],[bug-hurd@gnu.org]) m4_define([AC_PACKAGE_TARNAME],[gnumach]) -- cgit v1.2.3 From 54357e27b6f3f727357b6ae93808cc5da41291a2 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sat, 28 Sep 2013 13:01:05 +0200 Subject: Add files missing in distrib tarball * Makefrag.am (libkernel_a_SOURCES): Add ddb/db_write_cmd.h, ipc/ipc_print.h, vm/vm_print.h * linux/Makefrag.am (EXTRA_DIST): Add linux/src/drivers/scsi/FlashPoint.c, linux/src/drivers/scsi/eata_pio_proc.c, linux/src/drivers/scsi/scsiiom.c. --- Makefrag.am | 3 +++ linux/Makefrag.am | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/Makefrag.am b/Makefrag.am index bb08972c..cce42cb4 100644 --- a/Makefrag.am +++ b/Makefrag.am @@ -59,6 +59,7 @@ libkernel_a_SOURCES += \ ddb/db_watch.c \ ddb/db_watch.h \ ddb/db_write_cmd.c \ + ddb/db_write_cmd.h \ ddb/nlist.h \ ddb/stab.h \ ddb/tr.h @@ -93,6 +94,7 @@ libkernel_a_SOURCES += \ ipc/ipc_object.h \ ipc/ipc_port.c \ ipc/ipc_port.h \ + ipc/ipc_print.h \ ipc/ipc_pset.c \ ipc/ipc_pset.h \ ipc/ipc_right.c \ @@ -250,6 +252,7 @@ libkernel_a_SOURCES += \ vm/vm_page.h \ vm/vm_pageout.c \ vm/vm_pageout.h \ + vm/vm_print.h \ vm/vm_resident.c \ vm/vm_resident.h \ vm/vm_types.h \ diff --git a/linux/Makefrag.am b/linux/Makefrag.am index 52d91d03..0973f11c 100644 --- a/linux/Makefrag.am +++ b/linux/Makefrag.am @@ -749,6 +749,12 @@ EXTRA_DIST += \ linux/dev/README \ linux/src/COPYING +# Those get #included... +EXTRA_DIST += \ + linux/src/drivers/scsi/FlashPoint.c \ + linux/src/drivers/scsi/eata_pio_proc.c \ + linux/src/drivers/scsi/scsiiom.c + # Instead of listing each file individually... EXTRA_DIST += \ linux/dev/include \ -- cgit v1.2.3 From dd0989ad8e7526844fcbc2e26bbcc4cc37a010ac Mon Sep 17 00:00:00 2001 From: Richard Braun Date: Thu, 10 Oct 2013 20:21:17 +0200 Subject: Increase kernel map entry pool size * vm/vm_map.h (KENTRY_DATA_SIZE): Set to 256 pages. --- vm/vm_map.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vm/vm_map.h b/vm/vm_map.h index 5fdac4e6..1caf9ae6 100644 --- a/vm/vm_map.h +++ b/vm/vm_map.h @@ -55,7 +55,7 @@ #include /* TODO: make it dynamic */ -#define KENTRY_DATA_SIZE (64*PAGE_SIZE) +#define KENTRY_DATA_SIZE (256*PAGE_SIZE) /* * Types defined: -- cgit v1.2.3 From 24d8170fa18e3bad9ef2fa1e100e34e93a6c1126 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sat, 9 Nov 2013 05:29:01 +0100 Subject: Remove lint code --- i386/i386/ast_check.c | 6 ------ i386/i386at/model_dep.c | 4 ---- i386/intel/pmap.c | 9 --------- kern/assert.h | 4 ---- kern/debug.c | 3 --- kern/machine.c | 6 ------ kern/macro_help.h | 5 ----- kern/processor.c | 6 ------ kern/syscall_subr.c | 4 ---- vm/memory_object.c | 5 ----- vm/vm_object.c | 12 ------------ 11 files changed, 64 deletions(-) diff --git a/i386/i386/ast_check.c b/i386/i386/ast_check.c index 982c7053..9afb9028 100644 --- a/i386/i386/ast_check.c +++ b/i386/i386/ast_check.c @@ -40,9 +40,6 @@ init_ast_check(processor) processor_t processor; { -#ifdef lint - processor++; -#endif /* lint */ } /* @@ -51,9 +48,6 @@ init_ast_check(processor) cause_ast_check(processor) processor_t processor; { -#ifdef lint - processor++; -#endif /* lint */ } #endif /* NCPUS > 1 */ diff --git a/i386/i386at/model_dep.c b/i386/i386at/model_dep.c index d97f0850..2bc1996d 100644 --- a/i386/i386at/model_dep.c +++ b/i386/i386at/model_dep.c @@ -625,10 +625,6 @@ timemmap(dev,off,prot) { extern time_value_t *mtime; -#ifdef lint - dev++; off++; -#endif /* lint */ - if (prot & VM_PROT_WRITE) return (-1); return (i386_btop(pmap_extract(pmap_kernel(), (vm_offset_t) mtime))); diff --git a/i386/intel/pmap.c b/i386/intel/pmap.c index 490c1d95..c1eca6e0 100644 --- a/i386/intel/pmap.c +++ b/i386/intel/pmap.c @@ -2150,9 +2150,6 @@ void pmap_copy(dst_pmap, src_pmap, dst_addr, len, src_addr) vm_size_t len; vm_offset_t src_addr; { -#ifdef lint - dst_pmap++; src_pmap++; dst_addr++; len++; src_addr++; -#endif /* lint */ } #endif /* 0 */ @@ -2303,9 +2300,6 @@ void pmap_deactivate(pmap, th, which_cpu) thread_t th; int which_cpu; { -#ifdef lint - pmap++; th++; which_cpu++; -#endif /* lint */ PMAP_DEACTIVATE(pmap, th, which_cpu); } #endif /* 0 */ @@ -2384,9 +2378,6 @@ pmap_pageable(pmap, start, end, pageable) vm_offset_t end; boolean_t pageable; { -#ifdef lint - pmap++; start++; end++; pageable++; -#endif /* lint */ } /* diff --git a/kern/assert.h b/kern/assert.h index 2829728b..d2bb56e1 100644 --- a/kern/assert.h +++ b/kern/assert.h @@ -44,11 +44,7 @@ MACRO_BEGIN \ Assert(#ex, __FILE__, __LINE__); \ MACRO_END -#ifdef lint -#define assert_static(x) -#else /* lint */ #define assert_static(x) assert(x) -#endif /* lint */ #else /* MACH_ASSERT */ #define assert(ex) diff --git a/kern/debug.c b/kern/debug.c index 7f6e5557..33e64f33 100644 --- a/kern/debug.c +++ b/kern/debug.c @@ -199,9 +199,6 @@ log(int level, const char *fmt, ...) { va_list listp; -#ifdef lint - level++; -#endif va_start(listp, fmt); _doprnt(fmt, listp, do_cnputc, 0, 0); va_end(listp); diff --git a/kern/machine.c b/kern/machine.c index c2a19b99..e0ceb1a2 100644 --- a/kern/machine.c +++ b/kern/machine.c @@ -320,9 +320,6 @@ processor_t processor; processor_set_t new_pset; boolean_t wait; { -#ifdef lint - processor++; new_pset++; wait++; -#endif return KERN_FAILURE; } @@ -668,9 +665,6 @@ processor_t processor; processor_set_t new_pset; boolean_t wait; { -#ifdef lint - processor++; new_pset++; wait++; -#endif /* lint */ return(KERN_FAILURE); } diff --git a/kern/macro_help.h b/kern/macro_help.h index a3d156b7..7ce171f6 100644 --- a/kern/macro_help.h +++ b/kern/macro_help.h @@ -37,13 +37,8 @@ #include -#ifdef lint -boolean_t NEVER; -boolean_t ALWAYS; -#else /* lint */ #define NEVER FALSE #define ALWAYS TRUE -#endif /* lint */ #define MACRO_BEGIN ({ #define MACRO_END }) diff --git a/kern/processor.c b/kern/processor.c index 19868609..55daf7fb 100644 --- a/kern/processor.c +++ b/kern/processor.c @@ -647,18 +647,12 @@ processor_set_create( processor_set_t *new_set, processor_set_t *new_name) { -#ifdef lint - host++; new_set++; new_name++; -#endif /* lint */ return KERN_FAILURE; } kern_return_t processor_set_destroy( processor_set_t pset) { -#ifdef lint - pset++; -#endif /* lint */ return KERN_FAILURE; } diff --git a/kern/syscall_subr.c b/kern/syscall_subr.c index ae2d7d73..1a0ab933 100644 --- a/kern/syscall_subr.c +++ b/kern/syscall_subr.c @@ -113,10 +113,6 @@ boolean_t swtch_pri(pri) register thread_t thread = current_thread(); register processor_t myprocessor; -#ifdef lint - pri++; -#endif /* lint */ - #if NCPUS > 1 myprocessor = current_processor(); if (myprocessor->runq.count == 0 && diff --git a/vm/memory_object.c b/vm/memory_object.c index e281c6a3..8315182a 100644 --- a/vm/memory_object.c +++ b/vm/memory_object.c @@ -337,11 +337,6 @@ kern_return_t memory_object_data_error(object, offset, size, error_value) if (size != round_page(size)) return(KERN_INVALID_ARGUMENT); -#ifdef lint - /* Error value is ignored at this time */ - error_value++; -#endif - vm_object_lock(object); offset -= object->paging_offset; diff --git a/vm/vm_object.c b/vm/vm_object.c index 18a909f8..600aff24 100644 --- a/vm/vm_object.c +++ b/vm/vm_object.c @@ -813,10 +813,6 @@ kern_return_t memory_object_destroy( ipc_port_t old_object, old_name; pager_request_t old_control; -#ifdef lint - reason++; -#endif /* lint */ - if (object == VM_OBJECT_NULL) return KERN_SUCCESS; @@ -1257,10 +1253,6 @@ boolean_t vm_object_copy_temporary( { vm_object_t object = *_object; -#ifdef lint - ++*_offset; -#endif /* lint */ - if (object == VM_OBJECT_NULL) { *_src_needs_copy = FALSE; *_dst_needs_copy = FALSE; @@ -2823,10 +2815,6 @@ boolean_t vm_object_coalesce( { vm_size_t newsize; -#ifdef lint - next_offset++; -#endif /* lint */ - if (next_object != VM_OBJECT_NULL) { return FALSE; } -- cgit v1.2.3 From e2dde67c3f46f5bbe7deb90e52b61977df30a52c Mon Sep 17 00:00:00 2001 From: Vladimir 'φ-coder/phcoder' Serbinenko Date: Sat, 9 Nov 2013 18:52:21 +0100 Subject: Fix overflow in Xen clock computation * xen/time.c (hyp_get_stime): Split `delta` into `delta_high` and `delta_low`, as it may overflow 4 second timing nowadays. --- xen/time.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/xen/time.c b/xen/time.c index a11e7eb4..93d87d4a 100644 --- a/xen/time.c +++ b/xen/time.c @@ -34,6 +34,7 @@ static unsigned64_t lastnsec; static unsigned64_t hyp_get_stime(void) { unsigned32_t version; unsigned64_t cpu_clock, last_cpu_clock, delta, system_time; + unsigned64_t delta_high, delta_low; unsigned32_t mul; signed8_t shift; volatile struct vcpu_time_info *time = &hyp_shared_info.vcpu_info[0].time; @@ -54,7 +55,10 @@ static unsigned64_t hyp_get_stime(void) { delta >>= -shift; else delta <<= shift; - return system_time + ((delta * (unsigned64_t) mul) >> 32); + delta_high = delta >> 32; + delta_low = (unsigned32_t) delta; + return system_time + ((delta_low * (unsigned64_t) mul) >> 32) + + (delta_high * (unsigned64_t) mul); } unsigned64_t hyp_get_time(void) { -- cgit v1.2.3 From 65ff61bb7bcd35e3922a684c068289ccbcea32d7 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sun, 10 Nov 2013 10:53:39 +0100 Subject: remove register qualifiers * device/blkio.c: Remove register qualifiers. --- device/blkio.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/device/blkio.c b/device/blkio.c index 27fec0e4..939067d7 100644 --- a/device/blkio.c +++ b/device/blkio.c @@ -41,9 +41,9 @@ io_return_t block_io(strat, max_count, ior) void (*strat)(); void (*max_count)(); - register io_req_t ior; + io_req_t ior; { - register kern_return_t rc; + kern_return_t rc; boolean_t wait = FALSE; /* @@ -89,7 +89,7 @@ io_return_t block_io(strat, max_count, ior) #define MAX_PHYS (256 * 1024) void minphys(ior) - register io_req_t ior; + io_req_t ior; { if ((ior->io_op & (IO_WRITE | IO_READ | IO_OPEN)) == IO_WRITE) return; -- cgit v1.2.3 From f16aff4d11f818950a5db123e6c4674566ae34c2 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sun, 10 Nov 2013 10:53:40 +0100 Subject: remove definitions of ETHERMTU and ETHERMIN * device/if_ether.h (ETHERMTU, ETHERMIN): Remove unused definitions. --- device/if_ether.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/device/if_ether.h b/device/if_ether.h index 2ac938e2..dbdd8184 100644 --- a/device/if_ether.h +++ b/device/if_ether.h @@ -45,9 +45,6 @@ struct ether_header { u_short ether_type; }; -#define ETHERMTU 1500 -#define ETHERMIN (60-14) - #ifdef KERNEL u_char etherbroadcastaddr[6]; -- cgit v1.2.3 From 4337ebbb802886e2caacb77de0756e10086aa3af Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sun, 10 Nov 2013 10:53:41 +0100 Subject: remove register qualifiers * device/net_io.c: Remove register qualifiers. --- device/net_io.c | 102 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/device/net_io.c b/device/net_io.c index fd71c024..1958840b 100644 --- a/device/net_io.c +++ b/device/net_io.c @@ -144,7 +144,7 @@ vm_size_t net_kmsg_size; /* initialized below */ ipc_kmsg_t net_kmsg_get(void) { - register ipc_kmsg_t kmsg; + ipc_kmsg_t kmsg; spl_t s; /* @@ -196,7 +196,7 @@ net_kmsg_get(void) } void -net_kmsg_put(register ipc_kmsg_t kmsg) +net_kmsg_put(ipc_kmsg_t kmsg) { spl_t s; @@ -212,7 +212,7 @@ net_kmsg_put(register ipc_kmsg_t kmsg) void net_kmsg_collect(void) { - register ipc_kmsg_t kmsg; + ipc_kmsg_t kmsg; spl_t s; s = splimp(); @@ -238,7 +238,7 @@ net_kmsg_collect(void) void net_kmsg_more(void) { - register ipc_kmsg_t kmsg; + ipc_kmsg_t kmsg; /* * Replenish net kmsg pool if low. We don't have the locks @@ -387,7 +387,7 @@ int bpf_validate( int bpf_eq ( bpf_insn_t f1, bpf_insn_t f2, - register int bytes); + int bytes); int net_add_q_info (ipc_port_t rcv_port); @@ -413,7 +413,7 @@ int bpf_match ( boolean_t ethernet_priority(kmsg) ipc_kmsg_t kmsg; { - register unsigned char *addr = + unsigned char *addr = (unsigned char *) net_kmsg(kmsg)->header; /* @@ -457,7 +457,7 @@ mach_msg_type_t packet_type = { boolean_t net_deliver(nonblocking) boolean_t nonblocking; { - register ipc_kmsg_t kmsg; + ipc_kmsg_t kmsg; boolean_t high_priority; struct ipc_kmsg_queue send_list; @@ -646,9 +646,9 @@ void net_thread() void reorder_queue(first, last) - register queue_t first, last; + queue_t first, last; { - register queue_entry_t prev, next; + queue_entry_t prev, next; prev = first->prev; next = last->next; @@ -669,8 +669,8 @@ reorder_queue(first, last) */ void net_packet(ifp, kmsg, count, priority) - register struct ifnet *ifp; - register ipc_kmsg_t kmsg; + struct ifnet *ifp; + ipc_kmsg_t kmsg; unsigned int count; boolean_t priority; { @@ -732,12 +732,12 @@ int net_filter_queue_reorder = 0; /* non-zero to enable reordering */ */ void net_filter(kmsg, send_list) - register ipc_kmsg_t kmsg; + ipc_kmsg_t kmsg; ipc_kmsg_queue_t send_list; { - register struct ifnet *ifp; - register net_rcv_port_t infp, nextfp; - register ipc_kmsg_t new_kmsg; + struct ifnet *ifp; + net_rcv_port_t infp, nextfp; + ipc_kmsg_t new_kmsg; net_hash_entry_t entp, *hash_headp; ipc_port_t dest; @@ -857,7 +857,7 @@ net_filter(kmsg, send_list) ipc_kmsg_enqueue(send_list, new_kmsg); { - register net_rcv_port_t prevfp; + net_rcv_port_t prevfp; int rcount = ++infp->rcv_count; /* @@ -919,9 +919,9 @@ net_do_filter(infp, data, data_count, header) char * header; { int stack[NET_FILTER_STACK_DEPTH+1]; - register int *sp; - register filter_t *fp, *fpe; - register unsigned int op, arg; + int *sp; + filter_t *fp, *fpe; + unsigned int op, arg; /* * The filter accesses the header and data @@ -1053,12 +1053,12 @@ net_do_filter(infp, data, data_count, header) */ boolean_t parse_net_filter(filter, count) - register filter_t *filter; + filter_t *filter; unsigned int count; { - register int sp; - register filter_t *fpe = &filter[count]; - register filter_t op, arg; + int sp; + filter_t *fpe = &filter[count]; + filter_t op, arg; /* * count is at least 1, and filter[0] is used for flags. @@ -1155,10 +1155,10 @@ net_set_filter(ifp, rcv_port, priority, filter, filter_count) { int filter_bytes; bpf_insn_t match; - register net_rcv_port_t infp, my_infp; + net_rcv_port_t infp, my_infp; net_rcv_port_t nextfp; net_hash_header_t hhp; - register net_hash_entry_t entp, hash_entp; + net_hash_entry_t entp, hash_entp; net_hash_entry_t *head, nextentp; queue_entry_t dead_infp, dead_entp; int i; @@ -1413,7 +1413,7 @@ net_getstat(ifp, flavor, status, count) switch (flavor) { case NET_STATUS: { - register struct net_status *ns = (struct net_status *)status; + struct net_status *ns = (struct net_status *)status; if (*count < NET_STATUS_COUNT) return (D_INVALID_OPERATION); @@ -1431,9 +1431,9 @@ net_getstat(ifp, flavor, status, count) } case NET_ADDRESS: { - register int addr_byte_count; - register int addr_int_count; - register int i; + int addr_byte_count; + int addr_int_count; + int i; addr_byte_count = ifp->if_address_size; addr_int_count = (addr_byte_count + (sizeof(int)-1)) @@ -1454,7 +1454,7 @@ printf ("net_getstat: count: %d, addr_int_count: %d\n", - addr_byte_count)); for (i = 0; i < addr_int_count; i++) { - register int word; + int word; word = status[i]; status[i] = htonl(word); @@ -1470,7 +1470,7 @@ printf ("net_getstat: count: %d, addr_int_count: %d\n", io_return_t net_write(ifp, start, ior) - register struct ifnet *ifp; + struct ifnet *ifp; int (*start)(); io_req_t ior; { @@ -1525,7 +1525,7 @@ net_write(ifp, start, ior) void net_io_init() { - register vm_size_t size; + vm_size_t size; size = sizeof(struct net_rcv_port); kmem_cache_init(&net_rcv_cache, "net_rcv_port", size, 0, @@ -1633,11 +1633,11 @@ bpf_do_filter(infp, p, wirelen, header, hlen, hash_headpp, entpp) unsigned int hlen; /* header len (in bytes) */ net_hash_entry_t **hash_headpp, *entpp; /* out */ { - register bpf_insn_t pc, pc_end; - register unsigned int buflen; + bpf_insn_t pc, pc_end; + unsigned int buflen; - register unsigned int A, X; - register int k; + unsigned int A, X; + int k; unsigned int mem[BPF_MEMWORDS]; /* Generic pointer to either HEADER or P according to the specified offset. */ @@ -1929,8 +1929,8 @@ bpf_validate(f, bytes, match) int bytes; bpf_insn_t *match; { - register int i, j, len; - register bpf_insn_t p; + int i, j, len; + bpf_insn_t p; len = BPF_BYTES2LEN(bytes); @@ -1946,7 +1946,7 @@ bpf_validate(f, bytes, match) */ p = &f[i]; if (BPF_CLASS(p->code) == BPF_JMP) { - register int from = i + 1; + int from = i + 1; if (BPF_OP(p->code) == BPF_JA) { if (from + p->k >= len) @@ -1997,10 +1997,10 @@ bpf_validate(f, bytes, match) int bpf_eq (f1, f2, bytes) - register bpf_insn_t f1, f2; - register int bytes; + bpf_insn_t f1, f2; + int bytes; { - register int count; + int count; count = BPF_BYTES2LEN(bytes); for (; count--; f1++, f2++) { @@ -2016,10 +2016,10 @@ bpf_eq (f1, f2, bytes) unsigned int bpf_hash (n, keys) - register int n; - register unsigned int *keys; + int n; + unsigned int *keys; { - register unsigned int hval = 0; + unsigned int hval = 0; while (n--) { hval += *keys++; @@ -2031,12 +2031,12 @@ bpf_hash (n, keys) int bpf_match (hash, n_keys, keys, hash_headpp, entpp) net_hash_header_t hash; - register int n_keys; - register unsigned int *keys; + int n_keys; + unsigned int *keys; net_hash_entry_t **hash_headpp, *entpp; { - register net_hash_entry_t head, entp; - register int i; + net_hash_entry_t head, entp; + int i; if (n_keys != hash->n_keys) return FALSE; @@ -2154,7 +2154,7 @@ void net_free_dead_infp (dead_infp) queue_entry_t dead_infp; { - register net_rcv_port_t infp, nextfp; + net_rcv_port_t infp, nextfp; for (infp = (net_rcv_port_t) dead_infp; infp != 0; infp = nextfp) { @@ -2176,7 +2176,7 @@ void net_free_dead_entp (dead_entp) queue_entry_t dead_entp; { - register net_hash_entry_t entp, nextentp; + net_hash_entry_t entp, nextentp; for (entp = (net_hash_entry_t)dead_entp; entp != 0; entp = nextentp) { -- cgit v1.2.3 From 39ba9cefa7f34f72d6554e775923762e120bce49 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sun, 10 Nov 2013 10:53:42 +0100 Subject: remove register qualifiers * device/subrs.c: Remove register qualifiers. --- device/subrs.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/device/subrs.c b/device/subrs.c index a82bae38..e094f684 100644 --- a/device/subrs.c +++ b/device/subrs.c @@ -61,11 +61,11 @@ u_char etherbroadcastaddr[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; */ char * ether_sprintf(ap) - register u_char *ap; + u_char *ap; { - register int i; + int i; static char etherbuf[18]; - register char *cp = etherbuf; + char *cp = etherbuf; static char digits[] = "0123456789abcdef"; for (i = 0; i < 6; i++) { @@ -81,7 +81,7 @@ ether_sprintf(ap) * Initialize send and receive queues on an interface. */ void if_init_queues(ifp) - register struct ifnet *ifp; + struct ifnet *ifp; { IFQ_INIT(&ifp->if_snd); queue_init(&ifp->if_rcv_port_list); @@ -112,7 +112,7 @@ struct buf * geteblk(size) int size; { - register io_req_t ior; + io_req_t ior; io_req_alloc(ior, 0); ior->io_device = (mach_device_t)0; @@ -136,7 +136,7 @@ geteblk(size) void brelse(bp) struct buf *bp; { - register io_req_t ior = bp; + io_req_t ior = bp; (void) vm_deallocate(kernel_map, (vm_offset_t) ior->io_data, -- cgit v1.2.3 From 306d4abeb55cd8962e858563e24e5a5b8504edaa Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sun, 10 Nov 2013 16:46:29 +0100 Subject: device: initialize to zero offset Initialize addr to zero offset to quiet warnings about uninitialized deallocation. * device/chario.c (addr): Initialize to zero. --- device/chario.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/device/chario.c b/device/chario.c index c40705e3..19f3bae3 100644 --- a/device/chario.c +++ b/device/chario.c @@ -260,7 +260,7 @@ io_return_t char_write( spl_t s; int count; char *data; - vm_offset_t addr; + vm_offset_t addr = 0; io_return_t rc = D_SUCCESS; data = ior->io_data; -- cgit v1.2.3 From 7f200574a3b2a6bace24735a8fc11acfda1ecf1a Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sun, 10 Nov 2013 22:50:20 +0100 Subject: kern: comment unused variable Variable reply_port is never used. There is indication in the comments that it might be used in future function call, so comment it. * kern/ipc_mig.c (syscall_device_writev_request): Comment variable. --- kern/ipc_mig.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/kern/ipc_mig.c b/kern/ipc_mig.c index e1532ac8..2d93eaa6 100644 --- a/kern/ipc_mig.c +++ b/kern/ipc_mig.c @@ -979,7 +979,7 @@ syscall_device_writev_request(mach_port_t device_name, vm_size_t iocount) { device_t dev; - ipc_port_t reply_port; + /*ipc_port_t reply_port;*/ io_return_t res; /* @@ -1000,9 +1000,10 @@ syscall_device_writev_request(mach_port_t device_name, /* * Translate reply port. */ - if (reply_name == MACH_PORT_NULL) + /*if (reply_name == MACH_PORT_NULL) reply_port = IP_NULL; - else { + */ + if (reply_name != MACH_PORT_NULL) { /* Homey don't play that. */ device_deallocate(dev); return KERN_INVALID_RIGHT; -- cgit v1.2.3 From 520743674ab70e035644571d4c15dad9ce058ea8 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Mon, 4 Nov 2013 18:23:56 +0100 Subject: kern: fix the error handling in exec_load Found using the Clang Static Analyzer. * kern/elf-load.c (exec_load): Properly propagate errors. --- kern/elf-load.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kern/elf-load.c b/kern/elf-load.c index 1d103d3c..441276ef 100644 --- a/kern/elf-load.c +++ b/kern/elf-load.c @@ -80,6 +80,8 @@ int exec_load(exec_read_func_t *read, exec_read_exec_func_t *read_exec, result = (*read_exec)(handle, ph->p_offset, ph->p_filesz, ph->p_vaddr, ph->p_memsz, type); + if (result) + return result; } } -- cgit v1.2.3 From 7a3be2e8d55fbe9060de11c2ad6a9b23250224b0 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Mon, 11 Nov 2013 14:08:57 +0100 Subject: ipc: remove register qualifiers * ipc/ipc_kmsg.c: Remove register qualifiers. --- ipc/ipc_kmsg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ipc/ipc_kmsg.c b/ipc/ipc_kmsg.c index 3ad274d0..3bdd6b00 100644 --- a/ipc/ipc_kmsg.c +++ b/ipc/ipc_kmsg.c @@ -2280,7 +2280,7 @@ ipc_kmsg_copyout_object(space, object, msgt_name, namep) goto slow_copyout; { - register ipc_port_t port = (ipc_port_t) object; + ipc_port_t port = (ipc_port_t) object; ipc_entry_t entry; is_write_lock(space); @@ -2313,7 +2313,7 @@ ipc_kmsg_copyout_object(space, object, msgt_name, namep) assert(IE_BITS_UREFS(entry->ie_bits) < MACH_PORT_UREFS_MAX); { - register ipc_entry_bits_t bits = entry->ie_bits + 1; + ipc_entry_bits_t bits = entry->ie_bits + 1; if (IE_BITS_UREFS(bits) < MACH_PORT_UREFS_MAX) entry->ie_bits = bits; -- cgit v1.2.3 From 6a52b3abd91f9f026800bb886fa1ddd478ab8eed Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Mon, 11 Nov 2013 14:08:58 +0100 Subject: ipc: trivial stylistic fix for consistency * ipc/ipc_pset.c: Trivial stylistic fix for consistency. --- ipc/ipc_pset.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ipc/ipc_pset.c b/ipc/ipc_pset.c index c016d276..29f781e2 100644 --- a/ipc/ipc_pset.c +++ b/ipc/ipc_pset.c @@ -345,7 +345,7 @@ ipc_pset_print( iprintf("kmsgs = 0x%x", pset->ips_messages.imq_messages.ikmq_base); printf(",rcvrs = 0x%x\n", pset->ips_messages.imq_threads.ithq_base); - indent -=2; + indent -= 2; } #endif /* MACH_KDB */ -- cgit v1.2.3 From d7e923107008d82979dd8d0b3abc61b2825b118b Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Mon, 11 Nov 2013 14:08:59 +0100 Subject: ipc: qualify constants with const * ipc/ipc_table.c: Qualify constants with const. --- ipc/ipc_table.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ipc/ipc_table.c b/ipc/ipc_table.c index cbb6a894..78a82f2c 100644 --- a/ipc/ipc_table.c +++ b/ipc/ipc_table.c @@ -52,10 +52,10 @@ void ipc_table_fill( vm_size_t elemsize); ipc_table_size_t ipc_table_entries; -unsigned int ipc_table_entries_size = 512; +const unsigned int ipc_table_entries_size = 512; ipc_table_size_t ipc_table_dnrequests; -unsigned int ipc_table_dnrequests_size = 64; +const unsigned int ipc_table_dnrequests_size = 64; void ipc_table_fill( -- cgit v1.2.3 From bd4c953244912ab8108f4f8c3367fcdcc6c64640 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Mon, 11 Nov 2013 14:09:01 +0100 Subject: ipc: remove register qualifiers * ipc/mach_msg.c: Remove register qualifiers. --- ipc/mach_msg.c | 82 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/ipc/mach_msg.c b/ipc/mach_msg.c index 00ab085b..b83738b6 100644 --- a/ipc/mach_msg.c +++ b/ipc/mach_msg.c @@ -395,12 +395,12 @@ mach_msg_trap(msg, option, send_size, rcv_size, rcv_name, time_out, notify) /* first check for common cases */ if (option == (MACH_SEND_MSG|MACH_RCV_MSG)) { - register ipc_thread_t self = current_thread(); + ipc_thread_t self = current_thread(); ipc_space_t space = self->task->itk_space; - register ipc_kmsg_t kmsg; - register ipc_port_t dest_port; + ipc_kmsg_t kmsg; + ipc_port_t dest_port; ipc_object_t rcv_object; - register ipc_mqueue_t rcv_mqueue; + ipc_mqueue_t rcv_mqueue; mach_msg_size_t reply_size; /* @@ -484,18 +484,18 @@ mach_msg_trap(msg, option, send_size, rcv_size, rcv_name, time_out, notify) switch (kmsg->ikm_header.msgh_bits) { case MACH_MSGH_BITS(MACH_MSG_TYPE_COPY_SEND, MACH_MSG_TYPE_MAKE_SEND_ONCE): { - register ipc_entry_t table; - register ipc_entry_num_t size; - register ipc_port_t reply_port; + ipc_entry_t table; + ipc_entry_num_t size; + ipc_port_t reply_port; /* sending a request message */ { - register mach_port_index_t index; - register mach_port_gen_t gen; + mach_port_index_t index; + mach_port_gen_t gen; { - register mach_port_t reply_name = + mach_port_t reply_name = kmsg->ikm_header.msgh_local_port; if (reply_name != rcv_name) @@ -517,8 +517,8 @@ mach_msg_trap(msg, option, send_size, rcv_size, rcv_name, time_out, notify) goto abort_request_copyin; { - register ipc_entry_t entry; - register ipc_entry_bits_t bits; + ipc_entry_t entry; + ipc_entry_bits_t bits; entry = &table[index]; bits = entry->ie_bits; @@ -538,11 +538,11 @@ mach_msg_trap(msg, option, send_size, rcv_size, rcv_name, time_out, notify) /* optimized ipc_entry_lookup of dest_name */ { - register mach_port_index_t index; - register mach_port_gen_t gen; + mach_port_index_t index; + mach_port_gen_t gen; { - register mach_port_t dest_name = + mach_port_t dest_name = kmsg->ikm_header.msgh_remote_port; index = MACH_PORT_INDEX(dest_name); @@ -553,8 +553,8 @@ mach_msg_trap(msg, option, send_size, rcv_size, rcv_name, time_out, notify) goto abort_request_copyin; { - register ipc_entry_t entry; - register ipc_entry_bits_t bits; + ipc_entry_t entry; + ipc_entry_bits_t bits; entry = &table[index]; bits = entry->ie_bits; @@ -651,13 +651,13 @@ mach_msg_trap(msg, option, send_size, rcv_size, rcv_name, time_out, notify) } case MACH_MSGH_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE, 0): { - register ipc_entry_num_t size; - register ipc_entry_t table; + ipc_entry_num_t size; + ipc_entry_t table; /* sending a reply message */ { - register mach_port_t reply_name = + mach_port_t reply_name = kmsg->ikm_header.msgh_local_port; if (reply_name != MACH_PORT_NULL) @@ -673,12 +673,12 @@ mach_msg_trap(msg, option, send_size, rcv_size, rcv_name, time_out, notify) table = space->is_table; { - register ipc_entry_t entry; - register mach_port_gen_t gen; - register mach_port_index_t index; + ipc_entry_t entry; + mach_port_gen_t gen; + mach_port_index_t index; { - register mach_port_t dest_name = + mach_port_t dest_name = kmsg->ikm_header.msgh_remote_port; index = MACH_PORT_INDEX(dest_name); @@ -740,12 +740,12 @@ mach_msg_trap(msg, option, send_size, rcv_size, rcv_name, time_out, notify) /* optimized ipc_entry_lookup/ipc_mqueue_copyin */ { - register ipc_entry_t entry; - register ipc_entry_bits_t bits; + ipc_entry_t entry; + ipc_entry_bits_t bits; { - register mach_port_index_t index; - register mach_port_gen_t gen; + mach_port_index_t index; + mach_port_gen_t gen; index = MACH_PORT_INDEX(rcv_name); gen = MACH_PORT_GEN(rcv_name); @@ -765,7 +765,7 @@ mach_msg_trap(msg, option, send_size, rcv_size, rcv_name, time_out, notify) /* check type bits; looking for receive or set */ if (bits & MACH_PORT_TYPE_PORT_SET) { - register ipc_pset_t rcv_pset; + ipc_pset_t rcv_pset; rcv_pset = (ipc_pset_t) entry->ie_object; assert(rcv_pset != IPS_NULL); @@ -776,7 +776,7 @@ mach_msg_trap(msg, option, send_size, rcv_size, rcv_name, time_out, notify) rcv_object = (ipc_object_t) rcv_pset; rcv_mqueue = &rcv_pset->ips_messages; } else if (bits & MACH_PORT_TYPE_RECEIVE) { - register ipc_port_t rcv_port; + ipc_port_t rcv_port; rcv_port = (ipc_port_t) entry->ie_object; assert(rcv_port != IP_NULL); @@ -841,11 +841,11 @@ mach_msg_trap(msg, option, send_size, rcv_size, rcv_name, time_out, notify) MACH_MSGH_BITS_CIRCULAR) == 0); { - register ipc_mqueue_t dest_mqueue; - register ipc_thread_t receiver; + ipc_mqueue_t dest_mqueue; + ipc_thread_t receiver; { - register ipc_pset_t dest_pset; + ipc_pset_t dest_pset; dest_pset = dest_port->ip_pset; if (dest_pset == IPS_NULL) @@ -1074,9 +1074,9 @@ mach_msg_trap(msg, option, send_size, rcv_size, rcv_name, time_out, notify) ip_unlock(reply_port); { - register ipc_entry_t table; - register ipc_entry_t entry; - register mach_port_index_t index; + ipc_entry_t table; + ipc_entry_t entry; + mach_port_index_t index; /* optimized ipc_entry_get */ @@ -1091,7 +1091,7 @@ mach_msg_trap(msg, option, send_size, rcv_size, rcv_name, time_out, notify) entry->ie_request = 0; { - register mach_port_gen_t gen; + mach_port_gen_t gen; assert((entry->ie_bits &~ IE_BITS_GEN_MASK) == 0); gen = entry->ie_bits + IE_BITS_GEN_ONE; @@ -1148,7 +1148,7 @@ mach_msg_trap(msg, option, send_size, rcv_size, rcv_name, time_out, notify) } case MACH_MSGH_BITS(MACH_MSG_TYPE_PORT_SEND_ONCE, 0): { - register mach_port_t dest_name; + mach_port_t dest_name; /* receiving a reply message */ @@ -1182,7 +1182,7 @@ mach_msg_trap(msg, option, send_size, rcv_size, rcv_name, time_out, notify) case MACH_MSGH_BITS_COMPLEX| MACH_MSGH_BITS(MACH_MSG_TYPE_PORT_SEND_ONCE, 0): { - register mach_port_t dest_name; + mach_port_t dest_name; /* receiving a complex reply message */ @@ -1322,7 +1322,7 @@ mach_msg_trap(msg, option, send_size, rcv_size, rcv_name, time_out, notify) * It will work if this is a request message. */ - register ipc_port_t reply_port; + ipc_port_t reply_port; reply_port = (ipc_port_t) kmsg->ikm_header.msgh_local_port; @@ -1357,7 +1357,7 @@ mach_msg_trap(msg, option, send_size, rcv_size, rcv_name, time_out, notify) */ { - register ipc_port_t reply_port; + ipc_port_t reply_port; /* * Perform the kernel function. -- cgit v1.2.3 From 1e3112520097667203994a576f24dcd71e6fa6c0 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Mon, 11 Nov 2013 14:09:00 +0100 Subject: ipc: remove register qualifiers * ipc/ipc_thread.h: Remove register qualifiers. --- ipc/ipc_thread.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ipc/ipc_thread.h b/ipc/ipc_thread.h index fbeea46a..008ab4a9 100644 --- a/ipc/ipc_thread.h +++ b/ipc/ipc_thread.h @@ -75,7 +75,7 @@ MACRO_END #define ipc_thread_rmqueue_first_macro(queue, thread) \ MACRO_BEGIN \ - register ipc_thread_t _next; \ + ipc_thread_t _next; \ \ assert((queue)->ithq_base == (thread)); \ \ @@ -84,7 +84,7 @@ MACRO_BEGIN \ assert((thread)->ith_prev == (thread)); \ (queue)->ithq_base = ITH_NULL; \ } else { \ - register ipc_thread_t _prev = (thread)->ith_prev; \ + ipc_thread_t _prev = (thread)->ith_prev; \ \ (queue)->ithq_base = _next; \ _next->ith_prev = _prev; \ @@ -95,14 +95,14 @@ MACRO_END #define ipc_thread_enqueue_macro(queue, thread) \ MACRO_BEGIN \ - register ipc_thread_t _first = (queue)->ithq_base; \ + ipc_thread_t _first = (queue)->ithq_base; \ \ if (_first == ITH_NULL) { \ (queue)->ithq_base = (thread); \ assert((thread)->ith_next == (thread)); \ assert((thread)->ith_prev == (thread)); \ } else { \ - register ipc_thread_t _last = _first->ith_prev; \ + ipc_thread_t _last = _first->ith_prev; \ \ (thread)->ith_next = _first; \ (thread)->ith_prev = _last; \ -- cgit v1.2.3 From 97bd0931cd050d48a8b5a01570abe3c7d7b30c9e Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Mon, 11 Nov 2013 19:36:49 +0100 Subject: kern: remove register qualifiers * kern/act.c: Remove register qualifiers. --- kern/act.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kern/act.c b/kern/act.c index 4c3839c6..321ff98d 100644 --- a/kern/act.c +++ b/kern/act.c @@ -1014,7 +1014,7 @@ act_set_special_port(Act *act, int which, ipc_port_t port) */ kern_return_t act_get_state_immediate(act, flavor, old_state, old_state_count) - register Act *act; + Act *act; int flavor; void *old_state; /* pointer to OUT array */ unsigned int *old_state_count; /*IN/OUT*/ @@ -1040,7 +1040,7 @@ act_get_state_immediate(act, flavor, old_state, old_state_count) */ kern_return_t act_set_state_immediate(act, flavor, new_state, new_state_count) - register Act *act; + Act *act; int flavor; void *new_state; unsigned int new_state_count; -- cgit v1.2.3 From 2eb6a0e3ac5f4cf32ecdb5a7b2ae416a1cf19382 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Mon, 11 Nov 2013 19:42:58 +0100 Subject: kern: remove register qualifiers * kern/ast.c: Remove register qualifiers. --- kern/ast.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/kern/ast.c b/kern/ast.c index 97da3abc..e8e8c1bd 100644 --- a/kern/ast.c +++ b/kern/ast.c @@ -59,7 +59,7 @@ void ast_init() { #ifndef MACHINE_AST - register int i; + int i; for (i=0; iprocessor_set->runq); if (!(myprocessor->first_quantum) && (rq->count > 0)) { - register queue_t q; + queue_t q; /* * This is not the first quantum, and there may * be something in the processor_set runq. @@ -198,7 +198,7 @@ ast_check() */ q = rq->runq + *(volatile int *)&rq->low; if (queue_empty(q)) { - register int i; + int i; /* * Need to recheck and possibly update hint. -- cgit v1.2.3 From 5946df8a9291afd3daa5b2955f6e7630d2938288 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Mon, 11 Nov 2013 19:53:54 +0100 Subject: kern: remove register qualifiers * kern/bootstrap.c: Remove register qualifiers. --- kern/bootstrap.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/kern/bootstrap.c b/kern/bootstrap.c index c98b0a2c..a683ce91 100644 --- a/kern/bootstrap.c +++ b/kern/bootstrap.c @@ -318,7 +318,7 @@ itoa( vm_size_t num) { char buf[sizeof(vm_size_t)*2+3]; - register char *np; + char *np; np = buf + sizeof(buf); *--np = 0; @@ -338,7 +338,7 @@ itoa( */ static void get_compat_strings(char *flags_str, char *root_str) { - register char *ip, *cp; + char *ip, *cp; strcpy (root_str, "UNKNOWN"); @@ -528,7 +528,6 @@ build_args_and_stack(struct exec_info *boot_exec_info, { vm_offset_t stack_base; vm_size_t stack_size; - register char * arg_ptr; int arg_count, envc; int arg_len; -- cgit v1.2.3 From f5e6f0ed9bc32eb24541b090ebbcf451d59e1422 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Mon, 11 Nov 2013 20:02:30 +0100 Subject: kern: remove register qualifiers * kern/eventcount.c: Remove register qualifiers. --- kern/eventcount.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kern/eventcount.c b/kern/eventcount.c index 6fcebff5..50250003 100644 --- a/kern/eventcount.c +++ b/kern/eventcount.c @@ -235,8 +235,8 @@ kern_return_t evc_wait_clear(natural_t ev_id) void evc_signal(evc_t ev) { - register volatile thread_t thread; - register int state; + volatile thread_t thread; + int state; spl_t s; if (ev->sanity != ev) return; @@ -325,8 +325,8 @@ simpler_thread_setrun( thread_t th, boolean_t may_preempt) { - register struct run_queue *rq; - register int whichq; + struct run_queue *rq; + int whichq; /* * XXX should replace queue with a boolean in this case. -- cgit v1.2.3 From 4caf279e81207817423c1546ca0e9c755e4204c2 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Mon, 11 Nov 2013 20:56:31 +0100 Subject: kern: remove register qualifiers * kern/exception.c: Remove register qualifiers. --- kern/exception.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/kern/exception.c b/kern/exception.c index 453a0758..112511e5 100644 --- a/kern/exception.c +++ b/kern/exception.c @@ -96,8 +96,8 @@ void exception(_exception, code, subcode) integer_t _exception, code, subcode; { - register ipc_thread_t self = current_thread(); - register ipc_port_t exc_port; + ipc_thread_t self = current_thread(); + ipc_port_t exc_port; if (_exception == KERN_SUCCESS) panic("exception"); @@ -167,8 +167,8 @@ exception_try_task(_exception, code, subcode) integer_t _exception, code, subcode; { ipc_thread_t self = current_thread(); - register task_t task = self->task; - register ipc_port_t exc_port; + task_t task = self->task; + ipc_port_t exc_port; /* * Optimized version of retrieve_task_exception. @@ -230,7 +230,7 @@ exception_try_task(_exception, code, subcode) void exception_no_server() { - register ipc_thread_t self = current_thread(); + ipc_thread_t self = current_thread(); /* * If this thread is being terminated, cooperate. @@ -428,7 +428,7 @@ exception_raise(dest_port, thread_port, task_port, */ { - register ipc_pset_t dest_pset; + ipc_pset_t dest_pset; dest_pset = dest_port->ip_pset; if (dest_pset == IPS_NULL) @@ -490,7 +490,7 @@ exception_raise(dest_port, thread_port, task_port, * Release the receiver's reference for his object. */ { - register ipc_object_t object = receiver->ith_object; + ipc_object_t object = receiver->ith_object; io_lock(object); io_release(object); @@ -498,7 +498,7 @@ exception_raise(dest_port, thread_port, task_port, } { - register struct mach_exception *exc = + struct mach_exception *exc = (struct mach_exception *) &kmsg->ikm_header; ipc_space_t space = receiver->task->itk_space; @@ -609,9 +609,9 @@ exception_raise(dest_port, thread_port, task_port, ip_unlock(reply_port); { - register ipc_entry_t table; - register ipc_entry_t entry; - register mach_port_index_t index; + ipc_entry_t table; + ipc_entry_t entry; + mach_port_index_t index; /* optimized ipc_entry_get */ @@ -626,7 +626,7 @@ exception_raise(dest_port, thread_port, task_port, entry->ie_request = 0; { - register mach_port_gen_t gen; + mach_port_gen_t gen; assert((entry->ie_bits &~ IE_BITS_GEN_MASK) == 0); gen = entry->ie_bits + IE_BITS_GEN_ONE; @@ -710,7 +710,7 @@ exception_raise(dest_port, thread_port, task_port, #endif slow_exception_raise: { - register struct mach_exception *exc = + struct mach_exception *exc = (struct mach_exception *) &kmsg->ikm_header; ipc_kmsg_t reply_kmsg; mach_port_seqno_t reply_seqno; @@ -797,7 +797,7 @@ kern_return_t exception_parse_reply(kmsg) ipc_kmsg_t kmsg; { - register mig_reply_header_t *msg = + mig_reply_header_t *msg = (mig_reply_header_t *) &kmsg->ikm_header; kern_return_t kr; -- cgit v1.2.3 From adb8a48dd397a1c27273e9fce9c3bbf94c3ff79b Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Mon, 11 Nov 2013 20:59:56 +0100 Subject: kern: remove register qualifiers * kern/host.c: Remove register qualifiers. --- kern/host.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/kern/host.c b/kern/host.c index 57a40b43..773697c2 100644 --- a/kern/host.c +++ b/kern/host.c @@ -51,8 +51,8 @@ kern_return_t host_processors( processor_array_t *processor_list, natural_t *countp) { - register int i; - register processor_t *tp; + int i; + processor_t *tp; vm_offset_t addr; unsigned int count; @@ -100,7 +100,7 @@ kern_return_t host_info( host_info_t info, natural_t *count) { - register integer_t i, *slot_ptr; + integer_t i, *slot_ptr; if (host == HOST_NULL) return KERN_INVALID_ARGUMENT; @@ -109,7 +109,7 @@ kern_return_t host_info( case HOST_BASIC_INFO: { - register host_basic_info_t basic_info; + host_basic_info_t basic_info; /* * Basic information about this host. @@ -152,7 +152,7 @@ kern_return_t host_info( case HOST_SCHED_INFO: { - register host_sched_info_t sched_info; + host_sched_info_t sched_info; extern int min_quantum; /* minimum quantum, in microseconds */ @@ -174,7 +174,7 @@ kern_return_t host_info( case HOST_LOAD_INFO: { - register host_load_info_t load_info; + host_load_info_t load_info; extern long avenrun[3], mach_factor[3]; if (*count < HOST_LOAD_INFO_COUNT) -- cgit v1.2.3 From 7f2ebdf53252fd3b6544b4b6de1c4c4f5a279fd9 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Mon, 11 Nov 2013 21:11:35 +0100 Subject: kern: remove register qualifiers * kern/ipc_mig.c: Remove register qualifiers. --- kern/ipc_mig.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/kern/ipc_mig.c b/kern/ipc_mig.c index 2d93eaa6..3d48cb4a 100644 --- a/kern/ipc_mig.c +++ b/kern/ipc_mig.c @@ -303,9 +303,9 @@ int len; #define fast_send_right_lookup(name, port, abort) \ MACRO_BEGIN \ - register ipc_space_t space = current_space(); \ - register ipc_entry_t entry; \ - register mach_port_index_t index = MACH_PORT_INDEX(name); \ + ipc_space_t space = current_space(); \ + ipc_entry_t entry; \ + mach_port_index_t index = MACH_PORT_INDEX(name); \ \ is_read_lock(space); \ assert(space->is_active); \ @@ -330,8 +330,8 @@ device_t port_name_to_device(name) mach_port_t name; { - register ipc_port_t port; - register device_t device; + ipc_port_t port; + device_t device; fast_send_right_lookup(name, port, goto abort); /* port is locked */ @@ -374,14 +374,14 @@ thread_t port_name_to_thread(name) mach_port_t name; { - register ipc_port_t port; + ipc_port_t port; fast_send_right_lookup(name, port, goto abort); /* port is locked */ if (ip_active(port) && (ip_kotype(port) == IKOT_THREAD)) { - register thread_t thread; + thread_t thread; thread = (thread_t) port->ip_kobject; assert(thread != THREAD_NULL); @@ -420,14 +420,14 @@ task_t port_name_to_task(name) mach_port_t name; { - register ipc_port_t port; + ipc_port_t port; fast_send_right_lookup(name, port, goto abort); /* port is locked */ if (ip_active(port) && (ip_kotype(port) == IKOT_TASK)) { - register task_t task; + task_t task; task = (task_t) port->ip_kobject; assert(task != TASK_NULL); @@ -468,14 +468,14 @@ vm_map_t port_name_to_map( mach_port_t name) { - register ipc_port_t port; + ipc_port_t port; fast_send_right_lookup(name, port, goto abort); /* port is locked */ if (ip_active(port) && (ip_kotype(port) == IKOT_TASK)) { - register vm_map_t map; + vm_map_t map; map = ((task_t) port->ip_kobject)->map; assert(map != VM_MAP_NULL); @@ -516,14 +516,14 @@ ipc_space_t port_name_to_space(name) mach_port_t name; { - register ipc_port_t port; + ipc_port_t port; fast_send_right_lookup(name, port, goto abort); /* port is locked */ if (ip_active(port) && (ip_kotype(port) == IKOT_TASK)) { - register ipc_space_t space; + ipc_space_t space; space = ((task_t) port->ip_kobject)->itk_space; assert(space != IS_NULL); -- cgit v1.2.3 From df745857b3f58fc057919047efc522ccc4493035 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Mon, 11 Nov 2013 21:15:09 +0100 Subject: kern: remove register qualifiers * kern/ipc_sched.c: Remove register qualifiers. --- kern/ipc_sched.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kern/ipc_sched.c b/kern/ipc_sched.c index 615ad608..d5b9263c 100644 --- a/kern/ipc_sched.c +++ b/kern/ipc_sched.c @@ -182,9 +182,9 @@ thread_will_wait_with_timeout( boolean_t thread_handoff( - register thread_t old, - register continuation_t continuation, - register thread_t new) + thread_t old, + continuation_t continuation, + thread_t new) { spl_t s; -- cgit v1.2.3 From 66bd58f00d97eb59a353c3e2254c94c2ec2e6cbc Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Mon, 11 Nov 2013 21:20:38 +0100 Subject: kern: remove register qualifiers * kern/ipc_tt.c: Remove register qualifiers. --- kern/ipc_tt.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kern/ipc_tt.c b/kern/ipc_tt.c index 6d32e5b0..e5d928dc 100644 --- a/kern/ipc_tt.c +++ b/kern/ipc_tt.c @@ -387,9 +387,9 @@ retrieve_thread_self(thread) ipc_port_t retrieve_task_self_fast( - register task_t task) + task_t task) { - register ipc_port_t port; + ipc_port_t port; assert(task == current_task()); @@ -425,9 +425,9 @@ retrieve_task_self_fast( ipc_port_t retrieve_thread_self_fast(thread) - register thread_t thread; + thread_t thread; { - register ipc_port_t port; + ipc_port_t port; assert(thread == current_thread()); -- cgit v1.2.3 From b2828ba4d9f6cfe1cbc61ae12f755e1b3d568776 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Tue, 12 Nov 2013 09:52:11 +0100 Subject: kern: remove register qualifiers * kern/lock.c: Remove register qualifiers. --- kern/lock.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/kern/lock.c b/kern/lock.c index 44d4448e..fb5e3441 100644 --- a/kern/lock.c +++ b/kern/lock.c @@ -250,9 +250,9 @@ void lock_sleepable( */ void lock_write( - register lock_t l) + lock_t l) { - register int i; + int i; check_simple_locks(); simple_lock(&l->interlock); @@ -308,7 +308,7 @@ void lock_write( } void lock_done( - register lock_t l) + lock_t l) { simple_lock(&l->interlock); @@ -340,9 +340,9 @@ void lock_done( } void lock_read( - register lock_t l) + lock_t l) { - register int i; + int i; check_simple_locks(); simple_lock(&l->interlock); @@ -387,9 +387,9 @@ void lock_read( * Returns TRUE if the upgrade *failed*. */ boolean_t lock_read_to_write( - register lock_t l) + lock_t l) { - register int i; + int i; check_simple_locks(); simple_lock(&l->interlock); @@ -443,7 +443,7 @@ boolean_t lock_read_to_write( } void lock_write_to_read( - register lock_t l) + lock_t l) { simple_lock(&l->interlock); @@ -474,7 +474,7 @@ void lock_write_to_read( */ boolean_t lock_try_write( - register lock_t l) + lock_t l) { simple_lock(&l->interlock); @@ -513,7 +513,7 @@ boolean_t lock_try_write( */ boolean_t lock_try_read( - register lock_t l) + lock_t l) { simple_lock(&l->interlock); @@ -547,7 +547,7 @@ boolean_t lock_try_read( * Returns FALSE if the upgrade *failed*. */ boolean_t lock_try_read_to_write( - register lock_t l) + lock_t l) { check_simple_locks(); simple_lock(&l->interlock); -- cgit v1.2.3 From db4ebcbcf62767fa60d65d357ba1827c8b2e8471 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Tue, 12 Nov 2013 10:00:45 +0100 Subject: kern: remove register qualifiers * kern/lock_mon.c: Remove register qualifiers. --- kern/lock_mon.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/kern/lock_mon.c b/kern/lock_mon.c index 14504281..80c50b5f 100644 --- a/kern/lock_mon.c +++ b/kern/lock_mon.c @@ -94,8 +94,8 @@ locate_lock_info(lock) decl_simple_lock_data(, **lock) { struct lock_info *li = &(lock_info[HASH_LOCK(*lock)].info[0]); - register i; - register my_cpu = cpu_number(); + int i; + my_cpu = cpu_number(); for (i=0; i < LOCK_INFO_PER_BUCKET; i++, li++) if (li->lock) { @@ -115,8 +115,8 @@ decl_simple_lock_data(, **lock) simple_lock(lock) decl_simple_lock_data(, *lock) { - register struct lock_info *li = locate_lock_info(&lock); - register my_cpu = cpu_number(); + struct lock_info *li = locate_lock_info(&lock); + my_cpu = cpu_number(); if (current_thread()) li->stack = current_thread()->lock_stack++; @@ -134,8 +134,8 @@ decl_simple_lock_data(, *lock) simple_lock_try(lock) decl_simple_lock_data(, *lock) { - register struct lock_info *li = locate_lock_info(&lock); - register my_cpu = cpu_number(); + struct lock_info *li = locate_lock_info(&lock); + my_cpu = cpu_number(); if (curr_ipl[my_cpu]) li->masked++; @@ -154,9 +154,9 @@ decl_simple_lock_data(, *lock) simple_unlock(lock) decl_simple_lock_data(, *lock) { - register time_stamp_t stamp = time_stamp; - register time_stamp_t *time = &locate_lock_info(&lock)->time; - register unsigned *lock_stack; + time_stamp_t stamp = time_stamp; + time_stamp_t *time = &locate_lock_info(&lock)->time; + unsigned *lock_stack; *time = stamp - *time; _simple_unlock(lock); @@ -302,8 +302,8 @@ struct lock_info *li; time_lock(loops) { decl_simple_lock_data(, lock) - register time_stamp_t stamp; - register int i; + time_stamp_t stamp; + int i; if (!loops) @@ -340,7 +340,7 @@ void retry_simple_lock(lock) decl_simple_lock_data(, *lock) { - register count = 0; + count = 0; while(!simple_lock_try(lock)) if (count++ > 1000000 && lock != &kdb_lock) { @@ -356,7 +356,7 @@ decl_simple_lock_data(, *lock) void retry_bit_lock(index, addr) { - register count = 0; + count = 0; while(!bit_lock_try(index, addr)) if (count++ > 1000000) { -- cgit v1.2.3 From a0e89efc4cf81b3b219a56a97a2fdf9ef05b2f0a Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Tue, 12 Nov 2013 10:07:39 +0100 Subject: kern: remove register qualifiers * kern/mach_clock.c: Remove register qualifiers. --- kern/mach_clock.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/kern/mach_clock.c b/kern/mach_clock.c index edf87f07..cfc94a37 100644 --- a/kern/mach_clock.c +++ b/kern/mach_clock.c @@ -122,12 +122,12 @@ timer_elt_data_t timer_head; /* ordered list of timeouts */ * */ void clock_interrupt(usec, usermode, basepri) - register int usec; /* microseconds per tick */ + int usec; /* microseconds per tick */ boolean_t usermode; /* executing user code */ boolean_t basepri; /* at base priority */ { - register int my_cpu = cpu_number(); - register thread_t thread = current_thread(); + int my_cpu = cpu_number(); + thread_t thread = current_thread(); counter(c_clock_ticks++); counter(c_threads_total += c_threads_current); @@ -151,7 +151,7 @@ void clock_interrupt(usec, usermode, basepri) */ { extern void thread_quantum_update(); /* in priority.c */ - register int state; + int state; if (usermode) state = CPU_STATE_USER; @@ -187,8 +187,8 @@ void clock_interrupt(usec, usermode, basepri) */ if (my_cpu == master_cpu) { - register spl_t s; - register timer_elt_t telt; + spl_t s; + timer_elt_t telt; boolean_t needsoft = FALSE; #if TS_FORMAT == 1 @@ -221,7 +221,7 @@ void clock_interrupt(usec, usermode, basepri) time_value_add_usec(&time, usec); } else { - register int delta; + int delta; if (timedelta < 0) { delta = usec - tickdelta; @@ -278,9 +278,9 @@ void softclock() * Handle timeouts. */ spl_t s; - register timer_elt_t telt; - register void (*fcn)( void * param ); - register void *param; + timer_elt_t telt; + void (*fcn)( void * param ); + void *param; while (TRUE) { s = splsched(); @@ -312,11 +312,11 @@ void softclock() * interval time-out interval, in hz. */ void set_timeout(telt, interval) - register timer_elt_t telt; /* already loaded */ - register unsigned int interval; + timer_elt_t telt; /* already loaded */ + unsigned int interval; { spl_t s; - register timer_elt_t next; + timer_elt_t next; s = splsched(); simple_lock(&timer_lock); @@ -342,7 +342,7 @@ void set_timeout(telt, interval) } boolean_t reset_timeout(telt) - register timer_elt_t telt; + timer_elt_t telt; { spl_t s; @@ -534,7 +534,7 @@ void timeout(fcn, param, interval) int interval; { spl_t s; - register timer_elt_t elt; + timer_elt_t elt; s = splsched(); simple_lock(&timer_lock); @@ -557,11 +557,11 @@ void timeout(fcn, param, interval) * and removed. */ boolean_t untimeout(fcn, param) - register void (*fcn)( void * param ); - register void * param; + void (*fcn)( void * param ); + void * param; { spl_t s; - register timer_elt_t elt; + timer_elt_t elt; s = splsched(); simple_lock(&timer_lock); -- cgit v1.2.3 From fb7b8f3f7d19eb057d8f28fdaeb1d68ed377d252 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Tue, 12 Nov 2013 11:10:01 +0100 Subject: kern: remove register qualifiers * kern/mach_factor.c: Remove register qualifiers. --- kern/mach_factor.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/kern/mach_factor.c b/kern/mach_factor.c index 558c4a06..debce0b0 100644 --- a/kern/mach_factor.c +++ b/kern/mach_factor.c @@ -55,13 +55,13 @@ static long fract[3] = { void compute_mach_factor(void) { - register processor_set_t pset; - register processor_t processor; - register int ncpus; - register int nthreads; - register long factor_now; - register long average_now; - register long load_now; + processor_set_t pset; + processor_t processor; + int ncpus; + int nthreads; + long factor_now; + long average_now; + long load_now; simple_lock(&all_psets_lock); pset = (processor_set_t) queue_first(&all_psets); @@ -123,7 +123,7 @@ void compute_mach_factor(void) * And some ugly stuff to keep w happy. */ if (pset == &default_pset) { - register int i; + int i; for (i = 0; i < 3; i++) { mach_factor[i] = ( (mach_factor[i]*fract[i]) -- cgit v1.2.3 From 19fa33fd503b89ccebd446e5734365dcbc3475dd Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Tue, 12 Nov 2013 11:15:18 +0100 Subject: kern: remove register qualifiers * kern/machine.c: Remove register qualifiers. --- kern/machine.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/kern/machine.c b/kern/machine.c index e0ceb1a2..c1df28b3 100644 --- a/kern/machine.c +++ b/kern/machine.c @@ -75,9 +75,9 @@ decl_simple_lock_data(,action_lock); void cpu_up(cpu) int cpu; { - register struct machine_slot *ms; - register processor_t processor; - register spl_t s; + struct machine_slot *ms; + processor_t processor; + spl_t s; processor = cpu_to_processor(cpu); pset_lock(&default_pset); @@ -105,9 +105,9 @@ void cpu_up(cpu) void cpu_down(cpu) int cpu; { - register struct machine_slot *ms; - register processor_t processor; - register spl_t s; + struct machine_slot *ms; + processor_t processor; + spl_t s; s = splsched(); processor = cpu_to_processor(cpu); @@ -157,7 +157,7 @@ processor_request_action(processor, new_pset) processor_t processor; processor_set_t new_pset; { - register processor_set_t pset; + processor_set_t pset; /* * Processor must be in a processor set. Must lock its idle lock to @@ -365,8 +365,8 @@ void processor_doaction(); /* forward */ void action_thread_continue() { - register processor_t processor; - register spl_t s; + processor_t processor; + spl_t s; while (TRUE) { s = splsched(); @@ -413,11 +413,11 @@ register processor_t processor; { thread_t this_thread; spl_t s; - register processor_set_t pset; + processor_set_t pset; #if MACH_HOST - register processor_set_t new_pset; - register thread_t thread; - register thread_t prev_thread = THREAD_NULL; + processor_set_t new_pset; + thread_t thread; + thread_t prev_thread = THREAD_NULL; boolean_t have_pset_ref = FALSE; #endif /* MACH_HOST */ @@ -634,9 +634,9 @@ Restart_pset: __volatile__ #endif void processor_doshutdown(processor) -register processor_t processor; +processor_t processor; { - register int cpu = processor->slot_num; + int cpu = processor->slot_num; timer_switch(&kernel_timer[cpu]); -- cgit v1.2.3 From 1a9383dd33e4aae48139f68de28b0776f830f58a Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Tue, 12 Nov 2013 11:17:55 +0100 Subject: kern: remove register qualifiers * kern/pc_sample.c: Remove register qualifiers. --- kern/pc_sample.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kern/pc_sample.c b/kern/pc_sample.c index 57002581..05c08b81 100644 --- a/kern/pc_sample.c +++ b/kern/pc_sample.c @@ -47,8 +47,8 @@ int pc_sampling_enabled = 0; decl_simple_lock_data(, pc_sampling_lock) /* lock for enabling */ void take_pc_sample( - register thread_t t, - register sample_control_t *cp, + thread_t t, + sample_control_t *cp, sampled_pc_flavor_t flavor) { vm_offset_t pc; -- cgit v1.2.3 From f0184ed30aef57307ca209f41a3d7ce408efbaaa Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Tue, 12 Nov 2013 11:22:40 +0100 Subject: kern: remove register qualifiers * kern/printf.c: Remove register qualifiers. --- kern/printf.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/kern/printf.c b/kern/printf.c index a3a771d0..af59d5ac 100644 --- a/kern/printf.c +++ b/kern/printf.c @@ -130,13 +130,13 @@ void printnum( - register unsigned long u, - register int base, + unsigned long u, + int base, void (*putc)( char, vm_offset_t ), vm_offset_t putc_arg) { char buf[MAXBUF]; /* build number here */ - register char * p = &buf[MAXBUF-1]; + char * p = &buf[MAXBUF-1]; static char digs[] = "0123456789abcdef"; do { @@ -167,7 +167,7 @@ void printf_init(void) } void _doprnt( - register const char *fmt, + const char *fmt, va_list argp, /* character output routine */ void (*putc)( char, vm_offset_t), @@ -184,7 +184,7 @@ void _doprnt( int sign_char; boolean_t altfmt, truncate; int base; - register char c; + char c; printf_init(); @@ -193,7 +193,7 @@ void _doprnt( simple_lock(&_doprnt_lock); #else { - register int i = 0; + int i = 0; while (i < 1*1024*1024) { if (simple_lock_try(&_doprnt_lock)) break; @@ -283,9 +283,9 @@ void _doprnt( case 'b': case 'B': { - register char *p; - boolean_t any; - register int i; + char *p; + boolean_t any; + int i; u = va_arg(argp, unsigned long); p = va_arg(argp, char *); @@ -302,7 +302,7 @@ void _doprnt( /* * Bit field */ - register int j; + int j; if (any) (*putc)(',', putc_arg); else { @@ -342,8 +342,8 @@ void _doprnt( case 's': { - register char *p; - register char *p2; + char *p; + char *p2; if (prec == -1) prec = 0x7fffffff; /* MAXINT */ @@ -449,7 +449,7 @@ void _doprnt( print_num: { char buf[MAXBUF]; /* build number here */ - register char * p = &buf[MAXBUF-1]; + char * p = &buf[MAXBUF-1]; static char digits[] = "0123456789abcdef"; char *prefix = 0; @@ -540,7 +540,7 @@ int indent = 0; void iprintf(const char *fmt, ...) { va_list listp; - register int i; + int i; for (i = indent; i > 0; ){ if (i >= 8) { @@ -567,8 +567,8 @@ sputc( char c, vm_offset_t arg) { - register char **bufp = (char **) arg; - register char *p = *bufp; + char **bufp = (char **) arg; + char *p = *bufp; *p++ = c; *bufp = p; } @@ -620,8 +620,8 @@ void safe_gets(str, maxlen) char *str; int maxlen; { - register char *lp; - register int c; + char *lp; + int c; char *strmax = str + maxlen - 1; /* allow space for trailing 0 */ lp = str; -- cgit v1.2.3 From e60639327a9233b8e2ec5c6303a279145dae9f99 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Tue, 12 Nov 2013 11:25:28 +0100 Subject: kern: remove register qualifiers * kern/priority.c: Remove register qualifiers. --- kern/priority.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/kern/priority.c b/kern/priority.c index 17541b8b..ddb8fd60 100644 --- a/kern/priority.c +++ b/kern/priority.c @@ -75,15 +75,15 @@ */ void thread_quantum_update(mycpu, thread, nticks, state) - register int mycpu; - register thread_t thread; + int mycpu; + thread_t thread; int nticks; int state; { - register int quantum; - register processor_t myprocessor; + int quantum; + processor_t myprocessor; #if NCPUS > 1 - register processor_set_t pset; + processor_set_t pset; #endif spl_t s; -- cgit v1.2.3 From 0bc878ba51a4b0d419ae2b33b4ca93863799532c Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Tue, 12 Nov 2013 11:30:37 +0100 Subject: kern: remove register qualifiers * kern/processor.c: Remove register qualifiers. --- kern/processor.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/kern/processor.c b/kern/processor.c index 55daf7fb..0cb99742 100644 --- a/kern/processor.c +++ b/kern/processor.c @@ -77,7 +77,7 @@ void processor_init(processor_t, int); */ void pset_sys_bootstrap(void) { - register int i; + int i; pset_init(&default_pset); default_pset.empty = FALSE; @@ -109,8 +109,8 @@ void pset_sys_bootstrap(void) */ void pset_sys_init(void) { - register int i; - register processor_t processor; + int i; + processor_t processor; /* * Allocate the cache for processor sets. @@ -138,7 +138,7 @@ void pset_sys_init(void) */ void pset_init( - register processor_set_t pset) + processor_set_t pset) { int i; @@ -189,7 +189,7 @@ void pset_init( */ void processor_init( - register processor_t pr, + processor_t pr, int slot_num) { int i; @@ -414,14 +414,14 @@ void pset_reference( kern_return_t processor_info( - register processor_t processor, + processor_t processor, int flavor, host_t *host, processor_info_t info, natural_t *count) { - register int slot_num, state; - register processor_basic_info_t basic_info; + int slot_num, state; + processor_basic_info_t basic_info; if (processor == PROCESSOR_NULL) return KERN_INVALID_ARGUMENT; @@ -503,7 +503,7 @@ void quantum_set( processor_set_t pset) { #if NCPUS > 1 - register int i,ncpus; + int i, ncpus; ncpus = pset->processor_count; @@ -567,8 +567,8 @@ processor_set_create( kern_return_t processor_set_destroy( processor_set_t pset) { - register queue_entry_t elem; - register queue_head_t *list; + queue_entry_t elem; + queue_head_t *list; if (pset == PROCESSOR_SET_NULL || pset == &default_pset) return KERN_INVALID_ARGUMENT; @@ -686,7 +686,7 @@ processor_set_info( return KERN_INVALID_ARGUMENT; if (flavor == PROCESSOR_SET_BASIC_INFO) { - register processor_set_basic_info_t basic_info; + processor_set_basic_info_t basic_info; if (*count < PROCESSOR_SET_BASIC_INFO_COUNT) return KERN_FAILURE; @@ -706,7 +706,7 @@ processor_set_info( return KERN_SUCCESS; } else if (flavor == PROCESSOR_SET_SCHED_INFO) { - register processor_set_sched_info_t sched_info; + processor_set_sched_info_t sched_info; if (*count < PROCESSOR_SET_SCHED_INFO_COUNT) return KERN_FAILURE; @@ -751,8 +751,8 @@ processor_set_max_priority( pset->max_priority = max_priority; if (change_threads) { - register queue_head_t *list; - register thread_t thread; + queue_head_t *list; + thread_t thread; list = &pset->threads; queue_iterate(list, thread, thread_t, pset_threads) { @@ -822,8 +822,8 @@ processor_set_policy_disable( pset->policies &= ~policy; if (change_threads) { - register queue_head_t *list; - register thread_t thread; + queue_head_t *list; + thread_t thread; list = &pset->threads; queue_iterate(list, thread, thread_t, pset_threads) { -- cgit v1.2.3 From ae271dd63c94a3c9a6a3dbde364718ec954eba7b Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Tue, 12 Nov 2013 11:35:10 +0100 Subject: kern: remove register qualifiers * kern/queue.c: Remove register qualifiers. --- kern/queue.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/kern/queue.c b/kern/queue.c index 98b74c20..d9396e54 100644 --- a/kern/queue.c +++ b/kern/queue.c @@ -35,8 +35,8 @@ * Insert element at head of queue. */ void enqueue_head( - register queue_t que, - register queue_entry_t elt) + queue_t que, + queue_entry_t elt) { elt->next = que->next; elt->prev = que; @@ -48,8 +48,8 @@ void enqueue_head( * Insert element at tail of queue. */ void enqueue_tail( - register queue_t que, - register queue_entry_t elt) + queue_t que, + queue_entry_t elt) { elt->next = que; elt->prev = que->prev; @@ -61,9 +61,9 @@ void enqueue_tail( * Remove and return element at head of queue. */ queue_entry_t dequeue_head( - register queue_t que) + queue_t que) { - register queue_entry_t elt; + queue_entry_t elt; if (que->next == que) return((queue_entry_t)0); @@ -78,9 +78,9 @@ queue_entry_t dequeue_head( * Remove and return element at tail of queue. */ queue_entry_t dequeue_tail( - register queue_t que) + queue_t que) { - register queue_entry_t elt; + queue_entry_t elt; if (que->prev == que) return((queue_entry_t)0); @@ -100,7 +100,7 @@ queue_entry_t dequeue_tail( /*ARGSUSED*/ void remqueue( queue_t que, - register queue_entry_t elt) + queue_entry_t elt) { elt->next->prev = elt->prev; elt->prev->next = elt->next; @@ -111,8 +111,8 @@ void remqueue( * package. */ void insque( - register struct queue_entry *entry, - register struct queue_entry *pred) + struct queue_entry *entry, + struct queue_entry *pred) { entry->next = pred->next; entry->prev = pred; @@ -122,7 +122,7 @@ void insque( struct queue_entry *remque( - register struct queue_entry *elt) + struct queue_entry *elt) { (elt->next)->prev = elt->prev; (elt->prev)->next = elt->next; -- cgit v1.2.3 From 34a5ac483318f079fc38dc5e114267e4657234cf Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Tue, 12 Nov 2013 11:37:54 +0100 Subject: kern: remove register qualifiers * kern/queue.h: Remove register qualifiers. --- kern/queue.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kern/queue.h b/kern/queue.h index 1846922a..8835ad61 100644 --- a/kern/queue.h +++ b/kern/queue.h @@ -206,7 +206,7 @@ void insque(queue_entry_t, queue_entry_t); */ #define queue_enter_first(head, elt, type, field) \ { \ - register queue_entry_t next; \ + queue_entry_t next; \ \ next = (head)->next; \ if ((head) == next) { \ @@ -239,7 +239,7 @@ void insque(queue_entry_t, queue_entry_t); */ #define queue_remove(head, elt, type, field) \ { \ - register queue_entry_t next, prev; \ + queue_entry_t next, prev; \ \ next = (elt)->field.next; \ prev = (elt)->field.prev; \ @@ -266,7 +266,7 @@ void insque(queue_entry_t, queue_entry_t); */ #define queue_remove_first(head, entry, type, field) \ { \ - register queue_entry_t next; \ + queue_entry_t next; \ \ (entry) = (type) ((head)->next); \ next = (entry)->field.next; \ @@ -289,7 +289,7 @@ void insque(queue_entry_t, queue_entry_t); */ #define queue_remove_last(head, entry, type, field) \ { \ - register queue_entry_t prev; \ + queue_entry_t prev; \ \ (entry) = (type) ((head)->prev); \ prev = (entry)->field.prev; \ -- cgit v1.2.3 From 90a9c03f6cec8df77e98d52acfda55bee6eaf965 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Tue, 12 Nov 2013 11:42:14 +0100 Subject: kern: remove register qualifiers * kern/sched.h: Remove register qualifiers. --- kern/sched.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kern/sched.h b/kern/sched.h index 942dd80f..ea601c5b 100644 --- a/kern/sched.h +++ b/kern/sched.h @@ -153,7 +153,7 @@ extern unsigned sched_tick; #define thread_timer_delta(thread) \ MACRO_BEGIN \ - register unsigned delta; \ + unsigned delta; \ \ delta = 0; \ TIMER_DELTA((thread)->system_timer, \ -- cgit v1.2.3 From b44b062d319d4b27c6b7e057e992f15a273621cc Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Tue, 12 Nov 2013 11:53:45 +0100 Subject: kern: remove register qualifiers * kern/sched_prim.c: Remove register qualifiers. --- kern/sched_prim.c | 166 +++++++++++++++++++++++++++--------------------------- 1 file changed, 83 insertions(+), 83 deletions(-) diff --git a/kern/sched_prim.c b/kern/sched_prim.c index 46b5df43..d378fa3a 100644 --- a/kern/sched_prim.c +++ b/kern/sched_prim.c @@ -150,7 +150,7 @@ decl_simple_lock_data(, wait_lock[NUMQUEUES]) void wait_queue_init(void) { - register int i; + int i; for (i = 0; i < NUMQUEUES; i++) { queue_init(&wait_queue[i]); @@ -199,8 +199,8 @@ void thread_timeout( void thread_set_timeout( int t) /* timeout interval in ticks */ { - register thread_t thread = current_thread(); - register spl_t s; + thread_t thread = current_thread(); + spl_t s; s = splsched(); thread_lock(thread); @@ -215,7 +215,7 @@ void thread_set_timeout( * Set up thread timeout element when thread is created. */ void thread_timeout_setup( - register thread_t thread) + thread_t thread) { thread->timer.fcn = thread_timeout; thread->timer.param = thread; @@ -233,11 +233,11 @@ void assert_wait( event_t event, boolean_t interruptible) { - register queue_t q; - register int index; - register thread_t thread; + queue_t q; + int index; + thread_t thread; #if MACH_SLOCKS - register simple_lock_t lock; + simple_lock_t lock; #endif /* MACH_SLOCKS */ spl_t s; @@ -288,16 +288,16 @@ void assert_wait( * interruptible. */ void clear_wait( - register thread_t thread, + thread_t thread, int result, boolean_t interrupt_only) { - register int index; - register queue_t q; + int index; + queue_t q; #if MACH_SLOCKS - register simple_lock_t lock; + simple_lock_t lock; #endif /* MACH_SLOCKS */ - register event_t event; + event_t event; spl_t s; s = splsched(); @@ -335,7 +335,7 @@ void clear_wait( simple_unlock(lock); } if (event == 0) { - register int state = thread->state; + int state = thread->state; reset_timeout_check(&thread->timer); @@ -394,14 +394,14 @@ void thread_wakeup_prim( boolean_t one_thread, int result) { - register queue_t q; - register int index; - register thread_t thread, next_th; + queue_t q; + int index; + thread_t thread, next_th; #if MACH_SLOCKS - register simple_lock_t lock; + simple_lock_t lock; #endif /* MACH_SLOCKS */ spl_t s; - register int state; + int state; index = wait_hash(event); q = &wait_queue[index]; @@ -509,9 +509,9 @@ void thread_bind( */ thread_t thread_select( - register processor_t myprocessor) + processor_t myprocessor) { - register thread_t thread; + thread_t thread; myprocessor->first_quantum = TRUE; /* @@ -523,7 +523,7 @@ thread_t thread_select( myprocessor->quantum = min_quantum; } else { - register processor_set_t pset; + processor_set_t pset; #if MACH_HOST pset = myprocessor->processor_set; @@ -559,7 +559,7 @@ thread_t thread_select( } } else { - register queue_t q; + queue_t q; /* * If there is a thread at hint, grab it, @@ -622,9 +622,9 @@ thread_t thread_select( */ boolean_t thread_invoke( - register thread_t old_thread, - continuation_t continuation, - register thread_t new_thread) + thread_t old_thread, + continuation_t continuation, + thread_t new_thread) { /* * Check for invoking the same thread. @@ -829,9 +829,9 @@ boolean_t thread_invoke( * Called at splsched. */ void thread_continue( - register thread_t old_thread) + thread_t old_thread) { - register continuation_t continuation = current_thread()->swap_func; + continuation_t continuation = current_thread()->swap_func; /* * We must dispatch the old thread and then @@ -865,9 +865,9 @@ void thread_continue( void thread_block( continuation_t continuation) { - register thread_t thread = current_thread(); - register processor_t myprocessor = cpu_to_processor(cpu_number()); - register thread_t new_thread; + thread_t thread = current_thread(); + processor_t myprocessor = cpu_to_processor(cpu_number()); + thread_t new_thread; spl_t s; check_simple_locks(); @@ -906,10 +906,10 @@ void thread_block( */ void thread_run( continuation_t continuation, - register thread_t new_thread) + thread_t new_thread) { - register thread_t thread = current_thread(); - register processor_t myprocessor = cpu_to_processor(cpu_number()); + thread_t thread = current_thread(); + processor_t myprocessor = cpu_to_processor(cpu_number()); spl_t s; check_simple_locks(); @@ -928,7 +928,7 @@ void thread_run( */ void thread_dispatch( - register thread_t thread) + thread_t thread) { /* * If we are discarding the thread's stack, we must do it @@ -1053,10 +1053,10 @@ shift_data_t wait_shift[32] = { */ void compute_priority( - register thread_t thread, + thread_t thread, boolean_t resched) { - register int pri; + int pri; #if MACH_FIXPRI if (thread->policy == POLICY_TIMESHARE) { @@ -1085,9 +1085,9 @@ void compute_priority( */ void compute_my_priority( - register thread_t thread) + thread_t thread) { - register int temp_pri; + int temp_pri; do_priority_computation(thread,temp_pri); thread->sched_pri = temp_pri; @@ -1132,11 +1132,11 @@ void recompute_priorities(void *param) * can only be called by the thread on itself. */ void update_priority( - register thread_t thread) + thread_t thread) { - register unsigned int ticks; - register shift_t shiftp; - register int temp_pri; + unsigned int ticks; + shift_t shiftp; + int temp_pri; ticks = sched_tick - thread->sched_stamp; @@ -1196,7 +1196,7 @@ void update_priority( #if DEBUG #define run_queue_enqueue(rq, th) \ MACRO_BEGIN \ - register unsigned int whichq; \ + unsigned int whichq; \ \ whichq = (th)->sched_pri; \ if (whichq >= NRQS) { \ @@ -1220,7 +1220,7 @@ void update_priority( #else /* DEBUG */ #define run_queue_enqueue(rq, th) \ MACRO_BEGIN \ - register unsigned int whichq; \ + unsigned int whichq; \ \ whichq = (th)->sched_pri; \ if (whichq >= NRQS) { \ @@ -1249,13 +1249,13 @@ void update_priority( */ void thread_setrun( - register thread_t th, + thread_t th, boolean_t may_preempt) { - register processor_t processor; - register run_queue_t rq; + processor_t processor; + run_queue_t rq; #if NCPUS > 1 - register processor_set_t pset; + processor_set_t pset; #endif /* NCPUS > 1 */ /* @@ -1423,7 +1423,7 @@ void set_pri( int pri, boolean_t resched) { - register struct run_queue *rq; + struct run_queue *rq; rq = rem_runq(th); th->sched_pri = pri; @@ -1448,7 +1448,7 @@ void set_pri( struct run_queue *rem_runq( thread_t th) { - register struct run_queue *rq; + struct run_queue *rq; rq = th->runq; /* @@ -1514,10 +1514,10 @@ thread_t choose_thread( processor_t myprocessor) { thread_t th; - register queue_t q; - register run_queue_t runq; - register int i; - register processor_set_t pset; + queue_t q; + run_queue_t runq; + int i; + processor_set_t pset; runq = &myprocessor->runq; @@ -1558,13 +1558,13 @@ thread_t choose_thread( */ thread_t choose_pset_thread( - register processor_t myprocessor, + processor_t myprocessor, processor_set_t pset) { - register run_queue_t runq; - register thread_t th; - register queue_t q; - register int i; + run_queue_t runq; + thread_t th; + queue_t q; + int i; runq = &pset->runq; @@ -1642,12 +1642,12 @@ int no_dispatch_count = 0; void idle_thread_continue(void) { - register processor_t myprocessor; - register volatile thread_t *threadp; - register volatile int *gcount; - register volatile int *lcount; - register thread_t new_thread; - register int state; + processor_t myprocessor; + volatile thread_t *threadp; + volatile int *gcount; + volatile int *lcount; + thread_t new_thread; + int state; int mycpu; spl_t s; @@ -1746,7 +1746,7 @@ retry: thread_run(idle_thread_continue, new_thread); } else if (state == PROCESSOR_IDLE) { - register processor_set_t pset; + processor_set_t pset; pset = myprocessor->processor_set; simple_lock(&pset->idle_lock); @@ -1797,7 +1797,7 @@ retry: void idle_thread(void) { - register thread_t self = current_thread(); + thread_t self = current_thread(); spl_t s; stack_privilege(self); @@ -1900,10 +1900,10 @@ boolean_t do_runq_scan( run_queue_t runq) { - register spl_t s; - register queue_t q; - register thread_t thread; - register int count; + spl_t s; + queue_t q; + thread_t thread; + int count; s = splsched(); simple_lock(&runq->lock); @@ -1964,11 +1964,11 @@ if (do_thread_scan_debug) void do_thread_scan(void) { - register spl_t s; - register boolean_t restart_needed = 0; - register thread_t thread; + spl_t s; + boolean_t restart_needed = 0; + thread_t thread; #if MACH_HOST - register processor_set_t pset; + processor_set_t pset; #endif /* MACH_HOST */ do { @@ -2014,10 +2014,10 @@ void checkrq( run_queue_t rq, char *msg) { - register queue_t q1; - register int i, j; - register queue_entry_t e; - register int low; + queue_t q1; + int i, j; + queue_entry_t e; + int low; low = -1; j = 0; @@ -2048,10 +2048,10 @@ void checkrq( } void thread_check( - register thread_t th, - register run_queue_t rq) + thread_t th, + run_queue_t rq) { - register unsigned int whichq; + unsigned int whichq; whichq = th->sched_pri; if (whichq >= NRQS) { -- cgit v1.2.3 From 2299788617bd2dca2e2c6f33df04ffa5c4ab8fe4 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Tue, 12 Nov 2013 14:09:42 +0100 Subject: kern: remove register qualifiers * kern/startup.c: Remove register qualifiers. --- kern/startup.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kern/startup.c b/kern/startup.c index 6dced433..5e35b987 100644 --- a/kern/startup.c +++ b/kern/startup.c @@ -210,7 +210,7 @@ void setup_main() */ void start_kernel_threads() { - register int i; + int i; /* * Create the idle threads and the other @@ -287,9 +287,9 @@ void slave_main() * First thread is specified for the master CPU. */ void cpu_launch_first_thread(th) - register thread_t th; + thread_t th; { - register int mycpu; + int mycpu; mycpu = cpu_number(); -- cgit v1.2.3 From de8345d35743652032f575d4b1afb6d2a5d2781f Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Tue, 12 Nov 2013 14:12:33 +0100 Subject: kern: remove register qualifiers * kern/strings.c: Remove register qualifiers. --- kern/strings.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/kern/strings.c b/kern/strings.c index 3676f98e..07527226 100644 --- a/kern/strings.c +++ b/kern/strings.c @@ -55,10 +55,10 @@ int strcmp( - register const char *s1, - register const char *s2) + const char *s1, + const char *s2) { - register unsigned int a, b; + unsigned int a, b; do { a = *s1++; @@ -82,11 +82,11 @@ strcmp( int strncmp( - register const char *s1, - register const char *s2, + const char *s1, + const char *s2, size_t n) { - register unsigned int a, b; + unsigned int a, b; while (n != 0) { a = *s1++; @@ -113,10 +113,10 @@ strncmp( char * strcpy( - register char *to, - register const char *from) + char *to, + const char *from) { - register char *ret = to; + char *ret = to; while ((*to++ = *from++) != '\0') continue; @@ -135,11 +135,11 @@ strcpy( char * strncpy( - register char *to, - register const char *from, - register size_t count) + char *to, + const char *from, + size_t count) { - register char *ret = to; + char *ret = to; while (count != 0) { count--; @@ -163,9 +163,9 @@ strncpy( size_t strlen( - register const char *string) + const char *string) { - register const char *ret = string; + const char *ret = string; while (*string++ != '\0') continue; -- cgit v1.2.3 From 4ade3db4326be52fd9b88a7880d42daaf8fabe9e Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Tue, 12 Nov 2013 14:14:56 +0100 Subject: kern: remove register qualifiers * kern/syscall_emulation.c: Remove register qualifiers. --- kern/syscall_emulation.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kern/syscall_emulation.c b/kern/syscall_emulation.c index c1c3096c..0f4a2bec 100644 --- a/kern/syscall_emulation.c +++ b/kern/syscall_emulation.c @@ -71,7 +71,7 @@ void eml_init() void eml_task_reference(task, parent) task_t task, parent; { - register eml_dispatch_t eml; + eml_dispatch_t eml; if (parent == TASK_NULL) eml = EML_DISPATCH_NULL; @@ -96,7 +96,7 @@ void eml_task_reference(task, parent) void eml_task_deallocate(task) task_t task; { - register eml_dispatch_t eml; + eml_dispatch_t eml; eml = task->eml_dispatch; if (eml != EML_DISPATCH_NULL) { -- cgit v1.2.3 From bdf7752a7899d2496e088ba91ca3e7c43bebac7d Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Tue, 12 Nov 2013 14:19:46 +0100 Subject: kern: remove register qualifiers * kern/syscall_subr.c: Remove register qualifiers. --- kern/syscall_subr.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/kern/syscall_subr.c b/kern/syscall_subr.c index 1a0ab933..77ea8223 100644 --- a/kern/syscall_subr.c +++ b/kern/syscall_subr.c @@ -68,7 +68,7 @@ void thread_depress_priority(thread_t, mach_msg_timeout_t); void swtch_continue(void) { - register processor_t myprocessor; + processor_t myprocessor; myprocessor = current_processor(); thread_syscall_return(myprocessor->runq.count > 0 || @@ -78,7 +78,7 @@ void swtch_continue(void) boolean_t swtch(void) { - register processor_t myprocessor; + processor_t myprocessor; #if NCPUS > 1 myprocessor = current_processor(); @@ -96,8 +96,8 @@ boolean_t swtch(void) void swtch_pri_continue(void) { - register thread_t thread = current_thread(); - register processor_t myprocessor; + thread_t thread = current_thread(); + processor_t myprocessor; if (thread->depress_priority >= 0) (void) thread_depress_abort(thread); @@ -110,8 +110,8 @@ void swtch_pri_continue(void) boolean_t swtch_pri(pri) int pri; { - register thread_t thread = current_thread(); - register processor_t myprocessor; + thread_t thread = current_thread(); + processor_t myprocessor; #if NCPUS > 1 myprocessor = current_processor(); @@ -138,7 +138,7 @@ boolean_t swtch_pri(pri) void thread_switch_continue(void) { - register thread_t cur_thread = current_thread(); + thread_t cur_thread = current_thread(); /* * Restore depressed priority @@ -162,8 +162,8 @@ mach_port_t thread_name; int option; mach_msg_timeout_t option_time; { - register thread_t cur_thread = current_thread(); - register processor_t myprocessor; + thread_t cur_thread = current_thread(); + processor_t myprocessor; ipc_port_t port; /* @@ -204,8 +204,8 @@ mach_msg_timeout_t option_time; * Get corresponding thread. */ if (ip_active(port) && (ip_kotype(port) == IKOT_THREAD)) { - register thread_t thread; - register spl_t s; + thread_t thread; + spl_t s; thread = (thread_t) port->ip_kobject; /* @@ -286,7 +286,7 @@ mach_msg_timeout_t option_time; */ void thread_depress_priority(thread, depress_time) -register thread_t thread; +thread_t thread; mach_msg_timeout_t depress_time; { unsigned int ticks; @@ -324,7 +324,7 @@ mach_msg_timeout_t depress_time; */ void thread_depress_timeout(thread) -register thread_t thread; +thread_t thread; { spl_t s; @@ -353,7 +353,7 @@ register thread_t thread; */ kern_return_t thread_depress_abort(thread) -register thread_t thread; +thread_t thread; { spl_t s; -- cgit v1.2.3 From 8f9e4dbcbf2765ec25e7978609a471f374ae43db Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Tue, 12 Nov 2013 14:26:28 +0100 Subject: kern: remove register qualifiers * kern/task.c: Remove register qualifiers. --- kern/task.c | 68 ++++++++++++++++++++++++++++++------------------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/kern/task.c b/kern/task.c index 114dd319..f62e47be 100644 --- a/kern/task.c +++ b/kern/task.c @@ -78,8 +78,8 @@ kern_return_t task_create( boolean_t inherit_memory, task_t *child_task) /* OUT */ { - register task_t new_task; - register processor_set_t pset; + task_t new_task; + processor_set_t pset; #if FAST_TAS int i; #endif @@ -181,10 +181,10 @@ kern_return_t task_create( * is never in this task. */ void task_deallocate( - register task_t task) + task_t task) { - register int c; - register processor_set_t pset; + int c; + processor_set_t pset; if (task == TASK_NULL) return; @@ -210,7 +210,7 @@ void task_deallocate( } void task_reference( - register task_t task) + task_t task) { if (task == TASK_NULL) return; @@ -227,11 +227,11 @@ void task_reference( * (kern/thread.c) about problems with terminating the "current task." */ kern_return_t task_terminate( - register task_t task) + task_t task) { - register thread_t thread, cur_thread; - register queue_head_t *list; - register task_t cur_task; + thread_t thread, cur_thread; + queue_head_t *list; + task_t cur_task; spl_t s; if (task == TASK_NULL) @@ -402,10 +402,10 @@ kern_return_t task_terminate( * suspends is maintained. */ kern_return_t task_hold( - register task_t task) + task_t task) { - register queue_head_t *list; - register thread_t thread, cur_thread; + queue_head_t *list; + thread_t thread, cur_thread; cur_thread = current_thread(); @@ -441,12 +441,12 @@ kern_return_t task_hold( * must_wait is true. */ kern_return_t task_dowait( - register task_t task, + task_t task, boolean_t must_wait) { - register queue_head_t *list; - register thread_t thread, cur_thread, prev_thread; - register kern_return_t ret = KERN_SUCCESS; + queue_head_t *list; + thread_t thread, cur_thread, prev_thread; + kern_return_t ret = KERN_SUCCESS; /* * Iterate through all the threads. @@ -493,10 +493,10 @@ kern_return_t task_dowait( } kern_return_t task_release( - register task_t task) + task_t task) { - register queue_head_t *list; - register thread_t thread, next; + queue_head_t *list; + thread_t thread, next; task_lock(task); if (!task->active) { @@ -624,9 +624,9 @@ kern_return_t task_threads( } kern_return_t task_suspend( - register task_t task) + task_t task) { - register boolean_t hold; + boolean_t hold; if (task == TASK_NULL) return KERN_INVALID_ARGUMENT; @@ -675,9 +675,9 @@ kern_return_t task_suspend( } kern_return_t task_resume( - register task_t task) + task_t task) { - register boolean_t release; + boolean_t release; if (task == TASK_NULL) return KERN_INVALID_ARGUMENT; @@ -717,7 +717,7 @@ kern_return_t task_info( switch (flavor) { case TASK_BASIC_INFO: { - register task_basic_info_t basic_info; + task_basic_info_t basic_info; /* Allow *task_info_count to be two words smaller than the usual amount, because creation_time is a new member @@ -756,7 +756,7 @@ kern_return_t task_info( case TASK_EVENTS_INFO: { - register task_events_info_t event_info; + task_events_info_t event_info; if (*task_info_count < TASK_EVENTS_INFO_COUNT) { return KERN_INVALID_ARGUMENT; @@ -780,8 +780,8 @@ kern_return_t task_info( case TASK_THREAD_TIMES_INFO: { - register task_thread_times_info_t times_info; - register thread_t thread; + task_thread_times_info_t times_info; + thread_t thread; if (*task_info_count < TASK_THREAD_TIMES_INFO_COUNT) { return KERN_INVALID_ARGUMENT; @@ -837,9 +837,9 @@ task_assign( boolean_t assign_threads) { kern_return_t ret = KERN_SUCCESS; - register thread_t thread, prev_thread; - register queue_head_t *list; - register processor_set_t pset; + thread_t thread, prev_thread; + queue_head_t *list; + processor_set_t pset; if (task == TASK_NULL || new_pset == PROCESSOR_SET_NULL) { return KERN_INVALID_ARGUMENT; @@ -1055,8 +1055,8 @@ task_priority( task->priority = priority; if (change_threads) { - register thread_t thread; - register queue_head_t *list; + thread_t thread; + queue_head_t *list; list = &task->thread_list; queue_iterate(list, thread, thread_t, thread_list) { @@ -1078,7 +1078,7 @@ task_priority( void task_collect_scan(void) { - register task_t task, prev_task; + task_t task, prev_task; processor_set_t pset, prev_pset; prev_task = TASK_NULL; -- cgit v1.2.3 From fb74fda7e9b254cc3ee01726f78583e3c5f2260d Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Tue, 12 Nov 2013 14:36:10 +0100 Subject: kern: remove register qualifiers * kern/thread.c: Remove register qualifiers. --- kern/thread.c | 94 +++++++++++++++++++++++++++++------------------------------ 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/kern/thread.c b/kern/thread.c index 79f526a2..eb8a8bbe 100644 --- a/kern/thread.c +++ b/kern/thread.c @@ -149,7 +149,7 @@ boolean_t stack_alloc_try( thread_t thread, void (*resume)(thread_t)) { - register vm_offset_t stack; + vm_offset_t stack; stack_lock(); stack = stack_free_list; @@ -230,7 +230,7 @@ void stack_alloc( void stack_free( thread_t thread) { - register vm_offset_t stack; + vm_offset_t stack; stack = stack_detach(thread); @@ -253,7 +253,7 @@ void stack_free( void stack_collect(void) { - register vm_offset_t stack; + vm_offset_t stack; spl_t s; s = splsched(); @@ -285,7 +285,7 @@ void stack_collect(void) */ void stack_privilege( - register thread_t thread) + thread_t thread) { /* * This implementation only works for the current thread. @@ -398,11 +398,11 @@ void thread_init(void) } kern_return_t thread_create( - register task_t parent_task, + task_t parent_task, thread_t *child_thread) /* OUT */ { - register thread_t new_thread; - register processor_set_t pset; + thread_t new_thread; + processor_set_t pset; if (parent_task == TASK_NULL) return KERN_INVALID_ARGUMENT; @@ -575,11 +575,11 @@ kern_return_t thread_create( unsigned int thread_deallocate_stack = 0; void thread_deallocate( - register thread_t thread) + thread_t thread) { spl_t s; - register task_t task; - register processor_set_t pset; + task_t task; + processor_set_t pset; time_value_t user_time, system_time; @@ -710,7 +710,7 @@ void thread_deallocate( } void thread_reference( - register thread_t thread) + thread_t thread) { spl_t s; @@ -744,10 +744,10 @@ void thread_reference( * since it needs a kernel stack to execute.) */ kern_return_t thread_terminate( - register thread_t thread) + thread_t thread) { - register thread_t cur_thread = current_thread(); - register task_t cur_task; + thread_t cur_thread = current_thread(); + task_t cur_task; spl_t s; if (thread == THREAD_NULL) @@ -859,7 +859,7 @@ kern_return_t thread_terminate( */ void thread_force_terminate( - register thread_t thread) + thread_t thread) { boolean_t deallocate_here; spl_t s; @@ -901,11 +901,11 @@ thread_force_terminate( * */ kern_return_t thread_halt( - register thread_t thread, + thread_t thread, boolean_t must_halt) { - register thread_t cur_thread = current_thread(); - register kern_return_t ret; + thread_t cur_thread = current_thread(); + kern_return_t ret; spl_t s; if (thread == cur_thread) @@ -1115,7 +1115,7 @@ void walking_zombie(void) */ void thread_halt_self(void) { - register thread_t thread = current_thread(); + thread_t thread = current_thread(); spl_t s; if (thread->ast & AST_TERMINATE) { @@ -1169,7 +1169,7 @@ void thread_halt_self(void) * suspends is maintained. */ void thread_hold( - register thread_t thread) + thread_t thread) { spl_t s; @@ -1191,11 +1191,11 @@ void thread_hold( */ kern_return_t thread_dowait( - register thread_t thread, + thread_t thread, boolean_t must_halt) { - register boolean_t need_wakeup; - register kern_return_t ret = KERN_SUCCESS; + boolean_t need_wakeup; + kern_return_t ret = KERN_SUCCESS; spl_t s; if (thread == current_thread()) @@ -1295,7 +1295,7 @@ thread_dowait( } void thread_release( - register thread_t thread) + thread_t thread) { spl_t s; @@ -1314,9 +1314,9 @@ void thread_release( } kern_return_t thread_suspend( - register thread_t thread) + thread_t thread) { - register boolean_t hold; + boolean_t hold; spl_t spl; if (thread == THREAD_NULL) @@ -1360,9 +1360,9 @@ kern_return_t thread_suspend( kern_return_t thread_resume( - register thread_t thread) + thread_t thread) { - register kern_return_t ret; + kern_return_t ret; spl_t s; if (thread == THREAD_NULL) @@ -1398,7 +1398,7 @@ kern_return_t thread_resume( * Return thread's machine-dependent state. */ kern_return_t thread_get_state( - register thread_t thread, + thread_t thread, int flavor, thread_state_t old_state, /* pointer to OUT array */ natural_t *old_state_count) /*IN/OUT*/ @@ -1422,7 +1422,7 @@ kern_return_t thread_get_state( * Change thread's machine-dependent state. */ kern_return_t thread_set_state( - register thread_t thread, + thread_t thread, int flavor, thread_state_t new_state, natural_t new_state_count) @@ -1443,7 +1443,7 @@ kern_return_t thread_set_state( } kern_return_t thread_info( - register thread_t thread, + thread_t thread, int flavor, thread_info_t thread_info_out, /* pointer to OUT array */ natural_t *thread_info_count) /*IN/OUT*/ @@ -1455,7 +1455,7 @@ kern_return_t thread_info( return KERN_INVALID_ARGUMENT; if (flavor == THREAD_BASIC_INFO) { - register thread_basic_info_t basic_info; + thread_basic_info_t basic_info; /* Allow *thread_info_count to be one smaller than the usual amount, because creation_time is a new member @@ -1541,7 +1541,7 @@ kern_return_t thread_info( return KERN_SUCCESS; } else if (flavor == THREAD_SCHED_INFO) { - register thread_sched_info_t sched_info; + thread_sched_info_t sched_info; if (*thread_info_count < THREAD_SCHED_INFO_COUNT) { return KERN_INVALID_ARGUMENT; @@ -1583,7 +1583,7 @@ kern_return_t thread_info( } kern_return_t thread_abort( - register thread_t thread) + thread_t thread) { if (thread == THREAD_NULL || thread == current_thread()) { return KERN_INVALID_ARGUMENT; @@ -1677,7 +1677,7 @@ thread_t kernel_thread( void reaper_thread_continue(void) { for (;;) { - register thread_t thread; + thread_t thread; spl_t s; s = splsched(); @@ -1792,12 +1792,12 @@ thread_unfreeze( void thread_doassign( - register thread_t thread, - register processor_set_t new_pset, + thread_t thread, + processor_set_t new_pset, boolean_t release_freeze) { - register processor_set_t pset; - register boolean_t old_empty, new_empty; + processor_set_t pset; + boolean_t old_empty, new_empty; boolean_t recompute_pri = FALSE; spl_t s; @@ -2100,8 +2100,8 @@ thread_policy( int data) { #if MACH_FIXPRI - register kern_return_t ret = KERN_SUCCESS; - register int temp; + kern_return_t ret = KERN_SUCCESS; + int temp; spl_t s; #endif /* MACH_FIXPRI */ @@ -2304,7 +2304,7 @@ void consider_thread_collect(void) #if MACH_DEBUG vm_size_t stack_usage( - register vm_offset_t stack) + vm_offset_t stack) { int i; @@ -2321,7 +2321,7 @@ vm_size_t stack_usage( */ void stack_init( - register vm_offset_t stack) + vm_offset_t stack) { if (stack_check_usage) { int i; @@ -2337,7 +2337,7 @@ void stack_init( */ void stack_finalize( - register vm_offset_t stack) + vm_offset_t stack) { if (stack_check_usage) { vm_size_t used = stack_usage(stack); @@ -2430,8 +2430,8 @@ kern_return_t processor_set_stack_usage( vm_size_t maxusage; vm_offset_t maxstack; - register thread_t *threads; - register thread_t tmp_thread; + thread_t *threads; + thread_t tmp_thread; unsigned int actual; /* this many things */ unsigned int i; @@ -2549,7 +2549,7 @@ kern_return_t processor_set_stack_usage( void thread_stats(void) { - register thread_t thread; + thread_t thread; int total = 0, rpcreply = 0; queue_iterate(&default_pset.threads, thread, thread_t, pset_threads) { -- cgit v1.2.3 From ccfb0c2cd0154c18d0b885e6afcfaeebb7a8160b Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Tue, 12 Nov 2013 14:38:19 +0100 Subject: kern: remove register qualifiers * kern/thread_swap.c: Remove register qualifiers. --- kern/thread_swap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kern/thread_swap.c b/kern/thread_swap.c index f29bd5b7..e76511e6 100644 --- a/kern/thread_swap.c +++ b/kern/thread_swap.c @@ -125,7 +125,7 @@ void thread_swapin(thread) * likely that this routine will sleep (waiting for stack allocation). */ void thread_doswapin(thread) - register thread_t thread; + thread_t thread; { spl_t s; @@ -157,7 +157,7 @@ void thread_doswapin(thread) void swapin_thread_continue(void) { for (;;) { - register thread_t thread; + thread_t thread; spl_t s; s = splsched(); -- cgit v1.2.3 From cfb9fea2fafc51e878a1f446a024c02abd17b04d Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Tue, 12 Nov 2013 14:41:18 +0100 Subject: kern: remove register qualifiers * kern/timer.c: Remove register qualifiers. --- kern/timer.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/kern/timer.c b/kern/timer.c index ec0524a8..124227ce 100644 --- a/kern/timer.c +++ b/kern/timer.c @@ -49,8 +49,8 @@ void timer_init(); /* forward */ */ void init_timers() { - register int i; - register timer_t this_timer; + int i; + timer_t this_timer; /* * Initialize all the kernel timers and start the one @@ -69,7 +69,6 @@ void init_timers() * timer_init initializes a single timer. */ void timer_init(this_timer) -register timer_t this_timer; { this_timer->low_bits = 0; @@ -442,7 +441,7 @@ void thread_read_times(thread, user_time_p, system_time_p) time_value_t *system_time_p; { timer_save_data_t temp; - register timer_t timer; + timer_t timer; timer = &thread->user_timer; timer_grab(timer, &temp); @@ -476,7 +475,7 @@ void db_thread_read_times(thread, user_time_p, system_time_p) time_value_t *system_time_p; { timer_save_data_t temp; - register timer_t timer; + timer_t timer; timer = &thread->user_timer; db_timer_grab(timer, &temp); @@ -511,7 +510,7 @@ timer_t timer; timer_save_t save; { timer_save_data_t new_save; - register unsigned result; + unsigned result; timer_grab(timer,&new_save); result = (new_save.high - save->high) * TIMER_HIGH_UNIT + -- cgit v1.2.3 From 5b4c30b91a052e6ae13025577b1ab323ef836bed Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Tue, 12 Nov 2013 14:42:30 +0100 Subject: kern: remove register qualifiers * kern/timer.h: Remove register qualifiers. --- kern/timer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kern/timer.h b/kern/timer.h index 817fa356..f2154ddc 100644 --- a/kern/timer.h +++ b/kern/timer.h @@ -168,7 +168,7 @@ extern void time_int_exit(unsigned, timer_t); #define TIMER_DELTA(timer, save, result) \ MACRO_BEGIN \ - register unsigned temp; \ + unsigned temp; \ \ temp = (timer).low_bits; \ if ((save).high != (timer).high_bits_check) { \ -- cgit v1.2.3 From 7924754e3005efd978a7847e15606dbcdd929cfc Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Tue, 12 Nov 2013 14:45:01 +0100 Subject: kern: remove register qualifiers * kern/xpr.c: Remove register qualifiers. --- kern/xpr.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kern/xpr.c b/kern/xpr.c index 465ba7bb..af871a27 100644 --- a/kern/xpr.c +++ b/kern/xpr.c @@ -60,8 +60,8 @@ void xpr(msg, arg1, arg2, arg3, arg4, arg5) char *msg; int arg1, arg2, arg3, arg4, arg5; { - register spl_t s; - register struct xprbuf *x; + spl_t s; + struct xprbuf *x; /* If we aren't initialized, ignore trace request */ if (!xprenable || (xprptr == 0)) @@ -152,7 +152,7 @@ void xpr_dump(base, nbufs) jmp_buf_t db_jmpbuf; jmp_buf_t *prev; struct xprbuf *last, *ptr; - register struct xprbuf *x; + struct xprbuf *x; int i; spl_t s; -- cgit v1.2.3 From d02bd4542698cf63f371c64947f7d31a6d3cf6bf Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Wed, 13 Nov 2013 16:40:38 +0100 Subject: vm/memory_object.c: remove register qualifiers * vm/memory_object.c: Remove register qualifiers. --- vm/memory_object.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/vm/memory_object.c b/vm/memory_object.c index 8315182a..404ae73c 100644 --- a/vm/memory_object.c +++ b/vm/memory_object.c @@ -84,9 +84,7 @@ decl_simple_lock_data(,memory_manager_default_lock) kern_return_t memory_object_data_supply(object, offset, data_copy, data_cnt, lock_value, precious, reply_to, reply_to_type) - register vm_object_t object; - register vm_offset_t offset; vm_map_copy_t data_copy; unsigned int data_cnt; @@ -97,9 +95,7 @@ kern_return_t memory_object_data_supply(object, offset, data_copy, data_cnt, { kern_return_t result = KERN_SUCCESS; vm_offset_t error_offset = 0; - register vm_page_t m; - register vm_page_t data_m; vm_size_t original_length; vm_offset_t original_offset; @@ -341,7 +337,7 @@ kern_return_t memory_object_data_error(object, offset, size, error_value) offset -= object->paging_offset; while (size != 0) { - register vm_page_t m; + vm_page_t m; m = vm_page_lookup(object, offset); if ((m != VM_PAGE_NULL) && m->busy && m->absent) { @@ -401,7 +397,7 @@ kern_return_t memory_object_data_unavailable(object, offset, size) offset -= object->paging_offset; while (size != 0) { - register vm_page_t m; + vm_page_t m; /* * We're looking for pages that are both busy and @@ -654,16 +650,16 @@ kern_return_t memory_object_lock_request(object, offset, size, should_return, should_flush, prot, reply_to, reply_to_type) - register vm_object_t object; - register vm_offset_t offset; - register vm_size_t size; + vm_object_t object; + vm_offset_t offset; + vm_size_t size; memory_object_return_t should_return; boolean_t should_flush; vm_prot_t prot; ipc_port_t reply_to; mach_msg_type_name_t reply_to_type; { - register vm_page_t m; + vm_page_t m; vm_offset_t original_offset = offset; vm_size_t original_size = size; vm_offset_t paging_offset = 0; @@ -715,8 +711,8 @@ memory_object_lock_request(object, offset, size, #define PAGEOUT_PAGES \ MACRO_BEGIN \ vm_map_copy_t copy; \ - register int i; \ - register vm_page_t hp; \ + int i; \ + vm_page_t hp; \ \ vm_object_unlock(object); \ \ -- cgit v1.2.3 From 70b0570aa7c573c91b2d88fb32d1b67bffa9050a Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Wed, 13 Nov 2013 16:40:39 +0100 Subject: vm/memory_object_proxy.h: fix definition * vm/memory_object_proxy.h (_VM_MEMORY_OBJECT_PROXY_H_): Fix definition. --- vm/memory_object_proxy.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vm/memory_object_proxy.h b/vm/memory_object_proxy.h index f4be0d0d..8c2bc0f8 100644 --- a/vm/memory_object_proxy.h +++ b/vm/memory_object_proxy.h @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */ #ifndef _VM_MEMORY_OBJECT_PROXY_H_ -#define _VM_MEMORY_OBJECT_PROXT_H_ +#define _VM_MEMORY_OBJECT_PROXY_H_ #include #include @@ -45,4 +45,4 @@ extern kern_return_t memory_object_proxy_lookup (ipc_port_t port, ipc_port_t *object, vm_prot_t *max_protection); -#endif /* _VM_MEMORY_OBJECT_PROXT_H_ */ +#endif /* _VM_MEMORY_OBJECT_PROXY_H_ */ -- cgit v1.2.3 From 430d01080cb3fbe65fda64160b84df8075b6fd94 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Wed, 13 Nov 2013 16:40:41 +0100 Subject: vm/vm_fault.c: remove unused variable * vm/vm_fault.c: Remove unused variable. --- vm/vm_fault.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/vm/vm_fault.c b/vm/vm_fault.c index 7e849616..97086a0d 100644 --- a/vm/vm_fault.c +++ b/vm/vm_fault.c @@ -88,8 +88,6 @@ struct kmem_cache vm_fault_state_cache; int vm_object_absent_max = 50; -int vm_fault_debug = 0; - boolean_t vm_fault_dirty_handling = FALSE; boolean_t vm_fault_interruptible = TRUE; -- cgit v1.2.3 From a4af38f65af1c1780d8deeade8cbb63f9e322243 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Wed, 13 Nov 2013 16:40:42 +0100 Subject: vm/vm_fault.c: remove register qualifiers * vm/vm_fault.c: Remove register qualifiers. --- vm/vm_fault.c | 40 +++++++++++++++++----------------------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/vm/vm_fault.c b/vm/vm_fault.c index 97086a0d..4b30f98d 100644 --- a/vm/vm_fault.c +++ b/vm/vm_fault.c @@ -124,8 +124,8 @@ void vm_fault_init(void) */ void vm_fault_cleanup(object, top_page) - register vm_object_t object; - register vm_page_t top_page; + vm_object_t object; + vm_page_t top_page; { vm_object_paging_end(object); vm_object_unlock(object); @@ -224,11 +224,8 @@ vm_fault_return_t vm_fault_page(first_object, first_offset, boolean_t resume; /* We are restarting. */ void (*continuation)(); /* Continuation for blocking. */ { - register vm_page_t m; - register vm_object_t object; - register vm_offset_t offset; vm_page_t first_m; vm_object_t next_object; @@ -237,7 +234,7 @@ vm_fault_return_t vm_fault_page(first_object, first_offset, vm_prot_t access_required; if (resume) { - register vm_fault_state_t *state = + vm_fault_state_t *state = (vm_fault_state_t *) current_thread()->ith_other; if (state->vmfp_backoff) @@ -355,7 +352,7 @@ vm_fault_return_t vm_fault_page(first_object, first_offset, PAGE_ASSERT_WAIT(m, interruptible); vm_object_unlock(object); if (continuation != (void (*)()) 0) { - register vm_fault_state_t *state = + vm_fault_state_t *state = (vm_fault_state_t *) current_thread()->ith_other; /* @@ -1092,7 +1089,7 @@ vm_fault_return_t vm_fault_page(first_object, first_offset, vm_fault_cleanup(object, first_m); if (continuation != (void (*)()) 0) { - register vm_fault_state_t *state = + vm_fault_state_t *state = (vm_fault_state_t *) current_thread()->ith_other; /* @@ -1141,7 +1138,7 @@ vm_fault_return_t vm_fault_page(first_object, first_offset, void vm_fault_continue() { - register vm_fault_state_t *state = + vm_fault_state_t *state = (vm_fault_state_t *) current_thread()->ith_other; (void) vm_fault(state->vmf_map, @@ -1171,11 +1168,10 @@ kern_return_t vm_fault(map, vaddr, fault_type, change_wiring, vm_page_t top_page; /* Placeholder page */ kern_return_t kr; - register vm_page_t m; /* Fast access to result_page */ if (resume) { - register vm_fault_state_t *state = + vm_fault_state_t *state = (vm_fault_state_t *) current_thread()->ith_other; /* @@ -1251,7 +1247,7 @@ kern_return_t vm_fault(map, vaddr, fault_type, change_wiring, vm_object_paging_begin(object); if (continuation != (void (*)()) 0) { - register vm_fault_state_t *state = + vm_fault_state_t *state = (vm_fault_state_t *) current_thread()->ith_other; /* @@ -1488,7 +1484,7 @@ kern_return_t vm_fault(map, vaddr, fault_type, change_wiring, done: if (continuation != (void (*)()) 0) { - register vm_fault_state_t *state = + vm_fault_state_t *state = (vm_fault_state_t *) current_thread()->ith_other; kmem_cache_free(&vm_fault_state_cache, (vm_offset_t) state); @@ -1511,9 +1507,9 @@ void vm_fault_wire(map, entry) vm_map_entry_t entry; { - register vm_offset_t va; - register pmap_t pmap; - register vm_offset_t end_addr = entry->vme_end; + vm_offset_t va; + pmap_t pmap; + vm_offset_t end_addr = entry->vme_end; pmap = vm_map_pmap(map); @@ -1546,10 +1542,10 @@ void vm_fault_unwire(map, entry) vm_map_t map; vm_map_entry_t entry; { - register vm_offset_t va; - register pmap_t pmap; - register vm_offset_t end_addr = entry->vme_end; - vm_object_t object; + vm_offset_t va; + pmap_t pmap; + vm_offset_t end_addr = entry->vme_end; + vm_object_t object; pmap = vm_map_pmap(map); @@ -1638,7 +1634,7 @@ kern_return_t vm_fault_wire_fast(map, va, entry) { vm_object_t object; vm_offset_t offset; - register vm_page_t m; + vm_page_t m; vm_prot_t prot; vm_stat.faults++; /* needs lock XXX */ @@ -2021,12 +2017,10 @@ kern_return_t vm_fault_copy( * could be used in vm_fault_copy() to advantage. */ vm_fault_return_t vm_fault_page_overwrite(dst_object, dst_offset, result_page) - register vm_object_t dst_object; vm_offset_t dst_offset; vm_page_t *result_page; /* OUT */ { - register vm_page_t dst_page; #define interruptible FALSE /* XXX */ -- cgit v1.2.3 From 7600e415982ecdce39c7b51804b88543251b2136 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Wed, 13 Nov 2013 16:40:43 +0100 Subject: vm/vm_kern.c: remove register qualifiers * vm/vm_kern.c: Remove register qualifiers. --- vm/vm_kern.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/vm/vm_kern.c b/vm/vm_kern.c index fd46e982..ddbe555e 100644 --- a/vm/vm_kern.c +++ b/vm/vm_kern.c @@ -715,10 +715,10 @@ kmem_free(map, addr, size) */ void kmem_alloc_pages(object, offset, start, end, protection) - register vm_object_t object; - register vm_offset_t offset; - register vm_offset_t start, end; - vm_prot_t protection; + vm_object_t object; + vm_offset_t offset; + vm_offset_t start, end; + vm_prot_t protection; { /* * Mark the pmap region as not pageable. @@ -726,7 +726,7 @@ kmem_alloc_pages(object, offset, start, end, protection) pmap_pageable(kernel_pmap, start, end, FALSE); while (start < end) { - register vm_page_t mem; + vm_page_t mem; vm_object_lock(object); @@ -770,10 +770,10 @@ kmem_alloc_pages(object, offset, start, end, protection) */ void kmem_remap_pages(object, offset, start, end, protection) - register vm_object_t object; - register vm_offset_t offset; - register vm_offset_t start, end; - vm_prot_t protection; + vm_object_t object; + vm_offset_t offset; + vm_offset_t start, end; + vm_prot_t protection; { /* * Mark the pmap region as not pageable. @@ -781,7 +781,7 @@ kmem_remap_pages(object, offset, start, end, protection) pmap_pageable(kernel_pmap, start, end, FALSE); while (start < end) { - register vm_page_t mem; + vm_page_t mem; vm_object_lock(object); @@ -918,10 +918,8 @@ kmem_io_map_copyout(map, addr, alloc_addr, alloc_size, copy, min_size) vm_offset_t myaddr, offset; vm_size_t mysize, copy_size; kern_return_t ret; - register vm_page_t *page_list; vm_map_copy_t new_copy; - register int i; assert(copy->type == VM_MAP_COPY_PAGE_LIST); -- cgit v1.2.3 From d3d2483836501974e85c28133138d8e2e14a7c5f Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Wed, 13 Nov 2013 16:40:45 +0100 Subject: vm/vm_map.c: trivial stylistic fix for consistency * vm/vm_map.c: Trivial stylistic fix for consistency. --- vm/vm_map.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vm/vm_map.c b/vm/vm_map.c index 2be71471..a9a991ef 100644 --- a/vm/vm_map.c +++ b/vm/vm_map.c @@ -4887,6 +4887,6 @@ void vm_map_copy_print(copy) break; } - indent -=2; + indent -= 2; } #endif /* MACH_KDB */ -- cgit v1.2.3 From 1c75d87b8845af2b109063bc5ef5ddd782543739 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Wed, 13 Nov 2013 16:40:44 +0100 Subject: vm/vm_map.c: remove register qualifiers * vm/vm_map.c: Remove register qualifiers. --- vm/vm_map.c | 198 ++++++++++++++++++++++++++---------------------------------- 1 file changed, 87 insertions(+), 111 deletions(-) diff --git a/vm/vm_map.c b/vm/vm_map.c index a9a991ef..ce1ab237 100644 --- a/vm/vm_map.c +++ b/vm/vm_map.c @@ -248,7 +248,7 @@ vm_map_t vm_map_create(pmap, min, max, pageable) vm_offset_t min, max; boolean_t pageable; { - register vm_map_t result; + vm_map_t result; result = (vm_map_t) kmem_cache_alloc(&vm_map_cache); if (result == VM_MAP_NULL) @@ -272,10 +272,10 @@ vm_map_t vm_map_create(pmap, min, max, pageable) _vm_map_entry_create(&(copy)->cpy_hdr) vm_map_entry_t _vm_map_entry_create(map_header) - register struct vm_map_header *map_header; + struct vm_map_header *map_header; { - register kmem_cache_t cache; - register vm_map_entry_t entry; + kmem_cache_t cache; + vm_map_entry_t entry; if (map_header->entries_pageable) cache = &vm_map_entry_cache; @@ -301,10 +301,10 @@ vm_map_entry_t _vm_map_entry_create(map_header) _vm_map_entry_dispose(&(copy)->cpy_hdr, (entry)) void _vm_map_entry_dispose(map_header, entry) - register struct vm_map_header *map_header; - register vm_map_entry_t entry; + struct vm_map_header *map_header; + vm_map_entry_t entry; { - register kmem_cache_t cache; + kmem_cache_t cache; if (map_header->entries_pageable) cache = &vm_map_entry_cache; @@ -387,7 +387,7 @@ static inline int vm_map_entry_cmp_insert(const struct rbtree_node *a, * */ void vm_map_reference(map) - register vm_map_t map; + vm_map_t map; { if (map == VM_MAP_NULL) return; @@ -405,9 +405,9 @@ void vm_map_reference(map) * The map should not be locked. */ void vm_map_deallocate(map) - register vm_map_t map; + vm_map_t map; { - register int c; + int c; if (map == VM_MAP_NULL) return; @@ -450,12 +450,12 @@ void vm_map_deallocate(map) * actually contained in the map. */ boolean_t vm_map_lookup_entry(map, address, entry) - register vm_map_t map; - register vm_offset_t address; - vm_map_entry_t *entry; /* OUT */ + vm_map_t map; + vm_offset_t address; + vm_map_entry_t *entry; /* OUT */ { - register struct rbtree_node *node; - register vm_map_entry_t hint; + struct rbtree_node *node; + vm_map_entry_t hint; /* * First, make a quick check to see if we are already @@ -534,16 +534,16 @@ invalid_user_access(map, start, end, prot) * then an existing entry may be extended. */ kern_return_t vm_map_find_entry(map, address, size, mask, object, o_entry) - register vm_map_t map; + vm_map_t map; vm_offset_t *address; /* OUT */ vm_size_t size; vm_offset_t mask; vm_object_t object; vm_map_entry_t *o_entry; /* OUT */ { - register vm_map_entry_t entry, new_entry; - register vm_offset_t start; - register vm_offset_t end; + vm_map_entry_t entry, new_entry; + vm_offset_t start; + vm_offset_t end; /* * Look for the first possible address; @@ -562,7 +562,7 @@ kern_return_t vm_map_find_entry(map, address, size, mask, object, o_entry) */ while (TRUE) { - register vm_map_entry_t next; + vm_map_entry_t next; /* * Find the end of the proposed new region. @@ -707,17 +707,14 @@ int vm_map_pmap_enter_enable = FALSE; void vm_map_pmap_enter(map, addr, end_addr, object, offset, protection) vm_map_t map; - register vm_offset_t addr; - register vm_offset_t end_addr; - register vm_object_t object; vm_offset_t offset; vm_prot_t protection; { while (addr < end_addr) { - register vm_page_t m; + vm_page_t m; vm_object_lock(object); vm_object_paging_begin(object); @@ -770,7 +767,6 @@ kern_return_t vm_map_enter( address, size, mask, anywhere, object, offset, needs_copy, cur_protection, max_protection, inheritance) - register vm_map_t map; vm_offset_t *address; /* IN/OUT */ vm_size_t size; @@ -783,10 +779,10 @@ kern_return_t vm_map_enter( vm_prot_t max_protection; vm_inherit_t inheritance; { - register vm_map_entry_t entry; - register vm_offset_t start; - register vm_offset_t end; - kern_return_t result = KERN_SUCCESS; + vm_map_entry_t entry; + vm_offset_t start; + vm_offset_t end; + kern_return_t result = KERN_SUCCESS; #define RETURN(value) { result = value; goto BailOut; } @@ -832,7 +828,7 @@ kern_return_t vm_map_enter( */ while (TRUE) { - register vm_map_entry_t next; + vm_map_entry_t next; /* * Find the end of the proposed new region. @@ -980,7 +976,7 @@ kern_return_t vm_map_enter( */ /**/ { - register vm_map_entry_t new_entry; + vm_map_entry_t new_entry; new_entry = vm_map_entry_create(map); @@ -1070,11 +1066,11 @@ void _vm_map_copy_clip_start(); * the entry must be split. */ void _vm_map_clip_start(map_header, entry, start) - register struct vm_map_header *map_header; - register vm_map_entry_t entry; - register vm_offset_t start; + struct vm_map_header *map_header; + vm_map_entry_t entry; + vm_offset_t start; { - register vm_map_entry_t new_entry; + vm_map_entry_t new_entry; /* * Split off the front portion -- @@ -1125,11 +1121,11 @@ void _vm_map_copy_clip_end(); * the entry must be split. */ void _vm_map_clip_end(map_header, entry, end) - register struct vm_map_header *map_header; - register vm_map_entry_t entry; - register vm_offset_t end; + struct vm_map_header *map_header; + vm_map_entry_t entry; + vm_offset_t end; { - register vm_map_entry_t new_entry; + vm_map_entry_t new_entry; /* * Create a new entry and insert it @@ -1185,14 +1181,14 @@ void _vm_map_clip_end(map_header, entry, end) * submap (if desired). [Better yet, don't try it.] */ kern_return_t vm_map_submap(map, start, end, submap) - register vm_map_t map; - register vm_offset_t start; - register vm_offset_t end; - vm_map_t submap; + vm_map_t map; + vm_offset_t start; + vm_offset_t end; + vm_map_t submap; { vm_map_entry_t entry; - register kern_return_t result = KERN_INVALID_ARGUMENT; - register vm_object_t object; + kern_return_t result = KERN_INVALID_ARGUMENT; + vm_object_t object; vm_map_lock(map); @@ -1233,14 +1229,14 @@ kern_return_t vm_map_submap(map, start, end, submap) * otherwise, only the current protection is affected. */ kern_return_t vm_map_protect(map, start, end, new_prot, set_max) - register vm_map_t map; - register vm_offset_t start; - register vm_offset_t end; - register vm_prot_t new_prot; - register boolean_t set_max; + vm_map_t map; + vm_offset_t start; + vm_offset_t end; + vm_prot_t new_prot; + boolean_t set_max; { - register vm_map_entry_t current; - vm_map_entry_t entry; + vm_map_entry_t current; + vm_map_entry_t entry; vm_map_lock(map); @@ -1321,12 +1317,12 @@ kern_return_t vm_map_protect(map, start, end, new_prot, set_max) * child maps at the time of vm_map_fork. */ kern_return_t vm_map_inherit(map, start, end, new_inheritance) - register vm_map_t map; - register vm_offset_t start; - register vm_offset_t end; - register vm_inherit_t new_inheritance; + vm_map_t map; + vm_offset_t start; + vm_offset_t end; + vm_inherit_t new_inheritance; { - register vm_map_entry_t entry; + vm_map_entry_t entry; vm_map_entry_t temp_entry; vm_map_lock(map); @@ -1370,13 +1366,13 @@ kern_return_t vm_map_inherit(map, start, end, new_inheritance) * or vm_map_pageable_user); don't call vm_map_pageable directly. */ kern_return_t vm_map_pageable_common(map, start, end, access_type, user_wire) - register vm_map_t map; - register vm_offset_t start; - register vm_offset_t end; - register vm_prot_t access_type; - boolean_t user_wire; + vm_map_t map; + vm_offset_t start; + vm_offset_t end; + vm_prot_t access_type; + boolean_t user_wire; { - register vm_map_entry_t entry; + vm_map_entry_t entry; vm_map_entry_t start_entry; vm_map_lock(map); @@ -1619,11 +1615,11 @@ kern_return_t vm_map_pageable_common(map, start, end, access_type, user_wire) * Deallocate the given entry from the target map. */ void vm_map_entry_delete(map, entry) - register vm_map_t map; - register vm_map_entry_t entry; + vm_map_t map; + vm_map_entry_t entry; { - register vm_offset_t s, e; - register vm_object_t object; + vm_offset_t s, e; + vm_object_t object; extern vm_object_t kernel_object; s = entry->vme_start; @@ -1703,9 +1699,9 @@ void vm_map_entry_delete(map, entry) */ kern_return_t vm_map_delete(map, start, end) - register vm_map_t map; - register vm_offset_t start; - register vm_offset_t end; + vm_map_t map; + vm_offset_t start; + vm_offset_t end; { vm_map_entry_t entry; vm_map_entry_t first_entry; @@ -1786,11 +1782,11 @@ kern_return_t vm_map_delete(map, start, end) * This is the exported form of vm_map_delete. */ kern_return_t vm_map_remove(map, start, end) - register vm_map_t map; - register vm_offset_t start; - register vm_offset_t end; + vm_map_t map; + vm_offset_t start; + vm_offset_t end; { - register kern_return_t result; + kern_return_t result; vm_map_lock(map); VM_MAP_RANGE_CHECK(map, start, end); @@ -1811,9 +1807,9 @@ void vm_map_copy_steal_pages(copy) vm_map_copy_t copy; { - register vm_page_t m, new_m; - register int i; - vm_object_t object; + vm_page_t m, new_m; + int i; + vm_object_t object; for (i = 0; i < copy->cpy_npages; i++) { @@ -1943,7 +1939,7 @@ free_next_copy: * here to avoid tail recursion. */ if (copy->cpy_cont == vm_map_copy_discard_cont) { - register vm_map_copy_t new_copy; + vm_map_copy_t new_copy; new_copy = (vm_map_copy_t) copy->cpy_cont_args; kmem_cache_free(&vm_map_copy_cache, (vm_offset_t) copy); @@ -2460,10 +2456,8 @@ start_pass_1: * Otherwise, the caller is responsible for it. */ kern_return_t vm_map_copyout(dst_map, dst_addr, copy) - register vm_map_t dst_map; vm_offset_t *dst_addr; /* OUT */ - register vm_map_copy_t copy; { vm_size_t size; @@ -2471,7 +2465,6 @@ kern_return_t vm_map_copyout(dst_map, dst_addr, copy) vm_offset_t start; vm_offset_t vm_copy_start; vm_map_entry_t last; - register vm_map_entry_t entry; /* @@ -2617,9 +2610,9 @@ kern_return_t vm_map_copyout(dst_map, dst_addr, copy) * map the pages into the destination map. */ if (entry->wired_count != 0) { - register vm_offset_t va; - vm_offset_t offset; - register vm_object_t object; + vm_offset_t va; + vm_offset_t offset; + vm_object_t object; object = entry->object.vm_object; offset = entry->offset; @@ -2631,7 +2624,7 @@ kern_return_t vm_map_copyout(dst_map, dst_addr, copy) TRUE); while (va < entry->vme_end) { - register vm_page_t m; + vm_page_t m; /* * Look up the page in the object. @@ -2717,10 +2710,8 @@ kern_return_t vm_map_copyout(dst_map, dst_addr, copy) * */ kern_return_t vm_map_copyout_page_list(dst_map, dst_addr, copy) - register vm_map_t dst_map; vm_offset_t *dst_addr; /* OUT */ - register vm_map_copy_t copy; { vm_size_t size; @@ -2728,7 +2719,6 @@ kern_return_t vm_map_copyout_page_list(dst_map, dst_addr, copy) vm_offset_t end; vm_offset_t offset; vm_map_entry_t last; - register vm_object_t object; vm_page_t *page_list, m; vm_map_entry_t entry; @@ -3125,7 +3115,6 @@ kern_return_t vm_map_copyin(src_map, src_addr, len, src_destroy, copy_result) vm_offset_t src_end; /* End of entire region to be * copied */ - register vm_map_copy_t copy; /* Resulting copy */ /* @@ -3192,14 +3181,12 @@ kern_return_t vm_map_copyin(src_map, src_addr, len, src_destroy, copy_result) */ while (TRUE) { - register vm_map_entry_t src_entry = tmp_entry; /* Top-level entry */ vm_size_t src_size; /* Size of source * map entry (in both * maps) */ - register vm_object_t src_object; /* Object to copy */ vm_offset_t src_offset; @@ -3208,7 +3195,6 @@ kern_return_t vm_map_copyin(src_map, src_addr, len, src_destroy, copy_result) * for copy-on-write? */ - register vm_map_entry_t new_entry; /* Map entry for copy */ boolean_t new_entry_needs_copy; /* Will new entry be COW? */ @@ -3522,7 +3508,7 @@ vm_map_copyin_args_t cont_args; vm_map_copy_t *copy_result; /* OUT */ { kern_return_t result = 0; /* '=0' to quiet gcc warnings */ - register boolean_t do_abort, src_destroy, src_destroy_only; + boolean_t do_abort, src_destroy, src_destroy_only; /* * Check for cases that only require memory destruction. @@ -3588,12 +3574,9 @@ kern_return_t vm_map_copyin_page_list(src_map, src_addr, len, src_destroy, vm_offset_t src_start; vm_offset_t src_end; vm_size_t src_size; - register vm_object_t src_object; - register vm_offset_t src_offset; vm_offset_t src_last_offset; - register vm_map_copy_t copy; /* Resulting copy */ kern_return_t result = KERN_SUCCESS; boolean_t need_map_lookup; @@ -3927,7 +3910,7 @@ retry: */ src_start = trunc_page(src_addr); if (steal_pages) { - register int i; + int i; vm_offset_t unwire_end; unwire_end = src_start; @@ -4108,14 +4091,11 @@ vm_map_t vm_map_fork(old_map) vm_map_t old_map; { vm_map_t new_map; - register vm_map_entry_t old_entry; - register vm_map_entry_t new_entry; pmap_t new_pmap = pmap_create((vm_size_t) 0); vm_size_t new_size = 0; vm_size_t entry_size; - register vm_object_t object; vm_map_lock(old_map); @@ -4381,8 +4361,8 @@ vm_map_t vm_map_fork(old_map) kern_return_t vm_map_lookup(var_map, vaddr, fault_type, out_version, object, offset, out_prot, wired) vm_map_t *var_map; /* IN/OUT */ - register vm_offset_t vaddr; - register vm_prot_t fault_type; + vm_offset_t vaddr; + vm_prot_t fault_type; vm_map_version_t *out_version; /* OUT */ vm_object_t *object; /* OUT */ @@ -4390,9 +4370,9 @@ kern_return_t vm_map_lookup(var_map, vaddr, fault_type, out_version, vm_prot_t *out_prot; /* OUT */ boolean_t *wired; /* OUT */ { - register vm_map_entry_t entry; - register vm_map_t map = *var_map; - register vm_prot_t prot; + vm_map_entry_t entry; + vm_map_t map = *var_map; + vm_prot_t prot; RetryLookup: ; @@ -4561,9 +4541,7 @@ kern_return_t vm_map_lookup(var_map, vaddr, fault_type, out_version, * will not change until vm_map_verify_done() is called. */ boolean_t vm_map_verify(map, version) - register vm_map_t map; - register vm_map_version_t *version; /* REF */ { boolean_t result; @@ -4608,9 +4586,7 @@ kern_return_t vm_region(map, address, size, vm_offset_t *offset_in_object; /* OUT */ { vm_map_entry_t tmp_entry; - register vm_map_entry_t entry; - register vm_offset_t tmp_offset; vm_offset_t start; @@ -4759,9 +4735,9 @@ kern_return_t vm_map_machine_attribute(map, address, size, attribute, value) * vm_map_print: [ debug ] */ void vm_map_print(map) - register vm_map_t map; + vm_map_t map; { - register vm_map_entry_t entry; + vm_map_entry_t entry; iprintf("Task map 0x%X: pmap=0x%X,", (vm_offset_t) map, (vm_offset_t) (map->pmap)); -- cgit v1.2.3 From b282b8f0517ed8382c43616552f4d6e962cf57a3 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Wed, 13 Nov 2013 16:40:46 +0100 Subject: vm/vm_object.c: remove register qualifiers * vm/vm_object.c: Remove register qualifiers. --- vm/vm_object.c | 77 ++++++++++++++++++++++++++-------------------------------- 1 file changed, 35 insertions(+), 42 deletions(-) diff --git a/vm/vm_object.c b/vm/vm_object.c index 600aff24..3461b237 100644 --- a/vm/vm_object.c +++ b/vm/vm_object.c @@ -233,7 +233,7 @@ static void _vm_object_setup( vm_object_t _vm_object_allocate( vm_size_t size) { - register vm_object_t object; + vm_object_t object; object = (vm_object_t) kmem_cache_alloc(&vm_object_cache); @@ -245,8 +245,8 @@ vm_object_t _vm_object_allocate( vm_object_t vm_object_allocate( vm_size_t size) { - register vm_object_t object; - register ipc_port_t port; + vm_object_t object; + ipc_port_t port; object = _vm_object_allocate(size); port = ipc_port_alloc_kernel(); @@ -353,7 +353,7 @@ void vm_object_init(void) * Gets another reference to the given object. */ void vm_object_reference( - register vm_object_t object) + vm_object_t object) { if (object == VM_OBJECT_NULL) return; @@ -376,7 +376,7 @@ void vm_object_reference( * No object may be locked. */ void vm_object_deallocate( - register vm_object_t object) + vm_object_t object) { vm_object_t temp; @@ -546,10 +546,10 @@ boolean_t vm_object_terminate_remove_all = FALSE; * object will cease to exist. */ void vm_object_terminate( - register vm_object_t object) + vm_object_t object) { - register vm_page_t p; - vm_object_t shadow_object; + vm_page_t p; + vm_object_t shadow_object; /* * Make sure the object isn't already being terminated @@ -752,7 +752,6 @@ void memory_object_release( void vm_object_abort_activity( vm_object_t object) { - register vm_page_t p; vm_page_t next; @@ -806,7 +805,6 @@ void vm_object_abort_activity( * or from port destruction handling (via vm_object_destroy). */ kern_return_t memory_object_destroy( - register vm_object_t object, kern_return_t reason) { @@ -888,9 +886,9 @@ kern_return_t memory_object_destroy( * The object must be locked. */ void vm_object_deactivate_pages( - register vm_object_t object) + vm_object_t object) { - register vm_page_t p; + vm_page_t p; queue_iterate(&object->memq, p, vm_page_t, listq) { vm_page_lock_queues(); @@ -927,8 +925,8 @@ void vm_object_deactivate_pages( boolean_t vm_object_pmap_protect_by_page = FALSE; void vm_object_pmap_protect( - register vm_object_t object, - register vm_offset_t offset, + vm_object_t object, + vm_offset_t offset, vm_size_t size, pmap_t pmap, vm_offset_t pmap_start, @@ -950,8 +948,8 @@ void vm_object_pmap_protect( } { - register vm_page_t p; - register vm_offset_t end; + vm_page_t p; + vm_offset_t end; end = offset + size; @@ -982,7 +980,7 @@ void vm_object_pmap_protect( * Must follow shadow chain to remove access * to pages in shadowed objects. */ - register vm_object_t next_object; + vm_object_t next_object; next_object = object->shadow; if (next_object != VM_OBJECT_NULL) { @@ -1019,11 +1017,11 @@ void vm_object_pmap_protect( * The object must *not* be locked. */ void vm_object_pmap_remove( - register vm_object_t object, - register vm_offset_t start, - register vm_offset_t end) + vm_object_t object, + vm_offset_t start, + vm_offset_t end) { - register vm_page_t p; + vm_page_t p; if (object == VM_OBJECT_NULL) return; @@ -1069,7 +1067,6 @@ void vm_object_pmap_remove( * VM_OBJECT_NULL. */ kern_return_t vm_object_copy_slowly( - register vm_object_t src_object, vm_offset_t src_offset, vm_size_t size, @@ -1123,7 +1120,6 @@ kern_return_t vm_object_copy_slowly( vm_prot_t prot = VM_PROT_READ; vm_page_t _result_page; vm_page_t top_page; - register vm_page_t result_page; vm_object_lock(src_object); @@ -1615,7 +1611,6 @@ vm_object_t vm_object_copy_delayed( * and may be interrupted. */ kern_return_t vm_object_copy_strategically( - register vm_object_t src_object, vm_offset_t src_offset, vm_size_t size, @@ -1728,8 +1723,8 @@ void vm_object_shadow( vm_offset_t *offset, /* IN/OUT */ vm_size_t length) { - register vm_object_t source; - register vm_object_t result; + vm_object_t source; + vm_object_t result; source = *object; @@ -2001,7 +1996,6 @@ vm_object_t vm_object_enter( vm_size_t size, boolean_t internal) { - register vm_object_t object; vm_object_t new_object; boolean_t must_init; @@ -2219,7 +2213,6 @@ restart: * daemon will be using this routine. */ void vm_object_pager_create( - register vm_object_t object) { ipc_port_t pager; @@ -2364,14 +2357,14 @@ boolean_t vm_object_collapse_bypass_allowed = TRUE; * so the caller should hold a reference for the object. */ void vm_object_collapse( - register vm_object_t object) + vm_object_t object) { - register vm_object_t backing_object; - register vm_offset_t backing_offset; - register vm_size_t size; - register vm_offset_t new_offset; - register vm_page_t p, pp; - ipc_port_t old_name_port; + vm_object_t backing_object; + vm_offset_t backing_offset; + vm_size_t size; + vm_offset_t new_offset; + vm_page_t p, pp; + ipc_port_t old_name_port; if (!vm_object_collapse_allowed) return; @@ -2741,11 +2734,11 @@ unsigned int vm_object_page_remove_lookup = 0; unsigned int vm_object_page_remove_iterate = 0; void vm_object_page_remove( - register vm_object_t object, - register vm_offset_t start, - register vm_offset_t end) + vm_object_t object, + vm_offset_t start, + vm_offset_t end) { - register vm_page_t p, next; + vm_page_t p, next; /* * One and two page removals are most popular. @@ -2806,7 +2799,7 @@ void vm_object_page_remove( */ boolean_t vm_object_coalesce( - register vm_object_t prev_object, + vm_object_t prev_object, vm_object_t next_object, vm_offset_t prev_offset, vm_offset_t next_offset, @@ -2968,9 +2961,9 @@ boolean_t vm_object_print_pages = FALSE; void vm_object_print( vm_object_t object) { - register vm_page_t p; + vm_page_t p; - register int count; + int count; if (object == VM_OBJECT_NULL) return; -- cgit v1.2.3 From e7849a2f167b7f4269438ab30f41f503c807d713 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Wed, 13 Nov 2013 16:40:47 +0100 Subject: vm/vm_pageout.c: remove register qualifiers * vm/vm_pageout.c: Remove register qualifiers. --- vm/vm_pageout.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/vm/vm_pageout.c b/vm/vm_pageout.c index 661675f0..0f4f3ba6 100644 --- a/vm/vm_pageout.c +++ b/vm/vm_pageout.c @@ -231,15 +231,15 @@ unsigned int vm_pageout_inactive_cleaned_external = 0; */ vm_page_t vm_pageout_setup(m, paging_offset, new_object, new_offset, flush) - register vm_page_t m; + vm_page_t m; vm_offset_t paging_offset; - register vm_object_t new_object; + vm_object_t new_object; vm_offset_t new_offset; boolean_t flush; { - register vm_object_t old_object = m->object; - register vm_page_t holding_page = 0; /*'=0'to quiet gcc warnings*/ - register vm_page_t new_m; + vm_object_t old_object = m->object; + vm_page_t holding_page = 0; /*'=0'to quiet gcc warnings*/ + vm_page_t new_m; assert(m->busy && !m->absent && !m->fictitious); @@ -418,14 +418,14 @@ vm_pageout_setup(m, paging_offset, new_object, new_offset, flush) */ void vm_pageout_page(m, initial, flush) - register vm_page_t m; + vm_page_t m; boolean_t initial; boolean_t flush; { vm_map_copy_t copy; - register vm_object_t old_object; - register vm_object_t new_object; - register vm_page_t holding_page; + vm_object_t old_object; + vm_object_t new_object; + vm_page_t holding_page; vm_offset_t paging_offset; kern_return_t rc; boolean_t precious_clean; @@ -559,8 +559,8 @@ void vm_pageout_scan() slab_collect(); for (burst_count = 0;;) { - register vm_page_t m; - register vm_object_t object; + vm_page_t m; + vm_object_t object; unsigned int free_count; /* @@ -578,7 +578,7 @@ void vm_pageout_scan() while ((vm_page_inactive_count < vm_page_inactive_target) && !queue_empty(&vm_page_queue_active)) { - register vm_object_t obj; + vm_object_t obj; vm_pageout_active++; m = (vm_page_t) queue_first(&vm_page_queue_active); -- cgit v1.2.3 From 4bb97b951a4f312649d4e1c8214979e4620b7611 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Wed, 13 Nov 2013 16:40:48 +0100 Subject: vm/vm_resident.c: remove register qualifiers * vm/vm_resident.c: Remove register qualifiers. --- vm/vm_resident.c | 86 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/vm/vm_resident.c b/vm/vm_resident.c index 7906b583..fbd42750 100644 --- a/vm/vm_resident.c +++ b/vm/vm_resident.c @@ -192,7 +192,7 @@ void vm_page_bootstrap( vm_offset_t *startp, vm_offset_t *endp) { - register vm_page_t m; + vm_page_t m; int i; /* @@ -274,7 +274,7 @@ void vm_page_bootstrap( sizeof(vm_page_bucket_t)); for (i = 0; i < vm_page_bucket_count; i++) { - register vm_page_bucket_t *bucket = &vm_page_buckets[i]; + vm_page_bucket_t *bucket = &vm_page_buckets[i]; bucket->pages = VM_PAGE_NULL; simple_lock_init(&bucket->lock); @@ -483,11 +483,11 @@ void vm_page_create( */ void vm_page_insert( - register vm_page_t mem, - register vm_object_t object, - register vm_offset_t offset) + vm_page_t mem, + vm_object_t object, + vm_offset_t offset) { - register vm_page_bucket_t *bucket; + vm_page_bucket_t *bucket; VM_PAGE_CHECK(mem); @@ -555,11 +555,11 @@ void vm_page_insert( */ void vm_page_replace( - register vm_page_t mem, - register vm_object_t object, - register vm_offset_t offset) + vm_page_t mem, + vm_object_t object, + vm_offset_t offset) { - register vm_page_bucket_t *bucket; + vm_page_bucket_t *bucket; VM_PAGE_CHECK(mem); @@ -582,7 +582,7 @@ void vm_page_replace( simple_lock(&bucket->lock); if (bucket->pages) { vm_page_t *mp = &bucket->pages; - register vm_page_t m = *mp; + vm_page_t m = *mp; do { if (m->object == object && m->offset == offset) { /* @@ -646,10 +646,10 @@ void vm_page_replace( */ void vm_page_remove( - register vm_page_t mem) + vm_page_t mem) { - register vm_page_bucket_t *bucket; - register vm_page_t this; + vm_page_bucket_t *bucket; + vm_page_t this; assert(mem->tabled); VM_PAGE_CHECK(mem); @@ -665,7 +665,7 @@ void vm_page_remove( bucket->pages = mem->next; } else { - register vm_page_t *prev; + vm_page_t *prev; for (prev = &this->next; (this = *prev) != mem; @@ -704,11 +704,11 @@ void vm_page_remove( */ vm_page_t vm_page_lookup( - register vm_object_t object, - register vm_offset_t offset) + vm_object_t object, + vm_offset_t offset) { - register vm_page_t mem; - register vm_page_bucket_t *bucket; + vm_page_t mem; + vm_page_bucket_t *bucket; /* * Search the hash table for this object/offset pair @@ -735,9 +735,9 @@ vm_page_t vm_page_lookup( * The object must be locked. */ void vm_page_rename( - register vm_page_t mem, - register vm_object_t new_object, - vm_offset_t new_offset) + vm_page_t mem, + vm_object_t new_object, + vm_offset_t new_offset) { /* * Changes to mem->object require the page lock because @@ -774,7 +774,7 @@ void vm_page_init( vm_page_t vm_page_grab_fictitious(void) { - register vm_page_t m; + vm_page_t m; simple_lock(&vm_page_queue_free_lock); m = vm_page_queue_fictitious; @@ -795,7 +795,7 @@ vm_page_t vm_page_grab_fictitious(void) */ void vm_page_release_fictitious( - register vm_page_t m) + vm_page_t m) { simple_lock(&vm_page_queue_free_lock); if (m->free) @@ -818,7 +818,7 @@ int vm_page_fictitious_quantum = 5; void vm_page_more_fictitious(void) { - register vm_page_t m; + vm_page_t m; int i; for (i = 0; i < vm_page_fictitious_quantum; i++) { @@ -839,10 +839,10 @@ void vm_page_more_fictitious(void) */ boolean_t vm_page_convert( - register vm_page_t m, + vm_page_t m, boolean_t external) { - register vm_page_t real_m; + vm_page_t real_m; real_m = vm_page_grab(external); if (real_m == VM_PAGE_NULL) @@ -868,7 +868,7 @@ boolean_t vm_page_convert( vm_page_t vm_page_grab( boolean_t external) { - register vm_page_t mem; + vm_page_t mem; simple_lock(&vm_page_queue_free_lock); @@ -949,7 +949,7 @@ vm_page_grab_contiguous_pages( natural_t *bits, boolean_t external) { - register int first_set; + int first_set; int size, alloc_size; kern_return_t ret; vm_page_t mem, *prevmemp; @@ -1006,7 +1006,7 @@ vm_page_grab_contiguous_pages( */ mem = vm_page_queue_free; while (mem) { - register int word_index, bit_index; + int word_index, bit_index; bit_index = (mem->phys_addr >> PAGE_SHIFT); word_index = bit_index / NBPEL; @@ -1023,14 +1023,14 @@ vm_page_grab_contiguous_pages( * the free list. */ { - register int bits_so_far = 0, i; + int bits_so_far = 0, i; first_set = 0; for (i = 0; i < size; i += sizeof(natural_t)) { - register natural_t v = bits[i / sizeof(natural_t)]; - register int bitpos; + natural_t v = bits[i / sizeof(natural_t)]; + int bitpos; /* * Bitscan this one word @@ -1099,7 +1099,7 @@ found_em: if (external) vm_page_external_count += npages; { - register vm_offset_t first_phys, last_phys; + vm_offset_t first_phys, last_phys; /* cache values for compare */ first_phys = first_set << PAGE_SHIFT; @@ -1111,7 +1111,7 @@ found_em: while (mem) { - register vm_offset_t addr; + vm_offset_t addr; addr = mem->phys_addr; @@ -1165,8 +1165,8 @@ out: */ void vm_page_release( - register vm_page_t mem, - boolean_t external) + vm_page_t mem, + boolean_t external) { simple_lock(&vm_page_queue_free_lock); if (mem->free) @@ -1257,7 +1257,7 @@ vm_page_t vm_page_alloc( vm_object_t object, vm_offset_t offset) { - register vm_page_t mem; + vm_page_t mem; mem = vm_page_grab(!object->internal); if (mem == VM_PAGE_NULL) @@ -1279,7 +1279,7 @@ vm_page_t vm_page_alloc( * Object and page queues must be locked prior to entry. */ void vm_page_free( - register vm_page_t mem) + vm_page_t mem) { if (mem->free) panic("vm_page_free"); @@ -1330,7 +1330,7 @@ void vm_page_free( * The page's object and the page queues must be locked. */ void vm_page_wire( - register vm_page_t mem) + vm_page_t mem) { VM_PAGE_CHECK(mem); @@ -1351,7 +1351,7 @@ void vm_page_wire( * The page's object and the page queues must be locked. */ void vm_page_unwire( - register vm_page_t mem) + vm_page_t mem) { VM_PAGE_CHECK(mem); @@ -1374,7 +1374,7 @@ void vm_page_unwire( * The page queues must be locked. */ void vm_page_deactivate( - register vm_page_t m) + vm_page_t m) { VM_PAGE_CHECK(m); @@ -1408,7 +1408,7 @@ void vm_page_deactivate( */ void vm_page_activate( - register vm_page_t m) + vm_page_t m) { VM_PAGE_CHECK(m); -- cgit v1.2.3 From 09b1fe3eb0065c1b8ec8efe37184dfee4537af3a Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Wed, 13 Nov 2013 16:40:49 +0100 Subject: vm/vm_user.c: remove register qualifiers * vm/vm_user.c: Remove register qualifiers. --- vm/vm_user.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/vm/vm_user.c b/vm/vm_user.c index 6fe398e0..c18baf23 100644 --- a/vm/vm_user.c +++ b/vm/vm_user.c @@ -57,10 +57,10 @@ vm_statistics_data_t vm_stat; * map. */ kern_return_t vm_allocate(map, addr, size, anywhere) - register vm_map_t map; - register vm_offset_t *addr; - register vm_size_t size; - boolean_t anywhere; + vm_map_t map; + vm_offset_t *addr; + vm_size_t size; + boolean_t anywhere; { kern_return_t result; @@ -98,7 +98,7 @@ kern_return_t vm_allocate(map, addr, size, anywhere) * specified address map. */ kern_return_t vm_deallocate(map, start, size) - register vm_map_t map; + vm_map_t map; vm_offset_t start; vm_size_t size; { @@ -116,7 +116,7 @@ kern_return_t vm_deallocate(map, start, size) * specified map. */ kern_return_t vm_inherit(map, start, size, new_inheritance) - register vm_map_t map; + vm_map_t map; vm_offset_t start; vm_size_t size; vm_inherit_t new_inheritance; @@ -150,7 +150,7 @@ kern_return_t vm_inherit(map, start, size, new_inheritance) */ kern_return_t vm_protect(map, start, size, set_maximum, new_protection) - register vm_map_t map; + vm_map_t map; vm_offset_t start; vm_size_t size; boolean_t set_maximum; @@ -323,9 +323,7 @@ kern_return_t vm_map( vm_prot_t max_protection; vm_inherit_t inheritance; { - register vm_object_t object; - register kern_return_t result; if ((target_map == VM_MAP_NULL) || @@ -416,7 +414,7 @@ kern_return_t vm_map( */ kern_return_t vm_wire(host, map, start, size, access) host_t host; - register vm_map_t map; + vm_map_t map; vm_offset_t start; vm_size_t size; vm_prot_t access; -- cgit v1.2.3 From d7db88a17a6c5d56e18e3d3b0de9b459d0d62087 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 14 Nov 2013 10:33:46 +0100 Subject: chips/busses.c: use boolean instead of an int * chips/busses.c (found): Constrain range of values to a boolean. --- chips/busses.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/chips/busses.c b/chips/busses.c index 89afa973..e555856e 100644 --- a/chips/busses.c +++ b/chips/busses.c @@ -69,7 +69,7 @@ boolean_t configure_bus_master( register struct bus_ctlr *master; register struct bus_driver *driver; - int found = 0; + boolean_t found = FALSE; /* * Match the name in the table, then pick the entry that has the @@ -81,7 +81,7 @@ boolean_t configure_bus_master( continue; if (((master->adaptor == adpt_no) || (master->adaptor == '?')) && (strcmp(master->name, name) == 0)) { - found = 1; + found = TRUE; break; } } @@ -180,7 +180,7 @@ boolean_t configure_bus_device( register struct bus_device *device; register struct bus_driver *driver; - int found = 0; + boolean_t found = FALSE; /* * Walk all devices to find one with the right name @@ -196,7 +196,7 @@ boolean_t configure_bus_device( ((!device->phys_address) || ((device->phys_address == phys) && (device->address == virt))) && (strcmp(device->name, name) == 0)) { - found = 1; + found = TRUE; break; } } -- cgit v1.2.3 From 5bab8178a1b59c6563dcf87dcc034463d9f0a031 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 14 Nov 2013 10:33:47 +0100 Subject: chips/busses.c: remove register qualifiers * chips/busses.c: Remove register qualifiers. --- chips/busses.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/chips/busses.c b/chips/busses.c index e555856e..f9f6f1be 100644 --- a/chips/busses.c +++ b/chips/busses.c @@ -65,9 +65,9 @@ boolean_t configure_bus_master( int adpt_no, char *bus_name) { - register struct bus_device *device; - register struct bus_ctlr *master; - register struct bus_driver *driver; + struct bus_device *device; + struct bus_ctlr *master; + struct bus_driver *driver; boolean_t found = FALSE; @@ -177,8 +177,8 @@ boolean_t configure_bus_device( int adpt_no, char *bus_name) { - register struct bus_device *device; - register struct bus_driver *driver; + struct bus_device *device; + struct bus_driver *driver; boolean_t found = FALSE; -- cgit v1.2.3 From c19732181e805c31f968779141ce0c434b07b017 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 14 Nov 2013 21:04:04 +0100 Subject: i386/i386at: add ifndefs * i386/i386at/kd_queue.h: Add ifndef. * i386/i386at/kdsoft.h: Likewise. * i386/i386at/lprreg.h: Likewise. * i386/i386at/rtc.h: Likewise. --- i386/i386at/kd_queue.h | 5 +++++ i386/i386at/kdsoft.h | 5 +++++ i386/i386at/lprreg.h | 5 +++++ i386/i386at/rtc.h | 5 +++++ 4 files changed, 20 insertions(+) diff --git a/i386/i386at/kd_queue.h b/i386/i386at/kd_queue.h index c976acfa..bd3fc7bc 100644 --- a/i386/i386at/kd_queue.h +++ b/i386/i386at/kd_queue.h @@ -64,6 +64,9 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * /dev/mouse. */ +#ifndef _KD_QUEUE_H_ +#define _KD_QUEUE_H_ + #include #include @@ -79,3 +82,5 @@ extern void kdq_reset(kd_event_queue *); extern boolean_t kdq_empty(kd_event_queue *); extern boolean_t kdq_full(kd_event_queue *); extern kd_event *kdq_get(kd_event_queue *); + +#endif /* _KD_QUEUE_H_ */ diff --git a/i386/i386at/kdsoft.h b/i386/i386at/kdsoft.h index 96e2df8c..297c57b2 100644 --- a/i386/i386at/kdsoft.h +++ b/i386/i386at/kdsoft.h @@ -57,6 +57,9 @@ NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUR OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef _KDSOFT_H +#define _KDSOFT_H_ + /* * Globals used for both character-based controllers and bitmap-based * controllers. @@ -203,3 +206,5 @@ extern short xstart, ystart; extern short char_byte_width; /* char_width/8 */ extern short fb_byte_width; /* fb_width/8 */ extern short font_byte_width; /* num bytes in 1 scan line of font */ + +#endif /* _KDSOFT_H_ */ diff --git a/i386/i386at/lprreg.h b/i386/i386at/lprreg.h index c6fbed43..1fb62305 100644 --- a/i386/i386at/lprreg.h +++ b/i386/i386at/lprreg.h @@ -27,7 +27,12 @@ * Parallel port printer driver v1.0 * All rights reserved. */ + +#ifndef _LPRREG_H_ +#define _LPRREG_H_ #define DATA(addr) (addr + 0) #define STATUS(addr) (addr + 1) #define INTR_ENAB(addr) (addr + 2) + +#endif /* _LPRREG_H_ */ diff --git a/i386/i386at/rtc.h b/i386/i386at/rtc.h index ced39b98..64a528aa 100644 --- a/i386/i386at/rtc.h +++ b/i386/i386at/rtc.h @@ -45,6 +45,9 @@ NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef _RTC_H_ +#define _RTC_H_ + #define RTC_ADDR 0x70 /* I/O port address for register select */ #define RTC_DATA 0x71 /* I/O port address for data read/write */ @@ -136,3 +139,5 @@ struct rtc_st { extern int readtodc(u_int *tp); extern int writetodc(void); + +#endif /* _RTC_H_ */ -- cgit v1.2.3 From 7b7240a68c18804c553e9bc5664b3bcedcfbb1e1 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 14 Nov 2013 21:04:05 +0100 Subject: i386/i386/vm_tuning.h: remove file * i386/Makefrag.am: Remove i386/i386/vm_tuning.h. * i386/i386/vm_tuning.h: Remove file. * vm/vm_pageout.c: Don't include i386/i386/vm_tuning.h. --- i386/Makefrag.am | 1 - i386/i386/vm_tuning.h | 35 ----------------------------------- vm/vm_pageout.c | 1 - 3 files changed, 37 deletions(-) delete mode 100644 i386/i386/vm_tuning.h diff --git a/i386/Makefrag.am b/i386/Makefrag.am index 738c60ae..32730a51 100644 --- a/i386/Makefrag.am +++ b/i386/Makefrag.am @@ -134,7 +134,6 @@ libkernel_a_SOURCES += \ i386/i386/user_ldt.c \ i386/i386/user_ldt.h \ i386/i386/vm_param.h \ - i386/i386/vm_tuning.h \ i386/i386/xpr.h \ i386/intel/pmap.c \ i386/intel/pmap.h \ diff --git a/i386/i386/vm_tuning.h b/i386/i386/vm_tuning.h deleted file mode 100644 index f54e110a..00000000 --- a/i386/i386/vm_tuning.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1991,1990 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - */ -/* - * File: i386/vm_tuning.h - * - * VM tuning parameters for the i386 (without reference bits). - */ - -#ifndef _I386_VM_TUNING_H_ -#define _I386_VM_TUNING_H_ - -#endif /* _I386_VM_TUNING_H_ */ diff --git a/vm/vm_pageout.c b/vm/vm_pageout.c index 0f4f3ba6..38195ade 100644 --- a/vm/vm_pageout.c +++ b/vm/vm_pageout.c @@ -52,7 +52,6 @@ #include #include #include -#include -- cgit v1.2.3 From 96f2a76a04f08eefd43ff37ad48bc54276f815bc Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 15 Nov 2013 02:11:14 +0100 Subject: Fix typo --- i386/i386at/kdsoft.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i386/i386at/kdsoft.h b/i386/i386at/kdsoft.h index 297c57b2..1dfd2b2c 100644 --- a/i386/i386at/kdsoft.h +++ b/i386/i386at/kdsoft.h @@ -57,7 +57,7 @@ NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUR OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#ifndef _KDSOFT_H +#ifndef _KDSOFT_H_ #define _KDSOFT_H_ /* -- cgit v1.2.3 From 7971421a97901669d88a710fd934d177230da4fb Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 14 Nov 2013 11:21:20 +0100 Subject: i386/i386/db_interface.c: remove register qualifiers * i386/i386/db_interface.c: Remove register qualifiers. --- i386/i386/db_interface.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/i386/i386/db_interface.c b/i386/i386/db_interface.c index 90ca22dc..f89576d6 100644 --- a/i386/i386/db_interface.c +++ b/i386/i386/db_interface.c @@ -232,7 +232,7 @@ boolean_t kdb_trap( int type, int code, - register struct i386_saved_state *regs) + struct i386_saved_state *regs) { spl_t s; @@ -413,7 +413,7 @@ db_user_to_kernel_address( unsigned int *kaddr, int flag) { - register pt_entry_t *ptp; + pt_entry_t *ptp; boolean_t faulted = FALSE; retry: @@ -448,12 +448,12 @@ db_user_to_kernel_address( void db_read_bytes( vm_offset_t addr, - register int size, - register char *data, + int size, + char *data, task_t task) { - register char *src; - register int n; + char *src; + int n; unsigned kern_addr; src = (char *)addr; @@ -491,16 +491,16 @@ db_read_bytes( void db_write_bytes( vm_offset_t addr, - register int size, - register char *data, + int size, + char *data, task_t task) { - register char *dst; + char *dst; - register pt_entry_t *ptep0 = 0; + pt_entry_t *ptep0 = 0; pt_entry_t oldmap0 = 0; vm_offset_t addr1; - register pt_entry_t *ptep1 = 0; + pt_entry_t *ptep1 = 0; pt_entry_t oldmap1 = 0; extern char etext; void db_write_bytes_user_space(); @@ -560,12 +560,12 @@ db_write_bytes( void db_write_bytes_user_space( vm_offset_t addr, - register int size, - register char *data, + int size, + char *data, task_t task) { - register char *dst; - register int n; + char *dst; + int n; unsigned kern_addr; while (size > 0) { @@ -585,7 +585,7 @@ db_write_bytes_user_space( boolean_t db_check_access( vm_offset_t addr, - register int size, + int size, task_t task) { int n; @@ -647,8 +647,8 @@ db_search_null( vm_offset_t *skaddr, int flag) { - register unsigned vaddr; - register unsigned *kaddr; + unsigned vaddr; + unsigned *kaddr; kaddr = (unsigned *)*skaddr; for (vaddr = *svaddr; vaddr > evaddr; ) { @@ -721,8 +721,8 @@ void db_task_name( task_t task) { - register char *p; - register int n; + char *p; + int n; unsigned vaddr, kaddr; unsigned sp; -- cgit v1.2.3 From 02755a6b57e24d381563c48f382a646a4be007ae Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 14 Nov 2013 11:26:18 +0100 Subject: i386/i386/db_trace.c: remove register qualifiers * i386/i386/db_trace.c: Remove register qualifiers. --- i386/i386/db_trace.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/i386/i386/db_trace.c b/i386/i386/db_trace.c index 4e3bea39..151d90a8 100644 --- a/i386/i386/db_trace.c +++ b/i386/i386/db_trace.c @@ -115,7 +115,7 @@ db_lookup_i386_kreg( char *name, int *kregp) { - register struct i386_kregs *kp; + struct i386_kregs *kp; for (kp = i386_kregs; kp->name; kp++) { if (strcmp(name, kp->name) == 0) @@ -133,7 +133,7 @@ db_i386_reg_value( { long *dp = 0; db_expr_t null_reg = 0; - register thread_t thread = ap->thread; + thread_t thread = ap->thread; extern unsigned int_stack_high; if (db_option(ap->modif, 'u')) { @@ -343,8 +343,8 @@ db_stack_trace_cmd( thread_t th; { - register char *cp = modif; - register char c; + char *cp = modif; + char c; while ((c = *cp++) != 0) { if (c == 't') @@ -381,7 +381,7 @@ db_stack_trace_cmd( return; } if ((th->state & TH_SWAPPED) || th->kernel_stack == 0) { - register struct i386_saved_state *iss = &th->pcb->iss; + struct i386_saved_state *iss = &th->pcb->iss; db_printf("Continuation "); db_task_printsym((db_expr_t)th->swap_func, @@ -392,7 +392,7 @@ db_stack_trace_cmd( frame = (struct i386_frame *) (iss->ebp); callpc = (db_addr_t) (iss->eip); } else { - register struct i386_kernel_state *iks; + struct i386_kernel_state *iks; iks = STACK_IKS(th->kernel_stack); frame = (struct i386_frame *) (iks->k_ebp); callpc = (db_addr_t) (iks->k_eip); @@ -445,7 +445,7 @@ db_i386_stack_trace( lastframe = 0; while (count-- && frame != 0) { - register int narg; + int narg; char * name; db_expr_t offset; -- cgit v1.2.3 From 0cdc83f310f1275c3f11194dadcd3b56641beeba Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 14 Nov 2013 11:29:42 +0100 Subject: i386/i386/db_trace.c: qualify constants with const * i386/i386/db_trace.c: Qualify constants with const. --- i386/i386/db_trace.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/i386/i386/db_trace.c b/i386/i386/db_trace.c index 151d90a8..d7e13453 100644 --- a/i386/i386/db_trace.c +++ b/i386/i386/db_trace.c @@ -205,7 +205,7 @@ db_find_trace_symbols(void) /* * Figure out how many arguments were passed into the frame at "fp". */ -int db_numargs_default = 5; +const int db_numargs_default = 5; int db_numargs( @@ -571,18 +571,18 @@ static void db_cproc_state( /* offsets in a cproc structure */ /* TODO: longs? */ -int db_cproc_next_offset = 0 * 4; -int db_cproc_incarnation_offset = 1 * 4; -int db_cproc_list_offset = 2 * 4; -int db_cproc_wait_offset = 3 * 4; -int db_cproc_context_offset = 5 * 4; -int db_cproc_state_offset = 7 * 4; -int db_cproc_stack_base_offset = 10 * 4 + sizeof(mach_msg_header_t); -int db_cproc_stack_size_offset = 11 * 4 + sizeof(mach_msg_header_t); +const int db_cproc_next_offset = 0 * 4; +const int db_cproc_incarnation_offset = 1 * 4; +const int db_cproc_list_offset = 2 * 4; +const int db_cproc_wait_offset = 3 * 4; +const int db_cproc_context_offset = 5 * 4; +const int db_cproc_state_offset = 7 * 4; +const int db_cproc_stack_base_offset = 10 * 4 + sizeof(mach_msg_header_t); +const int db_cproc_stack_size_offset = 11 * 4 + sizeof(mach_msg_header_t); /* offsets in a cproc_switch context structure */ -int db_cprocsw_framep_offset = 3 * 4; -int db_cprocsw_pc_offset = 4 * 4; +const int db_cprocsw_framep_offset = 3 * 4; +const int db_cprocsw_pc_offset = 4 * 4; #include -- cgit v1.2.3 From 9e6ccbc26be76868e96836f9f0a71041fa3346de Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 14 Nov 2013 11:36:03 +0100 Subject: i386/i386/fpu.c: remove register qualifiers * i386/i386/fpu.c: Remove register qualifiers. --- i386/i386/fpu.c | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/i386/i386/fpu.c b/i386/i386/fpu.c index d35e3eff..fb2c8ce9 100644 --- a/i386/i386/fpu.c +++ b/i386/i386/fpu.c @@ -299,9 +299,9 @@ fpu_set_state(thread, state) thread_t thread; struct i386_float_state *state; { - register pcb_t pcb = thread->pcb; - register struct i386_fpsave_state *ifps; - register struct i386_fpsave_state *new_ifps; + pcb_t pcb = thread->pcb; + struct i386_fpsave_state *ifps; + struct i386_fpsave_state *new_ifps; ASSERT_IPL(SPL0); if (fp_kind == FP_NO) @@ -339,8 +339,8 @@ ASSERT_IPL(SPL0); /* * Valid state. Allocate the fp state if there is none. */ - register struct i386_fp_save *user_fp_state; - register struct i386_fp_regs *user_fp_regs; + struct i386_fp_save *user_fp_state; + struct i386_fp_regs *user_fp_regs; user_fp_state = (struct i386_fp_save *) &state->hw_state[0]; user_fp_regs = (struct i386_fp_regs *) @@ -408,10 +408,10 @@ ASSERT_IPL(SPL0); kern_return_t fpu_get_state(thread, state) thread_t thread; - register struct i386_float_state *state; + struct i386_float_state *state; { - register pcb_t pcb = thread->pcb; - register struct i386_fpsave_state *ifps; + pcb_t pcb = thread->pcb; + struct i386_fpsave_state *ifps; ASSERT_IPL(SPL0); if (fp_kind == FP_NO) @@ -445,8 +445,8 @@ ASSERT_IPL(SPL0); state->exc_status = 0; { - register struct i386_fp_save *user_fp_state; - register struct i386_fp_regs *user_fp_regs; + struct i386_fp_save *user_fp_state; + struct i386_fp_regs *user_fp_regs; state->initialized = ifps->fp_valid; @@ -569,9 +569,9 @@ ASSERT_IPL(SPL0); void fpextovrflt() { - register thread_t thread = current_thread(); - register pcb_t pcb; - register struct i386_fpsave_state *ifps; + thread_t thread = current_thread(); + pcb_t pcb; + struct i386_fpsave_state *ifps; #if NCPUS == 1 @@ -618,7 +618,7 @@ fpextovrflt() static int fphandleerr() { - register thread_t thread = current_thread(); + thread_t thread = current_thread(); /* * Save the FPU context to the thread using it. @@ -665,7 +665,7 @@ fphandleerr() void fpexterrflt() { - register thread_t thread = current_thread(); + thread_t thread = current_thread(); if (fphandleerr()) return; @@ -690,7 +690,7 @@ fpexterrflt() void fpastintr() { - register thread_t thread = current_thread(); + thread_t thread = current_thread(); ASSERT_IPL(SPL0); #if NCPUS == 1 @@ -752,10 +752,10 @@ ASSERT_IPL(SPL0); */ void fp_save(thread) - register thread_t thread; + thread_t thread; { - register pcb_t pcb = thread->pcb; - register struct i386_fpsave_state *ifps = pcb->ims.ifps; + pcb_t pcb = thread->pcb; + struct i386_fpsave_state *ifps = pcb->ims.ifps; if (ifps != 0 && !ifps->fp_valid) { /* registers are in FPU */ @@ -774,10 +774,10 @@ fp_save(thread) */ void fp_load(thread) - register thread_t thread; + thread_t thread; { - register pcb_t pcb = thread->pcb; - register struct i386_fpsave_state *ifps; + pcb_t pcb = thread->pcb; + struct i386_fpsave_state *ifps; ASSERT_IPL(SPL0); ifps = pcb->ims.ifps; -- cgit v1.2.3 From a3ce64a42720f3cc8f263968d9d58db05175e0f0 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 14 Nov 2013 11:37:12 +0100 Subject: i386/i386/fpu.h: remove register qualifiers * i386/i386/fpu.h: Remove register qualifiers. --- i386/i386/fpu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i386/i386/fpu.h b/i386/i386/fpu.h index 21561875..7bc64388 100644 --- a/i386/i386/fpu.h +++ b/i386/i386/fpu.h @@ -87,7 +87,7 @@ #if NCPUS > 1 #define fpu_save_context(thread) \ { \ - register struct i386_fpsave_state *ifps; \ + struct i386_fpsave_state *ifps; \ ifps = (thread)->pcb->ims.ifps; \ if (ifps != 0 && !ifps->fp_valid) { \ /* registers are in FPU - save to memory */ \ -- cgit v1.2.3 From 480142eb557ec6013b31305b2b0a005813151196 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 14 Nov 2013 11:58:01 +0100 Subject: i386/i386/hardclock.c: add comment after endif * i386/i386/hardclock.c (LINUX_DEV): Add comment after endif. --- i386/i386/hardclock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i386/i386/hardclock.c b/i386/i386/hardclock.c index 66150332..f119c6bb 100644 --- a/i386/i386/hardclock.c +++ b/i386/i386/hardclock.c @@ -77,5 +77,5 @@ hardclock(iunit, old_ipl, irq, ret_addr, regs) #ifdef LINUX_DEV linux_timer_intr(); -#endif +#endif /* LINUX_DEV */ } -- cgit v1.2.3 From cca9a557841e02c572fe6ecce96e489fb0f7af2b Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 14 Nov 2013 12:04:52 +0100 Subject: i386/i386/kttd_interface.c: trivial stylistic fix for consistency * i386/i386/kttd_interface.c: Trivial stylistic fix for consistency. --- i386/i386/kttd_interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i386/i386/kttd_interface.c b/i386/i386/kttd_interface.c index b9e0624b..c6caa76d 100644 --- a/i386/i386/kttd_interface.c +++ b/i386/i386/kttd_interface.c @@ -240,7 +240,7 @@ boolean_t kttd_mem_access(vm_offset_t offset, vm_prot_t access) trunc_page(offset), access); code = vm_fault(kernel_map, trunc_page(offset), access, FALSE, FALSE, (void (*)()) 0); - }else{ + } else { /* * Check for user thread */ -- cgit v1.2.3 From 7d649630994c765065aa3120ecfdc76800993ea0 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 14 Nov 2013 12:07:19 +0100 Subject: i386/i386/lock.h: remove register quaalifier * i386/i386/lock.h: Remove register qualifier. --- i386/i386/lock.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i386/i386/lock.h b/i386/i386/lock.h index 38a66c87..b989927b 100644 --- a/i386/i386/lock.h +++ b/i386/i386/lock.h @@ -44,7 +44,7 @@ */ #define _simple_lock_xchg_(lock, new_val) \ - ({ register int _old_val_; \ + ({ int _old_val_; \ asm volatile("xchgl %0, %2" \ : "=r" (_old_val_) \ : "0" (new_val), "m" (*(lock) : "memory") \ -- cgit v1.2.3 From 02894a8b3f1ffc7686154b13aa4bf88b36f87186 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 14 Nov 2013 12:09:48 +0100 Subject: i386/i386/loose_ends.c: add comment after endif * i386/i386/loose_ends.c (NDEBUG): Add comment after endif. --- i386/i386/loose_ends.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i386/i386/loose_ends.c b/i386/i386/loose_ends.c index d3108fdb..49848ab4 100644 --- a/i386/i386/loose_ends.c +++ b/i386/i386/loose_ends.c @@ -30,7 +30,7 @@ #define MACH_ASSERT 1 #else #define MACH_ASSERT 0 -#endif +#endif /* NDEBUG */ /* * For now we will always go to single user mode, since there is -- cgit v1.2.3 From f2f02114f65ca94c5c6db050136226377042a1e3 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 14 Nov 2013 12:11:59 +0100 Subject: i386/i386/loose_ends.c: remove unused variable * i386/i386/loose_ends.c (boothowto): Remove unused variable. --- i386/i386/loose_ends.c | 1 - 1 file changed, 1 deletion(-) diff --git a/i386/i386/loose_ends.c b/i386/i386/loose_ends.c index 49848ab4..30e7763f 100644 --- a/i386/i386/loose_ends.c +++ b/i386/i386/loose_ends.c @@ -36,7 +36,6 @@ * For now we will always go to single user mode, since there is * no way pass this request through the boot. */ -int boothowto = 0; /* Someone with time should write code to set cpuspeed automagically */ int cpuspeed = 4; -- cgit v1.2.3 From 26cde02db986bc1d36af9b34192fb47e8a01965d Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 14 Nov 2013 12:15:06 +0100 Subject: i386/i386/machine_routines.h: add comment after endif * i386/i386/machine_routines.h (_I386_MACHINE_ROUTINES_H_): Add comment after endif. --- i386/i386/machine_routines.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i386/i386/machine_routines.h b/i386/i386/machine_routines.h index a1fb489e..d77849a6 100644 --- a/i386/i386/machine_routines.h +++ b/i386/i386/machine_routines.h @@ -33,5 +33,5 @@ #define MACHINE_SERVER mach_i386_server #define MACHINE_SERVER_ROUTINE mach_i386_server_routine -#endif +#endif /* _I386_MACHINE_ROUTINES_H_ */ -- cgit v1.2.3 From 81d9de71e8a06c226f6e0e2987e31188f278e9dd Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 14 Nov 2013 12:20:04 +0100 Subject: i386/i386/mp_desc.c: remove register qualifiers * i386/i386/mp_desc.c: Remove register qualifiers. --- i386/i386/mp_desc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/i386/i386/mp_desc.c b/i386/i386/mp_desc.c index 95f55af2..efdc3eed 100644 --- a/i386/i386/mp_desc.c +++ b/i386/i386/mp_desc.c @@ -107,9 +107,9 @@ extern struct real_descriptor ldt[LDTSZ]; struct mp_desc_table * mp_desc_init(mycpu) - register int mycpu; + int mycpu; { - register struct mp_desc_table *mpt; + struct mp_desc_table *mpt; if (mycpu == master_cpu) { /* @@ -179,7 +179,7 @@ mp_desc_init(mycpu) void interrupt_stack_alloc() { - register int i; + int i; int cpu_count; vm_offset_t stack_start; -- cgit v1.2.3 From 7fd1f26a1284427b3d71b97da97141eb1fb4ae2d Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 14 Nov 2013 12:25:55 +0100 Subject: i386/i386/pcb.c: remove register qualifiers * i386/i386/pcb.c: Remove register qualifiers. --- i386/i386/pcb.c | 54 +++++++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/i386/i386/pcb.c b/i386/i386/pcb.c index 97ec00e6..da42bd1a 100644 --- a/i386/i386/pcb.c +++ b/i386/i386/pcb.c @@ -77,8 +77,8 @@ vm_offset_t kernel_stack[NCPUS]; /* top of active_stack */ */ void stack_attach(thread, stack, continuation) - register thread_t thread; - register vm_offset_t stack; + thread_t thread; + vm_offset_t stack; void (*continuation)(thread_t); { counter(if (++c_stacks_current > c_stacks_max) @@ -112,9 +112,9 @@ void stack_attach(thread, stack, continuation) */ vm_offset_t stack_detach(thread) - register thread_t thread; + thread_t thread; { - register vm_offset_t stack; + vm_offset_t stack; counter(if (--c_stacks_current < c_stacks_min) c_stacks_min = c_stacks_current); @@ -137,7 +137,7 @@ vm_offset_t stack_detach(thread) ((struct real_descriptor *)&curr_gdt(mycpu)[sel_idx(sel)]) void switch_ktss(pcb) - register pcb_t pcb; + pcb_t pcb; { int mycpu = cpu_number(); { @@ -166,7 +166,7 @@ void switch_ktss(pcb) } { - register user_ldt_t tldt = pcb->ims.ldt; + user_ldt_t tldt = pcb->ims.ldt; /* * Set the thread`s LDT. */ @@ -250,11 +250,11 @@ update_ktss_iopb (unsigned char *new_iopb, io_port_t size) */ void stack_handoff(old, new) - register thread_t old; - register thread_t new; + thread_t old; + thread_t new; { - register int mycpu = cpu_number(); - register vm_offset_t stack; + int mycpu = cpu_number(); + vm_offset_t stack; /* * Save FP registers if in use. @@ -314,7 +314,7 @@ void stack_handoff(old, new) * Switch to the first thread on a CPU. */ void load_context(new) - register thread_t new; + thread_t new; { switch_ktss(new->pcb); Load_context(new); @@ -326,9 +326,9 @@ void load_context(new) * and return it. */ thread_t switch_context(old, continuation, new) - register thread_t old; + thread_t old; void (*continuation)(); - register thread_t new; + thread_t new; { /* * Save FP registers if in use. @@ -380,9 +380,9 @@ void pcb_module_init() } void pcb_init(thread) - register thread_t thread; + thread_t thread; { - register pcb_t pcb; + pcb_t pcb; pcb = (pcb_t) kmem_cache_alloc(&pcb_cache); if (pcb == 0) @@ -413,9 +413,9 @@ void pcb_init(thread) } void pcb_terminate(thread) - register thread_t thread; + thread_t thread; { - register pcb_t pcb = thread->pcb; + pcb_t pcb = thread->pcb; counter(if (--c_threads_current < c_threads_min) c_threads_min = c_threads_current); @@ -456,8 +456,8 @@ kern_return_t thread_setstatus(thread, flavor, tstate, count) case i386_THREAD_STATE: case i386_REGS_SEGS_STATE: { - register struct i386_thread_state *state; - register struct i386_saved_state *saved_state; + struct i386_thread_state *state; + struct i386_saved_state *saved_state; if (count < i386_THREAD_STATE_COUNT) { return(KERN_INVALID_ARGUMENT); @@ -599,7 +599,7 @@ kern_return_t thread_setstatus(thread, flavor, tstate, count) case i386_V86_ASSIST_STATE: { - register struct i386_v86_assist_state *state; + struct i386_v86_assist_state *state; vm_offset_t int_table; int int_count; @@ -626,7 +626,7 @@ kern_return_t thread_setstatus(thread, flavor, tstate, count) case i386_DEBUG_STATE: { - register struct i386_debug_state *state; + struct i386_debug_state *state; kern_return_t ret; if (count < i386_DEBUG_STATE_COUNT) @@ -653,7 +653,7 @@ kern_return_t thread_setstatus(thread, flavor, tstate, count) */ kern_return_t thread_getstatus(thread, flavor, tstate, count) - register thread_t thread; + thread_t thread; int flavor; thread_state_t tstate; /* pointer to OUT array */ unsigned int *count; /* IN/OUT */ @@ -672,8 +672,8 @@ kern_return_t thread_getstatus(thread, flavor, tstate, count) case i386_THREAD_STATE: case i386_REGS_SEGS_STATE: { - register struct i386_thread_state *state; - register struct i386_saved_state *saved_state; + struct i386_thread_state *state; + struct i386_saved_state *saved_state; if (*count < i386_THREAD_STATE_COUNT) return(KERN_INVALID_ARGUMENT); @@ -743,7 +743,7 @@ kern_return_t thread_getstatus(thread, flavor, tstate, count) * Temporary - replace by i386_io_map */ case i386_ISA_PORT_MAP_STATE: { - register struct i386_isa_port_map_state *state; + struct i386_isa_port_map_state *state; if (*count < i386_ISA_PORT_MAP_STATE_COUNT) return(KERN_INVALID_ARGUMENT); @@ -780,7 +780,7 @@ kern_return_t thread_getstatus(thread, flavor, tstate, count) case i386_DEBUG_STATE: { - register struct i386_debug_state *state; + struct i386_debug_state *state; if (*count < i386_DEBUG_STATE_COUNT) return KERN_INVALID_ARGUMENT; @@ -837,7 +837,7 @@ set_user_regs(stack_base, stack_size, exec_info, arg_size) vm_size_t arg_size; { vm_offset_t arg_addr; - register struct i386_saved_state *saved_state; + struct i386_saved_state *saved_state; arg_size = (arg_size + sizeof(int) - 1) & ~(sizeof(int)-1); arg_addr = stack_base + stack_size - arg_size; -- cgit v1.2.3 From de80e220c5132e7224be2d388e3ff8cb5e5dd030 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 14 Nov 2013 12:28:55 +0100 Subject: i386/i386/pic.h: add comment after endif * i386/i386/pic.h (__ASSEMBLER__): Add comment after endif. --- i386/i386/pic.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i386/i386/pic.h b/i386/i386/pic.h index 52f6ec16..80bf65d6 100644 --- a/i386/i386/pic.h +++ b/i386/i386/pic.h @@ -183,6 +183,6 @@ extern int curr_pic_mask; extern int pic_mask[]; extern void prtnull(int unit); extern void intnull(int unit); -#endif +#endif /* __ASSEMBLER__ */ #endif /* _I386_PIC_H_ */ -- cgit v1.2.3 From a362fb22008bdab332d5da2d83f6428340c373ab Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 14 Nov 2013 12:39:34 +0100 Subject: i386/i386/thread.h: add comment after endif * i386/i386/thread.h (LINUX_DEV): Add comment after endif. --- i386/i386/thread.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i386/i386/thread.h b/i386/i386/thread.h index 450ec55f..35a28025 100644 --- a/i386/i386/thread.h +++ b/i386/i386/thread.h @@ -179,7 +179,7 @@ typedef struct pcb { decl_simple_lock_data(, lock) #ifdef LINUX_DEV void *data; -#endif +#endif /* LINUX_DEV */ } *pcb_t; /* -- cgit v1.2.3 From 6559a03dd8ea9e9af34802766417dde1d1b047b2 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 14 Nov 2013 12:45:16 +0100 Subject: i386/i386/trap.c: remove register qualifiers * i386/i386/trap.c: Remove register qualifiers. --- i386/i386/trap.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/i386/i386/trap.c b/i386/i386/trap.c index c6aab488..f4834977 100644 --- a/i386/i386/trap.c +++ b/i386/i386/trap.c @@ -75,8 +75,8 @@ extern boolean_t db_watchpoints_inserted; void thread_kdb_return() { - register thread_t thread = current_thread(); - register struct i386_saved_state *regs = USER_REGS(thread); + thread_t thread = current_thread(); + struct i386_saved_state *regs = USER_REGS(thread); if (kdb_trap(regs->trapno, regs->err, regs)) { thread_exception_return(); @@ -94,8 +94,8 @@ void user_page_fault_continue(kr) kern_return_t kr; { - register thread_t thread = current_thread(); - register struct i386_saved_state *regs = USER_REGS(thread); + thread_t thread = current_thread(); + struct i386_saved_state *regs = USER_REGS(thread); if (kr == KERN_SUCCESS) { #if MACH_KDB @@ -159,14 +159,14 @@ boolean_t brb = TRUE; * fatal. */ void kernel_trap(regs) - register struct i386_saved_state *regs; + struct i386_saved_state *regs; { - int code; - int subcode; - register int type; + int code; + int subcode; + int type; vm_map_t map; kern_return_t result; - register thread_t thread; + thread_t thread; extern char _start[], etext[]; type = regs->trapno; @@ -275,7 +275,7 @@ dump_ss(regs); * Certain faults require that we back up * the EIP. */ - register struct recovery *rp; + struct recovery *rp; /* Linear searching; but the list is small enough. */ for (rp = retry_table; rp < retry_table_end; rp++) { @@ -292,7 +292,7 @@ dump_ss(regs); * for this fault, go there. */ { - register struct recovery *rp; + struct recovery *rp; /* Linear searching; but the list is small enough. */ for (rp = recover_table; @@ -352,13 +352,13 @@ dump_ss(regs); * Return TRUE if from emulated system call. */ int user_trap(regs) - register struct i386_saved_state *regs; + struct i386_saved_state *regs; { int exc = 0; /* Suppress gcc warning */ int code; int subcode; - register int type; - register thread_t thread = current_thread(); + int type; + thread_t thread = current_thread(); if ((vm_offset_t)thread < phys_last_addr) { printf("user_trap: bad thread pointer 0x%p\n", thread); @@ -645,7 +645,7 @@ unsigned interrupted_pc(t) thread_t t; { - register struct i386_saved_state *iss; + struct i386_saved_state *iss; iss = USER_REGS(t); return iss->eip; -- cgit v1.2.3 From 0b7ba442c6422ebb4b403ef91effd63168c8b250 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 14 Nov 2013 13:05:16 +0100 Subject: i386/i386at/autoconf.c: remove register qualifiers * i386/i386at/autoconf.c: Remove register qualifiers. --- i386/i386at/autoconf.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/i386/i386at/autoconf.c b/i386/i386at/autoconf.c index 93c71412..66493b03 100644 --- a/i386/i386at/autoconf.c +++ b/i386/i386at/autoconf.c @@ -92,9 +92,9 @@ struct bus_device bus_device_init[] = { */ void probeio(void) { - register struct bus_device *device; - register struct bus_ctlr *master; - int i = 0; + struct bus_device *device; + struct bus_ctlr *master; + int i = 0; for (master = bus_master_init; master->driver; master++) { -- cgit v1.2.3 From c0039c01ace499c8e51fbd417f0a8df5db5d89fd Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 14 Nov 2013 13:07:40 +0100 Subject: i386/i386at/com.c: trivial stylistic fix for consistency * i386/i386at/com.c: Trivial stylistic fix for consistency. --- i386/i386at/com.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i386/i386at/com.c b/i386/i386at/com.c index 93c3faaa..5fb3ec09 100644 --- a/i386/i386at/com.c +++ b/i386/i386at/com.c @@ -265,7 +265,7 @@ comcninit(struct consdev *cp) outb(LINE_CTL(addr), iDLAB); outb(BAUD_LSB(addr), divisorreg[RCBAUD] & 0xff); outb(BAUD_MSB(addr), divisorreg[RCBAUD] >>8); - outb(LINE_CTL(addr), i8BITS); + outb(LINE_CTL(addr), i8BITS); outb(INTR_ENAB(addr), 0); outb(MODEM_CTL(addr), iDTR|iRTS|iOUT2); -- cgit v1.2.3 From 931fe2577d42b7779bf2e0c4d70f871f2d7fd39e Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 14 Nov 2013 13:09:37 +0100 Subject: i386/i386at/com.c: remove register qualifiers * i386/i386at/com.c: Remove register qualifiers. --- i386/i386at/com.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/i386/i386at/com.c b/i386/i386at/com.c index 5fb3ec09..e0549eae 100644 --- a/i386/i386at/com.c +++ b/i386/i386at/com.c @@ -499,7 +499,7 @@ void comintr(unit) int unit; { - register struct tty *tp = &com_tty[unit]; + struct tty *tp = &com_tty[unit]; u_short addr = cominfo[unit]->address; static char comoverrun = 0; char c, line, intr_id; @@ -751,14 +751,14 @@ commodem_intr( */ int commctl( - register struct tty *tp, - int bits, - int how) + struct tty *tp, + int bits, + int how) { spl_t s; int unit; vm_offset_t dev_addr; - register int b = 0; /* Suppress gcc warning */ + int b = 0; /* Suppress gcc warning */ unit = minor(tp->t_dev); @@ -818,7 +818,7 @@ commctl( void comstop(tp, flags) -register struct tty *tp; +struct tty *tp; int flags; { if ((tp->t_state & TS_BUSY) && (tp->t_state & TS_TTSTOP) == 0) -- cgit v1.2.3 From 1ba3de794c4a32f8dbe6e0a03d044a6d31425954 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 14 Nov 2013 13:13:17 +0100 Subject: i386/i386at/idt.h: add comment after endif * i386/i386at/idt.h (__ASSEMBLER__): Add comment after endif. --- i386/i386at/idt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i386/i386at/idt.h b/i386/i386at/idt.h index 1b3284fa..56e6296c 100644 --- a/i386/i386at/idt.h +++ b/i386/i386at/idt.h @@ -36,6 +36,6 @@ #ifndef __ASSEMBLER__ extern void idt_init (void); -#endif +#endif /* __ASSEMBLER__ */ #endif /* _I386AT_IDT_ */ -- cgit v1.2.3 From cee816436c38781fd4f182fd09448a6fdc6db006 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 14 Nov 2013 13:15:01 +0100 Subject: i386/i386at/int_init.h: add comment after endif * i386/i386at/int_init.h (__ASSEMBLER__): Add comment after endif. --- i386/i386at/int_init.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i386/i386at/int_init.h b/i386/i386at/int_init.h index f4abef0b..f9b03b74 100644 --- a/i386/i386at/int_init.h +++ b/i386/i386at/int_init.h @@ -29,6 +29,6 @@ #ifndef __ASSEMBLER__ extern void int_init (void); -#endif +#endif /* __ASSEMBLER__ */ #endif /* _INT_INIT_H_ */ -- cgit v1.2.3 From 708c68198de966b475a07b50ec8da3122d58d0db Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 14 Nov 2013 13:19:05 +0100 Subject: i386/i386at/kd_event.c: remove register qualifiers * i386/i386at/kd_event.c: Remove register qualifiers. --- i386/i386at/kd_event.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/i386/i386at/kd_event.c b/i386/i386at/kd_event.c index 4d2ea008..3a216c0b 100644 --- a/i386/i386at/kd_event.c +++ b/i386/i386at/kd_event.c @@ -206,11 +206,11 @@ boolean_t kbd_read_done(); /* forward */ int kbdread(dev, ior) - dev_t dev; - register io_req_t ior; + dev_t dev; + io_req_t ior; { - register int err, count; - register spl_t s; + int err, count; + spl_t s; /* Check if IO_COUNT is a multiple of the record size. */ if (ior->io_count % sizeof(kd_event) != 0) @@ -233,7 +233,7 @@ kbdread(dev, ior) } count = 0; while (!kdq_empty(&kbd_queue) && count < ior->io_count) { - register kd_event *ev; + kd_event *ev; ev = kdq_get(&kbd_queue); *(kd_event *)(&ior->io_data[count]) = *ev; @@ -245,10 +245,10 @@ kbdread(dev, ior) } boolean_t kbd_read_done(ior) - register io_req_t ior; + io_req_t ior; { - register int count; - register spl_t s; + int count; + spl_t s; s = SPLKD(); if (kdq_empty(&kbd_queue)) { @@ -260,7 +260,7 @@ boolean_t kbd_read_done(ior) count = 0; while (!kdq_empty(&kbd_queue) && count < ior->io_count) { - register kd_event *ev; + kd_event *ev; ev = kdq_get(&kbd_queue); *(kd_event *)(&ior->io_data[count]) = *ev; @@ -308,7 +308,7 @@ kbd_enqueue(ev) kdq_put(&kbd_queue, ev); { - register io_req_t ior; + io_req_t ior; while ((ior = (io_req_t)dequeue_head(&kbd_read_queue)) != 0) iodone(ior); } @@ -321,7 +321,7 @@ void kdb_in_out(p) u_int *p; { -register int t = p[0]; + int t = p[0]; switch (t & K_X_TYPE) { case K_X_IN|K_X_BYTE: @@ -353,7 +353,7 @@ register int t = p[0]; void X_kdb_enter() { -register u_int *u_ip, *endp; + u_int *u_ip, *endp; for (u_ip = X_kdb_enter_str, endp = &X_kdb_enter_str[X_kdb_enter_len]; u_ip < endp; @@ -364,7 +364,7 @@ register u_int *u_ip, *endp; void X_kdb_exit() { -register u_int *u_ip, *endp; + u_int *u_ip, *endp; for (u_ip = X_kdb_exit_str, endp = &X_kdb_exit_str[X_kdb_exit_len]; u_ip < endp; -- cgit v1.2.3 From 3ec46ece13c33805ad6f4fd991a70f14be4e8e78 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 14 Nov 2013 13:23:06 +0100 Subject: i386/i386at/kd.c: remove register qualifiers * i386/i386at/kd.c: Remove register qualifiers. --- i386/i386at/kd.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/i386/i386at/kd.c b/i386/i386at/kd.c index c9778629..3890c3d3 100644 --- a/i386/i386at/kd.c +++ b/i386/i386at/kd.c @@ -1133,7 +1133,7 @@ struct tty *tp; /*ARGSUSED*/ void kdstop(tp, flags) - register struct tty *tp; + struct tty *tp; int flags; { /* @@ -2084,9 +2084,9 @@ void kd_delch(number) int number; { - int count; /* num words moved/filled */ - int delbytes; /* bytes to delete */ - register csrpos_t to; + int count; /* num words moved/filled */ + int delbytes; /* bytes to delete */ + csrpos_t to; csrpos_t from; csrpos_t nextline; /* start of next line */ @@ -2713,8 +2713,8 @@ csrpos_t pos; char ch, chattr; { short xbit, ybit; /* u/l corner of char pos */ - register u_char *to, *from; - register short i, j; + u_char *to, *from; + short i, j; u_char mask = (chattr == KA_REVERSE ? 0xff : 0); if ((u_char)ch >= chars_in_font) @@ -2741,8 +2741,8 @@ csrpos_t from, to; { short from_xbit, from_ybit; short to_xbit, to_ybit; - register u_char *tp, *fp; - register short i, j; + u_char *tp, *fp; + short i, j; bmpch2bit(from, &from_xbit, &from_ybit); bmpch2bit(to, &to_xbit, &to_ybit); @@ -2840,7 +2840,7 @@ csrpos_t to; /* 1st char */ int count; /* num chars */ char chattr; /* reverse or normal */ { - register short i; + short i; u_short clearval; u_short clearbyte = (chattr == KA_REVERSE ? char_white : char_black); @@ -2879,8 +2879,8 @@ csrpos_t pos; u_char val; { short xbit, ybit; - register u_char *cp; - register short line, byte; + u_char *cp; + short line, byte; bmpch2bit(pos, &xbit, &ybit); ybit += char_height; /* position at bottom of line */ @@ -2901,7 +2901,7 @@ bmpch2bit(pos, xb, yb) csrpos_t pos; short *xb, *yb; /* x, y bit positions, u/l corner */ { - register short xch, ych; + short xch, ych; xch = (pos / ONE_SPACE) % kd_cols; ych = pos / (ONE_SPACE * kd_cols); -- cgit v1.2.3 From 5d58d71777f0f82598135088be8a7400965b7a53 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 14 Nov 2013 13:27:10 +0100 Subject: i386/i386at/kd_mouse.c: remove register qualifiers * i386/i386at/kd_mouse.c: Remove register qualifiers. --- i386/i386at/kd_mouse.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/i386/i386at/kd_mouse.c b/i386/i386at/kd_mouse.c index 6e7b68a8..99fc2662 100644 --- a/i386/i386at/kd_mouse.c +++ b/i386/i386at/kd_mouse.c @@ -323,11 +323,11 @@ boolean_t mouse_read_done(); /* forward */ int mouseread(dev, ior) - dev_t dev; - register io_req_t ior; + dev_t dev; + io_req_t ior; { - register int err, count; - register spl_t s; + int err, count; + spl_t s; /* Check if IO_COUNT is a multiple of the record size. */ if (ior->io_count % sizeof(kd_event) != 0) @@ -350,7 +350,7 @@ mouseread(dev, ior) } count = 0; while (!kdq_empty(&mouse_queue) && count < ior->io_count) { - register kd_event *ev; + kd_event *ev; ev = kdq_get(&mouse_queue); *(kd_event *)(&ior->io_data[count]) = *ev; @@ -362,10 +362,10 @@ mouseread(dev, ior) } boolean_t mouse_read_done(ior) - register io_req_t ior; + io_req_t ior; { - register int count; - register spl_t s; + int count; + spl_t s; s = SPLKD(); if (kdq_empty(&mouse_queue)) { @@ -377,7 +377,7 @@ boolean_t mouse_read_done(ior) count = 0; while (!kdq_empty(&mouse_queue) && count < ior->io_count) { - register kd_event *ev; + kd_event *ev; ev = kdq_get(&mouse_queue); *(kd_event *)(&ior->io_data[count]) = *ev; @@ -809,7 +809,7 @@ mouse_enqueue(ev) kdq_put(&mouse_queue, ev); { - register io_req_t ior; + io_req_t ior; while ((ior = (io_req_t)dequeue_head(&mouse_read_queue)) != 0) iodone(ior); } -- cgit v1.2.3 From 56a13f6f71faed22ae371394c086a84169725a22 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 14 Nov 2013 13:29:18 +0100 Subject: i386/i386at/lpr.c: remove register qualifier * i386/i386at/lpr.c: Remove register qualifier. --- i386/i386at/lpr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i386/i386at/lpr.c b/i386/i386at/lpr.c index c92795ef..0f06be0a 100644 --- a/i386/i386at/lpr.c +++ b/i386/i386at/lpr.c @@ -221,7 +221,7 @@ natural_t count; void lprintr(unit) int unit; { - register struct tty *tp = &lpr_tty[unit]; + struct tty *tp = &lpr_tty[unit]; if ((tp->t_state & TS_ISOPEN) == 0) return; -- cgit v1.2.3 From e99f8085989d9702fe55a818bc54a7799d9d29bb Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 14 Nov 2013 13:32:04 +0100 Subject: i386/i386at/rtc.c: remove register qualifier * i386/i386at/rtc.c: Remove register qualifier. --- i386/i386at/rtc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i386/i386at/rtc.c b/i386/i386at/rtc.c index 67768013..31128300 100644 --- a/i386/i386at/rtc.c +++ b/i386/i386at/rtc.c @@ -86,7 +86,7 @@ void rtcput(regs) unsigned char *regs; { - register unsigned char x; + unsigned char x; if (first_rtcopen_ever) { rtcinit(); -- cgit v1.2.3 From d16c391a0e9c95e21b173d4689556dcaaa6cbcd3 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 14 Nov 2013 13:32:56 +0100 Subject: i386/i386at/rtc.h: remove register qualifiers * i386/i386at/rtc.h: Remove register qualifiers. --- i386/i386at/rtc.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/i386/i386at/rtc.h b/i386/i386at/rtc.h index 64a528aa..97eabe95 100644 --- a/i386/i386at/rtc.h +++ b/i386/i386at/rtc.h @@ -117,7 +117,7 @@ struct rtc_st { */ #define load_rtc(regs) \ {\ - register int i; \ + int i; \ \ for (i = 0; i < RTC_NREG; i++) { \ outb(RTC_ADDR, i); \ @@ -130,7 +130,7 @@ struct rtc_st { */ #define save_rtc(regs) \ { \ - register int i; \ + int i; \ for (i = 0; i < RTC_NREGP; i++) { \ outb(RTC_ADDR, i); \ outb(RTC_DATA, regs[i]);\ -- cgit v1.2.3 From 6c571e4d893b07a7fef36fe703008f347739302e Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 14 Nov 2013 13:42:46 +0100 Subject: i386/intel/pmap.c: remove register qualifiers * i386/intel/pmap.c: Remove register qualifiers. --- i386/intel/pmap.c | 158 +++++++++++++++++++++++++++--------------------------- 1 file changed, 79 insertions(+), 79 deletions(-) diff --git a/i386/intel/pmap.c b/i386/intel/pmap.c index c1eca6e0..7db14e58 100644 --- a/i386/intel/pmap.c +++ b/i386/intel/pmap.c @@ -462,7 +462,7 @@ pmap_pte(pmap_t pmap, vm_offset_t addr) void ptep_check(ptep) ptep_t ptep; { - register pt_entry_t *pte, *epte; + pt_entry_t *pte, *epte; int ctu, ctw; /* check the use and wired counts */ @@ -497,12 +497,12 @@ void ptep_check(ptep) * specified memory. */ vm_offset_t pmap_map(virt, start, end, prot) - register vm_offset_t virt; - register vm_offset_t start; - register vm_offset_t end; - register int prot; + vm_offset_t virt; + vm_offset_t start; + vm_offset_t end; + int prot; { - register int ps; + int ps; ps = PAGE_SIZE; while (start < end) { @@ -520,14 +520,14 @@ vm_offset_t pmap_map(virt, start, end, prot) * Otherwise like pmap_map. */ vm_offset_t pmap_map_bd(virt, start, end, prot) - register vm_offset_t virt; - register vm_offset_t start; - register vm_offset_t end; - vm_prot_t prot; + vm_offset_t virt; + vm_offset_t start; + vm_offset_t end; + vm_prot_t prot; { - register pt_entry_t template; - register pt_entry_t *pte; - int spl; + pt_entry_t template; + pt_entry_t *pte; + int spl; #ifdef MACH_PV_PAGETABLES int n, i = 0; struct mmu_update update[HYP_BATCH_MMU_UPDATES]; @@ -906,9 +906,9 @@ void pmap_virtual_space(startp, endp) */ void pmap_init() { - register long npages; + long npages; vm_offset_t addr; - register vm_size_t s; + vm_size_t s; #if NCPUS > 1 int i; #endif /* NCPUS > 1 */ @@ -1005,8 +1005,8 @@ boolean_t pmap_verify_free(phys) vm_offset_t pmap_page_table_page_alloc() { - register vm_page_t m; - register vm_offset_t pa; + vm_page_t m; + vm_offset_t pa; check_simple_locks(); @@ -1121,8 +1121,8 @@ pmap_page_table_page_dealloc(pa) pmap_t pmap_create(size) vm_size_t size; { - register pmap_t p; - register pmap_statistics_t stats; + pmap_t p; + pmap_statistics_t stats; /* * A software use-only map doesn't even need a map. @@ -1199,12 +1199,12 @@ pmap_t pmap_create(size) */ void pmap_destroy(p) - register pmap_t p; + pmap_t p; { - register pt_entry_t *pdep; - register vm_offset_t pa; - register int c, s; - register vm_page_t m; + pt_entry_t *pdep; + vm_offset_t pa; + int c, s; + vm_page_t m; if (p == PMAP_NULL) return; @@ -1266,7 +1266,7 @@ void pmap_destroy(p) */ void pmap_reference(p) - register pmap_t p; + pmap_t p; { int s; if (p != PMAP_NULL) { @@ -1297,7 +1297,7 @@ void pmap_remove_range(pmap, va, spte, epte) pt_entry_t *spte; pt_entry_t *epte; { - register pt_entry_t *cpte; + pt_entry_t *cpte; int num_removed, num_unwired; int pai; vm_offset_t pa; @@ -1330,8 +1330,8 @@ void pmap_remove_range(pmap, va, spte, epte) * Outside range of managed physical memory. * Just remove the mappings. */ - register int i = ptes_per_vm_page; - register pt_entry_t *lpte = cpte; + int i = ptes_per_vm_page; + pt_entry_t *lpte = cpte; do { #ifdef MACH_PV_PAGETABLES update[ii].ptr = kv_to_ma(lpte); @@ -1358,8 +1358,8 @@ void pmap_remove_range(pmap, va, spte, epte) * Get the modify and reference bits. */ { - register int i; - register pt_entry_t *lpte; + int i; + pt_entry_t *lpte; i = ptes_per_vm_page; lpte = cpte; @@ -1388,7 +1388,7 @@ void pmap_remove_range(pmap, va, spte, epte) * this physical page. */ { - register pv_entry_t pv_h, prev, cur; + pv_entry_t pv_h, prev, cur; pv_h = pai_to_pvh(pai); if (pv_h->pmap == PMAP_NULL) { @@ -1452,8 +1452,8 @@ void pmap_remove(map, s, e) vm_offset_t s, e; { int spl; - register pt_entry_t *pde; - register pt_entry_t *spte, *epte; + pt_entry_t *pde; + pt_entry_t *spte, *epte; vm_offset_t l; vm_offset_t _s = s; @@ -1493,10 +1493,10 @@ void pmap_page_protect(phys, prot) vm_prot_t prot; { pv_entry_t pv_h, prev; - register pv_entry_t pv_e; - register pt_entry_t *pte; + pv_entry_t pv_e; + pt_entry_t *pte; int pai; - register pmap_t pmap; + pmap_t pmap; int spl; boolean_t remove; @@ -1542,7 +1542,7 @@ void pmap_page_protect(phys, prot) prev = pv_e = pv_h; do { - register vm_offset_t va; + vm_offset_t va; pmap = pv_e->pmap; /* @@ -1571,7 +1571,7 @@ void pmap_page_protect(phys, prot) panic("pmap_remove_all removing a wired page"); { - register int i = ptes_per_vm_page; + int i = ptes_per_vm_page; do { pmap_phys_attributes[pai] |= @@ -1656,9 +1656,9 @@ void pmap_protect(map, s, e, prot) vm_offset_t s, e; vm_prot_t prot; { - register pt_entry_t *pde; - register pt_entry_t *spte, *epte; - vm_offset_t l; + pt_entry_t *pde; + pt_entry_t *spte, *epte; + vm_offset_t l; int spl; vm_offset_t _s = s; @@ -1758,15 +1758,15 @@ void pmap_protect(map, s, e, prot) * insert this page into the given map NOW. */ void pmap_enter(pmap, v, pa, prot, wired) - register pmap_t pmap; + pmap_t pmap; vm_offset_t v; - register vm_offset_t pa; + vm_offset_t pa; vm_prot_t prot; boolean_t wired; { - register pt_entry_t *pte; - register pv_entry_t pv_h; - register int i, pai; + pt_entry_t *pte; + pv_entry_t pv_h; + int i, pai; pv_entry_t pv_e; pt_entry_t template; int spl; @@ -2060,13 +2060,13 @@ Retry: * The mapping must already exist in the pmap. */ void pmap_change_wiring(map, v, wired) - register pmap_t map; + pmap_t map; vm_offset_t v; boolean_t wired; { - register pt_entry_t *pte; - register int i; - int spl; + pt_entry_t *pte; + int i; + int spl; /* * We must grab the pmap system lock because we may @@ -2115,12 +2115,12 @@ void pmap_change_wiring(map, v, wired) */ vm_offset_t pmap_extract(pmap, va) - register pmap_t pmap; + pmap_t pmap; vm_offset_t va; { - register pt_entry_t *pte; - register vm_offset_t pa; - int spl; + pt_entry_t *pte; + vm_offset_t pa; + int spl; SPLVM(spl); simple_lock(&pmap->lock); @@ -2167,7 +2167,7 @@ void pmap_copy(dst_pmap, src_pmap, dst_addr, len, src_addr) void pmap_collect(p) pmap_t p; { - register pt_entry_t *pdp, *ptp; + pt_entry_t *pdp, *ptp; pt_entry_t *eptp; vm_offset_t pa; int spl, wired; @@ -2224,8 +2224,8 @@ void pmap_collect(p) * Invalidate the page directory pointer. */ { - register int i = ptes_per_vm_page; - register pt_entry_t *pdep = pdp; + int i = ptes_per_vm_page; + pt_entry_t *pdep = pdp; do { #ifdef MACH_PV_PAGETABLES unsigned long pte = *pdep; @@ -2389,10 +2389,10 @@ phys_attribute_clear(phys, bits) int bits; { pv_entry_t pv_h; - register pv_entry_t pv_e; - register pt_entry_t *pte; + pv_entry_t pv_e; + pt_entry_t *pte; int pai; - register pmap_t pmap; + pmap_t pmap; int spl; assert(phys != vm_page_fictitious_addr); @@ -2423,7 +2423,7 @@ phys_attribute_clear(phys, bits) * There are some mappings. */ for (pv_e = pv_h; pv_e != PV_ENTRY_NULL; pv_e = pv_e->next) { - register vm_offset_t va; + vm_offset_t va; pmap = pv_e->pmap; /* @@ -2446,7 +2446,7 @@ phys_attribute_clear(phys, bits) * Clear modify or reference bits. */ { - register int i = ptes_per_vm_page; + int i = ptes_per_vm_page; do { #ifdef MACH_PV_PAGETABLES if (!(hyp_mmu_update_pte(kv_to_ma(pte), *pte & ~bits))) @@ -2475,10 +2475,10 @@ phys_attribute_test(phys, bits) int bits; { pv_entry_t pv_h; - register pv_entry_t pv_e; - register pt_entry_t *pte; + pv_entry_t pv_e; + pt_entry_t *pte; int pai; - register pmap_t pmap; + pmap_t pmap; int spl; assert(phys != vm_page_fictitious_addr); @@ -2522,7 +2522,7 @@ phys_attribute_test(phys, bits) simple_lock(&pmap->lock); { - register vm_offset_t va; + vm_offset_t va; va = pv_e->va; pte = pmap_pte(pmap, va); @@ -2540,7 +2540,7 @@ phys_attribute_test(phys, bits) * Check modify or reference bits. */ { - register int i = ptes_per_vm_page; + int i = ptes_per_vm_page; do { if (*pte & bits) { @@ -2562,7 +2562,7 @@ phys_attribute_test(phys, bits) */ void pmap_clear_modify(phys) - register vm_offset_t phys; + vm_offset_t phys; { phys_attribute_clear(phys, PHYS_MODIFIED); } @@ -2575,7 +2575,7 @@ void pmap_clear_modify(phys) */ boolean_t pmap_is_modified(phys) - register vm_offset_t phys; + vm_offset_t phys; { return (phys_attribute_test(phys, PHYS_MODIFIED)); } @@ -2674,8 +2674,8 @@ void signal_cpus(use_list, pmap, start, end) pmap_t pmap; vm_offset_t start, end; { - register int which_cpu, j; - register pmap_update_list_t update_list_p; + int which_cpu, j; + pmap_update_list_t update_list_p; while ((which_cpu = ffs(use_list)) != 0) { which_cpu -= 1; /* convert to 0 origin */ @@ -2709,12 +2709,12 @@ void signal_cpus(use_list, pmap, start, end) } void process_pmap_updates(my_pmap) - register pmap_t my_pmap; + pmap_t my_pmap; { - register int my_cpu = cpu_number(); - register pmap_update_list_t update_list_p; - register int j; - register pmap_t pmap; + int my_cpu = cpu_number(); + pmap_update_list_t update_list_p; + int j; + pmap_t pmap; update_list_p = &cpu_update_list[my_cpu]; simple_lock(&update_list_p->lock); @@ -2739,9 +2739,9 @@ void process_pmap_updates(my_pmap) */ void pmap_update_interrupt(void) { - register int my_cpu; - register pmap_t my_pmap; - int s; + int my_cpu; + pmap_t my_pmap; + int s; my_cpu = cpu_number(); -- cgit v1.2.3 From 38552071b77e4bc21575892a5c499597e40632a7 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 14 Nov 2013 13:44:30 +0100 Subject: i386/intel/pmap.h: remove register qualifiers * i386/intel/pmap.h: Remove register qualifiers. --- i386/intel/pmap.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/i386/intel/pmap.h b/i386/intel/pmap.h index 93293e3d..087e0ef4 100644 --- a/i386/intel/pmap.h +++ b/i386/intel/pmap.h @@ -282,7 +282,7 @@ pt_entry_t *pmap_pte(pmap_t pmap, vm_offset_t addr); } #define PMAP_ACTIVATE_USER(pmap, th, my_cpu) { \ - register pmap_t tpmap = (pmap); \ + pmap_t tpmap = (pmap); \ \ if (tpmap == kernel_pmap) { \ /* \ @@ -324,7 +324,7 @@ pt_entry_t *pmap_pte(pmap_t pmap, vm_offset_t addr); } #define PMAP_DEACTIVATE_USER(pmap, thread, my_cpu) { \ - register pmap_t tpmap = (pmap); \ + pmap_t tpmap = (pmap); \ \ /* \ * Do nothing if this is the kernel pmap. \ @@ -395,7 +395,7 @@ pt_entry_t *pmap_pte(pmap_t pmap, vm_offset_t addr); } #define PMAP_ACTIVATE_USER(pmap, th, my_cpu) { \ - register pmap_t tpmap = (pmap); \ + pmap_t tpmap = (pmap); \ (void) (th); \ (void) (my_cpu); \ \ -- cgit v1.2.3 From 941f24160164d9cc07699d63b7435eedd348b8ad Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 14 Nov 2013 13:45:34 +0100 Subject: i386/intel/read_fault.c: remove register qualifier * i386/intel/read_fault.c: Remove register qualifier. --- i386/intel/read_fault.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i386/intel/read_fault.c b/i386/intel/read_fault.c index 762f60da..036d7ae9 100644 --- a/i386/intel/read_fault.c +++ b/i386/intel/read_fault.c @@ -52,7 +52,7 @@ intel_read_fault(map, vaddr) vm_page_t top_page; /* Placeholder page */ boolean_t wired; /* Is map region wired? */ kern_return_t result; - register vm_page_t m; + vm_page_t m; RetryFault: -- cgit v1.2.3 From 86c2a249355508cfa7150e00baa42d902e4c6ff8 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 17 Nov 2013 12:56:24 +0100 Subject: Remove dead code Thanks Marin Ramesa for the report. * i386/i386/user_ldt.c (selector_check): Remove function. * i386/i386/user_ldt.h (S_CODE, S_STACK, S_DATA): Remove macros. (selector_check): Remove declaration. --- i386/i386/user_ldt.c | 38 -------------------------------------- i386/i386/user_ldt.h | 11 ----------- 2 files changed, 49 deletions(-) diff --git a/i386/i386/user_ldt.c b/i386/i386/user_ldt.c index 74c10a4c..5c3d323f 100644 --- a/i386/i386/user_ldt.c +++ b/i386/i386/user_ldt.c @@ -55,44 +55,6 @@ char acc_type[8][3] = { { 1, 0, 1 }, /* code, readable, conforming */ }; -boolean_t selector_check(thread, sel, type) - thread_t thread; - int sel; - int type; /* code, stack, data */ -{ - struct user_ldt *ldt; - int access; - - ldt = thread->pcb->ims.ldt; - if (ldt == 0) { - switch (type) { - case S_CODE: - return sel == USER_CS; - case S_STACK: - return sel == USER_DS; - case S_DATA: - return sel == 0 || - sel == USER_CS || - sel == USER_DS; - } - } - - if (type != S_DATA && sel == 0) - return FALSE; - if ((sel & (SEL_LDT|SEL_PL)) != (SEL_LDT|SEL_PL_U) - || sel > ldt->desc.limit_low) - return FALSE; - - access = ldt->ldt[sel_idx(sel)].access; - - if ((access & (ACC_P|ACC_PL|ACC_TYPE_USER|SZ_64)) - != (ACC_P|ACC_PL_U|ACC_TYPE_USER)) - return FALSE; - /* present, pl == pl.user, not system, not 64bits */ - - return acc_type[(access & 0xe)>>1][type]; -} - /* * Add the descriptors to the LDT, starting with * the descriptor for 'first_selector'. diff --git a/i386/i386/user_ldt.h b/i386/i386/user_ldt.h index 6c6c858e..c90273f5 100644 --- a/i386/i386/user_ldt.h +++ b/i386/i386/user_ldt.h @@ -44,15 +44,4 @@ struct user_ldt { }; typedef struct user_ldt * user_ldt_t; -/* - * Check code/stack/data selector values against LDT if present. - */ -#define S_CODE 0 /* code segment */ -#define S_STACK 1 /* stack segment */ -#define S_DATA 2 /* data segment */ - -extern boolean_t selector_check(thread_t thread, - int sel, - int type); - #endif /* _I386_USER_LDT_H_ */ -- cgit v1.2.3 From 0749bd605acdfa2956dc1a3275a09cef98ba214b Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sat, 16 Nov 2013 08:51:58 +0100 Subject: ddb/db_access.c: remove register qualifiers * ddb/db_access.c: Remove register qualifiers. --- ddb/db_access.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ddb/db_access.c b/ddb/db_access.c index 69922557..4df98317 100644 --- a/ddb/db_access.c +++ b/ddb/db_access.c @@ -64,13 +64,13 @@ static int db_extend[sizeof(int)+1] = { /* table for sign-extending */ db_expr_t db_get_task_value(addr, size, is_signed, task) db_addr_t addr; - register int size; + int size; boolean_t is_signed; task_t task; { char data[sizeof(db_expr_t)]; - register db_expr_t value; - register int i; + db_expr_t value; + int i; db_read_bytes(addr, size, data, task); @@ -94,12 +94,12 @@ db_get_task_value(addr, size, is_signed, task) void db_put_task_value(addr, size, value, task) db_addr_t addr; - register int size; - register db_expr_t value; + int size; + db_expr_t value; task_t task; { char data[sizeof(db_expr_t)]; - register int i; + int i; #if BYTE_MSF for (i = size - 1; i >= 0; i--) -- cgit v1.2.3 From 40150357eb471658d37fdd6804434e4ddaf28f17 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sat, 16 Nov 2013 08:55:05 +0100 Subject: ddb/db_access.h: add ifndef * ddb/db_access.h: Add ifndef. --- ddb/db_access.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ddb/db_access.h b/ddb/db_access.h index 6cedf29f..3bda5a4a 100644 --- a/ddb/db_access.h +++ b/ddb/db_access.h @@ -30,6 +30,10 @@ /* * Data access functions for debugger. */ + +#ifndef _DDB_DB_ACCESS_H_ +#define _DDB_DB_ACCESS_H_ + #include #include #include @@ -71,3 +75,5 @@ extern void db_put_task_value( db_addr_t addr, int size, db_expr_t value, task_t task ); + +#endif /* _DDB_DB_ACCESS_H_ */ -- cgit v1.2.3 From 8a0f70fdb9c790584223147eadfe894f800c5459 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sat, 16 Nov 2013 08:59:43 +0100 Subject: ddb/db_aout.c: remove register qualifiers * ddb/db_aout.c: Remove register qualifiers. --- ddb/db_aout.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/ddb/db_aout.c b/ddb/db_aout.c index 42fa6f75..a36ca0e7 100644 --- a/ddb/db_aout.c +++ b/ddb/db_aout.c @@ -77,10 +77,10 @@ aout_db_sym_init(symtab, esymtab, name, task_addr) char * name; char * task_addr; /* use for this task only */ { - register struct nlist *sym_start, *sym_end; - register struct nlist *sp; - register char * strtab; - register int strlen; + struct nlist *sym_start, *sym_end; + struct nlist *sp; + char * strtab; + int strlen; char * estrtab; db_get_aout_symtab(symtab, sym_start, sym_end); @@ -100,7 +100,7 @@ aout_db_sym_init(symtab, esymtab, name, task_addr) #undef round_to_size for (sp = sym_start; sp < sym_end; sp++) { - register long strx; + long strx; strx = sp->n_un.n_strx; if (strx != 0) { if (strx > strlen) { @@ -133,7 +133,7 @@ aout_db_sym_init(symtab, esymtab, name, task_addr) */ private boolean_t aout_db_is_filename(name) - register char *name; + char *name; { while (*name) { if (*name == '.') { @@ -153,7 +153,7 @@ aout_db_eq_name(sp, name) struct nlist *sp; char *name; { - register char *s1, *s2; + char *s1, *s2; s1 = sp->n_un.n_name; s2 = name; @@ -185,7 +185,7 @@ aout_db_eq_name(sp, name) */ private struct nlist * aout_db_search_name(sp, ep, name, type, fp) - register struct nlist *sp; + struct nlist *sp; struct nlist *ep; char *name; int type; @@ -236,7 +236,7 @@ aout_db_qualified_search(stab, file, sym, line) char *sym; int line; { - register struct nlist *sp = (struct nlist *)stab->start; + struct nlist *sp = (struct nlist *)stab->start; struct nlist *ep = (struct nlist *)stab->end; struct nlist *fp = 0; struct nlist *found_sp; @@ -324,14 +324,13 @@ aout_db_lookup(stab, symstr) db_sym_t aout_db_search_symbol(symtab, off, strategy, diffp) db_symtab_t * symtab; - register db_addr_t off; db_strategy_t strategy; db_expr_t *diffp; /* in/out */ { - register unsigned long diff = *diffp; - register struct nlist *symp = 0; - register struct nlist *sp, *ep; + unsigned long diff = *diffp; + struct nlist *symp = 0; + struct nlist *sp, *ep; sp = (struct nlist *)symtab->start; ep = (struct nlist *)symtab->end; @@ -382,7 +381,7 @@ aout_db_symbol_values(stab, sym, namep, valuep) char **namep; db_expr_t *valuep; { - register struct nlist *sp; + struct nlist *sp; sp = (struct nlist *)sym; if (namep) @@ -399,15 +398,15 @@ aout_db_symbol_values(stab, sym, namep, valuep) private boolean_t aout_db_search_by_addr(stab, addr, file, func, line, diff) db_symtab_t *stab; - register vm_offset_t addr; + vm_offset_t addr; char **file; char **func; int *line; unsigned long *diff; { - register struct nlist *sp; - register struct nlist *line_sp, *func_sp, *file_sp, *line_func; - register vm_size_t func_diff, line_diff; + struct nlist *sp; + struct nlist *line_sp, *func_sp, *file_sp, *line_func; + vm_size_t func_diff, line_diff; boolean_t found_line = FALSE; struct nlist *ep = (struct nlist *)stab->end; -- cgit v1.2.3 From 73817b94f65ed347fc46aec8258cd62f4aa69e3a Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sat, 16 Nov 2013 09:05:15 +0100 Subject: ddb/db_break.c: remove register qualifiers * ddb/db_break.c: Remove register qualifiers. --- ddb/db_break.c | 56 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/ddb/db_break.c b/ddb/db_break.c index 75253923..a566d02d 100644 --- a/ddb/db_break.c +++ b/ddb/db_break.c @@ -64,7 +64,7 @@ static int db_breakpoint_number = 0; db_breakpoint_t db_breakpoint_alloc() { - register db_breakpoint_t bkpt; + db_breakpoint_t bkpt; if ((bkpt = db_free_breakpoints) != 0) { db_free_breakpoints = bkpt->link; @@ -90,11 +90,11 @@ db_breakpoint_free(bkpt) static int db_add_thread_breakpoint(bkpt, task_thd, count, task_bpt) - register db_breakpoint_t bkpt; + db_breakpoint_t bkpt; vm_offset_t task_thd; boolean_t task_bpt; { - register db_thread_breakpoint_t tp; + db_thread_breakpoint_t tp; if (db_thread_break_init == FALSE) { for (tp = db_thread_break_list; @@ -121,11 +121,11 @@ db_add_thread_breakpoint(bkpt, task_thd, count, task_bpt) static int db_delete_thread_breakpoint(bkpt, task_thd) - register db_breakpoint_t bkpt; + db_breakpoint_t bkpt; vm_offset_t task_thd; { - register db_thread_breakpoint_t tp; - register db_thread_breakpoint_t *tpp; + db_thread_breakpoint_t tp; + db_thread_breakpoint_t *tpp; if (task_thd == 0) { /* delete all the thread-breakpoints */ @@ -158,8 +158,8 @@ db_find_thread_breakpoint(bkpt, thread) db_breakpoint_t bkpt; thread_t thread; { - register db_thread_breakpoint_t tp; - register task_t task = (thread == THREAD_NULL)? TASK_NULL: thread->task; + db_thread_breakpoint_t tp; + task_t task = (thread == THREAD_NULL)? TASK_NULL: thread->task; for (tp = bkpt->threads; tp; tp = tp->tb_next) { if (tp->tb_is_task) { @@ -191,8 +191,8 @@ db_find_breakpoint_number(num, bkptp) int num; db_breakpoint_t *bkptp; { - register db_thread_breakpoint_t tp; - register db_breakpoint_t bkpt; + db_thread_breakpoint_t tp; + db_breakpoint_t bkpt; for (bkpt = db_breakpoint_list; bkpt != 0; bkpt = bkpt->link) { for (tp = bkpt->threads; tp; tp = tp->tb_next) { @@ -228,8 +228,8 @@ db_force_delete_breakpoint(bkpt, task_thd, is_task) void db_check_breakpoint_valid() { - register db_thread_breakpoint_t tbp, tbp_next; - register db_breakpoint_t bkpt, *bkptp; + db_thread_breakpoint_t tbp, tbp_next; + db_breakpoint_t bkpt, *bkptp; bkptp = &db_breakpoint_list; for (bkpt = *bkptp; bkpt; bkpt = *bkptp) { @@ -273,7 +273,7 @@ db_set_breakpoint(task, addr, count, thread, task_bpt) thread_t thread; boolean_t task_bpt; { - register db_breakpoint_t bkpt; + db_breakpoint_t bkpt; db_breakpoint_t alloc_bkpt = 0; vm_offset_t task_thd; @@ -324,8 +324,8 @@ db_delete_breakpoint(task, addr, task_thd) db_addr_t addr; vm_offset_t task_thd; { - register db_breakpoint_t bkpt; - register db_breakpoint_t *prev; + db_breakpoint_t bkpt; + db_breakpoint_t *prev; for (prev = &db_breakpoint_list; (bkpt = *prev) != 0; prev = &bkpt->link) { @@ -354,7 +354,7 @@ db_find_breakpoint(task, addr) task_t task; db_addr_t addr; { - register db_breakpoint_t bkpt; + db_breakpoint_t bkpt; for (bkpt = db_breakpoint_list; bkpt != 0; bkpt = bkpt->link) { if ((bkpt->task == task @@ -370,7 +370,7 @@ db_find_breakpoint_here(task, addr) task_t task; db_addr_t addr; { - register db_breakpoint_t bkpt; + db_breakpoint_t bkpt; for (bkpt = db_breakpoint_list; bkpt != 0; bkpt = bkpt->link) { if ((bkpt->task == task @@ -389,8 +389,8 @@ boolean_t db_breakpoints_inserted = TRUE; void db_set_breakpoints(void) { - register db_breakpoint_t bkpt; - register task_t task; + db_breakpoint_t bkpt; + task_t task; db_expr_t inst; task_t cur_task; @@ -434,8 +434,8 @@ db_set_breakpoints(void) void db_clear_breakpoints(void) { - register db_breakpoint_t bkpt, *bkptp; - register task_t task; + db_breakpoint_t bkpt, *bkptp; + task_t task; task_t cur_task; db_expr_t inst; @@ -485,7 +485,7 @@ db_set_temp_breakpoint(task, addr) task_t task; db_addr_t addr; { - register db_breakpoint_t bkpt; + db_breakpoint_t bkpt; bkpt = db_breakpoint_alloc(); if (bkpt == 0) { @@ -525,7 +525,7 @@ db_delete_temp_breakpoint(task, bkpt) void db_list_breakpoints() { - register db_breakpoint_t bkpt; + db_breakpoint_t bkpt; if (db_breakpoint_list == 0) { db_printf("No breakpoints set\n"); @@ -537,9 +537,9 @@ db_list_breakpoints() bkpt != 0; bkpt = bkpt->link) { - register db_thread_breakpoint_t tp; - int task_id; - int thread_id; + db_thread_breakpoint_t tp; + int task_id; + int thread_id; if (bkpt->threads) { for (tp = bkpt->threads; tp; tp = tp->tb_next) { @@ -599,7 +599,7 @@ db_list_breakpoints() void db_delete_cmd() { - register int n; + int n; thread_t thread; vm_offset_t task_thd; boolean_t user_global = FALSE; @@ -682,7 +682,7 @@ db_breakpoint_cmd(addr, have_addr, count, modif) db_expr_t count; char * modif; { - register int n; + int n; thread_t thread; boolean_t user_global = db_option(modif, 'U'); boolean_t task_bpt = db_option(modif, 'T'); -- cgit v1.2.3 From e2c721b60c62f3091965c6350270ff097e94640f Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sat, 16 Nov 2013 09:08:27 +0100 Subject: ddb/db_command.c: remove register qualifiers * ddb/db_command.c: Remove register qualifiers. --- ddb/db_command.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ddb/db_command.c b/ddb/db_command.c index cb14da82..6cca94b0 100644 --- a/ddb/db_command.c +++ b/ddb/db_command.c @@ -102,9 +102,9 @@ db_cmd_search(name, table, cmdp) int result = CMD_NONE; for (cmd = table; cmd->name != 0; cmd++) { - register char *lp; - register char *rp; - register int c; + char *lp; + char *rp; + int c; lp = name; rp = cmd->name; @@ -143,7 +143,7 @@ void db_cmd_list(table) struct db_command *table; { - register struct db_command *cmd; + struct db_command *cmd; for (cmd = table; cmd->name != 0; cmd++) { db_printf("%-12s", cmd->name); @@ -538,7 +538,7 @@ db_option(modif, option) char *modif; int option; { - register char *p; + char *p; for (p = modif; *p; p++) if (*p == option) -- cgit v1.2.3 From 05b52b83febed335d9fab20906803d322af57586 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sat, 16 Nov 2013 09:10:15 +0100 Subject: ddb/db_command.h: add ifndef * ddb/db_command.h: Add ifndef. --- ddb/db_command.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ddb/db_command.h b/ddb/db_command.h index 3ed1fb90..2517a909 100644 --- a/ddb/db_command.h +++ b/ddb/db_command.h @@ -28,6 +28,9 @@ * Date: 7/90 */ +#ifndef _DDB_DB_COMMAND_H_ +#define _DDB_DB_COMMAND_H_ + #if MACH_KDB /* @@ -71,3 +74,5 @@ extern boolean_t db_exec_cmd_nest(char *cmd, int size); void db_fncall(); #endif /* MACH_KDB */ + +#endif /* _DDB_DB_COMMAND_H_ */ -- cgit v1.2.3 From 0d464a3a695fba61132589c261858e0fc89278c3 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sat, 16 Nov 2013 09:12:13 +0100 Subject: ddb/db_cond.c: remove register qualifiers * ddb/db_cond.c: Remove register qualifiers. --- ddb/db_cond.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ddb/db_cond.c b/ddb/db_cond.c index 60ea4735..82ec0d69 100644 --- a/ddb/db_cond.c +++ b/ddb/db_cond.c @@ -62,7 +62,7 @@ boolean_t db_cond_check(bkpt) db_thread_breakpoint_t bkpt; { - register struct db_cond *cp; + struct db_cond *cp; db_expr_t value; int t; jmp_buf_t db_jmpbuf; @@ -107,8 +107,8 @@ void db_cond_print(bkpt) db_thread_breakpoint_t bkpt; { - register char *p, *ep; - register struct db_cond *cp; + char *p, *ep; + struct db_cond *cp; if (bkpt->tb_cond <= 0) return; @@ -125,9 +125,9 @@ db_cond_print(bkpt) void db_cond_cmd() { - register int c; - register struct db_cond *cp; - register char *p; + int c; + struct db_cond *cp; + char *p; db_expr_t value; db_thread_breakpoint_t bkpt; -- cgit v1.2.3 From 54eda5167e8ca1c272abfeb1bfbad36383f381d1 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sat, 16 Nov 2013 09:15:17 +0100 Subject: ddb/db_examine.c: remove register qualifiers * ddb/db_examine.c: Remove register qualifiers. --- ddb/db_examine.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/ddb/db_examine.c b/ddb/db_examine.c index 96c5eee1..071ca8f4 100644 --- a/ddb/db_examine.c +++ b/ddb/db_examine.c @@ -120,7 +120,6 @@ db_examine_backward(addr, have_addr, count, modif) void db_examine(addr, fmt, count, task) - register db_addr_t addr; char * fmt; /* format string */ int count; /* repeat count */ @@ -337,8 +336,8 @@ db_print_loc_and_inst(loc, task) void db_strcpy(dst, src) - register char *dst; - register char *src; + char *dst; + char *src; { while ((*dst++ = *src++)) ; @@ -360,7 +359,7 @@ db_search_cmd() db_addr_t count; thread_t thread; boolean_t thread_flag = FALSE; - register char *p; + char *p; t = db_read_token(); if (t == tSLASH) { @@ -432,7 +431,6 @@ db_search_cmd() void db_search(addr, size, value, mask, count, task) - register db_addr_t addr; int size; db_expr_t value; @@ -458,7 +456,7 @@ db_xcdump(addr, size, count, task) int count; task_t task; { - register int i, n; + int i, n; db_expr_t value; int bcount; db_addr_t off; -- cgit v1.2.3 From 5745ffb7fd010570084c31902b3ff4d7e49f76b3 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sat, 16 Nov 2013 09:25:01 +0100 Subject: ddb/db_expr.c: remove register qualifier * ddb/db_expr.c: Remove register qualifier. --- ddb/db_expr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ddb/db_expr.c b/ddb/db_expr.c index 611baa09..eee9e4f7 100644 --- a/ddb/db_expr.c +++ b/ddb/db_expr.c @@ -99,8 +99,8 @@ db_size_option(modif, u_option, t_option) boolean_t *u_option; boolean_t *t_option; { - register char *p; - int size = sizeof(int); + char *p; + int size = sizeof(int); *u_option = FALSE; *t_option = FALSE; -- cgit v1.2.3 From 0ed01aaa521c67fec37f116326d9c191b02b0702 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sat, 16 Nov 2013 09:28:41 +0100 Subject: ddb/db_input.c: remove register qualifiers * ddb/db_input.c: Remove register qualifiers. --- ddb/db_input.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ddb/db_input.c b/ddb/db_input.c index 6e7fa00b..8f875ada 100644 --- a/ddb/db_input.c +++ b/ddb/db_input.c @@ -95,7 +95,7 @@ db_delete(n, bwd) int n; int bwd; { - register char *p; + char *p; if (bwd) { db_lc -= n; @@ -214,7 +214,7 @@ db_inputchar(c) INC_DB_CURR(); db_le = db_lc = db_lbuf_start; } else { - register char *p; + char *p; INC_DB_CURR(); for (p = db_history_curr, db_le = db_lbuf_start; *p; ) { @@ -237,7 +237,7 @@ db_inputchar(c) INC_DB_CURR(); db_delete_line(); if (db_history_curr != db_history_last) { - register char *p; + char *p; for (p = db_history_curr, db_le = db_lbuf_start; *p;) { *db_le++ = *p++; @@ -268,7 +268,7 @@ db_inputchar(c) * save it. */ if (db_history_curr == db_history_prev) { - register char *pp, *pc; + char *pp, *pc; /* * Is it the same? @@ -292,7 +292,7 @@ db_inputchar(c) } } if (db_le != db_lbuf_start) { - register char *p; + char *p; db_history_prev = db_history_last; for (p = db_lbuf_start; p != db_le; p++) { *db_history_last++ = *p; @@ -312,7 +312,7 @@ db_inputchar(c) cnputc('\007'); } else if (c >= ' ' && c <= '~') { - register char *p; + char *p; for (p = db_le; p > db_lc; p--) *p = *(p-1); @@ -351,7 +351,7 @@ db_readline(lstart, lsize) void db_check_interrupt() { - register int c; + int c; c = cnmaygetc(); switch (c) { -- cgit v1.2.3 From 3d5cdd9bcea139b9606ce9e9af8b543fd64c1e9b Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sat, 16 Nov 2013 09:31:15 +0100 Subject: ddb/db_lex.c: remove register qualifiers * ddb/db_lex.c: Remove register qualifiers. --- ddb/db_lex.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ddb/db_lex.c b/ddb/db_lex.c index ebffe062..203472d0 100644 --- a/ddb/db_lex.c +++ b/ddb/db_lex.c @@ -95,7 +95,7 @@ db_switch_input(buffer, size) void db_save_lex_context(lp) - register struct db_lex_context *lp; + struct db_lex_context *lp; { lp->l_ptr = db_lp; lp->l_eptr = db_endlp; @@ -105,7 +105,7 @@ db_save_lex_context(lp) void db_restore_lex_context(lp) - register struct db_lex_context *lp; + struct db_lex_context *lp; { db_lp = lp->l_ptr; db_last_lp = db_lp; @@ -179,10 +179,10 @@ db_flush_lex(void) void db_skip_to_eol(void) { - register int skip; - register int t; - register int n; - register char *p; + int skip; + int t; + int n; + char *p; t = db_read_token(); p = db_last_lp; @@ -205,8 +205,8 @@ db_skip_to_eol(void) int db_lex(void) { - register char *cp; - register int c; + char *cp; + int c; c = db_read_char(); while (c <= ' ' || c > '~') { -- cgit v1.2.3 From 7ae7718d75fc924a66b78ec2b7311f0032770601 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sat, 16 Nov 2013 09:33:31 +0100 Subject: ddb/db_lex.h: add ifndef * ddb/db_lex.h: Add ifndef. --- ddb/db_lex.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ddb/db_lex.h b/ddb/db_lex.h index dc9da0a9..5900122f 100644 --- a/ddb/db_lex.h +++ b/ddb/db_lex.h @@ -31,6 +31,9 @@ * Lexical analyzer. */ +#ifndef _DDB_DB_LEX_H_ +#define _DDB_DB_LEX_H_ + #define TOK_STRING_SIZE 64 #define DB_LEX_LINE_SIZE 256 @@ -92,3 +95,5 @@ extern db_expr_t db_radix; #define tLOG_OR 31 #define tSTRING 32 #define tQUESTION 33 + +#endif /* _DDB_DB_LEX_H_ */ -- cgit v1.2.3 From 44cb653ff69d1041c1e24e6da469c9bb86564a51 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sat, 16 Nov 2013 09:37:02 +0100 Subject: ddb/db_macro.c: remove register qualifiers * ddb/db_macro.c: Remove register qualifiers. --- ddb/db_macro.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ddb/db_macro.c b/ddb/db_macro.c index 43bb5837..5b4264c7 100644 --- a/ddb/db_macro.c +++ b/ddb/db_macro.c @@ -61,7 +61,7 @@ static struct db_user_macro * db_lookup_macro(name) char *name; { - register struct db_user_macro *mp; + struct db_user_macro *mp; for (mp = db_user_macro; mp < &db_user_macro[DB_NUSER_MACRO]; mp++) { if (mp->m_name[0] == 0) @@ -75,9 +75,9 @@ db_lookup_macro(name) void db_def_macro_cmd() { - register char *p; - register int c; - register struct db_user_macro *mp, *ep; + char *p; + int c; + struct db_user_macro *mp, *ep; if (db_read_token() != tIDENT) { db_printf("Bad macro name \"%s\"\n", db_tok_string); @@ -106,7 +106,7 @@ db_def_macro_cmd() void db_del_macro_cmd() { - register struct db_user_macro *mp; + struct db_user_macro *mp; if (db_read_token() != tIDENT || (mp = db_lookup_macro(db_tok_string)) == 0) { @@ -122,7 +122,7 @@ db_del_macro_cmd() void db_show_macro() { - register struct db_user_macro *mp; + struct db_user_macro *mp; int t; char *name = 0; @@ -143,8 +143,8 @@ int db_exec_macro(name) char *name; { - register struct db_user_macro *mp; - register int n; + struct db_user_macro *mp; + int n; if ((mp = db_lookup_macro(name)) == 0) return(-1); -- cgit v1.2.3 From fe4b662e4a773bbd585f3e909a7cf99bf6e2a438 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sat, 16 Nov 2013 09:39:18 +0100 Subject: ddb/db_mp.c: remove register qualifier * ddb/db_mp.c: Remove register qualifier. --- ddb/db_mp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ddb/db_mp.c b/ddb/db_mp.c index cc14aea2..3ab00ce3 100644 --- a/ddb/db_mp.c +++ b/ddb/db_mp.c @@ -149,7 +149,7 @@ db_leave() void remote_db() { int my_cpu = cpu_number(); - register int i; + int i; for (i = 0; i < NCPUS; i++) { if (i != my_cpu && -- cgit v1.2.3 From 81f7d4a5e2ff7d3cae556d70996ad2012f3aa263 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sat, 16 Nov 2013 09:41:10 +0100 Subject: ddb/db_output.c: remove register qualifiers * ddb/db_output.c: Remove register qualifiers. --- ddb/db_output.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ddb/db_output.c b/ddb/db_output.c index ec73111a..c08db6f3 100644 --- a/ddb/db_output.c +++ b/ddb/db_output.c @@ -82,7 +82,7 @@ extern void db_check_interrupt(); void db_force_whitespace(void) { - register int last_print, next_tab; + int last_print, next_tab; last_print = db_last_non_space; while (last_print < db_output_position) { @@ -102,7 +102,7 @@ db_force_whitespace(void) static void db_more() { - register char *p; + char *p; boolean_t quit_output = FALSE; for (p = "--db_more--"; *p; p++) -- cgit v1.2.3 From 21ea7c1ca106b20bbb861bca8b93b2850b8df9e7 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sat, 16 Nov 2013 09:42:42 +0100 Subject: ddb/db_output.h: add ifndef * ddb/db_output.h: Add ifndef. --- ddb/db_output.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ddb/db_output.h b/ddb/db_output.h index 1159c6ba..e7a4ba3b 100644 --- a/ddb/db_output.h +++ b/ddb/db_output.h @@ -32,9 +32,14 @@ * Printing routines for kernel debugger. */ +#ifndef _DDB_DB_OUTPUT_H_ +#define _DDB_DB_OUTPUT_H_ + extern void db_force_whitespace(void); extern int db_print_position(void); extern void db_end_line(void); extern void db_printf(const char *fmt, ...); extern void db_putchar(int c); extern void kdbprintf(const char *fmt, ...); + +#endif /* _DDB_DB_OUTPUT_H_ */ -- cgit v1.2.3 From 85e35248c1dfe97980f106c6c2a605c80e63bd25 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sat, 16 Nov 2013 09:45:08 +0100 Subject: ddb/db_print.c: remove register qualifiers * ddb/db_print.c: Remove register qualifiers. --- ddb/db_print.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ddb/db_print.c b/ddb/db_print.c index 4692e4c4..75c914e6 100644 --- a/ddb/db_print.c +++ b/ddb/db_print.c @@ -63,11 +63,11 @@ db_show_regs(addr, have_addr, count, modif) db_expr_t count; char *modif; { - register struct db_variable *regp; + struct db_variable *regp; db_expr_t value; db_addr_t offset; char * name; - register int i; + int i; struct db_var_aux_param aux_param; task_t task = TASK_NULL; @@ -127,10 +127,10 @@ db_show_regs(addr, have_addr, count, modif) char * db_thread_stat(thread, status) - register thread_t thread; + thread_t thread; char *status; { - register char *p = status; + char *p = status; *p++ = (thread->state & TH_RUN) ? 'R' : '.'; *p++ = (thread->state & TH_WAIT) ? 'W' : '.'; @@ -435,8 +435,8 @@ db_lookup_port(thread, id) thread_t thread; int id; { - register ipc_space_t space; - register ipc_entry_t entry; + ipc_space_t space; + ipc_entry_t entry; if (thread == THREAD_NULL) return(0); -- cgit v1.2.3 From 10648165a5458fea1a4895a2b9647f960b4e3fb6 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sat, 16 Nov 2013 09:48:23 +0100 Subject: ddb/db_run.c: remove register qualifiers * ddb/db_run.c: Remove register qualifiers. --- ddb/db_run.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ddb/db_run.c b/ddb/db_run.c index 53a02ce1..7aaeb463 100644 --- a/ddb/db_run.c +++ b/ddb/db_run.c @@ -75,8 +75,8 @@ db_stop_at_pc(is_breakpoint, task) boolean_t *is_breakpoint; task_t task; { - register db_addr_t pc; - register db_thread_breakpoint_t bkpt; + db_addr_t pc; + db_thread_breakpoint_t bkpt; db_clear_task_single_step(DDB_REGS, task); db_clear_breakpoints(); @@ -131,7 +131,7 @@ db_stop_at_pc(is_breakpoint, task) (!inst_return(ins) || --db_call_depth != 0)) { if (db_sstep_print) { if (inst_call(ins) || inst_return(ins)) { - register int i; + int i; db_printf("[after %6d /%4d] ", db_inst_count, @@ -171,7 +171,7 @@ db_restart_at_pc(watchpt, task) boolean_t watchpt; task_t task; { - register db_addr_t pc = PC_REGS(DDB_REGS), brpc; + db_addr_t pc = PC_REGS(DDB_REGS), brpc; if ((db_run_mode == STEP_COUNT) || (db_run_mode == STEP_RETURN) || @@ -276,12 +276,12 @@ db_find_temp_breakpoint(task, addr) void db_set_task_single_step(regs, task) - register db_regs_t *regs; + db_regs_t *regs; task_t task; { db_addr_t pc = PC_REGS(regs), brpc; - register unsigned int inst; - register boolean_t unconditional; + unsigned int inst; + boolean_t unconditional; /* * User was stopped at pc, e.g. the instruction -- cgit v1.2.3 From 7f0d869d3defdebf01086a371752d13d5351a8f4 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sat, 16 Nov 2013 09:49:51 +0100 Subject: ddb/db_run.h: add ifndef * ddb/db_run.h: Add ifndef. --- ddb/db_run.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ddb/db_run.h b/ddb/db_run.h index e138f604..ee6e6f53 100644 --- a/ddb/db_run.h +++ b/ddb/db_run.h @@ -24,6 +24,9 @@ * the rights to redistribute these changes. */ +#ifndef _DDB_DB_RUN_H_ +#define _DDB_DB_RUN_H_ + #include #include @@ -66,3 +69,5 @@ void db_continue_cmd( char * modif); extern boolean_t db_in_single_step(void); + +#endif /* _DDB_DB_RUN_H_ */ -- cgit v1.2.3 From 1b332541d76de1443b72222779e7155aa2933ab2 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sat, 16 Nov 2013 09:53:06 +0100 Subject: ddb/db_sym.c: remove register qualifiers * ddb/db_sym.c: Remove register qualifiers. --- ddb/db_sym.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/ddb/db_sym.c b/ddb/db_sym.c index 5c5f7006..98f265e6 100644 --- a/ddb/db_sym.c +++ b/ddb/db_sym.c @@ -64,7 +64,7 @@ db_add_symbol_table(type, start, end, name, ref, map_pointer) char *ref; char *map_pointer; { - register db_symtab_t *st; + db_symtab_t *st; extern vm_map_t kernel_map; if (db_nsymtab >= MAXNOSYMTABS) @@ -92,10 +92,10 @@ db_add_symbol_table(type, start, end, name, ref, map_pointer) static char * db_qualify(symname, symtabname) char *symname; - register char *symtabname; + char *symtabname; { static char tmp[256]; - register char *s; + char *s; s = tmp; while ((*s++ = *symtabname++)) { @@ -145,10 +145,10 @@ db_lookup(symstr) char *symstr; { db_sym_t sp; - register int i; + int i; int symtab_start = 0; int symtab_end = db_nsymtab; - register char *cp; + char *cp; /* * Look for, remove, and remember any symbol table specifier. @@ -198,8 +198,8 @@ db_sym_parse_and_lookup(func, symtab, symstr) db_symtab_t *symtab; char *symstr; { - register char *p; - register int n; + char *p; + int n; int n_name; int line_number; char *file_name = 0; @@ -268,8 +268,7 @@ boolean_t db_name_is_ambiguous(sym_name) char *sym_name; { - register int i; - register + int i; boolean_t found_once = FALSE; if (!db_qualify_ambiguous_names) @@ -306,7 +305,7 @@ db_sym_t db_search_in_task_symbol(); */ db_sym_t db_search_task_symbol(val, strategy, offp, task) - register db_addr_t val; + db_addr_t val; db_strategy_t strategy; db_addr_t *offp; /* better be unsigned */ task_t task; @@ -335,14 +334,14 @@ db_search_task_symbol(val, strategy, offp, task) db_sym_t db_search_in_task_symbol(val, strategy, offp, task) - register db_addr_t val; + db_addr_t val; db_strategy_t strategy; db_addr_t *offp; task_t task; { - register vm_size_t diff; + vm_size_t diff; vm_size_t newdiff; - register int i; + int i; db_symtab_t *sp; db_sym_t ret = DB_SYM_NULL, sym; vm_map_t map_for_val; -- cgit v1.2.3 From c0ce9914832282cee4d9f5a0c29f6643193648a5 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sat, 16 Nov 2013 09:54:29 +0100 Subject: ddb/db_sym.h: add comment after endif * ddb/db_sym.h: Add comment after endif. --- ddb/db_sym.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ddb/db_sym.h b/ddb/db_sym.h index e40264ab..d3cfec7c 100644 --- a/ddb/db_sym.h +++ b/ddb/db_sym.h @@ -237,4 +237,4 @@ extern boolean_t db_line_at_pc( int *linenum, db_expr_t pc); -#endif +#endif /* _DDB_DB_SYM_H_ */ -- cgit v1.2.3 From 272a8e0dcec7b072926ce122988ccfb50ad1cf42 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sat, 16 Nov 2013 09:57:15 +0100 Subject: ddb/db_task_thread.c: remove register qualifiers * ddb/db_task_thread.c: Remove register qualifiers. --- ddb/db_task_thread.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/ddb/db_task_thread.c b/ddb/db_task_thread.c index 1146223b..41f11cc2 100644 --- a/ddb/db_task_thread.c +++ b/ddb/db_task_thread.c @@ -54,10 +54,10 @@ int db_lookup_task(target_task) task_t target_task; { - register task_t task; - register int task_id; - register processor_set_t pset; - register int npset = 0; + task_t task; + int task_id; + processor_set_t pset; + int npset = 0; task_id = 0; if (queue_first(&all_psets) == 0) @@ -85,8 +85,8 @@ db_lookup_task_thread(task, target_thread) task_t task; thread_t target_thread; { - register thread_t thread; - register int thread_id; + thread_t thread; + int thread_id; thread_id = 0; if (queue_first(&task->thread_list) == 0) @@ -108,11 +108,11 @@ int db_lookup_thread(target_thread) thread_t target_thread; { - register int thread_id; - register task_t task; - register processor_set_t pset; - register int ntask = 0; - register int npset = 0; + int thread_id; + task_t task; + processor_set_t pset; + int ntask = 0; + int npset = 0; if (queue_first(&all_psets) == 0) return(-1); @@ -154,11 +154,11 @@ db_check_thread_address_valid(thread) */ task_t db_lookup_task_id(task_id) - register int task_id; + int task_id; { - register task_t task; - register processor_set_t pset; - register int npset = 0; + task_t task; + processor_set_t pset; + int npset = 0; if (task_id > DB_MAX_TASKID) return(TASK_NULL); @@ -182,10 +182,10 @@ db_lookup_task_id(task_id) */ static thread_t db_lookup_thread_id(task, thread_id) - task_t task; - register int thread_id; + task_t task; + int thread_id; { - register thread_t thread; + thread_t thread; if (thread_id > DB_MAX_THREADID) -- cgit v1.2.3 From f4d24ba49d031610a841d5b416dde41279ef3189 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sat, 16 Nov 2013 10:00:27 +0100 Subject: ddb/db_variables.c: remove register qualifiers * ddb/db_variables.c: Remove register qualifiers. --- ddb/db_variables.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ddb/db_variables.c b/ddb/db_variables.c index 55b87422..055d6e4a 100644 --- a/ddb/db_variables.c +++ b/ddb/db_variables.c @@ -72,10 +72,10 @@ struct db_variable *db_evars = db_vars + sizeof(db_vars)/sizeof(db_vars[0]); char * db_get_suffix(suffix, suffix_value) - register char *suffix; + char *suffix; short *suffix_value; { - register int value; + int value; for (value = 0; *suffix && *suffix != '.' && *suffix != ':'; suffix++) { if (*suffix < '0' || *suffix > '9') @@ -92,10 +92,10 @@ static boolean_t db_cmp_variable_name(vp, name, ap) struct db_variable *vp; char *name; - register db_var_aux_param_t ap; + db_var_aux_param_t ap; { - register char *var_np, *np; - register int level; + char *var_np, *np; + int level; for (np = name, var_np = vp->name; *var_np; ) { if (*np++ != *var_np++) -- cgit v1.2.3 From b458364a43292fc327f12706cfa96edac8d24e22 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sat, 16 Nov 2013 10:03:07 +0100 Subject: ddb/db_watch.c: remove register qualifiers * ddb/db_watch.c: Remove register qualifiers. --- ddb/db_watch.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/ddb/db_watch.c b/ddb/db_watch.c index a2f852bd..e2bd8d68 100644 --- a/ddb/db_watch.c +++ b/ddb/db_watch.c @@ -67,7 +67,7 @@ extern vm_map_t kernel_map; db_watchpoint_t db_watchpoint_alloc() { - register db_watchpoint_t watch; + db_watchpoint_t watch; if ((watch = db_free_watchpoints) != 0) { db_free_watchpoints = watch->link; @@ -85,7 +85,7 @@ db_watchpoint_alloc() void db_watchpoint_free(watch) - register db_watchpoint_t watch; + db_watchpoint_t watch; { watch->link = db_free_watchpoints; db_free_watchpoints = watch; @@ -97,7 +97,7 @@ db_set_watchpoint(task, addr, size) db_addr_t addr; vm_size_t size; { - register db_watchpoint_t watch; + db_watchpoint_t watch; /* * Should we do anything fancy with overlapping regions? @@ -133,8 +133,8 @@ db_delete_watchpoint(task, addr) task_t task; db_addr_t addr; { - register db_watchpoint_t watch; - register db_watchpoint_t *prev; + db_watchpoint_t watch; + db_watchpoint_t *prev; for (prev = &db_watchpoint_list; (watch = *prev) != 0; prev = &watch->link) { @@ -153,8 +153,8 @@ db_delete_watchpoint(task, addr) void db_list_watchpoints(void) { - register db_watchpoint_t watch; - int task_id; + db_watchpoint_t watch; + int task_id; if (db_watchpoint_list == 0) { db_printf("No watchpoints set\n"); @@ -263,8 +263,8 @@ db_listwatch_cmd() void db_set_watchpoints(void) { - register db_watchpoint_t watch; - vm_map_t map; + db_watchpoint_t watch; + vm_map_t map; unsigned hw_idx = 0; if (!db_watchpoints_inserted) { @@ -300,9 +300,9 @@ db_find_watchpoint(map, addr, regs) db_addr_t addr; db_regs_t *regs; { - register db_watchpoint_t watch; + db_watchpoint_t watch; db_watchpoint_t found = 0; - register task_t task_space; + task_t task_space; task_space = (map == kernel_map)? TASK_NULL: db_current_task(); for (watch = db_watchpoint_list; watch != 0; watch = watch->link) { -- cgit v1.2.3 From aaaf735dfb76b1c933a157a56940c39f2483e32a Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sat, 16 Nov 2013 10:05:09 +0100 Subject: ddb/db_write_cmd.c: remove register qualifiers * ddb/db_write_cmd.c: Remove register qualifiers. --- ddb/db_write_cmd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ddb/db_write_cmd.c b/ddb/db_write_cmd.c index eacf53b4..1908005a 100644 --- a/ddb/db_write_cmd.c +++ b/ddb/db_write_cmd.c @@ -57,10 +57,10 @@ db_write_cmd(address, have_addr, count, modif) db_expr_t count; char * modif; { - register db_addr_t addr; - register db_expr_t old_value; + db_addr_t addr; + db_expr_t old_value; db_expr_t new_value; - register int size; + int size; boolean_t wrote_one = FALSE; boolean_t t_opt, u_opt; thread_t thread; -- cgit v1.2.3 From e9e9c47f7f398a590deb4c2491488394d7247166 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sat, 16 Nov 2013 10:07:31 +0100 Subject: ddb/stab.h: add ifndef * ddb/stab.h: Add ifndef. --- ddb/stab.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ddb/stab.h b/ddb/stab.h index 3ebc1af8..55e9d452 100644 --- a/ddb/stab.h +++ b/ddb/stab.h @@ -33,6 +33,8 @@ * @(#)stab.h 5.2 (Berkeley) 4/4/91 */ +#ifndef _DDB_STAB_H_ +#define _DDB_STAB_H_ /* * The following are symbols used by various debuggers and by the Pascal @@ -67,3 +69,5 @@ #define N_ECOMM 0xe4 /* end common */ #define N_ECOML 0xe8 /* end common (local name) */ #define N_LENG 0xfe /* length of preceding entry */ + +#endif /* _DDB_STAB_H_ */ -- cgit v1.2.3 From c929d179530872cb5f393bc604089e36d66b1841 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Mon, 18 Nov 2013 09:38:57 +0100 Subject: Add ifndefs Finish up with the addition of ifndefs. * device/buf.h: Add ifndef. * device/dev_master.h: Likewise. * include/device/tty_status.h: Likewise. * include/mach/version.h: Likewise. * ipc/ipc_machdep.h: Likewise. --- device/buf.h | 5 +++++ device/dev_master.h | 5 +++++ include/device/tty_status.h | 5 +++++ include/mach/version.h | 5 +++++ ipc/ipc_machdep.h | 4 ++++ 5 files changed, 24 insertions(+) diff --git a/device/buf.h b/device/buf.h index 80466c8d..806eb8d8 100644 --- a/device/buf.h +++ b/device/buf.h @@ -30,6 +30,9 @@ * Definitions to make new IO structures look like old ones */ +#ifndef _DEVICE_BUF_H_ +#define _DEVICE_BUF_H_ + /* * io_req and fields */ @@ -100,3 +103,5 @@ extern void minphys(io_req_t); */ #define biodone iodone #define biowait iowait + +#endif /* _DEVICE_BUF_H_ */ diff --git a/device/dev_master.h b/device/dev_master.h index 964ae828..6ad11526 100644 --- a/device/dev_master.h +++ b/device/dev_master.h @@ -30,6 +30,9 @@ * Bind an IO operation to the master CPU. */ +#ifndef _DEVICE_DEV_MASTER_H_ +#define _DEVICE_DEV_MASTER_H_ + #include #if NCPUS > 1 @@ -58,3 +61,5 @@ #define io_release_master() #endif NCPUS > 1 + +#endif /* _DEVICE_DEV_MASTER_H_ */ diff --git a/include/device/tty_status.h b/include/device/tty_status.h index 15249a40..2eed5d03 100644 --- a/include/device/tty_status.h +++ b/include/device/tty_status.h @@ -30,6 +30,9 @@ * Status information for tty. */ +#ifndef _DEVICE_TTY_STATUS_H_ +#define _DEVICE_TTY_STATUS_H_ + struct tty_status { int tt_ispeed; /* input speed */ int tt_ospeed; /* output speed */ @@ -127,3 +130,5 @@ struct tty_status { /* clear break condition */ #define TTY_SET_TRANSLATION (dev_flavor_t)(('t'<<16) + 8) /* set translation table */ + +#endif /* _DEVICE_TTY_STATUS_H_ */ diff --git a/include/mach/version.h b/include/mach/version.h index ec12ea74..3ef78592 100644 --- a/include/mach/version.h +++ b/include/mach/version.h @@ -43,6 +43,9 @@ * minor 0. */ +#ifndef _MACH_VERSION_H_ +#define _MACH_VERSION_H_ + #define KERNEL_MAJOR_VERSION 4 #define KERNEL_MINOR_VERSION 0 @@ -66,3 +69,5 @@ * excised from the CSD environment. */ #define INCLUDE_VERSION 0 + +#endif /* _MACH_VERSION_H_ */ diff --git a/ipc/ipc_machdep.h b/ipc/ipc_machdep.h index e864c4b0..c205ba45 100755 --- a/ipc/ipc_machdep.h +++ b/ipc/ipc_machdep.h @@ -24,6 +24,9 @@ * the rights to redistribute these changes. */ +#ifndef _IPC_IPC_MACHDEP_H_ +#define _IPC_IPC_MACHDEP_H_ + /* * At times, we need to know the size of a port in bits */ @@ -38,3 +41,4 @@ #define PORT_T_SIZE_IN_BITS 32 #endif +#endif /* _IPC_IPC_MACHDEP_H_ */ -- cgit v1.2.3 From e27673af1c84e523b387d79bbff804889b7763be Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Mon, 18 Nov 2013 09:38:56 +0100 Subject: Add copyright * ddb/db_write_cmd.h: Add copyright. * ipc/ipc_print.h: Likewise. * vm/vm_print.h: Likewise. --- ddb/db_write_cmd.h | 18 ++++++++++++++++++ ipc/ipc_print.h | 18 ++++++++++++++++++ vm/vm_print.h | 18 ++++++++++++++++++ 3 files changed, 54 insertions(+) diff --git a/ddb/db_write_cmd.h b/ddb/db_write_cmd.h index 74bac54c..056be470 100644 --- a/ddb/db_write_cmd.h +++ b/ddb/db_write_cmd.h @@ -1,3 +1,21 @@ +/* + * Copyright (c) 2013 Free Software Foundation. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + #ifndef _DDB_DB_WRITE_CMD_H_ #define _DDB_DB_WRITE_CMD_H_ diff --git a/ipc/ipc_print.h b/ipc/ipc_print.h index ef676a77..d1fef7ea 100644 --- a/ipc/ipc_print.h +++ b/ipc/ipc_print.h @@ -1,3 +1,21 @@ +/* + * Copyright (c) 2013 Free Software Foundation. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + #ifndef _IPC_PRINT_H_ #define _IPC_PRINT_H_ diff --git a/vm/vm_print.h b/vm/vm_print.h index 69a20ba3..c2c2918f 100644 --- a/vm/vm_print.h +++ b/vm/vm_print.h @@ -1,3 +1,21 @@ +/* + * Copyright (c) 2013 Free Software Foundation. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + #ifndef VM_PRINT_H #define VM_PRINT_H -- cgit v1.2.3 From da72db8811807d5d63ac97a1e3a7177205f241ee Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Tue, 19 Nov 2013 07:34:19 +0100 Subject: kern/slab.c: initialize optimal_embed optimal_embed is initialized to a random value. Quiet the warning by initializing to zero. * kern/slab.c (optimal_embed): Initialize to zero. --- kern/slab.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kern/slab.c b/kern/slab.c index 47c2c8f9..2ef82cd5 100644 --- a/kern/slab.c +++ b/kern/slab.c @@ -704,7 +704,7 @@ static void kmem_cache_compute_sizes(struct kmem_cache *cache, int flags) { size_t i, buffers, buf_size, slab_size, free_slab_size, optimal_size; size_t waste, waste_min; - int embed, optimal_embed = optimal_embed; + int embed, optimal_embed = 0; buf_size = cache->buf_size; -- cgit v1.2.3 From 5a7551cbbdf2d5f2df2fb60bdb85a0af9eaddcca Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Tue, 19 Nov 2013 07:34:20 +0100 Subject: kern/slab.c: initialize info_size info_size is initialized to a random value. Quiet the warning by initializing to zero. * kern/slab.c (info_size): Initialize to zero. --- kern/slab.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kern/slab.c b/kern/slab.c index 2ef82cd5..d1e3632a 100644 --- a/kern/slab.c +++ b/kern/slab.c @@ -1468,7 +1468,7 @@ kern_return_t host_slab_info(host_t host, cache_info_array_t *infop, struct kmem_cache *cache; cache_info_t *info; unsigned int i, nr_caches; - vm_size_t info_size = info_size; + vm_size_t info_size = 0; kern_return_t kr; if (host == HOST_NULL) -- cgit v1.2.3 From 74c43be20898dcf1e29aa1d6ea8ce1dce031f22f Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Wed, 20 Nov 2013 13:53:44 +0100 Subject: ddb/db_break.c: quiet GCC warning about uninitialized variable * ddb/db_break.c (bkpt): Initialize. --- ddb/db_break.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ddb/db_break.c b/ddb/db_break.c index a566d02d..b26e1f05 100644 --- a/ddb/db_break.c +++ b/ddb/db_break.c @@ -626,7 +626,7 @@ db_delete_cmd() } if (t == tHASH) { db_thread_breakpoint_t tbp; - db_breakpoint_t bkpt; + db_breakpoint_t bkpt = bkpt; if (db_read_token() != tNUMBER) { db_printf("Bad break point number #%s\n", db_tok_string); -- cgit v1.2.3 From f8e08f8ece7e275d3471e644c26334214d4a7897 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Wed, 20 Nov 2013 21:40:47 +0100 Subject: Drop volatile function qualifier * i386/i386/setjmp.h (_longjmp): Drop volatile function qualifier. --- i386/i386/setjmp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i386/i386/setjmp.h b/i386/i386/setjmp.h index 667eecfa..5c43d40f 100644 --- a/i386/i386/setjmp.h +++ b/i386/i386/setjmp.h @@ -36,7 +36,7 @@ typedef struct jmp_buf { extern int _setjmp(jmp_buf_t*); #ifdef __GNUC__ -extern __volatile__ void _longjmp(jmp_buf_t*, int); +extern void _longjmp(jmp_buf_t*, int); #endif #endif /* _I386_SETJMP_H_ */ -- cgit v1.2.3 From 9096a424b863e2d7c8b91eb74f6ce5888ac0adf8 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Wed, 20 Nov 2013 21:41:36 +0100 Subject: Add comment * ddb/db_command.c [DB_MACHINE_COMMANDS]: Add comment after endif. --- ddb/db_command.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ddb/db_command.c b/ddb/db_command.c index 6cca94b0..1299cfaa 100644 --- a/ddb/db_command.c +++ b/ddb/db_command.c @@ -383,7 +383,7 @@ struct db_command *ptr; return; } -#endif +#endif /* DB_MACHINE_COMMANDS */ struct db_command *db_last_command = 0; -- cgit v1.2.3 From 5e640ccf813a28e117796f9c67f2b6b0aa73d1d3 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Wed, 20 Nov 2013 13:53:46 +0100 Subject: ddb/db_examine.c: add missing cast ddb/db_examine.c (addr, count): Cast to (db_expr_t *). --- ddb/db_examine.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ddb/db_examine.c b/ddb/db_examine.c index 071ca8f4..31f77bde 100644 --- a/ddb/db_examine.c +++ b/ddb/db_examine.c @@ -394,7 +394,7 @@ db_search_cmd() size = sizeof(int); } - if (!db_expression(&addr)) { + if (!db_expression((db_expr_t *)&addr)) { db_printf("Address missing\n"); db_flush_lex(); return; @@ -411,7 +411,7 @@ db_search_cmd() t = db_read_token(); if (t == tCOMMA) { - if (!db_expression(&count)) { + if (!db_expression((db_expr_t *)&count)) { db_printf("Count missing\n"); db_flush_lex(); return; -- cgit v1.2.3 From 48d8537b52ce4308ba0a7c54e5504d128edb9335 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Wed, 20 Nov 2013 13:53:48 +0100 Subject: ddb: fix implicit declaration of function * ddb/db_variables.c (db_read_write_variable): Remove forward declaration. * ddb/db_variables.h (db_read_write_variable): Add prototype. --- ddb/db_variables.c | 3 --- ddb/db_variables.h | 2 ++ 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/ddb/db_variables.c b/ddb/db_variables.c index 055d6e4a..54fc06c5 100644 --- a/ddb/db_variables.c +++ b/ddb/db_variables.c @@ -143,9 +143,6 @@ db_find_variable(varp, ap) return (0); } - -void db_read_write_variable(); /* forward */ - int db_get_variable(valuep) db_expr_t *valuep; diff --git a/ddb/db_variables.h b/ddb/db_variables.h index af7068f5..81d4cfe4 100644 --- a/ddb/db_variables.h +++ b/ddb/db_variables.h @@ -82,4 +82,6 @@ extern int db_get_variable(db_expr_t *valuep); void db_set_cmd(); +void db_read_write_variable(struct db_variable *, db_expr_t *, int, struct db_var_aux_param *); + #endif /* _DB_VARIABLES_H_ */ -- cgit v1.2.3 From ac9ec944f00384a61cfeee5ecca571f6b4158496 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Wed, 20 Nov 2013 13:53:49 +0100 Subject: ddb/db_run.c: remove set but unused variable * ddb/db_run.c (ins): Remove variable. --- ddb/db_run.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ddb/db_run.c b/ddb/db_run.c index 7aaeb463..e3802539 100644 --- a/ddb/db_run.c +++ b/ddb/db_run.c @@ -176,14 +176,13 @@ db_restart_at_pc(watchpt, task) if ((db_run_mode == STEP_COUNT) || (db_run_mode == STEP_RETURN) || (db_run_mode == STEP_CALLT)) { - db_expr_t ins; /* * We are about to execute this instruction, * so count it now. */ - ins = db_get_task_value(pc, sizeof(int), FALSE, task); + db_get_task_value(pc, sizeof(int), FALSE, task); db_inst_count++; db_load_count += inst_load(ins); db_store_count += inst_store(ins); @@ -192,7 +191,7 @@ db_restart_at_pc(watchpt, task) brpc = next_instr_address(pc,1,task); if ((brpc != pc) && (inst_branch(ins) || inst_call(ins))) { /* Note: this ~assumes an instruction <= sizeof(int) */ - ins = db_get_task_value(brpc, sizeof(int), FALSE, task); + db_get_task_value(brpc, sizeof(int), FALSE, task); db_inst_count++; db_load_count += inst_load(ins); db_store_count += inst_store(ins); -- cgit v1.2.3 From 288dc96fedfeb1a1da35720419120cac2979050d Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Wed, 20 Nov 2013 13:53:50 +0100 Subject: ddb/db_run.c: trivial stylistic fix for consistency * ddb/db_run.c: Trivial stylistic fix for consistency. --- ddb/db_run.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ddb/db_run.c b/ddb/db_run.c index e3802539..a595af8d 100644 --- a/ddb/db_run.c +++ b/ddb/db_run.c @@ -188,7 +188,7 @@ db_restart_at_pc(watchpt, task) db_store_count += inst_store(ins); #ifdef SOFTWARE_SSTEP /* Account for instructions in delay slots */ - brpc = next_instr_address(pc,1,task); + brpc = next_instr_address(pc, 1, task); if ((brpc != pc) && (inst_branch(ins) || inst_call(ins))) { /* Note: this ~assumes an instruction <= sizeof(int) */ db_get_task_value(brpc, sizeof(int), FALSE, task); -- cgit v1.2.3 From 774d5d3c92fd44b89a00a064f4ff460609a0e177 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Wed, 20 Nov 2013 13:53:51 +0100 Subject: ddb/db_run.c: move declaration of brpc into SOFTWARE_SSTEP * ddb/db_run.c (brpc): Move declaration into SOFTWARE_SSTEP code. --- ddb/db_run.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ddb/db_run.c b/ddb/db_run.c index a595af8d..f528b39a 100644 --- a/ddb/db_run.c +++ b/ddb/db_run.c @@ -171,7 +171,7 @@ db_restart_at_pc(watchpt, task) boolean_t watchpt; task_t task; { - db_addr_t pc = PC_REGS(DDB_REGS), brpc; + db_addr_t pc = PC_REGS(DDB_REGS); if ((db_run_mode == STEP_COUNT) || (db_run_mode == STEP_RETURN) || @@ -187,6 +187,7 @@ db_restart_at_pc(watchpt, task) db_load_count += inst_load(ins); db_store_count += inst_store(ins); #ifdef SOFTWARE_SSTEP + db_addr_t brpc; /* Account for instructions in delay slots */ brpc = next_instr_address(pc, 1, task); if ((brpc != pc) && (inst_branch(ins) || inst_call(ins))) { -- cgit v1.2.3 From 300555b73ca5ae1f2508e2cbb1e5c4e83209d2fa Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Wed, 20 Nov 2013 13:53:53 +0100 Subject: ddb/db_variables.c: fix initializations from incompatible pointer type * ddb/db_variables.c (db_set_default_thread, db_get_task_thread, db_arg_variable, fcn): Declare long return type. --- ddb/db_variables.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ddb/db_variables.c b/ddb/db_variables.c index 54fc06c5..3a12e4a2 100644 --- a/ddb/db_variables.c +++ b/ddb/db_variables.c @@ -46,9 +46,9 @@ extern db_expr_t db_radix; extern db_expr_t db_max_width; extern db_expr_t db_tab_stop_width; extern db_expr_t db_max_line; -extern int db_set_default_thread(); -extern int db_get_task_thread(); -extern int db_arg_variable(); +extern long db_set_default_thread(); +extern long db_get_task_thread(); +extern long db_arg_variable(); #define DB_NWORK 32 /* number of work variable */ @@ -184,7 +184,7 @@ db_read_write_variable(vp, valuep, rw_flag, ap) int rw_flag; db_var_aux_param_t ap; { - int (*func)() = vp->fcn; + long (*func)() = vp->fcn; struct db_var_aux_param aux_param; if (ap == 0) { -- cgit v1.2.3 From edfa24bf9ff31a099016480857e34fc95385a400 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Wed, 20 Nov 2013 13:53:54 +0100 Subject: ipc/ipc_print.h: include ipc/ipc_pset.h for ipc_pset_t * ipc/ipc_print.h: Include ipc/ipc_pset.h for ipc_pset_t. --- ipc/ipc_print.h | 1 + 1 file changed, 1 insertion(+) diff --git a/ipc/ipc_print.h b/ipc/ipc_print.h index d1fef7ea..0a3f6459 100644 --- a/ipc/ipc_print.h +++ b/ipc/ipc_print.h @@ -24,6 +24,7 @@ #include #include #include +#include extern void ipc_port_print(ipc_port_t); -- cgit v1.2.3 From 6f9c19e543125a5c35cc8a1e3c8c7cf7ecc7f010 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Wed, 20 Nov 2013 13:53:55 +0100 Subject: kern/startup.c: fix implicit declaration of function * kern/startup.c [MACH_KDB]: Include device/cons.h. --- kern/startup.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kern/startup.c b/kern/startup.c index 5e35b987..22e99973 100644 --- a/kern/startup.c +++ b/kern/startup.c @@ -58,7 +58,9 @@ #include #include - +#if MACH_KDB +#include +#endif /* MACH_KDB */ extern void vm_mem_init(); extern void vm_mem_bootstrap(); -- cgit v1.2.3 From eda770864b0c42416fb3239db2c15544840e636f Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Wed, 20 Nov 2013 13:53:56 +0100 Subject: kern/xpr.c: quiet warning about uninitialized variable * kern/xpr.c (s): Initialize. --- kern/xpr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kern/xpr.c b/kern/xpr.c index af871a27..b482a12c 100644 --- a/kern/xpr.c +++ b/kern/xpr.c @@ -154,7 +154,7 @@ void xpr_dump(base, nbufs) struct xprbuf *last, *ptr; struct xprbuf *x; int i; - spl_t s; + spl_t s = s; if (base == 0) { base = xprbase; -- cgit v1.2.3 From e3ad43e464b6d5112aefb8c3a8a292023cf18731 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Wed, 20 Nov 2013 13:53:58 +0100 Subject: Fix implicit declaration of function * ddb/db_sym.c (aout_db_sym_init): Remove forward declaration. * ddb/db_sym.h (aout_db_sym_init): Add prototype. * i386/i386at/model_dep.c (aout_db_sym_init): Fix call. [MACH_KDB]: Include ddb/db_sym.h. [MACH_KDB]: Add comment after else and endif. --- ddb/db_sym.c | 2 +- ddb/db_sym.h | 6 ++++++ i386/i386at/model_dep.c | 7 ++++--- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/ddb/db_sym.c b/ddb/db_sym.c index 98f265e6..0819e08e 100644 --- a/ddb/db_sym.c +++ b/ddb/db_sym.c @@ -511,7 +511,7 @@ void db_free_symbol(db_sym_t s) * Switch into symbol-table specific routines */ -extern boolean_t aout_db_sym_init(), aout_db_line_at_pc(); +extern boolean_t aout_db_line_at_pc(); extern db_sym_t aout_db_lookup(), aout_db_search_symbol(); extern void aout_db_symbol_values(); diff --git a/ddb/db_sym.h b/ddb/db_sym.h index d3cfec7c..650822d8 100644 --- a/ddb/db_sym.h +++ b/ddb/db_sym.h @@ -237,4 +237,10 @@ extern boolean_t db_line_at_pc( int *linenum, db_expr_t pc); +extern boolean_t aout_db_sym_init( + char *symtab, + char *esymtab, + char *name, + char *task_addr); + #endif /* _DDB_DB_SYM_H_ */ diff --git a/i386/i386at/model_dep.c b/i386/i386at/model_dep.c index 2bc1996d..1a3aee8c 100644 --- a/i386/i386at/model_dep.c +++ b/i386/i386at/model_dep.c @@ -77,11 +77,12 @@ /* Location of the kernel's symbol table. Both of these are 0 if none is available. */ #if MACH_KDB +#include static vm_offset_t kern_sym_start, kern_sym_end; -#else +#else /* MACH_KDB */ #define kern_sym_start 0 #define kern_sym_end 0 -#endif +#endif /* MACH_KDB */ /* These indicate the total extent of physical memory addresses we're using. They are page-aligned. */ @@ -581,7 +582,7 @@ void c_boot_entry(vm_offset_t bi) */ if (kern_sym_start) { - aout_db_sym_init(kern_sym_start, kern_sym_end, "mach", 0); + aout_db_sym_init((char *)kern_sym_start, (char *)kern_sym_end, "mach", (char *)0); } #endif /* MACH_KDB */ -- cgit v1.2.3 From 89ed2dc4e5a7e1614d135ee59a49bfb327e02c80 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Wed, 20 Nov 2013 13:54:01 +0100 Subject: i386/i386/db_interface.c: fix implicit declaration of function * i386/i386/db_interface.c: Include vm/vm_fault.h. --- i386/i386/db_interface.c | 1 + 1 file changed, 1 insertion(+) diff --git a/i386/i386/db_interface.c b/i386/i386/db_interface.c index f89576d6..2eb54936 100644 --- a/i386/i386/db_interface.c +++ b/i386/i386/db_interface.c @@ -43,6 +43,7 @@ #include "vm_param.h" #include +#include #include #include #include -- cgit v1.2.3 From 145aa607ecd7a26258b94dfcf10aa27f1d89e543 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Wed, 20 Nov 2013 20:42:47 +0100 Subject: i386/i386/db_interface.c: fix implicit declaration of function * i386/i386/db_interface.c: Include string.h. --- i386/i386/db_interface.c | 1 + 1 file changed, 1 insertion(+) diff --git a/i386/i386/db_interface.c b/i386/i386/db_interface.c index 2eb54936..5aee7853 100644 --- a/i386/i386/db_interface.c +++ b/i386/i386/db_interface.c @@ -27,6 +27,7 @@ * Interface to new debugger. */ +#include #include #include -- cgit v1.2.3 From f1308a39ddc564ef05f4d1b28f785f72033a5477 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Wed, 20 Nov 2013 20:42:52 +0100 Subject: i386/i386/db_trace.c: fix implicit declaration of function * i386/i386/db_trace.c: Include machine/db_interface.h. --- i386/i386/db_trace.c | 1 + 1 file changed, 1 insertion(+) diff --git a/i386/i386/db_trace.c b/i386/i386/db_trace.c index d7e13453..bdd926f4 100644 --- a/i386/i386/db_trace.c +++ b/i386/i386/db_trace.c @@ -35,6 +35,7 @@ #include #include +#include #include #include -- cgit v1.2.3 From 1b213ab16320c0a0c2fafa772e06da45aa31f019 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Wed, 20 Nov 2013 20:42:48 +0100 Subject: i386/i386/db_interface.c: remove return value Void function returns with FALSE. Remove return value. * i386/i386/db_interface.c (db_task_name): Remove return value. --- i386/i386/db_interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i386/i386/db_interface.c b/i386/i386/db_interface.c index 5aee7853..b789a54b 100644 --- a/i386/i386/db_interface.c +++ b/i386/i386/db_interface.c @@ -760,7 +760,7 @@ db_task_name( vaddr = (sp & ~(INTEL_PGBYTES - 1)) + INTEL_PGBYTES; while (1) { if (db_user_to_kernel_address(task, vaddr, &kaddr, 0) < 0) - return FALSE; + return; if (looks_like_command(task, (char*) kaddr)) break; vaddr += INTEL_PGBYTES; -- cgit v1.2.3 From 919216ba523b8d16f2b94619af97e1e96fa6e3d8 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Wed, 20 Nov 2013 20:42:49 +0100 Subject: i386/i386/db_interface.c: add comments after else and endif * i386/i386/db_interface.c [GNU]: Add comments after else and endif. --- i386/i386/db_interface.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/i386/i386/db_interface.c b/i386/i386/db_interface.c index b789a54b..fcb18de3 100644 --- a/i386/i386/db_interface.c +++ b/i386/i386/db_interface.c @@ -717,7 +717,7 @@ looks_like_command( return TRUE; } -#endif +#endif /* GNU */ void db_task_name( @@ -765,7 +765,7 @@ db_task_name( break; vaddr += INTEL_PGBYTES; } -#else +#else /* GNU */ vaddr = DB_USER_STACK_ADDR; kaddr = 0; @@ -783,18 +783,18 @@ db_task_name( db_printf(DB_NULL_TASK_NAME); return; } -#endif +#endif /* GNU */ ok: n = DB_TASK_NAME_LEN-1; #ifdef GNU p = (char *)kaddr; for (; n > 0; vaddr++, p++, n--) { -#else +#else /* GNU */ p = (char *)kaddr + sizeof(unsigned); for (vaddr += sizeof(int); vaddr < DB_USER_STACK_ADDR && n > 0; vaddr++, p++, n--) { -#endif +#endif /* GNU */ if (vaddr % INTEL_PGBYTES == 0) { (void)db_user_to_kernel_address(task, vaddr, &kaddr, 0); p = (char*)kaddr; -- cgit v1.2.3 From 02f44401d169581253e7ec59f63be8e5cdffd3c5 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Wed, 20 Nov 2013 22:04:31 +0100 Subject: Comment out db_search_null * i386/i386/db_interface.c (db_search_null) [!GNU]: Do not define db_search_null. --- i386/i386/db_interface.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/i386/i386/db_interface.c b/i386/i386/db_interface.c index fcb18de3..a8ac52a1 100644 --- a/i386/i386/db_interface.c +++ b/i386/i386/db_interface.c @@ -641,6 +641,9 @@ db_phys_eq( #define DB_USER_STACK_ADDR (VM_MIN_KERNEL_ADDRESS) #define DB_NAME_SEARCH_LIMIT (DB_USER_STACK_ADDR-(INTEL_PGBYTES*3)) +#define GNU + +#ifndef GNU static boolean_t db_search_null( task_t task, @@ -671,8 +674,7 @@ db_search_null( } return FALSE; } - -#define GNU +#endif /* GNU */ #ifdef GNU static boolean_t -- cgit v1.2.3 From cd300e86d2931c0fed1d2b3e87be695a0988065f Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Wed, 20 Nov 2013 20:42:53 +0100 Subject: i386/i386/db_trace.c: don't cast to db_addr_t * i386/i386/db_trace.c (db_check_thread_address_valid): Don't cast argument 1 to db_addr_t. --- i386/i386/db_trace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i386/i386/db_trace.c b/i386/i386/db_trace.c index bdd926f4..8bad6b09 100644 --- a/i386/i386/db_trace.c +++ b/i386/i386/db_trace.c @@ -362,7 +362,7 @@ db_stack_trace_cmd( } else if (trace_thread) { if (have_addr) { th = (thread_t) addr; - if (!db_check_thread_address_valid((db_addr_t)th)) + if (!db_check_thread_address_valid(th)) return; } else { th = db_default_thread; -- cgit v1.2.3 From 9b76beb346fd7d81a2705fd35435d66056f6b615 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Wed, 20 Nov 2013 20:42:55 +0100 Subject: i386/i386/trap.c: fix implicit declaration of function * i386/i386/trap.c: Include machine/db_interface.h. --- i386/i386/trap.c | 1 + 1 file changed, 1 insertion(+) diff --git a/i386/i386/trap.c b/i386/i386/trap.c index f4834977..89d1f3df 100644 --- a/i386/i386/trap.c +++ b/i386/i386/trap.c @@ -37,6 +37,7 @@ #include #include #include /* for spl_t */ +#include #include #include -- cgit v1.2.3 From c09b15c372cea5857df724c19db309301029bde4 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 21 Nov 2013 13:11:04 +0100 Subject: ddb/db_break.c: fix implicit declaration of functions * ddb/db_break.c: Include machine/db_interface.h. --- ddb/db_break.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ddb/db_break.c b/ddb/db_break.c index b26e1f05..c32f5571 100644 --- a/ddb/db_break.c +++ b/ddb/db_break.c @@ -36,6 +36,7 @@ */ #include #include +#include #include #include #include -- cgit v1.2.3 From 58b9f11ca2df6daa5f6116e98f95e3916471cf27 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 21 Nov 2013 13:11:06 +0100 Subject: i386/i386at/kd.h: fix implicit declaration of function * i386/i386at/kd.h [MACH_KDB] (kdb_kintr): Add prototype. --- i386/i386at/kd.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/i386/i386at/kd.h b/i386/i386at/kd.h index 1d53538b..b29a5bf0 100644 --- a/i386/i386at/kd.h +++ b/i386/i386at/kd.h @@ -742,4 +742,8 @@ extern void kd_slmscd (void *from, void *to, int count); extern void kdintr(int vec); +#if MACH_KDB +extern void kdb_kintr(void); +#endif /* MACH_KDB */ + #endif /* _KD_H_ */ -- cgit v1.2.3 From 85f76af7c321294091dd704a096329be2f96ae74 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 21 Nov 2013 13:11:05 +0100 Subject: ddb/db_sym.c: move assignment outside if * ddb/db_sym.c: Move assignment outside of if. (db_lookup): New variable. --- ddb/db_sym.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ddb/db_sym.c b/ddb/db_sym.c index 0819e08e..359ec7ce 100644 --- a/ddb/db_sym.c +++ b/ddb/db_sym.c @@ -276,7 +276,9 @@ db_name_is_ambiguous(sym_name) for (i = 0; i < db_nsymtab; i++) { db_sym_t sp; - if (sp = X_db_lookup(&db_symtabs[i], sym_name)) { + boolean_t db_lookup; + db_lookup = (int)(sp = X_db_lookup(&db_symtabs[i], sym_name)); + if (db_lookup) { if (found_once) { db_free_symbol(sp); -- cgit v1.2.3 From 7ab5e915e8459fd6961f71accfadade1f8d05fa2 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 21 Nov 2013 13:11:07 +0100 Subject: i386/i386/db_interface.h: fix implicit declaration of function * i386/i386/db_interface.h (cnpollc): Add prototype. --- i386/i386/db_interface.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/i386/i386/db_interface.h b/i386/i386/db_interface.h index 3f6821da..82bfec7f 100644 --- a/i386/i386/db_interface.h +++ b/i386/i386/db_interface.h @@ -99,4 +99,6 @@ extern kern_return_t db_set_debug_state( extern void db_load_context(pcb_t pcb); +extern void cnpollc(boolean_t on); + #endif /* _I386_DB_INTERFACE_H_ */ -- cgit v1.2.3 From e23838032fef61d63bb82980dd0cbc1e6c0724f9 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 21 Nov 2013 22:03:22 +0100 Subject: ddb/db_break.c: remove duplicate include * ddb/db_break.c: Don't include ddb/db_access.h. --- ddb/db_break.c | 1 - 1 file changed, 1 deletion(-) diff --git a/ddb/db_break.c b/ddb/db_break.c index c32f5571..562c41a7 100644 --- a/ddb/db_break.c +++ b/ddb/db_break.c @@ -47,7 +47,6 @@ #include #include #include -#include #define NBREAKPOINTS 100 #define NTHREAD_LIST (NBREAKPOINTS*3) -- cgit v1.2.3 From 167804f7e91c8dfc8321299aacd82f831e01ef21 Mon Sep 17 00:00:00 2001 From: Richard Braun Date: Sun, 24 Nov 2013 11:17:49 +0100 Subject: Export mach_port_destroy declaration * ipc/mach_port.h (mach_port_destroy): Add prototype. --- ipc/mach_port.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ipc/mach_port.h b/ipc/mach_port.h index a82228fe..4116989f 100644 --- a/ipc/mach_port.h +++ b/ipc/mach_port.h @@ -42,6 +42,11 @@ mach_port_allocate ( mach_port_right_t right, mach_port_t *namep); +extern kern_return_t +mach_port_destroy( + ipc_space_t space, + mach_port_t name); + extern kern_return_t mach_port_deallocate( ipc_space_t space, -- cgit v1.2.3 From 22495036a354e209a7f2085bdd2e1fc82895208b Mon Sep 17 00:00:00 2001 From: Richard Braun Date: Sun, 24 Nov 2013 11:17:54 +0100 Subject: New RPC for thread destruction A new call, thread_terminate_release, is added to support self destruction in threading libraries. * include/mach/gnumach.defs (thread_terminate_release): New simpleroutine declaration. * kern/thread.c: Include vm/vm_user.h and ipc/mach_port.h. (thread_terminate_release): New function. * kern/thread.h (thread_terminate_release): New prototype. --- include/mach/gnumach.defs | 26 ++++++++++++++++++++++++++ kern/thread.c | 24 ++++++++++++++++++++++++ kern/thread.h | 7 +++++++ 3 files changed, 57 insertions(+) diff --git a/include/mach/gnumach.defs b/include/mach/gnumach.defs index 73313343..12c4e994 100644 --- a/include/mach/gnumach.defs +++ b/include/mach/gnumach.defs @@ -37,3 +37,29 @@ type vm_cache_statistics_data_t = struct[11] of integer_t; routine vm_cache_statistics( target_task : vm_task_t; out vm_cache_stats : vm_cache_statistics_data_t); + +/* + * Terminate a thread and release rights and memory. + * + * Intended to be used by threading libraries to provide a clean way for + * threads to terminate themselves. The resources a thread wouldn't be able + * to release without this call when terminating itself are its + * last reference to its kernel port, its reply port, and its stack. + * + * This call is semantically equivalent to : + * - mach_port_deallocate(task, thread_name); + * - if (reply_port != MACH_PORT_NULL) + * mach_port_destroy(task, reply_port); + * - if ((address != 0) || (size != 0)) + * vm_deallocate(task, address, size) + * - thread_terminate(thread) + * + * Implemented as a simple routine so a reply port isn't required. + */ +simpleroutine thread_terminate_release( + thread : thread_t; + task : task_t; + thread_name : mach_port_name_t; + reply_port : mach_port_name_t; + address : vm_address_t; + size : vm_size_t); diff --git a/kern/thread.c b/kern/thread.c index eb8a8bbe..67fd41ed 100644 --- a/kern/thread.c +++ b/kern/thread.c @@ -57,9 +57,11 @@ #include #include #include +#include #include #include #include +#include #include /* for splsched */ #include #include /* for MACHINE_STACK */ @@ -850,6 +852,28 @@ kern_return_t thread_terminate( return KERN_SUCCESS; } +kern_return_t thread_terminate_release( + thread_t thread, + task_t task, + mach_port_t thread_name, + mach_port_t reply_port, + vm_offset_t address, + vm_size_t size) +{ + if (task == NULL) + return KERN_INVALID_ARGUMENT; + + mach_port_deallocate(task->itk_space, thread_name); + + if (reply_port != MACH_PORT_NULL) + mach_port_destroy(task->itk_space, reply_port); + + if ((address != 0) || (size != 0)) + vm_deallocate(task->map, address, size); + + return thread_terminate(thread); +} + /* * thread_force_terminate: * diff --git a/kern/thread.h b/kern/thread.h index 3959dfce..beb2dbc0 100644 --- a/kern/thread.h +++ b/kern/thread.h @@ -259,6 +259,13 @@ extern kern_return_t thread_create( thread_t *child_thread); extern kern_return_t thread_terminate( thread_t thread); +extern kern_return_t thread_terminate_release( + thread_t thread, + task_t task, + mach_port_t thread_name, + mach_port_t reply_port, + vm_offset_t address, + vm_size_t size); extern kern_return_t thread_suspend( thread_t thread); extern kern_return_t thread_resume( -- cgit v1.2.3 From c7dddd3975e892bc062b55a63bccbc390fcb368a Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sat, 23 Nov 2013 18:01:44 +0100 Subject: Remove leftover register qualifiers * ddb/db_break.c: Remove register qualifiers. * i386/i386/pcb.c: Likewise. * i386/i386at/com.c: Likewise. * i386/i386at/lpr.c: Likewise. * i386/intel/pmap.c: Likewise. * kern/machine.c: Likewise. * kern/queue.h: Likewise. * kern/sched_prim.c: Likewise. * kern/sched_prim.h: Likewise. * kern/timer.c: Likewise. * vm/vm_fault.c: Likewise. * vm/vm_resident.h: Likewise. --- ddb/db_break.c | 2 +- i386/i386/pcb.c | 2 +- i386/i386at/com.c | 2 +- i386/i386at/lpr.c | 2 +- i386/intel/pmap.c | 6 +++--- kern/machine.c | 2 +- kern/queue.h | 2 +- kern/sched_prim.c | 4 ++-- kern/sched_prim.h | 2 +- kern/timer.c | 3 --- vm/vm_fault.c | 2 +- vm/vm_resident.h | 6 +++--- 12 files changed, 16 insertions(+), 19 deletions(-) diff --git a/ddb/db_break.c b/ddb/db_break.c index 562c41a7..0491be78 100644 --- a/ddb/db_break.c +++ b/ddb/db_break.c @@ -82,7 +82,7 @@ db_breakpoint_alloc() void db_breakpoint_free(bkpt) - register db_breakpoint_t bkpt; + db_breakpoint_t bkpt; { bkpt->link = db_free_breakpoints; db_free_breakpoints = bkpt; diff --git a/i386/i386/pcb.c b/i386/i386/pcb.c index da42bd1a..bb30959d 100644 --- a/i386/i386/pcb.c +++ b/i386/i386/pcb.c @@ -765,7 +765,7 @@ kern_return_t thread_getstatus(thread, flavor, tstate, count) case i386_V86_ASSIST_STATE: { - register struct i386_v86_assist_state *state; + struct i386_v86_assist_state *state; if (*count < i386_V86_ASSIST_STATE_COUNT) return KERN_INVALID_ARGUMENT; diff --git a/i386/i386at/com.c b/i386/i386at/com.c index e0549eae..90e1d0bb 100644 --- a/i386/i386at/com.c +++ b/i386/i386at/com.c @@ -548,7 +548,7 @@ int unit; static void comparam(unit) -register int unit; +int unit; { struct tty *tp = &com_tty[unit]; u_short addr = (int)tp->t_addr; diff --git a/i386/i386at/lpr.c b/i386/i386at/lpr.c index 0f06be0a..557eb15d 100644 --- a/i386/i386at/lpr.c +++ b/i386/i386at/lpr.c @@ -275,7 +275,7 @@ struct tty *tp; void lprstop(tp, flags) -register struct tty *tp; +struct tty *tp; int flags; { if ((tp->t_state & TS_BUSY) && (tp->t_state & TS_TTSTOP) == 0) diff --git a/i386/intel/pmap.c b/i386/intel/pmap.c index 7db14e58..038f3a82 100644 --- a/i386/intel/pmap.c +++ b/i386/intel/pmap.c @@ -1608,7 +1608,7 @@ void pmap_page_protect(phys, prot) /* * Write-protect. */ - register int i = ptes_per_vm_page; + int i = ptes_per_vm_page; do { #ifdef MACH_PV_PAGETABLES @@ -2198,7 +2198,7 @@ void pmap_collect(p) */ wired = 0; { - register pt_entry_t *ptep; + pt_entry_t *ptep; for (ptep = ptp; ptep < eptp; ptep++) { if (*ptep & INTEL_PTE_WIRED) { wired = 1; @@ -2247,7 +2247,7 @@ void pmap_collect(p) * And free the pte page itself. */ { - register vm_page_t m; + vm_page_t m; vm_object_lock(pmap_object); m = vm_page_lookup(pmap_object, pa); diff --git a/kern/machine.c b/kern/machine.c index c1df28b3..f69e7287 100644 --- a/kern/machine.c +++ b/kern/machine.c @@ -409,7 +409,7 @@ __volatile__ void processor_doshutdown(); /* forward */ void processor_doaction(processor) -register processor_t processor; +processor_t processor; { thread_t this_thread; spl_t s; diff --git a/kern/queue.h b/kern/queue.h index 8835ad61..518084db 100644 --- a/kern/queue.h +++ b/kern/queue.h @@ -179,7 +179,7 @@ void insque(queue_entry_t, queue_entry_t); */ #define queue_enter(head, elt, type, field) \ { \ - register queue_entry_t prev; \ + queue_entry_t prev; \ \ prev = (head)->prev; \ if ((head) == prev) { \ diff --git a/kern/sched_prim.c b/kern/sched_prim.c index d378fa3a..29467011 100644 --- a/kern/sched_prim.c +++ b/kern/sched_prim.c @@ -490,8 +490,8 @@ void thread_sleep( * xxx - DO NOT export this to users. */ void thread_bind( - register thread_t thread, - processor_t processor) + thread_t thread, + processor_t processor) { spl_t s; diff --git a/kern/sched_prim.h b/kern/sched_prim.h index 5311d160..e08f5703 100644 --- a/kern/sched_prim.h +++ b/kern/sched_prim.h @@ -115,7 +115,7 @@ extern void compute_priority( thread_t thread, boolean_t resched); extern void thread_timeout_setup( - register thread_t thread); + thread_t thread); /* * Routines defined as macros diff --git a/kern/timer.c b/kern/timer.c index 124227ce..d16329a1 100644 --- a/kern/timer.c +++ b/kern/timer.c @@ -328,7 +328,6 @@ timer_t new_timer; * called only rarely, to make sure low_bits never overflows. */ void timer_normalize(timer) -register timer_t timer; { unsigned int high_increment; @@ -410,7 +409,6 @@ timer_save_t save; void timer_read(timer, tv) timer_t timer; -register time_value_t *tv; { timer_save_data_t temp; @@ -505,7 +503,6 @@ void db_thread_read_times(thread, user_time_p, system_time_p) unsigned timer_delta(timer, save) -register timer_t timer; timer_save_t save; { diff --git a/vm/vm_fault.c b/vm/vm_fault.c index 4b30f98d..d0c7f968 100644 --- a/vm/vm_fault.c +++ b/vm/vm_fault.c @@ -1301,7 +1301,7 @@ kern_return_t vm_fault(map, vaddr, fault_type, change_wiring, goto done; case VM_FAULT_MEMORY_SHORTAGE: if (continuation != (void (*)()) 0) { - register vm_fault_state_t *state = + vm_fault_state_t *state = (vm_fault_state_t *) current_thread()->ith_other; /* diff --git a/vm/vm_resident.h b/vm/vm_resident.h index 67f1807f..e8bf6818 100644 --- a/vm/vm_resident.h +++ b/vm/vm_resident.h @@ -38,8 +38,8 @@ * The object and page must be locked. */ extern void vm_page_replace ( - register vm_page_t mem, - register vm_object_t object, - register vm_offset_t offset); + vm_page_t mem, + vm_object_t object, + vm_offset_t offset); #endif /* _VM_RESIDENT_H_ */ -- cgit v1.2.3 From db7bae79dedbbc06bf268d0a01785d52eab3876f Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sat, 23 Nov 2013 15:29:24 +0100 Subject: vm: move forward declarations into a header file * vm/vm_object.c (memory_object_release, vm_object_deactivate_pages, vm_object_copy_delayed): Remove forward declarations. * vm/vm_object.h (memory_object_release, vm_object_deactivate_pages, vm_object_copy_delayed): Add prototypes. --- vm/vm_object.c | 10 ---------- vm/vm_object.h | 10 ++++++++++ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/vm/vm_object.c b/vm/vm_object.c index 3461b237..e1264f1a 100644 --- a/vm/vm_object.c +++ b/vm/vm_object.c @@ -59,14 +59,6 @@ #include #endif /* MACH_KDB */ - -void memory_object_release( - ipc_port_t pager, - pager_request_t pager_request, - ipc_port_t pager_name); /* forward */ - -void vm_object_deactivate_pages(vm_object_t); - /* * Virtual memory objects maintain the actual data * associated with allocated virtual memory. A given @@ -1239,8 +1231,6 @@ kern_return_t vm_object_copy_slowly( * The object should be unlocked on entry and exit. */ -vm_object_t vm_object_copy_delayed(); /* forward declaration */ - boolean_t vm_object_copy_temporary( vm_object_t *_object, /* INOUT */ vm_offset_t *_offset, /* INOUT */ diff --git a/vm/vm_object.h b/vm/vm_object.h index adeff657..5c42f568 100644 --- a/vm/vm_object.h +++ b/vm/vm_object.h @@ -245,6 +245,16 @@ extern boolean_t vm_object_coalesce( extern void vm_object_pager_wakeup(ipc_port_t pager); +void memory_object_release( + ipc_port_t pager, + pager_request_t pager_request, + ipc_port_t pager_name); + +void vm_object_deactivate_pages(vm_object_t); + +vm_object_t vm_object_copy_delayed( + vm_object_t src_object); + /* * Event waiting handling */ -- cgit v1.2.3 From 9d6d964bad51968375b88e7b0bf56b4361801667 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sat, 23 Nov 2013 15:29:25 +0100 Subject: vm: move forward declarations into a header file * vm/vm_map.c (vm_map_delete, vm_map_copyout_page_list, vm_map_copy_page_discard, vm_map_lookup_entry): Remove forward declarations. * vm/vm_map.h (vm_map_delete, vm_map_copyout_page_list, vm_map_copy_page_discard, vm_map_lookup_entry): Add prototypes. --- vm/vm_map.c | 16 ---------------- vm/vm_map.h | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/vm/vm_map.c b/vm/vm_map.c index ce1ab237..6e4544a3 100644 --- a/vm/vm_map.c +++ b/vm/vm_map.c @@ -58,20 +58,6 @@ #include #endif /* MACH_KDB */ - -/* Forward declarations */ -kern_return_t vm_map_delete( - vm_map_t map, - vm_offset_t start, - vm_offset_t end); - -kern_return_t vm_map_copyout_page_list( - vm_map_t dst_map, - vm_offset_t *dst_addr, /* OUT */ - vm_map_copy_t copy); - -void vm_map_copy_page_discard (vm_map_copy_t copy); - /* * Macros to copy a vm_map_entry. We must be careful to correctly * manage the wired page count. vm_map_entry_copy() creates a new @@ -143,8 +129,6 @@ struct kmem_cache vm_map_entry_cache; /* cache for vm_map_entry structures */ struct kmem_cache vm_map_kentry_cache; /* cache for kernel entry structures */ struct kmem_cache vm_map_copy_cache; /* cache for vm_map_copy structures */ -boolean_t vm_map_lookup_entry(); /* forward declaration */ - /* * Placeholder object for submap operations. This object is dropped * into the range by a call to vm_map_find, and removed when diff --git a/vm/vm_map.h b/vm/vm_map.h index 1caf9ae6..19317ac7 100644 --- a/vm/vm_map.h +++ b/vm/vm_map.h @@ -437,6 +437,23 @@ extern kern_return_t vm_map_machine_attribute(vm_map_t, vm_offset_t, /* Delete entry from map */ extern void vm_map_entry_delete(vm_map_t, vm_map_entry_t); +kern_return_t vm_map_delete( + vm_map_t map, + vm_offset_t start, + vm_offset_t end); + +kern_return_t vm_map_copyout_page_list( + vm_map_t dst_map, + vm_offset_t *dst_addr, /* OUT */ + vm_map_copy_t copy); + +void vm_map_copy_page_discard (vm_map_copy_t copy); + +boolean_t vm_map_lookup_entry( + vm_map_t map, + vm_offset_t address, + vm_map_entry_t *entry); /* OUT */ + /* * Functions implemented as macros */ -- cgit v1.2.3 From 8c2e432aabda338af98d3fc6dbb21156108c58ae Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sat, 23 Nov 2013 15:29:26 +0100 Subject: kern: move forward declarations into a header file * kern/thread.c [MACH_DEBUG] (stack_init, stack_finalize): Remove forward declarations. * kern/thread.h [MACH_DEBUG] (stack_init, stack_finalize): Add prototypes. --- kern/thread.c | 3 --- kern/thread.h | 5 +++++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/kern/thread.c b/kern/thread.c index 67fd41ed..72324120 100644 --- a/kern/thread.c +++ b/kern/thread.c @@ -80,9 +80,6 @@ extern void pcb_module_init(void); struct thread thread_template; #if MACH_DEBUG -void stack_init(vm_offset_t stack); /* forward */ -void stack_finalize(vm_offset_t stack); /* forward */ - #define STACK_MARKER 0xdeadbeefU boolean_t stack_check_usage = FALSE; decl_simple_lock_data(, stack_usage_lock) diff --git a/kern/thread.h b/kern/thread.h index beb2dbc0..559e90b5 100644 --- a/kern/thread.h +++ b/kern/thread.h @@ -391,4 +391,9 @@ extern void thread_unfreeze( #define current_space() (current_task()->itk_space) #define current_map() (current_task()->map) +#if MACH_DEBUG +void stack_init(vm_offset_t stack); +void stack_finalize(vm_offset_t stack); +#endif /* MACH_DEBUG */ + #endif /* _KERN_THREAD_H_ */ -- cgit v1.2.3 From 8a0a0b374ce862fb784b5b56c2b9f8f4006242fd Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sat, 23 Nov 2013 15:29:27 +0100 Subject: kern: move forward declaration into a header file * kern/mach_clock.c (softclock): Remove forward declaration. * kern/timer.h (softclock): Add prototype. --- kern/mach_clock.c | 2 -- kern/timer.h | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kern/mach_clock.c b/kern/mach_clock.c index cfc94a37..844e7b37 100644 --- a/kern/mach_clock.c +++ b/kern/mach_clock.c @@ -64,8 +64,6 @@ #include #endif -void softclock(); /* forward */ - int hz = HZ; /* number of ticks per second */ int tick = (1000000 / HZ); /* number of usec per tick */ time_value_t time = { 0, 0 }; /* time since bootup (uncorrected) */ diff --git a/kern/timer.h b/kern/timer.h index f2154ddc..f5095b56 100644 --- a/kern/timer.h +++ b/kern/timer.h @@ -182,4 +182,6 @@ MACRO_END extern void init_timers(void); +void softclock(void); + #endif /* _KERN_TIMER_H_ */ -- cgit v1.2.3 From 16e5483d9e23593cb1e7f348301a63c6cdfdfe86 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sat, 23 Nov 2013 15:29:28 +0100 Subject: kern: move forward declaration into a header file * kern/timer.c (timer_init): Remove forward declaration. * kern/timer.h (timer_init): Add prototype. --- kern/timer.c | 2 -- kern/timer.h | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kern/timer.c b/kern/timer.c index d16329a1..0c73c695 100644 --- a/kern/timer.c +++ b/kern/timer.c @@ -40,8 +40,6 @@ timer_t current_timer[NCPUS]; timer_data_t kernel_timer[NCPUS]; -void timer_init(); /* forward */ - /* * init_timers initializes all non-thread timers and puts the * service routine on the callout queue. All timers must be diff --git a/kern/timer.h b/kern/timer.h index f5095b56..76a41178 100644 --- a/kern/timer.h +++ b/kern/timer.h @@ -184,4 +184,6 @@ extern void init_timers(void); void softclock(void); +void timer_init(timer_t this_timer); + #endif /* _KERN_TIMER_H_ */ -- cgit v1.2.3 From 47942d8e24b2764985da0ac6334f2f8ac8bea9ed Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sat, 23 Nov 2013 15:29:29 +0100 Subject: kern: move forward declaration into a header file * kern/eventcount.c [NCPUS] (simpler_thread_setrun): Remove forward declaration. * kern/eventcount.h [NCPUS] (simpler_thread_setrun): Add prototype. --- kern/eventcount.c | 7 ------- kern/eventcount.h | 6 ++++++ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/kern/eventcount.c b/kern/eventcount.c index 50250003..aa3f1e36 100644 --- a/kern/eventcount.c +++ b/kern/eventcount.c @@ -53,13 +53,6 @@ #include - -#if NCPUS <= 1 -void simpler_thread_setrun( - thread_t th, - boolean_t may_preempt); /* forward */ -#endif - #define MAX_EVCS 10 /* xxx for now */ evc_t all_eventcounters[MAX_EVCS]; diff --git a/kern/eventcount.h b/kern/eventcount.h index 6872a347..4a4125cf 100644 --- a/kern/eventcount.h +++ b/kern/eventcount.h @@ -56,4 +56,10 @@ extern kern_return_t evc_wait(natural_t ev_id); extern void evc_notify_abort (thread_t thread); +#if NCPUS <= 1 +void simpler_thread_setrun( + thread_t th, + boolean_t may_preempt); +#endif + #endif /* _KERN_EVENTCOUNT_H_ */ -- cgit v1.2.3 From a40ba17874eb44c206218223df338a3d9f8704f9 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sat, 23 Nov 2013 15:29:30 +0100 Subject: kern: move forward declarations into a header file * kern/machine.c (processor_doaction, processor_doshutdown): Remove forward declarations. * kern/processor.h (processor_doaction, processor_doshutdown): Add prototypes. --- kern/machine.c | 7 ------- kern/processor.h | 7 +++++++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/kern/machine.c b/kern/machine.c index f69e7287..3dadeb5d 100644 --- a/kern/machine.c +++ b/kern/machine.c @@ -361,8 +361,6 @@ processor_t processor; /* * action_thread() shuts down processors or changes their assignment. */ -void processor_doaction(); /* forward */ - void action_thread_continue() { processor_t processor; @@ -403,11 +401,6 @@ void action_thread() * is to schedule ourselves onto a cpu and then save our * context back into the runqs before taking out the cpu. */ -#ifdef __GNUC__ -__volatile__ -#endif -void processor_doshutdown(); /* forward */ - void processor_doaction(processor) processor_t processor; { diff --git a/kern/processor.h b/kern/processor.h index 9a6c944b..ea69c234 100644 --- a/kern/processor.h +++ b/kern/processor.h @@ -320,4 +320,11 @@ extern kern_return_t processor_set_threads( natural_t *count); #endif +void processor_doaction(processor_t processor); + +#ifdef __GNUC__ +__volatile__ +#endif +void processor_doshutdown(processor_t processor); + #endif /* _KERN_PROCESSOR_H_ */ -- cgit v1.2.3 From 5c4032339c996c9150c25e083adab547bc4d5fdc Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 24 Nov 2013 22:57:16 +0100 Subject: Drop spurious volatile qualifier * kern/processor.h (processor_doshutdown): Drop spurious volatile qualifier. --- kern/processor.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/kern/processor.h b/kern/processor.h index ea69c234..7bd29cfc 100644 --- a/kern/processor.h +++ b/kern/processor.h @@ -322,9 +322,6 @@ extern kern_return_t processor_set_threads( void processor_doaction(processor_t processor); -#ifdef __GNUC__ -__volatile__ -#endif void processor_doshutdown(processor_t processor); #endif /* _KERN_PROCESSOR_H_ */ -- cgit v1.2.3 From 9eedb4a3bef454d79f1309f963f0faeb7ca0efa0 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 24 Nov 2013 22:59:09 +0100 Subject: Simplify test * ddb/db_sym.c (db_name_is_ambiguous): Simplify test for value returned by X_db_lookup. --- ddb/db_sym.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ddb/db_sym.c b/ddb/db_sym.c index 359ec7ce..0a5c9db1 100644 --- a/ddb/db_sym.c +++ b/ddb/db_sym.c @@ -275,10 +275,8 @@ db_name_is_ambiguous(sym_name) return FALSE; for (i = 0; i < db_nsymtab; i++) { - db_sym_t sp; - boolean_t db_lookup; - db_lookup = (int)(sp = X_db_lookup(&db_symtabs[i], sym_name)); - if (db_lookup) { + db_sym_t sp = X_db_lookup(&db_symtabs[i], sym_name); + if (sp) { if (found_once) { db_free_symbol(sp); -- cgit v1.2.3 From 8abd38165bc354ab709042d560c948e845e19279 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 22 Nov 2013 18:30:35 +0100 Subject: ddb: move forward declarations into a header file * ddb/db_run.c (db_set_task_single_step, db_clear_task_single_step): Remove forward declarations. * ddb/db_run.h (db_set_task_single_step, db_clear_task_single_step): Add prototypes. --- ddb/db_run.c | 11 ----------- ddb/db_run.h | 11 +++++++++++ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/ddb/db_run.c b/ddb/db_run.c index f528b39a..acd55862 100644 --- a/ddb/db_run.c +++ b/ddb/db_run.c @@ -59,17 +59,6 @@ int db_last_inst_count; int db_load_count; int db_store_count; -#ifndef db_set_single_step -void db_set_task_single_step(/* db_regs_t *, task_t */);/* forward */ -#else -#define db_set_task_single_step(regs,task) db_set_single_step(regs) -#endif -#ifndef db_clear_single_step -void db_clear_task_single_step(/* db_regs_t *, task_t */); -#else -#define db_clear_task_single_step(regs,task) db_clear_single_step(regs) -#endif - boolean_t db_stop_at_pc(is_breakpoint, task) boolean_t *is_breakpoint; diff --git a/ddb/db_run.h b/ddb/db_run.h index ee6e6f53..241852f7 100644 --- a/ddb/db_run.h +++ b/ddb/db_run.h @@ -68,6 +68,17 @@ void db_continue_cmd( db_expr_t count, char * modif); +#ifndef db_set_single_step +void db_set_task_single_step(db_regs_t *, task_t); +#else +#define db_set_task_single_step(regs, task) db_set_single_step(regs) +#endif +#ifndef db_clear_single_step +void db_clear_task_single_step(db_regs_t *, task_t); +#else +#define db_clear_task_single_step(regs, task) db_clear_single_step(regs) +#endif + extern boolean_t db_in_single_step(void); #endif /* _DDB_DB_RUN_H_ */ -- cgit v1.2.3 From 84d3177baeadf10227e4ffe03dc22f0499eadb17 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 22 Nov 2013 18:30:36 +0100 Subject: ddb: create new header file db_mp.h * Makefrag.am: Include ddb/db_mp.h. * ddb/db_mp.c (remote_db, lock_db, unlock_db): Remove forward declarations. * ddb/db_mp.h: New file. Add copyright. [_DDB_DB_MP_H_]: Add ifndef. (remote_db, lock_db, unlock_db): Add prototypes. --- Makefrag.am | 1 + ddb/db_mp.c | 6 +----- ddb/db_mp.h | 26 ++++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 ddb/db_mp.h diff --git a/Makefrag.am b/Makefrag.am index cce42cb4..abebd089 100644 --- a/Makefrag.am +++ b/Makefrag.am @@ -42,6 +42,7 @@ libkernel_a_SOURCES += \ ddb/db_macro.c \ ddb/db_macro.h \ ddb/db_mp.c \ + ddb/db_mp.h \ ddb/db_output.c \ ddb/db_output.h \ ddb/db_print.c \ diff --git a/ddb/db_mp.c b/ddb/db_mp.c index 3ab00ce3..dc294134 100644 --- a/ddb/db_mp.c +++ b/ddb/db_mp.c @@ -38,6 +38,7 @@ #include #include +#include /* * Routines to interlock access to the kernel debugger on @@ -54,11 +55,6 @@ int db_slave[NCPUS] = { 0 }; /* nonzero if cpu interrupted int db_enter_debug = 0; -void remote_db(); /* forward */ -void lock_db(); -void unlock_db(); - - /* * Called when entering kernel debugger. * Takes db lock. If we were called remotely (slave state) we just diff --git a/ddb/db_mp.h b/ddb/db_mp.h new file mode 100644 index 00000000..a163d99d --- /dev/null +++ b/ddb/db_mp.h @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2013 Free Software Foundation. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef _DDB_DB_MP_H_ +#define _DDB_DB_MP_H_ + +void remote_db(void); +void lock_db(void); +void unlock_db(void); + +#endif /* _DDB_DB_MP_H_ */ -- cgit v1.2.3 From 403d8f883d3653c124012f01bb54ea9cae83d06b Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 22 Nov 2013 18:30:37 +0100 Subject: ddb: move forward declaration into a header file * ddb/db_sym.c (db_lookup): Remove forward declaration. * ddb/db_sym.h (db_lookup): Add prototype. --- ddb/db_sym.c | 2 -- ddb/db_sym.h | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ddb/db_sym.c b/ddb/db_sym.c index 0a5c9db1..fede7dc4 100644 --- a/ddb/db_sym.c +++ b/ddb/db_sym.c @@ -50,8 +50,6 @@ int db_nsymtab = 0; db_symtab_t *db_last_symtab; -db_sym_t db_lookup(); /* forward */ - /* * Add symbol table, with given name, to list of symbol tables. */ diff --git a/ddb/db_sym.h b/ddb/db_sym.h index 650822d8..9de12dfb 100644 --- a/ddb/db_sym.h +++ b/ddb/db_sym.h @@ -243,4 +243,6 @@ extern boolean_t aout_db_sym_init( char *name, char *task_addr); +db_sym_t db_lookup(char *); + #endif /* _DDB_DB_SYM_H_ */ -- cgit v1.2.3 From 21a911aa9623928b70f88804a40ec764e7952211 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 22 Nov 2013 18:30:38 +0100 Subject: ddb: move forward declarations into a header file * ddb/db_examine.c (db_disasm, db_search): Remove forward declarations. * ddb/db_examine.h (db_disasm, db_search): Add prototypes. --- ddb/db_examine.c | 4 ---- ddb/db_examine.h | 18 ++++++++++++++++-- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/ddb/db_examine.c b/ddb/db_examine.c index 31f77bde..3d2c42bd 100644 --- a/ddb/db_examine.c +++ b/ddb/db_examine.c @@ -53,9 +53,6 @@ int db_examine_count = 1; db_addr_t db_examine_prev_addr = 0; thread_t db_examine_thread = THREAD_NULL; -extern db_addr_t db_disasm(db_addr_t pc, boolean_t altform, task_t task); - /* instruction disassembler */ - /* * Examine (print) data. */ @@ -343,7 +340,6 @@ db_strcpy(dst, src) ; } -void db_search(); /*forward*/ /* * Search for a value in memory. * Syntax: search [/bhl] addr value [mask] [,count] [thread] diff --git a/ddb/db_examine.h b/ddb/db_examine.h index e1fb1eee..e4f34155 100644 --- a/ddb/db_examine.h +++ b/ddb/db_examine.h @@ -61,8 +61,22 @@ int db_xcdump( int count, task_t task); -void db_print_cmd(); +void db_print_cmd(void); -void db_search_cmd(); +void db_search_cmd(void); + +void db_search( + db_addr_t addr, + int size, + db_expr_t value, + db_expr_t mask, + unsigned int count, + task_t task); + +/* instruction disassembler */ +extern db_addr_t db_disasm( + db_addr_t pc, + boolean_t altform, + task_t task); #endif /* _DDB_DB_EXAMINE_H_ */ -- cgit v1.2.3 From 5ad897a1ef527fecad7caca6b0ba4f20afc95d1e Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 22 Nov 2013 18:30:39 +0100 Subject: ddb/db_examine.c: trivial stylistic fix for consistency * ddb/db_examine.c: Trivial stylistic fix for consistency. --- ddb/db_examine.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ddb/db_examine.c b/ddb/db_examine.c index 3d2c42bd..a90ffa66 100644 --- a/ddb/db_examine.c +++ b/ddb/db_examine.c @@ -436,7 +436,7 @@ db_search(addr, size, value, mask, count, task) { while (count-- != 0) { db_prev = addr; - if ((db_get_task_value(addr,size,FALSE,task) & mask) == value) + if ((db_get_task_value(addr, size, FALSE, task) & mask) == value) break; addr += size; } -- cgit v1.2.3 From c476fec1212370f2a24d79037c65970c1974ce19 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 22 Nov 2013 18:30:40 +0100 Subject: device: new header file chario.h * Makefrag.am: Include device/chario.h. * device/chario.c (queue_delayed_reply, tty_output, char_open_done, char_read_done, char_write_done): Remove forward declarations. * device/chario.h: New file. Add copyright. [_DEVICE_CHARIO_H_]: Add ifndef. Include device/tty.h. (queue_delayed_reply, tty_output, char_open_done, char_read_done, char_write_done): Add prototypes. --- Makefrag.am | 1 + device/chario.c | 11 +---------- device/chario.h | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 10 deletions(-) create mode 100644 device/chario.h diff --git a/Makefrag.am b/Makefrag.am index abebd089..cdb51f2a 100644 --- a/Makefrag.am +++ b/Makefrag.am @@ -275,6 +275,7 @@ libkernel_a_SOURCES += \ device/blkio.c \ device/buf.h \ device/chario.c \ + device/chario.h \ device/cirbuf.h \ device/conf.h \ device/cons.c \ diff --git a/device/chario.c b/device/chario.c index 19f3bae3..387428a6 100644 --- a/device/chario.c +++ b/device/chario.c @@ -49,6 +49,7 @@ #include #include #include +#include #include @@ -62,16 +63,6 @@ short ttlowat[NSPEEDS] = { 30, 30, 30, 30, 30, 30, 30, 50, 50,120,120,120,125,125, 125, 125, 125,125 }; -/* - * forward declarations - */ -void queue_delayed_reply( - queue_t, io_req_t, boolean_t (*)(io_req_t)); -void tty_output(struct tty *); -boolean_t char_open_done(io_req_t); -boolean_t char_read_done(io_req_t); -boolean_t char_write_done(io_req_t); - /* * Fake 'line discipline' switch for the benefit of old code * that wants to call through it. diff --git a/device/chario.h b/device/chario.h new file mode 100644 index 00000000..2dbf09f7 --- /dev/null +++ b/device/chario.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2013 Free Software Foundation. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef _DEVICE_CHARIO_H_ +#define _DEVICE_CHARIO_H_ + +#include + +void queue_delayed_reply( + queue_t qh, + io_req_t ior, + boolean_t (*io_done)(io_req_t)); + +void tty_output(struct tty *tp); + +boolean_t char_open_done(io_req_t); +boolean_t char_read_done(io_req_t); +boolean_t char_write_done(io_req_t); + +#endif /* _DEVICE_CHARIO_H_ */ -- cgit v1.2.3 From f34397dadc2d60c32aa1e42ab96950b61ea22f54 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 21 Nov 2013 22:03:23 +0100 Subject: Modify struct db_variable * ddb/db_macro.c (db_arg_variable): Make function void. * ddb/db_macro.h (db_arg_variable): Declare void return. * ddb/db_task_thread.c (db_set_default_thread): Make function void. (db_get_task_thread): Make function void. * ddb/db_variables.c (db_set_default_thread, db_get_task_thread, db_arg_variable): Declare void return. (db_read_write_variable): Use void in initialization. * ddb/db_variables.h (db_variable): Make third member return void. [FCN_NULL]: Define void. * i386/i386/db_trace.c (db_i386_reg_value): Make function void. --- ddb/db_macro.c | 4 ++-- ddb/db_macro.h | 2 +- ddb/db_task_thread.c | 12 ++++++------ ddb/db_variables.c | 8 ++++---- ddb/db_variables.h | 4 ++-- i386/i386/db_trace.c | 4 ++-- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/ddb/db_macro.c b/ddb/db_macro.c index 5b4264c7..9d14b121 100644 --- a/ddb/db_macro.c +++ b/ddb/db_macro.c @@ -165,7 +165,7 @@ db_exec_macro(name) return(0); } -long +void /* ARGSUSED */ db_arg_variable(vp, valuep, flag, ap) struct db_variable *vp; @@ -181,7 +181,7 @@ db_arg_variable(vp, valuep, flag, ap) *valuep = db_macro_args[db_macro_level][ap->suffix[0]-1]; else db_macro_args[db_macro_level][ap->suffix[0]-1] = *valuep; - return(0); + return; } #endif /* MACH_KDB */ diff --git a/ddb/db_macro.h b/ddb/db_macro.h index da5626f9..525eead3 100644 --- a/ddb/db_macro.h +++ b/ddb/db_macro.h @@ -32,7 +32,7 @@ extern void db_show_macro (void); extern int db_exec_macro (char *name); -extern long db_arg_variable ( +extern void db_arg_variable ( struct db_variable *vp, db_expr_t *valuep, int flag, diff --git a/ddb/db_task_thread.c b/ddb/db_task_thread.c index 41f11cc2..21ec3dd4 100644 --- a/ddb/db_task_thread.c +++ b/ddb/db_task_thread.c @@ -245,7 +245,7 @@ db_init_default_thread(void) * in the command line */ /* ARGSUSED */ -long +void db_set_default_thread(vp, valuep, flag) struct db_variable *vp; db_expr_t *valuep; @@ -255,7 +255,7 @@ db_set_default_thread(vp, valuep, flag) if (flag != DB_VAR_SET) { *valuep = (db_expr_t) db_default_thread; - return(0); + return; } thread = (thread_t) *valuep; if (thread != THREAD_NULL && !db_check_thread_address_valid(thread)) @@ -264,13 +264,13 @@ db_set_default_thread(vp, valuep, flag) db_default_thread = thread; if (thread) db_default_task = thread->task; - return(0); + return; } /* * convert $taskXXX[.YYY] type DDB variable to task or thread address */ -long +void db_get_task_thread(vp, valuep, flag, ap) struct db_variable *vp; db_expr_t *valuep; @@ -291,7 +291,7 @@ db_get_task_thread(vp, valuep, flag, ap) } if (ap->level <= 1) { *valuep = (db_expr_t) task; - return(0); + return; } if ((thread = db_lookup_thread_id(task, ap->suffix[1])) == THREAD_NULL){ db_printf("no such thread($task%d.%d)\n", @@ -300,7 +300,7 @@ db_get_task_thread(vp, valuep, flag, ap) /* NOTREACHED */ } *valuep = (db_expr_t) thread; - return(0); + return; } #endif /* MACH_KDB */ diff --git a/ddb/db_variables.c b/ddb/db_variables.c index 3a12e4a2..59f1ddf5 100644 --- a/ddb/db_variables.c +++ b/ddb/db_variables.c @@ -46,9 +46,9 @@ extern db_expr_t db_radix; extern db_expr_t db_max_width; extern db_expr_t db_tab_stop_width; extern db_expr_t db_max_line; -extern long db_set_default_thread(); -extern long db_get_task_thread(); -extern long db_arg_variable(); +extern void db_set_default_thread(); +extern void db_get_task_thread(); +extern void db_arg_variable(); #define DB_NWORK 32 /* number of work variable */ @@ -184,7 +184,7 @@ db_read_write_variable(vp, valuep, rw_flag, ap) int rw_flag; db_var_aux_param_t ap; { - long (*func)() = vp->fcn; + void (*func)() = vp->fcn; struct db_var_aux_param aux_param; if (ap == 0) { diff --git a/ddb/db_variables.h b/ddb/db_variables.h index 81d4cfe4..533c0645 100644 --- a/ddb/db_variables.h +++ b/ddb/db_variables.h @@ -42,7 +42,7 @@ struct db_variable { char *name; /* Name of variable */ db_expr_t *valuep; /* pointer to value of variable */ /* function to call when reading/writing */ - long (*fcn)(struct db_variable *, db_expr_t *, int, db_var_aux_param_t); + void (*fcn)(struct db_variable *, db_expr_t *, int, db_var_aux_param_t); short min_level; /* number of minimum suffix levels */ short max_level; /* number of maximum suffix levels */ short low; /* low value of level 1 suffix */ @@ -50,7 +50,7 @@ struct db_variable { #define DB_VAR_GET 0 #define DB_VAR_SET 1 }; -#define FCN_NULL ((long (*)())0) +#define FCN_NULL ((void (*)())0) #define DB_VAR_LEVEL 3 /* maximum number of suffix level */ diff --git a/i386/i386/db_trace.c b/i386/i386/db_trace.c index 8bad6b09..4c569380 100644 --- a/i386/i386/db_trace.c +++ b/i386/i386/db_trace.c @@ -46,7 +46,7 @@ #include "trap.h" -long +void db_i386_reg_value( struct db_variable *vp, db_expr_t *valuep, @@ -125,7 +125,7 @@ db_lookup_i386_kreg( return 0; } -long +void db_i386_reg_value( struct db_variable *vp, db_expr_t *valuep, -- cgit v1.2.3 From 4af39064e3e4a6e08f4d702092b1e4bfe3289be9 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Mon, 2 Dec 2013 23:30:03 +0100 Subject: device/net_io.c: initialize hash_entp to NULL * device/net_io.c (hash_entp): Initialize to NET_HASH_ENTRY_NULL. --- device/net_io.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/device/net_io.c b/device/net_io.c index 1958840b..ee475efc 100644 --- a/device/net_io.c +++ b/device/net_io.c @@ -1158,7 +1158,7 @@ net_set_filter(ifp, rcv_port, priority, filter, filter_count) net_rcv_port_t infp, my_infp; net_rcv_port_t nextfp; net_hash_header_t hhp; - net_hash_entry_t entp, hash_entp; + net_hash_entry_t entp; net_hash_entry_t *head, nextentp; queue_entry_t dead_infp, dead_entp; int i; @@ -1166,6 +1166,13 @@ net_set_filter(ifp, rcv_port, priority, filter, filter_count) io_return_t rval; boolean_t in, out; + /* Initialize hash_entp to NULL to quiet GCC + * warning about uninitialized variable. hash_entp is only + * used when match != 0; in that case it is properly initialized + * by kmem_cache_alloc(). + */ + net_hash_entry_t hash_entp = NULL; + /* * Check the filter syntax. */ -- cgit v1.2.3 From a1e11dc70e9a82211a949061d09e0da0fc96c3e9 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 29 Nov 2013 22:53:26 +0100 Subject: ddb/db_command.c: remove forward declarations * ddb/db_command.c: Include machine/db_interface.h. (db_help_cmd, db_stack_trace_cmd): Remove forward declarations. * ddb/db_command.h (db_help_cmd): Add prototype. * i386/i386/db_interface.h (db_stack_trace_cmd): Add prototype. --- ddb/db_command.c | 3 +-- ddb/db_command.h | 2 ++ i386/i386/db_interface.h | 8 ++++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ddb/db_command.c b/ddb/db_command.c index 1299cfaa..c44e18cc 100644 --- a/ddb/db_command.c +++ b/ddb/db_command.c @@ -54,6 +54,7 @@ #include #include +#include #include #include #include /* 4proto */ @@ -331,8 +332,6 @@ struct db_command db_show_cmds[] = { { (char *)0, } }; -void db_help_cmd(); -extern void db_stack_trace_cmd(); extern void db_reset_cpu(); struct db_command db_command_table[] = { diff --git a/ddb/db_command.h b/ddb/db_command.h index 2517a909..64e3b5cf 100644 --- a/ddb/db_command.h +++ b/ddb/db_command.h @@ -73,6 +73,8 @@ extern boolean_t db_exec_cmd_nest(char *cmd, int size); void db_fncall(); +void db_help_cmd(void); + #endif /* MACH_KDB */ #endif /* _DDB_DB_COMMAND_H_ */ diff --git a/i386/i386/db_interface.h b/i386/i386/db_interface.h index 82bfec7f..b0b11cf7 100644 --- a/i386/i386/db_interface.h +++ b/i386/i386/db_interface.h @@ -88,6 +88,14 @@ extern void db_dr ( int type, int len, int persistence); + +extern void +db_stack_trace_cmd( + db_expr_t addr, + boolean_t have_addr, + db_expr_t count, + char *modif); + #endif extern void db_get_debug_state( -- cgit v1.2.3 From 3dfd404c09e476f721c861337a2c029ee377d457 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 29 Nov 2013 22:53:27 +0100 Subject: ddb/db_input.c: add comment after endif * ddb/db_input.c [DB_HISTORY_SIZE]: Add comment after endif. --- ddb/db_input.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ddb/db_input.c b/ddb/db_input.c index 8f875ada..7fee8fd7 100644 --- a/ddb/db_input.c +++ b/ddb/db_input.c @@ -133,7 +133,7 @@ db_delete_line() db_history_curr = db_history + \ db_history_size - 1; \ } while (0) -#endif +#endif /* DB_HISTORY_SIZE */ /* returns TRUE at end-of-line */ boolean_t @@ -251,7 +251,7 @@ db_inputchar(c) db_putstring(db_lbuf_start, db_le - db_lbuf_start); } break; -#endif +#endif /* DB_HISTORY_SIZE */ case CTRL('r'): db_putstring("^R\n", 3); if (db_le > db_lbuf_start) { @@ -304,7 +304,7 @@ db_inputchar(c) *db_history_last++ = '\0'; } db_history_curr = db_history_last; -#endif +#endif /* DB_HISTORY_SIZE */ *db_le++ = c; return (TRUE); default: -- cgit v1.2.3 From a146f1f1bb27ebe20e8c3042a9f05fd299250dc7 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 29 Nov 2013 22:53:28 +0100 Subject: ddb/db_mp.c: add comment after else and endif * ddb/db_mp.c [CONSOLE_ON_MASTER]: Add comment after else and endif. --- ddb/db_mp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ddb/db_mp.c b/ddb/db_mp.c index dc294134..1785e4dd 100644 --- a/ddb/db_mp.c +++ b/ddb/db_mp.c @@ -276,7 +276,7 @@ lock_db() if (my_cpu == master_cpu) { db_console(); } -#endif +#endif /* CONSOLE_ON_MASTER */ if (db_cpu != -1 && db_cpu != my_cpu) continue; @@ -288,9 +288,9 @@ lock_db() else { simple_lock(&db_lock); } -#else +#else /* CONSOLE_ON_MASTER */ simple_lock(&db_lock); -#endif +#endif /* CONSOLE_ON_MASTER */ if (db_cpu == -1 || db_cpu == my_cpu) break; simple_unlock(&db_lock); -- cgit v1.2.3 From 718497d42d0511b6ad10880ea19863cb582c7daf Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 29 Nov 2013 22:53:30 +0100 Subject: ddb/db_run.c: add comment after endif * ddb/db_run.c [FIXUP_PC_AFTER_BREAK]: Add comment after endif. --- ddb/db_run.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ddb/db_run.c b/ddb/db_run.c index acd55862..330b41b7 100644 --- a/ddb/db_run.c +++ b/ddb/db_run.c @@ -81,7 +81,7 @@ db_stop_at_pc(is_breakpoint, task) FIXUP_PC_AFTER_BREAK pc = PC_REGS(DDB_REGS); } -#endif +#endif /* FIXUP_PC_AFTER_BREAK */ /* * Now check for a breakpoint at this address. -- cgit v1.2.3 From 95458404e12be506d6847baa7fbbf3aa8e709d60 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 29 Nov 2013 22:53:31 +0100 Subject: ddb/db_aout.c: trivial stylistic fix for consistency * ddb/db_aout.c: Trivial stylistic fix for consistency. --- ddb/db_aout.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ddb/db_aout.c b/ddb/db_aout.c index a36ca0e7..54803255 100644 --- a/ddb/db_aout.c +++ b/ddb/db_aout.c @@ -500,7 +500,7 @@ aout_db_line_at_pc(stab, sym, file, line, pc) unsigned long diff; boolean_t found; - found = aout_db_search_by_addr(stab,(vm_offset_t)pc,file,&func,line,&diff); + found = aout_db_search_by_addr(stab, (vm_offset_t)pc, file, &func, line, &diff); return(found && func && *file); } -- cgit v1.2.3 From bfcf9be868a79386a13635ea01a5c551d117eafd Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 29 Nov 2013 22:53:32 +0100 Subject: ddb: new header file db_aout.h * Makefrag.am: Include ddb/db_aout.h. * ddb/db_aout.c: Include ddb/db_aout.h. * ddb/db_aout.h: New file. Add copyright. [_DDB_DB_AOUT_H_]: Add ifndef. Include ddb/db_sym.h. Include machine/db_machdep.h. (aout_db_line_at_pc, aout_db_lookup, aout_db_search_symbol, aout_db_symbol_values): Add prototypes. * ddb/db_sym.c: Include ddb/db_aout.h. (db_search_in_task_symbol, aout_db_line_at_pc, aout_db_lookup, aout_db_search_symbol, aout_db_symbol_values): Remove forward declarations. * ddb/db_sym.h (db_search_in_task_symbol): Add prototype. --- Makefrag.am | 1 + ddb/db_aout.c | 1 + ddb/db_aout.h | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ ddb/db_sym.c | 8 +------- ddb/db_sym.h | 7 +++++++ 5 files changed, 62 insertions(+), 7 deletions(-) create mode 100644 ddb/db_aout.h diff --git a/Makefrag.am b/Makefrag.am index cdb51f2a..93481476 100644 --- a/Makefrag.am +++ b/Makefrag.am @@ -24,6 +24,7 @@ libkernel_a_SOURCES += \ ddb/db_access.c \ ddb/db_access.h \ ddb/db_aout.c \ + ddb/db_aout.h \ ddb/db_break.c \ ddb/db_break.h \ ddb/db_command.c \ diff --git a/ddb/db_aout.c b/ddb/db_aout.c index 54803255..9e1c3d49 100644 --- a/ddb/db_aout.c +++ b/ddb/db_aout.c @@ -39,6 +39,7 @@ #include /* data types */ #include #include +#include #ifndef DB_NO_AOUT diff --git a/ddb/db_aout.h b/ddb/db_aout.h new file mode 100644 index 00000000..a5a00cc5 --- /dev/null +++ b/ddb/db_aout.h @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2013 Free Software Foundation. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef _DDB_DB_AOUT_H_ +#define _DDB_DB_AOUT_H_ + +#include +#include + +extern boolean_t +aout_db_line_at_pc( + db_symtab_t *stab, + db_sym_t sym, + char **file, + int *line, + db_expr_t pc); + +extern db_sym_t +aout_db_lookup( + db_symtab_t *stab, + char * symstr); + +extern db_sym_t +aout_db_search_symbol( + db_symtab_t * symtab, + db_addr_t off, + db_strategy_t strategy, + db_expr_t *diffp); + +extern void +aout_db_symbol_values( + db_symtab_t *stab, + db_sym_t sym, + char **namep, + db_expr_t *valuep); + +#endif /* _DDB_DB_AOUT_H_ */ diff --git a/ddb/db_sym.c b/ddb/db_sym.c index fede7dc4..c0ad7bfc 100644 --- a/ddb/db_sym.c +++ b/ddb/db_sym.c @@ -37,6 +37,7 @@ #include #include #include +#include #include /* vm_map_t */ @@ -287,9 +288,6 @@ db_name_is_ambiguous(sym_name) return FALSE; } - -db_sym_t db_search_in_task_symbol(); - /* * Find the closest symbol to val, and return its name * and the difference between val and the symbol found. @@ -509,10 +507,6 @@ void db_free_symbol(db_sym_t s) * Switch into symbol-table specific routines */ -extern boolean_t aout_db_line_at_pc(); -extern db_sym_t aout_db_lookup(), aout_db_search_symbol(); -extern void aout_db_symbol_values(); - extern boolean_t coff_db_sym_init(), coff_db_line_at_pc(); extern db_sym_t coff_db_lookup(), coff_db_search_symbol(); extern void coff_db_symbol_values(); diff --git a/ddb/db_sym.h b/ddb/db_sym.h index 9de12dfb..8c1a4171 100644 --- a/ddb/db_sym.h +++ b/ddb/db_sym.h @@ -245,4 +245,11 @@ extern boolean_t aout_db_sym_init( db_sym_t db_lookup(char *); +db_sym_t +db_search_in_task_symbol( + db_addr_t val, + db_strategy_t strategy, + db_addr_t *offp, + task_t task); + #endif /* _DDB_DB_SYM_H_ */ -- cgit v1.2.3 From dd20c8ffce14a5d36142e9e2615d912ccaecd91c Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 29 Nov 2013 22:53:33 +0100 Subject: ddb/db_sym.c: remove useless forward declarations without definitions * ddb/db_sym.c (coff_db_sym_init, coff_db_line_at_pc, db_sym_t coff_db_lookup, coff_db_search_symbol, coff_db_symbol_values): Remove forward declarations. (x_db): Modify field definition. --- ddb/db_sym.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/ddb/db_sym.c b/ddb/db_sym.c index c0ad7bfc..9d64f5b5 100644 --- a/ddb/db_sym.c +++ b/ddb/db_sym.c @@ -507,10 +507,6 @@ void db_free_symbol(db_sym_t s) * Switch into symbol-table specific routines */ -extern boolean_t coff_db_sym_init(), coff_db_line_at_pc(); -extern db_sym_t coff_db_lookup(), coff_db_search_symbol(); -extern void coff_db_symbol_values(); - void dummy_db_free_symbol(sym_t) { } struct db_sym_switch x_db[] = { @@ -523,12 +519,7 @@ struct db_sym_switch x_db[] = { aout_db_line_at_pc, aout_db_symbol_values, dummy_db_free_symbol }, #endif /* DB_NO_AOUT */ -#ifdef DB_NO_COFF { 0,}, -#else /* DB_NO_COFF */ - { coff_db_sym_init, coff_db_lookup, coff_db_search_symbol, - coff_db_line_at_pc, coff_db_symbol_values, dummy_db_free_symbol }, -#endif /* DB_NO_COFF */ /* Machdep, not inited here */ { 0,} -- cgit v1.2.3 From bbd18a819d05b296500c316722dc9b640558bd96 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 29 Nov 2013 22:53:34 +0100 Subject: ddb/db_sym.c: fix argument list * ddb/db_sym.c (dummy_db_free_symbol): Fix argument list. --- ddb/db_sym.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ddb/db_sym.c b/ddb/db_sym.c index 9d64f5b5..fb0cd964 100644 --- a/ddb/db_sym.c +++ b/ddb/db_sym.c @@ -507,7 +507,7 @@ void db_free_symbol(db_sym_t s) * Switch into symbol-table specific routines */ -void dummy_db_free_symbol(sym_t) { } +void dummy_db_free_symbol(db_sym_t symbol) { } struct db_sym_switch x_db[] = { -- cgit v1.2.3 From 423e1a794d353aa4f777b50f99b72a7a2b806355 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 29 Nov 2013 22:53:35 +0100 Subject: ddb/db_command.c: remove forward declaration * ddb/db_command.c (db_reset_cpu): Remove forward declaration. * i386/i386/db_interface.h (db_reset_cpu): Add prototype. * i386/i386at/model_dep.c: Include i386/db_interface.h. --- ddb/db_command.c | 2 -- i386/i386/db_interface.h | 3 +++ i386/i386at/model_dep.c | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ddb/db_command.c b/ddb/db_command.c index c44e18cc..833b7204 100644 --- a/ddb/db_command.c +++ b/ddb/db_command.c @@ -332,8 +332,6 @@ struct db_command db_show_cmds[] = { { (char *)0, } }; -extern void db_reset_cpu(); - struct db_command db_command_table[] = { #ifdef DB_MACHINE_COMMANDS /* this must be the first entry, if it exists */ diff --git a/i386/i386/db_interface.h b/i386/i386/db_interface.h index b0b11cf7..e4ae1407 100644 --- a/i386/i386/db_interface.h +++ b/i386/i386/db_interface.h @@ -96,6 +96,9 @@ db_stack_trace_cmd( db_expr_t count, char *modif); +extern void +db_reset_cpu(void); + #endif extern void db_get_debug_state( diff --git a/i386/i386at/model_dep.c b/i386/i386at/model_dep.c index 1a3aee8c..56066395 100644 --- a/i386/i386at/model_dep.c +++ b/i386/i386at/model_dep.c @@ -78,6 +78,7 @@ Both of these are 0 if none is available. */ #if MACH_KDB #include +#include static vm_offset_t kern_sym_start, kern_sym_end; #else /* MACH_KDB */ #define kern_sym_start 0 -- cgit v1.2.3 From 6fcb37ce15ab5c2d24f79c2430865db11082302b Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 29 Nov 2013 22:53:36 +0100 Subject: ddb/db_command.c: remove useless forward declaration without definition * ddb/db_command.c (ddb_display): Remove forward declaration. Remove ddb_display call. --- ddb/db_command.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/ddb/db_command.c b/ddb/db_command.c index 833b7204..b2b2a468 100644 --- a/ddb/db_command.c +++ b/ddb/db_command.c @@ -397,8 +397,6 @@ db_help_cmd() } } -int (*ddb_display)(); - void db_command_loop(void) { @@ -413,9 +411,6 @@ db_command_loop(void) db_prev = db_dot; db_next = db_dot; - if (ddb_display) - (*ddb_display)(); - db_cmd_loop_done = 0; while (!db_cmd_loop_done) { (void) _setjmp(db_recover = &db_jmpbuf); -- cgit v1.2.3 From c47bf59c3d75b77b6cd0f242ffb471fcfbf68e1b Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 29 Nov 2013 22:53:37 +0100 Subject: ddb/db_trap.c: remove forward declarations * ddb/db_run.h (db_restart_at_pc, db_stop_at_pc): Add prototypes. * ddb/db_trap.c (db_restart_at_pc, db_stop_at_pc): Remove forward declarations. Include ddb/db_run.h. --- ddb/db_run.h | 10 ++++++++++ ddb/db_trap.c | 4 +--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/ddb/db_run.h b/ddb/db_run.h index 241852f7..0c552799 100644 --- a/ddb/db_run.h +++ b/ddb/db_run.h @@ -81,4 +81,14 @@ void db_clear_task_single_step(db_regs_t *, task_t); extern boolean_t db_in_single_step(void); +extern void +db_restart_at_pc( + boolean_t watchpt, + task_t task); + +extern boolean_t +db_stop_at_pc( + boolean_t *is_breakpoint, + task_t task); + #endif /* _DDB_DB_RUN_H_ */ diff --git a/ddb/db_trap.c b/ddb/db_trap.c index 8f59a367..d2abfbda 100644 --- a/ddb/db_trap.c +++ b/ddb/db_trap.c @@ -43,13 +43,11 @@ #include #include #include +#include extern jmp_buf_t *db_recover; -extern void db_restart_at_pc(); -extern boolean_t db_stop_at_pc(); - extern int db_inst_count; extern int db_load_count; extern int db_store_count; -- cgit v1.2.3 From 63e9b4ccc348a9e033b66ab5a2dc3cb7b3e15d5a Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 29 Nov 2013 22:53:38 +0100 Subject: ddb/db_variables.c: remove forward declarations * ddb/db_task_thread.h: Include ddb/db_variables.h. (db_set_default_thread, db_get_task_thread): Add prototypes. * ddb/db_variables: Include ddb/db_macro.h. (db_set_default_thread, db_get_task_thread, db_arg_variable): Remove forward declarations. --- ddb/db_task_thread.h | 15 +++++++++++++++ ddb/db_variables.c | 4 +--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/ddb/db_task_thread.h b/ddb/db_task_thread.h index ebf99d8d..0c7fafa1 100644 --- a/ddb/db_task_thread.h +++ b/ddb/db_task_thread.h @@ -27,6 +27,8 @@ #ifndef _DDB_DB_TASK_THREAD_H_ #define _DDB_DB_TASK_THREAD_H_ +#include + #include #include @@ -48,4 +50,17 @@ extern boolean_t db_check_thread_address_valid(thread_t); extern boolean_t db_get_next_thread(thread_t *, int); extern void db_init_default_thread(void); +extern void +db_set_default_thread( + struct db_variable *vp, + db_expr_t *valuep, + int flag); + +extern void +db_get_task_thread( + struct db_variable *vp, + db_expr_t *valuep, + int flag, + db_var_aux_param_t ap); + #endif /* _DDB_DB_TASK_THREAD_H_ */ diff --git a/ddb/db_variables.c b/ddb/db_variables.c index 59f1ddf5..e737cfe5 100644 --- a/ddb/db_variables.c +++ b/ddb/db_variables.c @@ -39,6 +39,7 @@ #include #include #include +#include extern unsigned long db_maxoff; @@ -46,9 +47,6 @@ extern db_expr_t db_radix; extern db_expr_t db_max_width; extern db_expr_t db_tab_stop_width; extern db_expr_t db_max_line; -extern void db_set_default_thread(); -extern void db_get_task_thread(); -extern void db_arg_variable(); #define DB_NWORK 32 /* number of work variable */ -- cgit v1.2.3 From fc1923a79c2f4e0b3a64792ff423cbd75d05108b Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 29 Nov 2013 22:53:39 +0100 Subject: device/device_init.c: remove forward declarations * device/dev_lookup.c: Include device/ds_routines.h. * device/device_init.c: Include device/ds_routines.h. Include device/net_io.h. (mach_device_init, dev_lookup_init, net_io_init, device_pager_init, io_done_thread, net_thread): Remove forward declarations. * device/ds_routines.h (mach_device_init, dev_lookup_init, device_pager_init, io_done_thread): Add prototypes. * device/net_io.h (net_io_init, net_thread): Add prototypes. --- device/dev_lookup.c | 1 + device/device_init.c | 10 ++-------- device/ds_routines.h | 6 ++++++ device/net_io.h | 3 +++ 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/device/dev_lookup.c b/device/dev_lookup.c index 01317b9b..e257ae9c 100644 --- a/device/dev_lookup.c +++ b/device/dev_lookup.c @@ -43,6 +43,7 @@ #include #include +#include /* * Device structure routines: reference counting, port->device. diff --git a/device/device_init.c b/device/device_init.c index e43a2a95..701898bb 100644 --- a/device/device_init.c +++ b/device/device_init.c @@ -38,16 +38,10 @@ #include #include #include +#include +#include -extern void mach_device_init(); -extern void dev_lookup_init(); -extern void net_io_init(); -extern void device_pager_init(); - -extern void io_done_thread(); -extern void net_thread(); - ipc_port_t master_device_port; void diff --git a/device/ds_routines.h b/device/ds_routines.h index c4333f48..6d5b61c5 100644 --- a/device/ds_routines.h +++ b/device/ds_routines.h @@ -65,4 +65,10 @@ kern_return_t device_pager_setup( vm_size_t size, mach_port_t *pager); +extern void mach_device_init(void); +extern void dev_lookup_init(void); +extern void device_pager_init(void); +extern void io_done_thread(void); + + #endif /* DS_ROUTINES_H */ diff --git a/device/net_io.h b/device/net_io.h index 5b3a55c6..cbf68455 100644 --- a/device/net_io.h +++ b/device/net_io.h @@ -80,6 +80,9 @@ extern vm_size_t net_kmsg_size; extern void net_kmsg_collect (void); +extern void net_io_init(void); +extern void net_thread(void); + #define net_kmsg_alloc() ((ipc_kmsg_t) kalloc(net_kmsg_size)) #define net_kmsg_free(kmsg) kfree((vm_offset_t) (kmsg), net_kmsg_size) -- cgit v1.2.3 From eecf95e4455a50b6f1738f91da00171a8056ad16 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 29 Nov 2013 22:53:40 +0100 Subject: i386/i386/db_trace.c: remove forward declaration * i386/i386/db_interface.h: Include ddb/db_variables.h. (db_i386_reg_value): Add prototype. * i386/i386/db_trace.c (db_i386_reg_value): Remove forward declaration. --- i386/i386/db_interface.h | 8 ++++++++ i386/i386/db_trace.c | 7 ------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/i386/i386/db_interface.h b/i386/i386/db_interface.h index e4ae1407..e43771e0 100644 --- a/i386/i386/db_interface.h +++ b/i386/i386/db_interface.h @@ -25,6 +25,7 @@ #include #include #include +#include extern boolean_t kdb_trap ( int type, @@ -99,6 +100,13 @@ db_stack_trace_cmd( extern void db_reset_cpu(void); +void +db_i386_reg_value( + struct db_variable *vp, + db_expr_t *valuep, + int flag, + struct db_var_aux_param *ap); + #endif extern void db_get_debug_state( diff --git a/i386/i386/db_trace.c b/i386/i386/db_trace.c index 4c569380..3a5148ad 100644 --- a/i386/i386/db_trace.c +++ b/i386/i386/db_trace.c @@ -46,13 +46,6 @@ #include "trap.h" -void -db_i386_reg_value( - struct db_variable *vp, - db_expr_t *valuep, - int flag, - struct db_var_aux_param *ap); /* forward */ - /* * Machine register set. */ -- cgit v1.2.3 From e2f095dc681558b63913e4080ee9a9bec595b427 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 29 Nov 2013 22:53:41 +0100 Subject: i386/i386/fpu.c, trap.c: remove forward declarations * i386/i386/fpu.c: Include i386/trap.h. (void i386_exception, fp_save, fp_load): Remove forward declaration. * i386/i386/trap.c (void i386_exception): Remove forward declaration. * i386/i386/trap.h (void i386_exception): Add prototype. --- i386/i386/fpu.c | 6 +----- i386/i386/trap.c | 2 -- i386/i386/trap.h | 6 ++++++ 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/i386/i386/fpu.c b/i386/i386/fpu.c index fb2c8ce9..4e3ab574 100644 --- a/i386/i386/fpu.c +++ b/i386/i386/fpu.c @@ -53,6 +53,7 @@ #include #include #include +#include #include "cpu_number.h" #if 0 @@ -68,15 +69,10 @@ #define ASSERT_IPL(L) #endif -extern void i386_exception(); - int fp_kind = FP_387; /* 80387 present */ struct kmem_cache ifps_cache; /* cache for FPU save area */ static unsigned long mxcsr_feature_mask = 0xffffffff; /* Always AND user-provided mxcsr with this security mask */ -void fp_save(thread_t thread); -void fp_load(thread_t thread); - #if NCPUS == 1 volatile thread_t fp_thread = THREAD_NULL; /* thread whose state is in FPU */ diff --git a/i386/i386/trap.c b/i386/i386/trap.c index 89d1f3df..5571a1fb 100644 --- a/i386/i386/trap.c +++ b/i386/i386/trap.c @@ -66,8 +66,6 @@ extern void exception() __attribute__ ((noreturn)); extern void thread_exception_return() __attribute__ ((noreturn)); -extern void i386_exception() __attribute__ ((noreturn)); - #if MACH_KDB boolean_t debug_all_traps_with_kdb = FALSE; extern struct db_watchpoint *db_watchpoint_list; diff --git a/i386/i386/trap.h b/i386/i386/trap.h index b4e92246..6f5d2af2 100644 --- a/i386/i386/trap.h +++ b/i386/i386/trap.h @@ -36,6 +36,12 @@ char *trap_name(unsigned int trapnum); unsigned int interrupted_pc(thread_t); +void +i386_exception( + int exc, + int code, + int subcode) __attribute__ ((noreturn)); + #endif /* !__ASSEMBLER__ */ #endif /* _I386_TRAP_H_ */ -- cgit v1.2.3 From c6478d03a31a170755423ea79ff6a2532d965d25 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 29 Nov 2013 22:53:43 +0100 Subject: i386/i386/io_perm.c: remove forward declaration * i386/i386/io_perm.c: Include pcb.h. (update_ktss_iopb): Remove forward declaration. * i386/i386/pcb.h (update_ktss_iopb): Add prototype. --- i386/i386/io_perm.c | 6 +----- i386/i386/pcb.h | 2 ++ 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/i386/i386/io_perm.c b/i386/i386/io_perm.c index 8bacb8d5..4704275e 100644 --- a/i386/i386/io_perm.c +++ b/i386/i386/io_perm.c @@ -66,6 +66,7 @@ #include "io_perm.h" #include "gdt.h" +#include "pcb.h" /* Our device emulation ops. See below, at the bottom of this file. */ static struct device_emulation_ops io_perm_device_emulation_ops; @@ -219,11 +220,6 @@ i386_io_perm_create (ipc_port_t master_port, io_port_t from, io_port_t to, return KERN_SUCCESS; } - -/* From pcb.c. */ -extern void update_ktss_iopb (unsigned char *new_iopb, int last); - - /* Modify the I/O permissions for TARGET_TASK. If ENABLE is TRUE, the permission to acces the I/O ports specified by IO_PERM is granted, otherwise it is withdrawn. diff --git a/i386/i386/pcb.h b/i386/i386/pcb.h index 21bdfd9c..9edc594c 100644 --- a/i386/i386/pcb.h +++ b/i386/i386/pcb.h @@ -70,4 +70,6 @@ extern vm_offset_t stack_detach (thread_t thread); extern void switch_ktss (pcb_t pcb); +extern void update_ktss_iopb (unsigned char *new_iopb, io_port_t size); + #endif /* _I386_PCB_H_ */ -- cgit v1.2.3 From 07b0148ff9148b07d3d100e4a57c3a5fc873029d Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 29 Nov 2013 22:53:45 +0100 Subject: i386/i386/pcb.c: remove forward declarations * i386/i386/pcb.c (Load_context, Switch_context, Thread_continue, user_ldt_free): Remove forward declarations. * i386/i386/pcb.h (Load_context, Switch_context, Thread_continue): Add prototypes. * i386/i386/user_ldt.h (user_ldt_free): Add prototype. --- i386/i386/pcb.c | 6 ------ i386/i386/pcb.h | 6 ++++++ i386/i386/user_ldt.h | 3 +++ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/i386/i386/pcb.c b/i386/i386/pcb.c index bb30959d..02627ae3 100644 --- a/i386/i386/pcb.c +++ b/i386/i386/pcb.c @@ -60,12 +60,6 @@ #include #endif -extern thread_t Load_context(); -extern thread_t Switch_context(); -extern void Thread_continue(); - -extern void user_ldt_free(); - struct kmem_cache pcb_cache; vm_offset_t kernel_stack[NCPUS]; /* top of active_stack */ diff --git a/i386/i386/pcb.h b/i386/i386/pcb.h index 9edc594c..cea2fe23 100644 --- a/i386/i386/pcb.h +++ b/i386/i386/pcb.h @@ -72,4 +72,10 @@ extern void switch_ktss (pcb_t pcb); extern void update_ktss_iopb (unsigned char *new_iopb, io_port_t size); +extern thread_t Load_context (thread_t new); + +extern thread_t Switch_context (thread_t old, void (*continuation)(), thread_t new); + +extern void Thread_continue (void); + #endif /* _I386_PCB_H_ */ diff --git a/i386/i386/user_ldt.h b/i386/i386/user_ldt.h index c90273f5..26caa274 100644 --- a/i386/i386/user_ldt.h +++ b/i386/i386/user_ldt.h @@ -44,4 +44,7 @@ struct user_ldt { }; typedef struct user_ldt * user_ldt_t; +extern void +user_ldt_free(user_ldt_t user_ldt); + #endif /* _I386_USER_LDT_H_ */ -- cgit v1.2.3 From 35f8aad6128b05bae4cbdab3dca68724482daa3d Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 29 Nov 2013 22:53:46 +0100 Subject: kern: new header file exception.h * Makefrag.am: Include kern/exception.h. * i386/i386/trap.c: Include kern/exception.h. (exception, thread_exception_return): Remove forward declarations. * kern/exception.c: Include kern/exception.h. (exception, exception_try_task, exception_no_server, exception_raise, exception_parse_reply, exception_raise_continue, exception_raise_continue_slow, exception_raise_continue_fast): Remove forward declarations. * kern/exception.h: New file. Add copyright. [_KERN_EXCEPTION_H_]: Add ifndef. (exception, exception_try_task, exception_no_server, exception_raise, exception_parse_reply, exception_raise_continue, exception_raise_continue_slow, exception_raise_continue_fast): Add prototypes. --- Makefrag.am | 1 + i386/i386/trap.c | 4 +--- kern/exception.c | 13 +----------- kern/exception.h | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 66 insertions(+), 15 deletions(-) create mode 100644 kern/exception.h diff --git a/Makefrag.am b/Makefrag.am index 93481476..2e08df1c 100644 --- a/Makefrag.am +++ b/Makefrag.am @@ -143,6 +143,7 @@ libkernel_a_SOURCES += \ kern/eventcount.c \ kern/eventcount.h \ kern/exception.c \ + kern/exception.h \ kern/host.c \ kern/host.h \ kern/ipc_host.c \ diff --git a/i386/i386/trap.c b/i386/i386/trap.c index 5571a1fb..e104e122 100644 --- a/i386/i386/trap.c +++ b/i386/i386/trap.c @@ -55,6 +55,7 @@ #include #include #include +#include #if MACH_KDB #include @@ -63,9 +64,6 @@ #include "debug.h" -extern void exception() __attribute__ ((noreturn)); -extern void thread_exception_return() __attribute__ ((noreturn)); - #if MACH_KDB boolean_t debug_all_traps_with_kdb = FALSE; extern struct db_watchpoint *db_watchpoint_list; diff --git a/kern/exception.c b/kern/exception.c index 112511e5..d73b196e 100644 --- a/kern/exception.c +++ b/kern/exception.c @@ -47,20 +47,9 @@ #include #include #include +#include #include - - -extern void exception() __attribute__ ((noreturn)); -extern void exception_try_task() __attribute__ ((noreturn)); -extern void exception_no_server() __attribute__ ((noreturn)); - -extern void exception_raise() __attribute__ ((noreturn)); -extern kern_return_t exception_parse_reply(); -extern void exception_raise_continue() __attribute__ ((noreturn)); -extern void exception_raise_continue_slow() __attribute__ ((noreturn)); -extern void exception_raise_continue_fast() __attribute__ ((noreturn)); - #if MACH_KDB extern void thread_kdb_return(); extern void db_printf(); diff --git a/kern/exception.h b/kern/exception.h new file mode 100644 index 00000000..8d4d79b2 --- /dev/null +++ b/kern/exception.h @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2013 Free Software Foundation. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef _KERN_EXCEPTION_H_ +#define _KERN_EXCEPTION_H_ + +extern void +exception( + integer_t _exception, + integer_t code, + integer_t subcode) __attribute__ ((noreturn)); + +extern void +exception_try_task( + integer_t _exception, + integer_t code, + integer_t subcode) __attribute__ ((noreturn)); + +extern void +exception_no_server(void) __attribute__ ((noreturn)); + +extern void +exception_raise( + ipc_port_t dest_port, + ipc_port_t thread_port, + ipc_port_t task_port, + integer_t _exception, + integer_t code, + integer_t subcode) __attribute__ ((noreturn)); + +extern kern_return_t +exception_parse_reply(ipc_kmsg_t kmsg); + +extern void +exception_raise_continue(void) __attribute__ ((noreturn)); + +extern void +exception_raise_continue_slow( + mach_msg_return_t mr, + ipc_kmsg_t kmsg, + mach_port_seqno_t seqno) __attribute__ ((noreturn)); + +extern void +exception_raise_continue_fast( + ipc_port_t reply_port, + ipc_kmsg_t kmsg) __attribute__ ((noreturn)); + +#endif /* _KERN_EXCEPTION_H_ */ -- cgit v1.2.3 From 61f523520d663b541f773243514561e847d1ad01 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 29 Nov 2013 22:53:47 +0100 Subject: kern/exception.c: remove forward declarations * i386/i386/trap.h (thread_kdb_return): Add prototype. * kern/exception.c (thread_kdb_return, db_printf): Remove forward declarations. Include machine/trap.h. Include ddb/db_output.h. --- i386/i386/trap.h | 3 +++ kern/exception.c | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/i386/i386/trap.h b/i386/i386/trap.h index 6f5d2af2..46612db5 100644 --- a/i386/i386/trap.h +++ b/i386/i386/trap.h @@ -42,6 +42,9 @@ i386_exception( int code, int subcode) __attribute__ ((noreturn)); +extern void +thread_kdb_return(void); + #endif /* !__ASSEMBLER__ */ #endif /* _I386_TRAP_H_ */ diff --git a/kern/exception.c b/kern/exception.c index d73b196e..02327739 100644 --- a/kern/exception.c +++ b/kern/exception.c @@ -51,8 +51,8 @@ #include #if MACH_KDB -extern void thread_kdb_return(); -extern void db_printf(); +#include +#include boolean_t debug_user_with_kdb = FALSE; #endif /* MACH_KDB */ -- cgit v1.2.3 From 3ede362d063931308f469768e27e096bafc34589 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 29 Nov 2013 22:53:48 +0100 Subject: i386/i386at/autoconf.c, com.c, lpr.c: remove forward declarations * i386/i386/autoconf.c (comintr, lprintr): Remove forward declarations. Include i386at/com.h. Include i386at/lprreg.h. * i386/i386at/com.c (comprobe, commctl, comstart, comstop, comattach, comintr, comgetstat, comsetstat): Remove forward declarations. * i386/i386at/com.h: Include device/tty.h. (comprobe, commctl, comstart, comstop, comattach, comintr, comgetstat, comsetstat): Add prototypes. * i386/i386at/lpr.c (lprprobe, lprstop, lprintr, lprstart, lprattach, lprgetstat, lprsetstat, lprpr_addr): Remove forward declarations. (lprprobe): Fix argument list. (lprpr): Define argument type. lprpr_addr): Likewise. * i386/i386at/lprreg.h (lprprobe, lprstop, lprintr, lprstart, lprattach, lprgetstat, lprsetstat, lprpr_addr): Add prototypes. --- i386/Makefrag.am | 2 +- i386/i386at/autoconf.c | 4 ++-- i386/i386at/com.c | 4 ---- i386/i386at/com.h | 22 ++++++++++++++++++ i386/i386at/lpr.c | 14 +++--------- i386/i386at/lpr.h | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++ i386/i386at/lprreg.h | 38 -------------------------------- 7 files changed, 88 insertions(+), 56 deletions(-) create mode 100644 i386/i386at/lpr.h delete mode 100644 i386/i386at/lprreg.h diff --git a/i386/Makefrag.am b/i386/Makefrag.am index 32730a51..15b867f5 100644 --- a/i386/Makefrag.am +++ b/i386/Makefrag.am @@ -62,7 +62,7 @@ endif if enable_lpr libkernel_a_SOURCES += \ i386/i386at/lpr.c \ - i386/i386at/lprreg.h + i386/i386at/lpr.h endif diff --git a/i386/i386at/autoconf.c b/i386/i386at/autoconf.c index 66493b03..31bb73cd 100644 --- a/i386/i386at/autoconf.c +++ b/i386/i386at/autoconf.c @@ -38,12 +38,12 @@ #if NCOM > 0 extern struct bus_driver comdriver; -extern void comintr(); +#include #endif /* NCOM */ #if NLPR > 0 extern struct bus_driver lprdriver; -extern void lprintr(); +#include #endif /* NLPR */ struct bus_ctlr bus_master_init[] = { diff --git a/i386/i386at/com.c b/i386/i386at/com.c index 90e1d0bb..7b184e33 100644 --- a/i386/i386at/com.c +++ b/i386/i386at/com.c @@ -49,11 +49,7 @@ #include -int comprobe(), commctl(); -void comstart(struct tty *); -void comstop(), comattach(), comintr(); static void comparam(); -int comgetstat(), comsetstat(); static vm_offset_t com_std[NCOM] = { 0 }; struct bus_device *cominfo[NCOM]; diff --git a/i386/i386at/com.h b/i386/i386at/com.h index 49f23eec..7d5ee5ef 100644 --- a/i386/i386at/com.h +++ b/i386/i386at/com.h @@ -28,6 +28,7 @@ #include #include +#include /* * Set receive modem state from modem status register. @@ -47,5 +48,26 @@ extern int comcnprobe(struct consdev *cp); extern int comcninit(struct consdev *cp); extern int comcngetc(dev_t dev, int wait); extern int comcnputc(dev_t dev, int c); +extern void comintr(int unit); + +int comprobe(int port, struct bus_device *dev); +int commctl(struct tty *tp, int bits, int how); +void comstart(struct tty *tp); +void comstop(struct tty *tp, int flags); +void comattach(struct bus_device *dev); + +io_return_t +comgetstat( + dev_t dev, + int flavor, + int *data, + natural_t *count); + +io_return_t +comsetstat( + dev_t dev, + int flavor, + int *data, + natural_t count); #endif /* _COM_H_ */ diff --git a/i386/i386at/lpr.c b/i386/i386at/lpr.c index 557eb15d..4431c370 100644 --- a/i386/i386at/lpr.c +++ b/i386/i386at/lpr.c @@ -44,20 +44,12 @@ #include #include #include -#include +#include - /* * Driver information for auto-configuration stuff. */ -int lprprobe(); -void lprstop(); -void lprintr(), lprstart(); -void lprattach(struct bus_device *); -int lprgetstat(), lprsetstat(); -void lprpr_addr(); - struct bus_device *lprinfo[NLPR]; /* ??? */ static vm_offset_t lpr_std[NLPR] = { 0 }; @@ -282,14 +274,14 @@ int flags; tp->t_state |= TS_FLUSH; } int -lprpr(unit) +lprpr(int unit) { lprpr_addr(lprinfo[unit]->address); return 0; } void -lprpr_addr(addr) +lprpr_addr(unsigned short addr) { printf("DATA(%x) %x, STATUS(%x) %x, INTR_ENAB(%x) %x\n", DATA(addr), inb(DATA(addr)), diff --git a/i386/i386at/lpr.h b/i386/i386at/lpr.h new file mode 100644 index 00000000..ca7aeeac --- /dev/null +++ b/i386/i386at/lpr.h @@ -0,0 +1,60 @@ +/* + * Mach Operating System + * Copyright (c) 1991,1990 Carnegie Mellon University + * All Rights Reserved. + * + * Permission to use, copy, modify and distribute this software and its + * documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie Mellon + * the rights to redistribute these changes. + */ +/* + * Parallel port printer driver v1.0 + * All rights reserved. + */ + +#ifndef _LPRREG_H_ +#define _LPRREG_H_ + +#define DATA(addr) (addr + 0) +#define STATUS(addr) (addr + 1) +#define INTR_ENAB(addr) (addr + 2) + +extern void lprintr(int unit); +int lprprobe(int port, struct bus_device *dev); +void lprstop(struct tty *tp, int flags); +void lprstart(struct tty *tp); +void lprattach(struct bus_device *dev); + +io_return_t +lprgetstat( + dev_t dev, + int flavor, + int *data, + natural_t *count); + +io_return_t +lprsetstat( + dev_t dev, + int flavor, + int *data, + natural_t count); + +void lprpr_addr(unsigned short addr); + +#endif /* _LPRREG_H_ */ diff --git a/i386/i386at/lprreg.h b/i386/i386at/lprreg.h deleted file mode 100644 index 1fb62305..00000000 --- a/i386/i386at/lprreg.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1991,1990 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - */ -/* - * Parallel port printer driver v1.0 - * All rights reserved. - */ - -#ifndef _LPRREG_H_ -#define _LPRREG_H_ - -#define DATA(addr) (addr + 0) -#define STATUS(addr) (addr + 1) -#define INTR_ENAB(addr) (addr + 2) - -#endif /* _LPRREG_H_ */ -- cgit v1.2.3 From 8c9b556f59821283ca62209efe0a0bf17fad0a49 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 29 Nov 2013 22:53:49 +0100 Subject: i386/i386at/conf.c: remove forward declarations * i386/Makefrag.am: Include i386/i386at/model_dep.h and i386/i386at/mem.h. * i386/i386at/com.h (comgetstat, comsetstat): Declare as extern. (comopen, comclose, comread, comwrite, comportdeath): Add prototypes. * i386/i386at/conf.c: Include kern/mach_clock.h and i386at/model_dep.h. (timeopen, timeclose, timemmap): Remove forward declarations. (kdopen, kdclose, kdread, kdwrite, kdgetstat, kdsetstat, kdportdeath, kdmmap): Likewise. (comopen, comclose, comread, comwrite, comportdeath, comgetstat, comsetstat): Likewise. (lpropen, lprclose, lprread, lprwrite, lprportdeath, lprgetstat, lprsetstat): Likewise. (kbdopen, kbdclose, kbdread, kbdgetstat, kbdsetstat): Likewise. (mouseopen, mouseclose, mouseread, mousegetstat): Likewise. (memmmap): Likewise. (kmsgopen, kmsgclose, kmsgread, kmsggetstat): Likewise. (hypcnopen, hypcnclose, hypcnread, hypcnwrite, hypcnportdeath, hypcngetstat, hypcnsetstat): Likewise. Include i386at/kd.h. Include i386at/com.h. Include i386at/lpr.h. Include i386at/kd_event.h. Include i386at/kd_mouse.h. Include i386at/mem.h. Include device/kmsg.h. Include xen/console.h. * i386/i386at/kd.h: Include device/io_req.h. (kdopen, kdclose, kdread, kdwrite, kdgetstat, kdsetstat, kdportdeath, kdmmap): Add prototypes. * i386/i386at/kd_event.h (kbdopen, kbdclose, kbdread, kbdgetstat, kbdsetstat): Likewise. * i386/i386at/kd_mouse.h (mouseopen, mouseclose, mouseread, mousegetstat): Likewise. * i386/i386at/lpr.h (lpropen, lprclose, lprread, lprwrite, lprportdeath): Likewise. (lprgetstat, lprsetstat): Declare as extern. * i386/i386at/mem.h: New file. Add copyright. [_MEM_H_]: Add ifndef. (memmmap): Add prototype. * i386/i386at/model_dep.c: Include i386/i386at/model_dep.h. (timemmap): Fix argument list. * i386/i386at/model_dep.h: New file. Add copyright. [_MODEL_DEP_H_]: Add ifndef. (timemmap): Add prototype. * kern/mach_clock.h (timeopen, timeclose): Add prototypes. * xen/console.h (hypcnopen, hypcnclose, hypcnread, hypcnwrite, hypcnportdeath, hypcngetstat, hypcnsetstat): Add prototypes. --- i386/Makefrag.am | 2 ++ i386/i386at/com.h | 10 ++++++++-- i386/i386at/conf.c | 26 ++++++++++---------------- i386/i386at/kd.h | 21 +++++++++++++++++++++ i386/i386at/kd_event.h | 16 ++++++++++++++++ i386/i386at/kd_mouse.h | 10 ++++++++++ i386/i386at/lpr.h | 10 ++++++++-- i386/i386at/mem.h | 24 ++++++++++++++++++++++++ i386/i386at/model_dep.c | 3 ++- i386/i386at/model_dep.h | 26 ++++++++++++++++++++++++++ kern/mach_clock.h | 3 +++ xen/console.h | 8 ++++++++ 12 files changed, 138 insertions(+), 21 deletions(-) create mode 100644 i386/i386at/mem.h create mode 100644 i386/i386at/model_dep.h diff --git a/i386/Makefrag.am b/i386/Makefrag.am index 15b867f5..76aa5385 100644 --- a/i386/Makefrag.am +++ b/i386/Makefrag.am @@ -24,6 +24,7 @@ libkernel_a_SOURCES += \ i386/i386at/cons_conf.c \ i386/i386at/idt.h \ i386/i386at/model_dep.c \ + i386/i386at/model_dep.h \ i386/include/mach/sa/stdarg.h if PLATFORM_at @@ -50,6 +51,7 @@ libkernel_a_SOURCES += \ i386/i386at/kdasm.S \ i386/i386at/kdsoft.h \ i386/i386at/mem.c \ + i386/i386at/mem.h \ i386/i386at/pic_isa.c \ i386/i386at/rtc.c \ i386/i386at/rtc.h diff --git a/i386/i386at/com.h b/i386/i386at/com.h index 7d5ee5ef..475fa699 100644 --- a/i386/i386at/com.h +++ b/i386/i386at/com.h @@ -56,18 +56,24 @@ void comstart(struct tty *tp); void comstop(struct tty *tp, int flags); void comattach(struct bus_device *dev); -io_return_t +extern io_return_t comgetstat( dev_t dev, int flavor, int *data, natural_t *count); -io_return_t +extern io_return_t comsetstat( dev_t dev, int flavor, int *data, natural_t count); +extern io_return_t comopen(int dev, int flag, io_req_t ior); +extern io_return_t comclose(int dev, int flag); +extern io_return_t comread(int dev, io_req_t ior); +extern io_return_t comwrite(int dev, io_req_t ior); +extern io_return_t comportdeath(dev_t dev, mach_port_t port); + #endif /* _COM_H_ */ diff --git a/i386/i386at/conf.c b/i386/i386at/conf.c index 83c8dbfc..4fcd81e5 100644 --- a/i386/i386at/conf.c +++ b/i386/i386at/conf.c @@ -29,48 +29,42 @@ #include #include +#include +#include -extern int timeopen(), timeclose(); -extern vm_offset_t timemmap(); #define timename "time" #ifndef MACH_HYP -extern int kdopen(), kdclose(), kdread(), kdwrite(); -extern int kdgetstat(), kdsetstat(), kdportdeath(); -extern vm_offset_t kdmmap(); +#include #define kdname "kd" #if NCOM > 0 -extern int comopen(), comclose(), comread(), comwrite(); -extern int comgetstat(), comsetstat(), comportdeath(); +#include #define comname "com" #endif /* NCOM > 0 */ #if NLPR > 0 -extern int lpropen(), lprclose(), lprread(), lprwrite(); -extern int lprgetstat(), lprsetstat(), lprportdeath(); +#include #define lprname "lpr" #endif /* NLPR > 0 */ #endif /* MACH_HYP */ -extern int kbdopen(), kbdclose(), kbdread(); -extern int kbdgetstat(), kbdsetstat(); +#include #define kbdname "kbd" #ifndef MACH_HYP -extern int mouseopen(), mouseclose(), mouseread(), mousegetstat(); +#include #define mousename "mouse" -extern vm_offset_t memmmap(); +#include #define memname "mem" #endif /* MACH_HYP */ -extern int kmsgopen(), kmsgclose(), kmsgread(), kmsggetstat(); +#include #define kmsgname "kmsg" #ifdef MACH_HYP -extern int hypcnopen(), hypcnclose(), hypcnread(), hypcnwrite(); -extern int hypcngetstat(), hypcnsetstat(), hypcnportdeath(); +#include #define hypcnname "hyp" #endif /* MACH_HYP */ diff --git a/i386/i386at/kd.h b/i386/i386at/kd.h index b29a5bf0..c38f90b8 100644 --- a/i386/i386at/kd.h +++ b/i386/i386at/kd.h @@ -76,6 +76,7 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include +#include /* @@ -746,4 +747,24 @@ extern void kdintr(int vec); extern void kdb_kintr(void); #endif /* MACH_KDB */ +extern int kdopen(dev_t dev, int flag, io_req_t ior); +extern void kdclose(int dev, int flag); +extern int kdread(int dev, struct uio *uio); +extern int kdwrite(int dev, struct uio *uio); + +extern io_return_t kdgetstat( + dev_t dev, + int flavor, + int *data, + natural_t *count); + +extern io_return_t kdsetstat( + dev_t dev, + int flavor, + int * data, + natural_t count); + +extern int kdportdeath(dev_t dev, mach_port_t port); +extern int kdmmap(dev_t dev, off_t off, int prot); + #endif /* _KD_H_ */ diff --git a/i386/i386at/kd_event.h b/i386/i386at/kd_event.h index 677af99b..ae180472 100644 --- a/i386/i386at/kd_event.h +++ b/i386/i386at/kd_event.h @@ -30,4 +30,20 @@ extern void X_kdb_enter (void); extern void X_kdb_exit (void); +extern int kbdopen(dev_t dev, int flags); +extern void kbdclose(dev_t dev, int flags); +extern int kbdread(dev_t dev, io_req_t ior); + +extern io_return_t kbdgetstat( + dev_t dev, + int flavor, + int *data, + unsigned int *count); + +extern io_return_t kbdsetstat( + dev_t dev, + int flavor, + int *data, + unsigned int count); + #endif /* _KD_EVENT_H_ */ diff --git a/i386/i386at/kd_mouse.h b/i386/i386at/kd_mouse.h index baa51c8a..0f094181 100644 --- a/i386/i386at/kd_mouse.h +++ b/i386/i386at/kd_mouse.h @@ -54,4 +54,14 @@ extern void mouse_packet_mouse_system_mouse (u_char *mousebuf); extern void mouse_packet_ibm_ps2_mouse (u_char *mousebuf); +extern int mouseopen(dev_t dev, int flags); +extern void mouseclose(dev_t dev, int flags); +extern int mouseread(dev_t dev, io_req_t ior); + +extern io_return_t mousegetstat( + dev_t dev, + int flavor, + int *data, + unsigned int *count); + #endif /* _KD_MOUSE_H_ */ diff --git a/i386/i386at/lpr.h b/i386/i386at/lpr.h index ca7aeeac..820d0ab7 100644 --- a/i386/i386at/lpr.h +++ b/i386/i386at/lpr.h @@ -41,14 +41,14 @@ void lprstop(struct tty *tp, int flags); void lprstart(struct tty *tp); void lprattach(struct bus_device *dev); -io_return_t +extern io_return_t lprgetstat( dev_t dev, int flavor, int *data, natural_t *count); -io_return_t +extern io_return_t lprsetstat( dev_t dev, int flavor, @@ -57,4 +57,10 @@ lprsetstat( void lprpr_addr(unsigned short addr); +extern int lpropen(int dev, int flag, io_req_t ior); +extern void lprclose(int dev, int flag); +extern int lprread(int dev, io_req_t ior); +extern int lprwrite(int dev, io_req_t ior); +extern int lprportdeath(dev_t dev, mach_port_t port); + #endif /* _LPRREG_H_ */ diff --git a/i386/i386at/mem.h b/i386/i386at/mem.h new file mode 100644 index 00000000..3d6a96cb --- /dev/null +++ b/i386/i386at/mem.h @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2013 Free Software Foundation. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef _MEM_H_ +#define _MEM_H_ + +extern int memmmap(int dev, vm_offset_t off, vm_prot_t prot); + +#endif /* _MEM_H_ */ diff --git a/i386/i386at/model_dep.c b/i386/i386at/model_dep.c index 56066395..48ef329e 100644 --- a/i386/i386at/model_dep.c +++ b/i386/i386at/model_dep.c @@ -620,9 +620,10 @@ void c_boot_entry(vm_offset_t bi) #include #include #include +#include int -timemmap(dev,off,prot) +timemmap(dev, off, prot) vm_prot_t prot; { extern time_value_t *mtime; diff --git a/i386/i386at/model_dep.h b/i386/i386at/model_dep.h new file mode 100644 index 00000000..3a5749f3 --- /dev/null +++ b/i386/i386at/model_dep.h @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2013 Free Software Foundation. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef _MODEL_DEP_H_ +#define _MODEL_DEP_H_ + +#include + +extern int timemmap(int dev, int off, vm_prot_t prot); + +#endif /* _MODEL_DEP_H_ */ diff --git a/kern/mach_clock.h b/kern/mach_clock.h index 4e4e8ff1..72189af6 100644 --- a/kern/mach_clock.h +++ b/kern/mach_clock.h @@ -104,4 +104,7 @@ extern void mapable_time_init (void); extern void timeout(timer_func_t *fcn, void *param, int interval); extern boolean_t untimeout(timer_func_t *fcn, void *param); +extern int timeopen(void); +extern int timeclose(void); + #endif /* _KERN_MACH_CLOCK_H_ */ diff --git a/xen/console.h b/xen/console.h index ad171a47..2b78f295 100644 --- a/xen/console.h +++ b/xen/console.h @@ -37,4 +37,12 @@ extern int hypcngetc(dev_t dev, int wait); extern int hypcnprobe(struct consdev *cp); extern int hypcninit(struct consdev *cp); +extern int hypcnopen(dev_t dev, int flag, io_req_t ior); +extern int hypcnread(int dev, io_req_t ior); +extern int hypcnwrite(int dev, io_req_t ior); +extern int hypcnclose(int dev, int flag); +extern io_return_t hypcngetstat(dev_t dev, int flavor, int *data, unsigned int *count); +extern io_return_t hypcnsetstat(dev_t dev, int flavor, int *data, unsigned int count); +extern int hypcnportdeath(dev_t dev, mach_port_t port); + #endif /* XEN_CONSOLE_H */ -- cgit v1.2.3 From 4bcaa65e3269f8b5d18d182999a5e81b2694c1a0 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 29 Nov 2013 22:53:50 +0100 Subject: i386/i386at/kd.c: remove forward declarations * i386/i386at/kd.c (kd_enqsc, kdcheckmagic, do_modifier, bmpch2bit, bmppaintcsr, bit2fbptr): Remove forward declarations. * i386/i386at/kd.h: Include device/buf.h. Include i386at/kdsoft.h. (kdcheckmagic, do_modifier, bmpch2bit, bmppaintcsr, bit2fbptr): Add prototypes. * i386/i386at/kd_event.h (kd_enqsc): Add prototype. --- i386/i386at/kd.c | 22 +--------------------- i386/i386at/kd.h | 20 +++++++++++++++++++- i386/i386at/kd_event.h | 2 ++ 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/i386/i386at/kd.c b/i386/i386at/kd.c index 3890c3d3..5605257f 100644 --- a/i386/i386at/kd.c +++ b/i386/i386at/kd.c @@ -100,20 +100,15 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #define DEBUG 1 /* export feep() */ -void kd_enqsc(); /* enqueues a scancode */ - #if 0 #define BROKEN_KEYBOARD_RESET #endif struct tty kd_tty; -extern int rebootflag; +extern int rebootflag; static void charput(), charmvup(), charmvdown(), charclear(), charsetcursor(); static void kd_noopreset(); -boolean_t kdcheckmagic(); - -int do_modifier (int, Scancode, boolean_t); /* * These routines define the interface to the device-specific layer. @@ -2688,21 +2683,6 @@ kd_noopreset() } - -/* - * Generic routines for bitmap devices (i.e., assume no hardware - * assist). Assumes a simple byte ordering (i.e., a byte at a lower - * address is to the left of the byte at the next higher address). - * For the 82786, this works anyway if the characters are 2 bytes - * wide. (more bubble gum and paper clips.) - * - * See the comments above about SLAMBPW. - */ - -void bmpch2bit(), bmppaintcsr(); -u_char *bit2fbptr(); - - /* * bmpput: Copy a character from the font to the frame buffer. */ diff --git a/i386/i386at/kd.h b/i386/i386at/kd.h index c38f90b8..d97fdd5e 100644 --- a/i386/i386at/kd.h +++ b/i386/i386at/kd.h @@ -77,7 +77,8 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include - +#include +#include /* * Where memory for various graphics adapters starts. @@ -767,4 +768,21 @@ extern io_return_t kdsetstat( extern int kdportdeath(dev_t dev, mach_port_t port); extern int kdmmap(dev_t dev, off_t off, int prot); +boolean_t kdcheckmagic(Scancode scancode); + +int do_modifier(int state, Scancode c, boolean_t up); + +/* + * Generic routines for bitmap devices (i.e., assume no hardware + * assist). Assumes a simple byte ordering (i.e., a byte at a lower + * address is to the left of the byte at the next higher address). + * For the 82786, this works anyway if the characters are 2 bytes + * wide. (more bubble gum and paper clips.) + * + * See the comments above (in i386at/kd.c) about SLAMBPW. + */ +void bmpch2bit(csrpos_t pos, short *xb, short *yb); +void bmppaintcsr(csrpos_t pos, u_char val); +u_char *bit2fbptr(short xb, short yb); + #endif /* _KD_H_ */ diff --git a/i386/i386at/kd_event.h b/i386/i386at/kd_event.h index ae180472..d2e5123e 100644 --- a/i386/i386at/kd_event.h +++ b/i386/i386at/kd_event.h @@ -46,4 +46,6 @@ extern io_return_t kbdsetstat( int *data, unsigned int count); +extern void kd_enqsc(Scancode sc); + #endif /* _KD_EVENT_H_ */ -- cgit v1.2.3 From 835ca96b6e9fa43f3f655f676777670085814537 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 29 Nov 2013 22:53:51 +0100 Subject: i386/i386at/kd_event.c: remove forward declarations * i386/i386at/kd_event.c (kbd_enqueue, X_kdb_enter_init, X_kdb_exit_init, kbd_read_done): Remove forward declarations. * i386/i386at/kd_event.h (kbd_enqueue, X_kdb_enter_init, X_kdb_exit_init, kbd_read_done): Add prototypes. --- i386/i386at/kd_event.c | 8 -------- i386/i386at/kd_event.h | 7 +++++++ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/i386/i386at/kd_event.c b/i386/i386at/kd_event.c index 3a216c0b..db14225c 100644 --- a/i386/i386at/kd_event.c +++ b/i386/i386at/kd_event.c @@ -83,11 +83,6 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. kd_event_queue kbd_queue; /* queue of keyboard events */ queue_head_t kbd_read_queue = { &kbd_read_queue, &kbd_read_queue }; - -void kbd_enqueue(); -io_return_t X_kdb_enter_init(); -io_return_t X_kdb_exit_init(); - static boolean_t initialized = FALSE; @@ -201,9 +196,6 @@ io_return_t kbdsetstat(dev, flavor, data, count) /* * kbdread - dequeue and return any queued events. */ - -boolean_t kbd_read_done(); /* forward */ - int kbdread(dev, ior) dev_t dev; diff --git a/i386/i386at/kd_event.h b/i386/i386at/kd_event.h index d2e5123e..f1295cb2 100644 --- a/i386/i386at/kd_event.h +++ b/i386/i386at/kd_event.h @@ -48,4 +48,11 @@ extern io_return_t kbdsetstat( extern void kd_enqsc(Scancode sc); +void kbd_enqueue(kd_event *ev); + +io_return_t X_kdb_enter_init(u_int *data, u_int count); +io_return_t X_kdb_exit_init(u_int *data, u_int count); + +boolean_t kbd_read_done(io_req_t ior); + #endif /* _KD_EVENT_H_ */ -- cgit v1.2.3 From cd76b756ea59e4f2e367c6d943932fa7d18b4681 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 29 Nov 2013 22:53:52 +0100 Subject: i386/i386at/kd_mouse.c: remove forward declarations * i386/i386at/kd_mouse.c (mouseintr, mouse_enqueue, mouse_read_done): Remove forward declarations. (mouseintr): Define argument type. * i386/i386at/kd_mouse.h (mouseintr, mouse_enqueue, mouse_read_done): Add prototypes. --- i386/i386at/kd_mouse.c | 6 +----- i386/i386at/kd_mouse.h | 3 +++ 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/i386/i386at/kd_mouse.c b/i386/i386at/kd_mouse.c index 99fc2662..5a804743 100644 --- a/i386/i386at/kd_mouse.c +++ b/i386/i386at/kd_mouse.c @@ -101,8 +101,6 @@ u_char lastbuttons; /* previous state of mouse buttons */ #define MOUSE_DOWN 0 #define MOUSE_ALL_UP 0x7 -void mouseintr(); -void mouse_enqueue(); int mouse_baud = BCNT1200; boolean_t mouse_char_cmd = FALSE; /* mouse response is to cmd */ @@ -319,8 +317,6 @@ io_return_t mousegetstat(dev, flavor, data, count) /* * mouseread - dequeue and return any queued events. */ -boolean_t mouse_read_done(); /* forward */ - int mouseread(dev, ior) dev_t dev; @@ -397,7 +393,7 @@ boolean_t mouse_read_done(ior) * mouseintr - Get a byte and pass it up for handling. Called at SPLKD. */ void -mouseintr(unit) +mouseintr(int unit) { unsigned short base_addr = cominfo[unit]->address; unsigned char id, ls; diff --git a/i386/i386at/kd_mouse.h b/i386/i386at/kd_mouse.h index 0f094181..ad07c6c8 100644 --- a/i386/i386at/kd_mouse.h +++ b/i386/i386at/kd_mouse.h @@ -64,4 +64,7 @@ extern io_return_t mousegetstat( int *data, unsigned int *count); +void mouseintr(int unit); +boolean_t mouse_read_done(io_req_t ior); + #endif /* _KD_MOUSE_H_ */ -- cgit v1.2.3 From e2f055b0224da1ee74398ff77e49e12e398e7afa Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 29 Nov 2013 22:53:53 +0100 Subject: i386/i386at: remove forward declarations * Makefrag.am: Include kern/startup.h. * i386/i386at/model_dep.c: Include kern/startup.h. Include i386at/model_dep.h. (setup_main, halt_all_cpus, halt_cpu, inittodr): Remove forward declarations. * i386/i386at/model_dep.h (halt_all_cpus, halt_cpu, inittodr): Add prototypes. * kern/startup.h: New file. Add copyright. [_KERN_STARTUP_H_]: Add ifndef. (setup_main): Add prototype. --- Makefrag.am | 1 + i386/i386at/model_dep.c | 10 ++-------- i386/i386at/model_dep.h | 5 +++++ kern/startup.h | 24 ++++++++++++++++++++++++ 4 files changed, 32 insertions(+), 8 deletions(-) create mode 100644 kern/startup.h diff --git a/Makefrag.am b/Makefrag.am index 2e08df1c..2d09b623 100644 --- a/Makefrag.am +++ b/Makefrag.am @@ -190,6 +190,7 @@ libkernel_a_SOURCES += \ kern/sched_prim.h \ kern/shuttle.h \ kern/startup.c \ + kern/startup.h \ kern/strings.c \ kern/syscall_emulation.c \ kern/syscall_emulation.h \ diff --git a/i386/i386at/model_dep.c b/i386/i386at/model_dep.c index 48ef329e..21f6186c 100644 --- a/i386/i386at/model_dep.c +++ b/i386/i386at/model_dep.c @@ -48,6 +48,7 @@ #include #include #include +#include #include #include #include @@ -67,6 +68,7 @@ #include #include #include +#include #ifdef MACH_XEN #include #include @@ -125,13 +127,6 @@ static vm_size_t avail_remaining; extern char version[]; -extern void setup_main(); - -void halt_all_cpus (boolean_t reboot) __attribute__ ((noreturn)); -void halt_cpu (void) __attribute__ ((noreturn)); - -void inittodr(); /* forward */ - int rebootflag = 0; /* exported to kdintr */ /* XX interrupt stack pointer and highwater mark, for locore.S. */ @@ -620,7 +615,6 @@ void c_boot_entry(vm_offset_t bi) #include #include #include -#include int timemmap(dev, off, prot) diff --git a/i386/i386at/model_dep.h b/i386/i386at/model_dep.h index 3a5749f3..11c6451f 100644 --- a/i386/i386at/model_dep.h +++ b/i386/i386at/model_dep.h @@ -23,4 +23,9 @@ extern int timemmap(int dev, int off, vm_prot_t prot); +void halt_all_cpus(boolean_t reboot) __attribute__ ((noreturn)); +void halt_cpu(void) __attribute__ ((noreturn)); + +void inittodr(void); + #endif /* _MODEL_DEP_H_ */ diff --git a/kern/startup.h b/kern/startup.h new file mode 100644 index 00000000..d167fde2 --- /dev/null +++ b/kern/startup.h @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2013 Free Software Foundation. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef _KERN_STARTUP_H_ +#define _KERN_STARTUP_H_ + +extern void setup_main(void); + +#endif /* _KERN_STARTUP_H_ */ -- cgit v1.2.3 From 4297d6038e93d87554116a0b311dd6daf1da985e Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Thu, 5 Dec 2013 06:24:00 +0900 Subject: Drop duplicate declaration * i386/i386/model_dep.h (halt_cpu, halt_all_cpus): Remove duplicate declaration. * i386/i386at/model_dep.h (halt_cpu, halt_all_cpus): Add comments. --- i386/i386/model_dep.h | 10 ---------- i386/i386at/model_dep.h | 11 +++++++++-- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/i386/i386/model_dep.h b/i386/i386/model_dep.h index a41c474d..c45b756c 100644 --- a/i386/i386/model_dep.h +++ b/i386/i386/model_dep.h @@ -36,16 +36,6 @@ extern void machine_init (void); /* Conserve power on processor CPU. */ extern void machine_idle (int cpu); -/* - * Halt a cpu. - */ -extern void halt_cpu (void) __attribute__ ((noreturn)); - -/* - * Halt the system or reboot. - */ -extern void halt_all_cpus (boolean_t reboot) __attribute__ ((noreturn)); - extern void resettodr (void); extern void startrtclock (void); diff --git a/i386/i386at/model_dep.h b/i386/i386at/model_dep.h index 11c6451f..65dc00bd 100644 --- a/i386/i386at/model_dep.h +++ b/i386/i386at/model_dep.h @@ -23,8 +23,15 @@ extern int timemmap(int dev, int off, vm_prot_t prot); -void halt_all_cpus(boolean_t reboot) __attribute__ ((noreturn)); -void halt_cpu(void) __attribute__ ((noreturn)); +/* + * Halt a cpu. + */ +extern void halt_cpu (void) __attribute__ ((noreturn)); + +/* + * Halt the system or reboot. + */ +extern void halt_all_cpus (boolean_t reboot) __attribute__ ((noreturn)); void inittodr(void); -- cgit v1.2.3 From 98d8a7b1245e737f5efc48d9c30dca830766b8ac Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 29 Nov 2013 22:53:55 +0100 Subject: i386/intel/pmap.c: remove forward declarations * i386/intel/pmap.c (pmap_remove_range, signal_cpus): Remove forward declarations. * i386/intel/pmap.h (pmap_remove_range, signal_cpus): Add prototypes. --- i386/intel/pmap.c | 5 ----- i386/intel/pmap.h | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/i386/intel/pmap.c b/i386/intel/pmap.c index 038f3a82..b89524e2 100644 --- a/i386/intel/pmap.c +++ b/i386/intel/pmap.c @@ -421,11 +421,6 @@ extern char end; */ pt_entry_t *kernel_page_dir; -void pmap_remove_range(); /* forward */ -#if NCPUS > 1 -void signal_cpus(); /* forward */ -#endif /* NCPUS > 1 */ - static inline pt_entry_t * pmap_pde(pmap_t pmap, vm_offset_t addr) { diff --git a/i386/intel/pmap.h b/i386/intel/pmap.h index 087e0ef4..20c62432 100644 --- a/i386/intel/pmap.h +++ b/i386/intel/pmap.h @@ -451,6 +451,20 @@ extern void pmap_copy_page (vm_offset_t, vm_offset_t); */ extern vm_offset_t kvtophys (vm_offset_t); +void pmap_remove_range( + pmap_t pmap, + vm_offset_t va, + pt_entry_t *spte, + pt_entry_t *epte); + +#if NCPUS > 1 +void signal_cpus( + cpu_set use_list, + pmap_t pmap, + vm_offset_t start, + vm_offset_t end); +#endif /* NCPUS > 1 */ + #endif /* __ASSEMBLER__ */ #endif /* _PMAP_MACHINE_ */ -- cgit v1.2.3 From 4448c2cd5acd431722508d8b020c0f7b6163fae0 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 29 Nov 2013 22:53:56 +0100 Subject: ipc/ipc_kmsg.c: remove forward declarations * ipc/ipc_kmsg.c (copyinmap, copyoutmap, ipc_msg_print): Remove forward declarations. * ipc/ipc_kmsg.h (ipc_msg_print): Add prototype. --- ipc/ipc_kmsg.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ipc/ipc_kmsg.c b/ipc/ipc_kmsg.c index 3bdd6b00..0e434105 100644 --- a/ipc/ipc_kmsg.c +++ b/ipc/ipc_kmsg.c @@ -69,10 +69,6 @@ #include #endif -extern int copyinmap(); -extern int copyoutmap(); -void ipc_msg_print(); /* forward */ - #define is_misaligned(x) ( ((vm_offset_t)(x)) & (sizeof(vm_offset_t)-1) ) #define ptr_align(x) \ ( ( ((vm_offset_t)(x)) + (sizeof(vm_offset_t)-1) ) & ~(sizeof(vm_offset_t)-1) ) -- cgit v1.2.3 From 43d00cc7405ebda7eaf18b888bbe1db288ca379a Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 29 Nov 2013 22:53:57 +0100 Subject: ipc/ipc_table.c: remove forward declaration * ipc/ipc_table.c (ipc_table_fill): Remove forward declaration. * ipc/ipc_table.h (ipc_table_fill): Add prototype. --- ipc/ipc_table.c | 9 --------- ipc/ipc_table.h | 6 ++++++ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/ipc/ipc_table.c b/ipc/ipc_table.c index 78a82f2c..90960a8f 100644 --- a/ipc/ipc_table.c +++ b/ipc/ipc_table.c @@ -42,15 +42,6 @@ #include #include -/* - * Forward declarations - */ -void ipc_table_fill( - ipc_table_size_t its, - unsigned int num, - unsigned int min, - vm_size_t elemsize); - ipc_table_size_t ipc_table_entries; const unsigned int ipc_table_entries_size = 512; diff --git a/ipc/ipc_table.h b/ipc/ipc_table.h index 695adae4..3cc5f561 100644 --- a/ipc/ipc_table.h +++ b/ipc/ipc_table.h @@ -108,6 +108,12 @@ extern void ipc_table_free( vm_size_t size, vm_offset_t table); +void ipc_table_fill( + ipc_table_size_t its, + unsigned int num, + unsigned int min, + vm_size_t elemsize); + #define it_entries_alloc(its) \ ((ipc_entry_t) \ ipc_table_alloc((its)->its_size * sizeof(struct ipc_entry))) -- cgit v1.2.3 From bf2393db5d814edf92dc9c6bd01dbb0511dc2519 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 29 Nov 2013 22:53:58 +0100 Subject: ipc/mach_msg.c: remove forward declarations * ipc/mach_msg.c: Include kern/exception.h. (exception_raise_continue, exception_raise_continue_fast): Remove forward declarations. * kern/exception.h: Include ipc/ipc_types.h. Include ipc/ipc_kmsg.h. --- ipc/mach_msg.c | 4 +--- kern/exception.h | 3 +++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ipc/mach_msg.c b/ipc/mach_msg.c index b83738b6..78247a4d 100644 --- a/ipc/mach_msg.c +++ b/ipc/mach_msg.c @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include @@ -61,9 +62,6 @@ #include #include -extern void exception_raise_continue(); -extern void exception_raise_continue_fast(); - /* * Routine: mach_msg_send * Purpose: diff --git a/kern/exception.h b/kern/exception.h index 8d4d79b2..55902dd1 100644 --- a/kern/exception.h +++ b/kern/exception.h @@ -19,6 +19,9 @@ #ifndef _KERN_EXCEPTION_H_ #define _KERN_EXCEPTION_H_ +#include +#include + extern void exception( integer_t _exception, -- cgit v1.2.3 From 072c63671c42b8ebcc3561b003bc087676be97fb Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 29 Nov 2013 22:53:59 +0100 Subject: kern/bootstrap.c: remove forward declarations * i386/i386/pcb.h: Include mach/thread_status.h. Include machine/thread.h. * kern/bootstrap.c: Include machine/pcb.h. (user_stack_low, set_user_regs): Remove forward declarations. --- i386/i386/pcb.h | 2 ++ kern/bootstrap.c | 4 +--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/i386/i386/pcb.h b/i386/i386/pcb.h index cea2fe23..4aad0b29 100644 --- a/i386/i386/pcb.h +++ b/i386/i386/pcb.h @@ -28,6 +28,8 @@ #include #include +#include +#include extern void pcb_init (thread_t thread); diff --git a/kern/bootstrap.c b/kern/bootstrap.c index a683ce91..41b02fee 100644 --- a/kern/bootstrap.c +++ b/kern/bootstrap.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -519,9 +520,6 @@ static void copy_bootstrap(void *e, exec_info_t *boot_exec_info) /* * Allocate the stack, and build the argument list. */ -extern vm_offset_t user_stack_low(); -extern vm_offset_t set_user_regs(); - static void build_args_and_stack(struct exec_info *boot_exec_info, char **argv, char **envp) -- cgit v1.2.3 From 016dba1c5e3aa0bfa24595978b296768844193bb Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 29 Nov 2013 22:54:00 +0100 Subject: kern/debug.c: remove forward declaration * kern/debug.c (cnputc): Remove forward declaration. Include device/cons.h. --- kern/debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kern/debug.c b/kern/debug.c index 33e64f33..e9427a3a 100644 --- a/kern/debug.c +++ b/kern/debug.c @@ -38,7 +38,7 @@ #include #include -extern void cnputc(); +#include #if MACH_KDB extern int db_breakpoints_inserted; -- cgit v1.2.3 From c1429f486d0c8af477fd01e76e08090e91ffc9bc Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 29 Nov 2013 22:54:01 +0100 Subject: kern/ipc_mig.c: remove forward declarations * device/ds_routines.h (ds_device_write_trap, ds_device_writev_trap): Add prototypes. * kern/ipc_mig.c (ds_device_write_trap, ds_device_writev_trap): Remove forward declarations. --- device/ds_routines.h | 13 +++++++++++++ kern/ipc_mig.c | 4 ---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/device/ds_routines.h b/device/ds_routines.h index 6d5b61c5..fad89acd 100644 --- a/device/ds_routines.h +++ b/device/ds_routines.h @@ -70,5 +70,18 @@ extern void dev_lookup_init(void); extern void device_pager_init(void); extern void io_done_thread(void); +io_return_t ds_device_write_trap( + device_t dev, + dev_mode_t mode, + recnum_t recnum, + vm_offset_t data, + vm_size_t count); + +io_return_t ds_device_writev_trap( + device_t dev, + dev_mode_t mode, + recnum_t recnum, + io_buf_vec_t *iovec, + vm_size_t count); #endif /* DS_ROUTINES_H */ diff --git a/kern/ipc_mig.c b/kern/ipc_mig.c index 3d48cb4a..20339a29 100644 --- a/kern/ipc_mig.c +++ b/kern/ipc_mig.c @@ -915,10 +915,6 @@ kern_return_t syscall_thread_depress_abort(thread) /* * Device traps -- these are way experimental. */ - -extern io_return_t ds_device_write_trap(); -extern io_return_t ds_device_writev_trap(); - io_return_t syscall_device_write_request(mach_port_t device_name, mach_port_t reply_name, -- cgit v1.2.3 From f7a65556ad6c395d5001bbc1a27b334715b40a85 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 29 Nov 2013 22:54:02 +0100 Subject: kern/processor.c: remove forward declarations * kern/processor.c (quantum_set, pset_init, processor_init): Remove forward declarations. * kern/processor.h (quantum_set, pset_init, processor_init): Add prototypes. --- kern/processor.c | 7 ------- kern/processor.h | 4 +++- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/kern/processor.c b/kern/processor.c index 0cb99742..865c3247 100644 --- a/kern/processor.c +++ b/kern/processor.c @@ -65,13 +65,6 @@ decl_simple_lock_data(, all_psets_lock); processor_t master_processor; processor_t processor_ptr[NCPUS]; -/* - * Forward declarations. - */ -void quantum_set(processor_set_t); -void pset_init(processor_set_t); -void processor_init(processor_t, int); - /* * Bootstrap the processor/pset system so the scheduler can run. */ diff --git a/kern/processor.h b/kern/processor.h index 7bd29cfc..b81526c0 100644 --- a/kern/processor.h +++ b/kern/processor.h @@ -321,7 +321,9 @@ extern kern_return_t processor_set_threads( #endif void processor_doaction(processor_t processor); - void processor_doshutdown(processor_t processor); +void quantum_set(processor_set_t pset); +void pset_init(processor_set_t pset); +void processor_init(processor_t pr, int slot_num); #endif /* _KERN_PROCESSOR_H_ */ -- cgit v1.2.3 From e7131e441628bf173eabd64d5498eebcdd533b69 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 29 Nov 2013 22:54:03 +0100 Subject: kern/sched_prim.c: remove forward declarations * kern/sched_prim.c (set_pri, do_thread_scan, choose_pset_thread, checkrq, thread_check): Remove forward declarations. * kern/sched_prim.h (set_pri, do_thread_scan, choose_pset_thread, checkrq, thread_check): Add prototypes. --- kern/sched_prim.c | 10 ---------- kern/sched_prim.h | 9 +++++++++ 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/kern/sched_prim.c b/kern/sched_prim.c index 29467011..c06cd770 100644 --- a/kern/sched_prim.c +++ b/kern/sched_prim.c @@ -70,18 +70,8 @@ int sched_usec; thread_t sched_thread_id; -void set_pri(thread_t, int, boolean_t); -void do_thread_scan(void); - -thread_t choose_pset_thread(); - timer_elt_data_t recompute_priorities_timer; -#if DEBUG -void checkrq(run_queue_t, char *); -void thread_check(thread_t, run_queue_t); -#endif - /* * State machine * diff --git a/kern/sched_prim.h b/kern/sched_prim.h index e08f5703..b7ecba7f 100644 --- a/kern/sched_prim.h +++ b/kern/sched_prim.h @@ -172,4 +172,13 @@ extern void stack_free( #define convert_ipc_timeout_to_ticks(millis) \ (((millis) * hz + 999) / 1000) +void set_pri(thread_t th, int pri, boolean_t resched); +void do_thread_scan(void); +thread_t choose_pset_thread(processor_t myprocessor, processor_set_t pset); + +#if DEBUG +void checkrq(run_queue_t rq, char *msg); +void thread_check(thread_t th, run_queue_t rq); +#endif /* DEBUG */ + #endif /* _KERN_SCHED_PRIM_H_ */ -- cgit v1.2.3 From 352e6c98625a080618a65001d29fa628737bd4d5 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 29 Nov 2013 22:54:04 +0100 Subject: kern/startup.c: remove forward declarations * Makefrag.am: Include kern/bootstrap.h. Include vm/vm_init.h. Include device/device_init.h. * device/device_init.h: New file. Add copyright. [_DEVICE_DEVICE_INIT_H_]: Add ifndef. (device_service_create): Add prototype. * i386/i386/mp_desc.h (start_other_cpus): Add prototype. * kern/bootstrap.h: New file. Add copyright. [_KERN_BOOTSTRAP_H_]: Add ifndef. (bootstrap_create): Add prototype. * kern/sched_prim.h (idle_thread, sched_thread): Add prototypes. * kern/startup.c: Include kern/bootstrap.h. Include kern/startup.h. Include vm/vm_init.h. Include vm/vm_pageout.h. Include device/device_init.h. (vm_mem_init, vm_mem_bootstrap, init_timeout, machine_init, idle_thread, vm_pageout, reaper_thread, swapin_thread, sched_thread, bootstrap_create, device_service_create, cpu_launch_first_thread, start_kernel_threads, start_other_cpus, action_thread): Remove forward declarations. [NCPUS > 1] Include machine/mp_desc.h and kern/machine.h. * kern/startup.h: Include kern/thread.h. (cpu_launch_first_thread, start_kernel_threads): Add prototypes. * vm/vm_init.h: New file. Add copyright. [_VM_VM_INIT_H_]: Add ifndef. (vm_mem_init, vm_mem_bootstrap): Add prototypes. * vm/vm_pageout.h (vm_pageout): Add prototype. --- Makefrag.am | 3 +++ device/device_init.h | 24 ++++++++++++++++++++++++ i386/i386/mp_desc.h | 2 ++ kern/bootstrap.h | 24 ++++++++++++++++++++++++ kern/sched_prim.h | 3 +++ kern/startup.c | 26 +++++++------------------- kern/startup.h | 4 ++++ vm/vm_init.h | 25 +++++++++++++++++++++++++ vm/vm_pageout.h | 2 ++ 9 files changed, 94 insertions(+), 19 deletions(-) create mode 100644 device/device_init.h create mode 100644 kern/bootstrap.h create mode 100644 vm/vm_init.h diff --git a/Makefrag.am b/Makefrag.am index 2d09b623..b3f9521c 100644 --- a/Makefrag.am +++ b/Makefrag.am @@ -135,6 +135,7 @@ libkernel_a_SOURCES += \ kern/ast.h \ kern/boot_script.h \ kern/bootstrap.c \ + kern/bootstrap.h \ kern/counters.c \ kern/counters.h \ kern/cpu_number.h \ @@ -247,6 +248,7 @@ libkernel_a_SOURCES += \ vm/vm_fault.c \ vm/vm_fault.h \ vm/vm_init.c \ + vm/vm_init.h \ vm/vm_kern.c \ vm/vm_kern.h \ vm/vm_map.c \ @@ -290,6 +292,7 @@ libkernel_a_SOURCES += \ device/dev_name.c \ device/dev_pager.c \ device/device_init.c \ + device/device_init.h \ device/device_port.h \ device/device_types_kernel.h \ device/ds_routines.c \ diff --git a/device/device_init.h b/device/device_init.h new file mode 100644 index 00000000..175b34d7 --- /dev/null +++ b/device/device_init.h @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2013 Free Software Foundation. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef _DEVICE_DEVICE_INIT_H_ +#define _DEVICE_DEVICE_INIT_H_ + +extern void device_service_create(void); + +#endif /* _DEVICE_DEVICE_INIT_H_ */ diff --git a/i386/i386/mp_desc.h b/i386/i386/mp_desc.h index 03d7194d..9f963123 100644 --- a/i386/i386/mp_desc.h +++ b/i386/i386/mp_desc.h @@ -79,4 +79,6 @@ extern struct mp_desc_table * mp_desc_init(int); #endif /* MULTIPROCESSOR */ +extern void start_other_cpus(void); + #endif /* _I386_MP_DESC_H_ */ diff --git a/kern/bootstrap.h b/kern/bootstrap.h new file mode 100644 index 00000000..b8ed8d9f --- /dev/null +++ b/kern/bootstrap.h @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2013 Free Software Foundation. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef _KERN_BOOTSTRAP_H_ +#define _KERN_BOOTSTRAP_H_ + +extern void bootstrap_create(void); + +#endif /* _KERN_BOOTSTRAP_H_ */ diff --git a/kern/sched_prim.h b/kern/sched_prim.h index b7ecba7f..07b5bf03 100644 --- a/kern/sched_prim.h +++ b/kern/sched_prim.h @@ -181,4 +181,7 @@ void checkrq(run_queue_t rq, char *msg); void thread_check(thread_t th, run_queue_t rq); #endif /* DEBUG */ +extern void idle_thread(void); +extern void sched_thread(void); + #endif /* _KERN_SCHED_PRIM_H_ */ diff --git a/kern/startup.c b/kern/startup.c index 22e99973..be83f6b4 100644 --- a/kern/startup.c +++ b/kern/startup.c @@ -47,45 +47,33 @@ #include #include #include +#include #include +#include #include #include #include #include +#include +#include #include #include #include #include #include +#include #if MACH_KDB #include #endif /* MACH_KDB */ -extern void vm_mem_init(); -extern void vm_mem_bootstrap(); -extern void init_timeout(); -extern void machine_init(); - -extern void idle_thread(); -extern void vm_pageout(); -extern void reaper_thread(); -extern void swapin_thread(); -extern void sched_thread(); - -extern void bootstrap_create(); -extern void device_service_create(); - -void cpu_launch_first_thread(); /* forward */ -void start_kernel_threads(); /* forward */ - #if ! MACH_KBD boolean_t reboot_on_panic = 1; #endif #if NCPUS > 1 -extern void start_other_cpus(); -extern void action_thread(); +#include +#include #endif /* NCPUS > 1 */ /* XX */ diff --git a/kern/startup.h b/kern/startup.h index d167fde2..d924d154 100644 --- a/kern/startup.h +++ b/kern/startup.h @@ -19,6 +19,10 @@ #ifndef _KERN_STARTUP_H_ #define _KERN_STARTUP_H_ +#include + extern void setup_main(void); +void cpu_launch_first_thread(thread_t th); +void start_kernel_threads(void); #endif /* _KERN_STARTUP_H_ */ diff --git a/vm/vm_init.h b/vm/vm_init.h new file mode 100644 index 00000000..42ef48b2 --- /dev/null +++ b/vm/vm_init.h @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2013 Free Software Foundation. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef _VM_VM_INIT_H_ +#define _VM_VM_INIT_H_ + +extern void vm_mem_init(void); +extern void vm_mem_bootstrap(void); + +#endif /* _VM_VM_INIT_H_ */ diff --git a/vm/vm_pageout.h b/vm/vm_pageout.h index d41ee30a..90e45a77 100644 --- a/vm/vm_pageout.h +++ b/vm/vm_pageout.h @@ -44,4 +44,6 @@ extern vm_page_t vm_pageout_setup(vm_page_t, vm_offset_t, vm_object_t, vm_offset_t, boolean_t); extern void vm_pageout_page(vm_page_t, boolean_t, boolean_t); +extern void vm_pageout(void); + #endif /* _VM_VM_PAGEOUT_H_ */ -- cgit v1.2.3 From 4360c7b7b58bc364a8521687a727ec136d00c770 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 29 Nov 2013 22:54:05 +0100 Subject: kern/syscall_subr.c: remove forward declaration * kern/syscall_subr.c (thread_depress_priority): Remove forward declaration. * kern/syscall_subr.h (thread_depress_priority): Add prototype. --- kern/syscall_subr.c | 3 --- kern/syscall_subr.h | 1 + 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/kern/syscall_subr.c b/kern/syscall_subr.c index 77ea8223..ed153ad4 100644 --- a/kern/syscall_subr.c +++ b/kern/syscall_subr.c @@ -63,9 +63,6 @@ * returned, the thread should make one more check on the * lock and then be a good citizen and really suspend. */ - -void thread_depress_priority(thread_t, mach_msg_timeout_t); - void swtch_continue(void) { processor_t myprocessor; diff --git a/kern/syscall_subr.h b/kern/syscall_subr.h index a2e39205..b6b61ab2 100644 --- a/kern/syscall_subr.h +++ b/kern/syscall_subr.h @@ -37,5 +37,6 @@ extern int thread_switch(mach_port_t, int, mach_msg_timeout_t); extern void thread_depress_timeout(thread_t); extern kern_return_t thread_depress_abort(thread_t); extern void mach_print(const char *); +extern void thread_depress_priority(thread_t thread, mach_msg_timeout_t depress_time); #endif /* _KERN_SYSCALL_SUBR_H_ */ -- cgit v1.2.3 From 34918f3816982301834a313f655e13804d6b8ac5 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 29 Nov 2013 22:54:06 +0100 Subject: kern/syscall_sw.c: remove forward declarations * kern/eventcount.h (evc_wait_clear): Add prototype. * kern/ipc_mig.h: Include device/device_types.h. (syscall_vm_map, syscall_vm_allocate, syscall_vm_deallocate, syscall_task_create, syscall_task_terminate, syscall_task_suspend, syscall_task_set_special_port, syscall_mach_port_allocate, syscall_mach_port_deallocate, syscall_mach_port_insert_right, syscall_mach_port_allocate_name, syscall_thread_depress_abort, syscall_device_write_request, syscall_device_writev_request): Add prototypes. * kern/syscall_sw.c (syscall_vm_map, syscall_vm_allocate, syscall_vm_deallocate, syscall_task_create, syscall_task_terminate, syscall_task_suspend, syscall_task_set_special_port, syscall_mach_port_allocate, syscall_mach_port_deallocate, syscall_mach_port_insert_right, syscall_mach_port_allocate_name, syscall_thread_depress_abort, evc_wait, evc_wait_clear, syscall_device_write_request, syscall_device_writev_request): Remove forward declarations. Include kern/ipc_mig.h. Include kern/eventcount.h. --- kern/eventcount.h | 1 + kern/ipc_mig.c | 1 + kern/ipc_mig.h | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ kern/syscall_sw.c | 23 ++--------------- 4 files changed, 81 insertions(+), 21 deletions(-) diff --git a/kern/eventcount.h b/kern/eventcount.h index 4a4125cf..f3ba0472 100644 --- a/kern/eventcount.h +++ b/kern/eventcount.h @@ -53,6 +53,7 @@ extern void evc_init(evc_t ev), /* kernel and user visible */ extern kern_return_t evc_wait(natural_t ev_id); +extern kern_return_t evc_wait_clear(natural_t ev_id); extern void evc_notify_abort (thread_t thread); diff --git a/kern/ipc_mig.c b/kern/ipc_mig.c index 20339a29..3cd0f886 100644 --- a/kern/ipc_mig.c +++ b/kern/ipc_mig.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include diff --git a/kern/ipc_mig.h b/kern/ipc_mig.h index f352bdc6..3e368ae7 100644 --- a/kern/ipc_mig.h +++ b/kern/ipc_mig.h @@ -27,6 +27,7 @@ #define _IPC_MIG_H_ #include +#include /* * Routine: mach_msg_send_from_kernel @@ -62,4 +63,80 @@ extern mach_msg_return_t mach_msg_rpc_from_kernel( mach_msg_size_t send_size, mach_msg_size_t reply_size); +extern kern_return_t syscall_vm_map( + mach_port_t target_map, + vm_offset_t *address, + vm_size_t size, + vm_offset_t mask, + boolean_t anywhere, + mach_port_t memory_object, + vm_offset_t offset, + boolean_t copy, + vm_prot_t cur_protection, + vm_prot_t max_protection, + vm_inherit_t inheritance); + +extern kern_return_t syscall_vm_allocate( + mach_port_t target_map, + vm_offset_t *address, + vm_size_t size, + boolean_t anywhere); + +extern kern_return_t syscall_vm_deallocate( + mach_port_t target_map, + vm_offset_t start, + vm_size_t size); + +extern kern_return_t syscall_task_create( + mach_port_t parent_task, + boolean_t inherit_memory, + mach_port_t *child_task); + +extern kern_return_t syscall_task_terminate(mach_port_t task); + +extern kern_return_t syscall_task_suspend(mach_port_t task); + +extern kern_return_t syscall_task_set_special_port( + mach_port_t task, + int which_port, + mach_port_t port_name); + +extern kern_return_t syscall_mach_port_allocate( + mach_port_t task, + mach_port_right_t right, + mach_port_t *namep); + +extern kern_return_t syscall_mach_port_deallocate( + mach_port_t task, + mach_port_t name); + +extern kern_return_t syscall_mach_port_insert_right( + mach_port_t task, + mach_port_t name, + mach_port_t right, + mach_msg_type_name_t rightType); + +extern kern_return_t syscall_mach_port_allocate_name( + mach_port_t task, + mach_port_right_t right, + mach_port_t name); + +extern kern_return_t syscall_thread_depress_abort(mach_port_t thread); + +extern io_return_t syscall_device_write_request( + mach_port_t device_name, + mach_port_t reply_name, + dev_mode_t mode, + recnum_t recnum, + vm_offset_t data, + vm_size_t data_count); + +io_return_t syscall_device_writev_request( + mach_port_t device_name, + mach_port_t reply_name, + dev_mode_t mode, + recnum_t recnum, + io_buf_vec_t *iovec, + vm_size_t iocount); + #endif /* _IPC_MIG_H_ */ diff --git a/kern/syscall_sw.c b/kern/syscall_sw.c index 607d843e..93974416 100644 --- a/kern/syscall_sw.c +++ b/kern/syscall_sw.c @@ -36,6 +36,8 @@ #include #include #include +#include +#include #include @@ -70,27 +72,6 @@ kern_return_t kern_invalid() return(KERN_INVALID_ARGUMENT); } -extern kern_return_t syscall_vm_map(); -extern kern_return_t syscall_vm_allocate(); -extern kern_return_t syscall_vm_deallocate(); - -extern kern_return_t syscall_task_create(); -extern kern_return_t syscall_task_terminate(); -extern kern_return_t syscall_task_suspend(); -extern kern_return_t syscall_task_set_special_port(); - -extern kern_return_t syscall_mach_port_allocate(); -extern kern_return_t syscall_mach_port_deallocate(); -extern kern_return_t syscall_mach_port_insert_right(); -extern kern_return_t syscall_mach_port_allocate_name(); - -extern kern_return_t syscall_thread_depress_abort(); -extern kern_return_t evc_wait(); -extern kern_return_t evc_wait_clear(); - -extern kern_return_t syscall_device_write_request(); -extern kern_return_t syscall_device_writev_request(); - mach_trap_t mach_trap_table[] = { MACH_TRAP(kern_invalid, 0), /* 0 */ /* Unix */ MACH_TRAP(kern_invalid, 0), /* 1 */ /* Unix */ -- cgit v1.2.3 From 4c427f351acb585bf06f63218cb8ced221d889e0 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 29 Nov 2013 22:54:07 +0100 Subject: kern/task.c: remove forward declarations * ipc/ipc_mqueue.h: Include ipc/ipc_kmsg_queue.h. * kern/ipc_kobject.h: Move includes into ifndef. * kern/syscall_emulation.h: Include kern/task.h. (eml_init, eml_task_reference, eml_task_deallocate): Add prototypes. * kern/task.c: Include kern/syscall_emulation.h. (eml_init, eml_task_reference, eml_task_deallocate): Remove forward declarations --- ipc/ipc_mqueue.h | 1 + kern/ipc_kobject.h | 5 ++--- kern/syscall_emulation.h | 6 ++++++ kern/task.c | 5 +---- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/ipc/ipc_mqueue.h b/ipc/ipc_mqueue.h index ef0f9425..f8a2f1e7 100644 --- a/ipc/ipc_mqueue.h +++ b/ipc/ipc_mqueue.h @@ -38,6 +38,7 @@ #include #include #include +#include #include #include diff --git a/kern/ipc_kobject.h b/kern/ipc_kobject.h index cb795741..606a66a9 100644 --- a/kern/ipc_kobject.h +++ b/kern/ipc_kobject.h @@ -36,13 +36,12 @@ * Declarations for letting a port represent a kernel object. */ -#include -#include - #ifndef _KERN_IPC_KOBJECT_H_ #define _KERN_IPC_KOBJECT_H_ #include +#include +#include typedef vm_offset_t ipc_kobject_t; diff --git a/kern/syscall_emulation.h b/kern/syscall_emulation.h index 501b0a83..bf20e441 100644 --- a/kern/syscall_emulation.h +++ b/kern/syscall_emulation.h @@ -33,6 +33,7 @@ #ifndef __ASSEMBLER__ #include #include +#include typedef vm_offset_t eml_routine_t; @@ -56,6 +57,11 @@ typedef vm_offset_t *emulation_vector_t; /* Variable-length array */ #define EML_MOD (err_kern|err_sub(2)) #define EML_BAD_TASK (EML_MOD|0x0001) #define EML_BAD_CNT (EML_MOD|0x0002) + +extern void eml_init(void); +extern void eml_task_reference(task_t task, task_t parent); +extern void eml_task_deallocate(task_t task); + #endif /* __ASSEMBLER__ */ #endif /* _KERN_SYSCALL_EMULATION_H_ */ diff --git a/kern/task.c b/kern/task.c index f62e47be..933a90e8 100644 --- a/kern/task.c +++ b/kern/task.c @@ -47,16 +47,13 @@ #include #include /* for thread_wakeup */ #include +#include #include /* for kernel_map, ipc_kernel_map */ #include /* for splsched */ task_t kernel_task = TASK_NULL; struct kmem_cache task_cache; -extern void eml_init(void); -extern void eml_task_reference(task_t, task_t); -extern void eml_task_deallocate(task_t); - void task_init(void) { kmem_cache_init(&task_cache, "task", sizeof(struct task), 0, -- cgit v1.2.3 From 55d31d595952e67e16f81f7ef60eda96fe577da4 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 29 Nov 2013 22:54:08 +0100 Subject: kern/thread.c: remove forward declaration * i386/i386/pcb.h (pcb_module_init): Add prototype. * kern/thread.c (pcb_module_init): Remove forward declaration. --- i386/i386/pcb.h | 2 ++ kern/thread.c | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/i386/i386/pcb.h b/i386/i386/pcb.h index 4aad0b29..b2e5f07b 100644 --- a/i386/i386/pcb.h +++ b/i386/i386/pcb.h @@ -80,4 +80,6 @@ extern thread_t Switch_context (thread_t old, void (*continuation)(), thread_t n extern void Thread_continue (void); +extern void pcb_module_init (void); + #endif /* _I386_PCB_H_ */ diff --git a/kern/thread.c b/kern/thread.c index 72324120..1414078a 100644 --- a/kern/thread.c +++ b/kern/thread.c @@ -74,8 +74,6 @@ struct kmem_cache thread_cache; queue_head_t reaper_queue; decl_simple_lock_data(, reaper_lock) -extern void pcb_module_init(void); - /* private */ struct thread thread_template; -- cgit v1.2.3 From 960c3f14be9def8cd11a0b9cedf7ef2cd68c43d1 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 29 Nov 2013 22:54:09 +0100 Subject: kern: remove forward declaration * kern/xpr.c (db_printf): Remove forward declaration. [MACH_KDB] Include ddb/db_output.h. --- kern/xpr.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kern/xpr.c b/kern/xpr.c index b482a12c..92b253c0 100644 --- a/kern/xpr.c +++ b/kern/xpr.c @@ -132,9 +132,8 @@ void xprinit(void) #if MACH_KDB #include +#include - -extern void db_printf(); extern jmp_buf_t *db_recover; /* -- cgit v1.2.3 From 4b17f665e5a83534361452eb5e4ab9aa1e54cd3b Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 29 Nov 2013 22:54:10 +0100 Subject: ipc/ipc_kmsg.h: update comment Struct ipc_kmsg_queue is not defined in kern/thread.h. * ipc/ipc_kmsg.h: Update comment. --- ipc/ipc_kmsg.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ipc/ipc_kmsg.h b/ipc/ipc_kmsg.h index 8867310d..07695fb5 100644 --- a/ipc/ipc_kmsg.h +++ b/ipc/ipc_kmsg.h @@ -140,8 +140,7 @@ MACRO_BEGIN \ MACRO_END /* - * struct ipc_kmsg_queue is defined in kern/thread.h instead of here, - * so that kern/thread.h doesn't have to include ipc/ipc_kmsg.h. + * struct ipc_kmsg_queue is defined in ipc/ipc_kmsg_queue.h */ #include -- cgit v1.2.3 From 032745204b45ef69ec382526bca206674d9d84de Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 29 Nov 2013 22:54:12 +0100 Subject: vm/vm_fault.c: remove forward declaration * vm/vm_fault.c (vm_fault_wire_fast): Remove forward declaration. * vm/vm_fault.h (vm_fault_wire_fast): Add prototype. --- vm/vm_fault.c | 2 -- vm/vm_fault.h | 6 ++++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/vm/vm_fault.c b/vm/vm_fault.c index d0c7f968..96c83873 100644 --- a/vm/vm_fault.c +++ b/vm/vm_fault.c @@ -1495,8 +1495,6 @@ kern_return_t vm_fault(map, vaddr, fault_type, change_wiring, return(kr); } -kern_return_t vm_fault_wire_fast(); - /* * vm_fault_wire: * diff --git a/vm/vm_fault.h b/vm/vm_fault.h index 0492ccf4..7fdbc417 100644 --- a/vm/vm_fault.h +++ b/vm/vm_fault.h @@ -69,4 +69,10 @@ extern void vm_fault_unwire(vm_map_t, vm_map_entry_t); extern kern_return_t vm_fault_copy(vm_object_t, vm_offset_t, vm_size_t *, vm_object_t, vm_offset_t, vm_map_t, vm_map_version_t *, boolean_t); + +kern_return_t vm_fault_wire_fast( + vm_map_t map, + vm_offset_t va, + vm_map_entry_t entry); + #endif /* _VM_VM_FAULT_H_ */ -- cgit v1.2.3 From 65e3849ec757c8764ef0549c8e494230155312d7 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 29 Nov 2013 22:54:13 +0100 Subject: vm/vm_kern.c: remove forward declarations * vm/vm_kern.c (kmem_alloc_pages, kmem_remap_pages): Remove forward declarations. * vm/vm_kern.h (kmem_alloc_pages, kmem_remap_pages): Add prototypes. --- vm/vm_kern.c | 3 --- vm/vm_kern.h | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/vm/vm_kern.c b/vm/vm_kern.c index ddbe555e..7e377ef3 100644 --- a/vm/vm_kern.c +++ b/vm/vm_kern.c @@ -62,9 +62,6 @@ static struct vm_map kernel_map_store; vm_map_t kernel_map = &kernel_map_store; vm_map_t kernel_pageable_map; -extern void kmem_alloc_pages(); -extern void kmem_remap_pages(); - /* * projected_buffer_allocate * diff --git a/vm/vm_kern.h b/vm/vm_kern.h index 22b7c123..0869217a 100644 --- a/vm/vm_kern.h +++ b/vm/vm_kern.h @@ -82,4 +82,18 @@ extern boolean_t projected_buffer_in_range( vm_offset_t start, vm_offset_t end); +extern void kmem_alloc_pages( + vm_object_t object, + vm_offset_t offset, + vm_offset_t start, + vm_offset_t end, + vm_prot_t protection); + +extern void kmem_remap_pages( + vm_object_t object, + vm_offset_t offset, + vm_offset_t start, + vm_offset_t end, + vm_prot_t protection); + #endif /* _VM_VM_KERN_H_ */ -- cgit v1.2.3 From 716beea2840054c8b64f5436379c949a9a43c6cc Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 29 Nov 2013 22:54:14 +0100 Subject: vm/vm_map.c: remove forward declarations * vm/vm_map.c (_vm_map_clip_start, _vm_map_copy_clip_start, _vm_map_clip_end, _vm_map_copy_clip_end): Remove forward declarations. * vm/vm_map.h (_vm_map_clip_end): Correct prototype. --- vm/vm_map.c | 4 ---- vm/vm_map.h | 5 ++++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/vm/vm_map.c b/vm/vm_map.c index 6e4544a3..914741ec 100644 --- a/vm/vm_map.c +++ b/vm/vm_map.c @@ -1031,14 +1031,12 @@ kern_return_t vm_map_enter( * the specified address; if necessary, * it splits the entry into two. */ -void _vm_map_clip_start(); #define vm_map_clip_start(map, entry, startaddr) \ MACRO_BEGIN \ if ((startaddr) > (entry)->vme_start) \ _vm_map_clip_start(&(map)->hdr,(entry),(startaddr)); \ MACRO_END -void _vm_map_copy_clip_start(); #define vm_map_copy_clip_start(copy, entry, startaddr) \ MACRO_BEGIN \ if ((startaddr) > (entry)->vme_start) \ @@ -1086,14 +1084,12 @@ void _vm_map_clip_start(map_header, entry, start) * the specified address; if necessary, * it splits the entry into two. */ -void _vm_map_clip_end(); #define vm_map_clip_end(map, entry, endaddr) \ MACRO_BEGIN \ if ((endaddr) < (entry)->vme_end) \ _vm_map_clip_end(&(map)->hdr,(entry),(endaddr)); \ MACRO_END -void _vm_map_copy_clip_end(); #define vm_map_copy_clip_end(copy, entry, endaddr) \ MACRO_BEGIN \ if ((endaddr) < (entry)->vme_end) \ diff --git a/vm/vm_map.h b/vm/vm_map.h index 19317ac7..b6bc177a 100644 --- a/vm/vm_map.h +++ b/vm/vm_map.h @@ -555,6 +555,9 @@ extern void _vm_map_clip_start( * the specified address; if necessary, * it splits the entry into two. */ -void _vm_map_clip_end(); +void _vm_map_clip_end( + struct vm_map_header *map_header, + vm_map_entry_t entry, + vm_offset_t end); #endif /* _VM_VM_MAP_H_ */ -- cgit v1.2.3 From 4cdc3589095af39ab09939195d420ac1a497af72 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 29 Nov 2013 22:54:16 +0100 Subject: vm/vm_resident.c: correct comment This is vm_resident.c, not vm_page.c. * vm/vm_resident.c: Correct comment. --- vm/vm_resident.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vm/vm_resident.c b/vm/vm_resident.c index fbd42750..f0f31f6b 100644 --- a/vm/vm_resident.c +++ b/vm/vm_resident.c @@ -27,7 +27,7 @@ * the rights to redistribute these changes. */ /* - * File: vm/vm_page.c + * File: vm/vm_resident.c * Author: Avadis Tevanian, Jr., Michael Wayne Young * * Resident memory management module. -- cgit v1.2.3 From 3fe3459635ff68572a2066083868253b989fa590 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 29 Nov 2013 22:54:17 +0100 Subject: vm/vm_user.c: remove forward declaration * vm/vm_user.c (vm_map_machine_attribute): Remove forward declaration. --- vm/vm_user.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/vm/vm_user.c b/vm/vm_user.c index c18baf23..f721e87d 100644 --- a/vm/vm_user.c +++ b/vm/vm_user.c @@ -224,8 +224,6 @@ kern_return_t vm_machine_attribute(map, address, size, attribute, value) vm_machine_attribute_t attribute; vm_machine_attribute_val_t* value; /* IN/OUT */ { - extern kern_return_t vm_map_machine_attribute(); - if (map == VM_MAP_NULL) return(KERN_INVALID_ARGUMENT); -- cgit v1.2.3 From 1f5907e551b3a9f31f72ab20e8c4db0339cc704a Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Thu, 5 Dec 2013 06:55:52 +0900 Subject: Remove unnecessary file * i386/Makefrag.am: Don't include i386/include/mach/i386/rpc.h. * i386/include/mach/i386/rpc.h: Remove file. --- i386/Makefrag.am | 1 - i386/include/mach/i386/rpc.h | 9 --------- include/mach/rpc.h | 1 - 3 files changed, 11 deletions(-) delete mode 100644 i386/include/mach/i386/rpc.h diff --git a/i386/Makefrag.am b/i386/Makefrag.am index 76aa5385..160ae17a 100644 --- a/i386/Makefrag.am +++ b/i386/Makefrag.am @@ -229,7 +229,6 @@ include_mach_i386_HEADERS = \ i386/include/mach/i386/mach_i386_types.h \ i386/include/mach/i386/machine_types.defs \ i386/include/mach/i386/multiboot.h \ - i386/include/mach/i386/rpc.h \ i386/include/mach/i386/syscall_sw.h \ i386/include/mach/i386/thread_status.h \ i386/include/mach/i386/trap.h \ diff --git a/i386/include/mach/i386/rpc.h b/i386/include/mach/i386/rpc.h deleted file mode 100644 index 71d31fb9..00000000 --- a/i386/include/mach/i386/rpc.h +++ /dev/null @@ -1,9 +0,0 @@ - -struct rpc_csig_action -{ -}; - -struct rpc_csig_entry -{ -}; - diff --git a/include/mach/rpc.h b/include/mach/rpc.h index d3098f80..36eb5921 100644 --- a/include/mach/rpc.h +++ b/include/mach/rpc.h @@ -21,7 +21,6 @@ #include #include -#include /* * Description of a port passed up by the leaky-register RPC path -- cgit v1.2.3 From e9ba474a0db66435be8386876a5a2d75adcba274 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 29 Nov 2013 22:54:23 +0100 Subject: kern/time_stamp.c: remove multimax code * kern/time_stamp.c [multimax]: Remove code. --- kern/time_stamp.c | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/kern/time_stamp.c b/kern/time_stamp.c index 22885b18..9adfc145 100644 --- a/kern/time_stamp.c +++ b/kern/time_stamp.c @@ -32,28 +32,16 @@ /* * ts.c - kern_timestamp system call. */ -#ifdef multimax -#include -#endif /* multimax */ - - - kern_return_t kern_timestamp(tsp) struct tsval *tsp; { -#ifdef multimax - struct tsval temp; - temp.low_val = FRcounter; - temp.high_val = 0; -#else /* multimax */ /* temp.low_val = 0; temp.high_val = ts_tick_count; */ time_value_t temp; temp = time; -#endif /* multimax */ if (copyout((char *)&temp, (char *)tsp, @@ -68,8 +56,5 @@ struct tsval *tsp; void timestamp_init() { -#ifdef multimax -#else /* multimax */ ts_tick_count = 0; -#endif /* multimax */ } -- cgit v1.2.3 From 922f4c2f0501a34f3914bfb9c7ca605031d99682 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 29 Nov 2013 22:54:27 +0100 Subject: i386/i386at/model_dep.c: remove forward declaration * i386/i386at/model_dep.c (init_alloc_aligned): Remove forward declaration. * i386/i386at/model_dep.h (init_alloc_aligned): Add prototype. --- i386/i386at/model_dep.c | 2 -- i386/i386at/model_dep.h | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/i386/i386at/model_dep.c b/i386/i386at/model_dep.c index 21f6186c..f0d49f45 100644 --- a/i386/i386at/model_dep.c +++ b/i386/i386at/model_dep.c @@ -136,8 +136,6 @@ vm_offset_t int_stack_top, int_stack_high; extern void linux_init(void); #endif -boolean_t init_alloc_aligned(vm_size_t size, vm_offset_t *addrp); - /* * Find devices. The system is alive. */ diff --git a/i386/i386at/model_dep.h b/i386/i386at/model_dep.h index 65dc00bd..73573140 100644 --- a/i386/i386at/model_dep.h +++ b/i386/i386at/model_dep.h @@ -35,4 +35,6 @@ extern void halt_all_cpus (boolean_t reboot) __attribute__ ((noreturn)); void inittodr(void); +boolean_t init_alloc_aligned(vm_size_t size, vm_offset_t *addrp); + #endif /* _MODEL_DEP_H_ */ -- cgit v1.2.3 From e04c5b38f743c1c76b7511aad04382c3a4a870da Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 29 Nov 2013 22:54:28 +0100 Subject: ipc/ipc_entry.c: remove forward declaration * ipc/ipc_entry.c (db_ipc_object_by_name): Remove forward declaration. * ipc/ipc_entry.h (db_ipc_object_by_name): Add prototype. --- ipc/ipc_entry.c | 5 ----- ipc/ipc_entry.h | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ipc/ipc_entry.c b/ipc/ipc_entry.c index 3a062447..6cb1cfb6 100644 --- a/ipc/ipc_entry.c +++ b/ipc/ipc_entry.c @@ -839,11 +839,6 @@ ipc_entry_grow_table(space) #define printf kdbprintf -ipc_entry_t db_ipc_object_by_name( - task_t task, - mach_port_t name); - - ipc_entry_t db_ipc_object_by_name( task_t task, diff --git a/ipc/ipc_entry.h b/ipc/ipc_entry.h index 6afa4f68..cb6d3f9f 100644 --- a/ipc/ipc_entry.h +++ b/ipc/ipc_entry.h @@ -153,4 +153,9 @@ ipc_entry_dealloc(ipc_space_t space, mach_port_t name, ipc_entry_t entry); extern kern_return_t ipc_entry_grow_table(ipc_space_t space); +ipc_entry_t +db_ipc_object_by_name( + task_t task, + mach_port_t name); + #endif /* _IPC_IPC_ENTRY_H_ */ -- cgit v1.2.3 From 1f59548942a9c029154703374e9a65c289cc6783 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 29 Nov 2013 22:54:29 +0100 Subject: ipc/mach_port.c: remove forward declaration * ipc/mach_port.c (mach_port_get_receive_status): Remove forward declaration. * ipc/mach_port.h (mach_port_get_receive_status): Add prototype. --- ipc/mach_port.c | 2 -- ipc/mach_port.h | 6 ++++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ipc/mach_port.c b/ipc/mach_port.c index 46cb4de4..f0f00d29 100644 --- a/ipc/mach_port.c +++ b/ipc/mach_port.c @@ -758,8 +758,6 @@ mach_port_mod_refs( * KERN_INVALID_RIGHT Name doesn't denote receive rights. */ -kern_return_t -mach_port_get_receive_status(ipc_space_t, mach_port_t, mach_port_status_t *); kern_return_t old_mach_port_get_receive_status(space, name, statusp) ipc_space_t space; diff --git a/ipc/mach_port.h b/ipc/mach_port.h index 4116989f..c4d9a1c3 100644 --- a/ipc/mach_port.h +++ b/ipc/mach_port.h @@ -59,4 +59,10 @@ mach_port_insert_right( ipc_port_t poly, mach_msg_type_name_t polyPoly); +kern_return_t +mach_port_get_receive_status( + ipc_space_t space, + mach_port_t name, + mach_port_status_t *statusp); + #endif /* _IPC_MACH_PORT_H_ */ -- cgit v1.2.3 From 16fda8b0bf4a05a35bdeaa798ff8432461634827 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 29 Nov 2013 22:54:30 +0100 Subject: kern/mach_clock.c: remove forward declaration * Makefrag.am: Include kern/priority.h. * kern/mach_clock.c (thread_quantum_update): Remove forward declaration. Include kern/priority.h. * kern/priority.h: New file. Add copyright. [_KERN_PRIORITY_H_]: Add ifndef. (thread_quantum_update): Add prototype. --- Makefrag.am | 1 + kern/mach_clock.c | 2 +- kern/priority.h | 28 ++++++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 kern/priority.h diff --git a/Makefrag.am b/Makefrag.am index b3f9521c..39da40db 100644 --- a/Makefrag.am +++ b/Makefrag.am @@ -175,6 +175,7 @@ libkernel_a_SOURCES += \ kern/printf.c \ kern/printf.h \ kern/priority.c \ + kern/priority.h \ kern/processor.c \ kern/processor.h \ kern/profile.c \ diff --git a/kern/mach_clock.c b/kern/mach_clock.c index 844e7b37..29a14c9d 100644 --- a/kern/mach_clock.c +++ b/kern/mach_clock.c @@ -54,6 +54,7 @@ #include #include #include +#include #include #include #include /* HZ */ @@ -148,7 +149,6 @@ void clock_interrupt(usec, usermode, basepri) * Increment the CPU time statistics. */ { - extern void thread_quantum_update(); /* in priority.c */ int state; if (usermode) diff --git a/kern/priority.h b/kern/priority.h new file mode 100644 index 00000000..2da93ebe --- /dev/null +++ b/kern/priority.h @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2013 Free Software Foundation. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef _KERN_PRIORITY_H_ +#define _KERN_PRIORITY_H_ + +extern void thread_quantum_update( + int mycpu, + thread_t thread, + int nticks, + int state); + +#endif /* _KERN_PRIORITY_H_ */ -- cgit v1.2.3 From 1156497c0ae4e18db9333901bbdd559b30099ae5 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 29 Nov 2013 22:54:31 +0100 Subject: ddb/db_variables.c: fix near initialization * ddb/db_task_thread.c (db_set_default_thread): New parameter. * ddb/db_task_thread.h (db_set_default_thread): Likewise. --- ddb/db_task_thread.c | 3 ++- ddb/db_task_thread.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ddb/db_task_thread.c b/ddb/db_task_thread.c index 21ec3dd4..f420b8d9 100644 --- a/ddb/db_task_thread.c +++ b/ddb/db_task_thread.c @@ -246,10 +246,11 @@ db_init_default_thread(void) */ /* ARGSUSED */ void -db_set_default_thread(vp, valuep, flag) +db_set_default_thread(vp, valuep, flag, ap) struct db_variable *vp; db_expr_t *valuep; int flag; + db_var_aux_param_t ap; { thread_t thread; diff --git a/ddb/db_task_thread.h b/ddb/db_task_thread.h index 0c7fafa1..e6ae114a 100644 --- a/ddb/db_task_thread.h +++ b/ddb/db_task_thread.h @@ -54,7 +54,8 @@ extern void db_set_default_thread( struct db_variable *vp, db_expr_t *valuep, - int flag); + int flag, + db_var_aux_param_t ap); extern void db_get_task_thread( -- cgit v1.2.3 From 7e80700cd73d0e581543e8f1361d7d9469d5ae08 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 29 Nov 2013 22:54:33 +0100 Subject: i386/i386at/com.h: include chips/busses.h for struct bus_device * i386/i386at/com.h: Include chips/busses.h. --- i386/i386at/com.h | 1 + 1 file changed, 1 insertion(+) diff --git a/i386/i386at/com.h b/i386/i386at/com.h index 475fa699..ae9434d1 100644 --- a/i386/i386at/com.h +++ b/i386/i386at/com.h @@ -29,6 +29,7 @@ #include #include #include +#include /* * Set receive modem state from modem status register. -- cgit v1.2.3 From fc4381de43acbf602e30ab31f73e47230caf2638 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Thu, 5 Dec 2013 07:17:01 +0900 Subject: Add missing include * ddb/db_variables.h: Include . --- ddb/db_variables.h | 1 + 1 file changed, 1 insertion(+) diff --git a/ddb/db_variables.h b/ddb/db_variables.h index 533c0645..934a61f5 100644 --- a/ddb/db_variables.h +++ b/ddb/db_variables.h @@ -32,6 +32,7 @@ #define _DB_VARIABLES_H_ #include +#include /* * Debugger variables. -- cgit v1.2.3 From 5eb7693cd909511308b6c2828686d51375a3506a Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sat, 30 Nov 2013 11:16:01 +0100 Subject: Add comments after endifs * device/cons.c [MACH_KMSG]: Likewise. [CONSBUFSIZE > 0]: Likewise. * i386/i386/trap.c [MACH_KDB]: Likewise. [MACH_PV_PAGETABLES]: Likewise. * i386/i386at/kd.c [ENABLE_IMMEDIATE_CONSOLE]: Likewise. * ipc/ipc_kmsg_queue.h [_IPC_KMSG_QUEUE_H_]: Likewise. * kern/act.c [ACTWATCH]: Likewise. * kern/refcount.h [MACHINE_REFCOUNT]: Likewise. * kern/task.c [FAST_TAS]: Likewise. --- device/cons.c | 8 ++++---- i386/i386/trap.c | 8 ++++---- i386/i386at/kd.c | 2 +- ipc/ipc_kmsg_queue.h | 2 +- kern/act.c | 2 +- kern/refcount.h | 2 +- kern/task.c | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/device/cons.c b/device/cons.c index ceba7f24..b35e79f4 100644 --- a/device/cons.c +++ b/device/cons.c @@ -30,7 +30,7 @@ #ifdef MACH_KMSG #include #include -#endif +#endif /* MACH_KMSG */ static boolean_t cn_inited = FALSE; static struct consdev *cn_tab = 0; /* physical console device info */ @@ -55,7 +55,7 @@ void (*romputc)() = 0; static char consbuf[CONSBUFSIZE] = { 0 }; static char *consbp = consbuf; static boolean_t consbufused = FALSE; -#endif +#endif /* CONSBUFSIZE > 0 */ void cninit() @@ -108,7 +108,7 @@ cninit() } while (cbp != consbp); consbufused = FALSE; } -#endif +#endif /* CONSBUFSIZE > 0 */ cn_inited = TRUE; return; } @@ -180,5 +180,5 @@ cnputc(c) if (consbp >= &consbuf[CONSBUFSIZE]) consbp = consbuf; } -#endif +#endif /* CONSBUFSIZE > 0 */ } diff --git a/i386/i386/trap.c b/i386/i386/trap.c index e104e122..ccbc94cc 100644 --- a/i386/i386/trap.c +++ b/i386/i386/trap.c @@ -400,7 +400,7 @@ printf("user trap %d error %d sub %08x\n", type, code, subcode); if (kdb_trap(type, regs->err, regs)) return 0; } -#endif +#endif /* MACH_KDB */ exc = EXC_BREAKPOINT; code = EXC_I386_SGL; break; @@ -422,7 +422,7 @@ printf("user trap %d error %d sub %08x\n", type, code, subcode); return 0; } } -#endif +#endif /* MACH_KDB */ exc = EXC_BREAKPOINT; code = EXC_I386_BPT; break; @@ -521,7 +521,7 @@ printf("user trap %d error %d sub %08x\n", type, code, subcode); } return 0; } -#endif +#endif /* MACH_PV_PAGETABLES */ case T_FLOATING_POINT_ERROR: fpexterrflt(); @@ -647,4 +647,4 @@ interrupted_pc(t) iss = USER_REGS(t); return iss->eip; } -#endif /* MACH_PCSAMPLE > 0*/ +#endif /* MACH_PCSAMPLE > 0 */ diff --git a/i386/i386at/kd.c b/i386/i386at/kd.c index 5605257f..def8a0ce 100644 --- a/i386/i386at/kd.c +++ b/i386/i386at/kd.c @@ -1197,7 +1197,7 @@ kdinit() screen rather than at the cursor position, so that's where we should start. */ kd_setpos(ONE_PAGE - ONE_LINE); printf("\n"); -#endif +#endif /* ENABLE_IMMEDIATE_CONSOLE */ cnsetleds(kd_state = KS_NORMAL); /* clear the LEDs AFTER we diff --git a/ipc/ipc_kmsg_queue.h b/ipc/ipc_kmsg_queue.h index 51ccbe24..b4b3df1d 100644 --- a/ipc/ipc_kmsg_queue.h +++ b/ipc/ipc_kmsg_queue.h @@ -27,5 +27,5 @@ #define _IPC_KMSG_QUEUE_H_ struct ipc_kmsg_queue { struct ipc_kmsg *ikmq_base; }; -#endif +#endif /* _IPC_KMSG_QUEUE_H_ */ diff --git a/kern/act.c b/kern/act.c index 321ff98d..d76fe0ef 100644 --- a/kern/act.c +++ b/kern/act.c @@ -1114,6 +1114,6 @@ get_next_act(sp) return act; } } -#endif +#endif /* ACTWATCH */ #endif /* MIGRATING_THREADS */ diff --git a/kern/refcount.h b/kern/refcount.h index 7fd6cdfb..c5275477 100644 --- a/kern/refcount.h +++ b/kern/refcount.h @@ -65,6 +65,6 @@ typedef struct RefCount RefCount; if (new_value == 0) { func; } \ MACRO_END -#endif +#endif /* MACHINE_REFCOUNT */ #endif _KERN_REFCOUNT_H_ diff --git a/kern/task.c b/kern/task.c index 933a90e8..8fe3672f 100644 --- a/kern/task.c +++ b/kern/task.c @@ -1206,6 +1206,6 @@ task_ras_control( break; } task_unlock(task); -#endif +#endif /* FAST_TAS */ return ret; } -- cgit v1.2.3 From 3ff76bcbb9853054a91f6292da85d3dad47382fe Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sat, 30 Nov 2013 11:16:02 +0100 Subject: Add ifndefs * i386/i386at/cram.h [_CRAM_H_]: Add ifndef. * i386/i386at/disk.h [_DISK_H_]: Likewise. * i386/i386at/i8250.h [_I8250_H_]: Likewise. * i386/include/mach/i386/asm.h [_MACH_I386_ASM_H_]: Likewise. * i386/include/mach/i386/disk.h [_MACH_I386_DISK_H_]: Likewise. --- i386/i386at/cram.h | 4 ++++ i386/i386at/disk.h | 4 ++++ i386/i386at/i8250.h | 5 +++++ i386/include/mach/i386/asm.h | 4 ++++ i386/include/mach/i386/disk.h | 4 ++++ 5 files changed, 21 insertions(+) diff --git a/i386/i386at/cram.h b/i386/i386at/cram.h index 8373ce03..40f3f0a5 100644 --- a/i386/i386at/cram.h +++ b/i386/i386at/cram.h @@ -50,6 +50,9 @@ NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUR OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef _CRAM_H_ +#define _CRAM_H_ + /* * outb(CMOS_ADDR, addr); * result = inb(CMOS_DATA); @@ -73,3 +76,4 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #define CM_CGA_80 0x20 #define CM_MONO_80 0x30 +#endif /* _CRAM_H_ */ diff --git a/i386/i386at/disk.h b/i386/i386at/disk.h index e1fe6b98..63d033f0 100644 --- a/i386/i386at/disk.h +++ b/i386/i386at/disk.h @@ -49,6 +49,9 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * disk.h */ +#ifndef _DISK_H_ +#define _DISK_H_ + /* Grab the public part. */ #include @@ -184,3 +187,4 @@ struct mboot { /* master boot block */ u_short signature; }; +#endif /* _DISK_H_ */ diff --git a/i386/i386at/i8250.h b/i386/i386at/i8250.h index fa81173e..9b8a8019 100644 --- a/i386/i386at/i8250.h +++ b/i386/i386at/i8250.h @@ -49,6 +49,9 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * Header file for i8250 chip */ +#ifndef _I8250_H_ +#define _I8250_H_ + /* port offsets from the base i/o address */ #define RDAT 0 @@ -127,3 +130,5 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #define BCNT2400 0x30 #define BCNT4800 0x18 #define BCNT9600 0x0c + +#endif /* _I8250_H_ */ diff --git a/i386/include/mach/i386/asm.h b/i386/include/mach/i386/asm.h index 3e3f48bf..4e3b589a 100644 --- a/i386/include/mach/i386/asm.h +++ b/i386/include/mach/i386/asm.h @@ -24,6 +24,8 @@ * the rights to redistribute these changes. */ +#ifndef _MACH_I386_ASM_H_ +#define _MACH_I386_ASM_H_ #define S_ARG0 4(%esp) #define S_ARG1 8(%esp) @@ -113,3 +115,5 @@ #define Entry(x) .globl EXT(x); .p2align TEXT_ALIGN; LEXT(x) #define DATA(x) .globl EXT(x); .p2align DATA_ALIGN; LEXT(x) + +#endif /* _MACH_I386_ASM_H_ */ diff --git a/i386/include/mach/i386/disk.h b/i386/include/mach/i386/disk.h index 40ed4fa8..1bbbbdf3 100644 --- a/i386/include/mach/i386/disk.h +++ b/i386/include/mach/i386/disk.h @@ -49,6 +49,9 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * disk.h */ +#ifndef _MACH_I386_DISK_H_ +#define _MACH_I386_DISK_H_ + #if defined(__linux__) || defined(__masix__) #define PART_DISK 4 /* partition number for entire disk */ #else @@ -118,3 +121,4 @@ struct absio { char *abs_buf; /* Sector buffer */ }; +#endif /* _MACH_I386_DISK_H_ */ -- cgit v1.2.3 From 6fbdbc6d7fe591592d32328a0066d3908143d6d4 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sun, 1 Dec 2013 15:41:16 +0100 Subject: device/device_types_kernel.h: remove redeclaration of dev_port_lookup() * device/device_types_kernel.h (dev_port_lookup): Remove prototype. --- device/device_types_kernel.h | 1 - 1 file changed, 1 deletion(-) diff --git a/device/device_types_kernel.h b/device/device_types_kernel.h index 87ce00f5..e17055c1 100644 --- a/device/device_types_kernel.h +++ b/device/device_types_kernel.h @@ -38,7 +38,6 @@ #include #include -extern device_t dev_port_lookup(ipc_port_t); extern ipc_port_t convert_device_to_port(device_t); #endif /* _DEVICE_DEVICE_TYPES_KERNEL_H_ */ -- cgit v1.2.3 From be841794c557bbddea42164dbd3bb54b7506e7c5 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 8 Dec 2013 23:11:35 +0900 Subject: Fix implicit declaration of function Thanks Marin Ramesa for the report. * device/ds_routines.h (device_deallocate): Move declaration to... * include/device/device_types.h (device_deallocate): ... here. --- device/ds_routines.h | 1 - include/device/device_types.h | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/device/ds_routines.h b/device/ds_routines.h index fad89acd..497b6ac1 100644 --- a/device/ds_routines.h +++ b/device/ds_routines.h @@ -49,7 +49,6 @@ kern_return_t device_read_alloc(io_req_t, vm_size_t); kern_return_t device_write_get(io_req_t, boolean_t *); boolean_t device_write_dealloc(io_req_t); void device_reference(device_t); -void device_deallocate(device_t); boolean_t ds_notify(mach_msg_header_t *msg); boolean_t ds_open_done(io_req_t); diff --git a/include/device/device_types.h b/include/device/device_types.h index caf4fc04..a6db051e 100644 --- a/include/device/device_types.h +++ b/include/device/device_types.h @@ -135,4 +135,6 @@ typedef int io_return_t; #define D_NO_MEMORY 2508 /* memory allocation failure */ #define D_READ_ONLY 2509 /* device cannot be written to */ +void device_deallocate(device_t); + #endif /* DEVICE_TYPES_H */ -- cgit v1.2.3 From 4dc587e9bd3e5e1a44df36e29c22645a074ae68f Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 8 Dec 2013 23:20:19 +0900 Subject: Always make Assert trigger debugger * kern/debug.c (Assert): Always call Debugger, even if db_breakpoints_insert is not set. --- kern/debug.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/kern/debug.c b/kern/debug.c index e9427a3a..2530fa6a 100644 --- a/kern/debug.c +++ b/kern/debug.c @@ -40,10 +40,6 @@ #include -#if MACH_KDB -extern int db_breakpoints_inserted; -#endif - #if NCPUS>1 simple_lock_data_t Assert_print_lock; /* uninited, we take our chances */ #endif @@ -67,9 +63,6 @@ Assert(char *exp, char *file, int line) exp, file, line); #endif -#if MACH_KDB - if (db_breakpoints_inserted) -#endif Debugger("assertion failure"); } -- cgit v1.2.3 From c73aec9cc3b7f299ebf7a66f6bb34a7fa5d978f6 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 8 Dec 2013 23:24:29 +0900 Subject: Make unsigned character constants unsigned Thanks Marin Ramesa for the report. * i386/i386at/kd.h (K_DONE, NC, K_SCAN): Make constants unsigned. --- i386/i386at/kd.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/i386/i386at/kd.h b/i386/i386at/kd.h index d97fdd5e..9d297d16 100644 --- a/i386/i386at/kd.h +++ b/i386/i386at/kd.h @@ -361,10 +361,10 @@ typedef u_char Scancode; * Other mappable non-Ascii keys (e.g., "ctrl") are represented by a * two-byte sequence: K_SCAN, followed by the key's scan code. */ -#define K_DONE 0xff /* must be same as NC */ -#define NC 0xff /* No character defined */ +#define K_DONE 0xffu /* must be same as NC */ +#define NC 0xffu /* No character defined */ -#define K_SCAN 0xfe /* followed by scan code */ +#define K_SCAN 0xfeu /* followed by scan code */ /* ascii char set */ #define K_NUL 0x00 /* Null character */ -- cgit v1.2.3 From cda5e793560d852afa34db48a4894d59ae4d5b79 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Mon, 2 Dec 2013 22:54:47 +0100 Subject: ipc/ipc_port.c: trivial stylistic fix for consistency * ipc/ipc_port.c (indent): Trivial stylistic fix for consistency. --- ipc/ipc_port.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ipc/ipc_port.c b/ipc/ipc_port.c index b9607395..99a6ad46 100644 --- a/ipc/ipc_port.c +++ b/ipc/ipc_port.c @@ -1240,7 +1240,7 @@ ipc_port_print(port) printf(", sndrs=0x%x", port->ip_blocked.ithq_base); printf(", kobj=0x%x\n", port->ip_kobject); - indent -=2; + indent -= 2; } #endif /* MACH_KDB */ -- cgit v1.2.3 From c86c2d084dbd8c004eaf9c81e2bf712a4318466c Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 5 Dec 2013 22:02:55 +0100 Subject: kern/machine.c: remove __volatile__ Shutdown can be optimised. Remove __volatile__. * kern/machine.c [__GNUC__] (processor_doshutdown): Remove volatile function qualifier. --- kern/machine.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/kern/machine.c b/kern/machine.c index 3dadeb5d..8a333271 100644 --- a/kern/machine.c +++ b/kern/machine.c @@ -623,9 +623,6 @@ Restart_pset: * running on the processor's shutdown stack. */ -#ifdef __GNUC__ -__volatile__ -#endif void processor_doshutdown(processor) processor_t processor; { -- cgit v1.2.3 From 8381f5f290482bce338188ede71499e616f1b6f2 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 5 Dec 2013 22:02:56 +0100 Subject: i386/i386/setjmp.h: remove ifdef Function _longjmp() is used even if __GNUC__ is not defined. Avoid implicit declaration in that case by removing the ifdef. * i386/i386/setjmp.h [__GNUC__] (_longjmp): Remove ifdef. --- i386/i386/setjmp.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/i386/i386/setjmp.h b/i386/i386/setjmp.h index 5c43d40f..80f0f5fe 100644 --- a/i386/i386/setjmp.h +++ b/i386/i386/setjmp.h @@ -35,8 +35,6 @@ typedef struct jmp_buf { extern int _setjmp(jmp_buf_t*); -#ifdef __GNUC__ extern void _longjmp(jmp_buf_t*, int); -#endif #endif /* _I386_SETJMP_H_ */ -- cgit v1.2.3 From 0538c719a05b53554c5a29187147ba386d5d0ffc Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 5 Dec 2013 22:02:58 +0100 Subject: ddb/db_command.c: remove forward declaration * ddb/db_command.c (db_skip_to_eol): Remove forward declaration. --- ddb/db_command.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/ddb/db_command.c b/ddb/db_command.c index b2b2a468..69fea857 100644 --- a/ddb/db_command.c +++ b/ddb/db_command.c @@ -298,8 +298,6 @@ db_command_list(last_cmdp, cmd_table) struct db_command **last_cmdp; /* IN_OUT */ struct db_command *cmd_table; { - void db_skip_to_eol(); - do { db_command(last_cmdp, cmd_table); db_skip_to_eol(); -- cgit v1.2.3 From d329a3411f0521caf03eeb8e3d6d8edb3696b9f9 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 5 Dec 2013 22:02:59 +0100 Subject: ddb/db_command.h: remove duplicate variable declaration * ddb/db_command.h (db_recover): Remove duplicate variable declaration. --- ddb/db_command.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/ddb/db_command.h b/ddb/db_command.h index 64e3b5cf..1edf1d65 100644 --- a/ddb/db_command.h +++ b/ddb/db_command.h @@ -53,8 +53,6 @@ extern db_addr_t db_next; /* next address to be examined or written */ extern jmp_buf_t * db_recover; /* error recovery */ -extern jmp_buf_t * db_recover; /* error recovery */ - /* * Command table */ -- cgit v1.2.3 From 653ebe7bf09d3f84dde263ac8fdecddb6239c36f Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 5 Dec 2013 22:03:00 +0100 Subject: ddb/db_output.c: remove call to nonexistent db_printf_enter() * ddb/db_output.c [db_printf_enter] (db_printf_enter): Remove call to nonexistent function. --- ddb/db_output.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/ddb/db_output.c b/ddb/db_output.c index c08db6f3..268de693 100644 --- a/ddb/db_output.c +++ b/ddb/db_output.c @@ -210,9 +210,6 @@ db_printf(const char *fmt, ...) { va_list listp; -#ifdef db_printf_enter - db_printf_enter(); /* optional multiP serialization */ -#endif va_start(listp, fmt); _doprnt(fmt, listp, db_id_putc, db_radix, 0); va_end(listp); -- cgit v1.2.3 From 50a41a4e8f602a8619f42e8685a9b66d66f59f22 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 5 Dec 2013 22:03:01 +0100 Subject: ddb/db_output.c: remove duplicate function Function kdbprintf() and db_printf() are the same function. Remove kdbprintf() and define kdbprintf to db_printf. * ddb/db_output.c (kdbprintf): Remove function. * ddb/db_output.h: Define kdbprintf to db_printf. (kdbprintf): Remove prototype. --- ddb/db_output.c | 12 ------------ ddb/db_output.h | 3 ++- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/ddb/db_output.c b/ddb/db_output.c index 268de693..91ade913 100644 --- a/ddb/db_output.c +++ b/ddb/db_output.c @@ -215,16 +215,4 @@ db_printf(const char *fmt, ...) va_end(listp); } -/* alternate name */ - -/*VARARGS1*/ -void -kdbprintf(const char *fmt, ...) -{ - va_list listp; - va_start(listp, fmt); - _doprnt(fmt, listp, db_id_putc, db_radix, 0); - va_end(listp); -} - #endif /* MACH_KDB */ diff --git a/ddb/db_output.h b/ddb/db_output.h index e7a4ba3b..e8866474 100644 --- a/ddb/db_output.h +++ b/ddb/db_output.h @@ -39,7 +39,8 @@ extern void db_force_whitespace(void); extern int db_print_position(void); extern void db_end_line(void); extern void db_printf(const char *fmt, ...); +/* alternate name */ +#define kdbprintf db_printf extern void db_putchar(int c); -extern void kdbprintf(const char *fmt, ...); #endif /* _DDB_DB_OUTPUT_H_ */ -- cgit v1.2.3 From 38e75e45cac850ae50a8d20494937e1fcf6459f3 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 5 Dec 2013 22:03:04 +0100 Subject: device/chario.c: use boolean instead of an int * device/chario.c (pdma_default): Use boolean instead of an int. --- device/chario.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/device/chario.c b/device/chario.c index 387428a6..8d688577 100644 --- a/device/chario.c +++ b/device/chario.c @@ -82,7 +82,7 @@ struct ldisc_switch linesw[] = { */ const int tty_inq_size = 4096; /* big nuf */ const int tty_outq_size = 2048; /* Must be bigger that tthiwat */ -int pdma_default = 1; /* turn pseudo dma on by default */ +boolean_t pdma_default = TRUE; /* turn pseudo dma on by default */ /* * compute pseudo-dma tables -- cgit v1.2.3 From 763723cc3fc373b29ce3b83c2dae5a7c75901512 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 5 Dec 2013 22:03:05 +0100 Subject: device/cirbuf.c: use boolean instead of an int * device/cirbuf.c (cb_check_enable): Use boolean instead of an int. --- device/cirbuf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/device/cirbuf.c b/device/cirbuf.c index 7af2d7ad..292b888d 100644 --- a/device/cirbuf.c +++ b/device/cirbuf.c @@ -42,7 +42,7 @@ /* if c_cl == c_cf - 1, buffer is full */ #if DEBUG -int cb_check_enable = 0; +boolean_t cb_check_enable = FALSE; #define CB_CHECK(cb) if (cb_check_enable) cb_check(cb) void -- cgit v1.2.3 From 5636bbf479dc4e8e2f50c40295b4e957aeff0809 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 5 Dec 2013 22:03:07 +0100 Subject: device/dev_lookup.c: remove unused lock * device/dev_lookup.c (dev_port_lock): Remove unused lock. --- device/dev_lookup.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/device/dev_lookup.c b/device/dev_lookup.c index e257ae9c..40373867 100644 --- a/device/dev_lookup.c +++ b/device/dev_lookup.c @@ -243,8 +243,6 @@ mach_device_deallocate(device) /* * port-to-device lookup routines. */ -decl_simple_lock_data(, - dev_port_lock) /* * Enter a port-to-device mapping. @@ -373,8 +371,6 @@ dev_lookup_init() for (i = 0; i < NDEVHASH; i++) queue_init(&dev_number_hash_table[i]); - simple_lock_init(&dev_port_lock); - kmem_cache_init(&dev_hdr_cache, "mach_device", sizeof(struct mach_device), 0, NULL, NULL, NULL, 0); } -- cgit v1.2.3 From d591ae773032ea0571bb1488ded979a384baae77 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 5 Dec 2013 22:03:08 +0100 Subject: device/if_ether.h: remove unused variable * device/if_ether.h (etherbroadcastaddr): Remove unused variable. * device/subrs.c (etherbroadcastaddr): Remove initialization. --- device/if_ether.h | 2 -- device/subrs.c | 5 ----- 2 files changed, 7 deletions(-) diff --git a/device/if_ether.h b/device/if_ether.h index dbdd8184..e368fbf6 100644 --- a/device/if_ether.h +++ b/device/if_ether.h @@ -46,8 +46,6 @@ struct ether_header { }; #ifdef KERNEL -u_char etherbroadcastaddr[6]; - extern char * ether_sprintf(u_char *); #endif /* KERNEL */ diff --git a/device/subrs.c b/device/subrs.c index e094f684..0382bc65 100644 --- a/device/subrs.c +++ b/device/subrs.c @@ -51,11 +51,6 @@ void harderr(bp, cp) bp->b_blkno); } -/* - * Ethernet support routines. - */ -u_char etherbroadcastaddr[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; - /* * Convert Ethernet address to printable (loggable) representation. */ -- cgit v1.2.3 From cc2dd46fb9672c2481104d05f3cdded5a5c9130a Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 5 Dec 2013 22:03:10 +0100 Subject: device/kmsg.c: use boolean instead of an int * device/kmsg.c (kmsg_in_use): Use boolean instead of an int. --- device/kmsg.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/device/kmsg.c b/device/kmsg.c index c8bd897a..0e187253 100644 --- a/device/kmsg.c +++ b/device/kmsg.c @@ -42,7 +42,7 @@ static int kmsg_read_offset; /* I/O request queue for blocking read */ static queue_head_t kmsg_read_queue; /* Used for exclusive access to the device */ -static int kmsg_in_use; +static boolean_t kmsg_in_use; /* Used for exclusive access to the routines */ decl_simple_lock_data (static, kmsg_lock); /* If already initialized or not */ @@ -55,7 +55,7 @@ kmsginit (void) kmsg_write_offset = 0; kmsg_read_offset = 0; queue_init (&kmsg_read_queue); - kmsg_in_use = 0; + kmsg_in_use = FALSE; simple_lock_init (&kmsg_lock); } @@ -70,7 +70,7 @@ kmsgopen (dev_t dev, int flag, io_req_t ior) return D_ALREADY_OPEN; } - kmsg_in_use = 1; + kmsg_in_use = TRUE; simple_unlock (&kmsg_lock); return D_SUCCESS; @@ -81,7 +81,7 @@ io_return_t kmsgclose (dev_t dev, int flag) { simple_lock (&kmsg_lock); - kmsg_in_use = 0; + kmsg_in_use = FALSE; simple_unlock (&kmsg_lock); return D_SUCCESS; -- cgit v1.2.3 From c2eebf318505a4c5b83ebff6e2d1974ce5bbf146 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 5 Dec 2013 22:03:11 +0100 Subject: device/kmsg.c: use boolean instead of an int * device/kmsg.c (kmsg_init_done): Use boolean instead of an int. --- device/kmsg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/device/kmsg.c b/device/kmsg.c index 0e187253..7034bfc2 100644 --- a/device/kmsg.c +++ b/device/kmsg.c @@ -46,7 +46,7 @@ static boolean_t kmsg_in_use; /* Used for exclusive access to the routines */ decl_simple_lock_data (static, kmsg_lock); /* If already initialized or not */ -static int kmsg_init_done = 0; +static boolean_t kmsg_init_done = FALSE; /* Kernel Message Initializer */ static void @@ -225,7 +225,7 @@ kmsg_putchar (int c) if (!kmsg_init_done) { kmsginit (); - kmsg_init_done = 1; + kmsg_init_done = TRUE; } simple_lock (&kmsg_lock); -- cgit v1.2.3 From 255638fec41bf310aa90cddd238e2251caadfc92 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 5 Dec 2013 22:03:12 +0100 Subject: device/tty.h, chario.h: move prototype Now that we have device/chario.h move the chario_init() prototype from device/tty.h to device/chario.h. * device/chario.h (chario_init): Add prototype. * device/device_init.c: Include device/chario.h. * device/tty.h (chario_init): Remove prototype. --- device/chario.h | 2 ++ device/device_init.c | 1 + device/tty.h | 2 -- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/device/chario.h b/device/chario.h index 2dbf09f7..52105a20 100644 --- a/device/chario.h +++ b/device/chario.h @@ -21,6 +21,8 @@ #include +extern void chario_init(void); + void queue_delayed_reply( queue_t qh, io_req_t ior, diff --git a/device/device_init.c b/device/device_init.c index 701898bb..b2c8b880 100644 --- a/device/device_init.c +++ b/device/device_init.c @@ -40,6 +40,7 @@ #include #include #include +#include ipc_port_t master_device_port; diff --git a/device/tty.h b/device/tty.h index dcc77119..2fafa42c 100644 --- a/device/tty.h +++ b/device/tty.h @@ -234,6 +234,4 @@ struct ldisc_switch { extern struct ldisc_switch linesw[]; -extern void chario_init(void); - #endif /* _DEVICE_TTY_H_ */ -- cgit v1.2.3 From a662fd0fb171133e8983ee1520a3160b86062167 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 5 Dec 2013 22:03:13 +0100 Subject: i386/i386/db_interface.c: use boolean instead of an int * i386/i386/db_interface.c (kernel_dr): Use boolean instead of an int. --- i386/i386/db_interface.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/i386/i386/db_interface.c b/i386/i386/db_interface.c index a8ac52a1..a59ed37e 100644 --- a/i386/i386/db_interface.c +++ b/i386/i386/db_interface.c @@ -61,7 +61,7 @@ #if MACH_KDB /* Whether the kernel uses any debugging register. */ -static int kernel_dr; +static boolean_t kernel_dr; #endif void db_load_context(pcb_t pcb) @@ -137,7 +137,7 @@ void db_dr ( splx(s); return; } - kernel_dr = 1; + kernel_dr = TRUE; /* Clear user debugging registers */ set_dr7(0); set_dr0(0); @@ -163,7 +163,7 @@ void db_dr ( if (kernel_dr) { if (!ids.dr[0] && !ids.dr[1] && !ids.dr[2] && !ids.dr[3]) { /* Not used any more, switch back to user debugging registers */ - kernel_dr = 0; + kernel_dr = FALSE; db_load_context(current_thread()->pcb); } } -- cgit v1.2.3 From 514fffdc6a8415271e1196cb363566c4630a5394 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 5 Dec 2013 22:03:17 +0100 Subject: i386/i386/ipl.h: remove ifdef and add ifndef This code is used even if KERNEL is not defined. Remove the ifdef. * i386/i386/ipl.h [_I386_IPL_H_]: Add ifndef. --- i386/i386/ipl.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/i386/i386/ipl.h b/i386/i386/ipl.h index 8f729e1d..2da2e89f 100644 --- a/i386/i386/ipl.h +++ b/i386/i386/ipl.h @@ -49,6 +49,8 @@ OTHER TORTIOUS ACTION, ARISING OUR OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef _I386_IPL_H_ +#define _I386_IPL_H_ #define SPL0 0 #define SPL1 1 @@ -76,3 +78,5 @@ extern int intpri[]; extern spl_t curr_ipl; #endif /* __ASSEMBLER__ */ #endif /* KERNEL */ + +#endif /* _I386_IPL_H_ */ -- cgit v1.2.3 From 4bf66deee8f6a1ac6e1922c617c820917367f88a Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 5 Dec 2013 22:03:18 +0100 Subject: i386/i386/mp_desc.c: remove unused variable * i386/i386/mp_desc.c (avail_start): Remove unused variable. --- i386/i386/mp_desc.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/i386/i386/mp_desc.c b/i386/i386/mp_desc.c index efdc3eed..5ede8f15 100644 --- a/i386/i386/mp_desc.c +++ b/i386/i386/mp_desc.c @@ -64,12 +64,6 @@ vm_offset_t int_stack_high; char intstack[]; /* bottom */ char eintstack[]; /* top */ -/* - * We allocate interrupt stacks from physical memory. - */ -extern -vm_offset_t avail_start; - /* * Multiprocessor i386/i486 systems use a separate copy of the * GDT, IDT, LDT, and kernel TSS per processor. The first three -- cgit v1.2.3 From 26c25f250695ba2e648be7751b4076a83d30b5c4 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 5 Dec 2013 22:03:20 +0100 Subject: i386/i386/pic.c: remove unused variables * i386/i386/pic.c (nintr, npics): Remove unused variables. --- i386/i386/pic.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/i386/i386/pic.c b/i386/i386/pic.c index 50ca1509..75cb835a 100644 --- a/i386/i386/pic.c +++ b/i386/i386/pic.c @@ -62,9 +62,6 @@ int curr_pic_mask; int iunit[NINTR] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; -int nintr = NINTR; -int npics = NPICS; - unsigned short master_icw, master_ocw, slaves_icw, slaves_ocw; u_short PICM_ICW1, PICM_OCW1, PICS_ICW1, PICS_OCW1 ; -- cgit v1.2.3 From 8f1efe32baa54f9ffcd89bb33ae28de4c889cc30 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 5 Dec 2013 22:03:21 +0100 Subject: i386/i386/pit.c: remove unused variables * i386/i386/pit.c (pitctr1_port, pitctr2_port): Remove unused variables. --- i386/i386/pit.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/i386/i386/pit.c b/i386/i386/pit.c index 4f156d87..85929e9e 100644 --- a/i386/i386/pit.c +++ b/i386/i386/pit.c @@ -57,8 +57,6 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. int pitctl_port = PITCTL_PORT; /* For 386/20 Board */ int pitctr0_port = PITCTR0_PORT; /* For 386/20 Board */ -int pitctr1_port = PITCTR1_PORT; /* For 386/20 Board */ -int pitctr2_port = PITCTR2_PORT; /* For 386/20 Board */ /* We want PIT 0 in square wave mode */ int pit0_mode = PIT_C0|PIT_SQUAREMODE|PIT_READMODE ; -- cgit v1.2.3 From fd672d12fd9dd8cf71cee7f52243f964f638a00c Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 5 Dec 2013 22:03:22 +0100 Subject: i386/i386/trap.c: remove unused variable * i386/i386/trap.c (brb): Remove unused variable. --- i386/i386/trap.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/i386/i386/trap.c b/i386/i386/trap.c index ccbc94cc..c0611d6f 100644 --- a/i386/i386/trap.c +++ b/i386/i386/trap.c @@ -147,9 +147,6 @@ char *trap_name(unsigned int trapnum) return trapnum < TRAP_TYPES ? trap_type[trapnum] : "(unknown)"; } - -boolean_t brb = TRUE; - /* * Trap from kernel mode. Only page-fault errors are recoverable, * and then only in special circumstances. All other errors are -- cgit v1.2.3 From cb685dd357b7ad7a02486a5085f911ca29c94e15 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 5 Dec 2013 22:03:23 +0100 Subject: i386/i386/trap.c: remove unused variables * i386/i386/trap.c (v86_assist_on, v86_unsafe_ok, v86_do_sti_cli, v86_do_sti_immediate, cli_count, sti_count): Remove unused variables. --- i386/i386/trap.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/i386/i386/trap.c b/i386/i386/trap.c index c0611d6f..b891527d 100644 --- a/i386/i386/trap.c +++ b/i386/i386/trap.c @@ -555,19 +555,8 @@ printf("user trap %d error %d sub %08x\n", type, code, subcode); /*NOTREACHED*/ } -/* - * V86 mode assist for interrupt handling. - */ -boolean_t v86_assist_on = TRUE; -boolean_t v86_unsafe_ok = FALSE; -boolean_t v86_do_sti_cli = TRUE; -boolean_t v86_do_sti_immediate = FALSE; - #define V86_IRET_PENDING 0x4000 -int cli_count = 0; -int sti_count = 0; - /* * Handle AST traps for i386. * Check for delayed floating-point exception from -- cgit v1.2.3 From 9bf69217ac9b64c9167956579c5284a9abcb73fe Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 5 Dec 2013 22:03:24 +0100 Subject: i386/i386/user_ldt.c: remove unused variable * i386/i386/user_ldt.c (acc_type): Remove unused variable. --- i386/i386/user_ldt.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/i386/i386/user_ldt.c b/i386/i386/user_ldt.c index 5c3d323f..07be0a0d 100644 --- a/i386/i386/user_ldt.c +++ b/i386/i386/user_ldt.c @@ -43,18 +43,6 @@ #include "ldt.h" #include "vm_param.h" -char acc_type[8][3] = { - /* code stack data */ - { 0, 0, 1 }, /* data */ - { 0, 1, 1 }, /* data, writable */ - { 0, 0, 1 }, /* data, expand-down */ - { 0, 1, 1 }, /* data, writable, expand-down */ - { 1, 0, 0 }, /* code */ - { 1, 0, 1 }, /* code, readable */ - { 1, 0, 0 }, /* code, conforming */ - { 1, 0, 1 }, /* code, readable, conforming */ -}; - /* * Add the descriptors to the LDT, starting with * the descriptor for 'first_selector'. -- cgit v1.2.3 From e86050875d72dbe2f80d3475220f769d7928f30b Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 5 Dec 2013 22:03:27 +0100 Subject: i386/i386at/immc.c, kd.c: use boolean instead of an int * i386/i386at/immc.c (immediate_console_enable): Use boolean instead of an int. * i386/i386at/kd.c (immediate_console_enable): Likewise. --- i386/i386at/immc.c | 2 +- i386/i386at/kd.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/i386/i386at/immc.c b/i386/i386at/immc.c index db64620e..b85eb07a 100644 --- a/i386/i386at/immc.c +++ b/i386/i386at/immc.c @@ -33,7 +33,7 @@ so it can be used to debug things that happen very early before any devices are initialized. */ -int immediate_console_enable = 1; +boolean_t immediate_console_enable = TRUE; void immc_cnputc(unsigned char c) diff --git a/i386/i386at/kd.c b/i386/i386at/kd.c index def8a0ce..24d999a6 100644 --- a/i386/i386at/kd.c +++ b/i386/i386at/kd.c @@ -1189,8 +1189,8 @@ kdinit() /* Now that we're set up, we no longer need or want the immediate console. */ { - extern int immediate_console_enable; - immediate_console_enable = 0; + extern boolean_t immediate_console_enable; + immediate_console_enable = FALSE; } /* The immediate console printed stuff at the bottom of the -- cgit v1.2.3 From 7806985ccef3fc8074a44dfd3f79b2ce21429338 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 5 Dec 2013 22:03:28 +0100 Subject: i386/i386at/model_dep.c, kd.c: use boolean instead of an int * i386/i386at/kd.c (rebootflag): Use boolean instead of an int. Remove duplicate variable declaration. * i386/i386at/model_dep.c (rebootflag): Use boolean instead of an int. --- i386/i386at/kd.c | 3 +-- i386/i386at/model_dep.c | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/i386/i386at/kd.c b/i386/i386at/kd.c index 24d999a6..b8e94879 100644 --- a/i386/i386at/kd.c +++ b/i386/i386at/kd.c @@ -105,7 +105,7 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #endif struct tty kd_tty; -extern int rebootflag; +extern boolean_t rebootflag; static void charput(), charmvup(), charmvdown(), charclear(), charsetcursor(); static void kd_noopreset(); @@ -984,7 +984,6 @@ Scancode scancode; { static int magic_state = KS_NORMAL; /* like kd_state */ boolean_t up = FALSE; - extern int rebootflag; if (scancode == 0x46) /* scroll lock */ /* if (scancode == 0x52) ** insert key */ diff --git a/i386/i386at/model_dep.c b/i386/i386at/model_dep.c index f0d49f45..30ef2043 100644 --- a/i386/i386at/model_dep.c +++ b/i386/i386at/model_dep.c @@ -127,7 +127,7 @@ static vm_size_t avail_remaining; extern char version[]; -int rebootflag = 0; /* exported to kdintr */ +boolean_t rebootflag = FALSE; /* exported to kdintr */ /* XX interrupt stack pointer and highwater mark, for locore.S. */ vm_offset_t int_stack_top, int_stack_high; @@ -228,7 +228,7 @@ void halt_all_cpus(reboot) kdreboot(); } else { - rebootflag = 1; + rebootflag = TRUE; #ifdef MACH_HYP hyp_halt(); #endif /* MACH_HYP */ -- cgit v1.2.3 From e4d39d55f160a7ae3c3b235efd40be9c7da953e3 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 5 Dec 2013 22:03:32 +0100 Subject: i386/i386at/kd.c: use boolean instead of an int * i386/i386at/kd.c (mouse_in_use): Use boolean instead of an int. Remove duplicate declaration. --- i386/i386at/kd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/i386/i386at/kd.c b/i386/i386at/kd.c index b8e94879..433d0f10 100644 --- a/i386/i386at/kd.c +++ b/i386/i386at/kd.c @@ -398,8 +398,8 @@ char c; #endif /* DEBUG */ -extern int mouse_in_use; -int old_kb_mode; +extern boolean_t mouse_in_use; +int old_kb_mode; void cnpollc(on) @@ -735,7 +735,7 @@ int vec; unsigned char scancode; int char_idx; boolean_t up = FALSE; /* key-up event */ - extern int mouse_in_use; + if (kd_pollc) return; /* kdb polling kbd */ -- cgit v1.2.3 From d3ac0b0895c94577d4a12861dfb530db92bcf5c7 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 5 Dec 2013 22:03:33 +0100 Subject: i386/i386at/kd.c: use boolean instead of an unsigned int * i386/i386at/kd.c (kd_bellstate): Use boolean instead of an unsigned int. --- i386/i386at/kd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/i386/i386at/kd.c b/i386/i386at/kd.c index 433d0f10..14524bf8 100644 --- a/i386/i386at/kd.c +++ b/i386/i386at/kd.c @@ -1218,7 +1218,7 @@ kdinit() * output : bell is turned off * */ -static unsigned int kd_bellstate = 0; +static boolean_t kd_bellstate = FALSE; void kd_belloff(void * param) @@ -1227,7 +1227,7 @@ kd_belloff(void * param) status = (inb(K_PORTB) & ~(K_SPKRDATA | K_ENABLETMR2)); outb(K_PORTB, status); - kd_bellstate = 0; + kd_bellstate = FALSE; return; } @@ -1300,7 +1300,7 @@ u_char ch; { kd_bellon(); timeout(kd_belloff, 0, hz/8 ); - kd_bellstate = 1; + kd_bellstate = TRUE; } break; default: -- cgit v1.2.3 From f13cdc6b8d46628f4f7f6e8a3bb1f719a2b9c771 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 5 Dec 2013 22:03:37 +0100 Subject: i386/i386at/rtc.c: use boolean instead of an int * i386/i386at/rtc.c (first_rtcopen_ever): Use boolean instead of an int. --- i386/i386at/rtc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/i386/i386at/rtc.c b/i386/i386at/rtc.c index 31128300..2115f23b 100644 --- a/i386/i386at/rtc.c +++ b/i386/i386at/rtc.c @@ -53,7 +53,7 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include -static int first_rtcopen_ever = 1; +static boolean_t first_rtcopen_ever = TRUE; void rtcinit() @@ -71,7 +71,7 @@ unsigned char *regs; { if (first_rtcopen_ever) { rtcinit(); - first_rtcopen_ever = 0; + first_rtcopen_ever = FALSE; } outb(RTC_ADDR, RTC_D); if ((inb(RTC_DATA) & RTC_VRT) == 0) return(-1); @@ -90,7 +90,7 @@ unsigned char *regs; if (first_rtcopen_ever) { rtcinit(); - first_rtcopen_ever = 0; + first_rtcopen_ever = FALSE; } outb(RTC_ADDR, RTC_B); x = inb(RTC_DATA); -- cgit v1.2.3 From a86e71f182495d73db2176d0927697e6e371517e Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 5 Dec 2013 22:03:38 +0100 Subject: time: remove unused variable * i386/i386at/rtc.c (tz): Remove unused variable. * xen/time.c (tz): Remove unused variable. --- i386/i386at/rtc.c | 1 - xen/time.c | 1 - 2 files changed, 2 deletions(-) diff --git a/i386/i386at/rtc.c b/i386/i386at/rtc.c index 2115f23b..98f157f9 100644 --- a/i386/i386at/rtc.c +++ b/i386/i386at/rtc.c @@ -103,7 +103,6 @@ unsigned char *regs; extern struct timeval time; -extern struct timezone tz; static int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; diff --git a/xen/time.c b/xen/time.c index 93d87d4a..4ebe91fa 100644 --- a/xen/time.c +++ b/xen/time.c @@ -111,7 +111,6 @@ static void hypclock_intr(int unit, int old_ipl, void *ret_addr, struct i386_int } extern struct timeval time; -extern struct timezone tz; int readtodc(tp) -- cgit v1.2.3 From 6fe7f4a63ac7b1efe182d861722e2baf71b1be16 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 5 Dec 2013 22:03:39 +0100 Subject: i386/intel/pmap.c: use boolean instead of an int * i386/intel/pmap.c (pmap_debug): Use boolean instead of an int. --- i386/intel/pmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i386/intel/pmap.c b/i386/intel/pmap.c index b89524e2..047f9544 100644 --- a/i386/intel/pmap.c +++ b/i386/intel/pmap.c @@ -402,7 +402,7 @@ pmap_t kernel_pmap; struct kmem_cache pmap_cache; /* cache of pmap structures */ -int pmap_debug = 0; /* flag for debugging prints */ +boolean_t pmap_debug = FALSE; /* flag for debugging prints */ #if 0 int ptes_per_vm_page; /* number of hardware ptes needed -- cgit v1.2.3 From db76d6bfd6b70c6fa03f90e0d77577df83e22f70 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 5 Dec 2013 22:03:40 +0100 Subject: i386/intel/pmap.c: remove unused variable * i386/intel/pmap.c (end): Remove unused variable. --- i386/intel/pmap.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/i386/intel/pmap.c b/i386/intel/pmap.c index 047f9544..2f1c5385 100644 --- a/i386/intel/pmap.c +++ b/i386/intel/pmap.c @@ -413,8 +413,6 @@ int ptes_per_vm_page; /* number of hardware ptes needed unsigned int inuse_ptepages_count = 0; /* debugging */ -extern char end; - /* * Pointer to the basic page directory for the kernel. * Initialized by pmap_bootstrap(). -- cgit v1.2.3 From 7ac2f982c65e38ab0fbc97b899178596bb4e9252 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 5 Dec 2013 22:03:41 +0100 Subject: ipc/ipc_init.c: qualify constant with const * ipc/ipc_init.c (ipc_kernel_map_size): Qualify constant with const. --- ipc/ipc_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ipc/ipc_init.c b/ipc/ipc_init.c index ca7e7912..a7e9ec17 100644 --- a/ipc/ipc_init.c +++ b/ipc/ipc_init.c @@ -54,7 +54,7 @@ static struct vm_map ipc_kernel_map_store; vm_map_t ipc_kernel_map = &ipc_kernel_map_store; -vm_size_t ipc_kernel_map_size = 8 * 1024 * 1024; +const vm_size_t ipc_kernel_map_size = 8 * 1024 * 1024; /* * Routine: ipc_bootstrap -- cgit v1.2.3 From 9341bd89f059310ab30ca0b644a88c73bb1458d9 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 5 Dec 2013 22:03:42 +0100 Subject: ipc/mach_port.c: use boolean instead of an int * ipc/mach_port.c (mach_port_deallocate_debug): Use boolean instead of an int. --- ipc/mach_port.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ipc/mach_port.c b/ipc/mach_port.c index f0f00d29..3e5af400 100644 --- a/ipc/mach_port.c +++ b/ipc/mach_port.c @@ -555,7 +555,7 @@ mach_port_allocate(space, right, namep) * KERN_INVALID_NAME The name doesn't denote a right. */ -static volatile int mach_port_deallocate_debug = 0; +static volatile boolean_t mach_port_deallocate_debug = FALSE; kern_return_t mach_port_destroy( -- cgit v1.2.3 From 56a1f2c7a861ef4f9fdd7546b50a5463c4a45a6b Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 5 Dec 2013 22:03:43 +0100 Subject: ipc/port.h: update comment This is ipc/port.h. Not ipc/ipc_port.h. * ipc/port.h: Update comment. --- ipc/port.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ipc/port.h b/ipc/port.h index 6e9f77b4..d6fb59b3 100644 --- a/ipc/port.h +++ b/ipc/port.h @@ -29,7 +29,7 @@ /* */ /* - * File: ipc/ipc_port.h + * File: ipc/port.h * Author: Rich Draves * Date: 1989 * -- cgit v1.2.3 From 5b52f611dd714b161337301109c28c2ae4a89dff Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Mon, 9 Dec 2013 00:18:22 +0900 Subject: Add comment --- kern/debug.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kern/debug.c b/kern/debug.c index 2530fa6a..add2accd 100644 --- a/kern/debug.c +++ b/kern/debug.c @@ -197,6 +197,7 @@ log(int level, const char *fmt, ...) va_end(listp); } +/* GCC references this for stack protection. */ unsigned char __stack_chk_guard [ sizeof (vm_offset_t) ] = { [ sizeof (vm_offset_t) - 3 ] = '\r', -- cgit v1.2.3 From 9003ab643c4fe5a54090c86fd4b8305c80f1e9bb Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 5 Dec 2013 22:03:45 +0100 Subject: kern/act.h: remove prototype without definition * kern/act.h (act_create_kernel): Remove prototype without definition. --- kern/act.h | 1 - 1 file changed, 1 deletion(-) diff --git a/kern/act.h b/kern/act.h index e0647244..35f1324b 100644 --- a/kern/act.h +++ b/kern/act.h @@ -176,7 +176,6 @@ kern_return_t act_terminate_task_locked(struct Act *act); /* Exported to thread.c */ extern Act null_act; -kern_return_t act_create_kernel(Act **out_act); /* Exported to machine-dependent activation code */ void act_execute_returnhandlers(void); -- cgit v1.2.3 From 99adfa5d7753ed949114be5fb1b8ffecfdf067e1 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 5 Dec 2013 22:03:50 +0100 Subject: kern/lock_mon.c: use spl_t instead of an int Variable curr_ipl is in other files declared as spl_t. * kern/lock_mon.c (curr_ipl): Use spl_t instead of an int. --- kern/lock_mon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kern/lock_mon.c b/kern/lock_mon.c index 80c50b5f..231b5305 100644 --- a/kern/lock_mon.c +++ b/kern/lock_mon.c @@ -85,7 +85,7 @@ struct lock_info_bucket lock_info[LOCK_INFO_HASH_COUNT]; struct lock_info default_lock_info; unsigned default_lock_stack = 0; -extern int curr_ipl[]; +extern spl_t curr_ipl[]; -- cgit v1.2.3 From d5f70349f3bfe387f07da38a9eccde0ccc5cdf3b Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 5 Dec 2013 22:03:51 +0100 Subject: kern/lock_mon.c: remove dead assignments * kern/lock_mon.c (scurval, ssum, sli): Remove variables. (scurval, ssum, sli): Remove dead assignments. --- kern/lock_mon.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/kern/lock_mon.c b/kern/lock_mon.c index 231b5305..6138efc2 100644 --- a/kern/lock_mon.c +++ b/kern/lock_mon.c @@ -173,9 +173,6 @@ lip() { #define lock_info_sort lis -unsigned scurval, ssum; -struct lock_info *sli; - lock_info_sort(arg, abs, count) { struct lock_info *li, mean; @@ -215,9 +212,6 @@ lock_info_sort(arg, abs, count) sum = li->success + li->fail; if(!sum && !abs) continue; - scurval = curval; - ssum = sum; - sli = li; if (!abs) switch(arg) { case 0: break; -- cgit v1.2.3 From 41f02ddf9c3a2357a0dbcce4b06010d54da4c123 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 5 Dec 2013 22:03:52 +0100 Subject: kern/pc_sample.c: remove unused variables * kern/pc_sample.c (pc_sampling_enabled, pc_sampling_lock): Remove unused variables. --- kern/pc_sample.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/kern/pc_sample.c b/kern/pc_sample.c index 05c08b81..cdf8e954 100644 --- a/kern/pc_sample.c +++ b/kern/pc_sample.c @@ -43,9 +43,6 @@ typedef sampled_pc_t sampled_pcs[MAX_PC_SAMPLES]; -int pc_sampling_enabled = 0; -decl_simple_lock_data(, pc_sampling_lock) /* lock for enabling */ - void take_pc_sample( thread_t t, sample_control_t *cp, -- cgit v1.2.3 From d07a5acea462921fb45362e7fbb569a7b7395268 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 5 Dec 2013 22:03:53 +0100 Subject: kern/priority.c: update comment This is priority.c. Not clock_prim.c. * kern/priority.c: Update comment. --- kern/priority.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kern/priority.c b/kern/priority.c index ddb8fd60..d9ded857 100644 --- a/kern/priority.c +++ b/kern/priority.c @@ -27,7 +27,7 @@ * the rights to redistribute these changes. */ /* - * File: clock_prim.c + * File: priority.c * Author: Avadis Tevanian, Jr. * Date: 1986 * -- cgit v1.2.3 From 512967fb52de27b2368625392dd675729be9aab0 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 5 Dec 2013 22:03:54 +0100 Subject: kern/rbtree.h: remove unnecessary include File kern/rbtree.h includes itself. Remove this include. * kern/rbtree.h: Don't include kern/rbtree.h. --- kern/rbtree.h | 1 - 1 file changed, 1 deletion(-) diff --git a/kern/rbtree.h b/kern/rbtree.h index 5a65d1ef..f577f7ed 100644 --- a/kern/rbtree.h +++ b/kern/rbtree.h @@ -32,7 +32,6 @@ #include #include #include -#include #include #define structof(ptr, type, member) \ -- cgit v1.2.3 From 4bea7554a73ea34f561bc2ecadcbecca09358b87 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 5 Dec 2013 22:03:55 +0100 Subject: kern/refcount.h: remove unnecessary include File kern/refcount.h includes itself. Remove this include. * kern/refcount.h: Don't include kern/refcount.h. --- kern/refcount.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/kern/refcount.h b/kern/refcount.h index c5275477..01dc6b59 100644 --- a/kern/refcount.h +++ b/kern/refcount.h @@ -29,8 +29,6 @@ #include -#include "refcount.h" /*XXX*/ - /* Unless the above include file specified otherwise, use the system-independent (unoptimized) atomic reference counter. */ #ifndef MACHINE_REFCOUNT -- cgit v1.2.3 From 18a03f7476f8e79f627bbabdcb478b3c81a6bbdf Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 5 Dec 2013 22:03:56 +0100 Subject: kern/syscall_sw.c: use boolean instead of an int * kern/syscall_sw.c (kern_invalid_debug): Use boolean instead of an int. --- kern/syscall_sw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kern/syscall_sw.c b/kern/syscall_sw.c index 93974416..084f2e0d 100644 --- a/kern/syscall_sw.c +++ b/kern/syscall_sw.c @@ -58,7 +58,7 @@ * the positive numbers) are reserved for Unix. */ -int kern_invalid_debug = 0; +boolean_t kern_invalid_debug = FALSE; mach_port_t null_port() { -- cgit v1.2.3 From b848914aac388e82948aa2b277c5a1edf3de158d Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 5 Dec 2013 22:03:57 +0100 Subject: vm/vm_page.h: remove unused variables * vm/vm_page.h (first_phys_addr, last_phys_addr): Remove unused variables. --- vm/vm_page.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/vm/vm_page.h b/vm/vm_page.h index 4536d1c5..f5681d7e 100644 --- a/vm/vm_page.h +++ b/vm/vm_page.h @@ -155,11 +155,6 @@ queue_head_t vm_page_queue_active; /* active memory queue */ extern queue_head_t vm_page_queue_inactive; /* inactive memory queue */ -extern -vm_offset_t first_phys_addr; /* physical address for first_page */ -extern -vm_offset_t last_phys_addr; /* physical address for last_page */ - extern int vm_page_free_count; /* How many pages are free? */ extern -- cgit v1.2.3 From 94c96554e093f4b6cc947125f60e8da39031f08c Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 5 Dec 2013 22:03:58 +0100 Subject: Cleanup of the prototypes * device/cirbuf.h (nqdb): Remove prototype without definition. * device/conf.h (dev_set_indirect): Likewise. * kern/boot_script.h (boot_script_read_file): Likewise. * kern/eventcount.h (evc_notify_abort): Remove duplicate prototype. * kern/thread.h (thread_set_own_priority): Likewise. * kern/thread_swap.h (thread_swapout): Remove prototype without definition. * kern/timer.h (softclock): Remove duplicate prototype. * vm/pmap.h (pmap_resident_count, pmap_access, pmap_phys_address, pmap_phys_to_frame): Remove prototypes without function definition. * vm/vm_page.h (vm_set_page_size): Likewise. --- device/cirbuf.h | 1 - device/conf.h | 5 ----- kern/boot_script.h | 4 ---- kern/eventcount.h | 2 -- kern/thread.h | 2 -- kern/thread_swap.h | 1 - kern/timer.h | 2 -- vm/pmap.h | 22 ---------------------- vm/vm_page.h | 2 -- 9 files changed, 41 deletions(-) diff --git a/device/cirbuf.h b/device/cirbuf.h index a3f50ce5..5e4360b1 100644 --- a/device/cirbuf.h +++ b/device/cirbuf.h @@ -52,7 +52,6 @@ extern int putc(int, struct cirbuf *); extern int getc(struct cirbuf *); extern int q_to_b(struct cirbuf *, char *, int); extern int b_to_q(char *, int, struct cirbuf *); -extern int nqdb(struct cirbuf *, int); extern void ndflush(struct cirbuf *, int); extern void cb_clear(struct cirbuf *); diff --git a/device/conf.h b/device/conf.h index e91e0996..8aacc86e 100644 --- a/device/conf.h +++ b/device/conf.h @@ -105,10 +105,5 @@ extern int dev_indirect_count; di < &dev_indirect_list[dev_indirect_count]; \ di++) -/* - * Exported routine to set indirection. - */ -extern void dev_set_indirect(char *, dev_ops_t, int); - #endif /* _DEVICE_CONF_H_ */ diff --git a/kern/boot_script.h b/kern/boot_script.h index c5ad6732..c007d777 100644 --- a/kern/boot_script.h +++ b/kern/boot_script.h @@ -69,10 +69,6 @@ int boot_script_exec_cmd (void *hook, task_t task, char *path, int argc, char **argv, char *strings, int stringlen); -/* The user must define this function. Load the contents of FILE - into a fresh anonymous memory object and return the memory object port. */ -mach_port_t boot_script_read_file (const char *file); - /* The user must define this functions to perform the corresponding Mach task manipulations. */ int boot_script_task_create (struct cmd *); /* task_create + task_suspend */ diff --git a/kern/eventcount.h b/kern/eventcount.h index f3ba0472..7cc82207 100644 --- a/kern/eventcount.h +++ b/kern/eventcount.h @@ -55,8 +55,6 @@ extern void evc_init(evc_t ev), extern kern_return_t evc_wait(natural_t ev_id); extern kern_return_t evc_wait_clear(natural_t ev_id); -extern void evc_notify_abort (thread_t thread); - #if NCPUS <= 1 void simpler_thread_setrun( thread_t th, diff --git a/kern/thread.h b/kern/thread.h index 559e90b5..9946bde6 100644 --- a/kern/thread.h +++ b/kern/thread.h @@ -345,8 +345,6 @@ extern kern_return_t thread_halt( boolean_t must_halt); extern void thread_halt_self(void); extern void thread_force_terminate(thread_t); -extern void thread_set_own_priority( - int priority); extern thread_t kernel_thread( task_t task, void (*start)(void), diff --git a/kern/thread_swap.h b/kern/thread_swap.h index 31130301..7f611ec4 100644 --- a/kern/thread_swap.h +++ b/kern/thread_swap.h @@ -39,6 +39,5 @@ extern void swapper_init(void); extern void thread_swapin(thread_t thread); extern void thread_doswapin(thread_t thread); extern void swapin_thread(void); -extern void thread_swapout(thread_t thread); #endif /* _KERN_THREAD_SWAP_H_ */ diff --git a/kern/timer.h b/kern/timer.h index 76a41178..57f017aa 100644 --- a/kern/timer.h +++ b/kern/timer.h @@ -182,8 +182,6 @@ MACRO_END extern void init_timers(void); -void softclock(void); - void timer_init(timer_t this_timer); #endif /* _KERN_TIMER_H_ */ diff --git a/vm/pmap.h b/vm/pmap.h index 59fd03ab..95ba6da5 100644 --- a/vm/pmap.h +++ b/vm/pmap.h @@ -163,38 +163,16 @@ void pmap_clear_modify(vm_offset_t pa); /* Return modify bit */ boolean_t pmap_is_modified(vm_offset_t pa); - -/* - * Statistics routines - */ - -#ifndef pmap_resident_count -extern int pmap_resident_count(); -#endif /* pmap_resident_count */ - /* * Sundry required routines */ /* Return a virtual-to-physical mapping, if possible. */ extern vm_offset_t pmap_extract(pmap_t, vm_offset_t); -/* Is virtual address valid? */ -extern boolean_t pmap_access(); /* Perform garbage collection, if any. */ extern void pmap_collect(pmap_t); /* Specify pageability. */ extern void pmap_change_wiring(pmap_t, vm_offset_t, boolean_t); -#ifndef pmap_phys_address -/* Transform address returned by device driver mapping function to physical - * address known to this module. */ -extern vm_offset_t pmap_phys_address(); -#endif /* pmap_phys_address */ -#ifndef pmap_phys_to_frame -/* Inverse of pmap_phys_address, for use by device driver mapping function in - * machine-independent pseudo-devices. */ -extern int pmap_phys_to_frame(); -#endif /* pmap_phys_to_frame */ - /* * Optional routines */ diff --git a/vm/vm_page.h b/vm/vm_page.h index f5681d7e..4445cb0d 100644 --- a/vm/vm_page.h +++ b/vm/vm_page.h @@ -242,8 +242,6 @@ extern void vm_page_copy(vm_page_t src_m, vm_page_t dest_m); extern void vm_page_wire(vm_page_t); extern void vm_page_unwire(vm_page_t); -extern void vm_set_page_size(void); - #if MACH_VM_DEBUG extern unsigned int vm_page_info( hash_info_bucket_t *info, -- cgit v1.2.3 From 1e10bea11c5e4789fa36592998312d84efe09158 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 5 Dec 2013 22:03:59 +0100 Subject: kern/act.h: remove unnecessary include File kern/act.h includes itself. Remove this include. * kern/act.h: Don't include kern/act.h. --- kern/act.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/kern/act.h b/kern/act.h index 35f1324b..6d3a9a9e 100644 --- a/kern/act.h +++ b/kern/act.h @@ -40,8 +40,6 @@ #include #include -#include "act.h"/*XXX*/ - struct task; struct thread; struct Act; -- cgit v1.2.3 From 8a5a8391c195ac46745825634755f41e8e31260c Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 6 Dec 2013 16:29:43 +0100 Subject: ddb/db_output.c: remove forward declaration * ddb/db_input.h (db_check_interrupt): Add prototype. * ddb/db_output.c: Include ddb/db_input.h. (db_check_interrupt): Remove forward declaration. --- ddb/db_input.h | 2 ++ ddb/db_output.c | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ddb/db_input.h b/ddb/db_input.h index 316e3268..77f07bb6 100644 --- a/ddb/db_input.h +++ b/ddb/db_input.h @@ -25,4 +25,6 @@ extern int db_readline (char *lstart, int lsize); +extern void db_check_interrupt(void); + #endif /* _DDB_DB_INPUT_H_ */ diff --git a/ddb/db_output.c b/ddb/db_output.c index 91ade913..e0ea2f3f 100644 --- a/ddb/db_output.c +++ b/ddb/db_output.c @@ -42,6 +42,7 @@ #include #include #include +#include /* * Character output - tracks position in line. @@ -74,8 +75,6 @@ int db_tab_stop_width = 8; /* how wide are tab stops? */ int db_max_line = DB_MAX_LINE; /* output max lines */ int db_max_width = DB_MAX_WIDTH; /* output line width */ -extern void db_check_interrupt(); - /* * Force pending whitespace. */ -- cgit v1.2.3 From 2fdf4f0db1ce5c3cd0dd0a139316d0056c89669a Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 6 Dec 2013 16:29:44 +0100 Subject: i386/i386at/lpr.c: fix argument list * i386/i386at/lpr.c (lprprobe): Fix argument list. --- i386/i386at/lpr.c | 1 + 1 file changed, 1 insertion(+) diff --git a/i386/i386at/lpr.c b/i386/i386at/lpr.c index 4431c370..39423351 100644 --- a/i386/i386at/lpr.c +++ b/i386/i386at/lpr.c @@ -63,6 +63,7 @@ int lpr_alive[NLPR]; int lprprobe(port, dev) +int port; struct bus_device *dev; { u_short addr = (u_short) dev->address; -- cgit v1.2.3 From a05fa165cc88ee47f69ef331bf8e39c18df7ec3d Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 6 Dec 2013 16:29:45 +0100 Subject: i386/i386at/model_dep.c: fix argument list * i386/i386at/model_dep.c (timemmap): Fix argument list. --- i386/i386at/model_dep.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/i386/i386at/model_dep.c b/i386/i386at/model_dep.c index 30ef2043..93aa87da 100644 --- a/i386/i386at/model_dep.c +++ b/i386/i386at/model_dep.c @@ -616,6 +616,8 @@ void c_boot_entry(vm_offset_t bi) int timemmap(dev, off, prot) + int dev; + int off; vm_prot_t prot; { extern time_value_t *mtime; -- cgit v1.2.3 From cc206bc51a08eb4c2a4908697c3585c44a91a8e9 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 6 Dec 2013 16:29:46 +0100 Subject: i386/i386at/pic_isa.c: remove forward declaration * i386/Makefrag.am: Include i386/i386/hardclock.h. * i386/i386/hardclock.h: New file. Add copyright. [_I386_HARDCLOCK_H_]: Add ifndef. (hardclock): Add prototype. * i386/i386at/pic_isa.c (hardclock): Remove forward declaration. Include i386/hardclock.h. --- i386/Makefrag.am | 1 + i386/i386/hardclock.h | 29 +++++++++++++++++++++++++++++ i386/i386at/pic_isa.c | 2 +- 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 i386/i386/hardclock.h diff --git a/i386/Makefrag.am b/i386/Makefrag.am index 160ae17a..23437c61 100644 --- a/i386/Makefrag.am +++ b/i386/Makefrag.am @@ -147,6 +147,7 @@ EXTRA_DIST += \ if PLATFORM_at libkernel_a_SOURCES += \ i386/i386/hardclock.c \ + i386/i386/hardclock.h \ i386/i386/io_map.c \ i386/i386/pic.c \ i386/i386/pic.h \ diff --git a/i386/i386/hardclock.h b/i386/i386/hardclock.h new file mode 100644 index 00000000..38c51ea6 --- /dev/null +++ b/i386/i386/hardclock.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2013 Free Software Foundation. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef _I386_HARDCLOCK_H_ +#define _I386_HARDCLOCK_H_ + +void hardclock( + int iunit, + int old_ipl, + int irq, + char *ret_addr, + struct i386_interrupt_state *regs); + +#endif /* _I386_HARDCLOCK_H_ */ diff --git a/i386/i386at/pic_isa.c b/i386/i386at/pic_isa.c index e48fb507..0b36534e 100644 --- a/i386/i386at/pic_isa.c +++ b/i386/i386at/pic_isa.c @@ -28,10 +28,10 @@ #include #include #include +#include #include /* These interrupts are always present */ -extern void hardclock(); void (*ivect[NINTR])() = { /* 00 */ hardclock, /* always */ -- cgit v1.2.3 From 894bc2481af492e85dc5718b847937868e475379 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 6 Dec 2013 16:29:47 +0100 Subject: vm/vm_pageout.c: remove forward declarations * vm/vm_pageout.c (vm_pageout_continue, vm_pageout_scan_continue): Remove forward declarations. * vm/vm_pageout.h (vm_pageout_continue, vm_pageout_scan_continue): Add prototypes. --- vm/vm_pageout.c | 3 --- vm/vm_pageout.h | 4 ++++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/vm/vm_pageout.c b/vm/vm_pageout.c index 38195ade..46ba56b8 100644 --- a/vm/vm_pageout.c +++ b/vm/vm_pageout.c @@ -159,9 +159,6 @@ #define VM_PAGEOUT_RESERVED_REALLY(reserve) ((reserve) - 40) #endif /* VM_PAGEOUT_RESERVED_REALLY */ -extern void vm_pageout_continue(); -extern void vm_pageout_scan_continue(); - unsigned int vm_pageout_reserved_internal = 0; unsigned int vm_pageout_reserved_really = 0; diff --git a/vm/vm_pageout.h b/vm/vm_pageout.h index 90e45a77..7e3e4e47 100644 --- a/vm/vm_pageout.h +++ b/vm/vm_pageout.h @@ -46,4 +46,8 @@ extern void vm_pageout_page(vm_page_t, boolean_t, boolean_t); extern void vm_pageout(void); +extern void vm_pageout_continue(void); + +extern void vm_pageout_scan_continue(void); + #endif /* _VM_VM_PAGEOUT_H_ */ -- cgit v1.2.3 From 8ea6b217fb1ded91dd764ac38cde577190879c2d Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 6 Dec 2013 16:29:48 +0100 Subject: vm/vm_object.c: remove unused variable * vm/vm_object.c (vm_object_terminate_remove_all): Remove unused variable. --- vm/vm_object.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/vm/vm_object.c b/vm/vm_object.c index e1264f1a..582487e6 100644 --- a/vm/vm_object.c +++ b/vm/vm_object.c @@ -522,8 +522,6 @@ void vm_object_deallocate( } } -boolean_t vm_object_terminate_remove_all = FALSE; - /* * Routine: vm_object_terminate * Purpose: -- cgit v1.2.3 From 57f37685f5b23170093ae69cbbe656a0288ea60e Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 6 Dec 2013 16:29:49 +0100 Subject: vm/vm_map.c: use boolean instead of an int * vm/vm_map.c (vm_map_pmap_enter_print, vm_map_pmap_enter_enable): Use boolean instead of an int. --- vm/vm_map.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vm/vm_map.c b/vm/vm_map.c index 914741ec..55ceb75e 100644 --- a/vm/vm_map.c +++ b/vm/vm_map.c @@ -671,8 +671,8 @@ kern_return_t vm_map_find_entry(map, address, size, mask, object, o_entry) return(KERN_SUCCESS); } -int vm_map_pmap_enter_print = FALSE; -int vm_map_pmap_enter_enable = FALSE; +boolean_t vm_map_pmap_enter_print = FALSE; +boolean_t vm_map_pmap_enter_enable = FALSE; /* * Routine: vm_map_pmap_enter -- cgit v1.2.3 From e849c67ce712f5fdc6812c4c5b19421bc59f8c0f Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 6 Dec 2013 16:29:52 +0100 Subject: kern/startup.c: use boolean values * kern/startup.c (reboot_on_panic): Use boolean values. --- kern/startup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kern/startup.c b/kern/startup.c index be83f6b4..78c210d2 100644 --- a/kern/startup.c +++ b/kern/startup.c @@ -68,7 +68,7 @@ #endif /* MACH_KDB */ #if ! MACH_KBD -boolean_t reboot_on_panic = 1; +boolean_t reboot_on_panic = TRUE; #endif #if NCPUS > 1 @@ -103,7 +103,7 @@ void setup_main() } #else /* MACH_KDB */ if (strstr (kernel_cmdline, "-H ")) { - reboot_on_panic = 0; + reboot_on_panic = FALSE; } #endif /* MACH_KDB */ -- cgit v1.2.3 From 7eee86071820dfe40d612f1daf488a983e30afe9 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 6 Dec 2013 16:29:57 +0100 Subject: i386/i386at/com.c: fix initialization from incompatible pointer type * i386/i386at/com.c (comprobe): Modify argument types. (comprobe): Cast from (struct bus_ctrl *) to (struct bus_device *). comprobe_general() uses only a small subset of members, so it's all the same which struct it is. * i386/i386at/com.h (comprobe): Modify argument types. --- i386/i386at/com.c | 4 ++-- i386/i386at/com.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/i386/i386at/com.c b/i386/i386at/com.c index 7b184e33..4a62bb7e 100644 --- a/i386/i386at/com.c +++ b/i386/i386at/com.c @@ -169,9 +169,9 @@ comprobe_general(struct bus_device *dev, int noisy) * all of bus_device_init */ int -comprobe(int port, struct bus_device *dev) +comprobe(vm_offset_t port, struct bus_ctlr *dev) { - return comprobe_general(dev, /*noisy*/ 0); + return comprobe_general((struct bus_device *)dev, /*noisy*/ 0); } /* diff --git a/i386/i386at/com.h b/i386/i386at/com.h index ae9434d1..81fccfa6 100644 --- a/i386/i386at/com.h +++ b/i386/i386at/com.h @@ -51,7 +51,7 @@ extern int comcngetc(dev_t dev, int wait); extern int comcnputc(dev_t dev, int c); extern void comintr(int unit); -int comprobe(int port, struct bus_device *dev); +int comprobe(vm_offset_t port, struct bus_ctlr *dev); int commctl(struct tty *tp, int bits, int how); void comstart(struct tty *tp); void comstop(struct tty *tp, int flags); -- cgit v1.2.3 From eb64b7283f17a4380b0b2aa553afc52d2468b980 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 6 Dec 2013 16:29:58 +0100 Subject: i386/i386at/com.c: fix assignment from incompatible pointer type * device/tty.h (tty): Modify so that correct argument list and return type is listed. --- device/tty.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/device/tty.h b/device/tty.h index 2fafa42c..a931e337 100644 --- a/device/tty.h +++ b/device/tty.h @@ -72,8 +72,8 @@ struct tty { * Items beyond this point should be removed to device-specific * extension structures. */ - int (*t_getstat)(); /* routine to get status */ - int (*t_setstat)(); /* routine to set status */ + io_return_t (*t_getstat)(dev_t, int, int *, natural_t *); /* routine to get status */ + io_return_t (*t_setstat)(dev_t, int, int *, natural_t); /* routine to set status */ dev_ops_t t_tops; /* another device to possibly push through */ }; -- cgit v1.2.3 From a6513fde6d4ae0ae6759a9a6b0f805b3e4921c22 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 6 Dec 2013 16:30:00 +0100 Subject: i386/i386at/lpr.c: fix initalization from incompatible pointer type * i386/i386at/lpr.c (lprprobe): Modify argument types. * i386/i386at/lpr.h (lprprobe): Likewise. --- i386/i386at/lpr.c | 4 ++-- i386/i386at/lpr.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/i386/i386at/lpr.c b/i386/i386at/lpr.c index 39423351..218f20df 100644 --- a/i386/i386at/lpr.c +++ b/i386/i386at/lpr.c @@ -63,8 +63,8 @@ int lpr_alive[NLPR]; int lprprobe(port, dev) -int port; -struct bus_device *dev; +vm_offset_t port; +struct bus_ctlr *dev; { u_short addr = (u_short) dev->address; int unit = dev->unit; diff --git a/i386/i386at/lpr.h b/i386/i386at/lpr.h index 820d0ab7..d2b9d4bf 100644 --- a/i386/i386at/lpr.h +++ b/i386/i386at/lpr.h @@ -36,7 +36,7 @@ #define INTR_ENAB(addr) (addr + 2) extern void lprintr(int unit); -int lprprobe(int port, struct bus_device *dev); +int lprprobe(vm_offset_t port, struct bus_ctlr *dev); void lprstop(struct tty *tp, int flags); void lprstart(struct tty *tp); void lprattach(struct bus_device *dev); -- cgit v1.2.3 From 1e2f0bcecaecb516d123db6d760c296f718bbcc1 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sun, 8 Dec 2013 12:40:07 +0100 Subject: i386/i386/db_interface.c: remove forward declaration * i386/i386/db_interface.c (db_write_bytes_user_space): Remove forward declaration. * i386/i386/db_interface.h (db_write_bytes_user_space): Add prototype. --- i386/i386/db_interface.c | 1 - i386/i386/db_interface.h | 7 +++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/i386/i386/db_interface.c b/i386/i386/db_interface.c index a59ed37e..15e486bc 100644 --- a/i386/i386/db_interface.c +++ b/i386/i386/db_interface.c @@ -505,7 +505,6 @@ db_write_bytes( pt_entry_t *ptep1 = 0; pt_entry_t oldmap1 = 0; extern char etext; - void db_write_bytes_user_space(); if ((addr < VM_MIN_KERNEL_ADDRESS) ^ ((addr + size) <= VM_MIN_KERNEL_ADDRESS)) { diff --git a/i386/i386/db_interface.h b/i386/i386/db_interface.h index e43771e0..8f276497 100644 --- a/i386/i386/db_interface.h +++ b/i386/i386/db_interface.h @@ -120,4 +120,11 @@ extern void db_load_context(pcb_t pcb); extern void cnpollc(boolean_t on); +void +db_write_bytes_user_space( + vm_offset_t addr, + int size, + char *data, + task_t task); + #endif /* _I386_DB_INTERFACE_H_ */ -- cgit v1.2.3 From 690144baccc1ea91ff87722b2a0515eebea6e148 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sun, 8 Dec 2013 12:40:12 +0100 Subject: ddb/db_aout.c (aout_db_qualified_search): use DB_SYM_NULL as return value Function aout_db_qualified_search() returns db_sym_t. Use DB_SYM_NULL as return value instead of zero. * ddb/db_aout.c (aout_db_qualified_search): Use DB_SYM_NULL as return value. --- ddb/db_aout.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ddb/db_aout.c b/ddb/db_aout.c index 9e1c3d49..54a9e646 100644 --- a/ddb/db_aout.c +++ b/ddb/db_aout.c @@ -245,19 +245,19 @@ aout_db_qualified_search(stab, file, sym, line) boolean_t in_file; if (file == 0 && sym == 0) - return(0); + return(DB_SYM_NULL); if (file) { if ((sp = aout_db_search_name(sp, ep, file, N_TEXT, &fp)) == 0) - return(0); + return(DB_SYM_NULL); } if (sym) { sp = aout_db_search_name(sp, ep, sym, (line > 0)? N_FUN: 0, &fp); if (sp == 0) - return(0); + return(DB_SYM_NULL); } if (line > 0) { if (file && !aout_db_eq_name(fp, file)) - return(0); + return(DB_SYM_NULL); found_sp = 0; if (sp->n_type == N_FUN) { /* @@ -279,7 +279,7 @@ aout_db_qualified_search(stab, file, sym, line) } } if (sp->n_type != N_SLINE || sp->n_value < func_top) - return(0); + return(DB_SYM_NULL); } else { /* * qualified by only file name -- cgit v1.2.3 From 6916384928be2fc1db19527620c57e4d93e07923 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sun, 8 Dec 2013 12:40:13 +0100 Subject: ddb/db_aout.c (aout_db_lookup): remove forward declaration * ddb/db_aout.c (db_sym_parse_and_lookup): Remove forward declaration. * ddb/db_sym.h (db_sym_parse_and_lookup): Add prototype. --- ddb/db_aout.c | 2 -- ddb/db_sym.h | 6 ++++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ddb/db_aout.c b/ddb/db_aout.c index 54a9e646..fda7f092 100644 --- a/ddb/db_aout.c +++ b/ddb/db_aout.c @@ -317,8 +317,6 @@ aout_db_lookup(stab, symstr) db_symtab_t *stab; char * symstr; { - db_sym_t db_sym_parse_and_lookup(); - return(db_sym_parse_and_lookup(aout_db_qualified_search, stab, symstr)); } diff --git a/ddb/db_sym.h b/ddb/db_sym.h index 8c1a4171..e3409e22 100644 --- a/ddb/db_sym.h +++ b/ddb/db_sym.h @@ -252,4 +252,10 @@ db_search_in_task_symbol( db_addr_t *offp, task_t task); +extern db_sym_t +db_sym_parse_and_lookup( + db_sym_t (*func)(), + db_symtab_t *symtab, + char *symstr); + #endif /* _DDB_DB_SYM_H_ */ -- cgit v1.2.3 From 9c8ac9efd5385771481968bec7d161875108dd3d Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sun, 8 Dec 2013 12:40:14 +0100 Subject: ddb/db_break.c (db_add_thread_breakpoint): fix argument list * ddb/db_break.c (db_add_thread_breakpoint): Fix argument list. --- ddb/db_break.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ddb/db_break.c b/ddb/db_break.c index 0491be78..b3f13c66 100644 --- a/ddb/db_break.c +++ b/ddb/db_break.c @@ -92,6 +92,7 @@ static int db_add_thread_breakpoint(bkpt, task_thd, count, task_bpt) db_breakpoint_t bkpt; vm_offset_t task_thd; + int count; boolean_t task_bpt; { db_thread_breakpoint_t tp; -- cgit v1.2.3 From 039ae1184c7cc855e0435004ef8d5933424be43d Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sun, 8 Dec 2013 12:40:15 +0100 Subject: ddb/db_break.c (db_find_thread_breakpoint_here): remove unnecessary cast Variable addr is already of type db_addr_t. * ddb/db_break.c (db_find_thread_breakpoint_here) (addr): Don't cast to db_addr_t. --- ddb/db_break.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ddb/db_break.c b/ddb/db_break.c index b3f13c66..f94663ae 100644 --- a/ddb/db_break.c +++ b/ddb/db_break.c @@ -181,7 +181,7 @@ db_find_thread_breakpoint_here(task, addr) { db_breakpoint_t bkpt; - bkpt = db_find_breakpoint(task, (db_addr_t)addr); + bkpt = db_find_breakpoint(task, addr); if (bkpt == 0) return(0); return(db_find_thread_breakpoint(bkpt, current_thread())); -- cgit v1.2.3 From cd79da88b148c79cec94f214c4efd07dd8069863 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sun, 8 Dec 2013 12:40:16 +0100 Subject: i386/i386at/kd.c: use io_req instead of uio Struct uio is nowhere defined and in device/buf.h the string uio is defined as io_req. Remove all declarations of uio structure and use io_req_t instead of it. * device/buf.h (uio, io_req): Remove definition. * i386/i386at/kd.c: Remove comment. (kdread): Use io_req_t. (kdwrite): Likewise. * i386/i386at/kd.h (kdread, kdwrite): Use io_req_t as argument type. --- device/buf.h | 5 ----- i386/i386at/kd.c | 6 +++--- i386/i386at/kd.h | 4 ++-- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/device/buf.h b/device/buf.h index 806eb8d8..a79ed8e4 100644 --- a/device/buf.h +++ b/device/buf.h @@ -82,11 +82,6 @@ #define B_MD1 IO_SPARE_START -/* - * Redefine uio structure - */ -#define uio io_req - /* * Redefine physio routine */ diff --git a/i386/i386at/kd.c b/i386/i386at/kd.c index 14524bf8..757bce28 100644 --- a/i386/i386at/kd.c +++ b/i386/i386at/kd.c @@ -83,7 +83,7 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include -#include /* for struct uio (!) */ +#include #include #include #include @@ -526,7 +526,7 @@ int flag; int kdread(dev, uio) int dev; -struct uio *uio; +io_req_t uio; { struct tty *tp; @@ -551,7 +551,7 @@ struct uio *uio; int kdwrite(dev, uio) int dev; -struct uio *uio; +io_req_t uio; { return((*linesw[kd_tty.t_line].l_write)(&kd_tty, uio)); } diff --git a/i386/i386at/kd.h b/i386/i386at/kd.h index 9d297d16..f5cd5fc4 100644 --- a/i386/i386at/kd.h +++ b/i386/i386at/kd.h @@ -750,8 +750,8 @@ extern void kdb_kintr(void); extern int kdopen(dev_t dev, int flag, io_req_t ior); extern void kdclose(int dev, int flag); -extern int kdread(int dev, struct uio *uio); -extern int kdwrite(int dev, struct uio *uio); +extern int kdread(int dev, io_req_t uio); +extern int kdwrite(int dev, io_req_t uio); extern io_return_t kdgetstat( dev_t dev, -- cgit v1.2.3 From c743a22c5a68d67a952acfeae9cedcd002537dde Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sun, 8 Dec 2013 12:40:17 +0100 Subject: ddb/db_command.c: use boolean values * ddb/db_command.c (db_cmd_loop_done): Use boolean values. --- ddb/db_command.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ddb/db_command.c b/ddb/db_command.c index 69fea857..b4180e26 100644 --- a/ddb/db_command.c +++ b/ddb/db_command.c @@ -301,7 +301,7 @@ db_command_list(last_cmdp, cmd_table) do { db_command(last_cmdp, cmd_table); db_skip_to_eol(); - } while (db_read_token() == tSEMI_COLON && db_cmd_loop_done == 0); + } while (db_read_token() == tSEMI_COLON && db_cmd_loop_done == FALSE); } struct db_command db_show_all_cmds[] = { @@ -409,7 +409,7 @@ db_command_loop(void) db_prev = db_dot; db_next = db_dot; - db_cmd_loop_done = 0; + db_cmd_loop_done = FALSE; while (!db_cmd_loop_done) { (void) _setjmp(db_recover = &db_jmpbuf); db_macro_level = 0; @@ -436,7 +436,7 @@ db_exec_cmd_nest(cmd, size) { struct db_lex_context lex_context; - db_cmd_loop_done = 0; + db_cmd_loop_done = FALSE; if (cmd) { db_save_lex_context(&lex_context); db_switch_input(cmd, size /**OLD, &lex_context OLD**/); @@ -444,7 +444,7 @@ db_exec_cmd_nest(cmd, size) db_command_list(&db_last_command, db_command_table); if (cmd) db_restore_lex_context(&lex_context); - return(db_cmd_loop_done == 0); + return(db_cmd_loop_done == FALSE); } void db_error(s) -- cgit v1.2.3 From 0178b269ab3e906ffc6f629b4ef62303ff85808b Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sun, 8 Dec 2013 12:40:19 +0100 Subject: ddb/db_command.c (db_command): remove forward declaration * ddb/db_command.c (db_fncall): Remove forward declaration. --- ddb/db_command.c | 1 - 1 file changed, 1 deletion(-) diff --git a/ddb/db_command.c b/ddb/db_command.c index b4180e26..2bff8291 100644 --- a/ddb/db_command.c +++ b/ddb/db_command.c @@ -176,7 +176,6 @@ db_command(last_cmdp, cmd_table) db_unread_token(t); } else if (t == tEXCL) { - void db_fncall(); db_fncall(); return; } -- cgit v1.2.3 From 1cf702c79105a4e188d9e25d3cde82b99af24261 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sun, 8 Dec 2013 12:40:21 +0100 Subject: ddb/db_examine.c (db_examine_cmd): remove forward declaration * ddb/db_examine.c (db_option): Remove forward declaration. --- ddb/db_examine.c | 1 - 1 file changed, 1 deletion(-) diff --git a/ddb/db_examine.c b/ddb/db_examine.c index a90ffa66..3f48250c 100644 --- a/ddb/db_examine.c +++ b/ddb/db_examine.c @@ -65,7 +65,6 @@ db_examine_cmd(addr, have_addr, count, modif) char * modif; { thread_t thread; - boolean_t db_option(); if (modif[0] != '\0') db_strcpy(db_examine_format, modif); -- cgit v1.2.3 From 1f8576d09048a063a5d491c16d7956fee1943bb1 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sun, 8 Dec 2013 12:40:22 +0100 Subject: ddb/db_examine.c: trivial stylistic fix for consistency * ddb/db_examine.c: Trivial stylistic fix for consistency. --- ddb/db_examine.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ddb/db_examine.c b/ddb/db_examine.c index 3f48250c..9ffcb01c 100644 --- a/ddb/db_examine.c +++ b/ddb/db_examine.c @@ -78,7 +78,7 @@ db_examine_cmd(addr, have_addr, count, modif) return; } else - if (db_option(modif,'u')) + if (db_option(modif, 'u')) thread = current_thread(); else thread = THREAD_NULL; @@ -158,7 +158,7 @@ db_examine(addr, fmt, count, task) db_printf(":\t"); break; case 'm': - db_next = db_xcdump(addr, size, count+1, task); + db_next = db_xcdump(addr, size, count + 1, task); return; default: if (db_print_position() == 0) { @@ -166,7 +166,7 @@ db_examine(addr, fmt, count, task) char * name; db_addr_t off; - db_find_task_sym_and_offset(addr,&name,&off,task); + db_find_task_sym_and_offset(addr, &name, &off, task); if (off == 0) db_printf("%s:\t", name); else -- cgit v1.2.3 From b8e3e8d4b938160d50b7e253e1acd08b1b90b0f0 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sun, 8 Dec 2013 12:40:25 +0100 Subject: ddb/db_mp.c: use boolean instead of an int * ddb/db_mp.c (db_enter_debug): Use boolean instead of an int. --- ddb/db_mp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ddb/db_mp.c b/ddb/db_mp.c index 1785e4dd..b99718e4 100644 --- a/ddb/db_mp.c +++ b/ddb/db_mp.c @@ -53,7 +53,7 @@ int db_active[NCPUS] = { 0 }; /* count recursive entries int db_slave[NCPUS] = { 0 }; /* nonzero if cpu interrupted by another cpu in debugger */ -int db_enter_debug = 0; +boolean_t db_enter_debug = FALSE; /* * Called when entering kernel debugger. -- cgit v1.2.3 From e2f988e458cb9ba80b29ad01352d264896d4c7d8 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sun, 8 Dec 2013 12:40:27 +0100 Subject: ddb/db_mp.c: definition of db_console() only if CONSOLE_ON_MASTER Function db_console() is called only if CONSOLE_ON_MASTER. If it stays this way, db_console() will not compile. I don't know if it should be removed. Maybe someone will rewrite it. * ddb/db_mp.c (db_console): Definition only if CONSOLE_ON_MASTER. * ddb/db_mp.h [CONSOLE_ON_MASTER] (db_console): Add prototype. --- ddb/db_mp.c | 4 ++-- ddb/db_mp.h | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ddb/db_mp.c b/ddb/db_mp.c index b99718e4..3dfef09c 100644 --- a/ddb/db_mp.c +++ b/ddb/db_mp.c @@ -303,7 +303,7 @@ unlock_db() simple_unlock(&db_lock); } -#ifdef sketch +#if CONSOLE_ON_MASTER void db_console() { @@ -326,7 +326,7 @@ db_console() db_cpu = my_cpu; } } -#endif /* sketch */ +#endif /* CONSOLE_ON_MASTER */ #endif /* NCPUS > 1 */ diff --git a/ddb/db_mp.h b/ddb/db_mp.h index a163d99d..722f28c7 100644 --- a/ddb/db_mp.h +++ b/ddb/db_mp.h @@ -23,4 +23,8 @@ void remote_db(void); void lock_db(void); void unlock_db(void); +#if CONSOLE_ON_MASTER +void db_console(void); +#endif /* CONSOLE_ON_MASTER */ + #endif /* _DDB_DB_MP_H_ */ -- cgit v1.2.3 From 8d2e05732d773546714a78dbc603b09d2504f1de Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sun, 8 Dec 2013 12:40:28 +0100 Subject: ddb/db_print.c: use unsigned long instead of an unsigned int Variable db_maxoff is in other files declared as unsigned long. * ddb/db_print.c (db_maxoff): Use unsigned long instead of an unsigned int. --- ddb/db_print.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ddb/db_print.c b/ddb/db_print.c index 75c914e6..fbc09608 100644 --- a/ddb/db_print.c +++ b/ddb/db_print.c @@ -53,7 +53,7 @@ #include #include -extern unsigned int db_maxoff; +extern unsigned long db_maxoff; /* ARGSUSED */ void -- cgit v1.2.3 From f2ceb891968886c2e1804b57070fe1376be6d646 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sun, 8 Dec 2013 12:40:29 +0100 Subject: Use db_addr_t instead of db_expr_t In this way everything falls into place and there is one cast less. Function db_task_printsym() is already always called with the cast to db_addr_t in the first argument. * ddb/db_aout.c (aout_db_line_at_pc): Use db_addr_t instead of db_expr_t. (aout_db_search_by_addr): Don't cast to vm_offset_t. Argument is already db_addr_t. * ddb/db_aout.h (aout_db_line_at_pc): Use db_addr_t instead of db_expr_t. * ddb/db_sym.c (db_task_printsym): Likewise. (db_line_at_pc): Likewise. * ddb/db_sym.h (db_task_printsym): Likewise. (db_line_at_pc): Likewise. * i386/i386/db_trace.c (db_task_printsym): Cast to db_addr_t instead of db_expr_t. Member swap_func is a pointer to void. --- ddb/db_aout.c | 4 ++-- ddb/db_aout.h | 2 +- ddb/db_sym.c | 4 ++-- ddb/db_sym.h | 6 +++--- i386/i386/db_trace.c | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ddb/db_aout.c b/ddb/db_aout.c index fda7f092..8ef7efb9 100644 --- a/ddb/db_aout.c +++ b/ddb/db_aout.c @@ -493,13 +493,13 @@ aout_db_line_at_pc(stab, sym, file, line, pc) db_sym_t sym; char **file; int *line; - db_expr_t pc; + db_addr_t pc; { char *func; unsigned long diff; boolean_t found; - found = aout_db_search_by_addr(stab, (vm_offset_t)pc, file, &func, line, &diff); + found = aout_db_search_by_addr(stab, pc, file, &func, line, &diff); return(found && func && *file); } diff --git a/ddb/db_aout.h b/ddb/db_aout.h index a5a00cc5..7c03d36d 100644 --- a/ddb/db_aout.h +++ b/ddb/db_aout.h @@ -28,7 +28,7 @@ aout_db_line_at_pc( db_sym_t sym, char **file, int *line, - db_expr_t pc); + db_addr_t pc); extern db_sym_t aout_db_lookup( diff --git a/ddb/db_sym.c b/ddb/db_sym.c index fb0cd964..e801e627 100644 --- a/ddb/db_sym.c +++ b/ddb/db_sym.c @@ -444,7 +444,7 @@ unsigned long db_maxoff = 0x4000; void db_task_printsym(off, strategy, task) - db_expr_t off; + db_addr_t off; db_strategy_t strategy; task_t task; { @@ -489,7 +489,7 @@ db_line_at_pc( sym, filename, linenum, pc) db_sym_t sym; char **filename; int *linenum; - db_expr_t pc; + db_addr_t pc; { return (db_last_symtab) ? X_db_line_at_pc( db_last_symtab, sym, filename, linenum, pc) : diff --git a/ddb/db_sym.h b/ddb/db_sym.h index e3409e22..cb574dd4 100644 --- a/ddb/db_sym.h +++ b/ddb/db_sym.h @@ -164,7 +164,7 @@ extern void db_symbol_values( db_symtab_t *stab, extern boolean_t db_eqname( char* src, char* dst, char c ); /* print closest symbol to a value */ -extern void db_task_printsym( db_expr_t off, +extern void db_task_printsym( db_addr_t off, db_strategy_t strategy, task_t task); @@ -205,7 +205,7 @@ extern struct db_sym_switch { db_sym_t sym, char **file, int *line, - db_expr_t pc + db_addr_t pc ); void (*symbol_values)( @@ -235,7 +235,7 @@ extern boolean_t db_line_at_pc( db_sym_t sym, char **filename, int *linenum, - db_expr_t pc); + db_addr_t pc); extern boolean_t aout_db_sym_init( char *symtab, diff --git a/i386/i386/db_trace.c b/i386/i386/db_trace.c index 3a5148ad..fb65524c 100644 --- a/i386/i386/db_trace.c +++ b/i386/i386/db_trace.c @@ -378,7 +378,7 @@ db_stack_trace_cmd( struct i386_saved_state *iss = &th->pcb->iss; db_printf("Continuation "); - db_task_printsym((db_expr_t)th->swap_func, + db_task_printsym((db_addr_t)th->swap_func, DB_STGY_PROC, th->task); db_printf("\n"); -- cgit v1.2.3 From e95d650716ec19e450baf1249d4d21025a8a289f Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sun, 8 Dec 2013 12:40:30 +0100 Subject: ddb/db_trap.c (db_task_trap): remove forward declarations * ddb/db_break.h (db_check_breakpoint_valid): Add prototype. * ddb/db_trap.c (db_init_default_thread, db_check_breakpoint_valid): Remove forward declarations. --- ddb/db_break.h | 2 ++ ddb/db_trap.c | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ddb/db_break.h b/ddb/db_break.h index 89e78894..e323a5f4 100644 --- a/ddb/db_break.h +++ b/ddb/db_break.h @@ -98,4 +98,6 @@ void db_breakpoint_cmd( db_expr_t count, char * modif); +extern void db_check_breakpoint_valid(void); + #endif /* _DDB_DB_BREAK_H_ */ diff --git a/ddb/db_trap.c b/ddb/db_trap.c index d2abfbda..28f64d14 100644 --- a/ddb/db_trap.c +++ b/ddb/db_trap.c @@ -61,8 +61,6 @@ db_task_trap(type, code, user_space) jmp_buf_t *prev; boolean_t bkpt; boolean_t watchpt; - void db_init_default_thread(); - void db_check_breakpoint_valid(); task_t task_space; task_space = db_target_space(current_thread(), user_space); -- cgit v1.2.3 From fe7b4a8bbfd41c90f16ab4b1bcd82babb811c7a7 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Mon, 9 Dec 2013 23:57:16 +0100 Subject: i386: move prototypes to fix implicit declaration of function This fixes the implicit declarations in kern/machine.c and kern/debug.c. * i386/i386/model_dep.h (halt_cpu, halt_all_cpus): Add prototypes. * i386/i386at/model_dep.h (halt_cpu, halt_all_cpus): Remove prototypes. --- i386/i386/model_dep.h | 10 ++++++++++ i386/i386at/model_dep.h | 10 ---------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/i386/i386/model_dep.h b/i386/i386/model_dep.h index c45b756c..ab2738f8 100644 --- a/i386/i386/model_dep.h +++ b/i386/i386/model_dep.h @@ -40,6 +40,16 @@ extern void resettodr (void); extern void startrtclock (void); +/* + * Halt a cpu. + */ +extern void halt_cpu (void) __attribute__ ((noreturn)); + +/* + * Halt the system or reboot. + */ +extern void halt_all_cpus (boolean_t reboot) __attribute__ ((noreturn)); + /* * More-specific code provides these; * they indicate the total extent of physical memory diff --git a/i386/i386at/model_dep.h b/i386/i386at/model_dep.h index 73573140..37cd86c9 100644 --- a/i386/i386at/model_dep.h +++ b/i386/i386at/model_dep.h @@ -23,16 +23,6 @@ extern int timemmap(int dev, int off, vm_prot_t prot); -/* - * Halt a cpu. - */ -extern void halt_cpu (void) __attribute__ ((noreturn)); - -/* - * Halt the system or reboot. - */ -extern void halt_all_cpus (boolean_t reboot) __attribute__ ((noreturn)); - void inittodr(void); boolean_t init_alloc_aligned(vm_size_t size, vm_offset_t *addrp); -- cgit v1.2.3 From 29ea7c6c7236c372ae0956651acc1bc25384b368 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Mon, 9 Dec 2013 23:57:17 +0100 Subject: i386/i386at/kd_event.c (kbdsetstat): fix difference in signedness * i386/i386at/kd_event.c (X_kdb_enter_init, X_kdb_exit_init): Cast first arguments to (unsigned int *). --- i386/i386at/kd_event.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/i386/i386at/kd_event.c b/i386/i386at/kd_event.c index db14225c..4e7b00a6 100644 --- a/i386/i386at/kd_event.c +++ b/i386/i386at/kd_event.c @@ -182,9 +182,9 @@ io_return_t kbdsetstat(dev, flavor, data, count) kd_setleds1 (*data); break; case K_X_KDB_ENTER: - return X_kdb_enter_init(data, count); + return X_kdb_enter_init((unsigned int *)data, count); case K_X_KDB_EXIT: - return X_kdb_exit_init(data, count); + return X_kdb_exit_init((unsigned int *)data, count); default: return (D_INVALID_OPERATION); } -- cgit v1.2.3 From 3eea18b7787b5efaadbee5d99a729a0f4c8dedb8 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Mon, 9 Dec 2013 23:57:18 +0100 Subject: i386/i386/db_interface.c: use vm_offset_t instead of an unsigned int This is more in line with how the function db_user_to_kernel_address() is called. In this way there is one cast less and several GCC warnings are silenced. * i386/i386/db_interface.c (db_set_hw_watchpoint) (kern_addr): Use vm_offset_t instead of an unsigned int. (db_user_to_kernel_address) (kaddr): Likewise. (db_user_to_kernel_address) (ptetokv): Don't cast return value. (db_read_bytes) (kern_addr): Use vm_offset_t instead of an unsigned int. (db_write_bytes_user_space) (kern_addr): Likewise. (db_task_name) (vaddr, kaddr): Likewise. * i386/i386/db_interface.h (db_user_to_kernel_address) (kaddr): Likewise. --- i386/i386/db_interface.c | 12 ++++++------ i386/i386/db_interface.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/i386/i386/db_interface.c b/i386/i386/db_interface.c index 15e486bc..f07c12c7 100644 --- a/i386/i386/db_interface.c +++ b/i386/i386/db_interface.c @@ -177,7 +177,7 @@ db_set_hw_watchpoint( { vm_size_t size = watch->hiaddr - watch->loaddr; db_addr_t addr = watch->loaddr; - unsigned int kern_addr; + vm_offset_t kern_addr; if (num >= 4) return FALSE; @@ -412,7 +412,7 @@ int db_user_to_kernel_address( task_t task, vm_offset_t addr, - unsigned int *kaddr, + vm_offset_t *kaddr, int flag) { pt_entry_t *ptp; @@ -439,7 +439,7 @@ db_user_to_kernel_address( } return(-1); } - *kaddr = (unsigned)ptetokv(*ptp) + (addr & (INTEL_PGBYTES-1)); + *kaddr = ptetokv(*ptp) + (addr & (INTEL_PGBYTES-1)); return(0); } @@ -456,7 +456,7 @@ db_read_bytes( { char *src; int n; - unsigned kern_addr; + vm_offset_t kern_addr; src = (char *)addr; if ((addr >= VM_MIN_KERNEL_ADDRESS && addr < VM_MAX_KERNEL_ADDRESS) || task == TASK_NULL) { @@ -567,7 +567,7 @@ db_write_bytes_user_space( { char *dst; int n; - unsigned kern_addr; + vm_offset_t kern_addr; while (size > 0) { if (db_user_to_kernel_address(task, addr, &kern_addr, 1) < 0) @@ -726,7 +726,7 @@ db_task_name( { char *p; int n; - unsigned vaddr, kaddr; + vm_offset_t vaddr, kaddr; unsigned sp; if (task->map->pmap == kernel_pmap) { diff --git a/i386/i386/db_interface.h b/i386/i386/db_interface.h index 8f276497..d41a97df 100644 --- a/i386/i386/db_interface.h +++ b/i386/i386/db_interface.h @@ -58,7 +58,7 @@ extern boolean_t db_phys_eq ( extern int db_user_to_kernel_address( task_t task, vm_offset_t addr, - unsigned int *kaddr, + vm_offset_t *kaddr, int flag); extern void db_task_name (task_t task); -- cgit v1.2.3 From 8d613a9cf8065e729694116132ec7ce703dabf10 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Mon, 9 Dec 2013 23:57:23 +0100 Subject: device/chario.c: trivial stylistic fix for consistency * device/chario.c: Trivial stylistic fix for consistency. --- device/chario.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/device/chario.c b/device/chario.c index 8d688577..c2887d04 100644 --- a/device/chario.c +++ b/device/chario.c @@ -907,7 +907,7 @@ void ttypush( if (state & TS_MIN_TO_RCV) { /* a character was received */ tp->t_state = state & ~TS_MIN_TO_RCV; - timeout(ttypush,tp,pdma_timeouts[tp->t_ispeed]); + timeout(ttypush, tp, pdma_timeouts[tp->t_ispeed]); } else { @@ -1004,7 +1004,7 @@ void ttyinput_many( * Do not want to overflow input queue */ if (tp->t_inq.c_cc < tp->t_inq.c_hog) - count -= b_to_q( chars, count, &tp->t_inq); + count -= b_to_q(chars, count, &tp->t_inq); tty_queue_completion(&tp->t_delayed_read); } -- cgit v1.2.3 From 8a3e30669d914581c47554b2a0325cafee147712 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Mon, 9 Dec 2013 23:57:25 +0100 Subject: device/cirbuf.c (cb_alloc): use vm_size_t instead of an int This is more in line with the call to kalloc() in cb_alloc(). * device/chario.c (tty_inq_size, tty_outq_size): Use unsigned int instead if an int. * device/cirbuf.c (cb_alloc) (buf_size): Use vm_size_t instead of an int. * device/cirbuf.h (cb_alloc) (buf_size): Likewise. --- device/chario.c | 6 +++--- device/cirbuf.c | 2 +- device/cirbuf.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/device/chario.c b/device/chario.c index c2887d04..91bd8e8a 100644 --- a/device/chario.c +++ b/device/chario.c @@ -80,9 +80,9 @@ struct ldisc_switch linesw[] = { /* * Sizes for input and output circular buffers. */ -const int tty_inq_size = 4096; /* big nuf */ -const int tty_outq_size = 2048; /* Must be bigger that tthiwat */ -boolean_t pdma_default = TRUE; /* turn pseudo dma on by default */ +const unsigned int tty_inq_size = 4096; /* big nuf */ +const unsigned int tty_outq_size = 2048; /* Must be bigger that tthiwat */ +boolean_t pdma_default = TRUE; /* turn pseudo dma on by default */ /* * compute pseudo-dma tables diff --git a/device/cirbuf.c b/device/cirbuf.c index 292b888d..39b1da20 100644 --- a/device/cirbuf.c +++ b/device/cirbuf.c @@ -270,7 +270,7 @@ void cb_clear(struct cirbuf *cb) void cb_alloc( struct cirbuf *cb, - int buf_size) + vm_size_t buf_size) { char *buf; diff --git a/device/cirbuf.h b/device/cirbuf.h index 5e4360b1..64771ce1 100644 --- a/device/cirbuf.h +++ b/device/cirbuf.h @@ -55,7 +55,7 @@ extern int b_to_q(char *, int, struct cirbuf *); extern void ndflush(struct cirbuf *, int); extern void cb_clear(struct cirbuf *); -extern void cb_alloc(struct cirbuf *, int); +extern void cb_alloc(struct cirbuf *, vm_size_t); extern void cb_free(struct cirbuf *); #endif /* _DEVICE_CIRBUF_H_ */ -- cgit v1.2.3 From 25140ed6e982b49329f202ba06ea2a488cd30f6b Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Mon, 9 Dec 2013 23:57:26 +0100 Subject: device/cirbuf.c (cb_free): use vm_size_t instead of an int This is more in line with the call to kfree() in cb_free(). * device/cirbuf.c (cb_free) (size): Use vm_size_t instead of an int. --- device/cirbuf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/device/cirbuf.c b/device/cirbuf.c index 39b1da20..dfb06df1 100644 --- a/device/cirbuf.c +++ b/device/cirbuf.c @@ -292,7 +292,7 @@ cb_alloc( void cb_free(struct cirbuf *cb) { - int size; + vm_size_t size; size = cb->c_end - cb->c_start; kfree((vm_offset_t)cb->c_start, size); -- cgit v1.2.3 From eaafcf0c76fe5a21f180c1a00a590e5f1d296ebc Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Mon, 9 Dec 2013 23:57:27 +0100 Subject: device/cons.c: fix argument list * device/cons.c (romgetc, romputc): Fix argument list. --- device/cons.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/device/cons.c b/device/cons.c index b35e79f4..285fb99e 100644 --- a/device/cons.c +++ b/device/cons.c @@ -42,8 +42,8 @@ static struct consdev *cn_tab = 0; /* physical console device info */ * is enabled. This can be useful to debug (or catch panics from) code early * in the bootstrap procedure. */ -int (*romgetc)() = 0; -void (*romputc)() = 0; +int (*romgetc)(char c) = 0; +void (*romputc)(char c) = 0; #if CONSBUFSIZE > 0 /* -- cgit v1.2.3 From a2622ab4a8b8dcf7feaaf9c466169feb929bcf2e Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Mon, 9 Dec 2013 23:57:28 +0100 Subject: device/dev_pager.c (device_pager_data_request): remove forward declaration * Makefrag.am: Include device/dev_pager.h. * device/dev_pager.c: Likewise. (device_map_page): Remove forward declaration. * device/dev_pager.h: New file. Add copyright. [_DEVICE_DEV_PAGER_H_]: Add ifndef. (device_map_page): Add prototype. --- Makefrag.am | 1 + device/dev_pager.c | 2 +- device/dev_pager.h | 24 ++++++++++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 device/dev_pager.h diff --git a/Makefrag.am b/Makefrag.am index 39da40db..155635bb 100644 --- a/Makefrag.am +++ b/Makefrag.am @@ -292,6 +292,7 @@ libkernel_a_SOURCES += \ device/dev_master.h \ device/dev_name.c \ device/dev_pager.c \ + device/dev_pager.h \ device/device_init.c \ device/device_init.h \ device/device_port.h \ diff --git a/device/dev_pager.c b/device/dev_pager.c index 1a60045c..8a2797c6 100644 --- a/device/dev_pager.c +++ b/device/dev_pager.c @@ -55,6 +55,7 @@ #include #include #include +#include extern vm_offset_t block_io_mmap(); /* dummy routine to allow mmap for block devices */ @@ -344,7 +345,6 @@ kern_return_t device_pager_data_request( if (ds->type == CHAR_PAGER_TYPE) { vm_object_t object; - vm_offset_t device_map_page(void *, vm_offset_t); object = vm_object_lookup(pager_request); if (object == VM_OBJECT_NULL) { diff --git a/device/dev_pager.h b/device/dev_pager.h new file mode 100644 index 00000000..193edc4b --- /dev/null +++ b/device/dev_pager.h @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2013 Free Software Foundation. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef _DEVICE_DEV_PAGER_H_ +#define _DEVICE_DEV_PAGER_H_ + +vm_offset_t device_map_page(void *dsp, vm_offset_t offset); + +#endif /* _DEVICE_DEV_PAGER_H_ */ -- cgit v1.2.3 From be8f70ce365dbfff087478ef3d3d90765465bbf2 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Mon, 9 Dec 2013 23:57:29 +0100 Subject: device/dev_pager.c (device_pager_data_request): cast to (void *) instead to (char *) * device/dev_pager.c (device_pager_data_request) (vm_object_page_map) (ds): Cast to (void *) instead to (char *). --- device/dev_pager.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/device/dev_pager.c b/device/dev_pager.c index 8a2797c6..35c79b33 100644 --- a/device/dev_pager.c +++ b/device/dev_pager.c @@ -357,7 +357,7 @@ kern_return_t device_pager_data_request( vm_object_page_map(object, offset, length, - device_map_page, (char *)ds); + device_map_page, (void *)ds); vm_object_deallocate(object); } -- cgit v1.2.3 From 3d30d7626d6041a8899137e6f39e6a26cae1f888 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Mon, 9 Dec 2013 23:57:32 +0100 Subject: device/dev_pager.c (device_pager_data_request_done): remove unnecessary cast The argument to trunc_page() is already cast to vm_offset_t in the macro itself. * device/dev_pager.c (device_pager_data_request_done) (trunc_page) (io_data): Don't cast to vm_offset_t. --- device/dev_pager.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/device/dev_pager.c b/device/dev_pager.c index 35c79b33..13300374 100644 --- a/device/dev_pager.c +++ b/device/dev_pager.c @@ -428,7 +428,7 @@ boolean_t device_pager_data_request_done(io_req_t ior) size_read = ior->io_count - ior->io_residual; } - start_alloc = trunc_page((vm_offset_t)ior->io_data); + start_alloc = trunc_page(ior->io_data); end_alloc = start_alloc + round_page(ior->io_alloc_size); if (ior->io_error == D_SUCCESS) { -- cgit v1.2.3 From b060efcc7a81bcfc2fabcb242ab8f6312c3aa78f Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Mon, 9 Dec 2013 23:57:33 +0100 Subject: device/dev_pager.c: remove forward declaration * Makefrag.am: Include device/blkio.h. * device/blkio.h: New file. Add copyright. [_DEVICE_BLKIO_H_]: Add ifndef. (block_io_mmap): Add prototype. * device/dev_pager.c: Include device/blkio.h. (block_io_mmap): Remove forward declaration. --- Makefrag.am | 1 + device/blkio.h | 24 ++++++++++++++++++++++++ device/dev_pager.c | 4 +--- 3 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 device/blkio.h diff --git a/Makefrag.am b/Makefrag.am index 155635bb..c1387bd3 100644 --- a/Makefrag.am +++ b/Makefrag.am @@ -279,6 +279,7 @@ EXTRA_DIST += \ # TODO. Functions in device/subrs.c should each be moved elsewhere. libkernel_a_SOURCES += \ device/blkio.c \ + device/blkio.h \ device/buf.h \ device/chario.c \ device/chario.h \ diff --git a/device/blkio.h b/device/blkio.h new file mode 100644 index 00000000..13a16690 --- /dev/null +++ b/device/blkio.h @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2013 Free Software Foundation. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef _DEVICE_BLKIO_H_ +#define _DEVICE_BLKIO_H_ + +extern vm_offset_t block_io_mmap(void); + +#endif /* _DEVICE_BLKIO_H_ */ diff --git a/device/dev_pager.c b/device/dev_pager.c index 13300374..7bb7bd9e 100644 --- a/device/dev_pager.c +++ b/device/dev_pager.c @@ -56,9 +56,7 @@ #include #include #include - -extern vm_offset_t block_io_mmap(); /* dummy routine to allow - mmap for block devices */ +#include /* * The device pager routines are called directly from the message -- cgit v1.2.3 From f66e92d3627d28ec7f62ec9b6a57f36373b7209c Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Mon, 9 Dec 2013 23:57:34 +0100 Subject: device/dev_pager.c: remove forward declarations * device/dev_pager.c (device_pager_data_request_done, device_pager_data_write_done): Remove forward declarations. * device/dev_pager.h (device_pager_data_request_done, device_pager_data_write_done): Add prototypes. --- device/dev_pager.c | 4 ---- device/dev_pager.h | 4 ++++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/device/dev_pager.c b/device/dev_pager.c index 7bb7bd9e..97e417e0 100644 --- a/device/dev_pager.c +++ b/device/dev_pager.c @@ -317,10 +317,6 @@ void device_pager_release(memory_object_t object) boolean_t device_pager_debug = FALSE; -boolean_t device_pager_data_request_done(); /* forward */ -boolean_t device_pager_data_write_done(); /* forward */ - - kern_return_t device_pager_data_request( ipc_port_t pager, ipc_port_t pager_request, diff --git a/device/dev_pager.h b/device/dev_pager.h index 193edc4b..7f97ee7e 100644 --- a/device/dev_pager.h +++ b/device/dev_pager.h @@ -21,4 +21,8 @@ vm_offset_t device_map_page(void *dsp, vm_offset_t offset); +boolean_t device_pager_data_request_done(io_req_t ior); + +boolean_t device_pager_data_write_done(io_req_t ior); + #endif /* _DEVICE_DEV_PAGER_H_ */ -- cgit v1.2.3 From 8ae2160beab7e58c60265648b21b3c1754fe4989 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Mon, 9 Dec 2013 23:57:40 +0100 Subject: device/net_io.c: remove forward declarations * device/net_io.c (bpf_hash, net_do_filter, bpf_do_filter, hash_ent_remove, net_free_dead_infp, net_free_dead_entp, bpf_validate, bpf_eq, net_add_q_info, bpf_match): Remove forward declarations. * device/net_io.h (net_rcv_port, net_hash_entry, net_hash_header): Declare forward. (bpf_hash, net_do_filter, bpf_do_filter, hash_ent_remove, net_free_dead_infp, net_free_dead_entp, bpf_validate, bpf_eq, net_add_q_info, bpf_match): Add prototypes. --- device/net_io.c | 38 ------------------------------------- device/net_io.h | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 38 deletions(-) diff --git a/device/net_io.c b/device/net_io.c index ee475efc..b3ec2926 100644 --- a/device/net_io.c +++ b/device/net_io.c @@ -305,13 +305,10 @@ typedef struct net_rcv_port *net_rcv_port_t; struct kmem_cache net_rcv_cache; /* cache of net_rcv_port structs */ - #define NET_HASH_SIZE 256 #define N_NET_HASH 4 #define N_NET_HASH_KEYS 4 -unsigned int bpf_hash (int, unsigned int *); - /* * A single hash entry. */ @@ -351,7 +348,6 @@ decl_simple_lock_data(,net_hash_header_lock) (elt) = (net_hash_entry_t) queue_next((queue_entry_t) (elt)); \ } while ((elt) != (head)); - #define FILTER_ITERATE(if_port_list, fp, nextfp, chain) \ for ((fp) = (net_rcv_port_t) queue_first(if_port_list); \ !queue_end(if_port_list, (queue_entry_t)(fp)); \ @@ -365,40 +361,6 @@ decl_simple_lock_data(,net_hash_header_lock) (dead) = (queue_entry_t)(entry_p); \ } -extern boolean_t net_do_filter(); /* CSPF */ -extern int bpf_do_filter(); /* BPF */ - -int hash_ent_remove ( - struct ifnet *ifp, - net_hash_header_t hp, - int used, - net_hash_entry_t *head, - net_hash_entry_t entp, - queue_entry_t *dead_p); - -void net_free_dead_infp (queue_entry_t dead_infp); -void net_free_dead_entp (queue_entry_t dead_entp); - -int bpf_validate( - bpf_insn_t f, - int bytes, - bpf_insn_t *match); - -int bpf_eq ( - bpf_insn_t f1, - bpf_insn_t f2, - int bytes); - -int net_add_q_info (ipc_port_t rcv_port); - -int bpf_match ( - net_hash_header_t hash, - int n_keys, - unsigned int *keys, - net_hash_entry_t **hash_headpp, - net_hash_entry_t *entpp); - - /* * ethernet_priority: * diff --git a/device/net_io.h b/device/net_io.h index cbf68455..0cdd7126 100644 --- a/device/net_io.h +++ b/device/net_io.h @@ -46,6 +46,15 @@ #include #include +struct net_rcv_port; +typedef struct net_rcv_port *net_rcv_port_t; + +struct net_hash_entry; +typedef struct net_hash_entry *net_hash_entry_t; + +struct net_hash_header; +typedef struct net_hash_header *net_hash_header_t; + /* * A network packet is wrapped in a kernel message while in * the kernel. @@ -91,4 +100,53 @@ extern unsigned short int ntohs(unsigned short int); extern unsigned int htonl(unsigned int); extern unsigned short int htons(unsigned short int); +unsigned int bpf_hash(int n, unsigned int *keys); + +extern boolean_t +net_do_filter( + net_rcv_port_t infp, + char * data, + unsigned int data_count, + char * header); /* CSPF */ + +extern int +bpf_do_filter( + net_rcv_port_t infp, + char * p, + unsigned int wirelen, + char * header, + unsigned int hlen, + net_hash_entry_t **hash_headpp, + net_hash_entry_t *entpp); /* BPF */ + +int hash_ent_remove( + struct ifnet *ifp, + net_hash_header_t hp, + int used, + net_hash_entry_t *head, + net_hash_entry_t entp, + queue_entry_t *dead_p); + +void net_free_dead_infp(queue_entry_t dead_infp); +void net_free_dead_entp (queue_entry_t dead_entp); + +int bpf_validate( + bpf_insn_t f, + int bytes, + bpf_insn_t *match); + +int bpf_eq( + bpf_insn_t f1, + bpf_insn_t f2, + int bytes); + +int net_add_q_info(ipc_port_t rcv_port); + +int bpf_match ( + net_hash_header_t hash, + int n_keys, + unsigned int *keys, + net_hash_entry_t **hash_headpp, + net_hash_entry_t *entpp); + #endif /* _DEVICE_NET_IO_H_ */ -- cgit v1.2.3 From af0c711a68e0ca4b8aa4e3e25fdf1f2206ec0911 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Mon, 9 Dec 2013 23:57:44 +0100 Subject: device/subrs.c: use io_req_t instead of struct buf Struct buf is not defined. Use io_req_t instead of it. * device/subrs.c (harderr) (bp): Change name to ior and use io_req_t as type instead of (struct buf *). (harderr) (minor): Use io_unit instead of b_dev. (harderr): Use io_recnum instead of b_blkno. (gateblk): Use io_req_t as return value instead of (struct buf *). (brelse) (bp): Change name to ior and use io_req_t as type instead of (struct buf *). (brelse) (ior): Remove variable. --- device/subrs.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/device/subrs.c b/device/subrs.c index 0382bc65..0a7d690c 100644 --- a/device/subrs.c +++ b/device/subrs.c @@ -40,15 +40,15 @@ /* * Print out disk name and block number for hard disk errors. */ -void harderr(bp, cp) - struct buf *bp; +void harderr(ior, cp) + io_req_t ior; char * cp; { printf("%s%d%c: hard error sn%d ", cp, - minor(bp->b_dev) >> 3, - 'a' + (minor(bp->b_dev) & 0x7), - bp->b_blkno); + minor(ior->io_unit) >> 3, + 'a' + (minor(ior->io_unit) & 0x7), + ior->io_recnum); } /* @@ -103,7 +103,7 @@ void wakeup(channel) thread_wakeup((event_t) channel); } -struct buf * +io_req_t geteblk(size) int size; { @@ -128,11 +128,9 @@ geteblk(size) return (ior); } -void brelse(bp) - struct buf *bp; +void brelse(ior) + io_req_t ior; { - io_req_t ior = bp; - (void) vm_deallocate(kernel_map, (vm_offset_t) ior->io_data, ior->io_alloc_size); -- cgit v1.2.3 From f167a7b8c8aaa0f5522303566a5b48d4d89782ef Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Wed, 11 Dec 2013 00:01:34 +0100 Subject: Cleanup of the memcpy(), memmove(), memcmp() and memset() calls Addresses were cast to (void *). Pointers uncasted. * device/ds_routines.c (ds_read_done) (memset) (start_sent): Cast to (void *) instead to (char *). Argument is an address. (ds_read_done) (memset) (end_data): Likewise. * i386/i386/pcb.c (thread_getstatus) (memcpy) (pm): Don't cast. Argument is a pointer. (thread_getstatus) (memcpy) (iopb): Likewise. * i386/i386at/immc.c (immc_cnputc) (memmove): Cast first argument to (void *). Argument is an address. (immc_cnputc) (memmove): Cast second argument to (void *). Argument is an address. (immc_cnputc) (memset): Cast first argument to (void *). Argument is an address. * i386/i386at/model_dep.c (i386at_init) (memcpy) (phystokv): Cast to (void *) instead to (char *). Argument is an address. * i386/intel/pmap.c (pmap_init) (memset) (addr): Likewise. * ipc/mach_debug.c (mach_port_space_info) (memset) (table_addr + size_used): Likewise. (mach_port_space_info) (memset) (tree_addr + size_used): Likewise. * kern/host.c (host_processor_sets) (memcpy) (newaddr): Likewise. (host_processor_sets) (memcpy) (addr): Likewise. * kern/xpr.c (xprbootstrap) (memset) (addr): Likewise. * vm/vm_debug.c (mach_vm_object_pages) (memset) (addr + size_used): Likewise. --- device/ds_routines.c | 4 ++-- i386/i386/pcb.c | 4 ++-- i386/i386at/immc.c | 4 ++-- i386/i386at/model_dep.c | 2 +- i386/intel/pmap.c | 2 +- ipc/mach_debug.c | 4 ++-- kern/host.c | 2 +- kern/xpr.c | 2 +- vm/vm_debug.c | 2 +- 9 files changed, 13 insertions(+), 13 deletions(-) diff --git a/device/ds_routines.c b/device/ds_routines.c index ee575e5b..d62be2bd 100644 --- a/device/ds_routines.c +++ b/device/ds_routines.c @@ -1274,9 +1274,9 @@ boolean_t ds_read_done(ior) * Zero memory that the device did not fill. */ if (start_sent < start_data) - memset((char *)start_sent, 0, start_data - start_sent); + memset((void *)start_sent, 0, start_data - start_sent); if (end_sent > end_data) - memset((char *)end_data, 0, end_sent - end_data); + memset((void *)end_data, 0, end_sent - end_data); /* diff --git a/i386/i386/pcb.c b/i386/i386/pcb.c index 02627ae3..3827f5e8 100644 --- a/i386/i386/pcb.c +++ b/i386/i386/pcb.c @@ -748,8 +748,8 @@ kern_return_t thread_getstatus(thread, flavor, tstate, count) if (thread->task->machine.iopb == 0) memset (state->pm, 0xff, sizeof state->pm); else - memcpy((char *) state->pm, - (char *) thread->task->machine.iopb, + memcpy(state->pm, + thread->task->machine.iopb, sizeof state->pm); simple_unlock (&thread->task->machine.iopb_lock); diff --git a/i386/i386at/immc.c b/i386/i386at/immc.c index b85eb07a..e0837f2c 100644 --- a/i386/i386at/immc.c +++ b/i386/i386at/immc.c @@ -49,8 +49,8 @@ immc_cnputc(unsigned char c) } else if (c == '\n') { - memmove(0xb8000, 0xb8000+80*2, 80*2*24); - memset(0xb8000+80*2*24, 0, 80*2); + memmove((void *)0xb8000, (void *)0xb8000+80*2, 80*2*24); + memset((void *)(0xb8000+80*2*24), 0, 80*2); ofs = 0; } else diff --git a/i386/i386at/model_dep.c b/i386/i386at/model_dep.c index 93aa87da..5015d410 100644 --- a/i386/i386at/model_dep.c +++ b/i386/i386at/model_dep.c @@ -369,7 +369,7 @@ i386at_init(void) int len = strlen ((char*)phystokv(boot_info.cmdline)) + 1; assert(init_alloc_aligned(round_page(len), &addr)); kernel_cmdline = (char*) phystokv(addr); - memcpy(kernel_cmdline, (char*)phystokv(boot_info.cmdline), len); + memcpy(kernel_cmdline, (void *)phystokv(boot_info.cmdline), len); boot_info.cmdline = addr; } diff --git a/i386/intel/pmap.c b/i386/intel/pmap.c index 2f1c5385..ff6a3277 100644 --- a/i386/intel/pmap.c +++ b/i386/intel/pmap.c @@ -919,7 +919,7 @@ void pmap_init() s = round_page(s); if (kmem_alloc_wired(kernel_map, &addr, s) != KERN_SUCCESS) panic("pmap_init"); - memset((char *) addr, 0, s); + memset((void *) addr, 0, s); /* * Allocate the structures first to preserve word-alignment. diff --git a/ipc/mach_debug.c b/ipc/mach_debug.c index 28dd6935..723d8646 100644 --- a/ipc/mach_debug.c +++ b/ipc/mach_debug.c @@ -447,7 +447,7 @@ mach_port_space_info( table_size - rsize_used); if (size_used != rsize_used) - memset((char *) (table_addr + size_used), 0, + memset((void *) (table_addr + size_used), 0, rsize_used - size_used); kr = vm_map_copyin(ipc_kernel_map, table_addr, rsize_used, @@ -482,7 +482,7 @@ mach_port_space_info( tree_size - rsize_used); if (size_used != rsize_used) - memset((char *) (tree_addr + size_used), 0, + memset((void *) (tree_addr + size_used), 0, rsize_used - size_used); kr = vm_map_copyin(ipc_kernel_map, tree_addr, rsize_used, diff --git a/kern/host.c b/kern/host.c index 773697c2..698acea9 100644 --- a/kern/host.c +++ b/kern/host.c @@ -302,7 +302,7 @@ host_processor_sets( return KERN_RESOURCE_SHORTAGE; } - memcpy((char *) newaddr, (char *) addr, size_needed); + memcpy((void *) newaddr, (void *) addr, size_needed); kfree(addr, size); psets = (processor_set_t *) newaddr; } diff --git a/kern/xpr.c b/kern/xpr.c index 92b253c0..a62472d2 100644 --- a/kern/xpr.c +++ b/kern/xpr.c @@ -115,7 +115,7 @@ void xprbootstrap(void) * the previous buffer contents. */ - memset((char *) addr, 0, size); + memset((void *) addr, 0, size); } xprbase = (struct xprbuf *) addr; diff --git a/vm/vm_debug.c b/vm/vm_debug.c index 0af58b69..a240ba85 100644 --- a/vm/vm_debug.c +++ b/vm/vm_debug.c @@ -404,7 +404,7 @@ mach_vm_object_pages(object, pagesp, countp) addr + rsize_used, size - rsize_used); if (size_used != rsize_used) - memset((char *) (addr + size_used), 0, + memset((void *) (addr + size_used), 0, rsize_used - size_used); kr = vm_map_copyin(ipc_kernel_map, addr, rsize_used, -- cgit v1.2.3 From 2b46d3fc3f7749b0dc2c0749c0ebf096d0147e45 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Wed, 11 Dec 2013 00:01:35 +0100 Subject: ipc/mach_debug.c (mach_port_kernel_object): remove unnecessary cast Return value from ip_kotype is an unsigned int. * ipc/mach_debug.c (mach_port_kernel_object) (ip_kotype): Remove unnecessary cast. --- ipc/mach_debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ipc/mach_debug.c b/ipc/mach_debug.c index 723d8646..7201f7c6 100644 --- a/ipc/mach_debug.c +++ b/ipc/mach_debug.c @@ -603,7 +603,7 @@ mach_port_kernel_object( return KERN_INVALID_RIGHT; } - *typep = (unsigned int) ip_kotype(port); + *typep = ip_kotype(port); *addrp = (vm_offset_t) port->ip_kobject; ip_unlock(port); return KERN_SUCCESS; -- cgit v1.2.3 From e16248d97c0775476947b8dfd24ff5e1ac822128 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Wed, 11 Dec 2013 00:01:36 +0100 Subject: ipc/mach_debug.c (mach_port_kernel_object): remove unnecessary cast Member ip_kobject is of type vm_offset_t. * ipc/mach_debug.c (mach_port_kernel_object) (ip_kobject): Remove unnecessary cast. --- ipc/mach_debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ipc/mach_debug.c b/ipc/mach_debug.c index 7201f7c6..dd9057a4 100644 --- a/ipc/mach_debug.c +++ b/ipc/mach_debug.c @@ -604,7 +604,7 @@ mach_port_kernel_object( } *typep = ip_kotype(port); - *addrp = (vm_offset_t) port->ip_kobject; + *addrp = port->ip_kobject; ip_unlock(port); return KERN_SUCCESS; } -- cgit v1.2.3 From c5a6bfecefda379e23daddc1e743360dcde8b73d Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Tue, 10 Dec 2013 19:19:57 +0100 Subject: i386/i386/db_trace.c: remove forward declaration * i386/Makefrag.am: List i386/i386/db_trace.h. * i386/i386/db_trace.c: Include machine/db_trace.h. (db_i386_stack_trace): Remove forward declaration. * i386/i386/db_trace.h: New file. Add copyright. [_I386_DB_TRACE_H_]: Add ifndef. (i386_frame): Declare forward. (db_i386_stack_trace): Add prototype. --- i386/Makefrag.am | 1 + i386/i386/db_trace.c | 9 +-------- i386/i386/db_trace.h | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 8 deletions(-) create mode 100644 i386/i386/db_trace.h diff --git a/i386/Makefrag.am b/i386/Makefrag.am index 23437c61..cac22678 100644 --- a/i386/Makefrag.am +++ b/i386/Makefrag.am @@ -83,6 +83,7 @@ libkernel_a_SOURCES += \ i386/i386/db_interface.h \ i386/i386/db_machdep.h \ i386/i386/db_trace.c \ + i386/i386/db_trace.h \ i386/i386/debug.h \ i386/i386/debug_i386.c \ i386/i386/debug_trace.S \ diff --git a/i386/i386/db_trace.c b/i386/i386/db_trace.c index fb65524c..b9c46a61 100644 --- a/i386/i386/db_trace.c +++ b/i386/i386/db_trace.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -312,14 +313,6 @@ db_nextframe( } } -void -db_i386_stack_trace( - thread_t th, - struct i386_frame *frame, - db_addr_t callpc, - db_expr_t count, - int flags); /* forward */ - #define F_USER_TRACE 1 #define F_TRACE_THREAD 2 diff --git a/i386/i386/db_trace.h b/i386/i386/db_trace.h new file mode 100644 index 00000000..604654c5 --- /dev/null +++ b/i386/i386/db_trace.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2013 Free Software Foundation. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef _I386_DB_TRACE_H_ +#define _I386_DB_TRACE_H_ + +struct i386_frame; + +void +db_i386_stack_trace( + thread_t th, + struct i386_frame *frame, + db_addr_t callpc, + db_expr_t count, + int flags); + +#endif /* _I386_DB_TRACE_H_ */ -- cgit v1.2.3 From d8ba8dbcc3535c67eeb1b75b89fc4b270bfb89b9 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Tue, 10 Dec 2013 19:19:58 +0100 Subject: i386/i386/db_trace.c (db_i386_stack_trace): remove unnecessary cast Argument to INKERNEL() is already cast to vm_offset_t in the macro itself. * i386/i386/db_trace.c (db_i386_stack_trace) (INKERNEL) (callpc): Don't cast to unsigned long. (db_i386_stack_trace) (INKERNEL) (frame): Likewise. --- i386/i386/db_trace.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/i386/i386/db_trace.c b/i386/i386/db_trace.c index b9c46a61..6247d4f6 100644 --- a/i386/i386/db_trace.c +++ b/i386/i386/db_trace.c @@ -425,7 +425,7 @@ db_i386_stack_trace( if (!db_trace_symbols_found) db_find_trace_symbols(); - if (!INKERNEL((unsigned long)callpc) && !INKERNEL((unsigned long)frame)) { + if (!INKERNEL(callpc) && !INKERNEL(frame)) { db_printf(">>>>> user space <<<<<\n"); user_frame++; } @@ -436,7 +436,7 @@ db_i386_stack_trace( char * name; db_expr_t offset; - if (INKERNEL((unsigned long)callpc) && user_frame == 0) { + if (INKERNEL(callpc) && user_frame == 0) { db_addr_t call_func = 0; db_sym_t sym_tmp; @@ -461,7 +461,7 @@ db_i386_stack_trace( frame_type = 0; narg = db_numargs(frame, task); } - } else if (INKERNEL((unsigned long)callpc) ^ INKERNEL((unsigned long)frame)) { + } else if (INKERNEL(callpc) ^ INKERNEL(frame)) { frame_type = 0; narg = -1; } else { @@ -506,7 +506,7 @@ db_i386_stack_trace( break; } if (!INKERNEL(lastframe) || - (!INKERNEL((unsigned long)callpc) && !INKERNEL((unsigned long)frame))) + (!INKERNEL(callpc) && !INKERNEL(frame))) user_frame++; if (user_frame == 1) { db_printf(">>>>> user space <<<<<\n"); -- cgit v1.2.3 From 20330e2ef271a5effee1d8b39db1bfec8f465ec7 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Tue, 10 Dec 2013 19:20:00 +0100 Subject: i386/i386at/kd.c: remove forward declarations * i386/i386at/kd.c (kd_getdata, state2leds, kdstart, kdstop): Remove forward declarations. * i386/i386at/kd.h (kd_getdata, state2leds, kdstart, kdstop): Add prototypes. Include device/tty.h. --- i386/i386at/kd.c | 6 ------ i386/i386at/kd.h | 7 +++++++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/i386/i386at/kd.c b/i386/i386at/kd.c index 757bce28..8b09ada8 100644 --- a/i386/i386at/kd.c +++ b/i386/i386at/kd.c @@ -122,10 +122,6 @@ void (*kd_dsetcursor)() = charsetcursor; /* set cursor position on displayed page */ void (*kd_dreset)() = kd_noopreset; /* prepare for reboot */ -/* forward declarations */ -unsigned char kd_getdata(), state2leds(); - - /* * Globals used for both character-based controllers and bitmap-based * controllers. Default is EGA. @@ -450,9 +446,7 @@ kdopen(dev, flag, ior) io_req_t ior; { struct tty *tp; - void kdstart(); spl_t o_pri; - void kdstop(); tp = &kd_tty; o_pri = spltty(); diff --git a/i386/i386at/kd.h b/i386/i386at/kd.h index f5cd5fc4..29c36112 100644 --- a/i386/i386at/kd.h +++ b/i386/i386at/kd.h @@ -78,6 +78,7 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include +#include #include /* @@ -785,4 +786,10 @@ void bmpch2bit(csrpos_t pos, short *xb, short *yb); void bmppaintcsr(csrpos_t pos, u_char val); u_char *bit2fbptr(short xb, short yb); +unsigned char kd_getdata(void); +unsigned char state2leds(int state); + +void kdstart(struct tty *tp); +void kdstop(struct tty *tp, int flags); + #endif /* _KD_H_ */ -- cgit v1.2.3 From 348fd187ba4108133b3ae82920e548e945f5c80c Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Tue, 10 Dec 2013 19:20:01 +0100 Subject: i386/i386at/kd.c (kdmmap): remove unnecessary cast Variable off is already an unsigned int. * i386/i386at/kd.c (kdmmap) (off): Remove unnecessary cast. --- i386/i386at/kd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i386/i386at/kd.c b/i386/i386at/kd.c index 8b09ada8..9182e260 100644 --- a/i386/i386at/kd.c +++ b/i386/i386at/kd.c @@ -561,7 +561,7 @@ kdmmap(dev, off, prot) off_t off; int prot; { - if ((u_int) off >= (128*1024)) + if (off >= (128*1024)) return(-1); /* Get page frame number for the page to be mapped. */ -- cgit v1.2.3 From 051840a8152d81ff3fccbb705d5ea806166b8236 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Tue, 10 Dec 2013 19:20:02 +0100 Subject: i386/i386at/kd.c (kdinit): remove forward declaration * i386/i386at/kd.c (kdinit) (kd_xga_init): Remove forward declaration. * i386/i386at/kd.h (kd_xga_init): Add prototype. --- i386/i386at/kd.c | 1 - i386/i386at/kd.h | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/i386/i386at/kd.c b/i386/i386at/kd.c index 9182e260..2404eaff 100644 --- a/i386/i386at/kd.c +++ b/i386/i386at/kd.c @@ -1149,7 +1149,6 @@ kdstop(tp, flags) void kdinit() { - void kd_xga_init(); unsigned char k_comm; /* keyboard command byte */ if (kd_initialized) diff --git a/i386/i386at/kd.h b/i386/i386at/kd.h index 29c36112..9909341e 100644 --- a/i386/i386at/kd.h +++ b/i386/i386at/kd.h @@ -792,4 +792,6 @@ unsigned char state2leds(int state); void kdstart(struct tty *tp); void kdstop(struct tty *tp, int flags); +void kd_xga_init(void); + #endif /* _KD_H_ */ -- cgit v1.2.3 From 6ff7e82fab67f23f0aa4caa18b886ce03c060f4d Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Tue, 10 Dec 2013 19:20:03 +0100 Subject: i386/i386at/kd_mouse.c (kd_mouse_open): remove forward declaration * i386/i386at/kd_mouse.c (kd_mouse_open) (kdintr): Remove forward declaration. --- i386/i386at/kd_mouse.c | 1 - 1 file changed, 1 deletion(-) diff --git a/i386/i386at/kd_mouse.c b/i386/i386at/kd_mouse.c index 5a804743..9aa4b819 100644 --- a/i386/i386at/kd_mouse.c +++ b/i386/i386at/kd_mouse.c @@ -222,7 +222,6 @@ kd_mouse_open(dev, mouse_pic) int mouse_pic; { spl_t s = splhi(); /* disable interrupts */ - extern void kdintr(); oldvect = ivect[mouse_pic]; ivect[mouse_pic] = kdintr; -- cgit v1.2.3 From be78a5c7937a31128a3624dcace9df23492866f9 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 29 Nov 2013 22:54:20 +0100 Subject: Declare void argument lists --- ddb/db_break.c | 8 +++---- ddb/db_command.c | 4 ++-- ddb/db_command.h | 2 +- ddb/db_cond.c | 2 +- ddb/db_examine.c | 4 ++-- ddb/db_input.c | 4 ++-- ddb/db_macro.c | 6 ++--- ddb/db_mp.c | 14 +++++------ ddb/db_output.c | 2 +- ddb/db_run.c | 2 +- ddb/db_variables.c | 2 +- ddb/db_variables.h | 2 +- ddb/db_watch.c | 2 +- ddb/db_watch.h | 2 +- device/cons.c | 6 ++--- device/dev_lookup.c | 2 +- device/dev_name.c | 6 ++--- device/device_init.c | 2 +- device/ds_routines.c | 6 ++--- device/net_io.c | 8 +++---- i386/i386/debug_i386.c | 5 ++-- i386/i386/fpu.c | 18 +++++++------- i386/i386/gdt.c | 2 +- i386/i386/idt.c | 2 +- i386/i386/ktss.c | 2 +- i386/i386/ldt.c | 2 +- i386/i386/pcb.c | 2 +- i386/i386/pic.c | 4 ++-- i386/i386/pit.c | 2 +- i386/i386/trap.c | 4 ++-- i386/i386at/int_init.c | 2 +- i386/i386at/kd.c | 62 ++++++++++++++++++++++++------------------------ i386/i386at/kd_event.c | 6 ++--- i386/i386at/model_dep.c | 2 +- i386/i386at/rtc.c | 4 ++-- i386/intel/pmap.c | 10 ++++---- ipc/ipc_init.c | 2 +- kern/act.c | 6 ++--- kern/ast.c | 4 ++-- kern/boot_script.c | 2 +- kern/bootstrap.c | 6 ++--- kern/exception.c | 4 ++-- kern/mach_clock.c | 10 ++++---- kern/startup.c | 6 ++--- kern/syscall_emulation.c | 2 +- kern/syscall_sw.c | 4 ++-- kern/time_stamp.c | 2 +- kern/timer.c | 2 +- vm/vm_fault.c | 2 +- vm/vm_init.c | 4 ++-- vm/vm_pageout.c | 8 +++---- 51 files changed, 139 insertions(+), 140 deletions(-) diff --git a/ddb/db_break.c b/ddb/db_break.c index f94663ae..0d099420 100644 --- a/ddb/db_break.c +++ b/ddb/db_break.c @@ -227,7 +227,7 @@ db_force_delete_breakpoint(bkpt, task_thd, is_task) } void -db_check_breakpoint_valid() +db_check_breakpoint_valid(void) { db_thread_breakpoint_t tbp, tbp_next; db_breakpoint_t bkpt, *bkptp; @@ -524,7 +524,7 @@ db_delete_temp_breakpoint(task, bkpt) * List breakpoints. */ void -db_list_breakpoints() +db_list_breakpoints(void) { db_breakpoint_t bkpt; @@ -598,7 +598,7 @@ db_list_breakpoints() /* Delete breakpoint */ /*ARGSUSED*/ void -db_delete_cmd() +db_delete_cmd(void) { int n; thread_t thread; @@ -731,7 +731,7 @@ db_breakpoint_cmd(addr, have_addr, count, modif) /* list breakpoints */ void -db_listbreak_cmd() +db_listbreak_cmd(void) { db_list_breakpoints(); } diff --git a/ddb/db_command.c b/ddb/db_command.c index 2bff8291..85cbf816 100644 --- a/ddb/db_command.c +++ b/ddb/db_command.c @@ -383,7 +383,7 @@ struct db_command *ptr; struct db_command *db_last_command = 0; void -db_help_cmd() +db_help_cmd(void) { struct db_command *cmd = db_command_table; @@ -471,7 +471,7 @@ void db_error(s) * !expr(arg,arg,arg) */ void -db_fncall() +db_fncall(void) { db_expr_t fn_addr; #define MAXARGS 11 diff --git a/ddb/db_command.h b/ddb/db_command.h index 1edf1d65..30e1f21e 100644 --- a/ddb/db_command.h +++ b/ddb/db_command.h @@ -69,7 +69,7 @@ struct db_command { extern boolean_t db_exec_cmd_nest(char *cmd, int size); -void db_fncall(); +void db_fncall(void); void db_help_cmd(void); diff --git a/ddb/db_cond.c b/ddb/db_cond.c index 82ec0d69..ae52bef8 100644 --- a/ddb/db_cond.c +++ b/ddb/db_cond.c @@ -123,7 +123,7 @@ db_cond_print(bkpt) } void -db_cond_cmd() +db_cond_cmd(void) { int c; struct db_cond *cp; diff --git a/ddb/db_examine.c b/ddb/db_examine.c index 9ffcb01c..6e7f89cc 100644 --- a/ddb/db_examine.c +++ b/ddb/db_examine.c @@ -255,7 +255,7 @@ char db_print_format = 'x'; /*ARGSUSED*/ void -db_print_cmd() +db_print_cmd(void) { db_expr_t value; int t; @@ -344,7 +344,7 @@ db_strcpy(dst, src) * Syntax: search [/bhl] addr value [mask] [,count] [thread] */ void -db_search_cmd() +db_search_cmd(void) { int t; db_addr_t addr; diff --git a/ddb/db_input.c b/ddb/db_input.c index 7fee8fd7..5be3a8ad 100644 --- a/ddb/db_input.c +++ b/ddb/db_input.c @@ -111,7 +111,7 @@ db_delete(n, bwd) } void -db_delete_line() +db_delete_line(void) { db_delete(db_le - db_lc, DEL_FWD); db_delete(db_lc - db_lbuf_start, DEL_BWD); @@ -349,7 +349,7 @@ db_readline(lstart, lsize) } void -db_check_interrupt() +db_check_interrupt(void) { int c; diff --git a/ddb/db_macro.c b/ddb/db_macro.c index 9d14b121..f985679e 100644 --- a/ddb/db_macro.c +++ b/ddb/db_macro.c @@ -73,7 +73,7 @@ db_lookup_macro(name) } void -db_def_macro_cmd() +db_def_macro_cmd(void) { char *p; int c; @@ -104,7 +104,7 @@ db_def_macro_cmd() } void -db_del_macro_cmd() +db_del_macro_cmd(void) { struct db_user_macro *mp; @@ -120,7 +120,7 @@ db_del_macro_cmd() } void -db_show_macro() +db_show_macro(void) { struct db_user_macro *mp; int t; diff --git a/ddb/db_mp.c b/ddb/db_mp.c index 3dfef09c..ae82c27d 100644 --- a/ddb/db_mp.c +++ b/ddb/db_mp.c @@ -63,7 +63,7 @@ boolean_t db_enter_debug = FALSE; */ boolean_t -db_enter() +db_enter(void) { int mycpu = cpu_number(); @@ -108,7 +108,7 @@ db_enter() * Leave debugger. */ void -db_leave() +db_leave(void) { int mycpu = cpu_number(); @@ -143,7 +143,7 @@ db_leave() */ void -remote_db() { +remote_db(void) { int my_cpu = cpu_number(); int i; @@ -250,7 +250,7 @@ db_on(cpu) * in kernel debugger and wants to stop other CPUs */ void -remote_db_enter() +remote_db_enter(void) { db_slave[cpu_number()]++; kdb_kintr(); @@ -267,7 +267,7 @@ remote_db_enter() * is active on another cpu. */ void -lock_db() +lock_db(void) { int my_cpu = cpu_number(); @@ -298,14 +298,14 @@ lock_db() } void -unlock_db() +unlock_db(void) { simple_unlock(&db_lock); } #if CONSOLE_ON_MASTER void -db_console() +db_console(void) { if (i_bit(CBUS_PUT_CHAR, my_word)) { volatile u_char c = cbus_ochar; diff --git a/ddb/db_output.c b/ddb/db_output.c index e0ea2f3f..f7561d24 100644 --- a/ddb/db_output.c +++ b/ddb/db_output.c @@ -99,7 +99,7 @@ db_force_whitespace(void) } static void -db_more() +db_more(void) { char *p; boolean_t quit_output = FALSE; diff --git a/ddb/db_run.c b/ddb/db_run.c index 330b41b7..09786673 100644 --- a/ddb/db_run.c +++ b/ddb/db_run.c @@ -426,7 +426,7 @@ db_continue_cmd(addr, have_addr, count, modif) } boolean_t -db_in_single_step() +db_in_single_step(void) { return(db_run_mode != STEP_NONE && db_run_mode != STEP_CONTINUE); } diff --git a/ddb/db_variables.c b/ddb/db_variables.c index e737cfe5..9d77c0a5 100644 --- a/ddb/db_variables.c +++ b/ddb/db_variables.c @@ -201,7 +201,7 @@ db_read_write_variable(vp, valuep, rw_flag, ap) } void -db_set_cmd() +db_set_cmd(void) { db_expr_t value; int t; diff --git a/ddb/db_variables.h b/ddb/db_variables.h index 934a61f5..9880d50f 100644 --- a/ddb/db_variables.h +++ b/ddb/db_variables.h @@ -81,7 +81,7 @@ extern struct db_variable *db_eregs; extern int db_get_variable(db_expr_t *valuep); -void db_set_cmd(); +void db_set_cmd(void); void db_read_write_variable(struct db_variable *, db_expr_t *, int, struct db_var_aux_param *); diff --git a/ddb/db_watch.c b/ddb/db_watch.c index e2bd8d68..567040c1 100644 --- a/ddb/db_watch.c +++ b/ddb/db_watch.c @@ -255,7 +255,7 @@ db_watchpoint_cmd(addr, have_addr, count, modif) /* list watchpoints */ void -db_listwatch_cmd() +db_listwatch_cmd(void) { db_list_watchpoints(); } diff --git a/ddb/db_watch.h b/ddb/db_watch.h index fb95ae53..8e0f32fb 100644 --- a/ddb/db_watch.h +++ b/ddb/db_watch.h @@ -57,7 +57,7 @@ extern void db_set_watchpoint(task_t task, db_addr_t addr, vm_size_t size); extern void db_delete_watchpoint(task_t task, db_addr_t addr); extern void db_list_watchpoints(void); -void db_listwatch_cmd(); +void db_listwatch_cmd(void); void db_deletewatch_cmd( db_expr_t addr, diff --git a/device/cons.c b/device/cons.c index 285fb99e..b04621ae 100644 --- a/device/cons.c +++ b/device/cons.c @@ -58,7 +58,7 @@ static boolean_t consbufused = FALSE; #endif /* CONSBUFSIZE > 0 */ void -cninit() +cninit(void) { struct consdev *cp; dev_ops_t cn_ops; @@ -120,7 +120,7 @@ cninit() int -cngetc() +cngetc(void) { if (cn_tab) return ((*cn_tab->cn_getc)(cn_tab->cn_dev, 1)); @@ -130,7 +130,7 @@ cngetc() } int -cnmaygetc() +cnmaygetc(void) { if (cn_tab) return((*cn_tab->cn_getc)(cn_tab->cn_dev, 0)); diff --git a/device/dev_lookup.c b/device/dev_lookup.c index 40373867..255102cc 100644 --- a/device/dev_lookup.c +++ b/device/dev_lookup.c @@ -362,7 +362,7 @@ dev_map(routine, port) * Initialization */ void -dev_lookup_init() +dev_lookup_init(void) { int i; diff --git a/device/dev_name.c b/device/dev_name.c index de9e360b..930930b4 100644 --- a/device/dev_name.c +++ b/device/dev_name.c @@ -39,18 +39,18 @@ /* * Routines placed in empty entries in the device tables */ -int nulldev() +int nulldev(void) { return (D_SUCCESS); } -int nodev() +int nodev(void) { return (D_INVALID_OPERATION); } vm_offset_t -nomap() +nomap(void) { return (D_INVALID_OPERATION); } diff --git a/device/device_init.c b/device/device_init.c index b2c8b880..794186ee 100644 --- a/device/device_init.c +++ b/device/device_init.c @@ -46,7 +46,7 @@ ipc_port_t master_device_port; void -device_service_create() +device_service_create(void) { master_device_port = ipc_port_alloc_kernel(); if (master_device_port == IP_NULL) diff --git a/device/ds_routines.c b/device/ds_routines.c index d62be2bd..bc22495f 100644 --- a/device/ds_routines.c +++ b/device/ds_routines.c @@ -1479,7 +1479,7 @@ void iodone(ior) splx(s); } -void io_done_thread_continue() +void io_done_thread_continue(void) { for (;;) { spl_t s; @@ -1514,7 +1514,7 @@ void io_done_thread_continue() } } -void io_done_thread() +void io_done_thread(void) { /* * Set thread privileges and highest priority. @@ -1531,7 +1531,7 @@ void io_done_thread() static void mach_device_trap_init(void); /* forward */ -void mach_device_init() +void mach_device_init(void) { vm_offset_t device_io_min, device_io_max; diff --git a/device/net_io.c b/device/net_io.c index b3ec2926..4c03f8ce 100644 --- a/device/net_io.c +++ b/device/net_io.c @@ -524,7 +524,7 @@ boolean_t net_deliver(nonblocking) * net_kmsg_get will do a wakeup. */ -void net_ast() +void net_ast(void) { spl_t s; @@ -553,7 +553,7 @@ void net_ast() (void) splx(s); } -void net_thread_continue() +void net_thread_continue(void) { for (;;) { spl_t s; @@ -579,7 +579,7 @@ void net_thread_continue() } } -void net_thread() +void net_thread(void) { spl_t s; @@ -1492,7 +1492,7 @@ net_write(ifp, start, ior) * Initialize the whole package. */ void -net_io_init() +net_io_init(void) { vm_size_t size; diff --git a/i386/i386/debug_i386.c b/i386/i386/debug_i386.c index 937d7b4b..01f26a06 100644 --- a/i386/i386/debug_i386.c +++ b/i386/i386/debug_i386.c @@ -59,9 +59,8 @@ struct debug_trace_entry struct debug_trace_entry debug_trace_buf[DEBUG_TRACE_LEN]; int debug_trace_pos; - void -debug_trace_reset() +debug_trace_reset(void) { int s = splhigh(); debug_trace_pos = 0; @@ -89,7 +88,7 @@ print_entry(int i, int *col) } void -debug_trace_dump() +debug_trace_dump(void) { int s = splhigh(); int i; diff --git a/i386/i386/fpu.c b/i386/i386/fpu.c index 4e3ab574..b1aed912 100644 --- a/i386/i386/fpu.c +++ b/i386/i386/fpu.c @@ -101,7 +101,7 @@ volatile thread_t fp_intr_thread = THREAD_NULL; * Called on each CPU. */ void -init_fpu() +init_fpu(void) { unsigned short status, control; @@ -185,7 +185,7 @@ init_fpu() * Initialize FP handling. */ void -fpu_module_init() +fpu_module_init(void) { kmem_cache_init(&ifps_cache, "i386_fpsave_state", sizeof(struct i386_fpsave_state), 16, @@ -495,7 +495,7 @@ ASSERT_IPL(SPL0); * * Use 53-bit precision. */ -void fpinit() +void fpinit(void) { unsigned short control; @@ -519,7 +519,7 @@ ASSERT_IPL(SPL0); * Coprocessor not present. */ void -fpnoextflt() +fpnoextflt(void) { /* * Enable FPU use. @@ -563,7 +563,7 @@ ASSERT_IPL(SPL0); * Re-initialize FPU. Floating point state is not valid. */ void -fpextovrflt() +fpextovrflt(void) { thread_t thread = current_thread(); pcb_t pcb; @@ -612,7 +612,7 @@ fpextovrflt() } static int -fphandleerr() +fphandleerr(void) { thread_t thread = current_thread(); @@ -659,7 +659,7 @@ fphandleerr() * FPU error. Called by exception handler. */ void -fpexterrflt() +fpexterrflt(void) { thread_t thread = current_thread(); @@ -684,7 +684,7 @@ fpexterrflt() * FPU error. Called by AST. */ void -fpastintr() +fpastintr(void) { thread_t thread = current_thread(); @@ -824,7 +824,7 @@ ASSERT_IPL(SPL0); * Locking not needed; always called on the current thread. */ void -fp_state_alloc() +fp_state_alloc(void) { pcb_t pcb = current_thread()->pcb; struct i386_fpsave_state *ifps; diff --git a/i386/i386/gdt.c b/i386/i386/gdt.c index 5523fea3..c895eb3a 100644 --- a/i386/i386/gdt.c +++ b/i386/i386/gdt.c @@ -46,7 +46,7 @@ extern struct real_descriptor gdt[GDTSZ]; void -gdt_init() +gdt_init(void) { /* Initialize the kernel code and data segment descriptors. */ fill_gdt_descriptor(KERNEL_CS, diff --git a/i386/i386/idt.c b/i386/i386/idt.c index 882764f4..d304ec3e 100644 --- a/i386/i386/idt.c +++ b/i386/i386/idt.c @@ -36,7 +36,7 @@ struct idt_init_entry }; extern struct idt_init_entry idt_inittab[]; -void idt_init() +void idt_init(void) { #ifdef MACH_PV_DESCRIPTORS if (hyp_set_trap_table(kvtolin(idt_inittab))) diff --git a/i386/i386/ktss.c b/i386/i386/ktss.c index 1b2938a0..21d00300 100644 --- a/i386/i386/ktss.c +++ b/i386/i386/ktss.c @@ -40,7 +40,7 @@ struct task_tss ktss; void -ktss_init() +ktss_init(void) { /* XXX temporary exception stack */ static int exception_stack[1024]; diff --git a/i386/i386/ldt.c b/i386/i386/ldt.c index 43b9efb5..a5e89f28 100644 --- a/i386/i386/ldt.c +++ b/i386/i386/ldt.c @@ -46,7 +46,7 @@ extern struct real_descriptor ldt[LDTSZ]; void -ldt_init() +ldt_init(void) { #ifdef MACH_PV_DESCRIPTORS #ifdef MACH_PV_PAGETABLES diff --git a/i386/i386/pcb.c b/i386/i386/pcb.c index 3827f5e8..82b2faf1 100644 --- a/i386/i386/pcb.c +++ b/i386/i386/pcb.c @@ -365,7 +365,7 @@ thread_t switch_context(old, continuation, new) return Switch_context(old, continuation, new); } -void pcb_module_init() +void pcb_module_init(void) { kmem_cache_init(&pcb_cache, "pcb", sizeof(struct pcb), 0, NULL, NULL, NULL, 0); diff --git a/i386/i386/pic.c b/i386/i386/pic.c index 75cb835a..9c51497b 100644 --- a/i386/i386/pic.c +++ b/i386/i386/pic.c @@ -102,7 +102,7 @@ u_short PICM_ICW4, PICS_ICW4 ; */ void -picinit() +picinit(void) { asm("cli"); @@ -220,7 +220,7 @@ picinit() #define SLAVEACTV 0xFF00 void -form_pic_mask() +form_pic_mask(void) { unsigned int i, j, bit, mask; diff --git a/i386/i386/pit.c b/i386/i386/pit.c index 85929e9e..da683308 100644 --- a/i386/i386/pit.c +++ b/i386/i386/pit.c @@ -65,7 +65,7 @@ int pit0_mode = PIT_C0|PIT_SQUAREMODE|PIT_READMODE ; unsigned int clknumb = CLKNUM; /* interrupt interval for timer 0 */ void -clkstart() +clkstart(void) { unsigned char byte; unsigned long s; diff --git a/i386/i386/trap.c b/i386/i386/trap.c index b891527d..97969404 100644 --- a/i386/i386/trap.c +++ b/i386/i386/trap.c @@ -70,7 +70,7 @@ extern struct db_watchpoint *db_watchpoint_list; extern boolean_t db_watchpoints_inserted; void -thread_kdb_return() +thread_kdb_return(void) { thread_t thread = current_thread(); struct i386_saved_state *regs = USER_REGS(thread); @@ -563,7 +563,7 @@ printf("user trap %d error %d sub %08x\n", type, code, subcode); * AT-bus machines. */ void -i386_astintr() +i386_astintr(void) { int mycpu = cpu_number(); diff --git a/i386/i386at/int_init.c b/i386/i386at/int_init.c index 0f00b868..43daad8b 100644 --- a/i386/i386at/int_init.c +++ b/i386/i386at/int_init.c @@ -27,7 +27,7 @@ /* defined in locore.S */ extern vm_offset_t int_entry_table[]; -void int_init() +void int_init(void) { int i; diff --git a/i386/i386at/kd.c b/i386/i386at/kd.c index 2404eaff..a326626b 100644 --- a/i386/i386at/kd.c +++ b/i386/i386at/kd.c @@ -108,7 +108,7 @@ struct tty kd_tty; extern boolean_t rebootflag; static void charput(), charmvup(), charmvdown(), charclear(), charsetcursor(); -static void kd_noopreset(); +static void kd_noopreset(void); /* * These routines define the interface to the device-specific layer. @@ -358,7 +358,7 @@ int kd_pollc = 0; * Warning: uses outb(). You may prefer to use kd_debug_put. */ void -feep() +feep(void) { int i; @@ -369,7 +369,7 @@ feep() } void -pause() +pause(void) { int i; @@ -862,7 +862,7 @@ int vec; * drop the ack on the floor. */ void -kd_handle_ack() +kd_handle_ack(void) { switch (kd_ack) { case SET_LEDS: @@ -887,7 +887,7 @@ kd_handle_ack() * Resend a missed keyboard command or data byte. */ void -kd_resend() +kd_resend(void) { if (kd_ack == NOT_WAITING) printf("unexpected RESEND from keyboard\n"); @@ -1147,7 +1147,7 @@ kdstop(tp, flags) * */ void -kdinit() +kdinit(void) { unsigned char k_comm; /* keyboard command byte */ @@ -1235,7 +1235,7 @@ kd_belloff(void * param) * */ void -kd_bellon() +kd_bellon(void) { unsigned char status; @@ -1346,7 +1346,7 @@ csrpos_t newpos; * */ void -kd_scrollup() +kd_scrollup(void) { csrpos_t to; csrpos_t from; @@ -1376,7 +1376,7 @@ kd_scrollup() * */ void -kd_scrolldn() +kd_scrolldn(void) { csrpos_t to; csrpos_t from; @@ -1410,7 +1410,7 @@ kd_scrolldn() * */ void -kd_parseesc() +kd_parseesc(void) { u_char *escp; @@ -1747,7 +1747,7 @@ u_char *cp; } void -kd_tab() +kd_tab(void) { int i; @@ -1768,7 +1768,7 @@ kd_tab() * */ void -kd_cls() +kd_cls(void) { (*kd_dclear)(0, ONE_PAGE/ONE_SPACE, kd_attr); return; @@ -1786,7 +1786,7 @@ kd_cls() * */ void -kd_home() +kd_home(void) { kd_setpos(0); return; @@ -1803,7 +1803,7 @@ kd_home() * */ void -kd_up() +kd_up(void) { if (kd_curpos < ONE_LINE) kd_scrolldn(); @@ -1823,7 +1823,7 @@ kd_up() * */ void -kd_down() +kd_down(void) { if (kd_curpos >= (ONE_PAGE - ONE_LINE)) kd_scrollup(); @@ -1843,7 +1843,7 @@ kd_down() * */ void -kd_right() +kd_right(void) { if (kd_curpos < (ONE_PAGE - ONE_SPACE)) kd_setpos(kd_curpos + ONE_SPACE); @@ -1865,7 +1865,7 @@ kd_right() * */ void -kd_left() +kd_left(void) { if (0 < kd_curpos) kd_setpos(kd_curpos - ONE_SPACE); @@ -1884,7 +1884,7 @@ kd_left() * */ void -kd_cr() +kd_cr(void) { kd_setpos(BEG_OF_LINE(kd_curpos)); return; @@ -1902,7 +1902,7 @@ kd_cr() * */ void -kd_cltobcur() +kd_cltobcur(void) { csrpos_t start; int count; @@ -1925,7 +1925,7 @@ kd_cltobcur() * */ void -kd_cltopcur() +kd_cltopcur(void) { int count; @@ -1945,7 +1945,7 @@ kd_cltopcur() * */ void -kd_cltoecur() +kd_cltoecur(void) { csrpos_t i; csrpos_t hold; @@ -1968,7 +1968,7 @@ kd_cltoecur() * */ void -kd_clfrbcur() +kd_clfrbcur(void) { csrpos_t i; @@ -2136,7 +2136,7 @@ int number; * */ void -kd_eraseln() +kd_eraseln(void) { csrpos_t i; csrpos_t stop; @@ -2264,14 +2264,14 @@ unsigned char ch; * read. */ unsigned char -kd_getdata() +kd_getdata(void) { while ((inb(K_STATUS) & K_OBUF_FUL) == 0); return(inb(K_RDWR)); } unsigned char -kd_cmdreg_read() +kd_cmdreg_read(void) { int ch=KC_CMD_READ; @@ -2295,7 +2295,7 @@ int ch=KC_CMD_WRITE; } void -kd_mouse_drain() +kd_mouse_drain(void) { int i; while(inb(K_STATUS) & K_IBUF_FUL); @@ -2357,7 +2357,7 @@ u_char val; } void -kd_setleds2() +kd_setleds2(void) { kd_senddata(kd_nextled); } @@ -2381,7 +2381,7 @@ u_char val; } void -kdreboot() +kdreboot(void) { (*kd_dreset)(); @@ -2494,7 +2494,7 @@ int new_button = 0; * Initialization specific to character-based graphics adapters. */ void -kd_xga_init() +kd_xga_init(void) { csrpos_t xga_getpos(); unsigned char screen; @@ -2567,7 +2567,7 @@ kd_xga_init() * */ csrpos_t -xga_getpos() +xga_getpos(void) { unsigned char low; @@ -2670,7 +2670,7 @@ char chattr; * No-op reset routine for kd_dreset. */ static void -kd_noopreset() +kd_noopreset(void) { } diff --git a/i386/i386at/kd_event.c b/i386/i386at/kd_event.c index 4e7b00a6..ac87b205 100644 --- a/i386/i386at/kd_event.c +++ b/i386/i386at/kd_event.c @@ -91,7 +91,7 @@ static boolean_t initialized = FALSE; */ void -kbdinit() +kbdinit(void) { spl_t s = SPLKD(); @@ -343,7 +343,7 @@ u_int *p; } void -X_kdb_enter() +X_kdb_enter(void) { u_int *u_ip, *endp; @@ -354,7 +354,7 @@ X_kdb_enter() } void -X_kdb_exit() +X_kdb_exit(void) { u_int *u_ip, *endp; diff --git a/i386/i386at/model_dep.c b/i386/i386at/model_dep.c index 5015d410..10c0c41d 100644 --- a/i386/i386at/model_dep.c +++ b/i386/i386at/model_dep.c @@ -196,7 +196,7 @@ void machine_idle (int cpu) #endif /* MACH_HYP */ } -void machine_relax () +void machine_relax (void) { asm volatile ("rep; nop" : : : "memory"); } diff --git a/i386/i386at/rtc.c b/i386/i386at/rtc.c index 98f157f9..ff4309be 100644 --- a/i386/i386at/rtc.c +++ b/i386/i386at/rtc.c @@ -56,7 +56,7 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. static boolean_t first_rtcopen_ever = TRUE; void -rtcinit() +rtcinit(void) { outb(RTC_ADDR, RTC_A); outb(RTC_DATA, RTC_DIV2 | RTC_RATE6); @@ -171,7 +171,7 @@ readtodc(tp) } int -writetodc() +writetodc(void) { struct rtc_st rtclk; time_t n; diff --git a/i386/intel/pmap.c b/i386/intel/pmap.c index ff6a3277..06c4daa0 100644 --- a/i386/intel/pmap.c +++ b/i386/intel/pmap.c @@ -573,7 +573,7 @@ vm_offset_t pmap_map_bd(virt, start, end, prot) * and direct-map all physical memory. * Called with mapping off. */ -void pmap_bootstrap() +void pmap_bootstrap(void) { /* * Mapping is turned off; we must reference only physical addresses. @@ -897,7 +897,7 @@ void pmap_virtual_space(startp, endp) * Called by vm_init, to initialize any structures that the pmap * system needs to map virtual memory. */ -void pmap_init() +void pmap_init(void) { long npages; vm_offset_t addr; @@ -996,7 +996,7 @@ boolean_t pmap_verify_free(phys) * since these must be unlocked to use vm_page_grab. */ vm_offset_t -pmap_page_table_page_alloc() +pmap_page_table_page_alloc(void) { vm_page_t m; vm_offset_t pa; @@ -2790,7 +2790,7 @@ void pmap_update_interrupt(void) /* * Dummy routine to satisfy external reference. */ -void pmap_update_interrupt() +void pmap_update_interrupt(void) { /* should never be called. */ } @@ -2799,7 +2799,7 @@ void pmap_update_interrupt() #if defined(__i386__) /* Unmap page 0 to trap NULL references. */ void -pmap_unmap_page_zero () +pmap_unmap_page_zero (void) { int *pte; diff --git a/ipc/ipc_init.c b/ipc/ipc_init.c index a7e9ec17..debda476 100644 --- a/ipc/ipc_init.c +++ b/ipc/ipc_init.c @@ -108,7 +108,7 @@ ipc_bootstrap(void) */ void -ipc_init() +ipc_init(void) { vm_offset_t min, max; diff --git a/kern/act.c b/kern/act.c index d76fe0ef..c0b6aa8b 100644 --- a/kern/act.c +++ b/kern/act.c @@ -64,7 +64,7 @@ static Act free_acts[ACT_STATIC_KLUDGE]; Act null_act; void -global_act_init() +global_act_init(void) { #ifndef ACT_STATIC_KLUDGE kmem_cache_init(&act_cache, "Act", sizeof(struct Act), 0, @@ -257,7 +257,7 @@ void act_detach(Act *cur_act) so RPC entry paths need not check it. Locking: Act */ -void act_execute_returnhandlers() +void act_execute_returnhandlers(void) { Act *act = current_act(); @@ -1061,7 +1061,7 @@ act_set_state_immediate(act, flavor, new_state, new_state_count) return act_set_state(act, flavor, new_state, new_state_count); } -void act_count() +void act_count(void) { int i; Act *act; diff --git a/kern/ast.c b/kern/ast.c index e8e8c1bd..4b9d63d6 100644 --- a/kern/ast.c +++ b/kern/ast.c @@ -56,7 +56,7 @@ volatile ast_t need_ast[NCPUS]; void -ast_init() +ast_init(void) { #ifndef MACHINE_AST int i; @@ -114,7 +114,7 @@ ast_taken(void) } void -ast_check() +ast_check(void) { int mycpu = cpu_number(); processor_t myprocessor; diff --git a/kern/boot_script.c b/kern/boot_script.c index b2e9393b..a6196e05 100644 --- a/kern/boot_script.c +++ b/kern/boot_script.c @@ -485,7 +485,7 @@ boot_script_parse_line (void *hook, char *cmdline) /* Execute commands previously parsed. */ int -boot_script_exec () +boot_script_exec (void) { int cmd_index; diff --git a/kern/bootstrap.c b/kern/bootstrap.c index 41b02fee..c0576b74 100644 --- a/kern/bootstrap.c +++ b/kern/bootstrap.c @@ -107,7 +107,7 @@ task_insert_send_right( return name; } -void bootstrap_create() +void bootstrap_create(void) { int compat; int n = 0; @@ -642,7 +642,7 @@ build_args_and_stack(struct exec_info *boot_exec_info, static void -user_bootstrap_compat() +user_bootstrap_compat(void) { exec_info_t boot_exec_info; @@ -744,7 +744,7 @@ boot_script_exec_cmd (void *hook, task_t task, char *path, int argc, return 0; } -static void user_bootstrap() +static void user_bootstrap(void) { struct user_bootstrap_info *info = current_thread()->saved.other; exec_info_t boot_exec_info; diff --git a/kern/exception.c b/kern/exception.c index 02327739..2ca404d1 100644 --- a/kern/exception.c +++ b/kern/exception.c @@ -217,7 +217,7 @@ exception_try_task(_exception, code, subcode) */ void -exception_no_server() +exception_no_server(void) { ipc_thread_t self = current_thread(); @@ -828,7 +828,7 @@ exception_parse_reply(kmsg) */ void -exception_raise_continue() +exception_raise_continue(void) { ipc_thread_t self = current_thread(); ipc_port_t reply_port = self->ith_port; diff --git a/kern/mach_clock.c b/kern/mach_clock.c index 29a14c9d..79e63dd8 100644 --- a/kern/mach_clock.c +++ b/kern/mach_clock.c @@ -270,7 +270,7 @@ void clock_interrupt(usec, usermode, basepri) * and corrupts it. */ -void softclock() +void softclock(void) { /* * Handle timeouts. @@ -360,7 +360,7 @@ boolean_t reset_timeout(telt) } } -void init_timeout() +void init_timeout(void) { simple_lock_init(&timer_lock); queue_init(&timer_head.chain); @@ -490,7 +490,7 @@ host_adjust_time(host, new_adjustment, old_adjustment) return (KERN_SUCCESS); } -void mapable_time_init() +void mapable_time_init(void) { if (kmem_alloc_wired(kernel_map, (vm_offset_t *) &mtime, PAGE_SIZE) != KERN_SUCCESS) @@ -499,11 +499,11 @@ void mapable_time_init() update_mapped_time(&time); } -int timeopen() +int timeopen(void) { return(0); } -int timeclose() +int timeclose(void) { return(0); } diff --git a/kern/startup.c b/kern/startup.c index 78c210d2..81874e73 100644 --- a/kern/startup.c +++ b/kern/startup.c @@ -86,7 +86,7 @@ extern char *kernel_cmdline; * * Assumes that master_cpu is set. */ -void setup_main() +void setup_main(void) { thread_t startup_thread; @@ -198,7 +198,7 @@ void setup_main() * Now running in a thread. Create the rest of the kernel threads * and the bootstrap task. */ -void start_kernel_threads() +void start_kernel_threads(void) { int i; @@ -266,7 +266,7 @@ void start_kernel_threads() } #if NCPUS > 1 -void slave_main() +void slave_main(void) { cpu_launch_first_thread(THREAD_NULL); } diff --git a/kern/syscall_emulation.c b/kern/syscall_emulation.c index 0f4a2bec..290c51a5 100644 --- a/kern/syscall_emulation.c +++ b/kern/syscall_emulation.c @@ -57,7 +57,7 @@ /* * eml_init: initialize user space emulation code */ -void eml_init() +void eml_init(void) { } diff --git a/kern/syscall_sw.c b/kern/syscall_sw.c index 084f2e0d..a383e467 100644 --- a/kern/syscall_sw.c +++ b/kern/syscall_sw.c @@ -60,13 +60,13 @@ boolean_t kern_invalid_debug = FALSE; -mach_port_t null_port() +mach_port_t null_port(void) { if (kern_invalid_debug) SoftDebugger("null_port mach trap"); return(MACH_PORT_NULL); } -kern_return_t kern_invalid() +kern_return_t kern_invalid(void) { if (kern_invalid_debug) SoftDebugger("kern_invalid mach trap"); return(KERN_INVALID_ARGUMENT); diff --git a/kern/time_stamp.c b/kern/time_stamp.c index 9adfc145..2c142746 100644 --- a/kern/time_stamp.c +++ b/kern/time_stamp.c @@ -54,7 +54,7 @@ struct tsval *tsp; * Initialization procedure. */ -void timestamp_init() +void timestamp_init(void) { ts_tick_count = 0; } diff --git a/kern/timer.c b/kern/timer.c index 0c73c695..6ee9a101 100644 --- a/kern/timer.c +++ b/kern/timer.c @@ -45,7 +45,7 @@ timer_data_t kernel_timer[NCPUS]; * service routine on the callout queue. All timers must be * serviced by the callout routine once an hour. */ -void init_timers() +void init_timers(void) { int i; timer_t this_timer; diff --git a/vm/vm_fault.c b/vm/vm_fault.c index 96c83873..d9c3d7b8 100644 --- a/vm/vm_fault.c +++ b/vm/vm_fault.c @@ -1136,7 +1136,7 @@ vm_fault_return_t vm_fault_page(first_object, first_offset, */ void -vm_fault_continue() +vm_fault_continue(void) { vm_fault_state_t *state = (vm_fault_state_t *) current_thread()->ith_other; diff --git a/vm/vm_init.c b/vm/vm_init.c index 89eb0984..3d1081cc 100644 --- a/vm/vm_init.c +++ b/vm/vm_init.c @@ -51,7 +51,7 @@ * This is done only by the first cpu up. */ -void vm_mem_bootstrap() +void vm_mem_bootstrap(void) { vm_offset_t start, end; @@ -79,7 +79,7 @@ void vm_mem_bootstrap() memory_manager_default_init(); } -void vm_mem_init() +void vm_mem_init(void) { vm_object_init(); memory_object_proxy_init(); diff --git a/vm/vm_pageout.c b/vm/vm_pageout.c index 46ba56b8..f4f1fef0 100644 --- a/vm/vm_pageout.c +++ b/vm/vm_pageout.c @@ -507,7 +507,7 @@ vm_pageout_page(m, initial, flush) * vm_page_free_wanted == 0. */ -void vm_pageout_scan() +void vm_pageout_scan(void) { unsigned int burst_count; unsigned int want_pages; @@ -853,7 +853,7 @@ void vm_pageout_scan() } } -void vm_pageout_scan_continue() +void vm_pageout_scan_continue(void) { /* * We just paused to let the pagers catch up. @@ -884,7 +884,7 @@ void vm_pageout_scan_continue() * vm_pageout is the high level pageout daemon. */ -void vm_pageout_continue() +void vm_pageout_continue(void) { /* * The pageout daemon is never done, so loop forever. @@ -906,7 +906,7 @@ void vm_pageout_continue() } } -void vm_pageout() +void vm_pageout(void) { int free_after_reserve; -- cgit v1.2.3 From d4d560090216ba3028fab57860dc90ed3d283368 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Wed, 11 Dec 2013 17:30:40 +0100 Subject: kern/mach_clock.c: update comment This is mach_clock.c, not clock_prim.c. * kern/mach_clock.c: Update comment. --- kern/mach_clock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kern/mach_clock.c b/kern/mach_clock.c index 79e63dd8..f167291d 100644 --- a/kern/mach_clock.c +++ b/kern/mach_clock.c @@ -27,7 +27,7 @@ * the rights to redistribute these changes. */ /* - * File: clock_prim.c + * File: mach_clock.c * Author: Avadis Tevanian, Jr. * Date: 1986 * -- cgit v1.2.3 From a69d9580375fa2f43eb68970e292447310c88e98 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Wed, 11 Dec 2013 17:30:41 +0100 Subject: i386/i386/ldt.c: remove forward declaration * i386/i386/ldt.c (syscall): Remove forward declaration. Include locore.h. * i386/i386/locore.h (syscall): Add prototype. --- i386/i386/ldt.c | 3 +-- i386/i386/locore.h | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/i386/i386/ldt.c b/i386/i386/ldt.c index a5e89f28..0250ee26 100644 --- a/i386/i386/ldt.c +++ b/i386/i386/ldt.c @@ -36,8 +36,7 @@ #include "seg.h" #include "gdt.h" #include "ldt.h" - -extern int syscall(); +#include "locore.h" #ifdef MACH_PV_DESCRIPTORS /* It is actually defined in xen_boothdr.S */ diff --git a/i386/i386/locore.h b/i386/i386/locore.h index bfd13177..6948f72d 100644 --- a/i386/i386/locore.h +++ b/i386/i386/locore.h @@ -56,6 +56,8 @@ extern int inst_fetch (int eip, int cs); extern void cpu_shutdown (void); +extern int syscall (void); + extern unsigned int cpu_features[1]; #define CPU_FEATURE_FPU 0 -- cgit v1.2.3 From 7009c4753929f3fb5e07647dde6c9be02bf7e22a Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Wed, 11 Dec 2013 17:30:45 +0100 Subject: vm/vm_kern.c (kmem_submap): remove unnecessary cast The return value from vm_map_min() is already of vm_offset_t type. * vm/vm_kern.c (kmem_submap) (addr): Remove unnecessary cast. --- vm/vm_kern.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vm/vm_kern.c b/vm/vm_kern.c index 7e377ef3..1c843ffe 100644 --- a/vm/vm_kern.c +++ b/vm/vm_kern.c @@ -842,7 +842,7 @@ kmem_submap(map, parent, min, max, size, pageable) */ vm_object_reference(vm_submap_object); - addr = (vm_offset_t) vm_map_min(parent); + addr = vm_map_min(parent); kr = vm_map_enter(parent, &addr, size, (vm_offset_t) 0, TRUE, vm_submap_object, (vm_offset_t) 0, FALSE, -- cgit v1.2.3 From 646001c0ed11c000d6a6c71594f89eeee3fd733f Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Wed, 11 Dec 2013 17:30:46 +0100 Subject: vm/vm_resident.c (vm_page_print): remove unnecessary casts Members offset and phys_addr are of vm_offset_t types. * vm/vm_resident.c (vm_page_print) (offset, phys_addr): Remove unnecessary casts. --- vm/vm_resident.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vm/vm_resident.c b/vm/vm_resident.c index f0f31f6b..7644fd39 100644 --- a/vm/vm_resident.c +++ b/vm/vm_resident.c @@ -1508,7 +1508,7 @@ void vm_page_print(p) vm_page_t p; { iprintf("Page 0x%X: object 0x%X,", (vm_offset_t) p, (vm_offset_t) p->object); - printf(" offset 0x%X", (vm_offset_t) p->offset); + printf(" offset 0x%X", p->offset); printf("wire_count %d,", p->wire_count); printf(" %s", (p->active ? "active" : (p->inactive ? "inactive" : "loose"))); @@ -1533,7 +1533,7 @@ void vm_page_print(p) printf("%s,", (p->tabled ? "" : "not_tabled")); printf("phys_addr = 0x%X, lock = 0x%X, unlock_request = 0x%X\n", - (vm_offset_t) p->phys_addr, + p->phys_addr, (vm_offset_t) p->page_lock, (vm_offset_t) p->unlock_request); } -- cgit v1.2.3 From 62c46407612daa716a6e0e7fd79a33a87a408578 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 12 Dec 2013 18:27:03 +0100 Subject: ddb/db_break.c (db_find_breakpoint_here): remove unnecessary casts Variable addr and member address are already of db_addr_t type which is type defined as vm_offset_t. * ddb/db_break.c (db_find_breakpoint_here) (DB_PHYS_EQ) (addr, address): Remove unecessary casts. --- ddb/db_break.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ddb/db_break.c b/ddb/db_break.c index 0d099420..854d054e 100644 --- a/ddb/db_break.c +++ b/ddb/db_break.c @@ -379,7 +379,7 @@ db_find_breakpoint_here(task, addr) && bkpt->address == addr) return(TRUE); if ((bkpt->flags & BKPT_USR_GLOBAL) == 0 && - DB_PHYS_EQ(task, (vm_offset_t)addr, bkpt->task, (vm_offset_t)bkpt->address)) + DB_PHYS_EQ(task, addr, bkpt->task, bkpt->address)) return (TRUE); } return(FALSE); -- cgit v1.2.3 From 159b9cdd18a8689493b5f031451ea301afd8a8ea Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 12 Dec 2013 18:27:06 +0100 Subject: ddb/db_break.c (db_delete_cmd): remove unnecessary initialization Now that we have returns there are no more warnings from GCC about uninitialized variable. Remove unnecessary initialization of variable bkpt. * ddb/db_break.c (db_delete_cmd) (bkpt): Remove unnecessary initialization. --- ddb/db_break.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ddb/db_break.c b/ddb/db_break.c index 854d054e..d8273ea5 100644 --- a/ddb/db_break.c +++ b/ddb/db_break.c @@ -627,7 +627,7 @@ db_delete_cmd(void) } if (t == tHASH) { db_thread_breakpoint_t tbp; - db_breakpoint_t bkpt = bkpt; + db_breakpoint_t bkpt; if (db_read_token() != tNUMBER) { db_printf("Bad break point number #%s\n", db_tok_string); -- cgit v1.2.3 From f9ed7a52c0384e523c1f02c684d6db575b920859 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 12 Dec 2013 18:27:07 +0100 Subject: ddb/db_expr.c (db_mult_expr): initialize lhs Initialize lhs to zero to avoid uninitialized usage in db_unary(). * ddb/db_expr.c (db_mult_expr) (lhs): Initialize to zero. --- ddb/db_expr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ddb/db_expr.c b/ddb/db_expr.c index eee9e4f7..82ada586 100644 --- a/ddb/db_expr.c +++ b/ddb/db_expr.c @@ -180,7 +180,7 @@ boolean_t db_mult_expr(valuep) db_expr_t *valuep; { - db_expr_t lhs, rhs; + db_expr_t lhs = 0, rhs; int t; char c; -- cgit v1.2.3 From bb6646c299da3dde90b2e208ba0a7d5a71719a0c Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sat, 14 Dec 2013 12:26:00 +0100 Subject: Type definition * i386/i386/ast_check.c (init_ast_check, cause_ast_check): Define return type. * i386/i386/pic.c (intnull, prtnull): Define argument types. * i386/i386at/com.c (compr_addr): Likewise. (compr): Likewise. (compr_addr): Fix printf format. * i386/i386at/kd.c (kd_cmdreg_write, kd_kbd_magic): Define argument types. * i386/i386at/kd_mouse.c (init_mouse_hw): Likewise. * ipc/mach_port.c (sact_count): Define return type. * ipc/mach_rpc.c (mach_port_rpc_sig): Define argument types. * kern/act.c (dump_act): Define return type. * kern/lock_mon.c (simple_lock, simple_lock_try, simple_unlock, lip, lock_info_sort, lock_info_clear, print_lock_info): Define return type. (time_lock): Define return type and argument type. * kern/timer.c (time_trap_uexit): Define argument type. --- i386/i386/ast_check.c | 4 ++-- i386/i386/pic.c | 4 ++-- i386/i386at/com.c | 10 +++++----- i386/i386at/kd.c | 4 ++-- i386/i386at/kd_mouse.c | 2 +- ipc/mach_port.c | 2 +- ipc/mach_rpc.c | 2 +- kern/act.c | 2 +- kern/lock_mon.c | 16 ++++++++-------- kern/timer.c | 2 +- 10 files changed, 24 insertions(+), 24 deletions(-) diff --git a/i386/i386/ast_check.c b/i386/i386/ast_check.c index 9afb9028..61c68da2 100644 --- a/i386/i386/ast_check.c +++ b/i386/i386/ast_check.c @@ -37,7 +37,7 @@ /* * Initialize for remote invocation of ast_check. */ -init_ast_check(processor) +void init_ast_check(processor) processor_t processor; { } @@ -45,7 +45,7 @@ init_ast_check(processor) /* * Cause remote invocation of ast_check. Caller is at splsched(). */ -cause_ast_check(processor) +void cause_ast_check(processor) processor_t processor; { } diff --git a/i386/i386/pic.c b/i386/i386/pic.c index 9c51497b..e8c881af 100644 --- a/i386/i386/pic.c +++ b/i386/i386/pic.c @@ -237,7 +237,7 @@ form_pic_mask(void) } void -intnull(unit_dev) +intnull(int unit_dev) { printf("intnull(%d)\n", unit_dev); } @@ -245,7 +245,7 @@ intnull(unit_dev) int prtnull_count = 0; void -prtnull(unit) +prtnull(int unit) { ++prtnull_count; } diff --git a/i386/i386at/com.c b/i386/i386at/com.c index 4a62bb7e..8f293afa 100644 --- a/i386/i386at/com.c +++ b/i386/i386at/com.c @@ -826,16 +826,16 @@ int flags; * Code to be called from debugger. * */ -void compr_addr(addr) +void compr_addr(vm_offset_t addr) { /* The two line_stat prints may show different values, since * touching some of the registers constitutes changing them. */ - printf("LINE_STAT(%x) %x\n", + printf("LINE_STAT(%lu) %x\n", LINE_STAT(addr), inb(LINE_STAT(addr))); - printf("TXRX(%x) %x, INTR_ENAB(%x) %x, INTR_ID(%x) %x, LINE_CTL(%x) %x,\n\ -MODEM_CTL(%x) %x, LINE_STAT(%x) %x, MODEM_STAT(%x) %x\n", + printf("TXRX(%lu) %x, INTR_ENAB(%lu) %x, INTR_ID(%lu) %x, LINE_CTL(%lu) %x,\n\ +MODEM_CTL(%lu) %x, LINE_STAT(%lu) %x, MODEM_STAT(%lu) %x\n", TXRX(addr), inb(TXRX(addr)), INTR_ENAB(addr), inb(INTR_ENAB(addr)), INTR_ID(addr), inb(INTR_ID(addr)), @@ -845,7 +845,7 @@ MODEM_CTL(%x) %x, LINE_STAT(%x) %x, MODEM_STAT(%x) %x\n", MODEM_STAT(addr),inb(MODEM_STAT(addr))); } -int compr(unit) +int compr(int unit) { compr_addr(cominfo[unit]->address); return(0); diff --git a/i386/i386at/kd.c b/i386/i386at/kd.c index a326626b..33d17992 100644 --- a/i386/i386at/kd.c +++ b/i386/i386at/kd.c @@ -2283,7 +2283,7 @@ int ch=KC_CMD_READ; } void -kd_cmdreg_write(val) +kd_cmdreg_write(int val) { int ch=KC_CMD_WRITE; @@ -2400,7 +2400,7 @@ static int which_button[] = {0, MOUSE_LEFT, MOUSE_MIDDLE, MOUSE_RIGHT}; static struct mouse_motion moved; int -kd_kbd_magic(scancode) +kd_kbd_magic(int scancode) { int new_button = 0; diff --git a/i386/i386at/kd_mouse.c b/i386/i386at/kd_mouse.c index 9aa4b819..ef399a55 100644 --- a/i386/i386at/kd_mouse.c +++ b/i386/i386at/kd_mouse.c @@ -112,7 +112,7 @@ int mouse_char_index; /* mouse response */ * init_mouse_hw - initialize the serial port. */ void -init_mouse_hw(unit, mode) +init_mouse_hw(dev_t unit, int mode) { unsigned short base_addr = cominfo[unit]->address; diff --git a/ipc/mach_port.c b/ipc/mach_port.c index 3e5af400..fbc5e696 100644 --- a/ipc/mach_port.c +++ b/ipc/mach_port.c @@ -1457,7 +1457,7 @@ mach_port_set_rpcinfo(space, name, rpc_info, rpc_info_count) int sacts, maxsacts; #endif -sact_count() +void sact_count(void) { printf("%d server activations in use, %d max\n", sacts, maxsacts); } diff --git a/ipc/mach_rpc.c b/ipc/mach_rpc.c index 7f5b2eb2..643d0fbf 100644 --- a/ipc/mach_rpc.c +++ b/ipc/mach_rpc.c @@ -141,7 +141,7 @@ mach_port_rpc_copy(portp, sact, dact) } kern_return_t -mach_port_rpc_sig(space, name, buffer, buflen) +mach_port_rpc_sig(ipc_space_t space, char *name, char *buffer, unsigned int buflen) { return KERN_FAILURE; } diff --git a/kern/act.c b/kern/act.c index c0b6aa8b..b8ad602f 100644 --- a/kern/act.c +++ b/kern/act.c @@ -1076,7 +1076,7 @@ void act_count(void) ACT_STATIC_KLUDGE-i, ACT_STATIC_KLUDGE, ACT_STATIC_KLUDGE-amin); } -dump_act(act) +void dump_act(act) Act *act; { act_count(); diff --git a/kern/lock_mon.c b/kern/lock_mon.c index 6138efc2..33ce70f1 100644 --- a/kern/lock_mon.c +++ b/kern/lock_mon.c @@ -112,7 +112,7 @@ decl_simple_lock_data(, **lock) } -simple_lock(lock) +void simple_lock(lock) decl_simple_lock_data(, *lock) { struct lock_info *li = locate_lock_info(&lock); @@ -131,7 +131,7 @@ decl_simple_lock_data(, *lock) li->time = time_stamp - li->time; } -simple_lock_try(lock) +int simple_lock_try(lock) decl_simple_lock_data(, *lock) { struct lock_info *li = locate_lock_info(&lock); @@ -151,7 +151,7 @@ decl_simple_lock_data(, *lock) } } -simple_unlock(lock) +void simple_unlock(lock) decl_simple_lock_data(, *lock) { time_stamp_t stamp = time_stamp; @@ -167,13 +167,13 @@ decl_simple_lock_data(, *lock) } } -lip() { +void lip(void) { lis(4, 1, 0); } #define lock_info_sort lis -lock_info_sort(arg, abs, count) +void lock_info_sort(arg, abs, count) { struct lock_info *li, mean; int bucket = 0; @@ -251,7 +251,7 @@ lock_info_sort(arg, abs, count) #define lock_info_clear lic -lock_info_clear() +void lock_info_clear(void) { struct lock_info *li; int bucket = 0; @@ -265,7 +265,7 @@ lock_info_clear() memset(&default_lock_info, 0, sizeof(struct lock_info)); } -print_lock_info(li) +void print_lock_info(li) struct lock_info *li; { int off; @@ -293,7 +293,7 @@ struct lock_info *li; * Measure lock/unlock operations */ -time_lock(loops) +void time_lock(int loops) { decl_simple_lock_data(, lock) time_stamp_t stamp; diff --git a/kern/timer.c b/kern/timer.c index 6ee9a101..47b834cf 100644 --- a/kern/timer.c +++ b/kern/timer.c @@ -147,7 +147,7 @@ unsigned ts; * user mode. */ void -time_trap_uexit(ts) +time_trap_uexit(int ts) { int elapsed; int mycpu; -- cgit v1.2.3 From 442227ee5519f307e9f74030a9eeb7aa7983a4bc Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 15 Dec 2013 21:18:30 +0100 Subject: Fix gcc signedness warning Thanks Marin Ramesa and Richard Braun for investigating. * i386/i386at/kd.c (kdintr): Make `char_idx' and `max' unsigned. (kdstate2idx): Make function take and return unsigned ints for the state. * i386/i386at/kd.h (kdstate2idx): Likewise. --- i386/i386at/kd.c | 8 ++++---- i386/i386at/kd.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/i386/i386at/kd.c b/i386/i386at/kd.c index 33d17992..3c66cc55 100644 --- a/i386/i386at/kd.c +++ b/i386/i386at/kd.c @@ -727,7 +727,7 @@ int vec; struct tty *tp; unsigned char c; unsigned char scancode; - int char_idx; + unsigned int char_idx; boolean_t up = FALSE; /* key-up event */ if (kd_pollc) @@ -807,7 +807,7 @@ int vec; set_kd_state(do_modifier(kd_state, c, up)); } else if (!up) { /* regular key-down */ - int max; /* max index for char sequence */ + unsigned int max; /* max index for char sequence */ max = char_idx + NUMOUTPUT; char_idx++; @@ -1028,9 +1028,9 @@ Scancode scancode; * Return the value for the 2nd index into key_map that * corresponds to the given state. */ -int +unsigned int kdstate2idx(state, extended) -int state; /* bit vector, not a state index */ +unsigned int state; /* bit vector, not a state index */ boolean_t extended; { int state_idx = NORM_STATE; diff --git a/i386/i386at/kd.h b/i386/i386at/kd.h index 9909341e..0907e239 100644 --- a/i386/i386at/kd.h +++ b/i386/i386at/kd.h @@ -731,7 +731,7 @@ extern int kdsetbell (int, int); extern void kd_resend (void); extern void kd_handle_ack (void); extern int kd_kbd_magic (int); -extern int kdstate2idx (int, boolean_t); +extern unsigned int kdstate2idx (unsigned int, boolean_t); extern void kd_parserest (u_char *); extern int kdcnprobe(struct consdev *cp); extern int kdcninit(struct consdev *cp); -- cgit v1.2.3 From f885fde0a7177f954893be22efdf8c55c7c40fdb Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sun, 15 Dec 2013 11:48:39 +0100 Subject: ddb: qualify pointers whose dereferenced values are constant with const --- chips/busses.c | 8 ++++---- chips/busses.h | 8 ++++---- ddb/db_aout.c | 34 +++++++++++++++++----------------- ddb/db_break.c | 20 ++++++++++---------- ddb/db_break.h | 12 ++++++------ ddb/db_command.c | 22 +++++++++++----------- ddb/db_command.h | 4 ++-- ddb/db_cond.c | 2 +- ddb/db_cond.h | 2 +- ddb/db_examine.c | 12 ++++++------ ddb/db_examine.h | 10 +++++----- ddb/db_expr.c | 6 +++--- ddb/db_expr.h | 2 +- ddb/db_input.c | 4 ++-- ddb/db_lex.c | 4 ++-- ddb/db_lex.h | 4 ++-- ddb/db_macro.c | 4 ++-- ddb/db_macro.h | 2 +- ddb/db_print.c | 18 +++++++++--------- ddb/db_print.h | 8 ++++---- ddb/db_run.c | 20 ++++++++++---------- ddb/db_run.h | 12 ++++++------ ddb/db_sym.c | 6 +++--- ddb/db_sym.h | 2 +- ddb/db_task_thread.c | 18 +++++++++--------- ddb/db_task_thread.h | 8 ++++---- ddb/db_variables.c | 9 +++++---- ddb/db_watch.c | 10 +++++----- ddb/db_watch.h | 10 +++++----- ddb/db_write_cmd.c | 2 +- ddb/db_write_cmd.h | 2 +- i386/intel/pmap.c | 4 ++-- i386/intel/pmap.h | 2 +- 33 files changed, 146 insertions(+), 145 deletions(-) diff --git a/chips/busses.c b/chips/busses.c index f9f6f1be..3811d0c6 100644 --- a/chips/busses.c +++ b/chips/busses.c @@ -59,11 +59,11 @@ * */ boolean_t configure_bus_master( - char *name, + const char *name, vm_offset_t virt, vm_offset_t phys, int adpt_no, - char *bus_name) + const char *bus_name) { struct bus_device *device; struct bus_ctlr *master; @@ -171,11 +171,11 @@ boolean_t configure_bus_master( * */ boolean_t configure_bus_device( - char *name, + const char *name, vm_offset_t virt, vm_offset_t phys, int adpt_no, - char *bus_name) + const char *bus_name) { struct bus_device *device; struct bus_driver *driver; diff --git a/chips/busses.h b/chips/busses.h index 49c0e44f..f728add0 100644 --- a/chips/busses.h +++ b/chips/busses.h @@ -144,10 +144,10 @@ struct bus_driver { extern struct bus_ctlr bus_master_init[]; extern struct bus_device bus_device_init[]; -extern boolean_t configure_bus_master(char *, vm_offset_t, vm_offset_t, - int, char * ); -extern boolean_t configure_bus_device(char *, vm_offset_t, vm_offset_t, - int, char * ); +extern boolean_t configure_bus_master(const char *, vm_offset_t, vm_offset_t, + int, const char * ); +extern boolean_t configure_bus_device(const char *, vm_offset_t, vm_offset_t, + int, const char * ); #endif /* KERNEL */ diff --git a/ddb/db_aout.c b/ddb/db_aout.c index 8ef7efb9..57c680a1 100644 --- a/ddb/db_aout.c +++ b/ddb/db_aout.c @@ -134,7 +134,7 @@ aout_db_sym_init(symtab, esymtab, name, task_addr) */ private boolean_t aout_db_is_filename(name) - char *name; + const char *name; { while (*name) { if (*name == '.') { @@ -151,10 +151,10 @@ aout_db_is_filename(name) */ private boolean_t aout_db_eq_name(sp, name) - struct nlist *sp; - char *name; + const struct nlist *sp; + const char *name; { - char *s1, *s2; + const char *s1, *s2; s1 = sp->n_un.n_name; s2 = name; @@ -186,11 +186,11 @@ aout_db_eq_name(sp, name) */ private struct nlist * aout_db_search_name(sp, ep, name, type, fp) - struct nlist *sp; - struct nlist *ep; - char *name; - int type; - struct nlist **fp; + struct nlist *sp; + const struct nlist *ep; + const char *name; + int type; + struct nlist **fp; { struct nlist *file_sp = *fp; struct nlist *found_sp = 0; @@ -233,8 +233,8 @@ aout_db_search_name(sp, ep, name, type, fp) private db_sym_t aout_db_qualified_search(stab, file, sym, line) db_symtab_t *stab; - char *file; - char *sym; + const char *file; + const char *sym; int line; { struct nlist *sp = (struct nlist *)stab->start; @@ -396,12 +396,12 @@ aout_db_symbol_values(stab, sym, namep, valuep) */ private boolean_t aout_db_search_by_addr(stab, addr, file, func, line, diff) - db_symtab_t *stab; - vm_offset_t addr; - char **file; - char **func; - int *line; - unsigned long *diff; + const db_symtab_t *stab; + vm_offset_t addr; + char **file; + char **func; + int *line; + unsigned long *diff; { struct nlist *sp; struct nlist *line_sp, *func_sp, *file_sp, *line_func; diff --git a/ddb/db_break.c b/ddb/db_break.c index d8273ea5..e41834da 100644 --- a/ddb/db_break.c +++ b/ddb/db_break.c @@ -90,7 +90,7 @@ db_breakpoint_free(bkpt) static int db_add_thread_breakpoint(bkpt, task_thd, count, task_bpt) - db_breakpoint_t bkpt; + const db_breakpoint_t bkpt; vm_offset_t task_thd; int count; boolean_t task_bpt; @@ -156,8 +156,8 @@ db_delete_thread_breakpoint(bkpt, task_thd) static db_thread_breakpoint_t db_find_thread_breakpoint(bkpt, thread) - db_breakpoint_t bkpt; - thread_t thread; + const db_breakpoint_t bkpt; + const thread_t thread; { db_thread_breakpoint_t tp; task_t task = (thread == THREAD_NULL)? TASK_NULL: thread->task; @@ -176,7 +176,7 @@ db_find_thread_breakpoint(bkpt, thread) db_thread_breakpoint_t db_find_thread_breakpoint_here(task, addr) - task_t task; + const task_t task; db_addr_t addr; { db_breakpoint_t bkpt; @@ -268,10 +268,10 @@ db_check_breakpoint_valid(void) db_breakpoint_t db_set_breakpoint(task, addr, count, thread, task_bpt) - task_t task; + const task_t task; db_addr_t addr; int count; - thread_t thread; + const thread_t thread; boolean_t task_bpt; { db_breakpoint_t bkpt; @@ -321,7 +321,7 @@ db_set_breakpoint(task, addr, count, thread, task_bpt) void db_delete_breakpoint(task, addr, task_thd) - task_t task; + const task_t task; db_addr_t addr; vm_offset_t task_thd; { @@ -352,7 +352,7 @@ db_delete_breakpoint(task, addr, task_thd) db_breakpoint_t db_find_breakpoint(task, addr) - task_t task; + const task_t task; db_addr_t addr; { db_breakpoint_t bkpt; @@ -368,7 +368,7 @@ db_find_breakpoint(task, addr) boolean_t db_find_breakpoint_here(task, addr) - task_t task; + const task_t task; db_addr_t addr; { db_breakpoint_t bkpt; @@ -681,7 +681,7 @@ db_breakpoint_cmd(addr, have_addr, count, modif) db_expr_t addr; int have_addr; db_expr_t count; - char * modif; + const char * modif; { int n; thread_t thread; diff --git a/ddb/db_break.h b/ddb/db_break.h index e323a5f4..ad861198 100644 --- a/ddb/db_break.h +++ b/ddb/db_break.h @@ -71,12 +71,12 @@ struct db_breakpoint { typedef struct db_breakpoint *db_breakpoint_t; -extern db_breakpoint_t db_find_breakpoint( task_t task, db_addr_t addr); -extern boolean_t db_find_breakpoint_here( task_t task, db_addr_t addr); +extern db_breakpoint_t db_find_breakpoint( const task_t task, db_addr_t addr); +extern boolean_t db_find_breakpoint_here( const task_t task, db_addr_t addr); extern void db_set_breakpoints(void); extern void db_clear_breakpoints(void); extern db_thread_breakpoint_t db_find_thread_breakpoint_here - ( task_t task, db_addr_t addr ); + ( const task_t task, db_addr_t addr ); extern db_thread_breakpoint_t db_find_breakpoint_number ( int num, db_breakpoint_t *bkptp); @@ -84,8 +84,8 @@ extern db_breakpoint_t db_set_temp_breakpoint( task_t task, db_addr_t addr); extern void db_delete_temp_breakpoint ( task_t task, db_breakpoint_t bkpt); -extern db_breakpoint_t db_set_breakpoint(task_t task, db_addr_t addr, - int count, thread_t thread, +extern db_breakpoint_t db_set_breakpoint(const task_t task, db_addr_t addr, + int count, const thread_t thread, boolean_t task_bpt); void db_listbreak_cmd(); @@ -96,7 +96,7 @@ void db_breakpoint_cmd( db_expr_t addr, int have_addr, db_expr_t count, - char * modif); + const char * modif); extern void db_check_breakpoint_valid(void); diff --git a/ddb/db_command.c b/ddb/db_command.c index 85cbf816..3257e073 100644 --- a/ddb/db_command.c +++ b/ddb/db_command.c @@ -95,15 +95,15 @@ boolean_t db_ed_style = TRUE; */ int db_cmd_search(name, table, cmdp) - char * name; - struct db_command *table; - struct db_command **cmdp; /* out */ + const char * name; + const struct db_command *table; + const struct db_command **cmdp; /* out */ { - struct db_command *cmd; + const struct db_command *cmd; int result = CMD_NONE; for (cmd = table; cmd->name != 0; cmd++) { - char *lp; + const char *lp; char *rp; int c; @@ -142,9 +142,9 @@ db_cmd_search(name, table, cmdp) void db_cmd_list(table) - struct db_command *table; + const struct db_command *table; { - struct db_command *cmd; + const struct db_command *cmd; for (cmd = table; cmd->name != 0; cmd++) { db_printf("%-12s", cmd->name); @@ -447,7 +447,7 @@ db_exec_cmd_nest(cmd, size) } void db_error(s) - char *s; + const char *s; { extern int db_macro_level; @@ -524,10 +524,10 @@ db_fncall(void) boolean_t db_option(modif, option) - char *modif; - int option; + const char *modif; + int option; { - char *p; + const char *p; for (p = modif; *p; p++) if (*p == option) diff --git a/ddb/db_command.h b/ddb/db_command.h index 30e1f21e..5f0236a7 100644 --- a/ddb/db_command.h +++ b/ddb/db_command.h @@ -41,9 +41,9 @@ #include extern void db_command_loop(void); -extern boolean_t db_option(char *, int); +extern boolean_t db_option(const char *, int); -extern void db_error(char *); /* report error */ +extern void db_error(const char *); /* report error */ extern db_addr_t db_dot; /* current location */ extern db_addr_t db_last_addr; /* last explicit address typed */ diff --git a/ddb/db_cond.c b/ddb/db_cond.c index ae52bef8..2c923b4d 100644 --- a/ddb/db_cond.c +++ b/ddb/db_cond.c @@ -105,7 +105,7 @@ db_cond_check(bkpt) void db_cond_print(bkpt) - db_thread_breakpoint_t bkpt; + const db_thread_breakpoint_t bkpt; { char *p, *ep; struct db_cond *cp; diff --git a/ddb/db_cond.h b/ddb/db_cond.h index dec4967d..6b9c3a5b 100644 --- a/ddb/db_cond.h +++ b/ddb/db_cond.h @@ -24,7 +24,7 @@ #include #include -extern void db_cond_free (db_thread_breakpoint_t bkpt); +extern void db_cond_free (const db_thread_breakpoint_t bkpt); extern boolean_t db_cond_check (db_thread_breakpoint_t bkpt); diff --git a/ddb/db_examine.c b/ddb/db_examine.c index 6e7f89cc..cb103aed 100644 --- a/ddb/db_examine.c +++ b/ddb/db_examine.c @@ -62,7 +62,7 @@ db_examine_cmd(addr, have_addr, count, modif) db_expr_t addr; int have_addr; db_expr_t count; - char * modif; + const char * modif; { thread_t thread; @@ -94,7 +94,7 @@ db_examine_forward(addr, have_addr, count, modif) db_expr_t addr; int have_addr; db_expr_t count; - char * modif; + const char * modif; { db_examine(db_next, db_examine_format, db_examine_count, db_thread_to_task(db_examine_thread)); @@ -106,7 +106,7 @@ db_examine_backward(addr, have_addr, count, modif) db_expr_t addr; int have_addr; db_expr_t count; - char * modif; + const char * modif; { db_examine(db_examine_prev_addr - (db_next - db_examine_prev_addr), @@ -117,7 +117,7 @@ db_examine_backward(addr, have_addr, count, modif) void db_examine(addr, fmt, count, task) db_addr_t addr; - char * fmt; /* format string */ + const char * fmt; /* format string */ int count; /* repeat count */ task_t task; { @@ -125,7 +125,7 @@ db_examine(addr, fmt, count, task) db_expr_t value; int size; /* in bytes */ int width; - char * fp; + const char * fp; db_examine_prev_addr = addr; while (--count >= 0) { @@ -333,7 +333,7 @@ db_print_loc_and_inst(loc, task) void db_strcpy(dst, src) char *dst; - char *src; + const char *src; { while ((*dst++ = *src++)) ; diff --git a/ddb/db_examine.h b/ddb/db_examine.h index e4f34155..df578a02 100644 --- a/ddb/db_examine.h +++ b/ddb/db_examine.h @@ -29,13 +29,13 @@ extern void db_examine_cmd ( db_expr_t addr, int have_addr, db_expr_t count, - char *modif); + const char *modif); -extern void db_strcpy (char *dst, char *src); +extern void db_strcpy (char *dst, const char *src); extern void db_examine ( db_addr_t addr, - char *fmt, + const char *fmt, int count, task_t task); @@ -43,13 +43,13 @@ void db_examine_forward( db_expr_t addr, int have_addr, db_expr_t count, - char * modif); + const char * modif); void db_examine_backward( db_expr_t addr, int have_addr, db_expr_t count, - char * modif); + const char * modif); extern void db_print_loc_and_inst ( db_addr_t loc, diff --git a/ddb/db_expr.c b/ddb/db_expr.c index 82ada586..dad09e5c 100644 --- a/ddb/db_expr.c +++ b/ddb/db_expr.c @@ -95,12 +95,12 @@ db_term(valuep) int db_size_option(modif, u_option, t_option) - char *modif; + const char *modif; boolean_t *u_option; boolean_t *t_option; { - char *p; - int size = sizeof(int); + const char *p; + int size = sizeof(int); *u_option = FALSE; *t_option = FALSE; diff --git a/ddb/db_expr.h b/ddb/db_expr.h index 989b66be..9c304e69 100644 --- a/ddb/db_expr.h +++ b/ddb/db_expr.h @@ -17,7 +17,7 @@ */ int db_size_option( - char *modif, + const char *modif, boolean_t *u_option, boolean_t *t_option); diff --git a/ddb/db_input.c b/ddb/db_input.c index 5be3a8ad..f908705d 100644 --- a/ddb/db_input.c +++ b/ddb/db_input.c @@ -69,8 +69,8 @@ char * db_history_prev = (char *) 0; /* start of previous line */ void db_putstring(s, count) - char *s; - int count; + const char *s; + int count; { while (--count >= 0) cnputc(*s++); diff --git a/ddb/db_lex.c b/ddb/db_lex.c index 203472d0..e7f67d29 100644 --- a/ddb/db_lex.c +++ b/ddb/db_lex.c @@ -50,7 +50,7 @@ db_expr_t db_look_token = 0; int db_read_line(repeat_last) - char *repeat_last; + const char *repeat_last; { int i; @@ -105,7 +105,7 @@ db_save_lex_context(lp) void db_restore_lex_context(lp) - struct db_lex_context *lp; + const struct db_lex_context *lp; { db_lp = lp->l_ptr; db_last_lp = db_lp; diff --git a/ddb/db_lex.h b/ddb/db_lex.h index 5900122f..f7677df8 100644 --- a/ddb/db_lex.h +++ b/ddb/db_lex.h @@ -45,7 +45,7 @@ struct db_lex_context { }; extern int db_lex(void); -extern int db_read_line(char *rep_str); +extern int db_read_line(const char *rep_str); extern void db_flush_line(void); extern int db_read_char(void); extern void db_unread_char(int c); @@ -54,7 +54,7 @@ extern void db_unread_token(int t); extern void db_flush_lex(void); extern void db_switch_input(char *, int); extern void db_save_lex_context(struct db_lex_context *); -extern void db_restore_lex_context(struct db_lex_context *); +extern void db_restore_lex_context(const struct db_lex_context *); extern void db_skip_to_eol(void); extern db_expr_t db_tok_number; diff --git a/ddb/db_macro.c b/ddb/db_macro.c index f985679e..e22f6bf3 100644 --- a/ddb/db_macro.c +++ b/ddb/db_macro.c @@ -59,7 +59,7 @@ db_expr_t db_macro_args[DB_MACRO_LEVEL][DB_NARGS]; static struct db_user_macro * db_lookup_macro(name) - char *name; + const char *name; { struct db_user_macro *mp; @@ -141,7 +141,7 @@ db_show_macro(void) int db_exec_macro(name) - char *name; + const char *name; { struct db_user_macro *mp; int n; diff --git a/ddb/db_macro.h b/ddb/db_macro.h index 525eead3..2c0a599b 100644 --- a/ddb/db_macro.h +++ b/ddb/db_macro.h @@ -30,7 +30,7 @@ extern void db_del_macro_cmd (void); extern void db_show_macro (void); -extern int db_exec_macro (char *name); +extern int db_exec_macro (const char *name); extern void db_arg_variable ( struct db_variable *vp, diff --git a/ddb/db_print.c b/ddb/db_print.c index fbc09608..17ca2ccf 100644 --- a/ddb/db_print.c +++ b/ddb/db_print.c @@ -127,8 +127,8 @@ db_show_regs(addr, have_addr, count, modif) char * db_thread_stat(thread, status) - thread_t thread; - char *status; + const thread_t thread; + char *status; { char *p = status; @@ -281,7 +281,7 @@ db_show_all_threads(addr, have_addr, count, modif) db_expr_t addr; boolean_t have_addr; db_expr_t count; - char * modif; + const char * modif; { task_t task; int task_id; @@ -332,7 +332,7 @@ db_show_one_thread(addr, have_addr, count, modif) db_expr_t addr; boolean_t have_addr; db_expr_t count; - char * modif; + const char * modif; { int flag; int thread_id; @@ -378,7 +378,7 @@ db_show_one_task(addr, have_addr, count, modif) db_expr_t addr; boolean_t have_addr; db_expr_t count; - char * modif; + const char * modif; { int flag; int task_id; @@ -410,7 +410,7 @@ db_show_one_task(addr, have_addr, count, modif) int db_port_iterate(thread, func) - thread_t thread; + const thread_t thread; void (*func)(); { ipc_entry_t entry; @@ -452,7 +452,7 @@ db_lookup_port(thread, id) static void db_print_port_id(id, port, bits, n) int id; - ipc_port_t port; + const ipc_port_t port; unsigned bits; int n; { @@ -466,7 +466,7 @@ db_print_port_id(id, port, bits, n) static void db_print_port_id_long( int id, - ipc_port_t port, + const ipc_port_t port, unsigned bits, int n) { @@ -484,7 +484,7 @@ db_show_port_id(addr, have_addr, count, modif) db_expr_t addr; boolean_t have_addr; db_expr_t count; - char * modif; + const char * modif; { thread_t thread; diff --git a/ddb/db_print.h b/ddb/db_print.h index 898014e8..dacb47b8 100644 --- a/ddb/db_print.h +++ b/ddb/db_print.h @@ -24,25 +24,25 @@ void db_show_one_task( db_expr_t addr, boolean_t have_addr, db_expr_t count, - char * modif); + const char * modif); void db_show_port_id( db_expr_t addr, boolean_t have_addr, db_expr_t count, - char * modif); + const char * modif); void db_show_one_thread( db_expr_t addr, int have_addr, db_expr_t count, - char * modif); + const char * modif); void db_show_all_threads( db_expr_t addr, int have_addr, db_expr_t count, - char * modif); + const char * modif); db_addr_t db_task_from_space( ipc_space_t space, diff --git a/ddb/db_run.c b/ddb/db_run.c index 09786673..945d097a 100644 --- a/ddb/db_run.c +++ b/ddb/db_run.c @@ -251,8 +251,8 @@ db_breakpoint_t db_taken_bkpt = 0; db_breakpoint_t db_find_temp_breakpoint(task, addr) - task_t task; - db_addr_t addr; + const task_t task; + db_addr_t addr; { if (db_taken_bkpt && (db_taken_bkpt->address == addr) && db_taken_bkpt->task == task) @@ -265,8 +265,8 @@ db_find_temp_breakpoint(task, addr) void db_set_task_single_step(regs, task) - db_regs_t *regs; - task_t task; + db_regs_t *regs; + task_t task; { db_addr_t pc = PC_REGS(regs), brpc; unsigned int inst; @@ -310,8 +310,8 @@ db_set_task_single_step(regs, task) void db_clear_task_single_step(regs, task) - db_regs_t *regs; - task_t task; + const db_regs_t *regs; + task_t task; { if (db_taken_bkpt != 0) { db_delete_temp_breakpoint(task, db_taken_bkpt); @@ -335,7 +335,7 @@ db_single_step_cmd(addr, have_addr, count, modif) db_expr_t addr; int have_addr; db_expr_t count; - char * modif; + const char * modif; { boolean_t print = FALSE; @@ -363,7 +363,7 @@ db_trace_until_call_cmd(addr, have_addr, count, modif) db_expr_t addr; int have_addr; db_expr_t count; - char * modif; + const char * modif; { boolean_t print = FALSE; @@ -386,7 +386,7 @@ db_trace_until_matching_cmd(addr, have_addr, count, modif) db_expr_t addr; int have_addr; db_expr_t count; - char * modif; + const char * modif; { boolean_t print = FALSE; @@ -411,7 +411,7 @@ db_continue_cmd(addr, have_addr, count, modif) db_expr_t addr; int have_addr; db_expr_t count; - char * modif; + const char * modif; { if (modif[0] == 'c') db_run_mode = STEP_COUNT; diff --git a/ddb/db_run.h b/ddb/db_run.h index 0c552799..c042d4ca 100644 --- a/ddb/db_run.h +++ b/ddb/db_run.h @@ -46,27 +46,27 @@ extern void db_single_step(db_regs_t *regs, task_t task); extern void db_single_step_cmd( db_expr_t addr, - int have_addr, + int have_addr, db_expr_t count, - char *modif); + const char *modif); void db_trace_until_call_cmd( db_expr_t addr, int have_addr, db_expr_t count, - char * modif); + const char * modif); void db_trace_until_matching_cmd( db_expr_t addr, int have_addr, db_expr_t count, - char * modif); + const char * modif); void db_continue_cmd( db_expr_t addr, int have_addr, db_expr_t count, - char * modif); + const char * modif); #ifndef db_set_single_step void db_set_task_single_step(db_regs_t *, task_t); @@ -74,7 +74,7 @@ void db_set_task_single_step(db_regs_t *, task_t); #define db_set_task_single_step(regs, task) db_set_single_step(regs) #endif #ifndef db_clear_single_step -void db_clear_task_single_step(db_regs_t *, task_t); +void db_clear_task_single_step(const db_regs_t *, task_t); #else #define db_clear_task_single_step(regs, task) db_clear_single_step(regs) #endif diff --git a/ddb/db_sym.c b/ddb/db_sym.c index e801e627..bbf14bdb 100644 --- a/ddb/db_sym.c +++ b/ddb/db_sym.c @@ -90,8 +90,8 @@ db_add_symbol_table(type, start, end, name, ref, map_pointer) */ static char * db_qualify(symname, symtabname) - char *symname; - char *symtabname; + const char *symname; + const char *symtabname; { static char tmp[256]; char *s; @@ -108,7 +108,7 @@ db_qualify(symname, symtabname) boolean_t -db_eqname( char* src, char* dst, char c ) +db_eqname( const char* src, const char* dst, char c ) { if (!strcmp(src, dst)) return (TRUE); diff --git a/ddb/db_sym.h b/ddb/db_sym.h index cb574dd4..2c3e10a6 100644 --- a/ddb/db_sym.h +++ b/ddb/db_sym.h @@ -161,7 +161,7 @@ extern void db_symbol_values( db_symtab_t *stab, db_search_task_symbol(val,strgy,offp,0) /* strcmp, modulo leading char */ -extern boolean_t db_eqname( char* src, char* dst, char c ); +extern boolean_t db_eqname( const char* src, const char* dst, char c ); /* print closest symbol to a value */ extern void db_task_printsym( db_addr_t off, diff --git a/ddb/db_task_thread.c b/ddb/db_task_thread.c index f420b8d9..266b1ea7 100644 --- a/ddb/db_task_thread.c +++ b/ddb/db_task_thread.c @@ -52,7 +52,7 @@ thread_t db_default_thread; /* default target thread */ */ int db_lookup_task(target_task) - task_t target_task; + const task_t target_task; { task_t task; int task_id; @@ -82,8 +82,8 @@ db_lookup_task(target_task) */ int db_lookup_task_thread(task, target_thread) - task_t task; - thread_t target_thread; + const task_t task; + const thread_t target_thread; { thread_t thread; int thread_id; @@ -106,7 +106,7 @@ db_lookup_task_thread(task, target_thread) */ int db_lookup_thread(target_thread) - thread_t target_thread; + const thread_t target_thread; { int thread_id; task_t task; @@ -139,7 +139,7 @@ db_lookup_thread(target_thread) */ boolean_t db_check_thread_address_valid(thread) - thread_t thread; + const thread_t thread; { if (db_lookup_thread(thread) < 0) { db_printf("Bad thread address 0x%x\n", thread); @@ -247,10 +247,10 @@ db_init_default_thread(void) /* ARGSUSED */ void db_set_default_thread(vp, valuep, flag, ap) - struct db_variable *vp; - db_expr_t *valuep; - int flag; - db_var_aux_param_t ap; + struct db_variable *vp; + db_expr_t *valuep; + int flag; + db_var_aux_param_t ap; { thread_t thread; diff --git a/ddb/db_task_thread.h b/ddb/db_task_thread.h index e6ae114a..cbb36802 100644 --- a/ddb/db_task_thread.h +++ b/ddb/db_task_thread.h @@ -43,10 +43,10 @@ extern task_t db_default_task; /* default target task */ extern thread_t db_default_thread; /* default target thread */ -extern int db_lookup_task(task_t); -extern int db_lookup_thread(thread_t); -extern int db_lookup_task_thread(task_t, thread_t); -extern boolean_t db_check_thread_address_valid(thread_t); +extern int db_lookup_task(const task_t); +extern int db_lookup_thread(const thread_t); +extern int db_lookup_task_thread(const task_t, const thread_t); +extern boolean_t db_check_thread_address_valid(const thread_t); extern boolean_t db_get_next_thread(thread_t *, int); extern void db_init_default_thread(void); diff --git a/ddb/db_variables.c b/ddb/db_variables.c index 9d77c0a5..7f5a2c9b 100644 --- a/ddb/db_variables.c +++ b/ddb/db_variables.c @@ -68,9 +68,9 @@ struct db_variable db_vars[] = { }; struct db_variable *db_evars = db_vars + sizeof(db_vars)/sizeof(db_vars[0]); -char * +const char * db_get_suffix(suffix, suffix_value) - char *suffix; + const char *suffix; short *suffix_value; { int value; @@ -90,9 +90,10 @@ static boolean_t db_cmp_variable_name(vp, name, ap) struct db_variable *vp; char *name; - db_var_aux_param_t ap; + const db_var_aux_param_t ap; { - char *var_np, *np; + char *var_np; + const char *np; int level; for (np = name, var_np = vp->name; *var_np; ) { diff --git a/ddb/db_watch.c b/ddb/db_watch.c index 567040c1..c8a42868 100644 --- a/ddb/db_watch.c +++ b/ddb/db_watch.c @@ -93,7 +93,7 @@ db_watchpoint_free(watch) void db_set_watchpoint(task, addr, size) - task_t task; + const task_t task; db_addr_t addr; vm_size_t size; { @@ -130,7 +130,7 @@ db_set_watchpoint(task, addr, size) void db_delete_watchpoint(task, addr) - task_t task; + const task_t task; db_addr_t addr; { db_watchpoint_t watch; @@ -179,7 +179,7 @@ db_list_watchpoints(void) static int db_get_task(modif, taskp, addr) - char *modif; + const char *modif; task_t *taskp; db_addr_t addr; { @@ -221,7 +221,7 @@ db_deletewatch_cmd(addr, have_addr, count, modif) db_expr_t addr; int have_addr; db_expr_t count; - char * modif; + const char * modif; { task_t task; @@ -237,7 +237,7 @@ db_watchpoint_cmd(addr, have_addr, count, modif) db_expr_t addr; int have_addr; db_expr_t count; - char * modif; + const char * modif; { vm_size_t size; db_expr_t value; diff --git a/ddb/db_watch.h b/ddb/db_watch.h index 8e0f32fb..7ef1a207 100644 --- a/ddb/db_watch.h +++ b/ddb/db_watch.h @@ -49,12 +49,12 @@ typedef struct db_watchpoint { } *db_watchpoint_t; extern boolean_t db_find_watchpoint(vm_map_t map, db_addr_t addr, - db_regs_t *regs); + db_regs_t *regs); extern void db_set_watchpoints(void); extern void db_clear_watchpoints(void); -extern void db_set_watchpoint(task_t task, db_addr_t addr, vm_size_t size); -extern void db_delete_watchpoint(task_t task, db_addr_t addr); +extern void db_set_watchpoint(const task_t task, db_addr_t addr, vm_size_t size); +extern void db_delete_watchpoint(const task_t task, db_addr_t addr); extern void db_list_watchpoints(void); void db_listwatch_cmd(void); @@ -63,13 +63,13 @@ void db_deletewatch_cmd( db_expr_t addr, int have_addr, db_expr_t count, - char * modif); + const char * modif); void db_watchpoint_cmd( db_expr_t addr, int have_addr, db_expr_t count, - char * modif); + const char * modif); #endif /* _DDB_DB_WATCH_ */ diff --git a/ddb/db_write_cmd.c b/ddb/db_write_cmd.c index 1908005a..46a2ee32 100644 --- a/ddb/db_write_cmd.c +++ b/ddb/db_write_cmd.c @@ -55,7 +55,7 @@ db_write_cmd(address, have_addr, count, modif) db_expr_t address; boolean_t have_addr; db_expr_t count; - char * modif; + const char * modif; { db_addr_t addr; db_expr_t old_value; diff --git a/ddb/db_write_cmd.h b/ddb/db_write_cmd.h index 056be470..3a1d0575 100644 --- a/ddb/db_write_cmd.h +++ b/ddb/db_write_cmd.h @@ -29,6 +29,6 @@ void db_write_cmd( db_expr_t address, boolean_t have_addr, db_expr_t count, - char * modif); + const char * modif); #endif /* !_DDB_DB_WRITE_CMD_H_ */ diff --git a/i386/intel/pmap.c b/i386/intel/pmap.c index 06c4daa0..2943d26f 100644 --- a/i386/intel/pmap.c +++ b/i386/intel/pmap.c @@ -420,7 +420,7 @@ unsigned int inuse_ptepages_count = 0; /* debugging */ pt_entry_t *kernel_page_dir; static inline pt_entry_t * -pmap_pde(pmap_t pmap, vm_offset_t addr) +pmap_pde(const pmap_t pmap, vm_offset_t addr) { if (pmap == kernel_pmap) addr = kvtolin(addr); @@ -435,7 +435,7 @@ pmap_pde(pmap_t pmap, vm_offset_t addr) * This is only used internally. */ pt_entry_t * -pmap_pte(pmap_t pmap, vm_offset_t addr) +pmap_pte(const pmap_t pmap, vm_offset_t addr) { pt_entry_t *ptp; pt_entry_t pte; diff --git a/i386/intel/pmap.h b/i386/intel/pmap.h index 20c62432..047a384b 100644 --- a/i386/intel/pmap.h +++ b/i386/intel/pmap.h @@ -227,7 +227,7 @@ extern pmap_t kernel_pmap; * Machine dependent routines that are used only for i386/i486. */ -pt_entry_t *pmap_pte(pmap_t pmap, vm_offset_t addr); +pt_entry_t *pmap_pte(const pmap_t pmap, vm_offset_t addr); /* * Macros for speed. -- cgit v1.2.3 From e1e4d8e34f49463b7d40ca2a2c86ce850d95571c Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 13 Dec 2013 21:06:52 +0100 Subject: kern/sched_prim.c: avoid casts Avoid the casts by passing the address of the links thread structure member to enqueue_tail(). * kern/sched_prim.c: Avoid casts. --- kern/sched_prim.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kern/sched_prim.c b/kern/sched_prim.c index c06cd770..ec041fc8 100644 --- a/kern/sched_prim.c +++ b/kern/sched_prim.c @@ -245,7 +245,7 @@ void assert_wait( #endif /* MACH_SLOCKS */ simple_lock(lock); thread_lock(thread); - enqueue_tail(q, (queue_entry_t) thread); + enqueue_tail(q, &(thread->links)); thread->wait_event = event; if (interruptible) thread->state |= TH_WAIT; @@ -1196,7 +1196,7 @@ void update_priority( \ simple_lock(&(rq)->lock); /* lock the run queue */ \ checkrq((rq), "thread_setrun: before adding thread"); \ - enqueue_tail(&(rq)->runq[whichq], (queue_entry_t) (th)); \ + enqueue_tail(&(rq)->runq[whichq], &((th)->links)); \ \ if (whichq < (rq)->low || (rq)->count == 0) \ (rq)->low = whichq; /* minimize */ \ @@ -1219,7 +1219,7 @@ void update_priority( } \ \ simple_lock(&(rq)->lock); /* lock the run queue */ \ - enqueue_tail(&(rq)->runq[whichq], (queue_entry_t) (th)); \ + enqueue_tail(&(rq)->runq[whichq], &((th)->links)); \ \ if (whichq < (rq)->low || (rq)->count == 0) \ (rq)->low = whichq; /* minimize */ \ -- cgit v1.2.3 From fcda4718b1b8135d0d484f97bddaa683292b97c1 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 13 Dec 2013 21:06:53 +0100 Subject: device/dev_pager.c: remove unnecessary casts Variable pager is already of ipc_port_t type. * device/dev_pager.c: Remove unnecessary casts. --- device/dev_pager.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/device/dev_pager.c b/device/dev_pager.c index 97e417e0..b9796caa 100644 --- a/device/dev_pager.c +++ b/device/dev_pager.c @@ -330,7 +330,7 @@ kern_return_t device_pager_data_request( printf("(device_pager)data_request: pager=%p, offset=0x%lx, length=0x%x\n", pager, offset, length); - ds = dev_pager_hash_lookup((ipc_port_t)pager); + ds = dev_pager_hash_lookup(pager); if (ds == DEV_PAGER_NULL) panic("(device_pager)data_request: lookup failed"); @@ -470,7 +470,7 @@ kern_return_t device_pager_data_write( panic("(device_pager)data_write: called"); - ds = dev_pager_hash_lookup((ipc_port_t)pager); + ds = dev_pager_hash_lookup(pager); if (ds == DEV_PAGER_NULL) panic("(device_pager)data_write: lookup failed"); -- cgit v1.2.3 From 220ca26c79398f99d5f514604ca34cb528f59e62 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 13 Dec 2013 21:06:54 +0100 Subject: device/dev_pager.c (device_pager_data_request_done): cast to size_t instead to unsigned * device/dev_pager.c (device_pager_data_request_done) (memset) (io_residual): Cast to size_t instead to unsigned. --- device/dev_pager.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/device/dev_pager.c b/device/dev_pager.c index b9796caa..7c3e088c 100644 --- a/device/dev_pager.c +++ b/device/dev_pager.c @@ -416,7 +416,7 @@ boolean_t device_pager_data_request_done(io_req_t ior) if (device_pager_debug) printf("(device_pager)data_request_done: r: 0x%lx\n", ior->io_residual); memset((&ior->io_data[ior->io_count - ior->io_residual]), 0, - (unsigned) ior->io_residual); + (size_t) ior->io_residual); } } else { size_read = ior->io_count - ior->io_residual; -- cgit v1.2.3 From 1e9c1fd4558f7777866ffa58ef5e26552106af0f Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Sun, 15 Dec 2013 22:00:11 +0100 Subject: i386/i386/db_trace.c: use (long *) instead of an (int *) * i386/i386/db_trace.c (db_lookup_i386_kreg) (kregp): Use (long *) instead of an (int *). --- i386/i386/db_trace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i386/i386/db_trace.c b/i386/i386/db_trace.c index 6247d4f6..d0c434e1 100644 --- a/i386/i386/db_trace.c +++ b/i386/i386/db_trace.c @@ -108,7 +108,7 @@ struct i386_kregs { long * db_lookup_i386_kreg( char *name, - int *kregp) + long *kregp) { struct i386_kregs *kp; -- cgit v1.2.3 From 4e639015436ec69fc161da2eb061073701483680 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Mon, 16 Dec 2013 00:18:40 +0100 Subject: Quiet GCC warning about uninitialized variable * ddb/db_command.h (db_error): Mark with attribute noreturn. * i386/i386/setjmp.h (_longjmp): Likewise. --- ddb/db_command.h | 2 +- i386/i386/setjmp.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ddb/db_command.h b/ddb/db_command.h index 5f0236a7..634dd9d1 100644 --- a/ddb/db_command.h +++ b/ddb/db_command.h @@ -43,7 +43,7 @@ extern void db_command_loop(void); extern boolean_t db_option(const char *, int); -extern void db_error(const char *); /* report error */ +extern void db_error(const char *) __attribute__ ((noreturn)); /* report error */ extern db_addr_t db_dot; /* current location */ extern db_addr_t db_last_addr; /* last explicit address typed */ diff --git a/i386/i386/setjmp.h b/i386/i386/setjmp.h index 80f0f5fe..930a9dd5 100644 --- a/i386/i386/setjmp.h +++ b/i386/i386/setjmp.h @@ -35,6 +35,6 @@ typedef struct jmp_buf { extern int _setjmp(jmp_buf_t*); -extern void _longjmp(jmp_buf_t*, int); +extern void _longjmp(jmp_buf_t*, int) __attribute__ ((noreturn)); #endif /* _I386_SETJMP_H_ */ -- cgit v1.2.3 From f3593b77a6ab8550c119e0617e3dee4abf144533 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Mon, 16 Dec 2013 00:18:41 +0100 Subject: kern: quiet GCC warnings about set but unused variables * kern/lock.h (simple_lock_data_empty): Define. (decl_simple_lock_data, simple_unlock): Likewise. * kern/sched_prim.c (lock): Declare. [MACH_SLOCKS]: Remove #ifs. * kern/task.c (task_lock, task_unlock): Remove address operator. --- kern/lock.h | 6 ++++-- kern/sched_prim.c | 18 +++--------------- kern/task.c | 4 ++-- 3 files changed, 9 insertions(+), 19 deletions(-) diff --git a/kern/lock.h b/kern/lock.h index 4f38ea33..a6d286a1 100644 --- a/kern/lock.h +++ b/kern/lock.h @@ -94,7 +94,9 @@ extern void check_simple_locks(void); /* * Do not allocate storage for locks if not needed. */ -#define decl_simple_lock_data(class,name) +struct simple_lock_data_empty {}; +#define decl_simple_lock_data(class,name) \ +class struct simple_lock_data_empty name; #define simple_lock_addr(lock) ((simple_lock_t)0) /* @@ -102,7 +104,7 @@ extern void check_simple_locks(void); */ #define simple_lock_init(l) #define simple_lock(l) -#define simple_unlock(l) +#define simple_unlock(l) ((void)(l)) #define simple_lock_try(l) (TRUE) /* always succeeds */ #define simple_lock_taken(l) (1) /* always succeeds */ #define check_simple_locks() diff --git a/kern/sched_prim.c b/kern/sched_prim.c index ec041fc8..8aad1462 100644 --- a/kern/sched_prim.c +++ b/kern/sched_prim.c @@ -226,9 +226,7 @@ void assert_wait( queue_t q; int index; thread_t thread; -#if MACH_SLOCKS - simple_lock_t lock; -#endif /* MACH_SLOCKS */ + decl_simple_lock_data( , *lock); spl_t s; thread = current_thread(); @@ -240,9 +238,7 @@ void assert_wait( if (event != 0) { index = wait_hash(event); q = &wait_queue[index]; -#if MACH_SLOCKS lock = &wait_lock[index]; -#endif /* MACH_SLOCKS */ simple_lock(lock); thread_lock(thread); enqueue_tail(q, &(thread->links)); @@ -284,9 +280,7 @@ void clear_wait( { int index; queue_t q; -#if MACH_SLOCKS - simple_lock_t lock; -#endif /* MACH_SLOCKS */ + decl_simple_lock_data( , *lock); event_t event; spl_t s; @@ -306,9 +300,7 @@ void clear_wait( thread_unlock(thread); index = wait_hash(event); q = &wait_queue[index]; -#if MACH_SLOCKS lock = &wait_lock[index]; -#endif /* MACH_SLOCKS */ simple_lock(lock); /* * If the thread is still waiting on that event, @@ -387,18 +379,14 @@ void thread_wakeup_prim( queue_t q; int index; thread_t thread, next_th; -#if MACH_SLOCKS - simple_lock_t lock; -#endif /* MACH_SLOCKS */ + decl_simple_lock_data( , *lock); spl_t s; int state; index = wait_hash(event); q = &wait_queue[index]; s = splsched(); -#if MACH_SLOCKS lock = &wait_lock[index]; -#endif /* MACH_SLOCKS */ simple_lock(lock); thread = (thread_t) queue_first(q); while (!queue_end(q, (queue_entry_t)thread)) { diff --git a/kern/task.c b/kern/task.c index 8fe3672f..13b3c761 100644 --- a/kern/task.c +++ b/kern/task.c @@ -761,7 +761,7 @@ kern_return_t task_info( event_info = (task_events_info_t) task_info_out; - task_lock(&task); + task_lock(task); event_info->faults = task->faults; event_info->zero_fills = task->zero_fills; event_info->reactivations = task->reactivations; @@ -769,7 +769,7 @@ kern_return_t task_info( event_info->cow_faults = task->cow_faults; event_info->messages_sent = task->messages_sent; event_info->messages_received = task->messages_received; - task_unlock(&task); + task_unlock(task); *task_info_count = TASK_EVENTS_INFO_COUNT; break; -- cgit v1.2.3 From b5dfcde4f7728e87860fcc3ac6b0c7a9abe8c94e Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Tue, 17 Dec 2013 13:15:42 +0100 Subject: xen: add missing includes * xen/console.h: Add missing includes. --- xen/console.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xen/console.h b/xen/console.h index 2b78f295..061ba281 100644 --- a/xen/console.h +++ b/xen/console.h @@ -21,7 +21,9 @@ #include #include +#include #include +#include #define hyp_console_write(str, len) hyp_console_io (CONSOLEIO_write, (len), kvtolin(str)) -- cgit v1.2.3 From b5e56770ae41abccdbc28195cc132ff3f8aa1587 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Tue, 17 Dec 2013 15:58:25 +0100 Subject: kern/sched_prim.h: remove unnecessary __GNUC__ #ifdef Attribute noreturn is used irrespective of __GNUC__. Remove unnecessary #ifdef. * kern/sched_prim.h [__GNUC__]: Remove #ifdef. --- kern/sched_prim.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/kern/sched_prim.h b/kern/sched_prim.h index 07b5bf03..c7ff9771 100644 --- a/kern/sched_prim.h +++ b/kern/sched_prim.h @@ -134,11 +134,8 @@ extern void thread_timeout_setup( extern void thread_bootstrap_return(void); extern void thread_exception_return(void); -#ifdef __GNUC__ extern void __attribute__((__noreturn__)) thread_syscall_return(kern_return_t); -#else -extern void thread_syscall_return(kern_return_t); -#endif + extern thread_t switch_context( thread_t old_thread, continuation_t continuation, -- cgit v1.2.3 From 68bbdd1e18a87afede6cbdffdb8c7078ed3fa835 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Tue, 17 Dec 2013 15:58:26 +0100 Subject: Cleanup of the copyin() and copyout() calls * device/ds_routines.c (device_write_trap) (copyin) (data): Cast to (void *). Argument is an address. (device_write_trap) (copyin) (io_data): Don't cast. (device_writev_trap) (copyin) (iovec, stack_iovec): Likewise. (device_writev_trap) (copyin) (data, p): Cast to (void *). Arguments are addresses. * kern/bootstrap.c (build_args_and_stack) (copyout) (arg_count, string_pos, zero): Don't cast. * kern/ipc_mig.c (syscall_vm_map) (copyin, copyout) (addr, address): Likewise. (syscall_vm_allocate) (copyin, copyout) (addr, address): Likewise. (syscall_task_create) (copyout) (name, child_task): Likewise. (syscall_mach_port_allocate) (copyout) (name, namep): Likewise. * kern/time_stamp.c (copyout) (temp, tsp): Likewise. --- device/ds_routines.c | 10 +++++----- kern/bootstrap.c | 10 +++++----- kern/ipc_mig.c | 12 ++++++------ kern/time_stamp.c | 4 ++-- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/device/ds_routines.c b/device/ds_routines.c index bc22495f..a68dc7ac 100644 --- a/device/ds_routines.c +++ b/device/ds_routines.c @@ -1688,7 +1688,7 @@ device_write_trap (mach_device_t device, dev_mode_t mode, * Copy the data from user space. */ if (data_count > 0) - copyin((char *)data, (char *)ior->io_data, data_count); + copyin((void *)data, ior->io_data, data_count); /* * The ior keeps an extra reference for the device. @@ -1735,8 +1735,8 @@ device_writev_trap (mach_device_t device, dev_mode_t mode, */ if (iocount > 16) return KERN_INVALID_VALUE; /* lame */ - copyin((char *)iovec, - (char *)stack_iovec, + copyin(iovec, + stack_iovec, iocount * sizeof(io_buf_vec_t)); for (data_count = 0, i = 0; i < iocount; i++) data_count += stack_iovec[i].count; @@ -1774,8 +1774,8 @@ device_writev_trap (mach_device_t device, dev_mode_t mode, p = (vm_offset_t) ior->io_data; for (i = 0; i < iocount; i++) { - copyin((char *) stack_iovec[i].data, - (char *) p, + copyin((void *) stack_iovec[i].data, + (void *) p, stack_iovec[i].count); p += stack_iovec[i].count; } diff --git a/kern/bootstrap.c b/kern/bootstrap.c index c0576b74..86e238af 100644 --- a/kern/bootstrap.c +++ b/kern/bootstrap.c @@ -587,7 +587,7 @@ build_args_and_stack(struct exec_info *boot_exec_info, /* * first the argument count */ - (void) copyout((char *)&arg_count, + (void) copyout(&arg_count, arg_pos, sizeof(integer_t)); arg_pos += sizeof(integer_t); @@ -600,7 +600,7 @@ build_args_and_stack(struct exec_info *boot_exec_info, arg_item_len = strlen(arg_ptr) + 1; /* include trailing 0 */ /* set string pointer */ - (void) copyout((char *)&string_pos, + (void) copyout(&string_pos, arg_pos, sizeof (char *)); arg_pos += sizeof(char *); @@ -613,7 +613,7 @@ build_args_and_stack(struct exec_info *boot_exec_info, /* * Null terminator for argv. */ - (void) copyout((char *)&zero, arg_pos, sizeof(char *)); + (void) copyout(&zero, arg_pos, sizeof(char *)); arg_pos += sizeof(char *); /* @@ -624,7 +624,7 @@ build_args_and_stack(struct exec_info *boot_exec_info, arg_item_len = strlen(arg_ptr) + 1; /* include trailing 0 */ /* set string pointer */ - (void) copyout((char *)&string_pos, + (void) copyout(&string_pos, arg_pos, sizeof (char *)); arg_pos += sizeof(char *); @@ -637,7 +637,7 @@ build_args_and_stack(struct exec_info *boot_exec_info, /* * Null terminator for envp. */ - (void) copyout((char *)&zero, arg_pos, sizeof(char *)); + (void) copyout(&zero, arg_pos, sizeof(char *)); } diff --git a/kern/ipc_mig.c b/kern/ipc_mig.c index 3cd0f886..f5e8e14e 100644 --- a/kern/ipc_mig.c +++ b/kern/ipc_mig.c @@ -651,12 +651,12 @@ syscall_vm_map( } else port = (ipc_port_t) memory_object; - copyin((char *)address, (char *)&addr, sizeof(vm_offset_t)); + copyin(address, &addr, sizeof(vm_offset_t)); result = vm_map(map, &addr, size, mask, anywhere, port, offset, copy, cur_protection, max_protection, inheritance); if (result == KERN_SUCCESS) - copyout((char *)&addr, (char *)address, sizeof(vm_offset_t)); + copyout(&addr, address, sizeof(vm_offset_t)); if (IP_VALID(port)) ipc_port_release_send(port); vm_map_deallocate(map); @@ -678,10 +678,10 @@ kern_return_t syscall_vm_allocate(target_map, address, size, anywhere) if (map == VM_MAP_NULL) return MACH_SEND_INTERRUPTED; - copyin((char *)address, (char *)&addr, sizeof(vm_offset_t)); + copyin(address, &addr, sizeof(vm_offset_t)); result = vm_allocate(map, &addr, size, anywhere); if (result == KERN_SUCCESS) - copyout((char *)&addr, (char *)address, sizeof(vm_offset_t)); + copyout(&addr, address, sizeof(vm_offset_t)); vm_map_deallocate(map); return result; @@ -726,7 +726,7 @@ kern_return_t syscall_task_create(parent_task, inherit_memory, child_task) (void) ipc_kmsg_copyout_object(current_space(), (ipc_object_t) port, MACH_MSG_TYPE_PORT_SEND, &name); - copyout((char *)&name, (char *)child_task, + copyout(&name, child_task, sizeof(mach_port_t)); } task_deallocate(t); @@ -814,7 +814,7 @@ syscall_mach_port_allocate(task, right, namep) kr = mach_port_allocate(space, right, &name); if (kr == KERN_SUCCESS) - copyout((char *)&name, (char *)namep, sizeof(mach_port_t)); + copyout(&name, namep, sizeof(mach_port_t)); is_release(space); return kr; diff --git a/kern/time_stamp.c b/kern/time_stamp.c index 2c142746..7f4c0f66 100644 --- a/kern/time_stamp.c +++ b/kern/time_stamp.c @@ -43,8 +43,8 @@ struct tsval *tsp; time_value_t temp; temp = time; - if (copyout((char *)&temp, - (char *)tsp, + if (copyout(&temp, + tsp, sizeof(struct tsval)) != KERN_SUCCESS) return(KERN_INVALID_ADDRESS); return(KERN_SUCCESS); -- cgit v1.2.3 From f4963a52e96230374826137cce44813c94853e6f Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Mon, 16 Dec 2013 23:55:12 +0100 Subject: device: qualify pointers whose dereferenced values are constant with const --- device/chario.c | 10 +++---- device/dev_hdr.h | 10 +++---- device/dev_lookup.c | 10 +++---- device/dev_name.c | 14 +++++----- device/dev_pager.c | 74 ++++++++++++++++++++++++++-------------------------- device/ds_routines.c | 26 +++++++++--------- device/ds_routines.h | 10 +++---- device/if_ether.h | 2 +- device/kmsg.c | 2 +- device/net_io.c | 14 +++++----- device/net_io.h | 8 +++--- device/subrs.c | 6 ++--- 12 files changed, 93 insertions(+), 93 deletions(-) diff --git a/device/chario.c b/device/chario.c index 91bd8e8a..0d9f803e 100644 --- a/device/chario.c +++ b/device/chario.c @@ -526,9 +526,9 @@ void ttyclose( */ boolean_t tty_queue_clean( - queue_t q, - ipc_port_t port, - boolean_t (*routine)(io_req_t) ) + queue_t q, + const ipc_port_t port, + boolean_t (*routine)(io_req_t) ) { io_req_t ior; @@ -552,8 +552,8 @@ tty_queue_clean( */ boolean_t tty_portdeath( - struct tty * tp, - ipc_port_t port) + struct tty * tp, + const ipc_port_t port) { spl_t spl = spltty(); boolean_t result; diff --git a/device/dev_hdr.h b/device/dev_hdr.h index 340a2db1..ff7d2ef5 100644 --- a/device/dev_hdr.h +++ b/device/dev_hdr.h @@ -134,16 +134,16 @@ boolean_t dev_map(boolean_t (*)(), mach_port_t); * device name lookup */ extern boolean_t dev_name_lookup( - char * name, - dev_ops_t *ops, /* out */ - int *unit); /* out */ + char * name, + dev_ops_t *ops, /* out */ + int *unit); /* out */ /* * Change an entry in the indirection list. */ extern void dev_set_indirection( - char *name, + const char *name, dev_ops_t ops, - int unit); + int unit); #endif /* _DEVICE_DEV_HDR_H_ */ diff --git a/device/dev_lookup.c b/device/dev_lookup.c index 255102cc..d371b608 100644 --- a/device/dev_lookup.c +++ b/device/dev_lookup.c @@ -71,7 +71,7 @@ struct kmem_cache dev_hdr_cache; */ void dev_number_enter(device) - mach_device_t device; + const mach_device_t device; { queue_t q; @@ -85,7 +85,7 @@ dev_number_enter(device) */ void dev_number_remove(device) - mach_device_t device; + const mach_device_t device; { queue_t q; @@ -99,7 +99,7 @@ dev_number_remove(device) */ mach_device_t dev_number_lookup(ops, devnum) - dev_ops_t ops; + const dev_ops_t ops; int devnum; { queue_t q; @@ -121,7 +121,7 @@ dev_number_lookup(ops, devnum) */ mach_device_t device_lookup(name) - char * name; + char * name; { dev_ops_t dev_ops; int dev_minor; @@ -306,7 +306,7 @@ dev_port_lookup(port) */ ipc_port_t convert_device_to_port(device) - device_t device; + const device_t device; { if (device == DEVICE_NULL) return IP_NULL; diff --git a/device/dev_name.c b/device/dev_name.c index 930930b4..49d96aa7 100644 --- a/device/dev_name.c +++ b/device/dev_name.c @@ -65,9 +65,9 @@ nomap(void) */ boolean_t name_equal(src, len, target) - char *src; - int len; - char *target; + const char *src; + int len; + const char *target; { while (--len >= 0) if (*src++ != *target++) @@ -191,7 +191,7 @@ boolean_t dev_name_lookup(name, ops, unit) */ void dev_set_indirection(name, ops, unit) - char *name; + const char *name; dev_ops_t ops; int unit; { @@ -207,9 +207,9 @@ dev_set_indirection(name, ops, unit) } boolean_t dev_change_indirect(iname, dname, unit) - char *iname; - char *dname; - int unit; + const char *iname; + const char *dname; + int unit; { struct dev_ops *dp; struct dev_indirect *di; diff --git a/device/dev_pager.c b/device/dev_pager.c index 7c3e088c..3fe47c72 100644 --- a/device/dev_pager.c +++ b/device/dev_pager.c @@ -180,8 +180,8 @@ void dev_pager_hash_init(void) } void dev_pager_hash_insert( - ipc_port_t name_port, - dev_pager_t rec) + const ipc_port_t name_port, + const dev_pager_t rec) { dev_pager_entry_t new_entry; @@ -195,7 +195,7 @@ void dev_pager_hash_insert( simple_unlock(&dev_pager_hash_lock); } -void dev_pager_hash_delete(ipc_port_t name_port) +void dev_pager_hash_delete(const ipc_port_t name_port) { queue_t bucket; dev_pager_entry_t entry; @@ -216,7 +216,7 @@ void dev_pager_hash_delete(ipc_port_t name_port) kmem_cache_free(&dev_pager_hash_cache, (vm_offset_t)entry); } -dev_pager_t dev_pager_hash_lookup(ipc_port_t name_port) +dev_pager_t dev_pager_hash_lookup(const ipc_port_t name_port) { queue_t bucket; dev_pager_entry_t entry; @@ -240,11 +240,11 @@ dev_pager_t dev_pager_hash_lookup(ipc_port_t name_port) } kern_return_t device_pager_setup( - mach_device_t device, - int prot, - vm_offset_t offset, - vm_size_t size, - mach_port_t *pager) + const mach_device_t device, + int prot, + vm_offset_t offset, + vm_size_t size, + mach_port_t *pager) { dev_pager_t d; @@ -318,11 +318,11 @@ void device_pager_release(memory_object_t object) boolean_t device_pager_debug = FALSE; kern_return_t device_pager_data_request( - ipc_port_t pager, - ipc_port_t pager_request, - vm_offset_t offset, - vm_size_t length, - vm_prot_t protection_required) + const ipc_port_t pager, + const ipc_port_t pager_request, + vm_offset_t offset, + vm_size_t length, + vm_prot_t protection_required) { dev_pager_t ds; @@ -457,8 +457,8 @@ boolean_t device_pager_data_request_done(io_req_t ior) } kern_return_t device_pager_data_write( - ipc_port_t pager, - ipc_port_t pager_request, + const ipc_port_t pager, + const ipc_port_t pager_request, vm_offset_t offset, pointer_t addr, vm_size_t data_count) @@ -523,19 +523,19 @@ boolean_t device_pager_data_write_done(ior) } kern_return_t device_pager_copy( - ipc_port_t pager, - ipc_port_t pager_request, + const ipc_port_t pager, + const ipc_port_t pager_request, vm_offset_t offset, vm_size_t length, - ipc_port_t new_pager) + const ipc_port_t new_pager) { panic("(device_pager)copy: called"); } kern_return_t device_pager_supply_completed( - ipc_port_t pager, - ipc_port_t pager_request, + const ipc_port_t pager, + const ipc_port_t pager_request, vm_offset_t offset, vm_size_t length, kern_return_t result, @@ -546,8 +546,8 @@ device_pager_supply_completed( kern_return_t device_pager_data_return( - ipc_port_t pager, - ipc_port_t pager_request, + const ipc_port_t pager, + const ipc_port_t pager_request, vm_offset_t offset, pointer_t addr, vm_size_t data_cnt, @@ -559,7 +559,7 @@ device_pager_data_return( kern_return_t device_pager_change_completed( - ipc_port_t pager, + const ipc_port_t pager, boolean_t may_cache, memory_object_copy_strategy_t copy_strategy) { @@ -584,10 +584,10 @@ vm_offset_t device_map_page( } kern_return_t device_pager_init_pager( - ipc_port_t pager, - ipc_port_t pager_request, - ipc_port_t pager_name, - vm_size_t pager_page_size) + const ipc_port_t pager, + const ipc_port_t pager_request, + const ipc_port_t pager_name, + vm_size_t pager_page_size) { dev_pager_t ds; @@ -635,9 +635,9 @@ kern_return_t device_pager_init_pager( } kern_return_t device_pager_terminate( - ipc_port_t pager, - ipc_port_t pager_request, - ipc_port_t pager_name) + const ipc_port_t pager, + const ipc_port_t pager_request, + const ipc_port_t pager_name) { dev_pager_t ds; @@ -677,8 +677,8 @@ kern_return_t device_pager_terminate( } kern_return_t device_pager_data_unlock( - ipc_port_t memory_object, - ipc_port_t memory_control_port, + const ipc_port_t memory_object, + const ipc_port_t memory_control_port, vm_offset_t offset, vm_size_t length, vm_prot_t desired_access) @@ -688,10 +688,10 @@ kern_return_t device_pager_data_unlock( } kern_return_t device_pager_lock_completed( - ipc_port_t memory_object, - ipc_port_t pager_request_port, - vm_offset_t offset, - vm_size_t length) + const ipc_port_t memory_object, + const ipc_port_t pager_request_port, + vm_offset_t offset, + vm_size_t length) { panic("(device_pager)lock_completed: called"); return (KERN_FAILURE); diff --git a/device/ds_routines.c b/device/ds_routines.c index a68dc7ac..146b7eb6 100644 --- a/device/ds_routines.c +++ b/device/ds_routines.c @@ -418,7 +418,7 @@ mach_convert_device_to_port (mach_device_t device) static io_return_t device_open(reply_port, reply_port_type, mode, name, device_p) - ipc_port_t reply_port; + const ipc_port_t reply_port; mach_msg_type_name_t reply_port_type; dev_mode_t mode; char * name; @@ -538,7 +538,7 @@ device_open(reply_port, reply_port_type, mode, name, device_p) boolean_t ds_open_done(ior) - io_req_t ior; + const io_req_t ior; { kern_return_t result; mach_device_t device; @@ -663,11 +663,11 @@ static io_return_t device_write(device, reply_port, reply_port_type, mode, recnum, data, data_count, bytes_written) mach_device_t device; - ipc_port_t reply_port; + const ipc_port_t reply_port; mach_msg_type_name_t reply_port_type; dev_mode_t mode; recnum_t recnum; - io_buf_ptr_t data; + const io_buf_ptr_t data; unsigned int data_count; int *bytes_written; /* out */ { @@ -754,7 +754,7 @@ static io_return_t device_write_inband(device, reply_port, reply_port_type, mode, recnum, data, data_count, bytes_written) mach_device_t device; - ipc_port_t reply_port; + const ipc_port_t reply_port; mach_msg_type_name_t reply_port_type; dev_mode_t mode; recnum_t recnum; @@ -1021,7 +1021,7 @@ device_write_dealloc(ior) */ boolean_t ds_write_done(ior) - io_req_t ior; + const io_req_t ior; { /* * device_write_dealloc discards the data that has been @@ -1069,7 +1069,7 @@ static io_return_t device_read(device, reply_port, reply_port_type, mode, recnum, bytes_wanted, data, data_count) mach_device_t device; - ipc_port_t reply_port; + const ipc_port_t reply_port; mach_msg_type_name_t reply_port_type; dev_mode_t mode; recnum_t recnum; @@ -1146,7 +1146,7 @@ static io_return_t device_read_inband(device, reply_port, reply_port_type, mode, recnum, bytes_wanted, data, data_count) mach_device_t device; - ipc_port_t reply_port; + const ipc_port_t reply_port; mach_msg_type_name_t reply_port_type; dev_mode_t mode; recnum_t recnum; @@ -1251,7 +1251,7 @@ kern_return_t device_read_alloc(ior, size) } boolean_t ds_read_done(ior) - io_req_t ior; + const io_req_t ior; { vm_offset_t start_data, end_data; vm_offset_t start_sent, end_sent; @@ -1384,7 +1384,7 @@ mach_device_get_status(device, flavor, status, status_count) static io_return_t device_set_filter(device, receive_port, priority, filter, filter_count) mach_device_t device; - ipc_port_t receive_port; + const ipc_port_t receive_port; int priority; filter_t filter[]; /* pointer to IN array */ unsigned int filter_count; @@ -1433,7 +1433,7 @@ device_map(device, protection, offset, size, pager, unmap) */ static void ds_no_senders(notification) - mach_no_senders_notification_t *notification; + const mach_no_senders_notification_t *notification; { printf("ds_no_senders called! device_port=0x%lx count=%d\n", notification->not_header.msgh_remote_port, @@ -1617,7 +1617,7 @@ mach_device_trap_init(void) * Could call a device-specific routine. */ io_req_t -ds_trap_req_alloc(mach_device_t device, vm_size_t data_size) +ds_trap_req_alloc(const mach_device_t device, vm_size_t data_size) { return (io_req_t) kmem_cache_alloc(&io_trap_cache); } @@ -1626,7 +1626,7 @@ ds_trap_req_alloc(mach_device_t device, vm_size_t data_size) * Called by iodone to release ior. */ boolean_t -ds_trap_write_done(io_req_t ior) +ds_trap_write_done(const io_req_t ior) { mach_device_t dev; diff --git a/device/ds_routines.h b/device/ds_routines.h index 497b6ac1..a68c6c63 100644 --- a/device/ds_routines.h +++ b/device/ds_routines.h @@ -58,11 +58,11 @@ boolean_t ds_write_done(io_req_t); void iowait (io_req_t ior); kern_return_t device_pager_setup( - mach_device_t device, - int prot, - vm_offset_t offset, - vm_size_t size, - mach_port_t *pager); + const mach_device_t device, + int prot, + vm_offset_t offset, + vm_size_t size, + mach_port_t *pager); extern void mach_device_init(void); extern void dev_lookup_init(void); diff --git a/device/if_ether.h b/device/if_ether.h index e368fbf6..91d4d9a6 100644 --- a/device/if_ether.h +++ b/device/if_ether.h @@ -46,7 +46,7 @@ struct ether_header { }; #ifdef KERNEL -extern char * ether_sprintf(u_char *); +extern char * ether_sprintf(const u_char *); #endif /* KERNEL */ #endif /*_DEVICE_IF_ETHER_H_*/ diff --git a/device/kmsg.c b/device/kmsg.c index 7034bfc2..40956ddd 100644 --- a/device/kmsg.c +++ b/device/kmsg.c @@ -61,7 +61,7 @@ kmsginit (void) /* Kernel Message Open Handler */ io_return_t -kmsgopen (dev_t dev, int flag, io_req_t ior) +kmsgopen (dev_t dev, int flag, const io_req_t ior) { simple_lock (&kmsg_lock); if (kmsg_in_use) diff --git a/device/net_io.c b/device/net_io.c index 4c03f8ce..bce27b32 100644 --- a/device/net_io.c +++ b/device/net_io.c @@ -196,7 +196,7 @@ net_kmsg_get(void) } void -net_kmsg_put(ipc_kmsg_t kmsg) +net_kmsg_put(const ipc_kmsg_t kmsg) { spl_t s; @@ -373,7 +373,7 @@ decl_simple_lock_data(,net_hash_header_lock) */ boolean_t ethernet_priority(kmsg) - ipc_kmsg_t kmsg; + const ipc_kmsg_t kmsg; { unsigned char *addr = (unsigned char *) net_kmsg(kmsg)->header; @@ -694,7 +694,7 @@ int net_filter_queue_reorder = 0; /* non-zero to enable reordering */ */ void net_filter(kmsg, send_list) - ipc_kmsg_t kmsg; + const ipc_kmsg_t kmsg; ipc_kmsg_queue_t send_list; { struct ifnet *ifp; @@ -876,9 +876,9 @@ net_filter(kmsg, send_list) boolean_t net_do_filter(infp, data, data_count, header) net_rcv_port_t infp; - char * data; + const char * data; unsigned int data_count; - char * header; + const char * header; { int stack[NET_FILTER_STACK_DEPTH+1]; int *sp; @@ -1986,7 +1986,7 @@ bpf_eq (f1, f2, bytes) unsigned int bpf_hash (n, keys) int n; - unsigned int *keys; + const unsigned int *keys; { unsigned int hval = 0; @@ -2001,7 +2001,7 @@ int bpf_match (hash, n_keys, keys, hash_headpp, entpp) net_hash_header_t hash; int n_keys; - unsigned int *keys; + const unsigned int *keys; net_hash_entry_t **hash_headpp, *entpp; { net_hash_entry_t head, entp; diff --git a/device/net_io.h b/device/net_io.h index 0cdd7126..0ffdc92c 100644 --- a/device/net_io.h +++ b/device/net_io.h @@ -100,14 +100,14 @@ extern unsigned short int ntohs(unsigned short int); extern unsigned int htonl(unsigned int); extern unsigned short int htons(unsigned short int); -unsigned int bpf_hash(int n, unsigned int *keys); +unsigned int bpf_hash(int n, const unsigned int *keys); extern boolean_t net_do_filter( net_rcv_port_t infp, - char * data, + const char * data, unsigned int data_count, - char * header); /* CSPF */ + const char * header); /* CSPF */ extern int bpf_do_filter( @@ -145,7 +145,7 @@ int net_add_q_info(ipc_port_t rcv_port); int bpf_match ( net_hash_header_t hash, int n_keys, - unsigned int *keys, + const unsigned int *keys, net_hash_entry_t **hash_headpp, net_hash_entry_t *entpp); diff --git a/device/subrs.c b/device/subrs.c index 0a7d690c..7e6e30d7 100644 --- a/device/subrs.c +++ b/device/subrs.c @@ -41,8 +41,8 @@ * Print out disk name and block number for hard disk errors. */ void harderr(ior, cp) - io_req_t ior; - char * cp; + const io_req_t ior; + const char * cp; { printf("%s%d%c: hard error sn%d ", cp, @@ -56,7 +56,7 @@ void harderr(ior, cp) */ char * ether_sprintf(ap) - u_char *ap; + const u_char *ap; { int i; static char etherbuf[18]; -- cgit v1.2.3 From 1a81c796689a01b00bc5aea0b3bd3fd672530798 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Mon, 16 Dec 2013 23:55:13 +0100 Subject: i386: qualify pointers whose dereferenced values are constant with const --- i386/i386/ast_check.c | 4 ++-- i386/i386/db_disasm.c | 10 +++++----- i386/i386/db_interface.c | 14 +++++++------- i386/i386/db_interface.h | 2 +- i386/i386/db_trace.c | 14 +++++++------- i386/i386/debug.h | 2 +- i386/i386/debug_i386.c | 2 +- i386/i386/fpu.c | 4 ++-- i386/i386/hardclock.c | 8 ++++---- i386/i386/io_perm.c | 2 +- i386/i386/loose_ends.c | 4 ++-- i386/i386/machine_task.c | 2 +- i386/i386/mp_desc.c | 2 +- i386/i386/pcb.c | 4 ++-- i386/i386/pcb.h | 2 +- i386/i386/trap.c | 2 +- i386/i386/user_ldt.c | 4 ++-- i386/i386at/autoconf.c | 4 ++-- i386/i386at/kd_event.c | 2 +- i386/i386at/kd_queue.c | 4 ++-- i386/i386at/kd_queue.h | 4 ++-- 21 files changed, 48 insertions(+), 48 deletions(-) diff --git a/i386/i386/ast_check.c b/i386/i386/ast_check.c index 61c68da2..f3e1c350 100644 --- a/i386/i386/ast_check.c +++ b/i386/i386/ast_check.c @@ -38,7 +38,7 @@ * Initialize for remote invocation of ast_check. */ void init_ast_check(processor) - processor_t processor; + const processor_t processor; { } @@ -46,7 +46,7 @@ void init_ast_check(processor) * Cause remote invocation of ast_check. Caller is at splsched(). */ void cause_ast_check(processor) - processor_t processor; + const processor_t processor; { } diff --git a/i386/i386/db_disasm.c b/i386/i386/db_disasm.c index e15293b0..4afbcf3e 100644 --- a/i386/i386/db_disasm.c +++ b/i386/i386/db_disasm.c @@ -950,10 +950,10 @@ db_read_address( void db_print_address( - char * seg, - int size, - struct i_addr *addrp, - task_t task) + const char * seg, + int size, + const struct i_addr *addrp, + task_t task) { if (addrp->is_reg) { db_printf("%s", db_reg[size][addrp->disp]); @@ -986,7 +986,7 @@ db_disasm_esc( int inst, int short_addr, int size, - char * seg, + const char * seg, task_t task) { int regmodrm; diff --git a/i386/i386/db_interface.c b/i386/i386/db_interface.c index f07c12c7..ca58ff34 100644 --- a/i386/i386/db_interface.c +++ b/i386/i386/db_interface.c @@ -172,8 +172,8 @@ void db_dr ( boolean_t db_set_hw_watchpoint( - db_watchpoint_t watch, - unsigned num) + const db_watchpoint_t watch, + unsigned num) { vm_size_t size = watch->hiaddr - watch->loaddr; db_addr_t addr = watch->loaddr; @@ -410,7 +410,7 @@ boolean_t db_no_vm_fault = TRUE; int db_user_to_kernel_address( - task_t task, + const task_t task, vm_offset_t addr, vm_offset_t *kaddr, int flag) @@ -617,7 +617,7 @@ boolean_t db_phys_eq( task_t task1, vm_offset_t addr1, - task_t task2, + const task_t task2, vm_offset_t addr2) { vm_offset_t kern_addr1, kern_addr2; @@ -645,7 +645,7 @@ db_phys_eq( #ifndef GNU static boolean_t db_search_null( - task_t task, + const task_t task, vm_offset_t *svaddr, vm_offset_t evaddr, vm_offset_t *skaddr, @@ -678,7 +678,7 @@ db_search_null( #ifdef GNU static boolean_t looks_like_command( - task_t task, + const task_t task, char* kaddr) { char *c; @@ -722,7 +722,7 @@ looks_like_command( void db_task_name( - task_t task) + const task_t task) { char *p; int n; diff --git a/i386/i386/db_interface.h b/i386/i386/db_interface.h index d41a97df..97ff5c7b 100644 --- a/i386/i386/db_interface.h +++ b/i386/i386/db_interface.h @@ -95,7 +95,7 @@ db_stack_trace_cmd( db_expr_t addr, boolean_t have_addr, db_expr_t count, - char *modif); + const char *modif); extern void db_reset_cpu(void); diff --git a/i386/i386/db_trace.c b/i386/i386/db_trace.c index d0c434e1..0f0bbdcc 100644 --- a/i386/i386/db_trace.c +++ b/i386/i386/db_trace.c @@ -107,8 +107,8 @@ struct i386_kregs { long * db_lookup_i386_kreg( - char *name, - long *kregp) + const char *name, + const long *kregp) { struct i386_kregs *kp; @@ -259,7 +259,7 @@ db_nextframe( struct i386_frame **fp, /* in/out */ db_addr_t *ip, /* out */ long frame_type, /* in */ - thread_t thread) /* in */ + const thread_t thread) /* in */ { struct i386_saved_state *saved_regs; struct interrupt_frame *ifp; @@ -321,7 +321,7 @@ db_stack_trace_cmd( db_expr_t addr, boolean_t have_addr, db_expr_t count, - char *modif) + const char *modif) { boolean_t trace_thread = FALSE; struct i386_frame *frame; @@ -330,7 +330,7 @@ db_stack_trace_cmd( thread_t th; { - char *cp = modif; + const char *cp = modif; char c; while ((c = *cp++) != 0) { @@ -399,7 +399,7 @@ db_stack_trace_cmd( void db_i386_stack_trace( - thread_t th, + const thread_t th, struct i386_frame *frame, db_addr_t callpc, db_expr_t count, @@ -633,7 +633,7 @@ void db_trace_cproc( } void db_all_cprocs( - task_t task, + const task_t task, db_expr_t cproc_list) { jmp_buf_t db_jmpbuf; diff --git a/i386/i386/debug.h b/i386/i386/debug.h index f87b95bb..e94649bb 100644 --- a/i386/i386/debug.h +++ b/i386/i386/debug.h @@ -26,7 +26,7 @@ /* Dump a saved state. Probably a good idea to have this around even when DEBUG isn't turned on. */ -void dump_ss(struct i386_saved_state *st); +void dump_ss(const struct i386_saved_state *st); #ifdef DEBUG diff --git a/i386/i386/debug_i386.c b/i386/i386/debug_i386.c index 01f26a06..76578081 100644 --- a/i386/i386/debug_i386.c +++ b/i386/i386/debug_i386.c @@ -27,7 +27,7 @@ #include "trap.h" #include "debug.h" -void dump_ss(struct i386_saved_state *st) +void dump_ss(const struct i386_saved_state *st) { printf("Dump of i386_saved_state %p:\n", st); printf("EAX %08lx EBX %08lx ECX %08lx EDX %08lx\n", diff --git a/i386/i386/fpu.c b/i386/i386/fpu.c index b1aed912..fd5f4b6d 100644 --- a/i386/i386/fpu.c +++ b/i386/i386/fpu.c @@ -292,7 +292,7 @@ twd_fxsr_to_i387 (struct i386_xfp_save *fxsave) */ kern_return_t fpu_set_state(thread, state) - thread_t thread; + const thread_t thread; struct i386_float_state *state; { pcb_t pcb = thread->pcb; @@ -403,7 +403,7 @@ ASSERT_IPL(SPL0); */ kern_return_t fpu_get_state(thread, state) - thread_t thread; + const thread_t thread; struct i386_float_state *state; { pcb_t pcb = thread->pcb; diff --git a/i386/i386/hardclock.c b/i386/i386/hardclock.c index f119c6bb..49ea82cd 100644 --- a/i386/i386/hardclock.c +++ b/i386/i386/hardclock.c @@ -47,10 +47,10 @@ extern char return_to_iret[]; void hardclock(iunit, old_ipl, irq, ret_addr, regs) - int iunit; /* 'unit' number */ - int old_ipl; /* old interrupt level */ - int irq; /* irq number */ - char * ret_addr; /* return address in interrupt handler */ + int iunit; /* 'unit' number */ + int old_ipl; /* old interrupt level */ + int irq; /* irq number */ + const char * ret_addr; /* return address in interrupt handler */ struct i386_interrupt_state *regs; /* saved registers */ { diff --git a/i386/i386/io_perm.c b/i386/i386/io_perm.c index 4704275e..6a6e6600 100644 --- a/i386/i386/io_perm.c +++ b/i386/i386/io_perm.c @@ -175,7 +175,7 @@ io_bitmap_clear (unsigned char *iopb, io_port_t from, io_port_t to) The function is exported. */ kern_return_t -i386_io_perm_create (ipc_port_t master_port, io_port_t from, io_port_t to, +i386_io_perm_create (const ipc_port_t master_port, io_port_t from, io_port_t to, io_perm_t *new) { if (master_port != master_device_port) diff --git a/i386/i386/loose_ends.c b/i386/i386/loose_ends.c index 30e7763f..bb2e5b69 100644 --- a/i386/i386/loose_ends.c +++ b/i386/i386/loose_ends.c @@ -54,8 +54,8 @@ delay(n) * levels of return pc information. */ void machine_callstack( - unsigned long *buf, - int callstack_max) + const unsigned long *buf, + int callstack_max) { } diff --git a/i386/i386/machine_task.c b/i386/i386/machine_task.c index 62b22e3a..490b1022 100644 --- a/i386/i386/machine_task.c +++ b/i386/i386/machine_task.c @@ -55,7 +55,7 @@ machine_task_init (task_t task) /* Destroy the machine specific part of task TASK and release all associated resources. */ void -machine_task_terminate (task_t task) +machine_task_terminate (const task_t task) { if (task->machine.iopb) kmem_cache_free (&machine_task_iopb_cache, diff --git a/i386/i386/mp_desc.c b/i386/i386/mp_desc.c index 5ede8f15..4ff5e613 100644 --- a/i386/i386/mp_desc.c +++ b/i386/i386/mp_desc.c @@ -238,7 +238,7 @@ simple_lock_pause(void) } kern_return_t -cpu_control(int cpu, int *info, unsigned int count) +cpu_control(int cpu, const int *info, unsigned int count) { printf("cpu_control(%d, %p, %d) not implemented\n", cpu, info, count); diff --git a/i386/i386/pcb.c b/i386/i386/pcb.c index 82b2faf1..a0578d1a 100644 --- a/i386/i386/pcb.c +++ b/i386/i386/pcb.c @@ -429,7 +429,7 @@ void pcb_terminate(thread) */ void pcb_collect(thread) - thread_t thread; + const thread_t thread; { } @@ -827,7 +827,7 @@ vm_offset_t set_user_regs(stack_base, stack_size, exec_info, arg_size) vm_offset_t stack_base; /* low address */ vm_offset_t stack_size; - struct exec_info *exec_info; + const struct exec_info *exec_info; vm_size_t arg_size; { vm_offset_t arg_addr; diff --git a/i386/i386/pcb.h b/i386/i386/pcb.h index b2e5f07b..708f30d8 100644 --- a/i386/i386/pcb.h +++ b/i386/i386/pcb.h @@ -58,7 +58,7 @@ extern vm_offset_t user_stack_low (vm_size_t stack_size); extern vm_offset_t set_user_regs ( vm_offset_t stack_base, vm_offset_t stack_size, - struct exec_info *exec_info, + const struct exec_info *exec_info, vm_size_t arg_size); extern void load_context (thread_t new); diff --git a/i386/i386/trap.c b/i386/i386/trap.c index 97969404..391b6001 100644 --- a/i386/i386/trap.c +++ b/i386/i386/trap.c @@ -626,7 +626,7 @@ i386_exception(exc, code, subcode) */ unsigned interrupted_pc(t) - thread_t t; + const thread_t t; { struct i386_saved_state *iss; diff --git a/i386/i386/user_ldt.c b/i386/i386/user_ldt.c index 07be0a0d..a83bc122 100644 --- a/i386/i386/user_ldt.c +++ b/i386/i386/user_ldt.c @@ -255,7 +255,7 @@ i386_set_ldt(thread, first_selector, desc_list, count, desc_list_inline) kern_return_t i386_get_ldt(thread, first_selector, selector_count, desc_list, count) - thread_t thread; + const thread_t thread; int first_selector; int selector_count; /* number wanted */ struct real_descriptor **desc_list; /* in/out */ @@ -431,7 +431,7 @@ i386_set_gdt (thread_t thread, int *selector, struct real_descriptor desc) } kern_return_t -i386_get_gdt (thread_t thread, int selector, struct real_descriptor *desc) +i386_get_gdt (const thread_t thread, int selector, struct real_descriptor *desc) { if (thread == THREAD_NULL) return KERN_INVALID_ARGUMENT; diff --git a/i386/i386at/autoconf.c b/i386/i386at/autoconf.c index 31bb73cd..908c3ec0 100644 --- a/i386/i386at/autoconf.c +++ b/i386/i386at/autoconf.c @@ -122,7 +122,7 @@ void probeio(void) } void take_dev_irq( - struct bus_device *dev) + const struct bus_device *dev) { int pic = (int)dev->sysdep1; @@ -144,7 +144,7 @@ void take_dev_irq( } void take_ctlr_irq( - struct bus_ctlr *ctlr) + const struct bus_ctlr *ctlr) { int pic = ctlr->sysdep1; if (intpri[pic] == 0) { diff --git a/i386/i386at/kd_event.c b/i386/i386at/kd_event.c index ac87b205..30a7f77d 100644 --- a/i386/i386at/kd_event.c +++ b/i386/i386at/kd_event.c @@ -311,7 +311,7 @@ int X_kdb_enter_len = 0, X_kdb_exit_len = 0; void kdb_in_out(p) -u_int *p; +const u_int *p; { int t = p[0]; diff --git a/i386/i386at/kd_queue.c b/i386/i386at/kd_queue.c index 2b83044a..2086eb11 100644 --- a/i386/i386at/kd_queue.c +++ b/i386/i386at/kd_queue.c @@ -72,14 +72,14 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. boolean_t kdq_empty(q) - kd_event_queue *q; + const kd_event_queue *q; { return(q->firstfree == q->firstout); } boolean_t kdq_full(q) - kd_event_queue *q; + const kd_event_queue *q; { return(q_next(q->firstfree) == q->firstout); } diff --git a/i386/i386at/kd_queue.h b/i386/i386at/kd_queue.h index bd3fc7bc..702efe8a 100644 --- a/i386/i386at/kd_queue.h +++ b/i386/i386at/kd_queue.h @@ -79,8 +79,8 @@ typedef struct { extern void kdq_put(kd_event_queue *, kd_event *); extern void kdq_reset(kd_event_queue *); -extern boolean_t kdq_empty(kd_event_queue *); -extern boolean_t kdq_full(kd_event_queue *); +extern boolean_t kdq_empty(const kd_event_queue *); +extern boolean_t kdq_full(const kd_event_queue *); extern kd_event *kdq_get(kd_event_queue *); #endif /* _KD_QUEUE_H_ */ -- cgit v1.2.3 From ece37d66ae394a0d783f3cba8a71d7b61735b0aa Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Mon, 16 Dec 2013 23:55:14 +0100 Subject: ipc: qualify pointers whose dereferenced values are constant with const --- ipc/ipc_entry.c | 2 +- ipc/ipc_mqueue.c | 6 +++--- ipc/ipc_object.c | 2 +- ipc/ipc_port.c | 8 ++++---- ipc/ipc_print.h | 6 +++--- ipc/ipc_pset.c | 2 +- ipc/mach_rpc.c | 2 +- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/ipc/ipc_entry.c b/ipc/ipc_entry.c index 6cb1cfb6..f1d763c3 100644 --- a/ipc/ipc_entry.c +++ b/ipc/ipc_entry.c @@ -841,7 +841,7 @@ ipc_entry_grow_table(space) ipc_entry_t db_ipc_object_by_name( - task_t task, + const task_t task, mach_port_t name) { ipc_space_t space = task->itk_space; diff --git a/ipc/ipc_mqueue.c b/ipc/ipc_mqueue.c index 80a34d3a..72eca76c 100644 --- a/ipc/ipc_mqueue.c +++ b/ipc/ipc_mqueue.c @@ -79,9 +79,9 @@ ipc_mqueue_init( void ipc_mqueue_move( - ipc_mqueue_t dest, - ipc_mqueue_t source, - ipc_port_t port) + ipc_mqueue_t dest, + ipc_mqueue_t source, + const ipc_port_t port) { ipc_kmsg_queue_t oldq, newq; ipc_thread_queue_t blockedq; diff --git a/ipc/ipc_object.c b/ipc/ipc_object.c index b8cae8f5..982bd4e1 100644 --- a/ipc/ipc_object.c +++ b/ipc/ipc_object.c @@ -1007,7 +1007,7 @@ char *ikot_print_array[IKOT_MAX_TYPE] = { void ipc_object_print( - ipc_object_t object) + const ipc_object_t object) { int kotype; diff --git a/ipc/ipc_port.c b/ipc/ipc_port.c index 99a6ad46..d4ade8e1 100644 --- a/ipc/ipc_port.c +++ b/ipc/ipc_port.c @@ -275,9 +275,9 @@ ipc_port_dncancel( void ipc_port_pdrequest( - ipc_port_t port, - ipc_port_t notify, - ipc_port_t *previousp) + ipc_port_t port, + const ipc_port_t notify, + ipc_port_t *previousp) { ipc_port_t previous; @@ -1212,7 +1212,7 @@ ipc_port_dealloc_special( void ipc_port_print(port) - ipc_port_t port; + const ipc_port_t port; { printf("port 0x%x\n", port); diff --git a/ipc/ipc_print.h b/ipc/ipc_print.h index 0a3f6459..5e8e4f34 100644 --- a/ipc/ipc_print.h +++ b/ipc/ipc_print.h @@ -26,11 +26,11 @@ #include #include -extern void ipc_port_print(ipc_port_t); +extern void ipc_port_print(const ipc_port_t); -extern void ipc_pset_print(ipc_pset_t); +extern void ipc_pset_print(const ipc_pset_t); -extern void ipc_kmsg_print(ipc_kmsg_t); +extern void ipc_kmsg_print(const ipc_kmsg_t); extern void ipc_msg_print(mach_msg_header_t*); diff --git a/ipc/ipc_pset.c b/ipc/ipc_pset.c index 29f781e2..884e8972 100644 --- a/ipc/ipc_pset.c +++ b/ipc/ipc_pset.c @@ -334,7 +334,7 @@ ipc_pset_destroy( void ipc_pset_print( - ipc_pset_t pset) + const ipc_pset_t pset) { printf("pset 0x%x\n", pset); diff --git a/ipc/mach_rpc.c b/ipc/mach_rpc.c index 643d0fbf..e056a7fd 100644 --- a/ipc/mach_rpc.c +++ b/ipc/mach_rpc.c @@ -141,7 +141,7 @@ mach_port_rpc_copy(portp, sact, dact) } kern_return_t -mach_port_rpc_sig(ipc_space_t space, char *name, char *buffer, unsigned int buflen) +mach_port_rpc_sig(const ipc_space_t space, const char *name, const char *buffer, unsigned int buflen) { return KERN_FAILURE; } -- cgit v1.2.3 From 827c01fadb98e77f692d39d0fb34a1944e43c99b Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Mon, 16 Dec 2013 23:55:15 +0100 Subject: kern: qualify pointers whose dereferenced values are constant with const --- kern/assert.h | 2 +- kern/boot_script.c | 4 ++-- kern/debug.c | 6 +++--- kern/debug.h | 4 ++-- kern/eventcount.c | 2 +- kern/host.c | 12 ++++++------ kern/ipc_host.c | 2 +- kern/ipc_mig.c | 5 +++-- kern/ipc_mig.h | 2 +- kern/ipc_tt.c | 6 +++--- kern/mach_clock.c | 16 ++++++++-------- kern/mach_clock.h | 2 +- kern/machine.c | 4 ++-- kern/pc_sample.c | 34 +++++++++++++++++----------------- kern/sched_prim.c | 6 +++--- kern/syscall_emulation.c | 2 +- 16 files changed, 55 insertions(+), 54 deletions(-) diff --git a/kern/assert.h b/kern/assert.h index d2bb56e1..b074fbb6 100644 --- a/kern/assert.h +++ b/kern/assert.h @@ -36,7 +36,7 @@ #endif #if MACH_ASSERT -extern void Assert(char *exp, char *filename, int line) __attribute__ ((noreturn)); +extern void Assert(const char *exp, const char *filename, int line) __attribute__ ((noreturn)); #define assert(ex) \ MACRO_BEGIN \ diff --git a/kern/boot_script.c b/kern/boot_script.c index a6196e05..b245d1d8 100644 --- a/kern/boot_script.c +++ b/kern/boot_script.c @@ -76,14 +76,14 @@ create_task (struct cmd *cmd, long *val) /* Resume a task. */ static int -resume_task (struct cmd *cmd, long *val) +resume_task (struct cmd *cmd, const long *val) { return boot_script_task_resume (cmd); } /* Resume a task when the user hits return. */ static int -prompt_resume_task (struct cmd *cmd, long *val) +prompt_resume_task (struct cmd *cmd, const long *val) { return boot_script_prompt_task_resume (cmd); } diff --git a/kern/debug.c b/kern/debug.c index add2accd..fd392d21 100644 --- a/kern/debug.c +++ b/kern/debug.c @@ -51,7 +51,7 @@ do_cnputc(char c, vm_offset_t offset) } void -Assert(char *exp, char *file, int line) +Assert(const char *exp, const char *file, int line) { #if NCPUS > 1 simple_lock(&Assert_print_lock); @@ -67,7 +67,7 @@ Assert(char *exp, char *file, int line) } void SoftDebugger(message) - char * message; + const char *message; { printf("Debugger invoked: %s\n", message); @@ -99,7 +99,7 @@ void SoftDebugger(message) } void Debugger(message) - char * message; + const char *message; { #if !MACH_KDB panic("Debugger invoked, but there isn't one!"); diff --git a/kern/debug.h b/kern/debug.h index e429bdd1..6c8977b8 100644 --- a/kern/debug.h +++ b/kern/debug.h @@ -62,7 +62,7 @@ extern void log (int level, const char *fmt, ...); extern void panic_init(void); extern void panic (const char *s, ...) __attribute__ ((noreturn)); -extern void SoftDebugger (char *message); -extern void Debugger (char *message) __attribute__ ((noreturn)); +extern void SoftDebugger (const char *message); +extern void Debugger (const char *message) __attribute__ ((noreturn)); #endif /* _mach_debug__debug_ */ diff --git a/kern/eventcount.c b/kern/eventcount.c index aa3f1e36..1bc9968d 100644 --- a/kern/eventcount.c +++ b/kern/eventcount.c @@ -98,7 +98,7 @@ evc_destroy(evc_t ev) * Thread termination. * HORRIBLE. This stuff needs to be fixed. */ -void evc_notify_abort(thread_t thread) +void evc_notify_abort(const thread_t thread) { int i; evc_t ev; diff --git a/kern/host.c b/kern/host.c index 698acea9..2855cd2d 100644 --- a/kern/host.c +++ b/kern/host.c @@ -47,7 +47,7 @@ host_data_t realhost; kern_return_t host_processors( - host_t host, + const host_t host, processor_array_t *processor_list, natural_t *countp) { @@ -95,7 +95,7 @@ kern_return_t host_processors( } kern_return_t host_info( - host_t host, + const host_t host, int flavor, host_info_t info, natural_t *count) @@ -204,7 +204,7 @@ kern_return_t host_info( */ kern_return_t host_kernel_version( - host_t host, + const host_t host, kernel_version_t out_version) { extern char version[]; @@ -225,7 +225,7 @@ kern_return_t host_kernel_version( #if MACH_HOST kern_return_t host_processor_sets( - host_t host, + const host_t host, processor_set_name_array_t *pset_list, natural_t *count) { @@ -324,7 +324,7 @@ host_processor_sets( */ kern_return_t host_processor_sets( - host_t host, + const host_t host, processor_set_name_array_t *pset_list, natural_t *count) { @@ -362,7 +362,7 @@ host_processor_sets( */ kern_return_t host_processor_set_priv( - host_t host, + const host_t host, processor_set_t pset_name, processor_set_t *pset) { diff --git a/kern/ipc_host.c b/kern/ipc_host.c index cd1c11ab..a02eb6f6 100644 --- a/kern/ipc_host.c +++ b/kern/ipc_host.c @@ -205,7 +205,7 @@ ipc_pset_terminate( */ kern_return_t processor_set_default( - host_t host, + const host_t host, processor_set_t *pset) { if (host == HOST_NULL) diff --git a/kern/ipc_mig.c b/kern/ipc_mig.c index f5e8e14e..bbc38cf6 100644 --- a/kern/ipc_mig.c +++ b/kern/ipc_mig.c @@ -92,7 +92,7 @@ mach_msg_send_from_kernel( mach_msg_return_t mach_msg_rpc_from_kernel(msg, send_size, reply_size) - mach_msg_header_t *msg; + const mach_msg_header_t *msg; mach_msg_size_t send_size; mach_msg_size_t reply_size; { @@ -286,7 +286,8 @@ mig_put_reply_port( * len - Length of destination buffer. */ void mig_strncpy(dest, src, len) -char *dest, *src; +char *dest; +const char *src; int len; { int i; diff --git a/kern/ipc_mig.h b/kern/ipc_mig.h index 3e368ae7..6f063eca 100644 --- a/kern/ipc_mig.h +++ b/kern/ipc_mig.h @@ -59,7 +59,7 @@ extern mach_msg_return_t mach_msg_send_from_kernel( extern void mach_msg_abort_rpc (ipc_thread_t); extern mach_msg_return_t mach_msg_rpc_from_kernel( - mach_msg_header_t *msg, + const mach_msg_header_t *msg, mach_msg_size_t send_size, mach_msg_size_t reply_size); diff --git a/kern/ipc_tt.c b/kern/ipc_tt.c index e5d928dc..f8d0f63c 100644 --- a/kern/ipc_tt.c +++ b/kern/ipc_tt.c @@ -648,9 +648,9 @@ task_get_special_port( kern_return_t task_set_special_port( - task_t task, - int which, - ipc_port_t port) + task_t task, + int which, + const ipc_port_t port) { ipc_port_t *whichp; ipc_port_t old; diff --git a/kern/mach_clock.c b/kern/mach_clock.c index f167291d..c68b460d 100644 --- a/kern/mach_clock.c +++ b/kern/mach_clock.c @@ -387,7 +387,7 @@ record_time_stamp (time_value_t *stamp) */ kern_return_t host_get_time(host, current_time) - host_t host; + const host_t host; time_value_t *current_time; /* OUT */ { if (host == HOST_NULL) @@ -406,7 +406,7 @@ host_get_time(host, current_time) */ kern_return_t host_set_time(host, new_time) - host_t host; + const host_t host; time_value_t new_time; { spl_t s; @@ -444,7 +444,7 @@ host_set_time(host, new_time) */ kern_return_t host_adjust_time(host, new_adjustment, old_adjustment) - host_t host; + const host_t host; time_value_t new_adjustment; time_value_t *old_adjustment; /* OUT */ { @@ -527,9 +527,9 @@ timer_elt_data_t timeout_timers[NTIMERS]; * interval: timeout interval, in hz. */ void timeout(fcn, param, interval) - void (*fcn)( void * param ); - void * param; - int interval; + void (*fcn)( void * param ); + void * param; + int interval; { spl_t s; timer_elt_t elt; @@ -555,8 +555,8 @@ void timeout(fcn, param, interval) * and removed. */ boolean_t untimeout(fcn, param) - void (*fcn)( void * param ); - void * param; + void (*fcn)( void * param ); + const void * param; { spl_t s; timer_elt_t elt; diff --git a/kern/mach_clock.h b/kern/mach_clock.h index 72189af6..827cf861 100644 --- a/kern/mach_clock.h +++ b/kern/mach_clock.h @@ -102,7 +102,7 @@ extern void mapable_time_init (void); /* For public timer elements. */ extern void timeout(timer_func_t *fcn, void *param, int interval); -extern boolean_t untimeout(timer_func_t *fcn, void *param); +extern boolean_t untimeout(timer_func_t *fcn, const void *param); extern int timeopen(void); extern int timeclose(void); diff --git a/kern/machine.c b/kern/machine.c index 8a333271..5d1ea346 100644 --- a/kern/machine.c +++ b/kern/machine.c @@ -126,8 +126,8 @@ void cpu_down(cpu) kern_return_t host_reboot(host, options) - host_t host; - int options; + const host_t host; + int options; { if (host == HOST_NULL) return (KERN_INVALID_HOST); diff --git a/kern/pc_sample.c b/kern/pc_sample.c index cdf8e954..81b20560 100644 --- a/kern/pc_sample.c +++ b/kern/pc_sample.c @@ -44,7 +44,7 @@ typedef sampled_pc_t sampled_pcs[MAX_PC_SAMPLES]; void take_pc_sample( - thread_t t, + const thread_t t, sample_control_t *cp, sampled_pc_flavor_t flavor) { @@ -241,8 +241,8 @@ task_get_sampled_pcs( kern_return_t thread_enable_pc_sampling( - thread_t thread, - int *tickp, + const thread_t thread, + const int *tickp, sampled_pc_flavor_t flavors) { return KERN_FAILURE; /* not implemented */ @@ -250,8 +250,8 @@ thread_enable_pc_sampling( kern_return_t task_enable_pc_sampling( - task_t task, - int *tickp, + const task_t task, + const int *tickp, sampled_pc_flavor_t flavors) { return KERN_FAILURE; /* not implemented */ @@ -259,36 +259,36 @@ task_enable_pc_sampling( kern_return_t thread_disable_pc_sampling( - thread_t thread, - int *samplecntp) + const thread_t thread, + const int *samplecntp) { return KERN_FAILURE; /* not implemented */ } kern_return_t task_disable_pc_sampling( - task_t task, - int *samplecntp) + const task_t task, + const int *samplecntp) { return KERN_FAILURE; /* not implemented */ } kern_return_t thread_get_sampled_pcs( - thread_t thread, - sampled_pc_seqno_t *seqnop, - sampled_pc_array_t sampled_pcs_out, - int *sampled_pcs_cntp) + const thread_t thread, + const sampled_pc_seqno_t *seqnop, + const sampled_pc_array_t sampled_pcs_out, + const int *sampled_pcs_cntp) { return KERN_FAILURE; /* not implemented */ } kern_return_t task_get_sampled_pcs( - task_t task, - sampled_pc_seqno_t *seqnop, - sampled_pc_array_t sampled_pcs_out, - int *sampled_pcs_cntp) + const task_t task, + const sampled_pc_seqno_t *seqnop, + const sampled_pc_array_t sampled_pcs_out, + const int *sampled_pcs_cntp) { return KERN_FAILURE; /* not implemented */ } diff --git a/kern/sched_prim.c b/kern/sched_prim.c index 8aad1462..f8170044 100644 --- a/kern/sched_prim.c +++ b/kern/sched_prim.c @@ -358,7 +358,7 @@ void clear_wait( } static inline void __attribute__((noreturn)) -state_panic(thread_t thread, const char *caller) +state_panic(const thread_t thread, const char *caller) { panic ("%s: thread %x has unexpected state %x", caller, thread, thread->state); @@ -1076,7 +1076,7 @@ void compute_my_priority( * * Update the priorities of all threads periodically. */ -void recompute_priorities(void *param) +void recompute_priorities(const void *param) { #if SIMPLE_CLOCK int new_usec; @@ -1990,7 +1990,7 @@ void do_thread_scan(void) #if DEBUG void checkrq( run_queue_t rq, - char *msg) + const char *msg) { queue_t q1; int i, j; diff --git a/kern/syscall_emulation.c b/kern/syscall_emulation.c index 290c51a5..da0a6cf2 100644 --- a/kern/syscall_emulation.c +++ b/kern/syscall_emulation.c @@ -94,7 +94,7 @@ void eml_task_reference(task, parent) */ void eml_task_deallocate(task) - task_t task; + const task_t task; { eml_dispatch_t eml; -- cgit v1.2.3 From cea1f71ee21451d89cddeff04d8145697a5deab8 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Mon, 16 Dec 2013 23:55:16 +0100 Subject: util: qualify pointers whose dereferenced values are constant with const --- util/atoi.c | 8 ++++---- util/atoi.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/util/atoi.c b/util/atoi.c index 64816b9d..e56f50d7 100644 --- a/util/atoi.c +++ b/util/atoi.c @@ -91,11 +91,11 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ int mach_atoi(cp, nump) -u_char *cp; -int *nump; +const u_char *cp; +int *nump; { - int number; - u_char *original; + int number; + const u_char *original; original = cp; for (number = 0; ('0' <= *cp) && (*cp <= '9'); cp++) diff --git a/util/atoi.h b/util/atoi.h index 921b1e81..47adb42e 100644 --- a/util/atoi.h +++ b/util/atoi.h @@ -62,6 +62,6 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #define MACH_ATOI_DEFAULT -1 -extern int mach_atoi (u_char *, int *); +extern int mach_atoi (const u_char *, int *); #endif /* _UTIL_ATOI_H_ */ -- cgit v1.2.3 From 5a5ec187ae6cb2afc874ad9ef118ef634e9164c8 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Mon, 16 Dec 2013 23:55:17 +0100 Subject: vm: qualify pointers whose dereferenced values are constant with const --- vm/memory_object.c | 4 ++-- vm/memory_object_proxy.c | 8 ++++---- vm/memory_object_proxy.h | 8 ++++---- vm/vm_debug.c | 2 +- vm/vm_external.c | 4 ++-- vm/vm_map.c | 8 ++++---- vm/vm_print.h | 4 ++-- vm/vm_resident.c | 2 +- vm/vm_user.c | 2 +- 9 files changed, 21 insertions(+), 21 deletions(-) diff --git a/vm/memory_object.c b/vm/memory_object.c index 404ae73c..024856d2 100644 --- a/vm/memory_object.c +++ b/vm/memory_object.c @@ -1032,7 +1032,7 @@ kern_return_t memory_object_get_attributes(object, object_ready, * If successful, consumes the supplied naked send right. */ kern_return_t vm_set_default_memory_manager(host, default_manager) - host_t host; + const host_t host; ipc_port_t *default_manager; { ipc_port_t current_manager; @@ -1114,7 +1114,7 @@ ipc_port_t memory_manager_default_reference(void) */ boolean_t memory_manager_default_port(port) - ipc_port_t port; + const ipc_port_t port; { ipc_port_t current; boolean_t result; diff --git a/vm/memory_object_proxy.c b/vm/memory_object_proxy.c index 4fed312e..a64bfcce 100644 --- a/vm/memory_object_proxy.c +++ b/vm/memory_object_proxy.c @@ -115,11 +115,11 @@ memory_object_proxy_notify (mach_msg_header_t *msg) given OBJECT at OFFSET in the new object with the maximum protection MAX_PROTECTION and return it in *PORT. */ kern_return_t -memory_object_create_proxy (ipc_space_t space, vm_prot_t max_protection, +memory_object_create_proxy (const ipc_space_t space, vm_prot_t max_protection, ipc_port_t *object, natural_t object_count, - vm_offset_t *offset, natural_t offset_count, - vm_offset_t *start, natural_t start_count, - vm_offset_t *len, natural_t len_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) { memory_object_proxy_t proxy; diff --git a/vm/memory_object_proxy.h b/vm/memory_object_proxy.h index 8c2bc0f8..3de69969 100644 --- a/vm/memory_object_proxy.h +++ b/vm/memory_object_proxy.h @@ -30,15 +30,15 @@ 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 (ipc_space_t space, +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, - vm_offset_t *offset, + const vm_offset_t *offset, natural_t offset_count, - vm_offset_t *start, + const vm_offset_t *start, natural_t start_count, - vm_offset_t *len, + 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, diff --git a/vm/vm_debug.c b/vm/vm_debug.c index a240ba85..e4a4b8b9 100644 --- a/vm/vm_debug.c +++ b/vm/vm_debug.c @@ -434,7 +434,7 @@ mach_vm_object_pages(object, pagesp, countp) kern_return_t host_virtual_physical_table_info(host, infop, countp) - host_t host; + const host_t host; hash_info_bucket_array_t *infop; natural_t *countp; { diff --git a/vm/vm_external.c b/vm/vm_external.c index e9643ffc..77bd44ba 100644 --- a/vm/vm_external.c +++ b/vm/vm_external.c @@ -97,8 +97,8 @@ void vm_external_destroy(e) } vm_external_state_t _vm_external_state_get(e, offset) - vm_external_t e; - vm_offset_t offset; + const vm_external_t e; + vm_offset_t offset; { unsigned int bit, byte; diff --git a/vm/vm_map.c b/vm/vm_map.c index 55ceb75e..e6eabdbc 100644 --- a/vm/vm_map.c +++ b/vm/vm_map.c @@ -256,7 +256,7 @@ vm_map_t vm_map_create(pmap, min, max, pageable) _vm_map_entry_create(&(copy)->cpy_hdr) vm_map_entry_t _vm_map_entry_create(map_header) - struct vm_map_header *map_header; + const struct vm_map_header *map_header; { kmem_cache_t cache; vm_map_entry_t entry; @@ -285,7 +285,7 @@ vm_map_entry_t _vm_map_entry_create(map_header) _vm_map_entry_dispose(&(copy)->cpy_hdr, (entry)) void _vm_map_entry_dispose(map_header, entry) - struct vm_map_header *map_header; + const struct vm_map_header *map_header; vm_map_entry_t entry; { kmem_cache_t cache; @@ -4715,7 +4715,7 @@ kern_return_t vm_map_machine_attribute(map, address, size, attribute, value) * vm_map_print: [ debug ] */ void vm_map_print(map) - vm_map_t map; + vm_map_t map; { vm_map_entry_t entry; @@ -4783,7 +4783,7 @@ void vm_map_print(map) */ void vm_map_copy_print(copy) - vm_map_copy_t copy; + const vm_map_copy_t copy; { int i, npages; diff --git a/vm/vm_print.h b/vm/vm_print.h index c2c2918f..eab534eb 100644 --- a/vm/vm_print.h +++ b/vm/vm_print.h @@ -26,7 +26,7 @@ extern void vm_map_print(vm_map_t); /* Pretty-print a copy object for ddb. */ -extern void vm_map_copy_print(vm_map_copy_t); +extern void vm_map_copy_print(const vm_map_copy_t); #include @@ -34,7 +34,7 @@ extern void vm_object_print(vm_object_t); #include -extern void vm_page_print(vm_page_t); +extern void vm_page_print(const vm_page_t); #endif /* VM_PRINT_H */ diff --git a/vm/vm_resident.c b/vm/vm_resident.c index 7644fd39..6f340413 100644 --- a/vm/vm_resident.c +++ b/vm/vm_resident.c @@ -1505,7 +1505,7 @@ vm_page_info( * Routine: vm_page_print [exported] */ void vm_page_print(p) - vm_page_t p; + const vm_page_t p; { iprintf("Page 0x%X: object 0x%X,", (vm_offset_t) p, (vm_offset_t) p->object); printf(" offset 0x%X", p->offset); diff --git a/vm/vm_user.c b/vm/vm_user.c index f721e87d..9ba5e1cf 100644 --- a/vm/vm_user.c +++ b/vm/vm_user.c @@ -411,7 +411,7 @@ kern_return_t vm_map( * [ To unwire the pages, specify VM_PROT_NONE. ] */ kern_return_t vm_wire(host, map, start, size, access) - host_t host; + const host_t host; vm_map_t map; vm_offset_t start; vm_size_t size; -- cgit v1.2.3 From 13a3d2472961902e809bb90fc5adc6b7696f7db5 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Mon, 16 Dec 2013 23:55:18 +0100 Subject: Mark functions that don't return with attribute noreturn --- device/ds_routines.c | 2 +- device/ds_routines.h | 2 +- device/net_io.c | 2 +- device/net_io.h | 2 +- kern/eventcount.c | 2 +- kern/machine.c | 2 +- kern/machine.h | 2 +- kern/sched_prim.c | 2 +- kern/sched_prim.h | 6 +++--- kern/thread.c | 4 ++-- kern/thread.h | 2 +- kern/thread_swap.c | 2 +- kern/thread_swap.h | 2 +- vm/vm_pageout.h | 6 +++--- 14 files changed, 19 insertions(+), 19 deletions(-) diff --git a/device/ds_routines.c b/device/ds_routines.c index 146b7eb6..c99818b5 100644 --- a/device/ds_routines.c +++ b/device/ds_routines.c @@ -1479,7 +1479,7 @@ void iodone(ior) splx(s); } -void io_done_thread_continue(void) +void __attribute__ ((noreturn)) io_done_thread_continue(void) { for (;;) { spl_t s; diff --git a/device/ds_routines.h b/device/ds_routines.h index a68c6c63..c0543cbc 100644 --- a/device/ds_routines.h +++ b/device/ds_routines.h @@ -67,7 +67,7 @@ kern_return_t device_pager_setup( extern void mach_device_init(void); extern void dev_lookup_init(void); extern void device_pager_init(void); -extern void io_done_thread(void); +extern void io_done_thread(void) __attribute__ ((noreturn)); io_return_t ds_device_write_trap( device_t dev, diff --git a/device/net_io.c b/device/net_io.c index bce27b32..68dcc096 100644 --- a/device/net_io.c +++ b/device/net_io.c @@ -553,7 +553,7 @@ void net_ast(void) (void) splx(s); } -void net_thread_continue(void) +void __attribute__ ((noreturn)) net_thread_continue(void) { for (;;) { spl_t s; diff --git a/device/net_io.h b/device/net_io.h index 0ffdc92c..e68e64a0 100644 --- a/device/net_io.h +++ b/device/net_io.h @@ -90,7 +90,7 @@ extern vm_size_t net_kmsg_size; extern void net_kmsg_collect (void); extern void net_io_init(void); -extern void net_thread(void); +extern void net_thread(void) __attribute__ ((noreturn)); #define net_kmsg_alloc() ((ipc_kmsg_t) kalloc(net_kmsg_size)) #define net_kmsg_free(kmsg) kfree((vm_offset_t) (kmsg), net_kmsg_size) diff --git a/kern/eventcount.c b/kern/eventcount.c index 1bc9968d..22c49327 100644 --- a/kern/eventcount.c +++ b/kern/eventcount.c @@ -123,7 +123,7 @@ void evc_notify_abort(const thread_t thread) * Just so that we return success, and give * up the stack while blocked */ -static void +static void __attribute__((noreturn)) evc_continue(void) { thread_syscall_return(KERN_SUCCESS); diff --git a/kern/machine.c b/kern/machine.c index 5d1ea346..d5944ce6 100644 --- a/kern/machine.c +++ b/kern/machine.c @@ -390,7 +390,7 @@ void action_thread_continue() } } -void action_thread() +void __attribute__((noreturn)) action_thread() { action_thread_continue(); /*NOTREACHED*/ diff --git a/kern/machine.h b/kern/machine.h index af2b7e91..c67213a2 100644 --- a/kern/machine.h +++ b/kern/machine.h @@ -53,6 +53,6 @@ extern kern_return_t processor_shutdown (processor_t); /* * action_thread() shuts down processors or changes their assignment. */ -extern void action_thread_continue (void); +extern void action_thread_continue (void) __attribute__((noreturn)); #endif /* _MACHINE_H_ */ diff --git a/kern/sched_prim.c b/kern/sched_prim.c index f8170044..1d2e14e5 100644 --- a/kern/sched_prim.c +++ b/kern/sched_prim.c @@ -1618,7 +1618,7 @@ int no_dispatch_count = 0; * to execute. */ -void idle_thread_continue(void) +void __attribute__((noreturn)) idle_thread_continue(void) { processor_t myprocessor; volatile thread_t *threadp; diff --git a/kern/sched_prim.h b/kern/sched_prim.h index c7ff9771..50041e4f 100644 --- a/kern/sched_prim.h +++ b/kern/sched_prim.h @@ -132,8 +132,8 @@ extern void thread_timeout_setup( * Machine-dependent code must define these functions. */ -extern void thread_bootstrap_return(void); -extern void thread_exception_return(void); +extern void thread_bootstrap_return(void) __attribute__((noreturn)); +extern void thread_exception_return(void) __attribute__((noreturn)); extern void __attribute__((__noreturn__)) thread_syscall_return(kern_return_t); extern thread_t switch_context( @@ -178,7 +178,7 @@ void checkrq(run_queue_t rq, char *msg); void thread_check(thread_t th, run_queue_t rq); #endif /* DEBUG */ -extern void idle_thread(void); +extern void idle_thread(void) __attribute__((noreturn)); extern void sched_thread(void); #endif /* _KERN_SCHED_PRIM_H_ */ diff --git a/kern/thread.c b/kern/thread.c index 1414078a..ddb06d52 100644 --- a/kern/thread.c +++ b/kern/thread.c @@ -1123,7 +1123,7 @@ kern_return_t thread_halt( } } -void walking_zombie(void) +void __attribute__((noreturn)) walking_zombie(void) { panic("the zombie walks!"); } @@ -1693,7 +1693,7 @@ thread_t kernel_thread( * This kernel thread runs forever looking for threads to destroy * (when they request that they be destroyed, of course). */ -void reaper_thread_continue(void) +void __attribute__((noreturn)) reaper_thread_continue(void) { for (;;) { thread_t thread; diff --git a/kern/thread.h b/kern/thread.h index 9946bde6..d088c274 100644 --- a/kern/thread.h +++ b/kern/thread.h @@ -350,7 +350,7 @@ extern thread_t kernel_thread( void (*start)(void), void * arg); -extern void reaper_thread(void); +extern void reaper_thread(void) __attribute__((noreturn)); #if MACH_HOST extern void thread_freeze( diff --git a/kern/thread_swap.c b/kern/thread_swap.c index e76511e6..94e5c218 100644 --- a/kern/thread_swap.c +++ b/kern/thread_swap.c @@ -154,7 +154,7 @@ void thread_doswapin(thread) * This procedure executes as a kernel thread. Threads that need to * be swapped in are swapped in by this thread. */ -void swapin_thread_continue(void) +void __attribute__((noreturn)) swapin_thread_continue(void) { for (;;) { thread_t thread; diff --git a/kern/thread_swap.h b/kern/thread_swap.h index 7f611ec4..9d645373 100644 --- a/kern/thread_swap.h +++ b/kern/thread_swap.h @@ -38,6 +38,6 @@ extern void swapper_init(void); extern void thread_swapin(thread_t thread); extern void thread_doswapin(thread_t thread); -extern void swapin_thread(void); +extern void swapin_thread(void) __attribute__((noreturn)); #endif /* _KERN_THREAD_SWAP_H_ */ diff --git a/vm/vm_pageout.h b/vm/vm_pageout.h index 7e3e4e47..ea6cfaf4 100644 --- a/vm/vm_pageout.h +++ b/vm/vm_pageout.h @@ -44,10 +44,10 @@ extern vm_page_t vm_pageout_setup(vm_page_t, vm_offset_t, vm_object_t, vm_offset_t, boolean_t); extern void vm_pageout_page(vm_page_t, boolean_t, boolean_t); -extern void vm_pageout(void); +extern void vm_pageout(void) __attribute__((noreturn)); -extern void vm_pageout_continue(void); +extern void vm_pageout_continue(void) __attribute__((noreturn)); -extern void vm_pageout_scan_continue(void); +extern void vm_pageout_scan_continue(void) __attribute__((noreturn)); #endif /* _VM_VM_PAGEOUT_H_ */ -- cgit v1.2.3 From f533e173fccb40aac5c3e7f4f2277f3cdec5d029 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Mon, 16 Dec 2013 23:55:19 +0100 Subject: kern: avoid the casts in enqueue_head() and enqueue_tail() * kern/eventcount.c (simpler_thread_setrun) (enqueue_head) (th): Avoid the cast. * kern/thread.c (thread_halt_self) (enqueue_tail) (thread): Likewise. * kern/thread_swap.c (thread_swapin) (enqueue_tail) (thread): Likewise. --- kern/eventcount.c | 2 +- kern/thread.c | 2 +- kern/thread_swap.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/kern/eventcount.c b/kern/eventcount.c index 22c49327..a9d7bd41 100644 --- a/kern/eventcount.c +++ b/kern/eventcount.c @@ -340,7 +340,7 @@ simpler_thread_setrun( whichq = (th)->sched_pri; simple_lock(&(rq)->lock); /* lock the run queue */ - enqueue_head(&(rq)->runq[whichq], (queue_entry_t) (th)); + enqueue_head(&(rq)->runq[whichq], &((th)->links)); if (whichq < (rq)->low || (rq)->count == 0) (rq)->low = whichq; /* minimize */ diff --git a/kern/thread.c b/kern/thread.c index ddb06d52..84749501 100644 --- a/kern/thread.c +++ b/kern/thread.c @@ -1149,7 +1149,7 @@ void thread_halt_self(void) s = splsched(); simple_lock(&reaper_lock); - enqueue_tail(&reaper_queue, (queue_entry_t) thread); + enqueue_tail(&reaper_queue, &(thread->links)); simple_unlock(&reaper_lock); thread_lock(thread); diff --git a/kern/thread_swap.c b/kern/thread_swap.c index 94e5c218..087c8bc2 100644 --- a/kern/thread_swap.c +++ b/kern/thread_swap.c @@ -97,7 +97,7 @@ void thread_swapin(thread) thread->state = (thread->state & ~TH_SWAP_STATE) | TH_SW_COMING_IN; swapper_lock(); - enqueue_tail(&swapin_queue, (queue_entry_t) thread); + enqueue_tail(&swapin_queue, &(thread->links)); swapper_unlock(); thread_wakeup((event_t) &swapin_queue); break; -- cgit v1.2.3 From b2c50e9cac17f5284401c22b5d912edf6e49f6ed Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Wed, 18 Dec 2013 12:17:49 +0100 Subject: i386: add missing includes * i386/i386at/kd_event.h: Add missing includes. --- i386/i386at/kd_event.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/i386/i386at/kd_event.h b/i386/i386at/kd_event.h index f1295cb2..9568fa56 100644 --- a/i386/i386at/kd_event.h +++ b/i386/i386at/kd_event.h @@ -26,6 +26,10 @@ #ifndef _KD_EVENT_H_ #define _KD_EVENT_H_ +#include +#include +#include + extern void X_kdb_enter (void); extern void X_kdb_exit (void); -- cgit v1.2.3 From 549984f6b3b5ec146edcb03d86e637eff9956bd2 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 19 Dec 2013 20:43:54 +0100 Subject: Declare void argument lists (part 2) Declare void argument lists that were not declared in the first part of this patch and * kern/sched_prim.h (recompute_priorities): Fix prototype. * kern/startup.c (setup_main) (recompute_priorities): Fix call. --- ddb/db_break.h | 4 ++-- ddb/db_watch.c | 2 +- device/blkio.c | 2 +- device/conf.h | 6 +++--- device/ds_routines.c | 2 +- device/net_io.h | 2 +- i386/i386/mp_desc.c | 2 +- kern/bootstrap.c | 4 ++-- kern/machine.c | 4 ++-- kern/sched_prim.h | 4 ++-- kern/startup.c | 2 +- vm/pmap.h | 2 +- vm/vm_resident.c | 2 +- 13 files changed, 19 insertions(+), 19 deletions(-) diff --git a/ddb/db_break.h b/ddb/db_break.h index ad861198..2dfa8040 100644 --- a/ddb/db_break.h +++ b/ddb/db_break.h @@ -88,9 +88,9 @@ extern db_breakpoint_t db_set_breakpoint(const task_t task, db_addr_t addr, int count, const thread_t thread, boolean_t task_bpt); -void db_listbreak_cmd(); +void db_listbreak_cmd(void); -void db_delete_cmd(); +void db_delete_cmd(void); void db_breakpoint_cmd( db_expr_t addr, diff --git a/ddb/db_watch.c b/ddb/db_watch.c index c8a42868..5551e667 100644 --- a/ddb/db_watch.c +++ b/ddb/db_watch.c @@ -65,7 +65,7 @@ db_watchpoint_t db_watchpoint_list = 0; extern vm_map_t kernel_map; db_watchpoint_t -db_watchpoint_alloc() +db_watchpoint_alloc(void) { db_watchpoint_t watch; diff --git a/device/blkio.c b/device/blkio.c index 939067d7..52d8c003 100644 --- a/device/blkio.c +++ b/device/blkio.c @@ -102,7 +102,7 @@ void minphys(ior) * Dummy routine placed in device switch entries to indicate that * block device may be mapped. */ -vm_offset_t block_io_mmap() +vm_offset_t block_io_mmap(void) { return (0); } diff --git a/device/conf.h b/device/conf.h index 8aacc86e..a0d5010f 100644 --- a/device/conf.h +++ b/device/conf.h @@ -58,9 +58,9 @@ typedef struct dev_ops *dev_ops_t; /* * Routines for null entries. */ -extern int nulldev(); /* no operation - OK */ -extern int nodev(); /* no operation - error */ -extern vm_offset_t nomap(); /* no operation - error */ +extern int nulldev(void); /* no operation - OK */ +extern int nodev(void); /* no operation - error */ +extern vm_offset_t nomap(void); /* no operation - error */ /* * Flavor constants for d_dev_info routine diff --git a/device/ds_routines.c b/device/ds_routines.c index c99818b5..82b52528 100644 --- a/device/ds_routines.c +++ b/device/ds_routines.c @@ -99,7 +99,7 @@ extern struct device_emulation_ops linux_block_emulation_ops; #ifdef CONFIG_INET extern struct device_emulation_ops linux_net_emulation_ops; -extern void free_skbuffs (); +extern void free_skbuffs (void); #ifdef CONFIG_PCMCIA extern struct device_emulation_ops linux_pcmcia_emulation_ops; #endif /* CONFIG_PCMCIA */ diff --git a/device/net_io.h b/device/net_io.h index e68e64a0..f6de8541 100644 --- a/device/net_io.h +++ b/device/net_io.h @@ -74,7 +74,7 @@ extern void net_kmsg_put(ipc_kmsg_t); * Network utility routines. */ -extern void net_ast(); +extern void net_ast(void); extern void net_packet(struct ifnet *, ipc_kmsg_t, unsigned int, boolean_t); extern void net_filter(ipc_kmsg_t, ipc_kmsg_queue_t); extern io_return_t net_getstat(struct ifnet *, dev_flavor_t, dev_status_t, diff --git a/i386/i386/mp_desc.c b/i386/i386/mp_desc.c index 4ff5e613..2ffe8ac0 100644 --- a/i386/i386/mp_desc.c +++ b/i386/i386/mp_desc.c @@ -171,7 +171,7 @@ mp_desc_init(mycpu) * is running. The machine array must show which CPUs exist. */ void -interrupt_stack_alloc() +interrupt_stack_alloc(void) { int i; int cpu_count; diff --git a/kern/bootstrap.c b/kern/bootstrap.c index 86e238af..3e24d7b7 100644 --- a/kern/bootstrap.c +++ b/kern/bootstrap.c @@ -82,8 +82,8 @@ static mach_port_t boot_host_port; /* local name */ extern char *kernel_cmdline; -static void user_bootstrap(); /* forward */ -static void user_bootstrap_compat(); /* forward */ +static void user_bootstrap(void); /* forward */ +static void user_bootstrap_compat(void); /* forward */ static void bootstrap_exec_compat(void *exec_data); /* forward */ static void get_compat_strings(char *flags_str, char *root_str); /* forward */ diff --git a/kern/machine.c b/kern/machine.c index d5944ce6..52133cb9 100644 --- a/kern/machine.c +++ b/kern/machine.c @@ -361,7 +361,7 @@ processor_t processor; /* * action_thread() shuts down processors or changes their assignment. */ -void action_thread_continue() +void action_thread_continue(void) { processor_t processor; spl_t s; @@ -390,7 +390,7 @@ void action_thread_continue() } } -void __attribute__((noreturn)) action_thread() +void __attribute__((noreturn)) action_thread(void) { action_thread_continue(); /*NOTREACHED*/ diff --git a/kern/sched_prim.h b/kern/sched_prim.h index 50041e4f..8c62b8b1 100644 --- a/kern/sched_prim.h +++ b/kern/sched_prim.h @@ -69,7 +69,7 @@ extern void thread_sleep( event_t event, simple_lock_t lock, boolean_t interruptible); -extern void thread_wakeup(); /* for function pointers */ +extern void thread_wakeup(void); /* for function pointers */ extern void thread_wakeup_prim( event_t event, boolean_t one_thread, @@ -103,7 +103,7 @@ extern boolean_t thread_handoff( thread_t old_thread, continuation_t continuation, thread_t new_thread); -extern void recompute_priorities(); +extern void recompute_priorities(const void *param); extern void update_priority( thread_t thread); extern void compute_my_priority( diff --git a/kern/startup.c b/kern/startup.c index 81874e73..12f51231 100644 --- a/kern/startup.c +++ b/kern/startup.c @@ -155,7 +155,7 @@ void setup_main(void) * Kick off the time-out driven routines by calling * them the first time. */ - recompute_priorities(); + recompute_priorities(NULL); compute_mach_factor(); /* diff --git a/vm/pmap.h b/vm/pmap.h index 95ba6da5..134f9c64 100644 --- a/vm/pmap.h +++ b/vm/pmap.h @@ -183,7 +183,7 @@ extern void pmap_copy(pmap_t, pmap_t, vm_offset_t, vm_size_t, #endif /* pmap_copy */ #ifndef pmap_attribute /* Get/Set special memory attributes. */ -extern kern_return_t pmap_attribute(); +extern kern_return_t pmap_attribute(void); #endif /* pmap_attribute */ /* diff --git a/vm/vm_resident.c b/vm/vm_resident.c index 6f340413..fa02cbcd 100644 --- a/vm/vm_resident.c +++ b/vm/vm_resident.c @@ -918,7 +918,7 @@ vm_page_t vm_page_grab( return mem; } -vm_offset_t vm_page_grab_phys_addr() +vm_offset_t vm_page_grab_phys_addr(void) { vm_page_t p = vm_page_grab(FALSE); if (p == VM_PAGE_NULL) -- cgit v1.2.3 From 2370957542f907f45395fdf5c8e18d76a4843f2a Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 19 Dec 2013 20:43:55 +0100 Subject: ddb/db_watch.c (db_watchpoint_cmd): remove forward declaration * ddb/db_watch.c (db_watchpoint_cmd) (db_option): Remove forward declaration. --- ddb/db_watch.c | 1 - 1 file changed, 1 deletion(-) diff --git a/ddb/db_watch.c b/ddb/db_watch.c index 5551e667..dbb4aea7 100644 --- a/ddb/db_watch.c +++ b/ddb/db_watch.c @@ -242,7 +242,6 @@ db_watchpoint_cmd(addr, have_addr, count, modif) vm_size_t size; db_expr_t value; task_t task; - boolean_t db_option(); if (db_get_task(modif, &task, addr) < 0) return; -- cgit v1.2.3 From 2b33e316ac0d14b564ade0dd6fc3be136e945926 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Thu, 19 Dec 2013 18:51:05 +0100 Subject: kern/strings.c (strlen): mark with attribute pure * kern/strings.c (strlen): Mark with attribute pure. --- kern/strings.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kern/strings.c b/kern/strings.c index 07527226..72eb4f3b 100644 --- a/kern/strings.c +++ b/kern/strings.c @@ -161,7 +161,7 @@ strncpy( * the terminating null character. */ -size_t +size_t __attribute__ ((pure)) strlen( const char *string) { -- cgit v1.2.3 From be1ce42e936c96776b661ba5a93b0c9d0d76bb31 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 20 Dec 2013 13:29:00 +0100 Subject: Mark pure functions with attribute pure --- ddb/db_aout.c | 4 ++-- ddb/db_break.c | 4 ++-- ddb/db_break.h | 2 +- ddb/db_command.c | 2 +- ddb/db_command.h | 2 +- ddb/db_output.c | 2 +- ddb/db_output.h | 2 +- ddb/db_run.c | 2 +- ddb/db_sym.c | 2 +- device/dev_name.c | 2 +- include/string.h | 8 ++++---- kern/strings.c | 4 ++-- 12 files changed, 18 insertions(+), 18 deletions(-) diff --git a/ddb/db_aout.c b/ddb/db_aout.c index 57c680a1..87ba9753 100644 --- a/ddb/db_aout.c +++ b/ddb/db_aout.c @@ -132,7 +132,7 @@ aout_db_sym_init(symtab, esymtab, name, task_addr) /* * check file name or not (check xxxx.x pattern) */ -private boolean_t +private boolean_t __attribute__ ((pure)) aout_db_is_filename(name) const char *name; { @@ -149,7 +149,7 @@ aout_db_is_filename(name) /* * special name comparison routine with a name in the symbol table entry */ -private boolean_t +private boolean_t __attribute__ ((pure)) aout_db_eq_name(sp, name) const struct nlist *sp; const char *name; diff --git a/ddb/db_break.c b/ddb/db_break.c index e41834da..0534f686 100644 --- a/ddb/db_break.c +++ b/ddb/db_break.c @@ -154,7 +154,7 @@ db_delete_thread_breakpoint(bkpt, task_thd) } } -static db_thread_breakpoint_t +static db_thread_breakpoint_t __attribute__ ((pure)) db_find_thread_breakpoint(bkpt, thread) const db_breakpoint_t bkpt; const thread_t thread; @@ -350,7 +350,7 @@ db_delete_breakpoint(task, addr, task_thd) } } -db_breakpoint_t +db_breakpoint_t __attribute__ ((pure)) db_find_breakpoint(task, addr) const task_t task; db_addr_t addr; diff --git a/ddb/db_break.h b/ddb/db_break.h index 2dfa8040..610af2f8 100644 --- a/ddb/db_break.h +++ b/ddb/db_break.h @@ -71,7 +71,7 @@ struct db_breakpoint { typedef struct db_breakpoint *db_breakpoint_t; -extern db_breakpoint_t db_find_breakpoint( const task_t task, db_addr_t addr); +extern db_breakpoint_t db_find_breakpoint( const task_t task, db_addr_t addr) __attribute__ ((pure)); extern boolean_t db_find_breakpoint_here( const task_t task, db_addr_t addr); extern void db_set_breakpoints(void); extern void db_clear_breakpoints(void); diff --git a/ddb/db_command.c b/ddb/db_command.c index 3257e073..3879ec5c 100644 --- a/ddb/db_command.c +++ b/ddb/db_command.c @@ -522,7 +522,7 @@ db_fncall(void) db_printf(" %#N\n", retval); } -boolean_t +boolean_t __attribute__ ((pure)) db_option(modif, option) const char *modif; int option; diff --git a/ddb/db_command.h b/ddb/db_command.h index 634dd9d1..4208bda8 100644 --- a/ddb/db_command.h +++ b/ddb/db_command.h @@ -41,7 +41,7 @@ #include extern void db_command_loop(void); -extern boolean_t db_option(const char *, int); +extern boolean_t db_option(const char *, int) __attribute__ ((pure)); extern void db_error(const char *) __attribute__ ((noreturn)); /* report error */ diff --git a/ddb/db_output.c b/ddb/db_output.c index f7561d24..f2829cc4 100644 --- a/ddb/db_output.c +++ b/ddb/db_output.c @@ -188,7 +188,7 @@ db_id_putc(char c, vm_offset_t dummy) /* * Return output position */ -int +int __attribute__ ((pure)) db_print_position(void) { return (db_output_position); diff --git a/ddb/db_output.h b/ddb/db_output.h index e8866474..497ae430 100644 --- a/ddb/db_output.h +++ b/ddb/db_output.h @@ -36,7 +36,7 @@ #define _DDB_DB_OUTPUT_H_ extern void db_force_whitespace(void); -extern int db_print_position(void); +extern int db_print_position(void) __attribute__ ((pure)); extern void db_end_line(void); extern void db_printf(const char *fmt, ...); /* alternate name */ diff --git a/ddb/db_run.c b/ddb/db_run.c index 945d097a..6e409ff3 100644 --- a/ddb/db_run.c +++ b/ddb/db_run.c @@ -249,7 +249,7 @@ db_single_step(regs, task) db_breakpoint_t db_not_taken_bkpt = 0; db_breakpoint_t db_taken_bkpt = 0; -db_breakpoint_t +db_breakpoint_t __attribute__ ((pure)) db_find_temp_breakpoint(task, addr) const task_t task; db_addr_t addr; diff --git a/ddb/db_sym.c b/ddb/db_sym.c index bbf14bdb..beb4d18e 100644 --- a/ddb/db_sym.c +++ b/ddb/db_sym.c @@ -88,7 +88,7 @@ db_add_symbol_table(type, start, end, name, ref, map_pointer) * Note: return value points to static data whose content is * overwritten by each call... but in practice this seems okay. */ -static char * +static char * __attribute__ ((pure)) db_qualify(symname, symtabname) const char *symname; const char *symtabname; diff --git a/device/dev_name.c b/device/dev_name.c index 49d96aa7..4cc046ab 100644 --- a/device/dev_name.c +++ b/device/dev_name.c @@ -63,7 +63,7 @@ nomap(void) * src and target are equal in first 'len' characters * next character of target is 0 (end of string). */ -boolean_t +boolean_t __attribute__ ((pure)) name_equal(src, len, target) const char *src; int len; diff --git a/include/string.h b/include/string.h index c77d387b..c31b4292 100644 --- a/include/string.h +++ b/include/string.h @@ -32,7 +32,7 @@ extern void *memcpy (void *dest, const void *src, size_t n); extern void *memmove (void *dest, const void *src, size_t n); -extern int memcmp (const void *s1, const void *s2, size_t n); +extern int memcmp (const void *s1, const void *s2, size_t n) __attribute__ ((pure)); extern void *memset (void *s, int c, size_t n); @@ -46,11 +46,11 @@ extern char *strrchr (const char *s, int c); extern char *strsep (char **strp, const char *delim); -extern int strcmp (const char *s1, const char *s2); +extern int strcmp (const char *s1, const char *s2) __attribute__ ((pure)); -extern int strncmp (const char *s1, const char *s2, size_t n); +extern int strncmp (const char *s1, const char *s2, size_t n) __attribute__ ((pure)); -extern size_t strlen (const char *s); +extern size_t strlen (const char *s) __attribute__ ((pure)); extern char *strstr(const char *haystack, const char *needle); diff --git a/kern/strings.c b/kern/strings.c index 72eb4f3b..c77ae4fe 100644 --- a/kern/strings.c +++ b/kern/strings.c @@ -53,7 +53,7 @@ * contents are identical upto the length of s1. */ -int +int __attribute__ ((pure)) strcmp( const char *s1, const char *s2) @@ -80,7 +80,7 @@ strcmp( * comparison runs for at most "n" characters. */ -int +int __attribute__ ((pure)) strncmp( const char *s1, const char *s2, -- cgit v1.2.3 From d23ad061809074f89206b95dd132820c306c9a3e Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Wed, 1 Jan 2014 14:46:01 +0100 Subject: Add comment after endif * i386/i386/io_perm.h (_I386_IO_PERM_H_): Add comment after endif. --- i386/i386/io_perm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i386/i386/io_perm.h b/i386/i386/io_perm.h index a68e1038..a7f1f6fe 100644 --- a/i386/i386/io_perm.h +++ b/i386/i386/io_perm.h @@ -62,4 +62,4 @@ extern ipc_port_t convert_io_perm_to_port (io_perm_t); extern void io_perm_deallocate (io_perm_t); #endif -#endif +#endif /* _I386_IO_PERM_H_ */ -- cgit v1.2.3 From fb124d6550f165ba971bf4b231f53e58c913d847 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 15 Nov 2013 19:39:18 +0100 Subject: i386/include/mach/i386/mach_i386_types.h: add comments after else and endif * i386/include/mach/i386/mach_i386_types.h (MACH_KERNEL): Add comments after else and endif. --- i386/include/mach/i386/mach_i386_types.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/i386/include/mach/i386/mach_i386_types.h b/i386/include/mach/i386/mach_i386_types.h index b03c0b06..b0552809 100644 --- a/i386/include/mach/i386/mach_i386_types.h +++ b/i386/include/mach/i386/mach_i386_types.h @@ -47,9 +47,9 @@ typedef struct descriptor *descriptor_list_t; #ifdef MACH_KERNEL #include -#else +#else /* MACH_KERNEL */ typedef unsigned short io_port_t; typedef mach_port_t io_perm_t; -#endif +#endif /* MACH_KERNEL */ #endif /* _MACH_MACH_I386_TYPES_H_ */ -- cgit v1.2.3 From e1cd0a70ace0944a4916f8a152c50e366c2c6984 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Thu, 2 Jan 2014 23:25:46 +0100 Subject: Make sure cursor is initialized * i386/i386at/kd.c (kd_xga_init): Add start, stop variables, read them from CRT registers, make sure the cursor is enabled and is not reduced to 0, and write them back to CRT registers. * i386/i386at/kd.h (C_START, C_STOP): New macros. --- i386/i386at/kd.c | 19 +++++++++++++++++++ i386/i386at/kd.h | 2 ++ 2 files changed, 21 insertions(+) diff --git a/i386/i386at/kd.c b/i386/i386at/kd.c index 3c66cc55..f70175cb 100644 --- a/i386/i386at/kd.c +++ b/i386/i386at/kd.c @@ -2498,6 +2498,7 @@ kd_xga_init(void) { csrpos_t xga_getpos(); unsigned char screen; + unsigned char start, stop; outb(CMOS_ADDR, CMOS_EB); screen = inb(CMOS_DATA) & CM_SCRMSK; @@ -2552,6 +2553,24 @@ kd_xga_init(void) printf("kd: unknown screen type, defaulting to EGA\n"); } + outb(kd_index_reg, C_START); + start = inb(kd_io_reg); + /* Make sure cursor is enabled */ + start &= ~0x20; + outb(kd_io_reg, start); + outb(kd_index_reg, C_STOP); + stop = inb(kd_io_reg); + + if (!start && !stop) + { + /* Some firmware seem not to be initializing the cursor size + * any more... Try using standard values. */ + outb(kd_index_reg, C_START); + outb(kd_io_reg, 14); + outb(kd_index_reg, C_STOP); + outb(kd_io_reg, 15); + } + kd_setpos(xga_getpos()); } diff --git a/i386/i386at/kd.h b/i386/i386at/kd.h index 0907e239..6c869d68 100644 --- a/i386/i386at/kd.h +++ b/i386/i386at/kd.h @@ -113,6 +113,8 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. /* * Commands sent to graphics adapter. */ +#define C_START 0x0a /* return cursor line start */ +#define C_STOP 0x0b /* return cursor line stop */ #define C_LOW 0x0f /* return low byte of cursor addr */ #define C_HIGH 0x0e /* high byte */ -- cgit v1.2.3 From 70833d9dc6c145e4535f94220eacfc05160bc110 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Thu, 2 Jan 2014 15:03:29 +0100 Subject: vm: remove NS32000-specific padding from struct vm_page Apparently, the NS32000 was a 32-bit CPU from the 1990ies. The string "ns32000" appears nowhere else in the source. * vm/vm_page.h (struct vm_page): Remove NS32000-specific padding. --- vm/vm_page.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/vm/vm_page.h b/vm/vm_page.h index 4445cb0d..73920444 100644 --- a/vm/vm_page.h +++ b/vm/vm_page.h @@ -94,9 +94,6 @@ struct vm_page { external:1, /* page considered external (P) */ extcounted:1, /* page counted in ext counts (P) */ :0; /* (force to 'long' boundary) */ -#ifdef ns32000 - int pad; /* extra space for ns32000 bit ops */ -#endif /* ns32000 */ unsigned int /* boolean_t */ busy:1, /* page is in transit (O) */ -- cgit v1.2.3 From 93b9dca0226cd08fd07db0ec72c34800720309be Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Thu, 2 Jan 2014 15:14:55 +0100 Subject: vm: merge the two bit fields in struct vm_page * vm/vm_page.h (struct vm_page): Merge the two bit fields. --- vm/vm_page.h | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/vm/vm_page.h b/vm/vm_page.h index 73920444..339d355d 100644 --- a/vm/vm_page.h +++ b/vm/vm_page.h @@ -92,11 +92,8 @@ struct vm_page { free:1, /* page is on free list (P) */ reference:1, /* page has been used (P) */ external:1, /* page considered external (P) */ - extcounted:1, /* page counted in ext counts (P) */ - :0; /* (force to 'long' boundary) */ - - unsigned int - /* boolean_t */ busy:1, /* page is in transit (O) */ + extcounted:1, /* page counted in ext counts (P) */ + busy:1, /* page is in transit (O) */ wanted:1, /* someone is waiting for page (O) */ tabled:1, /* page is in VP table (O) */ fictitious:1, /* Physical page doesn't exist (O) */ @@ -109,10 +106,9 @@ struct vm_page { dirty:1, /* Page must be cleaned (O) */ precious:1, /* Page is precious; data must be * returned even if clean (O) */ - overwriting:1, /* Request to unlock has been made + overwriting:1; /* Request to unlock has been made * without having data. (O) * [See vm_object_overwrite] */ - :0; vm_offset_t phys_addr; /* Physical address of page, passed * to pmap_enter (read-only) */ -- cgit v1.2.3 From 2f8477fb3bb1b95d2f814d76cf37777ec58c4c76 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Thu, 2 Jan 2014 15:54:17 +0100 Subject: vm: reduce the size of struct vm_page Previously, the bit field left 31 bits unused. By reducing the size of wire_count by one bit, the size of the whole struct is reduced by four bytes. * vm/vm_page.h (struct vm_page): Reduce the size of wire_count to 15 bits. --- vm/vm_page.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vm/vm_page.h b/vm/vm_page.h index 339d355d..4fe1b41d 100644 --- a/vm/vm_page.h +++ b/vm/vm_page.h @@ -84,7 +84,7 @@ struct vm_page { vm_object_t object; /* which object am I in (O,P) */ vm_offset_t offset; /* offset into that object (O,P) */ - unsigned int wire_count:16, /* how many wired down maps use me? + unsigned int wire_count:15, /* how many wired down maps use me? (O&P) */ /* boolean_t */ inactive:1, /* page is in inactive list (P) */ active:1, /* page is in active list (P) */ -- cgit v1.2.3 From d775e04dd3ee9648ca91b1df965b435a34632606 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Thu, 2 Jan 2014 16:14:19 +0100 Subject: kern: reduce the size of struct task * kern/task.h (struct task): Reduce the size of struct task by 2 * sizeof boolean_t by using a bit field for the boolean flags. --- kern/task.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/kern/task.h b/kern/task.h index 9bfea571..e8520331 100644 --- a/kern/task.h +++ b/kern/task.h @@ -52,7 +52,11 @@ struct task { /* Synchronization/destruction information */ decl_simple_lock_data(,lock) /* Task's lock */ int ref_count; /* Number of references to me */ - boolean_t active; /* Task has not been terminated */ + + /* Flags */ + unsigned int active:1, /* Task has not been terminated */ + /* boolean_t */ may_assign:1, /* can assigned pset be changed? */ + assign_active:1; /* waiting for may_assign */ /* Miscellaneous */ vm_map_t map; /* Address space description */ @@ -63,8 +67,6 @@ struct task { queue_head_t thread_list; /* list of threads */ int thread_count; /* number of threads */ processor_set_t processor_set; /* processor set for new threads */ - boolean_t may_assign; /* can assigned pset be changed? */ - boolean_t assign_active; /* waiting for may_assign */ /* User-visible scheduling information */ int user_stop_count; /* outstanding stops */ -- cgit v1.2.3 From 8982de2eb4fa2fa6f5a350c348c211542aecfaa1 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Thu, 2 Jan 2014 16:32:00 +0100 Subject: kern: make struct kmem_cache fit into two cache lines Previously, the size of struct kmem_cache was 136 bytes, just eight bytes larger than 128 bytes, which is typically two cache lines on today's CPUs. By reducing the size of the name field which holds a human-readable description by eight bytes to 24 bytes, the struct kmem_cache can be made fit into two cache lines. This change should not affect the usefulness of this field. For reference, the length of the largest hard-coded name is 17. * kern/slab.h (KMEM_CACHE_NAME_SIZE): Define to 24. --- kern/slab.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kern/slab.h b/kern/slab.h index b842fb74..a4219c42 100644 --- a/kern/slab.h +++ b/kern/slab.h @@ -149,7 +149,7 @@ typedef void (*kmem_slab_free_fn_t)(vm_offset_t, vm_size_t); /* * Cache name buffer size. */ -#define KMEM_CACHE_NAME_SIZE 32 +#define KMEM_CACHE_NAME_SIZE 24 /* * Cache of objects. -- cgit v1.2.3 From 5faed5128d3c07f055f96d910529c95814073a09 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Sun, 5 Jan 2014 14:11:29 +0100 Subject: linux: fix bit tests The pattern is !x&y. An expression of this form is almost always meaningless, because it combines a boolean operator with a bit operator. In particular, if the rightmost bit of y is 0, the result will always be 0. Fixed using coccinelle. // !x&y combines boolean negation with bitwise and // // Confidence: High // Copyright: (C) Gilles Muller, Julia Lawall, EMN, DIKU. GPLv2. // URL: http://www.emn.fr/x-info/coccinelle/rules/notand.html // Options: @@ expression E; constant C; @@ ( !E & !C | - !E & C + !(E & C) ) * linux/src/drivers/net/tlan.c: Fix bit tests. * linux/src/drivers/scsi/AM53C974.c: Likewise. * linux/src/drivers/scsi/FlashPoint.c: Likewise. * linux/src/drivers/scsi/NCR5380.c: Likewise. * linux/src/drivers/scsi/t128.c: Likewise. --- linux/src/drivers/net/tlan.c | 4 ++-- linux/src/drivers/scsi/AM53C974.c | 2 +- linux/src/drivers/scsi/FlashPoint.c | 2 +- linux/src/drivers/scsi/NCR5380.c | 4 ++-- linux/src/drivers/scsi/t128.c | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/linux/src/drivers/net/tlan.c b/linux/src/drivers/net/tlan.c index 11e12bbc..fedc11f3 100644 --- a/linux/src/drivers/net/tlan.c +++ b/linux/src/drivers/net/tlan.c @@ -1132,7 +1132,7 @@ u32 TLan_HandleTxEOF( struct device *dev, u16 host_int ) if ( head_list->cStat & TLAN_CSTAT_EOC ) eoc = 1; - if ( ! head_list->cStat & TLAN_CSTAT_FRM_CMP ) { + if (!(head_list->cStat & TLAN_CSTAT_FRM_CMP)) { printk( "TLAN: Received interrupt for uncompleted TX frame.\n" ); } @@ -1244,7 +1244,7 @@ u32 TLan_HandleRxEOF( struct device *dev, u16 host_int ) eoc = 1; } - if ( ! head_list->cStat & TLAN_CSTAT_FRM_CMP ) { + if (!(head_list->cStat & TLAN_CSTAT_FRM_CMP)) { printk( "TLAN: Received interrupt for uncompleted RX frame.\n" ); } else if ( bbuf ) { skb = dev_alloc_skb( head_list->frameSize + 7 ); diff --git a/linux/src/drivers/scsi/AM53C974.c b/linux/src/drivers/scsi/AM53C974.c index 5178ccf7..da139ced 100644 --- a/linux/src/drivers/scsi/AM53C974.c +++ b/linux/src/drivers/scsi/AM53C974.c @@ -1919,7 +1919,7 @@ if ((statreg & STATREG_PHASE) != PHASE_MSGIN) { goto EXIT_ABORT; } msg[0] = AM53C974_read_8(FFREG); -if (!msg[0] & 0x80) { +if (!(msg[0] & 0x80)) { printk("scsi%d: error: expecting IDENTIFY message, got ", instance->host_no); print_msg(msg); hostdata->aborted = 1; diff --git a/linux/src/drivers/scsi/FlashPoint.c b/linux/src/drivers/scsi/FlashPoint.c index aae35c03..4b96a66c 100644 --- a/linux/src/drivers/scsi/FlashPoint.c +++ b/linux/src/drivers/scsi/FlashPoint.c @@ -3845,7 +3845,7 @@ int SetDevWideMode(PSCCBcard pCurrCard,PUCB p_ucb) } else { - if(!currTar_Info->TarEEValue & EE_WIDE_SCSI) + if(!(currTar_Info->TarEEValue & EE_WIDE_SCSI)) { return(0); } diff --git a/linux/src/drivers/scsi/NCR5380.c b/linux/src/drivers/scsi/NCR5380.c index 295f2ad2..4f085e9b 100644 --- a/linux/src/drivers/scsi/NCR5380.c +++ b/linux/src/drivers/scsi/NCR5380.c @@ -1949,7 +1949,7 @@ static int do_abort (struct Scsi_Host *host) { * the target sees, so we just handshake. */ - while (!(tmp = NCR5380_read(STATUS_REG)) & SR_REQ); + while (!((tmp = NCR5380_read(STATUS_REG)) & SR_REQ)); NCR5380_write(TARGET_COMMAND_REG, PHASE_SR_TO_TCR(tmp)); @@ -2900,7 +2900,7 @@ static void NCR5380_reselect (struct Scsi_Host *instance) { NCR5380_transfer_pio(instance, &phase, &len, &data); - if (!msg[0] & 0x80) { + if (!(msg[0] & 0x80)) { printk("scsi%d : expecting IDENTIFY message, got ", instance->host_no); print_msg(msg); diff --git a/linux/src/drivers/scsi/t128.c b/linux/src/drivers/scsi/t128.c index d4c7452b..198e910b 100644 --- a/linux/src/drivers/scsi/t128.c +++ b/linux/src/drivers/scsi/t128.c @@ -327,7 +327,7 @@ static inline int NCR5380_pread (struct Scsi_Host *instance, unsigned char *dst, for (; i; --i) { while (!(instance->base[T_STATUS_REG_OFFSET]) & T_ST_RDY) barrier(); #else - while (!(instance->base[T_STATUS_REG_OFFSET]) & T_ST_RDY) barrier(); + while (!((instance->base[T_STATUS_REG_OFFSET]) & T_ST_RDY)) barrier(); for (; i; --i) { #endif *d++ = *reg; @@ -370,7 +370,7 @@ static inline int NCR5380_pwrite (struct Scsi_Host *instance, unsigned char *src for (; i; --i) { while (!(instance->base[T_STATUS_REG_OFFSET]) & T_ST_RDY) barrier(); #else - while (!(instance->base[T_STATUS_REG_OFFSET]) & T_ST_RDY) barrier(); + while (!((instance->base[T_STATUS_REG_OFFSET]) & T_ST_RDY)) barrier(); for (; i; --i) { #endif *reg = *s++; -- cgit v1.2.3 From e013a9371d567af6504ed38befb6e866faf7afe7 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Sun, 5 Jan 2014 14:22:15 +0100 Subject: linux: fix bit tests The pattern is !x&y. An expression of this form is almost always meaningless, because it combines a boolean operator with a bit operator. In particular, if the rightmost bit of y is 0, the result will always be 0. Fixed using coccinelle. // !x&y combines boolean negation with bitwise and // // Confidence: High // Copyright: (C) Gilles Muller, Julia Lawall, EMN, DIKU. GPLv2. // URL: http://www.emn.fr/x-info/coccinelle/rules/notand.html // Options: @@ expression E1,E2; @@ ( !E1 & !E2 | - !E1 & E2 + !(E1 & E2) ) * linux/src/drivers/scsi/FlashPoint.c: Fix bit tests. --- linux/src/drivers/scsi/FlashPoint.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/linux/src/drivers/scsi/FlashPoint.c b/linux/src/drivers/scsi/FlashPoint.c index 4b96a66c..8d2f1020 100644 --- a/linux/src/drivers/scsi/FlashPoint.c +++ b/linux/src/drivers/scsi/FlashPoint.c @@ -3756,17 +3756,17 @@ STATIC int SetDevSyncRate(PSCCBcard pCurrCard, PUCB p_ucb) } if(currTar_Info->TarEEValue && EE_SYNC_MASK == syncVal) return(0); - currTar_Info->TarEEValue = (currTar_Info->TarEEValue & !EE_SYNC_MASK) + currTar_Info->TarEEValue = (!(EE_SYNC_MASK & currTar_Info->TarEEValue)) | syncVal; syncOffset = (SYNC_RATE_TBL + scsiID) / 2; temp2.tempw = utilEERead(ioPort, syncOffset); if(scsiID & 0x01) { - temp2.tempb[0] = (temp2.tempb[0] & !EE_SYNC_MASK) | syncVal; + temp2.tempb[0] = (!(EE_SYNC_MASK & temp2.tempb[0])) | syncVal; } else { - temp2.tempb[1] = (temp2.tempb[1] & !EE_SYNC_MASK) | syncVal; + temp2.tempb[1] = (!(EE_SYNC_MASK & temp2.tempb[1])) | syncVal; } utilEEWriteOnOff(ioPort, 1); utilEEWrite(ioPort, temp2.tempw, syncOffset); @@ -3854,18 +3854,18 @@ int SetDevWideMode(PSCCBcard pCurrCard,PUCB p_ucb) scsiWideMode = 0; } } - currTar_Info->TarEEValue = (currTar_Info->TarEEValue & !EE_WIDE_SCSI) + currTar_Info->TarEEValue = (!(EE_WIDE_SCSI & currTar_Info->TarEEValue)) | scsiWideMode; syncOffset = (SYNC_RATE_TBL + scsiID) / 2; temp2.tempw = utilEERead(ioPort, syncOffset); if(scsiID & 0x01) { - temp2.tempb[0] = (temp2.tempb[0] & !EE_WIDE_SCSI) | scsiWideMode; + temp2.tempb[0] = (!(EE_WIDE_SCSI & temp2.tempb[0])) | scsiWideMode; } else { - temp2.tempb[1] = (temp2.tempb[1] & !EE_WIDE_SCSI) | scsiWideMode; + temp2.tempb[1] = (!(EE_WIDE_SCSI & temp2.tempb[1])) | scsiWideMode; } utilEEWriteOnOff(ioPort, 1); utilEEWrite(ioPort, temp2.tempw, syncOffset); -- cgit v1.2.3 From 069b4fb65ec13741c40356c16c312a50771fb589 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Sun, 5 Jan 2014 19:51:11 +0100 Subject: kern: explain the significance of the chosen length * kern/slab.h (KMEM_CACHE_NAME_SIZE): Explain the significance of the chosen length. --- kern/slab.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kern/slab.h b/kern/slab.h index a4219c42..fd658934 100644 --- a/kern/slab.h +++ b/kern/slab.h @@ -147,7 +147,9 @@ typedef vm_offset_t (*kmem_slab_alloc_fn_t)(vm_size_t); typedef void (*kmem_slab_free_fn_t)(vm_offset_t, vm_size_t); /* - * Cache name buffer size. + * Cache name buffer size. The size is chosen so that struct + * kmem_cache fits into two cache lines. The size of a cache line on + * a typical CPU is 64 bytes. */ #define KMEM_CACHE_NAME_SIZE 24 -- cgit v1.2.3 From 322fa73afed84fe37fb7bfe0583109ff33eb26d7 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Mon, 6 Jan 2014 00:31:16 +0100 Subject: kern: optimize the layout of struct kmem_cache * kern/slab.h (struct kmem_cache): Reorder the fields so that all hot fields are within the first cache line. --- kern/slab.h | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/kern/slab.h b/kern/slab.h index fd658934..457dee4c 100644 --- a/kern/slab.h +++ b/kern/slab.h @@ -157,6 +157,10 @@ typedef void (*kmem_slab_free_fn_t)(vm_offset_t, vm_size_t); * Cache of objects. * * Locking order : cpu_pool -> cache. CPU pools locking is ordered by CPU ID. + * + * Currently, SLAB_USE_CPU_POOLS is not defined. KMEM_CACHE_NAME_SIZE + * is chosen so that the struct fits into two cache lines. The first + * cache line contains all hot fields. */ struct kmem_cache { #if SLAB_USE_CPU_POOLS @@ -172,19 +176,21 @@ struct kmem_cache { struct list free_slabs; struct rbtree active_slabs; int flags; + size_t bufctl_dist; /* Distance from buffer to bufctl */ + size_t slab_size; + unsigned long bufs_per_slab; + unsigned long nr_objs; /* Number of allocated objects */ + unsigned long nr_free_slabs; + kmem_cache_ctor_t ctor; + /* All fields below are cold */ size_t obj_size; /* User-provided size */ + /* Assuming ! SLAB_USE_CPU_POOLS, here is the cacheline boundary */ size_t align; size_t buf_size; /* Aligned object size */ - size_t bufctl_dist; /* Distance from buffer to bufctl */ - size_t slab_size; size_t color; size_t color_max; - unsigned long bufs_per_slab; - unsigned long nr_objs; /* Number of allocated objects */ unsigned long nr_bufs; /* Total number of buffers */ unsigned long nr_slabs; - unsigned long nr_free_slabs; - kmem_cache_ctor_t ctor; kmem_slab_alloc_fn_t slab_alloc_fn; kmem_slab_free_fn_t slab_free_fn; char name[KMEM_CACHE_NAME_SIZE]; -- cgit v1.2.3 From 79ed64e24d2276a9a28ec9c3e0eedd23812c93da Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Tue, 7 Jan 2014 13:15:51 +0100 Subject: include: add new file for cache-related definitions * include/cache.h (__cacheline_aligned): This macro can be used to align statically allocated objects so that they start at a cache line. --- include/cache.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 include/cache.h diff --git a/include/cache.h b/include/cache.h new file mode 100644 index 00000000..6260366a --- /dev/null +++ b/include/cache.h @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2013 Free Software Foundation. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef _MACH_CACHE_H_ +#define _MACH_CACHE_H_ + +/* This macro can be used to align statically allocated objects so + that they start at a cache line. */ +#define __cacheline_aligned __attribute__((aligned(1 << CPU_L1_SHIFT))) + +#endif /* _MACH_CACHE_H_ */ -- cgit v1.2.3 From 84c4437004d9c4767da56500661f49afe4582658 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Thu, 9 Jan 2014 12:05:01 +0100 Subject: kern: align kmem_cache objects using __cacheline_aligned * kern/slab.h (struct kmem_cache): Align kmem_cache objects using __cacheline_aligned. --- kern/slab.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kern/slab.h b/kern/slab.h index 457dee4c..c7be1692 100644 --- a/kern/slab.h +++ b/kern/slab.h @@ -47,6 +47,7 @@ #ifndef _KERN_SLAB_H #define _KERN_SLAB_H +#include #include #include #include @@ -196,7 +197,7 @@ struct kmem_cache { char name[KMEM_CACHE_NAME_SIZE]; size_t buftag_dist; /* Distance from buffer to buftag */ size_t redzone_pad; /* Bytes from end of object to redzone word */ -}; +} __cacheline_aligned; /* * Mach-style declarations for struct kmem_cache. -- cgit v1.2.3 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 3de69969..dc0ea747 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 37d4eb99..13af8202 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 af59d5ac..ea78d482 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 8b4e7606..0f8b3281 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 13b3c761..0b5a6f7f 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 e8520331..7ae10cde 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 fbc5e696..13572a1c 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 f60125a0..d24b6f93 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 5d4efcde..9c7d1fde 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 From a693305ea05c405fe05b09061eee1fafc08d9e30 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Tue, 4 Feb 2014 12:50:25 +0100 Subject: Add missing break Found by Coverity * i386/i386at/kd_mouse.c (mouseopen): Add missing break. --- i386/i386at/kd_mouse.c | 1 + 1 file changed, 1 insertion(+) diff --git a/i386/i386at/kd_mouse.c b/i386/i386at/kd_mouse.c index ef399a55..da6f57f2 100644 --- a/i386/i386at/kd_mouse.c +++ b/i386/i386at/kd_mouse.c @@ -162,6 +162,7 @@ mouseopen(dev, flags) mousebufsize = 3; serial_mouse_open(dev); init_mouse_hw(dev&7, LC7); + breka; case MICROSOFT_MOUSE: mousebufsize = 3; serial_mouse_open(dev); -- cgit v1.2.3 From 03c81daf88237a9d32858310d597729ca923db61 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Tue, 4 Feb 2014 13:03:25 +0100 Subject: Fix typo * i386/i386at/kd_mouse.c (mouseopen): Fix typo. --- i386/i386at/kd_mouse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i386/i386at/kd_mouse.c b/i386/i386at/kd_mouse.c index da6f57f2..d09d7a71 100644 --- a/i386/i386at/kd_mouse.c +++ b/i386/i386at/kd_mouse.c @@ -162,7 +162,7 @@ mouseopen(dev, flags) mousebufsize = 3; serial_mouse_open(dev); init_mouse_hw(dev&7, LC7); - breka; + break; case MICROSOFT_MOUSE: mousebufsize = 3; serial_mouse_open(dev); -- cgit v1.2.3 From a9f5cf5d2ff55abdd05a2ab6965d8b4ba190eac9 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Tue, 4 Feb 2014 13:03:48 +0100 Subject: Fix FPU state access Found by coverity. * i386/i386/fpu.c (fpu_set_state, fpu_get_state): Fix out of bound `user_fp_regs' access. --- i386/i386/fpu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/i386/i386/fpu.c b/i386/i386/fpu.c index fd5f4b6d..62a4e675 100644 --- a/i386/i386/fpu.c +++ b/i386/i386/fpu.c @@ -374,7 +374,7 @@ ASSERT_IPL(SPL0); ifps->xfp_save_state.fp_dp = user_fp_state->fp_dp; ifps->xfp_save_state.fp_ds = user_fp_state->fp_ds; for (i=0; i<8; i++) - memcpy(&ifps->xfp_save_state.fp_reg_word[i], &user_fp_regs[i], sizeof(user_fp_regs[i])); + memcpy(&ifps->xfp_save_state.fp_reg_word[i], &user_fp_regs->fp_reg_word[i], sizeof(user_fp_regs[i])); } else { ifps->fp_save_state.fp_control = user_fp_state->fp_control; ifps->fp_save_state.fp_status = user_fp_state->fp_status; @@ -467,7 +467,7 @@ ASSERT_IPL(SPL0); user_fp_state->fp_dp = ifps->xfp_save_state.fp_dp; user_fp_state->fp_ds = ifps->xfp_save_state.fp_ds; for (i=0; i<8; i++) - memcpy(&user_fp_regs[i], &ifps->xfp_save_state.fp_reg_word[i], sizeof(user_fp_regs[i])); + memcpy(&user_fp_regs->fp_reg_word[i], &ifps->xfp_save_state.fp_reg_word[i], sizeof(user_fp_regs[i])); } else { user_fp_state->fp_control = ifps->fp_save_state.fp_control; user_fp_state->fp_status = ifps->fp_save_state.fp_status; -- cgit v1.2.3 From 1046eda445bb33249555cf186344ffb3431e6478 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Tue, 4 Feb 2014 13:11:24 +0100 Subject: Make empty while loops more prominent * i386/i386at/kd.c (kdintr, kd_senddata, kd_sendcmd, kd_getgata, kd_cmdreg_read, kd_cmdreg_write, kd_mouse_drain): Move semi colon of empty while loops on a single line to make it more visible. --- i386/i386at/kd.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/i386/i386at/kd.c b/i386/i386at/kd.c index f70175cb..d6b75af4 100644 --- a/i386/i386at/kd.c +++ b/i386/i386at/kd.c @@ -738,7 +738,8 @@ int vec; tp = &kd_tty; #ifdef old - while ((inb(K_STATUS) & K_OBUF_FUL) == 0); /* this should never loop */ + while ((inb(K_STATUS) & K_OBUF_FUL) == 0) + ; /* this should never loop */ #else /* old */ { /* @@ -2232,7 +2233,8 @@ void kd_senddata(ch) unsigned char ch; { - while (inb(K_STATUS) & K_IBUF_FUL); + while (inb(K_STATUS) & K_IBUF_FUL) + ; outb(K_RDWR, ch); last_sent = ch; return; @@ -2250,7 +2252,8 @@ void kd_sendcmd(ch) unsigned char ch; { - while (inb(K_STATUS) & K_IBUF_FUL); + while (inb(K_STATUS) & K_IBUF_FUL) + ; outb(K_CMD, ch); return; } @@ -2266,7 +2269,8 @@ unsigned char ch; unsigned char kd_getdata(void) { - while ((inb(K_STATUS) & K_OBUF_FUL) == 0); + while ((inb(K_STATUS) & K_OBUF_FUL) == 0) + ; return(inb(K_RDWR)); } @@ -2275,10 +2279,12 @@ kd_cmdreg_read(void) { int ch=KC_CMD_READ; - while (inb(K_STATUS) & K_IBUF_FUL); + while (inb(K_STATUS) & K_IBUF_FUL) + ; outb(K_CMD, ch); - while ((inb(K_STATUS) & K_OBUF_FUL) == 0); + while ((inb(K_STATUS) & K_OBUF_FUL) == 0) + ; return(inb(K_RDWR)); } @@ -2287,10 +2293,12 @@ kd_cmdreg_write(int val) { int ch=KC_CMD_WRITE; - while (inb(K_STATUS) & K_IBUF_FUL); + while (inb(K_STATUS) & K_IBUF_FUL) + ; outb(K_CMD, ch); - while (inb(K_STATUS) & K_IBUF_FUL); + while (inb(K_STATUS) & K_IBUF_FUL) + ; outb(K_RDWR, val); } @@ -2298,7 +2306,8 @@ void kd_mouse_drain(void) { int i; - while(inb(K_STATUS) & K_IBUF_FUL); + while(inb(K_STATUS) & K_IBUF_FUL) + ; while((i = inb(K_STATUS)) & K_OBUF_FUL) printf("kbd: S = %x D = %x\n", i, inb(K_RDWR)); } -- cgit v1.2.3 From a7fcd5dfaad27dc33c1c1e22ebef2ded8d53b5a0 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Tue, 4 Feb 2014 13:20:15 +0100 Subject: Fix FPU state copy size * i386/i386/fpu.c (fpu_set_state, fpu_get_state): Fix size of `user_fp_regs' access. --- i386/i386/fpu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/i386/i386/fpu.c b/i386/i386/fpu.c index 62a4e675..cd90ee9f 100644 --- a/i386/i386/fpu.c +++ b/i386/i386/fpu.c @@ -374,7 +374,7 @@ ASSERT_IPL(SPL0); ifps->xfp_save_state.fp_dp = user_fp_state->fp_dp; ifps->xfp_save_state.fp_ds = user_fp_state->fp_ds; for (i=0; i<8; i++) - memcpy(&ifps->xfp_save_state.fp_reg_word[i], &user_fp_regs->fp_reg_word[i], sizeof(user_fp_regs[i])); + memcpy(&ifps->xfp_save_state.fp_reg_word[i], &user_fp_regs->fp_reg_word[i], sizeof(user_fp_regs->fp_reg_word[i])); } else { ifps->fp_save_state.fp_control = user_fp_state->fp_control; ifps->fp_save_state.fp_status = user_fp_state->fp_status; @@ -467,7 +467,7 @@ ASSERT_IPL(SPL0); user_fp_state->fp_dp = ifps->xfp_save_state.fp_dp; user_fp_state->fp_ds = ifps->xfp_save_state.fp_ds; for (i=0; i<8; i++) - memcpy(&user_fp_regs->fp_reg_word[i], &ifps->xfp_save_state.fp_reg_word[i], sizeof(user_fp_regs[i])); + memcpy(&user_fp_regs->fp_reg_word[i], &ifps->xfp_save_state.fp_reg_word[i], sizeof(user_fp_regs->fp_reg_word[i])); } else { user_fp_state->fp_control = ifps->fp_save_state.fp_control; user_fp_state->fp_status = ifps->fp_save_state.fp_status; -- cgit v1.2.3 From 80d642898f5a95025afd3e5ee70e01cce0857845 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Tue, 4 Feb 2014 11:38:04 +0100 Subject: kern: use kmem_warn instead of kmem_error in kmem_cache_error * kern/slab.c (kmem_cache_error): Use kmem_warn instead of kmem_error to print the cache name and its address. --- kern/slab.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kern/slab.c b/kern/slab.c index d1e3632a..adf07e78 100644 --- a/kern/slab.c +++ b/kern/slab.c @@ -662,7 +662,7 @@ static void kmem_cache_error(struct kmem_cache *cache, void *buf, int error, { struct kmem_buftag *buftag; - kmem_error("cache: %s, buffer: %p", cache->name, (void *)buf); + kmem_warn("cache: %s, buffer: %p", cache->name, (void *)buf); switch(error) { case KMEM_ERR_INVALID: -- cgit v1.2.3 From d7b113dced48aaaba6db262db2ed420b47917896 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Tue, 4 Feb 2014 11:39:23 +0100 Subject: kern: make kmem_error panic The slab allocator relies on the fact that kmem_cache_error does not return. Previously, kmem_error was using printf. Use panic instead. Found using the Clang Static Analyzer. * kern/slab.c (kmem_error): Use panic instead of printf. --- kern/slab.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kern/slab.c b/kern/slab.c index adf07e78..f40afa11 100644 --- a/kern/slab.c +++ b/kern/slab.c @@ -289,8 +289,8 @@ vm_map_t kmem_map = &kmem_map_store; static unsigned long kmem_gc_last_tick; #define kmem_error(format, ...) \ - printf("mem: error: %s(): " format "\n", __func__, \ - ## __VA_ARGS__) + panic("mem: error: %s(): " format "\n", __func__, \ + ## __VA_ARGS__) #define kmem_warn(format, ...) \ printf("mem: warning: %s(): " format "\n", __func__, \ -- cgit v1.2.3 From 172f3ea324a3685a62b03edd8b03e5f09e265301 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Tue, 4 Feb 2014 11:43:41 +0100 Subject: ddb: safely copy symbol names into the symtab structure Use strncpy instead of strcpy to copy the name of a symbol into the symtab structure. Make sure that the string is properly terminated. Found using Coverity. * ddb/db_sym.c (db_add_symbol_table): Use strncpy instead of strcpy, ensure string termination. --- ddb/db_sym.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ddb/db_sym.c b/ddb/db_sym.c index beb4d18e..3c8caf49 100644 --- a/ddb/db_sym.c +++ b/ddb/db_sym.c @@ -75,7 +75,8 @@ db_add_symbol_table(type, start, end, name, ref, map_pointer) st->end = end; st->private = ref; st->map_pointer = (map_pointer == (char *)kernel_map)? 0: map_pointer; - strcpy(st->name, name); + strncpy(st->name, name, sizeof st->name - 1); + st->name[sizeof st->name - 1] = '\0'; db_nsymtab++; -- cgit v1.2.3 From 03df518586e3cfd106eb20827781f12a0596e48c Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Tue, 4 Feb 2014 11:47:00 +0100 Subject: xen: fix buffer size Previously, only strlen(device_name) bytes were allocated, missing one byte for the terminating zero. * xen/block.c (hyp_block_init): Fix buffer size. --- xen/block.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/block.c b/xen/block.c index 3e4ce7c6..bd3758f9 100644 --- a/xen/block.c +++ b/xen/block.c @@ -217,7 +217,7 @@ void hyp_block_init(void) { sprintf(device_name, "%s%ds%d", prefix, disk, partition); else sprintf(device_name, "%s%d", prefix, disk); - bd->name = (char*) kalloc(strlen(device_name)); + bd->name = (char*) kalloc(strlen(device_name) + 1); strcpy(bd->name, device_name); /* Get domain id of backend driver. */ -- cgit v1.2.3 From 9a54b8d78e9d63987379206a0cbc856c46a2ef44 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Tue, 4 Feb 2014 18:52:05 +0100 Subject: Fix potential NULL dereference Found by Coverity. * i386/i386at/com.c (comopen): On com_reprobe() returning success, check for `isai' again. --- i386/i386at/com.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/i386/i386at/com.c b/i386/i386at/com.c index 8f293afa..e1ba71a9 100644 --- a/i386/i386at/com.c +++ b/i386/i386at/com.c @@ -338,6 +338,8 @@ io_return_t comopen( */ if (!com_reprobe(unit)) return D_NO_SUCH_DEVICE; + if ((isai = cominfo[unit]) == 0 || isai->alive == 0) + return D_NO_SUCH_DEVICE; } tp = &com_tty[unit]; -- cgit v1.2.3 From d1435c2e91ed9146acd4b0d10e6a892dc79e67be Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Tue, 4 Feb 2014 18:55:14 +0100 Subject: Fix potential NULL dereference Found by Coverity * i386/i386/db_trace.c (db_find_kthread): Handle case when task is NULL. --- i386/i386/db_trace.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/i386/i386/db_trace.c b/i386/i386/db_trace.c index 0f0bbdcc..cdebde18 100644 --- a/i386/i386/db_trace.c +++ b/i386/i386/db_trace.c @@ -533,6 +533,8 @@ db_find_kthread( task_t task) { thread_t thread; + if (task == TASK_NULL) + task = db_current_task(); queue_iterate(&task->thread_list, thread, thread_t, thread_list) { vm_offset_t usp = thread->pcb->iss.uesp/*ebp works*/; -- cgit v1.2.3 From 3bc572030b864b2ef922325b7e4ed85a7c178200 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Tue, 4 Feb 2014 19:06:01 +0100 Subject: Fix potential NULL dereference * vm/vm_kern.c (projected_buffer_deallocate): Look for `map' being NULL or kernel_map before locking it. --- vm/vm_kern.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/vm/vm_kern.c b/vm/vm_kern.c index 1c843ffe..62edbc53 100644 --- a/vm/vm_kern.c +++ b/vm/vm_kern.c @@ -256,9 +256,11 @@ projected_buffer_deallocate(map, start, end) { vm_map_entry_t entry, k_entry; + if (map == VM_MAP_NULL || map == kernel_map) + return KERN_INVALID_ARGUMENT; + vm_map_lock(map); - if (map == VM_MAP_NULL || map == kernel_map || - !vm_map_lookup_entry(map, start, &entry) || + if (!vm_map_lookup_entry(map, start, &entry) || end > entry->vme_end || /*Check corresponding kernel entry*/ (k_entry = entry->projected_on) == 0) { -- cgit v1.2.3 From e6f93609728d0ad864fc2d7dacd9df128eccd37a Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Tue, 4 Feb 2014 19:07:47 +0100 Subject: Fix potential NULL dereference Found by Coverity * i386/i386/user_ldt.c (i386_get_ldt): Fetch `pcb' field of `thread' only after looking for `thread' being NULL. --- i386/i386/user_ldt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/i386/i386/user_ldt.c b/i386/i386/user_ldt.c index a83bc122..3a2c1cc4 100644 --- a/i386/i386/user_ldt.c +++ b/i386/i386/user_ldt.c @@ -262,7 +262,7 @@ i386_get_ldt(thread, first_selector, selector_count, desc_list, count) unsigned int *count; /* in/out */ { struct user_ldt *user_ldt; - pcb_t pcb = thread->pcb; + pcb_t pcb; int first_desc = sel_idx(first_selector); unsigned int ldt_count; vm_size_t ldt_size; @@ -276,6 +276,7 @@ i386_get_ldt(thread, first_selector, selector_count, desc_list, count) if (first_desc + selector_count >= 8192) return KERN_INVALID_ARGUMENT; + pcb = thread->pcb; addr = 0; size = 0; -- cgit v1.2.3 From 32dcfafb3b8cdc22641254d50571b8be1d33fae3 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Tue, 4 Feb 2014 19:18:54 +0100 Subject: Fix comstart when the queue is empty Found by Coverity * i386/i386at/com.c (comstart): Make `nch' an int. When `getc' returns -1, just return. --- i386/i386at/com.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/i386/i386at/com.c b/i386/i386at/com.c index e1ba71a9..6edbca08 100644 --- a/i386/i386at/com.c +++ b/i386/i386at/com.c @@ -618,7 +618,7 @@ void comstart(tp) struct tty *tp; { - char nch; + int nch; #if 0 int i; #endif @@ -654,6 +654,8 @@ comst_4++; } #else nch = getc(&tp->t_outq); + if (nch == -1) + return; if ((nch & 0200) && ((tp->t_flags & LITOUT) == 0)) { timeout((timer_func_t *)ttrstrt, (char *)tp, (nch & 0x7f) + 6); tp->t_state |= TS_TIMEOUT; -- cgit v1.2.3 From de74f85990dc39bc6723f046f83d4e53c45f4343 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Sat, 1 Feb 2014 02:23:07 +0100 Subject: kern: implement task_set_name task_set_name sets the name of a task. This is a debugging aid. The name will be used in error messages printed by the kernel. * kern/task.c (task_set_name): New function. * kern/task.h (task_set_name): New declaration. --- kern/task.c | 17 +++++++++++++++++ kern/task.h | 4 ++++ 2 files changed, 21 insertions(+) diff --git a/kern/task.c b/kern/task.c index 0b5a6f7f..66eb25ce 100644 --- a/kern/task.c +++ b/kern/task.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -1070,6 +1071,22 @@ task_priority( return ret; } +/* + * task_set_name + * + * Set the name of task TASK to NAME. This is a debugging aid. + * NAME will be used in error messages printed by the kernel. + */ +kern_return_t +task_set_name( + task_t task, + kernel_debug_name_t name) +{ + strncpy(task->name, name, sizeof task->name - 1); + task->name[sizeof task->name - 1] = '\0'; + return KERN_SUCCESS; +} + /* * task_collect_scan: * diff --git a/kern/task.h b/kern/task.h index 7ae10cde..3c10dc0c 100644 --- a/kern/task.h +++ b/kern/task.h @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -169,6 +170,9 @@ extern kern_return_t task_assign( extern kern_return_t task_assign_default( task_t task, boolean_t assign_threads); +extern kern_return_t task_set_name( + task_t task, + kernel_debug_name_t name); extern void consider_task_collect(void); /* -- cgit v1.2.3 From 877a319c94619e51a0103b9f201523b269588eb0 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Sat, 1 Feb 2014 02:25:45 +0100 Subject: include: add task_set_name task_set_name sets the name of a task. This is a debugging aid. The name will be used in error messages printed by the kernel. * include/mach/gnumach.defs (task_set_name): New procedure. --- include/mach/gnumach.defs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/mach/gnumach.defs b/include/mach/gnumach.defs index 12c4e994..6cfbb0d0 100644 --- a/include/mach/gnumach.defs +++ b/include/mach/gnumach.defs @@ -27,6 +27,7 @@ subsystem #include #include +#include type vm_cache_statistics_data_t = struct[11] of integer_t; @@ -63,3 +64,11 @@ simpleroutine thread_terminate_release( reply_port : mach_port_name_t; address : vm_address_t; size : vm_size_t); + +/* + * Set the name of task TASK to NAME. This is a debugging aid. + * NAME will be used in error messages printed by the kernel. + */ +simpleroutine task_set_name( + task : task_t; + name : kernel_debug_name_t); -- cgit v1.2.3 From 61104ec0056504e675d7096e23c9de3f7fdda2ff Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Sat, 1 Feb 2014 15:05:58 +0100 Subject: doc: document task_set_name * doc/mach.texi (Task Information): Document the new task_set_name procedure. --- doc/mach.texi | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/doc/mach.texi b/doc/mach.texi index 9ad9e70b..d089224d 100644 --- a/doc/mach.texi +++ b/doc/mach.texi @@ -5037,6 +5037,17 @@ total system run time for live threads This is a pointer to a @code{struct task_thread_times_info}. @end deftp +@deftypefun kern_return_t task_set_name (@w{task_t @var{target_task}}, @w{kernel_debug_name_t @var{name}}) + +The function @code{task_set_name} sets the name of @var{target_task} +to @var{name}, truncating it if necessary. + +This is a debugging aid. The name is used in diagnostic messages +printed by the kernel. + +The function returns @code{KERN_SUCCESS} if the call succeeded. +@end deftypefun + @node Task Execution @subsection Task Execution -- cgit v1.2.3 From e5b90c13cb7d762a52f81c110ca5cc53eb16ac7b Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Wed, 5 Feb 2014 14:50:27 +0100 Subject: Remove duplicate typedef * device/net_io.c (net_rcv_port_t, net_hash_entry_t, net_hash_header_t): Remove duplicate typedefs. --- device/net_io.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/device/net_io.c b/device/net_io.c index 68dcc096..e758f2d6 100644 --- a/device/net_io.c +++ b/device/net_io.c @@ -301,7 +301,6 @@ struct net_rcv_port { filter_t filter[NET_MAX_FILTER]; /* filter operations */ }; -typedef struct net_rcv_port *net_rcv_port_t; struct kmem_cache net_rcv_cache; /* cache of net_rcv_port structs */ @@ -320,7 +319,6 @@ struct net_hash_entry { int rcv_qlimit; /* qlimit for the port */ unsigned int keys[N_NET_HASH_KEYS]; }; -typedef struct net_hash_entry *net_hash_entry_t; struct kmem_cache net_hash_entry_cache; @@ -339,8 +337,6 @@ struct net_hash_header { net_hash_entry_t table[NET_HASH_SIZE]; } filter_hash_header[N_NET_HASH]; -typedef struct net_hash_header *net_hash_header_t; - decl_simple_lock_data(,net_hash_header_lock) #define HASH_ITERATE(head, elt) (elt) = (net_hash_entry_t) (head); do { -- cgit v1.2.3 From 134d5b6b353d438961bf989a823fed5e4793854f Mon Sep 17 00:00:00 2001 From: Richard Braun Date: Thu, 6 Feb 2014 00:41:06 +0100 Subject: vm: trigger garbage collection on kernel memory pressure In addition to physical pages, the slab allocator also consumes kernel virtual memory, so reclaim pages on failure to allocate from a kernel map. This method isn't foolproof but helps alleviate fragmentation. * vm/vm_kern.c (kmem_alloc): Call slab_collect and retry allocation once on failure. (kmem_realloc): Likewise. (kmem_alloc_wired): Likewise. (kmem_alloc_wired): Likewise. (kmem_alloc_aligned): Likewise. --- vm/vm_kern.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 48 insertions(+), 3 deletions(-) diff --git a/vm/vm_kern.c b/vm/vm_kern.c index 62edbc53..3eaf0a81 100644 --- a/vm/vm_kern.c +++ b/vm/vm_kern.c @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -366,6 +367,7 @@ kmem_alloc(map, addrp, size) vm_object_t object; vm_map_entry_t entry; vm_offset_t addr; + unsigned int attempts; kern_return_t kr; /* @@ -384,12 +386,22 @@ kmem_alloc(map, addrp, size) size = round_page(size); object = vm_object_allocate(size); + attempts = 0; + +retry: vm_map_lock(map); kr = vm_map_find_entry(map, &addr, size, (vm_offset_t) 0, VM_OBJECT_NULL, &entry); if (kr != KERN_SUCCESS) { - printf_once("no more room for kmem_alloc in %p\n", map); vm_map_unlock(map); + + if (attempts == 0) { + attempts++; + slab_collect(); + goto retry; + } + + printf_once("no more room for kmem_alloc in %p\n", map); vm_object_deallocate(object); return kr; } @@ -439,6 +451,7 @@ kern_return_t kmem_realloc(map, oldaddr, oldsize, newaddrp, newsize) vm_offset_t newaddr; vm_object_t object; vm_map_entry_t oldentry, newentry; + unsigned int attempts; kern_return_t kr; oldmin = trunc_page(oldaddr); @@ -450,11 +463,21 @@ kern_return_t kmem_realloc(map, oldaddr, oldsize, newaddrp, newsize) * Find space for the new region. */ + attempts = 0; + +retry: vm_map_lock(map); kr = vm_map_find_entry(map, &newaddr, newsize, (vm_offset_t) 0, VM_OBJECT_NULL, &newentry); if (kr != KERN_SUCCESS) { vm_map_unlock(map); + + if (attempts == 0) { + attempts++; + slab_collect(); + goto retry; + } + printf_once("no more room for kmem_realloc in %p\n", map); return kr; } @@ -526,6 +549,7 @@ kmem_alloc_wired(map, addrp, size) vm_map_entry_t entry; vm_offset_t offset; vm_offset_t addr; + unsigned int attempts; kern_return_t kr; /* @@ -536,12 +560,22 @@ kmem_alloc_wired(map, addrp, size) */ size = round_page(size); + attempts = 0; + +retry: vm_map_lock(map); kr = vm_map_find_entry(map, &addr, size, (vm_offset_t) 0, kernel_object, &entry); if (kr != KERN_SUCCESS) { - printf_once("no more room for kmem_alloc_wired in %p\n", map); vm_map_unlock(map); + + if (attempts == 0) { + attempts++; + slab_collect(); + goto retry; + } + + printf_once("no more room for kmem_alloc_wired in %p\n", map); return kr; } @@ -598,6 +632,7 @@ kmem_alloc_aligned(map, addrp, size) vm_map_entry_t entry; vm_offset_t offset; vm_offset_t addr; + unsigned int attempts; kern_return_t kr; if ((size & (size - 1)) != 0) @@ -611,12 +646,22 @@ kmem_alloc_aligned(map, addrp, size) */ size = round_page(size); + attempts = 0; + +retry: vm_map_lock(map); kr = vm_map_find_entry(map, &addr, size, size - 1, kernel_object, &entry); if (kr != KERN_SUCCESS) { - printf_once("no more rooom for kmem_alloc_aligned in %p\n", map); vm_map_unlock(map); + + if (attempts == 0) { + attempts++; + slab_collect(); + goto retry; + } + + printf_once("no more rooom for kmem_alloc_aligned in %p\n", map); return kr; } -- cgit v1.2.3 From abb50be5ea5c374cdb25f05eafdf8afac9b854b1 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Mon, 10 Feb 2014 00:04:34 +0100 Subject: Add quiet flag to block I/O This avoids grub & such making Mach print flurries of floppy errors. * linux/dev/include/linux/blkdev.h (request): Add `quiet' field. * linux/dev/include/linux/blk.h (end_request): Print I/O error only if the `quiet' field of the request is 0. * linux/dev/include/linux/fs.h (ll_rw_block): Add `quiet' parameter. * linux/dev/glue/block.c (ll_rw_block): Add `quiet' parameter, copied into the request. (bread, rdwr_partial, rdwr_full): Pass 0 to `ll_rw_block''s `quiet' parameter. * linux/dev/drivers/block/floppy.c (floppy_revalidate): Pass 1 to `ll_rw_block''s `quiet' parameter. --- linux/dev/drivers/block/floppy.c | 2 +- linux/dev/glue/block.c | 11 ++++++----- linux/dev/include/linux/blk.h | 5 +++-- linux/dev/include/linux/blkdev.h | 1 + linux/dev/include/linux/fs.h | 2 +- 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/linux/dev/drivers/block/floppy.c b/linux/dev/drivers/block/floppy.c index 4c0977a3..83d66f05 100644 --- a/linux/dev/drivers/block/floppy.c +++ b/linux/dev/drivers/block/floppy.c @@ -3723,7 +3723,7 @@ static int floppy_revalidate(kdev_t dev) return 1; } if (bh && !buffer_uptodate(bh)) - ll_rw_block(READ, 1, &bh); + ll_rw_block(READ, 1, &bh, 1); process_fd_request(); wait_on_buffer(bh); brelse(bh); diff --git a/linux/dev/glue/block.c b/linux/dev/glue/block.c index 011b6f56..ce4c633d 100644 --- a/linux/dev/glue/block.c +++ b/linux/dev/glue/block.c @@ -384,7 +384,7 @@ bread (kdev_t dev, int block, int size) bh = getblk (dev, block, size); if (bh) { - ll_rw_block (READ, 1, &bh); + ll_rw_block (READ, 1, &bh, 0); wait_on_buffer (bh); if (! buffer_uptodate (bh)) { @@ -444,7 +444,7 @@ enqueue_request (struct request *req) /* Perform the I/O operation RW on the buffer list BH containing NR buffers. */ void -ll_rw_block (int rw, int nr, struct buffer_head **bh) +ll_rw_block (int rw, int nr, struct buffer_head **bh, int quiet) { int i, bshift, bsize; unsigned major; @@ -476,6 +476,7 @@ ll_rw_block (int rw, int nr, struct buffer_head **bh) r->rq_dev = bh[0]->b_dev; r->cmd = rw; r->errors = 0; + r->quiet = quiet; r->sector = bh[0]->b_blocknr << (bshift - 9); r->current_nr_sectors = bh[0]->b_size >> 9; r->buffer = bh[0]->b_data; @@ -528,7 +529,7 @@ rdwr_partial (int rw, kdev_t dev, loff_t *off, bh->b_data = alloc_buffer (bh->b_size); if (! bh->b_data) return -ENOMEM; - ll_rw_block (READ, 1, &bh); + ll_rw_block (READ, 1, &bh, 0); wait_on_buffer (bh); if (buffer_uptodate (bh)) { @@ -542,7 +543,7 @@ rdwr_partial (int rw, kdev_t dev, loff_t *off, { memcpy (bh->b_data + o, *buf, c); bh->b_state = (1 << BH_Dirty) | (1 << BH_Lock); - ll_rw_block (WRITE, 1, &bh); + ll_rw_block (WRITE, 1, &bh, 0); wait_on_buffer (bh); if (! buffer_uptodate (bh)) { @@ -623,7 +624,7 @@ rdwr_full (int rw, kdev_t dev, loff_t *off, char **buf, int *resid, int bshift) } if (! err) { - ll_rw_block (rw, i, bhp); + ll_rw_block (rw, i, bhp, 0); wait_on_buffer (bhp[i - 1]); } for (bh = bhead, cc = 0, j = 0; j < i; cc += bh->b_size, bh++, j++) diff --git a/linux/dev/include/linux/blk.h b/linux/dev/include/linux/blk.h index 412b8641..156d91c4 100644 --- a/linux/dev/include/linux/blk.h +++ b/linux/dev/include/linux/blk.h @@ -391,8 +391,9 @@ static void end_request(int uptodate) { req->errors = 0; if (!uptodate) { - printk("end_request: I/O error, dev %s, sector %lu\n", - kdevname(req->rq_dev), req->sector); + if (!req->quiet) + printk("end_request: I/O error, dev %s, sector %lu\n", + kdevname(req->rq_dev), req->sector); #ifdef MACH for (bh = req->bh; bh; ) { diff --git a/linux/dev/include/linux/blkdev.h b/linux/dev/include/linux/blkdev.h index e9a40d7e..5bf0a288 100644 --- a/linux/dev/include/linux/blkdev.h +++ b/linux/dev/include/linux/blkdev.h @@ -23,6 +23,7 @@ struct request { kdev_t rq_dev; int cmd; /* READ or WRITE */ int errors; + int quiet; unsigned long sector; unsigned long nr_sectors; unsigned long current_nr_sectors; diff --git a/linux/dev/include/linux/fs.h b/linux/dev/include/linux/fs.h index 740ebb54..37f7173f 100644 --- a/linux/dev/include/linux/fs.h +++ b/linux/dev/include/linux/fs.h @@ -733,7 +733,7 @@ extern struct file * get_empty_filp(void); extern int close_fp(struct file *filp); extern struct buffer_head * get_hash_table(kdev_t dev, int block, int size); extern struct buffer_head * getblk(kdev_t dev, int block, int size); -extern void ll_rw_block(int rw, int nr, struct buffer_head * bh[]); +extern void ll_rw_block(int rw, int nr, struct buffer_head * bh[], int quiet); extern void ll_rw_page(int rw, kdev_t dev, unsigned long nr, char * buffer); extern void ll_rw_swap_file(int rw, kdev_t dev, unsigned int *b, int nb, char *buffer); extern int is_read_only(kdev_t dev); -- cgit v1.2.3 From 219ad2d6c3aa7574ed2e250b305b12a35eec24b3 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Mon, 10 Feb 2014 00:18:03 +0100 Subject: Add missing initialization * linux/src/drivers/block/ide.c (ide_init_drive_cmd): Initialize `quiet' field of request to 0; --- linux/src/drivers/block/ide.c | 1 + 1 file changed, 1 insertion(+) diff --git a/linux/src/drivers/block/ide.c b/linux/src/drivers/block/ide.c index 0f3fd01f..9b9ecc2d 100644 --- a/linux/src/drivers/block/ide.c +++ b/linux/src/drivers/block/ide.c @@ -1927,6 +1927,7 @@ void ide_init_drive_cmd (struct request *rq) rq->rq_status = RQ_ACTIVE; rq->rq_dev = ????; #endif + rq->quiet = 0; } /* -- cgit v1.2.3 From 55cdcf3ad3ebec3d9899130fe435a59f8e9e1617 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Mon, 10 Feb 2014 00:19:30 +0100 Subject: Add quiet flag to CD I/O * linux/src/drivers/block/ide-cd.c (cdrom_queue_packet_command): Add `quiet' parameter, copied into the request. (cdrom_decode_status): Do not print I/O error when `quiet' field of request is non-zero. (cdrom_end_request): Do not print sense results when `quiet' field of request is non-zero. (cdrom_check_status, cdrom_read_capacity, cdrom_read_tocentry): Pass 1 to `cdrom_queue_packet_command''s `quiet' parameter. (cdrom_lockdoor, cdrom_eject, cdrom_pause, cdrom_startstop, cdrom_read_subchannel, cdrom_mode_sense, cdrom_mode_select, cdrom_play_lba_range_1, cdrom_read_block, cdrom_load_unload, ide_cdrom_ioctl): Pass 0 to `cdrom_queue_packet_command''s `quiet' parameter. --- linux/src/drivers/block/ide-cd.c | 47 ++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/linux/src/drivers/block/ide-cd.c b/linux/src/drivers/block/ide-cd.c index e4548f54..ccf79542 100644 --- a/linux/src/drivers/block/ide-cd.c +++ b/linux/src/drivers/block/ide-cd.c @@ -649,7 +649,7 @@ static void cdrom_end_request (int uptodate, ide_drive_t *drive) { struct request *rq = HWGROUP(drive)->rq; - if (rq->cmd == REQUEST_SENSE_COMMAND && uptodate) { + if (rq->cmd == REQUEST_SENSE_COMMAND && uptodate && !rq->quiet) { struct packet_command *pc = (struct packet_command *) rq->buffer; cdrom_analyze_sense_data (drive, @@ -727,16 +727,18 @@ static int cdrom_decode_status (ide_drive_t *drive, int good_stat, because workman constantly polls the drive with this command, and we don't want to uselessly fill up the syslog. */ - if (pc->c[0] != SCMD_READ_SUBCHANNEL) + if (pc->c[0] != SCMD_READ_SUBCHANNEL && !rq->quiet) printk ("%s : tray open or drive not ready\n", drive->name); } else if (sense_key == UNIT_ATTENTION) { /* Check for media change. */ cdrom_saw_media_change (drive); - printk ("%s: media changed\n", drive->name); + if (!rq->quiet) + printk ("%s: media changed\n", drive->name); } else { /* Otherwise, print an error. */ - ide_dump_status (drive, "packet command error", + if (!rq->quiet) + ide_dump_status (drive, "packet command error", stat); } @@ -768,7 +770,8 @@ static int cdrom_decode_status (ide_drive_t *drive, int good_stat, cdrom_saw_media_change (drive); /* Fail the request. */ - printk ("%s : tray open\n", drive->name); + if (!rq->quiet) + printk ("%s : tray open\n", drive->name); cdrom_end_request (0, drive); } else if (sense_key == UNIT_ATTENTION) { /* Media change. */ @@ -783,7 +786,8 @@ static int cdrom_decode_status (ide_drive_t *drive, int good_stat, sense_key == DATA_PROTECT) { /* No point in retrying after an illegal request or data protect error.*/ - ide_dump_status (drive, "command error", stat); + if (!rq->quiet) + ide_dump_status (drive, "command error", stat); cdrom_end_request (0, drive); } else if ((err & ~ABRT_ERR) != 0) { /* Go to the default handler @@ -1406,7 +1410,7 @@ void cdrom_sleep (int time) #endif static -int cdrom_queue_packet_command (ide_drive_t *drive, struct packet_command *pc) +int cdrom_queue_packet_command (ide_drive_t *drive, struct packet_command *pc, int quiet) { struct atapi_request_sense my_reqbuf; int retries = 10; @@ -1423,6 +1427,7 @@ int cdrom_queue_packet_command (ide_drive_t *drive, struct packet_command *pc) ide_init_drive_cmd (&req); req.cmd = PACKET_COMMAND; req.buffer = (char *)pc; + req.quiet = quiet; (void) ide_do_drive_cmd (drive, &req, ide_wait); if (pc->stat != 0) { @@ -1563,7 +1568,7 @@ cdrom_check_status (ide_drive_t *drive, pc.c[7] = CDROM_STATE_FLAGS (drive)->sanyo_slot % 3; - return cdrom_queue_packet_command (drive, &pc); + return cdrom_queue_packet_command (drive, &pc, 1); } @@ -1588,7 +1593,7 @@ cdrom_lockdoor (ide_drive_t *drive, int lockflag, pc.c[0] = ALLOW_MEDIUM_REMOVAL; pc.c[4] = (lockflag != 0); - stat = cdrom_queue_packet_command (drive, &pc); + stat = cdrom_queue_packet_command (drive, &pc, 0); } if (stat == 0) @@ -1622,7 +1627,7 @@ cdrom_eject (ide_drive_t *drive, int ejectflag, pc.c[0] = START_STOP; pc.c[4] = 2 + (ejectflag != 0); - return cdrom_queue_packet_command (drive, &pc); + return cdrom_queue_packet_command (drive, &pc, 0); } @@ -1637,7 +1642,7 @@ cdrom_pause (ide_drive_t *drive, int pauseflag, pc.c[0] = SCMD_PAUSE_RESUME; pc.c[8] = !pauseflag; - return cdrom_queue_packet_command (drive, &pc); + return cdrom_queue_packet_command (drive, &pc, 0); } @@ -1653,7 +1658,7 @@ cdrom_startstop (ide_drive_t *drive, int startflag, pc.c[0] = START_STOP; pc.c[1] = 1; pc.c[4] = startflag; - return cdrom_queue_packet_command (drive, &pc); + return cdrom_queue_packet_command (drive, &pc, 0); } @@ -1676,7 +1681,7 @@ cdrom_read_capacity (ide_drive_t *drive, unsigned *capacity, pc.buffer = (unsigned char *)&capbuf; pc.buflen = sizeof (capbuf); - stat = cdrom_queue_packet_command (drive, &pc); + stat = cdrom_queue_packet_command (drive, &pc, 1); if (stat == 0) *capacity = ntohl (capbuf.lba); @@ -1702,7 +1707,7 @@ cdrom_read_tocentry (ide_drive_t *drive, int trackno, int msf_flag, pc.c[8] = (buflen & 0xff); pc.c[9] = (format << 6); if (msf_flag) pc.c[1] = 2; - return cdrom_queue_packet_command (drive, &pc); + return cdrom_queue_packet_command (drive, &pc, 1); } @@ -1834,7 +1839,7 @@ cdrom_read_subchannel (ide_drive_t *drive, int format, pc.c[3] = format, pc.c[7] = (buflen >> 8); pc.c[8] = (buflen & 0xff); - return cdrom_queue_packet_command (drive, &pc); + return cdrom_queue_packet_command (drive, &pc, 0); } @@ -1855,7 +1860,7 @@ cdrom_mode_sense (ide_drive_t *drive, int pageno, int modeflag, pc.c[2] = pageno | (modeflag << 6); pc.c[7] = (buflen >> 8); pc.c[8] = (buflen & 0xff); - return cdrom_queue_packet_command (drive, &pc); + return cdrom_queue_packet_command (drive, &pc, 0); } @@ -1875,7 +1880,7 @@ cdrom_mode_select (ide_drive_t *drive, int pageno, char *buf, int buflen, pc.c[2] = pageno; pc.c[7] = (buflen >> 8); pc.c[8] = (buflen & 0xff); - return cdrom_queue_packet_command (drive, &pc); + return cdrom_queue_packet_command (drive, &pc, 0); } @@ -1903,7 +1908,7 @@ cdrom_play_lba_range_1 (ide_drive_t *drive, int lba_start, int lba_end, } #endif /* not STANDARD_ATAPI */ - return cdrom_queue_packet_command (drive, &pc); + return cdrom_queue_packet_command (drive, &pc, 0); } @@ -2004,7 +2009,7 @@ cdrom_read_block (ide_drive_t *drive, int format, int lba, int nblocks, else pc.c[9] = 0x10; - stat = cdrom_queue_packet_command (drive, &pc); + stat = cdrom_queue_packet_command (drive, &pc, 0); #if ! STANDARD_ATAPI /* If the drive doesn't recognize the READ CD opcode, retry the command @@ -2059,7 +2064,7 @@ cdrom_load_unload (ide_drive_t *drive, int slot, pc.c[0] = LOAD_UNLOAD; pc.c[4] = 2 + (slot >= 0); pc.c[8] = slot; - return cdrom_queue_packet_command (drive, &pc); + return cdrom_queue_packet_command (drive, &pc, 0); } } @@ -2575,7 +2580,7 @@ int ide_cdrom_ioctl (ide_drive_t *drive, struct inode *inode, pc.buffer = buf; } - stat = cdrom_queue_packet_command (drive, &pc); + stat = cdrom_queue_packet_command (drive, &pc, 0); if (len > 0) memcpy_tofs ((void *)arg, buf, len); -- cgit v1.2.3 From be41c805265881172e8004c81dd646ad579c8009 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Mon, 10 Feb 2014 00:41:49 +0100 Subject: Make open return ENXIO on missing CD-ROM * linux/src/drivers/block/ide-cd.c (ide_cdrom_open): Return -ENXIO when CD sense failed. --- linux/src/drivers/block/ide-cd.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/linux/src/drivers/block/ide-cd.c b/linux/src/drivers/block/ide-cd.c index ccf79542..020a8313 100644 --- a/linux/src/drivers/block/ide-cd.c +++ b/linux/src/drivers/block/ide-cd.c @@ -2643,6 +2643,10 @@ int ide_cdrom_open (struct inode *ip, struct file *fp, ide_drive_t *drive) if (stat == 0 || my_reqbuf.sense_key == UNIT_ATTENTION) { (void) cdrom_lockdoor (drive, 1, &my_reqbuf); (void) cdrom_read_toc (drive, &my_reqbuf); + } else { + /* Otherwise return as missing */ + --drive->usage; + return -ENXIO; } } -- cgit v1.2.3 From 8d03c760d386d656ab5c0d976fbce30206501eac Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Wed, 12 Feb 2014 01:43:21 +0100 Subject: Reduce kmem_map to make room for kentry_data_size * kern/slab.c (KMEM_MAP_SIZE): Decrease from 128MiB to 96MiB. --- kern/slab.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kern/slab.c b/kern/slab.c index f40afa11..e8451a8a 100644 --- a/kern/slab.c +++ b/kern/slab.c @@ -165,7 +165,7 @@ /* * Size of the VM submap from which default backend functions allocate. */ -#define KMEM_MAP_SIZE (128 * 1024 * 1024) +#define KMEM_MAP_SIZE (96 * 1024 * 1024) /* * Shift for the first kalloc cache size. -- cgit v1.2.3 From a7261c78d3290338ab44abe22c3bebc8abcfb43b Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Thu, 21 Nov 2013 16:59:34 +0100 Subject: include: skip routines related to migrating threads * include/mach/mach_port.defs: Skip the routines mach_port_set_rpcinfo and mach_port_create_act if MIGRATING_THREADS is not defined. --- include/mach/mach_port.defs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/mach/mach_port.defs b/include/mach/mach_port.defs index e1f45e3c..769d8926 100644 --- a/include/mach/mach_port.defs +++ b/include/mach/mach_port.defs @@ -342,5 +342,10 @@ routine mach_port_create_act( user_rbuf_size : vm_size_t; out new_act : thread_t); +#else /* MIGRATING_THREADS */ + +skip; /* mach_port_set_rpcinfo */ +skip; /* mach_port_create_act */ + #endif /* MIGRATING_THREADS */ -- cgit v1.2.3 From c3f3e29ecd36052bfa4b01cd5d782c04836ae37a Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 23 Feb 2014 11:57:45 -0500 Subject: AHCI driver cleanups * linux/dev/drivers/block/ahci.c (struct port): Add id and is_cd fields. (ahci_end_request): Only print error if quiet flag of the request is not set. (ahci_do_port_request): Upgrade sector parameter to 64 bit. Include those bits in the LBA48 request. (ahci_do_request): Upgrade sector count to 64bit. Only print errors if quiet flag of the request is not set. (ahci_probe_port): Move identify code... (ahci_identify): ... to new function. Handle WIN_PIDENTIFY case to recognize ATAPI devices. (ahci_probe_port): Also try WIN_PIDENTIFY command. (ahci_geninit): Avoid checking partition table on empty devices. --- linux/dev/drivers/block/ahci.c | 260 ++++++++++++++++++++++++----------------- 1 file changed, 154 insertions(+), 106 deletions(-) diff --git a/linux/dev/drivers/block/ahci.c b/linux/dev/drivers/block/ahci.c index 2c573acb..7df6b70d 100644 --- a/linux/dev/drivers/block/ahci.c +++ b/linux/dev/drivers/block/ahci.c @@ -239,6 +239,8 @@ static struct port { struct ahci_fis *fis; struct ahci_cmd_tbl *prdtl; + struct hd_driveid id; + unsigned is_cd; unsigned long long capacity; /* Nr of sectors */ u32 status; /* interrupt status */ unsigned cls; /* Command list maximum size. @@ -264,9 +266,9 @@ static void ahci_end_request(int uptodate) rq->errors = 0; if (!uptodate) { - printk("end_request: I/O error, dev %s, sector %lu\n", - kdevname(rq->rq_dev), rq->sector); - assert(0); + if (!rq->quiet) + printk("end_request: I/O error, dev %s, sector %lu\n", + kdevname(rq->rq_dev), rq->sector); } for (bh = rq->bh; bh; ) @@ -286,7 +288,7 @@ static void ahci_end_request(int uptodate) } /* Push the request to the controler port */ -static void ahci_do_port_request(struct port *port, unsigned sector, struct request *rq) +static void ahci_do_port_request(struct port *port, unsigned long long sector, struct request *rq) { struct ahci_command *command = port->command; struct ahci_cmd_tbl *prdtl = port->prdtl; @@ -321,8 +323,8 @@ static void ahci_do_port_request(struct port *port, unsigned sector, struct requ fis_h2d->lba2 = sector >> 16; fis_h2d->lba3 = sector >> 24; - fis_h2d->lba4 = 0; - fis_h2d->lba5 = 0; + fis_h2d->lba4 = sector >> 32; + fis_h2d->lba5 = sector >> 40; fis_h2d->countl = rq->nr_sectors; fis_h2d->counth = rq->nr_sectors >> 8; @@ -360,7 +362,7 @@ static void ahci_do_request() /* invoked with cli() */ { struct request *rq; unsigned minor, unit; - unsigned long block, blockend; + unsigned long long block, blockend; struct port *port; rq = CURRENT; @@ -393,12 +395,16 @@ static void ahci_do_request() /* invoked with cli() */ /* And check end */ blockend = block + rq->nr_sectors; if (blockend < block) { - printk("bad blockend %lu vs %lu\n", blockend, block); + if (!rq->quiet) + printk("bad blockend %lu vs %lu\n", (unsigned long) blockend, (unsigned long) block); goto kill_rq; } if (blockend > port->capacity) { - printk("offset for %u was %lu\n", minor, port->part[minor & PARTN_MASK].start_sect); - printk("bad access: block %lu, count= %lu\n", blockend, (unsigned long) port->capacity); + if (!rq->quiet) + { + printk("offset for %u was %lu\n", minor, port->part[minor & PARTN_MASK].start_sect); + printk("bad access: block %lu, count= %lu\n", (unsigned long) blockend, (unsigned long) port->capacity); + } goto kill_rq; } @@ -553,103 +559,17 @@ static void identify_timeout(unsigned long data) static struct timer_list identify_timer = { .function = identify_timeout }; -/* Probe one AHCI port */ -static void ahci_probe_port(const volatile struct ahci_host *ahci_host, const volatile struct ahci_port *ahci_port) +static int ahci_identify(const volatile struct ahci_host *ahci_host, const volatile struct ahci_port *ahci_port, struct port *port, unsigned cmd) { - struct port *port; - void *mem; struct hd_driveid id; - unsigned cls = ((readl(&ahci_host->cap) >> 8) & 0x1f) + 1; - struct ahci_command *command; - struct ahci_fis *fis; - struct ahci_cmd_tbl *prdtl; struct ahci_fis_h2d *fis_h2d; - vm_size_t size = - cls * sizeof(*command) - + sizeof(*fis) - + cls * sizeof(*prdtl); - unsigned i; + struct ahci_command *command = port->command; + struct ahci_cmd_tbl *prdtl = port->prdtl; + unsigned long flags; unsigned slot; unsigned long first_part; unsigned long long timeout; - unsigned long flags; - - for (i = 0; i < MAX_PORTS; i++) { - if (!ports[i].ahci_port) - break; - } - if (i == MAX_PORTS) - return; - port = &ports[i]; - - /* Has to be 1K-aligned */ - mem = vmalloc (size); - if (!mem) - return; - assert (!(((unsigned long) mem) & (1024-1))); - memset (mem, 0, size); - - port->ahci_host = ahci_host; - port->ahci_port = ahci_port; - port->cls = cls; - - port->command = command = mem; - port->fis = fis = (void*) command + cls * sizeof(*command); - port->prdtl = prdtl = (void*) fis + sizeof(*fis); - - /* Stop commands */ - writel(readl(&ahci_port->cmd) & ~PORT_CMD_START, &ahci_port->cmd); - timeout = jiffies + WAIT_MAX; - while (readl(&ahci_port->cmd) & PORT_CMD_LIST_ON) - if (jiffies > timeout) { - printk("sd%u: timeout waiting for list completion\n", port-ports); - port->ahci_host = NULL; - port->ahci_port = NULL; - return; - } - - writel(readl(&ahci_port->cmd) & ~PORT_CMD_FIS_RX, &ahci_port->cmd); - timeout = jiffies + WAIT_MAX; - while (readl(&ahci_port->cmd) & PORT_CMD_FIS_ON) - if (jiffies > timeout) { - printk("sd%u: timeout waiting for FIS completion\n", port-ports); - port->ahci_host = NULL; - port->ahci_port = NULL; - return; - } - - /* We don't support 64bit */ - /* Point controller to our buffers */ - writel(0, &ahci_port->clbu); - writel(vmtophys((void*) command), &ahci_port->clb); - writel(0, &ahci_port->fbu); - writel(vmtophys((void*) fis), &ahci_port->fb); - - /* Clear any previous interrupts */ - writel(readl(&ahci_port->is), &ahci_port->is); - writel(1 << (ahci_port - ahci_host->ports), &ahci_host->is); - - /* And activate them */ - writel(DEF_PORT_IRQ, &ahci_port->ie); - writel(readl(&ahci_host->ghc) | HOST_IRQ_EN, &ahci_host->ghc); - - for (i = 0; i < cls; i++) - { - command[i].ctbau = 0; - command[i].ctba = vmtophys((void*) &prdtl[i]); - } - - /* Start commands */ - timeout = jiffies + WAIT_MAX; - while (readl(&ahci_port->cmd) & PORT_CMD_LIST_ON) - if (jiffies > timeout) { - printk("sd%u: timeout waiting for list completion\n", port-ports); - port->ahci_host = NULL; - port->ahci_port = NULL; - return; - } - - writel(readl(&ahci_port->cmd) | PORT_CMD_FIS_RX | PORT_CMD_START, &ahci_port->cmd); + int ret = 0; /* Identify device */ /* TODO: make this a request */ @@ -658,7 +578,7 @@ static void ahci_probe_port(const volatile struct ahci_host *ahci_host, const vo fis_h2d = (void*) &prdtl[slot].cfis; fis_h2d->fis_type = FIS_TYPE_REG_H2D; fis_h2d->flags = 128; - fis_h2d->command = WIN_IDENTIFY; + fis_h2d->command = cmd; fis_h2d->device = 0; /* Fetch the 512 identify data */ @@ -695,7 +615,7 @@ static void ahci_probe_port(const volatile struct ahci_host *ahci_host, const vo printk("sd%u: timeout waiting for ready\n", port-ports); port->ahci_host = NULL; port->ahci_port = NULL; - return; + return 3; } save_flags(flags); @@ -718,22 +638,48 @@ static void ahci_probe_port(const volatile struct ahci_host *ahci_host, const vo port->ahci_host = NULL; port->ahci_port = NULL; del_timer(&identify_timer); - return; + return 3; } sleep_on(&port->q); } del_timer(&identify_timer); restore_flags(flags); - if (readl(&ahci_port->is) & PORT_IRQ_TF_ERR) + if ((port->status & PORT_IRQ_TF_ERR) || readl(&ahci_port->is) & PORT_IRQ_TF_ERR) { - printk("sd%u: identify error\n", port-ports); + /* Identify error */ port->capacity = 0; port->lba48 = 0; + ret = 2; } else { + memcpy(&port->id, &id, sizeof(id)); + port->is_cd = 0; + ide_fixstring(id.model, sizeof(id.model), 1); ide_fixstring(id.fw_rev, sizeof(id.fw_rev), 1); ide_fixstring(id.serial_no, sizeof(id.serial_no), 1); + if (cmd == WIN_PIDENTIFY) + { + unsigned char type = (id.config >> 8) & 0x1f; + + printk("sd%u: %s, ATAPI ", port - ports, id.model); + if (type == 5) + { + printk("unsupported CDROM drive\n"); + port->is_cd = 1; + port->lba48 = 0; + port->capacity = 0; + } + else + { + printk("unsupported type %d\n", type); + port->lba48 = 0; + port->capacity = 0; + return 2; + } + return 0; + } + if (id.command_set_2 & (1U<<10)) { port->lba48 = 1; @@ -760,6 +706,106 @@ static void ahci_probe_port(const volatile struct ahci_host *ahci_host, const vo printk("sd%u: %s, %uMB w/%dkB Cache\n", port - ports, id.model, (unsigned) (port->capacity/2048), id.buf_size/2); } port->identify = 0; + + return ret; +} + +/* Probe one AHCI port */ +static void ahci_probe_port(const volatile struct ahci_host *ahci_host, const volatile struct ahci_port *ahci_port) +{ + struct port *port; + void *mem; + unsigned cls = ((readl(&ahci_host->cap) >> 8) & 0x1f) + 1; + struct ahci_command *command; + struct ahci_fis *fis; + struct ahci_cmd_tbl *prdtl; + vm_size_t size = + cls * sizeof(*command) + + sizeof(*fis) + + cls * sizeof(*prdtl); + unsigned i; + unsigned long long timeout; + + for (i = 0; i < MAX_PORTS; i++) { + if (!ports[i].ahci_port) + break; + } + if (i == MAX_PORTS) + return; + port = &ports[i]; + + /* Has to be 1K-aligned */ + mem = vmalloc (size); + if (!mem) + return; + assert (!(((unsigned long) mem) & (1024-1))); + memset (mem, 0, size); + + port->ahci_host = ahci_host; + port->ahci_port = ahci_port; + port->cls = cls; + + port->command = command = mem; + port->fis = fis = (void*) command + cls * sizeof(*command); + port->prdtl = prdtl = (void*) fis + sizeof(*fis); + + /* Stop commands */ + writel(readl(&ahci_port->cmd) & ~PORT_CMD_START, &ahci_port->cmd); + timeout = jiffies + WAIT_MAX; + while (readl(&ahci_port->cmd) & PORT_CMD_LIST_ON) + if (jiffies > timeout) { + printk("sd%u: timeout waiting for list completion\n", port-ports); + port->ahci_host = NULL; + port->ahci_port = NULL; + return; + } + + writel(readl(&ahci_port->cmd) & ~PORT_CMD_FIS_RX, &ahci_port->cmd); + timeout = jiffies + WAIT_MAX; + while (readl(&ahci_port->cmd) & PORT_CMD_FIS_ON) + if (jiffies > timeout) { + printk("sd%u: timeout waiting for FIS completion\n", port-ports); + port->ahci_host = NULL; + port->ahci_port = NULL; + return; + } + + /* We don't support 64bit */ + /* Point controller to our buffers */ + writel(0, &ahci_port->clbu); + writel(vmtophys((void*) command), &ahci_port->clb); + writel(0, &ahci_port->fbu); + writel(vmtophys((void*) fis), &ahci_port->fb); + + /* Clear any previous interrupts */ + writel(readl(&ahci_port->is), &ahci_port->is); + writel(1 << (ahci_port - ahci_host->ports), &ahci_host->is); + + /* And activate them */ + writel(DEF_PORT_IRQ, &ahci_port->ie); + writel(readl(&ahci_host->ghc) | HOST_IRQ_EN, &ahci_host->ghc); + + for (i = 0; i < cls; i++) + { + command[i].ctbau = 0; + command[i].ctba = vmtophys((void*) &prdtl[i]); + } + + /* Start commands */ + timeout = jiffies + WAIT_MAX; + while (readl(&ahci_port->cmd) & PORT_CMD_LIST_ON) + if (jiffies > timeout) { + printk("sd%u: timeout waiting for list completion\n", port-ports); + port->ahci_host = NULL; + port->ahci_port = NULL; + return; + } + + writel(readl(&ahci_port->cmd) | PORT_CMD_FIS_RX | PORT_CMD_START, &ahci_port->cmd); + + if (ahci_identify(ahci_host, ahci_port, port, WIN_IDENTIFY) >= 2) + /* Try ATAPI */ + ahci_identify(ahci_host, ahci_port, port, WIN_PIDENTIFY); } /* Probe one AHCI PCI device */ @@ -859,6 +905,8 @@ static void ahci_geninit(struct gendisk *gd) for (unit = 0; unit < gd->nr_real; unit++) { port = &ports[unit]; port->part[0].nr_sects = port->capacity; + if (!port->part[0].nr_sects) + port->part[0].nr_sects = -1; } } -- cgit v1.2.3 From 2d91aeafcf87e32fd3b5d447e20f421ee5d9f91f Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Fri, 21 Feb 2014 21:57:37 +0100 Subject: kern: fix mig_strncpy Previously, the function mig_strncpy would always zero-terminate the destination string. Make mig_strncpy behave like mig_strncpy and strncpy in the glibc. Also fix the implementation of mig_strncpy to return the length of the written string to align the implementation with the declaration in include/mach/mig_support.h. * kern/ipc_mig.c (mig_strncpy): Do not zero-terminate the destination string. Return length of destination string. --- kern/ipc_mig.c | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/kern/ipc_mig.c b/kern/ipc_mig.c index bbc38cf6..f2c3f458 100644 --- a/kern/ipc_mig.c +++ b/kern/ipc_mig.c @@ -272,10 +272,10 @@ mig_put_reply_port( /* * mig_strncpy.c - by Joshua Block * - * mig_strncp -- Bounded string copy. Does what the library routine strncpy - * OUGHT to do: Copies the (null terminated) string in src into dest, a - * buffer of length len. Assures that the copy is still null terminated - * and doesn't overflow the buffer, truncating the copy if necessary. + * mig_strncpy -- Bounded string copy. Does what the library routine + * strncpy does: Copies the (null terminated) string in src into dest, + * a buffer of length len. Returns the length of the destination + * string excluding the terminating null. * * Parameters: * @@ -285,22 +285,26 @@ mig_put_reply_port( * * len - Length of destination buffer. */ -void mig_strncpy(dest, src, len) -char *dest; -const char *src; -int len; +vm_size_t +mig_strncpy(dest, src, len) + char *dest; + const char *src; + int len; { - int i; + char *dest_ = dest; + int i; - if (len <= 0) - return; + if (len <= 0) + return 0; - for (i=1; i Date: Mon, 3 Mar 2014 00:50:33 +0100 Subject: Keep two virtual pages as mapping windows to access physical memory PCI devices expose their memory etc. way beyond last_phys_addr. Userland drivers opening /dev/mem need to open those too, even if phystokv() will not work for them. * i386/intel/pmap.h (pmap_mapwindow_t): New type. (pmap_get_mapwindow, pmap_put_mapwindow): New prototypes. (PMAP_NMAPWINDOWS): New macro. * i386/intel/pmap.c (mapwindows): New array. (pmap_get_mapwindow, pmap_put_mapwindow): New functions. (pmap_bootstrap, pmap_virtual_space): Reserve virtual pages for the mapping windows. * i386/i386/phys.c: Include (INTEL_PTE_W, INTEL_PTE_R): New macros (pmap_zero_page, pmap_copy_page, copy_to_phys, copy_from_phys): Use `pmap_get_mapwindow' to temporarily map physical pages beyond last_phys_addr. --- i386/i386/phys.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- i386/intel/pmap.c | 43 +++++++++++++++++++++++++++++- i386/intel/pmap.h | 10 +++++++ 3 files changed, 127 insertions(+), 5 deletions(-) diff --git a/i386/i386/phys.c b/i386/i386/phys.c index ed4a309a..d4bd6c38 100644 --- a/i386/i386/phys.c +++ b/i386/i386/phys.c @@ -37,8 +37,12 @@ #include #include +#include #include +#define INTEL_PTE_W(p) (INTEL_PTE_VALID | INTEL_PTE_WRITE | INTEL_PTE_REF | INTEL_PTE_MOD | pa_to_pte(p)) +#define INTEL_PTE_R(p) (INTEL_PTE_VALID | INTEL_PTE_REF | pa_to_pte(p)) + /* * pmap_zero_page zeros the specified (machine independent) page. */ @@ -47,7 +51,21 @@ pmap_zero_page(p) vm_offset_t p; { assert(p != vm_page_fictitious_addr); - memset((void *)phystokv(p), 0, PAGE_SIZE); + vm_offset_t v; + pmap_mapwindow_t *map; + + if (p >= phys_last_addr) + { + map = pmap_get_mapwindow(INTEL_PTE_W(p)); + v = map->vaddr; + } + else + v = phystokv(p); + + memset((void*) v, 0, PAGE_SIZE); + + if (p >= phys_last_addr) + pmap_put_mapwindow(map); } /* @@ -57,10 +75,33 @@ void pmap_copy_page(src, dst) vm_offset_t src, dst; { + vm_offset_t src_addr_v, dst_addr_v; + pmap_mapwindow_t *src_map, *dst_map; assert(src != vm_page_fictitious_addr); assert(dst != vm_page_fictitious_addr); - memcpy((void *)phystokv(dst), (void *)phystokv(src), PAGE_SIZE); + if (src >= phys_last_addr) + { + src_map = pmap_get_mapwindow(INTEL_PTE_R(src)); + src_addr_v = src_map->vaddr; + } + else + src_addr_v = phystokv(src); + + if (dst >= phys_last_addr) + { + dst_map = pmap_get_mapwindow(INTEL_PTE_W(dst)); + dst_addr_v = dst_map->vaddr; + } + else + dst_addr_v = phystokv(dst); + + memcpy((void *) dst_addr_v, (void *) src_addr_v, PAGE_SIZE); + + if (src >= phys_last_addr) + pmap_put_mapwindow(src_map); + if (dst >= phys_last_addr) + pmap_put_mapwindow(dst_map); } /* @@ -73,8 +114,23 @@ copy_to_phys(src_addr_v, dst_addr_p, count) vm_offset_t src_addr_v, dst_addr_p; int count; { + vm_offset_t dst_addr_v; + pmap_mapwindow_t *dst_map; assert(dst_addr_p != vm_page_fictitious_addr); - memcpy((void *)phystokv(dst_addr_p), (void *)src_addr_v, count); + assert(pa_to_pte(dst_addr_p + count-1) == pa_to_pte(dst_addr_p)); + + if (dst_addr_p >= phys_last_addr) + { + dst_map = pmap_get_mapwindow(INTEL_PTE_W(dst_addr_p)); + dst_addr_v = dst_map->vaddr; + } + else + dst_addr_v = phystokv(dst_addr_p); + + memcpy((void *)dst_addr_v, (void *)src_addr_v, count); + + if (dst_addr_p >= phys_last_addr) + pmap_put_mapwindow(dst_map); } /* @@ -88,8 +144,23 @@ copy_from_phys(src_addr_p, dst_addr_v, count) vm_offset_t src_addr_p, dst_addr_v; int count; { + vm_offset_t src_addr_v; + pmap_mapwindow_t *src_map; assert(src_addr_p != vm_page_fictitious_addr); - memcpy((void *)dst_addr_v, (void *)phystokv(src_addr_p), count); + assert(pa_to_pte(src_addr_p + count-1) == pa_to_pte(src_addr_p)); + + if (src_addr_p >= phys_last_addr) + { + src_map = pmap_get_mapwindow(INTEL_PTE_R(src_addr_p)); + src_addr_v = src_map->vaddr; + } + else + src_addr_v = phystokv(src_addr_p); + + memcpy((void *)dst_addr_v, (void *)src_addr_v, count); + + if (src_addr_p >= phys_last_addr) + pmap_put_mapwindow(src_map); } /* diff --git a/i386/intel/pmap.c b/i386/intel/pmap.c index 2943d26f..a3d96300 100644 --- a/i386/intel/pmap.c +++ b/i386/intel/pmap.c @@ -419,6 +419,12 @@ unsigned int inuse_ptepages_count = 0; /* debugging */ */ pt_entry_t *kernel_page_dir; +/* + * Two slots for temporary physical page mapping, to allow for + * physical-to-physical transfers. + */ +static pmap_mapwindow_t mapwindows[PMAP_NMAPWINDOWS]; + static inline pt_entry_t * pmap_pde(const pmap_t pmap, vm_offset_t addr) { @@ -774,6 +780,12 @@ void pmap_bootstrap(void) } for (; pte < ptable+NPTES; pte++) { + if (va >= kernel_virtual_end - PMAP_NMAPWINDOWS * PAGE_SIZE); + { + pmap_mapwindow_t *win = &mapwindows[atop(va - (kernel_virtual_end - PMAP_NMAPWINDOWS * PAGE_SIZE))]; + win->entry = pte; + win->vaddr = va; + } WRITE_PTE(pte, 0); va += INTEL_PGBYTES; } @@ -884,12 +896,41 @@ void pmap_clear_bootstrap_pagetable(pt_entry_t *base) { } #endif /* MACH_PV_PAGETABLES */ +/* + * Create a temporary mapping for a given physical entry + * + * This can be used to access physical pages which are not mapped 1:1 by + * phystokv(). + */ +pmap_mapwindow_t *pmap_get_mapwindow(pt_entry_t entry) +{ + pmap_mapwindow_t *map; + + /* Find an empty one. */ + for (map = &mapwindows[0]; map < &mapwindows[sizeof (mapwindows) / sizeof (*mapwindows)]; map++) + if (!(*map->entry)) + break; + assert(map < &mapwindows[sizeof (mapwindows) / sizeof (*mapwindows)]); + + WRITE_PTE(map->entry, entry); + return map; +} + +/* + * Destroy a temporary mapping for a physical entry + */ +void pmap_put_mapwindow(pmap_mapwindow_t *map) +{ + WRITE_PTE(map->entry, 0); + PMAP_UPDATE_TLBS(kernel_pmap, map->vaddr, map->vaddr + PAGE_SIZE); +} + void pmap_virtual_space(startp, endp) vm_offset_t *startp; vm_offset_t *endp; { *startp = kernel_virtual_start; - *endp = kernel_virtual_end; + *endp = kernel_virtual_end - PMAP_NMAPWINDOWS * PAGE_SIZE; } /* diff --git a/i386/intel/pmap.h b/i386/intel/pmap.h index 047a384b..382cd5f4 100644 --- a/i386/intel/pmap.h +++ b/i386/intel/pmap.h @@ -192,6 +192,16 @@ extern void pmap_clear_bootstrap_pagetable(pt_entry_t *addr); #define set_pmap(pmap) set_cr3(kvtophys((vm_offset_t)(pmap)->dirbase)) #endif /* PAE */ +typedef struct { + pt_entry_t *entry; + vm_offset_t vaddr; +} pmap_mapwindow_t; + +extern pmap_mapwindow_t *pmap_get_mapwindow(pt_entry_t entry); +extern void pmap_put_mapwindow(pmap_mapwindow_t *map); + +#define PMAP_NMAPWINDOWS 2 + #if NCPUS > 1 /* * List of cpus that are actively using mapped memory. Any -- cgit v1.2.3 From 7f862cffb41ba2a5110bc47ebe54feb5b3ffc8a0 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Mon, 17 Mar 2014 01:18:32 +0100 Subject: Increase possible number of AHCI devices to 8 by reducing possible number of partitions to 32. * linux/dev/drivers/block/ahci.c (MAX_PORTS): Set to 8. (PARTN_BITS): Set to 5. --- linux/dev/drivers/block/ahci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/linux/dev/drivers/block/ahci.c b/linux/dev/drivers/block/ahci.c index 7df6b70d..2b348e65 100644 --- a/linux/dev/drivers/block/ahci.c +++ b/linux/dev/drivers/block/ahci.c @@ -36,8 +36,8 @@ /* minor: 2 bits for device number, 6 bits for partition number. */ -#define MAX_PORTS 4 -#define PARTN_BITS 6 +#define MAX_PORTS 8 +#define PARTN_BITS 5 #define PARTN_MASK ((1< Date: Thu, 20 Mar 2014 02:34:06 +0100 Subject: Only complain once per boot about Xen console smash * xen/console.c (hypputc): Make `complain' variable static. --- xen/console.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/console.c b/xen/console.c index 884376ff..313b9342 100644 --- a/xen/console.c +++ b/xen/console.c @@ -47,7 +47,7 @@ int hypputc(int c) hyp_console_io(CONSOLEIO_write, 1, kvtolin(&d)); } else { spl_t spl = splhigh(); - int complain; + static int complain; simple_lock(&outlock); while (hyp_ring_smash(console->out, console->out_prod, console->out_cons)) { if (!complain) { -- cgit v1.2.3 From 3ce4896345a3c339f159674ddf15e28b5072cb62 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Wed, 19 Mar 2014 16:10:57 +0100 Subject: xen: fix error handling Previously, the error KERN_RESOURCE_SHORTAGE was not properly propagated. Found using the Clang Static Analyzer. * xen/block.c (device_open): Fix error handling, remove unused label. * xen/net.c (device_open): Likewise. --- xen/block.c | 5 ++--- xen/net.c | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/xen/block.c b/xen/block.c index bd3758f9..d98b31e2 100644 --- a/xen/block.c +++ b/xen/block.c @@ -382,8 +382,8 @@ device_open (ipc_port_t reply_port, mach_msg_type_name_t reply_port_type, port = ipc_port_alloc_kernel(); if (port == IP_NULL) { - err = KERN_RESOURCE_SHORTAGE; - goto out; + device_close(bd); + return KERN_RESOURCE_SHORTAGE; } bd->port = port; @@ -396,7 +396,6 @@ device_open (ipc_port_t reply_port, mach_msg_type_name_t reply_port_type, ipc_port_nsrequest (bd->port, 1, notify, ¬ify); assert (notify == IP_NULL); -out: if (IP_VALID (reply_port)) ds_device_open_reply (reply_port, reply_port_type, D_SUCCESS, port); else diff --git a/xen/net.c b/xen/net.c index fb264719..55643651 100644 --- a/xen/net.c +++ b/xen/net.c @@ -568,8 +568,8 @@ device_open (ipc_port_t reply_port, mach_msg_type_name_t reply_port_type, port = ipc_port_alloc_kernel(); if (port == IP_NULL) { - err = KERN_RESOURCE_SHORTAGE; - goto out; + device_close (nd); + return KERN_RESOURCE_SHORTAGE; } nd->port = port; @@ -582,7 +582,6 @@ device_open (ipc_port_t reply_port, mach_msg_type_name_t reply_port_type, ipc_port_nsrequest (nd->port, 1, notify, ¬ify); assert (notify == IP_NULL); -out: if (IP_VALID (reply_port)) ds_device_open_reply (reply_port, reply_port_type, D_SUCCESS, dev_to_port(nd)); else -- cgit v1.2.3 From 7e59fbeb2f05e1400dadbbd2d9c93d8bd2ad8178 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sat, 22 Mar 2014 16:33:25 +0100 Subject: Fix overflow We were filling much more than the mapwindows array, thus overwriting in at least debugger variables. * i386/intel/pmap.c (pmap_bootstrap): Make sure to limit mapwindows initialization within PMAP_NMAPWINDOWS. --- i386/intel/pmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i386/intel/pmap.c b/i386/intel/pmap.c index a3d96300..4b2892a7 100644 --- a/i386/intel/pmap.c +++ b/i386/intel/pmap.c @@ -780,7 +780,7 @@ void pmap_bootstrap(void) } for (; pte < ptable+NPTES; pte++) { - if (va >= kernel_virtual_end - PMAP_NMAPWINDOWS * PAGE_SIZE); + if (va >= kernel_virtual_end - PMAP_NMAPWINDOWS * PAGE_SIZE && va < kernel_virtual_end) { pmap_mapwindow_t *win = &mapwindows[atop(va - (kernel_virtual_end - PMAP_NMAPWINDOWS * PAGE_SIZE))]; win->entry = pte; -- cgit v1.2.3 From 50cc5152ebb4872b57a764d7b5ad62636f674e01 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Mon, 3 Mar 2014 19:12:52 +0100 Subject: include: make the memory_object_t types translation functions mutable Make the intran, outtran and destructor functions mutable using preprocessor macros. Make it possible to inject imports using the MEMORY_OBJECT_IMPORTS macro. This way, userspace servers can provide their own translation functions. * include/mach/mach_types.defs (memory_object_t): Make the translation mutable using preprocessor macros. * include/mach/memory_object.defs: Likewise for the inlined type declarations. Honor MEMORY_OBJECT_IMPORTS. * include/mach/memory_object_default.defs: Likewise. --- include/mach/mach_types.defs | 10 ++++++++++ include/mach/memory_object.defs | 28 ++++++++++++++++++++++++---- include/mach/memory_object_default.defs | 4 ++++ 3 files changed, 38 insertions(+), 4 deletions(-) diff --git a/include/mach/mach_types.defs b/include/mach/mach_types.defs index 607d5d92..bfce6cb5 100644 --- a/include/mach/mach_types.defs +++ b/include/mach/mach_types.defs @@ -135,6 +135,16 @@ type memory_object_t = mach_port_t ctype: mach_port_t #if KERNEL_SERVER intran: ipc_port_t null_conversion(mach_port_t) +#else /* KERNEL_SERVER */ +#ifdef MEMORY_OBJECT_INTRAN + intran: MEMORY_OBJECT_INTRAN +#endif +#ifdef MEMORY_OBJECT_OUTTRAN + outtran: MEMORY_OBJECT_OUTTRAN +#endif +#ifdef MEMORY_OBJECT_DESTRUCTOR + destructor: MEMORY_OBJECT_DESTRUCTOR +#endif #endif /* KERNEL_SERVER */ ; diff --git a/include/mach/memory_object.defs b/include/mach/memory_object.defs index ea7989aa..0ed8dbcd 100644 --- a/include/mach/memory_object.defs +++ b/include/mach/memory_object.defs @@ -42,6 +42,10 @@ subsystem #include #include +#ifdef MEMORY_OBJECT_IMPORTS +MEMORY_OBJECT_IMPORTS +#endif + #if SEQNOS serverprefix seqnos_; serverdemux seqnos_memory_object_server; @@ -85,7 +89,11 @@ simpleroutine memory_object_init( simpleroutine memory_object_terminate( memory_object : memory_object_t = MACH_MSG_TYPE_MOVE_SEND - ctype: mach_port_t; + ctype: mach_port_t +#ifdef MEMORY_OBJECT_INTRAN + intran: MEMORY_OBJECT_INTRAN +#endif + ; #if SEQNOS msgseqno seqno : mach_port_seqno_t; #endif /* SEQNOS */ @@ -221,7 +229,11 @@ simpleroutine memory_object_data_write( simpleroutine memory_object_lock_completed( memory_object : memory_object_t = polymorphic|MACH_MSG_TYPE_PORT_SEND_ONCE - ctype: mach_port_t; + ctype: mach_port_t +#ifdef MEMORY_OBJECT_INTRAN + intran: MEMORY_OBJECT_INTRAN +#endif + ; #if SEQNOS msgseqno seqno : mach_port_seqno_t; #endif /* SEQNOS */ @@ -252,7 +264,11 @@ simpleroutine memory_object_lock_completed( simpleroutine memory_object_supply_completed( memory_object : memory_object_t = polymorphic|MACH_MSG_TYPE_PORT_SEND_ONCE - ctype: mach_port_t; + ctype: mach_port_t +#ifdef MEMORY_OBJECT_INTRAN + intran: MEMORY_OBJECT_INTRAN +#endif + ; #if SEQNOS msgseqno seqno : mach_port_seqno_t; #endif /* SEQNOS */ @@ -298,7 +314,11 @@ simpleroutine memory_object_data_return( simpleroutine memory_object_change_completed( memory_object : memory_object_t = polymorphic|MACH_MSG_TYPE_PORT_SEND_ONCE - ctype: mach_port_t; + ctype: mach_port_t +#ifdef MEMORY_OBJECT_INTRAN + intran: MEMORY_OBJECT_INTRAN +#endif + ; #if SEQNOS msgseqno seqno : mach_port_seqno_t; #endif /* SEQNOS */ diff --git a/include/mach/memory_object_default.defs b/include/mach/memory_object_default.defs index 0eac2714..cfd54a48 100644 --- a/include/mach/memory_object_default.defs +++ b/include/mach/memory_object_default.defs @@ -40,6 +40,10 @@ subsystem #include #include +#ifdef MEMORY_OBJECT_IMPORTS +MEMORY_OBJECT_IMPORTS +#endif + #if SEQNOS serverprefix seqnos_; serverdemux seqnos_memory_object_default_server; -- cgit v1.2.3 From 120847a0c4b72da43ac2764ba73548e8916b1c0d Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Tue, 25 Mar 2014 23:09:55 +0100 Subject: kern: fix formatting of multiboot modules Previously, bootstrap_create would print the multiboot modules with padding applied to the end of the line. As multiboot modules as used by the Hurd span more than one line. This makes the list of modules hard to read and it looks unclean, more like an accident. Furthermore, it is not clear what the intend of this was, as the padding is applied at the end of the line, with no further information printed thereafter. * kern/bootstrap.c (bootstrap_create): Remove variable maxlen and len, update printfs. --- kern/bootstrap.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/kern/bootstrap.c b/kern/bootstrap.c index 3e24d7b7..7cfff3a1 100644 --- a/kern/bootstrap.c +++ b/kern/bootstrap.c @@ -150,7 +150,7 @@ void bootstrap_create(void) } else { - int i, losers, maxlen; + int i, losers; /* Initialize boot script variables. We leak these send rights. */ losers = boot_script_set_variable @@ -241,15 +241,11 @@ void bootstrap_create(void) } #endif - maxlen = 0; for (i = 0; i < boot_info.mods_count; ++i) { int err; char *line = (char*)phystokv(bmods[i].string); - int len = strlen (line) + 1; - if (len > maxlen) - maxlen = len; - printf ("\rmodule %d: %*s", i, -maxlen, line); + printf ("module %d: %s\n", i, line); err = boot_script_parse_line (&bmods[i], line); if (err) { @@ -257,7 +253,7 @@ void bootstrap_create(void) ++losers; } } - printf ("\r%d multiboot modules %*s", i, -maxlen, ""); + printf ("%d multiboot modules\n", i); if (losers) panic ("%d of %d boot script commands could not be parsed", losers, boot_info.mods_count); -- cgit v1.2.3 From ef1e38353b835ee1d5c0ff400f82cfc7b74c7649 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Fri, 28 Mar 2014 01:02:17 +0100 Subject: Really default to EGA/VGA on unknown CMOS values * i386/i386at/kd.c (kd_xga_init): Use CM_EGA_VGA behavior as default case for unknown values of CMOS data. --- i386/i386at/kd.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/i386/i386at/kd.c b/i386/i386at/kd.c index d6b75af4..2bb0a69a 100644 --- a/i386/i386at/kd.c +++ b/i386/i386at/kd.c @@ -2512,6 +2512,9 @@ kd_xga_init(void) outb(CMOS_ADDR, CMOS_EB); screen = inb(CMOS_DATA) & CM_SCRMSK; switch(screen) { + default: + printf("kd: unknown screen type, defaulting to EGA\n"); + /* FALLTHROUGH */ case CM_EGA_VGA: /* * Here we'll want to query to bios on the card @@ -2558,8 +2561,6 @@ kd_xga_init(void) kd_lines = 25; kd_cols = 80; break; - default: - printf("kd: unknown screen type, defaulting to EGA\n"); } outb(kd_index_reg, C_START); -- cgit v1.2.3 From 32be3a889794a212a5a4083de279134c22c314a3 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Fri, 28 Mar 2014 01:03:32 +0100 Subject: Assume EGA/VGA card CGA and MONO cards are more than hard to find nowadays, and some buggy BIOSes claim running them nowadays... * i386/i386at/kd.c (kd_xga_init): Do not handle CGA and MONO cases any more, which thus default to EGA/VGA. --- i386/i386at/kd.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/i386/i386at/kd.c b/i386/i386at/kd.c index 2bb0a69a..acd69f7d 100644 --- a/i386/i386at/kd.c +++ b/i386/i386at/kd.c @@ -2540,6 +2540,8 @@ kd_xga_init(void) addr[i] = 0x00; } break; +#if 0 + /* XXX: some buggy BIOSes report these... */ case CM_CGA_40: vid_start = (u_char *)phystokv(CGA_START); kd_index_reg = CGA_IDX_REG; @@ -2561,6 +2563,7 @@ kd_xga_init(void) kd_lines = 25; kd_cols = 80; break; +#endif } outb(kd_index_reg, C_START); -- cgit v1.2.3 From 2a8d65dfceb4ac35b09935a5e5fb62be1a44ab14 Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 4 Apr 2014 21:52:39 +0200 Subject: Use explicit prototypes for struct dev_ops fields * device/conf.h: Include , , . Predefine struct io_req, io_req_t and io_return_t. (dev_ops): Add explicit prototypes for d_open, d_close, d_read, d_write, d_getstat, d_setstat, d_mmap, d_port_death. (nulldev_open, nulldev_close, nulldev_read, nulldev_write, nulldev_getstat, nulldev_setstat, nulldev_portdeath): Add prototypes. (nomap): Fix prototype. * device/dev_name.c (nulldev_open, nulldev_close, nulldev_read, nulldev_write, nulldev_getstat, nulldev_setstat, nulldev_portdeath): New functions. (nomap): Fix prototype. * device/ds_routines.c (dev_close): Pass 0 as flag parameter. * device/kmsg.c (kmsgclose): Drop return value. * device/kmsg.h (kmsgclose): Fix prototype. * i386/i386at/com.c (comopen): Fix prototype. (comclose): Fix prototype, drop return value. (comread, comwrite): Fix prototype. * i386/i386at/com.h (comopen, comclose, comread, comwrite): Fix prototype. * i386/i386at/conf.c (dev_ops): Use nulldev_open, nulldev_close, nulldev_read, nulldev_write, nulldev_getstat, nulldev_setstat, nulldev_portdeath where appropriate. * i386/i386at/kd.c (kdclose, kdread, kdwrite, kdmmap): Fix prototype. * i386/i386at/kd.h (kdclose, kdread, kdwrite, kdmmap): Likewise. * i386/i386at/kd_event.c (kbdopen): Likewise. * i386/i386at/kd_event.h (kbdopen): Likewise. * i386/i386at/kd_mouse.c (mouseopen): Likewise. * i386/i386at/kd_mouse.h (mouseopen): Likewise. * i386/i386at/lpr.c (lpropen, lprclose, lprread, lprwrite): Likewise. * i386/i386at/lpr.h (lpropen, lprclose, lprread, lprwrite): Likewise. * i386/i386at/mem.c (memmmap): Likewise. * i386/i386at/mem.h (memmmap): Likewise. * i386/i386at/model_dep.c (timemmap): Likewise. * i386/i386at/model_dep.h (timemmap): Likewise. * kern/mach_clock.c (timeopen, timeclose): Likewise. * kern/mach_clock.h: Include , predefine struct io_req and io_req_t. (timeopen, timeclose): Fix prototype. --- device/conf.h | 39 +++++++++++++++++++++++++++------------ device/dev_name.c | 38 ++++++++++++++++++++++++++++++++++++-- device/ds_routines.c | 2 +- device/kmsg.c | 3 +-- device/kmsg.h | 2 +- i386/i386at/com.c | 12 ++++++------ i386/i386at/com.h | 8 ++++---- i386/i386at/conf.c | 30 +++++++++++++++--------------- i386/i386at/kd.c | 10 +++++----- i386/i386at/kd.h | 8 ++++---- i386/i386at/kd_event.c | 3 ++- i386/i386at/kd_event.h | 2 +- i386/i386at/kd_mouse.c | 3 ++- i386/i386at/kd_mouse.h | 2 +- i386/i386at/lpr.c | 8 ++++---- i386/i386at/lpr.h | 8 ++++---- i386/i386at/mem.c | 2 +- i386/i386at/mem.h | 2 +- i386/i386at/model_dep.c | 4 ++-- i386/i386at/model_dep.h | 2 +- kern/mach_clock.c | 6 +++--- kern/mach_clock.h | 8 ++++++-- 22 files changed, 128 insertions(+), 74 deletions(-) diff --git a/device/conf.h b/device/conf.h index a0d5010f..fea18223 100644 --- a/device/conf.h +++ b/device/conf.h @@ -32,22 +32,30 @@ #define _DEVICE_CONF_H_ #include +#include +#include +#include + +struct io_req; +typedef struct io_req *io_req_t; + +typedef int io_return_t; /* * Operations list for major device types. */ struct dev_ops { - char * d_name; /* name for major device */ - int (*d_open)(); /* open device */ - int (*d_close)(); /* close device */ - int (*d_read)(); /* read */ - int (*d_write)(); /* write */ - int (*d_getstat)(); /* get status/control */ - int (*d_setstat)(); /* set status/control */ - vm_offset_t (*d_mmap)(); /* map memory */ - int (*d_async_in)();/* asynchronous input setup */ - int (*d_reset)(); /* reset device */ - int (*d_port_death)(); + char * d_name; /* name for major device */ + int (*d_open)(dev_t, int, io_req_t);/* open device */ + void (*d_close)(dev_t, int); /* close device */ + int (*d_read)(dev_t, io_req_t); /* read */ + int (*d_write)(dev_t, io_req_t); /* write */ + int (*d_getstat)(dev_t, int, int *, natural_t *); /* get status/control */ + int (*d_setstat)(dev_t, int, int *, natural_t); /* set status/control */ + int (*d_mmap)(dev_t, vm_offset_t, vm_prot_t); /* map memory */ + int (*d_async_in)(); /* asynchronous input setup */ + int (*d_reset)(); /* reset device */ + int (*d_port_death)(dev_t, mach_port_t); /* clean up reply ports */ int d_subdev; /* number of sub-devices per unit */ @@ -59,8 +67,15 @@ typedef struct dev_ops *dev_ops_t; * Routines for null entries. */ extern int nulldev(void); /* no operation - OK */ +extern int nulldev_open(dev_t dev, int flag, io_req_t ior); +extern void nulldev_close(dev_t dev, int flags); +extern int nulldev_read(dev_t dev, io_req_t ior); +extern int nulldev_write(dev_t dev, io_req_t ior); +extern io_return_t nulldev_getstat(dev_t dev, int flavor, int *data, natural_t *count); +extern io_return_t nulldev_setstat(dev_t dev, int flavor, int *data, natural_t count); +extern io_return_t nulldev_portdeath(dev_t dev, mach_port_t port); extern int nodev(void); /* no operation - error */ -extern vm_offset_t nomap(void); /* no operation - error */ +extern int nomap(dev_t dev, vm_offset_t off, int prot); /* no operation - error */ /* * Flavor constants for d_dev_info routine diff --git a/device/dev_name.c b/device/dev_name.c index 4cc046ab..cd3a28ad 100644 --- a/device/dev_name.c +++ b/device/dev_name.c @@ -44,13 +44,47 @@ int nulldev(void) return (D_SUCCESS); } +int nulldev_open(dev_t dev, int flags, io_req_t ior) +{ + return (D_SUCCESS); +} + +void nulldev_close(dev_t dev, int flags) +{ +} + +int nulldev_read(dev_t dev, io_req_t ior) +{ + return (D_SUCCESS); +} + +int nulldev_write(dev_t dev, io_req_t ior) +{ + return (D_SUCCESS); +} + +io_return_t nulldev_getstat(dev_t dev, int flavor, int *data, natural_t *count) +{ + return (D_SUCCESS); +} + +io_return_t nulldev_setstat(dev_t dev, int flavor, int *data, natural_t count) +{ + return (D_SUCCESS); +} + +int nulldev_portdeath(dev_t dev, mach_port_t port) +{ + return (D_SUCCESS); +} + int nodev(void) { return (D_INVALID_OPERATION); } -vm_offset_t -nomap(void) +int +nomap(dev_t dev, vm_offset_t off, int prot) { return (D_INVALID_OPERATION); } diff --git a/device/ds_routines.c b/device/ds_routines.c index 82b52528..4e04445f 100644 --- a/device/ds_routines.c +++ b/device/ds_routines.c @@ -639,7 +639,7 @@ device_close(device) /* * Close the device */ - (*device->dev_ops->d_close)(device->dev_number); + (*device->dev_ops->d_close)(device->dev_number, 0); /* * Finally mark it closed. If someone else is trying diff --git a/device/kmsg.c b/device/kmsg.c index 40956ddd..c80775d9 100644 --- a/device/kmsg.c +++ b/device/kmsg.c @@ -77,14 +77,13 @@ kmsgopen (dev_t dev, int flag, const io_req_t ior) } /* Kernel Message Close Handler */ -io_return_t +void kmsgclose (dev_t dev, int flag) { simple_lock (&kmsg_lock); kmsg_in_use = FALSE; simple_unlock (&kmsg_lock); - return D_SUCCESS; } static boolean_t kmsg_read_done (io_req_t ior); diff --git a/device/kmsg.h b/device/kmsg.h index b8c1f366..8d907f1b 100644 --- a/device/kmsg.h +++ b/device/kmsg.h @@ -8,7 +8,7 @@ #include io_return_t kmsgopen (dev_t dev, int flag, io_req_t ior); -io_return_t kmsgclose (dev_t dev, int flag); +void kmsgclose (dev_t dev, int flag); io_return_t kmsgread (dev_t dev, io_req_t ior); io_return_t kmsggetstat (dev_t dev, int flavor, int *data, unsigned int *count); diff --git a/i386/i386at/com.c b/i386/i386at/com.c index 6edbca08..07521f92 100644 --- a/i386/i386at/com.c +++ b/i386/i386at/com.c @@ -319,7 +319,7 @@ boolean_t com_reprobe( } io_return_t comopen( - int dev, + dev_t dev, int flag, io_req_t ior) { @@ -400,8 +400,8 @@ io_return_t comopen( return result; } -io_return_t comclose(dev, flag) -int dev; +void comclose(dev, flag) +dev_t dev; int flag; { struct tty *tp = &com_tty[minor(dev)]; @@ -416,18 +416,18 @@ int flag; if (comfifo[minor(dev)] != 0) outb(INTR_ID(addr), 0x00); /* Disable fifos */ } - return 0; + return; } io_return_t comread(dev, ior) -int dev; +dev_t dev; io_req_t ior; { return char_read(&com_tty[minor(dev)], ior); } io_return_t comwrite(dev, ior) -int dev; +dev_t dev; io_req_t ior; { return char_write(&com_tty[minor(dev)], ior); diff --git a/i386/i386at/com.h b/i386/i386at/com.h index 81fccfa6..95baa457 100644 --- a/i386/i386at/com.h +++ b/i386/i386at/com.h @@ -71,10 +71,10 @@ comsetstat( int *data, natural_t count); -extern io_return_t comopen(int dev, int flag, io_req_t ior); -extern io_return_t comclose(int dev, int flag); -extern io_return_t comread(int dev, io_req_t ior); -extern io_return_t comwrite(int dev, io_req_t ior); +extern io_return_t comopen(dev_t dev, int flag, io_req_t ior); +extern void comclose(dev_t dev, int flag); +extern io_return_t comread(dev_t dev, io_req_t ior); +extern io_return_t comwrite(dev_t dev, io_req_t ior); extern io_return_t comportdeath(dev_t dev, mach_port_t port); #endif /* _COM_H_ */ diff --git a/i386/i386at/conf.c b/i386/i386at/conf.c index 4fcd81e5..ab4f6807 100644 --- a/i386/i386at/conf.c +++ b/i386/i386at/conf.c @@ -81,9 +81,9 @@ struct dev_ops dev_name_list[] = /* We don't assign a console here, when we find one via cninit() we stick something appropriate here through the indirect list */ - { "cn", nulldev, nulldev, nulldev, - nulldev, nulldev, nulldev, nomap, - nodev, nulldev, nulldev, 0, + { "cn", nulldev_open, nulldev_close, nulldev_read, + nulldev_write, nulldev_getstat, nulldev_setstat, nomap, + nodev, nulldev, nulldev_portdeath, 0, nodev }, #ifndef MACH_HYP @@ -93,9 +93,9 @@ struct dev_ops dev_name_list[] = nodev }, #endif /* MACH_HYP */ - { timename, timeopen, timeclose, nulldev, - nulldev, nulldev, nulldev, timemmap, - nodev, nulldev, nulldev, 0, + { timename, timeopen, timeclose, nulldev_read, + nulldev_write, nulldev_getstat, nulldev_setstat, timemmap, + nodev, nulldev, nulldev_portdeath, 0, nodev }, #ifndef MACH_HYP @@ -114,25 +114,25 @@ struct dev_ops dev_name_list[] = #endif { mousename, mouseopen, mouseclose, mouseread, - nodev, mousegetstat, nulldev, nomap, - nodev, nulldev, nulldev, 0, + nulldev_write, mousegetstat, nulldev_setstat, nomap, + nodev, nulldev, nulldev_portdeath, 0, nodev }, { kbdname, kbdopen, kbdclose, kbdread, - nodev, kbdgetstat, kbdsetstat, nomap, - nodev, nulldev, nulldev, 0, + nulldev_write, kbdgetstat, kbdsetstat, nomap, + nodev, nulldev, nulldev_portdeath, 0, nodev }, - { memname, nulldev, nulldev, nodev, - nodev, nodev, nodev, memmmap, - nodev, nulldev, nulldev, 0, + { memname, nulldev_open, nulldev_close, nulldev_read, + nulldev_write, nulldev_getstat, nulldev_setstat, memmmap, + nodev, nulldev, nulldev_portdeath, 0, nodev }, #endif /* MACH_HYP */ #ifdef MACH_KMSG { kmsgname, kmsgopen, kmsgclose, kmsgread, - nodev, kmsggetstat, nodev, nomap, - nodev, nulldev, nulldev, 0, + nulldev_write, kmsggetstat, nulldev_setstat, nomap, + nodev, nulldev, nulldev_portdeath, 0, nodev }, #endif diff --git a/i386/i386at/kd.c b/i386/i386at/kd.c index acd69f7d..0de1e505 100644 --- a/i386/i386at/kd.c +++ b/i386/i386at/kd.c @@ -487,7 +487,7 @@ kdopen(dev, flag, ior) /*ARGSUSED*/ void kdclose(dev, flag) -int dev; +dev_t dev; int flag; { struct tty *tp; @@ -519,7 +519,7 @@ int flag; /*ARGSUSED*/ int kdread(dev, uio) -int dev; +dev_t dev; io_req_t uio; { struct tty *tp; @@ -544,7 +544,7 @@ io_req_t uio; /*ARGSUSED*/ int kdwrite(dev, uio) -int dev; +dev_t dev; io_req_t uio; { return((*linesw[kd_tty.t_line].l_write)(&kd_tty, uio)); @@ -558,8 +558,8 @@ io_req_t uio; int kdmmap(dev, off, prot) dev_t dev; - off_t off; - int prot; + vm_offset_t off; + vm_prot_t prot; { if (off >= (128*1024)) return(-1); diff --git a/i386/i386at/kd.h b/i386/i386at/kd.h index 6c869d68..4ac93c7b 100644 --- a/i386/i386at/kd.h +++ b/i386/i386at/kd.h @@ -752,9 +752,9 @@ extern void kdb_kintr(void); #endif /* MACH_KDB */ extern int kdopen(dev_t dev, int flag, io_req_t ior); -extern void kdclose(int dev, int flag); -extern int kdread(int dev, io_req_t uio); -extern int kdwrite(int dev, io_req_t uio); +extern void kdclose(dev_t dev, int flag); +extern int kdread(dev_t dev, io_req_t uio); +extern int kdwrite(dev_t dev, io_req_t uio); extern io_return_t kdgetstat( dev_t dev, @@ -769,7 +769,7 @@ extern io_return_t kdsetstat( natural_t count); extern int kdportdeath(dev_t dev, mach_port_t port); -extern int kdmmap(dev_t dev, off_t off, int prot); +extern int kdmmap(dev_t dev, vm_offset_t off, vm_prot_t prot); boolean_t kdcheckmagic(Scancode scancode); diff --git a/i386/i386at/kd_event.c b/i386/i386at/kd_event.c index 30a7f77d..2a75f958 100644 --- a/i386/i386at/kd_event.c +++ b/i386/i386at/kd_event.c @@ -110,9 +110,10 @@ kbdinit(void) /*ARGSUSED*/ int -kbdopen(dev, flags) +kbdopen(dev, flags, ior) dev_t dev; int flags; + io_req_t ior; { spl_t o_pri = spltty(); kdinit(); diff --git a/i386/i386at/kd_event.h b/i386/i386at/kd_event.h index 9568fa56..8b2d6642 100644 --- a/i386/i386at/kd_event.h +++ b/i386/i386at/kd_event.h @@ -34,7 +34,7 @@ extern void X_kdb_enter (void); extern void X_kdb_exit (void); -extern int kbdopen(dev_t dev, int flags); +extern int kbdopen(dev_t dev, int flags, io_req_t ior); extern void kbdclose(dev_t dev, int flags); extern int kbdread(dev_t dev, io_req_t ior); diff --git a/i386/i386at/kd_mouse.c b/i386/i386at/kd_mouse.c index d09d7a71..8b1222da 100644 --- a/i386/i386at/kd_mouse.c +++ b/i386/i386at/kd_mouse.c @@ -147,9 +147,10 @@ int track_man[10]; /*ARGSUSED*/ int -mouseopen(dev, flags) +mouseopen(dev, flags, ior) dev_t dev; int flags; + io_req_t ior; { if (mouse_in_use) return (D_ALREADY_OPEN); diff --git a/i386/i386at/kd_mouse.h b/i386/i386at/kd_mouse.h index ad07c6c8..a8a72a3b 100644 --- a/i386/i386at/kd_mouse.h +++ b/i386/i386at/kd_mouse.h @@ -54,7 +54,7 @@ extern void mouse_packet_mouse_system_mouse (u_char *mousebuf); extern void mouse_packet_ibm_ps2_mouse (u_char *mousebuf); -extern int mouseopen(dev_t dev, int flags); +extern int mouseopen(dev_t dev, int flags, io_req_t ior); extern void mouseclose(dev_t dev, int flags); extern int mouseread(dev_t dev, io_req_t ior); diff --git a/i386/i386at/lpr.c b/i386/i386at/lpr.c index 218f20df..1f95a3f2 100644 --- a/i386/i386at/lpr.c +++ b/i386/i386at/lpr.c @@ -106,7 +106,7 @@ void lprattach(struct bus_device *dev) int lpropen(dev, flag, ior) -int dev; +dev_t dev; int flag; io_req_t ior; { @@ -135,7 +135,7 @@ u_short addr; void lprclose(dev, flag) -int dev; +dev_t dev; int flag; { int unit = minor(dev); @@ -151,7 +151,7 @@ u_short addr = (u_short) lprinfo[unit]->address; int lprread(dev, ior) -int dev; +dev_t dev; io_req_t ior; { return char_read(&lpr_tty[minor(dev)], ior); @@ -159,7 +159,7 @@ io_req_t ior; int lprwrite(dev, ior) -int dev; +dev_t dev; io_req_t ior; { return char_write(&lpr_tty[minor(dev)], ior); diff --git a/i386/i386at/lpr.h b/i386/i386at/lpr.h index d2b9d4bf..269fd643 100644 --- a/i386/i386at/lpr.h +++ b/i386/i386at/lpr.h @@ -57,10 +57,10 @@ lprsetstat( void lprpr_addr(unsigned short addr); -extern int lpropen(int dev, int flag, io_req_t ior); -extern void lprclose(int dev, int flag); -extern int lprread(int dev, io_req_t ior); -extern int lprwrite(int dev, io_req_t ior); +extern int lpropen(dev_t dev, int flag, io_req_t ior); +extern void lprclose(dev_t dev, int flag); +extern int lprread(dev_t dev, io_req_t ior); +extern int lprwrite(dev_t dev, io_req_t ior); extern int lprportdeath(dev_t dev, mach_port_t port); #endif /* _LPRREG_H_ */ diff --git a/i386/i386at/mem.c b/i386/i386at/mem.c index 5e51676b..f239afac 100644 --- a/i386/i386at/mem.c +++ b/i386/i386at/mem.c @@ -32,7 +32,7 @@ /*ARGSUSED*/ int memmmap(dev, off, prot) -int dev; +dev_t dev; vm_offset_t off; vm_prot_t prot; { diff --git a/i386/i386at/mem.h b/i386/i386at/mem.h index 3d6a96cb..0bc85ea4 100644 --- a/i386/i386at/mem.h +++ b/i386/i386at/mem.h @@ -19,6 +19,6 @@ #ifndef _MEM_H_ #define _MEM_H_ -extern int memmmap(int dev, vm_offset_t off, vm_prot_t prot); +extern int memmmap(dev_t dev, vm_offset_t off, vm_prot_t prot); #endif /* _MEM_H_ */ diff --git a/i386/i386at/model_dep.c b/i386/i386at/model_dep.c index 10c0c41d..128f2504 100644 --- a/i386/i386at/model_dep.c +++ b/i386/i386at/model_dep.c @@ -616,8 +616,8 @@ void c_boot_entry(vm_offset_t bi) int timemmap(dev, off, prot) - int dev; - int off; + dev_t dev; + vm_offset_t off; vm_prot_t prot; { extern time_value_t *mtime; diff --git a/i386/i386at/model_dep.h b/i386/i386at/model_dep.h index 37cd86c9..aa240320 100644 --- a/i386/i386at/model_dep.h +++ b/i386/i386at/model_dep.h @@ -21,7 +21,7 @@ #include -extern int timemmap(int dev, int off, vm_prot_t prot); +extern int timemmap(dev_t dev, vm_offset_t off, vm_prot_t prot); void inittodr(void); diff --git a/kern/mach_clock.c b/kern/mach_clock.c index c68b460d..f4a77145 100644 --- a/kern/mach_clock.c +++ b/kern/mach_clock.c @@ -499,13 +499,13 @@ void mapable_time_init(void) update_mapped_time(&time); } -int timeopen(void) +int timeopen(dev_t dev, int flag, io_req_t ior) { return(0); } -int timeclose(void) +void timeclose(dev_t dev, int flag) { - return(0); + return; } /* diff --git a/kern/mach_clock.h b/kern/mach_clock.h index 827cf861..89fd3352 100644 --- a/kern/mach_clock.h +++ b/kern/mach_clock.h @@ -29,6 +29,10 @@ #include #include #include +#include + +struct io_req; +typedef struct io_req *io_req_t; /* Timers in kernel. */ @@ -104,7 +108,7 @@ extern void mapable_time_init (void); extern void timeout(timer_func_t *fcn, void *param, int interval); extern boolean_t untimeout(timer_func_t *fcn, const void *param); -extern int timeopen(void); -extern int timeclose(void); +extern int timeopen(dev_t dev, int flag, io_req_t ior); +extern void timeclose(dev_t dev, int flag); #endif /* _KERN_MACH_CLOCK_H_ */ -- cgit v1.2.3 From 2aa14940b85cd3a38eff6ad4471ebf40a0074cb2 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Fri, 4 Apr 2014 22:14:50 +0200 Subject: Fix prototype * linux/dev/glue/block.c (device_set_status): Fix prototype. --- linux/dev/glue/block.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux/dev/glue/block.c b/linux/dev/glue/block.c index ce4c633d..79a3646e 100644 --- a/linux/dev/glue/block.c +++ b/linux/dev/glue/block.c @@ -1704,7 +1704,7 @@ device_get_status (void *d, dev_flavor_t flavor, dev_status_t status, static io_return_t device_set_status (void *d, dev_flavor_t flavor, dev_status_t status, - mach_msg_type_number_t *status_count) + mach_msg_type_number_t status_count) { struct block_data *bd = d; -- cgit v1.2.3 From fe0231ba14d8597b0d78bf6121dd15a82bbab34a Mon Sep 17 00:00:00 2001 From: Marin Ramesa Date: Fri, 4 Apr 2014 22:32:14 +0200 Subject: Convert from K&R to ANSI Convert from K&R style function definitions to ANSI style function definitions. * ddb/db_access.c: Convert function prototypes from K&R to ANSI. * ddb/db_aout.c: Likewise. * ddb/db_break.c: Likewise. * ddb/db_command.c: Likewise. * ddb/db_cond.c: Likewise. * ddb/db_examine.c: Likewise. * ddb/db_expr.c: Likewise. * ddb/db_ext_symtab.c: Likewise. * ddb/db_input.c: Likewise. * ddb/db_lex.c: Likewise. * ddb/db_macro.c: Likewise. * ddb/db_mp.c: Likewise. * ddb/db_output.c: Likewise. * ddb/db_print.c: Likewise. * ddb/db_run.c: Likewise. * ddb/db_sym.c: Likewise. * ddb/db_task_thread.c: Likewise. * ddb/db_trap.c: Likewise. * ddb/db_variables.c: Likewise. * ddb/db_watch.c: Likewise. * device/blkio.c: Likewise. * device/chario.c: Likewise. * device/dev_lookup.c: Likewise. * device/dev_name.c: Likewise. * device/dev_pager.c: Likewise. * device/ds_routines.c: Likewise. * device/net_io.c: Likewise. * device/subrs.c: Likewise. * i386/i386/db_interface.c: Likewise. * i386/i386/fpu.c: Likewise. * i386/i386/io_map.c: Likewise. * i386/i386/loose_ends.c: Likewise. * i386/i386/mp_desc.c: Likewise. * i386/i386/pcb.c: Likewise. * i386/i386/phys.c: Likewise. * i386/i386/trap.c: Likewise. * i386/i386/user_ldt.c: Likewise. * i386/i386at/com.c: Likewise. * i386/i386at/kd.c: Likewise. * i386/i386at/kd_event.c: Likewise. * i386/i386at/kd_mouse.c: Likewise. * i386/i386at/kd_queue.c: Likewise. * i386/i386at/lpr.c: Likewise. * i386/i386at/model_dep.c: Likewise. * i386/i386at/rtc.c: Likewise. * i386/intel/pmap.c: Likewise. * i386/intel/read_fault.c: Likewise. * ipc/ipc_entry.c: Likewise. * ipc/ipc_hash.c: Likewise. * ipc/ipc_kmsg.c: Likewise. * ipc/ipc_marequest.c: Likewise. * ipc/ipc_mqueue.c: Likewise. * ipc/ipc_notify.c: Likewise. * ipc/ipc_port.c: Likewise. * ipc/ipc_right.c: Likewise. * ipc/mach_debug.c: Likewise. * ipc/mach_msg.c: Likewise. * ipc/mach_port.c: Likewise. * ipc/mach_rpc.c: Likewise. * kern/act.c: Likewise. * kern/exception.c: Likewise. * kern/ipc_mig.c: Likewise. * kern/ipc_tt.c: Likewise. * kern/lock_mon.c: Likewise. * kern/mach_clock.c: Likewise. * kern/machine.c: Likewise. * kern/printf.c: Likewise. * kern/priority.c: Likewise. * kern/startup.c: Likewise. * kern/syscall_emulation.c: Likewise. * kern/syscall_subr.c: Likewise. * kern/thread_swap.c: Likewise. * kern/time_stamp.c: Likewise. * kern/timer.c: Likewise. * kern/xpr.c: Likewise. * vm/memory_object.c: Likewise. * vm/vm_debug.c: Likewise. * vm/vm_external.c: Likewise. * vm/vm_fault.c: Likewise. * vm/vm_kern.c: Likewise. * vm/vm_map.c: Likewise. * vm/vm_pageout.c: Likewise. * vm/vm_user.c: Likewise. --- ddb/db_access.c | 36 ++--- ddb/db_aout.c | 36 ++--- ddb/db_break.c | 32 ++--- ddb/db_command.c | 21 ++- ddb/db_cond.c | 6 +- ddb/db_examine.c | 30 ++--- ddb/db_expr.c | 28 ++-- ddb/db_ext_symtab.c | 12 +- ddb/db_input.c | 15 +-- ddb/db_lex.c | 15 +-- ddb/db_macro.c | 10 +- ddb/db_mp.c | 3 +- ddb/db_output.c | 3 +- ddb/db_print.c | 32 ++--- ddb/db_run.c | 24 ++-- ddb/db_sym.c | 64 +++++---- ddb/db_task_thread.c | 25 ++-- ddb/db_trap.c | 12 +- ddb/db_variables.c | 22 ++- ddb/db_watch.c | 8 +- device/blkio.c | 11 +- device/chario.c | 3 +- device/dev_lookup.c | 24 ++-- device/dev_name.c | 8 +- device/dev_pager.c | 3 +- device/ds_routines.c | 58 ++++---- device/net_io.c | 109 ++++++++------- device/subrs.c | 3 +- i386/i386/db_interface.c | 5 +- i386/i386/fpu.c | 9 +- i386/i386/io_map.c | 6 +- i386/i386/loose_ends.c | 3 +- i386/i386/mp_desc.c | 3 +- i386/i386/pcb.c | 67 +++++----- i386/i386/phys.c | 25 ++-- i386/i386/trap.c | 17 +-- i386/i386/user_ldt.c | 15 +-- i386/i386at/com.c | 30 ++--- i386/i386at/kd.c | 186 ++++++++++++-------------- i386/i386at/kd_event.c | 53 ++++---- i386/i386at/kd_mouse.c | 78 +++++------ i386/i386at/kd_queue.c | 6 +- i386/i386at/lpr.c | 22 ++- i386/i386at/model_dep.c | 9 +- i386/i386at/rtc.c | 18 +-- i386/intel/pmap.c | 151 ++++++++++----------- i386/intel/read_fault.c | 6 +- ipc/ipc_entry.c | 17 ++- ipc/ipc_hash.c | 10 +- ipc/ipc_kmsg.c | 130 +++++++++--------- ipc/ipc_marequest.c | 34 ++--- ipc/ipc_mqueue.c | 8 +- ipc/ipc_notify.c | 42 +++--- ipc/ipc_port.c | 25 ++-- ipc/ipc_right.c | 38 +++--- ipc/mach_debug.c | 10 +- ipc/mach_msg.c | 45 +++---- ipc/mach_port.c | 70 +++++----- ipc/mach_rpc.c | 7 +- kern/act.c | 23 ++-- kern/exception.c | 42 +++--- kern/ipc_mig.c | 128 ++++++++---------- kern/ipc_tt.c | 54 +++----- kern/lock_mon.c | 1 - kern/mach_clock.c | 25 ++-- kern/machine.c | 48 +++---- kern/printf.c | 6 +- kern/priority.c | 10 +- kern/startup.c | 3 +- kern/syscall_emulation.c | 46 +++---- kern/syscall_subr.c | 25 ++-- kern/thread_swap.c | 6 +- kern/time_stamp.c | 3 +- kern/timer.c | 67 +++++----- kern/xpr.c | 16 ++- vm/memory_object.c | 138 +++++++++---------- vm/vm_debug.c | 31 +++-- vm/vm_external.c | 14 +- vm/vm_fault.c | 106 +++++++-------- vm/vm_kern.c | 180 +++++++++++++------------ vm/vm_map.c | 342 +++++++++++++++++++++++------------------------ vm/vm_pageout.c | 20 +-- vm/vm_user.c | 117 ++++++++-------- 83 files changed, 1527 insertions(+), 1722 deletions(-) diff --git a/ddb/db_access.c b/ddb/db_access.c index 4df98317..16d4d3ef 100644 --- a/ddb/db_access.c +++ b/ddb/db_access.c @@ -62,11 +62,11 @@ static int db_extend[sizeof(int)+1] = { /* table for sign-extending */ }; db_expr_t -db_get_task_value(addr, size, is_signed, task) - db_addr_t addr; - int size; - boolean_t is_signed; - task_t task; +db_get_task_value( + db_addr_t addr, + int size, + boolean_t is_signed, + task_t task) { char data[sizeof(db_expr_t)]; db_expr_t value; @@ -92,11 +92,11 @@ db_get_task_value(addr, size, is_signed, task) } void -db_put_task_value(addr, size, value, task) - db_addr_t addr; - int size; - db_expr_t value; - task_t task; +db_put_task_value( + db_addr_t addr, + int size, + db_expr_t value, + task_t task) { char data[sizeof(db_expr_t)]; int i; @@ -115,19 +115,19 @@ db_put_task_value(addr, size, value, task) } db_expr_t -db_get_value(addr, size, is_signed) - db_addr_t addr; - int size; - boolean_t is_signed; +db_get_value( + db_addr_t addr, + int size, + boolean_t is_signed) { return(db_get_task_value(addr, size, is_signed, TASK_NULL)); } void -db_put_value(addr, size, value) - db_addr_t addr; - int size; - db_expr_t value; +db_put_value( + db_addr_t addr, + int size, + db_expr_t value) { db_put_task_value(addr, size, value, TASK_NULL); } diff --git a/ddb/db_aout.c b/ddb/db_aout.c index 87ba9753..d3f2e31e 100644 --- a/ddb/db_aout.c +++ b/ddb/db_aout.c @@ -70,13 +70,13 @@ ep = (struct nlist *)((char *)sp + *((int*)symtab))) boolean_t -aout_db_sym_init(symtab, esymtab, name, task_addr) - char * symtab; /* pointer to start of symbol table */ - char * esymtab; /* pointer to end of string table, +aout_db_sym_init( + char * symtab, /* pointer to start of symbol table */ + char * esymtab, /* pointer to end of string table, for checking - may be rounded up to integer boundary */ - char * name; - char * task_addr; /* use for this task only */ + char * name, + char * task_addr) /* use for this task only */ { struct nlist *sym_start, *sym_end; struct nlist *sp; @@ -313,19 +313,19 @@ aout_db_qualified_search(stab, file, sym, line) * lookup symbol by name */ db_sym_t -aout_db_lookup(stab, symstr) - db_symtab_t *stab; - char * symstr; +aout_db_lookup( + db_symtab_t *stab, + char * symstr) { return(db_sym_parse_and_lookup(aout_db_qualified_search, stab, symstr)); } db_sym_t -aout_db_search_symbol(symtab, off, strategy, diffp) - db_symtab_t * symtab; - db_addr_t off; - db_strategy_t strategy; - db_expr_t *diffp; /* in/out */ +aout_db_search_symbol( + db_symtab_t * symtab, + db_addr_t off, + db_strategy_t strategy, + db_expr_t *diffp) /* in/out */ { unsigned long diff = *diffp; struct nlist *symp = 0; @@ -374,11 +374,11 @@ aout_db_search_symbol(symtab, off, strategy, diffp) * Return the name and value for a symbol. */ void -aout_db_symbol_values(stab, sym, namep, valuep) - db_symtab_t *stab; - db_sym_t sym; - char **namep; - db_expr_t *valuep; +aout_db_symbol_values( + db_symtab_t *stab, + db_sym_t sym, + char **namep, + db_expr_t *valuep) { struct nlist *sp; diff --git a/ddb/db_break.c b/ddb/db_break.c index 0534f686..c3a9e181 100644 --- a/ddb/db_break.c +++ b/ddb/db_break.c @@ -121,9 +121,9 @@ db_add_thread_breakpoint(bkpt, task_thd, count, task_bpt) } static int -db_delete_thread_breakpoint(bkpt, task_thd) - db_breakpoint_t bkpt; - vm_offset_t task_thd; +db_delete_thread_breakpoint( + db_breakpoint_t bkpt, + vm_offset_t task_thd) { db_thread_breakpoint_t tp; db_thread_breakpoint_t *tpp; @@ -188,9 +188,9 @@ db_find_thread_breakpoint_here(task, addr) } db_thread_breakpoint_t -db_find_breakpoint_number(num, bkptp) - int num; - db_breakpoint_t *bkptp; +db_find_breakpoint_number( + int num, + db_breakpoint_t *bkptp) { db_thread_breakpoint_t tp; db_breakpoint_t bkpt; @@ -208,10 +208,10 @@ db_find_breakpoint_number(num, bkptp) } static void -db_force_delete_breakpoint(bkpt, task_thd, is_task) - db_breakpoint_t bkpt; - vm_offset_t task_thd; - boolean_t is_task; +db_force_delete_breakpoint( + db_breakpoint_t bkpt, + vm_offset_t task_thd, + boolean_t is_task) { db_printf("deleted a stale breakpoint at "); if (bkpt->task == TASK_NULL || db_lookup_task(bkpt->task) >= 0) @@ -482,9 +482,9 @@ db_clear_breakpoints(void) * so the breakpoint does not have to be on the breakpoint list. */ db_breakpoint_t -db_set_temp_breakpoint(task, addr) - task_t task; - db_addr_t addr; +db_set_temp_breakpoint( + task_t task, + db_addr_t addr) { db_breakpoint_t bkpt; @@ -511,9 +511,9 @@ db_set_temp_breakpoint(task, addr) } void -db_delete_temp_breakpoint(task, bkpt) - task_t task; - db_breakpoint_t bkpt; +db_delete_temp_breakpoint( + task_t task, + db_breakpoint_t bkpt) { db_put_task_value(bkpt->address, BKPT_SIZE, bkpt->bkpt_inst, task); db_delete_thread_breakpoint(bkpt, 0); diff --git a/ddb/db_command.c b/ddb/db_command.c index 3879ec5c..ebb13dfd 100644 --- a/ddb/db_command.c +++ b/ddb/db_command.c @@ -153,9 +153,9 @@ db_cmd_list(table) } void -db_command(last_cmdp, cmd_table) - struct db_command **last_cmdp; /* IN_OUT */ - struct db_command *cmd_table; +db_command( + struct db_command **last_cmdp, /* IN_OUT */ + struct db_command *cmd_table) { struct db_command *cmd; int t; @@ -293,9 +293,9 @@ db_command(last_cmdp, cmd_table) } void -db_command_list(last_cmdp, cmd_table) - struct db_command **last_cmdp; /* IN_OUT */ - struct db_command *cmd_table; +db_command_list( + struct db_command **last_cmdp, /* IN_OUT */ + struct db_command *cmd_table) { do { db_command(last_cmdp, cmd_table); @@ -370,8 +370,7 @@ struct db_command db_command_table[] = { /* this function should be called to install the machine dependent commands. It should be called before the debugger is enabled */ -void db_machine_commands_install(ptr) -struct db_command *ptr; +void db_machine_commands_install(struct db_command *ptr) { db_command_table[0].more = ptr; return; @@ -429,9 +428,9 @@ db_command_loop(void) } boolean_t -db_exec_cmd_nest(cmd, size) - char *cmd; - int size; +db_exec_cmd_nest( + char *cmd, + int size) { struct db_lex_context lex_context; diff --git a/ddb/db_cond.c b/ddb/db_cond.c index 2c923b4d..31e1d241 100644 --- a/ddb/db_cond.c +++ b/ddb/db_cond.c @@ -48,8 +48,7 @@ struct db_cond { } db_cond[DB_MAX_COND]; void -db_cond_free(bkpt) - db_thread_breakpoint_t bkpt; +db_cond_free(db_thread_breakpoint_t bkpt) { if (bkpt->tb_cond > 0) { db_cond[bkpt->tb_cond-1].c_size = 0; @@ -59,8 +58,7 @@ db_cond_free(bkpt) } boolean_t -db_cond_check(bkpt) - db_thread_breakpoint_t bkpt; +db_cond_check(db_thread_breakpoint_t bkpt) { struct db_cond *cp; db_expr_t value; diff --git a/ddb/db_examine.c b/ddb/db_examine.c index cb103aed..836b0e89 100644 --- a/ddb/db_examine.c +++ b/ddb/db_examine.c @@ -321,9 +321,9 @@ db_print_cmd(void) } void -db_print_loc_and_inst(loc, task) - db_addr_t loc; - task_t task; +db_print_loc_and_inst( + db_addr_t loc, + task_t task) { db_task_printsym(loc, DB_STGY_PROC, task); db_printf(":\t"); @@ -425,13 +425,13 @@ db_search_cmd(void) } void -db_search(addr, size, value, mask, count, task) - db_addr_t addr; - int size; - db_expr_t value; - db_expr_t mask; - unsigned int count; - task_t task; +db_search( + db_addr_t addr, + int size, + db_expr_t value, + db_expr_t mask, + unsigned int count, + task_t task) { while (count-- != 0) { db_prev = addr; @@ -445,11 +445,11 @@ db_search(addr, size, value, mask, count, task) #define DB_XCDUMP_NC 16 int -db_xcdump(addr, size, count, task) - db_addr_t addr; - int size; - int count; - task_t task; +db_xcdump( + db_addr_t addr, + int size, + int count, + task_t task) { int i, n; db_expr_t value; diff --git a/ddb/db_expr.c b/ddb/db_expr.c index dad09e5c..c9e6752a 100644 --- a/ddb/db_expr.c +++ b/ddb/db_expr.c @@ -41,10 +41,8 @@ #include #include - boolean_t -db_term(valuep) - db_expr_t *valuep; +db_term(db_expr_t *valuep) { int t; @@ -127,8 +125,7 @@ db_size_option(modif, u_option, t_option) } boolean_t -db_unary(valuep) - db_expr_t *valuep; +db_unary(db_expr_t *valuep) { int t; int size; @@ -177,8 +174,7 @@ db_unary(valuep) } boolean_t -db_mult_expr(valuep) - db_expr_t *valuep; +db_mult_expr(db_expr_t *valuep) { db_expr_t lhs = 0, rhs; int t; @@ -223,8 +219,7 @@ db_mult_expr(valuep) } boolean_t -db_add_expr(valuep) - db_expr_t *valuep; +db_add_expr(db_expr_t *valuep) { db_expr_t lhs, rhs; int t; @@ -255,8 +250,7 @@ db_add_expr(valuep) } boolean_t -db_shift_expr(valuep) - db_expr_t *valuep; +db_shift_expr(db_expr_t *valuep) { db_expr_t lhs, rhs; int t; @@ -290,8 +284,7 @@ db_shift_expr(valuep) } boolean_t -db_logical_relation_expr(valuep) - db_expr_t *valuep; +db_logical_relation_expr(db_expr_t *valuep) { db_expr_t lhs, rhs; int t; @@ -340,8 +333,7 @@ db_logical_relation_expr(valuep) } boolean_t -db_logical_and_expr(valuep) - db_expr_t *valuep; +db_logical_and_expr(db_expr_t *valuep) { db_expr_t lhs, rhs; int t; @@ -363,8 +355,7 @@ db_logical_and_expr(valuep) } boolean_t -db_logical_or_expr(valuep) - db_expr_t *valuep; +db_logical_or_expr(db_expr_t *valuep) { db_expr_t lhs, rhs; int t; @@ -386,8 +377,7 @@ db_logical_or_expr(valuep) } int -db_expression(valuep) - db_expr_t *valuep; +db_expression(db_expr_t *valuep) { return (db_logical_or_expr(valuep)); } diff --git a/ddb/db_ext_symtab.c b/ddb/db_ext_symtab.c index 9831a01c..cafb0c4c 100644 --- a/ddb/db_ext_symtab.c +++ b/ddb/db_ext_symtab.c @@ -46,12 +46,12 @@ * the caller and the kernel debugger agree on its format. */ kern_return_t -host_load_symbol_table(host, task, name, symtab, symtab_count) - host_t host; - task_t task; - char * name; - pointer_t symtab; - unsigned int symtab_count; +host_load_symbol_table( + host_t host, + task_t task, + char * name, + pointer_t symtab, + unsigned int symtab_count) { kern_return_t result; vm_offset_t symtab_start; diff --git a/ddb/db_input.c b/ddb/db_input.c index f908705d..6b6db764 100644 --- a/ddb/db_input.c +++ b/ddb/db_input.c @@ -91,9 +91,9 @@ db_putnchars(c, count) #define DEL_FWD 0 #define DEL_BWD 1 void -db_delete(n, bwd) - int n; - int bwd; +db_delete( + int n, + int bwd) { char *p; @@ -137,8 +137,7 @@ db_delete_line(void) /* returns TRUE at end-of-line */ boolean_t -db_inputchar(c) - int c; +db_inputchar(int c) { switch (c) { case CTRL('b'): @@ -328,9 +327,9 @@ db_inputchar(c) } int -db_readline(lstart, lsize) - char * lstart; - int lsize; +db_readline( + char * lstart, + int lsize) { db_force_whitespace(); /* synch output position */ diff --git a/ddb/db_lex.c b/ddb/db_lex.c index e7f67d29..8ab69106 100644 --- a/ddb/db_lex.c +++ b/ddb/db_lex.c @@ -82,9 +82,9 @@ db_flush_line(void) } void -db_switch_input(buffer, size) - char *buffer; - int size; +db_switch_input( + char *buffer, + int size) { db_lp = buffer; db_last_lp = db_lp; @@ -94,8 +94,7 @@ db_switch_input(buffer, size) } void -db_save_lex_context(lp) - struct db_lex_context *lp; +db_save_lex_context(struct db_lex_context *lp) { lp->l_ptr = db_lp; lp->l_eptr = db_endlp; @@ -131,15 +130,13 @@ db_read_char(void) } void -db_unread_char(c) - int c; +db_unread_char(int c) { db_look_char = c; } void -db_unread_token(t) - int t; +db_unread_token(int t) { db_look_token = t; } diff --git a/ddb/db_macro.c b/ddb/db_macro.c index e22f6bf3..307b7c59 100644 --- a/ddb/db_macro.c +++ b/ddb/db_macro.c @@ -167,11 +167,11 @@ db_exec_macro(name) void /* ARGSUSED */ -db_arg_variable(vp, valuep, flag, ap) - struct db_variable *vp; - db_expr_t *valuep; - int flag; - db_var_aux_param_t ap; +db_arg_variable( + struct db_variable *vp, + db_expr_t *valuep, + int flag, + db_var_aux_param_t ap) { if (ap->level != 1 || ap->suffix[0] < 1 || ap->suffix[0] > DB_NARGS) { db_error("Bad $arg variable\n"); diff --git a/ddb/db_mp.c b/ddb/db_mp.c index ae82c27d..8d1a5605 100644 --- a/ddb/db_mp.c +++ b/ddb/db_mp.c @@ -210,8 +210,7 @@ remote_db(void) { * switch to another cpu */ void -db_on(cpu) - int cpu; +db_on(int cpu) { /* * Save ddb global variables diff --git a/ddb/db_output.c b/ddb/db_output.c index f2829cc4..be5319d2 100644 --- a/ddb/db_output.c +++ b/ddb/db_output.c @@ -132,8 +132,7 @@ db_more(void) * Output character. Buffer whitespace. */ void -db_putchar(c) - int c; /* character to output */ +db_putchar(int c) /* character to output */ { if (db_max_line >= DB_MIN_MAX_LINE && db_output_line >= db_max_line-1) db_more(); diff --git a/ddb/db_print.c b/ddb/db_print.c index 17ca2ccf..c015d84b 100644 --- a/ddb/db_print.c +++ b/ddb/db_print.c @@ -57,11 +57,11 @@ extern unsigned long db_maxoff; /* ARGSUSED */ void -db_show_regs(addr, have_addr, count, modif) - db_expr_t addr; - boolean_t have_addr; - db_expr_t count; - char *modif; +db_show_regs( + db_expr_t addr, + boolean_t have_addr, + db_expr_t count, + char *modif) { struct db_variable *regp; db_expr_t value; @@ -144,10 +144,10 @@ db_thread_stat(thread, status) } void -db_print_thread(thread, thread_id, flag) - thread_t thread; - int thread_id; - int flag; +db_print_thread( + thread_t thread, + int thread_id, + int flag) { if (flag & OPTION_USER) { char status[8]; @@ -220,10 +220,10 @@ db_print_thread(thread, thread_id, flag) } void -db_print_task(task, task_id, flag) - task_t task; - int task_id; - int flag; +db_print_task( + task_t task, + int task_id, + int flag) { thread_t thread; int thread_id; @@ -431,9 +431,9 @@ db_port_iterate(thread, func) } ipc_port_t -db_lookup_port(thread, id) - thread_t thread; - int id; +db_lookup_port( + thread_t thread, + int id) { ipc_space_t space; ipc_entry_t entry; diff --git a/ddb/db_run.c b/ddb/db_run.c index 6e409ff3..9b467fc4 100644 --- a/ddb/db_run.c +++ b/ddb/db_run.c @@ -60,9 +60,9 @@ int db_load_count; int db_store_count; boolean_t -db_stop_at_pc(is_breakpoint, task) - boolean_t *is_breakpoint; - task_t task; +db_stop_at_pc( + boolean_t *is_breakpoint, + task_t task) { db_addr_t pc; db_thread_breakpoint_t bkpt; @@ -156,9 +156,9 @@ db_stop_at_pc(is_breakpoint, task) } void -db_restart_at_pc(watchpt, task) - boolean_t watchpt; - task_t task; +db_restart_at_pc( + boolean_t watchpt, + task_t task) { db_addr_t pc = PC_REGS(DDB_REGS); @@ -206,9 +206,9 @@ db_restart_at_pc(watchpt, task) } void -db_single_step(regs, task) - db_regs_t *regs; - task_t task; +db_single_step( + db_regs_t *regs, + task_t task) { if (db_run_mode == STEP_CONTINUE) { db_run_mode = STEP_INVISIBLE; @@ -264,9 +264,9 @@ db_find_temp_breakpoint(task, addr) } void -db_set_task_single_step(regs, task) - db_regs_t *regs; - task_t task; +db_set_task_single_step( + db_regs_t *regs, + task_t task) { db_addr_t pc = PC_REGS(regs), brpc; unsigned int inst; diff --git a/ddb/db_sym.c b/ddb/db_sym.c index 3c8caf49..7d97d15e 100644 --- a/ddb/db_sym.c +++ b/ddb/db_sym.c @@ -55,13 +55,13 @@ db_symtab_t *db_last_symtab; * Add symbol table, with given name, to list of symbol tables. */ boolean_t -db_add_symbol_table(type, start, end, name, ref, map_pointer) - int type; - char *start; - char *end; - char *name; - char *ref; - char *map_pointer; +db_add_symbol_table( + int type, + char *start, + char *end, + char *name, + char *ref, + char *map_pointer) { db_symtab_t *st; extern vm_map_t kernel_map; @@ -119,9 +119,9 @@ db_eqname( const char* src, const char* dst, char c ) } boolean_t -db_value_of_name(name, valuep) - char *name; - db_expr_t *valuep; +db_value_of_name( + char *name, + db_expr_t *valuep) { db_sym_t sym; @@ -141,8 +141,7 @@ db_value_of_name(name, valuep) * otherwise, all symbol tables will be searched. */ db_sym_t -db_lookup(symstr) - char *symstr; +db_lookup(char *symstr) { db_sym_t sp; int i; @@ -193,10 +192,10 @@ db_lookup(symstr) * with parsed file name, symbol name and line number. */ db_sym_t -db_sym_parse_and_lookup(func, symtab, symstr) - db_sym_t (*func)(); - db_symtab_t *symtab; - char *symstr; +db_sym_parse_and_lookup( + db_sym_t (*func)(), + db_symtab_t *symtab, + char *symstr) { char *p; int n; @@ -265,8 +264,7 @@ out: boolean_t db_qualify_ambiguous_names = FALSE; boolean_t -db_name_is_ambiguous(sym_name) - char *sym_name; +db_name_is_ambiguous(char *sym_name) { int i; boolean_t found_once = FALSE; @@ -301,11 +299,11 @@ db_name_is_ambiguous(sym_name) * */ db_sym_t -db_search_task_symbol(val, strategy, offp, task) - db_addr_t val; - db_strategy_t strategy; - db_addr_t *offp; /* better be unsigned */ - task_t task; +db_search_task_symbol( + db_addr_t val, + db_strategy_t strategy, + db_addr_t *offp, /* better be unsigned */ + task_t task) { db_sym_t ret; @@ -330,11 +328,11 @@ db_search_task_symbol(val, strategy, offp, task) } db_sym_t -db_search_in_task_symbol(val, strategy, offp, task) - db_addr_t val; - db_strategy_t strategy; - db_addr_t *offp; - task_t task; +db_search_in_task_symbol( + db_addr_t val, + db_strategy_t strategy, + db_addr_t *offp, + task_t task) { vm_size_t diff; vm_size_t newdiff; @@ -398,11 +396,11 @@ db_search_in_task_symbol(val, strategy, offp, task) * Return name and value of a symbol */ void -db_symbol_values(stab, sym, namep, valuep) - db_symtab_t *stab; - db_sym_t sym; - char **namep; - db_expr_t *valuep; +db_symbol_values( + db_symtab_t *stab, + db_sym_t sym, + char **namep, + db_expr_t *valuep) { db_expr_t value; char *name; diff --git a/ddb/db_task_thread.c b/ddb/db_task_thread.c index 266b1ea7..edab17e5 100644 --- a/ddb/db_task_thread.c +++ b/ddb/db_task_thread.c @@ -153,8 +153,7 @@ db_check_thread_address_valid(thread) * convert task_id(queue postion) to task address */ task_t -db_lookup_task_id(task_id) - int task_id; +db_lookup_task_id(int task_id) { task_t task; processor_set_t pset; @@ -181,9 +180,9 @@ db_lookup_task_id(task_id) * convert (task_id, thread_id) pair to thread address */ static thread_t -db_lookup_thread_id(task, thread_id) - task_t task; - int thread_id; +db_lookup_thread_id( + task_t task, + int thread_id) { thread_t thread; @@ -204,9 +203,9 @@ db_lookup_thread_id(task, thread_id) * thread address */ boolean_t -db_get_next_thread(threadp, position) - thread_t *threadp; - int position; +db_get_next_thread( + thread_t *threadp, + int position) { db_expr_t value; thread_t thread; @@ -272,11 +271,11 @@ db_set_default_thread(vp, valuep, flag, ap) * convert $taskXXX[.YYY] type DDB variable to task or thread address */ void -db_get_task_thread(vp, valuep, flag, ap) - struct db_variable *vp; - db_expr_t *valuep; - int flag; - db_var_aux_param_t ap; +db_get_task_thread( + struct db_variable *vp, + db_expr_t *valuep, + int flag, + db_var_aux_param_t ap) { task_t task; thread_t thread; diff --git a/ddb/db_trap.c b/ddb/db_trap.c index 28f64d14..b56ffdcc 100644 --- a/ddb/db_trap.c +++ b/ddb/db_trap.c @@ -53,9 +53,10 @@ extern int db_load_count; extern int db_store_count; void -db_task_trap(type, code, user_space) - int type, code; - boolean_t user_space; +db_task_trap( + int type, + int code, + boolean_t user_space) { jmp_buf_t db_jmpbuf; jmp_buf_t *prev; @@ -96,8 +97,9 @@ db_task_trap(type, code, user_space) } void -db_trap(type, code) - int type, code; +db_trap( + int type, + int code) { db_task_trap(type, code, !DB_VALID_KERN_ADDR(PC_REGS(DDB_REGS))); } diff --git a/ddb/db_variables.c b/ddb/db_variables.c index 7f5a2c9b..4442ccbc 100644 --- a/ddb/db_variables.c +++ b/ddb/db_variables.c @@ -115,9 +115,9 @@ db_cmp_variable_name(vp, name, ap) } int -db_find_variable(varp, ap) - struct db_variable **varp; - db_var_aux_param_t ap; +db_find_variable( + struct db_variable **varp, + db_var_aux_param_t ap) { int t; struct db_variable *vp; @@ -143,8 +143,7 @@ db_find_variable(varp, ap) } int -db_get_variable(valuep) - db_expr_t *valuep; +db_get_variable(db_expr_t *valuep) { struct db_variable *vp; struct db_var_aux_param aux_param; @@ -160,8 +159,7 @@ db_get_variable(valuep) } int -db_set_variable(value) - db_expr_t value; +db_set_variable(db_expr_t value) { struct db_variable *vp; struct db_var_aux_param aux_param; @@ -177,11 +175,11 @@ db_set_variable(value) } void -db_read_write_variable(vp, valuep, rw_flag, ap) - struct db_variable *vp; - db_expr_t *valuep; - int rw_flag; - db_var_aux_param_t ap; +db_read_write_variable( + struct db_variable *vp, + db_expr_t *valuep, + int rw_flag, + db_var_aux_param_t ap) { void (*func)() = vp->fcn; struct db_var_aux_param aux_param; diff --git a/ddb/db_watch.c b/ddb/db_watch.c index dbb4aea7..f0d0443f 100644 --- a/ddb/db_watch.c +++ b/ddb/db_watch.c @@ -294,10 +294,10 @@ db_clear_watchpoints(void) } boolean_t -db_find_watchpoint(map, addr, regs) - vm_map_t map; - db_addr_t addr; - db_regs_t *regs; +db_find_watchpoint( + vm_map_t map, + db_addr_t addr, + db_regs_t *regs) { db_watchpoint_t watch; db_watchpoint_t found = 0; diff --git a/device/blkio.c b/device/blkio.c index 52d8c003..ee866340 100644 --- a/device/blkio.c +++ b/device/blkio.c @@ -38,10 +38,10 @@ -io_return_t block_io(strat, max_count, ior) - void (*strat)(); - void (*max_count)(); - io_req_t ior; +io_return_t block_io( + void (*strat)(), + void (*max_count)(), + io_req_t ior) { kern_return_t rc; boolean_t wait = FALSE; @@ -88,8 +88,7 @@ io_return_t block_io(strat, max_count, ior) */ #define MAX_PHYS (256 * 1024) -void minphys(ior) - io_req_t ior; +void minphys(io_req_t ior) { if ((ior->io_op & (IO_WRITE | IO_READ | IO_OPEN)) == IO_WRITE) return; diff --git a/device/chario.c b/device/chario.c index 0d9f803e..0e9dd70b 100644 --- a/device/chario.c +++ b/device/chario.c @@ -839,8 +839,7 @@ void ttrstrt( * Called at spltty, tty already locked. * Must be on master CPU if device runs on master. */ -void ttstart(tp) - struct tty *tp; +void ttstart(struct tty *tp) { if ((tp->t_state & (TS_TIMEOUT|TS_TTSTOP|TS_BUSY)) == 0) { /* diff --git a/device/dev_lookup.c b/device/dev_lookup.c index d371b608..a80830c2 100644 --- a/device/dev_lookup.c +++ b/device/dev_lookup.c @@ -120,8 +120,7 @@ dev_number_lookup(ops, devnum) * table. */ mach_device_t -device_lookup(name) - char * name; +device_lookup(char *name) { dev_ops_t dev_ops; int dev_minor; @@ -198,8 +197,7 @@ device_lookup(name) * Add a reference to the device. */ void -mach_device_reference(device) - mach_device_t device; +mach_device_reference(mach_device_t device) { simple_lock(&device->ref_lock); device->ref_count++; @@ -211,8 +209,7 @@ mach_device_reference(device) * structure if no references are left. */ void -mach_device_deallocate(device) - mach_device_t device; +mach_device_deallocate(mach_device_t device) { simple_lock(&device->ref_lock); if (--device->ref_count > 0) { @@ -248,8 +245,7 @@ mach_device_deallocate(device) * Enter a port-to-device mapping. */ void -dev_port_enter(device) - mach_device_t device; +dev_port_enter(mach_device_t device) { mach_device_reference(device); @@ -267,8 +263,7 @@ dev_port_enter(device) * Remove a port-to-device mapping. */ void -dev_port_remove(device) - mach_device_t device; +dev_port_remove(mach_device_t device) { ipc_kobject_set(device->port, IKO_NULL, IKOT_NONE); mach_device_deallocate(device); @@ -279,8 +274,7 @@ dev_port_remove(device) * Doesn't consume the naked send right; produces a device reference. */ device_t -dev_port_lookup(port) - ipc_port_t port; +dev_port_lookup(ipc_port_t port) { device_t device; @@ -321,9 +315,9 @@ convert_device_to_port(device) * return FALSE. */ boolean_t -dev_map(routine, port) - boolean_t (*routine)(); - mach_port_t port; +dev_map( + boolean_t (*routine)(), + mach_port_t port) { int i; queue_t q; diff --git a/device/dev_name.c b/device/dev_name.c index cd3a28ad..5bf62a04 100644 --- a/device/dev_name.c +++ b/device/dev_name.c @@ -112,10 +112,10 @@ name_equal(src, len, target) /* * device name lookup */ -boolean_t dev_name_lookup(name, ops, unit) - char *name; - dev_ops_t *ops; /* out */ - int *unit; /* out */ +boolean_t dev_name_lookup( + char *name, + dev_ops_t *ops, /* out */ + int *unit) /* out */ { /* * Assume that block device names are of the form diff --git a/device/dev_pager.c b/device/dev_pager.c index 3fe47c72..815473a9 100644 --- a/device/dev_pager.c +++ b/device/dev_pager.c @@ -513,8 +513,7 @@ kern_return_t device_pager_data_write( return (KERN_SUCCESS); } -boolean_t device_pager_data_write_done(ior) - io_req_t ior; +boolean_t device_pager_data_write_done(io_req_t ior) { device_write_dealloc(ior); mach_device_deallocate(ior->io_device); diff --git a/device/ds_routines.c b/device/ds_routines.c index 4e04445f..38d773c2 100644 --- a/device/ds_routines.c +++ b/device/ds_routines.c @@ -597,8 +597,7 @@ ds_open_done(ior) } static io_return_t -device_close(device) - mach_device_t device; +device_close(mach_device_t device) { device_lock(device); @@ -824,9 +823,9 @@ device_write_inband(device, reply_port, reply_port_type, mode, recnum, * Wire down incoming memory to give to device. */ kern_return_t -device_write_get(ior, wait) - io_req_t ior; - boolean_t *wait; +device_write_get( + io_req_t ior, + boolean_t *wait) { vm_map_copy_t io_copy; vm_offset_t new_addr; @@ -919,8 +918,7 @@ device_write_get(ior, wait) * Clean up memory allocated for IO. */ boolean_t -device_write_dealloc(ior) - io_req_t ior; +device_write_dealloc(io_req_t ior) { vm_map_copy_t new_copy = VM_MAP_COPY_NULL; vm_map_copy_t io_copy; @@ -1221,9 +1219,9 @@ device_read_inband(device, reply_port, reply_port_type, mode, recnum, /* * Allocate wired-down memory for device read. */ -kern_return_t device_read_alloc(ior, size) - io_req_t ior; - vm_size_t size; +kern_return_t device_read_alloc( + io_req_t ior, + vm_size_t size) { vm_offset_t addr; kern_return_t kr; @@ -1346,11 +1344,11 @@ boolean_t ds_read_done(ior) } static io_return_t -device_set_status(device, flavor, status, status_count) - mach_device_t device; - dev_flavor_t flavor; - dev_status_t status; - mach_msg_type_number_t status_count; +device_set_status( + mach_device_t device, + dev_flavor_t flavor, + dev_status_t status, + mach_msg_type_number_t status_count) { if (device->state != DEV_STATE_OPEN) return (D_NO_SUCH_DEVICE); @@ -1364,11 +1362,11 @@ device_set_status(device, flavor, status, status_count) } io_return_t -mach_device_get_status(device, flavor, status, status_count) - mach_device_t device; - dev_flavor_t flavor; - dev_status_t status; /* pointer to OUT array */ - mach_msg_type_number_t *status_count; /* out */ +mach_device_get_status( + mach_device_t device, + dev_flavor_t flavor, + dev_status_t status, /* pointer to OUT array */ + mach_msg_type_number_t *status_count) /* out */ { if (device->state != DEV_STATE_OPEN) return (D_NO_SUCH_DEVICE); @@ -1408,13 +1406,13 @@ device_set_filter(device, receive_port, priority, filter, filter_count) } static io_return_t -device_map(device, protection, offset, size, pager, unmap) - mach_device_t device; - vm_prot_t protection; - vm_offset_t offset; - vm_size_t size; - ipc_port_t *pager; /* out */ - boolean_t unmap; /* ? */ +device_map( + mach_device_t device, + vm_prot_t protection, + vm_offset_t offset, + vm_size_t size, + ipc_port_t *pager, /* out */ + boolean_t unmap) /* ? */ { if (protection & ~VM_PROT_ALL) return (KERN_INVALID_ARGUMENT); @@ -1445,8 +1443,7 @@ decl_simple_lock_data(, io_done_list_lock) #define splio splsched /* XXX must block ALL io devices */ -void iodone(ior) - io_req_t ior; +void iodone(io_req_t ior) { spl_t s; @@ -1566,8 +1563,7 @@ void mach_device_init(void) mach_device_trap_init(); } -void iowait(ior) - io_req_t ior; +void iowait(io_req_t ior) { spl_t s; diff --git a/device/net_io.c b/device/net_io.c index e758f2d6..82b6fb92 100644 --- a/device/net_io.c +++ b/device/net_io.c @@ -412,8 +412,7 @@ mach_msg_type_t packet_type = { * Dequeues a message and delivers it at spl0. * Returns FALSE if no messages. */ -boolean_t net_deliver(nonblocking) - boolean_t nonblocking; +boolean_t net_deliver(boolean_t nonblocking) { ipc_kmsg_t kmsg; boolean_t high_priority; @@ -603,8 +602,9 @@ void net_thread(void) } void -reorder_queue(first, last) - queue_t first, last; +reorder_queue( + queue_t first, + queue_t last) { queue_entry_t prev, next; @@ -626,11 +626,11 @@ reorder_queue(first, last) * We are already at splimp. */ void -net_packet(ifp, kmsg, count, priority) - struct ifnet *ifp; - ipc_kmsg_t kmsg; - unsigned int count; - boolean_t priority; +net_packet( + struct ifnet *ifp, + ipc_kmsg_t kmsg, + unsigned int count, + boolean_t priority) { boolean_t awake; @@ -1010,9 +1010,9 @@ net_do_filter(infp, data, data_count, header) * Check filter for invalid operations or stack over/under-flow. */ boolean_t -parse_net_filter(filter, count) - filter_t *filter; - unsigned int count; +parse_net_filter( + filter_t *filter, + unsigned int count) { int sp; filter_t *fpe = &filter[count]; @@ -1104,12 +1104,12 @@ parse_net_filter(filter, count) * If we are successful, we must consume that right. */ io_return_t -net_set_filter(ifp, rcv_port, priority, filter, filter_count) - struct ifnet *ifp; - ipc_port_t rcv_port; - int priority; - filter_t *filter; - unsigned int filter_count; +net_set_filter( + struct ifnet *ifp, + ipc_port_t rcv_port, + int priority, + filter_t *filter, + unsigned int filter_count) { int filter_bytes; bpf_insn_t match; @@ -1369,11 +1369,11 @@ clean_and_return: * Other network operations */ io_return_t -net_getstat(ifp, flavor, status, count) - struct ifnet *ifp; - dev_flavor_t flavor; - dev_status_t status; /* pointer to OUT array */ - natural_t *count; /* OUT */ +net_getstat( + struct ifnet *ifp, + dev_flavor_t flavor, + dev_status_t status, /* pointer to OUT array */ + natural_t *count) /* OUT */ { switch (flavor) { case NET_STATUS: @@ -1434,10 +1434,10 @@ printf ("net_getstat: count: %d, addr_int_count: %d\n", } io_return_t -net_write(ifp, start, ior) - struct ifnet *ifp; - int (*start)(); - io_req_t ior; +net_write( + struct ifnet *ifp, + int (*start)(), + io_req_t ior) { spl_t s; kern_return_t rc; @@ -1590,13 +1590,14 @@ net_io_init(void) */ int -bpf_do_filter(infp, p, wirelen, header, hlen, hash_headpp, entpp) - net_rcv_port_t infp; - char * p; /* packet data */ - unsigned int wirelen; /* data_count (in bytes) */ - char * header; - unsigned int hlen; /* header len (in bytes) */ - net_hash_entry_t **hash_headpp, *entpp; /* out */ +bpf_do_filter( + net_rcv_port_t infp, + char * p, /* packet data */ + unsigned int wirelen, /* data_count (in bytes) */ + char * header, + unsigned int hlen, /* header len (in bytes) */ + net_hash_entry_t **hash_headpp, + net_hash_entry_t *entpp) /* out */ { bpf_insn_t pc, pc_end; unsigned int buflen; @@ -1889,10 +1890,10 @@ bpf_do_filter(infp, p, wirelen, header, hlen, hash_headpp, entpp) * Otherwise, a bogus program could easily crash the system. */ int -bpf_validate(f, bytes, match) - bpf_insn_t f; - int bytes; - bpf_insn_t *match; +bpf_validate( + bpf_insn_t f, + int bytes, + bpf_insn_t *match) { int i, j, len; bpf_insn_t p; @@ -1961,9 +1962,10 @@ bpf_validate(f, bytes, match) } int -bpf_eq (f1, f2, bytes) - bpf_insn_t f1, f2; - int bytes; +bpf_eq( + bpf_insn_t f1, + bpf_insn_t f2, + int bytes) { int count; @@ -2035,12 +2037,13 @@ bpf_match (hash, n_keys, keys, hash_headpp, entpp) */ int -hash_ent_remove (ifp, hp, used, head, entp, dead_p) - struct ifnet *ifp; - net_hash_header_t hp; - int used; - net_hash_entry_t *head, entp; - queue_entry_t *dead_p; +hash_ent_remove( + struct ifnet *ifp, + net_hash_header_t hp, + int used, + net_hash_entry_t *head, + net_hash_entry_t entp, + queue_entry_t *dead_p) { hp->ref_count--; @@ -2072,8 +2075,7 @@ hash_ent_remove (ifp, hp, used, head, entp, dead_p) } int -net_add_q_info (rcv_port) - ipc_port_t rcv_port; +net_add_q_info(ipc_port_t rcv_port) { mach_port_msgcount_t qlimit = 0; @@ -2098,8 +2100,7 @@ net_add_q_info (rcv_port) } void -net_del_q_info (qlimit) - int qlimit; +net_del_q_info(int qlimit) { simple_lock(&net_kmsg_total_lock); net_queue_free_min--; @@ -2116,8 +2117,7 @@ net_del_q_info (qlimit) * No locks should be held when called. */ void -net_free_dead_infp (dead_infp) - queue_entry_t dead_infp; +net_free_dead_infp(queue_entry_t dead_infp) { net_rcv_port_t infp, nextfp; @@ -2138,8 +2138,7 @@ net_free_dead_infp (dead_infp) * No locks should be held when called. */ void -net_free_dead_entp (dead_entp) - queue_entry_t dead_entp; +net_free_dead_entp(queue_entry_t dead_entp) { net_hash_entry_t entp, nextentp; diff --git a/device/subrs.c b/device/subrs.c index 7e6e30d7..a10b72d7 100644 --- a/device/subrs.c +++ b/device/subrs.c @@ -75,8 +75,7 @@ ether_sprintf(ap) /* * Initialize send and receive queues on an interface. */ -void if_init_queues(ifp) - struct ifnet *ifp; +void if_init_queues(struct ifnet *ifp) { IFQ_INIT(&ifp->if_snd); queue_init(&ifp->if_rcv_port_list); diff --git a/i386/i386/db_interface.c b/i386/i386/db_interface.c index ca58ff34..13376853 100644 --- a/i386/i386/db_interface.c +++ b/i386/i386/db_interface.c @@ -216,8 +216,9 @@ db_clear_hw_watchpoint( * Print trap reason. */ void -kdbprinttrap(type, code) - int type, code; +kdbprinttrap( + int type, + int code) { printf("kernel: %s (%d), code=%x\n", trap_name(type), type, code); diff --git a/i386/i386/fpu.c b/i386/i386/fpu.c index cd90ee9f..0f34833e 100644 --- a/i386/i386/fpu.c +++ b/i386/i386/fpu.c @@ -197,8 +197,7 @@ fpu_module_init(void) * Called only when thread terminating - no locking necessary. */ void -fp_free(fps) - struct i386_fpsave_state *fps; +fp_free(struct i386_fpsave_state *fps) { ASSERT_IPL(SPL0); #if NCPUS == 1 @@ -747,8 +746,7 @@ ASSERT_IPL(SPL0); * . otherwise, thread is running. */ void -fp_save(thread) - thread_t thread; +fp_save(thread_t thread) { pcb_t pcb = thread->pcb; struct i386_fpsave_state *ifps = pcb->ims.ifps; @@ -769,8 +767,7 @@ fp_save(thread) * Locking not needed; always called on the current thread. */ void -fp_load(thread) - thread_t thread; +fp_load(thread_t thread) { pcb_t pcb = thread->pcb; struct i386_fpsave_state *ifps; diff --git a/i386/i386/io_map.c b/i386/i386/io_map.c index b095f224..74e0b471 100644 --- a/i386/i386/io_map.c +++ b/i386/i386/io_map.c @@ -37,9 +37,9 @@ extern vm_offset_t kernel_virtual_start; * Mach VM is running. */ vm_offset_t -io_map(phys_addr, size) - vm_offset_t phys_addr; - vm_size_t size; +io_map( + vm_offset_t phys_addr, + vm_size_t size) { vm_offset_t start; diff --git a/i386/i386/loose_ends.c b/i386/i386/loose_ends.c index bb2e5b69..64b53b71 100644 --- a/i386/i386/loose_ends.c +++ b/i386/i386/loose_ends.c @@ -41,8 +41,7 @@ int cpuspeed = 4; #define DELAY(n) { volatile int N = cpuspeed * (n); while (--N > 0); } void -delay(n) - int n; +delay(int n) { DELAY(n); } diff --git a/i386/i386/mp_desc.c b/i386/i386/mp_desc.c index 2ffe8ac0..6aa8e664 100644 --- a/i386/i386/mp_desc.c +++ b/i386/i386/mp_desc.c @@ -100,8 +100,7 @@ extern struct real_descriptor ldt[LDTSZ]; */ struct mp_desc_table * -mp_desc_init(mycpu) - int mycpu; +mp_desc_init(int mycpu) { struct mp_desc_table *mpt; diff --git a/i386/i386/pcb.c b/i386/i386/pcb.c index a0578d1a..5866cac6 100644 --- a/i386/i386/pcb.c +++ b/i386/i386/pcb.c @@ -70,10 +70,10 @@ vm_offset_t kernel_stack[NCPUS]; /* top of active_stack */ * Attach a kernel stack to a thread. */ -void stack_attach(thread, stack, continuation) - thread_t thread; - vm_offset_t stack; - void (*continuation)(thread_t); +void stack_attach( + thread_t thread, + vm_offset_t stack, + void (*continuation)(thread_t)) { counter(if (++c_stacks_current > c_stacks_max) c_stacks_max = c_stacks_current); @@ -105,8 +105,7 @@ void stack_attach(thread, stack, continuation) * Detaches a kernel stack from a thread, returning the old stack. */ -vm_offset_t stack_detach(thread) - thread_t thread; +vm_offset_t stack_detach(thread_t thread) { vm_offset_t stack; @@ -130,8 +129,7 @@ vm_offset_t stack_detach(thread) #define gdt_desc_p(mycpu,sel) \ ((struct real_descriptor *)&curr_gdt(mycpu)[sel_idx(sel)]) -void switch_ktss(pcb) - pcb_t pcb; +void switch_ktss(pcb_t pcb) { int mycpu = cpu_number(); { @@ -243,9 +241,9 @@ update_ktss_iopb (unsigned char *new_iopb, io_port_t size) * Move the current thread's kernel stack to the new thread. */ -void stack_handoff(old, new) - thread_t old; - thread_t new; +void stack_handoff( + thread_t old, + thread_t new) { int mycpu = cpu_number(); vm_offset_t stack; @@ -307,8 +305,7 @@ void stack_handoff(old, new) /* * Switch to the first thread on a CPU. */ -void load_context(new) - thread_t new; +void load_context(thread_t new) { switch_ktss(new->pcb); Load_context(new); @@ -319,10 +316,10 @@ void load_context(new) * Save the old thread`s kernel state or continuation, * and return it. */ -thread_t switch_context(old, continuation, new) - thread_t old; - void (*continuation)(); - thread_t new; +thread_t switch_context( + thread_t old, + void (*continuation)(), + thread_t new) { /* * Save FP registers if in use. @@ -373,8 +370,7 @@ void pcb_module_init(void) fpu_module_init(); } -void pcb_init(thread) - thread_t thread; +void pcb_init(thread_t thread) { pcb_t pcb; @@ -406,8 +402,7 @@ void pcb_init(thread) thread->pcb = pcb; } -void pcb_terminate(thread) - thread_t thread; +void pcb_terminate(thread_t thread) { pcb_t pcb = thread->pcb; @@ -440,11 +435,11 @@ void pcb_collect(thread) * Set the status of the specified thread. */ -kern_return_t thread_setstatus(thread, flavor, tstate, count) - thread_t thread; - int flavor; - thread_state_t tstate; - unsigned int count; +kern_return_t thread_setstatus( + thread_t thread, + int flavor, + thread_state_t tstate, + unsigned int count) { switch (flavor) { case i386_THREAD_STATE: @@ -646,11 +641,11 @@ kern_return_t thread_setstatus(thread, flavor, tstate, count) * Get the status of the specified thread. */ -kern_return_t thread_getstatus(thread, flavor, tstate, count) - thread_t thread; - int flavor; - thread_state_t tstate; /* pointer to OUT array */ - unsigned int *count; /* IN/OUT */ +kern_return_t thread_getstatus( + thread_t thread, + int flavor, + thread_state_t tstate, /* pointer to OUT array */ + unsigned int *count) /* IN/OUT */ { switch (flavor) { case THREAD_STATE_FLAVOR_LIST: @@ -798,14 +793,13 @@ kern_return_t thread_getstatus(thread, flavor, tstate, count) * will make the thread return 'retval' from a syscall. */ void -thread_set_syscall_return(thread, retval) - thread_t thread; - kern_return_t retval; +thread_set_syscall_return( + thread_t thread, + kern_return_t retval) { thread->pcb->iss.eax = retval; } - /* * Return prefered address of user stack. * Always returns low address. If stack grows up, @@ -814,8 +808,7 @@ thread_set_syscall_return(thread, retval) * address. */ vm_offset_t -user_stack_low(stack_size) - vm_size_t stack_size; +user_stack_low(vm_size_t stack_size) { return (VM_MAX_ADDRESS - stack_size); } diff --git a/i386/i386/phys.c b/i386/i386/phys.c index d4bd6c38..3af508f5 100644 --- a/i386/i386/phys.c +++ b/i386/i386/phys.c @@ -47,8 +47,7 @@ * pmap_zero_page zeros the specified (machine independent) page. */ void -pmap_zero_page(p) - vm_offset_t p; +pmap_zero_page(vm_offset_t p) { assert(p != vm_page_fictitious_addr); vm_offset_t v; @@ -72,8 +71,9 @@ pmap_zero_page(p) * pmap_copy_page copies the specified (machine independent) pages. */ void -pmap_copy_page(src, dst) - vm_offset_t src, dst; +pmap_copy_page( + vm_offset_t src, + vm_offset_t dst) { vm_offset_t src_addr_v, dst_addr_v; pmap_mapwindow_t *src_map, *dst_map; @@ -110,9 +110,10 @@ pmap_copy_page(src, dst) * Copy virtual memory to physical memory */ void -copy_to_phys(src_addr_v, dst_addr_p, count) - vm_offset_t src_addr_v, dst_addr_p; - int count; +copy_to_phys( + vm_offset_t src_addr_v, + vm_offset_t dst_addr_p, + int count) { vm_offset_t dst_addr_v; pmap_mapwindow_t *dst_map; @@ -140,9 +141,10 @@ copy_to_phys(src_addr_v, dst_addr_p, count) * is assumed to be present (e.g. the buffer pool). */ void -copy_from_phys(src_addr_p, dst_addr_v, count) - vm_offset_t src_addr_p, dst_addr_v; - int count; +copy_from_phys( + vm_offset_t src_addr_p, + vm_offset_t dst_addr_v, + int count) { vm_offset_t src_addr_v; pmap_mapwindow_t *src_map; @@ -169,8 +171,7 @@ copy_from_phys(src_addr_p, dst_addr_v, count) * Convert a kernel virtual address to a physical address */ vm_offset_t -kvtophys(addr) -vm_offset_t addr; +kvtophys(vm_offset_t addr) { pt_entry_t *pte; diff --git a/i386/i386/trap.c b/i386/i386/trap.c index 391b6001..200cbccc 100644 --- a/i386/i386/trap.c +++ b/i386/i386/trap.c @@ -88,8 +88,7 @@ boolean_t debug_all_traps_with_kttd = TRUE; #endif /* MACH_TTD */ void -user_page_fault_continue(kr) - kern_return_t kr; +user_page_fault_continue(kern_return_t kr) { thread_t thread = current_thread(); struct i386_saved_state *regs = USER_REGS(thread); @@ -152,8 +151,7 @@ char *trap_name(unsigned int trapnum) * and then only in special circumstances. All other errors are * fatal. */ -void kernel_trap(regs) - struct i386_saved_state *regs; +void kernel_trap(struct i386_saved_state *regs) { int code; int subcode; @@ -345,8 +343,7 @@ dump_ss(regs); * Trap from user mode. * Return TRUE if from emulated system call. */ -int user_trap(regs) - struct i386_saved_state *regs; +int user_trap(struct i386_saved_state *regs) { int exc = 0; /* Suppress gcc warning */ int code; @@ -602,10 +599,10 @@ i386_astintr(void) * emulator. */ void -i386_exception(exc, code, subcode) - int exc; - int code; - int subcode; +i386_exception( + int exc, + int code, + int subcode) { spl_t s; diff --git a/i386/i386/user_ldt.c b/i386/i386/user_ldt.c index 3a2c1cc4..d8bdb90f 100644 --- a/i386/i386/user_ldt.c +++ b/i386/i386/user_ldt.c @@ -48,12 +48,12 @@ * the descriptor for 'first_selector'. */ kern_return_t -i386_set_ldt(thread, first_selector, desc_list, count, desc_list_inline) - thread_t thread; - int first_selector; - struct real_descriptor *desc_list; - unsigned int count; - boolean_t desc_list_inline; +i386_set_ldt( + thread_t thread, + int first_selector, + struct real_descriptor *desc_list, + unsigned int count, + boolean_t desc_list_inline) { user_ldt_t new_ldt, old_ldt, temp; struct real_descriptor *dp; @@ -367,8 +367,7 @@ i386_get_ldt(thread, first_selector, selector_count, desc_list, count) } void -user_ldt_free(user_ldt) - user_ldt_t user_ldt; +user_ldt_free(user_ldt_t user_ldt) { #ifdef MACH_PV_DESCRIPTORS int i; diff --git a/i386/i386at/com.c b/i386/i386at/com.c index 07521f92..5e65ad8a 100644 --- a/i386/i386at/com.c +++ b/i386/i386at/com.c @@ -464,11 +464,11 @@ natural_t *count; /* out */ } io_return_t -comsetstat(dev, flavor, data, count) -dev_t dev; -int flavor; -int * data; -natural_t count; +comsetstat( + dev_t dev, + int flavor, + int * data, + natural_t count) { io_return_t result = D_SUCCESS; int unit = minor(dev); @@ -494,8 +494,7 @@ natural_t count; } void -comintr(unit) -int unit; +comintr(int unit) { struct tty *tp = &com_tty[unit]; u_short addr = cominfo[unit]->address; @@ -545,8 +544,7 @@ int unit; } static void -comparam(unit) -int unit; +comparam(int unit) { struct tty *tp = &com_tty[unit]; u_short addr = (int)tp->t_addr; @@ -615,8 +613,7 @@ comparm(int unit, int baud, int intr, int mode, int modem) int comst_1, comst_2, comst_3, comst_4, comst_5 = 14; void -comstart(tp) -struct tty *tp; +comstart(struct tty *tp) { int nch; #if 0 @@ -698,8 +695,9 @@ printf("Tty %p was stuck\n", tp); * Set receive modem state from modem status register. */ void -fix_modem_state(unit, modem_stat) -int unit, modem_stat; +fix_modem_state( + int unit, + int modem_stat) { int stat = 0; @@ -817,9 +815,9 @@ commctl( } void -comstop(tp, flags) -struct tty *tp; -int flags; +comstop( + struct tty *tp, + int flags) { if ((tp->t_state & TS_BUSY) && (tp->t_state & TS_TTSTOP) == 0) tp->t_state |= TS_FLUSH; diff --git a/i386/i386at/kd.c b/i386/i386at/kd.c index 0de1e505..9f9faf41 100644 --- a/i386/i386at/kd.c +++ b/i386/i386at/kd.c @@ -383,9 +383,9 @@ pause(void) * one column to the left, etc. */ void -kd_debug_put(loc, c) -int loc; -char c; +kd_debug_put( + int loc, + char c) { csrpos_t pos = ONE_PAGE - (loc+1) * ONE_SPACE; @@ -398,8 +398,7 @@ extern boolean_t mouse_in_use; int old_kb_mode; void -cnpollc(on) -boolean_t on; +cnpollc(boolean_t on) { if (mouse_in_use) { if (on) { @@ -440,10 +439,10 @@ boolean_t on; * */ int -kdopen(dev, flag, ior) - dev_t dev; - int flag; - io_req_t ior; +kdopen( + dev_t dev, + int flag, + io_req_t ior) { struct tty *tp; spl_t o_pri; @@ -569,19 +568,19 @@ kdmmap(dev, off, prot) } int -kdportdeath(dev, port) - dev_t dev; - mach_port_t port; +kdportdeath( + dev_t dev, + mach_port_t port) { return (tty_portdeath(&kd_tty, (ipc_port_t)port)); } /*ARGSUSED*/ -io_return_t kdgetstat(dev, flavor, data, count) - dev_t dev; - int flavor; - int * data; /* pointer to OUT array */ - natural_t *count; /* OUT */ +io_return_t kdgetstat( + dev_t dev, + int flavor, + int * data, /* pointer to OUT array */ + natural_t *count) /* OUT */ { io_return_t result; @@ -607,11 +606,11 @@ io_return_t kdgetstat(dev, flavor, data, count) } /*ARGSUSED*/ -io_return_t kdsetstat(dev, flavor, data, count) - dev_t dev; - int flavor; - int * data; - natural_t count; +io_return_t kdsetstat( + dev_t dev, + int flavor, + int * data, + natural_t count) { io_return_t result; @@ -644,13 +643,12 @@ io_return_t kdsetstat(dev, flavor, data, count) * on/off value. */ int -kdsetbell(val, flags) -int val; /* on or off */ -int flags; /* flags set for console */ +kdsetbell( + int val, /* on or off */ + int flags) /* flags set for console */ { int err = 0; - if (val == KD_BELLON) kd_bellon(); else if (val == KD_BELLOFF) @@ -661,15 +659,13 @@ int flags; /* flags set for console */ return(err); } - /* * kdgetkbent: * * Get entry from key mapping table. Returns error code, if any. */ int -kdgetkbent(kbent) -struct kbentry * kbent; +kdgetkbent(struct kbentry *kbent) { u_char *cp; spl_t o_pri = SPLKD(); /* probably superfluous */ @@ -689,9 +685,9 @@ struct kbentry * kbent; * Set entry in key mapping table. Return error code, if any. */ int -kdsetkbent(kbent, flags) -struct kbentry * kbent; -int flags; /* flags set for console */ +kdsetkbent( + struct kbentry *kbent, + int flags) /* flags set for console */ { u_char *cp; spl_t o_pri; @@ -721,8 +717,7 @@ int flags; /* flags set for console */ */ /*ARGSUSED*/ void -kdintr(vec) -int vec; +kdintr(int vec) { struct tty *tp; unsigned char c; @@ -909,10 +904,10 @@ kd_resend(void) * output: the new state */ int -do_modifier(state, c, up) -int state; -Scancode c; -boolean_t up; +do_modifier( + int state, + Scancode c, + boolean_t up) { switch (c) { case (K_ALTSC): @@ -974,8 +969,7 @@ boolean_t up; * are still held down. */ boolean_t -kdcheckmagic(scancode) -Scancode scancode; +kdcheckmagic(Scancode scancode) { static int magic_state = KS_NORMAL; /* like kd_state */ boolean_t up = FALSE; @@ -1070,8 +1064,7 @@ boolean_t extended; * ASSUMES that it is never called from interrupt-driven code. */ void -kdstart(tp) -struct tty *tp; +kdstart(struct tty *tp) { spl_t o_pri; int ch; @@ -1121,9 +1114,9 @@ struct tty *tp; /*ARGSUSED*/ void -kdstop(tp, flags) - struct tty *tp; - int flags; +kdstop( + struct tty *tp, + int flags) { /* * do nothing - all characters are output by one call to @@ -1266,8 +1259,7 @@ kd_bellon(void) int sit_for_0 = 1; void -kd_putc(ch) -u_char ch; +kd_putc(u_char ch) { if ((!ch) && sit_for_0) return; @@ -1320,8 +1312,7 @@ u_char ch; * */ void -kd_setpos(newpos) -csrpos_t newpos; +kd_setpos(csrpos_t newpos) { if (newpos > ONE_PAGE) { kd_scrollup(); @@ -1483,8 +1474,7 @@ unsigned char color_table[] = { 0, 4, 2, 6, 1, 5, 3, 7, * */ void -kd_parserest(cp) -u_char *cp; +kd_parserest(u_char *cp) { int number[16], npar = 0, i; csrpos_t newpos; @@ -1990,8 +1980,7 @@ kd_clfrbcur(void) * */ void -kd_delln(number) -int number; +kd_delln(int number) { csrpos_t to; csrpos_t from; @@ -2029,8 +2018,7 @@ int number; * */ void -kd_insln(number) -int number; +kd_insln(int number) { csrpos_t to; csrpos_t from; @@ -2069,8 +2057,7 @@ int number; * */ void -kd_delch(number) -int number; +kd_delch(int number) { int count; /* num words moved/filled */ int delbytes; /* bytes to delete */ @@ -2111,8 +2098,7 @@ int number; * */ void -kd_erase(number) -int number; +kd_erase(int number) { csrpos_t i; csrpos_t stop; @@ -2161,8 +2147,7 @@ kd_eraseln(void) * */ void -kd_insch(number) -int number; +kd_insch(int number) { csrpos_t to; csrpos_t from; @@ -2203,8 +2188,7 @@ int number; * */ boolean_t -kd_isupper(c) -u_char c; +kd_isupper(u_char c) { if (('A' <= c) && (c <= 'Z')) return(TRUE); @@ -2212,8 +2196,7 @@ u_char c; } boolean_t -kd_islower(c) -u_char c; +kd_islower(u_char c) { if (('a' <= c) && (c <= 'z')) return(TRUE); @@ -2230,8 +2213,7 @@ u_char c; * */ void -kd_senddata(ch) -unsigned char ch; +kd_senddata(unsigned char ch) { while (inb(K_STATUS) & K_IBUF_FUL) ; @@ -2249,8 +2231,7 @@ unsigned char ch; * */ void -kd_sendcmd(ch) -unsigned char ch; +kd_sendcmd(unsigned char ch) { while (inb(K_STATUS) & K_IBUF_FUL) ; @@ -2318,8 +2299,7 @@ kd_mouse_drain(void) * Set kd_state and update the keyboard status LEDs. */ void -set_kd_state(newstate) -int newstate; +set_kd_state(int newstate) { kd_state = newstate; kd_setleds1(state2leds(newstate)); @@ -2332,8 +2312,7 @@ int newstate; * a state vector. */ u_char -state2leds(state) -int state; +state2leds(int state) { u_char result = 0; @@ -2350,8 +2329,7 @@ int state; * Set the keyboard LEDs according to the given byte. */ void -kd_setleds1(val) -u_char val; +kd_setleds1(u_char val) { if (kd_ack != NOT_WAITING) { #ifdef MACH_KBD @@ -2380,8 +2358,7 @@ kd_setleds2(void) * lock anyway. */ void -cnsetleds(val) -u_char val; +cnsetleds(u_char val) { kd_senddata(K_CMD_LEDS); (void)kd_getdata(); /* XXX - assume is ACK */ @@ -2712,9 +2689,10 @@ kd_noopreset(void) */ void -bmpput(pos, ch, chattr) -csrpos_t pos; -char ch, chattr; +bmpput( + csrpos_t pos, + char ch, + char chattr) { short xbit, ybit; /* u/l corner of char pos */ u_char *to, *from; @@ -2740,8 +2718,9 @@ char ch, chattr; * another. */ void -bmpcp1char(from, to) -csrpos_t from, to; +bmpcp1char( + csrpos_t from, + csrpos_t to) { short from_xbit, from_ybit; short to_xbit, to_ybit; @@ -2766,9 +2745,10 @@ csrpos_t from, to; * bmpvmup: Copy a block of character positions upwards. */ void -bmpmvup(from, to, count) -csrpos_t from, to; -int count; +bmpmvup( + csrpos_t from, + csrpos_t to, + int count) { short from_xbit, from_ybit; short to_xbit, to_ybit; @@ -2801,9 +2781,10 @@ int count; * bmpmvdown: copy a block of characters down. */ void -bmpmvdown(from, to, count) -csrpos_t from, to; -int count; +bmpmvdown( + csrpos_t from, + csrpos_t to, + int count) { short from_xbit, from_ybit; short to_xbit, to_ybit; @@ -2839,10 +2820,10 @@ int count; * bmpclear: clear one or more character positions. */ void -bmpclear(to, count, chattr) -csrpos_t to; /* 1st char */ -int count; /* num chars */ -char chattr; /* reverse or normal */ +bmpclear( + csrpos_t to, /* 1st char */ + int count, /* num chars */ + char chattr) /* reverse or normal */ { short i; u_short clearval; @@ -2865,8 +2846,7 @@ char chattr; /* reverse or normal */ * bmpsetcursor: update the display and set the logical cursor. */ void -bmpsetcursor(pos) -csrpos_t pos; +bmpsetcursor(csrpos_t pos) { /* erase old cursor & paint new one */ bmppaintcsr(kd_curpos, char_black); @@ -2878,9 +2858,9 @@ csrpos_t pos; * bmppaintcsr: paint cursor bits. */ void -bmppaintcsr(pos, val) -csrpos_t pos; -u_char val; +bmppaintcsr( + csrpos_t pos, + u_char val) { short xbit, ybit; u_char *cp; @@ -2901,9 +2881,10 @@ u_char val; * (0, 0) is the upper left corner. */ void -bmpch2bit(pos, xb, yb) -csrpos_t pos; -short *xb, *yb; /* x, y bit positions, u/l corner */ +bmpch2bit( + csrpos_t pos, + short *xb, + short *yb) /* x, y bit positions, u/l corner */ { short xch, ych; @@ -2920,8 +2901,9 @@ short *xb, *yb; /* x, y bit positions, u/l corner */ * byte. */ u_char * -bit2fbptr(xb, yb) -short xb, yb; +bit2fbptr( + short xb, + short yb) { return(vid_start + yb * fb_byte_width + xb/8); } diff --git a/i386/i386at/kd_event.c b/i386/i386at/kd_event.c index 2a75f958..b60118e1 100644 --- a/i386/i386at/kd_event.c +++ b/i386/i386at/kd_event.c @@ -131,9 +131,9 @@ kbdopen(dev, flags, ior) /*ARGSUSED*/ void -kbdclose(dev, flags) - dev_t dev; - int flags; +kbdclose( + dev_t dev, + int flags) { spl_t s = SPLKD(); @@ -143,11 +143,11 @@ kbdclose(dev, flags) } -io_return_t kbdgetstat(dev, flavor, data, count) - dev_t dev; - int flavor; - int * data; /* pointer to OUT array */ - unsigned int *count; /* OUT */ +io_return_t kbdgetstat( + dev_t dev, + int flavor, + int * data, /* pointer to OUT array */ + unsigned int *count) /* OUT */ { switch (flavor) { case KDGKBDTYPE: @@ -165,11 +165,11 @@ io_return_t kbdgetstat(dev, flavor, data, count) return (D_SUCCESS); } -io_return_t kbdsetstat(dev, flavor, data, count) - dev_t dev; - int flavor; - int * data; - unsigned int count; +io_return_t kbdsetstat( + dev_t dev, + int flavor, + int * data, + unsigned int count) { switch (flavor) { case KDSKBDMODE: @@ -198,9 +198,9 @@ io_return_t kbdsetstat(dev, flavor, data, count) * kbdread - dequeue and return any queued events. */ int -kbdread(dev, ior) - dev_t dev; - io_req_t ior; +kbdread( + dev_t dev, + io_req_t ior) { int err, count; spl_t s; @@ -237,8 +237,7 @@ kbdread(dev, ior) return (D_SUCCESS); } -boolean_t kbd_read_done(ior) - io_req_t ior; +boolean_t kbd_read_done(io_req_t ior) { int count; spl_t s; @@ -274,8 +273,7 @@ boolean_t kbd_read_done(ior) */ void -kd_enqsc(sc) - Scancode sc; +kd_enqsc(Scancode sc) { kd_event ev; @@ -292,8 +290,7 @@ kd_enqsc(sc) */ void -kbd_enqueue(ev) - kd_event *ev; +kbd_enqueue(kd_event *ev) { if (kdq_full(&kbd_queue)) printf("kbd: queue full\n"); @@ -366,9 +363,9 @@ X_kdb_exit(void) } io_return_t -X_kdb_enter_init(data, count) - u_int *data; - u_int count; +X_kdb_enter_init( + u_int *data, + u_int count) { if (count * sizeof X_kdb_enter_str[0] > sizeof X_kdb_enter_str) return D_INVALID_OPERATION; @@ -379,9 +376,9 @@ X_kdb_enter_init(data, count) } io_return_t -X_kdb_exit_init(data, count) - u_int *data; - u_int count; +X_kdb_exit_init( + u_int *data, + u_int count) { if (count * sizeof X_kdb_exit_str[0] > sizeof X_kdb_exit_str) return D_INVALID_OPERATION; diff --git a/i386/i386at/kd_mouse.c b/i386/i386at/kd_mouse.c index 8b1222da..16241efc 100644 --- a/i386/i386at/kd_mouse.c +++ b/i386/i386at/kd_mouse.c @@ -198,8 +198,7 @@ mouseopen(dev, flags, ior) } void -serial_mouse_open(dev) - dev_t dev; +serial_mouse_open(dev_t dev) { int unit = minor(dev) & 0x7; int mouse_pic = cominfo[unit]->sysdep1; @@ -219,9 +218,9 @@ serial_mouse_open(dev) int mouse_packets = 0; void -kd_mouse_open(dev, mouse_pic) - dev_t dev; - int mouse_pic; +kd_mouse_open( + dev_t dev, + int mouse_pic) { spl_t s = splhi(); /* disable interrupts */ @@ -238,9 +237,9 @@ kd_mouse_open(dev, mouse_pic) * and restore the serial port interrupt vector. */ void -mouseclose(dev, flags) - dev_t dev; - int flags; +mouseclose( + dev_t dev, + int flags) { switch (mouse_type) { case MICROSOFT_MOUSE: @@ -265,9 +264,9 @@ mouseclose(dev, flags) /*ARGSUSED*/ void -serial_mouse_close(dev, flags) - dev_t dev; - int flags; +serial_mouse_close( + dev_t dev, + int flags) { spl_t o_pri = splhi(); /* mutex with open() */ int unit = minor(dev) & 0x7; @@ -284,9 +283,9 @@ serial_mouse_close(dev, flags) } void -kd_mouse_close(dev, mouse_pic) - dev_t dev; - int mouse_pic; +kd_mouse_close( + dev_t dev, + int mouse_pic) { spl_t s = splhi(); @@ -296,11 +295,11 @@ kd_mouse_close(dev, mouse_pic) splx(s); } -io_return_t mousegetstat(dev, flavor, data, count) - dev_t dev; - int flavor; - int * data; /* pointer to OUT array */ - unsigned int *count; /* OUT */ +io_return_t mousegetstat( + dev_t dev, + int flavor, + int * data, /* pointer to OUT array */ + unsigned int *count) /* OUT */ { switch (flavor) { case DEV_GET_SIZE: @@ -319,9 +318,9 @@ io_return_t mousegetstat(dev, flavor, data, count) * mouseread - dequeue and return any queued events. */ int -mouseread(dev, ior) - dev_t dev; - io_req_t ior; +mouseread( + dev_t dev, + io_req_t ior) { int err, count; spl_t s; @@ -358,8 +357,7 @@ mouseread(dev, ior) return (D_SUCCESS); } -boolean_t mouse_read_done(ior) - io_req_t ior; +boolean_t mouse_read_done(io_req_t ior) { int count; spl_t s; @@ -442,8 +440,7 @@ int middlegitech = 0; /* what should the middle button be */ static u_char mousebuf[MOUSEBUFSIZE]; /* 5-byte packet from mouse */ void -mouse_handle_byte(ch) - u_char ch; +mouse_handle_byte(u_char ch) { if (show_mouse_byte) { printf("%x(%c) ", ch, ch); @@ -524,8 +521,7 @@ mouse_handle_byte(ch) } void -mouse_packet_mouse_system_mouse(mousebuf) -u_char mousebuf[MOUSEBUFSIZE]; +mouse_packet_mouse_system_mouse(u_char mousebuf[MOUSEBUFSIZE]) { u_char buttons, buttonchanges; struct mouse_motion moved; @@ -560,8 +556,7 @@ u_char mousebuf[MOUSEBUFSIZE]; * */ void -mouse_packet_microsoft_mouse(mousebuf) -u_char mousebuf[MOUSEBUFSIZE]; +mouse_packet_microsoft_mouse(u_char mousebuf[MOUSEBUFSIZE]) { u_char buttons, buttonchanges; struct mouse_motion moved; @@ -653,8 +648,7 @@ void kd_mouse_read_reset(void) } void -ibm_ps2_mouse_open(dev) - dev_t dev; +ibm_ps2_mouse_open(dev_t dev) { spl_t s = spltty(); @@ -697,8 +691,7 @@ ibm_ps2_mouse_open(dev) } void -ibm_ps2_mouse_close(dev) - dev_t dev; +ibm_ps2_mouse_close(dev_t dev) { spl_t s = spltty(); @@ -729,8 +722,7 @@ ibm_ps2_mouse_close(dev) * */ void -mouse_packet_ibm_ps2_mouse(mousebuf) -u_char mousebuf[MOUSEBUFSIZE]; +mouse_packet_ibm_ps2_mouse(u_char mousebuf[MOUSEBUFSIZE]) { u_char buttons, buttonchanges; struct mouse_motion moved; @@ -762,8 +754,7 @@ u_char mousebuf[MOUSEBUFSIZE]; * Enqueue a mouse-motion event. Called at SPLKD. */ void -mouse_moved(where) - struct mouse_motion where; +mouse_moved(struct mouse_motion where) { kd_event ev; @@ -773,14 +764,13 @@ mouse_moved(where) mouse_enqueue(&ev); } - /* * Enqueue an event for mouse button press or release. Called at SPLKD. */ void -mouse_button(which, direction) - kev_type which; - u_char direction; +mouse_button( + kev_type which, + u_char direction) { kd_event ev; @@ -790,15 +780,13 @@ mouse_button(which, direction) mouse_enqueue(&ev); } - /* * mouse_enqueue - enqueue an event and wake up selecting processes, if * any. Called at SPLKD. */ void -mouse_enqueue(ev) - kd_event *ev; +mouse_enqueue(kd_event *ev) { if (kdq_full(&mouse_queue)) printf("mouse: queue full\n"); diff --git a/i386/i386at/kd_queue.c b/i386/i386at/kd_queue.c index 2086eb11..57d6fbf7 100644 --- a/i386/i386at/kd_queue.c +++ b/i386/i386at/kd_queue.c @@ -98,8 +98,7 @@ kdq_put(q, ev) } kd_event * -kdq_get(q) - kd_event_queue *q; +kdq_get(kd_event_queue *q) { kd_event *result = q->events + q->firstout; @@ -108,8 +107,7 @@ kdq_get(q) } void -kdq_reset(q) - kd_event_queue *q; +kdq_reset(kd_event_queue *q) { q->firstout = q->firstfree = 0; } diff --git a/i386/i386at/lpr.c b/i386/i386at/lpr.c index 1f95a3f2..5c16b153 100644 --- a/i386/i386at/lpr.c +++ b/i386/i386at/lpr.c @@ -192,11 +192,11 @@ natural_t *count; /* out */ } io_return_t -lprsetstat(dev, flavor, data, count) -dev_t dev; -int flavor; -int * data; -natural_t count; +lprsetstat( + dev_t dev, + int flavor, + int * data, + natural_t count) { io_return_t result = D_SUCCESS; int unit = minor(dev); @@ -211,8 +211,7 @@ natural_t count; return (D_SUCCESS); } -void lprintr(unit) -int unit; +void lprintr(int unit) { struct tty *tp = &lpr_tty[unit]; @@ -226,8 +225,7 @@ int unit; lprstart(tp); } -void lprstart(tp) -struct tty *tp; +void lprstart(struct tty *tp) { spl_t s = spltty(); u_short addr = (natural_t) tp->t_addr; @@ -267,9 +265,9 @@ struct tty *tp; } void -lprstop(tp, flags) -struct tty *tp; -int flags; +lprstop( + struct tty *tp, + int flags) { if ((tp->t_state & TS_BUSY) && (tp->t_state & TS_TTSTOP) == 0) tp->t_state |= TS_FLUSH; diff --git a/i386/i386at/model_dep.c b/i386/i386at/model_dep.c index 128f2504..7d138bed 100644 --- a/i386/i386at/model_dep.c +++ b/i386/i386at/model_dep.c @@ -218,8 +218,7 @@ void halt_cpu(void) /* * Halt the system or reboot. */ -void halt_all_cpus(reboot) - boolean_t reboot; +void halt_all_cpus(boolean_t reboot) { if (reboot) { #ifdef MACH_HYP @@ -834,8 +833,7 @@ init_alloc_aligned(vm_size_t size, vm_offset_t *addrp) return TRUE; } -boolean_t pmap_next_page(addrp) - vm_offset_t *addrp; +boolean_t pmap_next_page(vm_offset_t *addrp) { return init_alloc_aligned(PAGE_SIZE, addrp); } @@ -852,8 +850,7 @@ pmap_grab_page(void) return addr; } -boolean_t pmap_valid_page(x) - vm_offset_t x; +boolean_t pmap_valid_page(vm_offset_t x) { /* XXX is this OK? What does it matter for? */ return (((phys_first_addr <= x) && (x < phys_last_addr)) diff --git a/i386/i386at/rtc.c b/i386/i386at/rtc.c index ff4309be..946f08fd 100644 --- a/i386/i386at/rtc.c +++ b/i386/i386at/rtc.c @@ -66,8 +66,7 @@ rtcinit(void) int -rtcget(regs) -unsigned char *regs; +rtcget(unsigned char *regs) { if (first_rtcopen_ever) { rtcinit(); @@ -83,8 +82,7 @@ unsigned char *regs; } void -rtcput(regs) -unsigned char *regs; +rtcput(unsigned char *regs) { unsigned char x; @@ -107,29 +105,25 @@ extern struct timeval time; static int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int -yeartoday(year) -int year; +yeartoday(int year) { return((year%4) ? 365 : 366); } int -hexdectodec(n) -char n; +hexdectodec(char n) { return(((n>>4)&0x0F)*10 + (n&0x0F)); } char -dectohexdec(n) -int n; +dectohexdec(int n) { return((char)(((n/10)<<4)&0xF0) | ((n%10)&0x0F)); } int -readtodc(tp) - u_int *tp; +readtodc(u_int *tp) { struct rtc_st rtclk; time_t n; diff --git a/i386/intel/pmap.c b/i386/intel/pmap.c index 4b2892a7..8a23a44d 100644 --- a/i386/intel/pmap.c +++ b/i386/intel/pmap.c @@ -458,8 +458,7 @@ pmap_pte(const pmap_t pmap, vm_offset_t addr) #define DEBUG_PTE_PAGE 0 #if DEBUG_PTE_PAGE -void ptep_check(ptep) - ptep_t ptep; +void ptep_check(ptep_t ptep) { pt_entry_t *pte, *epte; int ctu, ctw; @@ -495,11 +494,11 @@ void ptep_check(ptep) * For now, VM is already on, we only need to map the * specified memory. */ -vm_offset_t pmap_map(virt, start, end, prot) - vm_offset_t virt; - vm_offset_t start; - vm_offset_t end; - int prot; +vm_offset_t pmap_map( + vm_offset_t virt, + vm_offset_t start, + vm_offset_t end, + int prot) { int ps; @@ -518,11 +517,11 @@ vm_offset_t pmap_map(virt, start, end, prot) * [phys_first_addr, phys_last_addr) (i.e., devices). * Otherwise like pmap_map. */ -vm_offset_t pmap_map_bd(virt, start, end, prot) - vm_offset_t virt; - vm_offset_t start; - vm_offset_t end; - vm_prot_t prot; +vm_offset_t pmap_map_bd( + vm_offset_t virt, + vm_offset_t start, + vm_offset_t end, + vm_prot_t prot) { pt_entry_t template; pt_entry_t *pte; @@ -925,9 +924,9 @@ void pmap_put_mapwindow(pmap_mapwindow_t *map) PMAP_UPDATE_TLBS(kernel_pmap, map->vaddr, map->vaddr + PAGE_SIZE); } -void pmap_virtual_space(startp, endp) - vm_offset_t *startp; - vm_offset_t *endp; +void pmap_virtual_space( + vm_offset_t *startp, + vm_offset_t *endp) { *startp = kernel_virtual_start; *endp = kernel_virtual_end - PMAP_NMAPWINDOWS * PAGE_SIZE; @@ -1002,8 +1001,7 @@ void pmap_init(void) #define valid_page(x) (pmap_initialized && pmap_valid_page(x)) -boolean_t pmap_verify_free(phys) - vm_offset_t phys; +boolean_t pmap_verify_free(vm_offset_t phys) { pv_entry_t pv_h; int pai; @@ -1126,8 +1124,7 @@ void pmap_map_mfn(void *_addr, unsigned long mfn) { * and be removed from its page directory. */ void -pmap_page_table_page_dealloc(pa) - vm_offset_t pa; +pmap_page_table_page_dealloc(vm_offset_t pa) { vm_page_t m; @@ -1152,8 +1149,7 @@ pmap_page_table_page_dealloc(pa) * the map will be used in software only, and * is bounded by that size. */ -pmap_t pmap_create(size) - vm_size_t size; +pmap_t pmap_create(vm_size_t size) { pmap_t p; pmap_statistics_t stats; @@ -1232,8 +1228,7 @@ pmap_t pmap_create(size) * no valid mappings. */ -void pmap_destroy(p) - pmap_t p; +void pmap_destroy(pmap_t p) { pt_entry_t *pdep; vm_offset_t pa; @@ -1299,8 +1294,7 @@ void pmap_destroy(p) * Add a reference to the specified pmap. */ -void pmap_reference(p) - pmap_t p; +void pmap_reference(pmap_t p) { int s; if (p != PMAP_NULL) { @@ -1325,11 +1319,11 @@ void pmap_reference(p) */ /* static */ -void pmap_remove_range(pmap, va, spte, epte) - pmap_t pmap; - vm_offset_t va; - pt_entry_t *spte; - pt_entry_t *epte; +void pmap_remove_range( + pmap_t pmap, + vm_offset_t va, + pt_entry_t *spte, + pt_entry_t *epte) { pt_entry_t *cpte; int num_removed, num_unwired; @@ -1481,9 +1475,10 @@ void pmap_remove_range(pmap, va, spte, epte) * rounded to the hardware page size. */ -void pmap_remove(map, s, e) - pmap_t map; - vm_offset_t s, e; +void pmap_remove( + pmap_t map, + vm_offset_t s, + vm_offset_t e) { int spl; pt_entry_t *pde; @@ -1522,9 +1517,9 @@ void pmap_remove(map, s, e) * Lower the permission for all mappings to a given * page. */ -void pmap_page_protect(phys, prot) - vm_offset_t phys; - vm_prot_t prot; +void pmap_page_protect( + vm_offset_t phys, + vm_prot_t prot) { pv_entry_t pv_h, prev; pv_entry_t pv_e; @@ -1685,10 +1680,11 @@ void pmap_page_protect(phys, prot) * specified range of this map as requested. * Will not increase permissions. */ -void pmap_protect(map, s, e, prot) - pmap_t map; - vm_offset_t s, e; - vm_prot_t prot; +void pmap_protect( + pmap_t map, + vm_offset_t s, + vm_offset_t e, + vm_prot_t prot) { pt_entry_t *pde; pt_entry_t *spte, *epte; @@ -1791,12 +1787,12 @@ void pmap_protect(map, s, e, prot) * or lose information. That is, this routine must actually * insert this page into the given map NOW. */ -void pmap_enter(pmap, v, pa, prot, wired) - pmap_t pmap; - vm_offset_t v; - vm_offset_t pa; - vm_prot_t prot; - boolean_t wired; +void pmap_enter( + pmap_t pmap, + vm_offset_t v, + vm_offset_t pa, + vm_prot_t prot, + boolean_t wired) { pt_entry_t *pte; pv_entry_t pv_h; @@ -2093,10 +2089,10 @@ Retry: * In/out conditions: * The mapping must already exist in the pmap. */ -void pmap_change_wiring(map, v, wired) - pmap_t map; - vm_offset_t v; - boolean_t wired; +void pmap_change_wiring( + pmap_t map, + vm_offset_t v, + boolean_t wired) { pt_entry_t *pte; int i; @@ -2148,9 +2144,9 @@ void pmap_change_wiring(map, v, wired) * with the given map/virtual_address pair. */ -vm_offset_t pmap_extract(pmap, va) - pmap_t pmap; - vm_offset_t va; +vm_offset_t pmap_extract( + pmap_t pmap, + vm_offset_t va) { pt_entry_t *pte; vm_offset_t pa; @@ -2198,8 +2194,7 @@ void pmap_copy(dst_pmap, src_pmap, dst_addr, len, src_addr) * Usage: * Called by the pageout daemon when pages are scarce. */ -void pmap_collect(p) - pmap_t p; +void pmap_collect(pmap_t p) { pt_entry_t *pdp, *ptp; pt_entry_t *eptp; @@ -2406,11 +2401,11 @@ pmap_copy_page(src, dst) * down (or not) as appropriate. */ void -pmap_pageable(pmap, start, end, pageable) - pmap_t pmap; - vm_offset_t start; - vm_offset_t end; - boolean_t pageable; +pmap_pageable( + pmap_t pmap, + vm_offset_t start, + vm_offset_t end, + boolean_t pageable) { } @@ -2418,9 +2413,9 @@ pmap_pageable(pmap, start, end, pageable) * Clear specified attribute bits. */ void -phys_attribute_clear(phys, bits) - vm_offset_t phys; - int bits; +phys_attribute_clear( + vm_offset_t phys, + int bits) { pv_entry_t pv_h; pv_entry_t pv_e; @@ -2504,9 +2499,9 @@ phys_attribute_clear(phys, bits) * Check specified attribute bits. */ boolean_t -phys_attribute_test(phys, bits) - vm_offset_t phys; - int bits; +phys_attribute_test( + vm_offset_t phys, + int bits) { pv_entry_t pv_h; pv_entry_t pv_e; @@ -2595,8 +2590,7 @@ phys_attribute_test(phys, bits) * Clear the modify bits on the specified physical page. */ -void pmap_clear_modify(phys) - vm_offset_t phys; +void pmap_clear_modify(vm_offset_t phys) { phys_attribute_clear(phys, PHYS_MODIFIED); } @@ -2608,8 +2602,7 @@ void pmap_clear_modify(phys) * by any physical maps. */ -boolean_t pmap_is_modified(phys) - vm_offset_t phys; +boolean_t pmap_is_modified(vm_offset_t phys) { return (phys_attribute_test(phys, PHYS_MODIFIED)); } @@ -2620,8 +2613,7 @@ boolean_t pmap_is_modified(phys) * Clear the reference bit on the specified physical page. */ -void pmap_clear_reference(phys) - vm_offset_t phys; +void pmap_clear_reference(vm_offset_t phys) { phys_attribute_clear(phys, PHYS_REFERENCED); } @@ -2633,8 +2625,7 @@ void pmap_clear_reference(phys) * by any physical maps. */ -boolean_t pmap_is_referenced(phys) - vm_offset_t phys; +boolean_t pmap_is_referenced(vm_offset_t phys) { return (phys_attribute_test(phys, PHYS_REFERENCED)); } @@ -2703,10 +2694,11 @@ boolean_t pmap_is_referenced(phys) /* * Signal another CPU that it must flush its TLB */ -void signal_cpus(use_list, pmap, start, end) - cpu_set use_list; - pmap_t pmap; - vm_offset_t start, end; +void signal_cpus( + cpu_set use_list, + pmap_t pmap, + vm_offset_t start, + vm_offset_t end) { int which_cpu, j; pmap_update_list_t update_list_p; @@ -2742,8 +2734,7 @@ void signal_cpus(use_list, pmap, start, end) } } -void process_pmap_updates(my_pmap) - pmap_t my_pmap; +void process_pmap_updates(pmap_t my_pmap) { int my_cpu = cpu_number(); pmap_update_list_t update_list_p; diff --git a/i386/intel/read_fault.c b/i386/intel/read_fault.c index 036d7ae9..29f44396 100644 --- a/i386/intel/read_fault.c +++ b/i386/intel/read_fault.c @@ -39,9 +39,9 @@ * ignores write protection in kernel mode. */ kern_return_t -intel_read_fault(map, vaddr) - vm_map_t map; - vm_offset_t vaddr; +intel_read_fault( + vm_map_t map, + vm_offset_t vaddr) { vm_map_version_t version; /* Map version for verification */ diff --git a/ipc/ipc_entry.c b/ipc/ipc_entry.c index f1d763c3..e78f74ed 100644 --- a/ipc/ipc_entry.c +++ b/ipc/ipc_entry.c @@ -96,9 +96,9 @@ ipc_entry_tree_collision( */ ipc_entry_t -ipc_entry_lookup(space, name) - ipc_space_t space; - mach_port_t name; +ipc_entry_lookup( + ipc_space_t space, + mach_port_t name) { mach_port_index_t index; ipc_entry_t entry; @@ -140,10 +140,10 @@ ipc_entry_lookup(space, name) */ kern_return_t -ipc_entry_get(space, namep, entryp) - ipc_space_t space; - mach_port_t *namep; - ipc_entry_t *entryp; +ipc_entry_get( + ipc_space_t space, + mach_port_t *namep, + ipc_entry_t *entryp) { ipc_entry_t table; mach_port_index_t first_free; @@ -542,8 +542,7 @@ ipc_entry_dealloc( */ kern_return_t -ipc_entry_grow_table(space) - ipc_space_t space; +ipc_entry_grow_table(ipc_space_t space) { ipc_entry_num_t osize, size, nsize; diff --git a/ipc/ipc_hash.c b/ipc/ipc_hash.c index 5eec58cb..8285717c 100644 --- a/ipc/ipc_hash.c +++ b/ipc/ipc_hash.c @@ -64,11 +64,11 @@ */ boolean_t -ipc_hash_lookup(space, obj, namep, entryp) - ipc_space_t space; - ipc_object_t obj; - mach_port_t *namep; - ipc_entry_t *entryp; +ipc_hash_lookup( + ipc_space_t space, + ipc_object_t obj, + mach_port_t *namep, + ipc_entry_t *entryp) { return (ipc_hash_local_lookup(space, obj, namep, entryp) || ((space->is_tree_hash > 0) && diff --git a/ipc/ipc_kmsg.c b/ipc/ipc_kmsg.c index 0e434105..06cec726 100644 --- a/ipc/ipc_kmsg.c +++ b/ipc/ipc_kmsg.c @@ -218,9 +218,9 @@ ipc_kmsg_destroy( */ void -ipc_kmsg_clean_body(saddr, eaddr) - vm_offset_t saddr; - vm_offset_t eaddr; +ipc_kmsg_clean_body( + vm_offset_t saddr, + vm_offset_t eaddr) { while (saddr < eaddr) { mach_msg_type_long_t *type; @@ -317,8 +317,7 @@ ipc_kmsg_clean_body(saddr, eaddr) */ void -ipc_kmsg_clean(kmsg) - ipc_kmsg_t kmsg; +ipc_kmsg_clean(ipc_kmsg_t kmsg) { ipc_marequest_t marequest; ipc_object_t object; @@ -361,11 +360,11 @@ ipc_kmsg_clean(kmsg) */ void -ipc_kmsg_clean_partial(kmsg, eaddr, dolast, number) - ipc_kmsg_t kmsg; - vm_offset_t eaddr; - boolean_t dolast; - mach_msg_type_number_t number; +ipc_kmsg_clean_partial( + ipc_kmsg_t kmsg, + vm_offset_t eaddr, + boolean_t dolast, + mach_msg_type_number_t number) { ipc_object_t object; mach_msg_bits_t mbits = kmsg->ikm_header.msgh_bits; @@ -466,8 +465,7 @@ xxx: type = (mach_msg_type_long_t *) eaddr; */ void -ipc_kmsg_free(kmsg) - ipc_kmsg_t kmsg; +ipc_kmsg_free(ipc_kmsg_t kmsg) { vm_size_t size = kmsg->ikm_size; @@ -500,10 +498,10 @@ ipc_kmsg_free(kmsg) */ mach_msg_return_t -ipc_kmsg_get(msg, size, kmsgp) - mach_msg_header_t *msg; - mach_msg_size_t size; - ipc_kmsg_t *kmsgp; +ipc_kmsg_get( + mach_msg_header_t *msg, + mach_msg_size_t size, + ipc_kmsg_t *kmsgp) { ipc_kmsg_t kmsg; @@ -552,10 +550,10 @@ ipc_kmsg_get(msg, size, kmsgp) */ extern mach_msg_return_t -ipc_kmsg_get_from_kernel(msg, size, kmsgp) - mach_msg_header_t *msg; - mach_msg_size_t size; - ipc_kmsg_t *kmsgp; +ipc_kmsg_get_from_kernel( + mach_msg_header_t *msg, + mach_msg_size_t size, + ipc_kmsg_t *kmsgp) { ipc_kmsg_t kmsg; @@ -589,10 +587,10 @@ ipc_kmsg_get_from_kernel(msg, size, kmsgp) */ mach_msg_return_t -ipc_kmsg_put(msg, kmsg, size) - mach_msg_header_t *msg; - ipc_kmsg_t kmsg; - mach_msg_size_t size; +ipc_kmsg_put( + mach_msg_header_t *msg, + ipc_kmsg_t kmsg, + mach_msg_size_t size) { mach_msg_return_t mr; @@ -674,10 +672,10 @@ ipc_kmsg_put_to_kernel( */ mach_msg_return_t -ipc_kmsg_copyin_header(msg, space, notify) - mach_msg_header_t *msg; - ipc_space_t space; - mach_port_t notify; +ipc_kmsg_copyin_header( + mach_msg_header_t *msg, + ipc_space_t space, + mach_port_t notify) { mach_msg_bits_t mbits = msg->msgh_bits &~ MACH_MSGH_BITS_CIRCULAR; mach_port_t dest_name = msg->msgh_remote_port; @@ -1339,10 +1337,10 @@ ipc_kmsg_copyin_header(msg, space, notify) } mach_msg_return_t -ipc_kmsg_copyin_body(kmsg, space, map) - ipc_kmsg_t kmsg; - ipc_space_t space; - vm_map_t map; +ipc_kmsg_copyin_body( + ipc_kmsg_t kmsg, + ipc_space_t space, + vm_map_t map) { ipc_object_t dest; vm_offset_t saddr, eaddr; @@ -1559,11 +1557,11 @@ ipc_kmsg_copyin_body(kmsg, space, map) */ mach_msg_return_t -ipc_kmsg_copyin(kmsg, space, map, notify) - ipc_kmsg_t kmsg; - ipc_space_t space; - vm_map_t map; - mach_port_t notify; +ipc_kmsg_copyin( + ipc_kmsg_t kmsg, + ipc_space_t space, + vm_map_t map, + mach_port_t notify) { mach_msg_return_t mr; @@ -1594,8 +1592,7 @@ ipc_kmsg_copyin(kmsg, space, map, notify) */ void -ipc_kmsg_copyin_from_kernel( - ipc_kmsg_t kmsg) +ipc_kmsg_copyin_from_kernel(ipc_kmsg_t kmsg) { mach_msg_bits_t bits = kmsg->ikm_header.msgh_bits; mach_msg_type_name_t rname = MACH_MSGH_BITS_REMOTE(bits); @@ -1754,10 +1751,10 @@ ipc_kmsg_copyin_from_kernel( */ mach_msg_return_t -ipc_kmsg_copyout_header(msg, space, notify) - mach_msg_header_t *msg; - ipc_space_t space; - mach_port_t notify; +ipc_kmsg_copyout_header( + mach_msg_header_t *msg, + ipc_space_t space, + mach_port_t notify) { mach_msg_bits_t mbits = msg->msgh_bits; ipc_port_t dest = (ipc_port_t) msg->msgh_remote_port; @@ -2254,11 +2251,11 @@ ipc_kmsg_copyout_header(msg, space, notify) */ mach_msg_return_t -ipc_kmsg_copyout_object(space, object, msgt_name, namep) - ipc_space_t space; - ipc_object_t object; - mach_msg_type_name_t msgt_name; - mach_port_t *namep; +ipc_kmsg_copyout_object( + ipc_space_t space, + ipc_object_t object, + mach_msg_type_name_t msgt_name, + mach_port_t *namep) { if (!IO_VALID(object)) { *namep = (mach_port_t) object; @@ -2364,10 +2361,11 @@ ipc_kmsg_copyout_object(space, object, msgt_name, namep) */ mach_msg_return_t -ipc_kmsg_copyout_body(saddr, eaddr, space, map) - vm_offset_t saddr, eaddr; - ipc_space_t space; - vm_map_t map; +ipc_kmsg_copyout_body( + vm_offset_t saddr, + vm_offset_t eaddr, + ipc_space_t space, + vm_map_t map) { mach_msg_return_t mr = MACH_MSG_SUCCESS; kern_return_t kr; @@ -2516,11 +2514,11 @@ ipc_kmsg_copyout_body(saddr, eaddr, space, map) */ mach_msg_return_t -ipc_kmsg_copyout(kmsg, space, map, notify) - ipc_kmsg_t kmsg; - ipc_space_t space; - vm_map_t map; - mach_port_t notify; +ipc_kmsg_copyout( + ipc_kmsg_t kmsg, + ipc_space_t space, + vm_map_t map, + mach_port_t notify) { mach_msg_bits_t mbits = kmsg->ikm_header.msgh_bits; mach_msg_return_t mr; @@ -2610,9 +2608,9 @@ ipc_kmsg_copyout_pseudo( */ void -ipc_kmsg_copyout_dest(kmsg, space) - ipc_kmsg_t kmsg; - ipc_space_t space; +ipc_kmsg_copyout_dest( + ipc_kmsg_t kmsg, + ipc_space_t space) { mach_msg_bits_t mbits = kmsg->ikm_header.msgh_bits; ipc_object_t dest = (ipc_object_t) kmsg->ikm_header.msgh_remote_port; @@ -2658,9 +2656,9 @@ ipc_kmsg_copyout_dest(kmsg, space) #if MACH_KDB char * -ipc_type_name(type_name, received) - int type_name; - boolean_t received; +ipc_type_name( + int type_name, + boolean_t received) { switch (type_name) { case MACH_MSG_TYPE_BOOLEAN: @@ -2741,8 +2739,7 @@ ipc_print_type_name( * ipc_kmsg_print [ debug ] */ void -ipc_kmsg_print(kmsg) - ipc_kmsg_t kmsg; +ipc_kmsg_print(ipc_kmsg_t kmsg) { db_printf("kmsg=0x%x\n", kmsg); db_printf("ikm_next=0x%x,prev=0x%x,size=%d,marequest=0x%x", @@ -2758,8 +2755,7 @@ ipc_kmsg_print(kmsg) * ipc_msg_print [ debug ] */ void -ipc_msg_print(msgh) - mach_msg_header_t *msgh; +ipc_msg_print(mach_msg_header_t *msgh) { vm_offset_t saddr, eaddr; diff --git a/ipc/ipc_marequest.c b/ipc/ipc_marequest.c index 06c53eb4..ded1711d 100644 --- a/ipc/ipc_marequest.c +++ b/ipc/ipc_marequest.c @@ -160,11 +160,11 @@ ipc_marequest_init(void) */ mach_msg_return_t -ipc_marequest_create(space, port, notify, marequestp) - ipc_space_t space; - ipc_port_t port; - mach_port_t notify; - ipc_marequest_t *marequestp; +ipc_marequest_create( + ipc_space_t space, + ipc_port_t port, + mach_port_t notify, + ipc_marequest_t *marequestp) { mach_port_t name; ipc_entry_t entry; @@ -256,9 +256,9 @@ ipc_marequest_create(space, port, notify, marequestp) */ void -ipc_marequest_cancel(space, name) - ipc_space_t space; - mach_port_t name; +ipc_marequest_cancel( + ipc_space_t space, + mach_port_t name) { ipc_marequest_bucket_t bucket; ipc_marequest_t marequest, *last; @@ -292,9 +292,10 @@ ipc_marequest_cancel(space, name) */ void -ipc_marequest_rename(space, old, new) - ipc_space_t space; - mach_port_t old, new; +ipc_marequest_rename( + ipc_space_t space, + mach_port_t old, + mach_port_t new) { ipc_marequest_bucket_t bucket; ipc_marequest_t marequest, *last; @@ -336,8 +337,7 @@ ipc_marequest_rename(space, old, new) */ void -ipc_marequest_destroy(marequest) - ipc_marequest_t marequest; +ipc_marequest_destroy(ipc_marequest_t marequest) { ipc_space_t space = marequest->imar_space; mach_port_t name; @@ -404,10 +404,10 @@ ipc_marequest_destroy(marequest) */ unsigned int -ipc_marequest_info(maxp, info, count) - unsigned int *maxp; - hash_info_bucket_t *info; - unsigned int count; +ipc_marequest_info( + unsigned int *maxp, + hash_info_bucket_t *info, + unsigned int count) { ipc_marequest_index_t i; diff --git a/ipc/ipc_mqueue.c b/ipc/ipc_mqueue.c index 72eca76c..9138aec4 100644 --- a/ipc/ipc_mqueue.c +++ b/ipc/ipc_mqueue.c @@ -171,10 +171,10 @@ ipc_mqueue_changed( */ mach_msg_return_t -ipc_mqueue_send(kmsg, option, time_out) - ipc_kmsg_t kmsg; - mach_msg_option_t option; - mach_msg_timeout_t time_out; +ipc_mqueue_send( + ipc_kmsg_t kmsg, + mach_msg_option_t option, + mach_msg_timeout_t time_out) { ipc_port_t port; diff --git a/ipc/ipc_notify.c b/ipc/ipc_notify.c index 25fa421b..df5f68bc 100644 --- a/ipc/ipc_notify.c +++ b/ipc/ipc_notify.c @@ -59,8 +59,7 @@ mach_dead_name_notification_t ipc_notify_dead_name_template; */ void -ipc_notify_init_port_deleted(n) - mach_port_deleted_notification_t *n; +ipc_notify_init_port_deleted(mach_port_deleted_notification_t *n) { mach_msg_header_t *m = &n->not_header; mach_msg_type_t *t = &n->not_type; @@ -90,8 +89,7 @@ ipc_notify_init_port_deleted(n) */ void -ipc_notify_init_msg_accepted(n) - mach_msg_accepted_notification_t *n; +ipc_notify_init_msg_accepted(mach_msg_accepted_notification_t *n) { mach_msg_header_t *m = &n->not_header; mach_msg_type_t *t = &n->not_type; @@ -121,8 +119,7 @@ ipc_notify_init_msg_accepted(n) */ void -ipc_notify_init_port_destroyed( - mach_port_destroyed_notification_t *n) +ipc_notify_init_port_destroyed(mach_port_destroyed_notification_t *n) { mach_msg_header_t *m = &n->not_header; mach_msg_type_t *t = &n->not_type; @@ -255,9 +252,9 @@ ipc_notify_init(void) */ void -ipc_notify_port_deleted(port, name) - ipc_port_t port; - mach_port_t name; +ipc_notify_port_deleted( + ipc_port_t port, + mach_port_t name) { ipc_kmsg_t kmsg; mach_port_deleted_notification_t *n; @@ -289,9 +286,9 @@ ipc_notify_port_deleted(port, name) */ void -ipc_notify_msg_accepted(port, name) - ipc_port_t port; - mach_port_t name; +ipc_notify_msg_accepted( + ipc_port_t port, + mach_port_t name) { ipc_kmsg_t kmsg; mach_msg_accepted_notification_t *n; @@ -326,9 +323,9 @@ ipc_notify_msg_accepted(port, name) */ void -ipc_notify_port_destroyed(port, right) - ipc_port_t port; - ipc_port_t right; +ipc_notify_port_destroyed( + ipc_port_t port, + ipc_port_t right) { ipc_kmsg_t kmsg; mach_port_destroyed_notification_t *n; @@ -362,9 +359,9 @@ ipc_notify_port_destroyed(port, right) */ void -ipc_notify_no_senders(port, mscount) - ipc_port_t port; - mach_port_mscount_t mscount; +ipc_notify_no_senders( + ipc_port_t port, + mach_port_mscount_t mscount) { ipc_kmsg_t kmsg; mach_no_senders_notification_t *n; @@ -396,8 +393,7 @@ ipc_notify_no_senders(port, mscount) */ void -ipc_notify_send_once(port) - ipc_port_t port; +ipc_notify_send_once(ipc_port_t port) { ipc_kmsg_t kmsg; mach_send_once_notification_t *n; @@ -428,9 +424,9 @@ ipc_notify_send_once(port) */ void -ipc_notify_dead_name(port, name) - ipc_port_t port; - mach_port_t name; +ipc_notify_dead_name( + ipc_port_t port, + mach_port_t name) { ipc_kmsg_t kmsg; mach_dead_name_notification_t *n; diff --git a/ipc/ipc_port.c b/ipc/ipc_port.c index d4ade8e1..78211e64 100644 --- a/ipc/ipc_port.c +++ b/ipc/ipc_port.c @@ -94,11 +94,11 @@ ipc_port_timestamp(void) */ kern_return_t -ipc_port_dnrequest(port, name, soright, indexp) - ipc_port_t port; - mach_port_t name; - ipc_port_t soright; - ipc_port_request_index_t *indexp; +ipc_port_dnrequest( + ipc_port_t port, + mach_port_t name, + ipc_port_t soright, + ipc_port_request_index_t *indexp) { ipc_port_request_t ipr, table; ipc_port_request_index_t index; @@ -142,8 +142,7 @@ ipc_port_dnrequest(port, name, soright, indexp) */ kern_return_t -ipc_port_dngrow(port) - ipc_port_t port; +ipc_port_dngrow(ipc_port_t port) { ipc_table_size_t its; ipc_port_request_t otable, ntable; @@ -382,8 +381,7 @@ ipc_port_set_qlimit( */ ipc_mqueue_t -ipc_port_lock_mqueue(port) - ipc_port_t port; +ipc_port_lock_mqueue(ipc_port_t port) { if (port->ip_pset != IPS_NULL) { ipc_pset_t pset = port->ip_pset; @@ -413,9 +411,9 @@ ipc_port_lock_mqueue(port) */ void -ipc_port_set_seqno(port, seqno) - ipc_port_t port; - mach_port_seqno_t seqno; +ipc_port_set_seqno( + ipc_port_t port, + mach_port_seqno_t seqno) { ipc_mqueue_t mqueue; @@ -1135,8 +1133,7 @@ ipc_port_release_receive( */ ipc_port_t -ipc_port_alloc_special(space) - ipc_space_t space; +ipc_port_alloc_special(ipc_space_t space) { ipc_port_t port; diff --git a/ipc/ipc_right.c b/ipc/ipc_right.c index 41fe3de1..77a68cec 100644 --- a/ipc/ipc_right.c +++ b/ipc/ipc_right.c @@ -331,10 +331,10 @@ ipc_right_dncancel( */ boolean_t -ipc_right_inuse(space, name, entry) - ipc_space_t space; - mach_port_t name; - ipc_entry_t entry; +ipc_right_inuse( + ipc_space_t space, + mach_port_t name, + ipc_entry_t entry) { ipc_entry_bits_t bits = entry->ie_bits; @@ -359,11 +359,11 @@ ipc_right_inuse(space, name, entry) */ boolean_t -ipc_right_check(space, port, name, entry) - ipc_space_t space; - ipc_port_t port; - mach_port_t name; - ipc_entry_t entry; +ipc_right_check( + ipc_space_t space, + ipc_port_t port, + mach_port_t name, + ipc_entry_t entry) { ipc_entry_bits_t bits; @@ -697,10 +697,10 @@ ipc_right_destroy( */ kern_return_t -ipc_right_dealloc(space, name, entry) - ipc_space_t space; - mach_port_t name; - ipc_entry_t entry; +ipc_right_dealloc( + ipc_space_t space, + mach_port_t name, + ipc_entry_t entry) { ipc_entry_bits_t bits = entry->ie_bits; mach_port_type_t type = IE_BITS_TYPE(bits); @@ -874,12 +874,12 @@ ipc_right_dealloc(space, name, entry) */ kern_return_t -ipc_right_delta(space, name, entry, right, delta) - ipc_space_t space; - mach_port_t name; - ipc_entry_t entry; - mach_port_right_t right; - mach_port_delta_t delta; +ipc_right_delta( + ipc_space_t space, + mach_port_t name, + ipc_entry_t entry, + mach_port_right_t right, + mach_port_delta_t delta) { ipc_entry_bits_t bits = entry->ie_bits; diff --git a/ipc/mach_debug.c b/ipc/mach_debug.c index dd9057a4..eb52e1c8 100644 --- a/ipc/mach_debug.c +++ b/ipc/mach_debug.c @@ -185,11 +185,11 @@ host_ipc_hash_info( */ kern_return_t -host_ipc_marequest_info(host, maxp, infop, countp) - host_t host; - unsigned int *maxp; - hash_info_bucket_array_t *infop; - unsigned int *countp; +host_ipc_marequest_info( + host_t host, + unsigned int *maxp, + hash_info_bucket_array_t *infop, + unsigned int *countp) { vm_offset_t addr; vm_size_t size = 0; /* '=0' to shut up lint */ diff --git a/ipc/mach_msg.c b/ipc/mach_msg.c index 78247a4d..01d974b5 100644 --- a/ipc/mach_msg.c +++ b/ipc/mach_msg.c @@ -88,12 +88,12 @@ */ mach_msg_return_t -mach_msg_send(msg, option, send_size, time_out, notify) - mach_msg_header_t *msg; - mach_msg_option_t option; - mach_msg_size_t send_size; - mach_msg_timeout_t time_out; - mach_port_t notify; +mach_msg_send( + mach_msg_header_t *msg, + mach_msg_option_t option, + mach_msg_size_t send_size, + mach_msg_timeout_t time_out, + mach_port_t notify) { ipc_space_t space = current_space(); vm_map_t map = current_map(); @@ -170,13 +170,13 @@ mach_msg_send(msg, option, send_size, time_out, notify) */ mach_msg_return_t -mach_msg_receive(msg, option, rcv_size, rcv_name, time_out, notify) - mach_msg_header_t *msg; - mach_msg_option_t option; - mach_msg_size_t rcv_size; - mach_port_t rcv_name; - mach_msg_timeout_t time_out; - mach_port_t notify; +mach_msg_receive( + mach_msg_header_t *msg, + mach_msg_option_t option, + mach_msg_size_t rcv_size, + mach_port_t rcv_name, + mach_msg_timeout_t time_out, + mach_port_t notify) { ipc_thread_t self = current_thread(); ipc_space_t space = current_space(); @@ -379,14 +379,14 @@ mach_msg_receive_continue(void) */ mach_msg_return_t -mach_msg_trap(msg, option, send_size, rcv_size, rcv_name, time_out, notify) - mach_msg_header_t *msg; - mach_msg_option_t option; - mach_msg_size_t send_size; - mach_msg_size_t rcv_size; - mach_port_t rcv_name; - mach_msg_timeout_t time_out; - mach_port_t notify; +mach_msg_trap( + mach_msg_header_t *msg, + mach_msg_option_t option, + mach_msg_size_t send_size, + mach_msg_size_t rcv_size, + mach_port_t rcv_name, + mach_msg_timeout_t time_out, + mach_port_t notify) { mach_msg_return_t mr; @@ -1733,8 +1733,7 @@ mach_msg_continue(void) */ boolean_t -mach_msg_interrupt(thread) - thread_t thread; +mach_msg_interrupt(thread_t thread) { ipc_mqueue_t mqueue; diff --git a/ipc/mach_port.c b/ipc/mach_port.c index 13572a1c..4a4efcc5 100644 --- a/ipc/mach_port.c +++ b/ipc/mach_port.c @@ -434,10 +434,10 @@ mach_port_rename( */ kern_return_t -mach_port_allocate_name(space, right, name) - ipc_space_t space; - mach_port_right_t right; - mach_port_t name; +mach_port_allocate_name( + ipc_space_t space, + mach_port_right_t right, + mach_port_t name) { kern_return_t kr; @@ -497,10 +497,10 @@ mach_port_allocate_name(space, right, name) */ kern_return_t -mach_port_allocate(space, right, namep) - ipc_space_t space; - mach_port_right_t right; - mach_port_t *namep; +mach_port_allocate( + ipc_space_t space, + mach_port_right_t right, + mach_port_t *namep) { kern_return_t kr; @@ -759,10 +759,10 @@ mach_port_mod_refs( */ kern_return_t -old_mach_port_get_receive_status(space, name, statusp) - ipc_space_t space; - mach_port_t name; - old_mach_port_status_t *statusp; +old_mach_port_get_receive_status( + ipc_space_t space, + mach_port_t name, + old_mach_port_status_t *statusp) { mach_port_status_t status; kern_return_t kr; @@ -801,10 +801,10 @@ old_mach_port_get_receive_status(space, name, statusp) */ kern_return_t -mach_port_set_qlimit(space, name, qlimit) - ipc_space_t space; - mach_port_t name; - mach_port_msgcount_t qlimit; +mach_port_set_qlimit( + ipc_space_t space, + mach_port_t name, + mach_port_msgcount_t qlimit) { ipc_port_t port; kern_return_t kr; @@ -1365,10 +1365,10 @@ mach_port_extract_right( */ kern_return_t -mach_port_get_receive_status(space, name, statusp) - ipc_space_t space; - mach_port_t name; - mach_port_status_t *statusp; +mach_port_get_receive_status( + ipc_space_t space, + mach_port_t name, + mach_port_status_t *statusp) { ipc_port_t port; kern_return_t kr; @@ -1419,11 +1419,11 @@ mach_port_get_receive_status(space, name, statusp) #ifdef MIGRATING_THREADS kern_return_t -mach_port_set_rpcinfo(space, name, rpc_info, rpc_info_count) - ipc_space_t space; - mach_port_t name; - void *rpc_info; - unsigned int rpc_info_count; +mach_port_set_rpcinfo( + ipc_space_t space, + mach_port_t name, + void *rpc_info, + unsigned int rpc_info_count) { ipc_target_t target; ipc_object_t object; @@ -1463,13 +1463,13 @@ void sact_count(void) } kern_return_t -mach_port_create_act(task, name, user_stack, user_rbuf, user_rbuf_size, out_act) - task_t task; - mach_port_t name; - vm_offset_t user_stack; - vm_offset_t user_rbuf; - vm_size_t user_rbuf_size; - Act **out_act; +mach_port_create_act( + task_t task, + mach_port_t name, + vm_offset_t user_stack, + vm_offset_t user_rbuf, + vm_size_t user_rbuf_size, + Act **out_act) { ipc_target_t target; ipc_space_t space; @@ -1536,9 +1536,9 @@ mach_port_create_act(task, name, user_stack, user_rbuf, user_rbuf_size, out_act) #ifdef RPCKERNELSIG kern_return_t -mach_port_set_syscall_right(task, name) - task_t task; - mach_port_t name; +mach_port_set_syscall_right( + task_t task, + mach_port_t name) { ipc_entry_t entry; kern_return_t kr; diff --git a/ipc/mach_rpc.c b/ipc/mach_rpc.c index e056a7fd..6ca46cc9 100644 --- a/ipc/mach_rpc.c +++ b/ipc/mach_rpc.c @@ -58,9 +58,10 @@ * info to the other side. */ kern_return_t -mach_port_rpc_copy(portp, sact, dact) - struct rpc_port_desc *portp; - struct Act *sact, *dact; +mach_port_rpc_copy( + struct rpc_port_desc *portp, + struct Act *sact, + struct Act *dact) { ipc_space_t sspace, dspace; mach_msg_type_name_t tname; diff --git a/kern/act.c b/kern/act.c index b8ad602f..3186f7e9 100644 --- a/kern/act.c +++ b/kern/act.c @@ -1013,11 +1013,11 @@ act_set_special_port(Act *act, int which, ipc_port_t port) * Return thread's machine-dependent state. */ kern_return_t -act_get_state_immediate(act, flavor, old_state, old_state_count) - Act *act; - int flavor; - void *old_state; /* pointer to OUT array */ - unsigned int *old_state_count; /*IN/OUT*/ +act_get_state_immediate( + Act *act, + int flavor, + void *old_state, /* pointer to OUT array */ + unsigned int *old_state_count) /*IN/OUT*/ { kern_return_t ret; @@ -1039,11 +1039,11 @@ act_get_state_immediate(act, flavor, old_state, old_state_count) * Change thread's machine-dependent state. */ kern_return_t -act_set_state_immediate(act, flavor, new_state, new_state_count) - Act *act; - int flavor; - void *new_state; - unsigned int new_state_count; +act_set_state_immediate( + Act *act, + int flavor, + void *new_state, + unsigned int new_state_count) { kern_return_t ret; @@ -1097,8 +1097,7 @@ void dump_act(act) #ifdef ACTWATCH Act * -get_next_act(sp) - int sp; +get_next_act(int sp) { static int i; Act *act; diff --git a/kern/exception.c b/kern/exception.c index 2ca404d1..7954fbad 100644 --- a/kern/exception.c +++ b/kern/exception.c @@ -82,8 +82,10 @@ boolean_t debug_user_with_kdb = FALSE; */ void -exception(_exception, code, subcode) - integer_t _exception, code, subcode; +exception( + integer_t _exception, + integer_t code, + integer_t subcode) { ipc_thread_t self = current_thread(); ipc_port_t exc_port; @@ -152,8 +154,10 @@ exception(_exception, code, subcode) */ void -exception_try_task(_exception, code, subcode) - integer_t _exception, code, subcode; +exception_try_task( + integer_t _exception, + integer_t code, + integer_t subcode) { ipc_thread_t self = current_thread(); task_t task = self->task; @@ -319,12 +323,13 @@ mach_msg_type_t exc_code_proto = { int exception_raise_misses = 0; void -exception_raise(dest_port, thread_port, task_port, - _exception, code, subcode) - ipc_port_t dest_port; - ipc_port_t thread_port; - ipc_port_t task_port; - integer_t _exception, code, subcode; +exception_raise( + ipc_port_t dest_port, + ipc_port_t thread_port, + ipc_port_t task_port, + integer_t _exception, + integer_t code, + integer_t subcode) { ipc_thread_t self = current_thread(); ipc_thread_t receiver; @@ -783,8 +788,7 @@ mach_msg_type_t exc_RetCode_proto = { */ kern_return_t -exception_parse_reply(kmsg) - ipc_kmsg_t kmsg; +exception_parse_reply(ipc_kmsg_t kmsg) { mig_reply_header_t *msg = (mig_reply_header_t *) &kmsg->ikm_header; @@ -860,10 +864,10 @@ exception_raise_continue(void) */ void -exception_raise_continue_slow(mr, kmsg, seqno) - mach_msg_return_t mr; - ipc_kmsg_t kmsg; - mach_port_seqno_t seqno; +exception_raise_continue_slow( + mach_msg_return_t mr, + ipc_kmsg_t kmsg, + mach_port_seqno_t seqno) { ipc_thread_t self = current_thread(); ipc_port_t reply_port = self->ith_port; @@ -943,9 +947,9 @@ exception_raise_continue_slow(mr, kmsg, seqno) */ void -exception_raise_continue_fast(reply_port, kmsg) - ipc_port_t reply_port; - ipc_kmsg_t kmsg; +exception_raise_continue_fast( + ipc_port_t reply_port, + ipc_kmsg_t kmsg) { ipc_thread_t self = current_thread(); kern_return_t kr; diff --git a/kern/ipc_mig.c b/kern/ipc_mig.c index f2c3f458..41ebc94e 100644 --- a/kern/ipc_mig.c +++ b/kern/ipc_mig.c @@ -110,8 +110,7 @@ mach_msg_rpc_from_kernel(msg, send_size, reply_size) */ void -mach_msg_abort_rpc(thread) - ipc_thread_t thread; +mach_msg_abort_rpc(ipc_thread_t thread) { ipc_port_t reply = IP_NULL; @@ -141,14 +140,14 @@ mach_msg_abort_rpc(thread) */ mach_msg_return_t -mach_msg(msg, option, send_size, rcv_size, rcv_name, time_out, notify) - mach_msg_header_t *msg; - mach_msg_option_t option; - mach_msg_size_t send_size; - mach_msg_size_t rcv_size; - mach_port_t rcv_name; - mach_msg_timeout_t time_out; - mach_port_t notify; +mach_msg( + mach_msg_header_t *msg, + mach_msg_option_t option, + mach_msg_size_t send_size, + mach_msg_size_t rcv_size, + mach_port_t rcv_name, + mach_msg_timeout_t time_out, + mach_port_t notify) { ipc_space_t space = current_space(); vm_map_t map = current_map(); @@ -333,8 +332,7 @@ MACRO_BEGIN \ MACRO_END device_t -port_name_to_device(name) - mach_port_t name; +port_name_to_device(mach_port_t name) { ipc_port_t port; device_t device; @@ -377,8 +375,7 @@ port_name_to_device(name) } thread_t -port_name_to_thread(name) - mach_port_t name; +port_name_to_thread(mach_port_t name) { ipc_port_t port; @@ -423,8 +420,7 @@ port_name_to_thread(name) } task_t -port_name_to_task(name) - mach_port_t name; +port_name_to_task(mach_port_t name) { ipc_port_t port; @@ -519,8 +515,7 @@ port_name_to_map( } ipc_space_t -port_name_to_space(name) - mach_port_t name; +port_name_to_space(mach_port_t name) { ipc_port_t port; @@ -575,12 +570,11 @@ port_name_to_space(name) * AARGH! */ -kern_return_t thread_get_state_KERNEL(thread_port, flavor, - old_state, old_state_count) - mach_port_t thread_port; /* port right for thread */ - int flavor; - thread_state_t old_state; /* pointer to OUT array */ - natural_t *old_state_count; /* IN/OUT */ +kern_return_t thread_get_state_KERNEL( + mach_port_t thread_port, /* port right for thread */ + int flavor, + thread_state_t old_state, /* pointer to OUT array */ + natural_t *old_state_count) /* IN/OUT */ { thread_t thread; kern_return_t result; @@ -592,12 +586,11 @@ kern_return_t thread_get_state_KERNEL(thread_port, flavor, return result; } -kern_return_t thread_set_state_KERNEL(thread_port, flavor, - new_state, new_state_count) - mach_port_t thread_port; /* port right for thread */ - int flavor; - thread_state_t new_state; - natural_t new_state_count; +kern_return_t thread_set_state_KERNEL( + mach_port_t thread_port, /* port right for thread */ + int flavor, + thread_state_t new_state, + natural_t new_state_count) { thread_t thread; kern_return_t result; @@ -669,11 +662,11 @@ syscall_vm_map( return result; } -kern_return_t syscall_vm_allocate(target_map, address, size, anywhere) - mach_port_t target_map; - vm_offset_t *address; - vm_size_t size; - boolean_t anywhere; +kern_return_t syscall_vm_allocate( + mach_port_t target_map, + vm_offset_t *address, + vm_size_t size, + boolean_t anywhere) { vm_map_t map; vm_offset_t addr; @@ -692,10 +685,10 @@ kern_return_t syscall_vm_allocate(target_map, address, size, anywhere) return result; } -kern_return_t syscall_vm_deallocate(target_map, start, size) - mach_port_t target_map; - vm_offset_t start; - vm_size_t size; +kern_return_t syscall_vm_deallocate( + mach_port_t target_map, + vm_offset_t start, + vm_size_t size) { vm_map_t map; kern_return_t result; @@ -710,10 +703,10 @@ kern_return_t syscall_vm_deallocate(target_map, start, size) return result; } -kern_return_t syscall_task_create(parent_task, inherit_memory, child_task) - mach_port_t parent_task; - boolean_t inherit_memory; - mach_port_t *child_task; /* OUT */ +kern_return_t syscall_task_create( + mach_port_t parent_task, + boolean_t inherit_memory, + mach_port_t *child_task) /* OUT */ { task_t t, c; ipc_port_t port; @@ -739,8 +732,7 @@ kern_return_t syscall_task_create(parent_task, inherit_memory, child_task) return result; } -kern_return_t syscall_task_terminate(task) - mach_port_t task; +kern_return_t syscall_task_terminate(mach_port_t task) { task_t t; kern_return_t result; @@ -755,8 +747,7 @@ kern_return_t syscall_task_terminate(task) return result; } -kern_return_t syscall_task_suspend(task) - mach_port_t task; +kern_return_t syscall_task_suspend(mach_port_t task) { task_t t; kern_return_t result; @@ -771,10 +762,10 @@ kern_return_t syscall_task_suspend(task) return result; } -kern_return_t syscall_task_set_special_port(task, which_port, port_name) - mach_port_t task; - int which_port; - mach_port_t port_name; +kern_return_t syscall_task_set_special_port( + mach_port_t task, + int which_port, + mach_port_t port_name) { task_t t; ipc_port_t port; @@ -804,10 +795,10 @@ kern_return_t syscall_task_set_special_port(task, which_port, port_name) } kern_return_t -syscall_mach_port_allocate(task, right, namep) - mach_port_t task; - mach_port_right_t right; - mach_port_t *namep; +syscall_mach_port_allocate( + mach_port_t task, + mach_port_right_t right, + mach_port_t *namep) { ipc_space_t space; mach_port_t name; @@ -826,10 +817,10 @@ syscall_mach_port_allocate(task, right, namep) } kern_return_t -syscall_mach_port_allocate_name(task, right, name) - mach_port_t task; - mach_port_right_t right; - mach_port_t name; +syscall_mach_port_allocate_name( + mach_port_t task, + mach_port_right_t right, + mach_port_t name) { ipc_space_t space; kern_return_t kr; @@ -845,9 +836,9 @@ syscall_mach_port_allocate_name(task, right, name) } kern_return_t -syscall_mach_port_deallocate(task, name) - mach_port_t task; - mach_port_t name; +syscall_mach_port_deallocate( + mach_port_t task, + mach_port_t name) { ipc_space_t space; kern_return_t kr; @@ -863,11 +854,11 @@ syscall_mach_port_deallocate(task, name) } kern_return_t -syscall_mach_port_insert_right(task, name, right, rightType) - mach_port_t task; - mach_port_t name; - mach_port_t right; - mach_msg_type_name_t rightType; +syscall_mach_port_insert_right( + mach_port_t task, + mach_port_t name, + mach_port_t right, + mach_msg_type_name_t rightType) { ipc_space_t space; ipc_object_t object; @@ -902,8 +893,7 @@ syscall_mach_port_insert_right(task, name, right, rightType) return kr; } -kern_return_t syscall_thread_depress_abort(thread) - mach_port_t thread; +kern_return_t syscall_thread_depress_abort(mach_port_t thread) { thread_t t; kern_return_t result; diff --git a/kern/ipc_tt.c b/kern/ipc_tt.c index f8d0f63c..96737be8 100644 --- a/kern/ipc_tt.c +++ b/kern/ipc_tt.c @@ -213,8 +213,7 @@ ipc_task_terminate( */ void -ipc_thread_init(thread) - thread_t thread; +ipc_thread_init(thread_t thread) { ipc_port_t kport; @@ -243,8 +242,7 @@ ipc_thread_init(thread) */ void -ipc_thread_enable(thread) - thread_t thread; +ipc_thread_enable(thread_t thread) { ipc_port_t kport; @@ -264,8 +262,7 @@ ipc_thread_enable(thread) */ void -ipc_thread_disable(thread) - thread_t thread; +ipc_thread_disable(thread_t thread) { ipc_port_t kport; @@ -286,8 +283,7 @@ ipc_thread_disable(thread) */ void -ipc_thread_terminate(thread) - thread_t thread; +ipc_thread_terminate(thread_t thread) { ipc_port_t kport; @@ -424,8 +420,7 @@ retrieve_task_self_fast( */ ipc_port_t -retrieve_thread_self_fast(thread) - thread_t thread; +retrieve_thread_self_fast(thread_t thread) { ipc_port_t port; @@ -705,10 +700,10 @@ task_set_special_port( */ kern_return_t -thread_get_special_port(thread, which, portp) - thread_t thread; - int which; - ipc_port_t *portp; +thread_get_special_port( + thread_t thread, + int which, + ipc_port_t *portp) { ipc_port_t *whichp; ipc_port_t port; @@ -758,10 +753,10 @@ thread_get_special_port(thread, which, portp) */ kern_return_t -thread_set_special_port(thread, which, port) - thread_t thread; - int which; - ipc_port_t port; +thread_set_special_port( + thread_t thread, + int which, + ipc_port_t port) { ipc_port_t *whichp; ipc_port_t old; @@ -890,10 +885,10 @@ mach_ports_register( */ kern_return_t -mach_ports_lookup(task, portsp, portsCnt) - task_t task; - ipc_port_t **portsp; - mach_msg_type_number_t *portsCnt; +mach_ports_lookup( + task_t task, + ipc_port_t **portsp, + mach_msg_type_number_t *portsCnt) { vm_offset_t memory; vm_size_t size; @@ -1003,8 +998,7 @@ convert_port_to_space( */ vm_map_t -convert_port_to_map(port) - ipc_port_t port; +convert_port_to_map(ipc_port_t port) { vm_map_t map = VM_MAP_NULL; @@ -1032,8 +1026,7 @@ convert_port_to_map(port) */ thread_t -convert_port_to_thread(port) - ipc_port_t port; +convert_port_to_thread(ipc_port_t port) { thread_t thread = THREAD_NULL; @@ -1061,8 +1054,7 @@ convert_port_to_thread(port) */ ipc_port_t -convert_task_to_port(task) - task_t task; +convert_task_to_port(task_t task) { ipc_port_t port; @@ -1088,8 +1080,7 @@ convert_task_to_port(task) */ ipc_port_t -convert_thread_to_port(thread) - thread_t thread; +convert_thread_to_port(thread_t thread) { ipc_port_t port; @@ -1113,8 +1104,7 @@ convert_thread_to_port(thread) */ void -space_deallocate(space) - ipc_space_t space; +space_deallocate(ipc_space_t space) { if (space != IS_NULL) is_release(space); diff --git a/kern/lock_mon.c b/kern/lock_mon.c index 33ce70f1..f6bbd5dd 100644 --- a/kern/lock_mon.c +++ b/kern/lock_mon.c @@ -64,7 +64,6 @@ typedef unsigned int time_stamp_t; #define LOCK_INFO_HASH_COUNT 1024 #define LOCK_INFO_PER_BUCKET (LOCK_INFO_MAX/LOCK_INFO_HASH_COUNT) - #define HASH_LOCK(lock) ((long)lock>>5 & (LOCK_INFO_HASH_COUNT-1)) struct lock_info { diff --git a/kern/mach_clock.c b/kern/mach_clock.c index f4a77145..0a7458b0 100644 --- a/kern/mach_clock.c +++ b/kern/mach_clock.c @@ -120,10 +120,10 @@ timer_elt_data_t timer_head; /* ordered list of timeouts */ * the accuracy of the hardware clock. * */ -void clock_interrupt(usec, usermode, basepri) - int usec; /* microseconds per tick */ - boolean_t usermode; /* executing user code */ - boolean_t basepri; /* at base priority */ +void clock_interrupt( + int usec, /* microseconds per tick */ + boolean_t usermode, /* executing user code */ + boolean_t basepri) /* at base priority */ { int my_cpu = cpu_number(); thread_t thread = current_thread(); @@ -309,9 +309,9 @@ void softclock(void) * telt timer element. Function and param are already set. * interval time-out interval, in hz. */ -void set_timeout(telt, interval) - timer_elt_t telt; /* already loaded */ - unsigned int interval; +void set_timeout( + timer_elt_t telt, /* already loaded */ + unsigned int interval) { spl_t s; timer_elt_t next; @@ -339,8 +339,7 @@ void set_timeout(telt, interval) splx(s); } -boolean_t reset_timeout(telt) - timer_elt_t telt; +boolean_t reset_timeout(timer_elt_t telt) { spl_t s; @@ -526,10 +525,10 @@ timer_elt_data_t timeout_timers[NTIMERS]; * param: parameter to pass to function * interval: timeout interval, in hz. */ -void timeout(fcn, param, interval) - void (*fcn)( void * param ); - void * param; - int interval; +void timeout( + void (*fcn)(void *param), + void * param, + int interval) { spl_t s; timer_elt_t elt; diff --git a/kern/machine.c b/kern/machine.c index 52133cb9..eced7688 100644 --- a/kern/machine.c +++ b/kern/machine.c @@ -72,8 +72,7 @@ decl_simple_lock_data(,action_lock); * Flag specified cpu as up and running. Called when a processor comes * online. */ -void cpu_up(cpu) - int cpu; +void cpu_up(int cpu) { struct machine_slot *ms; processor_t processor; @@ -102,8 +101,7 @@ void cpu_up(cpu) * Flag specified cpu as down. Called when a processor is about to * go offline. */ -void cpu_down(cpu) - int cpu; +void cpu_down(int cpu) { struct machine_slot *ms; processor_t processor; @@ -153,9 +151,9 @@ host_reboot(host, options) * a reference. */ void -processor_request_action(processor, new_pset) -processor_t processor; -processor_set_t new_pset; +processor_request_action( + processor_t processor, + processor_set_t new_pset) { processor_set_t pset; @@ -228,10 +226,10 @@ processor_set_t new_pset; * Synchronizes with assignment completion if wait is TRUE. */ kern_return_t -processor_assign(processor, new_pset, wait) -processor_t processor; -processor_set_t new_pset; -boolean_t wait; +processor_assign( + processor_t processor, + processor_set_t new_pset, + boolean_t wait) { spl_t s; @@ -315,10 +313,10 @@ Retry: #else /* MACH_HOST */ kern_return_t -processor_assign(processor, new_pset, wait) -processor_t processor; -processor_set_t new_pset; -boolean_t wait; +processor_assign( + processor_t processor, + processor_set_t new_pset, + boolean_t wait) { return KERN_FAILURE; } @@ -331,8 +329,7 @@ boolean_t wait; * with the shutdown (can be called from interrupt level). */ kern_return_t -processor_shutdown(processor) -processor_t processor; +processor_shutdown(processor_t processor) { spl_t s; @@ -401,8 +398,7 @@ void __attribute__((noreturn)) action_thread(void) * is to schedule ourselves onto a cpu and then save our * context back into the runqs before taking out the cpu. */ -void processor_doaction(processor) -processor_t processor; +void processor_doaction(processor_t processor) { thread_t this_thread; spl_t s; @@ -650,10 +646,10 @@ processor_t processor; #else /* NCPUS > 1 */ kern_return_t -processor_assign(processor, new_pset, wait) -processor_t processor; -processor_set_t new_pset; -boolean_t wait; +processor_assign( + processor_t processor, + processor_set_t new_pset, + boolean_t wait) { return(KERN_FAILURE); } @@ -661,9 +657,9 @@ boolean_t wait; #endif /* NCPUS > 1 */ kern_return_t -host_get_boot_info(priv_host, boot_info) - host_t priv_host; - kernel_boot_info_t boot_info; +host_get_boot_info( + host_t priv_host, + kernel_boot_info_t boot_info) { char *src = ""; diff --git a/kern/printf.c b/kern/printf.c index ea78d482..1db0d08d 100644 --- a/kern/printf.c +++ b/kern/printf.c @@ -626,9 +626,9 @@ snprintf(char *buf, size_t size, const char *fmt, ...) return written; } -void safe_gets(str, maxlen) - char *str; - int maxlen; +void safe_gets( + char *str, + int maxlen) { char *lp; int c; diff --git a/kern/priority.c b/kern/priority.c index d9ded857..587ea2f9 100644 --- a/kern/priority.c +++ b/kern/priority.c @@ -74,11 +74,11 @@ * Called only from clock_interrupt(). */ -void thread_quantum_update(mycpu, thread, nticks, state) - int mycpu; - thread_t thread; - int nticks; - int state; +void thread_quantum_update( + int mycpu, + thread_t thread, + int nticks, + int state) { int quantum; processor_t myprocessor; diff --git a/kern/startup.c b/kern/startup.c index 12f51231..71cd04d5 100644 --- a/kern/startup.c +++ b/kern/startup.c @@ -276,8 +276,7 @@ void slave_main(void) * Start up the first thread on a CPU. * First thread is specified for the master CPU. */ -void cpu_launch_first_thread(th) - thread_t th; +void cpu_launch_first_thread(thread_t th) { int mycpu; diff --git a/kern/syscall_emulation.c b/kern/syscall_emulation.c index da0a6cf2..95e91d55 100644 --- a/kern/syscall_emulation.c +++ b/kern/syscall_emulation.c @@ -68,8 +68,9 @@ void eml_init(void) * vector. */ -void eml_task_reference(task, parent) - task_t task, parent; +void eml_task_reference( + task_t task, + task_t parent) { eml_dispatch_t eml; @@ -116,12 +117,11 @@ void eml_task_deallocate(task) * set a list of emulated system calls for this task. */ kern_return_t -task_set_emulation_vector_internal(task, vector_start, emulation_vector, - emulation_vector_count) - task_t task; - int vector_start; - emulation_vector_t emulation_vector; - unsigned int emulation_vector_count; +task_set_emulation_vector_internal( + task_t task, + int vector_start, + emulation_vector_t emulation_vector, + unsigned int emulation_vector_count) { eml_dispatch_t cur_eml, new_eml, old_eml; vm_size_t new_size; @@ -295,12 +295,11 @@ task_set_emulation_vector_internal(task, vector_start, emulation_vector, * The list is out-of-line. */ kern_return_t -task_set_emulation_vector(task, vector_start, emulation_vector, - emulation_vector_count) - task_t task; - int vector_start; - emulation_vector_t emulation_vector; - unsigned int emulation_vector_count; +task_set_emulation_vector( + task_t task, + int vector_start, + emulation_vector_t emulation_vector, + unsigned int emulation_vector_count) { kern_return_t kr; vm_offset_t emul_vector_addr; @@ -342,12 +341,11 @@ task_set_emulation_vector(task, vector_start, emulation_vector, * List is returned out-of-line. */ kern_return_t -task_get_emulation_vector(task, vector_start, emulation_vector, - emulation_vector_count) - task_t task; - int *vector_start; /* out */ - emulation_vector_t *emulation_vector; /* out */ - unsigned int *emulation_vector_count; /* out */ +task_get_emulation_vector( + task_t task, + int *vector_start, /* out */ + emulation_vector_t *emulation_vector, /* out */ + unsigned int *emulation_vector_count) /* out */ { eml_dispatch_t eml; vm_size_t vector_size, size; @@ -445,10 +443,10 @@ task_get_emulation_vector(task, vector_start, emulation_vector, * task_set_emulation: [Server Entry] * set up for user space emulation of syscalls within this task. */ -kern_return_t task_set_emulation(task, routine_entry_pt, routine_number) - task_t task; - vm_offset_t routine_entry_pt; - int routine_number; +kern_return_t task_set_emulation( + task_t task, + vm_offset_t routine_entry_pt, + int routine_number) { return task_set_emulation_vector_internal(task, routine_number, &routine_entry_pt, 1); diff --git a/kern/syscall_subr.c b/kern/syscall_subr.c index ed153ad4..3c369ef3 100644 --- a/kern/syscall_subr.c +++ b/kern/syscall_subr.c @@ -48,8 +48,6 @@ #include #endif /* MACH_FIXPRI */ - - /* * swtch and swtch_pri both attempt to context switch (logic in * thread_block no-ops the context switch if nothing would happen). @@ -104,8 +102,7 @@ void swtch_pri_continue(void) /*NOTREACHED*/ } -boolean_t swtch_pri(pri) - int pri; +boolean_t swtch_pri(int pri) { thread_t thread = current_thread(); processor_t myprocessor; @@ -154,10 +151,10 @@ void thread_switch_continue(void) * Fixed priority threads that call this get what they asked for * even if that violates priority order. */ -kern_return_t thread_switch(thread_name, option, option_time) -mach_port_t thread_name; -int option; -mach_msg_timeout_t option_time; +kern_return_t thread_switch( + mach_port_t thread_name, + int option, + mach_msg_timeout_t option_time) { thread_t cur_thread = current_thread(); processor_t myprocessor; @@ -282,9 +279,9 @@ mach_msg_timeout_t option_time; * of zero will result in no timeout being scheduled. */ void -thread_depress_priority(thread, depress_time) -thread_t thread; -mach_msg_timeout_t depress_time; +thread_depress_priority( + thread_t thread, + mach_msg_timeout_t depress_time) { unsigned int ticks; spl_t s; @@ -320,8 +317,7 @@ mach_msg_timeout_t depress_time; * Timeout routine for priority depression. */ void -thread_depress_timeout(thread) -thread_t thread; +thread_depress_timeout(thread_t thread) { spl_t s; @@ -349,8 +345,7 @@ thread_t thread; * Prematurely abort priority depression if there is one. */ kern_return_t -thread_depress_abort(thread) -thread_t thread; +thread_depress_abort(thread_t thread) { spl_t s; diff --git a/kern/thread_swap.c b/kern/thread_swap.c index 087c8bc2..dc2924a9 100644 --- a/kern/thread_swap.c +++ b/kern/thread_swap.c @@ -86,8 +86,7 @@ void swapper_init(void) * our callers have already tried that route. */ -void thread_swapin(thread) - thread_t thread; +void thread_swapin(thread_t thread) { switch (thread->state & TH_SWAP_STATE) { case TH_SWAPPED: @@ -124,8 +123,7 @@ void thread_swapin(thread) * it on a run queue. No locks should be held on entry, as it is * likely that this routine will sleep (waiting for stack allocation). */ -void thread_doswapin(thread) - thread_t thread; +void thread_doswapin(thread_t thread) { spl_t s; diff --git a/kern/time_stamp.c b/kern/time_stamp.c index 7f4c0f66..ee141a0e 100644 --- a/kern/time_stamp.c +++ b/kern/time_stamp.c @@ -33,8 +33,7 @@ * ts.c - kern_timestamp system call. */ kern_return_t -kern_timestamp(tsp) -struct tsval *tsp; +kern_timestamp(struct tsval *tsp) { /* temp.low_val = 0; diff --git a/kern/timer.c b/kern/timer.c index 47b834cf..6d6517ed 100644 --- a/kern/timer.c +++ b/kern/timer.c @@ -66,8 +66,7 @@ void init_timers(void) /* * timer_init initializes a single timer. */ -void timer_init(this_timer) -timer_t this_timer; +void timer_init(timer_t this_timer) { this_timer->low_bits = 0; this_timer->high_bits = 0; @@ -91,8 +90,7 @@ timer_t this_timer; * exactly once for each cpu during the boot sequence. */ void -start_timer(timer) -timer_t timer; +start_timer(timer_t timer) { timer->tstamp = get_timestamp(); current_timer[cpu_number()] = timer; @@ -105,8 +103,7 @@ timer_t timer; * from user mode. */ void -time_trap_uentry(ts) -unsigned ts; +time_trap_uentry(unsigned ts) { int elapsed; int mycpu; @@ -191,9 +188,9 @@ time_trap_uexit(int ts) * saved for time_int_exit. */ timer_t -time_int_entry(ts,new_timer) -unsigned ts; -timer_t new_timer; +time_int_entry( + unsigned ts, + timer_t new_timer) { int elapsed; int mycpu; @@ -232,9 +229,9 @@ timer_t new_timer; * it. */ void -time_int_exit(ts, old_timer) -unsigned ts; -timer_t old_timer; +time_int_exit( + unsigned ts, + timer_t old_timer) { int elapsed; int mycpu; @@ -279,8 +276,7 @@ timer_t old_timer; * Caller must lock out interrupts. */ void -timer_switch(new_timer) -timer_t new_timer; +timer_switch(timer_t new_timer) { int elapsed; int mycpu; @@ -325,8 +321,7 @@ timer_t new_timer; * timer_normalize normalizes the value of a timer. It is * called only rarely, to make sure low_bits never overflows. */ -void timer_normalize(timer) -timer_t timer; +void timer_normalize(timer_t timer) { unsigned int high_increment; @@ -352,9 +347,9 @@ timer_t timer; * Keep coherent with db_time_grab below. */ -static void timer_grab(timer, save) -timer_t timer; -timer_save_t save; +static void timer_grab( + timer_t timer, + timer_save_t save) { #if MACH_ASSERT unsigned int passes=0; @@ -386,9 +381,9 @@ timer_save_t save; * above. * */ -void db_timer_grab(timer, save) -timer_t timer; -timer_save_t save; +void db_timer_grab( + timer_t timer, + timer_save_t save) { /* Don't worry about coherency */ @@ -405,9 +400,9 @@ timer_save_t save; */ void -timer_read(timer, tv) -timer_t timer; -time_value_t *tv; +timer_read( + timer_t timer, + time_value_t *tv) { timer_save_data_t temp; @@ -431,10 +426,10 @@ time_value_t *tv; * * Needs to be kept coherent with thread_read_times ahead. */ -void thread_read_times(thread, user_time_p, system_time_p) - thread_t thread; - time_value_t *user_time_p; - time_value_t *system_time_p; +void thread_read_times( + thread_t thread, + time_value_t *user_time_p, + time_value_t *system_time_p) { timer_save_data_t temp; timer_t timer; @@ -465,10 +460,10 @@ void thread_read_times(thread, user_time_p, system_time_p) * thread_read_times above. * */ -void db_thread_read_times(thread, user_time_p, system_time_p) - thread_t thread; - time_value_t *user_time_p; - time_value_t *system_time_p; +void db_thread_read_times( + thread_t thread, + time_value_t *user_time_p, + time_value_t *system_time_p) { timer_save_data_t temp; timer_t timer; @@ -500,9 +495,9 @@ void db_thread_read_times(thread, user_time_p, system_time_p) */ unsigned -timer_delta(timer, save) -timer_t timer; -timer_save_t save; +timer_delta( + timer_t timer, + timer_save_t save) { timer_save_data_t new_save; unsigned result; diff --git a/kern/xpr.c b/kern/xpr.c index a62472d2..46cb2273 100644 --- a/kern/xpr.c +++ b/kern/xpr.c @@ -56,9 +56,13 @@ struct xprbuf *xprptr; /* Currently allocated xprbuf */ struct xprbuf *xprlast; /* Pointer to end of circular buffer */ /*VARARGS1*/ -void xpr(msg, arg1, arg2, arg3, arg4, arg5) -char *msg; -int arg1, arg2, arg3, arg4, arg5; +void xpr( + char *msg, + int arg1, + int arg2, + int arg3, + int arg4, + int arg5) { spl_t s; struct xprbuf *x; @@ -144,9 +148,9 @@ extern jmp_buf_t *db_recover; * Called with arguments, it can dump xpr buffers in user tasks, * assuming they use the same format as the kernel. */ -void xpr_dump(base, nbufs) - struct xprbuf *base; - int nbufs; +void xpr_dump( + struct xprbuf *base, + int nbufs) { jmp_buf_t db_jmpbuf; jmp_buf_t *prev; diff --git a/vm/memory_object.c b/vm/memory_object.c index 024856d2..097ed23d 100644 --- a/vm/memory_object.c +++ b/vm/memory_object.c @@ -82,16 +82,15 @@ decl_simple_lock_data(,memory_manager_default_lock) * argument conversion. Explicit deallocation is necessary. */ -kern_return_t memory_object_data_supply(object, offset, data_copy, data_cnt, - lock_value, precious, reply_to, reply_to_type) - vm_object_t object; - vm_offset_t offset; - vm_map_copy_t data_copy; - unsigned int data_cnt; - vm_prot_t lock_value; - boolean_t precious; - ipc_port_t reply_to; - mach_msg_type_name_t reply_to_type; +kern_return_t memory_object_data_supply( + vm_object_t object, + vm_offset_t offset, + vm_map_copy_t data_copy, + unsigned int data_cnt, + vm_prot_t lock_value, + boolean_t precious, + ipc_port_t reply_to, + mach_msg_type_name_t reply_to_type) { kern_return_t result = KERN_SUCCESS; vm_offset_t error_offset = 0; @@ -303,29 +302,26 @@ retry_lookup: return(result); } - /* * If successful, destroys the map copy object. */ -kern_return_t memory_object_data_provided(object, offset, data, data_cnt, - lock_value) - vm_object_t object; - vm_offset_t offset; - pointer_t data; - unsigned int data_cnt; - vm_prot_t lock_value; +kern_return_t memory_object_data_provided( + vm_object_t object, + vm_offset_t offset, + pointer_t data, + unsigned int data_cnt, + vm_prot_t lock_value) { return memory_object_data_supply(object, offset, (vm_map_copy_t) data, data_cnt, lock_value, FALSE, IP_NULL, 0); } - -kern_return_t memory_object_data_error(object, offset, size, error_value) - vm_object_t object; - vm_offset_t offset; - vm_size_t size; - kern_return_t error_value; +kern_return_t memory_object_data_error( + vm_object_t object, + vm_offset_t offset, + vm_size_t size, + kern_return_t error_value) { if (object == VM_OBJECT_NULL) return(KERN_INVALID_ARGUMENT); @@ -361,10 +357,10 @@ kern_return_t memory_object_data_error(object, offset, size, error_value) return(KERN_SUCCESS); } -kern_return_t memory_object_data_unavailable(object, offset, size) - vm_object_t object; - vm_offset_t offset; - vm_size_t size; +kern_return_t memory_object_data_unavailable( + vm_object_t object, + vm_offset_t offset, + vm_size_t size) { #if MACH_PAGEMAP vm_external_t existence_info = VM_EXTERNAL_NULL; @@ -444,12 +440,11 @@ kern_return_t memory_object_data_unavailable(object, offset, size) #define MEMORY_OBJECT_LOCK_RESULT_MUST_CLEAN 2 #define MEMORY_OBJECT_LOCK_RESULT_MUST_RETURN 3 -memory_object_lock_result_t memory_object_lock_page(m, should_return, - should_flush, prot) - vm_page_t m; - memory_object_return_t should_return; - boolean_t should_flush; - vm_prot_t prot; +memory_object_lock_result_t memory_object_lock_page( + vm_page_t m, + memory_object_return_t should_return, + boolean_t should_flush, + vm_prot_t prot) { /* * Don't worry about pages for which the kernel @@ -647,17 +642,15 @@ memory_object_lock_result_t memory_object_lock_page(m, should_return, */ kern_return_t -memory_object_lock_request(object, offset, size, - should_return, should_flush, prot, - reply_to, reply_to_type) - vm_object_t object; - vm_offset_t offset; - vm_size_t size; - memory_object_return_t should_return; - boolean_t should_flush; - vm_prot_t prot; - ipc_port_t reply_to; - mach_msg_type_name_t reply_to_type; +memory_object_lock_request( + vm_object_t object, + vm_offset_t offset, + vm_size_t size, + memory_object_return_t should_return, + boolean_t should_flush, + vm_prot_t prot, + ipc_port_t reply_to, + mach_msg_type_name_t reply_to_type) { vm_page_t m; vm_offset_t original_offset = offset; @@ -883,13 +876,12 @@ MACRO_END } kern_return_t -memory_object_set_attributes_common(object, object_ready, may_cache, - copy_strategy, use_old_pageout) - vm_object_t object; - boolean_t object_ready; - boolean_t may_cache; - memory_object_copy_strategy_t copy_strategy; - boolean_t use_old_pageout; +memory_object_set_attributes_common( + vm_object_t object, + boolean_t object_ready, + boolean_t may_cache, + memory_object_copy_strategy_t copy_strategy, + boolean_t use_old_pageout) { if (object == VM_OBJECT_NULL) return(KERN_INVALID_ARGUMENT); @@ -950,13 +942,12 @@ memory_object_set_attributes_common(object, object_ready, may_cache, * XXX stub that made change_attributes an RPC. Need investigation. */ -kern_return_t memory_object_change_attributes(object, may_cache, - copy_strategy, reply_to, reply_to_type) - vm_object_t object; - boolean_t may_cache; - memory_object_copy_strategy_t copy_strategy; - ipc_port_t reply_to; - mach_msg_type_name_t reply_to_type; +kern_return_t memory_object_change_attributes( + vm_object_t object, + boolean_t may_cache, + memory_object_copy_strategy_t copy_strategy, + ipc_port_t reply_to, + mach_msg_type_name_t reply_to_type) { kern_return_t result; @@ -986,33 +977,32 @@ kern_return_t memory_object_change_attributes(object, may_cache, } kern_return_t -memory_object_set_attributes(object, object_ready, may_cache, copy_strategy) - vm_object_t object; - boolean_t object_ready; - boolean_t may_cache; - memory_object_copy_strategy_t copy_strategy; +memory_object_set_attributes( + vm_object_t object, + boolean_t object_ready, + boolean_t may_cache, + memory_object_copy_strategy_t copy_strategy) { return memory_object_set_attributes_common(object, object_ready, may_cache, copy_strategy, TRUE); } -kern_return_t memory_object_ready(object, may_cache, copy_strategy) - vm_object_t object; - boolean_t may_cache; - memory_object_copy_strategy_t copy_strategy; +kern_return_t memory_object_ready( + vm_object_t object, + boolean_t may_cache, + memory_object_copy_strategy_t copy_strategy) { return memory_object_set_attributes_common(object, TRUE, may_cache, copy_strategy, FALSE); } -kern_return_t memory_object_get_attributes(object, object_ready, - may_cache, copy_strategy) - vm_object_t object; - boolean_t *object_ready; - boolean_t *may_cache; - memory_object_copy_strategy_t *copy_strategy; +kern_return_t memory_object_get_attributes( + vm_object_t object, + boolean_t *object_ready, + boolean_t *may_cache, + memory_object_copy_strategy_t *copy_strategy) { if (object == VM_OBJECT_NULL) return(KERN_INVALID_ARGUMENT); diff --git a/vm/vm_debug.c b/vm/vm_debug.c index e4a4b8b9..227090e6 100644 --- a/vm/vm_debug.c +++ b/vm/vm_debug.c @@ -65,8 +65,7 @@ */ ipc_port_t -vm_object_real_name(object) - vm_object_t object; +vm_object_real_name(vm_object_t object) { ipc_port_t port = IP_NULL; @@ -94,11 +93,11 @@ vm_object_real_name(object) */ kern_return_t -mach_vm_region_info(map, address, regionp, portp) - vm_map_t map; - vm_offset_t address; - vm_region_info_t *regionp; - ipc_port_t *portp; +mach_vm_region_info( + vm_map_t map, + vm_offset_t address, + vm_region_info_t *regionp, + ipc_port_t *portp) { vm_map_t cmap; /* current map in traversal */ vm_map_t nmap; /* next map to look at */ @@ -184,11 +183,11 @@ mach_vm_region_info(map, address, regionp, portp) */ kern_return_t -mach_vm_object_info(object, infop, shadowp, copyp) - vm_object_t object; - vm_object_info_t *infop; - ipc_port_t *shadowp; - ipc_port_t *copyp; +mach_vm_object_info( + vm_object_t object, + vm_object_info_t *infop, + ipc_port_t *shadowp, + ipc_port_t *copyp) { vm_object_info_t info; vm_object_info_state_t state; @@ -278,10 +277,10 @@ mach_vm_object_info(object, infop, shadowp, copyp) */ kern_return_t -mach_vm_object_pages(object, pagesp, countp) - vm_object_t object; - vm_page_info_array_t *pagesp; - natural_t *countp; +mach_vm_object_pages( + vm_object_t object, + vm_page_info_array_t *pagesp, + natural_t *countp) { vm_size_t size; vm_offset_t addr; diff --git a/vm/vm_external.c b/vm/vm_external.c index 77bd44ba..2e2593b1 100644 --- a/vm/vm_external.c +++ b/vm/vm_external.c @@ -56,8 +56,7 @@ struct kmem_cache vm_object_small_existence_map_cache; struct kmem_cache vm_object_large_existence_map_cache; -vm_external_t vm_external_create(size) - vm_offset_t size; +vm_external_t vm_external_create(vm_offset_t size) { vm_external_t result; vm_size_t bytes; @@ -78,8 +77,7 @@ vm_external_t vm_external_create(size) return(result); } -void vm_external_destroy(e) - vm_external_t e; +void vm_external_destroy(vm_external_t e) { if (e == VM_EXTERNAL_NULL) return; @@ -115,10 +113,10 @@ vm_external_state_t _vm_external_state_get(e, offset) VM_EXTERNAL_STATE_EXISTS : VM_EXTERNAL_STATE_ABSENT ); } -void vm_external_state_set(e, offset, state) - vm_external_t e; - vm_offset_t offset; - vm_external_state_t state; +void vm_external_state_set( + vm_external_t e, + vm_offset_t offset, + vm_external_state_t state) { unsigned int bit, byte; diff --git a/vm/vm_fault.c b/vm/vm_fault.c index d9c3d7b8..686156c9 100644 --- a/vm/vm_fault.c +++ b/vm/vm_fault.c @@ -123,9 +123,9 @@ void vm_fault_init(void) * "object" must be locked. */ void -vm_fault_cleanup(object, top_page) - vm_object_t object; - vm_page_t top_page; +vm_fault_cleanup( + vm_object_t object, + vm_page_t top_page) { vm_object_paging_end(object); vm_object_unlock(object); @@ -202,27 +202,23 @@ vm_fault_cleanup(object, top_page) * The "result_page" is also left busy. It is not removed * from the pageout queues. */ -vm_fault_return_t vm_fault_page(first_object, first_offset, - fault_type, must_be_resident, interruptible, - protection, - result_page, top_page, - resume, continuation) +vm_fault_return_t vm_fault_page( /* Arguments: */ - vm_object_t first_object; /* Object to begin search */ - vm_offset_t first_offset; /* Offset into object */ - vm_prot_t fault_type; /* What access is requested */ - boolean_t must_be_resident;/* Must page be resident? */ - boolean_t interruptible; /* May fault be interrupted? */ + vm_object_t first_object, /* Object to begin search */ + vm_offset_t first_offset, /* Offset into object */ + vm_prot_t fault_type, /* What access is requested */ + boolean_t must_be_resident,/* Must page be resident? */ + boolean_t interruptible, /* May fault be interrupted? */ /* Modifies in place: */ - vm_prot_t *protection; /* Protection for mapping */ + vm_prot_t *protection, /* Protection for mapping */ /* Returns: */ - vm_page_t *result_page; /* Page found, if successful */ - vm_page_t *top_page; /* Page in top object, if + vm_page_t *result_page, /* Page found, if successful */ + vm_page_t *top_page, /* Page in top object, if * not result_page. */ /* More arguments: */ - boolean_t resume; /* We are restarting. */ - void (*continuation)(); /* Continuation for blocking. */ + boolean_t resume, /* We are restarting. */ + void (*continuation)()) /* Continuation for blocking. */ { vm_page_t m; vm_object_t object; @@ -1149,14 +1145,13 @@ vm_fault_continue(void) /*NOTREACHED*/ } -kern_return_t vm_fault(map, vaddr, fault_type, change_wiring, - resume, continuation) - vm_map_t map; - vm_offset_t vaddr; - vm_prot_t fault_type; - boolean_t change_wiring; - boolean_t resume; - void (*continuation)(); +kern_return_t vm_fault( + vm_map_t map, + vm_offset_t vaddr, + vm_prot_t fault_type, + boolean_t change_wiring, + boolean_t resume, + void (*continuation)()) { vm_map_version_t version; /* Map version for verificiation */ boolean_t wired; /* Should mapping be wired down? */ @@ -1500,9 +1495,9 @@ kern_return_t vm_fault(map, vaddr, fault_type, change_wiring, * * Wire down a range of virtual addresses in a map. */ -void vm_fault_wire(map, entry) - vm_map_t map; - vm_map_entry_t entry; +void vm_fault_wire( + vm_map_t map, + vm_map_entry_t entry) { vm_offset_t va; @@ -1536,9 +1531,9 @@ void vm_fault_wire(map, entry) * * Unwire a range of virtual addresses in a map. */ -void vm_fault_unwire(map, entry) - vm_map_t map; - vm_map_entry_t entry; +void vm_fault_unwire( + vm_map_t map, + vm_map_entry_t entry) { vm_offset_t va; pmap_t pmap; @@ -1625,10 +1620,10 @@ void vm_fault_unwire(map, entry) * other than the common case will return KERN_FAILURE, and the caller * is expected to call vm_fault(). */ -kern_return_t vm_fault_wire_fast(map, va, entry) - vm_map_t map; - vm_offset_t va; - vm_map_entry_t entry; +kern_return_t vm_fault_wire_fast( + vm_map_t map, + vm_offset_t va, + vm_map_entry_t entry) { vm_object_t object; vm_offset_t offset; @@ -1774,9 +1769,9 @@ kern_return_t vm_fault_wire_fast(map, va, entry) * Release a page used by vm_fault_copy. */ -void vm_fault_copy_cleanup(page, top_page) - vm_page_t page; - vm_page_t top_page; +void vm_fault_copy_cleanup( + vm_page_t page, + vm_page_t top_page) { vm_object_t object = page->object; @@ -1817,23 +1812,14 @@ void vm_fault_copy_cleanup(page, top_page) * requested. */ kern_return_t vm_fault_copy( - src_object, - src_offset, - src_size, - dst_object, - dst_offset, - dst_map, - dst_version, - interruptible - ) - vm_object_t src_object; - vm_offset_t src_offset; - vm_size_t *src_size; /* INOUT */ - vm_object_t dst_object; - vm_offset_t dst_offset; - vm_map_t dst_map; - vm_map_version_t *dst_version; - boolean_t interruptible; + vm_object_t src_object, + vm_offset_t src_offset, + vm_size_t *src_size, /* INOUT */ + vm_object_t dst_object, + vm_offset_t dst_offset, + vm_map_t dst_map, + vm_map_version_t *dst_version, + boolean_t interruptible) { vm_page_t result_page; vm_prot_t prot; @@ -2014,10 +2000,10 @@ kern_return_t vm_fault_copy( * XXX Untested. Also unused. Eventually, this technology * could be used in vm_fault_copy() to advantage. */ -vm_fault_return_t vm_fault_page_overwrite(dst_object, dst_offset, result_page) - vm_object_t dst_object; - vm_offset_t dst_offset; - vm_page_t *result_page; /* OUT */ +vm_fault_return_t vm_fault_page_overwrite( + vm_object_t dst_object, + vm_offset_t dst_offset, + vm_page_t *result_page) /* OUT */ { vm_page_t dst_page; diff --git a/vm/vm_kern.c b/vm/vm_kern.c index 3eaf0a81..b997cb58 100644 --- a/vm/vm_kern.c +++ b/vm/vm_kern.c @@ -80,15 +80,14 @@ vm_map_t kernel_pageable_map; */ kern_return_t -projected_buffer_allocate(map, size, persistence, kernel_p, - user_p, protection, inheritance) - vm_map_t map; - vm_size_t size; - int persistence; - vm_offset_t *kernel_p; - vm_offset_t *user_p; - vm_prot_t protection; - vm_inherit_t inheritance; /*Currently only VM_INHERIT_NONE supported*/ +projected_buffer_allocate( + vm_map_t map, + vm_size_t size, + int persistence, + vm_offset_t *kernel_p, + vm_offset_t *user_p, + vm_prot_t protection, + vm_inherit_t inheritance) /*Currently only VM_INHERIT_NONE supported*/ { vm_object_t object; vm_map_entry_t u_entry, k_entry; @@ -178,13 +177,13 @@ projected_buffer_allocate(map, size, persistence, kernel_p, */ kern_return_t -projected_buffer_map(map, kernel_addr, size, user_p, protection, inheritance) - vm_map_t map; - vm_offset_t kernel_addr; - vm_size_t size; - vm_offset_t *user_p; - vm_prot_t protection; - vm_inherit_t inheritance; /*Currently only VM_INHERIT_NONE supported*/ +projected_buffer_map( + vm_map_t map, + vm_offset_t kernel_addr, + vm_size_t size, + vm_offset_t *user_p, + vm_prot_t protection, + vm_inherit_t inheritance) /*Currently only VM_INHERIT_NONE supported*/ { vm_map_entry_t u_entry, k_entry; vm_offset_t physical_addr, user_addr; @@ -251,9 +250,10 @@ projected_buffer_map(map, kernel_addr, size, user_p, protection, inheritance) */ kern_return_t -projected_buffer_deallocate(map, start, end) - vm_map_t map; - vm_offset_t start, end; +projected_buffer_deallocate( + vm_map_t map, + vm_offset_t start, + vm_offset_t end) { vm_map_entry_t entry, k_entry; @@ -303,8 +303,7 @@ projected_buffer_deallocate(map, start, end) */ kern_return_t -projected_buffer_collect(map) - vm_map_t map; +projected_buffer_collect(vm_map_t map) { vm_map_entry_t entry, next; @@ -330,9 +329,10 @@ projected_buffer_collect(map) */ boolean_t -projected_buffer_in_range(map, start, end) - vm_map_t map; - vm_offset_t start, end; +projected_buffer_in_range( + vm_map_t map, + vm_offset_t start, + vm_offset_t end) { vm_map_entry_t entry; @@ -359,10 +359,10 @@ projected_buffer_in_range(map, start, end) */ kern_return_t -kmem_alloc(map, addrp, size) - vm_map_t map; - vm_offset_t *addrp; - vm_size_t size; +kmem_alloc( + vm_map_t map, + vm_offset_t *addrp, + vm_size_t size) { vm_object_t object; vm_map_entry_t entry; @@ -440,12 +440,12 @@ retry: * If successful, the pages in the old region are mapped twice. * The old region is unchanged. Use kmem_free to get rid of it. */ -kern_return_t kmem_realloc(map, oldaddr, oldsize, newaddrp, newsize) - vm_map_t map; - vm_offset_t oldaddr; - vm_size_t oldsize; - vm_offset_t *newaddrp; - vm_size_t newsize; +kern_return_t kmem_realloc( + vm_map_t map, + vm_offset_t oldaddr, + vm_size_t oldsize, + vm_offset_t *newaddrp, + vm_size_t newsize) { vm_offset_t oldmin, oldmax; vm_offset_t newaddr; @@ -541,10 +541,10 @@ retry: */ kern_return_t -kmem_alloc_wired(map, addrp, size) - vm_map_t map; - vm_offset_t *addrp; - vm_size_t size; +kmem_alloc_wired( + vm_map_t map, + vm_offset_t *addrp, + vm_size_t size) { vm_map_entry_t entry; vm_offset_t offset; @@ -624,10 +624,10 @@ retry: */ kern_return_t -kmem_alloc_aligned(map, addrp, size) - vm_map_t map; - vm_offset_t *addrp; - vm_size_t size; +kmem_alloc_aligned( + vm_map_t map, + vm_offset_t *addrp, + vm_size_t size) { vm_map_entry_t entry; vm_offset_t offset; @@ -709,10 +709,10 @@ retry: */ kern_return_t -kmem_alloc_pageable(map, addrp, size) - vm_map_t map; - vm_offset_t *addrp; - vm_size_t size; +kmem_alloc_pageable( + vm_map_t map, + vm_offset_t *addrp, + vm_size_t size) { vm_offset_t addr; kern_return_t kr; @@ -740,10 +740,10 @@ kmem_alloc_pageable(map, addrp, size) */ void -kmem_free(map, addr, size) - vm_map_t map; - vm_offset_t addr; - vm_size_t size; +kmem_free( + vm_map_t map, + vm_offset_t addr, + vm_size_t size) { kern_return_t kr; @@ -758,11 +758,12 @@ kmem_free(map, addr, size) * a submap. */ void -kmem_alloc_pages(object, offset, start, end, protection) - vm_object_t object; - vm_offset_t offset; - vm_offset_t start, end; - vm_prot_t protection; +kmem_alloc_pages( + vm_object_t object, + vm_offset_t offset, + vm_offset_t start, + vm_offset_t end, + vm_prot_t protection) { /* * Mark the pmap region as not pageable. @@ -813,11 +814,12 @@ kmem_alloc_pages(object, offset, start, end, protection) * a submap. */ void -kmem_remap_pages(object, offset, start, end, protection) - vm_object_t object; - vm_offset_t offset; - vm_offset_t start, end; - vm_prot_t protection; +kmem_remap_pages( + vm_object_t object, + vm_offset_t offset, + vm_offset_t start, + vm_offset_t end, + vm_prot_t protection) { /* * Mark the pmap region as not pageable. @@ -871,11 +873,13 @@ kmem_remap_pages(object, offset, start, end, protection) */ void -kmem_submap(map, parent, min, max, size, pageable) - vm_map_t map, parent; - vm_offset_t *min, *max; - vm_size_t size; - boolean_t pageable; +kmem_submap( + vm_map_t map, + vm_map_t parent, + vm_offset_t *min, + vm_offset_t *max, + vm_size_t size, + boolean_t pageable) { vm_offset_t addr; kern_return_t kr; @@ -913,9 +917,9 @@ kmem_submap(map, parent, min, max, size, pageable) * Initialize the kernel's virtual memory map, taking * into account all memory allocated up to this time. */ -void kmem_init(start, end) - vm_offset_t start; - vm_offset_t end; +void kmem_init( + vm_offset_t start, + vm_offset_t end) { vm_map_setup(kernel_map, pmap_kernel(), VM_MIN_KERNEL_ADDRESS, end, FALSE); @@ -951,13 +955,13 @@ void kmem_init(start, end) */ kern_return_t -kmem_io_map_copyout(map, addr, alloc_addr, alloc_size, copy, min_size) - vm_map_t map; - vm_offset_t *addr; /* actual addr of data */ - vm_offset_t *alloc_addr; /* page aligned addr */ - vm_size_t *alloc_size; /* size allocated */ - vm_map_copy_t copy; - vm_size_t min_size; /* Do at least this much */ +kmem_io_map_copyout( + vm_map_t map, + vm_offset_t *addr, /* actual addr of data */ + vm_offset_t *alloc_addr, /* page aligned addr */ + vm_size_t *alloc_size, /* size allocated */ + vm_map_copy_t copy, + vm_size_t min_size) /* Do at least this much */ { vm_offset_t myaddr, offset; vm_size_t mysize, copy_size; @@ -1055,10 +1059,10 @@ kmem_io_map_copyout(map, addr, alloc_addr, alloc_size, copy, min_size) */ void -kmem_io_map_deallocate(map, addr, size) - vm_map_t map; - vm_offset_t addr; - vm_size_t size; +kmem_io_map_deallocate( + vm_map_t map, + vm_offset_t addr, + vm_size_t size) { /* * Remove the mappings. The pmap_remove is needed. @@ -1077,10 +1081,11 @@ kmem_io_map_deallocate(map, addr, size) * and the kernel map/submaps. */ -int copyinmap(map, fromaddr, toaddr, length) - vm_map_t map; - char *fromaddr, *toaddr; - int length; +int copyinmap( + vm_map_t map, + char *fromaddr, + char *toaddr, + int length) { if (vm_map_pmap(map) == kernel_pmap) { /* assume a correct copy */ @@ -1103,10 +1108,11 @@ int copyinmap(map, fromaddr, toaddr, length) * and the kernel map/submaps. */ -int copyoutmap(map, fromaddr, toaddr, length) - vm_map_t map; - char *fromaddr, *toaddr; - int length; +int copyoutmap( + vm_map_t map, + char *fromaddr, + char *toaddr, + int length) { if (vm_map_pmap(map) == kernel_pmap) { /* assume a correct copy */ diff --git a/vm/vm_map.c b/vm/vm_map.c index e6eabdbc..6b13724e 100644 --- a/vm/vm_map.c +++ b/vm/vm_map.c @@ -194,11 +194,12 @@ void vm_map_init(void) */ } -void vm_map_setup(map, pmap, min, max, pageable) - vm_map_t map; - pmap_t pmap; - vm_offset_t min, max; - boolean_t pageable; +void vm_map_setup( + vm_map_t map, + pmap_t pmap, + vm_offset_t min, + vm_offset_t max, + boolean_t pageable) { vm_map_first_entry(map) = vm_map_to_entry(map); vm_map_last_entry(map) = vm_map_to_entry(map); @@ -227,10 +228,11 @@ void vm_map_setup(map, pmap, min, max, pageable) * the given physical map structure, and having * the given lower and upper address bounds. */ -vm_map_t vm_map_create(pmap, min, max, pageable) - pmap_t pmap; - vm_offset_t min, max; - boolean_t pageable; +vm_map_t vm_map_create( + pmap_t pmap, + vm_offset_t min, + vm_offset_t max, + boolean_t pageable) { vm_map_t result; @@ -370,8 +372,7 @@ static inline int vm_map_entry_cmp_insert(const struct rbtree_node *a, * Creates another valid reference to the given map. * */ -void vm_map_reference(map) - vm_map_t map; +void vm_map_reference(vm_map_t map) { if (map == VM_MAP_NULL) return; @@ -388,8 +389,7 @@ void vm_map_reference(map) * destroying it if no references remain. * The map should not be locked. */ -void vm_map_deallocate(map) - vm_map_t map; +void vm_map_deallocate(vm_map_t map) { int c; @@ -433,10 +433,10 @@ void vm_map_deallocate(map) * result indicates whether the address is * actually contained in the map. */ -boolean_t vm_map_lookup_entry(map, address, entry) - vm_map_t map; - vm_offset_t address; - vm_map_entry_t *entry; /* OUT */ +boolean_t vm_map_lookup_entry( + vm_map_t map, + vm_offset_t address, + vm_map_entry_t *entry) /* OUT */ { struct rbtree_node *node; vm_map_entry_t hint; @@ -490,10 +490,11 @@ boolean_t vm_map_lookup_entry(map, address, entry) */ boolean_t -invalid_user_access(map, start, end, prot) - vm_map_t map; - vm_offset_t start, end; - vm_prot_t prot; +invalid_user_access( + vm_map_t map, + vm_offset_t start, + vm_offset_t end, + vm_prot_t prot) { vm_map_entry_t entry; @@ -517,13 +518,13 @@ invalid_user_access(map, start, end, prot) * are initialized to zero. If an object is supplied, * then an existing entry may be extended. */ -kern_return_t vm_map_find_entry(map, address, size, mask, object, o_entry) - vm_map_t map; - vm_offset_t *address; /* OUT */ - vm_size_t size; - vm_offset_t mask; - vm_object_t object; - vm_map_entry_t *o_entry; /* OUT */ +kern_return_t vm_map_find_entry( + vm_map_t map, + vm_offset_t *address, /* OUT */ + vm_size_t size, + vm_offset_t mask, + vm_object_t object, + vm_map_entry_t *o_entry) /* OUT */ { vm_map_entry_t entry, new_entry; vm_offset_t start; @@ -689,13 +690,13 @@ boolean_t vm_map_pmap_enter_enable = FALSE; * The source map should not be locked on entry. */ void -vm_map_pmap_enter(map, addr, end_addr, object, offset, protection) - vm_map_t map; - vm_offset_t addr; - vm_offset_t end_addr; - vm_object_t object; - vm_offset_t offset; - vm_prot_t protection; +vm_map_pmap_enter( + vm_map_t map, + vm_offset_t addr, + vm_offset_t end_addr, + vm_object_t object, + vm_offset_t offset, + vm_prot_t protection) { while (addr < end_addr) { vm_page_t m; @@ -747,21 +748,17 @@ vm_map_pmap_enter(map, addr, end_addr, object, offset, protection) * Arguments are as defined in the vm_map call. */ kern_return_t vm_map_enter( - map, - address, size, mask, anywhere, - object, offset, needs_copy, - cur_protection, max_protection, inheritance) - vm_map_t map; - vm_offset_t *address; /* IN/OUT */ - vm_size_t size; - vm_offset_t mask; - boolean_t anywhere; - vm_object_t object; - vm_offset_t offset; - boolean_t needs_copy; - vm_prot_t cur_protection; - vm_prot_t max_protection; - vm_inherit_t inheritance; + vm_map_t map, + vm_offset_t *address, /* IN/OUT */ + vm_size_t size, + vm_offset_t mask, + boolean_t anywhere, + vm_object_t object, + vm_offset_t offset, + boolean_t needs_copy, + vm_prot_t cur_protection, + vm_prot_t max_protection, + vm_inherit_t inheritance) { vm_map_entry_t entry; vm_offset_t start; @@ -1047,10 +1044,10 @@ kern_return_t vm_map_enter( * This routine is called only when it is known that * the entry must be split. */ -void _vm_map_clip_start(map_header, entry, start) - struct vm_map_header *map_header; - vm_map_entry_t entry; - vm_offset_t start; +void _vm_map_clip_start( + struct vm_map_header *map_header, + vm_map_entry_t entry, + vm_offset_t start) { vm_map_entry_t new_entry; @@ -1100,10 +1097,10 @@ void _vm_map_clip_start(map_header, entry, start) * This routine is called only when it is known that * the entry must be split. */ -void _vm_map_clip_end(map_header, entry, end) - struct vm_map_header *map_header; - vm_map_entry_t entry; - vm_offset_t end; +void _vm_map_clip_end( + struct vm_map_header *map_header, + vm_map_entry_t entry, + vm_offset_t end) { vm_map_entry_t new_entry; @@ -1160,11 +1157,11 @@ void _vm_map_clip_end(map_header, entry, end) * range from the superior map, and then destroy the * submap (if desired). [Better yet, don't try it.] */ -kern_return_t vm_map_submap(map, start, end, submap) - vm_map_t map; - vm_offset_t start; - vm_offset_t end; - vm_map_t submap; +kern_return_t vm_map_submap( + vm_map_t map, + vm_offset_t start, + vm_offset_t end, + vm_map_t submap) { vm_map_entry_t entry; kern_return_t result = KERN_INVALID_ARGUMENT; @@ -1208,12 +1205,12 @@ kern_return_t vm_map_submap(map, start, end, submap) * specified, the maximum protection is to be set; * otherwise, only the current protection is affected. */ -kern_return_t vm_map_protect(map, start, end, new_prot, set_max) - vm_map_t map; - vm_offset_t start; - vm_offset_t end; - vm_prot_t new_prot; - boolean_t set_max; +kern_return_t vm_map_protect( + vm_map_t map, + vm_offset_t start, + vm_offset_t end, + vm_prot_t new_prot, + boolean_t set_max) { vm_map_entry_t current; vm_map_entry_t entry; @@ -1296,11 +1293,11 @@ kern_return_t vm_map_protect(map, start, end, new_prot, set_max) * affects how the map will be shared with * child maps at the time of vm_map_fork. */ -kern_return_t vm_map_inherit(map, start, end, new_inheritance) - vm_map_t map; - vm_offset_t start; - vm_offset_t end; - vm_inherit_t new_inheritance; +kern_return_t vm_map_inherit( + vm_map_t map, + vm_offset_t start, + vm_offset_t end, + vm_inherit_t new_inheritance) { vm_map_entry_t entry; vm_map_entry_t temp_entry; @@ -1345,12 +1342,12 @@ kern_return_t vm_map_inherit(map, start, end, new_inheritance) * Callers should use macros in vm/vm_map.h (i.e. vm_map_pageable, * or vm_map_pageable_user); don't call vm_map_pageable directly. */ -kern_return_t vm_map_pageable_common(map, start, end, access_type, user_wire) - vm_map_t map; - vm_offset_t start; - vm_offset_t end; - vm_prot_t access_type; - boolean_t user_wire; +kern_return_t vm_map_pageable_common( + vm_map_t map, + vm_offset_t start, + vm_offset_t end, + vm_prot_t access_type, + boolean_t user_wire) { vm_map_entry_t entry; vm_map_entry_t start_entry; @@ -1594,9 +1591,9 @@ kern_return_t vm_map_pageable_common(map, start, end, access_type, user_wire) * * Deallocate the given entry from the target map. */ -void vm_map_entry_delete(map, entry) - vm_map_t map; - vm_map_entry_t entry; +void vm_map_entry_delete( + vm_map_t map, + vm_map_entry_t entry) { vm_offset_t s, e; vm_object_t object; @@ -1678,10 +1675,10 @@ void vm_map_entry_delete(map, entry) * map. */ -kern_return_t vm_map_delete(map, start, end) - vm_map_t map; - vm_offset_t start; - vm_offset_t end; +kern_return_t vm_map_delete( + vm_map_t map, + vm_offset_t start, + vm_offset_t end) { vm_map_entry_t entry; vm_map_entry_t first_entry; @@ -1761,10 +1758,10 @@ kern_return_t vm_map_delete(map, start, end) * Remove the given address range from the target map. * This is the exported form of vm_map_delete. */ -kern_return_t vm_map_remove(map, start, end) - vm_map_t map; - vm_offset_t start; - vm_offset_t end; +kern_return_t vm_map_remove( + vm_map_t map, + vm_offset_t start, + vm_offset_t end) { kern_return_t result; @@ -1784,8 +1781,7 @@ kern_return_t vm_map_remove(map, start, end) * that have not already been stolen. */ void -vm_map_copy_steal_pages(copy) -vm_map_copy_t copy; +vm_map_copy_steal_pages(vm_map_copy_t copy) { vm_page_t m, new_m; int i; @@ -1831,8 +1827,7 @@ vm_map_copy_t copy; * stolen, they are freed. If the pages are not stolen, they * are unbusied, and associated state is cleaned up. */ -void vm_map_copy_page_discard(copy) -vm_map_copy_t copy; +void vm_map_copy_page_discard(vm_map_copy_t copy) { while (copy->cpy_npages > 0) { vm_page_t m; @@ -1877,8 +1872,7 @@ vm_map_copy_t copy; * vm_map_copyin). */ void -vm_map_copy_discard(copy) - vm_map_copy_t copy; +vm_map_copy_discard(vm_map_copy_t copy) { free_next_copy: if (copy == VM_MAP_COPY_NULL) @@ -1954,8 +1948,7 @@ free_next_copy: * deallocation will not fail. */ vm_map_copy_t -vm_map_copy_copy(copy) - vm_map_copy_t copy; +vm_map_copy_copy(vm_map_copy_t copy) { vm_map_copy_t new_copy; @@ -2001,9 +1994,9 @@ vm_map_copy_copy(copy) * A version of vm_map_copy_discard that can be called * as a continuation from a vm_map_copy page list. */ -kern_return_t vm_map_copy_discard_cont(cont_args, copy_result) -vm_map_copyin_args_t cont_args; -vm_map_copy_t *copy_result; /* OUT */ +kern_return_t vm_map_copy_discard_cont( +vm_map_copyin_args_t cont_args, +vm_map_copy_t *copy_result) /* OUT */ { vm_map_copy_discard((vm_map_copy_t) cont_args); if (copy_result != (vm_map_copy_t *)0) @@ -2058,11 +2051,11 @@ vm_map_copy_t *copy_result; /* OUT */ * atomically and interruptibly, an error indication is * returned. */ -kern_return_t vm_map_copy_overwrite(dst_map, dst_addr, copy, interruptible) - vm_map_t dst_map; - vm_offset_t dst_addr; - vm_map_copy_t copy; - boolean_t interruptible; +kern_return_t vm_map_copy_overwrite( + vm_map_t dst_map, + vm_offset_t dst_addr, + vm_map_copy_t copy, + boolean_t interruptible) { vm_size_t size; vm_offset_t start; @@ -2435,10 +2428,10 @@ start_pass_1: * If successful, consumes the copy object. * Otherwise, the caller is responsible for it. */ -kern_return_t vm_map_copyout(dst_map, dst_addr, copy) - vm_map_t dst_map; - vm_offset_t *dst_addr; /* OUT */ - vm_map_copy_t copy; +kern_return_t vm_map_copyout( + vm_map_t dst_map, + vm_offset_t *dst_addr, /* OUT */ + vm_map_copy_t copy) { vm_size_t size; vm_size_t adjustment; @@ -2689,10 +2682,10 @@ kern_return_t vm_map_copyout(dst_map, dst_addr, copy) * Version of vm_map_copyout() for page list vm map copies. * */ -kern_return_t vm_map_copyout_page_list(dst_map, dst_addr, copy) - vm_map_t dst_map; - vm_offset_t *dst_addr; /* OUT */ - vm_map_copy_t copy; +kern_return_t vm_map_copyout_page_list( + vm_map_t dst_map, + vm_offset_t *dst_addr, /* OUT */ + vm_map_copy_t copy) { vm_size_t size; vm_offset_t start; @@ -3076,12 +3069,12 @@ error: * In/out conditions: * The source map should not be locked on entry. */ -kern_return_t vm_map_copyin(src_map, src_addr, len, src_destroy, copy_result) - vm_map_t src_map; - vm_offset_t src_addr; - vm_size_t len; - boolean_t src_destroy; - vm_map_copy_t *copy_result; /* OUT */ +kern_return_t vm_map_copyin( + vm_map_t src_map, + vm_offset_t src_addr, + vm_size_t len, + boolean_t src_destroy, + vm_map_copy_t *copy_result) /* OUT */ { vm_map_entry_t tmp_entry; /* Result of last map lookup -- * in multi-level lookup, this @@ -3438,11 +3431,11 @@ kern_return_t vm_map_copyin(src_map, src_addr, len, src_destroy, copy_result) * Our caller donates an object reference. */ -kern_return_t vm_map_copyin_object(object, offset, size, copy_result) - vm_object_t object; - vm_offset_t offset; /* offset of region in object */ - vm_size_t size; /* size of region in object */ - vm_map_copy_t *copy_result; /* OUT */ +kern_return_t vm_map_copyin_object( + vm_object_t object, + vm_offset_t offset, /* offset of region in object */ + vm_size_t size, /* size of region in object */ + vm_map_copy_t *copy_result) /* OUT */ { vm_map_copy_t copy; /* Resulting copy */ @@ -3483,9 +3476,9 @@ kern_return_t vm_map_copyin_object(object, offset, size, copy_result) * the scheduler. */ -kern_return_t vm_map_copyin_page_list_cont(cont_args, copy_result) -vm_map_copyin_args_t cont_args; -vm_map_copy_t *copy_result; /* OUT */ +kern_return_t vm_map_copyin_page_list_cont( + vm_map_copyin_args_t cont_args, + vm_map_copy_t *copy_result) /* OUT */ { kern_return_t result = 0; /* '=0' to quiet gcc warnings */ boolean_t do_abort, src_destroy, src_destroy_only; @@ -3539,15 +3532,14 @@ vm_map_copy_t *copy_result; /* OUT */ * the recipient of this copy_result must be prepared to deal with it. */ -kern_return_t vm_map_copyin_page_list(src_map, src_addr, len, src_destroy, - steal_pages, copy_result, is_cont) - vm_map_t src_map; - vm_offset_t src_addr; - vm_size_t len; - boolean_t src_destroy; - boolean_t steal_pages; - vm_map_copy_t *copy_result; /* OUT */ - boolean_t is_cont; +kern_return_t vm_map_copyin_page_list( + vm_map_t src_map, + vm_offset_t src_addr, + vm_size_t len, + boolean_t src_destroy, + boolean_t steal_pages, + vm_map_copy_t *copy_result, /* OUT */ + boolean_t is_cont) { vm_map_entry_t src_entry; vm_page_t m; @@ -4067,8 +4059,7 @@ error: * * The source map must not be locked. */ -vm_map_t vm_map_fork(old_map) - vm_map_t old_map; +vm_map_t vm_map_fork(vm_map_t old_map) { vm_map_t new_map; vm_map_entry_t old_entry; @@ -4338,17 +4329,16 @@ vm_map_t vm_map_fork(old_map) * copying operations, although the data referenced will * remain the same. */ -kern_return_t vm_map_lookup(var_map, vaddr, fault_type, out_version, - object, offset, out_prot, wired) - vm_map_t *var_map; /* IN/OUT */ - vm_offset_t vaddr; - vm_prot_t fault_type; - - vm_map_version_t *out_version; /* OUT */ - vm_object_t *object; /* OUT */ - vm_offset_t *offset; /* OUT */ - vm_prot_t *out_prot; /* OUT */ - boolean_t *wired; /* OUT */ +kern_return_t vm_map_lookup( + vm_map_t *var_map, /* IN/OUT */ + vm_offset_t vaddr, + vm_prot_t fault_type, + + vm_map_version_t *out_version, /* OUT */ + vm_object_t *object, /* OUT */ + vm_offset_t *offset, /* OUT */ + vm_prot_t *out_prot, /* OUT */ + boolean_t *wired) /* OUT */ { vm_map_entry_t entry; vm_map_t map = *var_map; @@ -4520,9 +4510,9 @@ kern_return_t vm_map_lookup(var_map, vaddr, fault_type, out_version, * since the given version. If successful, the map * will not change until vm_map_verify_done() is called. */ -boolean_t vm_map_verify(map, version) - vm_map_t map; - vm_map_version_t *version; /* REF */ +boolean_t vm_map_verify( + vm_map_t map, + vm_map_version_t *version) /* REF */ { boolean_t result; @@ -4551,19 +4541,16 @@ boolean_t vm_map_verify(map, version) * a task's address map. */ -kern_return_t vm_region(map, address, size, - protection, max_protection, - inheritance, is_shared, - object_name, offset_in_object) - vm_map_t map; - vm_offset_t *address; /* IN/OUT */ - vm_size_t *size; /* OUT */ - vm_prot_t *protection; /* OUT */ - vm_prot_t *max_protection; /* OUT */ - vm_inherit_t *inheritance; /* OUT */ - boolean_t *is_shared; /* OUT */ - ipc_port_t *object_name; /* OUT */ - vm_offset_t *offset_in_object; /* OUT */ +kern_return_t vm_region( + vm_map_t map, + vm_offset_t *address, /* IN/OUT */ + vm_size_t *size, /* OUT */ + vm_prot_t *protection, /* OUT */ + vm_prot_t *max_protection, /* OUT */ + vm_inherit_t *inheritance, /* OUT */ + boolean_t *is_shared, /* OUT */ + ipc_port_t *object_name, /* OUT */ + vm_offset_t *offset_in_object) /* OUT */ { vm_map_entry_t tmp_entry; vm_map_entry_t entry; @@ -4623,9 +4610,9 @@ kern_return_t vm_region(map, address, size, * at allocation time because the adjacent entry * is often wired down. */ -void vm_map_simplify(map, start) - vm_map_t map; - vm_offset_t start; +void vm_map_simplify( + vm_map_t map, + vm_offset_t start) { vm_map_entry_t this_entry; vm_map_entry_t prev_entry; @@ -4684,12 +4671,12 @@ void vm_map_simplify(map, start) * it itself. [This assumes that attributes do not * need to be inherited, which seems ok to me] */ -kern_return_t vm_map_machine_attribute(map, address, size, attribute, value) - vm_map_t map; - vm_offset_t address; - vm_size_t size; - vm_machine_attribute_t attribute; - vm_machine_attribute_val_t* value; /* IN/OUT */ +kern_return_t vm_map_machine_attribute( + vm_map_t map, + vm_offset_t address, + vm_size_t size, + vm_machine_attribute_t attribute, + vm_machine_attribute_val_t* value) /* IN/OUT */ { kern_return_t ret; @@ -4714,8 +4701,7 @@ kern_return_t vm_map_machine_attribute(map, address, size, attribute, value) /* * vm_map_print: [ debug ] */ -void vm_map_print(map) - vm_map_t map; +void vm_map_print(vm_map_t map) { vm_map_entry_t entry; diff --git a/vm/vm_pageout.c b/vm/vm_pageout.c index f4f1fef0..7ac43d6b 100644 --- a/vm/vm_pageout.c +++ b/vm/vm_pageout.c @@ -226,12 +226,12 @@ unsigned int vm_pageout_inactive_cleaned_external = 0; * not busy on exit. */ vm_page_t -vm_pageout_setup(m, paging_offset, new_object, new_offset, flush) - vm_page_t m; - vm_offset_t paging_offset; - vm_object_t new_object; - vm_offset_t new_offset; - boolean_t flush; +vm_pageout_setup( + vm_page_t m, + vm_offset_t paging_offset, + vm_object_t new_object, + vm_offset_t new_offset, + boolean_t flush) { vm_object_t old_object = m->object; vm_page_t holding_page = 0; /*'=0'to quiet gcc warnings*/ @@ -413,10 +413,10 @@ vm_pageout_setup(m, paging_offset, new_object, new_offset, flush) * copy to a new page in a new object, if not. */ void -vm_pageout_page(m, initial, flush) - vm_page_t m; - boolean_t initial; - boolean_t flush; +vm_pageout_page( + vm_page_t m, + boolean_t initial, + boolean_t flush) { vm_map_copy_t copy; vm_object_t old_object; diff --git a/vm/vm_user.c b/vm/vm_user.c index 9ba5e1cf..f7c87cc0 100644 --- a/vm/vm_user.c +++ b/vm/vm_user.c @@ -56,11 +56,11 @@ vm_statistics_data_t vm_stat; * vm_allocate allocates "zero fill" memory in the specfied * map. */ -kern_return_t vm_allocate(map, addr, size, anywhere) - vm_map_t map; - vm_offset_t *addr; - vm_size_t size; - boolean_t anywhere; +kern_return_t vm_allocate( + vm_map_t map, + vm_offset_t *addr, + vm_size_t size, + boolean_t anywhere) { kern_return_t result; @@ -97,10 +97,10 @@ kern_return_t vm_allocate(map, addr, size, anywhere) * vm_deallocate deallocates the specified range of addresses in the * specified address map. */ -kern_return_t vm_deallocate(map, start, size) - vm_map_t map; - vm_offset_t start; - vm_size_t size; +kern_return_t vm_deallocate( + vm_map_t map, + vm_offset_t start, + vm_size_t size) { if (map == VM_MAP_NULL) return(KERN_INVALID_ARGUMENT); @@ -115,11 +115,11 @@ kern_return_t vm_deallocate(map, start, size) * vm_inherit sets the inheritance of the specified range in the * specified map. */ -kern_return_t vm_inherit(map, start, size, new_inheritance) - vm_map_t map; - vm_offset_t start; - vm_size_t size; - vm_inherit_t new_inheritance; +kern_return_t vm_inherit( + vm_map_t map, + vm_offset_t start, + vm_size_t size, + vm_inherit_t new_inheritance) { if (map == VM_MAP_NULL) return(KERN_INVALID_ARGUMENT); @@ -149,12 +149,12 @@ kern_return_t vm_inherit(map, start, size, new_inheritance) * specified map. */ -kern_return_t vm_protect(map, start, size, set_maximum, new_protection) - vm_map_t map; - vm_offset_t start; - vm_size_t size; - boolean_t set_maximum; - vm_prot_t new_protection; +kern_return_t vm_protect( + vm_map_t map, + vm_offset_t start, + vm_size_t size, + boolean_t set_maximum, + vm_prot_t new_protection) { if ((map == VM_MAP_NULL) || (new_protection & ~(VM_PROT_ALL|VM_PROT_NOTIFY))) @@ -172,9 +172,9 @@ kern_return_t vm_protect(map, start, size, set_maximum, new_protection) set_maximum)); } -kern_return_t vm_statistics(map, stat) - vm_map_t map; - vm_statistics_data_t *stat; +kern_return_t vm_statistics( + vm_map_t map, + vm_statistics_data_t *stat) { if (map == VM_MAP_NULL) return(KERN_INVALID_ARGUMENT); @@ -217,12 +217,12 @@ kern_return_t vm_cache_statistics( * Handle machine-specific attributes for a mapping, such * as cachability, migrability, etc. */ -kern_return_t vm_machine_attribute(map, address, size, attribute, value) - vm_map_t map; - vm_address_t address; - vm_size_t size; - vm_machine_attribute_t attribute; - vm_machine_attribute_val_t* value; /* IN/OUT */ +kern_return_t vm_machine_attribute( + vm_map_t map, + vm_address_t address, + vm_size_t size, + vm_machine_attribute_t attribute, + vm_machine_attribute_val_t* value) /* IN/OUT */ { if (map == VM_MAP_NULL) return(KERN_INVALID_ARGUMENT); @@ -235,12 +235,12 @@ kern_return_t vm_machine_attribute(map, address, size, attribute, value) return vm_map_machine_attribute(map, address, size, attribute, value); } -kern_return_t vm_read(map, address, size, data, data_size) - vm_map_t map; - vm_address_t address; - vm_size_t size; - pointer_t *data; - vm_size_t *data_size; +kern_return_t vm_read( + vm_map_t map, + vm_address_t address, + vm_size_t size, + pointer_t *data, + vm_size_t *data_size) { kern_return_t error; vm_map_copy_t ipc_address; @@ -259,11 +259,11 @@ kern_return_t vm_read(map, address, size, data, data_size) return(error); } -kern_return_t vm_write(map, address, data, size) - vm_map_t map; - vm_address_t address; - pointer_t data; - vm_size_t size; +kern_return_t vm_write( + vm_map_t map, + vm_address_t address, + pointer_t data, + vm_size_t size) { if (map == VM_MAP_NULL) return KERN_INVALID_ARGUMENT; @@ -272,11 +272,11 @@ kern_return_t vm_write(map, address, data, size) FALSE /* interruptible XXX */); } -kern_return_t vm_copy(map, source_address, size, dest_address) - vm_map_t map; - vm_address_t source_address; - vm_size_t size; - vm_address_t dest_address; +kern_return_t vm_copy( + vm_map_t map, + vm_address_t source_address, + vm_size_t size, + vm_address_t dest_address) { vm_map_copy_t copy; kern_return_t kr; @@ -304,22 +304,17 @@ kern_return_t vm_copy(map, source_address, size, dest_address) * Routine: vm_map */ kern_return_t vm_map( - target_map, - address, size, mask, anywhere, - memory_object, offset, - copy, - cur_protection, max_protection, inheritance) - vm_map_t target_map; - vm_offset_t *address; - vm_size_t size; - vm_offset_t mask; - boolean_t anywhere; - ipc_port_t memory_object; - vm_offset_t offset; - boolean_t copy; - vm_prot_t cur_protection; - vm_prot_t max_protection; - vm_inherit_t inheritance; + vm_map_t target_map, + vm_offset_t *address, + vm_size_t size, + vm_offset_t mask, + boolean_t anywhere, + ipc_port_t memory_object, + vm_offset_t offset, + boolean_t copy, + vm_prot_t cur_protection, + vm_prot_t max_protection, + vm_inherit_t inheritance) { vm_object_t object; kern_return_t result; -- cgit v1.2.3 From 119294278af2390971305224c9772d89525d97e1 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Sat, 5 Apr 2014 15:08:06 +0200 Subject: include: make the notify_port_t types translation functions mutable Make the intran, outtran and destructor functions mutable using preprocessor macros. Make it possible to inject imports using the NOTIFY_IMPORTS macro. This way, userspace servers can provide their own translation functions. * include/mach/notify.defs: Honor NOTIFY_IMPORTS. (notify_port_t): Make the translation mutable using preprocessor macros. --- include/mach/notify.defs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/include/mach/notify.defs b/include/mach/notify.defs index e06f6b41..fdf35e98 100644 --- a/include/mach/notify.defs +++ b/include/mach/notify.defs @@ -28,6 +28,10 @@ subsystem notify 64; #include +#ifdef NOTIFY_IMPORTS +NOTIFY_IMPORTS +#endif + #if SEQNOS serverprefix do_seqnos_; serverdemux seqnos_notify_server; @@ -37,7 +41,17 @@ serverdemux notify_server; #endif SEQNOS type notify_port_t = MACH_MSG_TYPE_MOVE_SEND_ONCE - ctype: mach_port_t; + ctype: mach_port_t +#ifdef NOTIFY_INTRAN + intran: NOTIFY_INTRAN +#endif +#ifdef NOTIFY_OUTTRAN + outtran: NOTIFY_OUTTRAN +#endif +#ifdef NOTIFY_DESTRUCTOR + destructor: NOTIFY_DESTRUCTOR +#endif +; /* MACH_NOTIFY_FIRST: 0100 */ skip; -- cgit v1.2.3 From f1cdf417edeb9979a5f1f32c20d7ad75abc97a14 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Tue, 8 Apr 2014 15:40:42 +0200 Subject: include: make the device_t types translation functions mutable Make the intran, outtran and destructor functions mutable using preprocessor macros. Make it possible to inject imports using the DEVICE_IMPORTS macro. This way, userspace servers can provide their own translation functions. * include/device/device_types.defs: Honor DEVICE_IMPORTS. (device_t): Make the translation mutable using preprocessor macros. --- include/device/device_types.defs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/include/device/device_types.defs b/include/device/device_types.defs index 79e4c5b0..ff6cff68 100644 --- a/include/device/device_types.defs +++ b/include/device/device_types.defs @@ -39,6 +39,10 @@ #include +#ifdef DEVICE_IMPORTS +DEVICE_IMPORTS +#endif + type recnum_t = unsigned32; type dev_mode_t = unsigned32; type dev_flavor_t = unsigned32; @@ -55,6 +59,16 @@ type device_t = mach_port_t intran: device_t dev_port_lookup(mach_port_t) outtran: mach_port_t convert_device_to_port(device_t) destructor: device_deallocate(device_t) +#else /* KERNEL_SERVER */ +#ifdef DEVICE_INTRAN + intran: DEVICE_INTRAN +#endif +#ifdef DEVICE_OUTTRAN + outtran: DEVICE_OUTTRAN +#endif +#ifdef DEVICE_DESTRUCTOR + destructor: DEVICE_DESTRUCTOR +#endif #endif /* KERNEL_SERVER */ ; -- cgit v1.2.3 From 5e533682c0df29d28dc8250c57c2e33406a57835 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Thu, 10 Apr 2014 19:13:47 +0200 Subject: include: fix the definition of device_open Previously, every userspace server implementing the device protocol filtered the device definitions to replace the device_t type with mach_port_send_t to make the device argument of device_open polymorphic. Rather than doing that, which makes it impossible to use translation functions, fix the definition of device_open. * include/device/device.defs (device_open): Redefine the device argument to make it polymorphic unless a outran function is specified. --- include/device/device.defs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/include/device/device.defs b/include/device/device.defs index d9234e39..5fdf1bd6 100644 --- a/include/device/device.defs +++ b/include/device/device.defs @@ -52,7 +52,16 @@ routine device_open( sreplyport reply_port : reply_port_t; mode : dev_mode_t; name : dev_name_t; - out device : device_t + out device : device_t = + MACH_MSG_TYPE_PORT_SEND + ctype: mach_port_t +#if KERNEL_SERVER + outtran: mach_port_t convert_device_to_port(device_t) +#else +#ifdef DEVICE_OUTTRAN + outtran: DEVICE_OUTTRAN +#endif +#endif /* KERNEL_SERVER */ ); routine device_close( -- cgit v1.2.3 From 4e55e56252676ea4773023a08994c0f363844343 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Sun, 13 Apr 2014 09:16:58 +0200 Subject: kern: set the name of tasks created during the bootstrap * kern/bootstrap.c (boot_script_task_create): Set the name of newly created tasks. --- kern/bootstrap.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kern/bootstrap.c b/kern/bootstrap.c index 7cfff3a1..d919e905 100644 --- a/kern/bootstrap.c +++ b/kern/bootstrap.c @@ -800,6 +800,7 @@ boot_script_task_create (struct cmd *cmd) printf("boot_script_task_create failed with %x\n", rc); return BOOT_SCRIPT_MACH_ERROR; } + task_set_name(cmd->task, cmd->path); return 0; } -- cgit v1.2.3 From b28e05e203e0739fa5db59c5af378b29eea7a232 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Fri, 25 Apr 2014 20:39:23 +0200 Subject: Make sure mig is available * configure.ac (MIG): Error out if MiG was not found. --- configure.ac | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 40e78a04..bd8a1881 100644 --- a/configure.ac +++ b/configure.ac @@ -86,7 +86,12 @@ AC_CHECK_TOOL([AR], [ar]) AC_CHECK_TOOL([LD], [ld]) AC_CHECK_TOOL([NM], [nm]) -AC_CHECK_TOOL([MIG], [mig], [mig]) +AC_CHECK_TOOL([MIG], [mig], [:]) + +if test "$MIG" = : +then + AC_MSG_ERROR([The MiG generator is required to build GNU Mach]) +fi dnl Needed for the Automake option `subdir-objects'. AM_PROG_CC_C_O -- cgit v1.2.3 From 1a9af211b3f0fb93611e6795ce66576b2ab230c8 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Wed, 30 Apr 2014 12:31:09 +0200 Subject: doc: fix the number of priorities The number of priorities has been changed from 32 to 50 in 6a234201081156e6d5742e7eeabb68418b518fad. * doc/mach.texi: Update accordingly. --- doc/mach.texi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/mach.texi b/doc/mach.texi index d089224d..49c0d678 100644 --- a/doc/mach.texi +++ b/doc/mach.texi @@ -4557,7 +4557,7 @@ their priority from their task and their max priority from the thread. @deftypefun kern_return_t thread_priority (@w{thread_t @var{thread}}, @w{int @var{prority}}, @w{boolean_t @var{set_max}}) The function @code{thread_priority} changes the priority and optionally -the maximum priority of @var{thread}. Priorities range from 0 to 31, +the maximum priority of @var{thread}. Priorities range from 0 to 49, where lower numbers denote higher priorities. If the new priority is higher than the priority of the current thread, preemption may occur as a result of this call. The maximum priority of the thread is also set @@ -4568,7 +4568,7 @@ priority. The functions returns @code{KERN_SUCCESS} if the operation completed successfully, @code{KERN_INVALID_ARGUMENT} if @var{thread} is not a -thread or @var{priority} is out of range (not in 0..31), and +thread or @var{priority} is out of range (not in 0..49), and @code{KERN_FAILURE} if the requested operation would violate the thread's maximum priority (thread_priority). @end deftypefun @@ -4582,7 +4582,7 @@ legal value. The functions returns @code{KERN_SUCCESS} if the operation completed successfully, @code{KERN_INVALID_ARGUMENT} if @var{thread} is not a thread or @var{processor_set} is not a control port for a processor set -or @var{priority} is out of range (not in 0..31), and +or @var{priority} is out of range (not in 0..49), and @code{KERN_FAILURE} if the thread is not assigned to the processor set whose control port was presented. @end deftypefun -- cgit v1.2.3 From d12207fb5a8cef131f262878f98da923af1f8fea Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Wed, 30 Apr 2014 13:02:29 +0200 Subject: Install the mach_debug header files The task_set_name RPC introduced in 877a319c changed include/mach/gnumach.defs to include mach_debug/mach_debug_types.defs. Previously though, the debug headers were not installed. * Makefrag.am: Install the mach_debug header files. --- Makefrag.am | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Makefrag.am b/Makefrag.am index c1387bd3..d6dd77f9 100644 --- a/Makefrag.am +++ b/Makefrag.am @@ -419,9 +419,18 @@ include_mach_eXec_HEADERS = \ include/mach/exec/elf.h \ include/mach/exec/exec.h -# mach-debug-headers:= $(addprefix mach_debug/, hash_info.h ipc_info.h \ -# mach_debug.defs mach_debug_types.defs mach_debug_types.h \ -# pc_info.h vm_info.h slab_info.h) +include_mach_debugdir = $(includedir)/mach_debug +include_mach_debug_HEADERS = \ + $(addprefix include/mach_debug/, \ + hash_info.h \ + ipc_info.h \ + mach_debug.defs \ + mach_debug_types.defs \ + mach_debug_types.h \ + pc_info.h \ + vm_info.h \ + slab_info.h \ + ) # Other headers for the distribution. We don't install these, because the # GNU C library has correct versions for users to use. -- cgit v1.2.3 From 32b5d3ceb7a120b76f10f69afb6acbf453a76bbc Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Wed, 30 Apr 2014 13:52:47 +0200 Subject: include: do not guard the host_slab_info RPC with MACH_VM_DEBUG Previously, the definition of the host_slab_info RPC was guarded with MACH_VM_DEBUG, even though it is not at all concerned with the VM subsystem. Furthermore, there was no "skip" directive for host_slab_info. The function host_slab_info is guarded with MACH_DEBUG. The server for the RPCs in mach_debug.defs is only used if MACH_DEBUG is defined. There is no need to guard host_slab_info. * include/mach_debug/mach_debug.defs (host_slab_info): Unconditionally include the RPC. --- include/mach_debug/mach_debug.defs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/mach_debug/mach_debug.defs b/include/mach_debug/mach_debug.defs index 053c3fe6..fb6e3a95 100644 --- a/include/mach_debug/mach_debug.defs +++ b/include/mach_debug/mach_debug.defs @@ -218,6 +218,12 @@ routine mach_vm_object_pages( out pages : vm_page_info_array_t, CountInOut, Dealloc); +#else /* !defined(MACH_VM_DEBUG) || MACH_VM_DEBUG */ +skip; /* mach_vm_region_info */ +skip; /* mach_vm_object_info */ +skip; /* mach_vm_object_pages */ +#endif /* !defined(MACH_VM_DEBUG) || MACH_VM_DEBUG */ + /* * Returns information about the memory allocation caches. */ @@ -225,9 +231,3 @@ routine host_slab_info( host : host_t; out info : cache_info_array_t, CountInOut, Dealloc); - -#else /* !defined(MACH_VM_DEBUG) || MACH_VM_DEBUG */ -skip; /* mach_vm_region_info */ -skip; /* mach_vm_object_info */ -skip; /* mach_vm_object_pages */ -#endif /* !defined(MACH_VM_DEBUG) || MACH_VM_DEBUG */ -- cgit v1.2.3 From b6dab094d2b6531fdc867af906dd006e39cac2d9 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Wed, 30 Apr 2014 14:40:39 +0200 Subject: kern: include the MIG-generated server headers for MACHINE_SERVER 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 for the machine-dependent interfaces. (ipc_kobject_server): Drop the simple declaration of MACHINE_SERVER_ROUTINE. * i386/i386/machine_routines.h (MACHINE_SERVER_HEADER): New definition. --- i386/i386/machine_routines.h | 1 + kern/ipc_kobject.c | 5 +---- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/i386/i386/machine_routines.h b/i386/i386/machine_routines.h index d77849a6..65315e5f 100644 --- a/i386/i386/machine_routines.h +++ b/i386/i386/machine_routines.h @@ -31,6 +31,7 @@ * The i386 has a set of machine-dependent interfaces. */ #define MACHINE_SERVER mach_i386_server +#define MACHINE_SERVER_HEADER #define MACHINE_SERVER_ROUTINE mach_i386_server_routine #endif /* _I386_MACHINE_ROUTINES_H_ */ diff --git a/kern/ipc_kobject.c b/kern/ipc_kobject.c index 13af8202..bf22028e 100644 --- a/kern/ipc_kobject.c +++ b/kern/ipc_kobject.c @@ -63,6 +63,7 @@ #if MACH_MACHINE_ROUTINES #include +#include MACHINE_SERVER_HEADER #endif @@ -158,10 +159,6 @@ ipc_kobject_server(request) * to perform the kernel function */ { -#if MACH_MACHINE_ROUTINES - extern mig_routine_t MACHINE_SERVER_ROUTINE(); -#endif - check_simple_locks(); if ((routine = mach_server_routine(&request->ikm_header)) != 0 || (routine = mach_port_server_routine(&request->ikm_header)) != 0 -- cgit v1.2.3 From 4fda696b13d2d9fdb9496b2aeee1b05a6f852836 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Wed, 30 Apr 2014 17:31:49 +0200 Subject: i386: fix MACHINE_SERVER_HEADER Commit b6dab094 introduced a way to include the MIG-generated server files for the machine specific interface in ipc_kobject.c. This broke out-of-tree builds. Here, 'machine' is a symlink to '../i386/i386', it points into the source tree. The MIG-generated files however are put in the build tree in i386/i386. * i386/i386/machine_routines.h (MACHINE_SERVER_HEADER): Fix path. --- i386/i386/machine_routines.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i386/i386/machine_routines.h b/i386/i386/machine_routines.h index 65315e5f..d9dd94be 100644 --- a/i386/i386/machine_routines.h +++ b/i386/i386/machine_routines.h @@ -31,7 +31,7 @@ * The i386 has a set of machine-dependent interfaces. */ #define MACHINE_SERVER mach_i386_server -#define MACHINE_SERVER_HEADER +#define MACHINE_SERVER_HEADER "i386/i386/mach_i386.server.h" #define MACHINE_SERVER_ROUTINE mach_i386_server_routine #endif /* _I386_MACHINE_ROUTINES_H_ */ -- cgit v1.2.3 From dca400e253df97804dd04b24e96aebba878781a0 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Wed, 30 Apr 2014 15:23:36 +0200 Subject: vm: make struct vm_map fit into a cache line Currently, the size of struct vm_map is 68 bytes. By using a bit field for the boolean flags, it can be made fit into a cache line. * vm/vm_map.h (struct vm_map): Use a bit field for the boolean flags wait_for_space and wiring_required. --- vm/vm_map.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/vm/vm_map.h b/vm/vm_map.h index b6bc177a..b8103ebc 100644 --- a/vm/vm_map.h +++ b/vm/vm_map.h @@ -175,9 +175,12 @@ struct vm_map { vm_map_entry_t hint; /* hint for quick lookups */ decl_simple_lock_data(, hint_lock) /* lock for hint storage */ vm_map_entry_t first_free; /* First free space hint */ - boolean_t wait_for_space; /* Should callers wait + + /* Flags */ + unsigned int wait_for_space:1, /* Should callers wait for space? */ - boolean_t wiring_required;/* All memory wired? */ + /* boolean_t */ wiring_required:1; /* All memory wired? */ + unsigned int timestamp; /* Version number */ }; -- cgit v1.2.3 From 12baa940dd214046902a0d7815f24cfad989fe79 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Fri, 2 May 2014 18:51:50 +0200 Subject: ddb: add "halt" command * ddb/db_command.c (db_command_table): Add "halt" command. * i386/i386/db_interface.h (db_halt_cpu): New declaration. * i386/i386at/model_dep.c (db_halt_cpu): New function. --- ddb/db_command.c | 1 + i386/i386/db_interface.h | 2 ++ i386/i386at/model_dep.c | 5 +++++ 3 files changed, 8 insertions(+) diff --git a/ddb/db_command.c b/ddb/db_command.c index ebb13dfd..81711192 100644 --- a/ddb/db_command.c +++ b/ddb/db_command.c @@ -363,6 +363,7 @@ struct db_command db_command_table[] = { { "show", 0, 0, db_show_cmds }, { "reset", db_reset_cpu, 0, 0 }, { "reboot", db_reset_cpu, 0, 0 }, + { "halt", db_halt_cpu, 0, 0 }, { (char *)0, } }; diff --git a/i386/i386/db_interface.h b/i386/i386/db_interface.h index 97ff5c7b..8d7daeae 100644 --- a/i386/i386/db_interface.h +++ b/i386/i386/db_interface.h @@ -97,6 +97,8 @@ db_stack_trace_cmd( db_expr_t count, const char *modif); +extern void +db_halt_cpu(void); extern void db_reset_cpu(void); diff --git a/i386/i386at/model_dep.c b/i386/i386at/model_dep.c index 7d138bed..95752faa 100644 --- a/i386/i386at/model_dep.c +++ b/i386/i386at/model_dep.c @@ -243,6 +243,11 @@ void exit(int rc) halt_all_cpus(0); } +void db_halt_cpu(void) +{ + halt_all_cpus(0); +} + void db_reset_cpu(void) { halt_all_cpus(1); -- cgit v1.2.3 From 3617701208c6fd63386442d2d107d37ff7d22041 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Sun, 25 May 2014 15:53:23 +0200 Subject: include: fix the embedded type definitions in memory_object.defs In order to use MIG translation functions to lookup memory objects, preprocessor macros have been introduced into the definition of memory_object_t in 50cc5152. The procedure definitions contain inlined type definitions in order to change the type of the argument in question (i.e. to make it polymorphic). The inline definitions however lack the destructor function, leading to reference leaks when a reference is acquired in the intran function. * include/mach/memory_object.defs: Add the destructor functions to the inlined type definitions. --- include/mach/memory_object.defs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/mach/memory_object.defs b/include/mach/memory_object.defs index 0ed8dbcd..1ae36aa2 100644 --- a/include/mach/memory_object.defs +++ b/include/mach/memory_object.defs @@ -92,6 +92,9 @@ simpleroutine memory_object_terminate( ctype: mach_port_t #ifdef MEMORY_OBJECT_INTRAN intran: MEMORY_OBJECT_INTRAN +#endif +#ifdef MEMORY_OBJECT_DESTRUCTOR + destructor: MEMORY_OBJECT_DESTRUCTOR #endif ; #if SEQNOS @@ -232,6 +235,9 @@ simpleroutine memory_object_lock_completed( ctype: mach_port_t #ifdef MEMORY_OBJECT_INTRAN intran: MEMORY_OBJECT_INTRAN +#endif +#ifdef MEMORY_OBJECT_DESTRUCTOR + destructor: MEMORY_OBJECT_DESTRUCTOR #endif ; #if SEQNOS @@ -267,6 +273,9 @@ simpleroutine memory_object_supply_completed( ctype: mach_port_t #ifdef MEMORY_OBJECT_INTRAN intran: MEMORY_OBJECT_INTRAN +#endif +#ifdef MEMORY_OBJECT_DESTRUCTOR + destructor: MEMORY_OBJECT_DESTRUCTOR #endif ; #if SEQNOS @@ -317,6 +326,9 @@ simpleroutine memory_object_change_completed( ctype: mach_port_t #ifdef MEMORY_OBJECT_INTRAN intran: MEMORY_OBJECT_INTRAN +#endif +#ifdef MEMORY_OBJECT_DESTRUCTOR + destructor: MEMORY_OBJECT_DESTRUCTOR #endif ; #if SEQNOS -- cgit v1.2.3 From 306d763d872bae2a1cc23fe13b769cace8198a3a Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Sun, 25 May 2014 16:19:16 +0200 Subject: Rewrite old-style #endif FOO directives * i386/include/mach/i386/cthreads.h: Rewrite old-style #endif FOO directives. * include/device/tape_status.h: Likewise. * include/mach/alert.h: Likewise. * include/mach/boot.h: Likewise. * include/mach/default_pager_types.defs: Likewise. * include/mach/default_pager_types.h: Likewise. * include/mach/multiboot.h: Likewise. * include/mach/notify.defs: Likewise. * include/mach_debug/pc_info.h: Likewise. * kern/act.h: Likewise. * kern/refcount.h: Likewise. * kern/shuttle.h: Likewise. --- i386/include/mach/i386/cthreads.h | 2 +- include/device/tape_status.h | 2 +- include/mach/alert.h | 2 +- include/mach/boot.h | 4 ++-- include/mach/default_pager_types.defs | 2 +- include/mach/default_pager_types.h | 2 +- include/mach/multiboot.h | 2 +- include/mach/notify.defs | 16 ++++++++-------- include/mach_debug/pc_info.h | 2 +- kern/act.h | 2 +- kern/refcount.h | 2 +- kern/shuttle.h | 2 +- 12 files changed, 20 insertions(+), 20 deletions(-) diff --git a/i386/include/mach/i386/cthreads.h b/i386/include/mach/i386/cthreads.h index f9755b4a..d2aa16f5 100644 --- a/i386/include/mach/i386/cthreads.h +++ b/i386/include/mach/i386/cthreads.h @@ -53,4 +53,4 @@ typedef volatile int spin_lock_t; #endif /* __GNUC__ */ -#endif _MACHINE_CTHREADS_H_ +#endif /* _MACHINE_CTHREADS_H_ */ diff --git a/include/device/tape_status.h b/include/device/tape_status.h index 97cb098a..603d76c5 100644 --- a/include/device/tape_status.h +++ b/include/device/tape_status.h @@ -137,4 +137,4 @@ struct mtget { #define MTIOCEEOT _IO('m', 4) /* enable EOT error */ -#endif _TAPE_STATUS_H_ +#endif /* _TAPE_STATUS_H_ */ diff --git a/include/mach/alert.h b/include/mach/alert.h index 8232f9ef..e8eb3713 100644 --- a/include/mach/alert.h +++ b/include/mach/alert.h @@ -34,4 +34,4 @@ #define ALERT_USER 0xffff0000 /* User-defined alert bits */ -#endif _MACH_ALERT_H_ +#endif /* _MACH_ALERT_H_ */ diff --git a/include/mach/boot.h b/include/mach/boot.h index d3e141fa..7f14cc4b 100644 --- a/include/mach/boot.h +++ b/include/mach/boot.h @@ -65,7 +65,7 @@ struct boot_rendezvous int code; }; -#endif !__ASSEMBLER__ +#endif /* !__ASSEMBLER__ */ /* This is the magic value that must appear in boot_module.magic. */ @@ -90,4 +90,4 @@ struct boot_rendezvous #define BRZV_DATA 'D' -#endif _MACH_BOOT_ +#endif /* _MACH_BOOT_ */ diff --git a/include/mach/default_pager_types.defs b/include/mach/default_pager_types.defs index 3164f047..bee7c259 100644 --- a/include/mach/default_pager_types.defs +++ b/include/mach/default_pager_types.defs @@ -41,4 +41,4 @@ type default_pager_filename_t = (MACH_MSG_TYPE_STRING_C, 8*256); import ; -#endif _MACH_DEFAULT_PAGER_TYPES_DEFS_ +#endif /* _MACH_DEFAULT_PAGER_TYPES_DEFS_ */ diff --git a/include/mach/default_pager_types.h b/include/mach/default_pager_types.h index 99e43ce3..f5ce5a4f 100644 --- a/include/mach/default_pager_types.h +++ b/include/mach/default_pager_types.h @@ -55,4 +55,4 @@ typedef default_pager_page_t *default_pager_page_array_t; typedef char default_pager_filename_t[256]; -#endif _MACH_DEFAULT_PAGER_TYPES_H_ +#endif /* _MACH_DEFAULT_PAGER_TYPES_H_ */ diff --git a/include/mach/multiboot.h b/include/mach/multiboot.h index 3880fa80..b23df4a4 100644 --- a/include/mach/multiboot.h +++ b/include/mach/multiboot.h @@ -79,4 +79,4 @@ struct multiboot_info natural_t pad[4]; }; -#endif _MACH_MULTIBOOT_H_ +#endif /* _MACH_MULTIBOOT_H_ */ diff --git a/include/mach/notify.defs b/include/mach/notify.defs index fdf35e98..5e59d392 100644 --- a/include/mach/notify.defs +++ b/include/mach/notify.defs @@ -35,10 +35,10 @@ NOTIFY_IMPORTS #if SEQNOS serverprefix do_seqnos_; serverdemux seqnos_notify_server; -#else SEQNOS +#else serverprefix do_; serverdemux notify_server; -#endif SEQNOS +#endif type notify_port_t = MACH_MSG_TYPE_MOVE_SEND_ONCE ctype: mach_port_t @@ -61,7 +61,7 @@ simpleroutine mach_notify_port_deleted( notify : notify_port_t; #if SEQNOS msgseqno seqno : mach_port_seqno_t; -#endif SEQNOS +#endif name : mach_port_name_t); /* MACH_NOTIFY_MSG_ACCEPTED: 0102 */ @@ -69,7 +69,7 @@ simpleroutine mach_notify_msg_accepted( notify : notify_port_t; #if SEQNOS msgseqno seqno : mach_port_seqno_t; -#endif SEQNOS +#endif name : mach_port_name_t); skip; /* was NOTIFY_OWNERSHIP_RIGHTS: 0103 */ @@ -81,7 +81,7 @@ simpleroutine mach_notify_port_destroyed( notify : notify_port_t; #if SEQNOS msgseqno seqno : mach_port_seqno_t; -#endif SEQNOS +#endif rights : mach_port_receive_t); /* MACH_NOTIFY_NO_SENDERS: 0106 */ @@ -89,7 +89,7 @@ simpleroutine mach_notify_no_senders( notify : notify_port_t; #if SEQNOS msgseqno seqno : mach_port_seqno_t; -#endif SEQNOS +#endif mscount : mach_port_mscount_t); /* MACH_NOTIFY_SEND_ONCE: 0107 */ @@ -97,7 +97,7 @@ simpleroutine mach_notify_send_once( notify : notify_port_t #if SEQNOS ; msgseqno seqno : mach_port_seqno_t -#endif SEQNOS +#endif ); /* MACH_NOTIFY_DEAD_NAME: 0110 */ @@ -105,5 +105,5 @@ simpleroutine mach_notify_dead_name( notify : notify_port_t; #if SEQNOS msgseqno seqno : mach_port_seqno_t; -#endif SEQNOS +#endif name : mach_port_name_t); diff --git a/include/mach_debug/pc_info.h b/include/mach_debug/pc_info.h index bc43fa8d..912da9fd 100644 --- a/include/mach_debug/pc_info.h +++ b/include/mach_debug/pc_info.h @@ -40,4 +40,4 @@ typedef struct sampled_pc { typedef sampled_pc_t *sampled_pc_array_t; typedef unsigned int sampled_pc_seqno_t; -#endif _MACH_DEBUG_PC_INFO_H_ +#endif /* _MACH_DEBUG_PC_INFO_H_ */ diff --git a/kern/act.h b/kern/act.h index 6d3a9a9e..f46f53a3 100644 --- a/kern/act.h +++ b/kern/act.h @@ -189,4 +189,4 @@ kern_return_t act_machine_get_state(Act *inc, int flavor, int *tstate, unsigned #endif /* MIGRATING_THREADS */ -#endif _KERN_ACT_H_ +#endif /* _KERN_ACT_H_ */ diff --git a/kern/refcount.h b/kern/refcount.h index 01dc6b59..74204d6b 100644 --- a/kern/refcount.h +++ b/kern/refcount.h @@ -65,4 +65,4 @@ typedef struct RefCount RefCount; #endif /* MACHINE_REFCOUNT */ -#endif _KERN_REFCOUNT_H_ +#endif /* _KERN_REFCOUNT_H_ */ diff --git a/kern/shuttle.h b/kern/shuttle.h index e8e574b6..0b1c2c5e 100644 --- a/kern/shuttle.h +++ b/kern/shuttle.h @@ -68,4 +68,4 @@ typedef struct Shuttle Shuttle; -#endif _KERN_SHUTTLE_H_ +#endif /* _KERN_SHUTTLE_H_ */ -- cgit v1.2.3 From dc1631b7dc508cb67fa6983007ddba3a2314d6bf Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Tue, 27 May 2014 20:28:56 +0200 Subject: Add missing memory clobber * i386/i386/xen.h (mb, rmb, wmb): Add memory clobber. --- i386/i386/xen.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i386/i386/xen.h b/i386/i386/xen.h index 5bdaf0b8..638d6713 100644 --- a/i386/i386/xen.h +++ b/i386/i386/xen.h @@ -33,7 +33,7 @@ /* TODO: this should be moved in appropriate non-Xen place. */ #define barrier() __asm__ __volatile__ ("": : :"memory") -#define mb() __asm__ __volatile__("lock; addl $0,0(%esp)") +#define mb() __asm__ __volatile__("lock; addl $0,0(%%esp)":::"memory") #define rmb() mb() #define wmb() mb() MACH_INLINE unsigned long xchgl(volatile unsigned long *ptr, unsigned long x) -- cgit v1.2.3 From b0039d6972f631ca7fdff2379d50ad31c3781a7d Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Sun, 8 Jun 2014 11:17:08 +0200 Subject: device: fix net_rcv_msg-messages Previously, all net_rcv_msg-messages sent by net_deliver were malformed. It never was a problem in practice, since the messages are not complex and thus the kernel does not try to parse the message. struct net_rcv_msg contains an additional field of type boolean_t. This field has no associated type descriptor, so it must not be included in the message. * device/net_io.c (net_deliver): Account for the extra field in the msgh_size calculation. --- device/net_io.c | 1 + 1 file changed, 1 insertion(+) diff --git a/device/net_io.c b/device/net_io.c index 82b6fb92..a9d318e4 100644 --- a/device/net_io.c +++ b/device/net_io.c @@ -467,6 +467,7 @@ boolean_t net_deliver(boolean_t nonblocking) /* remember message sizes must be rounded up */ kmsg->ikm_header.msgh_size = (((mach_msg_size_t) (sizeof(struct net_rcv_msg) + - sizeof net_kmsg(kmsg)->sent - NET_RCV_MAX + count)) + 3) &~ 3; kmsg->ikm_header.msgh_local_port = MACH_PORT_NULL; kmsg->ikm_header.msgh_kind = MACH_MSGH_KIND_NORMAL; -- cgit v1.2.3 From e4b4e64ba7d2679df6508f27ce75d90cba7f5cb5 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Mon, 9 Jun 2014 15:12:03 +0200 Subject: kern: set the name of the kernel task to 'gnumach' * kern/taks.c (task_init): Set the name of the kernel task to 'gnumach'. --- kern/task.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kern/task.c b/kern/task.c index 66eb25ce..20acc6ac 100644 --- a/kern/task.c +++ b/kern/task.c @@ -70,6 +70,7 @@ void task_init(void) * for other initialization. (:-() */ (void) task_create(TASK_NULL, FALSE, &kernel_task); + (void) task_set_name(kernel_task, "gnumach"); } kern_return_t task_create( -- cgit v1.2.3 From 1d1a672bcac7b36ff35e48fb9633d56c8e733343 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Mon, 9 Jun 2014 15:15:58 +0200 Subject: ddb: print task names if available * ddb/db_print.c (db_print_task): Print task name if available. * i386/i386/db_interface.c (db_task_name): Likewise. * i386/i386/db_machdep.h (DB_GNUMACH_TASK_NAME): Remove unused definition. --- ddb/db_print.c | 7 ++++++- i386/i386/db_interface.c | 4 ++-- i386/i386/db_machdep.h | 1 - 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/ddb/db_print.c b/ddb/db_print.c index c015d84b..1cbff648 100644 --- a/ddb/db_print.c +++ b/ddb/db_print.c @@ -258,7 +258,12 @@ db_print_task( } else { if (flag & OPTION_TASK_TITLE) db_printf(" TASK THREADS\n"); - db_printf("%3d (%0*X): ", task_id, 2*sizeof(vm_offset_t), task); + if (task->name[0]) + db_printf("%3d %s (%0*X): ", task_id, task->name, + 2*sizeof(vm_offset_t), task); + else + db_printf("%3d (%0*X): ", task_id, + 2*sizeof(vm_offset_t), task); if (task->thread_count == 0) { db_printf("no threads\n"); } else { diff --git a/i386/i386/db_interface.c b/i386/i386/db_interface.c index 13376853..b442b862 100644 --- a/i386/i386/db_interface.c +++ b/i386/i386/db_interface.c @@ -730,8 +730,8 @@ db_task_name( vm_offset_t vaddr, kaddr; unsigned sp; - if (task->map->pmap == kernel_pmap) { - db_printf(DB_GNUMACH_TASK_NAME); + if (task->name[0]) { + db_printf("%s", task->name); return; } diff --git a/i386/i386/db_machdep.h b/i386/i386/db_machdep.h index c6ea3ca9..ae1f9c09 100644 --- a/i386/i386/db_machdep.h +++ b/i386/i386/db_machdep.h @@ -93,7 +93,6 @@ db_regs_t ddb_regs; /* register state */ #define DB_TASK_NAME_TITLE "COMMAND " #define DB_TASK_NAME_LEN 23 #define DB_NULL_TASK_NAME "? " -#define DB_GNUMACH_TASK_NAME "gnumach " /* macro for checking if a thread has used floating-point */ -- cgit v1.2.3 From 5fdfd14beb86088faa058bcd6c2b27bb41a1a510 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Mon, 9 Jun 2014 15:25:57 +0200 Subject: ddb: use db_thread_stat to format the flags * ddb/db_print.c (db_print_thread): Use db_thread_stat to format the flags. --- ddb/db_print.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/ddb/db_print.c b/ddb/db_print.c index 1cbff648..e711ab66 100644 --- a/ddb/db_print.c +++ b/ddb/db_print.c @@ -194,12 +194,8 @@ db_print_thread( 2*sizeof(vm_offset_t), thread); else db_printf("(%0*X) ", 2*sizeof(vm_offset_t), thread); - db_printf("%c%c%c%c%c", - (thread->state & TH_RUN) ? 'R' : ' ', - (thread->state & TH_WAIT) ? 'W' : ' ', - (thread->state & TH_SUSP) ? 'S' : ' ', - (thread->state & TH_UNINT)? 'N' : ' ', - db_thread_fp_used(thread) ? 'F' : ' '); + char status[8]; + db_printf("%s", db_thread_stat(thread, status)); if (thread->state & TH_SWAPPED) { if (thread->swap_func) { db_printf("("); -- cgit v1.2.3 From 24367e94ccb1e1b74b865d27ec31184184cd98e7 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Mon, 9 Jun 2014 17:40:18 +0200 Subject: i386: reformat the key map * i386/i386at/kd.c (key_map): Remove superfluous newlines so that every entry fits into one line. This way line numbers can be used as an index into the map. --- i386/i386at/kd.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/i386/i386at/kd.c b/i386/i386at/kd.c index 9f9faf41..5371fb2e 100644 --- a/i386/i386at/kd.c +++ b/i386/i386at/kd.c @@ -240,8 +240,7 @@ unsigned char key_map[NUMKEYS][WIDTH_KMAP] = { {K_LBRKT,NC,NC, K_LBRACE,NC,NC, K_ESC,NC,NC, 0x1b,K_LBRKT,NC, 0x1b,0x4e,K_LBRACE}, {K_RBRKT,NC,NC, K_RBRACE,NC,NC, K_GS,NC,NC, 0x1b,K_RBRKT,NC, 0x1b,0x4e,K_RBRACE}, {K_CR,NC,NC, K_CR,NC,NC, K_CR,NC,NC, 0x1b,K_CR,NC, K_CR,NC,NC}, -{K_SCAN,K_CTLSC,NC, K_SCAN,K_CTLSC,NC, K_SCAN,K_CTLSC,NC, K_SCAN,K_CTLSC,NC, - K_SCAN,K_CTLSC,NC}, +{K_SCAN,K_CTLSC,NC, K_SCAN,K_CTLSC,NC, K_SCAN,K_CTLSC,NC, K_SCAN,K_CTLSC,NC, K_SCAN,K_CTLSC,NC}, {K_a,NC,NC, K_A,NC,NC, K_SOH,NC,NC, 0x1b,K_a,NC, 0x1b,0x4e,K_A}, {K_s,NC,NC, K_S,NC,NC, K_DC3,NC,NC, 0x1b,K_s,NC, 0x1b,0x4e,K_S}, {K_d,NC,NC, K_D,NC,NC, K_EOT,NC,NC, 0x1b,K_d,NC, 0x1b,0x4e,K_D}, @@ -254,8 +253,7 @@ unsigned char key_map[NUMKEYS][WIDTH_KMAP] = { {K_SEMI,NC,NC, K_COLON,NC,NC, K_SEMI,NC,NC, 0x1b,K_SEMI,NC, 0x1b,0x4e,K_COLON}, {K_SQUOTE,NC,NC,K_DQUOTE,NC,NC, K_SQUOTE,NC,NC,0x1b,K_SQUOTE,NC, 0x1b,0x4e,K_DQUOTE}, {K_GRAV,NC,NC, K_TILDE,NC,NC, K_RS,NC,NC, 0x1b,K_GRAV,NC, 0x1b,0x4e,K_TILDE}, -{K_SCAN,K_LSHSC,NC, K_SCAN,K_LSHSC,NC, K_SCAN,K_LSHSC,NC, K_SCAN,K_LSHSC,NC, - K_SCAN,K_LSHSC,NC}, +{K_SCAN,K_LSHSC,NC, K_SCAN,K_LSHSC,NC, K_SCAN,K_LSHSC,NC, K_SCAN,K_LSHSC,NC, K_SCAN,K_LSHSC,NC}, {K_BSLSH,NC,NC, K_PIPE,NC,NC, K_FS,NC,NC, 0x1b,K_BSLSH,NC, 0x1b,0x4e,K_PIPE}, {K_z,NC,NC, K_Z,NC,NC, K_SUB,NC,NC, 0x1b,K_z,NC, 0x1b,0x4e,K_Z}, {K_x,NC,NC, K_X,NC,NC, K_CAN,NC,NC, 0x1b,K_x,NC, 0x1b,0x4e,K_X}, @@ -267,14 +265,11 @@ unsigned char key_map[NUMKEYS][WIDTH_KMAP] = { {K_COMMA,NC,NC, K_LTHN,NC,NC, K_COMMA,NC,NC, 0x1b,K_COMMA,NC, 0x1b,0x4e,K_LTHN}, {K_PERIOD,NC,NC,K_GTHN,NC,NC, K_PERIOD,NC,NC,0x1b,K_PERIOD,NC, 0x1b,0x4e,K_GTHN}, {K_SLASH,NC,NC, K_QUES,NC,NC, K_SLASH,NC,NC, 0x1b,K_SLASH,NC, 0x1b,0x4e,K_QUES}, -{K_SCAN,K_RSHSC,NC, K_SCAN,K_RSHSC,NC, K_SCAN,K_RSHSC,NC, K_SCAN,K_RSHSC,NC, - K_SCAN,K_RSHSC,NC}, +{K_SCAN,K_RSHSC,NC, K_SCAN,K_RSHSC,NC, K_SCAN,K_RSHSC,NC, K_SCAN,K_RSHSC,NC, K_SCAN,K_RSHSC,NC}, {K_ASTER,NC,NC, K_ASTER,NC,NC, K_ASTER,NC,NC, 0x1b,K_ASTER,NC, 0x1b,0x4e,K_ASTER}, -{K_SCAN,K_ALTSC,NC, K_SCAN,K_ALTSC,NC, K_SCAN,K_ALTSC,NC, K_SCAN,K_ALTSC,NC, - K_SCAN,K_ALTSC,NC}, +{K_SCAN,K_ALTSC,NC, K_SCAN,K_ALTSC,NC, K_SCAN,K_ALTSC,NC, K_SCAN,K_ALTSC,NC, K_SCAN,K_ALTSC,NC}, {K_SPACE,NC,NC, K_SPACE,NC,NC, K_NUL,NC,NC, 0x1b,K_SPACE,NC, K_SPACE,NC,NC}, -{K_SCAN,K_CLCKSC,NC, K_SCAN,K_CLCKSC,NC, K_SCAN,K_CLCKSC,NC, - K_SCAN,K_CLCKSC,NC, K_SCAN,K_CLCKSC,NC}, +{K_SCAN,K_CLCKSC,NC, K_SCAN,K_CLCKSC,NC, K_SCAN,K_CLCKSC,NC, K_SCAN,K_CLCKSC,NC, K_SCAN,K_CLCKSC,NC}, {K_F1, K_F1S, K_F1, K_F1A, K_F1S}, {K_F2, K_F2S, K_F2, K_F2A, K_F2S}, {K_F3, K_F3S, K_F3, K_F3A, K_F3S}, @@ -285,20 +280,16 @@ unsigned char key_map[NUMKEYS][WIDTH_KMAP] = { {K_F8, K_F8S, K_F8, K_F8A, K_F8S}, {K_F9, K_F9S, K_F9, K_F9A, K_F9S}, {K_F10, K_F10S, K_F10, K_F10A, K_F10S}, -{K_SCAN,K_NLCKSC,NC, K_SCAN,K_NLCKSC,NC, K_SCAN,K_NLCKSC,NC, - K_SCAN,K_NLCKSC,NC, K_SCAN,K_NLCKSC,NC}, +{K_SCAN,K_NLCKSC,NC, K_SCAN,K_NLCKSC,NC, K_SCAN,K_NLCKSC,NC, K_SCAN,K_NLCKSC,NC, K_SCAN,K_NLCKSC,NC}, {K_SCRL, K_NUL,NC,NC, K_SCRL, K_SCRL, K_NUL,NC,NC}, {K_HOME, K_SEVEN,NC,NC, K_HOME, K_HOME, 0x1b,0x4e,K_SEVEN}, {K_UA, K_EIGHT,NC,NC, K_UA, K_UA, 0x1b,0x4e,K_EIGHT}, {K_PUP, K_NINE,NC,NC, K_PUP, K_PUP, 0x1b,0x4e,K_NINE}, -{0x1b,0x5b,0x53, K_MINUS,NC,NC, 0x1b,0x5b,0x53, 0x1b,0x5b,0x53, - 0x1b,0x4e,0x2d}, +{0x1b,0x5b,0x53, K_MINUS,NC,NC, 0x1b,0x5b,0x53, 0x1b,0x5b,0x53, 0x1b,0x4e,0x2d}, {K_LA, K_FOUR,NC,NC, K_LA, K_LA, 0x1b,0x4e,K_FOUR}, -{0x1b,0x5b,0x47, K_FIVE,NC,NC, 0x1b,0x5b,0x47, 0x1b,0x5b,0x47, - 0x1b,0x4e,0x35}, +{0x1b,0x5b,0x47, K_FIVE,NC,NC, 0x1b,0x5b,0x47, 0x1b,0x5b,0x47, 0x1b,0x4e,0x35}, {K_RA, K_SIX,NC,NC, K_RA, K_RA, 0x1b,0x4e,K_SIX}, -{0x1b,0x5b,0x54, K_PLUS,NC,NC, 0x1b,0x5b,0x54, 0x1b,0x5b,0x54, - 0x1b,0x4e,0x2b}, +{0x1b,0x5b,0x54, K_PLUS,NC,NC, 0x1b,0x5b,0x54, 0x1b,0x5b,0x54, 0x1b,0x4e,0x2b}, {K_END, K_ONE,NC,NC, K_END, K_END, 0x1b,0x4e,K_ONE}, {K_DA, K_TWO,NC,NC, K_DA, K_DA, 0x1b,0x4e,K_TWO}, {K_PDN, K_THREE,NC,NC, K_PDN, K_PDN, 0x1b,0x4e,K_THREE}, -- cgit v1.2.3 From d18f4890ffb8d407a9c94c251f01712ecef767ca Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Mon, 9 Jun 2014 18:15:47 +0200 Subject: i386: remap some keys As a convenience for the nice people using our debugger, remap some keys to the readline-like shortcuts supported by dde. * i386/i386at/kd.c (kdcnmaygetc): Remap some keys. --- i386/i386at/kd.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/i386/i386at/kd.c b/i386/i386at/kd.c index 5371fb2e..7339767e 100644 --- a/i386/i386at/kd.c +++ b/i386/i386at/kd.c @@ -3029,6 +3029,39 @@ kdcnmaygetc(void) #ifdef notdef cnsetleds(state2leds(kd_state)); #endif + } else if (! up + && c == K_ESC + && key_map[scancode][char_idx+1] == 0x5b) { + /* As a convenience for the nice + people using our debugger, remap + some keys to the readline-like + shortcuts supported by dde. + + XXX This is a workaround for the + limited kernel getchar interface. + It is only used by the debugger. */ + c = key_map[scancode][char_idx+2]; + switch (c) { +#define _MAP(A,B,C) (C) +#define MAP(T) _MAP(T) +#define CTRL(c) ((c) & 0x1f) + case MAP(K_HOME): c = CTRL('a'); break; + case MAP(K_UA): c = CTRL('p'); break; + case MAP(K_LA): c = CTRL('b'); break; + case MAP(K_RA): c = CTRL('f'); break; + case MAP(K_DA): c = CTRL('n'); break; + case MAP(K_END): c = CTRL('e'); break; + /* delete */ + case 0x39: c = CTRL('d'); break; +#undef CTRL +#undef MAP +#undef _MAP + default: + /* Retain the old behavior. */ + c = K_ESC; + } + + return(c); } else if (!up) { /* regular key-down */ if (c == K_CR) -- cgit v1.2.3 From 0ab9ef8ab8c57ab83cb01bef37ca6d30395a43a2 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Mon, 9 Jun 2014 18:33:30 +0200 Subject: doc: explain the floating point flag in kdb output * doc/mach.texi (Kernel Debugger Commands): Explain the floating point flag. --- doc/mach.texi | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/mach.texi b/doc/mach.texi index 49c0d678..2da670f7 100644 --- a/doc/mach.texi +++ b/doc/mach.texi @@ -7029,8 +7029,9 @@ session. If the execution is resumed again, the numbers may change. The current thread can be distinguished from others by a @code{#} after the thread id instead of @code{:}. Without @code{l} option, it only shows thread id, thread structure address and the status for each -thread. The status consists of 5 letters, R(run), W(wait), S(suspended), -O(swapped out) and N(interruptible), and if corresponding +thread. The status consists of 6 letters, R(run), W(wait), S(suspended), +O(swapped out), N(interruptible), and F(loating) point arithmetic used (if +supported by the platform). If the corresponding status bit is off, @code{.} is printed instead. If @code{l} option is specified, more detail information is printed for each thread. -- cgit v1.2.3 From 3bb2b68bc84b9cb11aae7b46eeec3c5eb3363f54 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Fri, 2 May 2014 21:33:01 +0200 Subject: i386: add io_map_cached io_map_cached is like io_map, but reuses the old mapping if it is applicable. * i386/i386/io_map.c: Add io_map_cached. --- i386/i386/io_map.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/i386/i386/io_map.c b/i386/i386/io_map.c index 74e0b471..03d71521 100644 --- a/i386/i386/io_map.c +++ b/i386/i386/io_map.c @@ -58,3 +58,32 @@ io_map( VM_PROT_READ|VM_PROT_WRITE); return (start); } + +/* + * Allocate and map memory for devices that may need to be mapped before + * Mach VM is running. + * + * This maps the all pages containing [PHYS_ADDR:PHYS_ADDR + SIZE]. + * For contiguous requests to those pages will reuse the previously + * established mapping. + */ +vm_offset_t +io_map_cached( + vm_offset_t phys_addr, + vm_size_t size) +{ + static vm_offset_t base; + static vm_size_t length; + static vm_offset_t map; + + if (! map + || (phys_addr < base) + || (base + length < phys_addr + size)) + { + base = trunc_page(phys_addr); + length = round_page(phys_addr - base + size); + map = io_map(base, length); + } + + return map + (phys_addr - base); +} -- cgit v1.2.3 From c031b41b783cc99c0bd5aac7d14c1d6e34520397 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Sat, 3 May 2014 01:33:14 +0200 Subject: i386: use ACPI to power off the machine This is a mostly verbatim copy of acpihalt.c from GRUB2 with a little bit of glue code. * i386/Makefrag.am (libkernel_a_SOURCES): Add the new files. * i386/grub/acpi.h: Verbatim copy from GRUB2. * i386/grub/compiler.h: Likewise. * i386/grub/cpu/io.h: Likewise. * i386/grub/cpu/time.h: Likewise. * i386/grub/cpu/types.h: Likewise. * i386/grub/err.h: Likewise. * i386/grub/misc.h: Likewise. * i386/grub/mm.h: Likewise. * i386/grub/symbol.h: Likewise. * i386/grub/time.h: Likewise. * i386/grub/types.h: Likewise. * i386/i386at/acpi.c: Likewise. * i386/i386at/acpihalt.c: Likewise. (grub_acpi_halt): Map physical addresses. * i386/i386at/acpihalt.h: New file. * i386/grub/glue.h: Some glue macros. * i386/grub/i18n.h: Stub out i18n. * i386/i386at/grub_glue.c: Some glue code. * i386/i386at/model_dep.c (halt_all_cpus): Use grub_acpi_halt. --- i386/Makefrag.am | 19 ++ i386/grub/acpi.h | 220 +++++++++++++++++++++ i386/grub/compiler.h | 51 +++++ i386/grub/cpu/io.h | 72 +++++++ i386/grub/cpu/time.h | 29 +++ i386/grub/cpu/types.h | 33 ++++ i386/grub/err.h | 96 +++++++++ i386/grub/glue.h | 31 +++ i386/grub/i18n.h | 25 +++ i386/grub/misc.h | 517 ++++++++++++++++++++++++++++++++++++++++++++++++ i386/grub/mm.h | 77 ++++++++ i386/grub/symbol.h | 72 +++++++ i386/grub/time.h | 46 +++++ i386/grub/types.h | 325 ++++++++++++++++++++++++++++++ i386/i386at/acpi.c | 82 ++++++++ i386/i386at/acpihalt.c | 409 ++++++++++++++++++++++++++++++++++++++ i386/i386at/acpihalt.h | 23 +++ i386/i386at/grub_glue.c | 67 +++++++ i386/i386at/model_dep.c | 2 + 19 files changed, 2196 insertions(+) create mode 100644 i386/grub/acpi.h create mode 100644 i386/grub/compiler.h create mode 100644 i386/grub/cpu/io.h create mode 100644 i386/grub/cpu/time.h create mode 100644 i386/grub/cpu/types.h create mode 100644 i386/grub/err.h create mode 100644 i386/grub/glue.h create mode 100644 i386/grub/i18n.h create mode 100644 i386/grub/misc.h create mode 100644 i386/grub/mm.h create mode 100644 i386/grub/symbol.h create mode 100644 i386/grub/time.h create mode 100644 i386/grub/types.h create mode 100644 i386/i386at/acpi.c create mode 100644 i386/i386at/acpihalt.c create mode 100644 i386/i386at/acpihalt.h create mode 100644 i386/i386at/grub_glue.c diff --git a/i386/Makefrag.am b/i386/Makefrag.am index cac22678..4dd6a9f6 100644 --- a/i386/Makefrag.am +++ b/i386/Makefrag.am @@ -55,6 +55,25 @@ libkernel_a_SOURCES += \ i386/i386at/pic_isa.c \ i386/i386at/rtc.c \ i386/i386at/rtc.h + +libkernel_a_SOURCES += \ + i386/i386at/acpihalt.c \ + i386/i386at/acpihalt.h \ + i386/i386at/acpi.c \ + i386/i386at/grub_glue.c \ + i386/grub/err.h \ + i386/grub/cpu/io.h \ + i386/grub/cpu/types.h \ + i386/grub/cpu/time.h \ + i386/grub/mm.h \ + i386/grub/acpi.h \ + i386/grub/symbol.h \ + i386/grub/misc.h \ + i386/grub/types.h \ + i386/grub/time.h \ + i386/grub/i18n.h \ + i386/grub/compiler.h \ + i386/grub/glue.h endif # diff --git a/i386/grub/acpi.h b/i386/grub/acpi.h new file mode 100644 index 00000000..2ac2bd6f --- /dev/null +++ b/i386/grub/acpi.h @@ -0,0 +1,220 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2009 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see . + */ + +#ifndef GRUB_ACPI_HEADER +#define GRUB_ACPI_HEADER 1 + +#ifndef GRUB_DSDT_TEST +#include +#include +#endif + +#define GRUB_RSDP_SIGNATURE "RSD PTR " +#define GRUB_RSDP_SIGNATURE_SIZE 8 + +struct grub_acpi_rsdp_v10 +{ + grub_uint8_t signature[GRUB_RSDP_SIGNATURE_SIZE]; + grub_uint8_t checksum; + grub_uint8_t oemid[6]; + grub_uint8_t revision; + grub_uint32_t rsdt_addr; +} GRUB_PACKED; + +struct grub_acpi_rsdp_v20 +{ + struct grub_acpi_rsdp_v10 rsdpv1; + grub_uint32_t length; + grub_uint64_t xsdt_addr; + grub_uint8_t checksum; + grub_uint8_t reserved[3]; +} GRUB_PACKED; + +struct grub_acpi_table_header +{ + grub_uint8_t signature[4]; + grub_uint32_t length; + grub_uint8_t revision; + grub_uint8_t checksum; + grub_uint8_t oemid[6]; + grub_uint8_t oemtable[8]; + grub_uint32_t oemrev; + grub_uint8_t creator_id[4]; + grub_uint32_t creator_rev; +} GRUB_PACKED; + +#define GRUB_ACPI_FADT_SIGNATURE "FACP" + +struct grub_acpi_fadt +{ + struct grub_acpi_table_header hdr; + grub_uint32_t facs_addr; + grub_uint32_t dsdt_addr; + grub_uint8_t somefields1[20]; + grub_uint32_t pm1a; + grub_uint8_t somefields2[64]; + grub_uint64_t facs_xaddr; + grub_uint64_t dsdt_xaddr; + grub_uint8_t somefields3[96]; +} GRUB_PACKED; + +#define GRUB_ACPI_MADT_SIGNATURE "APIC" + +struct grub_acpi_madt_entry_header +{ + grub_uint8_t type; + grub_uint8_t len; +}; + +struct grub_acpi_madt +{ + struct grub_acpi_table_header hdr; + grub_uint32_t lapic_addr; + grub_uint32_t flags; + struct grub_acpi_madt_entry_header entries[0]; +}; + +enum + { + GRUB_ACPI_MADT_ENTRY_TYPE_LAPIC = 0, + GRUB_ACPI_MADT_ENTRY_TYPE_IOAPIC = 1, + GRUB_ACPI_MADT_ENTRY_TYPE_INTERRUPT_OVERRIDE = 2, + GRUB_ACPI_MADT_ENTRY_TYPE_LAPIC_NMI = 4, + GRUB_ACPI_MADT_ENTRY_TYPE_SAPIC = 6, + GRUB_ACPI_MADT_ENTRY_TYPE_LSAPIC = 7, + GRUB_ACPI_MADT_ENTRY_TYPE_PLATFORM_INT_SOURCE = 8 + }; + +struct grub_acpi_madt_entry_lapic +{ + struct grub_acpi_madt_entry_header hdr; + grub_uint8_t acpiid; + grub_uint8_t apicid; + grub_uint32_t flags; +}; + +struct grub_acpi_madt_entry_ioapic +{ + struct grub_acpi_madt_entry_header hdr; + grub_uint8_t id; + grub_uint8_t pad; + grub_uint32_t address; + grub_uint32_t global_sys_interrupt; +}; + +struct grub_acpi_madt_entry_interrupt_override +{ + struct grub_acpi_madt_entry_header hdr; + grub_uint8_t bus; + grub_uint8_t source; + grub_uint32_t global_sys_interrupt; + grub_uint16_t flags; +} GRUB_PACKED; + + +struct grub_acpi_madt_entry_lapic_nmi +{ + struct grub_acpi_madt_entry_header hdr; + grub_uint8_t acpiid; + grub_uint16_t flags; + grub_uint8_t lint; +} GRUB_PACKED; + +struct grub_acpi_madt_entry_sapic +{ + struct grub_acpi_madt_entry_header hdr; + grub_uint8_t id; + grub_uint8_t pad; + grub_uint32_t global_sys_interrupt_base; + grub_uint64_t addr; +}; + +struct grub_acpi_madt_entry_lsapic +{ + struct grub_acpi_madt_entry_header hdr; + grub_uint8_t cpu_id; + grub_uint8_t id; + grub_uint8_t eid; + grub_uint8_t pad[3]; + grub_uint32_t flags; + grub_uint32_t cpu_uid; + grub_uint8_t cpu_uid_str[0]; +}; + +struct grub_acpi_madt_entry_platform_int_source +{ + struct grub_acpi_madt_entry_header hdr; + grub_uint16_t flags; + grub_uint8_t inttype; + grub_uint8_t cpu_id; + grub_uint8_t cpu_eid; + grub_uint8_t sapic_vector; + grub_uint32_t global_sys_int; + grub_uint32_t src_flags; +}; + +enum + { + GRUB_ACPI_MADT_ENTRY_SAPIC_FLAGS_ENABLED = 1 + }; + +#ifndef GRUB_DSDT_TEST +struct grub_acpi_rsdp_v10 *grub_acpi_get_rsdpv1 (void); +struct grub_acpi_rsdp_v20 *grub_acpi_get_rsdpv2 (void); +struct grub_acpi_rsdp_v10 *grub_machine_acpi_get_rsdpv1 (void); +struct grub_acpi_rsdp_v20 *grub_machine_acpi_get_rsdpv2 (void); +grub_uint8_t grub_byte_checksum (void *base, grub_size_t size); + +grub_err_t grub_acpi_create_ebda (void); + +void grub_acpi_halt (void); +#endif + +#define GRUB_ACPI_SLP_EN (1 << 13) +#define GRUB_ACPI_SLP_TYP_OFFSET 10 + +enum + { + GRUB_ACPI_OPCODE_ZERO = 0, GRUB_ACPI_OPCODE_ONE = 1, + GRUB_ACPI_OPCODE_NAME = 8, GRUB_ACPI_OPCODE_BYTE_CONST = 0x0a, + GRUB_ACPI_OPCODE_WORD_CONST = 0x0b, + GRUB_ACPI_OPCODE_DWORD_CONST = 0x0c, + GRUB_ACPI_OPCODE_STRING_CONST = 0x0d, + GRUB_ACPI_OPCODE_SCOPE = 0x10, + GRUB_ACPI_OPCODE_BUFFER = 0x11, + GRUB_ACPI_OPCODE_PACKAGE = 0x12, + GRUB_ACPI_OPCODE_METHOD = 0x14, GRUB_ACPI_OPCODE_EXTOP = 0x5b, + GRUB_ACPI_OPCODE_CREATE_WORD_FIELD = 0x8b, + GRUB_ACPI_OPCODE_CREATE_BYTE_FIELD = 0x8c, + GRUB_ACPI_OPCODE_IF = 0xa0, GRUB_ACPI_OPCODE_ONES = 0xff + }; +enum + { + GRUB_ACPI_EXTOPCODE_MUTEX = 0x01, + GRUB_ACPI_EXTOPCODE_EVENT_OP = 0x02, + GRUB_ACPI_EXTOPCODE_OPERATION_REGION = 0x80, + GRUB_ACPI_EXTOPCODE_FIELD_OP = 0x81, + GRUB_ACPI_EXTOPCODE_DEVICE_OP = 0x82, + GRUB_ACPI_EXTOPCODE_PROCESSOR_OP = 0x83, + GRUB_ACPI_EXTOPCODE_POWER_RES_OP = 0x84, + GRUB_ACPI_EXTOPCODE_THERMAL_ZONE_OP = 0x85, + GRUB_ACPI_EXTOPCODE_INDEX_FIELD_OP = 0x86, + GRUB_ACPI_EXTOPCODE_BANK_FIELD_OP = 0x87, + }; + +#endif /* ! GRUB_ACPI_HEADER */ diff --git a/i386/grub/compiler.h b/i386/grub/compiler.h new file mode 100644 index 00000000..c9e1d7a7 --- /dev/null +++ b/i386/grub/compiler.h @@ -0,0 +1,51 @@ +/* compiler.h - macros for various compiler features */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2002,2003,2005,2006,2007,2008,2009,2010,2014 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see . + */ + +#ifndef GRUB_COMPILER_HEADER +#define GRUB_COMPILER_HEADER 1 + +/* GCC version checking borrowed from glibc. */ +#if defined(__GNUC__) && defined(__GNUC_MINOR__) +# define GNUC_PREREQ(maj,min) \ + ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) +#else +# define GNUC_PREREQ(maj,min) 0 +#endif + +/* Does this compiler support compile-time error attributes? */ +#if GNUC_PREREQ(4,3) +# define ATTRIBUTE_ERROR(msg) \ + __attribute__ ((__error__ (msg))) +#else +# define ATTRIBUTE_ERROR(msg) __attribute__ ((noreturn)) +#endif + +#if GNUC_PREREQ(4,4) +# define GNU_PRINTF gnu_printf +#else +# define GNU_PRINTF printf +#endif + +#if GNUC_PREREQ(3,4) +# define WARN_UNUSED_RESULT __attribute__ ((warn_unused_result)) +#else +# define WARN_UNUSED_RESULT +#endif + +#endif /* ! GRUB_COMPILER_HEADER */ diff --git a/i386/grub/cpu/io.h b/i386/grub/cpu/io.h new file mode 100644 index 00000000..ae12a3e3 --- /dev/null +++ b/i386/grub/cpu/io.h @@ -0,0 +1,72 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 1996,2000,2002,2007 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see . + */ + +/* Based on sys/io.h from GNU libc. */ + +#ifndef GRUB_IO_H +#define GRUB_IO_H 1 + +typedef unsigned short int grub_port_t; + +static __inline unsigned char +grub_inb (unsigned short int port) +{ + unsigned char _v; + + __asm__ __volatile__ ("inb %w1,%0":"=a" (_v):"Nd" (port)); + return _v; +} + +static __inline unsigned short int +grub_inw (unsigned short int port) +{ + unsigned short _v; + + __asm__ __volatile__ ("inw %w1,%0":"=a" (_v):"Nd" (port)); + return _v; +} + +static __inline unsigned int +grub_inl (unsigned short int port) +{ + unsigned int _v; + + __asm__ __volatile__ ("inl %w1,%0":"=a" (_v):"Nd" (port)); + return _v; +} + +static __inline void +grub_outb (unsigned char value, unsigned short int port) +{ + __asm__ __volatile__ ("outb %b0,%w1": :"a" (value), "Nd" (port)); +} + +static __inline void +grub_outw (unsigned short int value, unsigned short int port) +{ + __asm__ __volatile__ ("outw %w0,%w1": :"a" (value), "Nd" (port)); + +} + +static __inline void +grub_outl (unsigned int value, unsigned short int port) +{ + __asm__ __volatile__ ("outl %0,%w1": :"a" (value), "Nd" (port)); +} + +#endif /* _SYS_IO_H */ diff --git a/i386/grub/cpu/time.h b/i386/grub/cpu/time.h new file mode 100644 index 00000000..842882cf --- /dev/null +++ b/i386/grub/cpu/time.h @@ -0,0 +1,29 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2007 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see . + */ + +#ifndef KERNEL_CPU_TIME_HEADER +#define KERNEL_CPU_TIME_HEADER 1 + +static __inline void +grub_cpu_idle (void) +{ + /* FIXME: this can't work until we handle interrupts. */ +/* __asm__ __volatile__ ("hlt"); */ +} + +#endif /* ! KERNEL_CPU_TIME_HEADER */ diff --git a/i386/grub/cpu/types.h b/i386/grub/cpu/types.h new file mode 100644 index 00000000..c20063f3 --- /dev/null +++ b/i386/grub/cpu/types.h @@ -0,0 +1,33 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2002,2006,2007 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see . + */ + +#ifndef GRUB_TYPES_CPU_HEADER +#define GRUB_TYPES_CPU_HEADER 1 + +/* The size of void *. */ +#define GRUB_TARGET_SIZEOF_VOID_P 4 + +/* The size of long. */ +#define GRUB_TARGET_SIZEOF_LONG 4 + +/* i386 is little-endian. */ +#undef GRUB_TARGET_WORDS_BIGENDIAN + +#define GRUB_HAVE_UNALIGNED_ACCESS 1 + +#endif /* ! GRUB_TYPES_CPU_HEADER */ diff --git a/i386/grub/err.h b/i386/grub/err.h new file mode 100644 index 00000000..1590c688 --- /dev/null +++ b/i386/grub/err.h @@ -0,0 +1,96 @@ +/* err.h - error numbers and prototypes */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2002,2005,2007,2008 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see . + */ + +#ifndef GRUB_ERR_HEADER +#define GRUB_ERR_HEADER 1 + +#include + +#define GRUB_MAX_ERRMSG 256 + +typedef enum + { + GRUB_ERR_NONE = 0, + GRUB_ERR_TEST_FAILURE, + GRUB_ERR_BAD_MODULE, + GRUB_ERR_OUT_OF_MEMORY, + GRUB_ERR_BAD_FILE_TYPE, + GRUB_ERR_FILE_NOT_FOUND, + GRUB_ERR_FILE_READ_ERROR, + GRUB_ERR_BAD_FILENAME, + GRUB_ERR_UNKNOWN_FS, + GRUB_ERR_BAD_FS, + GRUB_ERR_BAD_NUMBER, + GRUB_ERR_OUT_OF_RANGE, + GRUB_ERR_UNKNOWN_DEVICE, + GRUB_ERR_BAD_DEVICE, + GRUB_ERR_READ_ERROR, + GRUB_ERR_WRITE_ERROR, + GRUB_ERR_UNKNOWN_COMMAND, + GRUB_ERR_INVALID_COMMAND, + GRUB_ERR_BAD_ARGUMENT, + GRUB_ERR_BAD_PART_TABLE, + GRUB_ERR_UNKNOWN_OS, + GRUB_ERR_BAD_OS, + GRUB_ERR_NO_KERNEL, + GRUB_ERR_BAD_FONT, + GRUB_ERR_NOT_IMPLEMENTED_YET, + GRUB_ERR_SYMLINK_LOOP, + GRUB_ERR_BAD_COMPRESSED_DATA, + GRUB_ERR_MENU, + GRUB_ERR_TIMEOUT, + GRUB_ERR_IO, + GRUB_ERR_ACCESS_DENIED, + GRUB_ERR_EXTRACTOR, + GRUB_ERR_NET_BAD_ADDRESS, + GRUB_ERR_NET_ROUTE_LOOP, + GRUB_ERR_NET_NO_ROUTE, + GRUB_ERR_NET_NO_ANSWER, + GRUB_ERR_NET_NO_CARD, + GRUB_ERR_WAIT, + GRUB_ERR_BUG, + GRUB_ERR_NET_PORT_CLOSED, + GRUB_ERR_NET_INVALID_RESPONSE, + GRUB_ERR_NET_UNKNOWN_ERROR, + GRUB_ERR_NET_PACKET_TOO_BIG, + GRUB_ERR_NET_NO_DOMAIN, + GRUB_ERR_EOF, + GRUB_ERR_BAD_SIGNATURE + } +grub_err_t; + +struct grub_error_saved +{ + grub_err_t grub_errno; + char errmsg[GRUB_MAX_ERRMSG]; +}; + +extern grub_err_t EXPORT_VAR(grub_errno); +extern char EXPORT_VAR(grub_errmsg)[GRUB_MAX_ERRMSG]; + +grub_err_t EXPORT_FUNC(grub_error) (grub_err_t n, const char *fmt, ...); +void EXPORT_FUNC(grub_fatal) (const char *fmt, ...) __attribute__ ((noreturn)); +void EXPORT_FUNC(grub_error_push) (void); +int EXPORT_FUNC(grub_error_pop) (void); +void EXPORT_FUNC(grub_print_error) (void); +extern int EXPORT_VAR(grub_err_printed_errors); +int grub_err_printf (const char *fmt, ...) + __attribute__ ((format (__printf__, 1, 2))); + +#endif /* ! GRUB_ERR_HEADER */ diff --git a/i386/grub/glue.h b/i386/grub/glue.h new file mode 100644 index 00000000..e1c62eba --- /dev/null +++ b/i386/grub/glue.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2014 Free Software Foundation. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef _GRUB_GLUE_H +#define _GRUB_GLUE_H + +#define GRUB_FILE __FILE__ +#define grub_memcmp memcmp +#define grub_printf printf +#define grub_puts_ puts + +#include +#include + +vm_offset_t io_map_cached(vm_offset_t phys_addr, vm_size_t size); + +#endif /* _GRUB_GLUE_H */ diff --git a/i386/grub/i18n.h b/i386/grub/i18n.h new file mode 100644 index 00000000..8b533571 --- /dev/null +++ b/i386/grub/i18n.h @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2014 Free Software Foundation. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef _GRUB_I18N_H +#define _GRUB_I18N_H + +/* No i18n please. */ +#define _(x) x +#define N_(x) x + +#endif /* _GRUB_I18N_H */ diff --git a/i386/grub/misc.h b/i386/grub/misc.h new file mode 100644 index 00000000..c6cd4564 --- /dev/null +++ b/i386/grub/misc.h @@ -0,0 +1,517 @@ +/* misc.h - prototypes for misc functions */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2002,2003,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see . + */ + +#ifndef GRUB_MISC_HEADER +#define GRUB_MISC_HEADER 1 + +#include +#include +#include +#include +#include +#include + +#define ALIGN_UP(addr, align) \ + ((addr + (typeof (addr)) align - 1) & ~((typeof (addr)) align - 1)) +#define ALIGN_UP_OVERHEAD(addr, align) ((-(addr)) & ((typeof (addr)) (align) - 1)) +#define ALIGN_DOWN(addr, align) \ + ((addr) & ~((typeof (addr)) align - 1)) +#define ARRAY_SIZE(array) (sizeof (array) / sizeof (array[0])) +#define COMPILE_TIME_ASSERT(cond) switch (0) { case 1: case !(cond): ; } + +#define grub_dprintf(condition, ...) grub_real_dprintf(GRUB_FILE, __LINE__, condition, __VA_ARGS__) + +void *EXPORT_FUNC(grub_memmove) (void *dest, const void *src, grub_size_t n); +char *EXPORT_FUNC(grub_strcpy) (char *dest, const char *src); + +static inline char * +grub_strncpy (char *dest, const char *src, int c) +{ + char *p = dest; + + while ((*p++ = *src++) != '\0' && --c) + ; + + return dest; +} + +static inline char * +grub_stpcpy (char *dest, const char *src) +{ + char *d = dest; + const char *s = src; + + do + *d++ = *s; + while (*s++ != '\0'); + + return d - 1; +} + +/* XXX: If grub_memmove is too slow, we must implement grub_memcpy. */ +static inline void * +grub_memcpy (void *dest, const void *src, grub_size_t n) +{ + return grub_memmove (dest, src, n); +} + +#if defined (__APPLE__) && defined(__i386__) && !defined (GRUB_UTIL) +#define GRUB_BUILTIN_ATTR __attribute__ ((regparm(0))) +#else +#define GRUB_BUILTIN_ATTR +#endif + +#if defined(__x86_64__) && !defined (GRUB_UTIL) +#if defined (__MINGW32__) || defined (__CYGWIN__) || defined (__MINGW64__) +#define GRUB_ASM_ATTR __attribute__ ((sysv_abi)) +#else +#define GRUB_ASM_ATTR +#endif +#endif + +/* Prototypes for aliases. */ +#ifndef GRUB_UTIL +int GRUB_BUILTIN_ATTR EXPORT_FUNC(memcmp) (const void *s1, const void *s2, grub_size_t n); +void *GRUB_BUILTIN_ATTR EXPORT_FUNC(memmove) (void *dest, const void *src, grub_size_t n); +void *GRUB_BUILTIN_ATTR EXPORT_FUNC(memcpy) (void *dest, const void *src, grub_size_t n); +void *GRUB_BUILTIN_ATTR EXPORT_FUNC(memset) (void *s, int c, grub_size_t n); + +#ifdef __APPLE__ +void GRUB_BUILTIN_ATTR EXPORT_FUNC (__bzero) (void *s, grub_size_t n); +#endif + +#endif + +int EXPORT_FUNC(grub_memcmp) (const void *s1, const void *s2, grub_size_t n); +int EXPORT_FUNC(grub_strcmp) (const char *s1, const char *s2); +int EXPORT_FUNC(grub_strncmp) (const char *s1, const char *s2, grub_size_t n); + +char *EXPORT_FUNC(grub_strchr) (const char *s, int c); +char *EXPORT_FUNC(grub_strrchr) (const char *s, int c); +int EXPORT_FUNC(grub_strword) (const char *s, const char *w); + +/* Copied from gnulib. + Written by Bruno Haible , 2005. */ +static inline char * +grub_strstr (const char *haystack, const char *needle) +{ + /* Be careful not to look at the entire extent of haystack or needle + until needed. This is useful because of these two cases: + - haystack may be very long, and a match of needle found early, + - needle may be very long, and not even a short initial segment of + needle may be found in haystack. */ + if (*needle != '\0') + { + /* Speed up the following searches of needle by caching its first + character. */ + char b = *needle++; + + for (;; haystack++) + { + if (*haystack == '\0') + /* No match. */ + return 0; + if (*haystack == b) + /* The first character matches. */ + { + const char *rhaystack = haystack + 1; + const char *rneedle = needle; + + for (;; rhaystack++, rneedle++) + { + if (*rneedle == '\0') + /* Found a match. */ + return (char *) haystack; + if (*rhaystack == '\0') + /* No match. */ + return 0; + if (*rhaystack != *rneedle) + /* Nothing in this round. */ + break; + } + } + } + } + else + return (char *) haystack; +} + +int EXPORT_FUNC(grub_isspace) (int c); + +static inline int +grub_isprint (int c) +{ + return (c >= ' ' && c <= '~'); +} + +static inline int +grub_iscntrl (int c) +{ + return (c >= 0x00 && c <= 0x1F) || c == 0x7F; +} + +static inline int +grub_isalpha (int c) +{ + return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); +} + +static inline int +grub_islower (int c) +{ + return (c >= 'a' && c <= 'z'); +} + +static inline int +grub_isupper (int c) +{ + return (c >= 'A' && c <= 'Z'); +} + +static inline int +grub_isgraph (int c) +{ + return (c >= '!' && c <= '~'); +} + +static inline int +grub_isdigit (int c) +{ + return (c >= '0' && c <= '9'); +} + +static inline int +grub_isxdigit (int c) +{ + return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'); +} + +static inline int +grub_isalnum (int c) +{ + return grub_isalpha (c) || grub_isdigit (c); +} + +static inline int +grub_tolower (int c) +{ + if (c >= 'A' && c <= 'Z') + return c - 'A' + 'a'; + + return c; +} + +static inline int +grub_toupper (int c) +{ + if (c >= 'a' && c <= 'z') + return c - 'a' + 'A'; + + return c; +} + +static inline int +grub_strcasecmp (const char *s1, const char *s2) +{ + while (*s1 && *s2) + { + if (grub_tolower ((grub_uint8_t) *s1) + != grub_tolower ((grub_uint8_t) *s2)) + break; + + s1++; + s2++; + } + + return (int) grub_tolower ((grub_uint8_t) *s1) + - (int) grub_tolower ((grub_uint8_t) *s2); +} + +static inline int +grub_strncasecmp (const char *s1, const char *s2, grub_size_t n) +{ + if (n == 0) + return 0; + + while (*s1 && *s2 && --n) + { + if (grub_tolower (*s1) != grub_tolower (*s2)) + break; + + s1++; + s2++; + } + + return (int) grub_tolower ((grub_uint8_t) *s1) + - (int) grub_tolower ((grub_uint8_t) *s2); +} + +unsigned long EXPORT_FUNC(grub_strtoul) (const char *str, char **end, int base); +unsigned long long EXPORT_FUNC(grub_strtoull) (const char *str, char **end, int base); + +static inline long +grub_strtol (const char *str, char **end, int base) +{ + int negative = 0; + unsigned long long magnitude; + + while (*str && grub_isspace (*str)) + str++; + + if (*str == '-') + { + negative = 1; + str++; + } + + magnitude = grub_strtoull (str, end, base); + if (negative) + { + if (magnitude > (unsigned long) GRUB_LONG_MAX + 1) + { + grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow is detected")); + return GRUB_LONG_MIN; + } + return -((long) magnitude); + } + else + { + if (magnitude > GRUB_LONG_MAX) + { + grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow is detected")); + return GRUB_LONG_MAX; + } + return (long) magnitude; + } +} + +char *EXPORT_FUNC(grub_strdup) (const char *s) WARN_UNUSED_RESULT; +char *EXPORT_FUNC(grub_strndup) (const char *s, grub_size_t n) WARN_UNUSED_RESULT; +void *EXPORT_FUNC(grub_memset) (void *s, int c, grub_size_t n); +grub_size_t EXPORT_FUNC(grub_strlen) (const char *s) WARN_UNUSED_RESULT; +int EXPORT_FUNC(grub_printf) (const char *fmt, ...) __attribute__ ((format (GNU_PRINTF, 1, 2))); +int EXPORT_FUNC(grub_printf_) (const char *fmt, ...) __attribute__ ((format (GNU_PRINTF, 1, 2))); + +/* Replace all `ch' characters of `input' with `with' and copy the + result into `output'; return EOS address of `output'. */ +static inline char * +grub_strchrsub (char *output, const char *input, char ch, const char *with) +{ + while (*input) + { + if (*input == ch) + { + grub_strcpy (output, with); + output += grub_strlen (with); + input++; + continue; + } + *output++ = *input++; + } + *output = '\0'; + return output; +} + +extern void (*EXPORT_VAR (grub_xputs)) (const char *str); + +static inline int +grub_puts (const char *s) +{ + const char nl[2] = "\n"; + grub_xputs (s); + grub_xputs (nl); + + return 1; /* Cannot fail. */ +} + +int EXPORT_FUNC(grub_puts_) (const char *s); +void EXPORT_FUNC(grub_real_dprintf) (const char *file, + const int line, + const char *condition, + const char *fmt, ...) __attribute__ ((format (GNU_PRINTF, 4, 5))); +int EXPORT_FUNC(grub_vprintf) (const char *fmt, va_list args); +int EXPORT_FUNC(grub_snprintf) (char *str, grub_size_t n, const char *fmt, ...) + __attribute__ ((format (GNU_PRINTF, 3, 4))); +int EXPORT_FUNC(grub_vsnprintf) (char *str, grub_size_t n, const char *fmt, + va_list args); +char *EXPORT_FUNC(grub_xasprintf) (const char *fmt, ...) + __attribute__ ((format (GNU_PRINTF, 1, 2))) WARN_UNUSED_RESULT; +char *EXPORT_FUNC(grub_xvasprintf) (const char *fmt, va_list args) WARN_UNUSED_RESULT; +void EXPORT_FUNC(grub_exit) (void) __attribute__ ((noreturn)); +grub_uint64_t EXPORT_FUNC(grub_divmod64) (grub_uint64_t n, + grub_uint64_t d, + grub_uint64_t *r); + +#if (defined (__MINGW32__) || defined (__CYGWIN__)) && !defined(GRUB_UTIL) +void EXPORT_FUNC (__register_frame_info) (void); +void EXPORT_FUNC (__deregister_frame_info) (void); +void EXPORT_FUNC (___chkstk_ms) (void); +void EXPORT_FUNC (__chkstk_ms) (void); +#endif + +/* Inline functions. */ + +static inline char * +grub_memchr (const void *p, int c, grub_size_t len) +{ + const char *s = (const char *) p; + const char *e = s + len; + + for (; s < e; s++) + if (*s == c) + return (char *) s; + + return 0; +} + + +static inline unsigned int +grub_abs (int x) +{ + if (x < 0) + return (unsigned int) (-x); + else + return (unsigned int) x; +} + +/* Rounded-up division */ +static inline unsigned int +grub_div_roundup (unsigned int x, unsigned int y) +{ + return (x + y - 1) / y; +} + +/* Reboot the machine. */ +#if defined (GRUB_MACHINE_EMU) || defined (GRUB_MACHINE_QEMU_MIPS) +void EXPORT_FUNC(grub_reboot) (void) __attribute__ ((noreturn)); +#else +void grub_reboot (void) __attribute__ ((noreturn)); +#endif + +#if defined (__clang__) && !defined (GRUB_UTIL) +void __attribute__ ((noreturn)) EXPORT_FUNC (abort) (void); +#endif + +#ifdef GRUB_MACHINE_PCBIOS +/* Halt the system, using APM if possible. If NO_APM is true, don't + * use APM even if it is available. */ +void grub_halt (int no_apm) __attribute__ ((noreturn)); +#elif defined (__mips__) && !defined (GRUB_MACHINE_EMU) +void EXPORT_FUNC (grub_halt) (void) __attribute__ ((noreturn)); +#else +void grub_halt (void) __attribute__ ((noreturn)); +#endif + +#ifdef GRUB_MACHINE_EMU +/* Flag to check if module loading is available. */ +extern const int EXPORT_VAR(grub_no_modules); +#else +#define grub_no_modules 0 +#endif + +static inline void +grub_error_save (struct grub_error_saved *save) +{ + grub_memcpy (save->errmsg, grub_errmsg, sizeof (save->errmsg)); + save->grub_errno = grub_errno; + grub_errno = GRUB_ERR_NONE; +} + +static inline void +grub_error_load (const struct grub_error_saved *save) +{ + grub_memcpy (grub_errmsg, save->errmsg, sizeof (grub_errmsg)); + grub_errno = save->grub_errno; +} + +#ifndef GRUB_UTIL + +#if defined (__arm__) + +grub_uint32_t +EXPORT_FUNC (__udivsi3) (grub_uint32_t a, grub_uint32_t b); + +grub_uint32_t +EXPORT_FUNC (__umodsi3) (grub_uint32_t a, grub_uint32_t b); + +#endif + +#if defined (__sparc__) || defined (__powerpc__) +unsigned +EXPORT_FUNC (__ctzdi2) (grub_uint64_t x); +#define NEED_CTZDI2 1 +#endif + +#if defined (__mips__) || defined (__arm__) +unsigned +EXPORT_FUNC (__ctzsi2) (grub_uint32_t x); +#define NEED_CTZSI2 1 +#endif + +#ifdef __arm__ +grub_uint32_t +EXPORT_FUNC (__aeabi_uidiv) (grub_uint32_t a, grub_uint32_t b); +grub_uint32_t +EXPORT_FUNC (__aeabi_uidivmod) (grub_uint32_t a, grub_uint32_t b); + +/* Needed for allowing modules to be compiled as thumb. */ +grub_uint64_t +EXPORT_FUNC (__muldi3) (grub_uint64_t a, grub_uint64_t b); +grub_uint64_t +EXPORT_FUNC (__aeabi_lmul) (grub_uint64_t a, grub_uint64_t b); + +#endif + +#if defined (__ia64__) + +grub_uint64_t +EXPORT_FUNC (__udivdi3) (grub_uint64_t a, grub_uint64_t b); + +grub_uint64_t +EXPORT_FUNC (__umoddi3) (grub_uint64_t a, grub_uint64_t b); + +#endif + +#endif /* GRUB_UTIL */ + + +#if BOOT_TIME_STATS +struct grub_boot_time +{ + struct grub_boot_time *next; + grub_uint64_t tp; + const char *file; + int line; + char *msg; +}; + +extern struct grub_boot_time *EXPORT_VAR(grub_boot_time_head); + +void EXPORT_FUNC(grub_real_boot_time) (const char *file, + const int line, + const char *fmt, ...) __attribute__ ((format (GNU_PRINTF, 3, 4))); +#define grub_boot_time(...) grub_real_boot_time(GRUB_FILE, __LINE__, __VA_ARGS__) +#else +#define grub_boot_time(...) +#endif + +#define grub_max(a, b) (((a) > (b)) ? (a) : (b)) +#define grub_min(a, b) (((a) < (b)) ? (a) : (b)) + +#endif /* ! GRUB_MISC_HEADER */ diff --git a/i386/grub/mm.h b/i386/grub/mm.h new file mode 100644 index 00000000..28e2e53e --- /dev/null +++ b/i386/grub/mm.h @@ -0,0 +1,77 @@ +/* mm.h - prototypes and declarations for memory manager */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2002,2007 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see . + */ + +#ifndef GRUB_MM_H +#define GRUB_MM_H 1 + +#include +#include +#include + +#ifndef NULL +# define NULL ((void *) 0) +#endif + +void grub_mm_init_region (void *addr, grub_size_t size); +void *EXPORT_FUNC(grub_malloc) (grub_size_t size); +void *EXPORT_FUNC(grub_zalloc) (grub_size_t size); +void EXPORT_FUNC(grub_free) (void *ptr); +void *EXPORT_FUNC(grub_realloc) (void *ptr, grub_size_t size); +#ifndef GRUB_MACHINE_EMU +void *EXPORT_FUNC(grub_memalign) (grub_size_t align, grub_size_t size); +#endif + +void grub_mm_check_real (const char *file, int line); +#define grub_mm_check() grub_mm_check_real (GRUB_FILE, __LINE__); + +/* For debugging. */ +#if defined(MM_DEBUG) && !defined(GRUB_UTIL) && !defined (GRUB_MACHINE_EMU) +/* Set this variable to 1 when you want to trace all memory function calls. */ +extern int EXPORT_VAR(grub_mm_debug); + +void grub_mm_dump_free (void); +void grub_mm_dump (unsigned lineno); + +#define grub_malloc(size) \ + grub_debug_malloc (GRUB_FILE, __LINE__, size) + +#define grub_zalloc(size) \ + grub_debug_zalloc (GRUB_FILE, __LINE__, size) + +#define grub_realloc(ptr,size) \ + grub_debug_realloc (GRUB_FILE, __LINE__, ptr, size) + +#define grub_memalign(align,size) \ + grub_debug_memalign (GRUB_FILE, __LINE__, align, size) + +#define grub_free(ptr) \ + grub_debug_free (GRUB_FILE, __LINE__, ptr) + +void *EXPORT_FUNC(grub_debug_malloc) (const char *file, int line, + grub_size_t size); +void *EXPORT_FUNC(grub_debug_zalloc) (const char *file, int line, + grub_size_t size); +void EXPORT_FUNC(grub_debug_free) (const char *file, int line, void *ptr); +void *EXPORT_FUNC(grub_debug_realloc) (const char *file, int line, void *ptr, + grub_size_t size); +void *EXPORT_FUNC(grub_debug_memalign) (const char *file, int line, + grub_size_t align, grub_size_t size); +#endif /* MM_DEBUG && ! GRUB_UTIL */ + +#endif /* ! GRUB_MM_H */ diff --git a/i386/grub/symbol.h b/i386/grub/symbol.h new file mode 100644 index 00000000..ed19f70d --- /dev/null +++ b/i386/grub/symbol.h @@ -0,0 +1,72 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 1999,2000,2001,2002,2006,2007,2008,2009 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see . + */ + +#ifndef GRUB_SYMBOL_HEADER +#define GRUB_SYMBOL_HEADER 1 + +#include + +/* Apple assembler requires local labels to start with a capital L */ +#define LOCAL(sym) L_ ## sym + +/* Add an underscore to a C symbol in assembler code if needed. */ +#ifndef GRUB_UTIL + +#ifdef __APPLE__ +#define MACRO_DOLLAR(x) $$ ## x +#else +#define MACRO_DOLLAR(x) $ ## x +#endif + +#if HAVE_ASM_USCORE +#ifdef ASM_FILE +# define EXT_C(sym) _ ## sym +#else +# define EXT_C(sym) "_" sym +#endif +#else +# define EXT_C(sym) sym +#endif + +#ifdef __arm__ +#define END .end +#endif + +#if defined (__APPLE__) +#define FUNCTION(x) .globl EXT_C(x) ; EXT_C(x): +#define VARIABLE(x) .globl EXT_C(x) ; EXT_C(x): +#elif defined (__CYGWIN__) || defined (__MINGW32__) +/* .type not supported for non-ELF targets. XXX: Check this in configure? */ +#define FUNCTION(x) .globl EXT_C(x) ; .def EXT_C(x); .scl 2; .type 32; .endef; EXT_C(x): +#define VARIABLE(x) .globl EXT_C(x) ; .def EXT_C(x); .scl 2; .type 0; .endef; EXT_C(x): +#elif defined (__arm__) +#define FUNCTION(x) .globl EXT_C(x) ; .type EXT_C(x), %function ; EXT_C(x): +#define VARIABLE(x) .globl EXT_C(x) ; .type EXT_C(x), %object ; EXT_C(x): +#else +#define FUNCTION(x) .globl EXT_C(x) ; .type EXT_C(x), @function ; EXT_C(x): +#define VARIABLE(x) .globl EXT_C(x) ; .type EXT_C(x), @object ; EXT_C(x): +#endif +#endif + +/* Mark an exported symbol. */ +#ifndef GRUB_SYMBOL_GENERATOR +# define EXPORT_FUNC(x) x +# define EXPORT_VAR(x) x +#endif /* ! GRUB_SYMBOL_GENERATOR */ + +#endif /* ! GRUB_SYMBOL_HEADER */ diff --git a/i386/grub/time.h b/i386/grub/time.h new file mode 100644 index 00000000..64ac99a1 --- /dev/null +++ b/i386/grub/time.h @@ -0,0 +1,46 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2007, 2008 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see . + */ + +#ifndef KERNEL_TIME_HEADER +#define KERNEL_TIME_HEADER 1 + +#include +#include +#ifndef GRUB_MACHINE_EMU +#include +#else +static inline void +grub_cpu_idle(void) +{ +} +#endif + +void EXPORT_FUNC(grub_millisleep) (grub_uint32_t ms); +grub_uint64_t EXPORT_FUNC(grub_get_time_ms) (void); + +grub_uint64_t grub_rtc_get_time_ms (void); + +static __inline void +grub_sleep (grub_uint32_t s) +{ + grub_millisleep (1000 * s); +} + +void grub_install_get_time_ms (grub_uint64_t (*get_time_ms_func) (void)); + +#endif /* ! KERNEL_TIME_HEADER */ diff --git a/i386/grub/types.h b/i386/grub/types.h new file mode 100644 index 00000000..79f765c6 --- /dev/null +++ b/i386/grub/types.h @@ -0,0 +1,325 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2002,2005,2006,2007,2008,2009 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see . + */ + +#ifndef GRUB_TYPES_HEADER +#define GRUB_TYPES_HEADER 1 + +#include +#ifndef GRUB_UTIL +#include +#endif + +#ifdef __MINGW32__ +#define GRUB_PACKED __attribute__ ((packed,gcc_struct)) +#else +#define GRUB_PACKED __attribute__ ((packed)) +#endif + +#ifdef GRUB_BUILD +# define GRUB_CPU_SIZEOF_VOID_P BUILD_SIZEOF_VOID_P +# define GRUB_CPU_SIZEOF_LONG BUILD_SIZEOF_LONG +# if BUILD_WORDS_BIGENDIAN +# define GRUB_CPU_WORDS_BIGENDIAN 1 +# else +# undef GRUB_CPU_WORDS_BIGENDIAN +# endif +#elif defined (GRUB_UTIL) +# define GRUB_CPU_SIZEOF_VOID_P SIZEOF_VOID_P +# define GRUB_CPU_SIZEOF_LONG SIZEOF_LONG +# ifdef WORDS_BIGENDIAN +# define GRUB_CPU_WORDS_BIGENDIAN 1 +# else +# undef GRUB_CPU_WORDS_BIGENDIAN +# endif +#else /* ! GRUB_UTIL */ +# define GRUB_CPU_SIZEOF_VOID_P GRUB_TARGET_SIZEOF_VOID_P +# define GRUB_CPU_SIZEOF_LONG GRUB_TARGET_SIZEOF_LONG +# ifdef GRUB_TARGET_WORDS_BIGENDIAN +# define GRUB_CPU_WORDS_BIGENDIAN 1 +# else +# undef GRUB_CPU_WORDS_BIGENDIAN +# endif +#endif /* ! GRUB_UTIL */ + +#if GRUB_CPU_SIZEOF_VOID_P != 4 && GRUB_CPU_SIZEOF_VOID_P != 8 +# error "This architecture is not supported because sizeof(void *) != 4 and sizeof(void *) != 8" +#endif + +#if GRUB_CPU_SIZEOF_LONG != 4 && GRUB_CPU_SIZEOF_LONG != 8 +# error "This architecture is not supported because sizeof(long) != 4 and sizeof(long) != 8" +#endif + +#if !defined (GRUB_UTIL) && !defined (GRUB_TARGET_WORDSIZE) +# if GRUB_TARGET_SIZEOF_VOID_P == 4 +# define GRUB_TARGET_WORDSIZE 32 +# elif GRUB_TARGET_SIZEOF_VOID_P == 8 +# define GRUB_TARGET_WORDSIZE 64 +# endif +#endif + +/* Define various wide integers. */ +typedef signed char grub_int8_t; +typedef short grub_int16_t; +typedef int grub_int32_t; +#if GRUB_CPU_SIZEOF_LONG == 8 +typedef long grub_int64_t; +#else +typedef long long grub_int64_t; +#endif + +typedef unsigned char grub_uint8_t; +typedef unsigned short grub_uint16_t; +typedef unsigned grub_uint32_t; +# define PRIxGRUB_UINT32_T "x" +# define PRIuGRUB_UINT32_T "u" +#if GRUB_CPU_SIZEOF_LONG == 8 +typedef unsigned long grub_uint64_t; +# define PRIxGRUB_UINT64_T "lx" +# define PRIuGRUB_UINT64_T "lu" +#else +typedef unsigned long long grub_uint64_t; +# define PRIxGRUB_UINT64_T "llx" +# define PRIuGRUB_UINT64_T "llu" +#endif + +/* Misc types. */ + +#if GRUB_CPU_SIZEOF_VOID_P == 8 +typedef grub_uint64_t grub_addr_t; +typedef grub_uint64_t grub_size_t; +typedef grub_int64_t grub_ssize_t; + +# define GRUB_SIZE_MAX 18446744073709551615UL + +# if GRUB_CPU_SIZEOF_LONG == 8 +# define PRIxGRUB_SIZE "lx" +# define PRIxGRUB_ADDR "lx" +# define PRIuGRUB_SIZE "lu" +# define PRIdGRUB_SSIZE "ld" +# else +# define PRIxGRUB_SIZE "llx" +# define PRIxGRUB_ADDR "llx" +# define PRIuGRUB_SIZE "llu" +# define PRIdGRUB_SSIZE "lld" +# endif +#else +typedef grub_uint32_t grub_addr_t; +typedef grub_uint32_t grub_size_t; +typedef grub_int32_t grub_ssize_t; + +# define GRUB_SIZE_MAX 4294967295UL + +# define PRIxGRUB_SIZE "x" +# define PRIxGRUB_ADDR "x" +# define PRIuGRUB_SIZE "u" +# define PRIdGRUB_SSIZE "d" +#endif + +#define GRUB_UCHAR_MAX 0xFF +#define GRUB_USHRT_MAX 65535 +#define GRUB_SHRT_MAX 0x7fff +#define GRUB_UINT_MAX 4294967295U +#define GRUB_INT_MAX 0x7fffffff +#define GRUB_INT32_MIN (-2147483647 - 1) +#define GRUB_INT32_MAX 2147483647 + +#if GRUB_CPU_SIZEOF_LONG == 8 +# define GRUB_ULONG_MAX 18446744073709551615UL +# define GRUB_LONG_MAX 9223372036854775807L +# define GRUB_LONG_MIN (-9223372036854775807L - 1) +#else +# define GRUB_ULONG_MAX 4294967295UL +# define GRUB_LONG_MAX 2147483647L +# define GRUB_LONG_MIN (-2147483647L - 1) +#endif + +typedef grub_uint64_t grub_properly_aligned_t; + +#define GRUB_PROPERLY_ALIGNED_ARRAY(name, size) grub_properly_aligned_t name[((size) + sizeof (grub_properly_aligned_t) - 1) / sizeof (grub_properly_aligned_t)] + +/* The type for representing a file offset. */ +typedef grub_uint64_t grub_off_t; + +/* The type for representing a disk block address. */ +typedef grub_uint64_t grub_disk_addr_t; + +/* Byte-orders. */ +static inline grub_uint16_t grub_swap_bytes16(grub_uint16_t _x) +{ + return (grub_uint16_t) ((_x << 8) | (_x >> 8)); +} + +#define grub_swap_bytes16_compile_time(x) ((((x) & 0xff) << 8) | (((x) & 0xff00) >> 8)) +#define grub_swap_bytes32_compile_time(x) ((((x) & 0xff) << 24) | (((x) & 0xff00) << 8) | (((x) & 0xff0000) >> 8) | (((x) & 0xff000000UL) >> 24)) +#define grub_swap_bytes64_compile_time(x) \ +({ \ + grub_uint64_t _x = (x); \ + (grub_uint64_t) ((_x << 56) \ + | ((_x & (grub_uint64_t) 0xFF00ULL) << 40) \ + | ((_x & (grub_uint64_t) 0xFF0000ULL) << 24) \ + | ((_x & (grub_uint64_t) 0xFF000000ULL) << 8) \ + | ((_x & (grub_uint64_t) 0xFF00000000ULL) >> 8) \ + | ((_x & (grub_uint64_t) 0xFF0000000000ULL) >> 24) \ + | ((_x & (grub_uint64_t) 0xFF000000000000ULL) >> 40) \ + | (_x >> 56)); \ +}) + +#if defined(__GNUC__) && (__GNUC__ > 3) && (__GNUC__ > 4 || __GNUC_MINOR__ >= 3) +static inline grub_uint32_t grub_swap_bytes32(grub_uint32_t x) +{ + return __builtin_bswap32(x); +} + +static inline grub_uint64_t grub_swap_bytes64(grub_uint64_t x) +{ + return __builtin_bswap64(x); +} +#else /* not gcc 4.3 or newer */ +static inline grub_uint32_t grub_swap_bytes32(grub_uint32_t _x) +{ + return ((_x << 24) + | ((_x & (grub_uint32_t) 0xFF00UL) << 8) + | ((_x & (grub_uint32_t) 0xFF0000UL) >> 8) + | (_x >> 24)); +} + +static inline grub_uint64_t grub_swap_bytes64(grub_uint64_t _x) +{ + return ((_x << 56) + | ((_x & (grub_uint64_t) 0xFF00ULL) << 40) + | ((_x & (grub_uint64_t) 0xFF0000ULL) << 24) + | ((_x & (grub_uint64_t) 0xFF000000ULL) << 8) + | ((_x & (grub_uint64_t) 0xFF00000000ULL) >> 8) + | ((_x & (grub_uint64_t) 0xFF0000000000ULL) >> 24) + | ((_x & (grub_uint64_t) 0xFF000000000000ULL) >> 40) + | (_x >> 56)); +} +#endif /* not gcc 4.3 or newer */ + +#ifdef GRUB_CPU_WORDS_BIGENDIAN +# define grub_cpu_to_le16(x) grub_swap_bytes16(x) +# define grub_cpu_to_le32(x) grub_swap_bytes32(x) +# define grub_cpu_to_le64(x) grub_swap_bytes64(x) +# define grub_le_to_cpu16(x) grub_swap_bytes16(x) +# define grub_le_to_cpu32(x) grub_swap_bytes32(x) +# define grub_le_to_cpu64(x) grub_swap_bytes64(x) +# define grub_cpu_to_be16(x) ((grub_uint16_t) (x)) +# define grub_cpu_to_be32(x) ((grub_uint32_t) (x)) +# define grub_cpu_to_be64(x) ((grub_uint64_t) (x)) +# define grub_be_to_cpu16(x) ((grub_uint16_t) (x)) +# define grub_be_to_cpu32(x) ((grub_uint32_t) (x)) +# define grub_be_to_cpu64(x) ((grub_uint64_t) (x)) +# define grub_cpu_to_be16_compile_time(x) ((grub_uint16_t) (x)) +# define grub_cpu_to_be32_compile_time(x) ((grub_uint32_t) (x)) +# define grub_cpu_to_be64_compile_time(x) ((grub_uint64_t) (x)) +# define grub_be_to_cpu64_compile_time(x) ((grub_uint64_t) (x)) +# define grub_cpu_to_le32_compile_time(x) grub_swap_bytes32_compile_time(x) +# define grub_cpu_to_le64_compile_time(x) grub_swap_bytes64_compile_time(x) +# define grub_cpu_to_le16_compile_time(x) grub_swap_bytes16_compile_time(x) +#else /* ! WORDS_BIGENDIAN */ +# define grub_cpu_to_le16(x) ((grub_uint16_t) (x)) +# define grub_cpu_to_le32(x) ((grub_uint32_t) (x)) +# define grub_cpu_to_le64(x) ((grub_uint64_t) (x)) +# define grub_le_to_cpu16(x) ((grub_uint16_t) (x)) +# define grub_le_to_cpu32(x) ((grub_uint32_t) (x)) +# define grub_le_to_cpu64(x) ((grub_uint64_t) (x)) +# define grub_cpu_to_be16(x) grub_swap_bytes16(x) +# define grub_cpu_to_be32(x) grub_swap_bytes32(x) +# define grub_cpu_to_be64(x) grub_swap_bytes64(x) +# define grub_be_to_cpu16(x) grub_swap_bytes16(x) +# define grub_be_to_cpu32(x) grub_swap_bytes32(x) +# define grub_be_to_cpu64(x) grub_swap_bytes64(x) +# define grub_cpu_to_be16_compile_time(x) grub_swap_bytes16_compile_time(x) +# define grub_cpu_to_be32_compile_time(x) grub_swap_bytes32_compile_time(x) +# define grub_cpu_to_be64_compile_time(x) grub_swap_bytes64_compile_time(x) +# define grub_be_to_cpu64_compile_time(x) grub_swap_bytes64_compile_time(x) +# define grub_cpu_to_le16_compile_time(x) ((grub_uint16_t) (x)) +# define grub_cpu_to_le32_compile_time(x) ((grub_uint32_t) (x)) +# define grub_cpu_to_le64_compile_time(x) ((grub_uint64_t) (x)) + +#endif /* ! WORDS_BIGENDIAN */ + +static inline grub_uint16_t grub_get_unaligned16 (const void *ptr) +{ + struct grub_unaligned_uint16_t + { + grub_uint16_t d; + } GRUB_PACKED; + const struct grub_unaligned_uint16_t *dd + = (const struct grub_unaligned_uint16_t *) ptr; + return dd->d; +} + +static inline void grub_set_unaligned16 (void *ptr, grub_uint16_t val) +{ + struct grub_unaligned_uint16_t + { + grub_uint16_t d; + } GRUB_PACKED; + struct grub_unaligned_uint16_t *dd = (struct grub_unaligned_uint16_t *) ptr; + dd->d = val; +} + +static inline grub_uint32_t grub_get_unaligned32 (const void *ptr) +{ + struct grub_unaligned_uint32_t + { + grub_uint32_t d; + } GRUB_PACKED; + const struct grub_unaligned_uint32_t *dd + = (const struct grub_unaligned_uint32_t *) ptr; + return dd->d; +} + +static inline void grub_set_unaligned32 (void *ptr, grub_uint32_t val) +{ + struct grub_unaligned_uint32_t + { + grub_uint32_t d; + } GRUB_PACKED; + struct grub_unaligned_uint32_t *dd = (struct grub_unaligned_uint32_t *) ptr; + dd->d = val; +} + +struct grub_unaligned_uint64 +{ + grub_uint64_t val; +} GRUB_PACKED; + +typedef struct grub_unaligned_uint64 grub_unaligned_uint64_t; + +static inline grub_uint64_t grub_get_unaligned64 (const void *ptr) +{ + const struct grub_unaligned_uint64 *dd + = (const struct grub_unaligned_uint64 *) ptr; + return dd->val; +} + +static inline void grub_set_unaligned64 (void *ptr, grub_uint64_t val) +{ + struct grub_unaligned_uint64_t + { + grub_uint64_t d; + } GRUB_PACKED; + struct grub_unaligned_uint64_t *dd = (struct grub_unaligned_uint64_t *) ptr; + dd->d = val; +} + +#define GRUB_CHAR_BIT 8 + +#endif /* ! GRUB_TYPES_HEADER */ diff --git a/i386/i386at/acpi.c b/i386/i386at/acpi.c new file mode 100644 index 00000000..ec8aeb1e --- /dev/null +++ b/i386/i386at/acpi.c @@ -0,0 +1,82 @@ +/* acpi.c - get acpi tables. */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2009 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see . + */ + +#include +#include +#include + +struct grub_acpi_rsdp_v10 * +grub_machine_acpi_get_rsdpv1 (void) +{ + int ebda_len; + grub_uint8_t *ebda, *ptr; + + grub_dprintf ("acpi", "Looking for RSDP. Scanning EBDA\n"); + ebda = (grub_uint8_t *) phystokv ((* ((grub_uint16_t *) phystokv (0x40e))) << 4); + ebda_len = * (grub_uint16_t *) ebda; + if (! ebda_len) + return 0; + for (ptr = ebda; ptr < ebda + 0x400; ptr += 16) + if (grub_memcmp (ptr, GRUB_RSDP_SIGNATURE, GRUB_RSDP_SIGNATURE_SIZE) == 0 + && grub_byte_checksum (ptr, sizeof (struct grub_acpi_rsdp_v10)) == 0 + && ((struct grub_acpi_rsdp_v10 *) ptr)->revision == 0) + return (struct grub_acpi_rsdp_v10 *) ptr; + + grub_dprintf ("acpi", "Looking for RSDP. Scanning BIOS\n"); + for (ptr = (grub_uint8_t *) phystokv (0xe0000); ptr < (grub_uint8_t *) phystokv (0x100000); + ptr += 16) + if (grub_memcmp (ptr, GRUB_RSDP_SIGNATURE, GRUB_RSDP_SIGNATURE_SIZE) == 0 + && grub_byte_checksum (ptr, sizeof (struct grub_acpi_rsdp_v10)) == 0 + && ((struct grub_acpi_rsdp_v10 *) ptr)->revision == 0) + return (struct grub_acpi_rsdp_v10 *) ptr; + return 0; +} + +struct grub_acpi_rsdp_v20 * +grub_machine_acpi_get_rsdpv2 (void) +{ + int ebda_len; + grub_uint8_t *ebda, *ptr; + + grub_dprintf ("acpi", "Looking for RSDP. Scanning EBDA\n"); + ebda = (grub_uint8_t *) phystokv ((* ((grub_uint16_t *) phystokv (0x40e))) << 4); + ebda_len = * (grub_uint16_t *) ebda; + if (! ebda_len) + return 0; + for (ptr = ebda; ptr < ebda + 0x400; ptr += 16) + if (grub_memcmp (ptr, GRUB_RSDP_SIGNATURE, GRUB_RSDP_SIGNATURE_SIZE) == 0 + && grub_byte_checksum (ptr, sizeof (struct grub_acpi_rsdp_v10)) == 0 + && ((struct grub_acpi_rsdp_v10 *) ptr)->revision != 0 + && ((struct grub_acpi_rsdp_v20 *) ptr)->length < 1024 + && grub_byte_checksum (ptr, ((struct grub_acpi_rsdp_v20 *) ptr)->length) + == 0) + return (struct grub_acpi_rsdp_v20 *) ptr; + + grub_dprintf ("acpi", "Looking for RSDP. Scanning BIOS\n"); + for (ptr = (grub_uint8_t *) phystokv (0xe0000); ptr < (grub_uint8_t *) phystokv (0x100000); + ptr += 16) + if (grub_memcmp (ptr, GRUB_RSDP_SIGNATURE, GRUB_RSDP_SIGNATURE_SIZE) == 0 + && grub_byte_checksum (ptr, sizeof (struct grub_acpi_rsdp_v10)) == 0 + && ((struct grub_acpi_rsdp_v10 *) ptr)->revision != 0 + && ((struct grub_acpi_rsdp_v20 *) ptr)->length < 1024 + && grub_byte_checksum (ptr, ((struct grub_acpi_rsdp_v20 *) ptr)->length) + == 0) + return (struct grub_acpi_rsdp_v20 *) ptr; + return 0; +} diff --git a/i386/i386at/acpihalt.c b/i386/i386at/acpihalt.c new file mode 100644 index 00000000..23df44ff --- /dev/null +++ b/i386/i386at/acpihalt.c @@ -0,0 +1,409 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2010 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see . + */ + +#include + +#ifdef GRUB_DSDT_TEST +#include +#include +#include +#include +#include +#include + +#define grub_dprintf(cond, args...) printf ( args ) +#define grub_printf printf +typedef uint64_t grub_uint64_t; +typedef uint32_t grub_uint32_t; +typedef uint16_t grub_uint16_t; +typedef uint8_t grub_uint8_t; + +#endif + +#include +#ifndef GRUB_DSDT_TEST +#include +#else +#define _(x) x +#define N_(x) x +#endif + +#ifndef GRUB_DSDT_TEST +#include +#include +#include +#include +#endif + +static inline grub_uint32_t +decode_length (const grub_uint8_t *ptr, int *numlen) +{ + int num_bytes, i; + grub_uint32_t ret; + if (*ptr < 64) + { + if (numlen) + *numlen = 1; + return *ptr; + } + num_bytes = *ptr >> 6; + if (numlen) + *numlen = num_bytes + 1; + ret = *ptr & 0xf; + ptr++; + for (i = 0; i < num_bytes; i++) + { + ret |= *ptr << (8 * i + 4); + ptr++; + } + return ret; +} + +static inline grub_uint32_t +skip_name_string (const grub_uint8_t *ptr, const grub_uint8_t *end) +{ + const grub_uint8_t *ptr0 = ptr; + + while (ptr < end && (*ptr == '^' || *ptr == '\\')) + ptr++; + switch (*ptr) + { + case '.': + ptr++; + ptr += 8; + break; + case '/': + ptr++; + ptr += 1 + (*ptr) * 4; + break; + case 0: + ptr++; + break; + default: + ptr += 4; + break; + } + return ptr - ptr0; +} + +static inline grub_uint32_t +skip_data_ref_object (const grub_uint8_t *ptr, const grub_uint8_t *end) +{ + grub_dprintf ("acpi", "data type = 0x%x\n", *ptr); + switch (*ptr) + { + case GRUB_ACPI_OPCODE_PACKAGE: + case GRUB_ACPI_OPCODE_BUFFER: + return 1 + decode_length (ptr + 1, 0); + case GRUB_ACPI_OPCODE_ZERO: + case GRUB_ACPI_OPCODE_ONES: + case GRUB_ACPI_OPCODE_ONE: + return 1; + case GRUB_ACPI_OPCODE_BYTE_CONST: + return 2; + case GRUB_ACPI_OPCODE_WORD_CONST: + return 3; + case GRUB_ACPI_OPCODE_DWORD_CONST: + return 5; + case GRUB_ACPI_OPCODE_STRING_CONST: + { + const grub_uint8_t *ptr0 = ptr; + for (ptr++; ptr < end && *ptr; ptr++); + if (ptr == end) + return 0; + return ptr - ptr0 + 1; + } + default: + if (*ptr == '^' || *ptr == '\\' || *ptr == '_' + || (*ptr >= 'A' && *ptr <= 'Z')) + return skip_name_string (ptr, end); + grub_printf ("Unknown opcode 0x%x\n", *ptr); + return 0; + } +} + +static inline grub_uint32_t +skip_ext_op (const grub_uint8_t *ptr, const grub_uint8_t *end) +{ + const grub_uint8_t *ptr0 = ptr; + int add; + grub_dprintf ("acpi", "Extended opcode: 0x%x\n", *ptr); + switch (*ptr) + { + case GRUB_ACPI_EXTOPCODE_MUTEX: + ptr++; + ptr += skip_name_string (ptr, end); + ptr++; + break; + case GRUB_ACPI_EXTOPCODE_EVENT_OP: + ptr++; + ptr += skip_name_string (ptr, end); + break; + case GRUB_ACPI_EXTOPCODE_OPERATION_REGION: + ptr++; + ptr += skip_name_string (ptr, end); + ptr++; + ptr += add = skip_data_ref_object (ptr, end); + if (!add) + return 0; + ptr += add = skip_data_ref_object (ptr, end); + if (!add) + return 0; + break; + case GRUB_ACPI_EXTOPCODE_FIELD_OP: + case GRUB_ACPI_EXTOPCODE_DEVICE_OP: + case GRUB_ACPI_EXTOPCODE_PROCESSOR_OP: + case GRUB_ACPI_EXTOPCODE_POWER_RES_OP: + case GRUB_ACPI_EXTOPCODE_THERMAL_ZONE_OP: + case GRUB_ACPI_EXTOPCODE_INDEX_FIELD_OP: + case GRUB_ACPI_EXTOPCODE_BANK_FIELD_OP: + ptr++; + ptr += decode_length (ptr, 0); + break; + default: + grub_printf ("Unexpected extended opcode: 0x%x\n", *ptr); + return 0; + } + return ptr - ptr0; +} + +static int +get_sleep_type (grub_uint8_t *table, grub_uint8_t *ptr, grub_uint8_t *end, + grub_uint8_t *scope, int scope_len) +{ + grub_uint8_t *prev = table; + + if (!ptr) + ptr = table + sizeof (struct grub_acpi_table_header); + while (ptr < end && prev < ptr) + { + int add; + prev = ptr; + grub_dprintf ("acpi", "Opcode 0x%x\n", *ptr); + grub_dprintf ("acpi", "Tell %x\n", (unsigned) (ptr - table)); + switch (*ptr) + { + case GRUB_ACPI_OPCODE_EXTOP: + ptr++; + ptr += add = skip_ext_op (ptr, end); + if (!add) + return -1; + break; + case GRUB_ACPI_OPCODE_CREATE_WORD_FIELD: + case GRUB_ACPI_OPCODE_CREATE_BYTE_FIELD: + { + ptr += 5; + ptr += add = skip_data_ref_object (ptr, end); + if (!add) + return -1; + ptr += 4; + break; + } + case GRUB_ACPI_OPCODE_NAME: + ptr++; + if ((!scope || grub_memcmp (scope, "\\", scope_len) == 0) && + (grub_memcmp (ptr, "_S5_", 4) == 0 || grub_memcmp (ptr, "\\_S5_", 4) == 0)) + { + int ll; + grub_uint8_t *ptr2 = ptr; + grub_dprintf ("acpi", "S5 found\n"); + ptr2 += skip_name_string (ptr, end); + if (*ptr2 != 0x12) + { + grub_printf ("Unknown opcode in _S5: 0x%x\n", *ptr2); + return -1; + } + ptr2++; + decode_length (ptr2, &ll); + ptr2 += ll; + ptr2++; + switch (*ptr2) + { + case GRUB_ACPI_OPCODE_ZERO: + return 0; + case GRUB_ACPI_OPCODE_ONE: + return 1; + case GRUB_ACPI_OPCODE_BYTE_CONST: + return ptr2[1]; + default: + grub_printf ("Unknown data type in _S5: 0x%x\n", *ptr2); + return -1; + } + } + ptr += add = skip_name_string (ptr, end); + if (!add) + return -1; + ptr += add = skip_data_ref_object (ptr, end); + if (!add) + return -1; + break; + case GRUB_ACPI_OPCODE_SCOPE: + { + int scope_sleep_type; + int ll; + grub_uint8_t *name; + int name_len; + + ptr++; + add = decode_length (ptr, &ll); + name = ptr + ll; + name_len = skip_name_string (name, ptr + add); + if (!name_len) + return -1; + scope_sleep_type = get_sleep_type (table, name + name_len, + ptr + add, name, name_len); + if (scope_sleep_type != -2) + return scope_sleep_type; + ptr += add; + break; + } + case GRUB_ACPI_OPCODE_IF: + case GRUB_ACPI_OPCODE_METHOD: + { + ptr++; + ptr += decode_length (ptr, 0); + break; + } + default: + grub_printf ("Unknown opcode 0x%x\n", *ptr); + return -1; + } + } + + return -2; +} + +#ifdef GRUB_DSDT_TEST +int +main (int argc, char **argv) +{ + FILE *f; + size_t len; + unsigned char *buf; + if (argc < 2) + printf ("Usage: %s FILE\n", argv[0]); + f = grub_util_fopen (argv[1], "rb"); + if (!f) + { + printf ("Couldn't open file\n"); + return 1; + } + fseek (f, 0, SEEK_END); + len = ftell (f); + fseek (f, 0, SEEK_SET); + buf = malloc (len); + if (!buf) + { + printf (_("error: %s.\n"), _("out of memory")); + fclose (f); + return 2; + } + if (fread (buf, 1, len, f) != len) + { + printf (_("cannot read `%s': %s"), argv[1], strerror (errno)); + free (buf); + fclose (f); + return 2; + } + + printf ("Sleep type = %d\n", get_sleep_type (buf, NULL, buf + len, NULL, 0)); + free (buf); + fclose (f); + return 0; +} + +#else + +void +grub_acpi_halt (void) +{ + struct grub_acpi_rsdp_v20 *rsdp2; + struct grub_acpi_rsdp_v10 *rsdp1; + struct grub_acpi_table_header *rsdt; + grub_uint32_t *entry_ptr; + grub_uint32_t port = 0; + int sleep_type = -1; + + rsdp2 = grub_acpi_get_rsdpv2 (); + if (rsdp2) + rsdp1 = &(rsdp2->rsdpv1); + else + rsdp1 = grub_acpi_get_rsdpv1 (); + grub_dprintf ("acpi", "rsdp1=%p\n", rsdp1); + if (!rsdp1) + return; + + rsdt = (struct grub_acpi_table_header *) + io_map_cached (rsdp1->rsdt_addr, sizeof *rsdt); + rsdt = (struct grub_acpi_table_header *) + io_map_cached (rsdp1->rsdt_addr, rsdt->length); + + for (entry_ptr = (grub_uint32_t *) (rsdt + 1); + entry_ptr < (grub_uint32_t *) (((grub_uint8_t *) rsdt) + + rsdt->length); + entry_ptr++) + { + if (grub_memcmp ((void *) io_map_cached (*entry_ptr, 4), + "FACP", 4) == 0) + { + struct grub_acpi_fadt *fadt = (struct grub_acpi_fadt *) + io_map_cached (*entry_ptr, sizeof *fadt); + + struct grub_acpi_table_header *dsdt = + (struct grub_acpi_table_header *) + io_map_cached (fadt->dsdt_addr, sizeof *dsdt); + grub_uint8_t *buf = (grub_uint8_t *) + io_map_cached (fadt->dsdt_addr, dsdt->length); + + port = fadt->pm1a; + + grub_dprintf ("acpi", "PM1a port=%x\n", port); + + if (grub_memcmp (dsdt->signature, "DSDT", + sizeof (dsdt->signature)) == 0 + && sleep_type < 0) + sleep_type = get_sleep_type (buf, NULL, buf + dsdt->length, + NULL, 0); + } + else + if (grub_memcmp ((void *) io_map_cached (*entry_ptr, 4), "SSDT", 4) == 0 + && sleep_type < 0) + { + struct grub_acpi_table_header *ssdt + = (struct grub_acpi_table_header *) (grub_addr_t) + io_map_cached (*entry_ptr, sizeof *ssdt); + grub_uint8_t *buf = (grub_uint8_t *) + io_map_cached (*entry_ptr, ssdt->length); + + grub_dprintf ("acpi", "SSDT = %p\n", ssdt); + + sleep_type = get_sleep_type (buf, NULL, buf + ssdt->length, NULL, 0); + } + } + + grub_dprintf ("acpi", "SLP_TYP = %d, port = 0x%x\n", sleep_type, port); + if (port && sleep_type >= 0 && sleep_type < 8) + grub_outw (GRUB_ACPI_SLP_EN | (sleep_type << GRUB_ACPI_SLP_TYP_OFFSET), + port & 0xffff); + + grub_millisleep (1500); + + /* TRANSLATORS: It's computer shutdown using ACPI, not disabling ACPI. */ + grub_puts_ (N_("ACPI shutdown failed")); +} +#endif diff --git a/i386/i386at/acpihalt.h b/i386/i386at/acpihalt.h new file mode 100644 index 00000000..a4fdb075 --- /dev/null +++ b/i386/i386at/acpihalt.h @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2014 Free Software Foundation. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef _ACPIHALT_H_ +#define _ACPIHALT_H_ + +void grub_acpi_halt (void); + +#endif /* _ACPIHALT_H_ */ diff --git a/i386/i386at/grub_glue.c b/i386/i386at/grub_glue.c new file mode 100644 index 00000000..68a4cb1f --- /dev/null +++ b/i386/i386at/grub_glue.c @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2014 Free Software Foundation. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include +#include + +#include +#include + +#define GRUB_DEBUG 0 + +void +grub_real_dprintf (const char *file, const int line, const char *condition, + const char *fmt, ...) +{ +#if GRUB_DEBUG + va_list listp; + va_start(listp, fmt); + vprintf (fmt, listp); + va_end(listp); +#endif +} + +void +grub_millisleep (grub_uint32_t ms) +{ + /* Do nothing. */ +} + +struct grub_acpi_rsdp_v20 * +grub_acpi_get_rsdpv2 (void) +{ + return grub_machine_acpi_get_rsdpv2 (); +} + +struct grub_acpi_rsdp_v10 * +grub_acpi_get_rsdpv1 (void) +{ + return grub_machine_acpi_get_rsdpv1 (); +} + +/* Simple checksum by summing all bytes. Used by ACPI and SMBIOS. */ +grub_uint8_t +grub_byte_checksum (void *base, grub_size_t size) +{ + grub_uint8_t *ptr; + grub_uint8_t ret = 0; + for (ptr = (grub_uint8_t *) base; ptr < ((grub_uint8_t *) base) + size; + ptr++) + ret += *ptr; + return ret; +} diff --git a/i386/i386at/model_dep.c b/i386/i386at/model_dep.c index 95752faa..6093a66c 100644 --- a/i386/i386at/model_dep.c +++ b/i386/i386at/model_dep.c @@ -69,6 +69,7 @@ #include #include #include +#include #ifdef MACH_XEN #include #include @@ -231,6 +232,7 @@ void halt_all_cpus(boolean_t reboot) #ifdef MACH_HYP hyp_halt(); #endif /* MACH_HYP */ + grub_acpi_halt(); printf("In tight loop: hit ctl-alt-del to reboot\n"); (void) spl0(); } -- cgit v1.2.3 From 97447914d6dcc32ada4ee028e1e2bab262501316 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 6 Jul 2014 18:48:45 +0200 Subject: Document that io_map_cached leaks memory --- i386/grub/glue.h | 2 ++ i386/i386/io_map.c | 3 +++ 2 files changed, 5 insertions(+) diff --git a/i386/grub/glue.h b/i386/grub/glue.h index e1c62eba..ae41014d 100644 --- a/i386/grub/glue.h +++ b/i386/grub/glue.h @@ -26,6 +26,8 @@ #include #include +/* Warning: this leaks memory maps for now, do not use it yet for something + * else than Mach shutdown. */ vm_offset_t io_map_cached(vm_offset_t phys_addr, vm_size_t size); #endif /* _GRUB_GLUE_H */ diff --git a/i386/i386/io_map.c b/i386/i386/io_map.c index 03d71521..2c2aa720 100644 --- a/i386/i386/io_map.c +++ b/i386/i386/io_map.c @@ -66,6 +66,9 @@ io_map( * This maps the all pages containing [PHYS_ADDR:PHYS_ADDR + SIZE]. * For contiguous requests to those pages will reuse the previously * established mapping. + * + * Warning: this leaks memory maps for now, do not use it yet for something + * else than Mach shutdown. */ vm_offset_t io_map_cached( -- cgit v1.2.3 From 859c342d11a2d018e7b220e955bbe1ba1940f02f Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 6 Jul 2014 18:49:55 +0200 Subject: Do not unmap page 0 when not needed Since we need it to access some BIOS information, e.g. at ACPI shutdown. When the kernel VM is not starting at 0, there is already nothing mapped there in user tasks, anyway. * i386/i386at/model_dep.c (machine_init) [VM_MIN_KERNEL_ADDRESS != 0]: Do not call pmap_unmap_page_zero. * i386/intel/pmap.c (pmap_unmap_page_zero): Warn that unmapping page zero may break some BIOS functions. --- i386/i386at/acpi.c | 3 +++ i386/i386at/model_dep.c | 4 ++++ i386/intel/pmap.c | 1 + 3 files changed, 8 insertions(+) diff --git a/i386/i386at/acpi.c b/i386/i386at/acpi.c index ec8aeb1e..986b3a25 100644 --- a/i386/i386at/acpi.c +++ b/i386/i386at/acpi.c @@ -55,8 +55,11 @@ grub_machine_acpi_get_rsdpv2 (void) grub_uint8_t *ebda, *ptr; grub_dprintf ("acpi", "Looking for RSDP. Scanning EBDA\n"); + printf("ptr is %p\n", (* ((grub_uint16_t *) phystokv (0x40e))) << 4); + printf("len is %u\n", *( (grub_uint16_t *) phystokv ((* ((grub_uint16_t *) phystokv (0x40e))) << 4))); ebda = (grub_uint8_t *) phystokv ((* ((grub_uint16_t *) phystokv (0x40e))) << 4); ebda_len = * (grub_uint16_t *) ebda; + printf("EBDA len %d\n", ebda_len); if (! ebda_len) return 0; for (ptr = ebda; ptr < ebda + 0x400; ptr += 16) diff --git a/i386/i386at/model_dep.c b/i386/i386at/model_dep.c index 6093a66c..209cfb14 100644 --- a/i386/i386at/model_dep.c +++ b/i386/i386at/model_dep.c @@ -180,10 +180,14 @@ void machine_init(void) *(unsigned short *)phystokv(0x472) = 0x1234; #endif /* MACH_HYP */ +#if VM_MIN_KERNEL_ADDRESS == 0 /* * Unmap page 0 to trap NULL references. + * + * Note that this breaks accessing some BIOS areas stored there. */ pmap_unmap_page_zero(); +#endif } /* Conserve power on processor CPU. */ diff --git a/i386/intel/pmap.c b/i386/intel/pmap.c index 8a23a44d..62b33cf7 100644 --- a/i386/intel/pmap.c +++ b/i386/intel/pmap.c @@ -2835,6 +2835,7 @@ pmap_unmap_page_zero (void) { int *pte; + printf("Unmapping the zero page. Some BIOS functions may not be working any more.\n"); pte = (int *) pmap_pte (kernel_pmap, 0); if (!pte) return; -- cgit v1.2.3 From a32b7409276fceedc25962d013afb471e9d4e164 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Fri, 25 Jul 2014 19:31:11 +0200 Subject: Drop debugging prints * i386/i386at/acpi.c (grub_machine_acpi_get_rsdpv2): Drop debugging prints. --- i386/i386at/acpi.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/i386/i386at/acpi.c b/i386/i386at/acpi.c index 986b3a25..ec8aeb1e 100644 --- a/i386/i386at/acpi.c +++ b/i386/i386at/acpi.c @@ -55,11 +55,8 @@ grub_machine_acpi_get_rsdpv2 (void) grub_uint8_t *ebda, *ptr; grub_dprintf ("acpi", "Looking for RSDP. Scanning EBDA\n"); - printf("ptr is %p\n", (* ((grub_uint16_t *) phystokv (0x40e))) << 4); - printf("len is %u\n", *( (grub_uint16_t *) phystokv ((* ((grub_uint16_t *) phystokv (0x40e))) << 4))); ebda = (grub_uint8_t *) phystokv ((* ((grub_uint16_t *) phystokv (0x40e))) << 4); ebda_len = * (grub_uint16_t *) ebda; - printf("EBDA len %d\n", ebda_len); if (! ebda_len) return 0; for (ptr = ebda; ptr < ebda + 0x400; ptr += 16) -- cgit v1.2.3 From ed650a41c57d824f6503f266f21093d3ee18d21d Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Thu, 21 Aug 2014 16:51:54 +0200 Subject: Support invoking the debugger over the serial console * i386/i386at/com.c (comintr): Invoke the debugger if ctrl-alt-d is pressed. * i386/i386at/com.h (kdb_kintr): Add declaration. --- i386/i386at/com.c | 27 ++++++++++++++++++++++++++- i386/i386at/com.h | 4 ++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/i386/i386at/com.c b/i386/i386at/com.c index 5e65ad8a..619e1afd 100644 --- a/i386/i386at/com.c +++ b/i386/i386at/com.c @@ -518,10 +518,35 @@ comintr(int unit) case RECi: case CTIi: /* Character timeout indication */ if (tp->t_state&TS_ISOPEN) { + int escape = 0; while ((line = inb(LINE_STAT(addr))) & iDR) { c = inb(TXRX(addr)); - ttyinput(c, tp); + + if (c == 0x1b) { + escape = 1; + continue; + } + +#if MACH_KDB + if (escape && c == 'D'-'@') + /* ctrl-alt-d pressed, + invoke debugger */ + kdb_kintr(); + else +#endif /* MACH_KDB */ + if (escape) { + ttyinput(0x1b, tp); + ttyinput(c, tp); + } + else + ttyinput(c, tp); + + escape = 0; } + + if (escape) + /* just escape */ + ttyinput(0x1b, tp); } else tt_open_wakeup(tp); break; diff --git a/i386/i386at/com.h b/i386/i386at/com.h index 95baa457..779cdba8 100644 --- a/i386/i386at/com.h +++ b/i386/i386at/com.h @@ -71,6 +71,10 @@ comsetstat( int *data, natural_t count); +#if MACH_KDB +extern void kdb_kintr(void); +#endif /* MACH_KDB */ + extern io_return_t comopen(dev_t dev, int flag, io_req_t ior); extern void comclose(dev_t dev, int flag); extern io_return_t comread(dev_t dev, io_req_t ior); -- cgit v1.2.3 From 96a5ee2a14bc1897635060ef14083fd6ff7a7959 Mon Sep 17 00:00:00 2001 From: "Neal H. Walfield" Date: Fri, 22 Aug 2014 10:27:42 +0200 Subject: Even less magic-looking control value * i386/i386at/com.c (comintr): Use 'A'-1 instead of '@'. --- i386/i386at/com.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i386/i386at/com.c b/i386/i386at/com.c index 619e1afd..78142402 100644 --- a/i386/i386at/com.c +++ b/i386/i386at/com.c @@ -528,7 +528,7 @@ comintr(int unit) } #if MACH_KDB - if (escape && c == 'D'-'@') + if (escape && c == 'D'-'A'-1) /* ctrl-alt-d pressed, invoke debugger */ kdb_kintr(); -- cgit v1.2.3 From 4acc8fbda38887826a2e356f1394cc346c96217f Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Fri, 22 Aug 2014 12:56:45 +0200 Subject: Fix computation * i386/i386at/com.c (comintr): Fix computation of '@'. --- i386/i386at/com.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i386/i386at/com.c b/i386/i386at/com.c index 78142402..c36cb6ae 100644 --- a/i386/i386at/com.c +++ b/i386/i386at/com.c @@ -528,7 +528,7 @@ comintr(int unit) } #if MACH_KDB - if (escape && c == 'D'-'A'-1) + if (escape && c == 'D'-('A'-1)) /* ctrl-alt-d pressed, invoke debugger */ kdb_kintr(); -- cgit v1.2.3 From ed32cdc81be98287e4678bdb4a71a578b548580d Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sat, 30 Aug 2014 12:48:44 +0200 Subject: Bump NR_GRANT_PAGES This has shown needed on buildds with several disks and network interfaces. * xen/grant.c (NR_GRANT_PAGES): Increase from 4 to 8. --- xen/grant.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/grant.c b/xen/grant.c index 3d5c3fe7..ae3a7bfc 100644 --- a/xen/grant.c +++ b/xen/grant.c @@ -25,7 +25,7 @@ #include "grant.h" #define NR_RESERVED_ENTRIES 8 -#define NR_GRANT_PAGES 4 +#define NR_GRANT_PAGES 8 decl_simple_lock_data(static,lock); static struct grant_entry *grants; -- cgit v1.2.3 From c7cdf5ff96e7c3bb008877893aa194908dca2185 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sat, 30 Aug 2014 12:51:11 +0200 Subject: Increate the pageout thread priority * vm/vm_pageout.c (vm_pageout): Set the priority to 0. --- vm/vm_pageout.c | 1 + 1 file changed, 1 insertion(+) diff --git a/vm/vm_pageout.c b/vm/vm_pageout.c index 7ac43d6b..d57da782 100644 --- a/vm/vm_pageout.c +++ b/vm/vm_pageout.c @@ -912,6 +912,7 @@ void vm_pageout(void) current_thread()->vm_privilege = TRUE; stack_privilege(current_thread()); + thread_set_own_priority(0); /* * Initialize some paging parameters. -- cgit v1.2.3 From 91f0887ca2345c2bd02747e4b437076641d77cd9 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sat, 30 Aug 2014 12:55:14 +0200 Subject: Tune pageout parameters This targets having always at least 8% free memory instead of just 1%. This has shown improving buildd stability a lot. Also increase the reserved amount to nowadays standards. * vm/vm_pageout.c (VM_PAGE_FREE_TARGET): Increase to 10%. (VM_PAGE_FREE_MIN): Increase to 8%. (VM_PAGE_FREE_RESERVED): Increase to 500 pages. (VM_PAGEOUT_RESERVED_INTERNAL): Increase to 150 pages. (VM_PAGEOUT_RESERVED_REALLY): Increase to 100 pages. --- vm/vm_pageout.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/vm/vm_pageout.c b/vm/vm_pageout.c index d57da782..ecedb571 100644 --- a/vm/vm_pageout.c +++ b/vm/vm_pageout.c @@ -97,7 +97,7 @@ */ #ifndef VM_PAGE_FREE_TARGET -#define VM_PAGE_FREE_TARGET(free) (15 + (free) / 80) +#define VM_PAGE_FREE_TARGET(free) (150 + (free) * 10 / 100) #endif /* VM_PAGE_FREE_TARGET */ /* @@ -106,7 +106,7 @@ */ #ifndef VM_PAGE_FREE_MIN -#define VM_PAGE_FREE_MIN(free) (10 + (free) / 100) +#define VM_PAGE_FREE_MIN(free) (100 + (free) * 8 / 100) #endif /* VM_PAGE_FREE_MIN */ /* When vm_page_external_count exceeds vm_page_external_limit, @@ -132,7 +132,7 @@ * operation by dipping into the reserved pool of pages. */ #ifndef VM_PAGE_FREE_RESERVED -#define VM_PAGE_FREE_RESERVED 50 +#define VM_PAGE_FREE_RESERVED 500 #endif /* VM_PAGE_FREE_RESERVED */ /* @@ -144,7 +144,7 @@ */ #ifndef VM_PAGEOUT_RESERVED_INTERNAL -#define VM_PAGEOUT_RESERVED_INTERNAL(reserve) ((reserve) - 25) +#define VM_PAGEOUT_RESERVED_INTERNAL(reserve) ((reserve) - 250) #endif /* VM_PAGEOUT_RESERVED_INTERNAL */ /* @@ -156,7 +156,7 @@ */ #ifndef VM_PAGEOUT_RESERVED_REALLY -#define VM_PAGEOUT_RESERVED_REALLY(reserve) ((reserve) - 40) +#define VM_PAGEOUT_RESERVED_REALLY(reserve) ((reserve) - 400) #endif /* VM_PAGEOUT_RESERVED_REALLY */ unsigned int vm_pageout_reserved_internal = 0; -- cgit v1.2.3 From ce5ce65631b20514189a8abe39fc096db1e8837c Mon Sep 17 00:00:00 2001 From: Pietro Braione Date: Mon, 1 Sep 2014 23:10:14 +0200 Subject: Fix printf warning linux/src/drivers/net/sundance.c (start_tx): Fix format string according to parameter. --- linux/src/drivers/net/sundance.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux/src/drivers/net/sundance.c b/linux/src/drivers/net/sundance.c index 47f32ebd..37231644 100644 --- a/linux/src/drivers/net/sundance.c +++ b/linux/src/drivers/net/sundance.c @@ -986,7 +986,7 @@ static int start_tx(struct sk_buff *skb, struct net_device *dev) dev->trans_start = jiffies; if (np->msg_level & NETIF_MSG_TX_QUEUED) { - printk(KERN_DEBUG "%s: Transmit frame #%d len %ld queued in slot %ld.\n", + printk(KERN_DEBUG "%s: Transmit frame #%d len %ld queued in slot %u.\n", dev->name, np->cur_tx, skb->len, entry); } return 0; -- cgit v1.2.3 From 5ae510e35c54009626999a88f0f1cb34d6dfc94f Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sat, 6 Sep 2014 11:55:48 +0200 Subject: Make vm_map really ignore `address' when `anywhere' is true As vm_allocate does. * vm/vm_user.c (vm_map): When `anywhere' is true, set `address' to the minimum address of the `target_map'. --- vm/vm_user.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/vm/vm_user.c b/vm/vm_user.c index f7c87cc0..1d8f37bb 100644 --- a/vm/vm_user.c +++ b/vm/vm_user.c @@ -336,7 +336,10 @@ kern_return_t vm_map( if (size == 0) return KERN_INVALID_ARGUMENT; - *address = trunc_page(*address); + if (anywhere) + *address = vm_map_min(target_map); + else + *address = trunc_page(*address); size = round_page(size); if (!IP_VALID(memory_object)) { -- cgit v1.2.3 From 96cec60d956bfb27f135d4e932a1c319cbc878df Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Wed, 17 Sep 2014 01:50:05 +0200 Subject: Report DR6 to userland * i386/i386/trap.c (user_trap): On T_DEBUG, record the content of dr6 in PCB, and clear it. --- i386/i386/trap.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/i386/i386/trap.c b/i386/i386/trap.c index 200cbccc..9d4d43d0 100644 --- a/i386/i386/trap.c +++ b/i386/i386/trap.c @@ -395,6 +395,11 @@ printf("user trap %d error %d sub %08x\n", type, code, subcode); return 0; } #endif /* MACH_KDB */ + /* Make the content of the debug status register (DR6) + available to user space. */ + if (thread->pcb) + thread->pcb->ims.ids.dr[6] = get_dr6() & 0x600F; + set_dr6(0); exc = EXC_BREAKPOINT; code = EXC_I386_SGL; break; -- cgit v1.2.3 From ffd4f3c8239b41d3fe9fa14403eb063e02b6a222 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Sat, 13 Sep 2014 00:41:11 +0200 Subject: ddb: add `show all tasks' command * ddb/db_command.c (db_show_all_cmds): Add `tasks'. * ddb/db_print.c (db_show_all_tasks): New function. * ddb/db_print.h (db_show_all_tasks): New prototype. --- ddb/db_command.c | 1 + ddb/db_print.c | 24 ++++++++++++++++++++++++ ddb/db_print.h | 6 ++++++ 3 files changed, 31 insertions(+) diff --git a/ddb/db_command.c b/ddb/db_command.c index 81711192..56516672 100644 --- a/ddb/db_command.c +++ b/ddb/db_command.c @@ -304,6 +304,7 @@ db_command_list( } struct db_command db_show_all_cmds[] = { + { "tasks", db_show_all_tasks, 0, 0 }, { "threads", db_show_all_threads, 0, 0 }, { "slocks", db_show_all_slocks, 0, 0 }, { (char *)0 } diff --git a/ddb/db_print.c b/ddb/db_print.c index e711ab66..24a3e337 100644 --- a/ddb/db_print.c +++ b/ddb/db_print.c @@ -276,6 +276,30 @@ db_print_task( } } +void +db_show_all_tasks(db_expr_t addr, + boolean_t have_addr, + db_expr_t count, + const char *modif) +{ + task_t task; + int task_id = 0; + processor_set_t pset; + + db_printf(" ID %-*s NAME [THREADS]\n", 2*sizeof(vm_offset_t), "TASK"); + + queue_iterate(&all_psets, pset, processor_set_t, all_psets) + queue_iterate(&pset->tasks, task, task_t, pset_tasks) { + db_printf("%3d %0*X %s [%d]\n", + task_id, + 2*sizeof(vm_offset_t), + task, + task->name, + task->thread_count); + task_id++; + } +} + /*ARGSUSED*/ void db_show_all_threads(addr, have_addr, count, modif) diff --git a/ddb/db_print.h b/ddb/db_print.h index dacb47b8..87db97be 100644 --- a/ddb/db_print.h +++ b/ddb/db_print.h @@ -38,6 +38,12 @@ void db_show_one_thread( db_expr_t count, const char * modif); +void db_show_all_tasks( + db_expr_t addr, + int have_addr, + db_expr_t count, + const char * modif); + void db_show_all_threads( db_expr_t addr, int have_addr, -- cgit v1.2.3 From 86f60379f71ec6d0aa3b93eaacc55bc5f453bda5 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Sun, 14 Sep 2014 13:35:50 +0200 Subject: ddb: add support for ELF symbol tables * ddb/db_elf.c: New file. * ddb/db_elf.h: Likewise. * Makefrag.am (libkernel_a_SOURCES): Add db_elf.{c,h}. * ddb/db_sym.c (dummy_db_sym_init): New stub db_sym_init function. (db_sym_switch): Add ELF functions. * ddb/db_sym.h (SYMTAB_ELF): New macro. (elf_db_sym_init): New declaration. * i386/i386at/model_dep.c (c_boot_entry): Get ELF section header information from the multiboot structure, and call elf_db_sym_init. --- Makefrag.am | 2 + ddb/db_elf.c | 232 ++++++++++++++++++++++++++++++++++++++++++++++++ ddb/db_elf.h | 52 +++++++++++ ddb/db_sym.c | 14 ++- ddb/db_sym.h | 9 ++ i386/i386at/model_dep.c | 27 ++++++ 6 files changed, 335 insertions(+), 1 deletion(-) create mode 100644 ddb/db_elf.c create mode 100644 ddb/db_elf.h diff --git a/Makefrag.am b/Makefrag.am index d6dd77f9..5e98b219 100644 --- a/Makefrag.am +++ b/Makefrag.am @@ -25,6 +25,8 @@ libkernel_a_SOURCES += \ ddb/db_access.h \ ddb/db_aout.c \ ddb/db_aout.h \ + ddb/db_elf.c \ + ddb/db_elf.h \ ddb/db_break.c \ ddb/db_break.h \ ddb/db_command.c \ diff --git a/ddb/db_elf.c b/ddb/db_elf.c new file mode 100644 index 00000000..10e71621 --- /dev/null +++ b/ddb/db_elf.c @@ -0,0 +1,232 @@ +/* + * Copyright (C) 2014 Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +/* + * Mach Operating System + * Copyright (c) 1991,1990 Carnegie Mellon University + * All Rights Reserved. + * + * Permission to use, copy, modify and distribute this software and its + * documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie Mellon + * the rights to redistribute these changes. + */ +/* + * Author: David B. Golub, Carnegie Mellon University + * Date: 7/90 + */ + +#if MACH_KDB + +/* + * Symbol table routines for ELF format files. + */ + +#include +#include +#include +#include /* data types */ +#include +#include +#include +#include + +#ifndef DB_NO_ELF + +struct db_symtab_elf { + int type; + Elf32_Sym *start; + Elf32_Sym *end; + char *strings; + char *map_pointer; /* symbols are for this map only, + if not null */ + char name[SYMTAB_NAME_LEN]; + /* symtab name */ +}; + +boolean_t +elf_db_sym_init (unsigned shdr_num, + vm_size_t shdr_size, + vm_offset_t shdr_addr, + unsigned shdr_shndx, + char *name, + char *task_addr) +{ + Elf32_Shdr *shdr, *symtab, *strtab; + const char *shstrtab; + int i; + + if (shdr_num == 0) + return FALSE; + + if (shdr_size != sizeof *shdr) + return FALSE; + + shdr = (Elf32_Shdr *) shdr_addr; + + if (shdr[shdr_shndx].sh_type != SHT_STRTAB) + return FALSE; + + shstrtab = (const char *) phystokv (shdr[shdr_shndx].sh_addr); + + symtab = strtab = NULL; + for (i = 0; i < shdr_num; i++) + switch (shdr[i].sh_type) { + case SHT_SYMTAB: + if (symtab) + db_printf ("Ignoring additional ELF symbol table at %d\n", i); + else + symtab = &shdr[i]; + break; + + case SHT_STRTAB: + if (strcmp (&shstrtab[shdr[i].sh_name], ".strtab") == 0) { + if (strtab) + db_printf ("Ignoring additional ELF string table at %d\n", i); + else + strtab = &shdr[i]; + } + break; + } + + if (symtab == NULL || strtab == NULL) + return FALSE; + + if (db_add_symbol_table (SYMTAB_ELF, + (char *) phystokv (symtab->sh_addr), + (char *) phystokv (symtab->sh_addr)+symtab->sh_size, + name, + (char *) phystokv (strtab->sh_addr), + task_addr)) { + db_printf ("Loaded ELF symbol table for %s (%d symbols)\n", + name, symtab->sh_size / sizeof (Elf32_Sym)); + return TRUE; + } + + return FALSE; +} + +/* + * lookup symbol by name + */ +db_sym_t +elf_db_lookup (db_symtab_t *stab, + char *symstr) +{ + struct db_symtab_elf *self = (struct db_symtab_elf *) stab; + Elf32_Sym *s; + + for (s = self->start; s < self->end; s++) + if (strcmp (symstr, &self->strings[s->st_name]) == 0) + return (db_sym_t) s; + + return NULL; +} + +db_sym_t +elf_db_search_symbol (db_symtab_t *stab, + db_addr_t off, + db_strategy_t strategy, + db_expr_t *diffp) /* in/out */ +{ + struct db_symtab_elf *self = (struct db_symtab_elf *) stab; + unsigned long diff = *diffp; + Elf32_Sym *s, *symp = NULL; + + for (s = self->start; s < self->end; s++) { + if (s->st_name == 0) + continue; + + if (strategy == DB_STGY_XTRN && (s->st_info & STB_GLOBAL) == 0) + continue; + + if (off >= s->st_value) { + if (s->st_info == STT_FUNC) + continue; + + if (off - s->st_value < diff) { + diff = off - s->st_value; + symp = s; + if (diff == 0 && (s->st_info & STB_GLOBAL)) + break; + } else if (off - s->st_value == diff) { + if (symp == NULL) + symp = s; + else if ((symp->st_info & STB_GLOBAL) == 0 + && (s->st_info & STB_GLOBAL) != 0) + symp = s; /* pick the external symbol */ + } + } + } + + if (symp == NULL) + *diffp = off; + else + *diffp = diff; + + return (db_sym_t) symp; +} + +/* + * Return the name and value for a symbol. + */ +void +elf_db_symbol_values (db_symtab_t *stab, + db_sym_t sym, + char **namep, + db_expr_t *valuep) +{ + struct db_symtab_elf *self = (struct db_symtab_elf *) stab; + Elf32_Sym *s = (Elf32_Sym *) sym; + + if (namep) + *namep = &self->strings[s->st_name]; + if (valuep) + *valuep = s->st_value; +} + +/* + * Find filename and lineno within, given the current pc. + */ +boolean_t +elf_db_line_at_pc (db_symtab_t *stab, + db_sym_t sym, + char **file, + int *line, + db_addr_t pc) +{ + /* XXX Parse DWARF information. */ + return FALSE; +} + +#endif /* DB_NO_ELF */ + +#endif /* MACH_KDB */ diff --git a/ddb/db_elf.h b/ddb/db_elf.h new file mode 100644 index 00000000..12b82868 --- /dev/null +++ b/ddb/db_elf.h @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2013 Free Software Foundation. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef _DDB_DB_ELF_H_ +#define _DDB_DB_ELF_H_ + +#include +#include + +extern boolean_t +elf_db_line_at_pc( + db_symtab_t *stab, + db_sym_t sym, + char **file, + int *line, + db_addr_t pc); + +extern db_sym_t +elf_db_lookup( + db_symtab_t *stab, + char * symstr); + +extern db_sym_t +elf_db_search_symbol( + db_symtab_t * symtab, + db_addr_t off, + db_strategy_t strategy, + db_expr_t *diffp); + +extern void +elf_db_symbol_values( + db_symtab_t *stab, + db_sym_t sym, + char **namep, + db_expr_t *valuep); + +#endif /* _DDB_DB_ELF_H_ */ diff --git a/ddb/db_sym.c b/ddb/db_sym.c index 7d97d15e..0179137f 100644 --- a/ddb/db_sym.c +++ b/ddb/db_sym.c @@ -38,6 +38,7 @@ #include #include #include +#include #include /* vm_map_t */ @@ -507,6 +508,10 @@ void db_free_symbol(db_sym_t s) */ void dummy_db_free_symbol(db_sym_t symbol) { } +boolean_t dummy_db_sym_init(char *a, char *b, char *c, char *d) { + return FALSE; +} + struct db_sym_switch x_db[] = { @@ -521,7 +526,14 @@ struct db_sym_switch x_db[] = { { 0,}, /* Machdep, not inited here */ - { 0,} + { 0,}, + +#ifdef DB_NO_ELF + { 0,}, +#else /* DB_NO_ELF */ + { dummy_db_sym_init, elf_db_lookup, elf_db_search_symbol, + elf_db_line_at_pc, elf_db_symbol_values, dummy_db_free_symbol }, +#endif /* DB_NO_ELF */ }; diff --git a/ddb/db_sym.h b/ddb/db_sym.h index 2c3e10a6..d8f33874 100644 --- a/ddb/db_sym.h +++ b/ddb/db_sym.h @@ -46,6 +46,7 @@ typedef struct { #define SYMTAB_AOUT 0 #define SYMTAB_COFF 1 #define SYMTAB_MACHDEP 2 +#define SYMTAB_ELF 3 char *start; /* symtab location */ char *end; char *private; /* optional machdep pointer */ @@ -243,6 +244,14 @@ extern boolean_t aout_db_sym_init( char *name, char *task_addr); +extern boolean_t elf_db_sym_init ( + unsigned shdr_num, + vm_size_t shdr_size, + vm_offset_t shdr_addr, + unsigned shdr_shndx, + char *name, + char *task_addr); + db_sym_t db_lookup(char *); db_sym_t diff --git a/i386/i386at/model_dep.c b/i386/i386at/model_dep.c index 209cfb14..bc34c9b0 100644 --- a/i386/i386at/model_dep.c +++ b/i386/i386at/model_dep.c @@ -82,7 +82,16 @@ #if MACH_KDB #include #include + +/* a.out symbol table */ static vm_offset_t kern_sym_start, kern_sym_end; + +/* ELF section header */ +static unsigned elf_shdr_num; +static vm_size_t elf_shdr_size; +static vm_offset_t elf_shdr_addr; +static unsigned elf_shdr_shndx; + #else /* MACH_KDB */ #define kern_sym_start 0 #define kern_sym_end 0 @@ -570,6 +579,17 @@ void c_boot_entry(vm_offset_t bi) kern_sym_start, kern_sym_end, symtab_size, strtab_size); } + + if ((boot_info.flags & MULTIBOOT_ELF_SHDR) + && boot_info.syms.e.num) + { + elf_shdr_num = boot_info.syms.e.num; + elf_shdr_size = boot_info.syms.e.size; + elf_shdr_addr = (vm_offset_t)phystokv(boot_info.syms.e.addr); + elf_shdr_shndx = boot_info.syms.e.shndx; + + printf("ELF section header table at %08lx\n", elf_shdr_addr); + } #endif /* MACH_KDB */ #endif /* MACH_XEN */ @@ -588,6 +608,13 @@ void c_boot_entry(vm_offset_t bi) { aout_db_sym_init((char *)kern_sym_start, (char *)kern_sym_end, "mach", (char *)0); } + + if (elf_shdr_num) + { + elf_db_sym_init(elf_shdr_num,elf_shdr_size, + elf_shdr_addr, elf_shdr_shndx, + "mach", NULL); + } #endif /* MACH_KDB */ machine_slot[0].is_cpu = TRUE; -- cgit v1.2.3 From 1c9bbcccfabbb451234d5a07f872b13d3278276e Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Wed, 24 Sep 2014 15:01:49 +0200 Subject: Update NEWS file --- NEWS | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/NEWS b/NEWS index 55d75ccf..9a9f620c 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,19 @@ +2014-XX-XX +Version 1.5 + +Numerous cleanups and stylistic fixes of the code base. Several +problems have been identified using static analysis tools and +subsequently been fixed. + +The kernel debugger can now parse ELF symbol tables, can be invoked +over serial lines, gained two new commands and has received usability +improvements. + +The vm pageout policy has been tuned to accommodate modern hardware. + +The kernel gained partial ACPI support on x86, enough to power down +the system. + 2013-09-27 Version 1.4 -- cgit v1.2.3 From dd2b22a787420e4b9d74e2778961b14f59293c91 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Fri, 26 Sep 2014 17:24:00 +0200 Subject: kern: create send rights as they are inserted at bootstrap time Previously, it was impossible to hand e.g. the master device port to more than one bootstrap task. Fix this by creating the send right as it is inserted into the target task. * kern/bootstrap.c (bootstrap_create): Do not create the send rights here... (boot_script_insert_right): ... but here. --- kern/bootstrap.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/kern/bootstrap.c b/kern/bootstrap.c index d919e905..4edae7bf 100644 --- a/kern/bootstrap.c +++ b/kern/bootstrap.c @@ -155,13 +155,13 @@ void bootstrap_create(void) /* Initialize boot script variables. We leak these send rights. */ losers = boot_script_set_variable ("host-port", VAL_PORT, - (long)ipc_port_make_send(realhost.host_priv_self)); + (long) realhost.host_priv_self); if (losers) panic ("cannot set boot-script variable host-port: %s", boot_script_error_string (losers)); losers = boot_script_set_variable ("device-port", VAL_PORT, - (long) ipc_port_make_send(master_device_port)); + (long) master_device_port); if (losers) panic ("cannot set boot-script variable device-port: %s", boot_script_error_string (losers)); @@ -838,7 +838,8 @@ boot_script_free_task (task_t task, int aborting) int boot_script_insert_right (struct cmd *cmd, mach_port_t port, mach_port_t *name) { - *name = task_insert_send_right (cmd->task, (ipc_port_t)port); + *name = task_insert_send_right (cmd->task, + ipc_port_make_send((ipc_port_t) port)); return 0; } -- cgit v1.2.3 From dfcdc049242c9ceb75fe82c16a20149244d8abd6 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Tue, 30 Sep 2014 09:08:55 +0200 Subject: kern: fix type of recompute_priorities * kern/sched_prim.c (recompute_priorities): Fix type. * kern/sched_prim.h (recompute_priorities): Likewise. --- kern/sched_prim.c | 2 +- kern/sched_prim.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kern/sched_prim.c b/kern/sched_prim.c index 1d2e14e5..66eb9c95 100644 --- a/kern/sched_prim.c +++ b/kern/sched_prim.c @@ -1076,7 +1076,7 @@ void compute_my_priority( * * Update the priorities of all threads periodically. */ -void recompute_priorities(const void *param) +void recompute_priorities(void *param) { #if SIMPLE_CLOCK int new_usec; diff --git a/kern/sched_prim.h b/kern/sched_prim.h index 8c62b8b1..fd989b6c 100644 --- a/kern/sched_prim.h +++ b/kern/sched_prim.h @@ -103,7 +103,7 @@ extern boolean_t thread_handoff( thread_t old_thread, continuation_t continuation, thread_t new_thread); -extern void recompute_priorities(const void *param); +extern void recompute_priorities(void *param); extern void update_priority( thread_t thread); extern void compute_my_priority( -- cgit v1.2.3 From 3166fe0edd4a5cf0d690c094f2fd06647ba380e5 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Tue, 30 Sep 2014 09:02:25 +0200 Subject: kern: silence compiler warning about uninitialized variable * kern/slab.c (kmem_cache_compute_sizes): Initialize optimal_size and assert that a size is selected. --- kern/slab.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kern/slab.c b/kern/slab.c index e8451a8a..19ebfedb 100644 --- a/kern/slab.c +++ b/kern/slab.c @@ -702,7 +702,7 @@ static void kmem_cache_error(struct kmem_cache *cache, void *buf, int error, */ static void kmem_cache_compute_sizes(struct kmem_cache *cache, int flags) { - size_t i, buffers, buf_size, slab_size, free_slab_size, optimal_size; + size_t i, buffers, buf_size, slab_size, free_slab_size, optimal_size = 0; size_t waste, waste_min; int embed, optimal_embed = 0; @@ -745,6 +745,7 @@ static void kmem_cache_compute_sizes(struct kmem_cache *cache, int flags) } while ((buffers < KMEM_MIN_BUFS_PER_SLAB) && (slab_size < KMEM_SLAB_SIZE_THRESHOLD)); + assert(optimal_size > 0); assert(!(flags & KMEM_CACHE_NOOFFSLAB) || optimal_embed); cache->slab_size = optimal_size; -- cgit v1.2.3 From 3a0fae39873c9c7d73dc978888e45b87ad27d44e Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Tue, 30 Sep 2014 03:58:43 +0200 Subject: ipc: use fast modulo operation in local hash table * ipc/ipc_table.h: Document that table sizes must be powers of two. * ipc/ipc_hash.c (IH_LOCAL_HASH): Use fast modulo operation. --- ipc/ipc_hash.c | 2 +- ipc/ipc_table.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ipc/ipc_hash.c b/ipc/ipc_hash.c index 8285717c..c2c6d6ef 100644 --- a/ipc/ipc_hash.c +++ b/ipc/ipc_hash.c @@ -326,7 +326,7 @@ ipc_hash_global_delete( */ #define IH_LOCAL_HASH(obj, size) \ - ((((mach_port_index_t) (vm_offset_t) (obj)) >> 6) % (size)) + ((((mach_port_index_t) (vm_offset_t) (obj)) >> 6) & (size - 1)) /* * Routine: ipc_hash_local_lookup diff --git a/ipc/ipc_table.h b/ipc/ipc_table.h index 3cc5f561..311b9a78 100644 --- a/ipc/ipc_table.h +++ b/ipc/ipc_table.h @@ -45,6 +45,8 @@ * an ipc_table_size structure. These structures must * be elements of an array, ipc_table_entries. * + * Every its_size value must must be a power of two. + * * The array must end with two elements with the same its_size value. * Except for the terminating element, the its_size values must * be strictly increasing. The largest (last) its_size value -- cgit v1.2.3 From d565bf2f784ce1203e77306d05eade03933bc523 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Thu, 21 Nov 2013 16:50:49 +0100 Subject: ipc: add protected payload Add a field ip_protected_payload and a flag ip_has_protected_payload to struct ipc_port. Clear the protected payload when a receive port is moved from one ipc space to another. This is done to retain the old behavior of mach_msg, so that a port name is sent in the msgh_local_port field. If the new owner of that receive right wishes to use the protected payload mechanism, it has to be explicitly set again. * ipc/ipc_port.h (struct ipc_port): Add field ip_protected_payload. (ipc_port_set_protected_payload): Add function declaration. (ipc_port_clear_protected_payload): Likewise. (ipc_port_flag_protected_payload): Add accessor for the protected payload flag. (ipc_port_flag_protected_payload_set): Likewise. (ipc_port_flag_protected_payload_clear): Likewise. * ipc/ipc_port.c (ipc_port_init): Initialize protected payload. (ipc_port_print): Print protected_payload. (ipc_port_set_protected_payload): New function. (ipc_port_clear_protected_payload): Likewise. (ipc_port_destroy): Clear the payload when moving a receive port. * ipc/ipc_right.c (ipc_right_copyin): Likewise. (ipc_right_copyout): Likewise. * ipc/ipc_object.c (ipc_object_copyin_from_kernel): Likewise. * ipc/ipc_object.h (IO_BITS_PROTECTED_PAYLOAD): New bitmask. (IO_BITS_OTYPE): Adjust accordingly. --- ipc/ipc_object.c | 1 + ipc/ipc_object.h | 4 +++- ipc/ipc_port.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ ipc/ipc_port.h | 27 +++++++++++++++++++++++++++ ipc/ipc_right.c | 12 ++++++++++++ 5 files changed, 91 insertions(+), 1 deletion(-) diff --git a/ipc/ipc_object.c b/ipc/ipc_object.c index 982bd4e1..db6ef018 100644 --- a/ipc/ipc_object.c +++ b/ipc/ipc_object.c @@ -481,6 +481,7 @@ ipc_object_copyin_from_kernel( port->ip_receiver_name = MACH_PORT_NULL; port->ip_destination = IP_NULL; + ipc_port_flag_protected_payload_clear(port); ip_unlock(port); break; } diff --git a/ipc/ipc_object.h b/ipc/ipc_object.h index adf5bca4..b83bb5a6 100644 --- a/ipc/ipc_object.h +++ b/ipc/ipc_object.h @@ -57,7 +57,9 @@ typedef struct ipc_object { #define IO_VALID(io) (((io) != IO_NULL) && ((io) != IO_DEAD)) #define IO_BITS_KOTYPE 0x0000ffff /* used by the object */ -#define IO_BITS_OTYPE 0x7fff0000 /* determines a cache */ +#define IO_BITS_OTYPE 0x3fff0000 /* determines a cache */ +/* The following masks are used to store attributes of ipc ports. */ +#define IO_BITS_PROTECTED_PAYLOAD 0x40000000 /* pp set? */ #define IO_BITS_ACTIVE 0x80000000U /* is object alive? */ #define io_active(io) ((int)(io)->io_bits < 0) /* hack */ diff --git a/ipc/ipc_port.c b/ipc/ipc_port.c index 78211e64..89a5d673 100644 --- a/ipc/ipc_port.c +++ b/ipc/ipc_port.c @@ -422,6 +422,44 @@ ipc_port_set_seqno( imq_unlock(mqueue); } +/* + * Routine: ipc_port_set_protected_payload + * Purpose: + * Changes a port's protected payload. + * Conditions: + * The port is locked and active. + */ + +void +ipc_port_set_protected_payload(ipc_port_t port, unsigned long payload) +{ + ipc_mqueue_t mqueue; + + mqueue = ipc_port_lock_mqueue(port); + port->ip_protected_payload = payload; + ipc_port_flag_protected_payload_set(port); + imq_unlock(mqueue); +} + +/* + * Routine: ipc_port_clear_protected_payload + * Purpose: + * Clear a port's protected payload. + * Conditions: + * The port is locked and active. + */ + +void +ipc_port_clear_protected_payload(ipc_port_t port) +{ + ipc_mqueue_t mqueue; + + mqueue = ipc_port_lock_mqueue(port); + ipc_port_flag_protected_payload_clear(port); + imq_unlock(mqueue); +} + + /* * Routine: ipc_port_clear_receiver * Purpose: @@ -491,6 +529,8 @@ ipc_port_init( port->ip_seqno = 0; port->ip_msgcount = 0; port->ip_qlimit = MACH_PORT_QLIMIT_DEFAULT; + ipc_port_flag_protected_payload_clear(port); + port->ip_protected_payload = 0; ipc_mqueue_init(&port->ip_messages); ipc_thread_queue_init(&port->ip_blocked); @@ -613,6 +653,7 @@ ipc_port_destroy( /* make port be in limbo */ port->ip_receiver_name = MACH_PORT_NULL; port->ip_destination = IP_NULL; + ipc_port_flag_protected_payload_clear(port); ip_unlock(port); if (!ipc_port_check_circularity(port, pdrequest)) { @@ -1215,6 +1256,11 @@ ipc_port_print(port) indent += 2; + iprintf("flags "); + printf("has_protected_payload=%d", + ipc_port_flag_protected_payload(port)); + printf("\n"); + ipc_object_print(&port->ip_object); iprintf("receiver=0x%x", port->ip_receiver); printf(", receiver_name=0x%x\n", port->ip_receiver_name); @@ -1237,6 +1283,8 @@ ipc_port_print(port) printf(", sndrs=0x%x", port->ip_blocked.ithq_base); printf(", kobj=0x%x\n", port->ip_kobject); + iprintf("protected_payload=%p\n", (void *) port->ip_protected_payload); + indent -= 2; } diff --git a/ipc/ipc_port.h b/ipc/ipc_port.h index 27d2e496..125fefc0 100644 --- a/ipc/ipc_port.h +++ b/ipc/ipc_port.h @@ -48,6 +48,7 @@ #include #include #include +#include #include "ipc_target.h" #include @@ -96,6 +97,7 @@ struct ipc_port { mach_port_msgcount_t ip_msgcount; mach_port_msgcount_t ip_qlimit; struct ipc_thread_queue ip_blocked; + unsigned long ip_protected_payload; }; #define ip_object ip_target.ipt_object @@ -261,6 +263,12 @@ ipc_port_lock_mqueue(ipc_port_t); extern void ipc_port_set_seqno(ipc_port_t, mach_port_seqno_t); +extern void +ipc_port_set_protected_payload(ipc_port_t, unsigned long); + +extern void +ipc_port_clear_protected_payload(ipc_port_t); + extern void ipc_port_clear_receiver(ipc_port_t); @@ -325,4 +333,23 @@ ipc_port_dealloc_special(ipc_port_t, ipc_space_t); #define ipc_port_release(port) \ ipc_object_release(&(port)->ip_object) +extern inline boolean_t +ipc_port_flag_protected_payload(const struct ipc_port *port) +{ + return !! (port->ip_target.ipt_object.io_bits + & IO_BITS_PROTECTED_PAYLOAD); +} + +extern inline void +ipc_port_flag_protected_payload_set(struct ipc_port *port) +{ + port->ip_target.ipt_object.io_bits |= IO_BITS_PROTECTED_PAYLOAD; +} + +extern inline void +ipc_port_flag_protected_payload_clear(struct ipc_port *port) +{ + port->ip_target.ipt_object.io_bits &= ~IO_BITS_PROTECTED_PAYLOAD; +} + #endif /* _IPC_IPC_PORT_H_ */ diff --git a/ipc/ipc_right.c b/ipc/ipc_right.c index 77a68cec..503eb1fc 100644 --- a/ipc/ipc_right.c +++ b/ipc/ipc_right.c @@ -1432,6 +1432,12 @@ ipc_right_copyin( port->ip_receiver_name = MACH_PORT_NULL; port->ip_destination = IP_NULL; + + /* + * Clear the protected payload field to retain + * the behavior of mach_msg. + */ + ipc_port_flag_protected_payload_clear(port); ip_unlock(port); *objectp = (ipc_object_t) port; @@ -1932,6 +1938,12 @@ ipc_right_copyout( port->ip_receiver_name = name; port->ip_receiver = space; + /* + * Clear the protected payload field to retain + * the behavior of mach_msg. + */ + ipc_port_flag_protected_payload_clear(port); + assert((bits & MACH_PORT_TYPE_RECEIVE) == 0); if (bits & MACH_PORT_TYPE_SEND) { -- cgit v1.2.3 From c4baf67b71e20d1fdd2cc6bda1a2ea15e9853cdd Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Thu, 21 Nov 2013 17:23:31 +0100 Subject: ipc: implement mach_port_{set,clear}_protected_payload * include/mach/mach_port.defs: Add mach_port_{set,clear}_protected_payload. * ipc/mach_port.c: Implement mach_port_{set,clear}_protected_payload. * doc/mach.texi (Receive Rights): Document mach_port_{set,clear}_protected_payload. --- doc/mach.texi | 35 ++++++++++++++++++++++ include/mach/mach_port.defs | 18 +++++++++++ ipc/mach_port.c | 73 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 126 insertions(+) diff --git a/doc/mach.texi b/doc/mach.texi index 2da670f7..3175df18 100644 --- a/doc/mach.texi +++ b/doc/mach.texi @@ -2715,6 +2715,41 @@ In addition to the normal diagnostic return codes from the call's server (normally the kernel), the call may return @code{mach_msg} return codes. @end deftypefun +@deftypefun kern_return_t mach_port_set_protected_payload (@w{ipc_space_t @var{task}}, @w{mach_port_t @var{name}}, @w{unsigned long @var{payload}}) +The function @code{mach_port_set_protected_payload} sets the protected +payload associated with the right @var{name} to @var{payload}. +Section @ref{Message Receive} describes how setting a protected +payload affects the messages delivered to @var{name}. + +The function returns @code{KERN_SUCCESS} if the call succeeded, +@code{KERN_INVALID_TASK} if @var{task} was invalid, +@code{KERN_INVALID_NAME} if @var{name} did not denote a right and +@code{KERN_INVALID_RIGHT} if @var{name} denoted a right, but not a +receive right. + +The @code{mach_port_set_protected_payload} call is actually an RPC to +@var{task}, normally a send right for a task port, but potentially any +send right. In addition to the normal diagnostic return codes from +the call's server (normally the kernel), the call may return +@code{mach_msg} return codes. +@end deftypefun + +@deftypefun kern_return_t mach_port_clear_protected_payload (@w{ipc_space_t @var{task}}, @w{mach_port_t @var{name}}, @w{unsigned long @var{payload}}) +The function @code{mach_port_clear_protected_payload} clears the +protected payload associated with the right @var{name}. + +The function returns @code{KERN_SUCCESS} if the call succeeded, +@code{KERN_INVALID_TASK} if @var{task} was invalid, +@code{KERN_INVALID_NAME} if @var{name} did not denote a right and +@code{KERN_INVALID_RIGHT} if @var{name} denoted a right, but not a +receive right. + +The @code{mach_port_clear_protected_payload} call is actually an RPC +to @var{task}, normally a send right for a task port, but potentially +any send right. In addition to the normal diagnostic return codes +from the call's server (normally the kernel), the call may return +@code{mach_msg} return codes. +@end deftypefun @node Port Sets @subsection Port Sets diff --git a/include/mach/mach_port.defs b/include/mach/mach_port.defs index 769d8926..c7e8526a 100644 --- a/include/mach/mach_port.defs +++ b/include/mach/mach_port.defs @@ -349,3 +349,21 @@ skip; /* mach_port_create_act */ #endif /* MIGRATING_THREADS */ +/* + * Only valid for receive rights. + * Set the protected payload for this right to the given value. + */ + +routine mach_port_set_protected_payload( + task : ipc_space_t; + name : mach_port_name_t; + payload : natural_t); + +/* + * Only valid for receive rights. + * Clear the protected payload for this right. + */ + +routine mach_port_clear_protected_payload( + task : ipc_space_t; + name : mach_port_name_t); diff --git a/ipc/mach_port.c b/ipc/mach_port.c index 4a4efcc5..4ff39f2c 100644 --- a/ipc/mach_port.c +++ b/ipc/mach_port.c @@ -1564,3 +1564,76 @@ mach_port_set_syscall_right( } #endif #endif /* MIGRATING_THREADS */ + +/* + * Routine: mach_port_set_protected_payload [kernel call] + * Purpose: + * Changes a receive right's protected payload. + * Conditions: + * Nothing locked. + * Returns: + * KERN_SUCCESS Set protected payload. + * KERN_INVALID_TASK The space is null. + * KERN_INVALID_TASK The space is dead. + * KERN_INVALID_NAME The name doesn't denote a right. + * KERN_INVALID_RIGHT Name doesn't denote receive rights. + */ + +kern_return_t +mach_port_set_protected_payload( + ipc_space_t space, + mach_port_t name, + unsigned long payload) +{ + ipc_port_t port; + kern_return_t kr; + + if (space == IS_NULL) + return KERN_INVALID_TASK; + + kr = ipc_port_translate_receive(space, name, &port); + if (kr != KERN_SUCCESS) + return kr; + /* port is locked and active */ + + ipc_port_set_protected_payload(port, payload); + + ip_unlock(port); + return KERN_SUCCESS; +} + +/* + * Routine: mach_port_clear_protected_payload [kernel call] + * Purpose: + * Clears a receive right's protected payload. + * Conditions: + * Nothing locked. + * Returns: + * KERN_SUCCESS Clear protected payload. + * KERN_INVALID_TASK The space is null. + * KERN_INVALID_TASK The space is dead. + * KERN_INVALID_NAME The name doesn't denote a right. + * KERN_INVALID_RIGHT Name doesn't denote receive rights. + */ + +kern_return_t +mach_port_clear_protected_payload( + ipc_space_t space, + mach_port_t name) +{ + ipc_port_t port; + kern_return_t kr; + + if (space == IS_NULL) + return KERN_INVALID_TASK; + + kr = ipc_port_translate_receive(space, name, &port); + if (kr != KERN_SUCCESS) + return kr; + /* port is locked and active */ + + ipc_port_clear_protected_payload(port); + + ip_unlock(port); + return KERN_SUCCESS; +} -- cgit v1.2.3 From 56dc414b0699d1576fc1deb983a4bd2b0ef10f5d Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Fri, 22 Nov 2013 10:04:07 +0100 Subject: include: add msgh_protected_payload to mach_msg_header_t * include/mach/message.h (mach_msg_header_t): Add msgh_protected_payload as a union with msgh_local_port. * doc/mach.texi (Message Format): Document msgh_protected_payload. --- doc/mach.texi | 9 +++++++++ include/mach/message.h | 5 ++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/doc/mach.texi b/doc/mach.texi index 3175df18..671e0d00 100644 --- a/doc/mach.texi +++ b/doc/mach.texi @@ -1330,6 +1330,15 @@ which is conventionally used as a reply port by the recipient of the message. The field must carry a send right, a send-once right, @code{MACH_PORT_NULL}, or @code{MACH_PORT_DEAD}. +@item unsigned long msgh_protected_payload +The @code{msgh_protected_payload} field carries a payload that is set +by the kernel during message delivery. The payload is an opaque +identifier that can be used by the receiver to lookup the associated +data structure. + +It is only valid in received messages. See @ref{Message Receive} for +further information. + @item mach_port_seqno_t msgh_seqno The @code{msgh_seqno} field provides a sequence number for the message. It is only valid in received messages; its value in sent messages is diff --git a/include/mach/message.h b/include/mach/message.h index f78e9780..7464a579 100644 --- a/include/mach/message.h +++ b/include/mach/message.h @@ -136,7 +136,10 @@ typedef struct { mach_msg_bits_t msgh_bits; mach_msg_size_t msgh_size; mach_port_t msgh_remote_port; - mach_port_t msgh_local_port; + union { + mach_port_t msgh_local_port; + unsigned long msgh_protected_payload; + }; mach_port_seqno_t msgh_seqno; mach_msg_id_t msgh_id; } mach_msg_header_t; -- cgit v1.2.3 From a8d611bdbf48906010c6cde67eb6ff720e715cf0 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Mon, 25 Nov 2013 01:27:14 +0100 Subject: include: define MACH_MSG_TYPE_PROTECTED_PAYLOAD * include/mach/message.h: Define MACH_MSG_TYPE_PROTECTED_PAYLOAD. (MACH_MSG_TYPE_LAST): Adjust accordingly. * doc/mach.texi (Message Format): Document MACH_MSG_TYPE_PROTECTED_PAYLOAD. --- doc/mach.texi | 6 ++++++ include/mach/message.h | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/doc/mach.texi b/doc/mach.texi index 671e0d00..b1878887 100644 --- a/doc/mach.texi +++ b/doc/mach.texi @@ -1426,6 +1426,7 @@ types are predefined: @item MACH_MSG_TYPE_STRING @item MACH_MSG_TYPE_STRING_C @item MACH_MSG_TYPE_PORT_NAME +@item MACH_MSG_TYPE_PROTECTED_PAYLOAD @end table The following predefined types specify port rights, and receive special @@ -1444,6 +1445,11 @@ should be used in preference to @code{MACH_MSG_TYPE_INTEGER_32}. @item MACH_MSG_TYPE_MAKE_SEND_ONCE @end table +The type @code{MACH_MSG_TYPE_PROTECTED_PAYLOAD} is used by the kernel +to indicate that a delivered message carries a payload in the +@code{msgh_protected_payload} field. See @ref{Message Receive} for +more information. + @item msgt_size : 8 The @code{msgt_size} field specifies the size of each datum, in bits. For example, the msgt_size of @code{MACH_MSG_TYPE_INTEGER_32} data is 32. diff --git a/include/mach/message.h b/include/mach/message.h index 7464a579..0a7297e1 100644 --- a/include/mach/message.h +++ b/include/mach/message.h @@ -256,7 +256,9 @@ typedef struct { #define MACH_MSG_TYPE_PORT_SEND MACH_MSG_TYPE_MOVE_SEND #define MACH_MSG_TYPE_PORT_SEND_ONCE MACH_MSG_TYPE_MOVE_SEND_ONCE -#define MACH_MSG_TYPE_LAST 22 /* Last assigned */ +#define MACH_MSG_TYPE_PROTECTED_PAYLOAD 23 + +#define MACH_MSG_TYPE_LAST 23 /* Last assigned */ /* * A dummy value. Mostly used to indicate that the actual value -- cgit v1.2.3 From 6b0ceb8aec7dc2d607523d7aadc2fec237ce2ca8 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Fri, 22 Nov 2013 16:03:52 +0100 Subject: ipc: provide the protected payload in ipc_kmsg_copyout_header * ipc/ipc_kmsg.c (ipc_kmsg_copyout_header): If a protected payload is set for the destination port, provide it in msgh_protected_payload. * ipc/mach_msg.c (mach_msg_trap): Likewise in the fast paths. * doc/mach.texi (Message Receive): Document message semantics with protected payloads. --- doc/mach.texi | 19 +++++++++++++++++++ ipc/ipc_kmsg.c | 58 +++++++++++++++++++++++++++++++++++++++++++++------------- ipc/mach_msg.c | 53 ++++++++++++++++++++++++++++++++++++++++------------- 3 files changed, 104 insertions(+), 26 deletions(-) diff --git a/doc/mach.texi b/doc/mach.texi index b1878887..c57e6078 100644 --- a/doc/mach.texi +++ b/doc/mach.texi @@ -1949,6 +1949,25 @@ loses the receive right after the message was dequeued from it, then right still exists, but isn't held by the caller, then @code{msgh_local_port} specifies @code{MACH_PORT_NULL}. +Servers usually associate some state with a receive right. To that +end, they might use a hash table to look up the state for the port a +message was sent to. To optimize this, a task may associate an opaque +@var{payload} with a receive right using the +@code{mach_port_set_protected_payload} function. Once this is done, +the kernel will set the @code{msgh_protected_payload} field to +@var{payload} when delivering a message to this right and indicate +this by setting the local part of @code{msgh_bits} to +@code{MACH_MSG_TYPE_PROTECTED_PAYLOAD}. + +The support for protected payloads was added to GNU Mach. To preserve +binary compatibility, the @code{msgh_local_port} and +@code{msgh_local_port} share the same location. This makes it +possible to add the payload information without increasing the size of +@code{mach_msg_header_t}. This is an implementation detail. Which +field is valid is determined by the local part of the +@code{msgh_bits}. Existing software is not affected. When a receive +right is transferred to another task, its payload is cleared. + Received messages are stamped with a sequence number, taken from the port from which the message was received. (Messages received from a port set are stamped with a sequence number from the appropriate member diff --git a/ipc/ipc_kmsg.c b/ipc/ipc_kmsg.c index 06cec726..71a0d74a 100644 --- a/ipc/ipc_kmsg.c +++ b/ipc/ipc_kmsg.c @@ -1799,9 +1799,17 @@ ipc_kmsg_copyout_header( } else ip_unlock(dest); - msg->msgh_bits = (MACH_MSGH_BITS_OTHER(mbits) | - MACH_MSGH_BITS(0, MACH_MSG_TYPE_PORT_SEND)); - msg->msgh_local_port = dest_name; + if (! ipc_port_flag_protected_payload(dest)) { + msg->msgh_bits = (MACH_MSGH_BITS_OTHER(mbits) | + MACH_MSGH_BITS(0, MACH_MSG_TYPE_PORT_SEND)); + msg->msgh_local_port = dest_name; + } else { + msg->msgh_bits = (MACH_MSGH_BITS_OTHER(mbits) | + MACH_MSGH_BITS( + 0, MACH_MSG_TYPE_PROTECTED_PAYLOAD)); + msg->msgh_protected_payload = + dest->ip_protected_payload; + } msg->msgh_remote_port = MACH_PORT_NULL; return MACH_MSG_SUCCESS; } @@ -1897,10 +1905,18 @@ ipc_kmsg_copyout_header( } else ip_unlock(dest); - msg->msgh_bits = (MACH_MSGH_BITS_OTHER(mbits) | - MACH_MSGH_BITS(MACH_MSG_TYPE_PORT_SEND_ONCE, - MACH_MSG_TYPE_PORT_SEND)); - msg->msgh_local_port = dest_name; + if (! ipc_port_flag_protected_payload(dest)) { + msg->msgh_bits = (MACH_MSGH_BITS_OTHER(mbits) | + MACH_MSGH_BITS(MACH_MSG_TYPE_PORT_SEND_ONCE, + MACH_MSG_TYPE_PORT_SEND)); + msg->msgh_local_port = dest_name; + } else { + msg->msgh_bits = (MACH_MSGH_BITS_OTHER(mbits) | + MACH_MSGH_BITS(MACH_MSG_TYPE_PORT_SEND_ONCE, + MACH_MSG_TYPE_PROTECTED_PAYLOAD)); + msg->msgh_protected_payload = + dest->ip_protected_payload; + } msg->msgh_remote_port = reply_name; return MACH_MSG_SUCCESS; } @@ -1932,9 +1948,18 @@ ipc_kmsg_copyout_header( dest_name = MACH_PORT_NULL; } - msg->msgh_bits = (MACH_MSGH_BITS_OTHER(mbits) | - MACH_MSGH_BITS(0, MACH_MSG_TYPE_PORT_SEND_ONCE)); - msg->msgh_local_port = dest_name; + if (! ipc_port_flag_protected_payload(dest)) { + msg->msgh_bits = (MACH_MSGH_BITS_OTHER(mbits) | + MACH_MSGH_BITS(0, + MACH_MSG_TYPE_PORT_SEND_ONCE)); + msg->msgh_local_port = dest_name; + } else { + msg->msgh_bits = (MACH_MSGH_BITS_OTHER(mbits) | + MACH_MSGH_BITS(0, + MACH_MSG_TYPE_PROTECTED_PAYLOAD)); + msg->msgh_protected_payload = + dest->ip_protected_payload; + } msg->msgh_remote_port = MACH_PORT_NULL; return MACH_MSG_SUCCESS; } @@ -2224,9 +2249,16 @@ ipc_kmsg_copyout_header( if (IP_VALID(reply)) ipc_port_release(reply); - msg->msgh_bits = (MACH_MSGH_BITS_OTHER(mbits) | - MACH_MSGH_BITS(reply_type, dest_type)); - msg->msgh_local_port = dest_name; + if (! ipc_port_flag_protected_payload(dest)) { + msg->msgh_bits = (MACH_MSGH_BITS_OTHER(mbits) | + MACH_MSGH_BITS(reply_type, dest_type)); + msg->msgh_local_port = dest_name; + } else { + msg->msgh_bits = (MACH_MSGH_BITS_OTHER(mbits) | + MACH_MSGH_BITS(reply_type, + MACH_MSG_TYPE_PROTECTED_PAYLOAD)); + msg->msgh_protected_payload = dest->ip_protected_payload; + } msg->msgh_remote_port = reply_name; } diff --git a/ipc/mach_msg.c b/ipc/mach_msg.c index 01d974b5..1e122c76 100644 --- a/ipc/mach_msg.c +++ b/ipc/mach_msg.c @@ -1132,11 +1132,19 @@ mach_msg_trap( } else ip_unlock(dest_port); - kmsg->ikm_header.msgh_bits = - MACH_MSGH_BITS(MACH_MSG_TYPE_PORT_SEND_ONCE, - MACH_MSG_TYPE_PORT_SEND); + if (! ipc_port_flag_protected_payload(dest_port)) { + kmsg->ikm_header.msgh_bits = MACH_MSGH_BITS( + MACH_MSG_TYPE_PORT_SEND_ONCE, + MACH_MSG_TYPE_PORT_SEND); + kmsg->ikm_header.msgh_local_port = dest_name; + } else { + kmsg->ikm_header.msgh_bits = MACH_MSGH_BITS( + MACH_MSG_TYPE_PORT_SEND_ONCE, + MACH_MSG_TYPE_PROTECTED_PAYLOAD); + kmsg->ikm_header.msgh_protected_payload = + dest_port->ip_protected_payload; + } kmsg->ikm_header.msgh_remote_port = reply_name; - kmsg->ikm_header.msgh_local_port = dest_name; goto fast_put; abort_request_copyout: @@ -1170,11 +1178,19 @@ mach_msg_trap( dest_name = MACH_PORT_NULL; } - kmsg->ikm_header.msgh_bits = - MACH_MSGH_BITS(0, - MACH_MSG_TYPE_PORT_SEND_ONCE); + if (! ipc_port_flag_protected_payload(dest_port)) { + kmsg->ikm_header.msgh_bits = MACH_MSGH_BITS( + 0, + MACH_MSG_TYPE_PORT_SEND_ONCE); + kmsg->ikm_header.msgh_local_port = dest_name; + } else { + kmsg->ikm_header.msgh_bits = MACH_MSGH_BITS( + 0, + MACH_MSG_TYPE_PROTECTED_PAYLOAD); + kmsg->ikm_header.msgh_protected_payload = + dest_port->ip_protected_payload; + } kmsg->ikm_header.msgh_remote_port = MACH_PORT_NULL; - kmsg->ikm_header.msgh_local_port = dest_name; goto fast_put; } @@ -1204,12 +1220,23 @@ mach_msg_trap( dest_name = MACH_PORT_NULL; } - kmsg->ikm_header.msgh_bits = - MACH_MSGH_BITS_COMPLEX | - MACH_MSGH_BITS(0, - MACH_MSG_TYPE_PORT_SEND_ONCE); + if (! ipc_port_flag_protected_payload(dest_port)) { + kmsg->ikm_header.msgh_bits = + MACH_MSGH_BITS_COMPLEX + | MACH_MSGH_BITS( + 0, + MACH_MSG_TYPE_PORT_SEND_ONCE); + kmsg->ikm_header.msgh_local_port = dest_name; + } else { + kmsg->ikm_header.msgh_bits = + MACH_MSGH_BITS_COMPLEX + | MACH_MSGH_BITS( + 0, + MACH_MSG_TYPE_PROTECTED_PAYLOAD); + kmsg->ikm_header.msgh_protected_payload = + dest_port->ip_protected_payload; + } kmsg->ikm_header.msgh_remote_port = MACH_PORT_NULL; - kmsg->ikm_header.msgh_local_port = dest_name; mr = ipc_kmsg_copyout_body( (vm_offset_t) (&kmsg->ikm_header + 1), -- cgit v1.2.3 From da5dea9b6f960603f0c02b42b5cc8384194faa5b Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Wed, 1 Oct 2014 15:56:40 +0200 Subject: Add protected payloads to NEWS --- NEWS | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NEWS b/NEWS index 9a9f620c..357b23f9 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,10 @@ Numerous cleanups and stylistic fixes of the code base. Several problems have been identified using static analysis tools and subsequently been fixed. +A protected payload can now be associated with capabilities. This +payload is attached by the kernel to delivered messages and can be +used to speed up the object lookup in the receiving task. + The kernel debugger can now parse ELF symbol tables, can be invoked over serial lines, gained two new commands and has received usability improvements. -- cgit v1.2.3 From ad0681db8840484c0a18bb69f4a9072d6e405ccd Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Mon, 26 May 2014 00:02:50 +0200 Subject: doc: restore section `Inherited Ports' Previously, the section `Inherited Ports' was commented out. This was done, as the functionality was unused by the Hurd. The functions `mach_ports_register' and `mach_ports_lookup' were never removed, and are exposed to user space. This patch brings the documentation back and adds a remark at the top, that the section documents the original intentions for this interface. I chose bringing back the documentation over removing the functionality because I like to make use of it as a method for service discovery that is deliberately orthogonal to the way the service lookup is usually done in the Hurd. This can be used to implement robust low-level debugging facilities. * doc/mach.texi: Restore section `Inherited Ports'. --- doc/mach.texi | 127 ++++++++++++++++++++++++++++++---------------------------- 1 file changed, 65 insertions(+), 62 deletions(-) diff --git a/doc/mach.texi b/doc/mach.texi index c57e6078..4cde9fe2 100644 --- a/doc/mach.texi +++ b/doc/mach.texi @@ -193,7 +193,7 @@ Port Manipulation Interface * Receive Rights:: How to work with receive rights. * Port Sets:: How to work with port sets. * Request Notifications:: How to request notifications for events. -@c * Inherited Ports:: How to work with the inherited system ports. +* Inherited Ports:: How to work with the inherited system ports. Virtual Memory Interface @@ -2198,7 +2198,7 @@ the kernel. * Receive Rights:: How to work with receive rights. * Port Sets:: How to work with port sets. * Request Notifications:: How to request notifications for events. -@c * Inherited Ports:: How to work with the inherited system ports. +* Inherited Ports:: How to work with the inherited system ports. @end menu @@ -2917,66 +2917,69 @@ call's server (normally the kernel), the call may return @code{mach_msg} return codes. @end deftypefun -@c The inherited ports concept is not used in the Hurd, -@c and so the _SLOT macros are not defined in GNU Mach. - -@c @node Inherited Ports -@c @subsection Inherited Ports - -@c @deftypefun kern_return_t mach_ports_register (@w{task_t @var{target_task}, @w{port_array_t @var{init_port_set}}, @w{int @var{init_port_array_count}}) -@c @deftypefunx kern_return_t mach_ports_lookup (@w{task_t @var{target_task}, @w{port_array_t *@var{init_port_set}}, @w{int *@var{init_port_array_count}}) -@c @code{mach_ports_register} manipulates the inherited ports array, -@c @code{mach_ports_lookup} is used to acquire specific parent ports. -@c @var{target_task} is the task to be affected. @var{init_port_set} is an -@c array of system ports to be registered, or returned. Although the array -@c size is given as variable, the kernel will only accept a limited number -@c of ports. @var{init_port_array_count} is the number of ports returned -@c in @var{init_port_set}. - -@c @code{mach_ports_register} registers an array of well-known system ports -@c with the kernel on behalf of a specific task. Currently the ports to be -@c registered are: the port to the Network Name Server, the port to the -@c Environment Manager, and a port to the Service server. These port -@c values must be placed in specific slots in the init_port_set. The slot -@c numbers are given by the global constants defined in @file{mach_init.h}: -@c @code{NAME_SERVER_SLOT}, @code{ENVIRONMENT_SLOT}, and -@c @code{SERVICE_SLOT}. These ports may later be retrieved with -@c @code{mach_ports_lookup}. - -@c When a new task is created (see @code{task_create}), the child task will -@c be given access to these ports. Only port send rights may be -@c registered. Furthermore, the number of ports which may be registered is -@c fixed and given by the global constant @code{MACH_PORT_SLOTS_USED} -@c Attempts to register too many ports will fail. - -@c It is intended that this mechanism be used only for task initialization, -@c and then only by runtime support modules. A parent task has three -@c choices in passing these system ports to a child task. Most commonly it -@c can do nothing and its child will inherit access to the same -@c @var{init_port_set} that the parent has; or a parent task may register a -@c set of ports it wishes to have passed to all of its children by calling -@c @code{mach_ports_register} using its task port; or it may make necessary -@c modifications to the set of ports it wishes its child to see, and then -@c register those ports using the child's task port prior to starting the -@c child's thread(s). The @code{mach_ports_lookup} call which is done by -@c @code{mach_init} in the child task will acquire these initial ports for -@c the child. - -@c Tasks other than the Network Name Server and the Environment Manager -@c should not need access to the Service port. The Network Name Server port -@c is the same for all tasks on a given machine. The Environment port is -@c the only port likely to have different values for different tasks. - -@c Since the number of ports which may be registered is limited, ports -@c other than those used by the runtime system to initialize a task should -@c be passed to children either through an initial message, or through the -@c Network Name Server for public ports, or the Environment Manager for -@c private ports. - -@c The function returns @code{KERN_SUCCESS} if the memory was allocated, -@c and @code{KERN_INVALID_ARGUMENT} if an attempt was made to register more -@c ports than the current kernel implementation allows. -@c @end deftypefun +@node Inherited Ports +@subsection Inherited Ports + +The inherited ports concept is not used in the Hurd, and so the _SLOT +macros are not defined in GNU Mach. + +The following section documents how @code{mach_ports_register} and +@code{mach_ports_lookup} were originally intended to be used. + +@deftypefun kern_return_t mach_ports_register (@w{task_t @var{target_task}}, @w{port_array_t @var{init_port_set}}, @w{int @var{init_port_array_count}}) +@deftypefunx kern_return_t mach_ports_lookup (@w{task_t @var{target_task}}, @w{port_array_t *@var{init_port_set}}, @w{int *@var{init_port_array_count}}) +@code{mach_ports_register} manipulates the inherited ports array, +@code{mach_ports_lookup} is used to acquire specific parent ports. +@var{target_task} is the task to be affected. @var{init_port_set} is an +array of system ports to be registered, or returned. Although the array +size is given as variable, the kernel will only accept a limited number +of ports. @var{init_port_array_count} is the number of ports returned +in @var{init_port_set}. + +@code{mach_ports_register} registers an array of well-known system ports +with the kernel on behalf of a specific task. Currently the ports to be +registered are: the port to the Network Name Server, the port to the +Environment Manager, and a port to the Service server. These port +values must be placed in specific slots in the init_port_set. The slot +numbers are given by the global constants defined in @file{mach_init.h}: +@code{NAME_SERVER_SLOT}, @code{ENVIRONMENT_SLOT}, and +@code{SERVICE_SLOT}. These ports may later be retrieved with +@code{mach_ports_lookup}. + +When a new task is created (see @code{task_create}), the child task will +be given access to these ports. Only port send rights may be +registered. Furthermore, the number of ports which may be registered is +fixed and given by the global constant @code{MACH_PORT_SLOTS_USED} +Attempts to register too many ports will fail. + +It is intended that this mechanism be used only for task initialization, +and then only by runtime support modules. A parent task has three +choices in passing these system ports to a child task. Most commonly it +can do nothing and its child will inherit access to the same +@var{init_port_set} that the parent has; or a parent task may register a +set of ports it wishes to have passed to all of its children by calling +@code{mach_ports_register} using its task port; or it may make necessary +modifications to the set of ports it wishes its child to see, and then +register those ports using the child's task port prior to starting the +child's thread(s). The @code{mach_ports_lookup} call which is done by +@code{mach_init} in the child task will acquire these initial ports for +the child. + +Tasks other than the Network Name Server and the Environment Manager +should not need access to the Service port. The Network Name Server port +is the same for all tasks on a given machine. The Environment port is +the only port likely to have different values for different tasks. + +Since the number of ports which may be registered is limited, ports +other than those used by the runtime system to initialize a task should +be passed to children either through an initial message, or through the +Network Name Server for public ports, or the Environment Manager for +private ports. + +The function returns @code{KERN_SUCCESS} if the memory was allocated, +and @code{KERN_INVALID_ARGUMENT} if an attempt was made to register more +ports than the current kernel implementation allows. +@end deftypefun @node Virtual Memory Interface -- cgit v1.2.3 From f65ac79a27478f66da875f4a8ac87d1c7fbcc053 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Wed, 22 Oct 2014 01:46:39 +0200 Subject: Revert "Make sure mig is available" This reverts commit b28e05e203e0739fa5db59c5af378b29eea7a232. --- configure.ac | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/configure.ac b/configure.ac index bd8a1881..40e78a04 100644 --- a/configure.ac +++ b/configure.ac @@ -86,12 +86,7 @@ AC_CHECK_TOOL([AR], [ar]) AC_CHECK_TOOL([LD], [ld]) AC_CHECK_TOOL([NM], [nm]) -AC_CHECK_TOOL([MIG], [mig], [:]) - -if test "$MIG" = : -then - AC_MSG_ERROR([The MiG generator is required to build GNU Mach]) -fi +AC_CHECK_TOOL([MIG], [mig], [mig]) dnl Needed for the Automake option `subdir-objects'. AM_PROG_CC_C_O -- cgit v1.2.3 From 1435b7f7d41a21fa45641b6aca505623297fba4a Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 2 Nov 2014 18:36:24 +0100 Subject: Fix build when gcc avoids inlining * ipc/ipc_port.h (ipc_port_flag_protected_payload, ipc_port_flag_protected_payload_set, ipc_port_flag_protected_payload_clear): Use static inline qualifier instead of extern inline. --- ipc/ipc_port.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ipc/ipc_port.h b/ipc/ipc_port.h index 125fefc0..6914c717 100644 --- a/ipc/ipc_port.h +++ b/ipc/ipc_port.h @@ -333,20 +333,20 @@ ipc_port_dealloc_special(ipc_port_t, ipc_space_t); #define ipc_port_release(port) \ ipc_object_release(&(port)->ip_object) -extern inline boolean_t +static inline boolean_t ipc_port_flag_protected_payload(const struct ipc_port *port) { return !! (port->ip_target.ipt_object.io_bits & IO_BITS_PROTECTED_PAYLOAD); } -extern inline void +static inline void ipc_port_flag_protected_payload_set(struct ipc_port *port) { port->ip_target.ipt_object.io_bits |= IO_BITS_PROTECTED_PAYLOAD; } -extern inline void +static inline void ipc_port_flag_protected_payload_clear(struct ipc_port *port) { port->ip_target.ipt_object.io_bits &= ~IO_BITS_PROTECTED_PAYLOAD; -- cgit v1.2.3 From 65637ceb7f104ccc56809adee34f49afb7884e47 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Mon, 3 Nov 2014 01:27:36 +0100 Subject: Refuse to link against a libc with multiarch support We don't have support for this yet. * Makefile.am (clib-routines.o): Check for the presence of __init_cpu_features, and in such case refuse to continue. --- Makefile.am | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile.am b/Makefile.am index 918cdc39..d4c04bb4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -173,6 +173,9 @@ clib-routines.o: gnumach-undef gnumach-undef-bad then cat gnumach-undef-bad; exit 2; else true; fi $(AM_V_CCLD) $(CCLD) -nostdlib -nostartfiles -r -static \ -o $@ `sed 's/^/-Wl,-u,/' < $<` -x c /dev/null -lc -lgcc + $(AM_V_at) if nm $@ | grep __init_cpu_features; \ + then echo Please install a 32bit libc without multiarch support. ; \ + fi ; false gnumach_LINK = $(LD) $(LINKFLAGS) $(gnumach_LINKFLAGS) -o $@ gnumach_LDADD = gnumach.o clib-routines.o -- cgit v1.2.3 From fde14995f9f1a5af830b12be6cc4f9eb2a0cc7bf Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Mon, 3 Nov 2014 01:29:36 +0100 Subject: Fix link refusal * Makefile.am (clib-routines.o): Refuse to link only when multiarch is detected. --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index d4c04bb4..cb8c096a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -175,7 +175,7 @@ clib-routines.o: gnumach-undef gnumach-undef-bad -o $@ `sed 's/^/-Wl,-u,/' < $<` -x c /dev/null -lc -lgcc $(AM_V_at) if nm $@ | grep __init_cpu_features; \ then echo Please install a 32bit libc without multiarch support. ; \ - fi ; false + false ; fi gnumach_LINK = $(LD) $(LINKFLAGS) $(gnumach_LINKFLAGS) -o $@ gnumach_LDADD = gnumach.o clib-routines.o -- cgit v1.2.3 From 81d37c131bcc83bc58dcabef2ef1513c1e208ed6 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Mon, 17 Mar 2014 10:17:02 +0100 Subject: include: add a payload-aware intran mutator for memory_object_t * include/mach/mach_types.defs (memory_object_t): Add a payload-aware intran mutator. * include/mach/memory_object.defs: Likewise in the inlined type declarations. --- include/mach/mach_types.defs | 3 +++ include/mach/memory_object.defs | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/mach/mach_types.defs b/include/mach/mach_types.defs index bfce6cb5..85ad6533 100644 --- a/include/mach/mach_types.defs +++ b/include/mach/mach_types.defs @@ -139,6 +139,9 @@ type memory_object_t = mach_port_t #ifdef MEMORY_OBJECT_INTRAN intran: MEMORY_OBJECT_INTRAN #endif +#ifdef MEMORY_OBJECT_INTRAN_PAYLOAD + intranpayload: MEMORY_OBJECT_INTRAN_PAYLOAD +#endif #ifdef MEMORY_OBJECT_OUTTRAN outtran: MEMORY_OBJECT_OUTTRAN #endif diff --git a/include/mach/memory_object.defs b/include/mach/memory_object.defs index 1ae36aa2..6372ded8 100644 --- a/include/mach/memory_object.defs +++ b/include/mach/memory_object.defs @@ -93,6 +93,10 @@ simpleroutine memory_object_terminate( #ifdef MEMORY_OBJECT_INTRAN intran: MEMORY_OBJECT_INTRAN #endif +#ifdef MEMORY_OBJECT_INTRAN_PAYLOAD + intranpayload: + MEMORY_OBJECT_INTRAN_PAYLOAD +#endif #ifdef MEMORY_OBJECT_DESTRUCTOR destructor: MEMORY_OBJECT_DESTRUCTOR #endif @@ -236,6 +240,9 @@ simpleroutine memory_object_lock_completed( #ifdef MEMORY_OBJECT_INTRAN intran: MEMORY_OBJECT_INTRAN #endif +#ifdef MEMORY_OBJECT_INTRAN_PAYLOAD + intranpayload: MEMORY_OBJECT_INTRAN_PAYLOAD +#endif #ifdef MEMORY_OBJECT_DESTRUCTOR destructor: MEMORY_OBJECT_DESTRUCTOR #endif @@ -274,6 +281,9 @@ simpleroutine memory_object_supply_completed( #ifdef MEMORY_OBJECT_INTRAN intran: MEMORY_OBJECT_INTRAN #endif +#ifdef MEMORY_OBJECT_INTRAN_PAYLOAD + intranpayload: MEMORY_OBJECT_INTRAN_PAYLOAD +#endif #ifdef MEMORY_OBJECT_DESTRUCTOR destructor: MEMORY_OBJECT_DESTRUCTOR #endif @@ -327,6 +337,9 @@ simpleroutine memory_object_change_completed( #ifdef MEMORY_OBJECT_INTRAN intran: MEMORY_OBJECT_INTRAN #endif +#ifdef MEMORY_OBJECT_INTRAN_PAYLOAD + intranpayload: MEMORY_OBJECT_INTRAN_PAYLOAD +#endif #ifdef MEMORY_OBJECT_DESTRUCTOR destructor: MEMORY_OBJECT_DESTRUCTOR #endif -- cgit v1.2.3 From f5fc494d1171e5ddda82bdd6c9793b1c5a55ec99 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Sat, 5 Apr 2014 15:12:18 +0200 Subject: include: add a payload-aware intran mutator for notify_port_t * include/mach/notify.defs (notify_port_t): Add a payload-aware intran mutator. --- include/mach/notify.defs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/mach/notify.defs b/include/mach/notify.defs index 5e59d392..6ba4cde7 100644 --- a/include/mach/notify.defs +++ b/include/mach/notify.defs @@ -45,6 +45,9 @@ type notify_port_t = MACH_MSG_TYPE_MOVE_SEND_ONCE #ifdef NOTIFY_INTRAN intran: NOTIFY_INTRAN #endif +#ifdef NOTIFY_INTRAN_PAYLOAD + intranpayload: NOTIFY_INTRAN_PAYLOAD +#endif #ifdef NOTIFY_OUTTRAN outtran: NOTIFY_OUTTRAN #endif -- cgit v1.2.3 From 79f9f058820be50e510f499b5b4d08144ab71bc2 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Sun, 8 Jun 2014 13:08:29 +0200 Subject: include: add a payload-aware intran mutator for device_t * include/device/device_types.defs (device_t): Add a payload-aware intran mutator. --- include/device/device_types.defs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/device/device_types.defs b/include/device/device_types.defs index ff6cff68..49cc2717 100644 --- a/include/device/device_types.defs +++ b/include/device/device_types.defs @@ -63,6 +63,9 @@ type device_t = mach_port_t #ifdef DEVICE_INTRAN intran: DEVICE_INTRAN #endif +#ifdef DEVICE_INTRAN_PAYLOAD + intranpayload: DEVICE_INTRAN_PAYLOAD +#endif #ifdef DEVICE_OUTTRAN outtran: DEVICE_OUTTRAN #endif -- cgit v1.2.3 From 92bdcff573a9734a926b4eba027c36134d5c7607 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Mon, 10 Nov 2014 03:39:05 +0100 Subject: Revert "Make vm_map really ignore `address' when `anywhere' is true" This reverts commit 5ae510e35c54009626999a88f0f1cb34d6dfc94f. --- vm/vm_user.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/vm/vm_user.c b/vm/vm_user.c index 1d8f37bb..f7c87cc0 100644 --- a/vm/vm_user.c +++ b/vm/vm_user.c @@ -336,10 +336,7 @@ kern_return_t vm_map( if (size == 0) return KERN_INVALID_ARGUMENT; - if (anywhere) - *address = vm_map_min(target_map); - else - *address = trunc_page(*address); + *address = trunc_page(*address); size = round_page(size); if (!IP_VALID(memory_object)) { -- cgit v1.2.3 From 57694037a02dda29bd678dc3b8531bd437682ba7 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Mon, 10 Nov 2014 03:40:23 +0100 Subject: Fix documentation for vm_map doc/mach.texi (vm_map): Document that vm_map uses the address as a starting hint even when anywhere is TRUE. --- doc/mach.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/mach.texi b/doc/mach.texi index 4cde9fe2..59872c97 100644 --- a/doc/mach.texi +++ b/doc/mach.texi @@ -3366,7 +3366,7 @@ exception. @var{target_task} is the task to be affected. The starting address is @var{address}. If the @var{anywhere} option is used, this address is -ignored. The address actually allocated will be returned in +used as a starting hint. The address actually allocated will be returned in @var{address}. @var{size} is the number of bytes to allocate (rounded by the system in a machine dependent way). The alignment restriction is specified by @var{mask}. Bits asserted in this mask must not be -- cgit v1.2.3 From dccf8be4b40ede12941ff347781fbff9330b2280 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Wed, 12 Nov 2014 14:18:55 +0100 Subject: Pass ide and hd kernel options to ide driver * linux/dev/drivers/block/genhd.c: Include and (device_setup): Look for ide and hd options, and call ide_setup with them. * linux/src/drivers/block/ide.c (ide_setup) [MACH]: Parse hd[0-7] instead of hd[a-h]. --- linux/dev/drivers/block/genhd.c | 26 ++++++++++++++++++++++++++ linux/src/drivers/block/ide.c | 12 ++++++++++++ 2 files changed, 38 insertions(+) diff --git a/linux/dev/drivers/block/genhd.c b/linux/dev/drivers/block/genhd.c index 95b499b1..3a861386 100644 --- a/linux/dev/drivers/block/genhd.c +++ b/linux/dev/drivers/block/genhd.c @@ -27,6 +27,8 @@ #ifdef CONFIG_BLK_DEV_INITRD #include #endif +#include +#include #include @@ -768,12 +770,36 @@ static void setup_dev(struct gendisk *dev) void device_setup(void) { extern void console_map_init(void); + extern char *kernel_cmdline; + char *c, *param, *white; struct gendisk *p; int nr=0; #ifdef MACH linux_intr_pri = SPL6; #endif + for (c = kernel_cmdline; c; ) + { + param = strstr(c, " ide"); + if (!param) + param = strstr(c, " hd"); + if (!param) + break; + if (param) { + param++; + white = strchr(param, ' '); + if (!white) { + ide_setup(param); + c = NULL; + } else { + char *word = alloca(white - param + 1); + strncpy(word, param, white - param); + word[white-param] = '\0'; + ide_setup(word); + c = white + 1; + } + } + } #ifndef MACH chr_dev_init(); #endif diff --git a/linux/src/drivers/block/ide.c b/linux/src/drivers/block/ide.c index 9b9ecc2d..7b639f77 100644 --- a/linux/src/drivers/block/ide.c +++ b/linux/src/drivers/block/ide.c @@ -3152,7 +3152,11 @@ void ide_setup (char *s) ide_hwif_t *hwif; ide_drive_t *drive; unsigned int hw, unit; +#ifdef MACH + const char max_drive = '0' + ((MAX_HWIFS * MAX_DRIVES) - 1); +#else const char max_drive = 'a' + ((MAX_HWIFS * MAX_DRIVES) - 1); +#endif const char max_hwif = '0' + (MAX_HWIFS - 1); printk("ide_setup: %s", s); @@ -3161,11 +3165,19 @@ void ide_setup (char *s) /* * Look for drive options: "hdx=" */ +#ifdef MACH + if (s[0] == 'h' && s[1] == 'd' && s[2] >= '0' && s[2] <= max_drive) { +#else if (s[0] == 'h' && s[1] == 'd' && s[2] >= 'a' && s[2] <= max_drive) { +#endif const char *hd_words[] = {"none", "noprobe", "nowerr", "cdrom", "serialize", "autotune", "noautotune", "slow", "ide-scsi", NULL}; +#ifdef MACH + unit = s[2] - '0'; +#else unit = s[2] - 'a'; +#endif hw = unit / MAX_DRIVES; unit = unit % MAX_DRIVES; hwif = &ide_hwifs[hw]; -- cgit v1.2.3 From acf1525f4dec4088c075e4d7847be7305873a3a9 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Thu, 13 Nov 2014 01:25:29 +0100 Subject: Add nodma options Some very slow qemu instances would eventually trigger DMA timeouts, let's give a way to disable DMA there, it does not actually slow down operations anyway. * linux/src/drivers/block/ide.h (ide_drive_s): Add nodma field. * linux/src/drivers/block/ide.c (do_identify): Do not call dmaproc(ide_dma_check) when nodma is 1. (ide_setup): Add nodma option. --- linux/src/drivers/block/ide.c | 10 +++++++--- linux/src/drivers/block/ide.h | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/linux/src/drivers/block/ide.c b/linux/src/drivers/block/ide.c index 7b639f77..41a26017 100644 --- a/linux/src/drivers/block/ide.c +++ b/linux/src/drivers/block/ide.c @@ -2526,7 +2526,7 @@ static inline void do_identify (ide_drive_t *drive, byte cmd) drive->media = ide_tape; drive->present = 1; drive->removable = 1; - if (drive->autotune != 2 && HWIF(drive)->dmaproc != NULL) { + if (drive->autotune != 2 && HWIF(drive)->dmaproc != NULL && !drive->nodma) { if (!HWIF(drive)->dmaproc(ide_dma_check, drive)) printk(", DMA"); } @@ -2653,7 +2653,7 @@ static inline void do_identify (ide_drive_t *drive, byte cmd) if (drive->mult_req || ((id->multsect_valid & 1) && id->multsect)) drive->special.b.set_multmode = 1; } - if (drive->autotune != 2 && HWIF(drive)->dmaproc != NULL) { + if (drive->autotune != 2 && HWIF(drive)->dmaproc != NULL && !drive->nodma) { if (!(HWIF(drive)->dmaproc(ide_dma_check, drive))) { if ((id->field_valid & 4) && (id->dma_ultra & (id->dma_ultra >> 8) & 7)) printk(", UDMA"); @@ -3108,6 +3108,7 @@ static int match_parm (char *s, const char *keywords[], int vals[], int max_vals * Not fully supported by all chipset types, * and quite likely to cause trouble with * older/odd IDE drives. + * "hdx=nodma" : disallow DMA for the drive * * "idebus=xx" : inform IDE driver of VESA/PCI bus speed in Mhz, * where "xx" is between 20 and 66 inclusive, @@ -3172,7 +3173,7 @@ void ide_setup (char *s) #endif const char *hd_words[] = {"none", "noprobe", "nowerr", "cdrom", "serialize", "autotune", "noautotune", - "slow", "ide-scsi", NULL}; + "slow", "ide-scsi", "nodma", NULL}; #ifdef MACH unit = s[2] - '0'; #else @@ -3212,6 +3213,9 @@ void ide_setup (char *s) case -9: /* "ide-scsi" */ drive->ide_scsi = 1; goto done; + case -10: /* "nodma" */ + drive->nodma = 1; + goto done; case 3: /* cyl,head,sect */ drive->media = ide_disk; drive->cyl = drive->bios_cyl = vals[0]; diff --git a/linux/src/drivers/block/ide.h b/linux/src/drivers/block/ide.h index edeedc97..28e371bf 100644 --- a/linux/src/drivers/block/ide.h +++ b/linux/src/drivers/block/ide.h @@ -344,6 +344,7 @@ typedef struct ide_drive_s { unsigned nobios : 1; /* flag: do not probe bios for drive */ unsigned slow : 1; /* flag: slow data port */ unsigned autotune : 2; /* 1=autotune, 2=noautotune, 0=default */ + unsigned nodma : 1; /* disk should not use dma for read/write */ #if FAKE_FDISK_FOR_EZDRIVE unsigned remap_0_to_1 : 1; /* flag: partitioned with ezdrive */ #endif /* FAKE_FDISK_FOR_EZDRIVE */ -- cgit v1.2.3 From e4f0d5fcc0f885ea34f83176b23871bba6346cc8 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 16 Nov 2014 22:02:09 +0100 Subject: Only set debug registers when they are used * i386/i386/db_interface.c (zero_dr): New variable (db_load_context): Do not set debug registers to zero when they are already zero. (db_dr): When kernel debug registers get zero, record that the debug registers have been zeroed. --- i386/i386/db_interface.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/i386/i386/db_interface.c b/i386/i386/db_interface.c index b442b862..b3fac0bb 100644 --- a/i386/i386/db_interface.c +++ b/i386/i386/db_interface.c @@ -63,6 +63,8 @@ /* Whether the kernel uses any debugging register. */ static boolean_t kernel_dr; #endif +/* Whether the current debug registers are zero. */ +static boolean_t zero_dr; void db_load_context(pcb_t pcb) { @@ -74,13 +76,20 @@ void db_load_context(pcb_t pcb) return; } #endif + /* Else set user debug registers, if any */ + unsigned int *dr = pcb->ims.ids.dr; + boolean_t will_zero_dr = !dr[0] && !dr[1] && !dr[2] && !dr[3] && !dr[7]; + + if (!(zero_dr && will_zero_dr)) + { + set_dr0(dr[0]); + set_dr1(dr[1]); + set_dr2(dr[2]); + set_dr3(dr[3]); + set_dr7(dr[7]); + zero_dr = will_zero_dr; + } - /* Else set user debug registers */ - set_dr0(pcb->ims.ids.dr[0]); - set_dr1(pcb->ims.ids.dr[1]); - set_dr2(pcb->ims.ids.dr[2]); - set_dr3(pcb->ims.ids.dr[3]); - set_dr7(pcb->ims.ids.dr[7]); #if MACH_KDB splx(s); #endif @@ -163,7 +172,9 @@ void db_dr ( if (kernel_dr) { if (!ids.dr[0] && !ids.dr[1] && !ids.dr[2] && !ids.dr[3]) { /* Not used any more, switch back to user debugging registers */ + set_dr7 (0); kernel_dr = FALSE; + zero_dr = TRUE; db_load_context(current_thread()->pcb); } } -- cgit v1.2.3 From 847f65a8b8ce1fa0d1f51a0e579768ac445cf244 Mon Sep 17 00:00:00 2001 From: David Michael Date: Tue, 18 Nov 2014 20:29:54 -0500 Subject: Correct GCC's -Wformat-security issues * linux/pcmcia-cs/clients/axnet_cs.c (axdev_init): Add a format string literal where printk only has a single variable argument. * linux/src/drivers/net/3c507.c (el16_probe1): Likewise. * linux/src/drivers/net/3c509.c (el3_probe): Likewise. * linux/src/drivers/net/3c515.c (init_module): Likewise. (tc515_probe): Likewise. * linux/src/drivers/net/ac3200.c (ac_probe1): Likewise. * linux/src/drivers/net/apricot.c (apricot_probe): Likewise. * linux/src/drivers/net/at1700.c (at1700_probe1): Likewise. * linux/src/drivers/net/de4x5.c (de4x5_hw_init): Likewise. * linux/src/drivers/net/de600.c (de600_probe): Likewise. * linux/src/drivers/net/de620.c (de620_probe): Likewise. * linux/src/drivers/net/depca.c (depca_hw_init): Likewise. * linux/src/drivers/net/e2100.c (e21_probe1): Likewise. * linux/src/drivers/net/eepro.c (eepro_probe1): Likewise. * linux/src/drivers/net/eepro100.c (speedo_found1): Likewise. * linux/src/drivers/net/eexpress.c (eexp_hw_probe): Likewise. * linux/src/drivers/net/ewrk3.c (ewrk3_hw_init): Likewise. * linux/src/drivers/net/fmv18x.c (fmv18x_probe1): Likewise. * linux/src/drivers/net/hp-plus.c (hpp_probe1): Likewise. * linux/src/drivers/net/hp.c (hp_probe1): Likewise. * linux/src/drivers/net/lance.c (lance_probe1): Likewise. * linux/src/drivers/net/ne.c (ne_probe1): Likewise. * linux/src/drivers/net/pcnet32.c (pcnet32_probe1): Likewise. * linux/src/drivers/net/seeq8005.c (seeq8005_probe1): Likewise. * linux/src/drivers/net/smc-ultra.c (ultra_probe1): Likewise. * linux/src/drivers/net/smc-ultra32.c (ultra32_probe1): Likewise. * linux/src/drivers/net/wd.c (wd_probe1): Likewise. --- linux/pcmcia-cs/clients/axnet_cs.c | 2 +- linux/src/drivers/net/3c507.c | 4 ++-- linux/src/drivers/net/3c509.c | 2 +- linux/src/drivers/net/3c515.c | 4 ++-- linux/src/drivers/net/ac3200.c | 2 +- linux/src/drivers/net/apricot.c | 2 +- linux/src/drivers/net/at1700.c | 2 +- linux/src/drivers/net/de4x5.c | 2 +- linux/src/drivers/net/de600.c | 2 +- linux/src/drivers/net/de620.c | 2 +- linux/src/drivers/net/depca.c | 2 +- linux/src/drivers/net/e2100.c | 2 +- linux/src/drivers/net/eepro.c | 2 +- linux/src/drivers/net/eepro100.c | 2 +- linux/src/drivers/net/eexpress.c | 2 +- linux/src/drivers/net/ewrk3.c | 2 +- linux/src/drivers/net/fmv18x.c | 2 +- linux/src/drivers/net/hp-plus.c | 2 +- linux/src/drivers/net/hp.c | 2 +- linux/src/drivers/net/lance.c | 2 +- linux/src/drivers/net/ne.c | 2 +- linux/src/drivers/net/pcnet32.c | 2 +- linux/src/drivers/net/seeq8005.c | 2 +- linux/src/drivers/net/smc-ultra.c | 2 +- linux/src/drivers/net/smc-ultra32.c | 2 +- linux/src/drivers/net/wd.c | 2 +- 26 files changed, 28 insertions(+), 28 deletions(-) diff --git a/linux/pcmcia-cs/clients/axnet_cs.c b/linux/pcmcia-cs/clients/axnet_cs.c index bcd79b0e..2e7d9edc 100644 --- a/linux/pcmcia-cs/clients/axnet_cs.c +++ b/linux/pcmcia-cs/clients/axnet_cs.c @@ -1814,7 +1814,7 @@ static void set_multicast_list(struct net_device *dev) static int axdev_init(struct net_device *dev) { if (ei_debug > 1) - printk(version_8390); + printk("%s", version_8390); if (dev->priv == NULL) { diff --git a/linux/src/drivers/net/3c507.c b/linux/src/drivers/net/3c507.c index 63f85a4c..58ba2d75 100644 --- a/linux/src/drivers/net/3c507.c +++ b/linux/src/drivers/net/3c507.c @@ -354,7 +354,7 @@ int el16_probe1(struct device *dev, int ioaddr) dev = init_etherdev(0, sizeof(struct net_local)); if (net_debug && version_printed++ == 0) - printk(version); + printk("%s", version); printk("%s: 3c507 at %#x,", dev->name, ioaddr); @@ -410,7 +410,7 @@ int el16_probe1(struct device *dev, int ioaddr) dev->if_port ? "ex" : "in", dev->mem_start, dev->mem_end-1); if (net_debug) - printk(version); + printk("%s", version); /* Initialize the device structure. */ dev->priv = kmalloc(sizeof(struct net_local), GFP_KERNEL); diff --git a/linux/src/drivers/net/3c509.c b/linux/src/drivers/net/3c509.c index f8842882..727595cd 100644 --- a/linux/src/drivers/net/3c509.c +++ b/linux/src/drivers/net/3c509.c @@ -314,7 +314,7 @@ int el3_probe(struct device *dev) el3_root_dev = dev; if (el3_debug > 0) - printk(version); + printk("%s", version); /* The EL3-specific entries in the device structure. */ dev->open = &el3_open; diff --git a/linux/src/drivers/net/3c515.c b/linux/src/drivers/net/3c515.c index fd6ec50c..52f47032 100644 --- a/linux/src/drivers/net/3c515.c +++ b/linux/src/drivers/net/3c515.c @@ -404,7 +404,7 @@ init_module(void) if (debug >= 0) vortex_debug = debug; if (vortex_debug) - printk(version); + printk("%s", version); root_vortex_dev = NULL; cards_found = vortex_scan(0); @@ -419,7 +419,7 @@ int tc515_probe(struct device *dev) cards_found = vortex_scan(dev); if (vortex_debug > 0 && cards_found) - printk(version); + printk("%s", version); return cards_found ? 0 : -ENODEV; } diff --git a/linux/src/drivers/net/ac3200.c b/linux/src/drivers/net/ac3200.c index 0337bab7..600949fa 100644 --- a/linux/src/drivers/net/ac3200.c +++ b/linux/src/drivers/net/ac3200.c @@ -208,7 +208,7 @@ static int ac_probe1(int ioaddr, struct device *dev) dev->mem_start, dev->mem_end-1); if (ei_debug > 0) - printk(version); + printk("%s", version); ei_status.reset_8390 = &ac_reset_8390; ei_status.block_input = &ac_block_input; diff --git a/linux/src/drivers/net/apricot.c b/linux/src/drivers/net/apricot.c index d106e50d..57fccafb 100644 --- a/linux/src/drivers/net/apricot.c +++ b/linux/src/drivers/net/apricot.c @@ -720,7 +720,7 @@ int apricot_probe(struct device *dev) dev->irq = 10; printk(" IRQ %d.\n", dev->irq); - if (i596_debug > 0) printk(version); + if (i596_debug > 0) printk("%s", version); /* The APRICOT-specific entries in the device structure. */ dev->open = &i596_open; diff --git a/linux/src/drivers/net/at1700.c b/linux/src/drivers/net/at1700.c index 9e42ab48..f4025f46 100644 --- a/linux/src/drivers/net/at1700.c +++ b/linux/src/drivers/net/at1700.c @@ -258,7 +258,7 @@ int at1700_probe1(struct device *dev, int ioaddr) outb(0x00, ioaddr + CONFIG_1); if (net_debug) - printk(version); + printk("%s", version); /* Initialize the device structure. */ dev->priv = kmalloc(sizeof(struct net_local), GFP_KERNEL); diff --git a/linux/src/drivers/net/de4x5.c b/linux/src/drivers/net/de4x5.c index a66f0564..c85bcdbf 100644 --- a/linux/src/drivers/net/de4x5.c +++ b/linux/src/drivers/net/de4x5.c @@ -1308,7 +1308,7 @@ de4x5_hw_init(struct device *dev, u_long iobase)) } if (de4x5_debug & DEBUG_VERSION) { - printk(version); + printk("%s", version); } /* The DE4X5-specific entries in the device structure. */ diff --git a/linux/src/drivers/net/de600.c b/linux/src/drivers/net/de600.c index 2488cd76..ce969422 100644 --- a/linux/src/drivers/net/de600.c +++ b/linux/src/drivers/net/de600.c @@ -644,7 +644,7 @@ de600_probe(struct device *dev) printk("%s: D-Link DE-600 pocket adapter", dev->name); /* Alpha testers must have the version number to report bugs. */ if (de600_debug > 1) - printk(version); + printk("%s", version); /* probe for adapter */ rx_page = 0; diff --git a/linux/src/drivers/net/de620.c b/linux/src/drivers/net/de620.c index ec639101..0e0c5522 100644 --- a/linux/src/drivers/net/de620.c +++ b/linux/src/drivers/net/de620.c @@ -843,7 +843,7 @@ de620_probe(struct device *dev) dev->irq = irq; if (de620_debug) - printk(version); + printk("%s", version); printk("D-Link DE-620 pocket adapter"); diff --git a/linux/src/drivers/net/depca.c b/linux/src/drivers/net/depca.c index e1b03429..2048812d 100644 --- a/linux/src/drivers/net/depca.c +++ b/linux/src/drivers/net/depca.c @@ -649,7 +649,7 @@ depca_hw_init(struct device *dev, u_long ioaddr) } if (!status) { if (depca_debug > 1) { - printk(version); + printk("%s", version); } /* The DEPCA-specific entries in the device structure. */ diff --git a/linux/src/drivers/net/e2100.c b/linux/src/drivers/net/e2100.c index 7ba12d31..537295a2 100644 --- a/linux/src/drivers/net/e2100.c +++ b/linux/src/drivers/net/e2100.c @@ -162,7 +162,7 @@ int e21_probe1(struct device *dev, int ioaddr) outb(0, ioaddr + E21_ASIC); /* and disable the secondary interface. */ if (ei_debug && version_printed++ == 0) - printk(version); + printk("%s", version); /* We should have a "dev" from Space.c or the static module table. */ if (dev == NULL) { diff --git a/linux/src/drivers/net/eepro.c b/linux/src/drivers/net/eepro.c index 2c3a6b26..3d4fc578 100644 --- a/linux/src/drivers/net/eepro.c +++ b/linux/src/drivers/net/eepro.c @@ -498,7 +498,7 @@ eepro_probe1(struct device *dev, short ioaddr) } if (net_debug) - printk(version); + printk("%s", version); /* Grab the region so we can find another board if autoIRQ fails. */ request_region(ioaddr, EEPRO_IO_EXTENT, "eepro"); diff --git a/linux/src/drivers/net/eepro100.c b/linux/src/drivers/net/eepro100.c index 6909cdc4..d03462cd 100644 --- a/linux/src/drivers/net/eepro100.c +++ b/linux/src/drivers/net/eepro100.c @@ -726,7 +726,7 @@ static void *speedo_found1(struct pci_dev *pdev, void *init_dev, eeprom[8], eeprom[9]>>8, eeprom[9] & 0xff); for (i = 0; i < 4; i++) if (eeprom[5] & (1<>8)&15], eeprom[6] & 0x1f); if (eeprom[7] & 0x0700) diff --git a/linux/src/drivers/net/eexpress.c b/linux/src/drivers/net/eexpress.c index d7065509..9c816ee9 100644 --- a/linux/src/drivers/net/eexpress.c +++ b/linux/src/drivers/net/eexpress.c @@ -794,7 +794,7 @@ static int eexp_hw_probe(struct device *dev, unsigned short ioaddr) } if (net_debug) - printk(version); + printk("%s", version); dev->open = eexp_open; dev->stop = eexp_close; dev->hard_start_xmit = eexp_xmit; diff --git a/linux/src/drivers/net/ewrk3.c b/linux/src/drivers/net/ewrk3.c index f91315ff..07b0f13f 100644 --- a/linux/src/drivers/net/ewrk3.c +++ b/linux/src/drivers/net/ewrk3.c @@ -589,7 +589,7 @@ ewrk3_hw_init(struct device *dev, u_long iobase) if (!status) { if (ewrk3_debug > 1) { - printk(version); + printk("%s", version); } /* The EWRK3-specific entries in the device structure. */ diff --git a/linux/src/drivers/net/fmv18x.c b/linux/src/drivers/net/fmv18x.c index 121dd0bb..b29ddf00 100644 --- a/linux/src/drivers/net/fmv18x.c +++ b/linux/src/drivers/net/fmv18x.c @@ -249,7 +249,7 @@ int fmv18x_probe1(struct device *dev, short ioaddr) outb(dev->if_port, ioaddr + MODE13); if (net_debug) - printk(version); + printk("%s", version); /* Initialize the device structure. */ dev->priv = kmalloc(sizeof(struct net_local), GFP_KERNEL); diff --git a/linux/src/drivers/net/hp-plus.c b/linux/src/drivers/net/hp-plus.c index c8e36111..c2b71169 100644 --- a/linux/src/drivers/net/hp-plus.c +++ b/linux/src/drivers/net/hp-plus.c @@ -164,7 +164,7 @@ int hpp_probe1(struct device *dev, int ioaddr) } if (ei_debug && version_printed++ == 0) - printk(version); + printk("%s", version); printk("%s: %s at %#3x,", dev->name, name, ioaddr); diff --git a/linux/src/drivers/net/hp.c b/linux/src/drivers/net/hp.c index 741924f9..6ddbfd2e 100644 --- a/linux/src/drivers/net/hp.c +++ b/linux/src/drivers/net/hp.c @@ -136,7 +136,7 @@ int hp_probe1(struct device *dev, int ioaddr) } if (ei_debug && version_printed++ == 0) - printk(version); + printk("%s", version); printk("%s: %s (ID %02x) at %#3x,", dev->name, name, board_id, ioaddr); diff --git a/linux/src/drivers/net/lance.c b/linux/src/drivers/net/lance.c index f64f0fee..fe3cf687 100644 --- a/linux/src/drivers/net/lance.c +++ b/linux/src/drivers/net/lance.c @@ -674,7 +674,7 @@ int lance_probe1(struct device *dev, int ioaddr, int irq, int options) } if (lance_debug > 0 && did_version++ == 0) - printk(version); + printk("%s", version); /* The LANCE-specific entries in the device structure. */ dev->open = lance_open; diff --git a/linux/src/drivers/net/ne.c b/linux/src/drivers/net/ne.c index 825b768e..ea2f9290 100644 --- a/linux/src/drivers/net/ne.c +++ b/linux/src/drivers/net/ne.c @@ -291,7 +291,7 @@ static int ne_probe1(struct device *dev, int ioaddr) } if (ei_debug && version_printed++ == 0) - printk(version); + printk("%s", version); printk("NE*000 ethercard probe at %#3x:", ioaddr); diff --git a/linux/src/drivers/net/pcnet32.c b/linux/src/drivers/net/pcnet32.c index 02e70982..da0e8709 100644 --- a/linux/src/drivers/net/pcnet32.c +++ b/linux/src/drivers/net/pcnet32.c @@ -344,7 +344,7 @@ static int pcnet32_probe1(struct device *dev, unsigned int ioaddr, unsigned char dev->irq = irq_line; if (pcnet32_debug > 0) - printk(version); + printk("%s", version); /* The PCNET32-specific entries in the device structure. */ dev->open = &pcnet32_open; diff --git a/linux/src/drivers/net/seeq8005.c b/linux/src/drivers/net/seeq8005.c index c4d48521..4adebdea 100644 --- a/linux/src/drivers/net/seeq8005.c +++ b/linux/src/drivers/net/seeq8005.c @@ -274,7 +274,7 @@ static int seeq8005_probe1(struct device *dev, int ioaddr) dev = init_etherdev(0, sizeof(struct net_local)); if (net_debug && version_printed++ == 0) - printk(version); + printk("%s", version); printk("%s: %s found at %#3x, ", dev->name, "seeq8005", ioaddr); diff --git a/linux/src/drivers/net/smc-ultra.c b/linux/src/drivers/net/smc-ultra.c index 074a235b..f593aeb6 100644 --- a/linux/src/drivers/net/smc-ultra.c +++ b/linux/src/drivers/net/smc-ultra.c @@ -156,7 +156,7 @@ int ultra_probe1(struct device *dev, int ioaddr) dev = init_etherdev(0, 0); if (ei_debug && version_printed++ == 0) - printk(version); + printk("%s", version); model_name = (idreg & 0xF0) == 0x20 ? "SMC Ultra" : "SMC EtherEZ"; diff --git a/linux/src/drivers/net/smc-ultra32.c b/linux/src/drivers/net/smc-ultra32.c index f616e259..6cde4c27 100644 --- a/linux/src/drivers/net/smc-ultra32.c +++ b/linux/src/drivers/net/smc-ultra32.c @@ -153,7 +153,7 @@ int ultra32_probe1(struct device *dev, int ioaddr) } if (ei_debug && version_printed++ == 0) - printk(version); + printk("%s", version); model_name = "SMC Ultra32"; diff --git a/linux/src/drivers/net/wd.c b/linux/src/drivers/net/wd.c index a737a01d..dd879021 100644 --- a/linux/src/drivers/net/wd.c +++ b/linux/src/drivers/net/wd.c @@ -137,7 +137,7 @@ int wd_probe1(struct device *dev, int ioaddr) } if (ei_debug && version_printed++ == 0) - printk(version); + printk("%s", version); printk("%s: WD80x3 at %#3x, ", dev->name, ioaddr); for (i = 0; i < 6; i++) -- cgit v1.2.3 From 9b6a4ba270d9d8850c5663567fb45e9a04530fa2 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 23 Nov 2014 22:53:45 +0100 Subject: Fix programming PIT counter * linux/dev/arch/i386/kernel/irq.c (init_IRQ): Properly mask 8 bits of PIT counter. --- linux/dev/arch/i386/kernel/irq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux/dev/arch/i386/kernel/irq.c b/linux/dev/arch/i386/kernel/irq.c index 68bf0c4b..7753814b 100644 --- a/linux/dev/arch/i386/kernel/irq.c +++ b/linux/dev/arch/i386/kernel/irq.c @@ -695,7 +695,7 @@ init_IRQ (void) * Program counter 0 of 8253 to interrupt hz times per second. */ outb_p (PIT_C0 | PIT_SQUAREMODE | PIT_READMODE, PITCTL_PORT); - outb_p (latch && 0xff, PITCTR0_PORT); + outb_p (latch & 0xff, PITCTR0_PORT); outb (latch >> 8, PITCTR0_PORT); /* -- cgit v1.2.3 From 51ebaeb376521c0dbd0020d3515a4b5dfe01a12d Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Fri, 21 Nov 2014 01:05:49 +0100 Subject: include: make `mach_port_t' payload-aware Honor a new macro `MACH_PAYLOAD_TO_PORT' to inject a translation function mapping payloads to port names in the definition of `mach_port_t'. * include/mach/std_types.defs (mach_port_t): Honor `MACH_PAYLOAD_TO_PORT'. * include/device/device.defs (reply_port_t): Likewise. * include/device/device_reply.defs (reply_port_t): Likewise. * include/device/device_request.defs (reply_port_t): Likewise. --- include/device/device.defs | 8 +++++++- include/device/device_reply.defs | 8 +++++++- include/device/device_request.defs | 8 +++++++- include/mach/std_types.defs | 8 +++++++- 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/include/device/device.defs b/include/device/device.defs index 5fdf1bd6..409146f5 100644 --- a/include/device/device.defs +++ b/include/device/device.defs @@ -45,7 +45,13 @@ subsystem serverprefix ds_; type reply_port_t = MACH_MSG_TYPE_MAKE_SEND_ONCE | polymorphic - ctype: mach_port_t; + ctype: mach_port_t +#ifndef KERNEL_SERVER +#ifdef MACH_PAYLOAD_TO_PORT + intranpayload: mach_port_t MACH_PAYLOAD_TO_PORT +#endif /* MACH_PAYLOAD_TO_PORT */ +#endif /* KERNEL_SERVER */ +; routine device_open( master_port : mach_port_t; diff --git a/include/device/device_reply.defs b/include/device/device_reply.defs index 34156776..5a325075 100644 --- a/include/device/device_reply.defs +++ b/include/device/device_reply.defs @@ -54,7 +54,13 @@ serverdemux seqnos_device_reply_server; #endif /* SEQNOS */ type reply_port_t = polymorphic|MACH_MSG_TYPE_PORT_SEND_ONCE - ctype: mach_port_t; + ctype: mach_port_t +#ifndef KERNEL_SERVER +#ifdef MACH_PAYLOAD_TO_PORT + intranpayload: mach_port_t MACH_PAYLOAD_TO_PORT +#endif /* MACH_PAYLOAD_TO_PORT */ +#endif /* KERNEL_SERVER */ +; simpleroutine device_open_reply( reply_port : reply_port_t; diff --git a/include/device/device_request.defs b/include/device/device_request.defs index e8aab2a6..7ea8637c 100644 --- a/include/device/device_request.defs +++ b/include/device/device_request.defs @@ -37,7 +37,13 @@ subsystem device_request 2800; /* to match device.defs */ serverprefix ds_; type reply_port_t = MACH_MSG_TYPE_MAKE_SEND_ONCE - ctype: mach_port_t; + ctype: mach_port_t +#ifndef KERNEL_SERVER +#ifdef MACH_PAYLOAD_TO_PORT + intranpayload: mach_port_t MACH_PAYLOAD_TO_PORT +#endif /* MACH_PAYLOAD_TO_PORT */ +#endif /* KERNEL_SERVER */ +; simpleroutine device_open_request( device_server_port : mach_port_t; diff --git a/include/mach/std_types.defs b/include/mach/std_types.defs index 00d1a698..a1f156d9 100644 --- a/include/mach/std_types.defs +++ b/include/mach/std_types.defs @@ -49,7 +49,13 @@ type pointer_t = ^array[] of MACH_MSG_TYPE_BYTE ctype: vm_offset_t; -type mach_port_t = MACH_MSG_TYPE_COPY_SEND; +type mach_port_t = MACH_MSG_TYPE_COPY_SEND +#ifndef KERNEL_SERVER +#ifdef MACH_PAYLOAD_TO_PORT + intranpayload: mach_port_t MACH_PAYLOAD_TO_PORT +#endif /* MACH_PAYLOAD_TO_PORT */ +#endif /* KERNEL_SERVER */ +; type mach_port_array_t = array[] of mach_port_t; type mach_port_name_t = MACH_MSG_TYPE_PORT_NAME -- cgit v1.2.3 From cd76999cd1cf590b95df3e22d2eb2a7dad333499 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Mon, 1 Dec 2014 16:16:04 +0100 Subject: kern: disable all counters by default Make all five non-conditional counters conditional ones. Casual checking revealed that the hits-to-miss ratio is excellent. * kern/counters.c: Make all counters conditional. * kern/counters.h: Likewise. * kern/ipc_sched.c: Likewise. * kern/sched_prim.c: Likewise. --- kern/counters.c | 3 +-- kern/counters.h | 3 +-- kern/ipc_sched.c | 4 ++-- kern/sched_prim.c | 8 ++++---- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/kern/counters.c b/kern/counters.c index a9d450e1..74fd42d1 100644 --- a/kern/counters.c +++ b/kern/counters.c @@ -32,13 +32,12 @@ * This makes them easier to examine with ddb. */ +#if MACH_COUNTERS mach_counter_t c_thread_invoke_hits = 0; mach_counter_t c_thread_invoke_misses = 0; mach_counter_t c_thread_invoke_csw = 0; mach_counter_t c_thread_handoff_hits = 0; mach_counter_t c_thread_handoff_misses = 0; - -#if MACH_COUNTERS mach_counter_t c_threads_current = 0; mach_counter_t c_threads_max = 0; mach_counter_t c_threads_min = 0; diff --git a/kern/counters.h b/kern/counters.h index 474c6a29..bfa9b44e 100644 --- a/kern/counters.h +++ b/kern/counters.h @@ -55,13 +55,12 @@ typedef unsigned int mach_counter_t; +#if MACH_COUNTERS extern mach_counter_t c_thread_invoke_hits; extern mach_counter_t c_thread_invoke_misses; extern mach_counter_t c_thread_invoke_csw; extern mach_counter_t c_thread_handoff_hits; extern mach_counter_t c_thread_handoff_misses; - -#if MACH_COUNTERS extern mach_counter_t c_threads_current; extern mach_counter_t c_threads_max; extern mach_counter_t c_threads_min; diff --git a/kern/ipc_sched.c b/kern/ipc_sched.c index d5b9263c..cc1672d6 100644 --- a/kern/ipc_sched.c +++ b/kern/ipc_sched.c @@ -214,7 +214,7 @@ thread_handoff( thread_unlock(new); (void) splx(s); - counter_always(c_thread_handoff_misses++); + counter(c_thread_handoff_misses++); return FALSE; } @@ -278,6 +278,6 @@ thread_handoff( after_old_thread: (void) splx(s); - counter_always(c_thread_handoff_hits++); + counter(c_thread_handoff_hits++); return TRUE; } diff --git a/kern/sched_prim.c b/kern/sched_prim.c index 66eb9c95..89fb1dc8 100644 --- a/kern/sched_prim.c +++ b/kern/sched_prim.c @@ -726,7 +726,7 @@ boolean_t thread_invoke( * running out of stack. */ - counter_always(c_thread_invoke_hits++); + counter(c_thread_invoke_hits++); (void) spl0(); call_continuation(new_thread->swap_func); /*NOTREACHED*/ @@ -738,7 +738,7 @@ boolean_t thread_invoke( */ thread_swapin(new_thread); thread_unlock(new_thread); - counter_always(c_thread_invoke_misses++); + counter(c_thread_invoke_misses++); return FALSE; case 0: @@ -759,7 +759,7 @@ boolean_t thread_invoke( { thread_swapin(new_thread); thread_unlock(new_thread); - counter_always(c_thread_invoke_misses++); + counter(c_thread_invoke_misses++); return FALSE; } } @@ -788,7 +788,7 @@ boolean_t thread_invoke( * changing address spaces. It updates active_threads. * It returns only if a continuation is not supplied. */ - counter_always(c_thread_invoke_csw++); + counter(c_thread_invoke_csw++); old_thread = switch_context(old_thread, continuation, new_thread); /* -- cgit v1.2.3 From be05086a4b9de42ba7c596905e8980d8713eae49 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 7 Dec 2014 23:05:48 +0100 Subject: Fix pthread_create warning on translator termination This was due to task_terminate not actually properly suspending threads before disable the task port, which was thus preventing pthread_create from being able to create a stack. Thanks Gabriele Giacone for finding out a reproducer of this. * kern/task.h (task_hold_locked): New declaration. * kern/task.c (task_hold): Move the locked part of the code into... (task_hold_locked): ... new function. (task_terminate): Call task_hold_locked just before deactivating the task. Call ipc_task_disable after waiting for threads to actually suspend with task_dowait. --- kern/task.c | 37 ++++++++++++++++++++++++++++--------- kern/task.h | 1 + 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/kern/task.c b/kern/task.c index 20acc6ac..44963c68 100644 --- a/kern/task.c +++ b/kern/task.c @@ -272,6 +272,7 @@ kern_return_t task_terminate( thread_terminate(cur_thread); return KERN_FAILURE; } + task_hold_locked(task); task->active = FALSE; queue_remove(list, cur_thread, thread_t, thread_list); thread_unlock(cur_thread); @@ -325,6 +326,7 @@ kern_return_t task_terminate( task_unlock(task); return KERN_FAILURE; } + task_hold_locked(task); task->active = FALSE; task_unlock(task); } @@ -335,9 +337,8 @@ kern_return_t task_terminate( * If this is the current task, the current thread will * be left running. */ - ipc_task_disable(task); - (void) task_hold(task); (void) task_dowait(task,TRUE); /* may block */ + ipc_task_disable(task); /* * Terminate each thread in the task. @@ -402,20 +403,18 @@ kern_return_t task_terminate( * Suspend execution of the specified task. * This is a recursive-style suspension of the task, a count of * suspends is maintained. + * + * CONDITIONS: the task is locked and active. */ -kern_return_t task_hold( +void task_hold_locked( task_t task) { queue_head_t *list; thread_t thread, cur_thread; - cur_thread = current_thread(); + assert(task->active); - task_lock(task); - if (!task->active) { - task_unlock(task); - return KERN_FAILURE; - } + cur_thread = current_thread(); task->suspend_count++; @@ -429,6 +428,26 @@ kern_return_t task_hold( if (thread != cur_thread) thread_hold(thread); } +} + +/* + * task_hold: + * + * Suspend execution of the specified task. + * This is a recursive-style suspension of the task, a count of + * suspends is maintained. + */ +kern_return_t task_hold( + task_t task) +{ + task_lock(task); + if (!task->active) { + task_unlock(task); + return KERN_FAILURE; + } + + task_hold_locked(task); + task_unlock(task); return KERN_SUCCESS; } diff --git a/kern/task.h b/kern/task.h index 3c10dc0c..2a4c28fc 100644 --- a/kern/task.h +++ b/kern/task.h @@ -182,6 +182,7 @@ extern void consider_task_collect(void); extern void task_init(void); extern void task_reference(task_t); extern void task_deallocate(task_t); +extern void task_hold_locked(task_t); extern kern_return_t task_hold(task_t); extern kern_return_t task_dowait(task_t, boolean_t); extern kern_return_t task_release(task_t); -- cgit v1.2.3 From 8214da0d2e0e6f01b17c9d1dc1608f0ec3cf3be4 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Sat, 6 Dec 2014 11:59:32 +0100 Subject: Retire procedure `old_mach_port_get_receive_status' Retire the compatibility RPC `old_mach_port_get_receive_status' that works like `mach_port_get_receive_status' but returns an `old_mach_port_status' object that lacks the `mps_seqno' field. Do not remove the type yet, so we do not break anyones build. The RPC stubs currently distributed with the glibc require it. * include/mach/mach_port.defs (old_mach_port_get_receive_status): Drop RPC. * include/mach/mach_types.defs (old_mach_port_status_t): Drop type. * include/mach/port.h (old_mach_port_status_t): Add note to remove this for the 1.6 release. * ipc/mach_port.c (old_mach_port_get_receive_status): Drop function. --- include/mach/mach_port.defs | 9 +-------- include/mach/mach_types.defs | 2 -- include/mach/port.h | 2 ++ ipc/mach_port.c | 40 ---------------------------------------- 4 files changed, 3 insertions(+), 50 deletions(-) diff --git a/include/mach/mach_port.defs b/include/mach/mach_port.defs index c7e8526a..c21c34bc 100644 --- a/include/mach/mach_port.defs +++ b/include/mach/mach_port.defs @@ -176,14 +176,7 @@ routine mach_port_mod_refs( right : mach_port_right_t; delta : mach_port_delta_t); -/* - * Temporary compatibility call. - */ - -routine old_mach_port_get_receive_status( - task : ipc_space_t; - name : mach_port_name_t; - out status : old_mach_port_status_t); +skip; /* old old_mach_port_get_receive_status */ /* * Only valid for receive rights. diff --git a/include/mach/mach_types.defs b/include/mach/mach_types.defs index 85ad6533..8e68d385 100644 --- a/include/mach/mach_types.defs +++ b/include/mach/mach_types.defs @@ -60,8 +60,6 @@ serverprefix SERVERPREFIX; type mach_port_status_t = struct[9] of integer_t; -type old_mach_port_status_t = struct[8] of integer_t; /* compatibility */ - type task_t = mach_port_t ctype: mach_port_t #if KERNEL_SERVER diff --git a/include/mach/port.h b/include/mach/port.h index 53f60716..3036a921 100644 --- a/include/mach/port.h +++ b/include/mach/port.h @@ -137,6 +137,8 @@ typedef struct mach_port_status { /* * Compatibility definitions, for code written * before there was an mps_seqno field. + * + * XXX: Remove this before releasing Gnumach 1.6. */ typedef struct old_mach_port_status { diff --git a/ipc/mach_port.c b/ipc/mach_port.c index 4ff39f2c..c7d9b810 100644 --- a/ipc/mach_port.c +++ b/ipc/mach_port.c @@ -743,46 +743,6 @@ mach_port_mod_refs( return kr; } -/* - * Routine: old_mach_port_get_receive_status [kernel call] - * Purpose: - * Compatibility for code written before sequence numbers. - * Retrieves mucho info about a receive right. - * Conditions: - * Nothing locked. - * Returns: - * KERN_SUCCESS Retrieved status. - * KERN_INVALID_TASK The space is null. - * KERN_INVALID_TASK The space is dead. - * KERN_INVALID_NAME The name doesn't denote a right. - * KERN_INVALID_RIGHT Name doesn't denote receive rights. - */ - -kern_return_t -old_mach_port_get_receive_status( - ipc_space_t space, - mach_port_t name, - old_mach_port_status_t *statusp) -{ - mach_port_status_t status; - kern_return_t kr; - - kr = mach_port_get_receive_status(space, name, &status); - if (kr != KERN_SUCCESS) - return kr; - - statusp->mps_pset = status.mps_pset; - statusp->mps_mscount = status.mps_mscount; - statusp->mps_qlimit = status.mps_qlimit; - statusp->mps_msgcount = status.mps_msgcount; - statusp->mps_sorights = status.mps_sorights; - statusp->mps_srights = status.mps_srights; - statusp->mps_pdrequest = status.mps_pdrequest; - statusp->mps_nsrequest = status.mps_nsrequest; - - return KERN_SUCCESS; -} - /* * Routine: mach_port_set_qlimit [kernel call] * Purpose: -- cgit v1.2.3 From 8c4d15d5b824fd02bd6909f6d254828732f3bb7b Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Tue, 4 Nov 2014 18:46:42 +0100 Subject: kern: provide notifications about new tasks These notifications are sent to the port registered via `register_new_task_notification' and provide a robust parental relation between tasks to a userspace server. * Makefrag.am: Add task_notify.defs. * include/mach/gnumach.defs: Add register_new_task_notification. * include/mach/task_notify.defs: New file. * kern/task.c (new_task_notification): New variable. (task_create): Send new task notifications. (register_new_task_notification): Add server function. * kern/task_notify.cli: New file. --- Makefrag.am | 8 ++++++++ include/mach/gnumach.defs | 8 ++++++++ include/mach/task_notify.defs | 36 ++++++++++++++++++++++++++++++++++++ kern/task.c | 33 +++++++++++++++++++++++++++++++++ kern/task_notify.cli | 7 +++++++ 5 files changed, 92 insertions(+) create mode 100644 include/mach/task_notify.defs create mode 100644 kern/task_notify.cli diff --git a/Makefrag.am b/Makefrag.am index 5e98b219..410f56d6 100644 --- a/Makefrag.am +++ b/Makefrag.am @@ -364,6 +364,7 @@ include_mach_HEADERS = \ include/mach/mach.defs \ include/mach/mach4.defs \ include/mach/gnumach.defs \ + include/mach/task_notify.defs \ include/mach/mach_host.defs \ include/mach/mach_port.defs \ include/mach/mach_types.defs \ @@ -488,6 +489,13 @@ nodist_libkernel_a_SOURCES += \ # device/device_reply.user.defs # device/memory_object_reply.user.defs +nodist_lib_dep_tr_for_defs_a_SOURCES += \ + kern/task_notify.user.defs.c +nodist_libkernel_a_SOURCES += \ + kern/task_notify.user.h \ + kern/task_notify.user.c \ + kern/task_notify.user.msgids + # Server stubs. nodist_lib_dep_tr_for_defs_a_SOURCES += \ device/device.server.defs.c \ diff --git a/include/mach/gnumach.defs b/include/mach/gnumach.defs index 6cfbb0d0..bac3b097 100644 --- a/include/mach/gnumach.defs +++ b/include/mach/gnumach.defs @@ -72,3 +72,11 @@ simpleroutine thread_terminate_release( simpleroutine task_set_name( task : task_t; name : kernel_debug_name_t); + +/* + * Register a port to which a notification about newly created tasks + * are sent. + */ +routine register_new_task_notification( + host_priv : host_priv_t; + notification : mach_port_send_t); diff --git a/include/mach/task_notify.defs b/include/mach/task_notify.defs new file mode 100644 index 00000000..5485d4e3 --- /dev/null +++ b/include/mach/task_notify.defs @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2014 Free Software Foundation + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +subsystem +#if KERNEL_SERVER + KernelServer +#endif /* KERNEL_SERVER */ +#if KERNEL_USER + KernelUser +#endif /* KERNEL_USER */ + task_notify 4400; + +#include +#include + +/* These notifications are sent to the port registered via + `register_new_task_notification' and provide a robust parental + relation between tasks. */ +simpleroutine mach_notify_new_task( + notify : mach_port_t; + task : task_t; + parent : task_t); diff --git a/kern/task.c b/kern/task.c index 44963c68..a11fb8ee 100644 --- a/kern/task.c +++ b/kern/task.c @@ -50,12 +50,16 @@ #include /* for thread_wakeup */ #include #include +#include #include /* for kernel_map, ipc_kernel_map */ #include /* for splsched */ task_t kernel_task = TASK_NULL; struct kmem_cache task_cache; +/* Where to send notifications about newly created tasks. */ +ipc_port_t new_task_notification = NULL; + void task_init(void) { kmem_cache_init(&task_cache, "task", sizeof(struct task), 0, @@ -169,6 +173,14 @@ kern_return_t task_create( snprintf (new_task->name, sizeof new_task->name, "%p", new_task); + if (new_task_notification != NULL) { + task_reference (new_task); + task_reference (parent_task); + mach_notify_new_task (new_task_notification, + convert_task_to_port (new_task), + convert_task_to_port (parent_task)); + } + ipc_task_enable(new_task); *child_task = new_task; @@ -1249,3 +1261,24 @@ task_ras_control( #endif /* FAST_TAS */ return ret; } + +/* + * register_new_task_notification + * + * Register a port to which a notification about newly created + * tasks are sent. + */ +kern_return_t +register_new_task_notification( + const host_t host, + ipc_port_t notification) +{ + if (host == HOST_NULL) + return KERN_INVALID_HOST; + + if (new_task_notification != NULL) + return KERN_NO_ACCESS; + + new_task_notification = notification; + return KERN_SUCCESS; +} diff --git a/kern/task_notify.cli b/kern/task_notify.cli new file mode 100644 index 00000000..c6c85d99 --- /dev/null +++ b/kern/task_notify.cli @@ -0,0 +1,7 @@ +/* XXX */ + +/* This is a client presentation file. */ + +#define KERNEL_USER 1 + +#include -- cgit v1.2.3 From c3473992f56e39acd11c6c4e64d6cd1c7d67d37a Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Thu, 6 Nov 2014 16:57:35 +0100 Subject: include: add X_IMPORTS to ipc definitions This makes it possible to inject imports. * include/mach/gnumach.defs: Make it possible to inject imports. * include/mach/mach.defs: Likewise. * include/mach/mach_host.defs: Likewise. --- include/mach/gnumach.defs | 4 ++++ include/mach/mach.defs | 4 ++++ include/mach/mach_host.defs | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/include/mach/gnumach.defs b/include/mach/gnumach.defs index bac3b097..dd4da870 100644 --- a/include/mach/gnumach.defs +++ b/include/mach/gnumach.defs @@ -29,6 +29,10 @@ subsystem #include #include +#ifdef GNUMACH_IMPORTS +GNUMACH_IMPORTS +#endif + type vm_cache_statistics_data_t = struct[11] of integer_t; /* diff --git a/include/mach/mach.defs b/include/mach/mach.defs index 58510805..3786f657 100644 --- a/include/mach/mach.defs +++ b/include/mach/mach.defs @@ -46,6 +46,10 @@ userprefix r_; #include #include +#ifdef MACH_IMPORTS +MACH_IMPORTS +#endif + skip; /* old port_allocate */ skip; /* old port_deallocate */ skip; /* old port_enable */ diff --git a/include/mach/mach_host.defs b/include/mach/mach_host.defs index 2644146f..6699a507 100644 --- a/include/mach/mach_host.defs +++ b/include/mach/mach_host.defs @@ -47,6 +47,10 @@ subsystem #include #include +#ifdef MACH_HOST_IMPORTS +MACH_HOST_IMPORTS +#endif + /* * Get list of processors on this host. */ -- cgit v1.2.3 From 48680cf730307b0432d98365ed2a32e3f18b6af0 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Thu, 11 Dec 2014 00:32:47 +0100 Subject: Ship missing file * Makefrag.am (EXTRA_DIST): Add kern/task_notify.cli. --- Makefrag.am | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefrag.am b/Makefrag.am index 410f56d6..91661437 100644 --- a/Makefrag.am +++ b/Makefrag.am @@ -221,7 +221,8 @@ EXTRA_DIST += \ kern/mach4.srv \ kern/gnumach.srv \ kern/mach_debug.srv \ - kern/mach_host.srv + kern/mach_host.srv \ + kern/task_notify.cli # -- cgit v1.2.3 From 6f8e390eea2ac9aaa754e1ab2ecd73af5857f798 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Mon, 15 Dec 2014 01:29:43 +0100 Subject: Make spl7 just clear IF instead of setting the PIC mask * i386/i386/spl.S (spl7): Just set curr_ipl and cli. (splx) [MACH_KDB || MACH_TTD]: When curr_ipl is 7, make sure that IF is cleared. (splx): When staying at ipl7, do not enable interrupts. (spl) [MACH_KDB || MACH_TTD]: When curr_ipl is 7, make sure that IF is cleared. (spl): When new ipl is 7, branch to spl7. * i386/i386/locore.S (TIME_TRAP_UENTRY, TIME_TRAP_SENTRY): Save flags, and restore them instead of blindly using sti. --- i386/i386/locore.S | 6 ++++-- i386/i386/spl.S | 36 +++++++++++++++++++++++++++++++++++- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/i386/i386/locore.S b/i386/i386/locore.S index e1befa71..15715f6b 100644 --- a/i386/i386/locore.S +++ b/i386/i386/locore.S @@ -119,6 +119,7 @@ LEXT(retry_table_end) ;\ * Uses %eax, %ebx, %ecx. */ #define TIME_TRAP_UENTRY \ + pushf /* Save flags */ ;\ cli /* block interrupts */ ;\ movl VA_ETC,%ebx /* get timer value */ ;\ movl CX(EXT(current_tstamp),%edx),%ecx /* get old time stamp */;\ @@ -131,7 +132,7 @@ LEXT(retry_table_end) ;\ 0: addl $(TH_SYSTEM_TIMER-TH_USER_TIMER),%ecx ;\ /* switch to sys timer */;\ movl %ecx,CX(EXT(current_timer),%edx) /* make it current */ ;\ - sti /* allow interrupts */ + popf /* allow interrupts */ /* * Update time on system call entry. @@ -141,6 +142,7 @@ LEXT(retry_table_end) ;\ * Same as TIME_TRAP_UENTRY, but preserves %eax. */ #define TIME_TRAP_SENTRY \ + pushf /* Save flags */ ;\ cli /* block interrupts */ ;\ movl VA_ETC,%ebx /* get timer value */ ;\ movl CX(EXT(current_tstamp),%edx),%ecx /* get old time stamp */;\ @@ -155,7 +157,7 @@ LEXT(retry_table_end) ;\ 0: addl $(TH_SYSTEM_TIMER-TH_USER_TIMER),%ecx ;\ /* switch to sys timer */;\ movl %ecx,CX(EXT(current_timer),%edx) /* make it current */ ;\ - sti /* allow interrupts */ + popf /* allow interrupts */ /* * update time on user trap exit. diff --git a/i386/i386/spl.S b/i386/i386/spl.S index 3c075092..41458ac4 100644 --- a/i386/i386/spl.S +++ b/i386/i386/spl.S @@ -140,15 +140,35 @@ Entry(splsched) Entry(splhigh) Entry(splhi) ENTRY(spl7) - SETIPL(SPL7) + /* ipl7 just clears IF */ + movl $SPL7,%eax + xchgl EXT(curr_ipl),%eax + cli + ret ENTRY(splx) movl S_ARG0,%edx /* get ipl */ + +#if MACH_KDB || MACH_TTD + /* First make sure that if we're exitting from ipl7, IF is still cleared */ + cmpl $SPL7,EXT(curr_ipl) /* from ipl7? */ + jne 0f + pushfl + popl %eax + testl $0x200,%eax /* IF? */ + jz 0f + int3 /* Oops, interrupts got enabled?! */ + +0: +#endif /* MACH_KDB || MACH_TTD */ testl %edx,%edx /* spl0? */ jz EXT(spl0) /* yes, handle specially */ cmpl EXT(curr_ipl),%edx /* same ipl as current? */ jne spl /* no */ + cmpl $SPL7,%edx /* spl7? */ + je 1f /* to ipl7, don't enable interrupts */ sti /* ensure interrupts are enabled */ +1: movl %edx,%eax /* return previous ipl */ ret @@ -207,6 +227,20 @@ splx_cli: .align TEXT_ALIGN .globl spl spl: +#if MACH_KDB || MACH_TTD + /* First make sure that if we're exitting from ipl7, IF is still cleared */ + cmpl $SPL7,EXT(curr_ipl) /* from ipl7? */ + jne 0f + pushfl + popl %eax + testl $0x200,%eax /* IF? */ + jz 0f + int3 /* Oops, interrupts got enabled?! */ + +0: +#endif /* MACH_KDB || MACH_TTD */ + cmpl $SPL7,%edx /* spl7? */ + je EXT(spl7) /* yes, handle specially */ movl EXT(pic_mask)(,%edx,4),%eax /* get PIC mask */ cli /* disable interrupts */ -- cgit v1.2.3 From 73314404a9bd7106514b711cd69765b4081b6bed Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Tue, 16 Dec 2014 13:36:08 +0100 Subject: ipc: tune size of cached kernel message buffers The previous limit was 256 bytes. That seems a little crummy by todays standards, and we are frequently sending bigger packets (e.g. every RPC containing a string_t on Hurd). Use the page size for IKM_SAVED_KMSG_SIZE to make sure the page is pinned to a single processor. * ipc/ipc_kmsg.h (IKM_SAVED_KMSG_SIZE): Define to `PAGE_SIZE'. --- ipc/ipc_kmsg.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ipc/ipc_kmsg.h b/ipc/ipc_kmsg.h index 07695fb5..f06857ad 100644 --- a/ipc/ipc_kmsg.h +++ b/ipc/ipc_kmsg.h @@ -92,9 +92,12 @@ extern ipc_kmsg_t ipc_kmsg_cache[NCPUS]; /* * The size of the kernel message buffers that will be cached. * IKM_SAVED_KMSG_SIZE includes overhead; IKM_SAVED_MSG_SIZE doesn't. + * + * We use the page size for IKM_SAVED_KMSG_SIZE to make sure the + * page is pinned to a single processor. */ -#define IKM_SAVED_KMSG_SIZE ((vm_size_t) 256) +#define IKM_SAVED_KMSG_SIZE PAGE_SIZE #define IKM_SAVED_MSG_SIZE ikm_less_overhead(IKM_SAVED_KMSG_SIZE) #define ikm_alloc(size) \ -- cgit v1.2.3 From 1bb1ba65cb9efceeb20b4296f903f3fe58b3341e Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Tue, 16 Dec 2014 14:21:26 +0100 Subject: ipc: guard test code with `MACH_IPC_TEST' * ipc/ipc_kmsg.h (ikm_mark_bogus): New macro. (ipc_kmsg_rmqueue_first_macro): Use `ikm_mark_bogus'. * ipc/ipc_kmsg.c (ipc_kmsg_rmqueue): Likewise. --- ipc/ipc_kmsg.c | 4 +--- ipc/ipc_kmsg.h | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/ipc/ipc_kmsg.c b/ipc/ipc_kmsg.c index 71a0d74a..66643fd5 100644 --- a/ipc/ipc_kmsg.c +++ b/ipc/ipc_kmsg.c @@ -139,9 +139,7 @@ ipc_kmsg_rmqueue( next->ikm_prev = prev; prev->ikm_next = next; } - /* XXX Temporary debug logic */ - kmsg->ikm_next = IKM_BOGUS; - kmsg->ikm_prev = IKM_BOGUS; + ikm_mark_bogus (kmsg); } /* diff --git a/ipc/ipc_kmsg.h b/ipc/ipc_kmsg.h index f06857ad..620785b5 100644 --- a/ipc/ipc_kmsg.h +++ b/ipc/ipc_kmsg.h @@ -72,11 +72,24 @@ typedef struct ipc_kmsg { #define ikm_plus_overhead(size) ((vm_size_t)((size) + IKM_OVERHEAD)) #define ikm_less_overhead(size) ((mach_msg_size_t)((size) - IKM_OVERHEAD)) +#if MACH_IPC_TEST /* - * XXX For debugging. + * For debugging. */ #define IKM_BOGUS ((ipc_kmsg_t) 0xffffff10) +#define ikm_mark_bogus(kmsg) \ +MACRO_BEGIN \ + (kmsg)->ikm_next = IKM_BOGUS; \ + (kmsg)->ikm_prev = IKM_BOGUS; \ +MACRO_END + +#else /* MACH_IPC_TEST */ + +#define ikm_mark_bogus(kmsg) ; + +#endif /* MACH_IPC_TEST */ + /* * We keep a per-processor cache of kernel message buffers. * The cache saves the overhead/locking of using kalloc/kfree. @@ -198,9 +211,7 @@ MACRO_BEGIN \ _next->ikm_prev = _prev; \ _prev->ikm_next = _next; \ } \ - /* XXX Debug paranoia */ \ - kmsg->ikm_next = IKM_BOGUS; \ - kmsg->ikm_prev = IKM_BOGUS; \ + ikm_mark_bogus (kmsg); \ MACRO_END #define ipc_kmsg_enqueue_macro(queue, kmsg) \ -- cgit v1.2.3 From cde7c781e172c1fd55f74550b66712540a677d85 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Tue, 16 Dec 2014 23:52:28 +0100 Subject: kern: gracefully handle bogus sample pc sequence number If a sequence number larger than the sample control sequence number is supplied, `nsamples' becomes negative. Handle this gracefully. * kern/pc_sample.c (get_sampled_pcs): Handle bogus sequence number. --- kern/pc_sample.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kern/pc_sample.c b/kern/pc_sample.c index 81b20560..fcb9d71b 100644 --- a/kern/pc_sample.c +++ b/kern/pc_sample.c @@ -189,6 +189,9 @@ get_sampled_pcs( (sampled_pc_array_t)cp->buffer, (seqidx2 + 1) * sizeof(sampled_pc_t)); } + } else if (nsamples < 0) { + /* Bogus SEQNO supplied. */ + nsamples = 0; } else { /* could either be zero because of overflow, or because * we are being lied to. In either case, return nothing. -- cgit v1.2.3 From ed959ff149a5794649312288f87453f63bbbf3c9 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Fri, 2 Jan 2015 17:31:51 +0100 Subject: Handle kernel traps happening before starting userland * i386/i386/trap.c (kernel_trap): When current_thread is null, assume that we are in kernel land. --- i386/i386/trap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/i386/i386/trap.c b/i386/i386/trap.c index 9d4d43d0..f1fe6343 100644 --- a/i386/i386/trap.c +++ b/i386/i386/trap.c @@ -217,9 +217,9 @@ dump_ss(regs); goto badtrap; } } else { - assert(thread); - map = thread->task->map; - if (map == kernel_map) { + if (thread) + map = thread->task->map; + if (!thread || map == kernel_map) { printf("kernel page fault at %08x:\n", subcode); dump_ss(regs); panic("kernel thread accessed user space!\n"); -- cgit v1.2.3 From 24a89f673857e8f49c3890f5a527f34d1b16806d Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Fri, 2 Jan 2015 16:02:47 +0100 Subject: ddb: Fix typos in comments (found by codespell) Signed-off-by: Stefan Weil --- ddb/db_sym.c | 2 +- ddb/db_task_thread.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ddb/db_sym.c b/ddb/db_sym.c index 0179137f..2abd5746 100644 --- a/ddb/db_sym.c +++ b/ddb/db_sym.c @@ -293,7 +293,7 @@ db_name_is_ambiguous(char *sym_name) * and the difference between val and the symbol found. * * Logic change. If the task argument is non NULL and a - * matching symbol is found in a symbol table which explictly + * matching symbol is found in a symbol table which explicitly * specifies its map to be task->map, that symbol will have * precedence over any symbol from a symbol table will a null * map. This allows overlapping kernel/user maps to work correctly. diff --git a/ddb/db_task_thread.c b/ddb/db_task_thread.c index edab17e5..7927e674 100644 --- a/ddb/db_task_thread.c +++ b/ddb/db_task_thread.c @@ -150,7 +150,7 @@ db_check_thread_address_valid(thread) } /* - * convert task_id(queue postion) to task address + * convert task_id(queue position) to task address */ task_t db_lookup_task_id(int task_id) -- cgit v1.2.3 From 0e2ab14cc24de704b00f63d1f47cf93245aa5d32 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Fri, 2 Jan 2015 16:02:46 +0100 Subject: Makefile.am: Fix typos and grammar in comment Signed-off-by: Stefan Weil --- Makefile.am | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.am b/Makefile.am index cb8c096a..1afddab2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -104,8 +104,8 @@ CPP = @CPP@ -x c # Other Tools' Configuration. # -# Don't needlessly overwrite files that whose contents haven't changed. This -# helps for avoinding unneccessary recompilation cycles when keeping +# Don't needlessly overwrite files whose contents haven't changed. +# This helps avoiding unnecessary recompilation cycles when keeping # cross-compilation toolchains up-to-date. Thus, unconditionally use the # `install-sh' that is supplied by GNU Automake 1.10.1, as the GNU Coreutils # one doesn't provide this functionality yet (TODO: change that). TODO: -- cgit v1.2.3 From b8fdffc2877992e5c5121bb7e011561581691d14 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Fri, 2 Jan 2015 16:02:48 +0100 Subject: device: Fix typos in comments (found by codespell) Signed-off-by: Stefan Weil --- device/dev_name.c | 2 +- device/net_io.c | 2 +- device/tty.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/device/dev_name.c b/device/dev_name.c index 5bf62a04..175e3890 100644 --- a/device/dev_name.c +++ b/device/dev_name.c @@ -207,7 +207,7 @@ boolean_t dev_name_lookup( } *unit += (slice_num << 4); - /* if slice==0, it is either compatability or whole device */ + /* if slice==0, it is either compatibility or whole device */ if (c >= 'a' && c < 'a' + j) { /* note: w/o this -> whole slice */ /* diff --git a/device/net_io.c b/device/net_io.c index a9d318e4..d2928cc5 100644 --- a/device/net_io.c +++ b/device/net_io.c @@ -640,7 +640,7 @@ net_packet( * Do a quick check to see if it is a kernel TTD packet. * * Only check if KernelTTD is enabled, ie. the current - * device driver supports TTD, and the bootp succeded. + * device driver supports TTD, and the bootp succeeded. */ if (kttd_enabled && kttd_handle_async(kmsg)) { /* diff --git a/device/tty.h b/device/tty.h index a931e337..d7aa2add 100644 --- a/device/tty.h +++ b/device/tty.h @@ -184,7 +184,7 @@ extern boolean_t tty_portdeath( #define TS_TRANSLATE 0x00100000 /* translation device enabled */ #define TS_KDB 0x00200000 /* should enter kdb on ALT */ -#define TS_MIN_TO_RCV 0x00400000 /* character recived during +#define TS_MIN_TO_RCV 0x00400000 /* character received during receive timeout interval */ /* flags - old names defined in terms of new ones */ -- cgit v1.2.3 From 2fbf8a78d7244fcf60eaeb218070959715f61f53 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Fri, 2 Jan 2015 16:02:49 +0100 Subject: i386: Fix typos in comments (found by codespell) Signed-off-by: Stefan Weil --- i386/i386/io_perm.c | 2 +- i386/i386/pcb.c | 2 +- i386/i386/trap.c | 2 +- i386/i386at/com.c | 2 +- i386/i386at/kd.c | 6 +++--- i386/include/mach/i386/vm_param.h | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/i386/i386/io_perm.c b/i386/i386/io_perm.c index 6a6e6600..d5c71035 100644 --- a/i386/i386/io_perm.c +++ b/i386/i386/io_perm.c @@ -221,7 +221,7 @@ i386_io_perm_create (const ipc_port_t master_port, io_port_t from, io_port_t to, } /* Modify the I/O permissions for TARGET_TASK. If ENABLE is TRUE, the - permission to acces the I/O ports specified by IO_PERM is granted, + permission to access the I/O ports specified by IO_PERM is granted, otherwise it is withdrawn. The function returns KERN_INVALID_ARGUMENT if TARGET_TASK is not a valid diff --git a/i386/i386/pcb.c b/i386/i386/pcb.c index 5866cac6..e8040c83 100644 --- a/i386/i386/pcb.c +++ b/i386/i386/pcb.c @@ -801,7 +801,7 @@ thread_set_syscall_return( } /* - * Return prefered address of user stack. + * Return preferred address of user stack. * Always returns low address. If stack grows up, * the stack grows away from this address; * if stack grows down, the stack grows towards this diff --git a/i386/i386/trap.c b/i386/i386/trap.c index f1fe6343..64705049 100644 --- a/i386/i386/trap.c +++ b/i386/i386/trap.c @@ -574,7 +574,7 @@ i386_astintr(void) if (need_ast[mycpu] & AST_I386_FP) { /* * AST was for delayed floating-point exception - - * FP interrupt occured while in kernel. + * FP interrupt occurred while in kernel. * Turn off this AST reason and handle the FPU error. */ ast_off(mycpu, AST_I386_FP); diff --git a/i386/i386at/com.c b/i386/i386at/com.c index c36cb6ae..84891bd2 100644 --- a/i386/i386at/com.c +++ b/i386/i386at/com.c @@ -145,7 +145,7 @@ comprobe_general(struct bus_device *dev, int noisy) type = "82450 or 16450"; outb(FIFO_CTL(addr), iFIFOENA | iFIFO14CH); /* Enable fifo */ if ((inb(FIFO_CTL(addr)) & iFIFO14CH) != 0) - { /* Was it successfull */ + { /* Was it successful */ /* if both bits are not set then broken xx550 */ if ((inb(FIFO_CTL(addr)) & iFIFO14CH) == iFIFO14CH) { diff --git a/i386/i386at/kd.c b/i386/i386at/kd.c index 7339767e..bbb00239 100644 --- a/i386/i386at/kd.c +++ b/i386/i386at/kd.c @@ -204,7 +204,7 @@ u_char *esc_spt = (u_char *)0; - Delete returns `ESC [ 9' instead of 0x7f. - Alt + function keys return key sequences that are different from the key sequences returned by the function keys alone. - This is done with the idea of alowing a terminal server to + This is done with the idea of allowing a terminal server to implement multiple virtual consoles mapped on Alt+F1, Alt+F2, etc, as in Linux. @@ -1880,7 +1880,7 @@ kd_cr(void) * of the screen. * * input : None - * output : Screen is cleared from current cursor postion to bottom + * output : Screen is cleared from current cursor position to bottom * */ void @@ -1903,7 +1903,7 @@ kd_cltobcur(void) * of the screen. * * input : None - * output : Screen is cleared from current cursor postion to top + * output : Screen is cleared from current cursor position to top * */ void diff --git a/i386/include/mach/i386/vm_param.h b/i386/include/mach/i386/vm_param.h index 8f708f0f..3a209b83 100644 --- a/i386/include/mach/i386/vm_param.h +++ b/i386/include/mach/i386/vm_param.h @@ -29,7 +29,7 @@ * Date: 1985 * * I386 machine dependent virtual memory parameters. - * Most of the declarations are preceeded by I386_ (or i386_) + * Most of the declarations are preceded by I386_ (or i386_) * which is OK because only I386 specific code will be using * them. */ -- cgit v1.2.3 From 01273099a4b7afb3b1c6eac7b31d73f599ef0beb Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Fri, 2 Jan 2015 16:02:50 +0100 Subject: include: Fix typos in comments (found by codespell) Signed-off-by: Stefan Weil --- include/mach/profil.h | 2 +- include/mach/vm_param.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/mach/profil.h b/include/mach/profil.h index 0eb4ce47..866f267b 100644 --- a/include/mach/profil.h +++ b/include/mach/profil.h @@ -137,7 +137,7 @@ extern vm_map_t kernel_map; /* MACRO set_pbuf_value ** ** enters the value 'val' in the buffer 'pbuf' and returns the following -** indications: 0: means that a fatal error occured: the buffer was full +** indications: 0: means that a fatal error occurred: the buffer was full ** (it hasn't been sent yet) ** 1: means that a value has been inserted successfully ** 2: means that we'v just entered the last value causing diff --git a/include/mach/vm_param.h b/include/mach/vm_param.h index 03609815..cdccce82 100644 --- a/include/mach/vm_param.h +++ b/include/mach/vm_param.h @@ -39,7 +39,7 @@ #include /* - * The machine independent pages are refered to as PAGES. A page + * The machine independent pages are referred to as PAGES. A page * is some number of hardware pages, depending on the target machine. * * All references to the size of a page should be done -- cgit v1.2.3 From 2c8514cfafb6daec4e76e3a8e0f1fd07ca0a4a33 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Fri, 2 Jan 2015 16:02:51 +0100 Subject: ipc: Fix typo in comment (found by codespell) Signed-off-by: Stefan Weil --- ipc/port.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ipc/port.h b/ipc/port.h index d6fb59b3..d359115d 100644 --- a/ipc/port.h +++ b/ipc/port.h @@ -45,7 +45,7 @@ * mach_port_t must be an unsigned type. Port values * have two parts, a generation number and an index. * These macros encapsulate all knowledge of how - * a mach_port_t is layed out. However, ipc/ipc_entry.c + * a mach_port_t is laid out. However, ipc/ipc_entry.c * implicitly assumes when it uses the splay tree functions * that the generation number is in the low bits, so that * names are ordered first by index and then by generation. -- cgit v1.2.3 From b5365a3c2cdaa507c0af3edd30d9d597083606bc Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Fri, 2 Jan 2015 16:02:52 +0100 Subject: kern: Fix typos in comments (found by codespell) Signed-off-by: Stefan Weil --- kern/ipc_kobject.c | 2 +- kern/ipc_mig.c | 2 +- kern/mach_clock.c | 2 +- kern/profile.c | 2 +- kern/sched_prim.c | 2 +- kern/strings.c | 4 ++-- kern/xpr.h | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/kern/ipc_kobject.c b/kern/ipc_kobject.c index bf22028e..709ec9ec 100644 --- a/kern/ipc_kobject.c +++ b/kern/ipc_kobject.c @@ -244,7 +244,7 @@ ipc_kobject_server(request) } else { /* * The message contents of the request are intact. - * Destroy everthing except the reply port right, + * Destroy everything except the reply port right, * which is needed in the reply message. */ diff --git a/kern/ipc_mig.c b/kern/ipc_mig.c index 41ebc94e..cc61ec76 100644 --- a/kern/ipc_mig.c +++ b/kern/ipc_mig.c @@ -612,7 +612,7 @@ kern_return_t thread_set_state_KERNEL( * knows to fall back on an RPC. For other return values, it won't * retry with an RPC. The retry might get a different (incorrect) rc. * Return values are only set (and should only be set, with copyout) - * on successfull calls. + * on successful calls. */ kern_return_t diff --git a/kern/mach_clock.c b/kern/mach_clock.c index 0a7458b0..b627b89d 100644 --- a/kern/mach_clock.c +++ b/kern/mach_clock.c @@ -234,7 +234,7 @@ void clock_interrupt( update_mapped_time(&time); /* - * Schedule soft-interupt for timeout if needed + * Schedule soft-interrupt for timeout if needed */ if (needsoft) { if (basepri) { diff --git a/kern/profile.c b/kern/profile.c index e14d4116..55107218 100644 --- a/kern/profile.c +++ b/kern/profile.c @@ -194,7 +194,7 @@ thread_t th; * Make a request to the profile_thread by inserting * the buffer in the send queue, and wake it up. * The last buffer must be inserted at the head of the - * send queue, so the profile_thread handles it immediatly. + * send queue, so the profile_thread handles it immediately. */ if (kmem_alloc( kernel_map, &vm_buf_entry, sizeof(struct buf_to_send)) != KERN_SUCCESS) diff --git a/kern/sched_prim.c b/kern/sched_prim.c index 89fb1dc8..376217a8 100644 --- a/kern/sched_prim.c +++ b/kern/sched_prim.c @@ -155,7 +155,7 @@ void sched_init(void) min_quantum = hz / 10; /* context switch 10 times/second */ wait_queue_init(); - pset_sys_bootstrap(); /* initialize processer mgmt. */ + pset_sys_bootstrap(); /* initialize processor mgmt. */ queue_init(&action_queue); simple_lock_init(&action_lock); sched_tick = 0; diff --git a/kern/strings.c b/kern/strings.c index c77ae4fe..e299534a 100644 --- a/kern/strings.c +++ b/kern/strings.c @@ -50,7 +50,7 @@ * the contents are identical up to the length of s2. * It returns < 0 if the first differing character is smaller * in s1 than in s2 or if s1 is shorter than s2 and the - * contents are identical upto the length of s1. + * contents are identical up to the length of s1. */ int __attribute__ ((pure)) @@ -157,7 +157,7 @@ strncpy( /* * Abstract: - * strlen returns the number of characters in "string" preceeding + * strlen returns the number of characters in "string" preceding * the terminating null character. */ diff --git a/kern/xpr.h b/kern/xpr.h index 4a06216a..72f68170 100644 --- a/kern/xpr.h +++ b/kern/xpr.h @@ -34,7 +34,7 @@ * which will expand into the following code: * if (xprflags & XPR_SYSCALLS) * xpr("syscall: %d, 0x%x\n", syscallno, arg1); - * Xpr will log the pointer to the printf string and up to 6 arguements, + * Xpr will log the pointer to the printf string and up to 6 arguments, * along with a timestamp and cpuinfo (for multi-processor systems), into * a circular buffer. The actual printf processing is delayed until after * the buffer has been collected. It is assumed that the text/data segments -- cgit v1.2.3 From 87b7d8226c4219fdf7b6f607a437e9c93c9211d7 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Fri, 2 Jan 2015 16:02:53 +0100 Subject: vm: Fix typo in comment (found by codespell) Signed-off-by: Stefan Weil --- vm/vm_object.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vm/vm_object.c b/vm/vm_object.c index 582487e6..71c0edb6 100644 --- a/vm/vm_object.c +++ b/vm/vm_object.c @@ -1466,7 +1466,7 @@ vm_object_t vm_object_copy_delayed( * synchronization required in the "push" * operation described above. * - * The copy-on-write is said to be assymetric because + * The copy-on-write is said to be asymmetric because * the original object is *not* marked copy-on-write. * A copied page is pushed to the copy object, regardless * which party attempted to modify the page. -- cgit v1.2.3 From 023f1fd20f8ffc29e2daa383756599cf14888418 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Wed, 21 Jan 2015 00:09:10 +0100 Subject: ipc: warn about more port management bugs * ipc/mach_port.c (mach_port_destroy): Simplify expression. Reword warning. (mach_port_deallocate): Likewise. (mach_port_mod_refs): Also warn about errors when using this function. --- ipc/mach_port.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/ipc/mach_port.c b/ipc/mach_port.c index c7d9b810..4e895275 100644 --- a/ipc/mach_port.c +++ b/ipc/mach_port.c @@ -570,8 +570,8 @@ 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 %.*s destroying an invalid port %lu, most probably a bug.\n", sizeof current_task()->name, current_task()->name, name); + if (MACH_PORT_VALID (name) && space == current_space()) { + printf("task %.*s destroying a bogus port %lu, most probably a bug.\n", sizeof current_task()->name, current_task()->name, name); if (mach_port_deallocate_debug) SoftDebugger("mach_port_deallocate"); } @@ -614,8 +614,8 @@ 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 %.*s deallocating an invalid port %lu, most probably a bug.\n", sizeof current_task()->name, current_task()->name, name); + if (MACH_PORT_VALID (name) && space == current_space()) { + printf("task %.*s deallocating a bogus port %lu, most probably a bug.\n", sizeof current_task()->name, current_task()->name, name); if (mach_port_deallocate_debug) SoftDebugger("mach_port_deallocate"); } @@ -735,8 +735,19 @@ mach_port_mod_refs( return KERN_INVALID_VALUE; kr = ipc_right_lookup_write(space, name, &entry); - if (kr != KERN_SUCCESS) + if (kr != KERN_SUCCESS) { + if (MACH_PORT_VALID (name) && space == current_space()) { + printf("task %.*s %screasing a bogus port " + "%lu by %d, most probably a bug.\n", + sizeof current_task()->name, + current_task()->name, + delta < 0 ? "de" : "in", name, + delta < 0 ? -delta : delta); + if (mach_port_deallocate_debug) + SoftDebugger("mach_port_mod_refs"); + } return kr; + } /* space is write-locked and active */ kr = ipc_right_delta(space, name, entry, right, delta); /* unlocks */ -- cgit v1.2.3 From aabd2b8ef9b1caa4c1f4339adeebef62b34f7a01 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Tue, 17 Feb 2015 22:37:01 +0100 Subject: vm: fix typo * vm/vm_resident.c: Fix typo. --- vm/vm_resident.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vm/vm_resident.c b/vm/vm_resident.c index fa02cbcd..c70fa734 100644 --- a/vm/vm_resident.c +++ b/vm/vm_resident.c @@ -65,7 +65,7 @@ /* - * Associated with eacn page of user-allocatable memory is a + * Associated with each page of user-allocatable memory is a * page structure. */ -- cgit v1.2.3 From b0fa32c1d7de74a8b83b33833640ff30c84e9fbd Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Wed, 18 Feb 2015 06:40:07 +0100 Subject: kern: avoid #if 0ing out thread_collect_scan Currently, `thread_collect_scan' does nothing because `pcb_collect' is a nop. Its body is exempt from compilation by means of the preprocessor. This is unfortunate as it increases the risk of bitrot, and we still need to pay the price of rate-limiting thread_collect_scan. * kern/thread.c (thread_collect_scan): Drop #if 0 around the body. * vm/vm_pageout.c (vm_pageout_scan): Do not call `consider_thread_collect' and document why. --- kern/thread.c | 2 -- vm/vm_pageout.c | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kern/thread.c b/kern/thread.c index 84749501..c627a06d 100644 --- a/kern/thread.c +++ b/kern/thread.c @@ -2236,7 +2236,6 @@ thread_wire( void thread_collect_scan(void) { -#if 0 register thread_t thread, prev_thread; processor_set_t pset, prev_pset; @@ -2289,7 +2288,6 @@ void thread_collect_scan(void) thread_deallocate(prev_thread); if (prev_pset != PROCESSOR_SET_NULL) pset_deallocate(prev_pset); -#endif /* 0 */ } boolean_t thread_collect_allowed = TRUE; diff --git a/vm/vm_pageout.c b/vm/vm_pageout.c index ecedb571..aff823ab 100644 --- a/vm/vm_pageout.c +++ b/vm/vm_pageout.c @@ -551,6 +551,8 @@ void vm_pageout_scan(void) stack_collect(); net_kmsg_collect(); consider_task_collect(); + if (0) /* XXX: pcb_collect doesn't do anything yet, so it is + pointless to call consider_thread_collect. */ consider_thread_collect(); slab_collect(); -- cgit v1.2.3 From 739421ac52472d8dd2f23c141d449ff112fbf9b6 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Tue, 30 Sep 2014 09:08:44 +0200 Subject: kern: reduce the size of `struct thread' Reduce the size of `struct thread' by twelve bytes making it fit into exactly five cache lines (on 32-bit platforms). * kern/thread.h (struct thread): Group the state and all flags in a bitfield. (TH_EV_WAKE_ACTIVE, TH_EV_STATE): Provide macros that generate keys for synchronization primitives like `thread_wakeup'. * kern/thread.c (thread_halt, thread_dowait, thread_suspend): Use the new keys instead of addresses of fields for the synchronisation. * kern/ipc_sched.c (thread_handoff): Likewise. * kern/sched_prim.c (thread_invoke, thread_dispatch): Likewise. --- kern/ipc_sched.c | 2 +- kern/sched_prim.c | 10 +++++----- kern/thread.c | 12 ++++++------ kern/thread.h | 27 +++++++++++++++++++++++---- 4 files changed, 35 insertions(+), 16 deletions(-) diff --git a/kern/ipc_sched.c b/kern/ipc_sched.c index cc1672d6..be82971b 100644 --- a/kern/ipc_sched.c +++ b/kern/ipc_sched.c @@ -268,7 +268,7 @@ thread_handoff( */ old->wake_active = FALSE; thread_unlock(old); - thread_wakeup((event_t)&old->wake_active); + thread_wakeup(TH_EV_WAKE_ACTIVE(old)); goto after_old_thread; } } else diff --git a/kern/sched_prim.c b/kern/sched_prim.c index 376217a8..d7792ae6 100644 --- a/kern/sched_prim.c +++ b/kern/sched_prim.c @@ -615,7 +615,7 @@ boolean_t thread_invoke( thread_lock(new_thread); new_thread->state &= ~TH_UNINT; thread_unlock(new_thread); - thread_wakeup(&new_thread->state); + thread_wakeup(TH_EV_STATE(new_thread)); if (continuation != (void (*)()) 0) { (void) spl0(); @@ -637,7 +637,7 @@ boolean_t thread_invoke( new_thread->state &= ~(TH_SWAPPED | TH_UNINT); thread_unlock(new_thread); - thread_wakeup(&new_thread->state); + thread_wakeup(TH_EV_STATE(new_thread)); #if NCPUS > 1 new_thread->last_processor = current_processor(); @@ -676,7 +676,7 @@ boolean_t thread_invoke( if (old_thread->wake_active) { old_thread->wake_active = FALSE; thread_unlock(old_thread); - thread_wakeup((event_t)&old_thread->wake_active); + thread_wakeup(TH_EV_WAKE_ACTIVE(old_thread)); goto after_old_thread; } @@ -767,7 +767,7 @@ boolean_t thread_invoke( new_thread->state &= ~(TH_SWAPPED | TH_UNINT); thread_unlock(new_thread); - thread_wakeup(&new_thread->state); + thread_wakeup(TH_EV_STATE(new_thread)); /* * Thread is now interruptible. @@ -932,7 +932,7 @@ void thread_dispatch( if (thread->wake_active) { thread->wake_active = FALSE; thread_unlock(thread); - thread_wakeup((event_t)&thread->wake_active); + thread_wakeup(TH_EV_WAKE_ACTIVE(thread)); return; } break; diff --git a/kern/thread.c b/kern/thread.c index c627a06d..5ffa844e 100644 --- a/kern/thread.c +++ b/kern/thread.c @@ -968,7 +968,7 @@ kern_return_t thread_halt( * operation can never cause a deadlock.) */ if (cur_thread->ast & AST_HALT) { - thread_wakeup_with_result((event_t)&cur_thread->wake_active, + thread_wakeup_with_result(TH_EV_WAKE_ACTIVE(cur_thread), THREAD_INTERRUPTED); thread_unlock(thread); thread_unlock(cur_thread); @@ -1006,7 +1006,7 @@ kern_return_t thread_halt( */ while ((thread->ast & AST_HALT) && (!(thread->state & TH_HALTED))) { thread->wake_active = TRUE; - thread_sleep((event_t) &thread->wake_active, + thread_sleep(TH_EV_WAKE_ACTIVE(thread), simple_lock_addr(thread->lock), TRUE); if (thread->state & TH_HALTED) { @@ -1045,7 +1045,7 @@ kern_return_t thread_halt( s = splsched(); thread_lock(thread); thread_ast_clear(thread, AST_HALT); - thread_wakeup_with_result((event_t)&thread->wake_active, + thread_wakeup_with_result(TH_EV_WAKE_ACTIVE(thread), THREAD_INTERRUPTED); thread_unlock(thread); (void) splx(s); @@ -1284,7 +1284,7 @@ thread_dowait( * Check for failure if interrupted. */ thread->wake_active = TRUE; - thread_sleep((event_t) &thread->wake_active, + thread_sleep(TH_EV_WAKE_ACTIVE(thread), simple_lock_addr(thread->lock), TRUE); thread_lock(thread); if ((current_thread()->wait_result != THREAD_AWAKENED) && @@ -1308,7 +1308,7 @@ thread_dowait( (void) splx(s); if (need_wakeup) - thread_wakeup((event_t) &thread->wake_active); + thread_wakeup(TH_EV_WAKE_ACTIVE(thread)); return ret; } @@ -1346,7 +1346,7 @@ kern_return_t thread_suspend( thread_lock(thread); /* Wait for thread to get interruptible */ while (thread->state & TH_UNINT) { - assert_wait(&thread->state, TRUE); + assert_wait(TH_EV_STATE(thread), TRUE); thread_unlock(thread); thread_block(NULL); thread_lock(thread); diff --git a/kern/thread.h b/kern/thread.h index d088c274..0e85d8c4 100644 --- a/kern/thread.h +++ b/kern/thread.h @@ -70,6 +70,22 @@ struct thread { task_t task; /* Task to which I belong */ queue_chain_t thread_list; /* list of threads in task */ + /* Flags */ + /* The flags are grouped here, but documented at the original + position. */ + union { + struct { + unsigned state:16; + unsigned wake_active:1; + unsigned vm_privilege:1; + unsigned active:1; + }; + event_t event_key; +/* These keys can be used with thread_wakeup and friends. */ +#define TH_EV_WAKE_ACTIVE(t) ((event_t) (&(t)->event_key + 0)) +#define TH_EV_STATE(t) ((event_t) (&(t)->event_key + 1)) + }; + /* Thread bookkeeping */ queue_chain_t pset_threads; /* list of all threads in proc set*/ @@ -92,9 +108,10 @@ struct thread { kern_return_t wait_result; /* outcome of wait - may be examined by this thread WITHOUT locking */ - boolean_t wake_active; /* someone is waiting for this + /* Defined above */ + /* boolean_t wake_active; someone is waiting for this thread to become suspended */ - int state; /* Thread state: */ + /* int state; Thread state: */ /* * Thread states [bits or'ed] */ @@ -129,7 +146,8 @@ struct thread { /* VM global variables */ vm_offset_t recover; /* page fault recovery (copyin/out) */ - boolean_t vm_privilege; /* Can use reserved memory? */ + /* Defined above */ + /* boolean_t vm_privilege; Can use reserved memory? */ /* User-visible scheduling state */ int user_stop_count; /* outstanding stops */ @@ -194,7 +212,8 @@ struct thread { timer_elt_data_t depress_timer; /* timer for priority depression */ /* Ast/Halt data structures */ - boolean_t active; /* how alive is the thread */ + /* Defined above */ + /* boolean_t active; how alive is the thread */ int ast; /* ast's needed. See ast.h */ /* Processor data structures */ -- cgit v1.2.3 From f2550dfc73da3951b411157d73bb4ad7bd2ea0b2 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Fri, 19 Dec 2014 02:02:44 +0100 Subject: linux: fix compiler warning If the loop above completes at least one iteration, `i' will be larger than zero. * linux/dev/glue/block.c (rdwr_full): Add assertion to appease the compiler. --- linux/dev/glue/block.c | 1 + 1 file changed, 1 insertion(+) diff --git a/linux/dev/glue/block.c b/linux/dev/glue/block.c index 79a3646e..da4ef38e 100644 --- a/linux/dev/glue/block.c +++ b/linux/dev/glue/block.c @@ -624,6 +624,7 @@ rdwr_full (int rw, kdev_t dev, loff_t *off, char **buf, int *resid, int bshift) } if (! err) { + assert (i > 0); ll_rw_block (rw, i, bhp, 0); wait_on_buffer (bhp[i - 1]); } -- cgit v1.2.3 From c2d5ad6f96746593257eb6aba02aae5de3d93664 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Fri, 19 Dec 2014 01:49:09 +0100 Subject: kern: improve assert Use the ternary operator to implement `assert' like it is done in the glibc. The glibcs changelog does not mention the rationale behind this change, but doing the same seems to improve our IPC performance. * kern/assert.h (assert): Define macro using the ternary operator. --- kern/assert.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/kern/assert.h b/kern/assert.h index b074fbb6..bd2a8beb 100644 --- a/kern/assert.h +++ b/kern/assert.h @@ -39,10 +39,9 @@ extern void Assert(const char *exp, const char *filename, int line) __attribute__ ((noreturn)); #define assert(ex) \ -MACRO_BEGIN \ - if (!(ex)) \ - Assert(#ex, __FILE__, __LINE__); \ -MACRO_END + ((ex) \ + ? (void) (0) \ + : Assert (#ex, __FILE__, __LINE__)) #define assert_static(x) assert(x) -- cgit v1.2.3 From 5bf4c1cb311ade33ea2c4b3706f7c6a42917b008 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Fri, 20 Feb 2015 19:03:20 +0100 Subject: i386: drop needless instruction from `copyout' * i386/i386/locore.S (copyout): Do not needlessly copy length to %eax first. --- i386/i386/locore.S | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/i386/i386/locore.S b/i386/i386/locore.S index 15715f6b..2e04bb89 100644 --- a/i386/i386/locore.S +++ b/i386/i386/locore.S @@ -1297,14 +1297,13 @@ Entry(copyoutmsg) jbe copyout_retry /* Use slow version on i386 */ #endif /* !defined(MACH_HYP) && !PAE */ - movl %edx,%eax /* use count */ /*cld*/ /* count up: always this way in GCC code */ - movl %eax,%ecx /* move by longwords first */ + movl %edx,%ecx /* move by longwords first */ shrl $2,%ecx RECOVER(copyout_fail) rep movsl - movl %eax,%ecx /* now move remaining bytes */ + movl %edx,%ecx /* now move remaining bytes */ andl $3,%ecx RECOVER(copyout_fail) rep -- cgit v1.2.3 From d3f20b06cee70fd5afe8aaff31614756a57e6bb6 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Fri, 19 Dec 2014 01:51:58 +0100 Subject: i386: specialize `copyinmsg' and `copyoutmsg' Previously, `copyinmsg' was the same function as `copyin'. The former is for messages, and the size of messages is a multiple of four. Likewise for `copyoutmsg'. Provide a specialized version of both functions. This shaves off a couple of instructions and improves our IPC performance. * i386/i386/locore.S (copyinmsg): New function. (copyoutmsg): New function. --- i386/i386/locore.S | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 79 insertions(+), 4 deletions(-) diff --git a/i386/i386/locore.S b/i386/i386/locore.S index 2e04bb89..cfda86f0 100644 --- a/i386/i386/locore.S +++ b/i386/i386/locore.S @@ -1232,13 +1232,12 @@ ENTRY(discover_x86_cpu_type) */ /* - * Copy from user address space. + * Copy from user address space - generic version. * arg0: user address * arg1: kernel address * arg2: byte count */ ENTRY(copyin) -Entry(copyinmsg) pushl %esi pushl %edi /* save registers */ @@ -1275,13 +1274,48 @@ copyin_fail: jmp copyin_ret /* pop frame and return */ /* - * Copy to user address space. + * Copy from user address space - version for copying messages. + * arg0: user address + * arg1: kernel address + * arg2: byte count - must be a multiple of four + */ +ENTRY(copyinmsg) + pushl %esi + pushl %edi /* save registers */ + + movl 8+S_ARG0,%esi /* get user start address */ + movl 8+S_ARG1,%edi /* get kernel destination address */ + movl 8+S_ARG2,%ecx /* get count */ + + movl $USER_DS,%eax /* use user data segment for accesses */ + mov %ax,%ds + + /*cld*/ /* count up: default mode in all GCC code */ + shrl $2,%ecx + RECOVER(copyinmsg_fail) + rep + movsl /* move longwords */ + xorl %eax,%eax /* return 0 for success */ + +copyinmsg_ret: + mov %ss,%di /* restore DS to kernel segment */ + mov %di,%ds + + popl %edi /* restore registers */ + popl %esi + ret /* and return */ + +copyinmsg_fail: + movl $1,%eax /* return 1 for failure */ + jmp copyinmsg_ret /* pop frame and return */ + +/* + * Copy to user address space - generic version. * arg0: kernel address * arg1: user address * arg2: byte count */ ENTRY(copyout) -Entry(copyoutmsg) pushl %esi pushl %edi /* save registers */ @@ -1322,6 +1356,47 @@ copyout_fail: movl $1,%eax /* return 1 for failure */ jmp copyout_ret /* pop frame and return */ +/* + * Copy to user address space - version for copying messages. + * arg0: kernel address + * arg1: user address + * arg2: byte count - must be a multiple of four + */ +ENTRY(copyoutmsg) + pushl %esi + pushl %edi /* save registers */ + + movl 8+S_ARG0,%esi /* get kernel start address */ + movl 8+S_ARG1,%edi /* get user start address */ + movl 8+S_ARG2,%ecx /* get count */ + + movl $USER_DS,%eax /* use user data segment for accesses */ + mov %ax,%es + +#if !defined(MACH_HYP) && !PAE + movl 8+S_ARG2,%edx /* copyout_retry expects count here */ + cmpl $3,machine_slot+SUB_TYPE_CPU_TYPE + jbe copyout_retry /* Use slow version on i386 */ +#endif /* !defined(MACH_HYP) && !PAE */ + + shrl $2,%ecx /* move by longwords */ + RECOVER(copyoutmsg_fail) + rep + movsl + xorl %eax,%eax /* return 0 for success */ + +copyoutmsg_ret: + mov %ss,%di /* restore ES to kernel segment */ + mov %di,%es + + popl %edi /* restore registers */ + popl %esi + ret /* and return */ + +copyoutmsg_fail: + movl $1,%eax /* return 1 for failure */ + jmp copyoutmsg_ret /* pop frame and return */ + #if !defined(MACH_HYP) && !PAE /* * Check whether user address space is writable -- cgit v1.2.3 From fe820bd2e22e5a0b5aa5bd50de3b06759e42af78 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Thu, 16 Oct 2014 18:13:39 +0200 Subject: kern: inherit the name of the parent task * kern/task.c (task_create): Inherit the name of the parent task. --- kern/task.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/kern/task.c b/kern/task.c index a11fb8ee..57e7f413 100644 --- a/kern/task.c +++ b/kern/task.c @@ -171,7 +171,12 @@ kern_return_t task_create( } #endif /* FAST_TAS */ - snprintf (new_task->name, sizeof new_task->name, "%p", new_task); + if (parent_task == TASK_NULL) + snprintf (new_task->name, sizeof new_task->name, "%p", + new_task); + else + snprintf (new_task->name, sizeof new_task->name, "(%.*s)", + sizeof new_task->name - 3, parent_task->name); if (new_task_notification != NULL) { task_reference (new_task); -- cgit v1.2.3 From 8d7cca39dd2c481e4c08d2dd2dc980fee22230ef Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Thu, 26 Feb 2015 09:24:04 +0100 Subject: Limit printing "queue full" messages * i386/i386at/kd_event.c (kbd_enqueue): Print "queue full" warning only once. * i386/i386at/kd_mouse.c (mouse_enqueue): Likewise. --- i386/i386at/kd_event.c | 9 ++++++++- i386/i386at/kd_mouse.c | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/i386/i386at/kd_event.c b/i386/i386at/kd_event.c index b60118e1..53dade76 100644 --- a/i386/i386at/kd_event.c +++ b/i386/i386at/kd_event.c @@ -293,7 +293,14 @@ void kbd_enqueue(kd_event *ev) { if (kdq_full(&kbd_queue)) - printf("kbd: queue full\n"); + { + static int warned; + if (!warned) + { + printf("kbd: queue full\n"); + warned = 1; + } + } else kdq_put(&kbd_queue, ev); diff --git a/i386/i386at/kd_mouse.c b/i386/i386at/kd_mouse.c index 16241efc..50a36831 100644 --- a/i386/i386at/kd_mouse.c +++ b/i386/i386at/kd_mouse.c @@ -789,7 +789,14 @@ void mouse_enqueue(kd_event *ev) { if (kdq_full(&mouse_queue)) - printf("mouse: queue full\n"); + { + static int warned; + if (!warned) + { + printf("mouse: queue full\n"); + warned = 1; + } + } else kdq_put(&mouse_queue, ev); -- cgit v1.2.3 From e0372735e1496bd6c47a264ef925bd39f29ad3ed Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Thu, 26 Feb 2015 21:00:11 +0100 Subject: Use printf_once instead of recoding it * i386/i386at/kd_event.c: Call printf_once instead of recoding it. * i386/i386at/kd_mouse.c: Likewise. --- i386/i386at/kd_event.c | 9 +-------- i386/i386at/kd_mouse.c | 9 +-------- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/i386/i386at/kd_event.c b/i386/i386at/kd_event.c index 53dade76..694c165e 100644 --- a/i386/i386at/kd_event.c +++ b/i386/i386at/kd_event.c @@ -293,14 +293,7 @@ void kbd_enqueue(kd_event *ev) { if (kdq_full(&kbd_queue)) - { - static int warned; - if (!warned) - { - printf("kbd: queue full\n"); - warned = 1; - } - } + printf_once("kbd: queue full\n"); else kdq_put(&kbd_queue, ev); diff --git a/i386/i386at/kd_mouse.c b/i386/i386at/kd_mouse.c index 50a36831..0f1881f4 100644 --- a/i386/i386at/kd_mouse.c +++ b/i386/i386at/kd_mouse.c @@ -789,14 +789,7 @@ void mouse_enqueue(kd_event *ev) { if (kdq_full(&mouse_queue)) - { - static int warned; - if (!warned) - { - printf("mouse: queue full\n"); - warned = 1; - } - } + printf_once("mouse: queue full\n"); else kdq_put(&mouse_queue, ev); -- cgit v1.2.3 From 713e142a5e98e394454c202abffb645181e11964 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Thu, 5 Mar 2015 20:15:23 +0100 Subject: Show odd number of ports * linux/dev/drivers/block/ahci.c (ahci_probe_dev): Show odd number of ports. --- linux/dev/drivers/block/ahci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux/dev/drivers/block/ahci.c b/linux/dev/drivers/block/ahci.c index 2b348e65..868f8d01 100644 --- a/linux/dev/drivers/block/ahci.c +++ b/linux/dev/drivers/block/ahci.c @@ -868,7 +868,7 @@ static void ahci_probe_dev(unsigned char bus, unsigned char device) n++; if (nports != n) { - printk("ahci: %02u:%02u.%u: Odd number of ports, assuming %d is correct\n", bus, dev, fun, nports); + printk("ahci: %02u:%02u.%u: Odd number of ports %u, assuming %u is correct\n", bus, dev, fun, n, nports); port_map = 0; } if (!port_map) { -- cgit v1.2.3 From f9ab17f900ccce345539a0d7a0c09363d414c7dc Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 8 Mar 2015 11:56:18 +0100 Subject: Remove spl debugging in Xen case xen cli/sti doesn't use IF * i386/i386/spl.S [MACH_XEN]: Disable IF check. --- i386/i386/spl.S | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/i386/i386/spl.S b/i386/i386/spl.S index 41458ac4..1dce991d 100644 --- a/i386/i386/spl.S +++ b/i386/i386/spl.S @@ -149,7 +149,7 @@ ENTRY(spl7) ENTRY(splx) movl S_ARG0,%edx /* get ipl */ -#if MACH_KDB || MACH_TTD +#if (MACH_KDB || MACH_TTD) && !defined(MACH_XEN) /* First make sure that if we're exitting from ipl7, IF is still cleared */ cmpl $SPL7,EXT(curr_ipl) /* from ipl7? */ jne 0f @@ -160,7 +160,7 @@ ENTRY(splx) int3 /* Oops, interrupts got enabled?! */ 0: -#endif /* MACH_KDB || MACH_TTD */ +#endif /* (MACH_KDB || MACH_TTD) && !MACH_XEN */ testl %edx,%edx /* spl0? */ jz EXT(spl0) /* yes, handle specially */ cmpl EXT(curr_ipl),%edx /* same ipl as current? */ @@ -227,7 +227,7 @@ splx_cli: .align TEXT_ALIGN .globl spl spl: -#if MACH_KDB || MACH_TTD +#if (MACH_KDB || MACH_TTD) && !defined(MACH_XEN) /* First make sure that if we're exitting from ipl7, IF is still cleared */ cmpl $SPL7,EXT(curr_ipl) /* from ipl7? */ jne 0f @@ -238,7 +238,7 @@ spl: int3 /* Oops, interrupts got enabled?! */ 0: -#endif /* MACH_KDB || MACH_TTD */ +#endif /* (MACH_KDB || MACH_TTD) && !MACH_XEN */ cmpl $SPL7,%edx /* spl7? */ je EXT(spl7) /* yes, handle specially */ movl EXT(pic_mask)(,%edx,4),%eax -- cgit v1.2.3 From d7ca106218fd8f9864c67c2f8335dd7b7c851865 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Thu, 19 Mar 2015 16:44:29 +0100 Subject: Give the Debian package name for the non-multilib libc.a * Makefile.am (clib-routines.o): Mention the Debian libc6-dev:i386 package. --- Makefile.am | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.am b/Makefile.am index 1afddab2..2c394518 100644 --- a/Makefile.am +++ b/Makefile.am @@ -173,8 +173,8 @@ clib-routines.o: gnumach-undef gnumach-undef-bad then cat gnumach-undef-bad; exit 2; else true; fi $(AM_V_CCLD) $(CCLD) -nostdlib -nostartfiles -r -static \ -o $@ `sed 's/^/-Wl,-u,/' < $<` -x c /dev/null -lc -lgcc - $(AM_V_at) if nm $@ | grep __init_cpu_features; \ - then echo Please install a 32bit libc without multiarch support. ; \ + @if nm $@ | grep __init_cpu_features; \ + then echo "Please install a 32bit libc without multiarch support (on Debian systems, the libc6-dev:i386 package containing /usr/lib/i386-linux-gnu/libc.a)". ; \ false ; fi gnumach_LINK = $(LD) $(LINKFLAGS) $(gnumach_LINKFLAGS) -o $@ -- cgit v1.2.3 From fabef8ce0ab00a2a6c92e100075dd8813af14998 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Fri, 10 Apr 2015 12:42:40 +0200 Subject: GNU Mach 1.5. * version.m4 (AC_PACKAGE_VERSION): Set to 1.5. * NEWS: Finalize for 1.5. --- NEWS | 6 ++---- version.m4 | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index 357b23f9..5d220fab 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,4 @@ -2014-XX-XX -Version 1.5 +Version 1.5 (2015-04-10) Numerous cleanups and stylistic fixes of the code base. Several problems have been identified using static analysis tools and @@ -18,8 +17,7 @@ The vm pageout policy has been tuned to accommodate modern hardware. The kernel gained partial ACPI support on x86, enough to power down the system. -2013-09-27 -Version 1.4 +Version 1.4 (2013-09-27) Really too many to list them individually. Highlight include numerous bug and stability fixes, a Xen port for 32-bit x86 including basic support for Physical diff --git a/version.m4 b/version.m4 index 4e1a2fd9..9bebd3b8 100644 --- a/version.m4 +++ b/version.m4 @@ -1,4 +1,4 @@ m4_define([AC_PACKAGE_NAME],[GNU Mach]) -m4_define([AC_PACKAGE_VERSION],[1.4]) +m4_define([AC_PACKAGE_VERSION],[1.5]) m4_define([AC_PACKAGE_BUGREPORT],[bug-hurd@gnu.org]) m4_define([AC_PACKAGE_TARNAME],[gnumach]) -- cgit v1.2.3 From c9aae1b6dadccfe81f919a2cc1eb393b1fda9b03 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Thu, 23 Apr 2015 01:24:39 +0200 Subject: Prepend 0x to hexadecimal offset * i386/i386/db_trace.c (db_i386_stack_trace): Prepend 0x to hexadecimal offset. --- i386/i386/db_trace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i386/i386/db_trace.c b/i386/i386/db_trace.c index cdebde18..ec338591 100644 --- a/i386/i386/db_trace.c +++ b/i386/i386/db_trace.c @@ -488,7 +488,7 @@ db_i386_stack_trace( db_printf("..."); db_printf(")"); if (offset) { - db_printf("+%x", offset); + db_printf("+0x%x", offset); } if (db_line_at_pc(0, &filename, &linenum, callpc)) { db_printf(" [%s", filename); -- cgit v1.2.3 From bdd46d40d96c4da6f2b98d4e1b2aa04ba5f5848e Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Thu, 23 Apr 2015 01:42:49 +0200 Subject: Avoid accessing ip_protected_payload without the lock. * ipc/ipc_kmsg.c (ipc_kmsg_copyout_header): Avoid accessing dest->ip_protected_payload without the lock. * ipc/mach_msg.c (ipc/mach_msg.c): Avoid accessing dest_port->ip_protected_payload without the lock. --- ipc/ipc_kmsg.c | 21 ++++++++++++++------- ipc/mach_msg.c | 14 +++++++++++--- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/ipc/ipc_kmsg.c b/ipc/ipc_kmsg.c index 66643fd5..c0f07dd8 100644 --- a/ipc/ipc_kmsg.c +++ b/ipc/ipc_kmsg.c @@ -1766,6 +1766,7 @@ ipc_kmsg_copyout_header( case MACH_MSGH_BITS(MACH_MSG_TYPE_PORT_SEND, 0): { mach_port_t dest_name; ipc_port_t nsrequest; + unsigned long payload; /* receiving an asynchronous message */ @@ -1784,6 +1785,7 @@ ipc_kmsg_copyout_header( dest_name = dest->ip_receiver_name; else dest_name = MACH_PORT_NULL; + payload = dest->ip_protected_payload; if ((--dest->ip_srights == 0) && ((nsrequest = dest->ip_nsrequest) != IP_NULL)) { @@ -1805,8 +1807,7 @@ ipc_kmsg_copyout_header( msg->msgh_bits = (MACH_MSGH_BITS_OTHER(mbits) | MACH_MSGH_BITS( 0, MACH_MSG_TYPE_PROTECTED_PAYLOAD)); - msg->msgh_protected_payload = - dest->ip_protected_payload; + msg->msgh_protected_payload = payload; } msg->msgh_remote_port = MACH_PORT_NULL; return MACH_MSG_SUCCESS; @@ -1820,6 +1821,7 @@ ipc_kmsg_copyout_header( ipc_port_t reply = (ipc_port_t) msg->msgh_local_port; mach_port_t dest_name, reply_name; ipc_port_t nsrequest; + unsigned long payload; /* receiving a request message */ @@ -1890,6 +1892,7 @@ ipc_kmsg_copyout_header( dest_name = dest->ip_receiver_name; else dest_name = MACH_PORT_NULL; + payload = dest->ip_protected_payload; if ((--dest->ip_srights == 0) && ((nsrequest = dest->ip_nsrequest) != IP_NULL)) { @@ -1912,8 +1915,7 @@ ipc_kmsg_copyout_header( msg->msgh_bits = (MACH_MSGH_BITS_OTHER(mbits) | MACH_MSGH_BITS(MACH_MSG_TYPE_PORT_SEND_ONCE, MACH_MSG_TYPE_PROTECTED_PAYLOAD)); - msg->msgh_protected_payload = - dest->ip_protected_payload; + msg->msgh_protected_payload = payload; } msg->msgh_remote_port = reply_name; return MACH_MSG_SUCCESS; @@ -1921,6 +1923,7 @@ ipc_kmsg_copyout_header( case MACH_MSGH_BITS(MACH_MSG_TYPE_PORT_SEND_ONCE, 0): { mach_port_t dest_name; + unsigned long payload; /* receiving a reply message */ @@ -1934,6 +1937,8 @@ ipc_kmsg_copyout_header( assert(dest->ip_sorights > 0); + payload = dest->ip_protected_payload; + if (dest->ip_receiver == space) { ip_release(dest); dest->ip_sorights--; @@ -1955,8 +1960,7 @@ ipc_kmsg_copyout_header( msg->msgh_bits = (MACH_MSGH_BITS_OTHER(mbits) | MACH_MSGH_BITS(0, MACH_MSG_TYPE_PROTECTED_PAYLOAD)); - msg->msgh_protected_payload = - dest->ip_protected_payload; + msg->msgh_protected_payload = payload; } msg->msgh_remote_port = MACH_PORT_NULL; return MACH_MSG_SUCCESS; @@ -1973,6 +1977,7 @@ ipc_kmsg_copyout_header( mach_msg_type_name_t reply_type = MACH_MSGH_BITS_LOCAL(mbits); ipc_port_t reply = (ipc_port_t) msg->msgh_local_port; mach_port_t dest_name, reply_name; + unsigned long payload; if (IP_VALID(reply)) { ipc_port_t notify_port; @@ -2219,6 +2224,7 @@ ipc_kmsg_copyout_header( */ copyout_dest: + payload = dest->ip_protected_payload; if (ip_active(dest)) { ipc_object_copyout_dest(space, (ipc_object_t) dest, @@ -2255,8 +2261,9 @@ ipc_kmsg_copyout_header( msg->msgh_bits = (MACH_MSGH_BITS_OTHER(mbits) | MACH_MSGH_BITS(reply_type, MACH_MSG_TYPE_PROTECTED_PAYLOAD)); - msg->msgh_protected_payload = dest->ip_protected_payload; + msg->msgh_protected_payload = payload; } + msg->msgh_remote_port = reply_name; } diff --git a/ipc/mach_msg.c b/ipc/mach_msg.c index 1e122c76..aecfcd4b 100644 --- a/ipc/mach_msg.c +++ b/ipc/mach_msg.c @@ -1041,6 +1041,7 @@ mach_msg_trap( ipc_port_t reply_port = (ipc_port_t) kmsg->ikm_header.msgh_local_port; mach_port_t dest_name, reply_name; + unsigned long payload; /* receiving a request message */ @@ -1115,6 +1116,7 @@ mach_msg_trap( dest_name = dest_port->ip_receiver_name; else dest_name = MACH_PORT_NULL; + payload = dest_port->ip_protected_payload; if ((--dest_port->ip_srights == 0) && (dest_port->ip_nsrequest != IP_NULL)) { @@ -1142,7 +1144,7 @@ mach_msg_trap( MACH_MSG_TYPE_PORT_SEND_ONCE, MACH_MSG_TYPE_PROTECTED_PAYLOAD); kmsg->ikm_header.msgh_protected_payload = - dest_port->ip_protected_payload; + payload; } kmsg->ikm_header.msgh_remote_port = reply_name; goto fast_put; @@ -1155,6 +1157,7 @@ mach_msg_trap( case MACH_MSGH_BITS(MACH_MSG_TYPE_PORT_SEND_ONCE, 0): { mach_port_t dest_name; + unsigned long payload; /* receiving a reply message */ @@ -1166,6 +1169,8 @@ mach_msg_trap( assert(dest_port->ip_sorights > 0); + payload = dest_port->ip_protected_payload; + if (dest_port->ip_receiver == space) { ip_release(dest_port); dest_port->ip_sorights--; @@ -1188,7 +1193,7 @@ mach_msg_trap( 0, MACH_MSG_TYPE_PROTECTED_PAYLOAD); kmsg->ikm_header.msgh_protected_payload = - dest_port->ip_protected_payload; + payload; } kmsg->ikm_header.msgh_remote_port = MACH_PORT_NULL; goto fast_put; @@ -1197,6 +1202,7 @@ mach_msg_trap( case MACH_MSGH_BITS_COMPLEX| MACH_MSGH_BITS(MACH_MSG_TYPE_PORT_SEND_ONCE, 0): { mach_port_t dest_name; + unsigned long payload; /* receiving a complex reply message */ @@ -1208,6 +1214,8 @@ mach_msg_trap( assert(dest_port->ip_sorights > 0); + payload = dest_port->ip_protected_payload; + if (dest_port->ip_receiver == space) { ip_release(dest_port); dest_port->ip_sorights--; @@ -1234,7 +1242,7 @@ mach_msg_trap( 0, MACH_MSG_TYPE_PROTECTED_PAYLOAD); kmsg->ikm_header.msgh_protected_payload = - dest_port->ip_protected_payload; + payload; } kmsg->ikm_header.msgh_remote_port = MACH_PORT_NULL; -- cgit v1.2.3 From 862b733dcbeabed8dd545e1c3b3e55bb4e4da52f Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Thu, 23 Apr 2015 19:51:51 +0200 Subject: kern: disable stack allocation counters by default Disable the stack allocation counters by default. Casual checking revealed that the hits-to-miss ratio is excellent. * kern/thread.c (stack_alloc_{hits,misses,max}): Move variables... * kern/counters.c: ... here, and add the usual counter prefix. * kern/counters.h: New declarations. --- kern/counters.c | 3 +++ kern/counters.h | 3 +++ kern/thread.c | 15 +++++++-------- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/kern/counters.c b/kern/counters.c index 74fd42d1..0a0665bf 100644 --- a/kern/counters.c +++ b/kern/counters.c @@ -46,6 +46,9 @@ mach_counter_t c_stacks_current = 0; mach_counter_t c_stacks_max = 0; mach_counter_t c_stacks_min = 0; mach_counter_t c_stacks_total = 0; +mach_counter_t c_stack_alloc_hits = 0; +mach_counter_t c_stack_alloc_misses = 0; +mach_counter_t c_stack_alloc_max = 0; mach_counter_t c_clock_ticks = 0; mach_counter_t c_ipc_mqueue_send_block = 0; mach_counter_t c_ipc_mqueue_receive_block_user = 0; diff --git a/kern/counters.h b/kern/counters.h index bfa9b44e..aa1e739b 100644 --- a/kern/counters.h +++ b/kern/counters.h @@ -69,6 +69,9 @@ extern mach_counter_t c_stacks_current; extern mach_counter_t c_stacks_max; extern mach_counter_t c_stacks_min; extern mach_counter_t c_stacks_total; +extern mach_counter_t c_stack_alloc_hits; +extern mach_counter_t c_stack_alloc_misses; +extern mach_counter_t c_stack_alloc_max; extern mach_counter_t c_clock_ticks; extern mach_counter_t c_ipc_mqueue_send_block; extern mach_counter_t c_ipc_mqueue_receive_block_user; diff --git a/kern/thread.c b/kern/thread.c index 5ffa844e..009884ce 100644 --- a/kern/thread.c +++ b/kern/thread.c @@ -124,10 +124,6 @@ vm_offset_t stack_free_list; /* splsched only */ unsigned int stack_free_count = 0; /* splsched only */ unsigned int stack_free_limit = 1; /* patchable */ -unsigned int stack_alloc_hits = 0; /* debugging */ -unsigned int stack_alloc_misses = 0; /* debugging */ -unsigned int stack_alloc_max = 0; /* debugging */ - /* * The next field is at the base of the stack, * so the low end is left unsullied. @@ -160,10 +156,10 @@ boolean_t stack_alloc_try( if (stack != 0) { stack_attach(thread, stack, resume); - stack_alloc_hits++; + counter(c_stack_alloc_hits++); return TRUE; } else { - stack_alloc_misses++; + counter(c_stack_alloc_misses++); return FALSE; } } @@ -235,8 +231,11 @@ void stack_free( stack_lock(); stack_next(stack) = stack_free_list; stack_free_list = stack; - if (++stack_free_count > stack_alloc_max) - stack_alloc_max = stack_free_count; + stack_free_count += 1; +#if MACH_COUNTERS + if (stack_free_count > c_stack_alloc_max) + c_stack_alloc_max = stack_free_count; +#endif /* MACH_COUNTERS */ stack_unlock(); } } -- cgit v1.2.3 From 3a4f2e95e91b1b23d5c11190ff2dfc3c048deffb Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Fri, 24 Apr 2015 00:08:23 +0200 Subject: kern: avoid hardcoding the lowest priority The number of priorities has been changed from 32 to 50 in 6a234201081156e6d5742e7eeabb68418b518fad. * kern/syscall_subr.c (thread_depress_priority): Avoid hardcoding the lowest priority. --- kern/syscall_subr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kern/syscall_subr.c b/kern/syscall_subr.c index 3c369ef3..6d23462c 100644 --- a/kern/syscall_subr.c +++ b/kern/syscall_subr.c @@ -302,8 +302,8 @@ thread_depress_priority( * sched_pri to their lowest possible values. */ thread->depress_priority = thread->priority; - thread->priority = 31; - thread->sched_pri = 31; + thread->priority = NRQS-1; + thread->sched_pri = NRQS-1; if (ticks != 0) set_timeout(&thread->depress_timer, ticks); -- cgit v1.2.3 From ea6acb75acf2cb3438f8b93480a2a4729807db85 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Thu, 30 Apr 2015 00:55:44 +0200 Subject: Fix build with gcc-5 * linux/src/include/linux/compiler-gcc5.h: New file. --- linux/src/include/linux/compiler-gcc5.h | 67 +++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 linux/src/include/linux/compiler-gcc5.h diff --git a/linux/src/include/linux/compiler-gcc5.h b/linux/src/include/linux/compiler-gcc5.h new file mode 100644 index 00000000..efee4937 --- /dev/null +++ b/linux/src/include/linux/compiler-gcc5.h @@ -0,0 +1,67 @@ +#ifndef __LINUX_COMPILER_H +#error "Please don't include directly, include instead." +#endif + +#define __used __attribute__((__used__)) +#define __must_check __attribute__((warn_unused_result)) +#define __compiler_offsetof(a, b) __builtin_offsetof(a, b) + +/* Mark functions as cold. gcc will assume any path leading to a call + to them will be unlikely. This means a lot of manual unlikely()s + are unnecessary now for any paths leading to the usual suspects + like BUG(), printk(), panic() etc. [but let's keep them for now for + older compilers] + + Early snapshots of gcc 4.3 don't support this and we can't detect this + in the preprocessor, but we can live with this because they're unreleased. + Maketime probing would be overkill here. + + gcc also has a __attribute__((__hot__)) to move hot functions into + a special section, but I don't see any sense in this right now in + the kernel context */ +#define __cold __attribute__((__cold__)) + +#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__) + +#ifndef __CHECKER__ +# define __compiletime_warning(message) __attribute__((warning(message))) +# define __compiletime_error(message) __attribute__((error(message))) +#endif /* __CHECKER__ */ + +/* + * Mark a position in code as unreachable. This can be used to + * suppress control flow warnings after asm blocks that transfer + * control elsewhere. + * + * Early snapshots of gcc 4.5 don't support this and we can't detect + * this in the preprocessor, but we can live with this because they're + * unreleased. Really, we need to have autoconf for the kernel. + */ +#define unreachable() __builtin_unreachable() + +/* Mark a function definition as prohibited from being cloned. */ +#define __noclone __attribute__((__noclone__)) + +/* + * Tell the optimizer that something else uses this function or variable. + */ +#define __visible __attribute__((externally_visible)) + +/* + * GCC 'asm goto' miscompiles certain code sequences: + * + * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58670 + * + * Work it around via a compiler barrier quirk suggested by Jakub Jelinek. + * + * (asm goto is automatically volatile - the naming reflects this.) + */ +#define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while (0) + +#ifdef CONFIG_ARCH_USE_BUILTIN_BSWAP +#define __HAVE_BUILTIN_BSWAP32__ +#define __HAVE_BUILTIN_BSWAP64__ +#define __HAVE_BUILTIN_BSWAP16__ +#endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP */ + +#define KASAN_ABI_VERSION 4 -- cgit v1.2.3 From 75a78c0eb4ed2d4bb9b461c4dae8aa71804b238b Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Fri, 1 May 2015 19:35:50 +0200 Subject: Replace clobbers with earlyclobbers Newer gccs consider the former "impossible" * linux/src/include/asm-i386/bitops.h (find_first_zero_bit): Replace clobbers with earlyclobbers. * linux/src/include/asm-i386/semaphore.h (down, down_interruptible, up): Likewise. --- linux/src/include/asm-i386/bitops.h | 6 +++--- linux/src/include/asm-i386/semaphore.h | 26 ++++++++++++++------------ 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/linux/src/include/asm-i386/bitops.h b/linux/src/include/asm-i386/bitops.h index fc4cf192..0bfa9fd3 100644 --- a/linux/src/include/asm-i386/bitops.h +++ b/linux/src/include/asm-i386/bitops.h @@ -108,6 +108,7 @@ extern __inline__ int test_bit(int nr, const SMPVOL void * addr) */ extern __inline__ int find_first_zero_bit(void * addr, unsigned size) { + int d0, d1, d2; int res; if (!size) @@ -123,9 +124,8 @@ extern __inline__ int find_first_zero_bit(void * addr, unsigned size) "1:\tsubl %%ebx,%%edi\n\t" "shll $3,%%edi\n\t" "addl %%edi,%%edx" - :"=d" (res) - :"c" ((size + 31) >> 5), "D" (addr), "b" (addr) - :"ax", "cx", "di"); + :"=d" (res), "=&c" (d0), "=&D" (d1), "=&a" (d2) + :"1" ((size + 31) >> 5), "2" (addr), "b" (addr)); return res; } diff --git a/linux/src/include/asm-i386/semaphore.h b/linux/src/include/asm-i386/semaphore.h index 1486d1c1..2a5f5b78 100644 --- a/linux/src/include/asm-i386/semaphore.h +++ b/linux/src/include/asm-i386/semaphore.h @@ -43,18 +43,19 @@ extern void __up(struct semaphore * sem); */ extern inline void down(struct semaphore * sem) { + int d0; __asm__ __volatile__( "# atomic down operation\n\t" "movl $1f,%%eax\n\t" #ifdef __SMP__ "lock ; " #endif - "decl 0(%0)\n\t" + "decl %1\n\t" "js " SYMBOL_NAME_STR(down_failed) "\n" "1:\n" - :/* no outputs */ - :"c" (sem) - :"ax","dx","memory"); + :"=&a" (d0), "=m" (sem->count) + : + :"memory"); } /* @@ -91,13 +92,13 @@ extern inline int down_interruptible(struct semaphore * sem) #ifdef __SMP__ "lock ; " #endif - "decl 0(%1)\n\t" + "decl %1\n\t" "js " SYMBOL_NAME_STR(down_failed_interruptible) "\n\t" "xorl %%eax,%%eax\n" "2:\n" - :"=a" (ret) - :"c" (sem) - :"ax","dx","memory"); + :"=&a" (ret), "=m" (sem->count) + : + :"memory"); return(ret) ; } @@ -110,18 +111,19 @@ extern inline int down_interruptible(struct semaphore * sem) */ extern inline void up(struct semaphore * sem) { + int d0; __asm__ __volatile__( "# atomic up operation\n\t" "movl $1f,%%eax\n\t" #ifdef __SMP__ "lock ; " #endif - "incl 0(%0)\n\t" + "incl %1\n\t" "jle " SYMBOL_NAME_STR(up_wakeup) "\n1:" - :/* no outputs */ - :"c" (sem) - :"ax", "dx", "memory"); + :"=&a" (d0), "=m" (sem->count) + : + :"memory"); } #endif -- cgit v1.2.3 From 7e0774107ef80938fdc9ab6e5d4808bcfdaf8ce9 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Fri, 1 May 2015 19:42:29 +0200 Subject: Use gnu89 inline style * Makefile.am (AM_CFLAGS): Add -fgnu89-inline option. --- Makefile.am | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Makefile.am b/Makefile.am index 2c394518..37dee761 100644 --- a/Makefile.am +++ b/Makefile.am @@ -63,6 +63,10 @@ AM_CFLAGS += \ AM_CFLAGS += \ -fno-strict-aliasing +# We need the GNU-style inline +AM_CFLAGS += \ + -fgnu89-inline + # The smashing stack protector might be enabled by default, but might emit # unsuitable code. if disable_smashing_stack_protector -- cgit v1.2.3 From 8ab33477c2009b998c781111ba53d38f3c90e427 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sat, 2 May 2015 14:05:52 +0200 Subject: Fix block_io_mmap prototype * device/blkio.c (block_io_mmap): Fix prototype of dummy function. * device/blkio.h (block_io_mmap): Likewise. --- device/blkio.c | 2 +- device/blkio.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/device/blkio.c b/device/blkio.c index ee866340..e5b4d09f 100644 --- a/device/blkio.c +++ b/device/blkio.c @@ -101,7 +101,7 @@ void minphys(io_req_t ior) * Dummy routine placed in device switch entries to indicate that * block device may be mapped. */ -vm_offset_t block_io_mmap(void) +int block_io_mmap(dev_t dev, vm_offset_t off, int prot) { return (0); } diff --git a/device/blkio.h b/device/blkio.h index 13a16690..77eb105a 100644 --- a/device/blkio.h +++ b/device/blkio.h @@ -19,6 +19,6 @@ #ifndef _DEVICE_BLKIO_H_ #define _DEVICE_BLKIO_H_ -extern vm_offset_t block_io_mmap(void); +extern int block_io_mmap(dev_t dev, vm_offset_t off, int prot); #endif /* _DEVICE_BLKIO_H_ */ -- cgit v1.2.3 From 30ce514d975026e05a3580c7fb9ab39c9f35b84e Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sat, 2 May 2015 14:18:47 +0200 Subject: Fix warnings * device/ds_routines.c (device_open, ds_open_done, device_close, device_write, device_write_inband, ds_write_done, device_read, device_read_inband, ds_read_done, device_set_status, mach_device_get_status, device_set_filter, device_map, ds_no_senders): Convert from K&R declaration, fix type of `device' into void*. --- device/ds_routines.c | 124 +++++++++++++++++++++++++-------------------------- 1 file changed, 60 insertions(+), 64 deletions(-) diff --git a/device/ds_routines.c b/device/ds_routines.c index 38d773c2..43ed5b5d 100644 --- a/device/ds_routines.c +++ b/device/ds_routines.c @@ -417,12 +417,11 @@ mach_convert_device_to_port (mach_device_t device) } static io_return_t -device_open(reply_port, reply_port_type, mode, name, device_p) - const ipc_port_t reply_port; - mach_msg_type_name_t reply_port_type; - dev_mode_t mode; - char * name; - device_t *device_p; /* out */ +device_open(const ipc_port_t reply_port, + mach_msg_type_name_t reply_port_type, + dev_mode_t mode, + char * name, + device_t *device_p) { mach_device_t device; kern_return_t result; @@ -537,8 +536,7 @@ device_open(reply_port, reply_port_type, mode, name, device_p) } boolean_t -ds_open_done(ior) - const io_req_t ior; +ds_open_done(const io_req_t ior) { kern_return_t result; mach_device_t device; @@ -597,8 +595,10 @@ ds_open_done(ior) } static io_return_t -device_close(mach_device_t device) +device_close(void *dev) { + mach_device_t device = dev; + device_lock(device); /* @@ -659,17 +659,16 @@ device_close(mach_device_t device) * Write to a device. */ static io_return_t -device_write(device, reply_port, reply_port_type, mode, recnum, - data, data_count, bytes_written) - mach_device_t device; - const ipc_port_t reply_port; - mach_msg_type_name_t reply_port_type; - dev_mode_t mode; - recnum_t recnum; - const io_buf_ptr_t data; - unsigned int data_count; - int *bytes_written; /* out */ +device_write(void *dev, + const ipc_port_t reply_port, + mach_msg_type_name_t reply_port_type, + dev_mode_t mode, + recnum_t recnum, + const io_buf_ptr_t data, + unsigned int data_count, + int *bytes_written) { + mach_device_t device = dev; io_req_t ior; io_return_t result; @@ -750,17 +749,16 @@ device_write(device, reply_port, reply_port_type, mode, recnum, * Write to a device, but memory is in message. */ static io_return_t -device_write_inband(device, reply_port, reply_port_type, mode, recnum, - data, data_count, bytes_written) - mach_device_t device; - const ipc_port_t reply_port; - mach_msg_type_name_t reply_port_type; - dev_mode_t mode; - recnum_t recnum; - io_buf_ptr_inband_t data; - unsigned int data_count; - int *bytes_written; /* out */ +device_write_inband(void *dev, + const ipc_port_t reply_port, + mach_msg_type_name_t reply_port_type, + dev_mode_t mode, + recnum_t recnum, + io_buf_ptr_inband_t data, + unsigned int data_count, + int *bytes_written) { + mach_device_t device = dev; io_req_t ior; io_return_t result; @@ -1018,8 +1016,7 @@ device_write_dealloc(io_req_t ior) * Send write completion message to client, and discard the data. */ boolean_t -ds_write_done(ior) - const io_req_t ior; +ds_write_done(const io_req_t ior) { /* * device_write_dealloc discards the data that has been @@ -1064,17 +1061,16 @@ ds_write_done(ior) * Read from a device. */ static io_return_t -device_read(device, reply_port, reply_port_type, mode, recnum, - bytes_wanted, data, data_count) - mach_device_t device; - const ipc_port_t reply_port; - mach_msg_type_name_t reply_port_type; - dev_mode_t mode; - recnum_t recnum; - int bytes_wanted; - io_buf_ptr_t *data; /* out */ - unsigned int *data_count; /* out */ +device_read(void *dev, + const ipc_port_t reply_port, + mach_msg_type_name_t reply_port_type, + dev_mode_t mode, + recnum_t recnum, + int bytes_wanted, + io_buf_ptr_t *data, + unsigned int *data_count) { + mach_device_t device = dev; io_req_t ior; io_return_t result; @@ -1141,17 +1137,16 @@ device_read(device, reply_port, reply_port_type, mode, recnum, * Read from a device, but return the data 'inband.' */ static io_return_t -device_read_inband(device, reply_port, reply_port_type, mode, recnum, - bytes_wanted, data, data_count) - mach_device_t device; - const ipc_port_t reply_port; - mach_msg_type_name_t reply_port_type; - dev_mode_t mode; - recnum_t recnum; - int bytes_wanted; - char *data; /* pointer to OUT array */ - unsigned int *data_count; /* out */ +device_read_inband(void *dev, + const ipc_port_t reply_port, + mach_msg_type_name_t reply_port_type, + dev_mode_t mode, + recnum_t recnum, + int bytes_wanted, + char *data, + unsigned int *data_count) { + mach_device_t device = dev; io_req_t ior; io_return_t result; @@ -1248,8 +1243,7 @@ kern_return_t device_read_alloc( return (KERN_SUCCESS); } -boolean_t ds_read_done(ior) - const io_req_t ior; +boolean_t ds_read_done(const io_req_t ior) { vm_offset_t start_data, end_data; vm_offset_t start_sent, end_sent; @@ -1345,11 +1339,12 @@ boolean_t ds_read_done(ior) static io_return_t device_set_status( - mach_device_t device, + void *dev, dev_flavor_t flavor, dev_status_t status, mach_msg_type_number_t status_count) { + mach_device_t device = dev; if (device->state != DEV_STATE_OPEN) return (D_NO_SUCH_DEVICE); @@ -1363,11 +1358,12 @@ device_set_status( io_return_t mach_device_get_status( - mach_device_t device, + void *dev, dev_flavor_t flavor, dev_status_t status, /* pointer to OUT array */ mach_msg_type_number_t *status_count) /* out */ { + mach_device_t device = dev; if (device->state != DEV_STATE_OPEN) return (D_NO_SUCH_DEVICE); @@ -1380,13 +1376,13 @@ mach_device_get_status( } static io_return_t -device_set_filter(device, receive_port, priority, filter, filter_count) - mach_device_t device; - const ipc_port_t receive_port; - int priority; - filter_t filter[]; /* pointer to IN array */ - unsigned int filter_count; +device_set_filter(void *dev, + const ipc_port_t receive_port, + int priority, + filter_t filter[], + unsigned int filter_count) { + mach_device_t device = dev; if (device->state != DEV_STATE_OPEN) return (D_NO_SUCH_DEVICE); @@ -1407,13 +1403,14 @@ device_set_filter(device, receive_port, priority, filter, filter_count) static io_return_t device_map( - mach_device_t device, + void *dev, vm_prot_t protection, vm_offset_t offset, vm_size_t size, ipc_port_t *pager, /* out */ boolean_t unmap) /* ? */ { + mach_device_t device = dev; if (protection & ~VM_PROT_ALL) return (KERN_INVALID_ARGUMENT); @@ -1430,8 +1427,7 @@ device_map( * Doesn't do anything (yet). */ static void -ds_no_senders(notification) - const mach_no_senders_notification_t *notification; +ds_no_senders(mach_no_senders_notification_t *notification) { printf("ds_no_senders called! device_port=0x%lx count=%d\n", notification->not_header.msgh_remote_port, -- cgit v1.2.3 From ef0547c90584f589281051d7b9b9f8b208b5b55b Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sat, 2 May 2015 14:24:45 +0200 Subject: Fix warning * i386/i386at/rtc.c (rtcget, rtcput): Make functions take an rtc_st structure which it casts to char * itself. --- i386/i386at/rtc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/i386/i386at/rtc.c b/i386/i386at/rtc.c index 946f08fd..01e09772 100644 --- a/i386/i386at/rtc.c +++ b/i386/i386at/rtc.c @@ -66,8 +66,9 @@ rtcinit(void) int -rtcget(unsigned char *regs) +rtcget(struct rtc_st *st) { + unsigned char *regs = (unsigned char *)st; if (first_rtcopen_ever) { rtcinit(); first_rtcopen_ever = FALSE; @@ -82,8 +83,9 @@ rtcget(unsigned char *regs) } void -rtcput(unsigned char *regs) +rtcput(struct rtc_st *st) { + unsigned char *regs = (unsigned char *)st; unsigned char x; if (first_rtcopen_ever) { -- cgit v1.2.3 From 32b3385c56912dac71e7f54fe03ff895cb4381c5 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Mon, 13 Apr 2015 16:27:25 +0200 Subject: kern: fix comment * kern/rbtree.h: Fix comment. --- kern/rbtree.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kern/rbtree.h b/kern/rbtree.h index f577f7ed..189a7fd6 100644 --- a/kern/rbtree.h +++ b/kern/rbtree.h @@ -177,8 +177,8 @@ MACRO_END * This macro performs a standard lookup to obtain the insertion point of * the given node in the tree (it is assumed that the inserted node never * compares equal to any other entry in the tree) and links the node. It - * then It then checks red-black rules violations, and rebalances the tree - * if necessary. + * then checks red-black rules violations, and rebalances the tree if + * necessary. * * Unlike rbtree_lookup(), the cmp_fn parameter must compare two complete * entries, so it is suggested to use two different comparison inline -- cgit v1.2.3 From 7803e9735dde445be3046a79bf1b4ca5ab525ac1 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sat, 2 May 2015 20:53:54 +0200 Subject: Fix semaphore failure path special calling convention * linux/src/include/asm-i386/semaphore.h (down): Pass semaphore address to down_failed through ecx. (down_interruptible): Likewise to down_failed_interruptible. (up): Likewise to up_wakeup. --- linux/src/include/asm-i386/semaphore.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/linux/src/include/asm-i386/semaphore.h b/linux/src/include/asm-i386/semaphore.h index 2a5f5b78..c351c3ad 100644 --- a/linux/src/include/asm-i386/semaphore.h +++ b/linux/src/include/asm-i386/semaphore.h @@ -30,6 +30,10 @@ struct semaphore { #define MUTEX ((struct semaphore) { 1, 0, 0, NULL }) #define MUTEX_LOCKED ((struct semaphore) { 0, 0, 0, NULL }) +/* Special register calling convention: + * eax contains return address + * ecx contains semaphore address + */ asmlinkage void down_failed(void /* special register calling convention */); asmlinkage void up_wakeup(void /* special register calling convention */); @@ -54,7 +58,7 @@ extern inline void down(struct semaphore * sem) "js " SYMBOL_NAME_STR(down_failed) "\n" "1:\n" :"=&a" (d0), "=m" (sem->count) - : + :"c" (sem) :"memory"); } @@ -97,7 +101,7 @@ extern inline int down_interruptible(struct semaphore * sem) "xorl %%eax,%%eax\n" "2:\n" :"=&a" (ret), "=m" (sem->count) - : + :"c" (sem) :"memory"); return(ret) ; @@ -122,7 +126,7 @@ extern inline void up(struct semaphore * sem) "jle " SYMBOL_NAME_STR(up_wakeup) "\n1:" :"=&a" (d0), "=m" (sem->count) - : + :"c" (sem) :"memory"); } -- cgit v1.2.3 From d249cb9c783eba61fe7b364560f8dfa36cfb0215 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Mon, 4 May 2015 01:56:12 +0200 Subject: i386: use macro to compute address of saved registers * i386/i386/pcb.c (stack_attach): Use `USER_REGS'. (stack_handoff): Likewise. --- i386/i386/pcb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/i386/i386/pcb.c b/i386/i386/pcb.c index e8040c83..dabe4814 100644 --- a/i386/i386/pcb.c +++ b/i386/i386/pcb.c @@ -96,7 +96,7 @@ void stack_attach( /* * Point top of kernel stack to user`s registers. */ - STACK_IEL(stack)->saved_state = &thread->pcb->iss; + STACK_IEL(stack)->saved_state = USER_REGS(thread); } /* @@ -298,7 +298,7 @@ void stack_handoff( * user registers. */ - STACK_IEL(stack)->saved_state = &new->pcb->iss; + STACK_IEL(stack)->saved_state = USER_REGS(new); } -- cgit v1.2.3 From 8b026d66eb22e1fcf1cb03974606dca991aae392 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Sun, 17 May 2015 15:10:18 +0200 Subject: i386: avoid compiler warning * i386/i386/phys.c (pmap_zero_page, pmap_copy_page, copy_to_phys, copy_from_phys): Avoid compiler warning about `map' being used uninitialized. --- i386/i386/phys.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/i386/i386/phys.c b/i386/i386/phys.c index 3af508f5..d55bdd9d 100644 --- a/i386/i386/phys.c +++ b/i386/i386/phys.c @@ -52,8 +52,9 @@ pmap_zero_page(vm_offset_t p) assert(p != vm_page_fictitious_addr); vm_offset_t v; pmap_mapwindow_t *map; + boolean_t mapped = p >= phys_last_addr; - if (p >= phys_last_addr) + if (mapped) { map = pmap_get_mapwindow(INTEL_PTE_W(p)); v = map->vaddr; @@ -63,7 +64,7 @@ pmap_zero_page(vm_offset_t p) memset((void*) v, 0, PAGE_SIZE); - if (p >= phys_last_addr) + if (mapped) pmap_put_mapwindow(map); } @@ -77,10 +78,12 @@ pmap_copy_page( { vm_offset_t src_addr_v, dst_addr_v; pmap_mapwindow_t *src_map, *dst_map; + boolean_t src_mapped = src >= phys_last_addr; + boolean_t dst_mapped = dst >= phys_last_addr; assert(src != vm_page_fictitious_addr); assert(dst != vm_page_fictitious_addr); - if (src >= phys_last_addr) + if (src_mapped) { src_map = pmap_get_mapwindow(INTEL_PTE_R(src)); src_addr_v = src_map->vaddr; @@ -88,7 +91,7 @@ pmap_copy_page( else src_addr_v = phystokv(src); - if (dst >= phys_last_addr) + if (dst_mapped) { dst_map = pmap_get_mapwindow(INTEL_PTE_W(dst)); dst_addr_v = dst_map->vaddr; @@ -98,9 +101,9 @@ pmap_copy_page( memcpy((void *) dst_addr_v, (void *) src_addr_v, PAGE_SIZE); - if (src >= phys_last_addr) + if (src_mapped) pmap_put_mapwindow(src_map); - if (dst >= phys_last_addr) + if (dst_mapped) pmap_put_mapwindow(dst_map); } @@ -117,10 +120,11 @@ copy_to_phys( { vm_offset_t dst_addr_v; pmap_mapwindow_t *dst_map; + boolean_t mapped = dst_addr_p >= phys_last_addr; assert(dst_addr_p != vm_page_fictitious_addr); assert(pa_to_pte(dst_addr_p + count-1) == pa_to_pte(dst_addr_p)); - if (dst_addr_p >= phys_last_addr) + if (mapped) { dst_map = pmap_get_mapwindow(INTEL_PTE_W(dst_addr_p)); dst_addr_v = dst_map->vaddr; @@ -130,7 +134,7 @@ copy_to_phys( memcpy((void *)dst_addr_v, (void *)src_addr_v, count); - if (dst_addr_p >= phys_last_addr) + if (mapped) pmap_put_mapwindow(dst_map); } @@ -148,10 +152,11 @@ copy_from_phys( { vm_offset_t src_addr_v; pmap_mapwindow_t *src_map; + boolean_t mapped = src_addr_p >= phys_last_addr; assert(src_addr_p != vm_page_fictitious_addr); assert(pa_to_pte(src_addr_p + count-1) == pa_to_pte(src_addr_p)); - if (src_addr_p >= phys_last_addr) + if (mapped) { src_map = pmap_get_mapwindow(INTEL_PTE_R(src_addr_p)); src_addr_v = src_map->vaddr; @@ -161,7 +166,7 @@ copy_from_phys( memcpy((void *)dst_addr_v, (void *)src_addr_v, count); - if (src_addr_p >= phys_last_addr) + if (mapped) pmap_put_mapwindow(src_map); } -- cgit v1.2.3 From b3c5e41bc05bc622c637d1da75a3c63091e4e789 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Tue, 31 Mar 2015 12:57:05 +0200 Subject: kern: import `macros.h' from x15 Import the macro definitions from the x15 kernel project, and replace all similar definitions littered all over the place with it. Importing this file will make importing code from the x15 kernel easier. We are already using the red-black tree implementation and the slab allocator from it, and we will import even more code in the near future. * kern/list.h: Do not define `structof', include `macros.h' instead. * kern/rbtree.h: Likewise. * kern/slab.c: Do not define `ARRAY_SIZE', include `macros.h' instead. * i386/grub/misc.h: Likewise. * i386/i386/xen.h: Do not define `barrier', include `macros.h' instead. * kern/macro_help.h: Delete file. Replaced by `macros.h'. * kern/macros.h: New file. * Makefrag.am (libkernel_a_SOURCES): Add new file, remove old file. * device/dev_master.h: Adopt accordingly. * device/io_req.h: Likewise. * device/net_io.h: Likewise. * i386/intel/read_fault.c: Likewise. * ipc/ipc_kmsg.h: Likewise. * ipc/ipc_mqueue.h: Likewise. * ipc/ipc_object.h: Likewise. * ipc/ipc_port.h: Likewise. * ipc/ipc_space.h: Likewise. * ipc/ipc_splay.c: Likewise. * ipc/ipc_splay.h: Likewise. * kern/assert.h: Likewise. * kern/ast.h: Likewise. * kern/pc_sample.h: Likewise. * kern/refcount.h: Likewise. * kern/sched.h: Likewise. * kern/sched_prim.c: Likewise. * kern/timer.c: Likewise. * kern/timer.h: Likewise. * vm/vm_fault.c: Likewise. * vm/vm_map.h: Likewise. * vm/vm_object.h: Likewise. * vm/vm_page.h: Likewise. --- Makefrag.am | 2 +- device/dev_master.h | 2 +- device/io_req.h | 2 +- device/net_io.h | 2 +- i386/grub/misc.h | 2 +- i386/i386/xen.h | 2 +- i386/intel/read_fault.c | 2 +- ipc/ipc_kmsg.h | 2 +- ipc/ipc_mqueue.h | 2 +- ipc/ipc_object.h | 2 +- ipc/ipc_port.h | 2 +- ipc/ipc_space.h | 2 +- ipc/ipc_splay.c | 2 +- ipc/ipc_splay.h | 2 +- kern/assert.h | 2 +- kern/ast.h | 2 +- kern/list.h | 4 +-- kern/macro_help.h | 50 ---------------------------------- kern/macros.h | 72 +++++++++++++++++++++++++++++++++++++++++++++++++ kern/pc_sample.h | 2 +- kern/rbtree.h | 5 +--- kern/refcount.h | 2 +- kern/sched.h | 2 +- kern/sched_prim.c | 2 +- kern/slab.c | 2 +- kern/timer.c | 2 +- kern/timer.h | 2 +- vm/vm_fault.c | 2 +- vm/vm_map.h | 2 +- vm/vm_object.h | 2 +- vm/vm_page.h | 2 +- 31 files changed, 101 insertions(+), 84 deletions(-) delete mode 100644 kern/macro_help.h create mode 100644 kern/macros.h diff --git a/Makefrag.am b/Makefrag.am index 91661437..9222ad20 100644 --- a/Makefrag.am +++ b/Makefrag.am @@ -171,7 +171,7 @@ libkernel_a_SOURCES += \ kern/mach_factor.h \ kern/machine.c \ kern/machine.h \ - kern/macro_help.h \ + kern/macros.h \ kern/pc_sample.c \ kern/pc_sample.h \ kern/printf.c \ diff --git a/device/dev_master.h b/device/dev_master.h index 6ad11526..70d4c63f 100644 --- a/device/dev_master.h +++ b/device/dev_master.h @@ -37,7 +37,7 @@ #if NCPUS > 1 -#include +#include #include #include #include diff --git a/device/io_req.h b/device/io_req.h index 65e23e60..1ad46801 100644 --- a/device/io_req.h +++ b/device/io_req.h @@ -42,7 +42,7 @@ #include #include -#include +#include /* * IO request element, queued on device for delayed replies. diff --git a/device/net_io.h b/device/net_io.h index f6de8541..d4e24d41 100644 --- a/device/net_io.h +++ b/device/net_io.h @@ -38,7 +38,7 @@ #include #include -#include +#include #include #include diff --git a/i386/grub/misc.h b/i386/grub/misc.h index c6cd4564..b71140a5 100644 --- a/i386/grub/misc.h +++ b/i386/grub/misc.h @@ -21,6 +21,7 @@ #define GRUB_MISC_HEADER 1 #include +#include #include #include #include @@ -32,7 +33,6 @@ #define ALIGN_UP_OVERHEAD(addr, align) ((-(addr)) & ((typeof (addr)) (align) - 1)) #define ALIGN_DOWN(addr, align) \ ((addr) & ~((typeof (addr)) align - 1)) -#define ARRAY_SIZE(array) (sizeof (array) / sizeof (array[0])) #define COMPILE_TIME_ASSERT(cond) switch (0) { case 1: case !(cond): ; } #define grub_dprintf(condition, ...) grub_real_dprintf(GRUB_FILE, __LINE__, condition, __VA_ARGS__) diff --git a/i386/i386/xen.h b/i386/i386/xen.h index 638d6713..c6811873 100644 --- a/i386/i386/xen.h +++ b/i386/i386/xen.h @@ -21,6 +21,7 @@ #ifdef MACH_XEN #ifndef __ASSEMBLER__ +#include #include #include #include @@ -32,7 +33,6 @@ #include /* TODO: this should be moved in appropriate non-Xen place. */ -#define barrier() __asm__ __volatile__ ("": : :"memory") #define mb() __asm__ __volatile__("lock; addl $0,0(%%esp)":::"memory") #define rmb() mb() #define wmb() mb() diff --git a/i386/intel/read_fault.c b/i386/intel/read_fault.c index 29f44396..4b1edce3 100644 --- a/i386/intel/read_fault.c +++ b/i386/intel/read_fault.c @@ -31,7 +31,7 @@ #include #include -#include +#include /* * Expansion of vm_fault for read fault in kernel mode. diff --git a/ipc/ipc_kmsg.h b/ipc/ipc_kmsg.h index 620785b5..393c0392 100644 --- a/ipc/ipc_kmsg.h +++ b/ipc/ipc_kmsg.h @@ -38,7 +38,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/ipc/ipc_mqueue.h b/ipc/ipc_mqueue.h index f8a2f1e7..2af5e02e 100644 --- a/ipc/ipc_mqueue.h +++ b/ipc/ipc_mqueue.h @@ -37,7 +37,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/ipc/ipc_object.h b/ipc/ipc_object.h index b83bb5a6..be5bea71 100644 --- a/ipc/ipc_object.h +++ b/ipc/ipc_object.h @@ -38,7 +38,7 @@ #include #include #include -#include +#include #include typedef unsigned int ipc_object_refs_t; diff --git a/ipc/ipc_port.h b/ipc/ipc_port.h index 6914c717..ade69679 100644 --- a/ipc/ipc_port.h +++ b/ipc/ipc_port.h @@ -43,7 +43,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/ipc/ipc_space.h b/ipc/ipc_space.h index c4683d20..3bd2f4d0 100644 --- a/ipc/ipc_space.h +++ b/ipc/ipc_space.h @@ -42,7 +42,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/ipc/ipc_splay.c b/ipc/ipc_splay.c index 6fb5bcbc..062a69f8 100644 --- a/ipc/ipc_splay.c +++ b/ipc/ipc_splay.c @@ -35,7 +35,7 @@ #include #include -#include +#include #include #include diff --git a/ipc/ipc_splay.h b/ipc/ipc_splay.h index d3316ef8..42e5a801 100644 --- a/ipc/ipc_splay.h +++ b/ipc/ipc_splay.h @@ -38,7 +38,7 @@ #include #include -#include +#include #include typedef struct ipc_splay_tree { diff --git a/kern/assert.h b/kern/assert.h index bd2a8beb..7b66d1b1 100644 --- a/kern/assert.h +++ b/kern/assert.h @@ -29,7 +29,7 @@ /* assert.h 4.2 85/01/21 */ -#include +#include #ifndef NDEBUG #define MACH_ASSERT 1 diff --git a/kern/ast.h b/kern/ast.h index 4c28b1e6..7d472be9 100644 --- a/kern/ast.h +++ b/kern/ast.h @@ -41,7 +41,7 @@ */ #include "cpu_number.h" -#include +#include #include /* diff --git a/kern/list.h b/kern/list.h index ad782a8a..be927625 100644 --- a/kern/list.h +++ b/kern/list.h @@ -31,9 +31,7 @@ #include #include - -#define structof(ptr, type, member) \ - ((type *)((char *)ptr - offsetof(type, member))) +#include /* * Structure used as both head and node. diff --git a/kern/macro_help.h b/kern/macro_help.h deleted file mode 100644 index 7ce171f6..00000000 --- a/kern/macro_help.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - */ -/* - * File: kern/macro_help.h - * - * Provide help in making lint-free macro routines - * - */ - -#ifndef _KERN_MACRO_HELP_H_ -#define _KERN_MACRO_HELP_H_ - -#if !defined(MACRO_BEGIN) - -#include - -#define NEVER FALSE -#define ALWAYS TRUE - -#define MACRO_BEGIN ({ -#define MACRO_END }) - -#define MACRO_RETURN if (ALWAYS) return - -#endif /* !MACRO_BEGIN */ - -#endif /* _KERN_MACRO_HELP_H_ */ diff --git a/kern/macros.h b/kern/macros.h new file mode 100644 index 00000000..fb8dc5e1 --- /dev/null +++ b/kern/macros.h @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2009, 2010, 2013 Richard Braun. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * + * Helper macros. + */ + +#ifndef _KERN_MACROS_H +#define _KERN_MACROS_H + +#define MACRO_BEGIN ({ +#define MACRO_END }) +#define MACRO_RETURN if (1) return + +#define __QUOTE(x) #x +#define QUOTE(x) __QUOTE(x) + +#ifdef __ASSEMBLER__ +#define DECL_CONST(x, s) x +#else /* __ASSEMBLER__ */ +#define __DECL_CONST(x, s) x##s +#define DECL_CONST(x, s) __DECL_CONST(x, s) +#endif /* __ASSEMBLER__ */ + +#define STRLEN(x) (sizeof(x) - 1) +#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) + +#define MIN(a, b) ((a) < (b) ? (a) : (b)) +#define MAX(a, b) ((a) > (b) ? (a) : (b)) + +#define DIV_CEIL(n, d) (((n) + (d) - 1) / (d)) + +#define P2ALIGNED(x, a) (((x) & ((a) - 1)) == 0) +#define ISP2(x) P2ALIGNED(x, x) +#define P2ALIGN(x, a) ((x) & -(a)) +#define P2ROUND(x, a) (-(-(x) & -(a))) +#define P2END(x, a) (-(~(x) & -(a))) + +#define structof(ptr, type, member) \ + ((type *)((char *)(ptr) - offsetof(type, member))) + +#define alignof(x) __alignof__(x) + +#define likely(expr) __builtin_expect(!!(expr), 1) +#define unlikely(expr) __builtin_expect(!!(expr), 0) + +#define barrier() asm volatile("" : : : "memory") + +#define __noreturn __attribute__((noreturn)) +#define __aligned(x) __attribute__((aligned(x))) +#define __always_inline inline __attribute__((always_inline)) +#define __section(x) __attribute__((section(x))) +#define __packed __attribute__((packed)) +#define __alias(x) __attribute__((alias(x))) + +#define __format_printf(fmt, args) \ + __attribute__((format(printf, fmt, args))) + +#endif /* _KERN_MACROS_H */ diff --git a/kern/pc_sample.h b/kern/pc_sample.h index 3c64068d..4832cb9f 100644 --- a/kern/pc_sample.h +++ b/kern/pc_sample.h @@ -49,7 +49,7 @@ #include #include #include -#include +#include /* * Control structure for sampling, included in diff --git a/kern/rbtree.h b/kern/rbtree.h index 189a7fd6..16ef2736 100644 --- a/kern/rbtree.h +++ b/kern/rbtree.h @@ -31,12 +31,9 @@ #include #include -#include +#include #include -#define structof(ptr, type, member) \ - ((type *)((char *)ptr - offsetof(type, member))) - /* * Indexes of the left and right nodes in the children array of a node. */ diff --git a/kern/refcount.h b/kern/refcount.h index 74204d6b..f32feb87 100644 --- a/kern/refcount.h +++ b/kern/refcount.h @@ -27,7 +27,7 @@ #ifndef _KERN_REFCOUNT_H_ #define _KERN_REFCOUNT_H_ -#include +#include /* Unless the above include file specified otherwise, use the system-independent (unoptimized) atomic reference counter. */ diff --git a/kern/sched.h b/kern/sched.h index ea601c5b..f82f9f56 100644 --- a/kern/sched.h +++ b/kern/sched.h @@ -38,7 +38,7 @@ #include #include #include -#include +#include #if MACH_FIXPRI #include diff --git a/kern/sched_prim.c b/kern/sched_prim.c index d7792ae6..e8f260e3 100644 --- a/kern/sched_prim.c +++ b/kern/sched_prim.c @@ -44,7 +44,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/kern/slab.c b/kern/slab.c index 19ebfedb..60378b5f 100644 --- a/kern/slab.c +++ b/kern/slab.c @@ -79,6 +79,7 @@ #include #include #include +#include #include #include #include @@ -96,7 +97,6 @@ /* * Utility macros. */ -#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) #define P2ALIGNED(x, a) (((x) & ((a) - 1)) == 0) #define ISP2(x) P2ALIGNED(x, x) #define P2ALIGN(x, a) ((x) & -(a)) diff --git a/kern/timer.c b/kern/timer.c index 6d6517ed..79ada27e 100644 --- a/kern/timer.c +++ b/kern/timer.c @@ -33,7 +33,7 @@ #include #include -#include +#include diff --git a/kern/timer.h b/kern/timer.h index 57f017aa..2f473cf8 100644 --- a/kern/timer.h +++ b/kern/timer.h @@ -27,7 +27,7 @@ #ifndef _KERN_TIMER_H_ #define _KERN_TIMER_H_ -#include +#include #if STAT_TIME /* diff --git a/vm/vm_fault.c b/vm/vm_fault.c index 686156c9..0fa4d6af 100644 --- a/vm/vm_fault.c +++ b/vm/vm_fault.c @@ -51,7 +51,7 @@ #include #include /* For memory_object_data_{request,unlock} */ -#include +#include #include #if MACH_PCSAMPLE diff --git a/vm/vm_map.h b/vm/vm_map.h index b8103ebc..fc7730a2 100644 --- a/vm/vm_map.h +++ b/vm/vm_map.h @@ -52,7 +52,7 @@ #include #include #include -#include +#include /* TODO: make it dynamic */ #define KENTRY_DATA_SIZE (256*PAGE_SIZE) diff --git a/vm/vm_object.h b/vm/vm_object.h index 5c42f568..3bfc67ab 100644 --- a/vm/vm_object.h +++ b/vm/vm_object.h @@ -45,7 +45,7 @@ #include #include #include -#include +#include #include #include diff --git a/vm/vm_page.h b/vm/vm_page.h index 4fe1b41d..e6a8c497 100644 --- a/vm/vm_page.h +++ b/vm/vm_page.h @@ -42,7 +42,7 @@ #include #include -#include +#include #include /* definitions of wait/wakeup */ #if MACH_VM_DEBUG -- cgit v1.2.3 From 82305c623900ce30a666bd14ae6901a1bf149bb7 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Sun, 26 Apr 2015 15:35:43 +0200 Subject: kern: gracefully handle resource shortage * kern/task.c (task_create): Gracefully handle resource shortage. --- kern/task.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/kern/task.c b/kern/task.c index 57e7f413..dcd53712 100644 --- a/kern/task.c +++ b/kern/task.c @@ -89,9 +89,8 @@ kern_return_t task_create( #endif new_task = (task_t) kmem_cache_alloc(&task_cache); - if (new_task == TASK_NULL) { - panic("task_create: no memory for task structure"); - } + if (new_task == TASK_NULL) + return KERN_RESOURCE_SHORTAGE; /* one ref for just being alive; one for our caller */ new_task->ref_count = 2; -- cgit v1.2.3 From 3c3d3614673c93bf1b1f47d612d8067455d06920 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Sun, 26 Apr 2015 15:39:00 +0200 Subject: vm: gracefully handle resource shortage * vm/vm_object.c (vm_object_copy_call): Gracefully handle resource shortage by doing the allocation earlier and aborting the function if unsuccessful. --- vm/vm_object.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/vm/vm_object.c b/vm/vm_object.c index 71c0edb6..8c6bbab4 100644 --- a/vm/vm_object.c +++ b/vm/vm_object.c @@ -1335,16 +1335,6 @@ kern_return_t vm_object_copy_call( vm_object_t new_object; vm_page_t p; - /* - * Set the backing object for the new - * temporary object. - */ - - assert(src_object->ref_count > 0); - src_object->ref_count++; - vm_object_paging_begin(src_object); - vm_object_unlock(src_object); - /* * Create a memory object port to be associated * with this new vm_object. @@ -1358,10 +1348,18 @@ kern_return_t vm_object_copy_call( */ new_memory_object = ipc_port_alloc_kernel(); - if (new_memory_object == IP_NULL) { - panic("vm_object_copy_call: allocate memory object port"); - /* XXX Shouldn't panic here. */ - } + if (new_memory_object == IP_NULL) + return KERN_RESOURCE_SHORTAGE; + + /* + * Set the backing object for the new + * temporary object. + */ + + assert(src_object->ref_count > 0); + src_object->ref_count++; + vm_object_paging_begin(src_object); + vm_object_unlock(src_object); /* we hold a naked receive right for new_memory_object */ (void) ipc_port_make_send(new_memory_object); -- cgit v1.2.3 From 6eb79f812ee43a4e9142de61a5821e0cc8c52bb1 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Sun, 26 Apr 2015 15:47:47 +0200 Subject: kern: gracefully handle resource shortage * kern/thread.c (stack_alloc): Report resource shortage. * kern/sched_prim.h (stack_alloc): Adjust declaration accordingly. * kern/thread_swap.c (thread_doswapin): Report resource shortage. (swapin_thread_continue): If the swap-in fails, put the thread back on the queue and go back to sleep. * kern/thread_swap.h (thread_doswapin): Adjust declaration accordingly. --- kern/sched_prim.h | 2 +- kern/thread.c | 11 ++++++----- kern/thread_swap.c | 17 ++++++++++++++--- kern/thread_swap.h | 2 +- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/kern/sched_prim.h b/kern/sched_prim.h index fd989b6c..62698dc2 100644 --- a/kern/sched_prim.h +++ b/kern/sched_prim.h @@ -150,7 +150,7 @@ extern void stack_handoff( * or are defined directly by machine-dependent code. */ -extern void stack_alloc( +extern kern_return_t stack_alloc( thread_t thread, void (*resume)(thread_t)); extern boolean_t stack_alloc_try( diff --git a/kern/thread.c b/kern/thread.c index 009884ce..f52c95b8 100644 --- a/kern/thread.c +++ b/kern/thread.c @@ -171,7 +171,7 @@ boolean_t stack_alloc_try( * May block. */ -void stack_alloc( +kern_return_t stack_alloc( thread_t thread, void (*resume)(thread_t)) { @@ -195,15 +195,15 @@ void stack_alloc( (void) splx(s); if (stack == 0) { + kern_return_t kr; /* * Kernel stacks should be naturally aligned, * so that it is easy to find the starting/ending * addresses of a stack given an address in the middle. */ - - if (kmem_alloc_aligned(kmem_map, &stack, KERNEL_STACK_SIZE) - != KERN_SUCCESS) - panic("stack_alloc"); + kr = kmem_alloc_aligned(kmem_map, &stack, KERNEL_STACK_SIZE); + if (kr != KERN_SUCCESS) + return kr; #if MACH_DEBUG stack_init(stack); @@ -211,6 +211,7 @@ void stack_alloc( } stack_attach(thread, stack, resume); + return KERN_SUCCESS; } /* diff --git a/kern/thread_swap.c b/kern/thread_swap.c index dc2924a9..20ad0409 100644 --- a/kern/thread_swap.c +++ b/kern/thread_swap.c @@ -123,15 +123,18 @@ void thread_swapin(thread_t thread) * it on a run queue. No locks should be held on entry, as it is * likely that this routine will sleep (waiting for stack allocation). */ -void thread_doswapin(thread_t thread) +kern_return_t thread_doswapin(thread_t thread) { + kern_return_t kr; spl_t s; /* * Allocate the kernel stack. */ - stack_alloc(thread, thread_continue); + kr = stack_alloc(thread, thread_continue); + if (kr != KERN_SUCCESS) + return kr; /* * Place on run queue. @@ -144,6 +147,7 @@ void thread_doswapin(thread_t thread) thread_setrun(thread, TRUE); thread_unlock(thread); (void) splx(s); + return KERN_SUCCESS; } /* @@ -163,13 +167,20 @@ void __attribute__((noreturn)) swapin_thread_continue(void) while ((thread = (thread_t) dequeue_head(&swapin_queue)) != THREAD_NULL) { + kern_return_t kr; swapper_unlock(); (void) splx(s); - thread_doswapin(thread); /* may block */ + kr = thread_doswapin(thread); /* may block */ s = splsched(); swapper_lock(); + + if (kr != KERN_SUCCESS) { + enqueue_head(&swapin_queue, + (queue_entry_t) thread); + break; + } } assert_wait((event_t) &swapin_queue, FALSE); diff --git a/kern/thread_swap.h b/kern/thread_swap.h index 9d645373..d032accf 100644 --- a/kern/thread_swap.h +++ b/kern/thread_swap.h @@ -37,7 +37,7 @@ */ extern void swapper_init(void); extern void thread_swapin(thread_t thread); -extern void thread_doswapin(thread_t thread); +extern kern_return_t thread_doswapin(thread_t thread); extern void swapin_thread(void) __attribute__((noreturn)); #endif /* _KERN_THREAD_SWAP_H_ */ -- cgit v1.2.3 From 7d76ea075c248b2ed64c69a5e5dd4493d943e628 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Mon, 16 Mar 2015 11:37:06 +0100 Subject: kern: add radix tree library Import a radix tree library from Richard Braun's librbraun. * Makefile.am (clib_routines): Steal `__ffsdi2'. * Makefrag.am (libkernel_a_SOURCES): Add new files. * kern/rdxtree.c: New file. * kern/rdxtree.h: Likewise. * kern/rdxtree_i.h: Likewise. * kern/startup.c (setup_main): Initialize radix tree library. --- Makefile.am | 1 + Makefrag.am | 3 + kern/rdxtree.c | 830 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ kern/rdxtree.h | 209 ++++++++++++++ kern/rdxtree_i.h | 66 +++++ kern/startup.c | 2 + 6 files changed, 1111 insertions(+) create mode 100644 kern/rdxtree.c create mode 100644 kern/rdxtree.h create mode 100644 kern/rdxtree_i.h diff --git a/Makefile.am b/Makefile.am index 37dee761..eb940cbb 100644 --- a/Makefile.am +++ b/Makefile.am @@ -165,6 +165,7 @@ clib_routines := memcmp memcpy memmove \ htonl htons ntohl ntohs \ udivdi3 __udivdi3 \ __rel_iplt_start __rel_iplt_end \ + __ffsdi2 \ _START _start etext _edata end _end # actually ld magic, not libc. gnumach-undef: gnumach.$(OBJEXT) $(NM_V) $(NM) -u $< | sed 's/ *U *//' | sort -u > $@ diff --git a/Makefrag.am b/Makefrag.am index 9222ad20..2eb835e9 100644 --- a/Makefrag.am +++ b/Makefrag.am @@ -186,6 +186,9 @@ libkernel_a_SOURCES += \ kern/rbtree.c \ kern/rbtree.h \ kern/rbtree_i.h \ + kern/rdxtree.c \ + kern/rdxtree.h \ + kern/rdxtree_i.h \ kern/refcount.h \ kern/slab.c \ kern/slab.h \ diff --git a/kern/rdxtree.c b/kern/rdxtree.c new file mode 100644 index 00000000..78868b1f --- /dev/null +++ b/kern/rdxtree.c @@ -0,0 +1,830 @@ +/* + * Copyright (c) 2011-2015 Richard Braun. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * Upstream site with license notes : + * http://git.sceen.net/rbraun/librbraun.git/ + */ + +#include +#include +#include +#include +#include + +#include "macros.h" +#include "rdxtree.h" +#include "rdxtree_i.h" + +/* XXX */ +#define CHAR_BIT 8U +#define ERR_SUCCESS KERN_SUCCESS +#define ERR_BUSY KERN_INVALID_ARGUMENT +#define ERR_NOMEM KERN_RESOURCE_SHORTAGE + +/* + * Mask applied on an entry to obtain its address. + */ +#define RDXTREE_ENTRY_ADDR_MASK (~0x3UL) + +/* + * Global properties used to shape radix trees. + */ +#define RDXTREE_RADIX 6 +#define RDXTREE_RADIX_SIZE (1UL << RDXTREE_RADIX) +#define RDXTREE_RADIX_MASK (RDXTREE_RADIX_SIZE - 1) + +#if RDXTREE_RADIX < 6 +typedef unsigned long rdxtree_bm_t; +#define rdxtree_ffs(x) __builtin_ffsl(x) +#elif RDXTREE_RADIX == 6 /* RDXTREE_RADIX < 6 */ +typedef unsigned long long rdxtree_bm_t; +#define rdxtree_ffs(x) __builtin_ffsll(x) +#else /* RDXTREE_RADIX < 6 */ +#error "radix too high" +#endif /* RDXTREE_RADIX < 6 */ + +/* + * Allocation bitmap size in bits. + */ +#define RDXTREE_BM_SIZE (sizeof(rdxtree_bm_t) * CHAR_BIT) + +/* + * Empty/full allocation bitmap words. + */ +#define RDXTREE_BM_EMPTY ((rdxtree_bm_t)0) +#define RDXTREE_BM_FULL \ + ((~(rdxtree_bm_t)0) >> (RDXTREE_BM_SIZE - RDXTREE_RADIX_SIZE)) + +/* + * These macros can be replaced by actual functions in an environment + * that provides lockless synchronization such as RCU. + */ +#define llsync_assign_ptr(ptr, value) ((ptr) = (value)) +#define llsync_read_ptr(ptr) (ptr) + +/* + * Radix tree node. + * + * The height of a tree is the number of nodes to traverse until stored + * pointers are reached. A height of 0 means the entries of a node (or the + * tree root) directly point to stored pointers. + * + * The index is valid if and only if the parent isn't NULL. + * + * Concerning the allocation bitmap, a bit is set when the node it denotes, + * or one of its children, can be used to allocate an entry. Conversely, a bit + * is clear when the matching node and all of its children have no free entry. + * + * In order to support safe lockless lookups, in particular during a resize, + * each node includes the height of its subtree, which is invariant during + * the entire node lifetime. Since the tree height does vary, it can't be + * used to determine whether the tree root is a node or a stored pointer. + * This implementation assumes that all nodes and stored pointers are at least + * 4-byte aligned, and uses the least significant bit of entries to indicate + * the pointer type. This bit is set for internal nodes, and clear for stored + * pointers so that they can be accessed from slots without conversion. + */ +struct rdxtree_node { + struct rdxtree_node *parent; + unsigned int index; + unsigned int height; + unsigned int nr_entries; + rdxtree_bm_t alloc_bm; + void *entries[RDXTREE_RADIX_SIZE]; +}; + +/* + * We allocate nodes using the slab allocator. + */ +static struct kmem_cache rdxtree_node_cache; + +void +rdxtree_cache_init(void) +{ + kmem_cache_init(&rdxtree_node_cache, "rdxtree_node", + sizeof(struct rdxtree_node), 0, NULL, NULL, NULL, 0); +} + +#ifdef RDXTREE_ENABLE_NODE_CREATION_FAILURES +unsigned int rdxtree_fail_node_creation_threshold; +unsigned int rdxtree_nr_node_creations; +#endif /* RDXTREE_ENABLE_NODE_CREATION_FAILURES */ + +static inline int +rdxtree_check_alignment(const void *ptr) +{ + return ((unsigned long)ptr & ~RDXTREE_ENTRY_ADDR_MASK) == 0; +} + +static inline void * +rdxtree_entry_addr(void *entry) +{ + return (void *)((unsigned long)entry & RDXTREE_ENTRY_ADDR_MASK); +} + +static inline int +rdxtree_entry_is_node(const void *entry) +{ + return ((unsigned long)entry & 1) != 0; +} + +static inline void * +rdxtree_node_to_entry(struct rdxtree_node *node) +{ + return (void *)((unsigned long)node | 1); +} + +static int +rdxtree_node_create(struct rdxtree_node **nodep, unsigned int height) +{ + struct rdxtree_node *node; + +#ifdef RDXTREE_ENABLE_NODE_CREATION_FAILURES + if (rdxtree_fail_node_creation_threshold != 0) { + rdxtree_nr_node_creations++; + + if (rdxtree_nr_node_creations == rdxtree_fail_node_creation_threshold) + return ERR_NOMEM; + } +#endif /* RDXTREE_ENABLE_NODE_CREATION_FAILURES */ + + node = (struct rdxtree_node *) kmem_cache_alloc(&rdxtree_node_cache); + + if (node == NULL) + return ERR_NOMEM; + + assert(rdxtree_check_alignment(node)); + node->parent = NULL; + node->height = height; + node->nr_entries = 0; + node->alloc_bm = RDXTREE_BM_FULL; + memset(node->entries, 0, sizeof(node->entries)); + *nodep = node; + return 0; +} + +static void +rdxtree_node_schedule_destruction(struct rdxtree_node *node) +{ + /* + * This function is intended to use the appropriate interface to defer + * destruction until all read-side references are dropped in an + * environment that provides lockless synchronization. + * + * Otherwise, it simply "schedules" destruction immediately. + */ + kmem_cache_free(&rdxtree_node_cache, (vm_offset_t) node); +} + +static inline void +rdxtree_node_link(struct rdxtree_node *node, struct rdxtree_node *parent, + unsigned int index) +{ + node->parent = parent; + node->index = index; +} + +static inline void +rdxtree_node_unlink(struct rdxtree_node *node) +{ + assert(node->parent != NULL); + node->parent = NULL; +} + +static inline int +rdxtree_node_full(struct rdxtree_node *node) +{ + return (node->nr_entries == ARRAY_SIZE(node->entries)); +} + +static inline int +rdxtree_node_empty(struct rdxtree_node *node) +{ + return (node->nr_entries == 0); +} + +static inline void +rdxtree_node_insert(struct rdxtree_node *node, unsigned int index, + void *entry) +{ + assert(index < ARRAY_SIZE(node->entries)); + assert(node->entries[index] == NULL); + + node->nr_entries++; + llsync_assign_ptr(node->entries[index], entry); +} + +static inline void +rdxtree_node_insert_node(struct rdxtree_node *node, unsigned int index, + struct rdxtree_node *child) +{ + rdxtree_node_insert(node, index, rdxtree_node_to_entry(child)); +} + +static inline void +rdxtree_node_remove(struct rdxtree_node *node, unsigned int index) +{ + assert(index < ARRAY_SIZE(node->entries)); + assert(node->entries[index] != NULL); + + node->nr_entries--; + llsync_assign_ptr(node->entries[index], NULL); +} + +static inline void * +rdxtree_node_find(struct rdxtree_node *node, unsigned int *indexp) +{ + unsigned int index; + void *ptr; + + index = *indexp; + + while (index < ARRAY_SIZE(node->entries)) { + ptr = rdxtree_entry_addr(llsync_read_ptr(node->entries[index])); + + if (ptr != NULL) { + *indexp = index; + return ptr; + } + + index++; + } + + return NULL; +} + +static inline void +rdxtree_node_bm_set(struct rdxtree_node *node, unsigned int index) +{ + node->alloc_bm |= (rdxtree_bm_t)1 << index; +} + +static inline void +rdxtree_node_bm_clear(struct rdxtree_node *node, unsigned int index) +{ + node->alloc_bm &= ~((rdxtree_bm_t)1 << index); +} + +static inline int +rdxtree_node_bm_is_set(struct rdxtree_node *node, unsigned int index) +{ + return (node->alloc_bm & ((rdxtree_bm_t)1 << index)); +} + +static inline int +rdxtree_node_bm_empty(struct rdxtree_node *node) +{ + return (node->alloc_bm == RDXTREE_BM_EMPTY); +} + +static inline unsigned int +rdxtree_node_bm_first(struct rdxtree_node *node) +{ + return rdxtree_ffs(node->alloc_bm) - 1; +} + +static inline rdxtree_key_t +rdxtree_max_key(unsigned int height) +{ + size_t shift; + + shift = RDXTREE_RADIX * height; + + if (likely(shift < (sizeof(rdxtree_key_t) * CHAR_BIT))) + return ((rdxtree_key_t)1 << shift) - 1; + else + return ~((rdxtree_key_t)0); +} + +static void +rdxtree_shrink(struct rdxtree *tree) +{ + struct rdxtree_node *node; + void *entry; + + while (tree->height > 0) { + node = rdxtree_entry_addr(tree->root); + + if (node->nr_entries != 1) + break; + + entry = node->entries[0]; + + if (entry == NULL) + break; + + tree->height--; + + if (tree->height > 0) + rdxtree_node_unlink(rdxtree_entry_addr(entry)); + + llsync_assign_ptr(tree->root, entry); + rdxtree_node_schedule_destruction(node); + } +} + +static int +rdxtree_grow(struct rdxtree *tree, rdxtree_key_t key) +{ + struct rdxtree_node *root, *node; + unsigned int new_height; + int error; + + new_height = tree->height + 1; + + while (key > rdxtree_max_key(new_height)) + new_height++; + + if (tree->root == NULL) { + tree->height = new_height; + return ERR_SUCCESS; + } + + root = rdxtree_entry_addr(tree->root); + + do { + error = rdxtree_node_create(&node, tree->height); + + if (error) { + rdxtree_shrink(tree); + return error; + } + + if (tree->height == 0) + rdxtree_node_bm_clear(node, 0); + else { + rdxtree_node_link(root, node, 0); + + if (rdxtree_node_bm_empty(root)) + rdxtree_node_bm_clear(node, 0); + } + + rdxtree_node_insert(node, 0, tree->root); + tree->height++; + llsync_assign_ptr(tree->root, rdxtree_node_to_entry(node)); + root = node; + } while (new_height > tree->height); + + return ERR_SUCCESS; +} + +static void +rdxtree_cleanup(struct rdxtree *tree, struct rdxtree_node *node) +{ + struct rdxtree_node *prev; + + for (;;) { + if (likely(!rdxtree_node_empty(node))) { + if (unlikely(node->parent == NULL)) + rdxtree_shrink(tree); + + break; + } + + if (node->parent == NULL) { + tree->height = 0; + llsync_assign_ptr(tree->root, NULL); + rdxtree_node_schedule_destruction(node); + break; + } + + prev = node; + node = node->parent; + rdxtree_node_unlink(prev); + rdxtree_node_remove(node, prev->index); + rdxtree_node_schedule_destruction(prev); + } +} + +static void +rdxtree_insert_bm_clear(struct rdxtree_node *node, unsigned int index) +{ + for (;;) { + rdxtree_node_bm_clear(node, index); + + if (!rdxtree_node_full(node) || (node->parent == NULL)) + break; + + index = node->index; + node = node->parent; + } +} + +int +rdxtree_insert_common(struct rdxtree *tree, rdxtree_key_t key, + void *ptr, void ***slotp) +{ + struct rdxtree_node *node, *prev; + unsigned int height, shift, index = index; + int error; + + assert(ptr != NULL); + assert(rdxtree_check_alignment(ptr)); + + if (unlikely(key > rdxtree_max_key(tree->height))) { + error = rdxtree_grow(tree, key); + + if (error) + return error; + } + + height = tree->height; + + if (unlikely(height == 0)) { + if (tree->root != NULL) + return ERR_BUSY; + + llsync_assign_ptr(tree->root, ptr); + + if (slotp != NULL) + *slotp = &tree->root; + + return ERR_SUCCESS; + } + + node = rdxtree_entry_addr(tree->root); + shift = (height - 1) * RDXTREE_RADIX; + prev = NULL; + + do { + if (node == NULL) { + error = rdxtree_node_create(&node, height - 1); + + if (error) { + if (prev == NULL) + tree->height = 0; + else + rdxtree_cleanup(tree, prev); + + return error; + } + + if (prev == NULL) + llsync_assign_ptr(tree->root, rdxtree_node_to_entry(node)); + else { + rdxtree_node_link(node, prev, index); + rdxtree_node_insert_node(prev, index, node); + } + } + + prev = node; + index = (unsigned int)(key >> shift) & RDXTREE_RADIX_MASK; + node = rdxtree_entry_addr(prev->entries[index]); + shift -= RDXTREE_RADIX; + height--; + } while (height > 0); + + if (unlikely(node != NULL)) + return ERR_BUSY; + + rdxtree_node_insert(prev, index, ptr); + rdxtree_insert_bm_clear(prev, index); + + if (slotp != NULL) + *slotp = &prev->entries[index]; + + return ERR_SUCCESS; +} + +int +rdxtree_insert_alloc_common(struct rdxtree *tree, void *ptr, + rdxtree_key_t *keyp, void ***slotp) +{ + struct rdxtree_node *node, *prev; + unsigned int height, shift, index = index; + rdxtree_key_t key; + int error; + + assert(ptr != NULL); + assert(rdxtree_check_alignment(ptr)); + + height = tree->height; + + if (unlikely(height == 0)) { + if (tree->root == NULL) { + llsync_assign_ptr(tree->root, ptr); + *keyp = 0; + + if (slotp != NULL) + *slotp = &tree->root; + + return ERR_SUCCESS; + } + + goto grow; + } + + node = rdxtree_entry_addr(tree->root); + key = 0; + shift = (height - 1) * RDXTREE_RADIX; + prev = NULL; + + do { + if (node == NULL) { + error = rdxtree_node_create(&node, height - 1); + + if (error) { + rdxtree_cleanup(tree, prev); + return error; + } + + rdxtree_node_link(node, prev, index); + rdxtree_node_insert_node(prev, index, node); + } + + prev = node; + index = rdxtree_node_bm_first(node); + + if (index == (unsigned int)-1) + goto grow; + + key |= (rdxtree_key_t)index << shift; + node = rdxtree_entry_addr(node->entries[index]); + shift -= RDXTREE_RADIX; + height--; + } while (height > 0); + + rdxtree_node_insert(prev, index, ptr); + rdxtree_insert_bm_clear(prev, index); + + if (slotp != NULL) + *slotp = &prev->entries[index]; + + goto out; + +grow: + key = rdxtree_max_key(height) + 1; + error = rdxtree_insert_common(tree, key, ptr, slotp); + + if (error) + return error; + +out: + *keyp = key; + return ERR_SUCCESS; +} + +static void +rdxtree_remove_bm_set(struct rdxtree_node *node, unsigned int index) +{ + do { + rdxtree_node_bm_set(node, index); + + if (node->parent == NULL) + break; + + index = node->index; + node = node->parent; + } while (!rdxtree_node_bm_is_set(node, index)); +} + +void * +rdxtree_remove(struct rdxtree *tree, rdxtree_key_t key) +{ + struct rdxtree_node *node, *prev; + unsigned int height, shift, index; + + height = tree->height; + + if (unlikely(key > rdxtree_max_key(height))) + return NULL; + + node = rdxtree_entry_addr(tree->root); + + if (unlikely(height == 0)) { + llsync_assign_ptr(tree->root, NULL); + return node; + } + + shift = (height - 1) * RDXTREE_RADIX; + + do { + if (node == NULL) + return NULL; + + prev = node; + index = (unsigned int)(key >> shift) & RDXTREE_RADIX_MASK; + node = rdxtree_entry_addr(node->entries[index]); + shift -= RDXTREE_RADIX; + height--; + } while (height > 0); + + if (node == NULL) + return NULL; + + rdxtree_node_remove(prev, index); + rdxtree_remove_bm_set(prev, index); + rdxtree_cleanup(tree, prev); + return node; +} + +void * +rdxtree_lookup_common(const struct rdxtree *tree, rdxtree_key_t key, + int get_slot) +{ + struct rdxtree_node *node, *prev; + unsigned int height, shift, index; + void *entry; + + entry = llsync_read_ptr(tree->root); + + if (entry == NULL) { + node = NULL; + height = 0; + } else { + node = rdxtree_entry_addr(entry); + height = rdxtree_entry_is_node(entry) ? node->height + 1 : 0; + } + + if (key > rdxtree_max_key(height)) + return NULL; + + if (height == 0) { + if (node == NULL) + return NULL; + + return get_slot ? (void *)&tree->root : node; + } + + shift = (height - 1) * RDXTREE_RADIX; + + do { + if (node == NULL) + return NULL; + + prev = node; + index = (unsigned int)(key >> shift) & RDXTREE_RADIX_MASK; + entry = llsync_read_ptr(node->entries[index]); + node = rdxtree_entry_addr(entry); + shift -= RDXTREE_RADIX; + height--; + } while (height > 0); + + if (node == NULL) + return NULL; + + return get_slot ? (void *)&prev->entries[index] : node; +} + +void * +rdxtree_replace_slot(void **slot, void *ptr) +{ + void *old; + + assert(ptr != NULL); + assert(rdxtree_check_alignment(ptr)); + + old = *slot; + assert(old != NULL); + assert(rdxtree_check_alignment(old)); + llsync_assign_ptr(*slot, ptr); + return old; +} + +static void * +rdxtree_walk_next(struct rdxtree *tree, struct rdxtree_iter *iter) +{ + struct rdxtree_node *root, *node, *prev; + unsigned int height, shift, index, orig_index; + rdxtree_key_t key; + void *entry; + + entry = llsync_read_ptr(tree->root); + + if (entry == NULL) + return NULL; + + if (!rdxtree_entry_is_node(entry)) { + if (iter->key != (rdxtree_key_t)-1) + return NULL; + else { + iter->key = 0; + return rdxtree_entry_addr(entry); + } + } + + key = iter->key + 1; + + if ((key == 0) && (iter->node != NULL)) + return NULL; + + root = rdxtree_entry_addr(entry); + +restart: + node = root; + height = root->height + 1; + + if (key > rdxtree_max_key(height)) + return NULL; + + shift = (height - 1) * RDXTREE_RADIX; + + do { + prev = node; + index = (key >> shift) & RDXTREE_RADIX_MASK; + orig_index = index; + node = rdxtree_node_find(node, &index); + + if (node == NULL) { + shift += RDXTREE_RADIX; + key = ((key >> shift) + 1) << shift; + + if (key == 0) + return NULL; + + goto restart; + } + + if (orig_index != index) + key = ((key >> shift) + (index - orig_index)) << shift; + + shift -= RDXTREE_RADIX; + height--; + } while (height > 0); + + iter->node = prev; + iter->key = key; + return node; +} + +void * +rdxtree_walk(struct rdxtree *tree, struct rdxtree_iter *iter) +{ + unsigned int index, orig_index; + void *ptr; + + if (iter->node == NULL) + return rdxtree_walk_next(tree, iter); + + index = (iter->key + 1) & RDXTREE_RADIX_MASK; + + if (index != 0) { + orig_index = index; + ptr = rdxtree_node_find(iter->node, &index); + + if (ptr != NULL) { + iter->key += (index - orig_index) + 1; + return ptr; + } + } + + return rdxtree_walk_next(tree, iter); +} + +void +rdxtree_remove_all(struct rdxtree *tree) +{ + struct rdxtree_node *node, *parent; + struct rdxtree_iter iter; + + if (tree->height == 0) { + if (tree->root != NULL) + llsync_assign_ptr(tree->root, NULL); + + return; + } + + for (;;) { + rdxtree_iter_init(&iter); + rdxtree_walk_next(tree, &iter); + + if (iter.node == NULL) + break; + + node = iter.node; + parent = node->parent; + + if (parent == NULL) + rdxtree_init(tree); + else { + rdxtree_node_remove(parent, node->index); + rdxtree_remove_bm_set(parent, node->index); + rdxtree_cleanup(tree, parent); + node->parent = NULL; + } + + rdxtree_node_schedule_destruction(node); + } +} diff --git a/kern/rdxtree.h b/kern/rdxtree.h new file mode 100644 index 00000000..1f8456e0 --- /dev/null +++ b/kern/rdxtree.h @@ -0,0 +1,209 @@ +/* + * Copyright (c) 2011-2015 Richard Braun. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * Radix tree. + * + * In addition to the standard insertion operation, this implementation + * can allocate keys for the caller at insertion time. + * + * Upstream site with license notes : + * http://git.sceen.net/rbraun/librbraun.git/ + */ + +#ifndef _RDXTREE_H +#define _RDXTREE_H + +#include +#include + +/* + * Initialize the node cache. + */ +void rdxtree_cache_init(void); + +/* + * This macro selects between 32 or 64-bits (the default) keys. + */ +#if 0 +#define RDXTREE_KEY_32 +#endif + +#ifdef RDXTREE_KEY_32 +typedef uint32_t rdxtree_key_t; +#else /* RDXTREE_KEY_32 */ +typedef uint64_t rdxtree_key_t; +#endif /* RDXTREE_KEY_32 */ + +/* + * Radix tree. + */ +struct rdxtree; + +/* + * Radix tree iterator. + */ +struct rdxtree_iter; + +/* + * Static tree initializer. + */ +#define RDXTREE_INITIALIZER { 0, NULL } + +#include "rdxtree_i.h" + +/* + * Initialize a tree. + */ +static inline void +rdxtree_init(struct rdxtree *tree) +{ + tree->height = 0; + tree->root = NULL; +} + +/* + * Insert a pointer in a tree. + * + * The ptr parameter must not be NULL. + */ +static inline int +rdxtree_insert(struct rdxtree *tree, rdxtree_key_t key, void *ptr) +{ + return rdxtree_insert_common(tree, key, ptr, NULL); +} + +/* + * Insert a pointer in a tree and obtain its slot. + * + * The ptr and slotp parameters must not be NULL. If successful, the slot of + * the newly inserted pointer is stored at the address pointed to by the slotp + * parameter. + */ +static inline int +rdxtree_insert_slot(struct rdxtree *tree, rdxtree_key_t key, + void *ptr, void ***slotp) +{ + return rdxtree_insert_common(tree, key, ptr, slotp); +} + +/* + * Insert a pointer in a tree, for which a new key is allocated. + * + * The ptr and keyp parameters must not be NULL. The newly allocated key is + * stored at the address pointed to by the keyp parameter. + */ +static inline int +rdxtree_insert_alloc(struct rdxtree *tree, void *ptr, rdxtree_key_t *keyp) +{ + return rdxtree_insert_alloc_common(tree, ptr, keyp, NULL); +} + +/* + * Insert a pointer in a tree, for which a new key is allocated, and obtain + * its slot. + * + * The ptr, keyp and slotp parameters must not be NULL. The newly allocated + * key is stored at the address pointed to by the keyp parameter while the + * slot of the inserted pointer is stored at the address pointed to by the + * slotp parameter. + */ +static inline int +rdxtree_insert_alloc_slot(struct rdxtree *tree, void *ptr, + rdxtree_key_t *keyp, void ***slotp) +{ + return rdxtree_insert_alloc_common(tree, ptr, keyp, slotp); +} + +/* + * Remove a pointer from a tree. + * + * The matching pointer is returned if successful, NULL otherwise. + */ +void * rdxtree_remove(struct rdxtree *tree, rdxtree_key_t key); + +/* + * Look up a pointer in a tree. + * + * The matching pointer is returned if successful, NULL otherwise. + */ +static inline void * +rdxtree_lookup(const struct rdxtree *tree, rdxtree_key_t key) +{ + return rdxtree_lookup_common(tree, key, 0); +} + +/* + * Look up a slot in a tree. + * + * A slot is a pointer to a stored pointer in a tree. It can be used as + * a placeholder for fast replacements to avoid multiple lookups on the same + * key. + * + * A slot for the matching pointer is returned if successful, NULL otherwise. + * + * See rdxtree_replace_slot(). + */ +static inline void ** +rdxtree_lookup_slot(const struct rdxtree *tree, rdxtree_key_t key) +{ + return rdxtree_lookup_common(tree, key, 1); +} + +/* + * Replace a pointer in a tree. + * + * The ptr parameter must not be NULL. The previous pointer is returned. + * + * See rdxtree_lookup_slot(). + */ +void * rdxtree_replace_slot(void **slot, void *ptr); + +/* + * Forge a loop to process all pointers of a tree. + */ +#define rdxtree_for_each(tree, iter, ptr) \ +for (rdxtree_iter_init(iter), ptr = rdxtree_walk(tree, iter); \ + ptr != NULL; \ + ptr = rdxtree_walk(tree, iter)) + +/* + * Return the key of the current pointer from an iterator. + */ +static inline rdxtree_key_t +rdxtree_iter_key(const struct rdxtree_iter *iter) +{ + return iter->key; +} + +/* + * Remove all pointers from a tree. + * + * The common way to destroy a tree and its pointers is to loop over all + * the pointers using rdxtree_for_each(), freeing them, then call this + * function. + */ +void rdxtree_remove_all(struct rdxtree *tree); + +#endif /* _RDXTREE_H */ diff --git a/kern/rdxtree_i.h b/kern/rdxtree_i.h new file mode 100644 index 00000000..1bd1f64a --- /dev/null +++ b/kern/rdxtree_i.h @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2013-2015 Richard Braun. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * + * Upstream site with license notes : + * http://git.sceen.net/rbraun/librbraun.git/ + */ + +#ifndef _RDXTREE_I_H +#define _RDXTREE_I_H + +/* + * Radix tree. + */ +struct rdxtree { + unsigned int height; + void *root; +}; + +/* + * Radix tree iterator. + * + * The node member refers to the node containing the current pointer, if any. + * The key member refers to the current pointer, and is valid if and only if + * rdxtree_walk() has been called at least once on the iterator. + */ +struct rdxtree_iter { + void *node; + rdxtree_key_t key; +}; + +/* + * Initialize an iterator. + */ +static inline void +rdxtree_iter_init(struct rdxtree_iter *iter) +{ + iter->node = NULL; + iter->key = (rdxtree_key_t)-1; +} + +int rdxtree_insert_common(struct rdxtree *tree, rdxtree_key_t key, + void *ptr, void ***slotp); + +int rdxtree_insert_alloc_common(struct rdxtree *tree, void *ptr, + rdxtree_key_t *keyp, void ***slotp); + +void * rdxtree_lookup_common(const struct rdxtree *tree, rdxtree_key_t key, + int get_slot); + +void * rdxtree_walk(struct rdxtree *tree, struct rdxtree_iter *iter); + +#endif /* _RDXTREE_I_H */ diff --git a/kern/startup.c b/kern/startup.c index 71cd04d5..f9f0c347 100644 --- a/kern/startup.c +++ b/kern/startup.c @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -112,6 +113,7 @@ void setup_main(void) sched_init(); vm_mem_bootstrap(); + rdxtree_cache_init(); ipc_bootstrap(); vm_mem_init(); ipc_init(); -- cgit v1.2.3 From aac601ac36c623247a51d442b2d6438b042d7515 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Mon, 16 Mar 2015 12:52:24 +0100 Subject: ipc: undo manual inlining of `ipc_entry_X' functions Today we can rely on the compiler to inline functions. Undoing this manual optimization is a first step to replace the IPC tables. * ipc/mach_msg.c (mach_msg_trap): Undo the manual inlining of `ipc_entry_lookup', `ipc_entry_dealloc', and `ipc_entry_get'. * ipc/ipc_kmsg.c (ipc_kmsg_copyin_header, ipc_kmsg_copyout_header): Likewise. * kern/exception.c (exception_raise): Likewise. * kern/ipc_mig.c (fast_send_right_lookup): Likewise. --- ipc/ipc_kmsg.c | 107 +++++++++++------------------------------- ipc/mach_msg.c | 139 ++++++++----------------------------------------------- kern/exception.c | 18 ++----- kern/ipc_mig.c | 14 +++--- 4 files changed, 57 insertions(+), 221 deletions(-) diff --git a/ipc/ipc_kmsg.c b/ipc/ipc_kmsg.c index c0f07dd8..cae700f5 100644 --- a/ipc/ipc_kmsg.c +++ b/ipc/ipc_kmsg.c @@ -698,24 +698,14 @@ ipc_kmsg_copyin_header( if (!space->is_active) goto abort_async; - /* optimized ipc_entry_lookup */ - - { - mach_port_index_t index = MACH_PORT_INDEX(dest_name); - mach_port_gen_t gen = MACH_PORT_GEN(dest_name); - - if (index >= space->is_table_size) + entry = ipc_entry_lookup (space, dest_name); + if (entry == IE_NULL) goto abort_async; - - entry = &space->is_table[index]; bits = entry->ie_bits; - /* check generation number and type bit */ - - if ((bits & (IE_BITS_GEN_MASK|MACH_PORT_TYPE_SEND)) != - (gen | MACH_PORT_TYPE_SEND)) + /* check type bits */ + if (IE_BITS_TYPE (bits) != MACH_PORT_TYPE_SEND) goto abort_async; - } /* optimized ipc_right_copyin */ @@ -750,8 +740,6 @@ ipc_kmsg_copyin_header( case MACH_MSGH_BITS(MACH_MSG_TYPE_COPY_SEND, MACH_MSG_TYPE_MAKE_SEND_ONCE): { - ipc_entry_num_t size; - ipc_entry_t table; ipc_entry_t entry; ipc_entry_bits_t bits; ipc_port_t dest_port, reply_port; @@ -762,51 +750,28 @@ ipc_kmsg_copyin_header( if (!space->is_active) goto abort_request; - size = space->is_table_size; - table = space->is_table; - - /* optimized ipc_entry_lookup of dest_name */ - - { - mach_port_index_t index = MACH_PORT_INDEX(dest_name); - mach_port_gen_t gen = MACH_PORT_GEN(dest_name); - - if (index >= size) + entry = ipc_entry_lookup (space, dest_name); + if (entry == IE_NULL) goto abort_request; - - entry = &table[index]; bits = entry->ie_bits; - /* check generation number and type bit */ - - if ((bits & (IE_BITS_GEN_MASK|MACH_PORT_TYPE_SEND)) != - (gen | MACH_PORT_TYPE_SEND)) + /* check type bits */ + if (IE_BITS_TYPE (bits) != MACH_PORT_TYPE_SEND) goto abort_request; - } assert(IE_BITS_UREFS(bits) > 0); dest_port = (ipc_port_t) entry->ie_object; assert(dest_port != IP_NULL); - /* optimized ipc_entry_lookup of reply_name */ - - { - mach_port_index_t index = MACH_PORT_INDEX(reply_name); - mach_port_gen_t gen = MACH_PORT_GEN(reply_name); - - if (index >= size) + entry = ipc_entry_lookup (space, reply_name); + if (entry == IE_NULL) goto abort_request; - - entry = &table[index]; bits = entry->ie_bits; - /* check generation number and type bit */ - - if ((bits & (IE_BITS_GEN_MASK|MACH_PORT_TYPE_RECEIVE)) != - (gen | MACH_PORT_TYPE_RECEIVE)) + /* check type bits */ + if (IE_BITS_TYPE (bits) != MACH_PORT_TYPE_RECEIVE) goto abort_request; - } reply_port = (ipc_port_t) entry->ie_object; assert(reply_port != IP_NULL); @@ -853,9 +818,6 @@ ipc_kmsg_copyin_header( } case MACH_MSGH_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE, 0): { - mach_port_index_t index; - mach_port_gen_t gen; - ipc_entry_t table; ipc_entry_t entry; ipc_entry_bits_t bits; ipc_port_t dest_port; @@ -869,24 +831,13 @@ ipc_kmsg_copyin_header( if (!space->is_active) goto abort_reply; - /* optimized ipc_entry_lookup */ - - table = space->is_table; - - index = MACH_PORT_INDEX(dest_name); - gen = MACH_PORT_GEN(dest_name); - - if (index >= space->is_table_size) + entry = ipc_entry_lookup (space, dest_name); + if (entry == IE_NULL) goto abort_reply; - - entry = &table[index]; bits = entry->ie_bits; - /* check generation number, collision bit, and type bit */ - - if ((bits & (IE_BITS_GEN_MASK|IE_BITS_COLLISION| - MACH_PORT_TYPE_SEND_ONCE)) != - (gen | MACH_PORT_TYPE_SEND_ONCE)) + /* check and type bits */ + if (IE_BITS_TYPE (bits) != MACH_PORT_TYPE_SEND_ONCE) goto abort_reply; /* optimized ipc_right_copyin */ @@ -910,12 +861,8 @@ ipc_kmsg_copyin_header( assert(dest_port->ip_sorights > 0); ip_unlock(dest_port); - /* optimized ipc_entry_dealloc */ - - entry->ie_next = table->ie_next; - table->ie_next = index; - entry->ie_bits = gen; entry->ie_object = IO_NULL; + ipc_entry_dealloc (space, dest_name, entry); is_write_unlock(space); msg->msgh_bits = (MACH_MSGH_BITS_OTHER(mbits) | @@ -1815,8 +1762,6 @@ ipc_kmsg_copyout_header( case MACH_MSGH_BITS(MACH_MSG_TYPE_PORT_SEND, MACH_MSG_TYPE_PORT_SEND_ONCE): { - ipc_entry_t table; - mach_port_index_t index; ipc_entry_t entry; ipc_port_t reply = (ipc_port_t) msg->msgh_local_port; mach_port_t dest_name, reply_name; @@ -1829,8 +1774,7 @@ ipc_kmsg_copyout_header( break; is_write_lock(space); - if (!space->is_active || - ((index = (table = space->is_table)->ie_next) == 0)) { + if (!space->is_active || space->is_table->ie_next == 0) { is_write_unlock(space); break; } @@ -1860,11 +1804,14 @@ ipc_kmsg_copyout_header( assert(reply->ip_sorights > 0); ip_unlock(reply); - /* optimized ipc_entry_get */ - - entry = &table[index]; - table->ie_next = entry->ie_next; - entry->ie_request = 0; + kern_return_t kr; + kr = ipc_entry_get (space, &reply_name, &entry); + if (kr) { + ip_unlock(reply); + ip_unlock(dest); + is_write_unlock(space); + break; + } { mach_port_gen_t gen; @@ -1872,8 +1819,6 @@ ipc_kmsg_copyout_header( assert((entry->ie_bits &~ IE_BITS_GEN_MASK) == 0); gen = entry->ie_bits + IE_BITS_GEN_ONE; - reply_name = MACH_PORT_MAKE(index, gen); - /* optimized ipc_right_copyout */ entry->ie_bits = gen | (MACH_PORT_TYPE_SEND_ONCE | 1); diff --git a/ipc/mach_msg.c b/ipc/mach_msg.c index aecfcd4b..fe0c43e3 100644 --- a/ipc/mach_msg.c +++ b/ipc/mach_msg.c @@ -482,16 +482,7 @@ mach_msg_trap( switch (kmsg->ikm_header.msgh_bits) { case MACH_MSGH_BITS(MACH_MSG_TYPE_COPY_SEND, MACH_MSG_TYPE_MAKE_SEND_ONCE): { - ipc_entry_t table; - ipc_entry_num_t size; ipc_port_t reply_port; - - /* sending a request message */ - - { - mach_port_index_t index; - mach_port_gen_t gen; - { mach_port_t reply_name = kmsg->ikm_header.msgh_local_port; @@ -499,75 +490,36 @@ mach_msg_trap( if (reply_name != rcv_name) goto slow_copyin; - /* optimized ipc_entry_lookup of reply_name */ - - index = MACH_PORT_INDEX(reply_name); - gen = MACH_PORT_GEN(reply_name); - } - is_read_lock(space); assert(space->is_active); - size = space->is_table_size; - table = space->is_table; - - if (index >= size) - goto abort_request_copyin; - - { ipc_entry_t entry; - ipc_entry_bits_t bits; - - entry = &table[index]; - bits = entry->ie_bits; - - /* check generation number and type bit */ - - if ((bits & (IE_BITS_GEN_MASK| - MACH_PORT_TYPE_RECEIVE)) != - (gen | MACH_PORT_TYPE_RECEIVE)) + entry = ipc_entry_lookup (space, reply_name); + if (entry == IE_NULL) goto abort_request_copyin; - reply_port = (ipc_port_t) entry->ie_object; assert(reply_port != IP_NULL); } - } - - /* optimized ipc_entry_lookup of dest_name */ - - { - mach_port_index_t index; - mach_port_gen_t gen; { mach_port_t dest_name = kmsg->ikm_header.msgh_remote_port; - index = MACH_PORT_INDEX(dest_name); - gen = MACH_PORT_GEN(dest_name); - } - - if (index >= size) - goto abort_request_copyin; - - { ipc_entry_t entry; ipc_entry_bits_t bits; - - entry = &table[index]; + entry = ipc_entry_lookup (space, dest_name); + if (entry == IE_NULL) + goto abort_request_copyin; bits = entry->ie_bits; - /* check generation number and type bit */ - - if ((bits & (IE_BITS_GEN_MASK|MACH_PORT_TYPE_SEND)) != - (gen | MACH_PORT_TYPE_SEND)) + /* check type bits */ + if (IE_BITS_TYPE (bits) != MACH_PORT_TYPE_SEND) goto abort_request_copyin; assert(IE_BITS_UREFS(bits) > 0); dest_port = (ipc_port_t) entry->ie_object; assert(dest_port != IP_NULL); - } } /* @@ -649,9 +601,6 @@ mach_msg_trap( } case MACH_MSGH_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE, 0): { - ipc_entry_num_t size; - ipc_entry_t table; - /* sending a reply message */ { @@ -665,35 +614,18 @@ mach_msg_trap( is_write_lock(space); assert(space->is_active); - /* optimized ipc_entry_lookup */ - - size = space->is_table_size; - table = space->is_table; - { ipc_entry_t entry; - mach_port_gen_t gen; - mach_port_index_t index; - - { mach_port_t dest_name = kmsg->ikm_header.msgh_remote_port; - index = MACH_PORT_INDEX(dest_name); - gen = MACH_PORT_GEN(dest_name); - } - - if (index >= size) + entry = ipc_entry_lookup (space, dest_name); + if (entry == IE_NULL) goto abort_reply_dest_copyin; - entry = &table[index]; - - /* check generation, collision bit, and type bit */ - - if ((entry->ie_bits & (IE_BITS_GEN_MASK| - IE_BITS_COLLISION| - MACH_PORT_TYPE_SEND_ONCE)) != - (gen | MACH_PORT_TYPE_SEND_ONCE)) + /* check type bits */ + if (IE_BITS_TYPE (entry->ie_bits) != + MACH_PORT_TYPE_SEND_ONCE) goto abort_reply_dest_copyin; /* optimized ipc_right_copyin */ @@ -716,13 +648,8 @@ mach_msg_trap( } assert(dest_port->ip_sorights > 0); - - /* optimized ipc_entry_dealloc */ - - entry->ie_next = table->ie_next; - table->ie_next = index; - entry->ie_bits = gen; entry->ie_object = IO_NULL; + ipc_entry_dealloc (space, dest_name, entry); } kmsg->ikm_header.msgh_bits = @@ -735,31 +662,16 @@ mach_msg_trap( assert(dest_port->ip_receiver != ipc_space_kernel); - /* optimized ipc_entry_lookup/ipc_mqueue_copyin */ + /* optimized ipc_mqueue_copyin */ { ipc_entry_t entry; ipc_entry_bits_t bits; - - { - mach_port_index_t index; - mach_port_gen_t gen; - - index = MACH_PORT_INDEX(rcv_name); - gen = MACH_PORT_GEN(rcv_name); - - if (index >= size) + entry = ipc_entry_lookup (space, rcv_name); + if (entry == IE_NULL) goto abort_reply_rcv_copyin; - - entry = &table[index]; bits = entry->ie_bits; - /* check generation number */ - - if ((bits & IE_BITS_GEN_MASK) != gen) - goto abort_reply_rcv_copyin; - } - /* check type bits; looking for receive or set */ if (bits & MACH_PORT_TYPE_PORT_SET) { @@ -1073,21 +985,12 @@ mach_msg_trap( ip_unlock(reply_port); { - ipc_entry_t table; ipc_entry_t entry; - mach_port_index_t index; - - /* optimized ipc_entry_get */ - - table = space->is_table; - index = table->ie_next; - - if (index == 0) + kern_return_t kr; + kr = ipc_entry_get (space, &reply_name, &entry); + if (kr) goto abort_request_copyout; - - entry = &table[index]; - table->ie_next = entry->ie_next; - entry->ie_request = 0; + assert (entry != NULL); { mach_port_gen_t gen; @@ -1095,8 +998,6 @@ mach_msg_trap( assert((entry->ie_bits &~ IE_BITS_GEN_MASK) == 0); gen = entry->ie_bits + IE_BITS_GEN_ONE; - reply_name = MACH_PORT_MAKE(index, gen); - /* optimized ipc_right_copyout */ entry->ie_bits = gen | (MACH_PORT_TYPE_SEND_ONCE | 1); diff --git a/kern/exception.c b/kern/exception.c index 7954fbad..6e84c0a5 100644 --- a/kern/exception.c +++ b/kern/exception.c @@ -603,30 +603,18 @@ exception_raise( ip_unlock(reply_port); { - ipc_entry_t table; + kern_return_t kr; ipc_entry_t entry; - mach_port_index_t index; - - /* optimized ipc_entry_get */ - - table = space->is_table; - index = table->ie_next; - if (index == 0) + kr = ipc_entry_get (space, &exc->Head.msgh_remote_port, &entry); + if (kr) goto abort_copyout; - - entry = &table[index]; - table->ie_next = entry->ie_next; - entry->ie_request = 0; - { mach_port_gen_t gen; assert((entry->ie_bits &~ IE_BITS_GEN_MASK) == 0); gen = entry->ie_bits + IE_BITS_GEN_ONE; - exc->Head.msgh_remote_port = MACH_PORT_MAKE(index, gen); - /* optimized ipc_right_copyout */ entry->ie_bits = gen | (MACH_PORT_TYPE_SEND_ONCE | 1); diff --git a/kern/ipc_mig.c b/kern/ipc_mig.c index cc61ec76..22dac420 100644 --- a/kern/ipc_mig.c +++ b/kern/ipc_mig.c @@ -310,16 +310,18 @@ mig_strncpy(dest, src, len) MACRO_BEGIN \ ipc_space_t space = current_space(); \ ipc_entry_t entry; \ - mach_port_index_t index = MACH_PORT_INDEX(name); \ \ is_read_lock(space); \ assert(space->is_active); \ \ - if ((index >= space->is_table_size) || \ - (((entry = &space->is_table[index])->ie_bits & \ - (IE_BITS_GEN_MASK|MACH_PORT_TYPE_SEND)) != \ - (MACH_PORT_GEN(name) | MACH_PORT_TYPE_SEND))) { \ - is_read_unlock(space); \ + entry = ipc_entry_lookup (space, name); \ + if (entry == IE_NULL) { \ + is_read_unlock (space); \ + abort; \ + } \ + \ + if (IE_BITS_TYPE (entry->ie_bits) != MACH_PORT_TYPE_SEND) { \ + is_read_unlock (space); \ abort; \ } \ \ -- cgit v1.2.3 From 5a00790518773385e681e6430a4f85245fae957d Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Wed, 18 Mar 2015 12:25:26 +0100 Subject: ipc: replace reverse hash table with a radix tree Currently, there is a hash table mapping (space, object) tuples to `ipc_entry' objects. This hash table is intertwined with the IPC tables. There is one hash table per IPC space, but it is only for the entries in the IPC table. This hash table is called `local' in the source. All IPC entries being spilled into the splay tree are instead mapped by a global hash table. Replace the local (i.e. per IPC space) reverse hash table with a radix tree. * ipc/ipc_entry.c (ipc_entry_grow_table): Adjust accordingly. * ipc/ipc_entry.h (struct ipc_entry): Adjust comment. * ipc/ipc_hash.c: Adjust comment explaining the local lookup table. (IPC_LOCAL_HASH_INVARIANT): New macro. (ipc_hash_local_lookup): Use the new `ipc_reverse_lookup' function. (ipc_hash_local_insert): Use the new `ipc_reverse_insert' function. (ipc_hash_local_delete): Use the new `ipc_reverse_remove' function. * ipc/ipc_space.c (ipc_space_create): Initialize radix tree. (ipc_space_destroy): Free radix tree. * ipc/ipc_space.h (struct ipc_space): Add radix tree. (ipc_reverse_insert): New function. (ipc_reverse_remove): Likewise. (ipc_reverse_remove_all): Likewise. (ipc_reverse_lookup): Likewise. * ipc/ipc_right.c (ipc_right_clean): Update comment. --- ipc/ipc_entry.c | 5 +- ipc/ipc_entry.h | 5 -- ipc/ipc_hash.c | 184 ++++++++------------------------------------------------ ipc/ipc_right.c | 2 +- ipc/ipc_space.c | 3 + ipc/ipc_space.h | 63 +++++++++++++++++++ 6 files changed, 94 insertions(+), 168 deletions(-) diff --git a/ipc/ipc_entry.c b/ipc/ipc_entry.c index e78f74ed..5b9fd98e 100644 --- a/ipc/ipc_entry.c +++ b/ipc/ipc_entry.c @@ -618,6 +618,7 @@ ipc_entry_grow_table(ipc_space_t space) is_write_unlock(space); thread_wakeup((event_t) space); it_entries_free(its, table); + ipc_reverse_remove_all(space); is_write_lock(space); return KERN_SUCCESS; } @@ -641,9 +642,6 @@ ipc_entry_grow_table(ipc_space_t space) memcpy(table, otable, osize * sizeof(struct ipc_entry)); - for (i = 0; i < osize; i++) - table[i].ie_index = 0; - (void) memset((void *) (table + osize), 0, (size - osize) * sizeof(struct ipc_entry)); @@ -651,6 +649,7 @@ ipc_entry_grow_table(ipc_space_t space) * Put old entries into the reverse hash table. */ + ipc_reverse_remove_all(space); for (i = 0; i < osize; i++) { ipc_entry_t entry = &table[i]; diff --git a/ipc/ipc_entry.h b/ipc/ipc_entry.h index cb6d3f9f..0caa70b0 100644 --- a/ipc/ipc_entry.h +++ b/ipc/ipc_entry.h @@ -54,11 +54,6 @@ * those entries. The cutoff point between the table and the tree * is adjusted dynamically to minimize memory consumption. * - * The ie_index field of entries in the table implements - * a ordered hash table with open addressing and linear probing. - * This hash table converts (space, object) -> name. - * It is used independently of the other fields. - * * Free (unallocated) entries in the table have null ie_object * fields. The ie_bits field is zero except for IE_BITS_GEN. * The ie_next (ie_request) field links free entries into a free list. diff --git a/ipc/ipc_hash.c b/ipc/ipc_hash.c index c2c6d6ef..87952a79 100644 --- a/ipc/ipc_hash.c +++ b/ipc/ipc_hash.c @@ -296,37 +296,19 @@ ipc_hash_global_delete( } /* - * Each space has a local reverse hash table, which holds - * entries from the space's table. In fact, the hash table - * just uses a field (ie_index) in the table itself. - * - * The local hash table is an open-addressing hash table, - * which means that when a collision occurs, instead of - * throwing the entry into a bucket, the entry is rehashed - * to another position in the table. In this case the rehash - * is very simple: linear probing (ie, just increment the position). - * This simple rehash makes deletions tractable (they're still a pain), - * but it means that collisions tend to build up into clumps. - * - * Because at least one entry in the table (index 0) is always unused, - * there will always be room in the reverse hash table. If a table - * with n slots gets completely full, the reverse hash table will - * have one giant clump of n-1 slots and one free slot somewhere. - * Because entries are only entered into the reverse table if they - * are pure send rights (not receive, send-once, port-set, - * or dead-name rights), and free entries of course aren't entered, - * I expect the reverse hash table won't get unreasonably full. - * - * Ordered hash tables (Amble & Knuth, Computer Journal, v. 17, no. 2, - * pp. 135-142.) may be desirable here. They can dramatically help - * unsuccessful lookups. But unsuccessful lookups are almost always - * followed by insertions, and those slow down somewhat. They - * also can help deletions somewhat. Successful lookups aren't affected. - * So possibly a small win; probably nothing significant. + * Each space has a local reverse mapping from objects to entries + * from the space's table. This used to be a hash table. */ -#define IH_LOCAL_HASH(obj, size) \ - ((((mach_port_index_t) (vm_offset_t) (obj)) >> 6) & (size - 1)) +#define IPC_LOCAL_HASH_INVARIANT(S, O, N, E) \ + MACRO_BEGIN \ + assert(IE_BITS_TYPE((E)->ie_bits) == MACH_PORT_TYPE_SEND || \ + IE_BITS_TYPE((E)->ie_bits) == MACH_PORT_TYPE_SEND_RECEIVE || \ + IE_BITS_TYPE((E)->ie_bits) == MACH_PORT_TYPE_NONE); \ + assert((E)->ie_object == (O)); \ + assert((E)->ie_index == (N)); \ + assert(&(S)->is_table[N] == (E)); \ + MACRO_END /* * Routine: ipc_hash_local_lookup @@ -345,37 +327,15 @@ ipc_hash_local_lookup( mach_port_t *namep, ipc_entry_t *entryp) { - ipc_entry_t table; - ipc_entry_num_t size; - mach_port_index_t hindex, index; - assert(space != IS_NULL); assert(obj != IO_NULL); - table = space->is_table; - size = space->is_table_size; - hindex = IH_LOCAL_HASH(obj, size); - - /* - * Ideally, table[hindex].ie_index is the name we want. - * However, must check ie_object to verify this, - * because collisions can happen. In case of a collision, - * search farther along in the clump. - */ - - while ((index = table[hindex].ie_index) != 0) { - ipc_entry_t entry = &table[index]; - - if (entry->ie_object == obj) { - *namep = MACH_PORT_MAKEB(index, entry->ie_bits); - *entryp = entry; - return TRUE; - } - - if (++hindex == size) - hindex = 0; + *entryp = ipc_reverse_lookup(space, obj); + if (*entryp != IE_NULL) { + *namep = (*entryp)->ie_index; + IPC_LOCAL_HASH_INVARIANT(space, obj, *namep, *entryp); + return TRUE; } - return FALSE; } @@ -394,33 +354,15 @@ ipc_hash_local_insert( mach_port_index_t index, ipc_entry_t entry) { - ipc_entry_t table; - ipc_entry_num_t size; - mach_port_index_t hindex; - + kern_return_t kr; assert(index != 0); assert(space != IS_NULL); assert(obj != IO_NULL); - table = space->is_table; - size = space->is_table_size; - hindex = IH_LOCAL_HASH(obj, size); - - assert(entry == &table[index]); - assert(entry->ie_object == obj); - - /* - * We want to insert at hindex, but there may be collisions. - * If a collision occurs, search for the end of the clump - * and insert there. - */ - - while (table[hindex].ie_index != 0) { - if (++hindex == size) - hindex = 0; - } - - table[hindex].ie_index = index; + entry->ie_index = index; + IPC_LOCAL_HASH_INVARIANT(space, obj, index, entry); + kr = ipc_reverse_insert(space, obj, entry); + assert(kr == 0); } /* @@ -438,90 +380,14 @@ ipc_hash_local_delete( mach_port_index_t index, ipc_entry_t entry) { - ipc_entry_t table; - ipc_entry_num_t size; - mach_port_index_t hindex, dindex; - + ipc_entry_t removed; assert(index != MACH_PORT_NULL); assert(space != IS_NULL); assert(obj != IO_NULL); - table = space->is_table; - size = space->is_table_size; - hindex = IH_LOCAL_HASH(obj, size); - - assert(entry == &table[index]); - assert(entry->ie_object == obj); - - /* - * First check we have the right hindex for this index. - * In case of collision, we have to search farther - * along in this clump. - */ - - while (table[hindex].ie_index != index) { - if (table[hindex].ie_index == 0) - { - static int gak = 0; - if (gak == 0) - { - printf("gak! entry wasn't in hash table!\n"); - gak = 1; - } - return; - } - if (++hindex == size) - hindex = 0; - } - - /* - * Now we want to set table[hindex].ie_index = 0. - * But if we aren't the last index in a clump, - * this might cause problems for lookups of objects - * farther along in the clump that are displaced - * due to collisions. Searches for them would fail - * at hindex instead of succeeding. - * - * So we must check the clump after hindex for objects - * that are so displaced, and move one up to the new hole. - * - * hindex - index of new hole in the clump - * dindex - index we are checking for a displaced object - * - * When we move a displaced object up into the hole, - * it creates a new hole, and we have to repeat the process - * until we get to the end of the clump. - */ - - for (dindex = hindex; index != 0; hindex = dindex) { - for (;;) { - mach_port_index_t tindex; - ipc_object_t tobj; - - if (++dindex == size) - dindex = 0; - assert(dindex != hindex); - - /* are we at the end of the clump? */ - - index = table[dindex].ie_index; - if (index == 0) - break; - - /* is this a displaced object? */ - - tobj = table[index].ie_object; - assert(tobj != IO_NULL); - tindex = IH_LOCAL_HASH(tobj, size); - - if ((dindex < hindex) ? - ((dindex < tindex) && (tindex <= hindex)) : - ((dindex < tindex) || (tindex <= hindex))) - break; - } - - table[hindex].ie_index = index; - } + IPC_LOCAL_HASH_INVARIANT(space, obj, index, entry); + removed = ipc_reverse_remove(space, obj); + assert(removed == entry); } /* diff --git a/ipc/ipc_right.c b/ipc/ipc_right.c index 503eb1fc..35061c9a 100644 --- a/ipc/ipc_right.c +++ b/ipc/ipc_right.c @@ -423,7 +423,7 @@ ipc_right_check( * Purpose: * Cleans up an entry in a dead space. * The entry isn't deallocated or removed - * from reverse hash tables. + * from the reverse mappings. * Conditions: * The space is dead and unlocked. */ diff --git a/ipc/ipc_space.c b/ipc/ipc_space.c index ab55e838..dcc96b34 100644 --- a/ipc/ipc_space.c +++ b/ipc/ipc_space.c @@ -148,6 +148,7 @@ ipc_space_create( space->is_tree_total = 0; space->is_tree_small = 0; space->is_tree_hash = 0; + rdxtree_init(&space->is_reverse_map); *spacep = space; return KERN_SUCCESS; @@ -271,6 +272,8 @@ ipc_space_destroy( } ipc_splay_traverse_finish(&space->is_tree); + rdxtree_remove_all(&space->is_reverse_map); + /* * Because the space is now dead, * we must release the "active" reference for it. diff --git a/ipc/ipc_space.h b/ipc/ipc_space.h index 3bd2f4d0..f41c64c2 100644 --- a/ipc/ipc_space.h +++ b/ipc/ipc_space.h @@ -42,8 +42,10 @@ #include #include #include +#include #include #include +#include #include #include #include @@ -79,6 +81,8 @@ struct ipc_space { ipc_entry_num_t is_tree_total; /* number of entries in the tree */ ipc_entry_num_t is_tree_small; /* # of small entries in the tree */ ipc_entry_num_t is_tree_hash; /* # of hashed entries in the tree */ + struct rdxtree is_reverse_map; /* maps objects to entries */ + }; #define IS_NULL ((ipc_space_t) 0) @@ -135,4 +139,63 @@ kern_return_t ipc_space_create(ipc_table_size_t, ipc_space_t *); kern_return_t ipc_space_create_special(struct ipc_space **); void ipc_space_destroy(struct ipc_space *); +/* Reverse lookups. */ + +/* Cast a pointer to a suitable key. */ +#define KEY(X) \ + ({ \ + assert((((unsigned long) (X)) & 0x07) == 0); \ + ((unsigned long long) \ + (((unsigned long) (X) - VM_MIN_KERNEL_ADDRESS) >> 3)); \ + }) + +/* Insert (OBJ, ENTRY) pair into the reverse mapping. SPACE must + be write-locked. */ +static inline kern_return_t +ipc_reverse_insert(ipc_space_t space, + ipc_object_t obj, + ipc_entry_t entry) +{ + assert(space != IS_NULL); + assert(obj != IO_NULL); + return (kern_return_t) rdxtree_insert(&space->is_reverse_map, + KEY(obj), entry); +} + +/* Remove OBJ from the reverse mapping. SPACE must be + write-locked. */ +static inline ipc_entry_t +ipc_reverse_remove(ipc_space_t space, + ipc_object_t obj) +{ + assert(space != IS_NULL); + assert(obj != IO_NULL); + return rdxtree_remove(&space->is_reverse_map, KEY(obj)); +} + +/* Remove all entries from the reverse mapping. SPACE must be + write-locked. */ +static inline void +ipc_reverse_remove_all(ipc_space_t space) +{ + assert(space != IS_NULL); + rdxtree_remove_all(&space->is_reverse_map); + assert(space->is_reverse_map.height == 0); + assert(space->is_reverse_map.root == NULL); +} + +/* Return ENTRY related to OBJ, or NULL if no such entry is found in + the reverse mapping. SPACE must be read-locked or + write-locked. */ +static inline ipc_entry_t +ipc_reverse_lookup(ipc_space_t space, + ipc_object_t obj) +{ + assert(space != IS_NULL); + assert(obj != IO_NULL); + return rdxtree_lookup(&space->is_reverse_map, KEY(obj)); +} + +#undef KEY + #endif /* _IPC_IPC_SPACE_H_ */ -- cgit v1.2.3 From 77b3b60aaee2382142dc7ed50e5b36664cdb21bc Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Fri, 20 Mar 2015 00:21:14 +0100 Subject: ipc: replace the IPC table with a radix tree Currently, the port names are mapped to an IPC object (e.g. a port) using a table. This, however, requires large chunks of continuous memory, and leads to scalability problems as virtual kernel memory is a scarce resource. To avoid excessive overhead, non-contiguous port names are spilled into a splay tree. Replace the IPC table with a radix tree. As the radix tree is able to store non-contiguous names with reasonable overhead, we can drop the splay tree as well. * ipc/ipc_entry.c (ipc_entry_tree_collision): Remove function. (ipc_entry_cache): New variable. (ipc_entry_lookup): Replace with a radix tree lookup. (ipc_entry_get): The free list handling is changed a little. Adopt accordingly. (ipc_entry_free_name): New function. (ipc_entry_alloc): Adopt accordingly. (ipc_entry_alloc_name): Likewise. (ipc_entry_dealloc): Likewise. (ipc_entry_grow_table): Remove function. * ipc/ipc_entry.h (struct ipc_entry): Update comment, add field for name and free list, remove unused fields. (ipc_entry_cache, ie_alloc, ie_free): New declarations. (struct ipc_tree_entry): Remove. Also remove any related declarations. (ipc_entry_grow_table): Remove declaration. * ipc/ipc_init.c (ipc_bootstrap): Adopt initialization. * ipc/ipc_kmsg.c (ipc_kmsg_copyout_header): Use `ipc_entry_alloc' instead of re-coding it. Adopt free list handling. (ipc_kmsg_copyout_object): Adopt free list handling, store the name. * ipc/ipc_object.c (ipc_object_copyout): Likewise. (ipc_object_copyout_multiname): Likewise. * ipc/ipc_space.c (ipc_space_create): Initialize radix tree and free list. Drop table and splay tree initialization. (ipc_space_destroy): Free ipc entries and radix tree, remove table and splay tree cleanup. * ipc/ipc_space.h (struct ipc_space): Add radix tree, free list, and size. Remove all fields related to the table and splay tree. * ddb/db_print.c (db_port_iterate): Adopt iteration. (db_lookup_port): Adopt lookup. * include/mach_debug/ipc_info.h: Remove unused parts of the debug interface. * include/mach_debug/mach_debug.defs: Likewise. * include/mach_debug/mach_debug_types.defs: Likewise. * ipc/mach_debug.c: Likewise. * ipc/ipc_right.c (ipc_right_reverse): Adopt lookup, store name. (ipc_right_check): Adopt removal. (ipc_right_destroy): Likewise. (ipc_right_dealloc): Likewise. (ipc_right_delta): Likewise. (ipc_right_copyin): Adopt insertion, adopt removal. (ipc_right_copyin_two): Adopt removal. (ipc_right_copyout): Adopt insertion, adopt removal. (ipc_right_rename): Likewise, also update comment. * ipc/mach_port.c (mach_port_names): Adopt iteration. (mach_port_get_set_status): Likewise. * ipc/port.h: Update comment. * ipc/ipc_hash.c: Delete file. * ipc/ipc_hash.h: Likewise. * ipc/ipc_splay.c: Likewise. * ipc/ipc_splay.h: Likewise. * Makefrag.am (libkernel_a_SOURCES): Remove these files. --- Makefrag.am | 4 - ddb/db_print.c | 20 +- include/mach_debug/ipc_info.h | 23 - include/mach_debug/mach_debug.defs | 21 +- include/mach_debug/mach_debug_types.defs | 7 +- ipc/ipc_entry.c | 720 ++++-------------------- ipc/ipc_entry.h | 55 +- ipc/ipc_hash.c | 486 ---------------- ipc/ipc_hash.h | 96 ---- ipc/ipc_init.c | 6 +- ipc/ipc_kmsg.c | 32 +- ipc/ipc_object.c | 23 +- ipc/ipc_right.c | 39 +- ipc/ipc_space.c | 104 +--- ipc/ipc_space.h | 18 +- ipc/ipc_splay.c | 920 ------------------------------- ipc/ipc_splay.h | 114 ---- ipc/mach_debug.c | 325 ----------- ipc/mach_port.c | 60 +- ipc/port.h | 5 +- 20 files changed, 198 insertions(+), 2880 deletions(-) delete mode 100644 ipc/ipc_hash.c delete mode 100644 ipc/ipc_hash.h delete mode 100644 ipc/ipc_splay.c delete mode 100644 ipc/ipc_splay.h diff --git a/Makefrag.am b/Makefrag.am index 2eb835e9..023a4d1d 100644 --- a/Makefrag.am +++ b/Makefrag.am @@ -80,8 +80,6 @@ endif libkernel_a_SOURCES += \ ipc/ipc_entry.c \ ipc/ipc_entry.h \ - ipc/ipc_hash.c \ - ipc/ipc_hash.h \ ipc/ipc_init.c \ ipc/ipc_init.h \ ipc/ipc_kmsg.c \ @@ -105,8 +103,6 @@ libkernel_a_SOURCES += \ ipc/ipc_right.h \ ipc/ipc_space.c \ ipc/ipc_space.h \ - ipc/ipc_splay.c \ - ipc/ipc_splay.h \ ipc/ipc_table.c \ ipc/ipc_table.h \ ipc/ipc_target.c \ diff --git a/ddb/db_print.c b/ddb/db_print.c index 24a3e337..fb4efaad 100644 --- a/ddb/db_print.c +++ b/ddb/db_print.c @@ -439,17 +439,11 @@ db_port_iterate(thread, func) void (*func)(); { ipc_entry_t entry; - int index; int n = 0; - int size; - ipc_space_t space; - - space = thread->task->itk_space; - entry = space->is_table; - size = space->is_table_size; - for (index = 0; index < size; index++, entry++) { + struct rdxtree_iter iter; + rdxtree_for_each(&thread->task->itk_space->is_map, &iter, entry) { if (entry->ie_bits & MACH_PORT_TYPE_PORT_RIGHTS) - (*func)(index, (ipc_port_t) entry->ie_object, + (*func)(entry->ie_name, (ipc_port_t) entry->ie_object, entry->ie_bits, n++); } return(n); @@ -460,16 +454,14 @@ db_lookup_port( thread_t thread, int id) { - ipc_space_t space; ipc_entry_t entry; if (thread == THREAD_NULL) return(0); - space = thread->task->itk_space; - if (id < 0 || id >= space->is_table_size) + if (id < 0) return(0); - entry = &space->is_table[id]; - if (entry->ie_bits & MACH_PORT_TYPE_PORT_RIGHTS) + entry = ipc_entry_lookup(thread->task->itk_space, (mach_port_t) id); + if (entry && entry->ie_bits & MACH_PORT_TYPE_PORT_RIGHTS) return((ipc_port_t)entry->ie_object); return(0); } diff --git a/include/mach_debug/ipc_info.h b/include/mach_debug/ipc_info.h index ef0b0c6a..a47ae7b4 100644 --- a/include/mach_debug/ipc_info.h +++ b/include/mach_debug/ipc_info.h @@ -43,40 +43,17 @@ * in mach_debug_types.defs when adding/removing fields. */ - -typedef struct ipc_info_space { - natural_t iis_genno_mask; /* generation number mask */ - natural_t iis_table_size; /* size of table */ - natural_t iis_table_next; /* next possible size of table */ - natural_t iis_tree_size; /* size of tree */ - natural_t iis_tree_small; /* # of small entries in tree */ - natural_t iis_tree_hash; /* # of hashed entries in tree */ -} ipc_info_space_t; - - typedef struct ipc_info_name { mach_port_t iin_name; /* port name, including gen number */ -/*boolean_t*/integer_t iin_collision; /* collision at this entry? */ -/*boolean_t*/integer_t iin_compat; /* is this a compat-mode entry? */ /*boolean_t*/integer_t iin_marequest; /* extant msg-accepted request? */ mach_port_type_t iin_type; /* straight port type */ mach_port_urefs_t iin_urefs; /* user-references */ vm_offset_t iin_object; /* object pointer */ natural_t iin_next; /* marequest/next in free list */ - natural_t iin_hash; /* hash index */ } ipc_info_name_t; typedef ipc_info_name_t *ipc_info_name_array_t; - -typedef struct ipc_info_tree_name { - ipc_info_name_t iitn_name; - mach_port_t iitn_lchild; /* name of left child */ - mach_port_t iitn_rchild; /* name of right child */ -} ipc_info_tree_name_t; - -typedef ipc_info_tree_name_t *ipc_info_tree_name_array_t; - /* * Type definitions for mach_port_kernel_object. * By remarkable coincidence, these closely resemble diff --git a/include/mach_debug/mach_debug.defs b/include/mach_debug/mach_debug.defs index fb6e3a95..c8e8b1b4 100644 --- a/include/mach_debug/mach_debug.defs +++ b/include/mach_debug/mach_debug.defs @@ -57,14 +57,7 @@ routine mach_port_get_srights( name : mach_port_name_t; out srights : mach_port_rights_t); -/* - * Returns information about the global reverse hash table. - */ - -routine host_ipc_hash_info( - host : host_t; - out info : hash_info_bucket_array_t, - CountInOut, Dealloc); +skip; /* host_ipc_hash_info */ /* * Returns information about the marequest hash table. @@ -76,17 +69,7 @@ routine host_ipc_marequest_info( out info : hash_info_bucket_array_t, CountInOut, Dealloc); -/* - * Returns information about an IPC space. - */ - -routine mach_port_space_info( - task : ipc_space_t; - out info : ipc_info_space_t; - out table_info : ipc_info_name_array_t, - CountInOut, Dealloc; - out tree_info : ipc_info_tree_name_array_t, - CountInOut, Dealloc); +skip; /* mach_port_space_info */ /* * Returns information about the dead-name requests diff --git a/include/mach_debug/mach_debug_types.defs b/include/mach_debug/mach_debug_types.defs index d24b6f93..8df2f344 100644 --- a/include/mach_debug/mach_debug_types.defs +++ b/include/mach_debug/mach_debug_types.defs @@ -38,14 +38,9 @@ type cache_info_array_t = array[] of cache_info_t; type hash_info_bucket_t = struct[1] of natural_t; type hash_info_bucket_array_t = array[] of hash_info_bucket_t; -type ipc_info_space_t = struct[6] of natural_t; - -type ipc_info_name_t = struct[9] of natural_t; +type ipc_info_name_t = struct[6] of natural_t; type ipc_info_name_array_t = array[] of ipc_info_name_t; -type ipc_info_tree_name_t = struct[11] of natural_t; -type ipc_info_tree_name_array_t = array[] of ipc_info_tree_name_t; - type vm_region_info_t = struct[11] of natural_t; type vm_region_info_array_t = array[] of vm_region_info_t; diff --git a/ipc/ipc_entry.c b/ipc/ipc_entry.c index 5b9fd98e..2d6e6658 100644 --- a/ipc/ipc_entry.c +++ b/ipc/ipc_entry.c @@ -46,45 +46,10 @@ #include #include #include -#include -#include #include #include -struct kmem_cache ipc_tree_entry_cache; - -/* - * Routine: ipc_entry_tree_collision - * Purpose: - * Checks if "name" collides with an allocated name - * in the space's tree. That is, returns TRUE - * if the splay tree contains a name with the same - * index as "name". - * Conditions: - * The space is locked (read or write) and active. - */ - -boolean_t -ipc_entry_tree_collision( - ipc_space_t space, - mach_port_t name) -{ - mach_port_index_t index; - mach_port_t lower, upper; - - assert(space->is_active); - - /* - * Check if we collide with the next smaller name - * or the next larger name. - */ - - ipc_splay_tree_bounds(&space->is_tree, name, &lower, &upper); - - index = MACH_PORT_INDEX(name); - return (((lower != ~0) && (MACH_PORT_INDEX(lower) == index)) || - ((upper != 0) && (MACH_PORT_INDEX(upper) == index))); -} +struct kmem_cache ipc_entry_cache; /* * Routine: ipc_entry_lookup @@ -100,29 +65,13 @@ ipc_entry_lookup( ipc_space_t space, mach_port_t name) { - mach_port_index_t index; ipc_entry_t entry; assert(space->is_active); - - index = MACH_PORT_INDEX(name); - if (index < space->is_table_size) { - entry = &space->is_table[index]; - if (IE_BITS_GEN(entry->ie_bits) != MACH_PORT_GEN(name)) - if (entry->ie_bits & IE_BITS_COLLISION) { - assert(space->is_tree_total > 0); - goto tree_lookup; - } else - entry = IE_NULL; - else if (IE_BITS_TYPE(entry->ie_bits) == MACH_PORT_TYPE_NONE) - entry = IE_NULL; - } else if (space->is_tree_total == 0) - entry = IE_NULL; - else - tree_lookup: - entry = (ipc_entry_t) - ipc_splay_tree_lookup(&space->is_tree, name); - + entry = rdxtree_lookup(&space->is_map, (rdxtree_key_t) name); + if (entry != IE_NULL + && IE_BITS_TYPE(entry->ie_bits) == MACH_PORT_TYPE_NONE) + entry = NULL; assert((entry == IE_NULL) || IE_BITS_TYPE(entry->ie_bits)); return entry; } @@ -145,21 +94,18 @@ ipc_entry_get( mach_port_t *namep, ipc_entry_t *entryp) { - ipc_entry_t table; - mach_port_index_t first_free; mach_port_t new_name; ipc_entry_t free_entry; assert(space->is_active); - table = space->is_table; - first_free = table->ie_next; - - if (first_free == 0) + /* Get entry from the free list. */ + free_entry = space->is_free_list; + if (free_entry == IE_NULL) return KERN_NO_SPACE; - free_entry = &table[first_free]; - table->ie_next = free_entry->ie_next; + space->is_free_list = free_entry->ie_next_free; + space->is_free_list_size -= 1; /* * Initialize the new entry. We need only @@ -173,7 +119,7 @@ ipc_entry_get( gen = free_entry->ie_bits + IE_BITS_GEN_ONE; free_entry->ie_bits = gen; free_entry->ie_request = 0; - new_name = MACH_PORT_MAKE(first_free, gen); + new_name = MACH_PORT_MAKE(free_entry->ie_name, gen); } /* @@ -186,6 +132,7 @@ ipc_entry_get( assert(MACH_PORT_VALID(new_name)); assert(free_entry->ie_object == IO_NULL); + space->is_size += 1; *namep = new_name; *entryp = free_entry; return KERN_SUCCESS; @@ -212,23 +159,44 @@ ipc_entry_alloc( ipc_entry_t *entryp) { kern_return_t kr; + ipc_entry_t entry; + rdxtree_key_t key; is_write_lock(space); - for (;;) { - if (!space->is_active) { - is_write_unlock(space); - return KERN_INVALID_TASK; - } + if (!space->is_active) { + is_write_unlock(space); + return KERN_INVALID_TASK; + } - kr = ipc_entry_get(space, namep, entryp); - if (kr == KERN_SUCCESS) - return kr; + kr = ipc_entry_get(space, namep, entryp); + if (kr == KERN_SUCCESS) + /* Success. Space is write-locked. */ + return kr; - kr = ipc_entry_grow_table(space); - if (kr != KERN_SUCCESS) - return kr; /* space is unlocked */ + entry = ie_alloc(); + if (entry == IE_NULL) { + is_write_unlock(space); + return KERN_RESOURCE_SHORTAGE; + } + + kr = rdxtree_insert_alloc(&space->is_map, entry, &key); + if (kr) { + is_write_unlock(space); + ie_free(entry); + return kr; } + space->is_size += 1; + + entry->ie_bits = 0; + entry->ie_object = IO_NULL; + entry->ie_request = 0; + entry->ie_name = (mach_port_t) key; + + *entryp = entry; + *namep = (mach_port_t) key; + /* Success. Space is write-locked. */ + return KERN_SUCCESS; } /* @@ -252,166 +220,77 @@ ipc_entry_alloc_name( mach_port_t name, ipc_entry_t *entryp) { - mach_port_index_t index = MACH_PORT_INDEX(name); - mach_port_gen_t gen = MACH_PORT_GEN(name); - ipc_tree_entry_t tree_entry = ITE_NULL; - + kern_return_t kr; + ipc_entry_t entry, e, *prevp; + void **slot; assert(MACH_PORT_VALID(name)); - is_write_lock(space); - for (;;) { - ipc_entry_t entry; - ipc_tree_entry_t tentry; - ipc_table_size_t its; + if (!space->is_active) { + is_write_unlock(space); + return KERN_INVALID_TASK; + } + + slot = rdxtree_lookup_slot(&space->is_map, (rdxtree_key_t) name); + if (slot != NULL) + entry = *(ipc_entry_t *) slot; - if (!space->is_active) { + if (slot == NULL || entry == IE_NULL) { + entry = ie_alloc(); + if (entry == IE_NULL) { is_write_unlock(space); - if (tree_entry) ite_free(tree_entry); - return KERN_INVALID_TASK; - } - - /* - * If we are under the table cutoff, - * there are three cases: - * 1) The entry is inuse, for the same name - * 2) The entry is inuse, for a different name - * 3) The entry is free - */ - - if ((0 < index) && (index < space->is_table_size)) { - ipc_entry_t table = space->is_table; - - entry = &table[index]; - - if (IE_BITS_TYPE(entry->ie_bits)) { - if (IE_BITS_GEN(entry->ie_bits) == gen) { - *entryp = entry; - if (tree_entry) ite_free(tree_entry); - return KERN_SUCCESS; - } - } else { - mach_port_index_t free_index, next_index; - - /* - * Rip the entry out of the free list. - */ - - for (free_index = 0; - (next_index = table[free_index].ie_next) - != index; - free_index = next_index) - continue; - - table[free_index].ie_next = - table[next_index].ie_next; - - entry->ie_bits = gen; - assert(entry->ie_object == IO_NULL); - entry->ie_request = 0; - - *entryp = entry; - if (tree_entry) ite_free(tree_entry); - return KERN_SUCCESS; - } + return KERN_RESOURCE_SHORTAGE; } - /* - * Before trying to allocate any memory, - * check if the entry already exists in the tree. - * This avoids spurious resource errors. - * The splay tree makes a subsequent lookup/insert - * of the same name cheap, so this costs little. - */ - - if ((space->is_tree_total > 0) && - ((tentry = ipc_splay_tree_lookup(&space->is_tree, name)) - != ITE_NULL)) { - assert(tentry->ite_space == space); - assert(IE_BITS_TYPE(tentry->ite_bits)); - - *entryp = &tentry->ite_entry; - if (tree_entry) ite_free(tree_entry); - return KERN_SUCCESS; - } + entry->ie_bits = 0; + entry->ie_object = IO_NULL; + entry->ie_request = 0; + entry->ie_name = name; - its = space->is_table_next; - - /* - * Check if the table should be grown. - * - * Note that if space->is_table_size == its->its_size, - * then we won't ever try to grow the table. - * - * Note that we are optimistically assuming that name - * doesn't collide with any existing names. (So if - * it were entered into the tree, is_tree_small would - * be incremented.) This is OK, because even in that - * case, we don't lose memory by growing the table. - */ - - if ((space->is_table_size <= index) && - (index < its->its_size) && - (((its->its_size - space->is_table_size) * - sizeof(struct ipc_entry)) < - ((space->is_tree_small + 1) * - sizeof(struct ipc_tree_entry)))) { - kern_return_t kr; - - /* - * Can save space by growing the table. - * Because the space will be unlocked, - * we must restart. - */ - - kr = ipc_entry_grow_table(space); - assert(kr != KERN_NO_SPACE); + if (slot != NULL) + rdxtree_replace_slot(slot, entry); + else { + kr = rdxtree_insert(&space->is_map, + (rdxtree_key_t) name, entry); if (kr != KERN_SUCCESS) { - /* space is unlocked */ - if (tree_entry) ite_free(tree_entry); + is_write_unlock(space); + ie_free(entry); return kr; } - - continue; - } - - /* - * If a splay-tree entry was allocated previously, - * go ahead and insert it into the tree. - */ - - if (tree_entry != ITE_NULL) { - space->is_tree_total++; - - if (index < space->is_table_size) - space->is_table[index].ie_bits |= - IE_BITS_COLLISION; - else if ((index < its->its_size) && - !ipc_entry_tree_collision(space, name)) - space->is_tree_small++; - - ipc_splay_tree_insert(&space->is_tree, - name, tree_entry); - - tree_entry->ite_bits = 0; - tree_entry->ite_object = IO_NULL; - tree_entry->ite_request = 0; - tree_entry->ite_space = space; - *entryp = &tree_entry->ite_entry; - return KERN_SUCCESS; } + space->is_size += 1; - /* - * Allocate a tree entry and try again. - */ + *entryp = entry; + /* Success. Space is write-locked. */ + return KERN_SUCCESS; + } - is_write_unlock(space); - tree_entry = ite_alloc(); - if (tree_entry == ITE_NULL) - return KERN_RESOURCE_SHORTAGE; - is_write_lock(space); + if (IE_BITS_TYPE(entry->ie_bits)) { + /* Used entry. */ + *entryp = entry; + /* Success. Space is write-locked. */ + return KERN_SUCCESS; } + + /* Free entry. Rip the entry out of the free list. */ + for (prevp = &space->is_free_list, e = space->is_free_list; + e != entry; + ({ prevp = &e->ie_next_free; e = e->ie_next_free; })) + continue; + + *prevp = entry->ie_next_free; + space->is_free_list_size -= 1; + + entry->ie_bits = 0; + assert(entry->ie_object == IO_NULL); + assert(entry->ie_name == name); + entry->ie_request = 0; + + space->is_size += 1; + *entryp = entry; + /* Success. Space is write-locked. */ + return KERN_SUCCESS; } /* @@ -429,405 +308,20 @@ ipc_entry_dealloc( mach_port_t name, ipc_entry_t entry) { - ipc_entry_t table; - ipc_entry_num_t size; - mach_port_index_t index; - assert(space->is_active); assert(entry->ie_object == IO_NULL); assert(entry->ie_request == 0); - index = MACH_PORT_INDEX(name); - table = space->is_table; - size = space->is_table_size; - - if ((index < size) && (entry == &table[index])) { - assert(IE_BITS_GEN(entry->ie_bits) == MACH_PORT_GEN(name)); - - if (entry->ie_bits & IE_BITS_COLLISION) { - struct ipc_splay_tree small, collisions; - ipc_tree_entry_t tentry; - mach_port_t tname; - boolean_t pick; - ipc_entry_bits_t bits; - ipc_object_t obj; - - /* must move an entry from tree to table */ - - ipc_splay_tree_split(&space->is_tree, - MACH_PORT_MAKE(index+1, 0), - &collisions); - ipc_splay_tree_split(&collisions, - MACH_PORT_MAKE(index, 0), - &small); - - pick = ipc_splay_tree_pick(&collisions, - &tname, &tentry); - assert(pick); - assert(MACH_PORT_INDEX(tname) == index); - - bits = tentry->ite_bits; - entry->ie_bits = bits | MACH_PORT_GEN(tname); - entry->ie_object = obj = tentry->ite_object; - entry->ie_request = tentry->ite_request; - assert(tentry->ite_space == space); - - if (IE_BITS_TYPE(bits) == MACH_PORT_TYPE_SEND) { - ipc_hash_global_delete(space, obj, - tname, tentry); - ipc_hash_local_insert(space, obj, - index, entry); - } - - ipc_splay_tree_delete(&collisions, tname, tentry); - - assert(space->is_tree_total > 0); - space->is_tree_total--; - - /* check if collision bit should still be on */ - - pick = ipc_splay_tree_pick(&collisions, - &tname, &tentry); - if (pick) { - entry->ie_bits |= IE_BITS_COLLISION; - ipc_splay_tree_join(&space->is_tree, - &collisions); - } - - ipc_splay_tree_join(&space->is_tree, &small); - } else { - entry->ie_bits &= IE_BITS_GEN_MASK; - entry->ie_next = table->ie_next; - table->ie_next = index; - } + if (space->is_free_list_size < IS_FREE_LIST_SIZE_LIMIT) { + space->is_free_list_size += 1; + entry->ie_bits &= IE_BITS_GEN_MASK; + entry->ie_next_free = space->is_free_list; + space->is_free_list = entry; } else { - ipc_tree_entry_t tentry = (ipc_tree_entry_t) entry; - - assert(tentry->ite_space == space); - - ipc_splay_tree_delete(&space->is_tree, name, tentry); - - assert(space->is_tree_total > 0); - space->is_tree_total--; - - if (index < size) { - ipc_entry_t ientry = &table[index]; - - assert(ientry->ie_bits & IE_BITS_COLLISION); - - if (!ipc_entry_tree_collision(space, name)) - ientry->ie_bits &= ~IE_BITS_COLLISION; - } else if ((index < space->is_table_next->its_size) && - !ipc_entry_tree_collision(space, name)) { - assert(space->is_tree_small > 0); - space->is_tree_small--; - } + rdxtree_remove(&space->is_map, (rdxtree_key_t) name); + ie_free(entry); } -} - -/* - * Routine: ipc_entry_grow_table - * Purpose: - * Grows the table in a space. - * Conditions: - * The space must be write-locked and active before. - * If successful, it is also returned locked. - * Allocates memory. - * Returns: - * KERN_SUCCESS Grew the table. - * KERN_SUCCESS Somebody else grew the table. - * KERN_SUCCESS The space died. - * KERN_NO_SPACE Table has maximum size already. - * KERN_RESOURCE_SHORTAGE Couldn't allocate a new table. - */ - -kern_return_t -ipc_entry_grow_table(ipc_space_t space) -{ - ipc_entry_num_t osize, size, nsize; - - do { - ipc_entry_t otable, table; - ipc_table_size_t oits, its, nits; - mach_port_index_t i, free_index; - - assert(space->is_active); - - if (space->is_growing) { - /* - * Somebody else is growing the table. - * We just wait for them to finish. - */ - - assert_wait((event_t) space, FALSE); - is_write_unlock(space); - thread_block((void (*)()) 0); - is_write_lock(space); - return KERN_SUCCESS; - } - - otable = space->is_table; - its = space->is_table_next; - size = its->its_size; - oits = its - 1; - osize = oits->its_size; - nits = its + 1; - nsize = nits->its_size; - - if (osize == size) { - is_write_unlock(space); - printf_once("no more room for ipc_entry_grow_table in space %p\n", space); - return KERN_NO_SPACE; - } - - assert((osize < size) && (size <= nsize)); - - /* - * OK, we'll attempt to grow the table. - * The realloc requires that the old table - * remain in existence. - */ - - space->is_growing = TRUE; - is_write_unlock(space); - if (it_entries_reallocable(oits)) - table = it_entries_realloc(oits, otable, its); - else - table = it_entries_alloc(its); - is_write_lock(space); - space->is_growing = FALSE; - - /* - * We need to do a wakeup on the space, - * to rouse waiting threads. We defer - * this until the space is unlocked, - * because we don't want them to spin. - */ - - if (table == IE_NULL) { - is_write_unlock(space); - thread_wakeup((event_t) space); - return KERN_RESOURCE_SHORTAGE; - } - - if (!space->is_active) { - /* - * The space died while it was unlocked. - */ - - is_write_unlock(space); - thread_wakeup((event_t) space); - it_entries_free(its, table); - ipc_reverse_remove_all(space); - is_write_lock(space); - return KERN_SUCCESS; - } - - assert(space->is_table == otable); - assert(space->is_table_next == its); - assert(space->is_table_size == osize); - - space->is_table = table; - space->is_table_size = size; - space->is_table_next = nits; - - /* - * If we did a realloc, it remapped the data. - * Otherwise we copy by hand first. Then we have - * to clear the index fields in the old part and - * zero the new part. - */ - - if (!it_entries_reallocable(oits)) - memcpy(table, otable, - osize * sizeof(struct ipc_entry)); - - (void) memset((void *) (table + osize), 0, - (size - osize) * sizeof(struct ipc_entry)); - - /* - * Put old entries into the reverse hash table. - */ - - ipc_reverse_remove_all(space); - for (i = 0; i < osize; i++) { - ipc_entry_t entry = &table[i]; - - if (IE_BITS_TYPE(entry->ie_bits) == - MACH_PORT_TYPE_SEND) - ipc_hash_local_insert(space, entry->ie_object, - i, entry); - } - - /* - * If there are entries in the splay tree, - * then we have work to do: - * 1) transfer entries to the table - * 2) update is_tree_small - */ - - if (space->is_tree_total > 0) { - mach_port_index_t index; - boolean_t delete; - struct ipc_splay_tree ignore; - struct ipc_splay_tree move; - struct ipc_splay_tree small; - ipc_entry_num_t nosmall; - ipc_tree_entry_t tentry; - - /* - * The splay tree divides into four regions, - * based on the index of the entries: - * 1) 0 <= index < osize - * 2) osize <= index < size - * 3) size <= index < nsize - * 4) nsize <= index - * - * Entries in the first part are ignored. - * Entries in the second part, that don't - * collide, are moved into the table. - * Entries in the third part, that don't - * collide, are counted for is_tree_small. - * Entries in the fourth part are ignored. - */ - - ipc_splay_tree_split(&space->is_tree, - MACH_PORT_MAKE(nsize, 0), - &small); - ipc_splay_tree_split(&small, - MACH_PORT_MAKE(size, 0), - &move); - ipc_splay_tree_split(&move, - MACH_PORT_MAKE(osize, 0), - &ignore); - - /* move entries into the table */ - - for (tentry = ipc_splay_traverse_start(&move); - tentry != ITE_NULL; - tentry = ipc_splay_traverse_next(&move, delete)) { - mach_port_t name; - mach_port_gen_t gen; - mach_port_type_t type; - ipc_entry_bits_t bits; - ipc_object_t obj; - ipc_entry_t entry; - - name = tentry->ite_name; - gen = MACH_PORT_GEN(name); - index = MACH_PORT_INDEX(name); - - assert(tentry->ite_space == space); - assert((osize <= index) && (index < size)); - - entry = &table[index]; - - /* collision with previously moved entry? */ - - bits = entry->ie_bits; - if (bits != 0) { - assert(IE_BITS_TYPE(bits)); - assert(IE_BITS_GEN(bits) != gen); - - entry->ie_bits = - bits | IE_BITS_COLLISION; - delete = FALSE; - continue; - } - - bits = tentry->ite_bits; - type = IE_BITS_TYPE(bits); - assert(type != MACH_PORT_TYPE_NONE); - - entry->ie_bits = bits | gen; - entry->ie_object = obj = tentry->ite_object; - entry->ie_request = tentry->ite_request; - - if (type == MACH_PORT_TYPE_SEND) { - ipc_hash_global_delete(space, obj, - name, tentry); - ipc_hash_local_insert(space, obj, - index, entry); - } - - space->is_tree_total--; - delete = TRUE; - } - ipc_splay_traverse_finish(&move); - - /* count entries for is_tree_small */ - - nosmall = 0; index = 0; - for (tentry = ipc_splay_traverse_start(&small); - tentry != ITE_NULL; - tentry = ipc_splay_traverse_next(&small, FALSE)) { - mach_port_index_t nindex; - - nindex = MACH_PORT_INDEX(tentry->ite_name); - - if (nindex != index) { - nosmall++; - index = nindex; - } - } - ipc_splay_traverse_finish(&small); - - assert(nosmall <= (nsize - size)); - assert(nosmall <= space->is_tree_total); - space->is_tree_small = nosmall; - - /* put the splay tree back together */ - - ipc_splay_tree_join(&space->is_tree, &small); - ipc_splay_tree_join(&space->is_tree, &move); - ipc_splay_tree_join(&space->is_tree, &ignore); - } - - /* - * Add entries in the new part which still aren't used - * to the free list. Add them in reverse order, - * and set the generation number to -1, so that - * early allocations produce "natural" names. - */ - - free_index = table[0].ie_next; - for (i = size-1; i >= osize; --i) { - ipc_entry_t entry = &table[i]; - - if (entry->ie_bits == 0) { - entry->ie_bits = IE_BITS_GEN_MASK; - entry->ie_next = free_index; - free_index = i; - } - } - table[0].ie_next = free_index; - - /* - * Now we need to free the old table. - * If the space dies or grows while unlocked, - * then we can quit here. - */ - - is_write_unlock(space); - thread_wakeup((event_t) space); - it_entries_free(oits, otable); - is_write_lock(space); - if (!space->is_active || (space->is_table_next != nits)) - return KERN_SUCCESS; - - /* - * We might have moved enough entries from - * the splay tree into the table that - * the table can be profitably grown again. - * - * Note that if size == nsize, then - * space->is_tree_small == 0. - */ - } while ((space->is_tree_small > 0) && - (((nsize - size) * sizeof(struct ipc_entry)) < - (space->is_tree_small * sizeof(struct ipc_tree_entry)))); - - return KERN_SUCCESS; + space->is_size -= 1; } diff --git a/ipc/ipc_entry.h b/ipc/ipc_entry.h index 0caa70b0..5c1f8fd4 100644 --- a/ipc/ipc_entry.h +++ b/ipc/ipc_entry.h @@ -48,42 +48,27 @@ /* * Spaces hold capabilities for ipc_object_t's (ports and port sets). - * Each ipc_entry_t records a capability. Most capabilities have - * small names, and the entries are elements of a table. - * Capabilities can have large names, and a splay tree holds - * those entries. The cutoff point between the table and the tree - * is adjusted dynamically to minimize memory consumption. - * - * Free (unallocated) entries in the table have null ie_object - * fields. The ie_bits field is zero except for IE_BITS_GEN. - * The ie_next (ie_request) field links free entries into a free list. - * - * The first entry in the table (index 0) is always free. - * It is used as the head of the free list. + * Each ipc_entry_t records a capability. */ typedef unsigned int ipc_entry_bits_t; typedef ipc_table_elems_t ipc_entry_num_t; /* number of entries */ typedef struct ipc_entry { + mach_port_t ie_name; ipc_entry_bits_t ie_bits; struct ipc_object *ie_object; union { - mach_port_index_t next; + struct ipc_entry *next_free; /*XXX ipc_port_request_index_t request;*/ unsigned int request; } index; - union { - mach_port_index_t table; - struct ipc_tree_entry *tree; - } hash; } *ipc_entry_t; #define IE_NULL ((ipc_entry_t) 0) #define ie_request index.request -#define ie_next index.next -#define ie_index hash.table +#define ie_next_free index.next_free #define IE_BITS_UREFS_MASK 0x0000ffff /* 16 bits of user-reference */ #define IE_BITS_UREFS(bits) ((bits) & IE_BITS_UREFS_MASK) @@ -93,12 +78,10 @@ typedef struct ipc_entry { #define IE_BITS_MAREQUEST 0x00200000 /* 1 bit for msg-accepted */ -#define IE_BITS_COMPAT 0x00400000 /* 1 bit for compatibility */ - -#define IE_BITS_COLLISION 0x00800000 /* 1 bit for collisions */ -#define IE_BITS_RIGHT_MASK 0x007fffff /* relevant to the right */ +#define IE_BITS_RIGHT_MASK 0x003fffff /* relevant to the right */ #if PORT_GENERATIONS +#error "not supported" #define IE_BITS_GEN_MASK 0xff000000U /* 8 bits for generation */ #define IE_BITS_GEN(bits) ((bits) & IE_BITS_GEN_MASK) #define IE_BITS_GEN_ONE 0x01000000 /* low bit of generation */ @@ -109,26 +92,9 @@ typedef struct ipc_entry { #endif -typedef struct ipc_tree_entry { - struct ipc_entry ite_entry; - mach_port_t ite_name; - struct ipc_space *ite_space; - struct ipc_tree_entry *ite_lchild; - struct ipc_tree_entry *ite_rchild; -} *ipc_tree_entry_t; - -#define ITE_NULL ((ipc_tree_entry_t) 0) - -#define ite_bits ite_entry.ie_bits -#define ite_object ite_entry.ie_object -#define ite_request ite_entry.ie_request -#define ite_next ite_entry.hash.tree - -extern struct kmem_cache ipc_tree_entry_cache; - -#define ite_alloc() ((ipc_tree_entry_t) kmem_cache_alloc(&ipc_tree_entry_cache)) -#define ite_free(ite) kmem_cache_free(&ipc_tree_entry_cache, (vm_offset_t) (ite)) - +extern struct kmem_cache ipc_entry_cache; +#define ie_alloc() ((ipc_entry_t) kmem_cache_alloc(&ipc_entry_cache)) +#define ie_free(e) kmem_cache_free(&ipc_entry_cache, (vm_offset_t) (e)) extern ipc_entry_t ipc_entry_lookup(ipc_space_t space, mach_port_t name); @@ -145,9 +111,6 @@ ipc_entry_alloc_name(ipc_space_t space, mach_port_t name, ipc_entry_t *entryp); extern void ipc_entry_dealloc(ipc_space_t space, mach_port_t name, ipc_entry_t entry); -extern kern_return_t -ipc_entry_grow_table(ipc_space_t space); - ipc_entry_t db_ipc_object_by_name( task_t task, diff --git a/ipc/ipc_hash.c b/ipc/ipc_hash.c deleted file mode 100644 index 87952a79..00000000 --- a/ipc/ipc_hash.c +++ /dev/null @@ -1,486 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1991,1990,1989 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - */ -/* - * File: ipc/ipc_hash.c - * Author: Rich Draves - * Date: 1989 - * - * Entry hash table operations. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if MACH_IPC_DEBUG -#include -#include -#include -#include -#include -#endif - - - -/* - * Routine: ipc_hash_lookup - * Purpose: - * Converts (space, obj) -> (name, entry). - * Returns TRUE if an entry was found. - * Conditions: - * The space must be locked (read or write) throughout. - */ - -boolean_t -ipc_hash_lookup( - ipc_space_t space, - ipc_object_t obj, - mach_port_t *namep, - ipc_entry_t *entryp) -{ - return (ipc_hash_local_lookup(space, obj, namep, entryp) || - ((space->is_tree_hash > 0) && - ipc_hash_global_lookup(space, obj, namep, - (ipc_tree_entry_t *) entryp))); -} - -/* - * Routine: ipc_hash_insert - * Purpose: - * Inserts an entry into the appropriate reverse hash table, - * so that ipc_hash_lookup will find it. - * Conditions: - * The space must be write-locked. - */ - -void -ipc_hash_insert( - ipc_space_t space, - ipc_object_t obj, - mach_port_t name, - ipc_entry_t entry) -{ - mach_port_index_t index; - - index = MACH_PORT_INDEX(name); - if ((index < space->is_table_size) && - (entry == &space->is_table[index])) - ipc_hash_local_insert(space, obj, index, entry); - else - ipc_hash_global_insert(space, obj, name, - (ipc_tree_entry_t) entry); -} - -/* - * Routine: ipc_hash_delete - * Purpose: - * Deletes an entry from the appropriate reverse hash table. - * Conditions: - * The space must be write-locked. - */ - -void -ipc_hash_delete( - ipc_space_t space, - ipc_object_t obj, - mach_port_t name, - ipc_entry_t entry) -{ - mach_port_index_t index; - - index = MACH_PORT_INDEX(name); - if ((index < space->is_table_size) && - (entry == &space->is_table[index])) - ipc_hash_local_delete(space, obj, index, entry); - else - ipc_hash_global_delete(space, obj, name, - (ipc_tree_entry_t) entry); -} - -/* - * The global reverse hash table holds splay tree entries. - * It is a simple open-chaining hash table with singly-linked buckets. - * Each bucket is locked separately, with an exclusive lock. - * Within each bucket, move-to-front is used. - */ - -ipc_hash_index_t ipc_hash_global_size; -ipc_hash_index_t ipc_hash_global_mask; - -#define IH_GLOBAL_HASH(space, obj) \ - (((((ipc_hash_index_t) ((vm_offset_t)space)) >> 4) + \ - (((ipc_hash_index_t) ((vm_offset_t)obj)) >> 6)) & \ - ipc_hash_global_mask) - -typedef struct ipc_hash_global_bucket { - decl_simple_lock_data(, ihgb_lock_data) - ipc_tree_entry_t ihgb_head; -} *ipc_hash_global_bucket_t; - -#define IHGB_NULL ((ipc_hash_global_bucket_t) 0) - -#define ihgb_lock_init(ihgb) simple_lock_init(&(ihgb)->ihgb_lock_data) -#define ihgb_lock(ihgb) simple_lock(&(ihgb)->ihgb_lock_data) -#define ihgb_unlock(ihgb) simple_unlock(&(ihgb)->ihgb_lock_data) - -ipc_hash_global_bucket_t ipc_hash_global_table; - -/* - * Routine: ipc_hash_global_lookup - * Purpose: - * Converts (space, obj) -> (name, entry). - * Looks in the global table, for splay tree entries. - * Returns TRUE if an entry was found. - * Conditions: - * The space must be locked (read or write) throughout. - */ - -boolean_t -ipc_hash_global_lookup( - ipc_space_t space, - ipc_object_t obj, - mach_port_t *namep, - ipc_tree_entry_t *entryp) -{ - ipc_hash_global_bucket_t bucket; - ipc_tree_entry_t this, *last; - - assert(space != IS_NULL); - assert(obj != IO_NULL); - - bucket = &ipc_hash_global_table[IH_GLOBAL_HASH(space, obj)]; - ihgb_lock(bucket); - - if ((this = bucket->ihgb_head) != ITE_NULL) { - if ((this->ite_object == obj) && - (this->ite_space == space)) { - /* found it at front; no need to move */ - - *namep = this->ite_name; - *entryp = this; - } else for (last = &this->ite_next; - (this = *last) != ITE_NULL; - last = &this->ite_next) { - if ((this->ite_object == obj) && - (this->ite_space == space)) { - /* found it; move to front */ - - *last = this->ite_next; - this->ite_next = bucket->ihgb_head; - bucket->ihgb_head = this; - - *namep = this->ite_name; - *entryp = this; - break; - } - } - } - - ihgb_unlock(bucket); - return this != ITE_NULL; -} - -/* - * Routine: ipc_hash_global_insert - * Purpose: - * Inserts an entry into the global reverse hash table. - * Conditions: - * The space must be write-locked. - */ - -void -ipc_hash_global_insert( - ipc_space_t space, - ipc_object_t obj, - mach_port_t name, - ipc_tree_entry_t entry) -{ - ipc_hash_global_bucket_t bucket; - - - assert(entry->ite_name == name); - assert(space != IS_NULL); - assert(entry->ite_space == space); - assert(obj != IO_NULL); - assert(entry->ite_object == obj); - - space->is_tree_hash++; - assert(space->is_tree_hash <= space->is_tree_total); - - bucket = &ipc_hash_global_table[IH_GLOBAL_HASH(space, obj)]; - ihgb_lock(bucket); - - /* insert at front of bucket */ - - entry->ite_next = bucket->ihgb_head; - bucket->ihgb_head = entry; - - ihgb_unlock(bucket); -} - -/* - * Routine: ipc_hash_global_delete - * Purpose: - * Deletes an entry from the global reverse hash table. - * Conditions: - * The space must be write-locked. - */ - -void -ipc_hash_global_delete( - ipc_space_t space, - ipc_object_t obj, - mach_port_t name, - ipc_tree_entry_t entry) -{ - ipc_hash_global_bucket_t bucket; - ipc_tree_entry_t this, *last; - - assert(entry->ite_name == name); - assert(space != IS_NULL); - assert(entry->ite_space == space); - assert(obj != IO_NULL); - assert(entry->ite_object == obj); - - assert(space->is_tree_hash > 0); - space->is_tree_hash--; - - bucket = &ipc_hash_global_table[IH_GLOBAL_HASH(space, obj)]; - ihgb_lock(bucket); - - for (last = &bucket->ihgb_head; - (this = *last) != ITE_NULL; - last = &this->ite_next) { - if (this == entry) { - /* found it; remove from bucket */ - - *last = this->ite_next; - break; - } - } - assert(this != ITE_NULL); - - ihgb_unlock(bucket); -} - -/* - * Each space has a local reverse mapping from objects to entries - * from the space's table. This used to be a hash table. - */ - -#define IPC_LOCAL_HASH_INVARIANT(S, O, N, E) \ - MACRO_BEGIN \ - assert(IE_BITS_TYPE((E)->ie_bits) == MACH_PORT_TYPE_SEND || \ - IE_BITS_TYPE((E)->ie_bits) == MACH_PORT_TYPE_SEND_RECEIVE || \ - IE_BITS_TYPE((E)->ie_bits) == MACH_PORT_TYPE_NONE); \ - assert((E)->ie_object == (O)); \ - assert((E)->ie_index == (N)); \ - assert(&(S)->is_table[N] == (E)); \ - MACRO_END - -/* - * Routine: ipc_hash_local_lookup - * Purpose: - * Converts (space, obj) -> (name, entry). - * Looks in the space's local table, for table entries. - * Returns TRUE if an entry was found. - * Conditions: - * The space must be locked (read or write) throughout. - */ - -boolean_t -ipc_hash_local_lookup( - ipc_space_t space, - ipc_object_t obj, - mach_port_t *namep, - ipc_entry_t *entryp) -{ - assert(space != IS_NULL); - assert(obj != IO_NULL); - - *entryp = ipc_reverse_lookup(space, obj); - if (*entryp != IE_NULL) { - *namep = (*entryp)->ie_index; - IPC_LOCAL_HASH_INVARIANT(space, obj, *namep, *entryp); - return TRUE; - } - return FALSE; -} - -/* - * Routine: ipc_hash_local_insert - * Purpose: - * Inserts an entry into the space's reverse hash table. - * Conditions: - * The space must be write-locked. - */ - -void -ipc_hash_local_insert( - ipc_space_t space, - ipc_object_t obj, - mach_port_index_t index, - ipc_entry_t entry) -{ - kern_return_t kr; - assert(index != 0); - assert(space != IS_NULL); - assert(obj != IO_NULL); - - entry->ie_index = index; - IPC_LOCAL_HASH_INVARIANT(space, obj, index, entry); - kr = ipc_reverse_insert(space, obj, entry); - assert(kr == 0); -} - -/* - * Routine: ipc_hash_local_delete - * Purpose: - * Deletes an entry from the space's reverse hash table. - * Conditions: - * The space must be write-locked. - */ - -void -ipc_hash_local_delete( - ipc_space_t space, - ipc_object_t obj, - mach_port_index_t index, - ipc_entry_t entry) -{ - ipc_entry_t removed; - assert(index != MACH_PORT_NULL); - assert(space != IS_NULL); - assert(obj != IO_NULL); - - IPC_LOCAL_HASH_INVARIANT(space, obj, index, entry); - removed = ipc_reverse_remove(space, obj); - assert(removed == entry); -} - -/* - * Routine: ipc_hash_init - * Purpose: - * Initialize the reverse hash table implementation. - */ - -void -ipc_hash_init(void) -{ - ipc_hash_index_t i; - - /* initialize ipc_hash_global_size */ - - ipc_hash_global_size = IPC_HASH_GLOBAL_SIZE; - - /* make sure it is a power of two */ - - ipc_hash_global_mask = ipc_hash_global_size - 1; - if ((ipc_hash_global_size & ipc_hash_global_mask) != 0) { - natural_t bit; - - /* round up to closest power of two */ - - for (bit = 1;; bit <<= 1) { - ipc_hash_global_mask |= bit; - ipc_hash_global_size = ipc_hash_global_mask + 1; - - if ((ipc_hash_global_size & ipc_hash_global_mask) == 0) - break; - } - } - - /* allocate ipc_hash_global_table */ - - ipc_hash_global_table = (ipc_hash_global_bucket_t) - kalloc((vm_size_t) (ipc_hash_global_size * - sizeof(struct ipc_hash_global_bucket))); - assert(ipc_hash_global_table != IHGB_NULL); - - /* and initialize it */ - - for (i = 0; i < ipc_hash_global_size; i++) { - ipc_hash_global_bucket_t bucket; - - bucket = &ipc_hash_global_table[i]; - ihgb_lock_init(bucket); - bucket->ihgb_head = ITE_NULL; - } -} - -#if MACH_IPC_DEBUG - -/* - * Routine: ipc_hash_info - * Purpose: - * Return information about the global reverse hash table. - * Fills the buffer with as much information as possible - * and returns the desired size of the buffer. - * Conditions: - * Nothing locked. The caller should provide - * possibly-pageable memory. - */ - - -ipc_hash_index_t -ipc_hash_info( - hash_info_bucket_t *info, - mach_msg_type_number_t count) -{ - ipc_hash_index_t i; - - if (ipc_hash_global_size < count) - count = ipc_hash_global_size; - - for (i = 0; i < count; i++) { - ipc_hash_global_bucket_t bucket = &ipc_hash_global_table[i]; - unsigned int bucket_count = 0; - ipc_tree_entry_t entry; - - ihgb_lock(bucket); - for (entry = bucket->ihgb_head; - entry != ITE_NULL; - entry = entry->ite_next) - bucket_count++; - ihgb_unlock(bucket); - - /* don't touch pageable memory while holding locks */ - info[i].hib_count = bucket_count; - } - - return ipc_hash_global_size; -} - -#endif /* MACH_IPC_DEBUG */ diff --git a/ipc/ipc_hash.h b/ipc/ipc_hash.h deleted file mode 100644 index 929ba77d..00000000 --- a/ipc/ipc_hash.h +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1991,1990,1989 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - */ -/* - * File: ipc/ipc_hash.h - * Author: Rich Draves - * Date: 1989 - * - * Declarations of entry hash table operations. - */ - -#ifndef _IPC_IPC_HASH_H_ -#define _IPC_IPC_HASH_H_ - -#include -#include - -typedef natural_t ipc_hash_index_t; - -extern void -ipc_hash_init(void); - -#if MACH_IPC_DEBUG - -extern ipc_hash_index_t -ipc_hash_info(hash_info_bucket_t *, mach_msg_type_number_t); - -#endif /* MACH_IPC_DEBUG */ - -extern boolean_t -ipc_hash_lookup(ipc_space_t space, ipc_object_t obj, - mach_port_t *namep, ipc_entry_t *entryp); - -extern void -ipc_hash_insert(ipc_space_t space, ipc_object_t obj, - mach_port_t name, ipc_entry_t entry); - -extern void -ipc_hash_delete(ipc_space_t space, ipc_object_t obj, - mach_port_t name, ipc_entry_t entry); - -/* - * For use by functions that know what they're doing: - * the global primitives, for splay tree entries, - * and the local primitives, for table entries. - */ - -#define IPC_HASH_GLOBAL_SIZE 256 - -extern boolean_t -ipc_hash_global_lookup(ipc_space_t space, ipc_object_t obj, - mach_port_t *namep, ipc_tree_entry_t *entryp); - -extern void -ipc_hash_global_insert(ipc_space_t space, ipc_object_t obj, - mach_port_t name, ipc_tree_entry_t entry); - -extern void -ipc_hash_global_delete(ipc_space_t space, ipc_object_t obj, - mach_port_t name, ipc_tree_entry_t entry); - -extern boolean_t -ipc_hash_local_lookup(ipc_space_t space, ipc_object_t obj, - mach_port_t *namep, ipc_entry_t *entryp); - -extern void -ipc_hash_local_insert(ipc_space_t space, ipc_object_t obj, - mach_port_index_t index, ipc_entry_t entry); - -extern void -ipc_hash_local_delete(ipc_space_t space, ipc_object_t obj, - mach_port_index_t index, ipc_entry_t entry); - -#endif /* _IPC_IPC_HASH_H_ */ diff --git a/ipc/ipc_init.c b/ipc/ipc_init.c index debda476..2c58a6e4 100644 --- a/ipc/ipc_init.c +++ b/ipc/ipc_init.c @@ -47,7 +47,6 @@ #include #include #include -#include #include @@ -76,8 +75,8 @@ ipc_bootstrap(void) kmem_cache_init(&ipc_space_cache, "ipc_space", sizeof(struct ipc_space), 0, NULL, NULL, NULL, 0); - kmem_cache_init(&ipc_tree_entry_cache, "ipc_tree_entry", - sizeof(struct ipc_tree_entry), 0, NULL, NULL, NULL, 0); + kmem_cache_init(&ipc_entry_cache, "ipc_entry", + sizeof(struct ipc_entry), 0, NULL, NULL, NULL, 0); kmem_cache_init(&ipc_object_caches[IOT_PORT], "ipc_port", sizeof(struct ipc_port), 0, NULL, NULL, NULL, 0); @@ -97,7 +96,6 @@ ipc_bootstrap(void) ipc_table_init(); ipc_notify_init(); - ipc_hash_init(); ipc_marequest_init(); } diff --git a/ipc/ipc_kmsg.c b/ipc/ipc_kmsg.c index cae700f5..5076809e 100644 --- a/ipc/ipc_kmsg.c +++ b/ipc/ipc_kmsg.c @@ -50,7 +50,6 @@ #include #include #include -#include #include #include #include @@ -1774,7 +1773,7 @@ ipc_kmsg_copyout_header( break; is_write_lock(space); - if (!space->is_active || space->is_table->ie_next == 0) { + if (!space->is_active || space->is_free_list == NULL) { is_write_unlock(space); break; } @@ -2003,28 +2002,20 @@ ipc_kmsg_copyout_header( goto copyout_dest; } - kr = ipc_entry_get(space, &reply_name, &entry); + kr = ipc_entry_alloc(space, &reply_name, &entry); if (kr != KERN_SUCCESS) { ip_unlock(reply); if (notify_port != IP_NULL) ipc_port_release_sonce(notify_port); - /* space is locked */ - kr = ipc_entry_grow_table(space); - if (kr != KERN_SUCCESS) { - /* space is unlocked */ - - if (kr == KERN_RESOURCE_SHORTAGE) - return (MACH_RCV_HEADER_ERROR| - MACH_MSG_IPC_KERNEL); - else - return (MACH_RCV_HEADER_ERROR| - MACH_MSG_IPC_SPACE); - } - /* space is locked again; start over */ - - continue; + is_write_unlock(space); + if (kr == KERN_RESOURCE_SHORTAGE) + return (MACH_RCV_HEADER_ERROR| + MACH_MSG_IPC_KERNEL); + else + return (MACH_RCV_HEADER_ERROR| + MACH_MSG_IPC_SPACE); } assert(IE_BITS_TYPE(entry->ie_bits) @@ -2266,12 +2257,13 @@ ipc_kmsg_copyout_object( ip_lock(port); if (!ip_active(port) || - !ipc_hash_local_lookup(space, (ipc_object_t) port, - namep, &entry)) { + (entry = ipc_reverse_lookup(space, + (ipc_object_t) port)) == NULL) { ip_unlock(port); is_write_unlock(space); goto slow_copyout; } + *namep = entry->ie_name; /* * Copyout the send right, incrementing urefs diff --git a/ipc/ipc_object.c b/ipc/ipc_object.c index db6ef018..2d84cf52 100644 --- a/ipc/ipc_object.c +++ b/ipc/ipc_object.c @@ -41,7 +41,6 @@ #include #include #include -#include #include #include #include @@ -630,15 +629,10 @@ ipc_object_copyout( break; } - kr = ipc_entry_get(space, &name, &entry); + kr = ipc_entry_alloc(space, &name, &entry); if (kr != KERN_SUCCESS) { - /* unlocks/locks space, so must start again */ - - kr = ipc_entry_grow_table(space); - if (kr != KERN_SUCCESS) - return kr; /* space is unlocked */ - - continue; + is_write_unlock(space); + return kr; } assert(IE_BITS_TYPE(entry->ie_bits) == MACH_PORT_TYPE_NONE); @@ -691,15 +685,10 @@ ipc_object_copyout_multiname(space, object, namep) return KERN_INVALID_TASK; } - kr = ipc_entry_get(space, &name, &entry); + kr = ipc_entry_alloc(space, &name, &entry); if (kr != KERN_SUCCESS) { - /* unlocks/locks space, so must start again */ - - kr = ipc_entry_grow_table(space); - if (kr != KERN_SUCCESS) - return kr; /* space is unlocked */ - - continue; + is_write_unlock(space); + return kr; /* space is unlocked */ } assert(IE_BITS_TYPE(entry->ie_bits) == MACH_PORT_TYPE_NONE); diff --git a/ipc/ipc_right.c b/ipc/ipc_right.c index 35061c9a..773b3b10 100644 --- a/ipc/ipc_right.c +++ b/ipc/ipc_right.c @@ -43,7 +43,6 @@ #include #include #include -#include #include #include #include @@ -142,7 +141,8 @@ ipc_right_reverse( return TRUE; } - if (ipc_hash_lookup(space, (ipc_object_t) port, namep, entryp)) { + if ((*entryp = ipc_reverse_lookup(space, (ipc_object_t) port))) { + *namep = (*entryp)->ie_name; assert((entry = *entryp) != IE_NULL); assert(IE_BITS_TYPE(entry->ie_bits) == MACH_PORT_TYPE_SEND); assert(port == (ipc_port_t) entry->ie_object); @@ -392,7 +392,7 @@ ipc_right_check( ipc_marequest_cancel(space, name); } - ipc_hash_delete(space, (ipc_object_t) port, name, entry); + ipc_reverse_remove(space, (ipc_object_t) port); } else { assert(IE_BITS_TYPE(bits) == MACH_PORT_TYPE_SEND_ONCE); assert(IE_BITS_UREFS(bits) == 1); @@ -609,8 +609,7 @@ ipc_right_destroy( } if (type == MACH_PORT_TYPE_SEND) - ipc_hash_delete(space, (ipc_object_t) port, - name, entry); + ipc_reverse_remove(space, (ipc_object_t) port); ip_lock(port); @@ -789,8 +788,7 @@ ipc_right_dealloc( dnrequest = ipc_right_dncancel_macro(space, port, name, entry); - ipc_hash_delete(space, (ipc_object_t) port, - name, entry); + ipc_reverse_remove(space, (ipc_object_t) port); if (bits & IE_BITS_MAREQUEST) ipc_marequest_cancel(space, name); @@ -1134,8 +1132,7 @@ ipc_right_delta( dnrequest = ipc_right_dncancel_macro( space, port, name, entry); - ipc_hash_delete(space, (ipc_object_t) port, - name, entry); + ipc_reverse_remove(space, (ipc_object_t) port); if (bits & IE_BITS_MAREQUEST) ipc_marequest_cancel(space, name); @@ -1410,8 +1407,8 @@ ipc_right_copyin( assert(IE_BITS_UREFS(bits) > 0); assert(port->ip_srights > 0); - ipc_hash_insert(space, (ipc_object_t) port, - name, entry); + entry->ie_name = name; + ipc_reverse_insert(space, (ipc_object_t) port, entry); ip_reference(port); } else { @@ -1534,8 +1531,7 @@ ipc_right_copyin( dnrequest = ipc_right_dncancel_macro( space, port, name, entry); - ipc_hash_delete(space, (ipc_object_t) port, - name, entry); + ipc_reverse_remove(space, (ipc_object_t) port); if (bits & IE_BITS_MAREQUEST) ipc_marequest_cancel(space, name); @@ -1796,8 +1792,7 @@ ipc_right_copyin_two( dnrequest = ipc_right_dncancel_macro(space, port, name, entry); - ipc_hash_delete(space, (ipc_object_t) port, - name, entry); + ipc_reverse_remove(space, (ipc_object_t) port); if (bits & IE_BITS_MAREQUEST) ipc_marequest_cancel(space, name); @@ -1921,8 +1916,8 @@ ipc_right_copyout( /* entry is locked holding ref, so can use port */ - ipc_hash_insert(space, (ipc_object_t) port, - name, entry); + entry->ie_name = name; + ipc_reverse_insert(space, (ipc_object_t) port, entry); } entry->ie_bits = (bits | MACH_PORT_TYPE_SEND) + 1; @@ -1956,8 +1951,7 @@ ipc_right_copyout( /* entry is locked holding ref, so can use port */ - ipc_hash_delete(space, (ipc_object_t) port, - name, entry); + ipc_reverse_remove(space, (ipc_object_t) port); } else { assert(IE_BITS_TYPE(bits) == MACH_PORT_TYPE_NONE); assert(IE_BITS_UREFS(bits) == 0); @@ -2083,7 +2077,7 @@ ipc_right_rename( ipc_marequest_rename(space, oname, nname); } - /* initialize nentry before letting ipc_hash_insert see it */ + /* initialize nentry before letting ipc_reverse_insert see it */ assert((nentry->ie_bits & IE_BITS_RIGHT_MASK) == 0); nentry->ie_bits |= bits & IE_BITS_RIGHT_MASK; @@ -2097,8 +2091,9 @@ ipc_right_rename( port = (ipc_port_t) object; assert(port != IP_NULL); - ipc_hash_delete(space, (ipc_object_t) port, oname, oentry); - ipc_hash_insert(space, (ipc_object_t) port, nname, nentry); + ipc_reverse_remove(space, (ipc_object_t) port); + nentry->ie_name = nname; + ipc_reverse_insert(space, (ipc_object_t) port, nentry); break; } diff --git a/ipc/ipc_space.c b/ipc/ipc_space.c index dcc96b34..ea3cb3b2 100644 --- a/ipc/ipc_space.c +++ b/ipc/ipc_space.c @@ -46,8 +46,6 @@ #include #include #include -#include -#include #include #include #include @@ -82,6 +80,9 @@ ipc_space_release( ipc_space_release_macro(space); } +/* A place-holder object for the zeroth entry. */ +struct ipc_entry zero_entry; + /* * Routine: ipc_space_create * Purpose: @@ -102,53 +103,24 @@ ipc_space_create( ipc_space_t *spacep) { ipc_space_t space; - ipc_entry_t table; - ipc_entry_num_t new_size; - mach_port_index_t index; space = is_alloc(); if (space == IS_NULL) return KERN_RESOURCE_SHORTAGE; - table = it_entries_alloc(initial); - if (table == IE_NULL) { - is_free(space); - return KERN_RESOURCE_SHORTAGE; - } - - new_size = initial->its_size; - memset((void *) table, 0, new_size * sizeof(struct ipc_entry)); - - /* - * Initialize the free list in the table. - * Add the entries in reverse order, and - * set the generation number to -1, so that - * initial allocations produce "natural" names. - */ - - for (index = 0; index < new_size; index++) { - ipc_entry_t entry = &table[index]; - - entry->ie_bits = IE_BITS_GEN_MASK; - entry->ie_next = index+1; - } - table[new_size-1].ie_next = 0; - is_ref_lock_init(space); space->is_references = 2; is_lock_init(space); space->is_active = TRUE; - space->is_growing = FALSE; - space->is_table = table; - space->is_table_size = new_size; - space->is_table_next = initial+1; - - ipc_splay_tree_init(&space->is_tree); - space->is_tree_total = 0; - space->is_tree_small = 0; - space->is_tree_hash = 0; + + rdxtree_init(&space->is_map); rdxtree_init(&space->is_reverse_map); + /* The zeroth entry is reserved. */ + rdxtree_insert(&space->is_map, 0, &zero_entry); + space->is_size = 1; + space->is_free_list = NULL; + space->is_free_list_size = 0; *spacep = space; return KERN_SUCCESS; @@ -202,10 +174,6 @@ void ipc_space_destroy( ipc_space_t space) { - ipc_tree_entry_t tentry; - ipc_entry_t table; - ipc_entry_num_t size; - mach_port_index_t index; boolean_t active; assert(space != IS_NULL); @@ -218,60 +186,24 @@ ipc_space_destroy( if (!active) return; - /* - * If somebody is trying to grow the table, - * we must wait until they finish and figure - * out the space died. - */ + ipc_entry_t entry; + struct rdxtree_iter iter; + rdxtree_for_each(&space->is_map, &iter, entry) { + if (entry->ie_name == MACH_PORT_NULL) + continue; - is_read_lock(space); - while (space->is_growing) { - assert_wait((event_t) space, FALSE); - is_read_unlock(space); - thread_block((void (*)(void)) 0); - is_read_lock(space); - } - is_read_unlock(space); - - /* - * Now we can futz with it without having it locked. - */ - - table = space->is_table; - size = space->is_table_size; - - for (index = 0; index < size; index++) { - ipc_entry_t entry = &table[index]; mach_port_type_t type = IE_BITS_TYPE(entry->ie_bits); if (type != MACH_PORT_TYPE_NONE) { mach_port_t name = - MACH_PORT_MAKEB(index, entry->ie_bits); + MACH_PORT_MAKEB(entry->ie_name, entry->ie_bits); ipc_right_clean(space, name, entry); } - } - it_entries_free(space->is_table_next-1, table); - - for (tentry = ipc_splay_traverse_start(&space->is_tree); - tentry != ITE_NULL; - tentry = ipc_splay_traverse_next(&space->is_tree, TRUE)) { - mach_port_type_t type = IE_BITS_TYPE(tentry->ite_bits); - mach_port_t name = tentry->ite_name; - - assert(type != MACH_PORT_TYPE_NONE); - - /* use object before ipc_right_clean releases ref */ - - if (type == MACH_PORT_TYPE_SEND) - ipc_hash_global_delete(space, tentry->ite_object, - name, tentry); - - ipc_right_clean(space, name, &tentry->ite_entry); + ie_free(entry); } - ipc_splay_traverse_finish(&space->is_tree); - + rdxtree_remove_all(&space->is_map); rdxtree_remove_all(&space->is_reverse_map); /* diff --git a/ipc/ipc_space.h b/ipc/ipc_space.h index f41c64c2..20b9d57d 100644 --- a/ipc/ipc_space.h +++ b/ipc/ipc_space.h @@ -47,7 +47,7 @@ #include #include #include -#include +#include #include /* @@ -73,18 +73,16 @@ struct ipc_space { decl_simple_lock_data(,is_lock_data) boolean_t is_active; /* is the space alive? */ - boolean_t is_growing; /* is the space growing? */ - ipc_entry_t is_table; /* an array of entries */ - ipc_entry_num_t is_table_size; /* current size of table */ - struct ipc_table_size *is_table_next; /* info for larger table */ - struct ipc_splay_tree is_tree; /* a splay tree of entries */ - ipc_entry_num_t is_tree_total; /* number of entries in the tree */ - ipc_entry_num_t is_tree_small; /* # of small entries in the tree */ - ipc_entry_num_t is_tree_hash; /* # of hashed entries in the tree */ + struct rdxtree is_map; /* a map of entries */ + size_t is_size; /* number of entries */ struct rdxtree is_reverse_map; /* maps objects to entries */ - + ipc_entry_t is_free_list; /* a linked list of free entries */ + size_t is_free_list_size; /* number of free entries */ +#define IS_FREE_LIST_SIZE_LIMIT 64 /* maximum number of entries + in the free list */ }; + #define IS_NULL ((ipc_space_t) 0) extern struct kmem_cache ipc_space_cache; diff --git a/ipc/ipc_splay.c b/ipc/ipc_splay.c deleted file mode 100644 index 062a69f8..00000000 --- a/ipc/ipc_splay.c +++ /dev/null @@ -1,920 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1991,1990,1989 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - */ -/* - */ -/* - * File: ipc/ipc_splay.c - * Author: Rich Draves - * Date: 1989 - * - * Primitive splay tree operations. - */ - -#include -#include -#include -#include -#include - -/* - * Splay trees are self-adjusting binary search trees. - * They have the following attractive properties: - * 1) Space efficient; only two pointers per entry. - * 2) Robust performance; amortized O(log n) per operation. - * 3) Recursion not needed. - * This makes them a good fall-back data structure for those - * entries that don't fit into the lookup table. - * - * The paper by Sleator and Tarjan, JACM v. 32, no. 3, pp. 652-686, - * describes the splaying operation. ipc_splay_prim_lookup - * and ipc_splay_prim_assemble implement the top-down splay - * described on p. 669. - * - * The tree is stored in an unassembled form. If ist_root is null, - * then the tree has no entries. Otherwise, ist_name records - * the value used for the last lookup. ist_root points to the - * middle tree obtained from the top-down splay. ist_ltree and - * ist_rtree point to left and right subtrees, whose entries - * are all smaller (larger) than those in the middle tree. - * ist_ltreep and ist_rtreep are pointers to fields in the - * left and right subtrees. ist_ltreep points to the rchild field - * of the largest entry in ltree, and ist_rtreep points to the - * lchild field of the smallest entry in rtree. The pointed-to - * fields aren't initialized. If the left (right) subtree is null, - * then ist_ltreep (ist_rtreep) points to the ist_ltree (ist_rtree) - * field in the splay structure itself. - * - * The primary advantage of the unassembled form is that repeated - * unsuccessful lookups are efficient. In particular, an unsuccessful - * lookup followed by an insert only requires one splaying operation. - * - * The traversal algorithm works via pointer inversion. - * When descending down the tree, child pointers are reversed - * to point back to the parent entry. When ascending, - * the pointers are restored to their original value. - * - * The biggest potential problem with the splay tree implementation - * is that the operations, even lookup, require an exclusive lock. - * If IPC spaces are protected with exclusive locks, then - * the splay tree doesn't require its own lock, and ist_lock/ist_unlock - * needn't do anything. If IPC spaces are protected with read/write - * locks then ist_lock/ist_unlock should provide exclusive access. - * - * If it becomes important to let lookups run in parallel, - * or if the restructuring makes lookups too expensive, then - * there is hope. Use a read/write lock on the splay tree. - * Keep track of the number of entries in the tree. When doing - * a lookup, first try a non-restructuring lookup with a read lock held, - * with a bound (based on log of size of the tree) on the number of - * entries to traverse. If the lookup runs up against the bound, - * then take a write lock and do a reorganizing lookup. - * This way, if lookups only access roughly balanced parts - * of the tree, then lookups run in parallel and do no restructuring. - * - * The traversal algorithm currently requires an exclusive lock. - * If that is a problem, the tree could be changed from an lchild/rchild - * representation to a leftmost child/right sibling representation. - * In conjunction with non-restructing lookups, this would let - * lookups and traversals all run in parallel. But this representation - * is more complicated and would slow down the operations. - */ - -/* - * Boundary values to hand to ipc_splay_prim_lookup: - */ - -#define MACH_PORT_SMALLEST ((mach_port_t) 0) -#define MACH_PORT_LARGEST ((mach_port_t) ~0) - -/* - * Routine: ipc_splay_prim_lookup - * Purpose: - * Searches for the node labeled name in the splay tree. - * Returns three nodes (treep, ltreep, rtreep) and - * two pointers to nodes (ltreepp, rtreepp). - * - * ipc_splay_prim_lookup splits the supplied tree into - * three subtrees, left, middle, and right, returned - * in ltreep, treep, and rtreep. - * - * If name is present in the tree, then it is at - * the root of the middle tree. Otherwise, the root - * of the middle tree is the last node traversed. - * - * ipc_splay_prim_lookup returns a pointer into - * the left subtree, to the rchild field of its - * largest node, in ltreepp. It returns a pointer - * into the right subtree, to the lchild field of its - * smallest node, in rtreepp. - */ - -static void -ipc_splay_prim_lookup( - mach_port_t name, - ipc_tree_entry_t tree, - ipc_tree_entry_t *treep, - ipc_tree_entry_t *ltreep, - ipc_tree_entry_t **ltreepp, - ipc_tree_entry_t *rtreep, - ipc_tree_entry_t **rtreepp) -{ - mach_port_t tname; /* temp name */ - ipc_tree_entry_t lchild, rchild; /* temp child pointers */ - - assert(tree != ITE_NULL); - -#define link_left \ -MACRO_BEGIN \ - *ltreep = tree; \ - ltreep = &tree->ite_rchild; \ - tree = *ltreep; \ -MACRO_END - -#define link_right \ -MACRO_BEGIN \ - *rtreep = tree; \ - rtreep = &tree->ite_lchild; \ - tree = *rtreep; \ -MACRO_END - -#define rotate_left \ -MACRO_BEGIN \ - ipc_tree_entry_t temp = tree; \ - \ - tree = temp->ite_rchild; \ - temp->ite_rchild = tree->ite_lchild; \ - tree->ite_lchild = temp; \ -MACRO_END - -#define rotate_right \ -MACRO_BEGIN \ - ipc_tree_entry_t temp = tree; \ - \ - tree = temp->ite_lchild; \ - temp->ite_lchild = tree->ite_rchild; \ - tree->ite_rchild = temp; \ -MACRO_END - - while (name != (tname = tree->ite_name)) { - if (name < tname) { - /* descend to left */ - - lchild = tree->ite_lchild; - if (lchild == ITE_NULL) - break; - tname = lchild->ite_name; - - if ((name < tname) && - (lchild->ite_lchild != ITE_NULL)) - rotate_right; - link_right; - if ((name > tname) && - (lchild->ite_rchild != ITE_NULL)) - link_left; - } else { - /* descend to right */ - - rchild = tree->ite_rchild; - if (rchild == ITE_NULL) - break; - tname = rchild->ite_name; - - if ((name > tname) && - (rchild->ite_rchild != ITE_NULL)) - rotate_left; - link_left; - if ((name < tname) && - (rchild->ite_lchild != ITE_NULL)) - link_right; - } - - assert(tree != ITE_NULL); - } - - *treep = tree; - *ltreepp = ltreep; - *rtreepp = rtreep; - -#undef link_left -#undef link_right -#undef rotate_left -#undef rotate_right -} - -/* - * Routine: ipc_splay_prim_assemble - * Purpose: - * Assembles the results of ipc_splay_prim_lookup - * into a splay tree with the found node at the root. - * - * ltree and rtree are by-reference so storing - * through ltreep and rtreep can change them. - */ - -static void -ipc_splay_prim_assemble( - ipc_tree_entry_t tree, - ipc_tree_entry_t *ltree, - ipc_tree_entry_t *ltreep, - ipc_tree_entry_t *rtree, - ipc_tree_entry_t *rtreep) -{ - assert(tree != ITE_NULL); - - *ltreep = tree->ite_lchild; - *rtreep = tree->ite_rchild; - - tree->ite_lchild = *ltree; - tree->ite_rchild = *rtree; -} - -/* - * Routine: ipc_splay_tree_init - * Purpose: - * Initialize a raw splay tree for use. - */ - -void -ipc_splay_tree_init( - ipc_splay_tree_t splay) -{ - splay->ist_root = ITE_NULL; -} - -/* - * Routine: ipc_splay_tree_pick - * Purpose: - * Picks and returns a random entry in a splay tree. - * Returns FALSE if the splay tree is empty. - */ - -boolean_t -ipc_splay_tree_pick( - ipc_splay_tree_t splay, - mach_port_t *namep, - ipc_tree_entry_t *entryp) -{ - ipc_tree_entry_t root; - - ist_lock(splay); - - root = splay->ist_root; - if (root != ITE_NULL) { - *namep = root->ite_name; - *entryp = root; - } - - ist_unlock(splay); - - return root != ITE_NULL; -} - -/* - * Routine: ipc_splay_tree_lookup - * Purpose: - * Finds an entry in a splay tree. - * Returns ITE_NULL if not found. - */ - -ipc_tree_entry_t -ipc_splay_tree_lookup( - ipc_splay_tree_t splay, - mach_port_t name) -{ - ipc_tree_entry_t root; - - ist_lock(splay); - - root = splay->ist_root; - if (root != ITE_NULL) { - if (splay->ist_name != name) { - ipc_splay_prim_assemble(root, - &splay->ist_ltree, splay->ist_ltreep, - &splay->ist_rtree, splay->ist_rtreep); - ipc_splay_prim_lookup(name, root, &root, - &splay->ist_ltree, &splay->ist_ltreep, - &splay->ist_rtree, &splay->ist_rtreep); - splay->ist_name = name; - splay->ist_root = root; - } - - if (name != root->ite_name) - root = ITE_NULL; - } - - ist_unlock(splay); - - return root; -} - -/* - * Routine: ipc_splay_tree_insert - * Purpose: - * Inserts a new entry into a splay tree. - * The caller supplies a new entry. - * The name can't already be present in the tree. - */ - -void -ipc_splay_tree_insert( - ipc_splay_tree_t splay, - mach_port_t name, - ipc_tree_entry_t entry) -{ - ipc_tree_entry_t root; - - assert(entry != ITE_NULL); - - ist_lock(splay); - - root = splay->ist_root; - if (root == ITE_NULL) { - entry->ite_lchild = ITE_NULL; - entry->ite_rchild = ITE_NULL; - } else { - if (splay->ist_name != name) { - ipc_splay_prim_assemble(root, - &splay->ist_ltree, splay->ist_ltreep, - &splay->ist_rtree, splay->ist_rtreep); - ipc_splay_prim_lookup(name, root, &root, - &splay->ist_ltree, &splay->ist_ltreep, - &splay->ist_rtree, &splay->ist_rtreep); - } - - assert(root->ite_name != name); - - if (name < root->ite_name) { - assert(root->ite_lchild == ITE_NULL); - - *splay->ist_ltreep = ITE_NULL; - *splay->ist_rtreep = root; - } else { - assert(root->ite_rchild == ITE_NULL); - - *splay->ist_ltreep = root; - *splay->ist_rtreep = ITE_NULL; - } - - entry->ite_lchild = splay->ist_ltree; - entry->ite_rchild = splay->ist_rtree; - } - - entry->ite_name = name; - splay->ist_root = entry; - splay->ist_name = name; - splay->ist_ltreep = &splay->ist_ltree; - splay->ist_rtreep = &splay->ist_rtree; - - ist_unlock(splay); -} - -/* - * Routine: ipc_splay_tree_delete - * Purpose: - * Deletes an entry from a splay tree. - * The name must be present in the tree. - * Frees the entry. - * - * The "entry" argument isn't currently used. - * Other implementations might want it, though. - */ - -void -ipc_splay_tree_delete( - ipc_splay_tree_t splay, - mach_port_t name, - ipc_tree_entry_t entry) -{ - ipc_tree_entry_t root, saved; - - ist_lock(splay); - - root = splay->ist_root; - assert(root != ITE_NULL); - - if (splay->ist_name != name) { - ipc_splay_prim_assemble(root, - &splay->ist_ltree, splay->ist_ltreep, - &splay->ist_rtree, splay->ist_rtreep); - ipc_splay_prim_lookup(name, root, &root, - &splay->ist_ltree, &splay->ist_ltreep, - &splay->ist_rtree, &splay->ist_rtreep); - } - - assert(root->ite_name == name); - assert(root == entry); - - *splay->ist_ltreep = root->ite_lchild; - *splay->ist_rtreep = root->ite_rchild; - ite_free(root); - - root = splay->ist_ltree; - saved = splay->ist_rtree; - - if (root == ITE_NULL) - root = saved; - else if (saved != ITE_NULL) { - /* - * Find the largest node in the left subtree, and splay it - * to the root. Then add the saved right subtree. - */ - - ipc_splay_prim_lookup(MACH_PORT_LARGEST, root, &root, - &splay->ist_ltree, &splay->ist_ltreep, - &splay->ist_rtree, &splay->ist_rtreep); - ipc_splay_prim_assemble(root, - &splay->ist_ltree, splay->ist_ltreep, - &splay->ist_rtree, splay->ist_rtreep); - - assert(root->ite_rchild == ITE_NULL); - root->ite_rchild = saved; - } - - splay->ist_root = root; - if (root != ITE_NULL) { - splay->ist_name = root->ite_name; - splay->ist_ltreep = &splay->ist_ltree; - splay->ist_rtreep = &splay->ist_rtree; - } - - ist_unlock(splay); -} - -/* - * Routine: ipc_splay_tree_split - * Purpose: - * Split a splay tree. Puts all entries smaller than "name" - * into a new tree, "small". - * - * Doesn't do locking on "small", because nobody else - * should be fiddling with the uninitialized tree. - */ - -void -ipc_splay_tree_split( - ipc_splay_tree_t splay, - mach_port_t name, - ipc_splay_tree_t small) -{ - ipc_tree_entry_t root; - - ipc_splay_tree_init(small); - - ist_lock(splay); - - root = splay->ist_root; - if (root != ITE_NULL) { - /* lookup name, to get it (or last traversed) to the top */ - - if (splay->ist_name != name) { - ipc_splay_prim_assemble(root, - &splay->ist_ltree, splay->ist_ltreep, - &splay->ist_rtree, splay->ist_rtreep); - ipc_splay_prim_lookup(name, root, &root, - &splay->ist_ltree, &splay->ist_ltreep, - &splay->ist_rtree, &splay->ist_rtreep); - } - - if (root->ite_name < name) { - /* root goes into small */ - - *splay->ist_ltreep = root->ite_lchild; - *splay->ist_rtreep = ITE_NULL; - root->ite_lchild = splay->ist_ltree; - assert(root->ite_rchild == ITE_NULL); - - small->ist_root = root; - small->ist_name = root->ite_name; - small->ist_ltreep = &small->ist_ltree; - small->ist_rtreep = &small->ist_rtree; - - /* rtree goes into splay */ - - root = splay->ist_rtree; - splay->ist_root = root; - if (root != ITE_NULL) { - splay->ist_name = root->ite_name; - splay->ist_ltreep = &splay->ist_ltree; - splay->ist_rtreep = &splay->ist_rtree; - } - } else { - /* root stays in splay */ - - *splay->ist_ltreep = root->ite_lchild; - root->ite_lchild = ITE_NULL; - - splay->ist_root = root; - splay->ist_name = name; - splay->ist_ltreep = &splay->ist_ltree; - - /* ltree goes into small */ - - root = splay->ist_ltree; - small->ist_root = root; - if (root != ITE_NULL) { - small->ist_name = root->ite_name; - small->ist_ltreep = &small->ist_ltree; - small->ist_rtreep = &small->ist_rtree; - } - } - } - - ist_unlock(splay); -} - -/* - * Routine: ipc_splay_tree_join - * Purpose: - * Joins two splay trees. Merges the entries in "small", - * which must all be smaller than the entries in "splay", - * into "splay". - */ - -void -ipc_splay_tree_join( - ipc_splay_tree_t splay, - ipc_splay_tree_t small) -{ - ipc_tree_entry_t sroot; - - /* pull entries out of small */ - - ist_lock(small); - - sroot = small->ist_root; - if (sroot != ITE_NULL) { - ipc_splay_prim_assemble(sroot, - &small->ist_ltree, small->ist_ltreep, - &small->ist_rtree, small->ist_rtreep); - small->ist_root = ITE_NULL; - } - - ist_unlock(small); - - /* put entries, if any, into splay */ - - if (sroot != ITE_NULL) { - ipc_tree_entry_t root; - - ist_lock(splay); - - root = splay->ist_root; - if (root == ITE_NULL) { - root = sroot; - } else { - /* get smallest entry in splay tree to top */ - - if (splay->ist_name != MACH_PORT_SMALLEST) { - ipc_splay_prim_assemble(root, - &splay->ist_ltree, splay->ist_ltreep, - &splay->ist_rtree, splay->ist_rtreep); - ipc_splay_prim_lookup(MACH_PORT_SMALLEST, - root, &root, - &splay->ist_ltree, &splay->ist_ltreep, - &splay->ist_rtree, &splay->ist_rtreep); - } - - ipc_splay_prim_assemble(root, - &splay->ist_ltree, splay->ist_ltreep, - &splay->ist_rtree, splay->ist_rtreep); - - assert(root->ite_lchild == ITE_NULL); - assert(sroot->ite_name < root->ite_name); - root->ite_lchild = sroot; - } - - splay->ist_root = root; - splay->ist_name = root->ite_name; - splay->ist_ltreep = &splay->ist_ltree; - splay->ist_rtreep = &splay->ist_rtree; - - ist_unlock(splay); - } -} - -/* - * Routine: ipc_splay_tree_bounds - * Purpose: - * Given a name, returns the largest value present - * in the tree that is smaller than or equal to the name, - * or ~0 if no such value exists. Similarly, returns - * the smallest value present that is greater than or - * equal to the name, or 0 if no such value exists. - * - * Hence, if - * lower = upper, then lower = name = upper - * and name is present in the tree - * lower = ~0 and upper = 0, - * then the tree is empty - * lower = ~0 and upper > 0, then name < upper - * and upper is smallest value in tree - * lower < ~0 and upper = 0, then lower < name - * and lower is largest value in tree - * lower < ~0 and upper > 0, then lower < name < upper - * and they are tight bounds on name - * - * (Note MACH_PORT_SMALLEST = 0 and MACH_PORT_LARGEST = ~0.) - */ - -void -ipc_splay_tree_bounds( - ipc_splay_tree_t splay, - mach_port_t name, - mach_port_t *lowerp, - mach_port_t *upperp) -{ - ipc_tree_entry_t root; - - ist_lock(splay); - - root = splay->ist_root; - if (root == ITE_NULL) { - *lowerp = MACH_PORT_LARGEST; - *upperp = MACH_PORT_SMALLEST; - } else { - mach_port_t rname; - - if (splay->ist_name != name) { - ipc_splay_prim_assemble(root, - &splay->ist_ltree, splay->ist_ltreep, - &splay->ist_rtree, splay->ist_rtreep); - ipc_splay_prim_lookup(name, root, &root, - &splay->ist_ltree, &splay->ist_ltreep, - &splay->ist_rtree, &splay->ist_rtreep); - splay->ist_name = name; - splay->ist_root = root; - } - - rname = root->ite_name; - - /* - * OK, it's a hack. We convert the ltreep and rtreep - * pointers back into real entry pointers, - * so we can pick the names out of the entries. - */ - - if (rname <= name) - *lowerp = rname; - else if (splay->ist_ltreep == &splay->ist_ltree) - *lowerp = MACH_PORT_LARGEST; - else { - ipc_tree_entry_t entry; - - entry = (ipc_tree_entry_t) - ((char *)splay->ist_ltreep - - ((char *)&root->ite_rchild - - (char *)root)); - *lowerp = entry->ite_name; - } - - if (rname >= name) - *upperp = rname; - else if (splay->ist_rtreep == &splay->ist_rtree) - *upperp = MACH_PORT_SMALLEST; - else { - ipc_tree_entry_t entry; - - entry = (ipc_tree_entry_t) - ((char *)splay->ist_rtreep - - ((char *)&root->ite_lchild - - (char *)root)); - *upperp = entry->ite_name; - } - } - - ist_unlock(splay); -} - -/* - * Routine: ipc_splay_traverse_start - * Routine: ipc_splay_traverse_next - * Routine: ipc_splay_traverse_finish - * Purpose: - * Perform a symmetric order traversal of a splay tree. - * Usage: - * for (entry = ipc_splay_traverse_start(splay); - * entry != ITE_NULL; - * entry = ipc_splay_traverse_next(splay, delete)) { - * do something with entry - * } - * ipc_splay_traverse_finish(splay); - * - * If "delete" is TRUE, then the current entry - * is removed from the tree and deallocated. - * - * During the traversal, the splay tree is locked. - */ - -ipc_tree_entry_t -ipc_splay_traverse_start( - ipc_splay_tree_t splay) -{ - ipc_tree_entry_t current, parent; - - ist_lock(splay); - - current = splay->ist_root; - if (current != ITE_NULL) { - ipc_splay_prim_assemble(current, - &splay->ist_ltree, splay->ist_ltreep, - &splay->ist_rtree, splay->ist_rtreep); - - parent = ITE_NULL; - - while (current->ite_lchild != ITE_NULL) { - ipc_tree_entry_t next; - - next = current->ite_lchild; - current->ite_lchild = parent; - parent = current; - current = next; - } - - splay->ist_ltree = current; - splay->ist_rtree = parent; - } - - return current; -} - -ipc_tree_entry_t -ipc_splay_traverse_next( - ipc_splay_tree_t splay, - boolean_t delete) -{ - ipc_tree_entry_t current, parent; - - /* pick up where traverse_entry left off */ - - current = splay->ist_ltree; - parent = splay->ist_rtree; - assert(current != ITE_NULL); - - if (!delete) - goto traverse_right; - - /* we must delete current and patch the tree */ - - if (current->ite_lchild == ITE_NULL) { - if (current->ite_rchild == ITE_NULL) { - /* like traverse_back, but with deletion */ - - if (parent == ITE_NULL) { - ite_free(current); - - splay->ist_root = ITE_NULL; - return ITE_NULL; - } - - if (current->ite_name < parent->ite_name) { - ite_free(current); - - current = parent; - parent = current->ite_lchild; - current->ite_lchild = ITE_NULL; - goto traverse_entry; - } else { - ite_free(current); - - current = parent; - parent = current->ite_rchild; - current->ite_rchild = ITE_NULL; - goto traverse_back; - } - } else { - ipc_tree_entry_t prev; - - prev = current; - current = current->ite_rchild; - ite_free(prev); - goto traverse_left; - } - } else { - if (current->ite_rchild == ITE_NULL) { - ipc_tree_entry_t prev; - - prev = current; - current = current->ite_lchild; - ite_free(prev); - goto traverse_back; - } else { - ipc_tree_entry_t prev; - ipc_tree_entry_t ltree, rtree; - ipc_tree_entry_t *ltreep, *rtreep; - - /* replace current with largest of left children */ - - prev = current; - ipc_splay_prim_lookup(MACH_PORT_LARGEST, - current->ite_lchild, ¤t, - <ree, <reep, &rtree, &rtreep); - ipc_splay_prim_assemble(current, - <ree, ltreep, &rtree, rtreep); - - assert(current->ite_rchild == ITE_NULL); - current->ite_rchild = prev->ite_rchild; - ite_free(prev); - goto traverse_right; - } - } - /*NOTREACHED*/ - - /* - * A state machine: for each entry, we - * 1) traverse left subtree - * 2) traverse the entry - * 3) traverse right subtree - * 4) traverse back to parent - */ - - traverse_left: - if (current->ite_lchild != ITE_NULL) { - ipc_tree_entry_t next; - - next = current->ite_lchild; - current->ite_lchild = parent; - parent = current; - current = next; - goto traverse_left; - } - - traverse_entry: - splay->ist_ltree = current; - splay->ist_rtree = parent; - return current; - - traverse_right: - if (current->ite_rchild != ITE_NULL) { - ipc_tree_entry_t next; - - next = current->ite_rchild; - current->ite_rchild = parent; - parent = current; - current = next; - goto traverse_left; - } - - traverse_back: - if (parent == ITE_NULL) { - splay->ist_root = current; - return ITE_NULL; - } - - if (current->ite_name < parent->ite_name) { - ipc_tree_entry_t prev; - - prev = current; - current = parent; - parent = current->ite_lchild; - current->ite_lchild = prev; - goto traverse_entry; - } else { - ipc_tree_entry_t prev; - - prev = current; - current = parent; - parent = current->ite_rchild; - current->ite_rchild = prev; - goto traverse_back; - } -} - -void -ipc_splay_traverse_finish( - ipc_splay_tree_t splay) -{ - ipc_tree_entry_t root; - - root = splay->ist_root; - if (root != ITE_NULL) { - splay->ist_name = root->ite_name; - splay->ist_ltreep = &splay->ist_ltree; - splay->ist_rtreep = &splay->ist_rtree; - } - - ist_unlock(splay); -} - diff --git a/ipc/ipc_splay.h b/ipc/ipc_splay.h deleted file mode 100644 index 42e5a801..00000000 --- a/ipc/ipc_splay.h +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1991,1990,1989 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - */ -/* - */ -/* - * File: ipc/ipc_splay.h - * Author: Rich Draves - * Date: 1989 - * - * Declarations of primitive splay tree operations. - */ - -#ifndef _IPC_IPC_SPLAY_H_ -#define _IPC_IPC_SPLAY_H_ - -#include -#include -#include -#include - -typedef struct ipc_splay_tree { - mach_port_t ist_name; /* name used in last lookup */ - ipc_tree_entry_t ist_root; /* root of middle tree */ - ipc_tree_entry_t ist_ltree; /* root of left tree */ - ipc_tree_entry_t *ist_ltreep; /* pointer into left tree */ - ipc_tree_entry_t ist_rtree; /* root of right tree */ - ipc_tree_entry_t *ist_rtreep; /* pointer into right tree */ -} *ipc_splay_tree_t; - -#define ist_lock(splay) /* no locking */ -#define ist_unlock(splay) /* no locking */ - -/* Initialize a raw splay tree */ -extern void ipc_splay_tree_init( - ipc_splay_tree_t splay); - -/* Pick a random entry in a splay tree */ -extern boolean_t ipc_splay_tree_pick( - ipc_splay_tree_t splay, - mach_port_t *namep, - ipc_tree_entry_t *entryp); - -/* Find an entry in a splay tree */ -extern ipc_tree_entry_t ipc_splay_tree_lookup( - ipc_splay_tree_t splay, - mach_port_t name); - -/* Insert a new entry into a splay tree */ -extern void ipc_splay_tree_insert( - ipc_splay_tree_t splay, - mach_port_t name, - ipc_tree_entry_t entry); - -/* Delete an entry from a splay tree */ -extern void ipc_splay_tree_delete( - ipc_splay_tree_t splay, - mach_port_t name, - ipc_tree_entry_t entry); - -/* Split a splay tree */ -extern void ipc_splay_tree_split( - ipc_splay_tree_t splay, - mach_port_t name, - ipc_splay_tree_t entry); - -/* Join two splay trees */ -extern void ipc_splay_tree_join( - ipc_splay_tree_t splay, - ipc_splay_tree_t small); - -/* Do a bounded splay tree lookup */ -extern void ipc_splay_tree_bounds( - ipc_splay_tree_t splay, - mach_port_t name, - mach_port_t *lowerp, - mach_port_t *upperp); - -/* Initialize a symmetric order traversal of a splay tree */ -extern ipc_tree_entry_t ipc_splay_traverse_start( - ipc_splay_tree_t splay); - -/* Return the next entry in a symmetric order traversal of a splay tree */ -extern ipc_tree_entry_t ipc_splay_traverse_next( - ipc_splay_tree_t splay, - boolean_t delete); - -/* Terminate a symmetric order traversal of a splay tree */ -extern void ipc_splay_traverse_finish( - ipc_splay_tree_t splay); - -#endif /* _IPC_IPC_SPLAY_H_ */ diff --git a/ipc/mach_debug.c b/ipc/mach_debug.c index eb52e1c8..efb07a4f 100644 --- a/ipc/mach_debug.c +++ b/ipc/mach_debug.c @@ -46,7 +46,6 @@ #include #include #include -#include #include #include #include @@ -93,85 +92,6 @@ mach_port_get_srights( return KERN_SUCCESS; } -/* - * Routine: host_ipc_hash_info - * Purpose: - * Return information about the global reverse hash table. - * Conditions: - * Nothing locked. Obeys CountInOut protocol. - * Returns: - * KERN_SUCCESS Returned information. - * KERN_INVALID_HOST The host is null. - * KERN_RESOURCE_SHORTAGE Couldn't allocate memory. - */ - -kern_return_t -host_ipc_hash_info( - host_t host, - hash_info_bucket_array_t *infop, - mach_msg_type_number_t *countp) -{ - vm_offset_t addr; - vm_size_t size = 0; /* Suppress gcc warning */ - hash_info_bucket_t *info; - unsigned int potential, actual; - kern_return_t kr; - - if (host == HOST_NULL) - return KERN_INVALID_HOST; - - /* start with in-line data */ - - info = *infop; - potential = *countp; - - for (;;) { - actual = ipc_hash_info(info, potential); - if (actual <= potential) - break; - - /* allocate more memory */ - - if (info != *infop) - kmem_free(ipc_kernel_map, addr, size); - - size = round_page(actual * sizeof *info); - kr = kmem_alloc_pageable(ipc_kernel_map, &addr, size); - if (kr != KERN_SUCCESS) - return KERN_RESOURCE_SHORTAGE; - - info = (hash_info_bucket_t *) addr; - potential = size/sizeof *info; - } - - if (info == *infop) { - /* data fit in-line; nothing to deallocate */ - - *countp = actual; - } else if (actual == 0) { - kmem_free(ipc_kernel_map, addr, size); - - *countp = 0; - } else { - vm_map_copy_t copy; - vm_size_t used; - - used = round_page(actual * sizeof *info); - - if (used != size) - kmem_free(ipc_kernel_map, addr + used, size - used); - - kr = vm_map_copyin(ipc_kernel_map, addr, used, - TRUE, ©); - assert(kr == KERN_SUCCESS); - - *infop = (hash_info_bucket_t *) copy; - *countp = actual; - } - - return KERN_SUCCESS; -} - /* * Routine: host_ipc_marequest_info * Purpose: @@ -252,251 +172,6 @@ host_ipc_marequest_info( return KERN_SUCCESS; } -/* - * Routine: mach_port_space_info - * Purpose: - * Returns information about an IPC space. - * Conditions: - * Nothing locked. Obeys CountInOut protocol. - * Returns: - * KERN_SUCCESS Returned information. - * KERN_INVALID_TASK The space is null. - * KERN_INVALID_TASK The space is dead. - * KERN_RESOURCE_SHORTAGE Couldn't allocate memory. - */ - -kern_return_t -mach_port_space_info( - ipc_space_t space, - ipc_info_space_t *infop, - ipc_info_name_array_t *tablep, - mach_msg_type_number_t *tableCntp, - ipc_info_tree_name_array_t *treep, - mach_msg_type_number_t *treeCntp) -{ - ipc_info_name_t *table_info; - unsigned int table_potential, table_actual; - vm_offset_t table_addr; - vm_size_t table_size = 0; /* Suppress gcc warning */ - ipc_info_tree_name_t *tree_info; - unsigned int tree_potential, tree_actual; - vm_offset_t tree_addr; - vm_size_t tree_size = 0; /* Suppress gcc warning */ - ipc_tree_entry_t tentry; - ipc_entry_t table; - ipc_entry_num_t tsize; - mach_port_index_t index; - kern_return_t kr; - - if (space == IS_NULL) - return KERN_INVALID_TASK; - - /* start with in-line memory */ - - table_info = *tablep; - table_potential = *tableCntp; - tree_info = *treep; - tree_potential = *treeCntp; - - for (;;) { - is_read_lock(space); - if (!space->is_active) { - is_read_unlock(space); - if (table_info != *tablep) - kmem_free(ipc_kernel_map, - table_addr, table_size); - if (tree_info != *treep) - kmem_free(ipc_kernel_map, - tree_addr, tree_size); - return KERN_INVALID_TASK; - } - - table_actual = space->is_table_size; - tree_actual = space->is_tree_total; - - if ((table_actual <= table_potential) && - (tree_actual <= tree_potential)) - break; - - is_read_unlock(space); - - if (table_actual > table_potential) { - if (table_info != *tablep) - kmem_free(ipc_kernel_map, - table_addr, table_size); - - table_size = round_page(table_actual * - sizeof *table_info); - kr = kmem_alloc(ipc_kernel_map, - &table_addr, table_size); - if (kr != KERN_SUCCESS) { - if (tree_info != *treep) - kmem_free(ipc_kernel_map, - tree_addr, tree_size); - - return KERN_RESOURCE_SHORTAGE; - } - - table_info = (ipc_info_name_t *) table_addr; - table_potential = table_size/sizeof *table_info; - } - - if (tree_actual > tree_potential) { - if (tree_info != *treep) - kmem_free(ipc_kernel_map, - tree_addr, tree_size); - - tree_size = round_page(tree_actual * - sizeof *tree_info); - kr = kmem_alloc(ipc_kernel_map, - &tree_addr, tree_size); - if (kr != KERN_SUCCESS) { - if (table_info != *tablep) - kmem_free(ipc_kernel_map, - table_addr, table_size); - - return KERN_RESOURCE_SHORTAGE; - } - - tree_info = (ipc_info_tree_name_t *) tree_addr; - tree_potential = tree_size/sizeof *tree_info; - } - } - /* space is read-locked and active; we have enough wired memory */ - - infop->iis_genno_mask = MACH_PORT_NGEN(MACH_PORT_DEAD); - infop->iis_table_size = space->is_table_size; - infop->iis_table_next = space->is_table_next->its_size; - infop->iis_tree_size = space->is_tree_total; - infop->iis_tree_small = space->is_tree_small; - infop->iis_tree_hash = space->is_tree_hash; - - table = space->is_table; - tsize = space->is_table_size; - - for (index = 0; index < tsize; index++) { - ipc_info_name_t *iin = &table_info[index]; - ipc_entry_t entry = &table[index]; - ipc_entry_bits_t bits = entry->ie_bits; - - iin->iin_name = MACH_PORT_MAKEB(index, bits); - iin->iin_collision = (bits & IE_BITS_COLLISION) ? TRUE : FALSE; - iin->iin_compat = FALSE; - iin->iin_marequest = (bits & IE_BITS_MAREQUEST) ? TRUE : FALSE; - iin->iin_type = IE_BITS_TYPE(bits); - iin->iin_urefs = IE_BITS_UREFS(bits); - iin->iin_object = (vm_offset_t) entry->ie_object; - iin->iin_next = entry->ie_next; - iin->iin_hash = entry->ie_index; - } - - for (tentry = ipc_splay_traverse_start(&space->is_tree), index = 0; - tentry != ITE_NULL; - tentry = ipc_splay_traverse_next(&space->is_tree, FALSE)) { - ipc_info_tree_name_t *iitn = &tree_info[index++]; - ipc_info_name_t *iin = &iitn->iitn_name; - ipc_entry_t entry = &tentry->ite_entry; - ipc_entry_bits_t bits = entry->ie_bits; - - assert(IE_BITS_TYPE(bits) != MACH_PORT_TYPE_NONE); - - iin->iin_name = tentry->ite_name; - iin->iin_collision = (bits & IE_BITS_COLLISION) ? TRUE : FALSE; - iin->iin_compat = FALSE; - iin->iin_marequest = (bits & IE_BITS_MAREQUEST) ? TRUE : FALSE; - iin->iin_type = IE_BITS_TYPE(bits); - iin->iin_urefs = IE_BITS_UREFS(bits); - iin->iin_object = (vm_offset_t) entry->ie_object; - iin->iin_next = entry->ie_next; - iin->iin_hash = entry->ie_index; - - if (tentry->ite_lchild == ITE_NULL) - iitn->iitn_lchild = MACH_PORT_NULL; - else - iitn->iitn_lchild = tentry->ite_lchild->ite_name; - - if (tentry->ite_rchild == ITE_NULL) - iitn->iitn_rchild = MACH_PORT_NULL; - else - iitn->iitn_rchild = tentry->ite_rchild->ite_name; - - } - ipc_splay_traverse_finish(&space->is_tree); - is_read_unlock(space); - - if (table_info == *tablep) { - /* data fit in-line; nothing to deallocate */ - - *tableCntp = table_actual; - } else if (table_actual == 0) { - kmem_free(ipc_kernel_map, table_addr, table_size); - - *tableCntp = 0; - } else { - vm_size_t size_used, rsize_used; - vm_map_copy_t copy; - - /* kmem_alloc doesn't zero memory */ - - size_used = table_actual * sizeof *table_info; - rsize_used = round_page(size_used); - - if (rsize_used != table_size) - kmem_free(ipc_kernel_map, - table_addr + rsize_used, - table_size - rsize_used); - - if (size_used != rsize_used) - memset((void *) (table_addr + size_used), 0, - rsize_used - size_used); - - kr = vm_map_copyin(ipc_kernel_map, table_addr, rsize_used, - TRUE, ©); - - assert(kr == KERN_SUCCESS); - - *tablep = (ipc_info_name_t *) copy; - *tableCntp = table_actual; - } - - if (tree_info == *treep) { - /* data fit in-line; nothing to deallocate */ - - *treeCntp = tree_actual; - } else if (tree_actual == 0) { - kmem_free(ipc_kernel_map, tree_addr, tree_size); - - *treeCntp = 0; - } else { - vm_size_t size_used, rsize_used; - vm_map_copy_t copy; - - /* kmem_alloc doesn't zero memory */ - - size_used = tree_actual * sizeof *tree_info; - rsize_used = round_page(size_used); - - if (rsize_used != tree_size) - kmem_free(ipc_kernel_map, - tree_addr + rsize_used, - tree_size - rsize_used); - - if (size_used != rsize_used) - memset((void *) (tree_addr + size_used), 0, - rsize_used - size_used); - - kr = vm_map_copyin(ipc_kernel_map, tree_addr, rsize_used, - TRUE, ©); - - assert(kr == KERN_SUCCESS); - - *treep = (ipc_info_tree_name_t *) copy; - *treeCntp = tree_actual; - } - - return KERN_SUCCESS; -} - /* * Routine: mach_port_dnrequest_info * Purpose: diff --git a/ipc/mach_port.c b/ipc/mach_port.c index 4e895275..93a1248f 100644 --- a/ipc/mach_port.c +++ b/ipc/mach_port.c @@ -150,10 +150,6 @@ mach_port_names( mach_port_type_t **typesp, mach_msg_type_number_t *typesCnt) { - ipc_tree_entry_t tentry; - ipc_entry_t table; - ipc_entry_num_t tsize; - mach_port_index_t index; ipc_entry_num_t actual; /* this many names */ ipc_port_timestamp_t timestamp; /* logical time of this operation */ mach_port_t *names; @@ -190,7 +186,7 @@ mach_port_names( /* upper bound on number of names in the space */ - bound = space->is_table_size + space->is_tree_total; + bound = space->is_size; size_needed = round_page(bound * sizeof(mach_port_t)); if (size_needed <= size) @@ -235,33 +231,16 @@ mach_port_names( timestamp = ipc_port_timestamp(); - table = space->is_table; - tsize = space->is_table_size; - - for (index = 0; index < tsize; index++) { - ipc_entry_t entry = &table[index]; + ipc_entry_t entry; + struct rdxtree_iter iter; + rdxtree_for_each(&space->is_map, &iter, entry) { ipc_entry_bits_t bits = entry->ie_bits; if (IE_BITS_TYPE(bits) != MACH_PORT_TYPE_NONE) { - mach_port_t name = MACH_PORT_MAKEB(index, bits); - - mach_port_names_helper(timestamp, entry, name, + mach_port_names_helper(timestamp, entry, entry->ie_name, names, types, &actual); } } - - for (tentry = ipc_splay_traverse_start(&space->is_tree); - tentry != ITE_NULL; - tentry = ipc_splay_traverse_next(&space->is_tree, FALSE)) { - ipc_entry_t entry = &tentry->ite_entry; - mach_port_t name = tentry->ite_name; - - assert(IE_BITS_TYPE(tentry->ite_bits) != MACH_PORT_TYPE_NONE); - - mach_port_names_helper(timestamp, entry, name, - names, types, &actual); - } - ipc_splay_traverse_finish(&space->is_tree); is_read_unlock(space); if (actual == 0) { @@ -946,10 +925,7 @@ mach_port_get_set_status( size = PAGE_SIZE; /* initial guess */ for (;;) { - ipc_tree_entry_t tentry; - ipc_entry_t entry, table; - ipc_entry_num_t tsize; - mach_port_index_t index; + ipc_entry_t entry; mach_port_t *names; ipc_pset_t pset; @@ -986,11 +962,9 @@ mach_port_get_set_status( maxnames = size / sizeof(mach_port_t); actual = 0; - table = space->is_table; - tsize = space->is_table_size; - - for (index = 0; index < tsize; index++) { - ipc_entry_t ientry = &table[index]; + ipc_entry_t ientry; + struct rdxtree_iter iter; + rdxtree_for_each(&space->is_map, &iter, ientry) { ipc_entry_bits_t bits = ientry->ie_bits; if (bits & MACH_PORT_TYPE_RECEIVE) { @@ -1002,22 +976,6 @@ mach_port_get_set_status( } } - for (tentry = ipc_splay_traverse_start(&space->is_tree); - tentry != ITE_NULL; - tentry = ipc_splay_traverse_next(&space->is_tree,FALSE)) { - ipc_entry_bits_t bits = tentry->ite_bits; - - assert(IE_BITS_TYPE(bits) != MACH_PORT_TYPE_NONE); - - if (bits & MACH_PORT_TYPE_RECEIVE) { - ipc_port_t port = - (ipc_port_t) tentry->ite_object; - - mach_port_gst_helper(pset, port, maxnames, - names, &actual); - } - } - ipc_splay_traverse_finish(&space->is_tree); is_read_unlock(space); if (actual <= maxnames) diff --git a/ipc/port.h b/ipc/port.h index d359115d..49af6e2c 100644 --- a/ipc/port.h +++ b/ipc/port.h @@ -45,10 +45,7 @@ * mach_port_t must be an unsigned type. Port values * have two parts, a generation number and an index. * These macros encapsulate all knowledge of how - * a mach_port_t is laid out. However, ipc/ipc_entry.c - * implicitly assumes when it uses the splay tree functions - * that the generation number is in the low bits, so that - * names are ordered first by index and then by generation. + * a mach_port_t is laid out. * * If the size of generation numbers changes, * be sure to update IE_BITS_GEN_MASK and friends -- cgit v1.2.3 From 4934e7c3735dbd25953c922a1327a875f47046a4 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Wed, 1 Apr 2015 17:17:01 +0200 Subject: ipc: inline key ipc entry lookup functions Declare functions looking up IPC entries that were previously inlined manually with `static inline' so that they will be inlined into the fast paths by the compiler. * ipc/ipc_entry.c (ipc_entry_lookup, ipc_entry_get, ipc_entry_dealloc): Move functions... * ipc/ipc_space.h: ... here, and declare them as `static inline'. * ipc/ipc_entry.h: Drop associated declarations. --- ipc/ipc_entry.c | 119 ------------------------------------------------------- ipc/ipc_entry.h | 9 ----- ipc/ipc_space.h | 120 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 120 insertions(+), 128 deletions(-) diff --git a/ipc/ipc_entry.c b/ipc/ipc_entry.c index 2d6e6658..a5fe319f 100644 --- a/ipc/ipc_entry.c +++ b/ipc/ipc_entry.c @@ -51,93 +51,6 @@ struct kmem_cache ipc_entry_cache; -/* - * Routine: ipc_entry_lookup - * Purpose: - * Searches for an entry, given its name. - * Conditions: - * The space must be read or write locked throughout. - * The space must be active. - */ - -ipc_entry_t -ipc_entry_lookup( - ipc_space_t space, - mach_port_t name) -{ - ipc_entry_t entry; - - assert(space->is_active); - entry = rdxtree_lookup(&space->is_map, (rdxtree_key_t) name); - if (entry != IE_NULL - && IE_BITS_TYPE(entry->ie_bits) == MACH_PORT_TYPE_NONE) - entry = NULL; - assert((entry == IE_NULL) || IE_BITS_TYPE(entry->ie_bits)); - return entry; -} - -/* - * Routine: ipc_entry_get - * Purpose: - * Tries to allocate an entry out of the space. - * Conditions: - * The space is write-locked and active throughout. - * An object may be locked. Will not allocate memory. - * Returns: - * KERN_SUCCESS A free entry was found. - * KERN_NO_SPACE No entry allocated. - */ - -kern_return_t -ipc_entry_get( - ipc_space_t space, - mach_port_t *namep, - ipc_entry_t *entryp) -{ - mach_port_t new_name; - ipc_entry_t free_entry; - - assert(space->is_active); - - /* Get entry from the free list. */ - free_entry = space->is_free_list; - if (free_entry == IE_NULL) - return KERN_NO_SPACE; - - space->is_free_list = free_entry->ie_next_free; - space->is_free_list_size -= 1; - - /* - * Initialize the new entry. We need only - * increment the generation number and clear ie_request. - */ - - { - mach_port_gen_t gen; - - assert((free_entry->ie_bits &~ IE_BITS_GEN_MASK) == 0); - gen = free_entry->ie_bits + IE_BITS_GEN_ONE; - free_entry->ie_bits = gen; - free_entry->ie_request = 0; - new_name = MACH_PORT_MAKE(free_entry->ie_name, gen); - } - - /* - * The new name can't be MACH_PORT_NULL because index - * is non-zero. It can't be MACH_PORT_DEAD because - * the table isn't allowed to grow big enough. - * (See comment in ipc/ipc_table.h.) - */ - - assert(MACH_PORT_VALID(new_name)); - assert(free_entry->ie_object == IO_NULL); - - space->is_size += 1; - *namep = new_name; - *entryp = free_entry; - return KERN_SUCCESS; -} - /* * Routine: ipc_entry_alloc * Purpose: @@ -293,38 +206,6 @@ ipc_entry_alloc_name( return KERN_SUCCESS; } -/* - * Routine: ipc_entry_dealloc - * Purpose: - * Deallocates an entry from a space. - * Conditions: - * The space must be write-locked throughout. - * The space must be active. - */ - -void -ipc_entry_dealloc( - ipc_space_t space, - mach_port_t name, - ipc_entry_t entry) -{ - assert(space->is_active); - assert(entry->ie_object == IO_NULL); - assert(entry->ie_request == 0); - - if (space->is_free_list_size < IS_FREE_LIST_SIZE_LIMIT) { - space->is_free_list_size += 1; - entry->ie_bits &= IE_BITS_GEN_MASK; - entry->ie_next_free = space->is_free_list; - space->is_free_list = entry; - } else { - rdxtree_remove(&space->is_map, (rdxtree_key_t) name); - ie_free(entry); - } - space->is_size -= 1; -} - - #if MACH_KDB #include #include diff --git a/ipc/ipc_entry.h b/ipc/ipc_entry.h index 5c1f8fd4..b429984b 100644 --- a/ipc/ipc_entry.h +++ b/ipc/ipc_entry.h @@ -96,21 +96,12 @@ extern struct kmem_cache ipc_entry_cache; #define ie_alloc() ((ipc_entry_t) kmem_cache_alloc(&ipc_entry_cache)) #define ie_free(e) kmem_cache_free(&ipc_entry_cache, (vm_offset_t) (e)) -extern ipc_entry_t -ipc_entry_lookup(ipc_space_t space, mach_port_t name); - -extern kern_return_t -ipc_entry_get(ipc_space_t space, mach_port_t *namep, ipc_entry_t *entryp); - extern kern_return_t ipc_entry_alloc(ipc_space_t space, mach_port_t *namep, ipc_entry_t *entryp); extern kern_return_t ipc_entry_alloc_name(ipc_space_t space, mach_port_t name, ipc_entry_t *entryp); -extern void -ipc_entry_dealloc(ipc_space_t space, mach_port_t name, ipc_entry_t entry); - ipc_entry_t db_ipc_object_by_name( task_t task, diff --git a/ipc/ipc_space.h b/ipc/ipc_space.h index 20b9d57d..58fe47c4 100644 --- a/ipc/ipc_space.h +++ b/ipc/ipc_space.h @@ -137,6 +137,126 @@ kern_return_t ipc_space_create(ipc_table_size_t, ipc_space_t *); kern_return_t ipc_space_create_special(struct ipc_space **); void ipc_space_destroy(struct ipc_space *); +/* IPC entry lookups. */ + +/* + * Routine: ipc_entry_lookup + * Purpose: + * Searches for an entry, given its name. + * Conditions: + * The space must be read or write locked throughout. + * The space must be active. + */ + +static inline ipc_entry_t +ipc_entry_lookup( + ipc_space_t space, + mach_port_t name) +{ + ipc_entry_t entry; + + assert(space->is_active); + entry = rdxtree_lookup(&space->is_map, (rdxtree_key_t) name); + if (entry != IE_NULL + && IE_BITS_TYPE(entry->ie_bits) == MACH_PORT_TYPE_NONE) + entry = NULL; + assert((entry == IE_NULL) || IE_BITS_TYPE(entry->ie_bits)); + return entry; +} + +/* + * Routine: ipc_entry_get + * Purpose: + * Tries to allocate an entry out of the space. + * Conditions: + * The space is write-locked and active throughout. + * An object may be locked. Will not allocate memory. + * Returns: + * KERN_SUCCESS A free entry was found. + * KERN_NO_SPACE No entry allocated. + */ + +static inline kern_return_t +ipc_entry_get( + ipc_space_t space, + mach_port_t *namep, + ipc_entry_t *entryp) +{ + mach_port_t new_name; + ipc_entry_t free_entry; + + assert(space->is_active); + + /* Get entry from the free list. */ + free_entry = space->is_free_list; + if (free_entry == IE_NULL) + return KERN_NO_SPACE; + + space->is_free_list = free_entry->ie_next_free; + space->is_free_list_size -= 1; + + /* + * Initialize the new entry. We need only + * increment the generation number and clear ie_request. + */ + + { + mach_port_gen_t gen; + + assert((free_entry->ie_bits &~ IE_BITS_GEN_MASK) == 0); + gen = free_entry->ie_bits + IE_BITS_GEN_ONE; + free_entry->ie_bits = gen; + free_entry->ie_request = 0; + new_name = MACH_PORT_MAKE(free_entry->ie_name, gen); + } + + /* + * The new name can't be MACH_PORT_NULL because index + * is non-zero. It can't be MACH_PORT_DEAD because + * the table isn't allowed to grow big enough. + * (See comment in ipc/ipc_table.h.) + */ + + assert(MACH_PORT_VALID(new_name)); + assert(free_entry->ie_object == IO_NULL); + + space->is_size += 1; + *namep = new_name; + *entryp = free_entry; + return KERN_SUCCESS; +} + +/* + * Routine: ipc_entry_dealloc + * Purpose: + * Deallocates an entry from a space. + * Conditions: + * The space must be write-locked throughout. + * The space must be active. + */ + +static inline void +ipc_entry_dealloc( + ipc_space_t space, + mach_port_t name, + ipc_entry_t entry) +{ + assert(space->is_active); + assert(entry->ie_object == IO_NULL); + assert(entry->ie_request == 0); + + if (space->is_free_list_size < IS_FREE_LIST_SIZE_LIMIT) { + space->is_free_list_size += 1; + entry->ie_bits &= IE_BITS_GEN_MASK; + entry->ie_next_free = space->is_free_list; + space->is_free_list = entry; + } else { + rdxtree_remove(&space->is_map, (rdxtree_key_t) name); + ie_free(entry); + } + space->is_size -= 1; +} + /* Reverse lookups. */ /* Cast a pointer to a suitable key. */ -- cgit v1.2.3 From e03567399f762998a4a0b4227adf86a38009c712 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Fri, 22 May 2015 19:25:41 +0200 Subject: ipc: drop size parameter from `ipc_space_create' * ipc/ipc_space.c (ipc_space_create): Drop size parameter. * ipc/ipc_space.h (ipc_space_create): Adopt declaration, fix comment. * kern/ipc_tt.c (ipc_task_init): Adopt accordingly. --- ipc/ipc_space.c | 1 - ipc/ipc_space.h | 11 +---------- kern/ipc_tt.c | 2 +- 3 files changed, 2 insertions(+), 12 deletions(-) diff --git a/ipc/ipc_space.c b/ipc/ipc_space.c index ea3cb3b2..894cf58e 100644 --- a/ipc/ipc_space.c +++ b/ipc/ipc_space.c @@ -99,7 +99,6 @@ struct ipc_entry zero_entry; kern_return_t ipc_space_create( - ipc_table_size_t initial, ipc_space_t *spacep) { ipc_space_t space; diff --git a/ipc/ipc_space.h b/ipc/ipc_space.h index 58fe47c4..bbfee46e 100644 --- a/ipc/ipc_space.h +++ b/ipc/ipc_space.h @@ -54,15 +54,6 @@ * Every task has a space of IPC capabilities. * IPC operations like send and receive use this space. * IPC kernel calls manipulate the space of the target task. - * - * Every space has a non-NULL is_table with is_table_size entries. - * A space may have a NULL is_tree. is_tree_small records the - * number of entries in the tree that, if the table were to grow - * to the next larger size, would move from the tree to the table. - * - * is_growing marks when the table is in the process of growing. - * When the table is growing, it can't be freed or grown by another - * thread, because of krealloc/kmem_realloc's requirements. */ typedef unsigned int ipc_space_refs_t; @@ -133,7 +124,7 @@ extern void ipc_space_release(struct ipc_space *space); #define is_reference(is) ipc_space_reference(is) #define is_release(is) ipc_space_release(is) -kern_return_t ipc_space_create(ipc_table_size_t, ipc_space_t *); +kern_return_t ipc_space_create(ipc_space_t *); kern_return_t ipc_space_create_special(struct ipc_space **); void ipc_space_destroy(struct ipc_space *); diff --git a/kern/ipc_tt.c b/kern/ipc_tt.c index 96737be8..e4d657b7 100644 --- a/kern/ipc_tt.c +++ b/kern/ipc_tt.c @@ -72,7 +72,7 @@ ipc_task_init( int i; - kr = ipc_space_create(&ipc_table_entries[0], &space); + kr = ipc_space_create(&space); if (kr != KERN_SUCCESS) panic("ipc_task_init"); -- cgit v1.2.3 From 2ca216d03ead0249bf9e33cbea2c0328637943ad Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Fri, 22 May 2015 19:36:07 +0200 Subject: ipc: drop remnants of the IPC tables * ipc/ipc_table.c (ipc_table_entries): Remove. (ipc_table_entries_size): Likewise. (ipc_table_init): Remove initialization of `ipc_table_entries'. (ipc_table_realloc): Remove function. * ipc/ipc_table.h: Adjust comments. (ipc_table_entries): Remove declaration. (ipc_table_realloc): Likewise. (it_entries_{alloc,reallocable,realloc,free}): Remove macros. --- ipc/ipc_table.c | 44 -------------------------------------------- ipc/ipc_table.h | 55 +++++-------------------------------------------------- 2 files changed, 5 insertions(+), 94 deletions(-) diff --git a/ipc/ipc_table.c b/ipc/ipc_table.c index 90960a8f..1a89d812 100644 --- a/ipc/ipc_table.c +++ b/ipc/ipc_table.c @@ -42,9 +42,6 @@ #include #include -ipc_table_size_t ipc_table_entries; -const unsigned int ipc_table_entries_size = 512; - ipc_table_size_t ipc_table_dnrequests; const unsigned int ipc_table_dnrequests_size = 64; @@ -92,20 +89,6 @@ ipc_table_fill( void ipc_table_init(void) { - ipc_table_entries = (ipc_table_size_t) - kalloc(sizeof(struct ipc_table_size) * - ipc_table_entries_size); - assert(ipc_table_entries != ITS_NULL); - - ipc_table_fill(ipc_table_entries, ipc_table_entries_size - 1, - 4, sizeof(struct ipc_entry)); - - /* the last two elements should have the same size */ - - ipc_table_entries[ipc_table_entries_size - 1].its_size = - ipc_table_entries[ipc_table_entries_size - 2].its_size; - - ipc_table_dnrequests = (ipc_table_size_t) kalloc(sizeof(struct ipc_table_size) * ipc_table_dnrequests_size); @@ -142,33 +125,6 @@ ipc_table_alloc( return table; } -/* - * Routine: ipc_table_realloc - * Purpose: - * Reallocate a big table. - * - * The new table remaps the old table, - * so copying is not necessary. - * Conditions: - * Only works for page-size or bigger tables. - * May block. - */ - -vm_offset_t -ipc_table_realloc( - vm_size_t old_size, - vm_offset_t old_table, - vm_size_t new_size) -{ - vm_offset_t new_table; - - if (kmem_realloc(kmem_map, old_table, old_size, - &new_table, new_size) != KERN_SUCCESS) - new_table = 0; - - return new_table; -} - /* * Routine: ipc_table_free * Purpose: diff --git a/ipc/ipc_table.h b/ipc/ipc_table.h index 311b9a78..7968e6bb 100644 --- a/ipc/ipc_table.h +++ b/ipc/ipc_table.h @@ -30,8 +30,8 @@ * Author: Rich Draves * Date: 1989 * - * Definitions for tables, used for IPC capabilities (ipc_entry_t) - * and dead-name requests (ipc_port_request_t). + * Definitions for tables, used for dead-name requests + * (ipc_port_request_t). */ #ifndef _IPC_IPC_TABLE_H_ @@ -41,23 +41,8 @@ #include /* - * The is_table_next field of an ipc_space_t points to - * an ipc_table_size structure. These structures must - * be elements of an array, ipc_table_entries. - * * Every its_size value must must be a power of two. * - * The array must end with two elements with the same its_size value. - * Except for the terminating element, the its_size values must - * be strictly increasing. The largest (last) its_size value - * must be less than or equal to MACH_PORT_INDEX(MACH_PORT_DEAD). - * This ensures that - * 1) MACH_PORT_INDEX(MACH_PORT_DEAD) isn't a valid index - * in the table, so ipc_entry_get won't allocate it. - * 2) MACH_PORT_MAKE(index+1, 0) and MAKE_PORT_MAKE(size, 0) - * won't ever overflow. - * - * * The ipr_size field of the first element in a table of * dead-name requests (ipc_port_request_t) points to the * ipc_table_size structure. The structures must be elements @@ -65,8 +50,6 @@ * with an element with zero its_size, and except for this last * element, the its_size values must be strictly increasing. * - * The is_table_next field points to the ipc_table_size structure - * for the next larger size of table, not the one currently in use. * The ipr_size field points to the currently used ipc_table_size. */ @@ -79,32 +62,21 @@ typedef struct ipc_table_size { #define ITS_NULL ((ipc_table_size_t) 0) -extern ipc_table_size_t ipc_table_entries; extern ipc_table_size_t ipc_table_dnrequests; extern void ipc_table_init(void); /* - * Note that ipc_table_alloc, ipc_table_realloc, and ipc_table_free - * all potentially use the VM system. Hence simple locks can't - * be held across them. - * - * We can't use a copying realloc, because the realloc happens - * with the data unlocked. ipc_table_realloc remaps the data, - * so it is OK. + * Note that ipc_table_alloc, and ipc_table_free all potentially + * use the VM system. Hence simple locks can't be held across + * them. */ /* Allocate a table */ extern vm_offset_t ipc_table_alloc( vm_size_t size); -/* Reallocate a big table */ -extern vm_offset_t ipc_table_realloc( - vm_size_t old_size, - vm_offset_t old_table, - vm_size_t new_size); - /* Free a table */ extern void ipc_table_free( vm_size_t size, @@ -116,23 +88,6 @@ void ipc_table_fill( unsigned int min, vm_size_t elemsize); -#define it_entries_alloc(its) \ - ((ipc_entry_t) \ - ipc_table_alloc((its)->its_size * sizeof(struct ipc_entry))) - -#define it_entries_reallocable(its) \ - (((its)->its_size * sizeof(struct ipc_entry)) >= PAGE_SIZE) - -#define it_entries_realloc(its, table, nits) \ - ((ipc_entry_t) \ - ipc_table_realloc((its)->its_size * sizeof(struct ipc_entry), \ - (vm_offset_t)(table), \ - (nits)->its_size * sizeof(struct ipc_entry))) - -#define it_entries_free(its, table) \ - ipc_table_free((its)->its_size * sizeof(struct ipc_entry), \ - (vm_offset_t)(table)) - #define it_dnrequests_alloc(its) \ ((ipc_port_request_t) \ ipc_table_alloc((its)->its_size * \ -- cgit v1.2.3 From 9c6db49cc8bb097b4bf2c6a6ad331bcb58f0eca7 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sat, 23 May 2015 16:35:14 +0530 Subject: Add stdint integer types in Linux glue * linux/dev/include/linux/types.h (int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t, int64_t, uint64_t): New types. --- linux/dev/include/linux/types.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/linux/dev/include/linux/types.h b/linux/dev/include/linux/types.h index 57bb25f4..b697d9ec 100644 --- a/linux/dev/include/linux/types.h +++ b/linux/dev/include/linux/types.h @@ -109,6 +109,15 @@ struct ustat { char f_fpack[6]; }; +/* stdint.h */ +typedef s8 int8_t; +typedef u8 uint8_t; +typedef s16 int16_t; +typedef u16 uint16_t; +typedef s32 int32_t; +typedef u32 uint32_t; +typedef s64 int64_t; +typedef u64 uint64_t; /* Yes, this is ugly. But that's why it is called glue code. */ -- cgit v1.2.3 From 417ca3833d651a89dc55462739f9dbb9f7af7866 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Sat, 23 May 2015 07:31:17 +0200 Subject: vm: drop unused `kmem_realloc' * vm/vm_kern.c (kmem_realloc): Remove function. (kmem_alloc_wired): Adopt comment. * vm/vm_kern.h (kmem_realloc): Remove declaration. --- vm/vm_kern.c | 102 +---------------------------------------------------------- vm/vm_kern.h | 2 -- 2 files changed, 1 insertion(+), 103 deletions(-) diff --git a/vm/vm_kern.c b/vm/vm_kern.c index b997cb58..ab1ddac6 100644 --- a/vm/vm_kern.c +++ b/vm/vm_kern.c @@ -430,105 +430,6 @@ retry: return KERN_SUCCESS; } -/* - * kmem_realloc: - * - * Reallocate wired-down memory in the kernel's address map - * or a submap. Newly allocated pages are not zeroed. - * This can only be used on regions allocated with kmem_alloc. - * - * If successful, the pages in the old region are mapped twice. - * The old region is unchanged. Use kmem_free to get rid of it. - */ -kern_return_t kmem_realloc( - vm_map_t map, - vm_offset_t oldaddr, - vm_size_t oldsize, - vm_offset_t *newaddrp, - vm_size_t newsize) -{ - vm_offset_t oldmin, oldmax; - vm_offset_t newaddr; - vm_object_t object; - vm_map_entry_t oldentry, newentry; - unsigned int attempts; - kern_return_t kr; - - oldmin = trunc_page(oldaddr); - oldmax = round_page(oldaddr + oldsize); - oldsize = oldmax - oldmin; - newsize = round_page(newsize); - - /* - * Find space for the new region. - */ - - attempts = 0; - -retry: - vm_map_lock(map); - kr = vm_map_find_entry(map, &newaddr, newsize, (vm_offset_t) 0, - VM_OBJECT_NULL, &newentry); - if (kr != KERN_SUCCESS) { - vm_map_unlock(map); - - if (attempts == 0) { - attempts++; - slab_collect(); - goto retry; - } - - printf_once("no more room for kmem_realloc in %p\n", map); - return kr; - } - - /* - * Find the VM object backing the old region. - */ - - if (!vm_map_lookup_entry(map, oldmin, &oldentry)) - panic("kmem_realloc"); - object = oldentry->object.vm_object; - - /* - * Increase the size of the object and - * fill in the new region. - */ - - vm_object_reference(object); - vm_object_lock(object); - if (object->size != oldsize) - panic("kmem_realloc"); - object->size = newsize; - vm_object_unlock(object); - - newentry->object.vm_object = object; - newentry->offset = 0; - - /* - * Since we have not given out this address yet, - * it is safe to unlock the map. We are trusting - * that nobody will play with either region. - */ - - vm_map_unlock(map); - - /* - * Remap the pages in the old region and - * allocate more pages for the new region. - */ - - kmem_remap_pages(object, 0, - newaddr, newaddr + oldsize, - VM_PROT_DEFAULT); - kmem_alloc_pages(object, oldsize, - newaddr + oldsize, newaddr + newsize, - VM_PROT_DEFAULT); - - *newaddrp = newaddr; - return KERN_SUCCESS; -} - /* * kmem_alloc_wired: * @@ -536,8 +437,7 @@ retry: * or a submap. The memory is not zero-filled. * * The memory is allocated in the kernel_object. - * It may not be copied with vm_map_copy, and - * it may not be reallocated with kmem_realloc. + * It may not be copied with vm_map_copy. */ kern_return_t diff --git a/vm/vm_kern.h b/vm/vm_kern.h index 0869217a..fb8ac7f8 100644 --- a/vm/vm_kern.h +++ b/vm/vm_kern.h @@ -54,8 +54,6 @@ extern kern_return_t kmem_alloc_pageable(vm_map_t, vm_offset_t *, vm_size_t); extern kern_return_t kmem_alloc_wired(vm_map_t, vm_offset_t *, vm_size_t); extern kern_return_t kmem_alloc_aligned(vm_map_t, vm_offset_t *, vm_size_t); -extern kern_return_t kmem_realloc(vm_map_t, vm_offset_t, vm_size_t, - vm_offset_t *, vm_size_t); extern void kmem_free(vm_map_t, vm_offset_t, vm_size_t); extern void kmem_submap(vm_map_t, vm_map_t, vm_offset_t *, -- cgit v1.2.3 From 96ade86f9f410cee6377f60530bcc3aa89b20402 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Sat, 23 May 2015 18:23:45 +0200 Subject: kern: avoid breaking the strict-aliasing rules * kern/exception.c (exception_parse_reply): Use `BAD_TYPECHECK'. --- kern/exception.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/kern/exception.c b/kern/exception.c index 6e84c0a5..6cb3bfbf 100644 --- a/kern/exception.c +++ b/kern/exception.c @@ -48,6 +48,7 @@ #include #include #include +#include #include #if MACH_KDB @@ -754,6 +755,12 @@ exception_raise( } } +/* Macro used by MIG to cleanly check the type. */ +#define BAD_TYPECHECK(type, check) unlikely (({\ + union { mach_msg_type_t t; unsigned32_t w; } _t, _c;\ + _t.t = *(type); _c.t = *(check);_t.w != _c.w; })) + +/* Type descriptor for the return code. */ mach_msg_type_t exc_RetCode_proto = { /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, /* msgt_size = */ 32, @@ -786,7 +793,7 @@ exception_parse_reply(ipc_kmsg_t kmsg) MACH_MSGH_BITS(MACH_MSG_TYPE_PORT_SEND_ONCE, 0)) || (msg->Head.msgh_size != sizeof *msg) || (msg->Head.msgh_id != MACH_EXCEPTION_REPLY_ID) || - (* (int *) &msg->RetCodeType != * (int *) &exc_RetCode_proto)) { + (BAD_TYPECHECK(&msg->RetCodeType, &exc_RetCode_proto))) { /* * Bozo user sent us a misformatted reply. */ -- cgit v1.2.3 From 6af2316771841cd4d2770fae00d3d147aa11a5d9 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Sat, 23 May 2015 18:51:56 +0200 Subject: i386: avoid breaking the strict-aliasing rules * i386/i386/pcb.c (switch_ktss): Cleanly convert the value. --- i386/i386/pcb.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/i386/i386/pcb.c b/i386/i386/pcb.c index dabe4814..3a0eba0f 100644 --- a/i386/i386/pcb.c +++ b/i386/i386/pcb.c @@ -193,8 +193,14 @@ void switch_ktss(pcb_t pcb) for (i=0; i < USER_GDT_SLOTS; i++) { if (memcmp(gdt_desc_p (mycpu, USER_GDT + (i << 3)), &pcb->ims.user_gdt[i], sizeof pcb->ims.user_gdt[i])) { + union { + struct real_descriptor real_descriptor; + uint64_t descriptor; + } user_gdt; + user_gdt.real_descriptor = pcb->ims.user_gdt[i]; + if (hyp_do_update_descriptor(kv_to_ma(gdt_desc_p (mycpu, USER_GDT + (i << 3))), - *(uint64_t *) &pcb->ims.user_gdt[i])) + user_gdt.descriptor)) panic("couldn't set user gdt %d\n",i); } } -- cgit v1.2.3 From b2b8bf37934087f8fb2a246316ecf9e91955ec57 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Sat, 23 May 2015 19:06:10 +0200 Subject: Restrict `-fno-strict-aliasing' to the Linux drivers * Makefile.am: Move `-fno-strict-aliasing'... * linux/Makefrag.am: ... here. --- Makefile.am | 4 ---- linux/Makefrag.am | 5 +++++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Makefile.am b/Makefile.am index eb940cbb..913db55e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -59,10 +59,6 @@ AM_CFLAGS += \ AM_CFLAGS += \ -Wall -# See . -AM_CFLAGS += \ - -fno-strict-aliasing - # We need the GNU-style inline AM_CFLAGS += \ -fgnu89-inline diff --git a/linux/Makefrag.am b/linux/Makefrag.am index 0973f11c..1b690108 100644 --- a/linux/Makefrag.am +++ b/linux/Makefrag.am @@ -36,6 +36,11 @@ liblinux_a_CPPFLAGS = $(AM_CPPFLAGS) \ # Because of the use of `extern inline' in some Linux header files without # corresponding text segment definitions, we must always optimize. liblinux_a_CFLAGS = -O2 $(AM_CFLAGS) + +# See . +liblinux_a_CFLAGS += \ + -fno-strict-aliasing + # TODO. Do we really need `-traditional'? liblinux_a_CCASFLAGS = $(AM_CCASFLAGS) \ -D__ASSEMBLY__ -traditional \ -- cgit v1.2.3 From 99a43d36c83d318f24edd8c6d80f060686a6c398 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Fri, 29 May 2015 14:44:39 +0200 Subject: kern: fix argument handling Previously, the processor argument was not checked. If called with a non-processor argument (like a task), `processor' is set to NULL, triggering a page fault. Likewise for the other functions. * kern/processor.c (processor_get_assignment): Fix argument handling. * kern/task.c (task_get_assignment): Likewise. * kern/thread.c (thread_get_assignment): Likewise. --- kern/processor.c | 2 ++ kern/task.c | 3 +++ kern/thread.c | 3 +++ 3 files changed, 8 insertions(+) diff --git a/kern/processor.c b/kern/processor.c index 865c3247..48e92731 100644 --- a/kern/processor.c +++ b/kern/processor.c @@ -657,6 +657,8 @@ processor_get_assignment( processor_set_t *pset) { int state; + if (processor == PROCESSOR_NULL) + return KERN_INVALID_ARGUMENT; state = processor->state; if (state == PROCESSOR_SHUTDOWN || state == PROCESSOR_OFF_LINE) diff --git a/kern/task.c b/kern/task.c index dcd53712..b384347f 100644 --- a/kern/task.c +++ b/kern/task.c @@ -1063,6 +1063,9 @@ kern_return_t task_get_assignment( task_t task, processor_set_t *pset) { + if (task == TASK_NULL) + return KERN_INVALID_ARGUMENT; + if (!task->active) return KERN_FAILURE; diff --git a/kern/thread.c b/kern/thread.c index f52c95b8..8b1e9f58 100644 --- a/kern/thread.c +++ b/kern/thread.c @@ -1974,6 +1974,9 @@ kern_return_t thread_get_assignment( thread_t thread, processor_set_t *pset) { + if (thread == THREAD_NULL) + return KERN_INVALID_ARGUMENT; + *pset = thread->processor_set; pset_reference(*pset); return KERN_SUCCESS; -- cgit v1.2.3 From 255c47e669819f153c722c98a230f6fe4e6ece08 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Sun, 25 May 2014 16:26:42 +0200 Subject: Include the notify protocol in `gnumach.msgids' * Makefrag.am (gnumach.msgids): Add `notify.msgids' as prerequisite. * Makerules.mig.am: Add rule to generate the list of message ids when neither the client nor the server stubs are required. * ipc/notify.defs: New file. --- Makefrag.am | 3 ++- Makerules.mig.am | 10 ++++++++++ ipc/notify.defs | 22 ++++++++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 ipc/notify.defs diff --git a/Makefrag.am b/Makefrag.am index 023a4d1d..0e4a9173 100644 --- a/Makefrag.am +++ b/Makefrag.am @@ -547,7 +547,8 @@ nodist_libkernel_a_SOURCES += \ # rpctrace can make use of that. MOSTLYCLEANFILES += \ gnumach.msgids -gnumach.msgids: $(filter %.msgids,$(nodist_libkernel_a_SOURCES)) +gnumach.msgids: $(filter %.msgids,$(nodist_libkernel_a_SOURCES)) \ + ipc/notify.msgids $(AM_V_at) cat $^ > $@.new $(AM_V_GEN) mv $@.new $@ # `exec_' prefix, so that we don't try to build that file during when running diff --git a/Makerules.mig.am b/Makerules.mig.am index 30609846..085b247a 100644 --- a/Makerules.mig.am +++ b/Makerules.mig.am @@ -88,6 +88,16 @@ lib_dep_tr_for_defs_a_CPPFLAGS = $(AM_CPPFLAGS) \ -list $*.user.msgids \ < $< +vpath %.defs $(top_srcdir) + +# Stand-alone rule to generate the list of message ids when neither +# the client nor the server stubs are required. +%.msgids: %.defs + $(MIGCOM_V) $(CPP) $(AM_CPPFLAGS) $(CPPFLAGS) -E $< \ + | $(MIGCOM) $(MIGCOMFLAGS) $(MIGCOMSFLAGS) \ + -sheader /dev/null -server /dev/null \ + -list "$*.msgids" + # This is how it should be done, but this is not integrated into GNU Automake # and is missing automatic inter-file dependency management because of that. diff --git a/ipc/notify.defs b/ipc/notify.defs new file mode 100644 index 00000000..d34eb9c6 --- /dev/null +++ b/ipc/notify.defs @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2015 Free Software Foundation. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* We use custom functions to send notifications. This functions can + be found in `ipc_notify.c'. We use this file merely to produce the + list of message ids. */ + +#include -- cgit v1.2.3 From 0d44362ce83ed75ea0bd0d24a5461c93561e8b11 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Sun, 31 May 2015 18:02:55 +0200 Subject: ipc: fix typo * ipc/notify.defs: Fix typo. --- ipc/notify.defs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ipc/notify.defs b/ipc/notify.defs index d34eb9c6..db059b8d 100644 --- a/ipc/notify.defs +++ b/ipc/notify.defs @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -/* We use custom functions to send notifications. This functions can +/* We use custom functions to send notifications. These functions can be found in `ipc_notify.c'. We use this file merely to produce the list of message ids. */ -- cgit v1.2.3 From d48d85e729f6d7651e276b83ac01d40e467936b8 Mon Sep 17 00:00:00 2001 From: Flávio Cruz Date: Fri, 5 Jun 2015 11:56:20 +0530 Subject: Use custom port macros. * ipc/ipc_port.c (ipc_port_alloc_special): Use ip_alloc and ip_lock_init macros instead of manually inlining them. --- ipc/ipc_port.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ipc/ipc_port.c b/ipc/ipc_port.c index 89a5d673..86a4ee2a 100644 --- a/ipc/ipc_port.c +++ b/ipc/ipc_port.c @@ -1178,11 +1178,11 @@ ipc_port_alloc_special(ipc_space_t space) { ipc_port_t port; - port = (ipc_port_t) io_alloc(IOT_PORT); + port = ip_alloc(); if (port == IP_NULL) return IP_NULL; - io_lock_init(&port->ip_object); + ip_lock_init(port); port->ip_references = 1; port->ip_object.io_bits = io_makebits(TRUE, IOT_PORT, 0); -- cgit v1.2.3 From 1b8b9c142fb8735ca5a5806ce92ac2e327131f6d Mon Sep 17 00:00:00 2001 From: Flávio Cruz Date: Fri, 5 Jun 2015 11:58:08 +0530 Subject: Fix typo * vm/vm_kern.c (kmem_alloc_aligned): Fix typo. --- vm/vm_kern.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vm/vm_kern.c b/vm/vm_kern.c index ab1ddac6..775d8e8c 100644 --- a/vm/vm_kern.c +++ b/vm/vm_kern.c @@ -561,7 +561,7 @@ retry: goto retry; } - printf_once("no more rooom for kmem_alloc_aligned in %p\n", map); + printf_once("no more room for kmem_alloc_aligned in %p\n", map); return kr; } -- cgit v1.2.3 From 064cee5a224129d200a4a32a27e2ba8114a2b564 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Wed, 20 May 2015 10:28:12 +0200 Subject: kern: add function attributes to the printf-functions * kern/printf.h (sprintf, snprintf, vsnprintf, printf): Add the `printf' function attribute that allows the compiler to check the format strings and arguments. --- kern/printf.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/kern/printf.h b/kern/printf.h index 0f8b3281..86857d33 100644 --- a/kern/printf.h +++ b/kern/printf.h @@ -39,11 +39,16 @@ extern void printnum (unsigned long u, int base, void (*putc)(char, vm_offset_t), 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 sprintf (char *buf, const char *fmt, ...) + __attribute__ ((format (printf, 2, 3))); +extern int snprintf (char *buf, size_t size, const char *fmt, ...) + __attribute__ ((format (printf, 3, 4))); +extern int vsnprintf (char *buf, size_t size, const char *fmt, va_list args) + __attribute__ ((format (printf, 3, 0))); -extern int printf (const char *fmt, ...); + +extern int printf (const char *fmt, ...) + __attribute__ ((format (printf, 1, 2))); #define printf_once(fmt, ...) \ MACRO_BEGIN \ -- cgit v1.2.3 From 4d5b3fc228780ef2ad2e4758afe56740cc59e82d Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Thu, 18 Jun 2015 13:45:01 +0200 Subject: kern: fix error handling This avoids calling `thread_deallocate' with an uninitialized value, as found by the Clang Static Analyzer. * kern/thread.c (kernel_thread): Fix error handling. --- kern/thread.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kern/thread.c b/kern/thread.c index 8b1e9f58..1f47553f 100644 --- a/kern/thread.c +++ b/kern/thread.c @@ -1667,9 +1667,13 @@ thread_t kernel_thread( continuation_t start, void * arg) { + kern_return_t kr; thread_t thread; - (void) thread_create(task, &thread); + kr = thread_create(task, &thread); + if (kr != KERN_SUCCESS) + return THREAD_NULL; + /* release "extra" ref that thread_create gave us */ thread_deallocate(thread); thread_start(thread, start); -- cgit v1.2.3 From fa5e2ae5645b3eb005931f60b5481ee7e478640e Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Fri, 26 Jun 2015 12:55:41 +0200 Subject: i386: add comment * i386/i386at/model_dep.c (rebootflag): Explain flag. --- i386/i386at/model_dep.c | 1 + 1 file changed, 1 insertion(+) diff --git a/i386/i386at/model_dep.c b/i386/i386at/model_dep.c index bc34c9b0..03a9f15d 100644 --- a/i386/i386at/model_dep.c +++ b/i386/i386at/model_dep.c @@ -137,6 +137,7 @@ static vm_size_t avail_remaining; extern char version[]; +/* If set, reboot the system on ctrl-alt-delete. */ boolean_t rebootflag = FALSE; /* exported to kdintr */ /* XX interrupt stack pointer and highwater mark, for locore.S. */ -- cgit v1.2.3 From 4b9758c8ec6103c26228e1cda9731ab8bf1113e9 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Tue, 25 Mar 2014 22:25:44 +0100 Subject: i386: improve the immediate console Improve the immediate console to the point that it can be enabled and display e.g. assertion failures from very early on (i.e. from `c_boot_entry'). * device/cons.h (romgetc, romputc): New declarations. * i386/configfrag.ac: Add configuration variable. * i386/i386at/conf.c (dev_name_list): Add entry. * i386/i386at/cons_conf.c (constab): Add entry. * i386/i386at/immc.c: Add missing includes. (immc_cnprobe, immc_cninit, immc_cngetc, immc_romputc): New functions. (immc_cnputc): Fix signature, use virtual addresses. * i386/i386at/immc.h: New file. * i386/i386at/kd.c: Use `#if ENABLE_IMMEDIATE_CONSOLE'. * i386/i386at/kd.h (kd_setpos): Add missing declaration. * i386/i386at/model_dep.c (c_boot_entry): Install immediate console as early boot console. --- device/cons.h | 11 ++++++++ i386/configfrag.ac | 4 +++ i386/i386at/conf.c | 6 ++++ i386/i386at/cons_conf.c | 7 +++++ i386/i386at/immc.c | 74 ++++++++++++++++++++++++++++++++++++++++--------- i386/i386at/immc.h | 31 +++++++++++++++++++++ i386/i386at/kd.c | 2 +- i386/i386at/kd.h | 1 + i386/i386at/model_dep.c | 8 ++++++ 9 files changed, 130 insertions(+), 14 deletions(-) create mode 100644 i386/i386at/immc.h diff --git a/device/cons.h b/device/cons.h index 8ac796cd..34f3bc56 100644 --- a/device/cons.h +++ b/device/cons.h @@ -54,4 +54,15 @@ extern int cngetc(void); extern int cnmaygetc(void); extern void cnputc(char); + +/* + * ROM getc/putc primitives. + * On some architectures, the boot ROM provides basic character input/output + * routines that can be used before devices are configured or virtual memory + * is enabled. This can be useful to debug (or catch panics from) code early + * in the bootstrap procedure. + */ +extern int (*romgetc)(char c); +extern void (*romputc)(char c); + #endif /* _DEVICE_CONS_H */ diff --git a/i386/configfrag.ac b/i386/configfrag.ac index 1eaabcad..48744b12 100644 --- a/i386/configfrag.ac +++ b/i386/configfrag.ac @@ -73,6 +73,10 @@ AC_DEFINE_UNQUOTED([NLPR], [$nlpr], [NLPR]) # Options. # +# The immediate console, useful for debugging early system +# initialization. Disabled by default. +AC_DEFINE([ENABLE_IMMEDIATE_CONSOLE], [0], [ENABLE_IMMEDIATE_CONSOLE]) + AC_ARG_ENABLE([lpr], AS_HELP_STRING([--enable-lpr], [lpr device; on ix86-at enabled by default])) [case $host_platform:$host_cpu in diff --git a/i386/i386at/conf.c b/i386/i386at/conf.c index ab4f6807..fe7c7c09 100644 --- a/i386/i386at/conf.c +++ b/i386/i386at/conf.c @@ -87,6 +87,12 @@ struct dev_ops dev_name_list[] = nodev }, #ifndef MACH_HYP +#if ENABLE_IMMEDIATE_CONSOLE + { "immc", nulldev_open, nulldev_close, nulldev_read, + nulldev_write, nulldev_getstat, nulldev_setstat, + nomap, nodev, nulldev, nulldev_portdeath, 0, + nodev }, +#endif /* ENABLE_IMMEDIATE_CONSOLE */ { kdname, kdopen, kdclose, kdread, kdwrite, kdgetstat, kdsetstat, kdmmap, nodev, nulldev, kdportdeath, 0, diff --git a/i386/i386at/cons_conf.c b/i386/i386at/cons_conf.c index cf42bb63..1d7dd387 100644 --- a/i386/i386at/cons_conf.c +++ b/i386/i386at/cons_conf.c @@ -39,6 +39,10 @@ #endif #endif /* MACH_HYP */ +#if ENABLE_IMMEDIATE_CONSOLE +#include "immc.h" +#endif /* ENABLE_IMMEDIATE_CONSOLE */ + /* * The rest of the consdev fields are filled in by the respective * cnprobe routine. @@ -47,6 +51,9 @@ struct consdev constab[] = { #ifdef MACH_HYP {"hyp", hypcnprobe, hypcninit, hypcngetc, hypcnputc}, #else /* MACH_HYP */ +#if ENABLE_IMMEDIATE_CONSOLE + {"immc", immc_cnprobe, immc_cninit, immc_cngetc, immc_cnputc}, +#endif /* ENABLE_IMMEDIATE_CONSOLE */ {"kd", kdcnprobe, kdcninit, kdcngetc, kdcnputc}, #if NCOM > 0 {"com", comcnprobe, comcninit, comcngetc, comcnputc}, diff --git a/i386/i386at/immc.c b/i386/i386at/immc.c index e0837f2c..ea951690 100644 --- a/i386/i386at/immc.c +++ b/i386/i386at/immc.c @@ -21,8 +21,11 @@ * Author: Bryan Ford, University of Utah CSL */ -#ifdef ENABLE_IMMEDIATE_CONSOLE +#if ENABLE_IMMEDIATE_CONSOLE +#include +#include +#include #include /* This is a special "feature" (read: kludge) @@ -35,22 +38,65 @@ boolean_t immediate_console_enable = TRUE; -void -immc_cnputc(unsigned char c) +/* + * XXX we assume that pcs *always* have a console + */ +int +immc_cnprobe(struct consdev *cp) +{ + int maj, unit, pri; + + maj = 0; + unit = 0; + pri = CN_INTERNAL; + + cp->cn_dev = makedev(maj, unit); + cp->cn_pri = pri; + return 0; +} + +int +immc_cninit(struct consdev *cp) +{ + return 0; +} + +int immc_cnmaygetc(void) +{ + return -1; +} + +int +immc_cngetc(dev_t dev, int wait) +{ + if (wait) { + int c; + while ((c = immc_cnmaygetc()) < 0) + continue; + return c; + } + else + return immc_cnmaygetc(); +} + +int +immc_cnputc(dev_t dev, int c) { static int ofs = -1; if (!immediate_console_enable) - return; + return -1; if (ofs < 0) { ofs = 0; - immc_cnputc('\n'); + immc_cnputc(dev, '\n'); } - else if (c == '\n') + + if (c == '\n') { - memmove((void *)0xb8000, (void *)0xb8000+80*2, 80*2*24); - memset((void *)(0xb8000+80*2*24), 0, 80*2); + memmove((void *) phystokv(0xb8000), + (void *) phystokv(0xb8000+80*2), 80*2*24); + memset((void *) phystokv((0xb8000+80*2*24)), 0, 80*2); ofs = 0; } else @@ -59,20 +105,22 @@ immc_cnputc(unsigned char c) if (ofs >= 80) { - immc_cnputc('\r'); - immc_cnputc('\n'); + immc_cnputc(dev, '\r'); + immc_cnputc(dev, '\n'); } - p = (void*)0xb8000 + 80*2*24 + ofs*2; + p = (void *) phystokv(0xb8000 + 80*2*24 + ofs*2); p[0] = c; p[1] = 0x0f; ofs++; } + return 0; } -int immc_cnmaygetc(void) +void +immc_romputc(char c) { - return -1; + immc_cnputc (0, c); } #endif /* ENABLE_IMMEDIATE_CONSOLE */ diff --git a/i386/i386at/immc.h b/i386/i386at/immc.h new file mode 100644 index 00000000..dc802c84 --- /dev/null +++ b/i386/i386at/immc.h @@ -0,0 +1,31 @@ +/* Declarations for the immediate console. + + Copyright (C) 2015 Free Software Foundation, Inc. + + This file is part of the GNU Mach. + + The GNU Mach is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + The GNU Mach is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with the GNU Mach. If not, see . */ + +#ifndef _IMMC_H_ +#define _IMMC_H_ + +#include + +int immc_cnprobe(struct consdev *cp); +int immc_cninit(struct consdev *cp); +int immc_cngetc(dev_t dev, int wait); +int immc_cnputc(dev_t dev, int c); +void immc_romputc(char c); + +#endif /* _IMMC_H_ */ diff --git a/i386/i386at/kd.c b/i386/i386at/kd.c index bbb00239..5656e830 100644 --- a/i386/i386at/kd.c +++ b/i386/i386at/kd.c @@ -1162,7 +1162,7 @@ kdinit(void) kd_senddata(k_comm); kd_initialized = TRUE; -#ifdef ENABLE_IMMEDIATE_CONSOLE +#if ENABLE_IMMEDIATE_CONSOLE /* Now that we're set up, we no longer need or want the immediate console. */ { diff --git a/i386/i386at/kd.h b/i386/i386at/kd.h index 4ac93c7b..0cfed695 100644 --- a/i386/i386at/kd.h +++ b/i386/i386at/kd.h @@ -740,6 +740,7 @@ extern int kdcninit(struct consdev *cp); extern int kdcngetc(dev_t dev, int wait); extern int kdcnmaygetc (void); extern int kdcnputc(dev_t dev, int c); +extern void kd_setpos(csrpos_t newpos); extern void kd_slmwd (void *start, int count, int value); extern void kd_slmscu (void *from, void *to, int count); diff --git a/i386/i386at/model_dep.c b/i386/i386at/model_dep.c index 03a9f15d..fdf983b9 100644 --- a/i386/i386at/model_dep.c +++ b/i386/i386at/model_dep.c @@ -77,6 +77,10 @@ #include #endif /* MACH_XEN */ +#if ENABLE_IMMEDIATE_CONSOLE +#include "immc.h" +#endif /* ENABLE_IMMEDIATE_CONSOLE */ + /* Location of the kernel's symbol table. Both of these are 0 if none is available. */ #if MACH_KDB @@ -541,6 +545,10 @@ i386at_init(void) */ void c_boot_entry(vm_offset_t bi) { +#if ENABLE_IMMEDIATE_CONSOLE + romputc = immc_romputc; +#endif /* ENABLE_IMMEDIATE_CONSOLE */ + /* Stash the boot_image_info pointer. */ boot_info = *(typeof(boot_info)*)phystokv(bi); int cpu_type; -- cgit v1.2.3 From 3007bbdba1283f03fb64c15fe8145090382c1f95 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Fri, 26 Jun 2015 14:44:32 +0200 Subject: ddb: automatically display stack traces * ddb/db_trap.c (db_task_trap): Automatically display stack traces if an unexpected trap occurs. --- ddb/db_trap.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ddb/db_trap.c b/ddb/db_trap.c index b56ffdcc..7e107319 100644 --- a/ddb/db_trap.c +++ b/ddb/db_trap.c @@ -44,6 +44,7 @@ #include #include #include +#include extern jmp_buf_t *db_recover; @@ -88,6 +89,9 @@ db_task_trap( db_print_loc_and_inst(db_dot, task_space); else db_printf("Trouble printing location %#X.\n", db_dot); + + if (!bkpt && !watchpt && _setjmp(db_recover = &db_jmpbuf) == 0) + db_stack_trace_cmd(0, 0, -1, ""); db_recover = prev; db_command_loop(); -- cgit v1.2.3 From 9df8dabddf63500e478ec449d022881643255cf2 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Mon, 29 Jun 2015 22:38:17 +0200 Subject: Print about powered-down AHCI ports * linux/dev/drivers/block/ahci.c (ahci_probe_dev): Print messages when device is present but powered down. --- linux/dev/drivers/block/ahci.c | 46 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/linux/dev/drivers/block/ahci.c b/linux/dev/drivers/block/ahci.c index 868f8d01..58105a70 100644 --- a/linux/dev/drivers/block/ahci.c +++ b/linux/dev/drivers/block/ahci.c @@ -877,6 +877,7 @@ static void ahci_probe_dev(unsigned char bus, unsigned char device) for (i = 0; i < AHCI_MAX_PORTS; i++) { u32 ssts; + u8 spd, ipm; if (!(port_map & (1U << i))) continue; @@ -884,12 +885,45 @@ static void ahci_probe_dev(unsigned char bus, unsigned char device) ahci_port = &ahci_host->ports[i]; ssts = readl(&ahci_port->ssts); - if ((ssts & 0xf) != 0x3) - /* Device not present */ - continue; - if (((ssts >> 8) & 0xf) != 0x1) - /* Device down */ - continue; + spd = ssts & 0xf; + switch (spd) + { + case 0x0: + /* Device not present */ + continue; + case 0x1: + printk("ahci: %02u:%02u.%u: Port %u communication not established. TODO: power on device\n", bus, dev, fun, i); + continue; + case 0x3: + /* Present and communication established */ + break; + case 0x4: + printk("ahci: %02u:%02u.%u: Phy offline?!\n", bus, dev, fun, i); + continue; + default: + printk("ahci: %02u:%02u.%u: Unknown port %u SPD %x\n", bus, dev, fun, i, spd); + continue; + } + + ipm = (ssts >> 8) & 0xf; + switch (ipm) + { + case 0x0: + /* Device not present */ + continue; + case 0x1: + /* Active */ + break; + case 0x2: + printk("ahci: %02u:%02u.%u: Port %u in Partial power management. TODO: power on device\n", bus, dev, fun, i); + continue; + case 0x6: + printk("ahci: %02u:%02u.%u: Port %u in Slumber power management. TODO: power on device\n", bus, dev, fun, i); + continue; + default: + printk("ahci: %02u:%02u.%u: Unknown port %u IPM %x\n", bus, dev, fun, i, ipm); + continue; + } /* OK! Probe this port */ ahci_probe_port(ahci_host, ahci_port); -- cgit v1.2.3 From a6b89d0dadce72ddf0e029999b968d611225d87f Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Tue, 30 Jun 2015 00:30:26 +0200 Subject: Fix restoring interrupts on timeout * linux/dev/drivers/block/ahci.c (ahci_identify): Restore flags before returning on timeout. --- linux/dev/drivers/block/ahci.c | 1 + 1 file changed, 1 insertion(+) diff --git a/linux/dev/drivers/block/ahci.c b/linux/dev/drivers/block/ahci.c index 58105a70..9bb2e6b4 100644 --- a/linux/dev/drivers/block/ahci.c +++ b/linux/dev/drivers/block/ahci.c @@ -638,6 +638,7 @@ static int ahci_identify(const volatile struct ahci_host *ahci_host, const volat port->ahci_host = NULL; port->ahci_port = NULL; del_timer(&identify_timer); + restore_flags(flags); return 3; } sleep_on(&port->q); -- cgit v1.2.3 From cf81d409818bd07b222af9faeb250de844da6236 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Tue, 30 Jun 2015 15:32:17 +0200 Subject: Fix re-configuring out-of-tree builds Previously, running `../configure ...' to reconfigure an out-of-tree build would link `machine' to `i386/i386' instead of `../i386/i386' (i.e. point to the build directory instead to the source) if `i386/i386' also exists in the build directory because of a previous build. * configfrag.ac: Prefix machine link target with `$srcdir'. --- configfrag.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configfrag.ac b/configfrag.ac index 5f13b63c..5df6239d 100644 --- a/configfrag.ac +++ b/configfrag.ac @@ -142,7 +142,7 @@ AC_ARG_ENABLE([kmsg], # `${file}' and `$file' have different meanings here with respect to having the # files in the referenced directory considered for `make dist' or not. See # . -AC_CONFIG_LINKS([machine:$systype/$systype +AC_CONFIG_LINKS([machine:$srcdir/$systype/$systype mach/machine:$systype/include/mach/$systype]) dnl Local Variables: -- cgit v1.2.3 From ba76c46181ca2bcbdf99bca0e2c23cc9e484de0d Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 5 Jul 2015 00:40:14 +0200 Subject: Add missing distributed file * Makefrag.am (EXTRA_DIST): Add ipc/notify.defs. --- Makefrag.am | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefrag.am b/Makefrag.am index 0e4a9173..b9d96c5d 100644 --- a/Makefrag.am +++ b/Makefrag.am @@ -118,7 +118,8 @@ libkernel_a_SOURCES += \ ipc/mach_debug.c \ ipc/port.h EXTRA_DIST += \ - ipc/mach_port.srv + ipc/mach_port.srv \ + ipc/notify.defs # -- cgit v1.2.3 From 1e0429e5f39ec219cbef3af2752528b8a29bc1be Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Tue, 7 Jul 2015 17:44:41 +0200 Subject: Fix build with -O0 * linux/src/include/linux/string.h (strcpy, strncpy, strcat, strncat, strchr, strrchr, strlen, strnlen, strcmp, strncmp, memmove, memscan): Comment out extern declarations. * linux/dev/include/asm-i386/string.h (strcpy, strncpy, strcat, strncat, strcmp, strncmp, strchr, strrchr, strlen, __memcpy, __constant_memcpy, memmove, memchr, __memset_generic, __constant_c_memset, strnlen, __constant_c_and_count_memset, memscan): Turn extern inline into static inline. * linux/dev/include/linux/fs.h (mark_buffer_uptodate): Likewise. * linux/src/include/asm-i386/bitops.h (set_bit, clear_bit, change_bit, test_and_set_bit, test_and_clear_bit, test_and_change_bit, test_bit, find_first_zero_bit, find_next_zero_bit, ffz, ffs): Likewise. * linux/src/include/asm-i386/io.h (virt_to_phys, phys_to_virt, __out##s, __in##s, ins##s, outs##s): Likewise. * linux/src/include/asm-i386/semaphore.h (down, down_interruptible, up): Likewise. * linux/src/include/asm-i386/segment.h [!__OPTIMIZE]: Emit an ud2 instruction instead of an undefined reference. --- linux/dev/include/asm-i386/string.h | 36 +++++++++++++++++----------------- linux/dev/include/linux/fs.h | 2 +- linux/src/include/asm-i386/bitops.h | 22 ++++++++++----------- linux/src/include/asm-i386/io.h | 12 ++++++------ linux/src/include/asm-i386/segment.h | 8 ++++++++ linux/src/include/asm-i386/semaphore.h | 6 +++--- linux/src/include/linux/string.h | 8 ++++++++ 7 files changed, 55 insertions(+), 39 deletions(-) diff --git a/linux/dev/include/asm-i386/string.h b/linux/dev/include/asm-i386/string.h index bdb75455..f41ca5c0 100644 --- a/linux/dev/include/asm-i386/string.h +++ b/linux/dev/include/asm-i386/string.h @@ -28,7 +28,7 @@ */ #define __HAVE_ARCH_STRCPY -extern inline char * strcpy(char * dest,const char *src) +static inline char * strcpy(char * dest,const char *src) { int d0, d1, d2; __asm__ __volatile__( @@ -43,7 +43,7 @@ return dest; } #define __HAVE_ARCH_STRNCPY -extern inline char * strncpy(char * dest,const char *src,size_t count) +static inline char * strncpy(char * dest,const char *src,size_t count) { int d0, d1, d2, d3; __asm__ __volatile__( @@ -63,7 +63,7 @@ return dest; } #define __HAVE_ARCH_STRCAT -extern inline char * strcat(char * dest,const char * src) +static inline char * strcat(char * dest,const char * src) { int d0, d1, d2, d3; __asm__ __volatile__( @@ -81,7 +81,7 @@ return dest; } #define __HAVE_ARCH_STRNCAT -extern inline char * strncat(char * dest,const char * src,size_t count) +static inline char * strncat(char * dest,const char * src,size_t count) { int d0, d1, d2, d3; __asm__ __volatile__( @@ -105,7 +105,7 @@ return dest; } #define __HAVE_ARCH_STRCMP -extern inline int strcmp(const char * cs,const char * ct) +static inline int strcmp(const char * cs,const char * ct) { int d0, d1; register int __res; @@ -127,7 +127,7 @@ return __res; } #define __HAVE_ARCH_STRNCMP -extern inline int strncmp(const char * cs,const char * ct,size_t count) +static inline int strncmp(const char * cs,const char * ct,size_t count) { register int __res; int d0, d1, d2; @@ -151,7 +151,7 @@ return __res; } #define __HAVE_ARCH_STRCHR -extern inline char * strchr(const char * s, int c) +static inline char * strchr(const char * s, int c) { int d0; register char * __res; @@ -171,7 +171,7 @@ return __res; } #define __HAVE_ARCH_STRRCHR -extern inline char * strrchr(const char * s, int c) +static inline char * strrchr(const char * s, int c) { int d0, d1; register char * __res; @@ -189,7 +189,7 @@ return __res; } #define __HAVE_ARCH_STRLEN -extern inline size_t strlen(const char * s) +static inline size_t strlen(const char * s) { int d0; register int __res; @@ -203,7 +203,7 @@ __asm__ __volatile__( return __res; } -extern inline void * __memcpy(void * to, const void * from, size_t n) +static inline void * __memcpy(void * to, const void * from, size_t n) { int d0, d1, d2; __asm__ __volatile__( @@ -226,7 +226,7 @@ return (to); * This looks horribly ugly, but the compiler can optimize it totally, * as the count is constant. */ -extern inline void * __constant_memcpy(void * to, const void * from, size_t n) +static inline void * __constant_memcpy(void * to, const void * from, size_t n) { switch (n) { case 0: @@ -299,7 +299,7 @@ __asm__ __volatile__( \ __memcpy((t),(f),(n))) #define __HAVE_ARCH_MEMMOVE -extern inline void * memmove(void * dest,const void * src, size_t n) +static inline void * memmove(void * dest,const void * src, size_t n) { int d0, d1, d2; if (dest> 5])) != 0; } @@ -106,7 +106,7 @@ extern __inline__ int test_bit(int nr, const SMPVOL void * addr) /* * Find-bit routines.. */ -extern __inline__ int find_first_zero_bit(void * addr, unsigned size) +static __inline__ int find_first_zero_bit(void * addr, unsigned size) { int d0, d1, d2; int res; @@ -129,7 +129,7 @@ extern __inline__ int find_first_zero_bit(void * addr, unsigned size) return res; } -extern __inline__ int find_next_zero_bit (void * addr, int size, int offset) +static __inline__ int find_next_zero_bit (void * addr, int size, int offset) { unsigned long * p = ((unsigned long *) addr) + (offset >> 5); int set = 0, bit = offset & 31, res; @@ -160,7 +160,7 @@ extern __inline__ int find_next_zero_bit (void * addr, int size, int offset) * ffz = Find First Zero in word. Undefined if no zero exists, * so code should check against ~0UL first.. */ -extern __inline__ unsigned long ffz(unsigned long word) +static __inline__ unsigned long ffz(unsigned long word) { __asm__("bsfl %1,%0" :"=r" (word) @@ -176,7 +176,7 @@ extern __inline__ unsigned long ffz(unsigned long word) * differs in spirit from the above ffz (man ffs). */ -extern __inline__ int ffs(int x) +static __inline__ int ffs(int x) { int r; diff --git a/linux/src/include/asm-i386/io.h b/linux/src/include/asm-i386/io.h index f961f1d2..34cf105b 100644 --- a/linux/src/include/asm-i386/io.h +++ b/linux/src/include/asm-i386/io.h @@ -45,12 +45,12 @@ * make the kernel segment mapped at 0, we need to do translation * on the i386 as well) */ -extern inline unsigned long virt_to_phys(volatile void * address) +static inline unsigned long virt_to_phys(volatile void * address) { return (unsigned long) _kvtophys(address); } -extern inline void * phys_to_virt(unsigned long address) +static inline void * phys_to_virt(unsigned long address) { return (void *) phystokv(address); } @@ -90,7 +90,7 @@ extern inline void * phys_to_virt(unsigned long address) */ #define __OUT1(s,x) \ -extern inline void __out##s(unsigned x value, unsigned short port) { +static inline void __out##s(unsigned x value, unsigned short port) { #define __OUT2(s,s1,s2) \ __asm__ __volatile__ ("out" #s " %" s1 "0,%" s2 "1" @@ -102,7 +102,7 @@ __OUT1(s##_p,x) __OUT2(s,s1,"w") : : "a" (value), "d" (port)); SLOW_DOWN_IO; } \ __OUT1(s##c_p,x) __OUT2(s,s1,"") : : "a" (value), "id" (port)); SLOW_DOWN_IO; } #define __IN1(s) \ -extern inline RETURN_TYPE __in##s(unsigned short port) { RETURN_TYPE _v; +static inline RETURN_TYPE __in##s(unsigned short port) { RETURN_TYPE _v; #define __IN2(s,s1,s2) \ __asm__ __volatile__ ("in" #s " %" s2 "1,%" s1 "0" @@ -114,12 +114,12 @@ __IN1(s##_p) __IN2(s,s1,"w") : "=a" (_v) : "d" (port) ,##i ); SLOW_DOWN_IO; retu __IN1(s##c_p) __IN2(s,s1,"") : "=a" (_v) : "id" (port) ,##i ); SLOW_DOWN_IO; return _v; } #define __INS(s) \ -extern inline void ins##s(unsigned short port, void * addr, unsigned long count) \ +static inline void ins##s(unsigned short port, void * addr, unsigned long count) \ { __asm__ __volatile__ ("cld ; rep ; ins" #s \ : "=D" (addr), "=c" (count) : "d" (port),"0" (addr),"1" (count)); } #define __OUTS(s) \ -extern inline void outs##s(unsigned short port, const void * addr, unsigned long count) \ +static inline void outs##s(unsigned short port, const void * addr, unsigned long count) \ { __asm__ __volatile__ ("cld ; rep ; outs" #s \ : "=S" (addr), "=c" (count) : "d" (port),"0" (addr),"1" (count)); } diff --git a/linux/src/include/asm-i386/segment.h b/linux/src/include/asm-i386/segment.h index 5f8af993..d23aa173 100644 --- a/linux/src/include/asm-i386/segment.h +++ b/linux/src/include/asm-i386/segment.h @@ -60,7 +60,11 @@ static inline void __attribute__((always_inline)) __put_user(unsigned long x, vo :"ir" (x), "m" (*__sd(y))); break; default: +#ifdef __OPTIMIZE__ bad_user_access_length(); +#else + asm volatile("ud2"); +#endif } } @@ -85,7 +89,11 @@ static inline unsigned long __attribute__((always_inline)) __get_user(const void :"m" (*__const_sd(y))); return result; default: +#ifdef __OPTIMIZE__ return bad_user_access_length(); +#else + asm volatile("ud2"); +#endif } } diff --git a/linux/src/include/asm-i386/semaphore.h b/linux/src/include/asm-i386/semaphore.h index c351c3ad..18e12c10 100644 --- a/linux/src/include/asm-i386/semaphore.h +++ b/linux/src/include/asm-i386/semaphore.h @@ -45,7 +45,7 @@ extern void __up(struct semaphore * sem); * "down_failed" is a special asm handler that calls the C * routine that actually waits. See arch/i386/lib/semaphore.S */ -extern inline void down(struct semaphore * sem) +static inline void down(struct semaphore * sem) { int d0; __asm__ __volatile__( @@ -86,7 +86,7 @@ asmlinkage int down_failed_interruptible(void); /* params in registers */ * process can be killed. The down_failed_interruptible routine * returns negative for signalled and zero for semaphore acquired. */ -extern inline int down_interruptible(struct semaphore * sem) +static inline int down_interruptible(struct semaphore * sem) { int ret ; @@ -113,7 +113,7 @@ extern inline int down_interruptible(struct semaphore * sem) * The default case (no contention) will result in NO * jumps for both down() and up(). */ -extern inline void up(struct semaphore * sem) +static inline void up(struct semaphore * sem) { int d0; __asm__ __volatile__( diff --git a/linux/src/include/linux/string.h b/linux/src/include/linux/string.h index 214503c2..62ff8802 100644 --- a/linux/src/include/linux/string.h +++ b/linux/src/include/linux/string.h @@ -12,25 +12,33 @@ extern "C" { #endif extern char * ___strtok; +#if 0 extern char * strcpy(char *,const char *); extern char * strncpy(char *,const char *, __kernel_size_t); extern char * strcat(char *, const char *); extern char * strncat(char *, const char *, __kernel_size_t); extern char * strchr(const char *,int); extern char * strrchr(const char *,int); +#endif extern char * strpbrk(const char *,const char *); extern char * strtok(char *,const char *); extern char * strstr(const char *,const char *); +#if 0 extern __kernel_size_t strlen(const char *); extern __kernel_size_t strnlen(const char *,__kernel_size_t); +#endif extern __kernel_size_t strspn(const char *,const char *); +#if 0 extern int strcmp(const char *,const char *); extern int strncmp(const char *,const char *,__kernel_size_t); +#endif extern void * memset(void *,int,__kernel_size_t); extern void * memcpy(void *,const void *,__kernel_size_t); +#if 0 extern void * memmove(void *,const void *,__kernel_size_t); extern void * memscan(void *,int,__kernel_size_t); +#endif extern int memcmp(const void *,const void *,__kernel_size_t); /* -- cgit v1.2.3 From eaee9424a120c289abc3eeeff331cb0d45efe971 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Thu, 9 Jul 2015 14:13:25 +0200 Subject: Allow non-privileged tasks to wire 64KiB task memory * doc/mach.texi (vm_wire): Document that the host port does not have to be privileged. * include/mach/mach_hosts.defs (vm_wire): Use mach_port_t instead of host_priv_t. * vm/vm_map.h (vm_map): Add user_wired field. * vm/vm_map.c (vm_map_setup): Initialize user_wired field to 0. (vm_map_pageable_common, vm_map_entry_delete, vm_map_copy_overwrite, vm_map_copyout_page_list, vm_map_copyin_page_list): When switching user_wired_count field of entry between 0 and non-0, accumulate the corresponding size into the user_wired field of map. * vm/vm_user.c (vm_wire): Turn host parameter into port parameter, and inline a version of convert_port_to_host_priv which records whether the host port is privileged or not. When it is not privileged, check whether the additional amount to user_wired will overcome 64KiB. --- doc/mach.texi | 13 +++++++------ include/mach/mach_host.defs | 2 +- vm/vm_map.c | 15 +++++++++++++++ vm/vm_map.h | 1 + vm/vm_user.c | 27 ++++++++++++++++++++++++--- 5 files changed, 48 insertions(+), 10 deletions(-) diff --git a/doc/mach.texi b/doc/mach.texi index 59872c97..6fc79f70 100644 --- a/doc/mach.texi +++ b/doc/mach.texi @@ -3241,14 +3241,15 @@ successfully set and @code{KERN_INVALID_ADDRESS} if an invalid or non-allocated address was specified. @end deftypefun -@deftypefun kern_return_t vm_wire (@w{host_priv_t @var{host_priv}}, @w{vm_task_t @var{target_task}}, @w{vm_address_t @var{address}}, @w{vm_size_t @var{size}}, @w{vm_prot_t @var{access}}) -The function @code{vm_wire} allows privileged applications to control -memory pageability. @var{host_priv} is the privileged host port for the +@deftypefun kern_return_t vm_wire (@w{host_t @var{host}}, @w{vm_task_t @var{target_task}}, @w{vm_address_t @var{address}}, @w{vm_size_t @var{size}}, @w{vm_prot_t @var{access}}) +The function @code{vm_wire} allows applications to control +memory pageability. @var{host} is the host port for the host on which @var{target_task} resides. @var{address} is the starting address, which will be rounded down to a page boundary. @var{size} is the size in bytes of the region for which protection is to change, and will be rounded up to give a page boundary. @var{access} specifies the -types of accesses that must not cause page faults. +types of accesses that must not cause page faults. If the host port is +not privileged, the amount of memory is limited per task. The semantics of a successful @code{vm_wire} operation are that memory in the specified range will not cause page faults for any accesses @@ -3257,7 +3258,7 @@ access argument of @code{VM_PROT_READ | VM_PROT_WRITE}. A special case is that @code{VM_PROT_NONE} makes the memory pageable. The function returns @code{KERN_SUCCESS} if the call succeeded, -@code{KERN_INVALID_HOST} if @var{host_priv} was not the privileged host +@code{KERN_INVALID_HOST} if @var{host} was not a valid host port, @code{KERN_INVALID_TASK} if @var{task} was not a valid task, @code{KERN_INVALID_VALUE} if @var{access} specified an invalid access mode, @code{KERN_FAILURE} if some memory in the specified range is not @@ -3265,7 +3266,7 @@ present or has an inappropriate protection value, and @code{KERN_INVALID_ARGUMENT} if unwiring (@var{access} is @code{VM_PROT_NONE}) and the memory is not already wired. -The @code{vm_wire} call is actually an RPC to @var{host_priv}, normally +The @code{vm_wire} call is actually an RPC to @var{host}, normally a send right for a privileged host port, but potentially any send right. In addition to the normal diagnostic return codes from the call's server (normally the kernel), the call may return @code{mach_msg} return codes. diff --git a/include/mach/mach_host.defs b/include/mach/mach_host.defs index 6699a507..28439a01 100644 --- a/include/mach/mach_host.defs +++ b/include/mach/mach_host.defs @@ -296,7 +296,7 @@ routine host_reboot( * [ To unwire the pages, specify VM_PROT_NONE. ] */ routine vm_wire( - host_priv : host_priv_t; + host : mach_port_t; task : vm_task_t; address : vm_address_t; size : vm_size_t; diff --git a/vm/vm_map.c b/vm/vm_map.c index 6b13724e..ae3ce21f 100644 --- a/vm/vm_map.c +++ b/vm/vm_map.c @@ -208,6 +208,7 @@ void vm_map_setup( rbtree_init(&map->hdr.tree); map->size = 0; + map->user_wired = 0; map->ref_count = 1; map->pmap = pmap; map->min_offset = min; @@ -1409,7 +1410,10 @@ kern_return_t vm_map_pageable_common( if (user_wire) { if (--(entry->user_wired_count) == 0) + { + map->user_wired -= entry->vme_end - entry->vme_start; entry->wired_count--; + } } else { entry->wired_count--; @@ -1486,7 +1490,10 @@ kern_return_t vm_map_pageable_common( if (user_wire) { if ((entry->user_wired_count)++ == 0) + { + map->user_wired += entry->vme_end - entry->vme_start; entry->wired_count++; + } } else { entry->wired_count++; @@ -1512,6 +1519,7 @@ kern_return_t vm_map_pageable_common( (entry->vme_end > start)) { if (user_wire) { if (--(entry->user_wired_count) == 0) + map->user_wired -= entry->vme_end - entry->vme_start; entry->wired_count--; } else { @@ -1627,6 +1635,8 @@ void vm_map_entry_delete( if (entry->wired_count != 0) { vm_fault_unwire(map, entry); entry->wired_count = 0; + if (entry->user_wired_count) + map->user_wired -= entry->vme_end - entry->vme_start; entry->user_wired_count = 0; } @@ -2274,6 +2284,8 @@ start_pass_1: entry->offset = copy_entry->offset; entry->needs_copy = copy_entry->needs_copy; entry->wired_count = 0; + if (entry->user_wired_count) + dst_map->user_wired -= entry->vme_end - entry->vme_start; entry->user_wired_count = 0; vm_map_copy_entry_unlink(copy, copy_entry); @@ -2869,6 +2881,7 @@ create_object: if (must_wire) { entry->wired_count = 1; + dst_map->user_wired += entry->vme_end - entry->vme_start; entry->user_wired_count = 1; } else { entry->wired_count = 0; @@ -3954,6 +3967,8 @@ retry: assert(src_entry->wired_count > 0); src_entry->wired_count = 0; + if (src_entry->user_wired_count) + src_map->user_wired -= src_entry->vme_end - src_entry->vme_start; src_entry->user_wired_count = 0; unwire_end = src_entry->vme_end; pmap_pageable(vm_map_pmap(src_map), diff --git a/vm/vm_map.h b/vm/vm_map.h index fc7730a2..9b31f90a 100644 --- a/vm/vm_map.h +++ b/vm/vm_map.h @@ -170,6 +170,7 @@ struct vm_map { #define max_offset hdr.links.end /* end of range */ pmap_t pmap; /* Physical map */ vm_size_t size; /* virtual size */ + vm_size_t user_wired; /* wired by user size */ int ref_count; /* Reference count */ decl_simple_lock_data(, ref_lock) /* Lock for ref_count field */ vm_map_entry_t hint; /* hint for quick lookups */ diff --git a/vm/vm_user.c b/vm/vm_user.c index f7c87cc0..8c7a5d8f 100644 --- a/vm/vm_user.c +++ b/vm/vm_user.c @@ -405,15 +405,32 @@ kern_return_t vm_map( * * [ To unwire the pages, specify VM_PROT_NONE. ] */ -kern_return_t vm_wire(host, map, start, size, access) - const host_t host; +kern_return_t vm_wire(port, map, start, size, access) + const ipc_port_t port; vm_map_t map; vm_offset_t start; vm_size_t size; vm_prot_t access; { - if (host == HOST_NULL) + host_t host; + boolean_t priv; + + if (!IP_VALID(port)) + return KERN_INVALID_HOST; + + ip_lock(port); + if (!ip_active(port) || + (ip_kotype(port) != IKOT_HOST_PRIV + && ip_kotype(port) != IKOT_HOST)) + { + ip_unlock(port); return KERN_INVALID_HOST; + } + + priv = ip_kotype(port) == IKOT_HOST_PRIV; + ip_unlock(port); + + host = (host_t) port->ip_kobject; if (map == VM_MAP_NULL) return KERN_INVALID_TASK; @@ -426,6 +443,10 @@ kern_return_t vm_wire(host, map, start, size, access) if (projected_buffer_in_range(map, start, start+size)) return(KERN_INVALID_ARGUMENT); + /* TODO: make it tunable */ + if (!priv && access != VM_PROT_NONE && map->user_wired + size > 65536) + return KERN_NO_ACCESS; + return vm_map_pageable_user(map, trunc_page(start), round_page(start+size), -- cgit v1.2.3 From babb522465c0a3339dfea673d2e6c85d304606f3 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Sun, 5 Jul 2015 00:14:30 +0200 Subject: kern: improve error handling * kern/bootstrap.c (boot_script_exec_cmd): Improve error handling. --- kern/bootstrap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kern/bootstrap.c b/kern/bootstrap.c index 4edae7bf..e70e1f68 100644 --- a/kern/bootstrap.c +++ b/kern/bootstrap.c @@ -725,7 +725,8 @@ boot_script_exec_cmd (void *hook, task_t task, char *path, int argc, assert(err == 0); thread->saved.other = &info; thread_start (thread, user_bootstrap); - thread_resume (thread); + err = thread_resume (thread); + assert(err == 0); /* We need to synchronize with the new thread and block this main thread until it has finished referring to our local state. */ -- cgit v1.2.3 From 4b8a219f30c319c9965204e42b7167c4ca90656c Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Sun, 5 Jul 2015 00:08:16 +0200 Subject: kern: remove superfluous file * kern/server_loop.ch: Remove superfluous file. --- kern/server_loop.ch | 104 ---------------------------------------------------- 1 file changed, 104 deletions(-) delete mode 100644 kern/server_loop.ch diff --git a/kern/server_loop.ch b/kern/server_loop.ch deleted file mode 100644 index 409e013d..00000000 --- a/kern/server_loop.ch +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - */ -/* - * File: kern/server_loop.c - * - * A common server loop for builtin tasks. - */ - -/* - * Must define symbols for: - * SERVER_NAME String name of this module - * SERVER_LOOP Routine name for the loop - * SERVER_DISPATCH MiG function(s) to handle message - * - * Must redefine symbols for pager_server functions. - */ - -#include -#include -#include -#include -#include /* for kernel_map */ - -void SERVER_LOOP(rcv_set, max_size) -{ - register mach_msg_header_t *in_msg; - register mach_msg_header_t *out_msg; - register mach_msg_header_t *tmp_msg; - vm_offset_t messages; - mach_msg_return_t r; - - /* - * Allocate our message buffers. - */ - - messages = kalloc(2 * max_size); - if (messages == 0) - panic(SERVER_NAME); - in_msg = (mach_msg_header_t *) messages; - out_msg = (mach_msg_header_t *) (messages + max_size); - - /* - * Service loop... receive messages and process them. - */ - - for (;;) { - /* receive first message */ - - receive_msg: - r = mach_msg(in_msg, MACH_RCV_MSG, 0, max_size, rcv_set, - MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); - if (r == MACH_MSG_SUCCESS) - break; - - printf("%s: receive failed, 0x%x.\n", SERVER_NAME, r); - } - - for (;;) { - /* process request message */ - - (void) SERVER_DISPATCH(in_msg, out_msg); - - /* send reply and receive next request */ - - if (out_msg->msgh_remote_port == MACH_PORT_NULL) - goto receive_msg; - - r = mach_msg(out_msg, MACH_SEND_MSG|MACH_RCV_MSG, - out_msg->msgh_size, max_size, rcv_set, - MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); - if (r != MACH_MSG_SUCCESS) { - printf("%s: send/receive failed, 0x%x.\n", - SERVER_NAME, r); - goto receive_msg; - } - - /* swap message buffers */ - - tmp_msg = in_msg; in_msg = out_msg; out_msg = tmp_msg; - } -} -- cgit v1.2.3 From 4f7070b8d271888ce57529a44f5c4b69cc894135 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Thu, 9 Jul 2015 19:20:04 +0200 Subject: i386: fix line wrapping in the immediate console * i386/i386at/immc.c (immc_cnputc): Fix line wrapping. --- i386/i386at/immc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i386/i386at/immc.c b/i386/i386at/immc.c index ea951690..bd61522d 100644 --- a/i386/i386at/immc.c +++ b/i386/i386at/immc.c @@ -86,7 +86,7 @@ immc_cnputc(dev_t dev, int c) if (!immediate_console_enable) return -1; - if (ofs < 0) + if (ofs < 0 || ofs >= 80) { ofs = 0; immc_cnputc(dev, '\n'); -- cgit v1.2.3 From 923c1f275596b97e823023e7020475b9a5258d5e Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Sat, 4 Jul 2015 16:36:03 +0200 Subject: vm: fix panic message * vm/vm_kern.c (kmem_init): Fix panic message. --- vm/vm_kern.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/vm/vm_kern.c b/vm/vm_kern.c index 775d8e8c..9c0a20b7 100644 --- a/vm/vm_kern.c +++ b/vm/vm_kern.c @@ -827,7 +827,6 @@ void kmem_init( /* * Reserve virtual memory allocated up to this time. */ - if (start != VM_MIN_KERNEL_ADDRESS) { kern_return_t rc; vm_offset_t addr = VM_MIN_KERNEL_ADDRESS; @@ -838,7 +837,7 @@ void kmem_init( VM_PROT_DEFAULT, VM_PROT_ALL, VM_INHERIT_DEFAULT); if (rc) - panic("%s:%d: vm_map_enter failed (%d)\n", rc); + panic("vm_map_enter failed (%d)\n", rc); } } -- cgit v1.2.3 From 78262cab3a92e09f63f5853d77db87620eac2543 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Sat, 4 Jul 2015 11:59:48 +0200 Subject: kern: make printf handle long long integers * Makefile.am (clib_routines): Steal `__umoddi3'. * kern/printf.c (MAXBUF): Increase size. (printnum, _doprnt): Handle long long integers. * kern/printf.h (printnum): Adjust declaration. --- Makefile.am | 2 +- kern/printf.c | 29 ++++++++++++++++++++++------- kern/printf.h | 2 +- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/Makefile.am b/Makefile.am index 913db55e..76a192ba 100644 --- a/Makefile.am +++ b/Makefile.am @@ -159,7 +159,7 @@ noinst_PROGRAMS += \ clib_routines := memcmp memcpy memmove \ strchr strstr strsep strtok \ htonl htons ntohl ntohs \ - udivdi3 __udivdi3 \ + udivdi3 __udivdi3 __umoddi3 \ __rel_iplt_start __rel_iplt_end \ __ffsdi2 \ _START _start etext _edata end _end # actually ld magic, not libc. diff --git a/kern/printf.c b/kern/printf.c index 1db0d08d..13f2dc05 100644 --- a/kern/printf.c +++ b/kern/printf.c @@ -126,11 +126,11 @@ #define isdigit(d) ((d) >= '0' && (d) <= '9') #define Ctod(c) ((c) - '0') -#define MAXBUF (sizeof(long int) * 8) /* enough for binary */ +#define MAXBUF (sizeof(long long int) * 8) /* enough for binary */ void printnum( - unsigned long u, + unsigned long long u, int base, void (*putc)( char, vm_offset_t ), vm_offset_t putc_arg) @@ -178,8 +178,9 @@ void _doprnt( int prec; boolean_t ladjust; char padc; - long n; - unsigned long u; + long long n; + unsigned long long u; + int have_long_long; int plus_sign; int sign_char; boolean_t altfmt, truncate; @@ -218,6 +219,7 @@ void _doprnt( plus_sign = 0; sign_char = 0; altfmt = FALSE; + have_long_long = FALSE; while (TRUE) { c = *fmt; @@ -276,6 +278,10 @@ void _doprnt( if (c == 'l') c = *++fmt; /* need it if sizeof(int) < sizeof(long) */ + if (c == 'l') { + c = *++fmt; /* handle `long long' */ + have_long_long = TRUE; + } truncate = FALSE; @@ -287,7 +293,10 @@ void _doprnt( boolean_t any; int i; - u = va_arg(argp, unsigned long); + if (! have_long_long) + u = va_arg(argp, unsigned long); + else + u = va_arg(argp, unsigned long long); p = va_arg(argp, char *); base = *p++; printnum(u, base, putc, putc_arg); @@ -431,7 +440,10 @@ void _doprnt( goto print_unsigned; print_signed: - n = va_arg(argp, long); + if (! have_long_long) + n = va_arg(argp, long); + else + n = va_arg(argp, long long); if (n >= 0) { u = n; sign_char = plus_sign; @@ -443,7 +455,10 @@ void _doprnt( goto print_num; print_unsigned: - u = va_arg(argp, unsigned long); + if (! have_long_long) + u = va_arg(argp, unsigned long); + else + u = va_arg(argp, unsigned long long); goto print_num; print_num: diff --git a/kern/printf.h b/kern/printf.h index 86857d33..76047f0b 100644 --- a/kern/printf.h +++ b/kern/printf.h @@ -35,7 +35,7 @@ extern void _doprnt (const char *fmt, int radix, vm_offset_t putc_arg); -extern void printnum (unsigned long u, int base, +extern void printnum (unsigned long long u, int base, void (*putc)(char, vm_offset_t), vm_offset_t putc_arg); -- cgit v1.2.3 From ef0ae1b884891af08626e8e52d62fdb02ec23ee1 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Fri, 10 Jul 2015 02:00:56 +0200 Subject: vm: drop debugging remnants * vm/vm_object.c (vm_object_terminate): Drop debugging remnants. --- vm/vm_object.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/vm/vm_object.c b/vm/vm_object.c index 8c6bbab4..deac0c2a 100644 --- a/vm/vm_object.c +++ b/vm/vm_object.c @@ -588,10 +588,6 @@ void vm_object_terminate( VM_PAGE_CHECK(p); - if (p->busy && !p->absent) - panic("vm_object_terminate.2 0x%x 0x%x", - object, p); - VM_PAGE_FREE(p); } } else while (!queue_empty(&object->memq)) { @@ -599,9 +595,6 @@ void vm_object_terminate( VM_PAGE_CHECK(p); - if (p->busy && !p->absent) - panic("vm_object_terminate.3 0x%x 0x%x", object, p); - vm_page_lock_queues(); VM_PAGE_QUEUES_REMOVE(p); vm_page_unlock_queues(); @@ -619,9 +612,6 @@ void vm_object_terminate( goto free_page; } - if (p->fictitious) - panic("vm_object_terminate.4 0x%x 0x%x", object, p); - if (!p->dirty) p->dirty = pmap_is_modified(p->phys_addr); -- cgit v1.2.3 From e59f05e940643350bb3813e5b7f18f9fe54806f6 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Fri, 10 Jul 2015 11:11:27 +0200 Subject: vm: fix traversing the list of inactive pages Previously, the pageout code traversed the hash table chain instead of the list of inactive pages. The code merely compiled by accident, because the `struct page' also has a field called `next' for the hash table chain. * vm/vm_pageout.c (vm_pageout_scan): Fix traversing the list of inactive pages. --- vm/vm_pageout.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vm/vm_pageout.c b/vm/vm_pageout.c index aff823ab..b13128a4 100644 --- a/vm/vm_pageout.c +++ b/vm/vm_pageout.c @@ -693,7 +693,7 @@ void vm_pageout_scan(void) if (want_pages || m->external) break; - m = (vm_page_t) queue_next (m); + m = (vm_page_t) queue_next (&m->listq); if (!m) goto pause; } -- cgit v1.2.3 From 2ba043d04468261cc767a3b91cec6df4b2238950 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Sat, 11 Jul 2015 13:27:58 +0200 Subject: kern: make sure the queue macros are only used on queues This turns mistakes as the one corrected in e59f05e9 into compile-time errors. * kern/queue.h: Add a new macro, queue_assert, and use it to assert that all arguments given to the queue macros have the correct type. * device/net_io.c (ENQUEUE_DEAD): Adapt to the fact that `queue_next(q)' is no longer an lvalue. --- device/net_io.c | 2 +- kern/queue.h | 31 ++++++++++++++++++++++++++----- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/device/net_io.c b/device/net_io.c index d2928cc5..47ef2ea8 100644 --- a/device/net_io.c +++ b/device/net_io.c @@ -353,7 +353,7 @@ decl_simple_lock_data(,net_hash_header_lock) /* entry_p must be net_rcv_port_t or net_hash_entry_t */ #define ENQUEUE_DEAD(dead, entry_p, chain) { \ - queue_next(&(entry_p)->chain) = (queue_entry_t) (dead); \ + (entry_p)->chain.next = (queue_entry_t) (dead); \ (dead) = (queue_entry_t)(entry_p); \ } diff --git a/kern/queue.h b/kern/queue.h index 518084db..f0b4002f 100644 --- a/kern/queue.h +++ b/kern/queue.h @@ -86,6 +86,14 @@ queue_entry_t dequeue_tail(queue_t); void remqueue(queue_t, queue_entry_t); void insque(queue_entry_t, queue_entry_t); +/* + * Macro: queue_assert + * Function: + * Used by macros to assert that the given argument is a + * queue. + */ +#define queue_assert(q) (void) ((void) (q)->next, (q)->prev) + /* * Macro: queue_init * Function: @@ -104,7 +112,7 @@ void insque(queue_entry_t, queue_entry_t); * queue_entry_t queue_first(q) * queue_t q; *IN* */ -#define queue_first(q) ((q)->next) +#define queue_first(q) (queue_assert(q), (q)->next) /* * Macro: queue_next @@ -114,7 +122,7 @@ void insque(queue_entry_t, queue_entry_t); * queue_entry_t queue_next(qc) * queue_t qc; */ -#define queue_next(qc) ((qc)->next) +#define queue_next(qc) (queue_assert(qc), (qc)->next) /* * Macro: queue_last @@ -124,7 +132,7 @@ void insque(queue_entry_t, queue_entry_t); * queue_entry_t queue_last(q) * queue_t q; *IN* */ -#define queue_last(q) ((q)->prev) +#define queue_last(q) (queue_assert(q), (q)->prev) /* * Macro: queue_prev @@ -134,7 +142,7 @@ void insque(queue_entry_t, queue_entry_t); * queue_entry_t queue_prev(qc) * queue_t qc; */ -#define queue_prev(qc) ((qc)->prev) +#define queue_prev(qc) (queue_assert(qc), (qc)->prev) /* * Macro: queue_end @@ -146,7 +154,8 @@ void insque(queue_entry_t, queue_entry_t); * queue_t q; * queue_entry_t qe; */ -#define queue_end(q, qe) ((q) == (qe)) +#define queue_end(q, qe) (queue_assert(q), queue_assert(qe), \ + (q) == (qe)) /* * Macro: queue_empty @@ -179,6 +188,8 @@ void insque(queue_entry_t, queue_entry_t); */ #define queue_enter(head, elt, type, field) \ { \ + queue_assert(head); \ + queue_assert(&(elt)->field); \ queue_entry_t prev; \ \ prev = (head)->prev; \ @@ -206,6 +217,8 @@ void insque(queue_entry_t, queue_entry_t); */ #define queue_enter_first(head, elt, type, field) \ { \ + queue_assert(head); \ + queue_assert(&(elt)->field); \ queue_entry_t next; \ \ next = (head)->next; \ @@ -239,6 +252,8 @@ void insque(queue_entry_t, queue_entry_t); */ #define queue_remove(head, elt, type, field) \ { \ + queue_assert(head); \ + queue_assert(&(elt)->field); \ queue_entry_t next, prev; \ \ next = (elt)->field.next; \ @@ -266,6 +281,8 @@ void insque(queue_entry_t, queue_entry_t); */ #define queue_remove_first(head, entry, type, field) \ { \ + queue_assert(head); \ + queue_assert(&(entry)->field); \ queue_entry_t next; \ \ (entry) = (type) ((head)->next); \ @@ -289,6 +306,8 @@ void insque(queue_entry_t, queue_entry_t); */ #define queue_remove_last(head, entry, type, field) \ { \ + queue_assert(head); \ + queue_assert(&(entry)->field); \ queue_entry_t prev; \ \ (entry) = (type) ((head)->prev); \ @@ -306,6 +325,8 @@ void insque(queue_entry_t, queue_entry_t); */ #define queue_assign(to, from, type, field) \ { \ + queue_assert(&(to)->field); \ + queue_assert(&(from)->field); \ ((type)((from)->prev))->field.next = (to); \ ((type)((from)->next))->field.prev = (to); \ *to = *from; \ -- cgit v1.2.3 From c40798e0fda94a1b4178b7e620a0777bb86927be Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Sun, 12 Jul 2015 13:00:07 +0200 Subject: vm: really fix traversing the list of inactive pages Previously, the pageout code traversed the list of pages in an object instead of the list of inactive pages. * vm/vm_pageout.c (vm_pageout_scan): Fix traversing the list of inactive pages. --- vm/vm_pageout.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vm/vm_pageout.c b/vm/vm_pageout.c index b13128a4..51a6a0d4 100644 --- a/vm/vm_pageout.c +++ b/vm/vm_pageout.c @@ -693,7 +693,7 @@ void vm_pageout_scan(void) if (want_pages || m->external) break; - m = (vm_page_t) queue_next (&m->listq); + m = (vm_page_t) queue_next (&m->pageq); if (!m) goto pause; } -- cgit v1.2.3 From 8760a60438d4f06b0a65b7fe2719bc39ad02c50d Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Thu, 2 Jul 2015 16:14:18 +0200 Subject: ipc: avoid kmem_alloc * ipc/ipc_table.c (ipc_table_alloc): Unconditionally use `kalloc'. (ipc_table_free): Unconditionally use `kfree'. --- ipc/ipc_table.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/ipc/ipc_table.c b/ipc/ipc_table.c index 1a89d812..0f8592a3 100644 --- a/ipc/ipc_table.c +++ b/ipc/ipc_table.c @@ -114,15 +114,7 @@ vm_offset_t ipc_table_alloc( vm_size_t size) { - vm_offset_t table; - - if (size < PAGE_SIZE) - table = kalloc(size); - else - if (kmem_alloc(kmem_map, &table, size) != KERN_SUCCESS) - table = 0; - - return table; + return kalloc(size); } /* @@ -139,8 +131,5 @@ ipc_table_free( vm_size_t size, vm_offset_t table) { - if (size < PAGE_SIZE) - kfree(table, size); - else - kmem_free(kmem_map, table, size); + kfree(table, size); } -- cgit v1.2.3 From 3b3e25e36a01df682973c1c72b084fe4c9bbdea8 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Wed, 15 Jul 2015 03:01:38 +0200 Subject: i386: fix typo * i386/intel/pmap.c: Fix typo. --- i386/intel/pmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i386/intel/pmap.c b/i386/intel/pmap.c index 62b33cf7..dc9f3605 100644 --- a/i386/intel/pmap.c +++ b/i386/intel/pmap.c @@ -166,7 +166,7 @@ vm_offset_t kernel_virtual_end; #define unlock_pvh_pai(pai) (bit_unlock(pai, pv_lock_table)) /* - * Array of physical page attribites for managed pages. + * Array of physical page attributes for managed pages. * One byte per physical page. */ char *pmap_phys_attributes; -- cgit v1.2.3 From 8a68e0a6f3a62c3e382791774e5feb9506e1f7d8 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Wed, 15 Jul 2015 15:11:05 +0200 Subject: ipc: fix the locking of the IPC entry allocation functions * ipc/ipc_entry.c (ipc_entry_alloc): Assume the space is write-locked. (ipc_entry_alloc_name): Likewise. * ipc/ipc_object.c: Fix the locking around all call sites to the two functions where the space was not locked before. --- ipc/ipc_entry.c | 21 ++------------------- ipc/ipc_object.c | 32 ++++++++++++++++++++------------ 2 files changed, 22 insertions(+), 31 deletions(-) diff --git a/ipc/ipc_entry.c b/ipc/ipc_entry.c index a5fe319f..0414ba5f 100644 --- a/ipc/ipc_entry.c +++ b/ipc/ipc_entry.c @@ -56,8 +56,7 @@ struct kmem_cache ipc_entry_cache; * Purpose: * Allocate an entry out of the space. * Conditions: - * The space is not locked before, but it is write-locked after - * if the call is successful. May allocate memory. + * The space must be write-locked. May allocate memory. * Returns: * KERN_SUCCESS An entry was allocated. * KERN_INVALID_TASK The space is dead. @@ -75,27 +74,21 @@ ipc_entry_alloc( ipc_entry_t entry; rdxtree_key_t key; - is_write_lock(space); - if (!space->is_active) { - is_write_unlock(space); return KERN_INVALID_TASK; } kr = ipc_entry_get(space, namep, entryp); if (kr == KERN_SUCCESS) - /* Success. Space is write-locked. */ return kr; entry = ie_alloc(); if (entry == IE_NULL) { - is_write_unlock(space); return KERN_RESOURCE_SHORTAGE; } kr = rdxtree_insert_alloc(&space->is_map, entry, &key); if (kr) { - is_write_unlock(space); ie_free(entry); return kr; } @@ -108,7 +101,6 @@ ipc_entry_alloc( *entryp = entry; *namep = (mach_port_t) key; - /* Success. Space is write-locked. */ return KERN_SUCCESS; } @@ -118,8 +110,7 @@ ipc_entry_alloc( * Allocates/finds an entry with a specific name. * If an existing entry is returned, its type will be nonzero. * Conditions: - * The space is not locked before, but it is write-locked after - * if the call is successful. May allocate memory. + * The space must be write-locked. May allocate memory. * Returns: * KERN_SUCCESS Found existing entry with same name. * KERN_SUCCESS Allocated a new entry. @@ -138,10 +129,7 @@ ipc_entry_alloc_name( void **slot; assert(MACH_PORT_VALID(name)); - is_write_lock(space); - if (!space->is_active) { - is_write_unlock(space); return KERN_INVALID_TASK; } @@ -152,7 +140,6 @@ ipc_entry_alloc_name( if (slot == NULL || entry == IE_NULL) { entry = ie_alloc(); if (entry == IE_NULL) { - is_write_unlock(space); return KERN_RESOURCE_SHORTAGE; } @@ -167,7 +154,6 @@ ipc_entry_alloc_name( kr = rdxtree_insert(&space->is_map, (rdxtree_key_t) name, entry); if (kr != KERN_SUCCESS) { - is_write_unlock(space); ie_free(entry); return kr; } @@ -175,14 +161,12 @@ ipc_entry_alloc_name( space->is_size += 1; *entryp = entry; - /* Success. Space is write-locked. */ return KERN_SUCCESS; } if (IE_BITS_TYPE(entry->ie_bits)) { /* Used entry. */ *entryp = entry; - /* Success. Space is write-locked. */ return KERN_SUCCESS; } @@ -202,7 +186,6 @@ ipc_entry_alloc_name( space->is_size += 1; *entryp = entry; - /* Success. Space is write-locked. */ return KERN_SUCCESS; } diff --git a/ipc/ipc_object.c b/ipc/ipc_object.c index 2d84cf52..320fbcb2 100644 --- a/ipc/ipc_object.c +++ b/ipc/ipc_object.c @@ -155,11 +155,12 @@ ipc_object_alloc_dead( ipc_entry_t entry; kern_return_t kr; - + is_write_lock(space); kr = ipc_entry_alloc(space, namep, &entry); - if (kr != KERN_SUCCESS) + if (kr != KERN_SUCCESS) { + is_write_unlock(space); return kr; - /* space is write-locked */ + } /* null object, MACH_PORT_TYPE_DEAD_NAME, 1 uref */ @@ -191,11 +192,12 @@ ipc_object_alloc_dead_name( ipc_entry_t entry; kern_return_t kr; - + is_write_lock(space); kr = ipc_entry_alloc_name(space, name, &entry); - if (kr != KERN_SUCCESS) + if (kr != KERN_SUCCESS) { + is_write_unlock(space); return kr; - /* space is write-locked */ + } if (ipc_right_inuse(space, name, entry)) return KERN_NAME_EXISTS; @@ -254,12 +256,13 @@ ipc_object_alloc( memset(pset, 0, sizeof(*pset)); } + is_write_lock(space); kr = ipc_entry_alloc(space, namep, &entry); if (kr != KERN_SUCCESS) { + is_write_unlock(space); io_free(otype, object); return kr; } - /* space is write-locked */ entry->ie_bits |= type | urefs; entry->ie_object = object; @@ -321,12 +324,13 @@ ipc_object_alloc_name( memset(pset, 0, sizeof(*pset)); } + is_write_lock(space); kr = ipc_entry_alloc_name(space, name, &entry); if (kr != KERN_SUCCESS) { + is_write_unlock(space); io_free(otype, object); return kr; } - /* space is write-locked */ if (ipc_right_inuse(space, name, entry)) { io_free(otype, object); @@ -753,10 +757,12 @@ ipc_object_copyout_name( assert(IO_VALID(object)); assert(io_otype(object) == IOT_PORT); + is_write_lock(space); kr = ipc_entry_alloc_name(space, name, &entry); - if (kr != KERN_SUCCESS) + if (kr != KERN_SUCCESS) { + is_write_unlock(space); return kr; - /* space is write-locked and active */ + } if ((msgt_name != MACH_MSG_TYPE_PORT_SEND_ONCE) && ipc_right_reverse(space, object, &oname, &oentry)) { @@ -930,10 +936,12 @@ ipc_object_rename( ipc_entry_t oentry, nentry; kern_return_t kr; + is_write_lock(space); kr = ipc_entry_alloc_name(space, nname, &nentry); - if (kr != KERN_SUCCESS) + if (kr != KERN_SUCCESS) { + is_write_unlock(space); return kr; - /* space is write-locked and active */ + } if (ipc_right_inuse(space, nname, nentry)) { /* space is unlocked */ -- cgit v1.2.3 From 7c9b83c90e2acc4f9eb74713c47796a3c0a08800 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Wed, 15 Jul 2015 12:40:50 +0200 Subject: ipc: use a general lock to protect IPC spaces This fixes a corruption in the radix trees representing the IPC spaces when memory was tight. * ipc/ipc_space.h: Use a general lock to protect IPC spaces. --- ipc/ipc_space.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ipc/ipc_space.h b/ipc/ipc_space.h index bbfee46e..73c90ef8 100644 --- a/ipc/ipc_space.h +++ b/ipc/ipc_space.h @@ -62,7 +62,7 @@ struct ipc_space { decl_simple_lock_data(,is_ref_lock_data) ipc_space_refs_t is_references; - decl_simple_lock_data(,is_lock_data) + struct lock is_lock_data; boolean_t is_active; /* is the space alive? */ struct rdxtree is_map; /* a map of entries */ size_t is_size; /* number of entries */ @@ -107,16 +107,16 @@ MACRO_BEGIN \ is_free(is); \ MACRO_END -#define is_lock_init(is) simple_lock_init(&(is)->is_lock_data) +#define is_lock_init(is) lock_init(&(is)->is_lock_data, TRUE) -#define is_read_lock(is) simple_lock(&(is)->is_lock_data) -#define is_read_unlock(is) simple_unlock(&(is)->is_lock_data) +#define is_read_lock(is) lock_read(&(is)->is_lock_data) +#define is_read_unlock(is) lock_done(&(is)->is_lock_data) -#define is_write_lock(is) simple_lock(&(is)->is_lock_data) -#define is_write_lock_try(is) simple_lock_try(&(is)->is_lock_data) -#define is_write_unlock(is) simple_unlock(&(is)->is_lock_data) +#define is_write_lock(is) lock_write(&(is)->is_lock_data) +#define is_write_lock_try(is) lock_try_write(&(is)->is_lock_data) +#define is_write_unlock(is) lock_done(&(is)->is_lock_data) -#define is_write_to_read_lock(is) +#define is_write_to_read_lock(is) lock_write_to_read(&(is)->is_lock_data) extern void ipc_space_reference(struct ipc_space *space); extern void ipc_space_release(struct ipc_space *space); -- cgit v1.2.3 From 63e97b694c2f9eefe33d5ac84c18df0dc102759a Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Sat, 18 Jul 2015 13:33:33 +0200 Subject: kern/slab: fix locking * kern/slab.c (host_slab_info): Fix locking. --- kern/slab.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kern/slab.c b/kern/slab.c index 60378b5f..1114cfa3 100644 --- a/kern/slab.c +++ b/kern/slab.c @@ -1503,7 +1503,7 @@ kern_return_t host_slab_info(host_t host, cache_info_array_t *infop, i = 0; list_for_each_entry(&kmem_cache_list, cache, node) { - simple_lock(&cache_lock); + simple_lock(&cache->lock); info[i].flags = ((cache->flags & KMEM_CF_NO_CPU_POOL) ? CACHE_FLAGS_NO_CPU_POOL : 0) | ((cache->flags & KMEM_CF_SLAB_EXTERNAL) -- cgit v1.2.3 From 661a0a5c59714b95633a866f717d8072c67f7ac7 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Sat, 18 Jul 2015 18:40:47 +0200 Subject: kern/bootstrap: fix locking * kern/bootstrap.c (boot_script_exec_cmd): Add missing unlock. (user_bootstrap): Likewise. --- kern/bootstrap.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kern/bootstrap.c b/kern/bootstrap.c index e70e1f68..50388ade 100644 --- a/kern/bootstrap.c +++ b/kern/bootstrap.c @@ -735,6 +735,7 @@ boot_script_exec_cmd (void *hook, task_t task, char *path, int argc, thread_sleep ((event_t) &info, simple_lock_addr(info.lock), FALSE); simple_lock (&info.lock); } + simple_unlock (&info.lock); printf ("\n"); } @@ -769,6 +770,7 @@ static void user_bootstrap(void) simple_lock (&info->lock); assert (!info->done); info->done = 1; + simple_unlock (&info->lock); thread_wakeup ((event_t) info); /* -- cgit v1.2.3 From 1451a958347f5e683c63466cd7dfb893c1651f19 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Sat, 18 Jul 2015 18:46:24 +0200 Subject: kern/lock: use compiler built-in functions to get return address * kern/lock.c (struct simple_locks_info): Fix type of `ra'. (simple_lock, simple_lock_try): Use compiler built-in functions to get return address. --- kern/lock.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/kern/lock.c b/kern/lock.c index fb5e3441..3c74fec8 100644 --- a/kern/lock.c +++ b/kern/lock.c @@ -133,7 +133,7 @@ unsigned int simple_locks_taken = 0; struct simple_locks_info { simple_lock_t l; - unsigned int ra; + void *ra; } simple_locks_info[NSLINFO]; void check_simple_locks(void) @@ -161,10 +161,8 @@ void simple_lock( info = &simple_locks_info[simple_locks_taken++]; info->l = l; - /* XXX we want our return address, if possible */ -#if defined(__i386__) - info->ra = *((unsigned long *)&l - 1); -#endif /* i386 */ + info->ra = + __builtin_extract_return_addr (__builtin_return_address (0)); } boolean_t simple_lock_try( @@ -179,10 +177,8 @@ boolean_t simple_lock_try( info = &simple_locks_info[simple_locks_taken++]; info->l = l; - /* XXX we want our return address, if possible */ -#if defined(__i386__) - info->ra = *((unsigned long *)&l - 1); -#endif /* i386 */ + info->ra = + __builtin_extract_return_addr (__builtin_return_address (0)); return TRUE; } -- cgit v1.2.3 From c9e087748246622d824b5ab83ad8cc79b31014d1 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Sat, 18 Jul 2015 16:17:50 +0200 Subject: kern/printf: do not serialize printf and co A lot of code assumes that printf is re-entrant, e.g. the pagination code in the debugger, or any use of assert inside the console driver. * kern/printf.c: Drop the lock serializing calls to `_doprnt'. (printf_init): Remove function. * kern/printf.h (printf_init): Remove declaration. * kern/startup.c (setup_main): Remove call to `printf_init'. --- kern/printf.c | 33 --------------------------------- kern/printf.h | 2 -- kern/startup.c | 2 -- 3 files changed, 37 deletions(-) diff --git a/kern/printf.c b/kern/printf.c index 13f2dc05..50f23623 100644 --- a/kern/printf.c +++ b/kern/printf.c @@ -151,21 +151,6 @@ void printnum( boolean_t _doprnt_truncates = FALSE; -/* printf could be called at _any_ point during system initialization, - including before printf_init() gets called from the "normal" place - in kern/startup.c. */ -boolean_t _doprnt_lock_initialized = FALSE; -decl_simple_lock_data(,_doprnt_lock) - -void printf_init(void) -{ - if (!_doprnt_lock_initialized) - { - _doprnt_lock_initialized = TRUE; - simple_lock_init(&_doprnt_lock); - } -} - void _doprnt( const char *fmt, va_list argp, @@ -187,22 +172,6 @@ void _doprnt( int base; char c; - printf_init(); - -#if 0 - /* Make sure that we get *some* printout, no matter what */ - simple_lock(&_doprnt_lock); -#else - { - int i = 0; - while (i < 1*1024*1024) { - if (simple_lock_try(&_doprnt_lock)) - break; - i++; - } - } -#endif - while ((c = *fmt) != '\0') { if (c != '%') { (*putc)(c, putc_arg); @@ -522,8 +491,6 @@ void _doprnt( } fmt++; } - - simple_unlock(&_doprnt_lock); } /* diff --git a/kern/printf.h b/kern/printf.h index 76047f0b..b72640aa 100644 --- a/kern/printf.h +++ b/kern/printf.h @@ -27,8 +27,6 @@ #include #include -extern void printf_init (void); - extern void _doprnt (const char *fmt, va_list argp, void (*putc)(char, vm_offset_t), diff --git a/kern/startup.c b/kern/startup.c index f9f0c347..30cff5c0 100644 --- a/kern/startup.c +++ b/kern/startup.c @@ -39,7 +39,6 @@ #include #include #include -#include #include #include #include @@ -109,7 +108,6 @@ void setup_main(void) #endif /* MACH_KDB */ panic_init(); - printf_init(); sched_init(); vm_mem_bootstrap(); -- cgit v1.2.3 From 92e98a7f4d4fa75b286a067e1d1caef514fccb0d Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Sat, 18 Jul 2015 18:52:22 +0200 Subject: linux/net: fix build with -O0 * linux/src/drivers/net/pci-scan.c: Avoid #erroring out. --- linux/src/drivers/net/pci-scan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux/src/drivers/net/pci-scan.c b/linux/src/drivers/net/pci-scan.c index 60525b76..ffb7b128 100644 --- a/linux/src/drivers/net/pci-scan.c +++ b/linux/src/drivers/net/pci-scan.c @@ -31,7 +31,7 @@ static int min_pci_latency = 32; #if ! defined(__KERNEL__) #define __KERNEL__ 1 #endif -#if !defined(__OPTIMIZE__) +#if !defined(__OPTIMIZE__) && /* Mach glue, we think this is ok now: */ 0 #warning You must compile this file with the correct options! #warning See the last lines of the source file. #error You must compile this driver with the proper options, including "-O". -- cgit v1.2.3