[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnumach] 01/02: Imported Upstream version 1.4+git20141107
From: |
Samuel Thibault |
Subject: |
[gnumach] 01/02: Imported Upstream version 1.4+git20141107 |
Date: |
Fri, 07 Nov 2014 01:34:19 +0000 |
This is an automated email from the git hooks/post-receive script.
sthibault pushed a commit to branch master
in repository gnumach.
commit 3019fdab5488048f797c862eec0d0a9c564f5e38
Author: Samuel Thibault <address@hidden>
Date: Fri Nov 7 00:37:28 2014 +0000
Imported Upstream version 1.4+git20141107
---
ChangeLog | 2973 +++++
INSTALL | 4 +-
Makefile.am | 3 +
Makefile.in | 363 +-
Makefrag.am | 31 +-
NEWS | 20 +
README | 2 +-
aclocal.m4 | 160 +-
chips/busses.c | 26 +-
chips/busses.h | 8 +-
config.h.in | 3 -
configure | 311 +-
ddb/db_access.c | 42 +-
ddb/db_access.h | 6 +
ddb/db_aout.c | 118 +-
include/mach/gnumach.defs => ddb/db_aout.h | 51 +-
ddb/db_break.c | 125 +-
ddb/db_break.h | 18 +-
ddb/db_command.c | 78 +-
ddb/db_command.h | 15 +-
ddb/db_cond.c | 22 +-
ddb/db_cond.h | 2 +-
ddb/db_elf.c | 232 +
include/mach/gnumach.defs => ddb/db_elf.h | 51 +-
ddb/db_examine.c | 71 +-
ddb/db_examine.h | 28 +-
ddb/db_expr.c | 36 +-
ddb/db_expr.h | 2 +-
ddb/db_ext_symtab.c | 12 +-
ddb/db_input.c | 43 +-
ddb/db_input.h | 2 +
ddb/db_lex.c | 31 +-
ddb/db_lex.h | 9 +-
ddb/db_macro.c | 40 +-
ddb/db_macro.h | 4 +-
ddb/db_mp.c | 37 +-
include/mach/gnumach.defs => ddb/db_mp.h | 29 +-
ddb/db_output.c | 29 +-
ddb/db_output.h | 10 +-
ddb/db_print.c | 101 +-
ddb/db_print.h | 14 +-
ddb/db_run.c | 77 +-
ddb/db_run.h | 36 +-
ddb/db_sym.c | 135 +-
ddb/db_sym.h | 42 +-
ddb/db_task_thread.c | 86 +-
ddb/db_task_thread.h | 24 +-
ddb/db_trap.c | 18 +-
ddb/db_variables.c | 46 +-
ddb/db_variables.h | 9 +-
ddb/db_watch.c | 45 +-
ddb/db_watch.h | 12 +-
ddb/db_write_cmd.c | 8 +-
include/mach/gnumach.defs => ddb/db_write_cmd.h | 33 +-
ddb/stab.h | 4 +
device/blkio.c | 15 +-
include/mach/gnumach.defs => device/blkio.h | 25 +-
device/buf.h | 10 +-
device/chario.c | 36 +-
include/mach/gnumach.defs => device/chario.h | 36 +-
device/cirbuf.c | 6 +-
device/cirbuf.h | 3 +-
device/conf.h | 48 +-
device/cons.c | 18 +-
device/dev_hdr.h | 10 +-
device/dev_lookup.c | 39 +-
device/dev_master.h | 5 +
device/dev_name.c | 66 +-
device/dev_pager.c | 97 +-
include/mach/gnumach.defs => device/dev_pager.h | 27 +-
device/device_init.c | 13 +-
include/mach/gnumach.defs => device/device_init.h | 25 +-
device/device_types_kernel.h | 1 -
device/ds_routines.c | 108 +-
device/ds_routines.h | 30 +-
device/if_ether.h | 7 +-
device/kmsg.c | 17 +-
device/kmsg.h | 2 +-
device/net_io.c | 259 +-
device/net_io.h | 63 +-
device/subrs.c | 36 +-
device/tty.h | 6 +-
doc/mach.info | 241 +-
doc/mach.info-1 | 419 +-
doc/mach.info-2 | 299 +-
doc/mach.texi | 218 +-
doc/stamp-vti | 8 +-
doc/version.texi | 8 +-
i386/Makefrag.am | 27 +-
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 | 33 +
ddb/db_input.h => i386/grub/i18n.h | 23 +-
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/i386/ast_check.c | 14 +-
i386/i386/db_disasm.c | 10 +-
i386/i386/db_interface.c | 102 +-
i386/i386/db_interface.h | 32 +-
i386/i386/db_machdep.h | 1 -
i386/i386/db_trace.c | 81 +-
include/mach/gnumach.defs => i386/i386/db_trace.h | 31 +-
i386/i386/debug.h | 2 +-
i386/i386/debug_i386.c | 7 +-
i386/i386/fpu.c | 81 +-
i386/i386/fpu.h | 2 +-
i386/i386/gdt.c | 2 +-
i386/i386/hardclock.c | 10 +-
include/mach/gnumach.defs => i386/i386/hardclock.h | 30 +-
i386/i386/idt.c | 2 +-
i386/i386/io_map.c | 38 +-
i386/i386/io_perm.c | 8 +-
i386/i386/io_perm.h | 2 +-
i386/i386/ipl.h | 4 +
i386/i386/ktss.c | 2 +-
i386/i386/kttd_interface.c | 2 +-
i386/i386/ldt.c | 5 +-
i386/i386/lock.h | 2 +-
i386/i386/locore.h | 2 +
i386/i386/loose_ends.c | 10 +-
i386/i386/machine_routines.h | 3 +-
i386/i386/machine_task.c | 2 +-
i386/i386/model_dep.h | 8 +-
i386/i386/mp_desc.c | 17 +-
i386/i386/mp_desc.h | 2 +
i386/i386/pcb.c | 115 +-
i386/i386/pcb.h | 14 +-
i386/i386/phys.c | 104 +-
i386/i386/pic.c | 11 +-
i386/i386/pic.h | 2 +-
i386/i386/pit.c | 4 +-
i386/i386/setjmp.h | 4 +-
i386/i386/thread.h | 2 +-
i386/i386/trap.c | 83 +-
i386/i386/trap.h | 9 +
i386/i386/user_ldt.c | 72 +-
i386/i386/user_ldt.h | 12 +-
i386/i386/vm_tuning.h | 35 -
i386/i386/xen.h | 2 +-
i386/i386at/acpi.c | 82 +
i386/i386at/acpihalt.c | 409 +
ddb/db_input.h => i386/i386at/acpihalt.h | 21 +-
i386/i386at/autoconf.c | 14 +-
i386/i386at/com.c | 105 +-
i386/i386at/com.h | 33 +
i386/i386at/conf.c | 56 +-
i386/i386at/cram.h | 4 +
i386/i386at/disk.h | 4 +
i386/i386at/grub_glue.c | 67 +
i386/i386at/i8250.h | 5 +
i386/i386at/idt.h | 2 +-
i386/i386at/immc.c | 6 +-
i386/i386at/int_init.c | 2 +-
i386/i386at/int_init.h | 2 +-
i386/i386at/kd.c | 462 +-
i386/i386at/kd.h | 64 +-
i386/i386at/kd_event.c | 96 +-
i386/i386at/kd_event.h | 29 +
i386/i386at/kd_mouse.c | 105 +-
i386/i386at/kd_mouse.h | 13 +
i386/i386at/kd_queue.c | 10 +-
i386/i386at/kd_queue.h | 9 +-
i386/i386at/kdsoft.h | 5 +
i386/i386at/lpr.c | 49 +-
i386/i386at/{lprreg.h => lpr.h} | 33 +
i386/i386at/mem.c | 2 +-
include/mach/gnumach.defs => i386/i386at/mem.h | 25 +-
i386/i386at/model_dep.c | 82 +-
.../mach/gnumach.defs => i386/i386at/model_dep.h | 29 +-
i386/i386at/pic_isa.c | 2 +-
i386/i386at/rtc.c | 31 +-
i386/i386at/rtc.h | 9 +-
i386/include/mach/i386/asm.h | 4 +
i386/include/mach/i386/cthreads.h | 2 +-
i386/include/mach/i386/disk.h | 4 +
i386/include/mach/i386/mach_i386_types.h | 4 +-
i386/include/mach/i386/rpc.h | 9 -
i386/intel/pmap.c | 357 +-
i386/intel/pmap.h | 32 +-
i386/intel/read_fault.c | 8 +-
include/cache.h | 25 +
include/device/device.defs | 11 +-
include/device/device_types.defs | 14 +
include/device/device_types.h | 2 +
include/device/tape_status.h | 2 +-
include/device/tty_status.h | 5 +
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/gnumach.defs | 35 +
include/mach/mach_port.defs | 23 +
include/mach/mach_types.defs | 10 +
include/mach/memory_object.defs | 40 +-
include/mach/memory_object_default.defs | 4 +
include/mach/message.h | 9 +-
include/mach/multiboot.h | 2 +-
include/mach/notify.defs | 32 +-
include/mach/rpc.h | 1 -
include/mach/version.h | 5 +
include/mach_debug/mach_debug.defs | 12 +-
include/mach_debug/mach_debug_types.defs | 2 +
include/mach_debug/mach_debug_types.h | 11 +
include/mach_debug/pc_info.h | 2 +-
include/string.h | 8 +-
ipc/ipc_entry.c | 24 +-
ipc/ipc_entry.h | 5 +
ipc/ipc_hash.c | 12 +-
ipc/ipc_init.c | 4 +-
ipc/ipc_kmsg.c | 196 +-
ipc/ipc_kmsg.h | 3 +-
ipc/ipc_kmsg_queue.h | 2 +-
ipc/ipc_machdep.h | 4 +
ipc/ipc_marequest.c | 34 +-
ipc/ipc_mqueue.c | 14 +-
ipc/ipc_mqueue.h | 1 +
ipc/ipc_notify.c | 42 +-
ipc/ipc_object.c | 3 +-
ipc/ipc_object.h | 4 +-
ipc/ipc_port.c | 83 +-
ipc/ipc_port.h | 27 +
include/mach/gnumach.defs => ipc/ipc_print.h | 38 +-
ipc/ipc_pset.c | 4 +-
ipc/ipc_right.c | 50 +-
ipc/ipc_table.c | 13 +-
ipc/ipc_table.h | 8 +
ipc/ipc_thread.h | 8 +-
ipc/mach_debug.c | 18 +-
ipc/mach_msg.c | 184 +-
ipc/mach_port.c | 153 +-
ipc/mach_port.h | 11 +
ipc/mach_rpc.c | 9 +-
ipc/port.h | 2 +-
kern/act.c | 33 +-
kern/act.h | 5 +-
kern/assert.h | 6 +-
kern/ast.c | 22 +-
kern/boot_script.c | 6 +-
kern/boot_script.h | 4 -
kern/bootstrap.c | 47 +-
include/mach/gnumach.defs => kern/bootstrap.h | 25 +-
kern/debug.c | 19 +-
kern/debug.h | 4 +-
kern/elf-load.c | 2 +
kern/eventcount.c | 21 +-
kern/eventcount.h | 7 +-
kern/exception.c | 91 +-
kern/exception.h | 66 +
kern/host.c | 26 +-
kern/ipc_host.c | 2 +-
kern/ipc_kobject.c | 28 +-
kern/ipc_kobject.h | 5 +-
kern/ipc_mig.c | 215 +-
kern/ipc_mig.h | 79 +-
kern/ipc_sched.c | 6 +-
kern/ipc_tt.c | 66 +-
kern/lock.c | 22 +-
kern/lock.h | 6 +-
kern/lock_mon.c | 51 +-
kern/mach_clock.c | 77 +-
kern/mach_clock.h | 9 +-
kern/mach_factor.c | 16 +-
kern/machine.c | 102 +-
kern/machine.h | 2 +-
kern/macro_help.h | 5 -
kern/pc_sample.c | 39 +-
kern/printf.c | 52 +-
kern/printf.h | 1 +
kern/priority.c | 18 +-
include/mach/gnumach.defs => kern/priority.h | 29 +-
kern/processor.c | 47 +-
kern/processor.h | 6 +
kern/queue.c | 24 +-
kern/queue.h | 10 +-
kern/rbtree.h | 1 -
kern/refcount.h | 6 +-
kern/sched.h | 2 +-
kern/sched_prim.c | 204 +-
kern/sched_prim.h | 27 +-
kern/shuttle.h | 2 +-
kern/slab.c | 15 +-
kern/slab.h | 27 +-
kern/startup.c | 49 +-
include/mach/gnumach.defs => kern/startup.h | 27 +-
kern/strings.c | 36 +-
kern/syscall_emulation.c | 54 +-
kern/syscall_emulation.h | 6 +
kern/syscall_subr.c | 54 +-
kern/syscall_subr.h | 1 +
kern/syscall_sw.c | 29 +-
kern/task.c | 100 +-
kern/task.h | 21 +-
kern/thread.c | 129 +-
kern/thread.h | 16 +-
kern/thread_swap.c | 12 +-
kern/thread_swap.h | 3 +-
kern/time_stamp.c | 24 +-
kern/timer.c | 87 +-
kern/timer.h | 4 +-
kern/xpr.c | 29 +-
linux/Makefrag.am | 6 +
linux/dev/drivers/block/ahci.c | 264 +-
linux/dev/drivers/block/floppy.c | 2 +-
linux/dev/glue/block.c | 13 +-
linux/dev/include/linux/blk.h | 5 +-
linux/dev/include/linux/blkdev.h | 1 +
linux/dev/include/linux/fs.h | 2 +-
linux/src/drivers/block/ide-cd.c | 51 +-
linux/src/drivers/block/ide.c | 1 +
linux/src/drivers/net/sundance.c | 2 +-
linux/src/drivers/net/tlan.c | 4 +-
linux/src/drivers/scsi/AM53C974.c | 2 +-
linux/src/drivers/scsi/FlashPoint.c | 12156 +++++++++++++++++++
linux/src/drivers/scsi/NCR5380.c | 4 +-
linux/src/drivers/scsi/eata_pio_proc.c | 135 +
linux/src/drivers/scsi/scsiiom.c | 1540 +++
linux/src/drivers/scsi/t128.c | 4 +-
util/atoi.c | 8 +-
util/atoi.h | 2 +-
version.m4 | 2 +-
vm/memory_object.c | 161 +-
vm/memory_object_proxy.c | 8 +-
vm/memory_object_proxy.h | 15 +-
vm/pmap.h | 24 +-
vm/vm_debug.c | 35 +-
vm/vm_external.c | 18 +-
vm/vm_fault.c | 150 +-
vm/vm_fault.h | 6 +
vm/vm_init.c | 4 +-
include/mach/gnumach.defs => vm/vm_init.h | 26 +-
vm/vm_kern.c | 248 +-
vm/vm_kern.h | 14 +
vm/vm_map.c | 486 +-
vm/vm_map.h | 31 +-
vm/vm_object.c | 101 +-
vm/vm_object.h | 10 +
vm/vm_page.h | 22 +-
vm/vm_pageout.c | 61 +-
vm/vm_pageout.h | 6 +
include/mach/gnumach.defs => vm/vm_print.h | 39 +-
vm/vm_resident.c | 96 +-
vm/vm_resident.h | 6 +-
vm/vm_user.c | 130 +-
xen/block.c | 7 +-
xen/console.c | 2 +-
xen/console.h | 10 +
xen/grant.c | 2 +-
xen/net.c | 5 +-
xen/time.c | 7 +-
356 files changed, 26309 insertions(+), 5941 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 3e23dae..3caf42d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,2973 @@
+2014-11-03 Samuel Thibault <address@hidden>
+
+ Fix link refusal
+ * Makefile.am (clib-routines.o): Refuse to link only when multiarch is
+ detected.
+
+2014-11-03 Samuel Thibault <address@hidden>
+
+ 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.
+
+2014-11-02 Samuel Thibault <address@hidden>
+
+ 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.
+
+2014-10-22 Samuel Thibault <address@hidden>
+
+ Revert "Make sure mig is available"
+ This reverts commit b28e05e203e0739fa5db59c5af378b29eea7a232.
+
+2014-10-10 Justus Winter <address@hidden>
+
+ 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'.
+
+2014-10-01 Justus Winter <address@hidden>
+
+ Add protected payloads to NEWS
+
+ 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.
+
+ 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.
+
+ 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.
+
+ 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.
+
+2014-10-01 Justus Winter <address@hidden>
+
+ 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.
+
+2014-09-30 Justus Winter <address@hidden>
+
+ 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.
+
+ 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: fix type of recompute_priorities
+ * kern/sched_prim.c (recompute_priorities): Fix type.
+ * kern/sched_prim.h (recompute_priorities): Likewise.
+
+2014-09-26 Justus Winter <address@hidden>
+
+ 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.
+
+2014-09-25 Justus Winter <address@hidden>
+
+ Update NEWS file
+
+2014-09-17 Justus Winter <address@hidden>
+
+ 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.
+
+ 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.
+
+2014-09-17 Samuel Thibault <address@hidden>
+
+ Report DR6 to userland
+ * i386/i386/trap.c (user_trap): On T_DEBUG, record the content of dr6 in
+ PCB, and clear it.
+
+2014-09-06 Samuel Thibault <address@hidden>
+
+ 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'.
+
+2014-09-01 Pietro Braione <address@hidden>
+
+ Fix printf warning
+ linux/src/drivers/net/sundance.c (start_tx): Fix format string according
+ to parameter.
+
+2014-08-30 Samuel Thibault <address@hidden>
+
+ 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.
+
+2014-08-30 Samuel Thibault <address@hidden>
+
+ Increate the pageout thread priority
+ * vm/vm_pageout.c (vm_pageout): Set the priority to 0.
+
+2014-08-30 Samuel Thibault <address@hidden>
+
+ 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.
+
+2014-08-22 Samuel Thibault <address@hidden>
+
+ Fix computation
+ * i386/i386at/com.c (comintr): Fix computation of '@'.
+
+2014-08-22 Neal H. Walfield <address@hidden>
+
+ Even less magic-looking control value
+ * i386/i386at/com.c (comintr): Use 'A'-1 instead of '@'.
+
+2014-08-22 Justus Winter <address@hidden>
+
+ 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.
+
+2014-07-25 Samuel Thibault <address@hidden>
+
+ Drop debugging prints
+ * i386/i386at/acpi.c (grub_machine_acpi_get_rsdpv2): Drop debugging
+ prints.
+
+2014-07-06 Samuel Thibault <address@hidden>
+
+ 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.
+
+2014-07-06 Samuel Thibault <address@hidden>
+
+ Document that io_map_cached leaks memory
+
+ Merge branch 'master' of git.savannah.gnu.org:/srv/git/hurd/gnumach
+
+2014-07-06 Justus Winter <address@hidden>
+
+ 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.
+
+2014-07-06 Justus Winter <address@hidden>
+
+ 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.
+
+2014-06-11 Justus Winter <address@hidden>
+
+ doc: explain the floating point flag in kdb output
+ * doc/mach.texi (Kernel Debugger Commands): Explain the floating point
+ flag.
+
+2014-06-11 Justus Winter <address@hidden>
+
+ 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.
+
+2014-06-11 Justus Winter <address@hidden>
+
+ 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.
+
+ 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: 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.
+
+ kern: set the name of the kernel task to 'gnumach'
+ * kern/taks.c (task_init): Set the name of the kernel task to 'gnumach'.
+
+2014-06-11 Justus Winter <address@hidden>
+
+ 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.
+
+2014-05-27 Samuel Thibault <address@hidden>
+
+ Add missing memory clobber
+ * i386/i386/xen.h (mb, rmb, wmb): Add memory clobber.
+
+2014-05-25 Justus Winter <address@hidden>
+
+ 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.
+
+2014-05-25 Justus Winter <address@hidden>
+
+ 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.
+
+2014-05-03 Justus Winter <address@hidden>
+
+ 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.
+
+2014-04-30 Justus Winter <address@hidden>
+
+ 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.
+
+2014-04-30 Justus Winter <address@hidden>
+
+ 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.
+
+2014-04-30 Justus Winter <address@hidden>
+
+ 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.
+
+2014-04-30 Justus Winter <address@hidden>
+
+ 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.
+
+2014-04-30 Justus Winter <address@hidden>
+
+ 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.
+
+2014-04-30 Justus Winter <address@hidden>
+
+ doc: fix the number of priorities
+ The number of priorities has been changed from 32 to 50 in
+ 6a234201081156e6d5742e7eeabb68418b518fad.
+
+ * doc/mach.texi: Update accordingly.
+
+2014-04-25 Samuel Thibault <address@hidden>
+
+ Make sure mig is available
+ * configure.ac (MIG): Error out if MiG was not found.
+
+2014-04-13 Justus Winter <address@hidden>
+
+ kern: set the name of tasks created during the bootstrap
+ * kern/bootstrap.c (boot_script_task_create): Set the name of newly
+ created tasks.
+
+2014-04-10 Justus Winter <address@hidden>
+
+ 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.
+
+2014-04-08 Justus Winter <address@hidden>
+
+ 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.
+
+2014-04-05 Justus Winter <address@hidden>
+
+ 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.
+
+2014-04-04 Marin Ramesa <address@hidden>
+
+ 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.
+
+2014-04-04 Samuel Thibault <address@hidden>
+
+ Fix prototype
+ * linux/dev/glue/block.c (device_set_status): Fix prototype.
+
+2014-04-04 Marin Ramesa <address@hidden>
+
+ Use explicit prototypes for struct dev_ops fields
+ * device/conf.h: Include <sys/types.h>, <mach/port.h>, <mach/vm_prot.h>.
+ 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 <sys/types.h>, predefine struct io_req and
+ io_req_t.
+ (timeopen, timeclose): Fix prototype.
+
+2014-03-28 Samuel Thibault <address@hidden>
+
+ 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.
+
+2014-03-28 Samuel Thibault <address@hidden>
+
+ 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.
+
+2014-03-26 Justus Winter <address@hidden>
+
+ 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.
+
+2014-03-25 Justus Winter <address@hidden>
+
+ 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.
+
+2014-03-22 Samuel Thibault <address@hidden>
+
+ Merge branch 'master' of git.savannah.gnu.org:/srv/git/hurd/gnumach
+
+2014-03-22 Samuel Thibault <address@hidden>
+
+ 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.
+
+2014-03-20 Justus Winter <address@hidden>
+
+ 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.
+
+2014-03-20 Samuel Thibault <address@hidden>
+
+ Only complain once per boot about Xen console smash
+ * xen/console.c (hypputc): Make `complain' variable static.
+
+2014-03-17 Samuel Thibault <address@hidden>
+
+ 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.
+
+2014-03-03 Samuel Thibault <address@hidden>
+
+ Merge branch 'master' of git.savannah.gnu.org:/srv/git/hurd/gnumach
+
+2014-03-03 Samuel Thibault <address@hidden>
+
+ 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 <i386/model_dep.h>
+ (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.
+
+2014-02-26 Justus Winter <address@hidden>
+
+ 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.
+
+2014-02-23 Samuel Thibault <address@hidden>
+
+ Merge branch 'master' of git.savannah.gnu.org:/srv/git/hurd/gnumach
+
+ 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.
+
+2014-02-19 Justus Winter <address@hidden>
+
+ 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.
+
+2014-02-12 Samuel Thibault <address@hidden>
+
+ Reduce kmem_map to make room for kentry_data_size
+ * kern/slab.c (KMEM_MAP_SIZE): Decrease from 128MiB to 96MiB.
+
+2014-02-10 Samuel Thibault <address@hidden>
+
+ Make open return ENXIO on missing CD-ROM
+ * linux/src/drivers/block/ide-cd.c (ide_cdrom_open): Return -ENXIO when
+ CD sense failed.
+
+ 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.
+
+ Add missing initialization
+ * linux/src/drivers/block/ide.c (ide_init_drive_cmd): Initialize `quiet'
+ field of request to 0;
+
+ Merge branch 'master' of git.savannah.gnu.org:/srv/git/hurd/gnumach
+
+2014-02-10 Samuel Thibault <address@hidden>
+
+ 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.
+
+2014-02-06 Richard Braun <address@hidden>
+
+ 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.
+
+2014-02-05 Samuel Thibault <address@hidden>
+
+ Remove duplicate typedef
+ * device/net_io.c (net_rcv_port_t, net_hash_entry_t, net_hash_header_t):
+ Remove duplicate typedefs.
+
+2014-02-05 Justus Winter <address@hidden>
+
+ doc: document task_set_name
+ * doc/mach.texi (Task Information): Document the new task_set_name
+ procedure.
+
+2014-02-05 Justus Winter <address@hidden>
+
+ 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.
+
+2014-02-05 Justus Winter <address@hidden>
+
+ 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.
+
+2014-02-04 Samuel Thibault <address@hidden>
+
+ 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.
+
+2014-02-04 Samuel Thibault <address@hidden>
+
+ 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.
+
+2014-02-04 Samuel Thibault <address@hidden>
+
+ Fix potential NULL dereference
+ * vm/vm_kern.c (projected_buffer_deallocate): Look for `map' being NULL
+ or kernel_map before locking it.
+
+2014-02-04 Samuel Thibault <address@hidden>
+
+ Fix potential NULL dereference
+ Found by Coverity
+
+ * i386/i386/db_trace.c (db_find_kthread): Handle case when task is NULL.
+
+2014-02-04 Samuel Thibault <address@hidden>
+
+ Fix potential NULL dereference
+ Found by Coverity.
+
+ * i386/i386at/com.c (comopen): On com_reprobe() returning success, check
+ for `isai' again.
+
+2014-02-04 Justus Winter <address@hidden>
+
+ 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.
+
+2014-02-04 Justus Winter <address@hidden>
+
+ 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.
+
+2014-02-04 Justus Winter <address@hidden>
+
+ 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.
+
+2014-02-04 Justus Winter <address@hidden>
+
+ 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.
+
+2014-02-04 Samuel Thibault <address@hidden>
+
+ Fix FPU state copy size
+ * i386/i386/fpu.c (fpu_set_state, fpu_get_state): Fix size of
+ `user_fp_regs' access.
+
+ 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.
+
+2014-02-04 Samuel Thibault <address@hidden>
+
+ 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.
+
+2014-02-04 Samuel Thibault <address@hidden>
+
+ Fix typo
+ * i386/i386at/kd_mouse.c (mouseopen): Fix typo.
+
+ Merge branch 'master' of git.savannah.gnu.org:/srv/git/hurd/gnumach
+
+2014-02-04 Samuel Thibault <address@hidden>
+
+ Add missing break
+ Found by Coverity
+
+ * i386/i386at/kd_mouse.c (mouseopen): Add missing break.
+
+2014-02-01 Justus Winter <address@hidden>
+
+ include: add a fixed-size string type for debugging purposes
+ * include/mach/debug.defs: New file.
+ * include/mach/debug.h: Likewise.
+
+ 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.
+
+ 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: add snprintf
+ * kern/printf.c (snprintf): New function.
+ * kern/printf.h (snprintf): New declaration.
+
+2014-01-16 Justus Winter <address@hidden>
+
+ 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.
+
+2014-01-16 Justus Winter <address@hidden>
+
+ 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.
+
+2014-01-09 Justus Winter <address@hidden>
+
+ kern: align kmem_cache objects using __cacheline_aligned
+ * kern/slab.h (struct kmem_cache): Align kmem_cache objects using
+ __cacheline_aligned.
+
+ 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.
+
+2014-01-06 Justus Winter <address@hidden>
+
+ 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.
+
+2014-01-05 Justus Winter <address@hidden>
+
+ kern: explain the significance of the chosen length
+ * kern/slab.h (KMEM_CACHE_NAME_SIZE): Explain the significance of the
+ chosen length.
+
+2014-01-05 Justus Winter <address@hidden>
+
+ 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.
+
+2014-01-05 Justus Winter <address@hidden>
+
+ 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.
+
+2014-01-03 Justus Winter <address@hidden>
+
+ 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.
+
+2014-01-03 Justus Winter <address@hidden>
+
+ 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.
+
+2014-01-03 Justus Winter <address@hidden>
+
+ 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.
+
+2014-01-03 Justus Winter <address@hidden>
+
+ vm: merge the two bit fields in struct vm_page
+ * vm/vm_page.h (struct vm_page): Merge the two bit fields.
+
+2014-01-03 Justus Winter <address@hidden>
+
+ 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.
+
+2014-01-02 Samuel Thibault <address@hidden>
+
+ 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.
+
+2014-01-01 Marin Ramesa <address@hidden>
+
+ 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.
+
+ Add comment after endif
+ * i386/i386/io_perm.h (_I386_IO_PERM_H_): Add comment after endif.
+
+2013-12-20 Samuel Thibault <address@hidden>
+
+ Merge branch 'master' of git.savannah.gnu.org:/srv/git/hurd/gnumach
+
+2013-12-20 Marin Ramesa <address@hidden>
+
+ Mark pure functions with attribute pure
+
+ kern/strings.c (strlen): mark with attribute pure
+ * kern/strings.c (strlen): Mark with attribute pure.
+
+ ddb/db_watch.c (db_watchpoint_cmd): remove forward declaration
+ * ddb/db_watch.c (db_watchpoint_cmd) (db_option): Remove forward
declaration.
+
+2013-12-20 Marin Ramesa <address@hidden>
+
+ 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.
+
+2013-12-18 Justus Winter <address@hidden>
+
+ i386: add missing includes
+ * i386/i386at/kd_event.h: Add missing includes.
+
+2013-12-17 Marin Ramesa <address@hidden>
+
+ 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.
+
+ Mark functions that don't return with attribute noreturn
+
+ vm: qualify pointers whose dereferenced values are constant with const
+
+ util: qualify pointers whose dereferenced values are constant with const
+
+ kern: qualify pointers whose dereferenced values are constant with const
+
+ ipc: qualify pointers whose dereferenced values are constant with const
+
+ i386: qualify pointers whose dereferenced values are constant with const
+
+ device: qualify pointers whose dereferenced values are constant with
const
+
+ 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.
+
+2013-12-17 Marin Ramesa <address@hidden>
+
+ 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.
+
+2013-12-17 Justus Winter <address@hidden>
+
+ xen: add missing includes
+ * xen/console.h: Add missing includes.
+
+2013-12-16 Marin Ramesa <address@hidden>
+
+ 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.
+
+ Quiet GCC warning about uninitialized variable
+ * ddb/db_command.h (db_error): Mark with attribute noreturn.
+ * i386/i386/setjmp.h (_longjmp): Likewise.
+
+2013-12-15 Marin Ramesa <address@hidden>
+
+ 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 *).
+
+ 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.
+
+2013-12-15 Marin Ramesa <address@hidden>
+
+ device/dev_pager.c: remove unnecessary casts
+ Variable pager is already of ipc_port_t type.
+
+ * device/dev_pager.c: Remove unnecessary casts.
+
+2013-12-15 Marin Ramesa <address@hidden>
+
+ 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.
+
+2013-12-15 Marin Ramesa <address@hidden>
+
+ ddb: qualify pointers whose dereferenced values are constant with const
+
+2013-12-15 Samuel Thibault <address@hidden>
+
+ 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.
+
+2013-12-15 Marin Ramesa <address@hidden>
+
+ 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.
+
+2013-12-15 Marin Ramesa <address@hidden>
+
+ 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.
+
+2013-12-15 Marin Ramesa <address@hidden>
+
+ 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.
+
+2013-12-15 Marin Ramesa <address@hidden>
+
+ 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.
+
+2013-12-15 Marin Ramesa <address@hidden>
+
+ 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.
+
+2013-12-15 Marin Ramesa <address@hidden>
+
+ 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.
+
+2013-12-15 Marin Ramesa <address@hidden>
+
+ 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.
+
+2013-12-15 Marin Ramesa <address@hidden>
+
+ kern/mach_clock.c: update comment
+ This is mach_clock.c, not clock_prim.c.
+
+ * kern/mach_clock.c: Update comment.
+
+2013-12-15 Marin Ramesa <address@hidden>
+
+ Declare void argument lists
+
+2013-12-11 Marin Ramesa <address@hidden>
+
+ 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.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.
+
+2013-12-11 Marin Ramesa <address@hidden>
+
+ i386/i386at/kd.c (kdmmap): remove unnecessary cast
+ Variable off is already an unsigned int.
+
+ * i386/i386at/kd.c (kdmmap) (off): Remove unnecessary cast.
+
+2013-12-11 Marin Ramesa <address@hidden>
+
+ 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.
+
+2013-12-11 Marin Ramesa <address@hidden>
+
+ 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.
+
+2013-12-11 Marin Ramesa <address@hidden>
+
+ 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.
+
+2013-12-11 Marin Ramesa <address@hidden>
+
+ 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.
+
+2013-12-11 Marin Ramesa <address@hidden>
+
+ 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.
+
+2013-12-11 Marin Ramesa <address@hidden>
+
+ 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.
+
+2013-12-10 Marin Ramesa <address@hidden>
+
+ 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.
+
+2013-12-10 Marin Ramesa <address@hidden>
+
+ 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/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: 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.
+
+2013-12-10 Marin Ramesa <address@hidden>
+
+ 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.
+
+2013-12-10 Marin Ramesa <address@hidden>
+
+ 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 (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.
+
+ device/cons.c: fix argument list
+ * device/cons.c (romgetc, romputc): Fix argument list.
+
+2013-12-10 Marin Ramesa <address@hidden>
+
+ 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.
+
+2013-12-10 Marin Ramesa <address@hidden>
+
+ 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.
+
+2013-12-10 Marin Ramesa <address@hidden>
+
+ device/chario.c: trivial stylistic fix for consistency
+ * device/chario.c: Trivial stylistic fix for consistency.
+
+2013-12-10 Marin Ramesa <address@hidden>
+
+ 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.
+
+2013-12-10 Marin Ramesa <address@hidden>
+
+ 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 *).
+
+2013-12-10 Marin Ramesa <address@hidden>
+
+ 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.
+
+2013-12-08 Marin Ramesa <address@hidden>
+
+ 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.
+
+2013-12-08 Marin Ramesa <address@hidden>
+
+ 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.
+
+2013-12-08 Marin Ramesa <address@hidden>
+
+ 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.
+
+2013-12-08 Marin Ramesa <address@hidden>
+
+ 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.
+
+2013-12-08 Marin Ramesa <address@hidden>
+
+ 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_examine.c: trivial stylistic fix for consistency
+ * ddb/db_examine.c: Trivial stylistic fix for consistency.
+
+ ddb/db_examine.c (db_examine_cmd): remove forward declaration
+ * ddb/db_examine.c (db_option): Remove forward declaration.
+
+ ddb/db_command.c (db_command): remove forward declaration
+ * ddb/db_command.c (db_fncall): Remove forward declaration.
+
+ ddb/db_command.c: use boolean values
+ * ddb/db_command.c (db_cmd_loop_done): Use boolean values.
+
+2013-12-08 Marin Ramesa <address@hidden>
+
+ 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.
+
+2013-12-08 Marin Ramesa <address@hidden>
+
+ 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.
+
+2013-12-08 Marin Ramesa <address@hidden>
+
+ ddb/db_break.c (db_add_thread_breakpoint): fix argument list
+ * ddb/db_break.c (db_add_thread_breakpoint): Fix argument list.
+
+ 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.
+
+2013-12-08 Marin Ramesa <address@hidden>
+
+ 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.
+
+2013-12-08 Marin Ramesa <address@hidden>
+
+ 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/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/com.c: fix assignment from incompatible pointer type
+ * device/tty.h (tty): Modify so that correct argument list and return
type is listed.
+
+ 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.
+
+ kern/startup.c: use boolean values
+ * kern/startup.c (reboot_on_panic): Use boolean values.
+
+ 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_object.c: remove unused variable
+ * vm/vm_object.c (vm_object_terminate_remove_all): Remove unused
variable.
+
+ 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.
+
+ 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/i386at/model_dep.c: fix argument list
+ * i386/i386at/model_dep.c (timemmap): Fix argument list.
+
+ i386/i386at/lpr.c: fix argument list
+ * i386/i386at/lpr.c (lprprobe): Fix argument list.
+
+ 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.
+
+2013-12-08 Marin Ramesa <address@hidden>
+
+ kern/act.h: remove unnecessary include
+ File kern/act.h includes itself. Remove this include.
+
+ * kern/act.h: Don't include kern/act.h.
+
+2013-12-08 Marin Ramesa <address@hidden>
+
+ 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.
+
+ vm/vm_page.h: remove unused variables
+ * vm/vm_page.h (first_phys_addr, last_phys_addr): Remove unused
variables.
+
+ kern/syscall_sw.c: use boolean instead of an int
+ * kern/syscall_sw.c (kern_invalid_debug): Use boolean instead of an int.
+
+2013-12-08 Marin Ramesa <address@hidden>
+
+ kern/refcount.h: remove unnecessary include
+ File kern/refcount.h includes itself. Remove this include.
+
+ * kern/refcount.h: Don't include kern/refcount.h.
+
+2013-12-08 Marin Ramesa <address@hidden>
+
+ kern/rbtree.h: remove unnecessary include
+ File kern/rbtree.h includes itself. Remove this include.
+
+ * kern/rbtree.h: Don't include kern/rbtree.h.
+
+2013-12-08 Marin Ramesa <address@hidden>
+
+ kern/priority.c: update comment
+ This is priority.c. Not clock_prim.c.
+
+ * kern/priority.c: Update comment.
+
+2013-12-08 Marin Ramesa <address@hidden>
+
+ kern/pc_sample.c: remove unused variables
+ * kern/pc_sample.c (pc_sampling_enabled, pc_sampling_lock): Remove
unused variables.
+
+ kern/lock_mon.c: remove dead assignments
+ * kern/lock_mon.c (scurval, ssum, sli): Remove variables.
+ (scurval, ssum, sli): Remove dead assignments.
+
+2013-12-08 Marin Ramesa <address@hidden>
+
+ 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.
+
+2013-12-08 Marin Ramesa <address@hidden>
+
+ kern/act.h: remove prototype without definition
+ * kern/act.h (act_create_kernel): Remove prototype without definition.
+
+2013-12-08 Samuel Thibault <address@hidden>
+
+ Add comment
+
+2013-12-08 Marin Ramesa <address@hidden>
+
+ ipc/port.h: update comment
+ This is ipc/port.h. Not ipc/ipc_port.h.
+
+ * ipc/port.h: Update comment.
+
+2013-12-08 Marin Ramesa <address@hidden>
+
+ 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/ipc_init.c: qualify constant with const
+ * ipc/ipc_init.c (ipc_kernel_map_size): Qualify constant with const.
+
+ i386/intel/pmap.c: remove unused variable
+ * i386/intel/pmap.c (end): Remove unused variable.
+
+ i386/intel/pmap.c: use boolean instead of an int
+ * i386/intel/pmap.c (pmap_debug): Use boolean instead of an int.
+
+ time: remove unused variable
+ * i386/i386at/rtc.c (tz): Remove unused variable.
+ * xen/time.c (tz): Remove unused variable.
+
+ 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/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: use boolean instead of an int
+ * i386/i386at/kd.c (mouse_in_use): Use boolean instead of an int.
+ Remove duplicate declaration.
+
+ 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/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/i386/user_ldt.c: remove unused variable
+ * i386/i386/user_ldt.c (acc_type): Remove unused variable.
+
+ 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: remove unused variable
+ * i386/i386/trap.c (brb): Remove unused variable.
+
+ i386/i386/pit.c: remove unused variables
+ * i386/i386/pit.c (pitctr1_port, pitctr2_port): Remove unused variables.
+
+ i386/i386/pic.c: remove unused variables
+ * i386/i386/pic.c (nintr, npics): Remove unused variables.
+
+ i386/i386/mp_desc.c: remove unused variable
+ * i386/i386/mp_desc.c (avail_start): Remove unused variable.
+
+2013-12-08 Marin Ramesa <address@hidden>
+
+ 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.
+
+2013-12-08 Marin Ramesa <address@hidden>
+
+ i386/i386/db_interface.c: use boolean instead of an int
+ * i386/i386/db_interface.c (kernel_dr): Use boolean instead of an int.
+
+2013-12-08 Marin Ramesa <address@hidden>
+
+ 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.
+
+2013-12-08 Marin Ramesa <address@hidden>
+
+ device/kmsg.c: use boolean instead of an int
+ * device/kmsg.c (kmsg_init_done): Use boolean instead of an int.
+
+ device/kmsg.c: use boolean instead of an int
+ * device/kmsg.c (kmsg_in_use): Use boolean instead of an int.
+
+ device/if_ether.h: remove unused variable
+ * device/if_ether.h (etherbroadcastaddr): Remove unused variable.
+ * device/subrs.c (etherbroadcastaddr): Remove initialization.
+
+ device/dev_lookup.c: remove unused lock
+ * device/dev_lookup.c (dev_port_lock): Remove unused lock.
+
+ device/cirbuf.c: use boolean instead of an int
+ * device/cirbuf.c (cb_check_enable): Use boolean instead of an int.
+
+ device/chario.c: use boolean instead of an int
+ * device/chario.c (pdma_default): Use boolean instead of an int.
+
+2013-12-08 Marin Ramesa <address@hidden>
+
+ 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.
+
+2013-12-08 Marin Ramesa <address@hidden>
+
+ 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_command.h: remove duplicate variable declaration
+ * ddb/db_command.h (db_recover): Remove duplicate variable declaration.
+
+ ddb/db_command.c: remove forward declaration
+ * ddb/db_command.c (db_skip_to_eol): Remove forward declaration.
+
+2013-12-08 Marin Ramesa <address@hidden>
+
+ 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.
+
+2013-12-08 Marin Ramesa <address@hidden>
+
+ kern/machine.c: remove __volatile__
+ Shutdown can be optimised. Remove __volatile__.
+
+ * kern/machine.c [__GNUC__] (processor_doshutdown): Remove volatile
function qualifier.
+
+2013-12-08 Marin Ramesa <address@hidden>
+
+ ipc/ipc_port.c: trivial stylistic fix for consistency
+ * ipc/ipc_port.c (indent): Trivial stylistic fix for consistency.
+
+2013-12-08 Samuel Thibault <address@hidden>
+
+ Make unsigned character constants unsigned
+ Thanks Marin Ramesa for the report.
+
+ * i386/i386at/kd.h (K_DONE, NC, K_SCAN): Make constants unsigned.
+
+2013-12-08 Samuel Thibault <address@hidden>
+
+ Always make Assert trigger debugger
+ * kern/debug.c (Assert): Always call Debugger, even if
db_breakpoints_insert
+ is not set.
+
+2013-12-08 Samuel Thibault <address@hidden>
+
+ 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.
+
+2013-12-08 Marin Ramesa <address@hidden>
+
+ device/device_types_kernel.h: remove redeclaration of dev_port_lookup()
+ * device/device_types_kernel.h (dev_port_lookup): Remove prototype.
+
+ 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.
+
+ 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.
+
+2013-12-04 Samuel Thibault <address@hidden>
+
+ Add missing include
+ * ddb/db_variables.h: Include <machine/db_machdep.h>.
+
+2013-12-04 Marin Ramesa <address@hidden>
+
+ i386/i386at/com.h: include chips/busses.h for struct bus_device
+ * i386/i386at/com.h: Include chips/busses.h.
+
+ 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.
+
+ 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.
+
+ 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/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.
+
+ 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.
+
+ kern/time_stamp.c: remove multimax code
+ * kern/time_stamp.c [multimax]: Remove code.
+
+2013-12-04 Samuel Thibault <address@hidden>
+
+ Remove unnecessary file
+ * i386/Makefrag.am: Don't include i386/include/mach/i386/rpc.h.
+ * i386/include/mach/i386/rpc.h: Remove file.
+
+2013-12-04 Marin Ramesa <address@hidden>
+
+ vm/vm_user.c: remove forward declaration
+ * vm/vm_user.c (vm_map_machine_attribute): Remove forward declaration.
+
+2013-12-04 Marin Ramesa <address@hidden>
+
+ vm/vm_resident.c: correct comment
+ This is vm_resident.c, not vm_page.c.
+
+ * vm/vm_resident.c: Correct comment.
+
+2013-12-04 Marin Ramesa <address@hidden>
+
+ 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_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_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.
+
+2013-12-04 Marin Ramesa <address@hidden>
+
+ ipc/ipc_kmsg.h: update comment
+ Struct ipc_kmsg_queue is not defined in kern/thread.h.
+
+ * ipc/ipc_kmsg.h: Update comment.
+
+2013-12-04 Marin Ramesa <address@hidden>
+
+ kern: remove forward declaration
+ * kern/xpr.c (db_printf): Remove forward declaration.
+ [MACH_KDB] Include ddb/db_output.h.
+
+ kern/thread.c: remove forward declaration
+ * i386/i386/pcb.h (pcb_module_init): Add prototype.
+ * kern/thread.c (pcb_module_init): Remove forward declaration.
+
+ 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
+
+ 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/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/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.
+
+ 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/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/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.
+
+ kern/debug.c: remove forward declaration
+ * kern/debug.c (cnputc): Remove forward declaration.
+ Include device/cons.h.
+
+ 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.
+
+ 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/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_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.
+
+ 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.
+
+2013-12-04 Samuel Thibault <address@hidden>
+
+ 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.
+
+2013-12-04 Marin Ramesa <address@hidden>
+
+ 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.
+
+ 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_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.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/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/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.
+
+ 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.
+
+ 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.
+
+ 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/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/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/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.
+
+ 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.
+
+ 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_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_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: 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_sym.c: fix argument list
+ * ddb/db_sym.c (dummy_db_free_symbol): Fix argument list.
+
+ 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: 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.
+
+ ddb/db_aout.c: trivial stylistic fix for consistency
+ * ddb/db_aout.c: Trivial stylistic fix for consistency.
+
+ ddb/db_run.c: add comment after endif
+ * ddb/db_run.c [FIXUP_PC_AFTER_BREAK]: Add comment after endif.
+
+ 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_input.c: add comment after endif
+ * ddb/db_input.c [DB_HISTORY_SIZE]: Add comment after endif.
+
+ 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.
+
+ device/net_io.c: initialize hash_entp to NULL
+ * device/net_io.c (hash_entp): Initialize to NET_HASH_ENTRY_NULL.
+
+2013-11-24 Marin Ramesa <address@hidden>
+
+ 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.
+
+ 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.
+
+ ddb/db_examine.c: trivial stylistic fix for consistency
+ * ddb/db_examine.c: Trivial stylistic fix for consistency.
+
+ 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: 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: 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.
+
+ 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.
+
+2013-11-24 Samuel Thibault <address@hidden>
+
+ Simplify test
+ * ddb/db_sym.c (db_name_is_ambiguous): Simplify test for value returned
by
+ X_db_lookup.
+
+ Drop spurious volatile qualifier
+ * kern/processor.h (processor_doshutdown): Drop spurious volatile
qualifier.
+
+2013-11-24 Marin Ramesa <address@hidden>
+
+ 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: 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: move forward declaration into a header file
+ * kern/timer.c (timer_init): Remove forward declaration.
+ * kern/timer.h (timer_init): Add prototype.
+
+ kern: move forward declaration into a header file
+ * kern/mach_clock.c (softclock): Remove forward declaration.
+ * kern/timer.h (softclock): Add prototype.
+
+ 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.
+
+ 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: 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.
+
+2013-11-24 Samuel Thibault <address@hidden>
+
+ Merge branch 'master' of git.savannah.gnu.org:/srv/git/hurd/gnumach
+
+2013-11-24 Marin Ramesa <address@hidden>
+
+ 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.
+
+2013-11-24 Richard Braun <address@hidden>
+
+ 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.
+
+2013-11-24 Richard Braun <address@hidden>
+
+ Export mach_port_destroy declaration
+ * ipc/mach_port.h (mach_port_destroy): Add prototype.
+
+2013-11-22 Marin Ramesa <address@hidden>
+
+ ddb/db_break.c: remove duplicate include
+ * ddb/db_break.c: Don't include ddb/db_access.h.
+
+2013-11-21 Marin Ramesa <address@hidden>
+
+ i386/i386/db_interface.h: fix implicit declaration of function
+ * i386/i386/db_interface.h (cnpollc): Add prototype.
+
+ ddb/db_sym.c: move assignment outside if
+ * ddb/db_sym.c: Move assignment outside of if.
+ (db_lookup): New variable.
+
+ i386/i386at/kd.h: fix implicit declaration of function
+ * i386/i386at/kd.h [MACH_KDB] (kdb_kintr): Add prototype.
+
+ ddb/db_break.c: fix implicit declaration of functions
+ * ddb/db_break.c: Include machine/db_interface.h.
+
+2013-11-20 Marin Ramesa <address@hidden>
+
+ i386/i386/trap.c: fix implicit declaration of function
+ * i386/i386/trap.c: Include machine/db_interface.h.
+
+ 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.
+
+2013-11-20 Samuel Thibault <address@hidden>
+
+ Comment out db_search_null
+ * i386/i386/db_interface.c (db_search_null) [!GNU]: Do not define
+ db_search_null.
+
+2013-11-20 Marin Ramesa <address@hidden>
+
+ i386/i386/db_interface.c: add comments after else and endif
+ * i386/i386/db_interface.c [GNU]: Add comments after else and endif.
+
+2013-11-20 Marin Ramesa <address@hidden>
+
+ 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.
+
+2013-11-20 Marin Ramesa <address@hidden>
+
+ i386/i386/db_trace.c: fix implicit declaration of function
+ * i386/i386/db_trace.c: Include machine/db_interface.h.
+
+ i386/i386/db_interface.c: fix implicit declaration of function
+ * i386/i386/db_interface.c: Include string.h.
+
+ i386/i386/db_interface.c: fix implicit declaration of function
+ * i386/i386/db_interface.c: Include vm/vm_fault.h.
+
+ 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.
+
+ kern/xpr.c: quiet warning about uninitialized variable
+ * kern/xpr.c (s): Initialize.
+
+ kern/startup.c: fix implicit declaration of function
+ * kern/startup.c [MACH_KDB]: Include device/cons.h.
+
+ 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.
+
+ 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_run.c: move declaration of brpc into SOFTWARE_SSTEP
+ * ddb/db_run.c (brpc): Move declaration into SOFTWARE_SSTEP code.
+
+ ddb/db_run.c: trivial stylistic fix for consistency
+ * ddb/db_run.c: Trivial stylistic fix for consistency.
+
+ ddb/db_run.c: remove set but unused variable
+ * ddb/db_run.c (ins): Remove variable.
+
+ 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_examine.c: add missing cast
+ ddb/db_examine.c (addr, count): Cast to (db_expr_t *).
+
+ Add comment
+ * ddb/db_command.c [DB_MACHINE_COMMANDS]: Add comment after endif.
+
+2013-11-20 Samuel Thibault <address@hidden>
+
+ Drop volatile function qualifier
+ * i386/i386/setjmp.h (_longjmp): Drop volatile function qualifier.
+
+2013-11-20 Marin Ramesa <address@hidden>
+
+ ddb/db_break.c: quiet GCC warning about uninitialized variable
+ * ddb/db_break.c (bkpt): Initialize.
+
+2013-11-19 Marin Ramesa <address@hidden>
+
+ 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.
+
+2013-11-19 Marin Ramesa <address@hidden>
+
+ 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.
+
+2013-11-19 Marin Ramesa <address@hidden>
+
+ Add copyright
+ * ddb/db_write_cmd.h: Add copyright.
+ * ipc/ipc_print.h: Likewise.
+ * vm/vm_print.h: Likewise.
+
+2013-11-18 Marin Ramesa <address@hidden>
+
+ 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.
+
+2013-11-17 Marin Ramesa <address@hidden>
+
+ ddb/stab.h: add ifndef
+ * ddb/stab.h: Add ifndef.
+
+ ddb/db_write_cmd.c: remove register qualifiers
+ * ddb/db_write_cmd.c: Remove register qualifiers.
+
+ ddb/db_watch.c: remove register qualifiers
+ * ddb/db_watch.c: Remove register qualifiers.
+
+ ddb/db_variables.c: remove register qualifiers
+ * ddb/db_variables.c: Remove register qualifiers.
+
+ ddb/db_task_thread.c: remove register qualifiers
+ * ddb/db_task_thread.c: Remove register qualifiers.
+
+ ddb/db_sym.h: add comment after endif
+ * ddb/db_sym.h: Add comment after endif.
+
+ ddb/db_sym.c: remove register qualifiers
+ * ddb/db_sym.c: Remove register qualifiers.
+
+ ddb/db_run.h: add ifndef
+ * ddb/db_run.h: Add ifndef.
+
+ ddb/db_run.c: remove register qualifiers
+ * ddb/db_run.c: Remove register qualifiers.
+
+ ddb/db_print.c: remove register qualifiers
+ * ddb/db_print.c: Remove register qualifiers.
+
+ ddb/db_output.h: add ifndef
+ * ddb/db_output.h: Add ifndef.
+
+ ddb/db_output.c: remove register qualifiers
+ * ddb/db_output.c: Remove register qualifiers.
+
+ ddb/db_mp.c: remove register qualifier
+ * ddb/db_mp.c: Remove register qualifier.
+
+ ddb/db_macro.c: remove register qualifiers
+ * ddb/db_macro.c: Remove register qualifiers.
+
+ ddb/db_lex.h: add ifndef
+ * ddb/db_lex.h: Add ifndef.
+
+ ddb/db_lex.c: remove register qualifiers
+ * ddb/db_lex.c: Remove register qualifiers.
+
+ ddb/db_input.c: remove register qualifiers
+ * ddb/db_input.c: Remove register qualifiers.
+
+ ddb/db_expr.c: remove register qualifier
+ * ddb/db_expr.c: Remove register qualifier.
+
+ ddb/db_examine.c: remove register qualifiers
+ * ddb/db_examine.c: Remove register qualifiers.
+
+ ddb/db_cond.c: remove register qualifiers
+ * ddb/db_cond.c: Remove register qualifiers.
+
+ ddb/db_command.h: add ifndef
+ * ddb/db_command.h: Add ifndef.
+
+ ddb/db_command.c: remove register qualifiers
+ * ddb/db_command.c: Remove register qualifiers.
+
+ ddb/db_break.c: remove register qualifiers
+ * ddb/db_break.c: Remove register qualifiers.
+
+ ddb/db_aout.c: remove register qualifiers
+ * ddb/db_aout.c: Remove register qualifiers.
+
+ ddb/db_access.h: add ifndef
+ * ddb/db_access.h: Add ifndef.
+
+ ddb/db_access.c: remove register qualifiers
+ * ddb/db_access.c: Remove register qualifiers.
+
+2013-11-17 Samuel Thibault <address@hidden>
+
+ 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.
+
+2013-11-15 Marin Ramesa <address@hidden>
+
+ i386/intel/read_fault.c: remove register qualifier
+ * i386/intel/read_fault.c: Remove register qualifier.
+
+ i386/intel/pmap.h: remove register qualifiers
+ * i386/intel/pmap.h: Remove register qualifiers.
+
+ i386/intel/pmap.c: remove register qualifiers
+ * i386/intel/pmap.c: Remove register qualifiers.
+
+ i386/i386at/rtc.h: remove register qualifiers
+ * i386/i386at/rtc.h: Remove register qualifiers.
+
+ i386/i386at/rtc.c: remove register qualifier
+ * i386/i386at/rtc.c: Remove register qualifier.
+
+ i386/i386at/lpr.c: remove register qualifier
+ * i386/i386at/lpr.c: Remove register qualifier.
+
+ i386/i386at/kd_mouse.c: remove register qualifiers
+ * i386/i386at/kd_mouse.c: Remove register qualifiers.
+
+ i386/i386at/kd.c: remove register qualifiers
+ * i386/i386at/kd.c: Remove register qualifiers.
+
+ i386/i386at/kd_event.c: remove register qualifiers
+ * i386/i386at/kd_event.c: Remove register qualifiers.
+
+ i386/i386at/int_init.h: add comment after endif
+ * i386/i386at/int_init.h (__ASSEMBLER__): Add comment after endif.
+
+ i386/i386at/idt.h: add comment after endif
+ * i386/i386at/idt.h (__ASSEMBLER__): Add comment after endif.
+
+ i386/i386at/com.c: remove register qualifiers
+ * i386/i386at/com.c: Remove register qualifiers.
+
+ i386/i386at/com.c: trivial stylistic fix for consistency
+ * i386/i386at/com.c: Trivial stylistic fix for consistency.
+
+ i386/i386at/autoconf.c: remove register qualifiers
+ * i386/i386at/autoconf.c: Remove register qualifiers.
+
+ i386/i386/trap.c: remove register qualifiers
+ * i386/i386/trap.c: Remove register qualifiers.
+
+ i386/i386/thread.h: add comment after endif
+ * i386/i386/thread.h (LINUX_DEV): Add comment after endif.
+
+ i386/i386/pic.h: add comment after endif
+ * i386/i386/pic.h (__ASSEMBLER__): Add comment after endif.
+
+ i386/i386/pcb.c: remove register qualifiers
+ * i386/i386/pcb.c: Remove register qualifiers.
+
+ i386/i386/mp_desc.c: remove register qualifiers
+ * i386/i386/mp_desc.c: Remove register qualifiers.
+
+ i386/i386/machine_routines.h: add comment after endif
+ * i386/i386/machine_routines.h (_I386_MACHINE_ROUTINES_H_): Add comment
after endif.
+
+ i386/i386/loose_ends.c: remove unused variable
+ * i386/i386/loose_ends.c (boothowto): Remove unused variable.
+
+ i386/i386/loose_ends.c: add comment after endif
+ * i386/i386/loose_ends.c (NDEBUG): Add comment after endif.
+
+ i386/i386/lock.h: remove register quaalifier
+ * i386/i386/lock.h: Remove register qualifier.
+
+ i386/i386/kttd_interface.c: trivial stylistic fix for consistency
+ * i386/i386/kttd_interface.c: Trivial stylistic fix for consistency.
+
+ i386/i386/hardclock.c: add comment after endif
+ * i386/i386/hardclock.c (LINUX_DEV): Add comment after endif.
+
+ i386/i386/fpu.h: remove register qualifiers
+ * i386/i386/fpu.h: Remove register qualifiers.
+
+ i386/i386/fpu.c: remove register qualifiers
+ * i386/i386/fpu.c: Remove register qualifiers.
+
+ i386/i386/db_trace.c: qualify constants with const
+ * i386/i386/db_trace.c: Qualify constants with const.
+
+ i386/i386/db_trace.c: remove register qualifiers
+ * i386/i386/db_trace.c: Remove register qualifiers.
+
+ i386/i386/db_interface.c: remove register qualifiers
+ * i386/i386/db_interface.c: Remove register qualifiers.
+
+ Fix typo
+
+ 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/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.
+
+ chips/busses.c: remove register qualifiers
+ * chips/busses.c: Remove register qualifiers.
+
+ chips/busses.c: use boolean instead of an int
+ * chips/busses.c (found): Constrain range of values to a boolean.
+
+ vm/vm_user.c: remove register qualifiers
+ * vm/vm_user.c: Remove register qualifiers.
+
+ vm/vm_resident.c: remove register qualifiers
+ * vm/vm_resident.c: Remove register qualifiers.
+
+ vm/vm_pageout.c: remove register qualifiers
+ * vm/vm_pageout.c: Remove register qualifiers.
+
+ vm/vm_object.c: remove register qualifiers
+ * vm/vm_object.c: Remove register qualifiers.
+
+ vm/vm_map.c: remove register qualifiers
+ * vm/vm_map.c: Remove register qualifiers.
+
+ vm/vm_map.c: trivial stylistic fix for consistency
+ * vm/vm_map.c: Trivial stylistic fix for consistency.
+
+ vm/vm_kern.c: remove register qualifiers
+ * vm/vm_kern.c: Remove register qualifiers.
+
+ vm/vm_fault.c: remove register qualifiers
+ * vm/vm_fault.c: Remove register qualifiers.
+
+ vm/vm_fault.c: remove unused variable
+ * vm/vm_fault.c: Remove unused variable.
+
+ vm/memory_object_proxy.h: fix definition
+ * vm/memory_object_proxy.h (_VM_MEMORY_OBJECT_PROXY_H_): Fix definition.
+
+ vm/memory_object.c: remove register qualifiers
+ * vm/memory_object.c: Remove register qualifiers.
+
+2013-11-13 Marin Ramesa <address@hidden>
+
+ kern: remove register qualifiers
+ * kern/xpr.c: Remove register qualifiers.
+
+ kern: remove register qualifiers
+ * kern/timer.h: Remove register qualifiers.
+
+ kern: remove register qualifiers
+ * kern/timer.c: Remove register qualifiers.
+
+ kern: remove register qualifiers
+ * kern/thread_swap.c: Remove register qualifiers.
+
+ kern: remove register qualifiers
+ * kern/thread.c: Remove register qualifiers.
+
+ kern: remove register qualifiers
+ * kern/task.c: Remove register qualifiers.
+
+ kern: remove register qualifiers
+ * kern/syscall_subr.c: Remove register qualifiers.
+
+ kern: remove register qualifiers
+ * kern/syscall_emulation.c: Remove register qualifiers.
+
+ kern: remove register qualifiers
+ * kern/strings.c: Remove register qualifiers.
+
+ kern: remove register qualifiers
+ * kern/startup.c: Remove register qualifiers.
+
+ kern: remove register qualifiers
+ * kern/sched_prim.c: Remove register qualifiers.
+
+ kern: remove register qualifiers
+ * kern/sched.h: Remove register qualifiers.
+
+ kern: remove register qualifiers
+ * kern/queue.h: Remove register qualifiers.
+
+ kern: remove register qualifiers
+ * kern/queue.c: Remove register qualifiers.
+
+ kern: remove register qualifiers
+ * kern/processor.c: Remove register qualifiers.
+
+ kern: remove register qualifiers
+ * kern/priority.c: Remove register qualifiers.
+
+ kern: remove register qualifiers
+ * kern/printf.c: Remove register qualifiers.
+
+ kern: remove register qualifiers
+ * kern/pc_sample.c: Remove register qualifiers.
+
+ kern: remove register qualifiers
+ * kern/machine.c: Remove register qualifiers.
+
+ kern: remove register qualifiers
+ * kern/mach_factor.c: Remove register qualifiers.
+
+ kern: remove register qualifiers
+ * kern/mach_clock.c: Remove register qualifiers.
+
+ kern: remove register qualifiers
+ * kern/lock_mon.c: Remove register qualifiers.
+
+ kern: remove register qualifiers
+ * kern/lock.c: Remove register qualifiers.
+
+ kern: remove register qualifiers
+ * kern/ipc_tt.c: Remove register qualifiers.
+
+ kern: remove register qualifiers
+ * kern/ipc_sched.c: Remove register qualifiers.
+
+ kern: remove register qualifiers
+ * kern/ipc_mig.c: Remove register qualifiers.
+
+ kern: remove register qualifiers
+ * kern/host.c: Remove register qualifiers.
+
+ kern: remove register qualifiers
+ * kern/exception.c: Remove register qualifiers.
+
+ kern: remove register qualifiers
+ * kern/eventcount.c: Remove register qualifiers.
+
+ kern: remove register qualifiers
+ * kern/bootstrap.c: Remove register qualifiers.
+
+ kern: remove register qualifiers
+ * kern/ast.c: Remove register qualifiers.
+
+ kern: remove register qualifiers
+ * kern/act.c: Remove register qualifiers.
+
+2013-11-11 Marin Ramesa <address@hidden>
+
+ ipc: remove register qualifiers
+ * ipc/ipc_thread.h: Remove register qualifiers.
+
+ ipc: remove register qualifiers
+ * ipc/mach_msg.c: Remove register qualifiers.
+
+ ipc: qualify constants with const
+ * ipc/ipc_table.c: Qualify constants with const.
+
+ ipc: trivial stylistic fix for consistency
+ * ipc/ipc_pset.c: Trivial stylistic fix for consistency.
+
+2013-11-11 Samuel Thibault <address@hidden>
+
+ Merge branch 'master' of git.savannah.gnu.org:/srv/git/hurd/gnumach
+
+2013-11-11 Marin Ramesa <address@hidden>
+
+ ipc: remove register qualifiers
+ * ipc/ipc_kmsg.c: Remove register qualifiers.
+
+2013-11-11 Justus Winter <address@hidden>
+
+ kern: fix the error handling in exec_load
+ Found using the Clang Static Analyzer.
+
+ * kern/elf-load.c (exec_load): Properly propagate errors.
+
+2013-11-10 Marin Ramesa <address@hidden>
+
+ 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.
+
+2013-11-10 Marin Ramesa <address@hidden>
+
+ device: initialize to zero offset
+ Initialize addr to zero offset to quiet warnings about uninitialized
+ deallocation.
+
+ * device/chario.c (addr): Initialize to zero.
+
+2013-11-10 Marin Ramesa <address@hidden>
+
+ remove register qualifiers
+ * device/subrs.c: Remove register qualifiers.
+
+ remove register qualifiers
+ * device/net_io.c: Remove register qualifiers.
+
+ remove definitions of ETHERMTU and ETHERMIN
+ * device/if_ether.h (ETHERMTU, ETHERMIN): Remove unused definitions.
+
+ remove register qualifiers
+ * device/blkio.c: Remove register qualifiers.
+
+2013-11-09 Vladimir 'φ-coder/phcoder' Serbinenko <address@hidden>
+
+ 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.
+
+2013-11-09 Marin Ramesa <address@hidden>
+
+ Remove lint code
+
+2013-10-10 Richard Braun <address@hidden>
+
+ Increase kernel map entry pool size
+ * vm/vm_map.h (KENTRY_DATA_SIZE): Set to 256 pages.
+
+2013-09-28 Samuel Thibault <address@hidden>
+
+ 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.
+
2013-09-27 Thomas Schwinge <address@hidden>
+ Merge remote-tracking branch 'savannah/master' into master
+
GNU Mach 1.4.
* version.m4 (AC_PACKAGE_VERSION): Set to 1.4.
* NEWS: Finalize changes for 1.4.
@@ -21,6 +2989,11 @@
* README: Simplify build instructions.
Follow-up to commit 471e5b080f7790c2cf95e3069d9fed1173c9ec17.
+2013-09-27 Svante Signell <address@hidden>
+
+ Fix typo
+ * README: Fix typo.
+
2013-09-26 Samuel Thibault <address@hidden>
Fix gpl.texi build
diff --git a/INSTALL b/INSTALL
index 007e939..2099840 100644
--- a/INSTALL
+++ b/INSTALL
@@ -12,8 +12,8 @@ without warranty of any kind.
Basic Installation
==================
- Briefly, the shell commands `./configure; make; make install' should
-configure, build, and install this package. The following
+ Briefly, the shell command `./configure && make && make install'
+should configure, build, and install this package. The following
more-detailed instructions are generic; see the `README' file for
instructions specific to this package. Some packages provide this
`INSTALL' file but do not implement all of the features documented
diff --git a/Makefile.am b/Makefile.am
index 918cdc3..cb8c096 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. ; \
+ false ; fi
gnumach_LINK = $(LD) $(LINKFLAGS) $(gnumach_LINKFLAGS) -o $@
gnumach_LDADD = gnumach.o clib-routines.o
diff --git a/Makefile.in b/Makefile.in
index 5bbbbd1..a3870ca 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.13.3 from Makefile.am.
+# Makefile.in generated by automake 1.14.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2013 Free Software Foundation, Inc.
@@ -379,7 +379,7 @@ DIST_COMMON = $(srcdir)/Makerules.am
$(srcdir)/Makerules.mig.am \
$(top_srcdir)/build-aux/mdate-sh $(srcdir)/doc/version.texi \
$(srcdir)/doc/stamp-vti $(top_srcdir)/build-aux/texinfo.tex \
$(include_device_HEADERS) $(include_mach_HEADERS) \
- $(include_mach_eXec_HEADERS) \
+ $(include_mach_debug_HEADERS) $(include_mach_eXec_HEADERS) \
$(am__include_mach_i386_HEADERS_DIST) \
$(top_srcdir)/build-aux/test-driver COPYING build-aux/compile \
build-aux/config.guess build-aux/config.sub build-aux/depcomp \
@@ -395,6 +395,9 @@ DIST_COMMON = $(srcdir)/Makerules.am
$(srcdir)/Makerules.mig.am \
@enable_kdb_TRUE@ ddb/db_access.c \
@enable_kdb_TRUE@ ddb/db_access.h \
@enable_kdb_TRUE@ ddb/db_aout.c \
address@hidden@ ddb/db_aout.h \
address@hidden@ ddb/db_elf.c \
address@hidden@ ddb/db_elf.h \
@enable_kdb_TRUE@ ddb/db_break.c \
@enable_kdb_TRUE@ ddb/db_break.h \
@enable_kdb_TRUE@ ddb/db_command.c \
@@ -413,6 +416,7 @@ DIST_COMMON = $(srcdir)/Makerules.am
$(srcdir)/Makerules.mig.am \
@enable_kdb_TRUE@ ddb/db_macro.c \
@enable_kdb_TRUE@ ddb/db_macro.h \
@enable_kdb_TRUE@ ddb/db_mp.c \
address@hidden@ ddb/db_mp.h \
@enable_kdb_TRUE@ ddb/db_output.c \
@enable_kdb_TRUE@ ddb/db_output.h \
@enable_kdb_TRUE@ ddb/db_print.c \
@@ -430,6 +434,7 @@ DIST_COMMON = $(srcdir)/Makerules.am
$(srcdir)/Makerules.mig.am \
@enable_kdb_TRUE@ ddb/db_watch.c \
@enable_kdb_TRUE@ ddb/db_watch.h \
@enable_kdb_TRUE@ ddb/db_write_cmd.c \
address@hidden@ ddb/db_write_cmd.h \
@enable_kdb_TRUE@ ddb/nlist.h \
@enable_kdb_TRUE@ ddb/stab.h \
@enable_kdb_TRUE@ ddb/tr.h
@@ -965,9 +970,10 @@ DIST_COMMON = $(srcdir)/Makerules.am
$(srcdir)/Makerules.mig.am \
@HOST_ix86_TRUE@ i386/i386at/cons_conf.c \
@HOST_ix86_TRUE@ i386/i386at/idt.h \
@HOST_ix86_TRUE@ i386/i386at/model_dep.c \
address@hidden@ i386/i386at/model_dep.h \
@HOST_ix86_TRUE@ i386/include/mach/sa/stdarg.h
address@hidden@@address@hidden = \
address@hidden@@address@hidden = \
@HOST_ix86_TRUE@@PLATFORM_at_TRUE@ i386/i386at/boothdr.S \
@HOST_ix86_TRUE@@PLATFORM_at_TRUE@ i386/i386at/com.c \
@HOST_ix86_TRUE@@PLATFORM_at_TRUE@ i386/i386at/com.h \
@@ -990,17 +996,34 @@ DIST_COMMON = $(srcdir)/Makerules.am
$(srcdir)/Makerules.mig.am \
@HOST_ix86_TRUE@@PLATFORM_at_TRUE@ i386/i386at/kdasm.S \
@HOST_ix86_TRUE@@PLATFORM_at_TRUE@ i386/i386at/kdsoft.h \
@HOST_ix86_TRUE@@PLATFORM_at_TRUE@ i386/i386at/mem.c \
address@hidden@@PLATFORM_at_TRUE@ i386/i386at/mem.h \
@HOST_ix86_TRUE@@PLATFORM_at_TRUE@ i386/i386at/pic_isa.c \
@HOST_ix86_TRUE@@PLATFORM_at_TRUE@ i386/i386at/rtc.c \
address@hidden@@PLATFORM_at_TRUE@ i386/i386at/rtc.h
-
address@hidden@@PLATFORM_at_TRUE@ i386/i386at/rtc.h \
address@hidden@@PLATFORM_at_TRUE@ i386/i386at/acpihalt.c \
address@hidden@@PLATFORM_at_TRUE@ i386/i386at/acpihalt.h \
address@hidden@@PLATFORM_at_TRUE@ i386/i386at/acpi.c \
address@hidden@@PLATFORM_at_TRUE@ i386/i386at/grub_glue.c \
address@hidden@@PLATFORM_at_TRUE@ i386/grub/err.h \
address@hidden@@PLATFORM_at_TRUE@ i386/grub/cpu/io.h \
address@hidden@@PLATFORM_at_TRUE@ i386/grub/cpu/types.h \
address@hidden@@PLATFORM_at_TRUE@ i386/grub/cpu/time.h \
address@hidden@@PLATFORM_at_TRUE@ i386/grub/mm.h \
address@hidden@@PLATFORM_at_TRUE@ i386/grub/acpi.h \
address@hidden@@PLATFORM_at_TRUE@ i386/grub/symbol.h \
address@hidden@@PLATFORM_at_TRUE@ i386/grub/misc.h \
address@hidden@@PLATFORM_at_TRUE@ i386/grub/types.h \
address@hidden@@PLATFORM_at_TRUE@ i386/grub/time.h \
address@hidden@@PLATFORM_at_TRUE@ i386/grub/i18n.h \
address@hidden@@PLATFORM_at_TRUE@ i386/grub/compiler.h \
address@hidden@@PLATFORM_at_TRUE@ i386/grub/glue.h
#
# `lpr' device support.
#
@HOST_ix86_TRUE@@address@hidden = \
@HOST_ix86_TRUE@@enable_lpr_TRUE@ i386/i386at/lpr.c \
address@hidden@@enable_lpr_TRUE@ i386/i386at/lprreg.h
address@hidden@@enable_lpr_TRUE@ i386/i386at/lpr.h
#
@@ -1017,6 +1040,7 @@ DIST_COMMON = $(srcdir)/Makerules.am
$(srcdir)/Makerules.mig.am \
@HOST_ix86_TRUE@ i386/i386/db_interface.h \
@HOST_ix86_TRUE@ i386/i386/db_machdep.h \
@HOST_ix86_TRUE@ i386/i386/db_trace.c \
address@hidden@ i386/i386/db_trace.h \
@HOST_ix86_TRUE@ i386/i386/debug.h \
@HOST_ix86_TRUE@ i386/i386/debug_i386.c \
@HOST_ix86_TRUE@ i386/i386/debug_trace.S \
@@ -1070,7 +1094,6 @@ DIST_COMMON = $(srcdir)/Makerules.am
$(srcdir)/Makerules.mig.am \
@HOST_ix86_TRUE@ i386/i386/user_ldt.c \
@HOST_ix86_TRUE@ i386/i386/user_ldt.h \
@HOST_ix86_TRUE@ i386/i386/vm_param.h \
address@hidden@ i386/i386/vm_tuning.h \
@HOST_ix86_TRUE@ i386/i386/xpr.h \
@HOST_ix86_TRUE@ i386/intel/pmap.c \
@HOST_ix86_TRUE@ i386/intel/pmap.h \
@@ -1093,6 +1116,7 @@ DIST_COMMON = $(srcdir)/Makerules.am
$(srcdir)/Makerules.mig.am \
@HOST_ix86_TRUE@ i386/README-Drivers i386/include
@HOST_ix86_TRUE@@address@hidden = \
@HOST_ix86_TRUE@@PLATFORM_at_TRUE@ i386/i386/hardclock.c \
address@hidden@@PLATFORM_at_TRUE@ i386/i386/hardclock.h \
@HOST_ix86_TRUE@@PLATFORM_at_TRUE@ i386/i386/io_map.c \
@HOST_ix86_TRUE@@PLATFORM_at_TRUE@ i386/i386/pic.c \
@HOST_ix86_TRUE@@PLATFORM_at_TRUE@ i386/i386/pic.h \
@@ -1197,23 +1221,25 @@ lib_dep_tr_for_defs_a_OBJECTS = \
libkernel_a_AR = $(AR) $(ARFLAGS)
libkernel_a_LIBADD =
am__libkernel_a_SOURCES_DIST = ddb/db_access.c ddb/db_access.h \
- ddb/db_aout.c ddb/db_break.c ddb/db_break.h ddb/db_command.c \
+ 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 \
ddb/db_command.h ddb/db_cond.c ddb/db_cond.h ddb/db_examine.c \
ddb/db_examine.h ddb/db_expr.c ddb/db_expr.h \
ddb/db_ext_symtab.c ddb/db_input.c ddb/db_input.h ddb/db_lex.c \
ddb/db_lex.h ddb/db_macro.c ddb/db_macro.h ddb/db_mp.c \
- ddb/db_output.c ddb/db_output.h ddb/db_print.c ddb/db_print.h \
- ddb/db_run.c ddb/db_run.h ddb/db_sym.c ddb/db_sym.h \
- ddb/db_task_thread.c ddb/db_task_thread.h ddb/db_trap.c \
- ddb/db_trap.h ddb/db_variables.c ddb/db_variables.h \
- ddb/db_watch.c ddb/db_watch.h ddb/db_write_cmd.c ddb/nlist.h \
- ddb/stab.h ddb/tr.h 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 ipc/ipc_kmsg.h ipc/ipc_kmsg_queue.h \
- ipc/ipc_machdep.h ipc/ipc_marequest.c ipc/ipc_marequest.h \
- ipc/ipc_mqueue.c ipc/ipc_mqueue.h ipc/ipc_notify.c \
- ipc/ipc_notify.h ipc/ipc_object.c ipc/ipc_object.h \
- ipc/ipc_port.c ipc/ipc_port.h ipc/ipc_pset.c ipc/ipc_pset.h \
+ ddb/db_mp.h ddb/db_output.c ddb/db_output.h ddb/db_print.c \
+ ddb/db_print.h ddb/db_run.c ddb/db_run.h ddb/db_sym.c \
+ ddb/db_sym.h ddb/db_task_thread.c ddb/db_task_thread.h \
+ ddb/db_trap.c ddb/db_trap.h ddb/db_variables.c \
+ ddb/db_variables.h 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 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 \
+ ipc/ipc_kmsg.h ipc/ipc_kmsg_queue.h ipc/ipc_machdep.h \
+ ipc/ipc_marequest.c ipc/ipc_marequest.h ipc/ipc_mqueue.c \
+ ipc/ipc_mqueue.h ipc/ipc_notify.c ipc/ipc_notify.h \
+ ipc/ipc_object.c 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 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 \
@@ -1221,48 +1247,51 @@ am__libkernel_a_SOURCES_DIST = ddb/db_access.c
ddb/db_access.h \
ipc/ipc_types.h ipc/mach_msg.c ipc/mach_msg.h ipc/mach_port.c \
ipc/mach_port.h ipc/mach_rpc.c ipc/mach_debug.c ipc/port.h \
kern/act.c kern/act.h kern/assert.h kern/ast.c kern/ast.h \
- kern/boot_script.h kern/bootstrap.c kern/counters.c \
- kern/counters.h kern/cpu_number.h kern/debug.c kern/debug.h \
- kern/eventcount.c kern/eventcount.h kern/exception.c \
- kern/host.c kern/host.h kern/ipc_host.c kern/ipc_host.h \
- kern/ipc_kobject.c kern/ipc_kobject.h kern/ipc_mig.c \
- kern/ipc_mig.h kern/ipc_sched.c kern/ipc_sched.h kern/ipc_tt.c \
- kern/ipc_tt.h kern/kalloc.h kern/kern_types.h kern/list.h \
- kern/lock.c kern/lock.h kern/lock_mon.c kern/mach_clock.c \
+ kern/boot_script.h kern/bootstrap.c kern/bootstrap.h \
+ kern/counters.c kern/counters.h kern/cpu_number.h kern/debug.c \
+ kern/debug.h kern/eventcount.c kern/eventcount.h \
+ kern/exception.c kern/exception.h kern/host.c kern/host.h \
+ kern/ipc_host.c kern/ipc_host.h kern/ipc_kobject.c \
+ kern/ipc_kobject.h kern/ipc_mig.c kern/ipc_mig.h \
+ kern/ipc_sched.c kern/ipc_sched.h kern/ipc_tt.c kern/ipc_tt.h \
+ kern/kalloc.h kern/kern_types.h kern/list.h kern/lock.c \
+ kern/lock.h kern/lock_mon.c kern/mach_clock.c \
kern/mach_clock.h kern/mach_factor.c kern/mach_factor.h \
kern/machine.c kern/machine.h kern/macro_help.h \
kern/pc_sample.c kern/pc_sample.h kern/printf.c kern/printf.h \
- kern/priority.c kern/processor.c kern/processor.h \
- kern/profile.c kern/queue.c kern/queue.h kern/rbtree.c \
- kern/rbtree.h kern/rbtree_i.h kern/refcount.h kern/slab.c \
- kern/slab.h kern/sched.h kern/sched_prim.c kern/sched_prim.h \
- kern/shuttle.h kern/startup.c kern/strings.c \
- kern/syscall_emulation.c kern/syscall_emulation.h \
- kern/syscall_subr.c kern/syscall_subr.h kern/syscall_sw.c \
- kern/syscall_sw.h kern/task.c kern/task.h kern/thread.c \
- kern/thread.h kern/thread_swap.c kern/thread_swap.h \
- kern/time_stamp.c kern/time_stamp.h kern/timer.c kern/timer.h \
- kern/xpr.c kern/xpr.h kern/elf-load.c kern/boot_script.c \
- util/putchar.c util/putchar.h util/puts.c util/atoi.c \
- util/atoi.h vm/memory_object_proxy.c vm/memory_object_proxy.h \
+ kern/priority.c kern/priority.h kern/processor.c \
+ kern/processor.h kern/profile.c kern/queue.c kern/queue.h \
+ kern/rbtree.c kern/rbtree.h kern/rbtree_i.h kern/refcount.h \
+ kern/slab.c kern/slab.h kern/sched.h kern/sched_prim.c \
+ kern/sched_prim.h kern/shuttle.h kern/startup.c kern/startup.h \
+ kern/strings.c kern/syscall_emulation.c \
+ kern/syscall_emulation.h kern/syscall_subr.c \
+ kern/syscall_subr.h kern/syscall_sw.c kern/syscall_sw.h \
+ kern/task.c kern/task.h kern/thread.c kern/thread.h \
+ kern/thread_swap.c kern/thread_swap.h kern/time_stamp.c \
+ kern/time_stamp.h kern/timer.c kern/timer.h kern/xpr.c \
+ kern/xpr.h kern/elf-load.c kern/boot_script.c util/putchar.c \
+ util/putchar.h util/puts.c util/atoi.c util/atoi.h \
+ vm/memory_object_proxy.c vm/memory_object_proxy.h \
vm/memory_object.c vm/memory_object.h vm/pmap.h vm/vm_debug.c \
vm/vm_external.c vm/vm_external.h vm/vm_fault.c vm/vm_fault.h \
- vm/vm_init.c vm/vm_kern.c vm/vm_kern.h vm/vm_map.c vm/vm_map.h \
- vm/vm_object.c vm/vm_object.h vm/vm_page.h vm/vm_pageout.c \
- vm/vm_pageout.h vm/vm_resident.c vm/vm_resident.h \
- vm/vm_types.h vm/vm_user.c vm/vm_user.h device/blkio.c \
- device/buf.h device/chario.c device/cirbuf.h device/conf.h \
+ vm/vm_init.c vm/vm_init.h vm/vm_kern.c vm/vm_kern.h \
+ vm/vm_map.c vm/vm_map.h vm/vm_object.c vm/vm_object.h \
+ 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 vm/vm_user.c \
+ vm/vm_user.h device/blkio.c device/blkio.h device/buf.h \
+ device/chario.c device/chario.h device/cirbuf.h device/conf.h \
device/cons.c device/cons.h device/device_emul.h \
device/dev_hdr.h device/dev_lookup.c device/dev_master.h \
- device/dev_name.c device/dev_pager.c device/device_init.c \
- device/device_port.h device/device_types_kernel.h \
- device/ds_routines.c device/ds_routines.h device/if_ether.h \
- device/if_hdr.h device/io_req.h device/net_io.c \
- device/net_io.h device/param.h device/subrs.c device/subrs.h \
- device/tty.h device/kmsg.c device/kmsg.h \
- xen/public/arch-x86_32.h xen/public/arch-x86_64.h \
- xen/public/arch-x86/xen.h xen/public/arch-x86/xen-mca.h \
- xen/public/arch-x86/xen-x86_32.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 \
+ device/device_types_kernel.h device/ds_routines.c \
+ device/ds_routines.h device/if_ether.h device/if_hdr.h \
+ device/io_req.h device/net_io.c device/net_io.h device/param.h \
+ device/subrs.c device/subrs.h device/tty.h device/kmsg.c \
+ device/kmsg.h xen/public/arch-x86_32.h \
+ xen/public/arch-x86_64.h xen/public/arch-x86/xen.h \
+ xen/public/arch-x86/xen-mca.h xen/public/arch-x86/xen-x86_32.h \
xen/public/arch-x86/xen-x86_64.h xen/public/callback.h \
xen/public/COPYING xen/public/dom0_ops.h xen/public/domctl.h \
xen/public/elfnote.h xen/public/elfstructs.h \
@@ -1284,22 +1313,30 @@ am__libkernel_a_SOURCES_DIST = ddb/db_access.c
ddb/db_access.h \
xen/store.h xen/time.c xen/time.h xen/xen.c xen/xen.h \
i386/i386at/autoconf.c i386/i386at/autoconf.h \
i386/i386at/conf.c i386/i386at/cons_conf.c i386/i386at/idt.h \
- i386/i386at/model_dep.c i386/include/mach/sa/stdarg.h \
- i386/i386at/boothdr.S i386/i386at/com.c i386/i386at/com.h \
- i386/i386at/comreg.h i386/i386at/cram.h i386/i386at/disk.h \
- i386/i386at/i8250.h i386/i386at/immc.c i386/i386at/int_init.c \
+ i386/i386at/model_dep.c i386/i386at/model_dep.h \
+ i386/include/mach/sa/stdarg.h i386/i386at/boothdr.S \
+ i386/i386at/com.c i386/i386at/com.h i386/i386at/comreg.h \
+ i386/i386at/cram.h i386/i386at/disk.h i386/i386at/i8250.h \
+ i386/i386at/immc.c i386/i386at/int_init.c \
i386/i386at/int_init.h i386/i386at/interrupt.S \
i386/i386at/kd.c i386/i386at/kd.h i386/i386at/kd_event.c \
i386/i386at/kd_event.h i386/i386at/kd_queue.c \
i386/i386at/kd_queue.h i386/i386at/kd_mouse.c \
i386/i386at/kd_mouse.h i386/i386at/kdasm.S \
- i386/i386at/kdsoft.h i386/i386at/mem.c i386/i386at/pic_isa.c \
- i386/i386at/rtc.c i386/i386at/rtc.h i386/i386at/lpr.c \
- i386/i386at/lprreg.h i386/i386/ast.h i386/i386/ast_check.c \
- i386/i386/ast_types.h i386/i386/cpu_number.h \
- i386/i386/cswitch.S i386/i386/db_disasm.c \
- i386/i386/db_interface.c i386/i386/db_interface.h \
- i386/i386/db_machdep.h i386/i386/db_trace.c i386/i386/debug.h \
+ 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 \
+ 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 \
+ i386/i386at/lpr.c i386/i386at/lpr.h i386/i386/ast.h \
+ i386/i386/ast_check.c i386/i386/ast_types.h \
+ i386/i386/cpu_number.h i386/i386/cswitch.S \
+ i386/i386/db_disasm.c i386/i386/db_interface.c \
+ 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 \
i386/i386/eflags.h i386/i386/fpu.c i386/i386/fpu.h \
i386/i386/gdt.c i386/i386/gdt.h i386/i386/idt-gen.h \
@@ -1319,15 +1356,16 @@ am__libkernel_a_SOURCES_DIST = ddb/db_access.c
ddb/db_access.h \
i386/i386/task.h i386/i386/thread.h i386/i386/time_stamp.h \
i386/i386/trap.c i386/i386/trap.h i386/i386/tss.h \
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 i386/intel/read_fault.c \
- i386/intel/read_fault.h i386/i386/hardclock.c \
- i386/i386/io_map.c i386/i386/pic.c i386/i386/pic.h \
- i386/i386/pit.c i386/i386/pit.h i386/i386/_setjmp.S \
- chips/busses.c chips/busses.h device/cirbuf.c i386/xen/xen.c \
+ i386/i386/xpr.h i386/intel/pmap.c i386/intel/pmap.h \
+ i386/intel/read_fault.c i386/intel/read_fault.h \
+ i386/i386/hardclock.c i386/i386/hardclock.h i386/i386/io_map.c \
+ i386/i386/pic.c i386/i386/pic.h i386/i386/pit.c \
+ i386/i386/pit.h i386/i386/_setjmp.S chips/busses.c \
+ chips/busses.h device/cirbuf.c i386/xen/xen.c \
i386/xen/xen_locore.S i386/xen/xen_boothdr.S i386/i386/xen.h
@address@hidden = ddb/db_access.$(OBJEXT) \
address@hidden@ ddb/db_aout.$(OBJEXT) ddb/db_break.$(OBJEXT) \
address@hidden@ ddb/db_aout.$(OBJEXT) ddb/db_elf.$(OBJEXT) \
address@hidden@ ddb/db_break.$(OBJEXT) \
@enable_kdb_TRUE@ ddb/db_command.$(OBJEXT) \
@enable_kdb_TRUE@ ddb/db_cond.$(OBJEXT) \
@enable_kdb_TRUE@ ddb/db_examine.$(OBJEXT) \
@@ -1365,7 +1403,10 @@ am__libkernel_a_SOURCES_DIST = ddb/db_access.c
ddb/db_access.h \
@HOST_ix86_TRUE@@PLATFORM_at_TRUE@ i386/i386at/kdasm.$(OBJEXT) \
@HOST_ix86_TRUE@@PLATFORM_at_TRUE@ i386/i386at/mem.$(OBJEXT) \
@HOST_ix86_TRUE@@PLATFORM_at_TRUE@ i386/i386at/pic_isa.$(OBJEXT) \
address@hidden@@PLATFORM_at_TRUE@ i386/i386at/rtc.$(OBJEXT)
address@hidden@@PLATFORM_at_TRUE@ i386/i386at/rtc.$(OBJEXT) \
address@hidden@@PLATFORM_at_TRUE@ i386/i386at/acpihalt.$(OBJEXT) \
address@hidden@@PLATFORM_at_TRUE@ i386/i386at/acpi.$(OBJEXT) \
address@hidden@@PLATFORM_at_TRUE@ i386/i386at/grub_glue.$(OBJEXT)
@HOST_ix86_TRUE@@address@hidden = \
@HOST_ix86_TRUE@@enable_lpr_TRUE@ i386/i386at/lpr.$(OBJEXT)
@address@hidden = i386/i386/ast_check.$(OBJEXT) \
@@ -1854,6 +1895,7 @@ liblinux_pcmcia_cs_wireless_a_OBJECTS = \
am__installdirs = "$(DESTDIR)$(exec_bootdir)" "$(DESTDIR)$(infodir)" \
"$(DESTDIR)$(exec_msgidsdir)" "$(DESTDIR)$(include_devicedir)" \
"$(DESTDIR)$(include_machdir)" \
+ "$(DESTDIR)$(include_mach_debugdir)" \
"$(DESTDIR)$(include_mach_eXecdir)" \
"$(DESTDIR)$(include_mach_i386dir)"
PROGRAMS = $(exec_boot_PROGRAMS) $(noinst_PROGRAMS)
@@ -2006,14 +2048,14 @@ am__include_mach_i386_HEADERS_DIST =
i386/include/mach/i386/asm.h \
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 \
i386/include/mach/i386/vm_param.h \
i386/include/mach/i386/vm_types.h
HEADERS = $(include_device_HEADERS) $(include_mach_HEADERS) \
- $(include_mach_eXec_HEADERS) $(include_mach_i386_HEADERS)
+ $(include_mach_debug_HEADERS) $(include_mach_eXec_HEADERS) \
+ $(include_mach_i386_HEADERS)
RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
distclean-recursive maintainer-clean-recursive
am__recursive_targets = \
@@ -2388,6 +2430,8 @@ DIST_SUBDIRS =
# Building a distribution.
#
+# Those get #included...
+
# Instead of listing each file individually...
#
@@ -2403,7 +2447,10 @@ EXTRA_DIST = gensym.awk ipc/mach_port.srv kern/mach.srv
kern/mach4.srv \
linux/src/drivers/scsi/NCR5380.c \
linux/src/drivers/scsi/NCR5380.h linux/src/drivers/net/8390.h \
linux/src/drivers/net/kern_compat.h linux/pcmcia-cs/glue/ds.c \
- linux/dev/README linux/src/COPYING linux/dev/include \
+ linux/dev/README linux/src/COPYING \
+ linux/src/drivers/scsi/FlashPoint.c \
+ linux/src/drivers/scsi/eata_pio_proc.c \
+ linux/src/drivers/scsi/scsiiom.c linux/dev/include \
linux/src/include linux/pcmcia-cs/include $(am__append_117) \
$(mach_TEXINFOS) config.status.dep.patch DEVELOPMENT
@@ -2502,56 +2549,59 @@ libkernel_a_SOURCES = $(am__append_2) ipc/ipc_entry.c
ipc/ipc_entry.h \
ipc/ipc_machdep.h ipc/ipc_marequest.c ipc/ipc_marequest.h \
ipc/ipc_mqueue.c ipc/ipc_mqueue.h ipc/ipc_notify.c \
ipc/ipc_notify.h ipc/ipc_object.c ipc/ipc_object.h \
- ipc/ipc_port.c ipc/ipc_port.h ipc/ipc_pset.c ipc/ipc_pset.h \
- ipc/ipc_right.c ipc/ipc_right.h ipc/ipc_space.c \
+ ipc/ipc_port.c ipc/ipc_port.h ipc/ipc_print.h ipc/ipc_pset.c \
+ ipc/ipc_pset.h ipc/ipc_right.c 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 \
ipc/ipc_target.h ipc/ipc_thread.c ipc/ipc_thread.h \
ipc/ipc_types.h ipc/mach_msg.c ipc/mach_msg.h ipc/mach_port.c \
ipc/mach_port.h ipc/mach_rpc.c ipc/mach_debug.c ipc/port.h \
kern/act.c kern/act.h kern/assert.h kern/ast.c kern/ast.h \
- kern/boot_script.h kern/bootstrap.c kern/counters.c \
- kern/counters.h kern/cpu_number.h kern/debug.c kern/debug.h \
- kern/eventcount.c kern/eventcount.h kern/exception.c \
- kern/host.c kern/host.h kern/ipc_host.c kern/ipc_host.h \
- kern/ipc_kobject.c kern/ipc_kobject.h kern/ipc_mig.c \
- kern/ipc_mig.h kern/ipc_sched.c kern/ipc_sched.h kern/ipc_tt.c \
- kern/ipc_tt.h kern/kalloc.h kern/kern_types.h kern/list.h \
- kern/lock.c kern/lock.h kern/lock_mon.c kern/mach_clock.c \
+ kern/boot_script.h kern/bootstrap.c kern/bootstrap.h \
+ kern/counters.c kern/counters.h kern/cpu_number.h kern/debug.c \
+ kern/debug.h kern/eventcount.c kern/eventcount.h \
+ kern/exception.c kern/exception.h kern/host.c kern/host.h \
+ kern/ipc_host.c kern/ipc_host.h kern/ipc_kobject.c \
+ kern/ipc_kobject.h kern/ipc_mig.c kern/ipc_mig.h \
+ kern/ipc_sched.c kern/ipc_sched.h kern/ipc_tt.c kern/ipc_tt.h \
+ kern/kalloc.h kern/kern_types.h kern/list.h kern/lock.c \
+ kern/lock.h kern/lock_mon.c kern/mach_clock.c \
kern/mach_clock.h kern/mach_factor.c kern/mach_factor.h \
kern/machine.c kern/machine.h kern/macro_help.h \
kern/pc_sample.c kern/pc_sample.h kern/printf.c kern/printf.h \
- kern/priority.c kern/processor.c kern/processor.h \
- kern/profile.c kern/queue.c kern/queue.h kern/rbtree.c \
- kern/rbtree.h kern/rbtree_i.h kern/refcount.h kern/slab.c \
- kern/slab.h kern/sched.h kern/sched_prim.c kern/sched_prim.h \
- kern/shuttle.h kern/startup.c kern/strings.c \
- kern/syscall_emulation.c kern/syscall_emulation.h \
- kern/syscall_subr.c kern/syscall_subr.h kern/syscall_sw.c \
- kern/syscall_sw.h kern/task.c kern/task.h kern/thread.c \
- kern/thread.h kern/thread_swap.c kern/thread_swap.h \
- kern/time_stamp.c kern/time_stamp.h kern/timer.c kern/timer.h \
- kern/xpr.c kern/xpr.h kern/elf-load.c kern/boot_script.c \
- util/putchar.c util/putchar.h util/puts.c util/atoi.c \
- util/atoi.h vm/memory_object_proxy.c vm/memory_object_proxy.h \
+ kern/priority.c kern/priority.h kern/processor.c \
+ kern/processor.h kern/profile.c kern/queue.c kern/queue.h \
+ kern/rbtree.c kern/rbtree.h kern/rbtree_i.h kern/refcount.h \
+ kern/slab.c kern/slab.h kern/sched.h kern/sched_prim.c \
+ kern/sched_prim.h kern/shuttle.h kern/startup.c kern/startup.h \
+ kern/strings.c kern/syscall_emulation.c \
+ kern/syscall_emulation.h kern/syscall_subr.c \
+ kern/syscall_subr.h kern/syscall_sw.c kern/syscall_sw.h \
+ kern/task.c kern/task.h kern/thread.c kern/thread.h \
+ kern/thread_swap.c kern/thread_swap.h kern/time_stamp.c \
+ kern/time_stamp.h kern/timer.c kern/timer.h kern/xpr.c \
+ kern/xpr.h kern/elf-load.c kern/boot_script.c util/putchar.c \
+ util/putchar.h util/puts.c util/atoi.c util/atoi.h \
+ vm/memory_object_proxy.c vm/memory_object_proxy.h \
vm/memory_object.c vm/memory_object.h vm/pmap.h vm/vm_debug.c \
vm/vm_external.c vm/vm_external.h vm/vm_fault.c vm/vm_fault.h \
- vm/vm_init.c vm/vm_kern.c vm/vm_kern.h vm/vm_map.c vm/vm_map.h \
- vm/vm_object.c vm/vm_object.h vm/vm_page.h vm/vm_pageout.c \
- vm/vm_pageout.h vm/vm_resident.c vm/vm_resident.h \
- vm/vm_types.h vm/vm_user.c vm/vm_user.h device/blkio.c \
- device/buf.h device/chario.c device/cirbuf.h device/conf.h \
+ vm/vm_init.c vm/vm_init.h vm/vm_kern.c vm/vm_kern.h \
+ vm/vm_map.c vm/vm_map.h vm/vm_object.c vm/vm_object.h \
+ 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 vm/vm_user.c \
+ vm/vm_user.h device/blkio.c device/blkio.h device/buf.h \
+ device/chario.c device/chario.h device/cirbuf.h device/conf.h \
device/cons.c device/cons.h device/device_emul.h \
device/dev_hdr.h device/dev_lookup.c device/dev_master.h \
- device/dev_name.c device/dev_pager.c device/device_init.c \
- device/device_port.h device/device_types_kernel.h \
- device/ds_routines.c device/ds_routines.h device/if_ether.h \
- device/if_hdr.h device/io_req.h device/net_io.c \
- device/net_io.h device/param.h device/subrs.c device/subrs.h \
- device/tty.h $(am__append_4) $(am__append_112) \
- $(am__append_113) $(am__append_114) $(am__append_115) \
- $(am__append_116) $(am__append_118) $(am__append_119) \
- $(am__append_120) $(am__append_125)
+ device/dev_name.c device/dev_pager.c device/dev_pager.h \
+ device/device_init.c device/device_init.h device/device_port.h \
+ device/device_types_kernel.h device/ds_routines.c \
+ device/ds_routines.h device/if_ether.h device/if_hdr.h \
+ device/io_req.h device/net_io.c device/net_io.h device/param.h \
+ device/subrs.c device/subrs.h device/tty.h $(am__append_4) \
+ $(am__append_112) $(am__append_113) $(am__append_114) \
+ $(am__append_115) $(am__append_116) $(am__append_118) \
+ $(am__append_119) $(am__append_120) $(am__append_125)
#
# Version number.
@@ -2698,6 +2748,19 @@ include_mach_eXec_HEADERS = \
include/mach/exec/elf.h \
include/mach/exec/exec.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 \
+ )
+
# `exec_' prefix, so that we don't try to build that file during when running
# `make install-data', as it may fail there, but isn't needed there either.
exec_msgidsdir = $(datadir)/msgids
@@ -2808,7 +2871,6 @@ liblinux_pcmcia_cs_wireless_a_SOURCES = $(am__append_110)
@HOST_ix86_TRUE@ i386/include/mach/i386/mach_i386_types.h \
@HOST_ix86_TRUE@ i386/include/mach/i386/machine_types.defs \
@HOST_ix86_TRUE@ i386/include/mach/i386/multiboot.h \
address@hidden@ i386/include/mach/i386/rpc.h \
@HOST_ix86_TRUE@ i386/include/mach/i386/syscall_sw.h \
@HOST_ix86_TRUE@ i386/include/mach/i386/thread_status.h \
@HOST_ix86_TRUE@ i386/include/mach/i386/trap.h \
@@ -2904,8 +2966,8 @@ $(ACLOCAL_M4): $(am__aclocal_m4_deps)
$(am__aclocal_m4_deps):
config.h: stamp-h1
- @if test ! -f $@; then rm -f stamp-h1; else :; fi
- @if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) stamp-h1; else :; fi
+ @test -f $@ || rm -f stamp-h1
+ @test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h1
stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
@rm -f stamp-h1
@@ -2995,6 +3057,8 @@ ddb/db_access.$(OBJEXT): ddb/$(am__dirstamp) \
ddb/$(DEPDIR)/$(am__dirstamp)
ddb/db_aout.$(OBJEXT): ddb/$(am__dirstamp) \
ddb/$(DEPDIR)/$(am__dirstamp)
+ddb/db_elf.$(OBJEXT): ddb/$(am__dirstamp) \
+ ddb/$(DEPDIR)/$(am__dirstamp)
ddb/db_break.$(OBJEXT): ddb/$(am__dirstamp) \
ddb/$(DEPDIR)/$(am__dirstamp)
ddb/db_command.$(OBJEXT): ddb/$(am__dirstamp) \
@@ -3260,6 +3324,12 @@ i386/i386at/pic_isa.$(OBJEXT):
i386/i386at/$(am__dirstamp) \
i386/i386at/$(DEPDIR)/$(am__dirstamp)
i386/i386at/rtc.$(OBJEXT): i386/i386at/$(am__dirstamp) \
i386/i386at/$(DEPDIR)/$(am__dirstamp)
+i386/i386at/acpihalt.$(OBJEXT): i386/i386at/$(am__dirstamp) \
+ i386/i386at/$(DEPDIR)/$(am__dirstamp)
+i386/i386at/acpi.$(OBJEXT): i386/i386at/$(am__dirstamp) \
+ i386/i386at/$(DEPDIR)/$(am__dirstamp)
+i386/i386at/grub_glue.$(OBJEXT): i386/i386at/$(am__dirstamp) \
+ i386/i386at/$(DEPDIR)/$(am__dirstamp)
i386/i386at/lpr.$(OBJEXT): i386/i386at/$(am__dirstamp) \
i386/i386at/$(DEPDIR)/$(am__dirstamp)
i386/i386/ast_check.$(OBJEXT): i386/i386/$(am__dirstamp) \
@@ -4059,6 +4129,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @address@hidden/$(DEPDIR)/address@hidden@
@AMDEP_TRUE@@am__include@ @address@hidden/$(DEPDIR)/address@hidden@
@AMDEP_TRUE@@am__include@ @address@hidden/$(DEPDIR)/address@hidden@
address@hidden@@am__include@ @address@hidden/$(DEPDIR)/address@hidden@
@AMDEP_TRUE@@am__include@ @address@hidden/$(DEPDIR)/address@hidden@
@AMDEP_TRUE@@am__include@ @address@hidden/$(DEPDIR)/address@hidden@
@AMDEP_TRUE@@am__include@ @address@hidden/$(DEPDIR)/address@hidden@
@@ -4127,11 +4198,14 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @address@hidden/i386/$(DEPDIR)/address@hidden@
@AMDEP_TRUE@@am__include@ @address@hidden/i386/$(DEPDIR)/address@hidden@
@AMDEP_TRUE@@am__include@ @address@hidden/i386/$(DEPDIR)/address@hidden@
address@hidden@@am__include@ @address@hidden/i386at/$(DEPDIR)/address@hidden@
address@hidden@@am__include@ @address@hidden/i386at/$(DEPDIR)/address@hidden@
@AMDEP_TRUE@@am__include@ @address@hidden/i386at/$(DEPDIR)/address@hidden@
@AMDEP_TRUE@@am__include@ @address@hidden/i386at/$(DEPDIR)/address@hidden@
@AMDEP_TRUE@@am__include@ @address@hidden/i386at/$(DEPDIR)/address@hidden@
@AMDEP_TRUE@@am__include@ @address@hidden/i386at/$(DEPDIR)/address@hidden@
@AMDEP_TRUE@@am__include@ @address@hidden/i386at/$(DEPDIR)/address@hidden@
address@hidden@@am__include@ @address@hidden/i386at/$(DEPDIR)/address@hidden@
@AMDEP_TRUE@@am__include@ @address@hidden/i386at/$(DEPDIR)/address@hidden@
@AMDEP_TRUE@@am__include@ @address@hidden/i386at/$(DEPDIR)/address@hidden@
@AMDEP_TRUE@@am__include@ @address@hidden/i386at/$(DEPDIR)/address@hidden@
@@ -6682,16 +6756,12 @@ doc/mach.html: doc/mach.texi $(srcdir)/doc/version.texi
doc/$(am__dirstamp)
$(AM_V_at)if $(MAKEINFOHTML) $(AM_MAKEINFOHTMLFLAGS) $(MAKEINFOFLAGS)
-I doc -I $(srcdir)/doc \
-o $(@:.html=.htp) `test -f 'doc/mach.texi' || echo
'$(srcdir)/'`doc/mach.texi; \
then \
- rm -rf $@; \
- if test ! -d $(@:.html=.htp) && test -d $(@:.html=); then \
- mv $(@:.html=) $@; else mv $(@:.html=.htp) $@; fi; \
+ rm -rf $@ && mv $(@:.html=.htp) $@; \
else \
- if test ! -d $(@:.html=.htp) && test -d $(@:.html=); then \
- rm -rf $(@:.html=); else rm -Rf $(@:.html=.htp) $@; fi; \
- exit 1; \
+ rm -rf $(@:.html=.htp); exit 1; \
fi
$(srcdir)/doc/stamp-vti: doc/mach.texi $(top_srcdir)/configure
- test -f doc/$(am__dirstamp) || $(MAKE) $(AM_MAKEFLAGS)
doc/$(am__dirstamp)
+ @test -f doc/$(am__dirstamp) || $(MAKE) $(AM_MAKEFLAGS)
doc/$(am__dirstamp)
@(dir=.; test -f ./doc/mach.texi || dir=$(srcdir); \
set `$(SHELL) $(top_srcdir)/build-aux/mdate-sh $$dir/doc/mach.texi`; \
echo "@set UPDATED $$1 $$2 $$3"; \
@@ -6865,6 +6935,27 @@ uninstall-include_machHEADERS:
@list='$(include_mach_HEADERS)'; test -n "$(include_machdir)" || list=;
\
files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
dir='$(DESTDIR)$(include_machdir)'; $(am__uninstall_files_from_dir)
+install-include_mach_debugHEADERS: $(include_mach_debug_HEADERS)
+ @$(NORMAL_INSTALL)
+ @list='$(include_mach_debug_HEADERS)'; test -n
"$(include_mach_debugdir)" || list=; \
+ if test -n "$$list"; then \
+ echo " $(MKDIR_P) '$(DESTDIR)$(include_mach_debugdir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(include_mach_debugdir)" || exit 1; \
+ fi; \
+ for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ echo "$$d$$p"; \
+ done | $(am__base_list) | \
+ while read files; do \
+ echo " $(INSTALL_HEADER) $$files
'$(DESTDIR)$(include_mach_debugdir)'"; \
+ $(INSTALL_HEADER) $$files "$(DESTDIR)$(include_mach_debugdir)" ||
exit $$?; \
+ done
+
+uninstall-include_mach_debugHEADERS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(include_mach_debug_HEADERS)'; test -n
"$(include_mach_debugdir)" || list=; \
+ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+ dir='$(DESTDIR)$(include_mach_debugdir)';
$(am__uninstall_files_from_dir)
install-include_mach_eXecHEADERS: $(include_mach_eXec_HEADERS)
@$(NORMAL_INSTALL)
@list='$(include_mach_eXec_HEADERS)'; test -n "$(include_mach_eXecdir)"
|| list=; \
@@ -7260,10 +7351,16 @@ dist-xz: distdir
$(am__post_remove_distdir)
dist-tarZ: distdir
+ @echo WARNING: "Support for shar distribution archives is" \
+ "deprecated." >&2
+ @echo WARNING: "It will be removed altogether in Automake 2.0" >&2
tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
$(am__post_remove_distdir)
dist-shar: distdir
+ @echo WARNING: "Support for distribution archives compressed with" \
+ "legacy program 'compress' is deprecated." >&2
+ @echo WARNING: "It will be removed altogether in Automake 2.0" >&2
shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
$(am__post_remove_distdir)
@@ -7305,9 +7402,10 @@ distcheck: dist
&& dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
&& am__cwd=`pwd` \
&& $(am__cd) $(distdir)/_build \
- && ../configure --srcdir=.. --prefix="$$dc_install_base" \
+ && ../configure \
$(AM_DISTCHECK_CONFIGURE_FLAGS) \
$(DISTCHECK_CONFIGURE_FLAGS) \
+ --srcdir=.. --prefix="$$dc_install_base" \
&& $(MAKE) $(AM_MAKEFLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) dvi \
&& $(MAKE) $(AM_MAKEFLAGS) check \
@@ -7367,7 +7465,7 @@ all-am: Makefile $(INFO_DEPS) $(LIBRARIES) $(PROGRAMS)
$(DATA) \
$(HEADERS) config.h
installdirs: installdirs-recursive
installdirs-am:
- for dir in "$(DESTDIR)$(exec_bootdir)" "$(DESTDIR)$(infodir)"
"$(DESTDIR)$(exec_msgidsdir)" "$(DESTDIR)$(include_devicedir)"
"$(DESTDIR)$(include_machdir)" "$(DESTDIR)$(include_mach_eXecdir)"
"$(DESTDIR)$(include_mach_i386dir)"; do \
+ for dir in "$(DESTDIR)$(exec_bootdir)" "$(DESTDIR)$(infodir)"
"$(DESTDIR)$(exec_msgidsdir)" "$(DESTDIR)$(include_devicedir)"
"$(DESTDIR)$(include_machdir)" "$(DESTDIR)$(include_mach_debugdir)"
"$(DESTDIR)$(include_mach_eXecdir)" "$(DESTDIR)$(include_mach_i386dir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-recursive
@@ -7495,7 +7593,8 @@ info: info-recursive
info-am: $(INFO_DEPS)
install-data-am: install-include_deviceHEADERS \
- install-include_machHEADERS install-include_mach_eXecHEADERS \
+ install-include_machHEADERS install-include_mach_debugHEADERS \
+ install-include_mach_eXecHEADERS \
install-include_mach_i386HEADERS install-info-am
@$(NORMAL_INSTALL)
$(MAKE) $(AM_MAKEFLAGS) install-data-hook
@@ -7640,6 +7739,7 @@ ps-am: $(PSS) ps-local
uninstall-am: uninstall-dvi-am uninstall-exec_bootPROGRAMS \
uninstall-exec_msgidsDATA uninstall-html-am \
uninstall-include_deviceHEADERS uninstall-include_machHEADERS \
+ uninstall-include_mach_debugHEADERS \
uninstall-include_mach_eXecHEADERS \
uninstall-include_mach_i386HEADERS uninstall-info-am \
uninstall-pdf-am uninstall-ps-am
@@ -7661,6 +7761,7 @@ uninstall-am: uninstall-dvi-am
uninstall-exec_bootPROGRAMS \
install-exec-am install-exec_bootPROGRAMS \
install-exec_msgidsDATA install-html install-html-am \
install-include_deviceHEADERS install-include_machHEADERS \
+ install-include_mach_debugHEADERS \
install-include_mach_eXecHEADERS \
install-include_mach_i386HEADERS install-info install-info-am \
install-man install-pdf install-pdf-am install-ps \
@@ -7674,6 +7775,7 @@ uninstall-am: uninstall-dvi-am
uninstall-exec_bootPROGRAMS \
uninstall-exec_bootPROGRAMS uninstall-exec_msgidsDATA \
uninstall-html-am uninstall-include_deviceHEADERS \
uninstall-include_machHEADERS \
+ uninstall-include_mach_debugHEADERS \
uninstall-include_mach_eXecHEADERS \
uninstall-include_mach_i386HEADERS uninstall-info-am \
uninstall-pdf-am uninstall-ps-am
@@ -7757,10 +7859,6 @@ uninstall-am: uninstall-dvi-am
uninstall-exec_bootPROGRAMS \
echo-%:
@echo '$* = `$($*)'\'
-# 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)
-
# Other headers for the distribution. We don't install these, because the
# GNU C library has correct versions for users to use.
# other-sys-headers := types.h time.h reboot.h ioctl.h
@@ -7897,6 +7995,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. ; \
+ false ; fi
dist-hook: dist-rm-CVS gen-ChangeLog
diff --git a/Makefrag.am b/Makefrag.am
index bb08972..5e98b21 100644
--- a/Makefrag.am
+++ b/Makefrag.am
@@ -24,6 +24,9 @@ libkernel_a_SOURCES += \
ddb/db_access.c \
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 \
@@ -42,6 +45,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 \
@@ -59,6 +63,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 +98,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 \
@@ -131,6 +137,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 \
@@ -139,6 +146,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 \
@@ -169,6 +177,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 \
@@ -185,6 +194,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 \
@@ -241,6 +251,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 \
@@ -250,6 +261,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 \
@@ -269,8 +281,10 @@ 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 \
device/cirbuf.h \
device/conf.h \
device/cons.c \
@@ -281,7 +295,9 @@ 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 \
device/device_types_kernel.h \
device/ds_routines.c \
@@ -405,9 +421,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.
diff --git a/NEWS b/NEWS
index 55d75cc..357b23f 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,23 @@
+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.
+
+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.
+
+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
diff --git a/README b/README
index 2d7724a..6c0ea5b 100644
--- a/README
+++ b/README
@@ -28,7 +28,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.
diff --git a/aclocal.m4 b/aclocal.m4
index 4d4fb78..9ce1375 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -1,4 +1,4 @@
-# generated automatically by aclocal 1.13.3 -*- Autoconf -*-
+# generated automatically by aclocal 1.14.1 -*- Autoconf -*-
# Copyright (C) 1996-2013 Free Software Foundation, Inc.
@@ -32,10 +32,10 @@ To do so, use the procedure documented by the package,
typically 'autoreconf'.])
# generated from the m4 files accompanying Automake X.Y.
# (This private macro should not be called outside this file.)
AC_DEFUN([AM_AUTOMAKE_VERSION],
-[am__api_version='1.13'
+[am__api_version='1.14'
dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
dnl require some minimum version. Point them to the right macro.
-m4_if([$1], [1.13.3], [],
+m4_if([$1], [1.14.1], [],
[AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
])
@@ -51,7 +51,7 @@ m4_define([_AM_AUTOCONF_VERSION], [])
# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
-[AM_AUTOMAKE_VERSION([1.13.3])dnl
+[AM_AUTOMAKE_VERSION([1.14.1])dnl
m4_ifndef([AC_AUTOCONF_VERSION],
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
@@ -123,10 +123,9 @@ _AM_IF_OPTION([no-dependencies],,
[_AM_DEPENDENCIES([CCAS])])dnl
# configured tree to be moved without reconfiguration.
AC_DEFUN([AM_AUX_DIR_EXPAND],
-[dnl Rely on autoconf to set up CDPATH properly.
-AC_PREREQ([2.50])dnl
-# expand $ac_aux_dir to an absolute path
-am_aux_dir=`cd $ac_aux_dir && pwd`
+[AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
+# Expand $ac_aux_dir to an absolute path.
+am_aux_dir=`cd "$ac_aux_dir" && pwd`
])
# AM_CONDITIONAL -*- Autoconf -*-
@@ -438,6 +437,12 @@ AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
# This macro actually does too much. Some checks are only needed if
# your package does certain things. But this isn't really a big deal.
+dnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O.
+m4_define([AC_PROG_CC],
+m4_defn([AC_PROG_CC])
+[_AM_PROG_CC_C_O
+])
+
# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
# AM_INIT_AUTOMAKE([OPTIONS])
# -----------------------------------------------
@@ -546,6 +551,48 @@ dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see
below.
AC_CONFIG_COMMANDS_PRE(dnl
[m4_provide_if([_AM_COMPILER_EXEEXT],
[AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl
+
+# POSIX will say in a future version that running "rm -f" with no argument
+# is OK; and we want to be able to make that assumption in our Makefile
+# recipes. So use an aggressive probe to check that the usage we want is
+# actually supported "in the wild" to an acceptable degree.
+# See automake bug#10828.
+# To make any issue more visible, cause the running configure to be aborted
+# by default if the 'rm' program in use doesn't match our expectations; the
+# user can still override this though.
+if rm -f && rm -fr && rm -rf; then : OK; else
+ cat >&2 <<'END'
+Oops!
+
+Your 'rm' program seems unable to run without file operands specified
+on the command line, even when the '-f' option is present. This is contrary
+to the behaviour of most rm programs out there, and not conforming with
+the upcoming POSIX standard: <http://austingroupbugs.net/view.php?id=542>
+
+Please tell address@hidden about your system, including the value
+of your $PATH and any error possibly output before this message. This
+can help us improve future automake versions.
+
+END
+ if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then
+ echo 'Configuration will proceed anyway, since you have set the' >&2
+ echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2
+ echo >&2
+ else
+ cat >&2 <<'END'
+Aborting the configuration process, to ensure you take notice of the issue.
+
+You can download and install GNU coreutils to get an 'rm' implementation
+that behaves properly: <http://www.gnu.org/software/coreutils/>.
+
+If you want to complete the configuration process using your problematic
+'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM
+to "yes", and re-run configure.
+
+END
+ AC_MSG_ERROR([Your 'rm' program is bad, sorry.])
+ fi
+fi
])
dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not
@@ -554,7 +601,6 @@ dnl mangled by Autoconf and run in a shell conditional
statement.
m4_define([_AC_COMPILER_EXEEXT],
m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])])
-
# When config.status generates a header, we must update the stamp-h file.
# This file resides in the same directory as the config header
# that is generated. The stamp files are numbered to have different names.
@@ -666,38 +712,6 @@ AC_MSG_RESULT([$_am_result])
rm -f confinc confmf
])
-# Copyright (C) 1999-2013 Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# AM_PROG_CC_C_O
-# --------------
-# Like AC_PROG_CC_C_O, but changed for automake.
-AC_DEFUN([AM_PROG_CC_C_O],
-[AC_REQUIRE([AC_PROG_CC_C_O])dnl
-AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
-AC_REQUIRE_AUX_FILE([compile])dnl
-# FIXME: we rely on the cache variable name because
-# there is no other way.
-set dummy $CC
-am_cc=`echo $[2] | sed ['s/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/']`
-eval am_t=\$ac_cv_prog_cc_${am_cc}_c_o
-if test "$am_t" != yes; then
- # Losing compiler, so override with the script.
- # FIXME: It is wrong to rewrite CC.
- # But if we don't then we get into trouble of one sort or another.
- # A longer-term fix would be to have automake use am__CC in this case,
- # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
- CC="$am_aux_dir/compile $CC"
-fi
-dnl Make sure AC_PROG_CC is never called again, or it will override our
-dnl setting of CC.
-m4_define([AC_PROG_CC],
- [m4_fatal([AC_PROG_CC cannot be called after AM_PROG_CC_C_O])])
-])
-
# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*-
# Copyright (C) 1997-2013 Free Software Foundation, Inc.
@@ -768,6 +782,70 @@ AC_DEFUN([_AM_SET_OPTIONS],
AC_DEFUN([_AM_IF_OPTION],
[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
+# Copyright (C) 1999-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# _AM_PROG_CC_C_O
+# ---------------
+# Like AC_PROG_CC_C_O, but changed for automake. We rewrite AC_PROG_CC
+# to automatically call this.
+AC_DEFUN([_AM_PROG_CC_C_O],
+[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
+AC_REQUIRE_AUX_FILE([compile])dnl
+AC_LANG_PUSH([C])dnl
+AC_CACHE_CHECK(
+ [whether $CC understands -c and -o together],
+ [am_cv_prog_cc_c_o],
+ [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])])
+ # Make sure it works both with $CC and with simple cc.
+ # Following AC_PROG_CC_C_O, we do the test twice because some
+ # compilers refuse to overwrite an existing .o file with -o,
+ # though they will create one.
+ am_cv_prog_cc_c_o=yes
+ for am_i in 1 2; do
+ if AM_RUN_LOG([$CC -c conftest.$ac_ext -o conftest2.$ac_objext]) \
+ && test -f conftest2.$ac_objext; then
+ : OK
+ else
+ am_cv_prog_cc_c_o=no
+ break
+ fi
+ done
+ rm -f core conftest*
+ unset am_i])
+if test "$am_cv_prog_cc_c_o" != yes; then
+ # Losing compiler, so override with the script.
+ # FIXME: It is wrong to rewrite CC.
+ # But if we don't then we get into trouble of one sort or another.
+ # A longer-term fix would be to have automake use am__CC in this case,
+ # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
+ CC="$am_aux_dir/compile $CC"
+fi
+AC_LANG_POP([C])])
+
+# For backward compatibility.
+AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])])
+
+# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_RUN_LOG(COMMAND)
+# -------------------
+# Run COMMAND, save the exit status in ac_status, and log it.
+# (This has been adapted from Autoconf's _AC_RUN_LOG macro.)
+AC_DEFUN([AM_RUN_LOG],
+[{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD
+ ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
+ (exit $ac_status); }])
+
# Check to make sure that the build environment is sane. -*- Autoconf -*-
# Copyright (C) 1996-2013 Free Software Foundation, Inc.
diff --git a/chips/busses.c b/chips/busses.c
index 89afa97..3811d0c 100644
--- a/chips/busses.c
+++ b/chips/busses.c
@@ -59,17 +59,17 @@
*
*/
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)
{
- 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;
- 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;
}
}
@@ -171,16 +171,16 @@ 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)
{
- register struct bus_device *device;
- register struct bus_driver *driver;
+ struct bus_device *device;
+ 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;
}
}
diff --git a/chips/busses.h b/chips/busses.h
index 49c0e44..f728add 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/config.h.in b/config.h.in
index 1a04572..1afe5a6 100644
--- a/config.h.in
+++ b/config.h.in
@@ -524,9 +524,6 @@
/* NLPR */
#undef NLPR
-/* Define to 1 if your C compiler doesn't accept -c and -o together. */
-#undef NO_MINUS_C_MINUS_O
-
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
diff --git a/configure b/configure
index f90be76..df61b1c 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for GNU Mach 1.4.
+# Generated by GNU Autoconf 2.69 for GNU Mach 1.4+git20141107.
#
# Report bugs to <address@hidden>.
#
@@ -579,8 +579,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='GNU Mach'
PACKAGE_TARNAME='gnumach'
-PACKAGE_VERSION='1.4'
-PACKAGE_STRING='GNU Mach 1.4'
+PACKAGE_VERSION='1.4+git20141107'
+PACKAGE_STRING='GNU Mach 1.4+git20141107'
PACKAGE_BUGREPORT='address@hidden'
PACKAGE_URL=''
@@ -1584,7 +1584,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures GNU Mach 1.4 to adapt to many kinds of systems.
+\`configure' configures GNU Mach 1.4+git20141107 to adapt to many kinds of
systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1654,7 +1654,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of GNU Mach 1.4:";;
+ short | recursive ) echo "Configuration of GNU Mach 1.4+git20141107:";;
esac
cat <<\_ACEOF
@@ -2002,7 +2002,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-GNU Mach configure 1.4
+GNU Mach configure 1.4+git20141107
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2094,7 +2094,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by GNU Mach $as_me 1.4, which was
+It was created by GNU Mach $as_me 1.4+git20141107, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@@ -2474,7 +2474,7 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please
don't use this var.
-am__api_version='1.13'
+am__api_version='1.14'
# Find a good install program. We prefer a C program (faster),
# so one script is as good as another. But avoid the broken or
@@ -2646,8 +2646,8 @@ test "$program_suffix" != NONE &&
ac_script='s/[\\$]/&&/g;s/;s,x,x,$//'
program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"`
-# expand $ac_aux_dir to an absolute path
-am_aux_dir=`cd $ac_aux_dir && pwd`
+# Expand $ac_aux_dir to an absolute path.
+am_aux_dir=`cd "$ac_aux_dir" && pwd`
if test x"${MISSING+set}" != xset; then
case $am_aux_dir in
@@ -2960,7 +2960,7 @@ fi
# Define the identity of the package.
PACKAGE='gnumach'
- VERSION='1.4'
+ VERSION='1.4+git20141107'
# Some tools Automake needs.
@@ -3002,6 +3002,48 @@ am__tar='$${TAR-tar} chof - "$$tardir"'
am__untar='$${TAR-tar} xf -'
+# POSIX will say in a future version that running "rm -f" with no argument
+# is OK; and we want to be able to make that assumption in our Makefile
+# recipes. So use an aggressive probe to check that the usage we want is
+# actually supported "in the wild" to an acceptable degree.
+# See automake bug#10828.
+# To make any issue more visible, cause the running configure to be aborted
+# by default if the 'rm' program in use doesn't match our expectations; the
+# user can still override this though.
+if rm -f && rm -fr && rm -rf; then : OK; else
+ cat >&2 <<'END'
+Oops!
+
+Your 'rm' program seems unable to run without file operands specified
+on the command line, even when the '-f' option is present. This is contrary
+to the behaviour of most rm programs out there, and not conforming with
+the upcoming POSIX standard: <http://austingroupbugs.net/view.php?id=542>
+
+Please tell address@hidden about your system, including the value
+of your $PATH and any error possibly output before this message. This
+can help us improve future automake versions.
+
+END
+ if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then
+ echo 'Configuration will proceed anyway, since you have set the' >&2
+ echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2
+ echo >&2
+ else
+ cat >&2 <<'END'
+Aborting the configuration process, to ensure you take notice of the issue.
+
+You can download and install GNU coreutils to get an 'rm' implementation
+that behaves properly: <http://www.gnu.org/software/coreutils/>.
+
+If you want to complete the configuration process using your problematic
+'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM
+to "yes", and re-run configure.
+
+END
+ as_fn_error $? "Your 'rm' program is bad, sorry." "$LINENO" 5
+ fi
+fi
+
# Check whether --enable-silent-rules was given.
if test "${enable_silent_rules+set}" = set; then :
@@ -4047,6 +4089,65 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext
>&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext
$LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext
$LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC understands -c
and -o together" >&5
+$as_echo_n "checking whether $CC understands -c and -o together... " >&6; }
+if ${am_cv_prog_cc_c_o+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+ # Make sure it works both with $CC and with simple cc.
+ # Following AC_PROG_CC_C_O, we do the test twice because some
+ # compilers refuse to overwrite an existing .o file with -o,
+ # though they will create one.
+ am_cv_prog_cc_c_o=yes
+ for am_i in 1 2; do
+ if { echo "$as_me:$LINENO: $CC -c conftest.$ac_ext -o
conftest2.$ac_objext" >&5
+ ($CC -c conftest.$ac_ext -o conftest2.$ac_objext) >&5 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } \
+ && test -f conftest2.$ac_objext; then
+ : OK
+ else
+ am_cv_prog_cc_c_o=no
+ break
+ fi
+ done
+ rm -f core conftest*
+ unset am_i
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5
+$as_echo "$am_cv_prog_cc_c_o" >&6; }
+if test "$am_cv_prog_cc_c_o" != yes; then
+ # Losing compiler, so override with the script.
+ # FIXME: It is wrong to rewrite CC.
+ # But if we don't then we get into trouble of one sort or another.
+ # A longer-term fix would be to have automake use am__CC in this case,
+ # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
+ CC="$am_aux_dir/compile $CC"
+fi
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext
$LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
depcc="$CC" am_compiler_list=
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc"
>&5
@@ -4847,6 +4948,65 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext
>&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext
$LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext
$LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC understands -c
and -o together" >&5
+$as_echo_n "checking whether $CC understands -c and -o together... " >&6; }
+if ${am_cv_prog_cc_c_o+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+ # Make sure it works both with $CC and with simple cc.
+ # Following AC_PROG_CC_C_O, we do the test twice because some
+ # compilers refuse to overwrite an existing .o file with -o,
+ # though they will create one.
+ am_cv_prog_cc_c_o=yes
+ for am_i in 1 2; do
+ if { echo "$as_me:$LINENO: $CC -c conftest.$ac_ext -o
conftest2.$ac_objext" >&5
+ ($CC -c conftest.$ac_ext -o conftest2.$ac_objext) >&5 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } \
+ && test -f conftest2.$ac_objext; then
+ : OK
+ else
+ am_cv_prog_cc_c_o=no
+ break
+ fi
+ done
+ rm -f core conftest*
+ unset am_i
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5
+$as_echo "$am_cv_prog_cc_c_o" >&6; }
+if test "$am_cv_prog_cc_c_o" != yes; then
+ # Losing compiler, so override with the script.
+ # FIXME: It is wrong to rewrite CC.
+ # But if we don't then we get into trouble of one sort or another.
+ # A longer-term fix would be to have automake use am__CC in this case,
+ # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
+ CC="$am_aux_dir/compile $CC"
+fi
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext
$LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
depcc="$CC" am_compiler_list=
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc"
>&5
@@ -5575,131 +5735,6 @@ else
fi
-if test "x$CC" != xcc; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC and cc
understand -c and -o together" >&5
-$as_echo_n "checking whether $CC and cc understand -c and -o together... "
>&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether cc understands -c
and -o together" >&5
-$as_echo_n "checking whether cc understands -c and -o together... " >&6; }
-fi
-set dummy $CC; ac_cc=`$as_echo "$2" |
- sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'`
-if eval \${ac_cv_prog_cc_${ac_cc}_c_o+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-# Make sure it works both with $CC and with simple cc.
-# We do the test twice because some compilers refuse to overwrite an
-# existing .o file with -o, though they will create one.
-ac_try='$CC -c conftest.$ac_ext -o conftest2.$ac_objext >&5'
-rm -f conftest2.*
-if { { case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
- test $ac_status = 0; } &&
- test -f conftest2.$ac_objext && { { case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
- test $ac_status = 0; };
-then
- eval ac_cv_prog_cc_${ac_cc}_c_o=yes
- if test "x$CC" != xcc; then
- # Test first that cc exists at all.
- if { ac_try='cc -c conftest.$ac_ext >&5'
- { { case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
- test $ac_status = 0; }; }; then
- ac_try='cc -c conftest.$ac_ext -o conftest2.$ac_objext >&5'
- rm -f conftest2.*
- if { { case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
- test $ac_status = 0; } &&
- test -f conftest2.$ac_objext && { { case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
- test $ac_status = 0; };
- then
- # cc works too.
- :
- else
- # cc exists but doesn't like -o.
- eval ac_cv_prog_cc_${ac_cc}_c_o=no
- fi
- fi
- fi
-else
- eval ac_cv_prog_cc_${ac_cc}_c_o=no
-fi
-rm -f core conftest*
-
-fi
-if eval test \$ac_cv_prog_cc_${ac_cc}_c_o = yes; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-
-$as_echo "#define NO_MINUS_C_MINUS_O 1" >>confdefs.h
-
-fi
-
-# FIXME: we rely on the cache variable name because
-# there is no other way.
-set dummy $CC
-am_cc=`echo $2 | sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'`
-eval am_t=\$ac_cv_prog_cc_${am_cc}_c_o
-if test "$am_t" != yes; then
- # Losing compiler, so override with the script.
- # FIXME: It is wrong to rewrite CC.
- # But if we don't then we get into trouble of one sort or another.
- # A longer-term fix would be to have automake use am__CC in this case,
- # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
- CC="$am_aux_dir/compile $CC"
-fi
-
# Extract the first word of "gzip", so it can be a program name with args.
@@ -12075,7 +12110,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by GNU Mach $as_me 1.4, which was
+This file was extended by GNU Mach $as_me 1.4+git20141107, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -12146,7 +12181,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //;
s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
-GNU Mach config.status 1.4
+GNU Mach config.status 1.4+git20141107
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
diff --git a/ddb/db_access.c b/ddb/db_access.c
index 6992255..16d4d3e 100644
--- a/ddb/db_access.c
+++ b/ddb/db_access.c
@@ -62,15 +62,15 @@ 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;
- 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)];
- register db_expr_t value;
- register int i;
+ db_expr_t value;
+ int i;
db_read_bytes(addr, size, data, task);
@@ -92,14 +92,14 @@ 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;
- 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)];
- register int i;
+ int i;
#if BYTE_MSF
for (i = size - 1; i >= 0; 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_access.h b/ddb/db_access.h
index 6cedf29..3bda5a4 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 <mach/boolean.h>
#include <machine/db_machdep.h>
#include <ddb/db_task_thread.h>
@@ -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_ */
diff --git a/ddb/db_aout.c b/ddb/db_aout.c
index 42fa6f7..d3f2e31 100644
--- a/ddb/db_aout.c
+++ b/ddb/db_aout.c
@@ -39,6 +39,7 @@
#include <machine/db_machdep.h> /* data types */
#include <ddb/db_output.h>
#include <ddb/db_sym.h>
+#include <ddb/db_aout.h>
#ifndef DB_NO_AOUT
@@ -69,18 +70,18 @@
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 */
{
- 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 +101,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) {
@@ -131,9 +132,9 @@ 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)
- register char *name;
+ const char *name;
{
while (*name) {
if (*name == '.') {
@@ -148,12 +149,12 @@ 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)
- struct nlist *sp;
- char *name;
+ const struct nlist *sp;
+ const char *name;
{
- register char *s1, *s2;
+ const char *s1, *s2;
s1 = sp->n_un.n_name;
s2 = name;
@@ -185,11 +186,11 @@ aout_db_eq_name(sp, name)
*/
private struct nlist *
aout_db_search_name(sp, ep, name, type, fp)
- register 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;
@@ -232,11 +233,11 @@ 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;
{
- 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;
@@ -244,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) {
/*
@@ -278,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
@@ -312,26 +313,23 @@ 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)
{
- db_sym_t db_sym_parse_and_lookup();
-
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;
- register
- 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 */
{
- 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;
@@ -376,13 +374,13 @@ 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)
{
- register struct nlist *sp;
+ struct nlist *sp;
sp = (struct nlist *)sym;
if (namep)
@@ -398,16 +396,16 @@ 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;
- 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;
{
- 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;
@@ -495,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/include/mach/gnumach.defs b/ddb/db_aout.h
similarity index 54%
copy from include/mach/gnumach.defs
copy to ddb/db_aout.h
index 7331334..7c03d36 100644
--- a/include/mach/gnumach.defs
+++ b/ddb/db_aout.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 Free Software Foundation
+ * 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
@@ -16,24 +16,37 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-subsystem
-#if KERNEL_SERVER
- KernelServer
-#endif /* KERNEL_SERVER */
-#if KERNEL_USER
- KernelUser
-#endif /* KERNEL_USER */
- gnumach 4200;
+#ifndef _DDB_DB_AOUT_H_
+#define _DDB_DB_AOUT_H_
-#include <mach/std_types.defs>
-#include <mach/mach_types.defs>
+#include <ddb/db_sym.h>
+#include <machine/db_machdep.h>
-type vm_cache_statistics_data_t = struct[11] of integer_t;
+extern boolean_t
+aout_db_line_at_pc(
+ db_symtab_t *stab,
+ db_sym_t sym,
+ char **file,
+ int *line,
+ db_addr_t pc);
-/*
- * Return page cache statistics for the host on which the target task
- * resides.
- */
-routine vm_cache_statistics(
- target_task : vm_task_t;
- out vm_cache_stats : vm_cache_statistics_data_t);
+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_break.c b/ddb/db_break.c
index 7525392..c3a9e18 100644
--- a/ddb/db_break.c
+++ b/ddb/db_break.c
@@ -36,6 +36,7 @@
*/
#include <mach/boolean.h>
#include <machine/db_machdep.h>
+#include <machine/db_interface.h>
#include <ddb/db_lex.h>
#include <ddb/db_break.h>
#include <ddb/db_access.h>
@@ -46,7 +47,6 @@
#include <ddb/db_output.h>
#include <ddb/db_cond.h>
#include <ddb/db_expr.h>
-#include <ddb/db_access.h>
#define NBREAKPOINTS 100
#define NTHREAD_LIST (NBREAKPOINTS*3)
@@ -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;
@@ -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;
@@ -90,11 +90,12 @@ db_breakpoint_free(bkpt)
static int
db_add_thread_breakpoint(bkpt, task_thd, count, task_bpt)
- register db_breakpoint_t bkpt;
+ const db_breakpoint_t bkpt;
vm_offset_t task_thd;
+ int count;
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;
@@ -120,12 +121,12 @@ db_add_thread_breakpoint(bkpt, task_thd, count, task_bpt)
}
static int
-db_delete_thread_breakpoint(bkpt, task_thd)
- register db_breakpoint_t bkpt;
- vm_offset_t task_thd;
+db_delete_thread_breakpoint(
+ 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 */
@@ -153,13 +154,13 @@ 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)
- db_breakpoint_t bkpt;
- thread_t thread;
+ const db_breakpoint_t bkpt;
+ const 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) {
@@ -175,24 +176,24 @@ 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;
- 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()));
}
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)
{
- 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) {
@@ -207,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)
@@ -226,10 +227,10 @@ db_force_delete_breakpoint(bkpt, task_thd, is_task)
}
void
-db_check_breakpoint_valid()
+db_check_breakpoint_valid(void)
{
- 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) {
@@ -267,13 +268,13 @@ db_check_breakpoint_valid()
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;
{
- register db_breakpoint_t bkpt;
+ db_breakpoint_t bkpt;
db_breakpoint_t alloc_bkpt = 0;
vm_offset_t task_thd;
@@ -320,12 +321,12 @@ 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;
{
- 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) {
@@ -349,12 +350,12 @@ db_delete_breakpoint(task, addr, task_thd)
}
}
-db_breakpoint_t
+db_breakpoint_t __attribute__ ((pure))
db_find_breakpoint(task, addr)
- task_t task;
+ const 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
@@ -367,10 +368,10 @@ db_find_breakpoint(task, addr)
boolean_t
db_find_breakpoint_here(task, addr)
- task_t task;
+ const 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
@@ -378,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);
@@ -389,8 +390,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 +435,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;
@@ -481,11 +482,11 @@ 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)
{
- register db_breakpoint_t bkpt;
+ db_breakpoint_t bkpt;
bkpt = db_breakpoint_alloc();
if (bkpt == 0) {
@@ -510,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);
@@ -523,9 +524,9 @@ db_delete_temp_breakpoint(task, bkpt)
* List breakpoints.
*/
void
-db_list_breakpoints()
+db_list_breakpoints(void)
{
- register db_breakpoint_t bkpt;
+ db_breakpoint_t bkpt;
if (db_breakpoint_list == 0) {
db_printf("No breakpoints set\n");
@@ -537,9 +538,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) {
@@ -597,9 +598,9 @@ db_list_breakpoints()
/* Delete breakpoint */
/*ARGSUSED*/
void
-db_delete_cmd()
+db_delete_cmd(void)
{
- register int n;
+ int n;
thread_t thread;
vm_offset_t task_thd;
boolean_t user_global = FALSE;
@@ -680,9 +681,9 @@ db_breakpoint_cmd(addr, have_addr, count, modif)
db_expr_t addr;
int have_addr;
db_expr_t count;
- char * modif;
+ const 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');
@@ -730,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_break.h b/ddb/db_break.h
index 89e7889..610af2f 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)
__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);
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,18 +84,20 @@ 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();
+void db_listbreak_cmd(void);
-void db_delete_cmd();
+void db_delete_cmd(void);
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);
#endif /* _DDB_DB_BREAK_H_ */
diff --git a/ddb/db_command.c b/ddb/db_command.c
index cb14da8..5651667 100644
--- a/ddb/db_command.c
+++ b/ddb/db_command.c
@@ -54,6 +54,7 @@
#include <ddb/db_cond.h>
#include <machine/setjmp.h>
+#include <machine/db_interface.h>
#include <kern/debug.h>
#include <kern/thread.h>
#include <ipc/ipc_pset.h> /* 4proto */
@@ -94,17 +95,17 @@ 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++) {
- register char *lp;
- register char *rp;
- register int c;
+ const char *lp;
+ char *rp;
+ int c;
lp = name;
rp = cmd->name;
@@ -141,9 +142,9 @@ db_cmd_search(name, table, cmdp)
void
db_cmd_list(table)
- struct db_command *table;
+ const struct db_command *table;
{
- register struct db_command *cmd;
+ const struct db_command *cmd;
for (cmd = table; cmd->name != 0; cmd++) {
db_printf("%-12s", cmd->name);
@@ -152,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;
@@ -175,7 +176,6 @@ db_command(last_cmdp, cmd_table)
db_unread_token(t);
}
else if (t == tEXCL) {
- void db_fncall();
db_fncall();
return;
}
@@ -293,19 +293,18 @@ 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)
{
- void db_skip_to_eol();
-
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[] = {
+ { "tasks", db_show_all_tasks, 0, 0 },
{ "threads", db_show_all_threads, 0, 0 },
{ "slocks", db_show_all_slocks, 0, 0 },
{ (char *)0 }
@@ -331,10 +330,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[] = {
#ifdef DB_MACHINE_COMMANDS
/* this must be the first entry, if it exists */
@@ -369,6 +364,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, }
};
@@ -376,20 +372,19 @@ 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;
}
-#endif
+#endif /* DB_MACHINE_COMMANDS */
struct db_command *db_last_command = 0;
void
-db_help_cmd()
+db_help_cmd(void)
{
struct db_command *cmd = db_command_table;
@@ -400,8 +395,6 @@ db_help_cmd()
}
}
-int (*ddb_display)();
-
void
db_command_loop(void)
{
@@ -416,10 +409,7 @@ db_command_loop(void)
db_prev = db_dot;
db_next = db_dot;
- if (ddb_display)
- (*ddb_display)();
-
- 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;
@@ -440,13 +430,13 @@ 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;
- 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**/);
@@ -454,11 +444,11 @@ 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)
- char *s;
+ const char *s;
{
extern int db_macro_level;
@@ -482,7 +472,7 @@ void db_error(s)
* !expr(arg,arg,arg)
*/
void
-db_fncall()
+db_fncall(void)
{
db_expr_t fn_addr;
#define MAXARGS 11
@@ -533,12 +523,12 @@ db_fncall()
db_printf(" %#N\n", retval);
}
-boolean_t
+boolean_t __attribute__ ((pure))
db_option(modif, option)
- char *modif;
- int option;
+ const char *modif;
+ int option;
{
- register 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 3ed1fb9..4208bda 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
/*
@@ -38,9 +41,9 @@
#include <machine/setjmp.h>
extern void db_command_loop(void);
-extern boolean_t db_option(char *, int);
+extern boolean_t db_option(const char *, int) __attribute__ ((pure));
-extern void db_error(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 */
@@ -50,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
*/
@@ -68,6 +69,10 @@ 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);
#endif /* MACH_KDB */
+
+#endif /* _DDB_DB_COMMAND_H_ */
diff --git a/ddb/db_cond.c b/ddb/db_cond.c
index 60ea473..31e1d24 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,10 +58,9 @@ db_cond_free(bkpt)
}
boolean_t
-db_cond_check(bkpt)
- db_thread_breakpoint_t bkpt;
+db_cond_check(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;
@@ -105,10 +103,10 @@ db_cond_check(bkpt)
void
db_cond_print(bkpt)
- db_thread_breakpoint_t bkpt;
+ const 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;
@@ -123,11 +121,11 @@ db_cond_print(bkpt)
}
void
-db_cond_cmd()
+db_cond_cmd(void)
{
- 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;
diff --git a/ddb/db_cond.h b/ddb/db_cond.h
index dec4967..6b9c3a5 100644
--- a/ddb/db_cond.h
+++ b/ddb/db_cond.h
@@ -24,7 +24,7 @@
#include <sys/types.h>
#include <machine/db_machdep.h>
-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_elf.c b/ddb/db_elf.c
new file mode 100644
index 0000000..10e7162
--- /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 <http://www.gnu.org/licenses/>.
+ */
+/*
+ * 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 address@hidden
+ * 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 <string.h>
+#include <mach/std_types.h>
+#include <mach/exec/elf.h>
+#include <machine/db_machdep.h> /* data types */
+#include <machine/vm_param.h>
+#include <ddb/db_output.h>
+#include <ddb/db_sym.h>
+#include <ddb/db_elf.h>
+
+#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/include/mach/gnumach.defs b/ddb/db_elf.h
similarity index 55%
copy from include/mach/gnumach.defs
copy to ddb/db_elf.h
index 7331334..12b8286 100644
--- a/include/mach/gnumach.defs
+++ b/ddb/db_elf.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 Free Software Foundation
+ * 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
@@ -16,24 +16,37 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-subsystem
-#if KERNEL_SERVER
- KernelServer
-#endif /* KERNEL_SERVER */
-#if KERNEL_USER
- KernelUser
-#endif /* KERNEL_USER */
- gnumach 4200;
+#ifndef _DDB_DB_ELF_H_
+#define _DDB_DB_ELF_H_
-#include <mach/std_types.defs>
-#include <mach/mach_types.defs>
+#include <ddb/db_sym.h>
+#include <machine/db_machdep.h>
-type vm_cache_statistics_data_t = struct[11] of integer_t;
+extern boolean_t
+elf_db_line_at_pc(
+ db_symtab_t *stab,
+ db_sym_t sym,
+ char **file,
+ int *line,
+ db_addr_t pc);
-/*
- * Return page cache statistics for the host on which the target task
- * resides.
- */
-routine vm_cache_statistics(
- target_task : vm_task_t;
- out vm_cache_stats : vm_cache_statistics_data_t);
+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_examine.c b/ddb/db_examine.c
index 96c5eee..836b0e8 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.
*/
@@ -65,10 +62,9 @@ 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;
- boolean_t db_option();
if (modif[0] != '\0')
db_strcpy(db_examine_format, modif);
@@ -82,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;
@@ -98,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));
@@ -110,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),
@@ -120,9 +116,8 @@ db_examine_backward(addr, have_addr, count, modif)
void
db_examine(addr, fmt, count, task)
- register
db_addr_t addr;
- char * fmt; /* format string */
+ const char * fmt; /* format string */
int count; /* repeat count */
task_t task;
{
@@ -130,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) {
@@ -163,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) {
@@ -171,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
@@ -260,7 +255,7 @@ char db_print_format = 'x';
/*ARGSUSED*/
void
-db_print_cmd()
+db_print_cmd(void)
{
db_expr_t value;
int t;
@@ -326,9 +321,9 @@ db_print_cmd()
}
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");
@@ -337,20 +332,19 @@ db_print_loc_and_inst(loc, task)
void
db_strcpy(dst, src)
- register char *dst;
- register char *src;
+ char *dst;
+ const char *src;
{
while ((*dst++ = *src++))
;
}
-void db_search(); /*forward*/
/*
* Search for a value in memory.
* Syntax: search [/bhl] addr value [mask] [,count] [thread]
*/
void
-db_search_cmd()
+db_search_cmd(void)
{
int t;
db_addr_t addr;
@@ -360,7 +354,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) {
@@ -395,7 +389,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;
@@ -412,7 +406,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;
@@ -431,18 +425,17 @@ db_search_cmd()
}
void
-db_search(addr, size, value, mask, count, task)
- register
- 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;
- 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;
}
@@ -452,13 +445,13 @@ 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)
{
- register int i, n;
+ int i, n;
db_expr_t value;
int bcount;
db_addr_t off;
diff --git a/ddb/db_examine.h b/ddb/db_examine.h
index e1fb1ee..df578a0 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,
@@ -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_ */
diff --git a/ddb/db_expr.c b/ddb/db_expr.c
index 611baa0..c9e6752 100644
--- a/ddb/db_expr.c
+++ b/ddb/db_expr.c
@@ -41,10 +41,8 @@
#include <ddb/db_variables.h>
#include <kern/task.h>
-
boolean_t
-db_term(valuep)
- db_expr_t *valuep;
+db_term(db_expr_t *valuep)
{
int t;
@@ -95,12 +93,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;
{
- register char *p;
- int size = sizeof(int);
+ const char *p;
+ int size = sizeof(int);
*u_option = FALSE;
*t_option = FALSE;
@@ -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,10 +174,9 @@ db_unary(valuep)
}
boolean_t
-db_mult_expr(valuep)
- db_expr_t *valuep;
+db_mult_expr(db_expr_t *valuep)
{
- db_expr_t lhs, rhs;
+ db_expr_t lhs = 0, rhs;
int t;
char c;
@@ -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_expr.h b/ddb/db_expr.h
index 989b66b..9c304e6 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_ext_symtab.c b/ddb/db_ext_symtab.c
index 9831a01..cafb0c4 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 6e7fa00..6b6db76 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++);
@@ -91,11 +91,11 @@ 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)
{
- register char *p;
+ char *p;
if (bwd) {
db_lc -= n;
@@ -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);
@@ -133,12 +133,11 @@ 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
-db_inputchar(c)
- int c;
+db_inputchar(int c)
{
switch (c) {
case CTRL('b'):
@@ -214,7 +213,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 +236,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++;
@@ -251,7 +250,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) {
@@ -268,7 +267,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 +291,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;
@@ -304,7 +303,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:
@@ -312,7 +311,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);
@@ -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 */
@@ -349,9 +348,9 @@ db_readline(lstart, lsize)
}
void
-db_check_interrupt()
+db_check_interrupt(void)
{
- register int c;
+ int c;
c = cnmaygetc();
switch (c) {
diff --git a/ddb/db_input.h b/ddb/db_input.h
index 316e326..77f07bb 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_lex.c b/ddb/db_lex.c
index ebffe06..8ab6910 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;
@@ -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)
- register struct db_lex_context *lp;
+db_save_lex_context(struct db_lex_context *lp)
{
lp->l_ptr = db_lp;
lp->l_eptr = db_endlp;
@@ -105,7 +104,7 @@ db_save_lex_context(lp)
void
db_restore_lex_context(lp)
- register struct db_lex_context *lp;
+ const struct db_lex_context *lp;
{
db_lp = lp->l_ptr;
db_last_lp = db_lp;
@@ -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;
}
@@ -179,10 +176,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 +202,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 > '~') {
diff --git a/ddb/db_lex.h b/ddb/db_lex.h
index dc9da0a..f7677df 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
@@ -42,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);
@@ -51,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;
@@ -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_ */
diff --git a/ddb/db_macro.c b/ddb/db_macro.c
index 43bb583..307b7c5 100644
--- a/ddb/db_macro.c
+++ b/ddb/db_macro.c
@@ -59,9 +59,9 @@ 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;
{
- 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)
@@ -73,11 +73,11 @@ db_lookup_macro(name)
}
void
-db_def_macro_cmd()
+db_def_macro_cmd(void)
{
- 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);
@@ -104,9 +104,9 @@ db_def_macro_cmd()
}
void
-db_del_macro_cmd()
+db_del_macro_cmd(void)
{
- register struct db_user_macro *mp;
+ struct db_user_macro *mp;
if (db_read_token() != tIDENT
|| (mp = db_lookup_macro(db_tok_string)) == 0) {
@@ -120,9 +120,9 @@ db_del_macro_cmd()
}
void
-db_show_macro()
+db_show_macro(void)
{
- register struct db_user_macro *mp;
+ struct db_user_macro *mp;
int t;
char *name = 0;
@@ -141,10 +141,10 @@ db_show_macro()
int
db_exec_macro(name)
- char *name;
+ const 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);
@@ -165,13 +165,13 @@ db_exec_macro(name)
return(0);
}
-long
+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");
@@ -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 da5626f..2c0a599 100644
--- a/ddb/db_macro.h
+++ b/ddb/db_macro.h
@@ -30,9 +30,9 @@ 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 long db_arg_variable (
+extern void db_arg_variable (
struct db_variable *vp,
db_expr_t *valuep,
int flag,
diff --git a/ddb/db_mp.c b/ddb/db_mp.c
index cc14aea..8d1a560 100644
--- a/ddb/db_mp.c
+++ b/ddb/db_mp.c
@@ -38,6 +38,7 @@
#include <ddb/db_command.h>
#include <ddb/db_run.h>
+#include <ddb/db_mp.h>
/*
* Routines to interlock access to the kernel debugger on
@@ -52,12 +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;
-
-void remote_db(); /* forward */
-void lock_db();
-void unlock_db();
-
+boolean_t db_enter_debug = FALSE;
/*
* Called when entering kernel debugger.
@@ -67,7 +63,7 @@ void unlock_db();
*/
boolean_t
-db_enter()
+db_enter(void)
{
int mycpu = cpu_number();
@@ -112,7 +108,7 @@ db_enter()
* Leave debugger.
*/
void
-db_leave()
+db_leave(void)
{
int mycpu = cpu_number();
@@ -147,9 +143,9 @@ db_leave()
*/
void
-remote_db() {
+remote_db(void) {
int my_cpu = cpu_number();
- register int i;
+ int i;
for (i = 0; i < NCPUS; i++) {
if (i != my_cpu &&
@@ -214,8 +210,7 @@ remote_db() {
* switch to another cpu
*/
void
-db_on(cpu)
- int cpu;
+db_on(int cpu)
{
/*
* Save ddb global variables
@@ -254,7 +249,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();
@@ -271,7 +266,7 @@ remote_db_enter()
* is active on another cpu.
*/
void
-lock_db()
+lock_db(void)
{
int my_cpu = cpu_number();
@@ -280,7 +275,7 @@ lock_db()
if (my_cpu == master_cpu) {
db_console();
}
-#endif
+#endif /* CONSOLE_ON_MASTER */
if (db_cpu != -1 && db_cpu != my_cpu)
continue;
@@ -292,9 +287,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);
@@ -302,14 +297,14 @@ lock_db()
}
void
-unlock_db()
+unlock_db(void)
{
simple_unlock(&db_lock);
}
-#ifdef sketch
+#if CONSOLE_ON_MASTER
void
-db_console()
+db_console(void)
{
if (i_bit(CBUS_PUT_CHAR, my_word)) {
volatile u_char c = cbus_ochar;
@@ -330,7 +325,7 @@ db_console()
db_cpu = my_cpu;
}
}
-#endif /* sketch */
+#endif /* CONSOLE_ON_MASTER */
#endif /* NCPUS > 1 */
diff --git a/include/mach/gnumach.defs b/ddb/db_mp.h
similarity index 58%
copy from include/mach/gnumach.defs
copy to ddb/db_mp.h
index 7331334..722f28c 100644
--- a/include/mach/gnumach.defs
+++ b/ddb/db_mp.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 Free Software Foundation
+ * 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
@@ -16,24 +16,15 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-subsystem
-#if KERNEL_SERVER
- KernelServer
-#endif /* KERNEL_SERVER */
-#if KERNEL_USER
- KernelUser
-#endif /* KERNEL_USER */
- gnumach 4200;
+#ifndef _DDB_DB_MP_H_
+#define _DDB_DB_MP_H_
-#include <mach/std_types.defs>
-#include <mach/mach_types.defs>
+void remote_db(void);
+void lock_db(void);
+void unlock_db(void);
-type vm_cache_statistics_data_t = struct[11] of integer_t;
+#if CONSOLE_ON_MASTER
+void db_console(void);
+#endif /* CONSOLE_ON_MASTER */
-/*
- * Return page cache statistics for the host on which the target task
- * resides.
- */
-routine vm_cache_statistics(
- target_task : vm_task_t;
- out vm_cache_stats : vm_cache_statistics_data_t);
+#endif /* _DDB_DB_MP_H_ */
diff --git a/ddb/db_output.c b/ddb/db_output.c
index ec73111..be5319d 100644
--- a/ddb/db_output.c
+++ b/ddb/db_output.c
@@ -42,6 +42,7 @@
#include <ddb/db_command.h>
#include <ddb/db_lex.h>
#include <ddb/db_output.h>
+#include <ddb/db_input.h>
/*
* Character output - tracks position in line.
@@ -74,15 +75,13 @@ 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.
*/
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) {
@@ -100,9 +99,9 @@ db_force_whitespace(void)
}
static void
-db_more()
+db_more(void)
{
- register char *p;
+ char *p;
boolean_t quit_output = FALSE;
for (p = "--db_more--"; *p; p++)
@@ -133,8 +132,7 @@ db_more()
* 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();
@@ -189,7 +187,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);
@@ -210,21 +208,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);
-}
-
-/* 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);
diff --git a/ddb/db_output.h b/ddb/db_output.h
index 1159c6b..497ae43 100644
--- a/ddb/db_output.h
+++ b/ddb/db_output.h
@@ -32,9 +32,15 @@
* 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 int db_print_position(void) __attribute__ ((pure));
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_ */
diff --git a/ddb/db_print.c b/ddb/db_print.c
index 4692e4c..24a3e33 100644
--- a/ddb/db_print.c
+++ b/ddb/db_print.c
@@ -53,21 +53,21 @@
#include <ddb/db_task_thread.h>
#include <ddb/db_print.h>
-extern unsigned int db_maxoff;
+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)
{
- 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;
- char *status;
+ const thread_t thread;
+ char *status;
{
- register char *p = status;
+ char *p = status;
*p++ = (thread->state & TH_RUN) ? 'R' : '.';
*p++ = (thread->state & TH_WAIT) ? 'W' : '.';
@@ -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];
@@ -194,12 +194,8 @@ db_print_thread(thread, thread_id, flag)
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("(");
@@ -220,10 +216,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;
@@ -258,7 +254,12 @@ db_print_task(task, task_id, flag)
} 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 {
@@ -275,13 +276,37 @@ db_print_task(task, task_id, flag)
}
}
+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)
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 +357,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 +403,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 +435,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;
@@ -431,12 +456,12 @@ 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)
{
- register ipc_space_t space;
- register ipc_entry_t entry;
+ ipc_space_t space;
+ ipc_entry_t entry;
if (thread == THREAD_NULL)
return(0);
@@ -452,7 +477,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 +491,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 +509,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 898014e..87db97b 100644
--- a/ddb/db_print.h
+++ b/ddb/db_print.h
@@ -24,25 +24,31 @@ 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_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,
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 53a02ce..9b467fc 100644
--- a/ddb/db_run.c
+++ b/ddb/db_run.c
@@ -59,24 +59,13 @@ 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;
- task_t task;
+db_stop_at_pc(
+ 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();
@@ -92,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.
@@ -131,7 +120,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,
@@ -167,32 +156,32 @@ 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)
{
- register 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) ||
(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);
#ifdef SOFTWARE_SSTEP
+ db_addr_t brpc;
/* 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) */
- 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);
@@ -217,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;
@@ -260,10 +249,10 @@ 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)
- 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)
@@ -275,13 +264,13 @@ db_find_temp_breakpoint(task, addr)
}
void
-db_set_task_single_step(regs, task)
- register 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;
- register unsigned int inst;
- register boolean_t unconditional;
+ unsigned int inst;
+ boolean_t unconditional;
/*
* User was stopped at pc, e.g. the instruction
@@ -321,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);
@@ -346,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;
@@ -374,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;
@@ -397,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;
@@ -422,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;
@@ -437,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_run.h b/ddb/db_run.h
index e138f60..c042d4c 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 <kern/task.h>
#include <machine/db_machdep.h>
@@ -43,26 +46,49 @@ 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);
+#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(const 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);
+
+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_sym.c b/ddb/db_sym.c
index 5c5f700..0179137 100644
--- a/ddb/db_sym.c
+++ b/ddb/db_sym.c
@@ -37,6 +37,8 @@
#include <ddb/db_output.h>
#include <ddb/db_sym.h>
#include <ddb/db_task_thread.h>
+#include <ddb/db_aout.h>
+#include <ddb/db_elf.h>
#include <vm/vm_map.h> /* vm_map_t */
@@ -50,21 +52,19 @@ 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.
*/
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)
{
- register db_symtab_t *st;
+ db_symtab_t *st;
extern vm_map_t kernel_map;
if (db_nsymtab >= MAXNOSYMTABS)
@@ -76,7 +76,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++;
@@ -89,13 +90,13 @@ 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)
- char *symname;
- register char *symtabname;
+ const char *symname;
+ const char *symtabname;
{
static char tmp[256];
- register char *s;
+ char *s;
s = tmp;
while ((*s++ = *symtabname++)) {
@@ -109,7 +110,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);
@@ -119,9 +120,9 @@ db_eqname( char* src, 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,14 +142,13 @@ 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;
- 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.
@@ -193,13 +193,13 @@ 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)
{
- register char *p;
- register int n;
+ char *p;
+ int n;
int n_name;
int line_number;
char *file_name = 0;
@@ -265,19 +265,17 @@ 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)
{
- register int i;
- register
+ int i;
boolean_t found_once = FALSE;
if (!db_qualify_ambiguous_names)
return FALSE;
for (i = 0; i < db_nsymtab; i++) {
- db_sym_t sp;
- if (sp = X_db_lookup(&db_symtabs[i], sym_name)) {
+ db_sym_t sp = X_db_lookup(&db_symtabs[i], sym_name);
+ if (sp) {
if (found_once)
{
db_free_symbol(sp);
@@ -290,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.
@@ -305,11 +300,11 @@ 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_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;
@@ -334,15 +329,15 @@ 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_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)
{
- 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;
@@ -402,11 +397,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;
@@ -449,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;
{
@@ -494,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) :
@@ -512,15 +507,11 @@ 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 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();
+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;
+}
-void dummy_db_free_symbol(sym_t) { }
struct db_sym_switch x_db[] = {
@@ -532,15 +523,17 @@ 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,}
+ { 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 e40264a..d8f3387 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 */
@@ -161,10 +162,10 @@ 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_expr_t off,
+extern void db_task_printsym( db_addr_t off,
db_strategy_t strategy,
task_t task);
@@ -205,7 +206,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,6 +236,35 @@ extern boolean_t db_line_at_pc(
db_sym_t sym,
char **filename,
int *linenum,
- db_expr_t pc);
-
-#endif
+ db_addr_t pc);
+
+extern boolean_t aout_db_sym_init(
+ char *symtab,
+ char *esymtab,
+ 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
+db_search_in_task_symbol(
+ db_addr_t val,
+ db_strategy_t strategy,
+ 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_ */
diff --git a/ddb/db_task_thread.c b/ddb/db_task_thread.c
index 1146223..edab17e 100644
--- a/ddb/db_task_thread.c
+++ b/ddb/db_task_thread.c
@@ -52,12 +52,12 @@ thread_t db_default_thread; /* default target
thread */
*/
int
db_lookup_task(target_task)
- task_t target_task;
+ const 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)
@@ -82,11 +82,11 @@ 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;
{
- register thread_t thread;
- register int thread_id;
+ thread_t thread;
+ int thread_id;
thread_id = 0;
if (queue_first(&task->thread_list) == 0)
@@ -106,13 +106,13 @@ db_lookup_task_thread(task, target_thread)
*/
int
db_lookup_thread(target_thread)
- thread_t target_thread;
+ const 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);
@@ -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);
@@ -153,12 +153,11 @@ db_check_thread_address_valid(thread)
* convert task_id(queue postion) to task address
*/
task_t
-db_lookup_task_id(task_id)
- register int task_id;
+db_lookup_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);
@@ -181,11 +180,11 @@ 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;
- register int thread_id;
+db_lookup_thread_id(
+ task_t task,
+ int thread_id)
{
- register thread_t thread;
+ thread_t thread;
if (thread_id > DB_MAX_THREADID)
@@ -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;
@@ -245,17 +244,18 @@ db_init_default_thread(void)
* in the command line
*/
/* ARGSUSED */
-long
-db_set_default_thread(vp, valuep, flag)
- struct db_variable *vp;
- db_expr_t *valuep;
- int flag;
+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;
{
thread_t thread;
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,18 +264,18 @@ 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
-db_get_task_thread(vp, valuep, flag, ap)
- struct db_variable *vp;
- db_expr_t *valuep;
- int flag;
- db_var_aux_param_t ap;
+void
+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;
@@ -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_task_thread.h b/ddb/db_task_thread.h
index ebf99d8..cbb3680 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 <ddb/db_variables.h>
+
#include <kern/task.h>
#include <kern/thread.h>
@@ -41,11 +43,25 @@
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);
+extern void
+db_set_default_thread(
+ struct db_variable *vp,
+ db_expr_t *valuep,
+ int flag,
+ db_var_aux_param_t ap);
+
+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_trap.c b/ddb/db_trap.c
index 8f59a36..b56ffdc 100644
--- a/ddb/db_trap.c
+++ b/ddb/db_trap.c
@@ -43,28 +43,25 @@
#include <ddb/db_output.h>
#include <ddb/db_task_thread.h>
#include <ddb/db_trap.h>
+#include <ddb/db_run.h>
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;
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;
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);
@@ -100,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 55b8742..4442ccb 100644
--- a/ddb/db_variables.c
+++ b/ddb/db_variables.c
@@ -39,6 +39,7 @@
#include <ddb/db_output.h>
#include <ddb/db_variables.h>
#include <ddb/db_task_thread.h>
+#include <ddb/db_macro.h>
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 int db_set_default_thread();
-extern int db_get_task_thread();
-extern int db_arg_variable();
#define DB_NWORK 32 /* number of work variable */
@@ -70,12 +68,12 @@ 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)
- register char *suffix;
+ const char *suffix;
short *suffix_value;
{
- register int value;
+ int value;
for (value = 0; *suffix && *suffix != '.' && *suffix != ':'; suffix++) {
if (*suffix < '0' || *suffix > '9')
@@ -92,10 +90,11 @@ static boolean_t
db_cmp_variable_name(vp, name, ap)
struct db_variable *vp;
char *name;
- register db_var_aux_param_t ap;
+ const db_var_aux_param_t ap;
{
- register char *var_np, *np;
- register int level;
+ char *var_np;
+ const char *np;
+ int level;
for (np = name, var_np = vp->name; *var_np; ) {
if (*np++ != *var_np++)
@@ -116,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,12 +142,8 @@ db_find_variable(varp, ap)
return (0);
}
-
-void db_read_write_variable(); /* forward */
-
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;
@@ -164,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;
@@ -181,13 +175,13 @@ 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)
{
- int (*func)() = vp->fcn;
+ void (*func)() = vp->fcn;
struct db_var_aux_param aux_param;
if (ap == 0) {
@@ -206,7 +200,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 af7068f..9880d50 100644
--- a/ddb/db_variables.h
+++ b/ddb/db_variables.h
@@ -32,6 +32,7 @@
#define _DB_VARIABLES_H_
#include <kern/thread.h>
+#include <machine/db_machdep.h>
/*
* Debugger variables.
@@ -42,7 +43,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 +51,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 */
@@ -80,6 +81,8 @@ 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 *);
#endif /* _DB_VARIABLES_H_ */
diff --git a/ddb/db_watch.c b/ddb/db_watch.c
index a2f852b..f0d0443 100644
--- a/ddb/db_watch.c
+++ b/ddb/db_watch.c
@@ -65,9 +65,9 @@ db_watchpoint_t db_watchpoint_list = 0;
extern vm_map_t kernel_map;
db_watchpoint_t
-db_watchpoint_alloc()
+db_watchpoint_alloc(void)
{
- 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;
@@ -93,11 +93,11 @@ 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;
{
- register db_watchpoint_t watch;
+ db_watchpoint_t watch;
/*
* Should we do anything fancy with overlapping regions?
@@ -130,11 +130,11 @@ db_set_watchpoint(task, addr, size)
void
db_delete_watchpoint(task, addr)
- task_t task;
+ const 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");
@@ -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,12 +237,11 @@ 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;
task_t task;
- boolean_t db_option();
if (db_get_task(modif, &task, addr) < 0)
return;
@@ -255,7 +254,7 @@ db_watchpoint_cmd(addr, have_addr, count, modif)
/* list watchpoints */
void
-db_listwatch_cmd()
+db_listwatch_cmd(void)
{
db_list_watchpoints();
}
@@ -263,8 +262,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) {
@@ -295,14 +294,14 @@ 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)
{
- 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) {
diff --git a/ddb/db_watch.h b/ddb/db_watch.h
index fb95ae5..7ef1a20 100644
--- a/ddb/db_watch.h
+++ b/ddb/db_watch.h
@@ -49,27 +49,27 @@ 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 db_listwatch_cmd(void);
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 eacf53b..46a2ee3 100644
--- a/ddb/db_write_cmd.c
+++ b/ddb/db_write_cmd.c
@@ -55,12 +55,12 @@ 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;
{
- 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;
diff --git a/include/mach/gnumach.defs b/ddb/db_write_cmd.h
similarity index 59%
copy from include/mach/gnumach.defs
copy to ddb/db_write_cmd.h
index 7331334..3a1d057 100644
--- a/include/mach/gnumach.defs
+++ b/ddb/db_write_cmd.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 Free Software Foundation
+ * 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
@@ -16,24 +16,19 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-subsystem
-#if KERNEL_SERVER
- KernelServer
-#endif /* KERNEL_SERVER */
-#if KERNEL_USER
- KernelUser
-#endif /* KERNEL_USER */
- gnumach 4200;
+#ifndef _DDB_DB_WRITE_CMD_H_
+#define _DDB_DB_WRITE_CMD_H_
-#include <mach/std_types.defs>
-#include <mach/mach_types.defs>
+#include <mach/boolean.h>
+#include <machine/db_machdep.h>
-type vm_cache_statistics_data_t = struct[11] of integer_t;
-
-/*
- * Return page cache statistics for the host on which the target task
- * resides.
+/* Prototypes for functions exported by this module.
*/
-routine vm_cache_statistics(
- target_task : vm_task_t;
- out vm_cache_stats : vm_cache_statistics_data_t);
+
+void db_write_cmd(
+ db_expr_t address,
+ boolean_t have_addr,
+ db_expr_t count,
+ const char * modif);
+
+#endif /* !_DDB_DB_WRITE_CMD_H_ */
diff --git a/ddb/stab.h b/ddb/stab.h
index 3ebc1af..55e9d45 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_ */
diff --git a/device/blkio.c b/device/blkio.c
index 27fec0e..ee86634 100644
--- a/device/blkio.c
+++ b/device/blkio.c
@@ -38,12 +38,12 @@
-io_return_t block_io(strat, max_count, ior)
- void (*strat)();
- void (*max_count)();
- register io_req_t ior;
+io_return_t block_io(
+ void (*strat)(),
+ void (*max_count)(),
+ io_req_t ior)
{
- register kern_return_t rc;
+ 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)
- register io_req_t ior;
+void minphys(io_req_t ior)
{
if ((ior->io_op & (IO_WRITE | IO_READ | IO_OPEN)) == IO_WRITE)
return;
@@ -102,7 +101,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/include/mach/gnumach.defs b/device/blkio.h
similarity index 58%
copy from include/mach/gnumach.defs
copy to device/blkio.h
index 7331334..13a1669 100644
--- a/include/mach/gnumach.defs
+++ b/device/blkio.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 Free Software Foundation
+ * 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
@@ -16,24 +16,9 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-subsystem
-#if KERNEL_SERVER
- KernelServer
-#endif /* KERNEL_SERVER */
-#if KERNEL_USER
- KernelUser
-#endif /* KERNEL_USER */
- gnumach 4200;
+#ifndef _DEVICE_BLKIO_H_
+#define _DEVICE_BLKIO_H_
-#include <mach/std_types.defs>
-#include <mach/mach_types.defs>
+extern vm_offset_t block_io_mmap(void);
-type vm_cache_statistics_data_t = struct[11] of integer_t;
-
-/*
- * Return page cache statistics for the host on which the target task
- * resides.
- */
-routine vm_cache_statistics(
- target_task : vm_task_t;
- out vm_cache_stats : vm_cache_statistics_data_t);
+#endif /* _DEVICE_BLKIO_H_ */
diff --git a/device/buf.h b/device/buf.h
index 80466c8..a79ed8e 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
*/
@@ -80,11 +83,6 @@
#define B_MD1 IO_SPARE_START
/*
- * Redefine uio structure
- */
-#define uio io_req
-
-/*
* Redefine physio routine
*/
#define physio(strat, xbuf, dev, ops, minphys, ior) \
@@ -100,3 +98,5 @@ extern void minphys(io_req_t);
*/
#define biodone iodone
#define biowait iowait
+
+#endif /* _DEVICE_BUF_H_ */
diff --git a/device/chario.c b/device/chario.c
index c40705e..0e9dd70 100644
--- a/device/chario.c
+++ b/device/chario.c
@@ -49,6 +49,7 @@
#include <device/io_req.h>
#include <device/ds_routines.h>
#include <device/device_reply.user.h>
+#include <device/chario.h>
#include <device/tty.h>
@@ -63,16 +64,6 @@ short ttlowat[NSPEEDS] =
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.
*/
@@ -89,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 */
-int pdma_default = 1; /* 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
@@ -260,7 +251,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;
@@ -535,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;
@@ -561,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;
@@ -848,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) {
/*
@@ -916,7 +906,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
{
@@ -1013,7 +1003,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);
}
diff --git a/include/mach/gnumach.defs b/device/chario.h
similarity index 58%
copy from include/mach/gnumach.defs
copy to device/chario.h
index 7331334..52105a2 100644
--- a/include/mach/gnumach.defs
+++ b/device/chario.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 Free Software Foundation
+ * 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
@@ -16,24 +16,22 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-subsystem
-#if KERNEL_SERVER
- KernelServer
-#endif /* KERNEL_SERVER */
-#if KERNEL_USER
- KernelUser
-#endif /* KERNEL_USER */
- gnumach 4200;
+#ifndef _DEVICE_CHARIO_H_
+#define _DEVICE_CHARIO_H_
-#include <mach/std_types.defs>
-#include <mach/mach_types.defs>
+#include <device/tty.h>
-type vm_cache_statistics_data_t = struct[11] of integer_t;
+extern void chario_init(void);
-/*
- * Return page cache statistics for the host on which the target task
- * resides.
- */
-routine vm_cache_statistics(
- target_task : vm_task_t;
- out vm_cache_stats : vm_cache_statistics_data_t);
+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_ */
diff --git a/device/cirbuf.c b/device/cirbuf.c
index 7af2d7a..dfb06df 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
@@ -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;
@@ -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);
diff --git a/device/cirbuf.h b/device/cirbuf.h
index a3f50ce..64771ce 100644
--- a/device/cirbuf.h
+++ b/device/cirbuf.h
@@ -52,11 +52,10 @@ 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 *);
-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_ */
diff --git a/device/conf.h b/device/conf.h
index e91e099..fea1822 100644
--- a/device/conf.h
+++ b/device/conf.h
@@ -32,22 +32,30 @@
#define _DEVICE_CONF_H_
#include <mach/machine/vm_types.h>
+#include <sys/types.h>
+#include <mach/port.h>
+#include <mach/vm_prot.h>
+
+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 */
@@ -58,9 +66,16 @@ 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 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 int nomap(dev_t dev, vm_offset_t off, int prot); /* no
operation - error */
/*
* Flavor constants for d_dev_info routine
@@ -105,10 +120,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/device/cons.c b/device/cons.c
index ceba7f2..b04621a 100644
--- a/device/cons.c
+++ b/device/cons.c
@@ -30,7 +30,7 @@
#ifdef MACH_KMSG
#include <device/io_req.h>
#include <device/kmsg.h>
-#endif
+#endif /* MACH_KMSG */
static boolean_t cn_inited = FALSE;
static struct consdev *cn_tab = 0; /* physical console device info */
@@ -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
/*
@@ -55,10 +55,10 @@ void (*romputc)() = 0;
static char consbuf[CONSBUFSIZE] = { 0 };
static char *consbp = consbuf;
static boolean_t consbufused = FALSE;
-#endif
+#endif /* CONSBUFSIZE > 0 */
void
-cninit()
+cninit(void)
{
struct consdev *cp;
dev_ops_t cn_ops;
@@ -108,7 +108,7 @@ cninit()
} while (cbp != consbp);
consbufused = FALSE;
}
-#endif
+#endif /* CONSBUFSIZE > 0 */
cn_inited = TRUE;
return;
}
@@ -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));
@@ -180,5 +180,5 @@ cnputc(c)
if (consbp >= &consbuf[CONSBUFSIZE])
consbp = consbuf;
}
-#endif
+#endif /* CONSBUFSIZE > 0 */
}
diff --git a/device/dev_hdr.h b/device/dev_hdr.h
index 340a2db..ff7d2ef 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 01317b9..a80830c 100644
--- a/device/dev_lookup.c
+++ b/device/dev_lookup.c
@@ -43,6 +43,7 @@
#include <kern/ipc_kobject.h>
#include <device/device_emul.h>
+#include <device/ds_routines.h>
/*
* Device structure routines: reference counting, port->device.
@@ -70,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;
@@ -84,7 +85,7 @@ dev_number_enter(device)
*/
void
dev_number_remove(device)
- mach_device_t device;
+ const mach_device_t device;
{
queue_t q;
@@ -98,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;
@@ -119,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;
@@ -197,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++;
@@ -210,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) {
@@ -242,15 +240,12 @@ mach_device_deallocate(device)
/*
* port-to-device lookup routines.
*/
-decl_simple_lock_data(,
- dev_port_lock)
/*
* 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);
@@ -268,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);
@@ -280,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;
@@ -307,7 +300,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;
@@ -322,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;
@@ -363,7 +356,7 @@ dev_map(routine, port)
* Initialization
*/
void
-dev_lookup_init()
+dev_lookup_init(void)
{
int i;
@@ -372,8 +365,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);
}
diff --git a/device/dev_master.h b/device/dev_master.h
index 964ae82..6ad1152 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 <cpus.h>
#if NCPUS > 1
@@ -58,3 +61,5 @@
#define io_release_master()
#endif NCPUS > 1
+
+#endif /* _DEVICE_DEV_MASTER_H_ */
diff --git a/device/dev_name.c b/device/dev_name.c
index de9e360..5bf62a0 100644
--- a/device/dev_name.c
+++ b/device/dev_name.c
@@ -39,18 +39,52 @@
/*
* Routines placed in empty entries in the device tables
*/
-int nulldev()
+int nulldev(void)
{
return (D_SUCCESS);
}
-int nodev()
+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()
+int
+nomap(dev_t dev, vm_offset_t off, int prot)
{
return (D_INVALID_OPERATION);
}
@@ -63,11 +97,11 @@ nomap()
* 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)
- char *src;
- int len;
- char *target;
+ const char *src;
+ int len;
+ const char *target;
{
while (--len >= 0)
if (*src++ != *target++)
@@ -78,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
@@ -191,7 +225,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 +241,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 1a60045..815473a 100644
--- a/device/dev_pager.c
+++ b/device/dev_pager.c
@@ -55,9 +55,8 @@
#include <device/dev_hdr.h>
#include <device/io_req.h>
#include <device/memory_object_reply.user.h>
-
-extern vm_offset_t block_io_mmap(); /* dummy routine to allow
- mmap for block devices */
+#include <device/dev_pager.h>
+#include <device/blkio.h>
/*
* The device pager routines are called directly from the message
@@ -181,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;
@@ -196,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;
@@ -217,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;
@@ -241,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,16 +317,12 @@ 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,
- 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;
@@ -335,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");
@@ -344,7 +339,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) {
@@ -357,7 +351,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);
}
@@ -422,13 +416,13 @@ 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;
}
- 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) {
@@ -463,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)
@@ -476,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");
@@ -519,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);
@@ -529,19 +522,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,
@@ -552,8 +545,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,
@@ -565,7 +558,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)
{
@@ -590,10 +583,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;
@@ -641,9 +634,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;
@@ -683,8 +676,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)
@@ -694,10 +687,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/include/mach/gnumach.defs b/device/dev_pager.h
similarity index 58%
copy from include/mach/gnumach.defs
copy to device/dev_pager.h
index 7331334..7f97ee7 100644
--- a/include/mach/gnumach.defs
+++ b/device/dev_pager.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 Free Software Foundation
+ * 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
@@ -16,24 +16,13 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-subsystem
-#if KERNEL_SERVER
- KernelServer
-#endif /* KERNEL_SERVER */
-#if KERNEL_USER
- KernelUser
-#endif /* KERNEL_USER */
- gnumach 4200;
+#ifndef _DEVICE_DEV_PAGER_H_
+#define _DEVICE_DEV_PAGER_H_
-#include <mach/std_types.defs>
-#include <mach/mach_types.defs>
+vm_offset_t device_map_page(void *dsp, vm_offset_t offset);
-type vm_cache_statistics_data_t = struct[11] of integer_t;
+boolean_t device_pager_data_request_done(io_req_t ior);
-/*
- * Return page cache statistics for the host on which the target task
- * resides.
- */
-routine vm_cache_statistics(
- target_task : vm_task_t;
- out vm_cache_stats : vm_cache_statistics_data_t);
+boolean_t device_pager_data_write_done(io_req_t ior);
+
+#endif /* _DEVICE_DEV_PAGER_H_ */
diff --git a/device/device_init.c b/device/device_init.c
index e43a2a9..794186e 100644
--- a/device/device_init.c
+++ b/device/device_init.c
@@ -38,20 +38,15 @@
#include <device/device_types.h>
#include <device/device_port.h>
#include <device/tty.h>
+#include <device/ds_routines.h>
+#include <device/net_io.h>
+#include <device/chario.h>
-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
-device_service_create()
+device_service_create(void)
{
master_device_port = ipc_port_alloc_kernel();
if (master_device_port == IP_NULL)
diff --git a/include/mach/gnumach.defs b/device/device_init.h
similarity index 58%
copy from include/mach/gnumach.defs
copy to device/device_init.h
index 7331334..175b34d 100644
--- a/include/mach/gnumach.defs
+++ b/device/device_init.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 Free Software Foundation
+ * 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
@@ -16,24 +16,9 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-subsystem
-#if KERNEL_SERVER
- KernelServer
-#endif /* KERNEL_SERVER */
-#if KERNEL_USER
- KernelUser
-#endif /* KERNEL_USER */
- gnumach 4200;
+#ifndef _DEVICE_DEVICE_INIT_H_
+#define _DEVICE_DEVICE_INIT_H_
-#include <mach/std_types.defs>
-#include <mach/mach_types.defs>
+extern void device_service_create(void);
-type vm_cache_statistics_data_t = struct[11] of integer_t;
-
-/*
- * Return page cache statistics for the host on which the target task
- * resides.
- */
-routine vm_cache_statistics(
- target_task : vm_task_t;
- out vm_cache_stats : vm_cache_statistics_data_t);
+#endif /* _DEVICE_DEVICE_INIT_H_ */
diff --git a/device/device_types_kernel.h b/device/device_types_kernel.h
index 87ce00f..e17055c 100644
--- a/device/device_types_kernel.h
+++ b/device/device_types_kernel.h
@@ -38,7 +38,6 @@
#include <mach/port.h>
#include <device/dev_hdr.h>
-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_ */
diff --git a/device/ds_routines.c b/device/ds_routines.c
index ee575e5..38d773c 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 */
@@ -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;
@@ -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);
@@ -639,7 +638,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
@@ -663,11 +662,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 +753,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;
@@ -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;
@@ -1021,7 +1019,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 +1067,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 +1144,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;
@@ -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;
@@ -1251,7 +1249,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;
@@ -1274,9 +1272,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);
/*
@@ -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);
@@ -1384,7 +1382,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;
@@ -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);
@@ -1433,7 +1431,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,
@@ -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;
@@ -1479,7 +1476,7 @@ void iodone(ior)
splx(s);
}
-void io_done_thread_continue()
+void __attribute__ ((noreturn)) io_done_thread_continue(void)
{
for (;;) {
spl_t s;
@@ -1514,7 +1511,7 @@ void io_done_thread_continue()
}
}
-void io_done_thread()
+void io_done_thread(void)
{
/*
* Set thread privileges and highest priority.
@@ -1531,7 +1528,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;
@@ -1566,8 +1563,7 @@ void mach_device_init()
mach_device_trap_init();
}
-void iowait(ior)
- io_req_t ior;
+void iowait(io_req_t ior)
{
spl_t s;
@@ -1617,7 +1613,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 +1622,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;
@@ -1688,7 +1684,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 +1731,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 +1770,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/device/ds_routines.h b/device/ds_routines.h
index c4333f4..c0543cb 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);
@@ -59,10 +58,29 @@ 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);
+extern void device_pager_init(void);
+extern void io_done_thread(void) __attribute__ ((noreturn));
+
+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/device/if_ether.h b/device/if_ether.h
index 2ac938e..91d4d9a 100644
--- a/device/if_ether.h
+++ b/device/if_ether.h
@@ -45,13 +45,8 @@ struct ether_header {
u_short ether_type;
};
-#define ETHERMTU 1500
-#define ETHERMIN (60-14)
-
#ifdef KERNEL
-u_char etherbroadcastaddr[6];
-
-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 c8bd897..c80775d 100644
--- a/device/kmsg.c
+++ b/device/kmsg.c
@@ -42,11 +42,11 @@ 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 */
-static int kmsg_init_done = 0;
+static boolean_t kmsg_init_done = FALSE;
/* Kernel Message Initializer */
static void
@@ -55,13 +55,13 @@ 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);
}
/* 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)
@@ -70,21 +70,20 @@ 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;
}
/* Kernel Message Close Handler */
-io_return_t
+void
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;
}
static boolean_t kmsg_read_done (io_req_t ior);
@@ -225,7 +224,7 @@ kmsg_putchar (int c)
if (!kmsg_init_done)
{
kmsginit ();
- kmsg_init_done = 1;
+ kmsg_init_done = TRUE;
}
simple_lock (&kmsg_lock);
diff --git a/device/kmsg.h b/device/kmsg.h
index b8c1f36..8d907f1 100644
--- a/device/kmsg.h
+++ b/device/kmsg.h
@@ -8,7 +8,7 @@
#include <device/io_req.h>
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/device/net_io.c b/device/net_io.c
index fd71c02..a9d318e 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(const 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
@@ -301,17 +301,13 @@ 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 */
-
#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.
*/
@@ -323,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;
@@ -342,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 {
@@ -351,7 +344,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 +357,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,
- register 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:
*
@@ -411,9 +369,9 @@ int bpf_match (
*/
boolean_t ethernet_priority(kmsg)
- ipc_kmsg_t kmsg;
+ const ipc_kmsg_t kmsg;
{
- register unsigned char *addr =
+ unsigned char *addr =
(unsigned char *) net_kmsg(kmsg)->header;
/*
@@ -454,10 +412,9 @@ 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)
{
- register ipc_kmsg_t kmsg;
+ ipc_kmsg_t kmsg;
boolean_t high_priority;
struct ipc_kmsg_queue send_list;
@@ -510,6 +467,7 @@ boolean_t net_deliver(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;
@@ -562,7 +520,7 @@ boolean_t net_deliver(nonblocking)
* net_kmsg_get will do a wakeup.
*/
-void net_ast()
+void net_ast(void)
{
spl_t s;
@@ -591,7 +549,7 @@ void net_ast()
(void) splx(s);
}
-void net_thread_continue()
+void __attribute__ ((noreturn)) net_thread_continue(void)
{
for (;;) {
spl_t s;
@@ -617,7 +575,7 @@ void net_thread_continue()
}
}
-void net_thread()
+void net_thread(void)
{
spl_t s;
@@ -645,10 +603,11 @@ void net_thread()
}
void
-reorder_queue(first, last)
- register queue_t first, last;
+reorder_queue(
+ queue_t first,
+ queue_t last)
{
- register queue_entry_t prev, next;
+ queue_entry_t prev, next;
prev = first->prev;
next = last->next;
@@ -668,11 +627,11 @@ reorder_queue(first, last)
* We are already at splimp.
*/
void
-net_packet(ifp, kmsg, count, priority)
- register struct ifnet *ifp;
- register 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;
@@ -732,12 +691,12 @@ int net_filter_queue_reorder = 0; /* non-zero to enable
reordering */
*/
void
net_filter(kmsg, send_list)
- register ipc_kmsg_t kmsg;
+ const 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 +816,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;
/*
@@ -914,14 +873,14 @@ 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];
- 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
@@ -1052,13 +1011,13 @@ 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)
- register filter_t *filter;
- unsigned int count;
+parse_net_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.
@@ -1146,19 +1105,19 @@ 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;
- 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;
net_hash_entry_t *head, nextentp;
queue_entry_t dead_infp, dead_entp;
int i;
@@ -1166,6 +1125,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.
*/
@@ -1404,16 +1370,16 @@ 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:
{
- 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 +1397,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 +1420,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);
@@ -1469,10 +1435,10 @@ printf ("net_getstat: count: %d, addr_int_count: %d\n",
}
io_return_t
-net_write(ifp, start, ior)
- register 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;
@@ -1523,9 +1489,9 @@ net_write(ifp, start, ior)
* Initialize the whole package.
*/
void
-net_io_init()
+net_io_init(void)
{
- 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,
@@ -1625,19 +1591,20 @@ net_io_init()
*/
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 */
{
- 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. */
@@ -1924,13 +1891,13 @@ 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)
{
- register int i, j, len;
- register bpf_insn_t p;
+ int i, j, len;
+ bpf_insn_t p;
len = BPF_BYTES2LEN(bytes);
@@ -1946,7 +1913,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)
@@ -1996,11 +1963,12 @@ bpf_validate(f, bytes, match)
}
int
-bpf_eq (f1, f2, bytes)
- register bpf_insn_t f1, f2;
- register int bytes;
+bpf_eq(
+ bpf_insn_t f1,
+ bpf_insn_t f2,
+ int bytes)
{
- register int count;
+ int count;
count = BPF_BYTES2LEN(bytes);
for (; count--; f1++, f2++) {
@@ -2016,10 +1984,10 @@ bpf_eq (f1, f2, bytes)
unsigned int
bpf_hash (n, keys)
- register int n;
- register unsigned int *keys;
+ int n;
+ const unsigned int *keys;
{
- register unsigned int hval = 0;
+ unsigned int hval = 0;
while (n--) {
hval += *keys++;
@@ -2031,12 +1999,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;
+ const 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;
@@ -2070,12 +2038,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--;
@@ -2107,8 +2076,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;
@@ -2133,8 +2101,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--;
@@ -2151,10 +2118,9 @@ 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)
{
- 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)
{
@@ -2173,10 +2139,9 @@ 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)
{
- 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)
{
diff --git a/device/net_io.h b/device/net_io.h
index 5b3a55c..f6de854 100644
--- a/device/net_io.h
+++ b/device/net_io.h
@@ -46,6 +46,15 @@
#include <device/io_req.h>
#include <device/net_status.h>
+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.
@@ -65,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,
@@ -80,6 +89,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) __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)
@@ -88,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, const unsigned int *keys);
+
+extern boolean_t
+net_do_filter(
+ net_rcv_port_t infp,
+ const char * data,
+ unsigned int data_count,
+ const 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,
+ const unsigned int *keys,
+ net_hash_entry_t **hash_headpp,
+ net_hash_entry_t *entpp);
+
#endif /* _DEVICE_NET_IO_H_ */
diff --git a/device/subrs.c b/device/subrs.c
index a82bae3..a10b72d 100644
--- a/device/subrs.c
+++ b/device/subrs.c
@@ -40,32 +40,27 @@
/*
* Print out disk name and block number for hard disk errors.
*/
-void harderr(bp, cp)
- struct buf *bp;
- char * cp;
+void harderr(ior, cp)
+ const io_req_t ior;
+ const 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);
}
/*
- * Ethernet support routines.
- */
-u_char etherbroadcastaddr[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
-
-/*
* Convert Ethernet address to printable (loggable) representation.
*/
char *
ether_sprintf(ap)
- register u_char *ap;
+ const 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++) {
@@ -80,8 +75,7 @@ ether_sprintf(ap)
/*
* Initialize send and receive queues on an interface.
*/
-void if_init_queues(ifp)
- register struct ifnet *ifp;
+void if_init_queues(struct ifnet *ifp)
{
IFQ_INIT(&ifp->if_snd);
queue_init(&ifp->if_rcv_port_list);
@@ -108,11 +102,11 @@ void wakeup(channel)
thread_wakeup((event_t) channel);
}
-struct buf *
+io_req_t
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;
@@ -133,11 +127,9 @@ geteblk(size)
return (ior);
}
-void brelse(bp)
- struct buf *bp;
+void brelse(ior)
+ io_req_t ior;
{
- register io_req_t ior = bp;
-
(void) vm_deallocate(kernel_map,
(vm_offset_t) ior->io_data,
ior->io_alloc_size);
diff --git a/device/tty.h b/device/tty.h
index dcc7711..a931e33 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 */
};
@@ -234,6 +234,4 @@ struct ldisc_switch {
extern struct ldisc_switch linesw[];
-extern void chario_init(void);
-
#endif /* _DEVICE_TTY_H_ */
diff --git a/doc/mach.info b/doc/mach.info
index 19fab2e..f94c4fe 100644
--- a/doc/mach.info
+++ b/doc/mach.info
@@ -1,9 +1,9 @@
-This is mach.info, produced by makeinfo version 5.1 from mach.texi.
+This is mach.info, produced by makeinfo version 5.2 from mach.texi.
This file documents the GNU Mach microkernel.
- This is edition 0.4, last updated on 27 September 2013, of 'The GNU
-Mach Reference Manual', for version 1.4.
+ This is edition 0.4, last updated on 22 October 2014, of 'The GNU
+Mach Reference Manual', for version 1.4+git20141107.
Copyright (C) 2001, 2002, 2006, 2007, 2008 Free Software Foundation,
Inc.
@@ -39,125 +39,126 @@ END-INFO-DIR-ENTRY
Indirect:
-mach.info-1: 1631
-mach.info-2: 304236
+mach.info-1: 1641
+mach.info-2: 302527
Tag Table:
(Indirect)
-Node: Top1631
-Node: Introduction11181
-Node: Audience12012
-Node: Features13047
-Node: Overview14874
-Node: History16067
-Node: Installing16212
-Node: Binary Distributions17437
-Node: Compilation18245
-Node: Configuration19478
-Node: Cross-Compilation35889
-Node: Bootstrap36670
-Ref: Bootstrap-Footnote-137113
-Node: Bootloader37350
-Ref: Bootloader-Footnote-138630
-Node: Modules38716
-Node: Inter Process Communication39543
-Node: Major Concepts40166
-Node: Messaging Interface43971
-Node: Mach Message Call44701
-Node: Message Format48016
-Node: Exchanging Port Rights58499
-Ref: Exchanging Port Rights-Footnote-164061
-Node: Memory64233
-Ref: Memory-Footnote-167327
-Node: Message Send67669
-Ref: Message Send-Footnote-174691
-Node: Message Receive74974
-Ref: Message Receive-Footnote-183612
-Node: Atomicity83893
-Node: Port Manipulation Interface86667
-Node: Port Creation88143
-Node: Port Destruction92932
-Node: Port Names96075
-Node: Port Rights100322
-Node: Ports and other Tasks104111
-Node: Receive Rights108204
-Node: Port Sets113383
-Node: Request Notifications115786
-Node: Virtual Memory Interface120566
-Node: Memory Allocation121819
-Node: Memory Deallocation124344
-Node: Data Transfer125808
-Node: Memory Attributes129334
-Node: Mapping Memory Objects138753
-Node: Memory Statistics142045
-Node: External Memory Management143619
-Node: Memory Object Server144324
-Node: Memory Object Creation147033
-Node: Memory Object Termination151039
-Node: Memory Objects and Data153978
-Node: Memory Object Locking171124
-Node: Memory Object Attributes177019
-Node: Default Memory Manager182856
-Node: Threads and Tasks188578
-Node: Thread Interface188915
-Node: Thread Creation189911
-Node: Thread Termination191028
-Node: Thread Information191499
-Node: Thread Settings197598
-Node: Thread Execution198832
-Node: Scheduling206125
-Node: Thread Priority206480
-Node: Hand-Off Scheduling209114
-Node: Scheduling Policy214239
-Node: Thread Special Ports215571
-Node: Exceptions218017
-Node: Task Interface218887
-Node: Task Creation219899
-Node: Task Termination221234
-Node: Task Information221836
-Node: Task Execution228367
-Node: Task Special Ports232780
-Node: Syscall Emulation236634
-Node: Profiling237865
-Node: Host Interface241628
-Node: Host Ports242613
-Node: Host Information244686
-Node: Host Time250069
-Node: Host Reboot252736
-Node: Processors and Processor Sets253288
-Node: Processor Set Interface254266
-Node: Processor Set Ports255033
-Node: Processor Set Access255863
-Node: Processor Set Creation258123
-Node: Processor Set Destruction259150
-Node: Tasks and Threads on Sets260071
-Node: Processor Set Priority265238
-Node: Processor Set Policy266528
-Node: Processor Set Info268142
-Node: Processor Interface271955
-Node: Hosted Processors272680
-Node: Processor Control273671
-Node: Processors and Sets275137
-Node: Processor Info277015
-Node: Device Interface279757
-Node: Device Reply Server281372
-Node: Device Open282664
-Node: Device Close284787
-Node: Device Read285366
-Node: Device Write288285
-Node: Device Map291090
-Node: Device Status291981
-Node: Device Filter293154
-Node: Kernel Debugger298901
-Node: Operation299628
-Node: Commands304236
-Node: Variables317950
-Node: Expressions319338
-Node: Copying320687
-Node: Documentation License339914
-Node: GNU Free Documentation License340503
-Node: CMU License362901
-Node: Concept Index364136
-Node: Function and Data Index367982
+Node: Top1641
+Node: Introduction11280
+Node: Audience12111
+Node: Features13146
+Node: Overview14973
+Node: History16166
+Node: Installing16311
+Node: Binary Distributions17536
+Node: Compilation18344
+Node: Configuration19577
+Node: Cross-Compilation35988
+Node: Bootstrap36769
+Ref: Bootstrap-Footnote-137212
+Node: Bootloader37449
+Ref: Bootloader-Footnote-138729
+Node: Modules38815
+Node: Inter Process Communication39642
+Node: Major Concepts40265
+Node: Messaging Interface44070
+Node: Mach Message Call44800
+Node: Message Format48115
+Node: Exchanging Port Rights59307
+Ref: Exchanging Port Rights-Footnote-164869
+Node: Memory65041
+Ref: Memory-Footnote-168135
+Node: Message Send68477
+Ref: Message Send-Footnote-175499
+Node: Message Receive75782
+Ref: Message Receive-Footnote-185434
+Node: Atomicity85715
+Node: Port Manipulation Interface88489
+Node: Port Creation90044
+Node: Port Destruction94833
+Node: Port Names97976
+Node: Port Rights102223
+Node: Ports and other Tasks106012
+Node: Receive Rights110105
+Node: Port Sets117036
+Node: Request Notifications119439
+Node: Inherited Ports124243
+Node: Virtual Memory Interface127927
+Node: Memory Allocation129180
+Node: Memory Deallocation131705
+Node: Data Transfer133169
+Node: Memory Attributes136695
+Node: Mapping Memory Objects146114
+Node: Memory Statistics149406
+Node: External Memory Management150980
+Node: Memory Object Server151685
+Node: Memory Object Creation154394
+Node: Memory Object Termination158400
+Node: Memory Objects and Data161339
+Node: Memory Object Locking178485
+Node: Memory Object Attributes184380
+Node: Default Memory Manager190217
+Node: Threads and Tasks195939
+Node: Thread Interface196276
+Node: Thread Creation197272
+Node: Thread Termination198389
+Node: Thread Information198860
+Node: Thread Settings204959
+Node: Thread Execution206193
+Node: Scheduling213486
+Node: Thread Priority213841
+Node: Hand-Off Scheduling216475
+Node: Scheduling Policy221600
+Node: Thread Special Ports222932
+Node: Exceptions225378
+Node: Task Interface226248
+Node: Task Creation227260
+Node: Task Termination228595
+Node: Task Information229197
+Node: Task Execution236099
+Node: Task Special Ports240512
+Node: Syscall Emulation244366
+Node: Profiling245597
+Node: Host Interface249360
+Node: Host Ports250345
+Node: Host Information252418
+Node: Host Time257801
+Node: Host Reboot260468
+Node: Processors and Processor Sets261020
+Node: Processor Set Interface261998
+Node: Processor Set Ports262765
+Node: Processor Set Access263595
+Node: Processor Set Creation265855
+Node: Processor Set Destruction266882
+Node: Tasks and Threads on Sets267803
+Node: Processor Set Priority272970
+Node: Processor Set Policy274260
+Node: Processor Set Info275874
+Node: Processor Interface279687
+Node: Hosted Processors280412
+Node: Processor Control281403
+Node: Processors and Sets282869
+Node: Processor Info284747
+Node: Device Interface287489
+Node: Device Reply Server289104
+Node: Device Open290396
+Node: Device Close292519
+Node: Device Read293098
+Node: Device Write296017
+Node: Device Map298822
+Node: Device Status299713
+Node: Device Filter302527
+Node: Kernel Debugger308274
+Node: Operation309001
+Node: Commands311978
+Node: Variables325763
+Node: Expressions327151
+Node: Copying328500
+Node: Documentation License347729
+Node: GNU Free Documentation License348318
+Node: CMU License370717
+Node: Concept Index371952
+Node: Function and Data Index375798
End Tag Table
diff --git a/doc/mach.info-1 b/doc/mach.info-1
index a24394a..53f79f5 100644
--- a/doc/mach.info-1
+++ b/doc/mach.info-1
@@ -1,9 +1,9 @@
-This is mach.info, produced by makeinfo version 5.1 from mach.texi.
+This is mach.info, produced by makeinfo version 5.2 from mach.texi.
This file documents the GNU Mach microkernel.
- This is edition 0.4, last updated on 27 September 2013, of 'The GNU
-Mach Reference Manual', for version 1.4.
+ This is edition 0.4, last updated on 22 October 2014, of 'The GNU
+Mach Reference Manual', for version 1.4+git20141107.
Copyright (C) 2001, 2002, 2006, 2007, 2008 Free Software Foundation,
Inc.
@@ -45,8 +45,8 @@ Main Menu
This file documents the GNU Mach microkernel.
- This is edition 0.4, last updated on 27 September 2013, of 'The GNU
-Mach Reference Manual', for version 1.4.
+ This is edition 0.4, last updated on 22 October 2014, of 'The GNU
+Mach Reference Manual', for version 1.4+git20141107.
Copyright (C) 2001, 2002, 2006, 2007, 2008 Free Software Foundation,
Inc.
@@ -150,6 +150,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.
+* Inherited Ports:: How to work with the inherited system ports.
Virtual Memory Interface
@@ -1291,6 +1292,15 @@ are typed. Each item has a type descriptor followed by
the actual data
of the message. The field must carry a send right, a
send-once right, 'MACH_PORT_NULL', or 'MACH_PORT_DEAD'.
+ 'unsigned long msgh_protected_payload'
+ The '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 *note Message
+ Receive:: for further information.
+
'mach_port_seqno_t msgh_seqno'
The 'msgh_seqno' field provides a sequence number for the
message. It is only valid in received messages; its value in
@@ -1367,6 +1377,7 @@ bits.
'MACH_MSG_TYPE_STRING'
'MACH_MSG_TYPE_STRING_C'
'MACH_MSG_TYPE_PORT_NAME'
+ 'MACH_MSG_TYPE_PROTECTED_PAYLOAD'
The following predefined types specify port rights, and
receive special treatment. The next section discusses these
@@ -1382,6 +1393,11 @@ bits.
'MACH_MSG_TYPE_MAKE_SEND'
'MACH_MSG_TYPE_MAKE_SEND_ONCE'
+ The type 'MACH_MSG_TYPE_PROTECTED_PAYLOAD' is used by the
+ kernel to indicate that a delivered message carries a payload
+ in the 'msgh_protected_payload' field. See *note Message
+ Receive:: for more information.
+
'msgt_size : 8'
The 'msgt_size' field specifies the size of each datum, in
bits. For example, the msgt_size of
@@ -1880,6 +1896,24 @@ then 'msgh_local_port' specifies 'MACH_PORT_DEAD'. If
the receive right
still exists, but isn't held by the caller, then 'msgh_local_port'
specifies '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
+PAYLOAD with a receive right using the 'mach_port_set_protected_payload'
+function. Once this is done, the kernel will set the
+'msgh_protected_payload' field to PAYLOAD when delivering a message to
+this right and indicate this by setting the local part of 'msgh_bits' to
+'MACH_MSG_TYPE_PROTECTED_PAYLOAD'.
+
+ The support for protected payloads was added to GNU Mach. To
+preserve binary compatibility, the 'msgh_local_port' and
+'msgh_local_port' share the same location. This makes it possible to
+add the payload information without increasing the size of
+'mach_msg_header_t'. This is an implementation detail. Which field is
+valid is determined by the local part of the '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
@@ -2105,6 +2139,7 @@ ports, port rights and port sets.
* Receive Rights:: How to work with receive rights.
* Port Sets:: How to work with port sets.
* Request Notifications:: How to request notifications for events.
+* Inherited Ports:: How to work with the inherited system ports.
File: mach.info, Node: Port Creation, Next: Port Destruction, Up: Port
Manipulation Interface
@@ -2663,6 +2698,40 @@ File: mach.info, Node: Receive Rights, Next: Port
Sets, Prev: Ports and other
server (normally the kernel), the call may return 'mach_msg' return
codes.
+ -- Function: kern_return_t mach_port_set_protected_payload
+ (ipc_space_t TASK, mach_port_t NAME, unsigned long PAYLOAD)
+ The function 'mach_port_set_protected_payload' sets the protected
+ payload associated with the right NAME to PAYLOAD. Section *note
+ Message Receive:: describes how setting a protected payload affects
+ the messages delivered to NAME.
+
+ The function returns 'KERN_SUCCESS' if the call succeeded,
+ 'KERN_INVALID_TASK' if TASK was invalid, 'KERN_INVALID_NAME' if
+ NAME did not denote a right and 'KERN_INVALID_RIGHT' if NAME
+ denoted a right, but not a receive right.
+
+ The 'mach_port_set_protected_payload' call is actually an RPC to
+ 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
+ 'mach_msg' return codes.
+
+ -- Function: kern_return_t mach_port_clear_protected_payload
+ (ipc_space_t TASK, mach_port_t NAME, unsigned long PAYLOAD)
+ The function 'mach_port_clear_protected_payload' clears the
+ protected payload associated with the right NAME.
+
+ The function returns 'KERN_SUCCESS' if the call succeeded,
+ 'KERN_INVALID_TASK' if TASK was invalid, 'KERN_INVALID_NAME' if
+ NAME did not denote a right and 'KERN_INVALID_RIGHT' if NAME
+ denoted a right, but not a receive right.
+
+ The 'mach_port_clear_protected_payload' call is actually an RPC to
+ 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
+ 'mach_msg' return codes.
+
File: mach.info, Node: Port Sets, Next: Request Notifications, Prev:
Receive Rights, Up: Port Manipulation Interface
@@ -2712,7 +2781,7 @@ File: mach.info, Node: Port Sets, Next: Request
Notifications, Prev: Receive
return codes.
-File: mach.info, Node: Request Notifications, Prev: Port Sets, Up: Port
Manipulation Interface
+File: mach.info, Node: Request Notifications, Next: Inherited Ports, Prev:
Port Sets, Up: Port Manipulation Interface
4.3.8 Request Notifications
---------------------------
@@ -2803,6 +2872,76 @@ File: mach.info, Node: Request Notifications, Prev:
Port Sets, Up: Port Manip
'mach_msg' return codes.
+File: mach.info, Node: Inherited Ports, Prev: Request Notifications, Up:
Port Manipulation Interface
+
+4.3.9 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 'mach_ports_register' and
+'mach_ports_lookup' were originally intended to be used.
+
+ -- Function: kern_return_t mach_ports_register (task_t TARGET_TASK,
+ port_array_t INIT_PORT_SET, int INIT_PORT_ARRAY_COUNT)
+ -- Function: kern_return_t mach_ports_lookup (task_t TARGET_TASK,
+ port_array_t *INIT_PORT_SET, int *INIT_PORT_ARRAY_COUNT)
+ 'mach_ports_register' manipulates the inherited ports array,
+ 'mach_ports_lookup' is used to acquire specific parent ports.
+ TARGET_TASK is the task to be affected. 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. INIT_PORT_ARRAY_COUNT is the number of ports
+ returned in INIT_PORT_SET.
+
+ '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 'mach_init.h': 'NAME_SERVER_SLOT', 'ENVIRONMENT_SLOT',
+ and 'SERVICE_SLOT'. These ports may later be retrieved with
+ 'mach_ports_lookup'.
+
+ When a new task is created (see '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
+ '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 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 '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
+ 'mach_ports_lookup' call which is done by '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 'KERN_SUCCESS' if the memory was allocated,
+ and 'KERN_INVALID_ARGUMENT' if an attempt was made to register more
+ ports than the current kernel implementation allows.
+
+
File: mach.info, Node: Virtual Memory Interface, Next: External Memory
Management, Prev: Inter Process Communication, Up: Top
5 Virtual Memory Interface
@@ -4557,7 +4696,7 @@ their priority from their task and their max priority
from the thread.
-- Function: kern_return_t thread_priority (thread_t THREAD,
int PRORITY, boolean_t SET_MAX)
The function 'thread_priority' changes the priority and optionally
- the maximum priority of THREAD. Priorities range from 0 to 31,
+ the maximum priority of 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
@@ -4568,7 +4707,7 @@ their priority from their task and their max priority
from the thread.
The functions returns 'KERN_SUCCESS' if the operation completed
successfully, 'KERN_INVALID_ARGUMENT' if THREAD is not a thread or
- PRIORITY is out of range (not in 0..31), and 'KERN_FAILURE' if the
+ PRIORITY is out of range (not in 0..49), and 'KERN_FAILURE' if the
requested operation would violate the thread's maximum priority
(thread_priority).
@@ -4582,7 +4721,7 @@ their priority from their task and their max priority
from the thread.
The functions returns 'KERN_SUCCESS' if the operation completed
successfully, 'KERN_INVALID_ARGUMENT' if THREAD is not a thread or
PROCESSOR_SET is not a control port for a processor set or PRIORITY
- is out of range (not in 0..31), and 'KERN_FAILURE' if the thread is
+ is out of range (not in 0..49), and 'KERN_FAILURE' if the thread is
not assigned to the processor set whose control port was presented.
@@ -5025,6 +5164,17 @@ File: mach.info, Node: Task Information, Next: Task
Execution, Prev: Task Ter
-- Data type: task_thread_times_info_t
This is a pointer to a 'struct task_thread_times_info'.
+ -- Function: kern_return_t task_set_name (task_t TARGET_TASK,
+ kernel_debug_name_t NAME)
+
+ The function 'task_set_name' sets the name of TARGET_TASK to NAME,
+ truncating it if necessary.
+
+ This is a debugging aid. The name is used in diagnostic messages
+ printed by the kernel.
+
+ The function returns 'KERN_SUCCESS' if the call succeeded.
+
File: mach.info, Node: Task Execution, Next: Task Special Ports, Prev: Task
Information, Up: Task Interface
@@ -6482,254 +6632,3 @@ File: mach.info, Node: Device Status, Next: Device
Filter, Prev: Device Map,
written and 'D_NO_SUCH_DEVICE' if DEVICE does not denote a device
port or the device is dead or not completely open.
-
-File: mach.info, Node: Device Filter, Prev: Device Status, Up: Device
Interface
-
-10.8 Device Filter
-==================
-
- -- Function: kern_return_t device_set_filter (device_t DEVICE,
- mach_port_t RECEIVE_PORT,
- mach_msg_type_name_t RECEIVE_PORT_TYPE, int PRIORITY,
- filter_array_t FILTER, mach_msg_type_number_t FILTER_COUNT)
- The function 'device_set_filter' makes it possible to filter out
- selected data arriving at or leaving the device and forward it to a
- port. FILTER is a list of filter commands, which are applied to
- incoming data to determine if the data should be sent to
- RECEIVE_PORT. The IPC type of the send right is specified by
- RECEIVE_PORT_RIGHT, it is either 'MACH_MSG_TYPE_MAKE_SEND' or
- 'MACH_MSG_TYPE_MOVE_SEND'. The PRIORITY value is used to order
- multiple filters.
-
- There can be up to 'NET_MAX_FILTER' commands in FILTER. The actual
- number of commands is passed in FILTER_COUNT. For the purpose of
- the filter test, an internal stack is provided. After all commands
- have been processed, the value on the top of the stack determines
- if the data is forwarded or the next filter is tried.
-
- The first command is a header which contains two fields: one for
- flags and the other for the type of interpreter used to run the
- rest of the commands.
-
- Any combination of the following flags is allowed but at least one
- of them must be specified.
-
- 'NETF_IN'
- The filter will be applied to data received by the device.
-
- 'NETF_OUT'
- The filter will be applied to data transmitted by the device.
-
- Unless the type is given explicitly the native NETF interpreter
- will be used. To select an alternative implementation use one of
- the following types:
-
- 'NETF_BPF'
- Use Berkeley Packet Filter.
-
- For the listener to know what kind of packet is being received,
- when the filter code accepts a packet the message sent to
- RECEIVE_PORT is tagged with either NETF_IN or NETF_OUT.
-
- Each word of the command list specifies a data (push) operation
- (high order NETF_NBPO bits) as well as a binary operator (low order
- NETF_NBPA bits). The value to be pushed onto the stack is chosen
- as follows.
-
- 'NETF_PUSHLIT'
- Use the next short word of the filter as the value.
-
- 'NETF_PUSHZERO'
- Use 0 as the value.
-
- 'NETF_PUSHWORD+N'
- Use short word N of the "data" portion of the message as the
- value.
-
- 'NETF_PUSHHDR+N'
- Use short word N of the "header" portion of the message as the
- value.
-
- 'NETF_PUSHIND+N'
- Pops the top long word from the stack and then uses short word
- N of the "data" portion of the message as the value.
-
- 'NETF_PUSHHDRIND+N'
- Pops the top long word from the stack and then uses short word
- N of the "header" portion of the message as the value.
-
- 'NETF_PUSHSTK+N'
- Use long word N of the stack (where the top of stack is long
- word 0) as the value.
-
- 'NETF_NOPUSH'
- Don't push a value.
-
- The unsigned value so chosen is promoted to a long word before
- being pushed. Once a value is pushed (except for the case of
- 'NETF_NOPUSH'), the top two long words of the stack are popped and
- a binary operator applied to them (with the old top of stack as the
- second operand). The result of the operator is pushed on the
- stack. These operators are:
-
- 'NETF_NOP'
- Don't pop off any values and do no operation.
-
- 'NETF_EQ'
- Perform an equal comparison.
-
- 'NETF_LT'
- Perform a less than comparison.
-
- 'NETF_LE'
- Perform a less than or equal comparison.
-
- 'NETF_GT'
- Perform a greater than comparison.
-
- 'NETF_GE'
- Perform a greater than or equal comparison.
-
- 'NETF_AND'
- Perform a bitise boolean AND operation.
-
- 'NETF_OR'
- Perform a bitise boolean inclusive OR operation.
-
- 'NETF_XOR'
- Perform a bitise boolean exclusive OR operation.
-
- 'NETF_NEQ'
- Perform a not equal comparison.
-
- 'NETF_LSH'
- Perform a left shift operation.
-
- 'NETF_RSH'
- Perform a right shift operation.
-
- 'NETF_ADD'
- Perform an addition.
-
- 'NETF_SUB'
- Perform a subtraction.
-
- 'NETF_COR'
- Perform an equal comparison. If the comparison is 'TRUE',
- terminate the filter list. Otherwise, pop the result of the
- comparison off the stack.
-
- 'NETF_CAND'
- Perform an equal comparison. If the comparison is 'FALSE',
- terminate the filter list. Otherwise, pop the result of the
- comparison off the stack.
-
- 'NETF_CNOR'
- Perform a not equal comparison. If the comparison is 'FALSE',
- terminate the filter list. Otherwise, pop the result of the
- comparison off the stack.
-
- 'NETF_CNAND'
- Perform a not equal comparison. If the comparison is 'TRUE',
- terminate the filter list. Otherwise, pop the result of the
- comparison off the stack. The scan of the filter list
- terminates when the filter list is emptied, or a 'NETF_C...'
- operation terminates the list. At this time, if the final
- value of the top of the stack is 'TRUE', then the message is
- accepted for the filter.
-
- The function returns 'D_SUCCESS' if some data was successfully
- written, 'D_INVALID_OPERATION' if RECEIVE_PORT is not a valid send
- right, and 'D_NO_SUCH_DEVICE' if DEVICE does not denote a device
- port or the device is dead or not completely open.
-
-
-File: mach.info, Node: Kernel Debugger, Next: Copying, Prev: Device
Interface, Up: Top
-
-11 Kernel Debugger
-******************
-
-The GNU Mach kernel debugger 'ddb' is a powerful built-in debugger with
-a gdb like syntax. It is enabled at compile time using the
-'--enable-kdb' option. Whenever you want to enter the debugger while
-running the kernel, you can press the key combination <Ctrl-Alt-D>.
-
-* Menu:
-
-* Operation:: Basic architecture of the kernel debugger.
-* Commands:: Available commands in the kernel debugger.
-* Variables:: Access of variables from the kernel debugger.
-* Expressions:: Usage of expressions in the kernel debugger.
-
-
-File: mach.info, Node: Operation, Next: Commands, Up: Kernel Debugger
-
-11.1 Operation
-==============
-
-The current location is called "dot". The dot is displayed with a
-hexadecimal format at a prompt. Examine and write commands update dot
-to the address of the last line examined or the last location modified,
-and set "next" to the address of the next location to be examined or
-changed. Other commands don't change dot, and set next to be the same
-as dot.
-
- The general command syntax is:
-
- COMMAND[/MODIFIER] ADDRESS [,COUNT]
-
- '!!' repeats the previous command, and a blank line repeats from the
-address next with count 1 and no modifiers. Specifying ADDRESS sets dot
-to the address. Omitting ADDRESS uses dot. A missing COUNT is taken to
-be 1 for printing commands or infinity for stack traces.
-
- Current 'ddb' is enhanced to support multi-thread debugging. A break
-point can be set only for a specific thread, and the address space or
-registers of non current thread can be examined or modified if supported
-by machine dependent routines. For example,
-
- break/t mach_msg_trap $task11.0
-
- sets a break point at 'mach_msg_trap' for the first thread of task 11
-listed by a 'show all threads' command.
-
- In the above example, '$task11.0' is translated to the corresponding
-thread structure's address by variable translation mechanism described
-later. If a default target thread is set in a variable '$thread', the
-'$task11.0' can be omitted. In general, if 't' is specified in a
-modifier of a command line, a specified thread or a default target
-thread is used as a target thread instead of the current one. The 't'
-modifier in a command line is not valid in evaluating expressions in a
-command line. If you want to get a value indirectly from a specific
-thread's address space or access to its registers within an expression,
-you have to specify a default target thread in advance, and to use ':t'
-modifier immediately after the indirect access or the register reference
-like as follows:
-
- set $thread $task11.0
- print $eax:t *(0x100):tuh
-
- No sign extension and indirection 'size(long, half word, byte)' can
-be specified with 'u', 'l', 'h' and 'b' respectively for the indirect
-access.
-
- Note: Support of non current space/register access and user space
-break point depend on the machines. If not supported, attempts of such
-operation may provide incorrect information or may cause strange
-behavior. Even if supported, the user space access is limited to the
-pages resident in the main memory at that time. If a target page is not
-in the main memory, an error will be reported.
-
- 'ddb' has a feature like a command 'more' for the output. If an
-output line exceeds the number set in the '$lines' variable, it displays
-'--db_more--' and waits for a response. The valid responses for it are:
-
-'<SPC>'
- one more page
-
-'<RET>'
- one more line
-
-'q'
- abort the current command, and return to the command input mode
-
diff --git a/doc/mach.info-2 b/doc/mach.info-2
index 2ca87f1..c6a0a98 100644
--- a/doc/mach.info-2
+++ b/doc/mach.info-2
@@ -1,9 +1,9 @@
-This is mach.info, produced by makeinfo version 5.1 from mach.texi.
+This is mach.info, produced by makeinfo version 5.2 from mach.texi.
This file documents the GNU Mach microkernel.
- This is edition 0.4, last updated on 27 September 2013, of 'The GNU
-Mach Reference Manual', for version 1.4.
+ This is edition 0.4, last updated on 22 October 2014, of 'The GNU
+Mach Reference Manual', for version 1.4+git20141107.
Copyright (C) 2001, 2002, 2006, 2007, 2008 Free Software Foundation,
Inc.
@@ -38,6 +38,257 @@ START-INFO-DIR-ENTRY
END-INFO-DIR-ENTRY
+File: mach.info, Node: Device Filter, Prev: Device Status, Up: Device
Interface
+
+10.8 Device Filter
+==================
+
+ -- Function: kern_return_t device_set_filter (device_t DEVICE,
+ mach_port_t RECEIVE_PORT,
+ mach_msg_type_name_t RECEIVE_PORT_TYPE, int PRIORITY,
+ filter_array_t FILTER, mach_msg_type_number_t FILTER_COUNT)
+ The function 'device_set_filter' makes it possible to filter out
+ selected data arriving at or leaving the device and forward it to a
+ port. FILTER is a list of filter commands, which are applied to
+ incoming data to determine if the data should be sent to
+ RECEIVE_PORT. The IPC type of the send right is specified by
+ RECEIVE_PORT_RIGHT, it is either 'MACH_MSG_TYPE_MAKE_SEND' or
+ 'MACH_MSG_TYPE_MOVE_SEND'. The PRIORITY value is used to order
+ multiple filters.
+
+ There can be up to 'NET_MAX_FILTER' commands in FILTER. The actual
+ number of commands is passed in FILTER_COUNT. For the purpose of
+ the filter test, an internal stack is provided. After all commands
+ have been processed, the value on the top of the stack determines
+ if the data is forwarded or the next filter is tried.
+
+ The first command is a header which contains two fields: one for
+ flags and the other for the type of interpreter used to run the
+ rest of the commands.
+
+ Any combination of the following flags is allowed but at least one
+ of them must be specified.
+
+ 'NETF_IN'
+ The filter will be applied to data received by the device.
+
+ 'NETF_OUT'
+ The filter will be applied to data transmitted by the device.
+
+ Unless the type is given explicitly the native NETF interpreter
+ will be used. To select an alternative implementation use one of
+ the following types:
+
+ 'NETF_BPF'
+ Use Berkeley Packet Filter.
+
+ For the listener to know what kind of packet is being received,
+ when the filter code accepts a packet the message sent to
+ RECEIVE_PORT is tagged with either NETF_IN or NETF_OUT.
+
+ Each word of the command list specifies a data (push) operation
+ (high order NETF_NBPO bits) as well as a binary operator (low order
+ NETF_NBPA bits). The value to be pushed onto the stack is chosen
+ as follows.
+
+ 'NETF_PUSHLIT'
+ Use the next short word of the filter as the value.
+
+ 'NETF_PUSHZERO'
+ Use 0 as the value.
+
+ 'NETF_PUSHWORD+N'
+ Use short word N of the "data" portion of the message as the
+ value.
+
+ 'NETF_PUSHHDR+N'
+ Use short word N of the "header" portion of the message as the
+ value.
+
+ 'NETF_PUSHIND+N'
+ Pops the top long word from the stack and then uses short word
+ N of the "data" portion of the message as the value.
+
+ 'NETF_PUSHHDRIND+N'
+ Pops the top long word from the stack and then uses short word
+ N of the "header" portion of the message as the value.
+
+ 'NETF_PUSHSTK+N'
+ Use long word N of the stack (where the top of stack is long
+ word 0) as the value.
+
+ 'NETF_NOPUSH'
+ Don't push a value.
+
+ The unsigned value so chosen is promoted to a long word before
+ being pushed. Once a value is pushed (except for the case of
+ 'NETF_NOPUSH'), the top two long words of the stack are popped and
+ a binary operator applied to them (with the old top of stack as the
+ second operand). The result of the operator is pushed on the
+ stack. These operators are:
+
+ 'NETF_NOP'
+ Don't pop off any values and do no operation.
+
+ 'NETF_EQ'
+ Perform an equal comparison.
+
+ 'NETF_LT'
+ Perform a less than comparison.
+
+ 'NETF_LE'
+ Perform a less than or equal comparison.
+
+ 'NETF_GT'
+ Perform a greater than comparison.
+
+ 'NETF_GE'
+ Perform a greater than or equal comparison.
+
+ 'NETF_AND'
+ Perform a bitise boolean AND operation.
+
+ 'NETF_OR'
+ Perform a bitise boolean inclusive OR operation.
+
+ 'NETF_XOR'
+ Perform a bitise boolean exclusive OR operation.
+
+ 'NETF_NEQ'
+ Perform a not equal comparison.
+
+ 'NETF_LSH'
+ Perform a left shift operation.
+
+ 'NETF_RSH'
+ Perform a right shift operation.
+
+ 'NETF_ADD'
+ Perform an addition.
+
+ 'NETF_SUB'
+ Perform a subtraction.
+
+ 'NETF_COR'
+ Perform an equal comparison. If the comparison is 'TRUE',
+ terminate the filter list. Otherwise, pop the result of the
+ comparison off the stack.
+
+ 'NETF_CAND'
+ Perform an equal comparison. If the comparison is 'FALSE',
+ terminate the filter list. Otherwise, pop the result of the
+ comparison off the stack.
+
+ 'NETF_CNOR'
+ Perform a not equal comparison. If the comparison is 'FALSE',
+ terminate the filter list. Otherwise, pop the result of the
+ comparison off the stack.
+
+ 'NETF_CNAND'
+ Perform a not equal comparison. If the comparison is 'TRUE',
+ terminate the filter list. Otherwise, pop the result of the
+ comparison off the stack. The scan of the filter list
+ terminates when the filter list is emptied, or a 'NETF_C...'
+ operation terminates the list. At this time, if the final
+ value of the top of the stack is 'TRUE', then the message is
+ accepted for the filter.
+
+ The function returns 'D_SUCCESS' if some data was successfully
+ written, 'D_INVALID_OPERATION' if RECEIVE_PORT is not a valid send
+ right, and 'D_NO_SUCH_DEVICE' if DEVICE does not denote a device
+ port or the device is dead or not completely open.
+
+
+File: mach.info, Node: Kernel Debugger, Next: Copying, Prev: Device
Interface, Up: Top
+
+11 Kernel Debugger
+******************
+
+The GNU Mach kernel debugger 'ddb' is a powerful built-in debugger with
+a gdb like syntax. It is enabled at compile time using the
+'--enable-kdb' option. Whenever you want to enter the debugger while
+running the kernel, you can press the key combination <Ctrl-Alt-D>.
+
+* Menu:
+
+* Operation:: Basic architecture of the kernel debugger.
+* Commands:: Available commands in the kernel debugger.
+* Variables:: Access of variables from the kernel debugger.
+* Expressions:: Usage of expressions in the kernel debugger.
+
+
+File: mach.info, Node: Operation, Next: Commands, Up: Kernel Debugger
+
+11.1 Operation
+==============
+
+The current location is called "dot". The dot is displayed with a
+hexadecimal format at a prompt. Examine and write commands update dot
+to the address of the last line examined or the last location modified,
+and set "next" to the address of the next location to be examined or
+changed. Other commands don't change dot, and set next to be the same
+as dot.
+
+ The general command syntax is:
+
+ COMMAND[/MODIFIER] ADDRESS [,COUNT]
+
+ '!!' repeats the previous command, and a blank line repeats from the
+address next with count 1 and no modifiers. Specifying ADDRESS sets dot
+to the address. Omitting ADDRESS uses dot. A missing COUNT is taken to
+be 1 for printing commands or infinity for stack traces.
+
+ Current 'ddb' is enhanced to support multi-thread debugging. A break
+point can be set only for a specific thread, and the address space or
+registers of non current thread can be examined or modified if supported
+by machine dependent routines. For example,
+
+ break/t mach_msg_trap $task11.0
+
+ sets a break point at 'mach_msg_trap' for the first thread of task 11
+listed by a 'show all threads' command.
+
+ In the above example, '$task11.0' is translated to the corresponding
+thread structure's address by variable translation mechanism described
+later. If a default target thread is set in a variable '$thread', the
+'$task11.0' can be omitted. In general, if 't' is specified in a
+modifier of a command line, a specified thread or a default target
+thread is used as a target thread instead of the current one. The 't'
+modifier in a command line is not valid in evaluating expressions in a
+command line. If you want to get a value indirectly from a specific
+thread's address space or access to its registers within an expression,
+you have to specify a default target thread in advance, and to use ':t'
+modifier immediately after the indirect access or the register reference
+like as follows:
+
+ set $thread $task11.0
+ print $eax:t *(0x100):tuh
+
+ No sign extension and indirection 'size(long, half word, byte)' can
+be specified with 'u', 'l', 'h' and 'b' respectively for the indirect
+access.
+
+ Note: Support of non current space/register access and user space
+break point depend on the machines. If not supported, attempts of such
+operation may provide incorrect information or may cause strange
+behavior. Even if supported, the user space access is limited to the
+pages resident in the main memory at that time. If a target page is not
+in the main memory, an error will be reported.
+
+ 'ddb' has a feature like a command 'more' for the output. If an
+output line exceeds the number set in the '$lines' variable, it displays
+'--db_more--' and waits for a response. The valid responses for it are:
+
+'<SPC>'
+ one more page
+
+'<RET>'
+ one more line
+
+'q'
+ abort the current command, and return to the command input mode
+
+
File: mach.info, Node: Commands, Next: Variables, Prev: Operation, Up:
Kernel Debugger
11.2 Commands
@@ -313,11 +564,12 @@ File: mach.info, Node: Commands, Next: Variables,
Prev: Operation, Up: Kerne
numbers may change. The current thread can be distinguished from
others by a '#' after the thread id instead of ':'. Without '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 status bit is off, '.' is printed instead. If 'l'
- option is specified, more detail information is printed for each
- thread.
+ status for each 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, '.' is printed instead. If
+ 'l' option is specified, more detail information is printed for
+ each thread.
'show task [ ADDR ]'
Display the information of a task specified by ADDR. If ADDR is
@@ -1438,26 +1690,29 @@ Function and Data Index
(line 9)
* mach_host_self: Host Ports. (line 13)
* mach_msg: Mach Message Call. (line 9)
-* MACH_MSGH_BITS: Message Format. (line 94)
-* MACH_MSGH_BITS_LOCAL: Message Format. (line 106)
-* MACH_MSGH_BITS_OTHER: Message Format. (line 116)
-* MACH_MSGH_BITS_PORTS: Message Format. (line 111)
-* MACH_MSGH_BITS_REMOTE: Message Format. (line 101)
+* MACH_MSGH_BITS: Message Format. (line 103)
+* MACH_MSGH_BITS_LOCAL: Message Format. (line 115)
+* MACH_MSGH_BITS_OTHER: Message Format. (line 125)
+* MACH_MSGH_BITS_PORTS: Message Format. (line 120)
+* MACH_MSGH_BITS_REMOTE: Message Format. (line 110)
* mach_msg_bits_t: Message Format. (line 20)
* mach_msg_header_t: Message Format. (line 32)
* mach_msg_id_t: Message Format. (line 28)
* mach_msg_size_t: Message Format. (line 24)
* mach_msg_timeout_t: Mach Message Call. (line 60)
-* mach_msg_type_long_t: Message Format. (line 231)
-* mach_msg_type_name_t: Message Format. (line 127)
-* mach_msg_type_number_t: Message Format. (line 137)
-* MACH_MSG_TYPE_PORT_ANY: Message Format. (line 217)
-* MACH_MSG_TYPE_PORT_ANY_RIGHT: Message Format. (line 226)
-* MACH_MSG_TYPE_PORT_ANY_SEND: Message Format. (line 221)
-* mach_msg_type_size_t: Message Format. (line 132)
-* mach_msg_type_t: Message Format. (line 142)
+* mach_msg_type_long_t: Message Format. (line 246)
+* mach_msg_type_name_t: Message Format. (line 136)
+* mach_msg_type_number_t: Message Format. (line 146)
+* MACH_MSG_TYPE_PORT_ANY: Message Format. (line 232)
+* MACH_MSG_TYPE_PORT_ANY_RIGHT: Message Format. (line 241)
+* MACH_MSG_TYPE_PORT_ANY_SEND: Message Format. (line 236)
+* mach_msg_type_size_t: Message Format. (line 141)
+* mach_msg_type_t: Message Format. (line 151)
+* mach_ports_lookup: Inherited Ports. (line 14)
+* mach_ports_register: Inherited Ports. (line 12)
* mach_port_allocate: Port Creation. (line 6)
* mach_port_allocate_name: Port Creation. (line 64)
+* mach_port_clear_protected_payload: Receive Rights. (line 142)
* mach_port_deallocate: Port Destruction. (line 6)
* mach_port_destroy: Port Destruction. (line 28)
* mach_port_extract_right: Ports and other Tasks.
@@ -1478,6 +1733,7 @@ Function and Data Index
* mach_port_rights_t: Receive Rights. (line 18)
* mach_port_seqno_t: Receive Rights. (line 6)
* mach_port_set_mscount: Receive Rights. (line 71)
+* mach_port_set_protected_payload: Receive Rights. (line 124)
* mach_port_set_qlimit: Receive Rights. (line 88)
* mach_port_set_seqno: Receive Rights. (line 106)
* mach_port_status_t: Receive Rights. (line 22)
@@ -1632,6 +1888,7 @@ Function and Data Index
* task_set_emulation_vector: Syscall Emulation. (line 12)
* task_set_exception_port: Task Special Ports. (line 70)
* task_set_kernel_port: Task Special Ports. (line 64)
+* task_set_name: Task Information. (line 160)
* task_set_special_port: Task Special Ports. (line 46)
* task_suspend: Task Execution. (line 6)
* task_t: Task Interface. (line 6)
diff --git a/doc/mach.texi b/doc/mach.texi
index 9ad9e70..4cde9fe 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.
address@hidden * Inherited Ports:: How to work with the
inherited system ports.
+* Inherited Ports:: How to work with the inherited system ports.
Virtual Memory Interface
@@ -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}.
address@hidden 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
@@ -1417,6 +1426,7 @@ types are predefined:
@item MACH_MSG_TYPE_STRING
@item MACH_MSG_TYPE_STRING_C
@item MACH_MSG_TYPE_PORT_NAME
address@hidden MACH_MSG_TYPE_PROTECTED_PAYLOAD
@end table
The following predefined types specify port rights, and receive special
@@ -1435,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
address@hidden 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.
@@ -1934,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
address@hidden with a receive right using the
address@hidden function. Once this is done,
+the kernel will set the @code{msgh_protected_payload} field to
address@hidden when delivering a message to this right and indicate
+this by setting the local part of @code{msgh_bits} to
address@hidden
+
+The support for protected payloads was added to GNU Mach. To preserve
+binary compatibility, the @code{msgh_local_port} and
address@hidden share the same location. This makes it
+possible to add the payload information without increasing the size of
address@hidden This is an implementation detail. Which
+field is valid is determined by the local part of the
address@hidden 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
@@ -2164,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.
address@hidden * Inherited Ports:: How to work with the
inherited system ports.
+* Inherited Ports:: How to work with the inherited system ports.
@end menu
@@ -2715,6 +2749,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
address@hidden 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,
address@hidden if @var{task} was invalid,
address@hidden if @var{name} did not denote a right and
address@hidden if @var{name} denoted a right, but not a
+receive right.
+
+The @code{mach_port_set_protected_payload} call is actually an RPC to
address@hidden, 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
address@hidden return codes.
address@hidden deftypefun
+
address@hidden 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,
address@hidden if @var{task} was invalid,
address@hidden if @var{name} did not denote a right and
address@hidden 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
address@hidden return codes.
address@hidden deftypefun
@node Port Sets
@subsection Port Sets
@@ -2848,66 +2917,69 @@ call's server (normally the kernel), the call may
return @code{mach_msg}
return codes.
@end deftypefun
address@hidden The inherited ports concept is not used in the Hurd,
address@hidden and so the _SLOT macros are not defined in GNU Mach.
-
address@hidden @node Inherited Ports
address@hidden @subsection Inherited Ports
-
address@hidden @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}})
address@hidden @deftypefunx kern_return_t mach_ports_lookup (@w{task_t
@var{target_task}, @w{port_array_t address@hidden, @w{int address@hidden)
address@hidden @code{mach_ports_register} manipulates the inherited ports
array,
address@hidden @code{mach_ports_lookup} is used to acquire specific parent
ports.
address@hidden @var{target_task} is the task to be affected.
@var{init_port_set} is an
address@hidden array of system ports to be registered, or returned. Although
the array
address@hidden size is given as variable, the kernel will only accept a
limited number
address@hidden of ports. @var{init_port_array_count} is the number of ports
returned
address@hidden in @var{init_port_set}.
-
address@hidden @code{mach_ports_register} registers an array of well-known
system ports
address@hidden with the kernel on behalf of a specific task. Currently the
ports to be
address@hidden registered are: the port to the Network Name Server, the port
to the
address@hidden Environment Manager, and a port to the Service server. These
port
address@hidden values must be placed in specific slots in the init_port_set.
The slot
address@hidden numbers are given by the global constants defined in
@file{mach_init.h}:
address@hidden @code{NAME_SERVER_SLOT}, @code{ENVIRONMENT_SLOT}, and
address@hidden @code{SERVICE_SLOT}. These ports may later be retrieved with
address@hidden @code{mach_ports_lookup}.
-
address@hidden When a new task is created (see @code{task_create}), the child
task will
address@hidden be given access to these ports. Only port send rights may be
address@hidden registered. Furthermore, the number of ports which may be
registered is
address@hidden fixed and given by the global constant
@code{MACH_PORT_SLOTS_USED}
address@hidden Attempts to register too many ports will fail.
-
address@hidden It is intended that this mechanism be used only for task
initialization,
address@hidden and then only by runtime support modules. A parent task has
three
address@hidden choices in passing these system ports to a child task. Most
commonly it
address@hidden can do nothing and its child will inherit access to the same
address@hidden @var{init_port_set} that the parent has; or a parent task may
register a
address@hidden set of ports it wishes to have passed to all of its children by
calling
address@hidden @code{mach_ports_register} using its task port; or it may make
necessary
address@hidden modifications to the set of ports it wishes its child to see,
and then
address@hidden register those ports using the child's task port prior to
starting the
address@hidden child's thread(s). The @code{mach_ports_lookup} call which is
done by
address@hidden @code{mach_init} in the child task will acquire these initial
ports for
address@hidden the child.
-
address@hidden Tasks other than the Network Name Server and the Environment
Manager
address@hidden should not need access to the Service port. The Network Name
Server port
address@hidden is the same for all tasks on a given machine. The Environment
port is
address@hidden the only port likely to have different values for different
tasks.
-
address@hidden Since the number of ports which may be registered is limited,
ports
address@hidden other than those used by the runtime system to initialize a
task should
address@hidden be passed to children either through an initial message, or
through the
address@hidden Network Name Server for public ports, or the Environment
Manager for
address@hidden private ports.
-
address@hidden The function returns @code{KERN_SUCCESS} if the memory was
allocated,
address@hidden and @code{KERN_INVALID_ARGUMENT} if an attempt was made to
register more
address@hidden ports than the current kernel implementation allows.
address@hidden @end deftypefun
address@hidden Inherited Ports
address@hidden 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
address@hidden were originally intended to be used.
+
address@hidden 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}})
address@hidden kern_return_t mach_ports_lookup (@w{task_t @var{target_task}},
@w{port_array_t address@hidden, @w{int address@hidden)
address@hidden manipulates the inherited ports array,
address@hidden is used to acquire specific parent ports.
address@hidden 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}.
+
address@hidden 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}:
address@hidden, @code{ENVIRONMENT_SLOT}, and
address@hidden These ports may later be retrieved with
address@hidden
+
+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
address@hidden 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
address@hidden 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
address@hidden 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.
address@hidden deftypefun
@node Virtual Memory Interface
@@ -4557,7 +4629,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 +4640,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 +4654,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
@@ -5037,6 +5109,17 @@ total system run time for live threads
This is a pointer to a @code{struct task_thread_times_info}.
@end deftp
address@hidden 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.
address@hidden deftypefun
+
@node Task Execution
@subsection Task Execution
@@ -7018,8 +7101,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.
diff --git a/doc/stamp-vti b/doc/stamp-vti
index 5517e3f..cd116f1 100644
--- a/doc/stamp-vti
+++ b/doc/stamp-vti
@@ -1,4 +1,4 @@
address@hidden UPDATED 27 September 2013
address@hidden UPDATED-MONTH September 2013
address@hidden EDITION 1.4
address@hidden VERSION 1.4
address@hidden UPDATED 22 October 2014
address@hidden UPDATED-MONTH October 2014
address@hidden EDITION 1.4+git20141107
address@hidden VERSION 1.4+git20141107
diff --git a/doc/version.texi b/doc/version.texi
index 5517e3f..cd116f1 100644
--- a/doc/version.texi
+++ b/doc/version.texi
@@ -1,4 +1,4 @@
address@hidden UPDATED 27 September 2013
address@hidden UPDATED-MONTH September 2013
address@hidden EDITION 1.4
address@hidden VERSION 1.4
address@hidden UPDATED 22 October 2014
address@hidden UPDATED-MONTH October 2014
address@hidden EDITION 1.4+git20141107
address@hidden VERSION 1.4+git20141107
diff --git a/i386/Makefrag.am b/i386/Makefrag.am
index 738c60a..4dd6a9f 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,9 +51,29 @@ 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
+
+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
#
@@ -62,7 +83,7 @@ endif
if enable_lpr
libkernel_a_SOURCES += \
i386/i386at/lpr.c \
- i386/i386at/lprreg.h
+ i386/i386at/lpr.h
endif
@@ -81,6 +102,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 \
@@ -134,7 +156,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 \
@@ -146,6 +167,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 \
@@ -228,7 +250,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/grub/acpi.h b/i386/grub/acpi.h
new file mode 100644
index 0000000..2ac2bd6
--- /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 <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GRUB_ACPI_HEADER
+#define GRUB_ACPI_HEADER 1
+
+#ifndef GRUB_DSDT_TEST
+#include <grub/types.h>
+#include <grub/err.h>
+#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 0000000..c9e1d7a
--- /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 <http://www.gnu.org/licenses/>.
+ */
+
+#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 0000000..ae12a3e
--- /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 <http://www.gnu.org/licenses/>.
+ */
+
+/* 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 0000000..842882c
--- /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 <http://www.gnu.org/licenses/>.
+ */
+
+#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 0000000..c20063f
--- /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 <http://www.gnu.org/licenses/>.
+ */
+
+#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 0000000..1590c68
--- /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 <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GRUB_ERR_HEADER
+#define GRUB_ERR_HEADER 1
+
+#include <grub/symbol.h>
+
+#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 0000000..ae41014
--- /dev/null
+++ b/i386/grub/glue.h
@@ -0,0 +1,33 @@
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+#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 <mach/mach_types.h>
+#include <i386/vm_param.h>
+
+/* 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/ddb/db_input.h b/i386/grub/i18n.h
similarity index 51%
copy from ddb/db_input.h
copy to i386/grub/i18n.h
index 316e326..8b53357 100644
--- a/ddb/db_input.h
+++ b/i386/grub/i18n.h
@@ -1,10 +1,10 @@
/*
- * Copyright (C) 2007 Free Software Foundation, Inc.
+ * 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, or (at your option)
- * any later version.
+ * 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
@@ -12,17 +12,14 @@
* 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, 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * Author: Barry deFreese.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef _DDB_DB_INPUT_H_
-#define _DDB_DB_INPUT_H_
-
-#include <sys/types.h>
+#ifndef _GRUB_I18N_H
+#define _GRUB_I18N_H
-extern int db_readline (char *lstart, int lsize);
+/* No i18n please. */
+#define _(x) x
+#define N_(x) x
-#endif /* _DDB_DB_INPUT_H_ */
+#endif /* _GRUB_I18N_H */
diff --git a/i386/grub/misc.h b/i386/grub/misc.h
new file mode 100644
index 0000000..c6cd456
--- /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 <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GRUB_MISC_HEADER
+#define GRUB_MISC_HEADER 1
+
+#include <stdarg.h>
+#include <grub/types.h>
+#include <grub/symbol.h>
+#include <grub/err.h>
+#include <grub/i18n.h>
+#include <grub/compiler.h>
+
+#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 <address@hidden>, 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 0000000..28e2e53
--- /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 <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GRUB_MM_H
+#define GRUB_MM_H 1
+
+#include <grub/types.h>
+#include <grub/symbol.h>
+#include <config.h>
+
+#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 0000000..ed19f70
--- /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 <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GRUB_SYMBOL_HEADER
+#define GRUB_SYMBOL_HEADER 1
+
+#include <config.h>
+
+/* 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 0000000..64ac99a
--- /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 <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef KERNEL_TIME_HEADER
+#define KERNEL_TIME_HEADER 1
+
+#include <grub/types.h>
+#include <grub/symbol.h>
+#ifndef GRUB_MACHINE_EMU
+#include <grub/cpu/time.h>
+#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 0000000..79f765c
--- /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 <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GRUB_TYPES_HEADER
+#define GRUB_TYPES_HEADER 1
+
+#include <config.h>
+#ifndef GRUB_UTIL
+#include <grub/cpu/types.h>
+#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/i386/ast_check.c b/i386/i386/ast_check.c
index 982c705..f3e1c35 100644
--- a/i386/i386/ast_check.c
+++ b/i386/i386/ast_check.c
@@ -37,23 +37,17 @@
/*
* Initialize for remote invocation of ast_check.
*/
-init_ast_check(processor)
- processor_t processor;
+void init_ast_check(processor)
+ const processor_t processor;
{
-#ifdef lint
- processor++;
-#endif /* lint */
}
/*
* Cause remote invocation of ast_check. Caller is at splsched().
*/
-cause_ast_check(processor)
- processor_t processor;
+void cause_ast_check(processor)
+ const processor_t processor;
{
-#ifdef lint
- processor++;
-#endif /* lint */
}
#endif /* NCPUS > 1 */
diff --git a/i386/i386/db_disasm.c b/i386/i386/db_disasm.c
index e15293b..4afbcf3 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 90ca22d..b442b86 100644
--- a/i386/i386/db_interface.c
+++ b/i386/i386/db_interface.c
@@ -27,6 +27,7 @@
* Interface to new debugger.
*/
+#include <string.h>
#include <sys/reboot.h>
#include <vm/pmap.h>
@@ -43,6 +44,7 @@
#include "vm_param.h"
#include <vm/vm_map.h>
+#include <vm/vm_fault.h>
#include <kern/cpu_number.h>
#include <kern/printf.h>
#include <kern/thread.h>
@@ -59,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)
@@ -135,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);
@@ -161,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);
}
}
@@ -170,12 +172,12 @@ 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;
- unsigned int kern_addr;
+ vm_offset_t kern_addr;
if (num >= 4)
return FALSE;
@@ -214,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);
@@ -232,7 +235,7 @@ boolean_t
kdb_trap(
int type,
int code,
- register struct i386_saved_state *regs)
+ struct i386_saved_state *regs)
{
spl_t s;
@@ -408,12 +411,12 @@ boolean_t db_no_vm_fault = TRUE;
int
db_user_to_kernel_address(
- task_t task,
+ const task_t task,
vm_offset_t addr,
- unsigned int *kaddr,
+ vm_offset_t *kaddr,
int flag)
{
- register pt_entry_t *ptp;
+ pt_entry_t *ptp;
boolean_t faulted = FALSE;
retry:
@@ -437,7 +440,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);
}
@@ -448,13 +451,13 @@ 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;
- unsigned kern_addr;
+ char *src;
+ int n;
+ vm_offset_t kern_addr;
src = (char *)addr;
if ((addr >= VM_MIN_KERNEL_ADDRESS && addr < VM_MAX_KERNEL_ADDRESS) ||
task == TASK_NULL) {
@@ -491,19 +494,18 @@ 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();
if ((addr < VM_MIN_KERNEL_ADDRESS) ^
((addr + size) <= VM_MIN_KERNEL_ADDRESS)) {
@@ -560,13 +562,13 @@ 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;
- unsigned kern_addr;
+ char *dst;
+ int n;
+ vm_offset_t kern_addr;
while (size > 0) {
if (db_user_to_kernel_address(task, addr, &kern_addr, 1) < 0)
@@ -585,7 +587,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;
@@ -616,7 +618,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;
@@ -639,16 +641,19 @@ 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,
+ const task_t task,
vm_offset_t *svaddr,
vm_offset_t evaddr,
vm_offset_t *skaddr,
int flag)
{
- register unsigned vaddr;
- register unsigned *kaddr;
+ unsigned vaddr;
+ unsigned *kaddr;
kaddr = (unsigned *)*skaddr;
for (vaddr = *svaddr; vaddr > evaddr; ) {
@@ -669,13 +674,12 @@ db_search_null(
}
return FALSE;
}
-
-#define GNU
+#endif /* GNU */
#ifdef GNU
static boolean_t
looks_like_command(
- task_t task,
+ const task_t task,
char* kaddr)
{
char *c;
@@ -715,19 +719,19 @@ looks_like_command(
return TRUE;
}
-#endif
+#endif /* GNU */
void
db_task_name(
- task_t task)
+ const task_t task)
{
- register char *p;
- register int n;
- unsigned vaddr, kaddr;
+ char *p;
+ int n;
+ 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;
}
@@ -758,12 +762,12 @@ 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;
}
-#else
+#else /* GNU */
vaddr = DB_USER_STACK_ADDR;
kaddr = 0;
@@ -781,18 +785,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;
diff --git a/i386/i386/db_interface.h b/i386/i386/db_interface.h
index 3f6821d..8d7daea 100644
--- a/i386/i386/db_interface.h
+++ b/i386/i386/db_interface.h
@@ -25,6 +25,7 @@
#include <kern/task.h>
#include <machine/thread.h>
#include <ddb/db_watch.h>
+#include <ddb/db_variables.h>
extern boolean_t kdb_trap (
int type,
@@ -57,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);
@@ -88,6 +89,26 @@ 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,
+ const char *modif);
+
+extern void
+db_halt_cpu(void);
+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(
@@ -99,4 +120,13 @@ extern kern_return_t db_set_debug_state(
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_ */
diff --git a/i386/i386/db_machdep.h b/i386/i386/db_machdep.h
index c6ea3ca..ae1f9c0 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 */
diff --git a/i386/i386/db_trace.c b/i386/i386/db_trace.c
index 4e3bea3..cdebde1 100644
--- a/i386/i386/db_trace.c
+++ b/i386/i386/db_trace.c
@@ -35,6 +35,8 @@
#include <machine/db_machdep.h>
#include <machine/machspl.h>
+#include <machine/db_interface.h>
+#include <machine/db_trace.h>
#include <ddb/db_access.h>
#include <ddb/db_command.h>
@@ -45,13 +47,6 @@
#include "trap.h"
-long
-db_i386_reg_value(
- struct db_variable *vp,
- db_expr_t *valuep,
- int flag,
- struct db_var_aux_param *ap); /* forward */
-
/*
* Machine register set.
*/
@@ -112,10 +107,10 @@ struct i386_kregs {
long *
db_lookup_i386_kreg(
- char *name,
- int *kregp)
+ const char *name,
+ const long *kregp)
{
- register struct i386_kregs *kp;
+ struct i386_kregs *kp;
for (kp = i386_kregs; kp->name; kp++) {
if (strcmp(name, kp->name) == 0)
@@ -124,7 +119,7 @@ db_lookup_i386_kreg(
return 0;
}
-long
+void
db_i386_reg_value(
struct db_variable *vp,
db_expr_t *valuep,
@@ -133,7 +128,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')) {
@@ -205,7 +200,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(
@@ -264,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;
@@ -318,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
@@ -334,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;
@@ -343,8 +330,8 @@ db_stack_trace_cmd(
thread_t th;
{
- register char *cp = modif;
- register char c;
+ const char *cp = modif;
+ char c;
while ((c = *cp++) != 0) {
if (c == 't')
@@ -361,7 +348,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;
@@ -381,10 +368,10 @@ 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,
+ db_task_printsym((db_addr_t)th->swap_func,
DB_STGY_PROC,
th->task);
db_printf("\n");
@@ -392,7 +379,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);
@@ -412,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,
@@ -438,18 +425,18 @@ 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++;
}
lastframe = 0;
while (count-- && frame != 0) {
- register int narg;
+ int narg;
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;
@@ -474,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 {
@@ -519,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");
@@ -546,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*/;
@@ -571,18 +560,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 <machine/setjmp.h>
@@ -646,7 +635,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/include/mach/gnumach.defs b/i386/i386/db_trace.h
similarity index 58%
copy from include/mach/gnumach.defs
copy to i386/i386/db_trace.h
index 7331334..604654c 100644
--- a/include/mach/gnumach.defs
+++ b/i386/i386/db_trace.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 Free Software Foundation
+ * 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
@@ -16,24 +16,17 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-subsystem
-#if KERNEL_SERVER
- KernelServer
-#endif /* KERNEL_SERVER */
-#if KERNEL_USER
- KernelUser
-#endif /* KERNEL_USER */
- gnumach 4200;
+#ifndef _I386_DB_TRACE_H_
+#define _I386_DB_TRACE_H_
-#include <mach/std_types.defs>
-#include <mach/mach_types.defs>
+struct i386_frame;
-type vm_cache_statistics_data_t = struct[11] of integer_t;
+void
+db_i386_stack_trace(
+ thread_t th,
+ struct i386_frame *frame,
+ db_addr_t callpc,
+ db_expr_t count,
+ int flags);
-/*
- * Return page cache statistics for the host on which the target task
- * resides.
- */
-routine vm_cache_statistics(
- target_task : vm_task_t;
- out vm_cache_stats : vm_cache_statistics_data_t);
+#endif /* _I386_DB_TRACE_H_ */
diff --git a/i386/i386/debug.h b/i386/i386/debug.h
index f87b95b..e94649b 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 937d7b4..7657808 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",
@@ -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 d35e3ef..0f34833 100644
--- a/i386/i386/fpu.c
+++ b/i386/i386/fpu.c
@@ -53,6 +53,7 @@
#include <i386/pio.h>
#include <i386/pic.h>
#include <i386/locore.h>
+#include <i386/trap.h>
#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 */
@@ -105,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;
@@ -189,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,
@@ -201,8 +197,7 @@ fpu_module_init()
* 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
@@ -296,12 +291,12 @@ 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;
{
- 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 +334,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 *)
@@ -378,7 +373,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->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;
@@ -407,11 +402,11 @@ ASSERT_IPL(SPL0);
*/
kern_return_t
fpu_get_state(thread, state)
- thread_t thread;
- register struct i386_float_state *state;
+ const thread_t thread;
+ 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 +440,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;
@@ -471,7 +466,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->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;
@@ -499,7 +494,7 @@ ASSERT_IPL(SPL0);
*
* Use 53-bit precision.
*/
-void fpinit()
+void fpinit(void)
{
unsigned short control;
@@ -523,7 +518,7 @@ ASSERT_IPL(SPL0);
* Coprocessor not present.
*/
void
-fpnoextflt()
+fpnoextflt(void)
{
/*
* Enable FPU use.
@@ -567,11 +562,11 @@ ASSERT_IPL(SPL0);
* Re-initialize FPU. Floating point state is not valid.
*/
void
-fpextovrflt()
+fpextovrflt(void)
{
- 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
@@ -616,9 +611,9 @@ fpextovrflt()
}
static int
-fphandleerr()
+fphandleerr(void)
{
- register thread_t thread = current_thread();
+ thread_t thread = current_thread();
/*
* Save the FPU context to the thread using it.
@@ -663,9 +658,9 @@ fphandleerr()
* FPU error. Called by exception handler.
*/
void
-fpexterrflt()
+fpexterrflt(void)
{
- register thread_t thread = current_thread();
+ thread_t thread = current_thread();
if (fphandleerr())
return;
@@ -688,9 +683,9 @@ fpexterrflt()
* FPU error. Called by AST.
*/
void
-fpastintr()
+fpastintr(void)
{
- register thread_t thread = current_thread();
+ thread_t thread = current_thread();
ASSERT_IPL(SPL0);
#if NCPUS == 1
@@ -751,11 +746,10 @@ ASSERT_IPL(SPL0);
* . otherwise, thread is running.
*/
void
-fp_save(thread)
- register thread_t thread;
+fp_save(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 */
@@ -773,11 +767,10 @@ fp_save(thread)
* Locking not needed; always called on the current thread.
*/
void
-fp_load(thread)
- register thread_t thread;
+fp_load(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;
@@ -828,7 +821,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/fpu.h b/i386/i386/fpu.h
index 2156187..7bc6438 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 */ \
diff --git a/i386/i386/gdt.c b/i386/i386/gdt.c
index 5523fea..c895eb3 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/hardclock.c b/i386/i386/hardclock.c
index 6615033..49ea82c 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 */
{
@@ -77,5 +77,5 @@ hardclock(iunit, old_ipl, irq, ret_addr, regs)
#ifdef LINUX_DEV
linux_timer_intr();
-#endif
+#endif /* LINUX_DEV */
}
diff --git a/include/mach/gnumach.defs b/i386/i386/hardclock.h
similarity index 58%
copy from include/mach/gnumach.defs
copy to i386/i386/hardclock.h
index 7331334..38c51ea 100644
--- a/include/mach/gnumach.defs
+++ b/i386/i386/hardclock.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 Free Software Foundation
+ * 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
@@ -16,24 +16,14 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-subsystem
-#if KERNEL_SERVER
- KernelServer
-#endif /* KERNEL_SERVER */
-#if KERNEL_USER
- KernelUser
-#endif /* KERNEL_USER */
- gnumach 4200;
+#ifndef _I386_HARDCLOCK_H_
+#define _I386_HARDCLOCK_H_
-#include <mach/std_types.defs>
-#include <mach/mach_types.defs>
+void hardclock(
+ int iunit,
+ int old_ipl,
+ int irq,
+ char *ret_addr,
+ struct i386_interrupt_state *regs);
-type vm_cache_statistics_data_t = struct[11] of integer_t;
-
-/*
- * Return page cache statistics for the host on which the target task
- * resides.
- */
-routine vm_cache_statistics(
- target_task : vm_task_t;
- out vm_cache_stats : vm_cache_statistics_data_t);
+#endif /* _I386_HARDCLOCK_H_ */
diff --git a/i386/i386/idt.c b/i386/i386/idt.c
index 882764f..d304ec3 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/io_map.c b/i386/i386/io_map.c
index b095f22..2c2aa72 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;
@@ -58,3 +58,35 @@ io_map(phys_addr, size)
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.
+ *
+ * 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)
+{
+ 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);
+}
diff --git a/i386/i386/io_perm.c b/i386/i386/io_perm.c
index 8bacb8d..6a6e660 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;
@@ -174,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)
@@ -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/io_perm.h b/i386/i386/io_perm.h
index a68e103..a7f1f6f 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_ */
diff --git a/i386/i386/ipl.h b/i386/i386/ipl.h
index 8f729e1..2da2e89 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_ */
diff --git a/i386/i386/ktss.c b/i386/i386/ktss.c
index 1b2938a..21d0030 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/kttd_interface.c b/i386/i386/kttd_interface.c
index b9e0624..c6caa76 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
*/
diff --git a/i386/i386/ldt.c b/i386/i386/ldt.c
index 43b9efb..0250ee2 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 */
@@ -46,7 +45,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/lock.h b/i386/i386/lock.h
index 38a66c8..b989927 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") \
diff --git a/i386/i386/locore.h b/i386/i386/locore.h
index bfd1317..6948f72 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
diff --git a/i386/i386/loose_ends.c b/i386/i386/loose_ends.c
index d3108fd..64b53b7 100644
--- a/i386/i386/loose_ends.c
+++ b/i386/i386/loose_ends.c
@@ -30,20 +30,18 @@
#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
* no way pass this request through the boot.
*/
-int boothowto = 0;
/* Someone with time should write code to set cpuspeed automagically */
int cpuspeed = 4;
#define DELAY(n) { volatile int N = cpuspeed * (n); while (--N >
0); }
void
-delay(n)
- int n;
+delay(int n)
{
DELAY(n);
}
@@ -55,8 +53,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_routines.h b/i386/i386/machine_routines.h
index a1fb489..d9dd94b 100644
--- a/i386/i386/machine_routines.h
+++ b/i386/i386/machine_routines.h
@@ -31,7 +31,8 @@
* The i386 has a set of machine-dependent interfaces.
*/
#define MACHINE_SERVER mach_i386_server
+#define MACHINE_SERVER_HEADER "i386/i386/mach_i386.server.h"
#define MACHINE_SERVER_ROUTINE mach_i386_server_routine
-#endif
+#endif /* _I386_MACHINE_ROUTINES_H_ */
diff --git a/i386/i386/machine_task.c b/i386/i386/machine_task.c
index 62b22e3..490b102 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/model_dep.h b/i386/i386/model_dep.h
index a41c474..ab2738f 100644
--- a/i386/i386/model_dep.h
+++ b/i386/i386/model_dep.h
@@ -36,6 +36,10 @@ extern void machine_init (void);
/* Conserve power on processor CPU. */
extern void machine_idle (int cpu);
+extern void resettodr (void);
+
+extern void startrtclock (void);
+
/*
* Halt a cpu.
*/
@@ -46,10 +50,6 @@ extern void halt_cpu (void) __attribute__ ((noreturn));
*/
extern void halt_all_cpus (boolean_t reboot) __attribute__ ((noreturn));
-extern void resettodr (void);
-
-extern void startrtclock (void);
-
/*
* More-specific code provides these;
* they indicate the total extent of physical memory
diff --git a/i386/i386/mp_desc.c b/i386/i386/mp_desc.c
index 95f55af..6aa8e66 100644
--- a/i386/i386/mp_desc.c
+++ b/i386/i386/mp_desc.c
@@ -65,12 +65,6 @@ 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
* are separate to avoid lock contention: the i386 uses locked
@@ -106,10 +100,9 @@ extern struct real_descriptor ldt[LDTSZ];
*/
struct mp_desc_table *
-mp_desc_init(mycpu)
- register int mycpu;
+mp_desc_init(int mycpu)
{
- register struct mp_desc_table *mpt;
+ struct mp_desc_table *mpt;
if (mycpu == master_cpu) {
/*
@@ -177,9 +170,9 @@ mp_desc_init(mycpu)
* is running. The machine array must show which CPUs exist.
*/
void
-interrupt_stack_alloc()
+interrupt_stack_alloc(void)
{
- register int i;
+ int i;
int cpu_count;
vm_offset_t stack_start;
@@ -244,7 +237,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/mp_desc.h b/i386/i386/mp_desc.h
index 03d7194..9f96312 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/i386/i386/pcb.c b/i386/i386/pcb.c
index 97ec00e..5866cac 100644
--- a/i386/i386/pcb.c
+++ b/i386/i386/pcb.c
@@ -60,12 +60,6 @@
#include <i386/mp_desc.h>
#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 */
@@ -76,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)
- register thread_t thread;
- register 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);
@@ -111,10 +105,9 @@ void stack_attach(thread, stack, continuation)
* Detaches a kernel stack from a thread, returning the old stack.
*/
-vm_offset_t stack_detach(thread)
- register thread_t thread;
+vm_offset_t stack_detach(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);
@@ -136,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)
- register pcb_t pcb;
+void switch_ktss(pcb_t pcb)
{
int mycpu = cpu_number();
{
@@ -166,7 +158,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.
*/
@@ -249,12 +241,12 @@ 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)
- register thread_t old;
- register thread_t new;
+void stack_handoff(
+ 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.
@@ -313,8 +305,7 @@ void stack_handoff(old, new)
/*
* Switch to the first thread on a CPU.
*/
-void load_context(new)
- register thread_t new;
+void load_context(thread_t new)
{
switch_ktss(new->pcb);
Load_context(new);
@@ -325,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)
- register thread_t old;
- void (*continuation)();
- register thread_t new;
+thread_t switch_context(
+ thread_t old,
+ void (*continuation)(),
+ thread_t new)
{
/*
* Save FP registers if in use.
@@ -371,7 +362,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);
@@ -379,10 +370,9 @@ void pcb_module_init()
fpu_module_init();
}
-void pcb_init(thread)
- register thread_t thread;
+void pcb_init(thread_t thread)
{
- register pcb_t pcb;
+ pcb_t pcb;
pcb = (pcb_t) kmem_cache_alloc(&pcb_cache);
if (pcb == 0)
@@ -412,10 +402,9 @@ void pcb_init(thread)
thread->pcb = pcb;
}
-void pcb_terminate(thread)
- register thread_t thread;
+void pcb_terminate(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);
@@ -435,7 +424,7 @@ void pcb_terminate(thread)
*/
void pcb_collect(thread)
- thread_t thread;
+ const thread_t thread;
{
}
@@ -446,18 +435,18 @@ 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:
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 +588,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 +615,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)
@@ -652,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)
- register 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:
@@ -672,8 +661,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 +732,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);
@@ -754,8 +743,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);
@@ -765,7 +754,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;
@@ -780,7 +769,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;
@@ -804,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,
@@ -820,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);
}
@@ -833,11 +820,11 @@ 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;
- 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;
diff --git a/i386/i386/pcb.h b/i386/i386/pcb.h
index 21bdfd9..708f30d 100644
--- a/i386/i386/pcb.h
+++ b/i386/i386/pcb.h
@@ -28,6 +28,8 @@
#include <sys/types.h>
#include <mach/exec/exec.h>
+#include <mach/thread_status.h>
+#include <machine/thread.h>
extern void pcb_init (thread_t thread);
@@ -56,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);
@@ -70,4 +72,14 @@ 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);
+
+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);
+
+extern void pcb_module_init (void);
+
#endif /* _I386_PCB_H_ */
diff --git a/i386/i386/phys.c b/i386/i386/phys.c
index ed4a309..3af508f 100644
--- a/i386/i386/phys.c
+++ b/i386/i386/phys.c
@@ -37,30 +37,71 @@
#include <vm/vm_page.h>
#include <i386/pmap.h>
+#include <i386/model_dep.h>
#include <mach/machine/vm_param.h>
+#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.
*/
void
-pmap_zero_page(p)
- vm_offset_t p;
+pmap_zero_page(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);
}
/*
* 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;
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);
}
/*
@@ -69,12 +110,28 @@ 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;
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);
}
/*
@@ -84,12 +141,28 @@ 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;
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);
}
/*
@@ -98,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/pic.c b/i386/i386/pic.c
index 50ca150..e8c881a 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 ;
@@ -105,7 +102,7 @@ u_short PICM_ICW4, PICS_ICW4 ;
*/
void
-picinit()
+picinit(void)
{
asm("cli");
@@ -223,7 +220,7 @@ picinit()
#define SLAVEACTV 0xFF00
void
-form_pic_mask()
+form_pic_mask(void)
{
unsigned int i, j, bit, mask;
@@ -240,7 +237,7 @@ form_pic_mask()
}
void
-intnull(unit_dev)
+intnull(int unit_dev)
{
printf("intnull(%d)\n", unit_dev);
}
@@ -248,7 +245,7 @@ intnull(unit_dev)
int prtnull_count = 0;
void
-prtnull(unit)
+prtnull(int unit)
{
++prtnull_count;
}
diff --git a/i386/i386/pic.h b/i386/i386/pic.h
index 52f6ec1..80bf65d 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_ */
diff --git a/i386/i386/pit.c b/i386/i386/pit.c
index 4f156d8..da68330 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 ;
@@ -67,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/setjmp.h b/i386/i386/setjmp.h
index 667eecf..930a9dd 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 __volatile__ void _longjmp(jmp_buf_t*, int);
-#endif
+extern void _longjmp(jmp_buf_t*, int) __attribute__ ((noreturn));
#endif /* _I386_SETJMP_H_ */
diff --git a/i386/i386/thread.h b/i386/i386/thread.h
index 450ec55..35a2802 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;
/*
diff --git a/i386/i386/trap.c b/i386/i386/trap.c
index c6aab48..9d4d43d 100644
--- a/i386/i386/trap.c
+++ b/i386/i386/trap.c
@@ -37,6 +37,7 @@
#include <i386/model_dep.h>
#include <intel/read_fault.h>
#include <machine/machspl.h> /* for spl_t */
+#include <machine/db_interface.h>
#include <mach/exception.h>
#include <mach/kern_return.h>
@@ -54,6 +55,7 @@
#include <kern/task.h>
#include <kern/sched.h>
#include <kern/sched_prim.h>
+#include <kern/exception.h>
#if MACH_KDB
#include <ddb/db_run.h>
@@ -62,21 +64,16 @@
#include "debug.h"
-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;
extern boolean_t db_watchpoints_inserted;
void
-thread_kdb_return()
+thread_kdb_return(void)
{
- 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();
@@ -91,11 +88,10 @@ 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)
{
- 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
@@ -150,23 +146,19 @@ 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
* fatal.
*/
-void kernel_trap(regs)
- register struct i386_saved_state *regs;
+void kernel_trap(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 +267,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 +284,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;
@@ -351,14 +343,13 @@ dump_ss(regs);
* Trap from user mode.
* Return TRUE if from emulated system call.
*/
-int user_trap(regs)
- register struct i386_saved_state *regs;
+int user_trap(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);
@@ -403,7 +394,12 @@ 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 */
+ /* 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;
@@ -425,7 +421,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;
@@ -524,7 +520,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();
@@ -561,26 +557,15 @@ 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
* AT-bus machines.
*/
void
-i386_astintr()
+i386_astintr(void)
{
int mycpu = cpu_number();
@@ -619,10 +604,10 @@ i386_astintr()
* emulator.
*/
void
-i386_exception(exc, code, subcode)
- int exc;
- int code;
- int subcode;
+i386_exception(
+ int exc,
+ int code,
+ int subcode)
{
spl_t s;
@@ -643,11 +628,11 @@ i386_exception(exc, code, subcode)
*/
unsigned
interrupted_pc(t)
- thread_t t;
+ const thread_t t;
{
- register struct i386_saved_state *iss;
+ struct i386_saved_state *iss;
iss = USER_REGS(t);
return iss->eip;
}
-#endif /* MACH_PCSAMPLE > 0*/
+#endif /* MACH_PCSAMPLE > 0 */
diff --git a/i386/i386/trap.h b/i386/i386/trap.h
index b4e9224..46612db 100644
--- a/i386/i386/trap.h
+++ b/i386/i386/trap.h
@@ -36,6 +36,15 @@ char *trap_name(unsigned int trapnum);
unsigned int interrupted_pc(thread_t);
+void
+i386_exception(
+ int exc,
+ int code,
+ int subcode) __attribute__ ((noreturn));
+
+extern void
+thread_kdb_return(void);
+
#endif /* !__ASSEMBLER__ */
#endif /* _I386_TRAP_H_ */
diff --git a/i386/i386/user_ldt.c b/i386/i386/user_ldt.c
index 74c10a4..d8bdb90 100644
--- a/i386/i386/user_ldt.c
+++ b/i386/i386/user_ldt.c
@@ -43,67 +43,17 @@
#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 */
-};
-
-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'.
*/
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;
@@ -305,14 +255,14 @@ 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 */
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;
@@ -326,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;
@@ -416,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;
@@ -481,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/i386/user_ldt.h b/i386/i386/user_ldt.h
index 6c6c858..26caa27 100644
--- a/i386/i386/user_ldt.h
+++ b/i386/i386/user_ldt.h
@@ -44,15 +44,7 @@ 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);
+extern void
+user_ldt_free(user_ldt_t user_ldt);
#endif /* _I386_USER_LDT_H_ */
diff --git a/i386/i386/vm_tuning.h b/i386/i386/vm_tuning.h
deleted file mode 100644
index f54e110..0000000
--- 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 address@hidden
- * 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/i386/i386/xen.h b/i386/i386/xen.h
index 5bdaf0b..638d671 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)
diff --git a/i386/i386at/acpi.c b/i386/i386at/acpi.c
new file mode 100644
index 0000000..ec8aeb1
--- /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 <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/glue.h>
+#include <grub/acpi.h>
+#include <grub/misc.h>
+
+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 0000000..23df44f
--- /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 <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/glue.h>
+
+#ifdef GRUB_DSDT_TEST
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+#include <errno.h>
+
+#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 <grub/acpi.h>
+#ifndef GRUB_DSDT_TEST
+#include <grub/i18n.h>
+#else
+#define _(x) x
+#define N_(x) x
+#endif
+
+#ifndef GRUB_DSDT_TEST
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/time.h>
+#include <grub/cpu/io.h>
+#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/ddb/db_input.h b/i386/i386at/acpihalt.h
similarity index 51%
copy from ddb/db_input.h
copy to i386/i386at/acpihalt.h
index 316e326..a4fdb07 100644
--- a/ddb/db_input.h
+++ b/i386/i386at/acpihalt.h
@@ -1,10 +1,10 @@
/*
- * Copyright (C) 2007 Free Software Foundation, Inc.
+ * 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, or (at your option)
- * any later version.
+ * 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
@@ -12,17 +12,12 @@
* 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, 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * Author: Barry deFreese.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef _DDB_DB_INPUT_H_
-#define _DDB_DB_INPUT_H_
-
-#include <sys/types.h>
+#ifndef _ACPIHALT_H_
+#define _ACPIHALT_H_
-extern int db_readline (char *lstart, int lsize);
+void grub_acpi_halt (void);
-#endif /* _DDB_DB_INPUT_H_ */
+#endif /* _ACPIHALT_H_ */
diff --git a/i386/i386at/autoconf.c b/i386/i386at/autoconf.c
index 93c7141..908c3ec 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 <i386at/com.h>
#endif /* NCOM */
#if NLPR > 0
extern struct bus_driver lprdriver;
-extern void lprintr();
+#include <i386at/lpr.h>
#endif /* NLPR */
struct bus_ctlr bus_master_init[] = {
@@ -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++)
{
@@ -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/com.c b/i386/i386at/com.c
index 93c3faa..c36cb6a 100644
--- a/i386/i386at/com.c
+++ b/i386/i386at/com.c
@@ -49,11 +49,7 @@
#include <device/cons.h>
-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];
@@ -173,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);
}
/*
@@ -265,7 +261,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);
@@ -323,7 +319,7 @@ boolean_t com_reprobe(
}
io_return_t comopen(
- int dev,
+ dev_t dev,
int flag,
io_req_t ior)
{
@@ -342,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];
@@ -402,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)];
@@ -418,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);
@@ -466,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);
@@ -496,10 +494,9 @@ natural_t count;
}
void
-comintr(unit)
-int unit;
+comintr(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;
@@ -521,10 +518,35 @@ 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'-('A'-1))
+ /* 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;
@@ -547,8 +569,7 @@ int unit;
}
static void
-comparam(unit)
-register int unit;
+comparam(int unit)
{
struct tty *tp = &com_tty[unit];
u_short addr = (int)tp->t_addr;
@@ -617,10 +638,9 @@ 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)
{
- char nch;
+ int nch;
#if 0
int i;
#endif
@@ -656,6 +676,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;
@@ -698,8 +720,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;
@@ -751,14 +774,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);
@@ -817,9 +840,9 @@ commctl(
}
void
-comstop(tp, flags)
-register 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;
@@ -830,16 +853,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)),
@@ -849,7 +872,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/com.h b/i386/i386at/com.h
index 49f23ee..779cdba 100644
--- a/i386/i386at/com.h
+++ b/i386/i386at/com.h
@@ -28,6 +28,8 @@
#include <mach/std_types.h>
#include <device/cons.h>
+#include <device/tty.h>
+#include <chips/busses.h>
/*
* Set receive modem state from modem status register.
@@ -47,5 +49,36 @@ 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(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);
+void comattach(struct bus_device *dev);
+
+extern io_return_t
+comgetstat(
+ dev_t dev,
+ int flavor,
+ int *data,
+ natural_t *count);
+
+extern io_return_t
+comsetstat(
+ dev_t dev,
+ int flavor,
+ 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);
+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 83c8dbf..ab4f680 100644
--- a/i386/i386at/conf.c
+++ b/i386/i386at/conf.c
@@ -29,48 +29,42 @@
#include <mach/machine/vm_types.h>
#include <device/conf.h>
+#include <kern/mach_clock.h>
+#include <i386at/model_dep.h>
-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 <i386at/kd.h>
#define kdname "kd"
#if NCOM > 0
-extern int comopen(), comclose(), comread(), comwrite();
-extern int comgetstat(), comsetstat(), comportdeath();
+#include <i386at/com.h>
#define comname "com"
#endif /* NCOM > 0 */
#if NLPR > 0
-extern int lpropen(), lprclose(), lprread(), lprwrite();
-extern int lprgetstat(), lprsetstat(), lprportdeath();
+#include <i386at/lpr.h>
#define lprname "lpr"
#endif /* NLPR > 0 */
#endif /* MACH_HYP */
-extern int kbdopen(), kbdclose(), kbdread();
-extern int kbdgetstat(), kbdsetstat();
+#include <i386at/kd_event.h>
#define kbdname "kbd"
#ifndef MACH_HYP
-extern int mouseopen(), mouseclose(), mouseread(), mousegetstat();
+#include <i386at/kd_mouse.h>
#define mousename "mouse"
-extern vm_offset_t memmmap();
+#include <i386at/mem.h>
#define memname "mem"
#endif /* MACH_HYP */
-extern int kmsgopen(), kmsgclose(), kmsgread(), kmsggetstat();
+#include <device/kmsg.h>
#define kmsgname "kmsg"
#ifdef MACH_HYP
-extern int hypcnopen(), hypcnclose(), hypcnread(), hypcnwrite();
-extern int hypcngetstat(), hypcnsetstat(), hypcnportdeath();
+#include <xen/console.h>
#define hypcnname "hyp"
#endif /* MACH_HYP */
@@ -87,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
@@ -99,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
@@ -120,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/cram.h b/i386/i386at/cram.h
index 8373ce0..40f3f0a 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 e1fe6b9..63d033f 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 <mach/machine/disk.h>
@@ -184,3 +187,4 @@ struct mboot { /* master
boot block */
u_short signature;
};
+#endif /* _DISK_H_ */
diff --git a/i386/i386at/grub_glue.c b/i386/i386at/grub_glue.c
new file mode 100644
index 0000000..68a4cb1
--- /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 <http://www.gnu.org/licenses/>.
+ */
+
+#include <kern/printf.h>
+#include <stdarg.h>
+#include <i386/vm_param.h>
+
+#include <grub/glue.h>
+#include <grub/acpi.h>
+
+#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/i8250.h b/i386/i386at/i8250.h
index fa81173..9b8a801 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/i386at/idt.h b/i386/i386at/idt.h
index 1b3284f..56e6296 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_ */
diff --git a/i386/i386at/immc.c b/i386/i386at/immc.c
index db64620..e0837f2 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)
@@ -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/int_init.c b/i386/i386at/int_init.c
index 0f00b86..43daad8 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/int_init.h b/i386/i386at/int_init.h
index f4abef0..f9b03b7 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_ */
diff --git a/i386/i386at/kd.c b/i386/i386at/kd.c
index c977862..7339767 100644
--- a/i386/i386at/kd.c
+++ b/i386/i386at/kd.c
@@ -83,7 +83,7 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <device/conf.h>
#include <device/tty.h>
#include <device/io_req.h>
-#include <device/buf.h> /* for struct uio (!) */
+#include <device/buf.h>
#include <vm/vm_kern.h>
#include <i386/locore.h>
#include <i386/loose_ends.h>
@@ -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 boolean_t rebootflag;
static void charput(), charmvup(), charmvdown(), charclear(), charsetcursor();
-static void kd_noopreset();
-boolean_t kdcheckmagic();
-
-int do_modifier (int, Scancode, boolean_t);
+static void kd_noopreset(void);
/*
* These routines define the interface to the device-specific layer.
@@ -127,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.
@@ -249,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},
@@ -263,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},
@@ -276,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},
@@ -294,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},
@@ -367,7 +349,7 @@ int kd_pollc = 0;
* Warning: uses outb(). You may prefer to use kd_debug_put.
*/
void
-feep()
+feep(void)
{
int i;
@@ -378,7 +360,7 @@ feep()
}
void
-pause()
+pause(void)
{
int i;
@@ -392,9 +374,9 @@ pause()
* 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;
@@ -403,12 +385,11 @@ 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)
-boolean_t on;
+cnpollc(boolean_t on)
{
if (mouse_in_use) {
if (on) {
@@ -449,15 +430,13 @@ 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;
- void kdstart();
spl_t o_pri;
- void kdstop();
tp = &kd_tty;
o_pri = spltty();
@@ -498,7 +477,7 @@ kdopen(dev, flag, ior)
/*ARGSUSED*/
void
kdclose(dev, flag)
-int dev;
+dev_t dev;
int flag;
{
struct tty *tp;
@@ -530,8 +509,8 @@ int flag;
/*ARGSUSED*/
int
kdread(dev, uio)
-int dev;
-struct uio *uio;
+dev_t dev;
+io_req_t uio;
{
struct tty *tp;
@@ -555,8 +534,8 @@ struct uio *uio;
/*ARGSUSED*/
int
kdwrite(dev, uio)
-int dev;
-struct uio *uio;
+dev_t dev;
+io_req_t uio;
{
return((*linesw[kd_tty.t_line].l_write)(&kd_tty, uio));
}
@@ -569,10 +548,10 @@ struct uio *uio;
int
kdmmap(dev, off, prot)
dev_t dev;
- off_t off;
- int prot;
+ vm_offset_t off;
+ vm_prot_t prot;
{
- if ((u_int) off >= (128*1024))
+ if (off >= (128*1024))
return(-1);
/* Get page frame number for the page to be mapped. */
@@ -580,19 +559,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;
@@ -618,11 +597,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;
@@ -655,13 +634,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)
@@ -672,15 +650,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 */
@@ -700,9 +676,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;
@@ -732,15 +708,14 @@ int flags; /* flags set
for console */
*/
/*ARGSUSED*/
void
-kdintr(vec)
-int vec;
+kdintr(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 */
- extern int mouse_in_use;
+
if (kd_pollc)
return; /* kdb polling kbd */
@@ -749,7 +724,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 */
{
/*
@@ -818,7 +794,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++;
@@ -873,7 +849,7 @@ int vec;
* drop the ack on the floor.
*/
void
-kd_handle_ack()
+kd_handle_ack(void)
{
switch (kd_ack) {
case SET_LEDS:
@@ -898,7 +874,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");
@@ -919,10 +895,10 @@ kd_resend()
* 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):
@@ -984,12 +960,10 @@ 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;
- extern int rebootflag;
if (scancode == 0x46) /* scroll lock */
/* if (scancode == 0x52) ** insert key */
@@ -1040,9 +1014,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;
@@ -1081,8 +1055,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;
@@ -1132,9 +1105,9 @@ struct tty *tp;
/*ARGSUSED*/
void
-kdstop(tp, flags)
- register struct tty *tp;
- int flags;
+kdstop(
+ struct tty *tp,
+ int flags)
{
/*
* do nothing - all characters are output by one call to
@@ -1159,9 +1132,8 @@ kdstop(tp, flags)
*
*/
void
-kdinit()
+kdinit(void)
{
- void kd_xga_init();
unsigned char k_comm; /* keyboard command byte */
if (kd_initialized)
@@ -1194,15 +1166,15 @@ 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
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
@@ -1224,7 +1196,7 @@ kdinit()
* output : bell is turned off
*
*/
-static unsigned int kd_bellstate = 0;
+static boolean_t kd_bellstate = FALSE;
void
kd_belloff(void * param)
@@ -1233,7 +1205,7 @@ kd_belloff(void * param)
status = (inb(K_PORTB) & ~(K_SPKRDATA | K_ENABLETMR2));
outb(K_PORTB, status);
- kd_bellstate = 0;
+ kd_bellstate = FALSE;
return;
}
@@ -1248,7 +1220,7 @@ kd_belloff(void * param)
*
*/
void
-kd_bellon()
+kd_bellon(void)
{
unsigned char status;
@@ -1278,8 +1250,7 @@ kd_bellon()
int sit_for_0 = 1;
void
-kd_putc(ch)
-u_char ch;
+kd_putc(u_char ch)
{
if ((!ch) && sit_for_0)
return;
@@ -1306,7 +1277,7 @@ u_char ch;
{
kd_bellon();
timeout(kd_belloff, 0, hz/8 );
- kd_bellstate = 1;
+ kd_bellstate = TRUE;
}
break;
default:
@@ -1332,8 +1303,7 @@ u_char ch;
*
*/
void
-kd_setpos(newpos)
-csrpos_t newpos;
+kd_setpos(csrpos_t newpos)
{
if (newpos > ONE_PAGE) {
kd_scrollup();
@@ -1359,7 +1329,7 @@ csrpos_t newpos;
*
*/
void
-kd_scrollup()
+kd_scrollup(void)
{
csrpos_t to;
csrpos_t from;
@@ -1389,7 +1359,7 @@ kd_scrollup()
*
*/
void
-kd_scrolldn()
+kd_scrolldn(void)
{
csrpos_t to;
csrpos_t from;
@@ -1423,7 +1393,7 @@ kd_scrolldn()
*
*/
void
-kd_parseesc()
+kd_parseesc(void)
{
u_char *escp;
@@ -1495,8 +1465,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;
@@ -1760,7 +1729,7 @@ u_char *cp;
}
void
-kd_tab()
+kd_tab(void)
{
int i;
@@ -1781,7 +1750,7 @@ kd_tab()
*
*/
void
-kd_cls()
+kd_cls(void)
{
(*kd_dclear)(0, ONE_PAGE/ONE_SPACE, kd_attr);
return;
@@ -1799,7 +1768,7 @@ kd_cls()
*
*/
void
-kd_home()
+kd_home(void)
{
kd_setpos(0);
return;
@@ -1816,7 +1785,7 @@ kd_home()
*
*/
void
-kd_up()
+kd_up(void)
{
if (kd_curpos < ONE_LINE)
kd_scrolldn();
@@ -1836,7 +1805,7 @@ kd_up()
*
*/
void
-kd_down()
+kd_down(void)
{
if (kd_curpos >= (ONE_PAGE - ONE_LINE))
kd_scrollup();
@@ -1856,7 +1825,7 @@ kd_down()
*
*/
void
-kd_right()
+kd_right(void)
{
if (kd_curpos < (ONE_PAGE - ONE_SPACE))
kd_setpos(kd_curpos + ONE_SPACE);
@@ -1878,7 +1847,7 @@ kd_right()
*
*/
void
-kd_left()
+kd_left(void)
{
if (0 < kd_curpos)
kd_setpos(kd_curpos - ONE_SPACE);
@@ -1897,7 +1866,7 @@ kd_left()
*
*/
void
-kd_cr()
+kd_cr(void)
{
kd_setpos(BEG_OF_LINE(kd_curpos));
return;
@@ -1915,7 +1884,7 @@ kd_cr()
*
*/
void
-kd_cltobcur()
+kd_cltobcur(void)
{
csrpos_t start;
int count;
@@ -1938,7 +1907,7 @@ kd_cltobcur()
*
*/
void
-kd_cltopcur()
+kd_cltopcur(void)
{
int count;
@@ -1958,7 +1927,7 @@ kd_cltopcur()
*
*/
void
-kd_cltoecur()
+kd_cltoecur(void)
{
csrpos_t i;
csrpos_t hold;
@@ -1981,7 +1950,7 @@ kd_cltoecur()
*
*/
void
-kd_clfrbcur()
+kd_clfrbcur(void)
{
csrpos_t i;
@@ -2002,8 +1971,7 @@ kd_clfrbcur()
*
*/
void
-kd_delln(number)
-int number;
+kd_delln(int number)
{
csrpos_t to;
csrpos_t from;
@@ -2041,8 +2009,7 @@ int number;
*
*/
void
-kd_insln(number)
-int number;
+kd_insln(int number)
{
csrpos_t to;
csrpos_t from;
@@ -2081,12 +2048,11 @@ int number;
*
*/
void
-kd_delch(number)
-int number;
+kd_delch(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 */
@@ -2123,8 +2089,7 @@ int number;
*
*/
void
-kd_erase(number)
-int number;
+kd_erase(int number)
{
csrpos_t i;
csrpos_t stop;
@@ -2149,7 +2114,7 @@ int number;
*
*/
void
-kd_eraseln()
+kd_eraseln(void)
{
csrpos_t i;
csrpos_t stop;
@@ -2173,8 +2138,7 @@ kd_eraseln()
*
*/
void
-kd_insch(number)
-int number;
+kd_insch(int number)
{
csrpos_t to;
csrpos_t from;
@@ -2215,8 +2179,7 @@ int number;
*
*/
boolean_t
-kd_isupper(c)
-u_char c;
+kd_isupper(u_char c)
{
if (('A' <= c) && (c <= 'Z'))
return(TRUE);
@@ -2224,8 +2187,7 @@ u_char c;
}
boolean_t
-kd_islower(c)
-u_char c;
+kd_islower(u_char c)
{
if (('a' <= c) && (c <= 'z'))
return(TRUE);
@@ -2242,10 +2204,10 @@ u_char c;
*
*/
void
-kd_senddata(ch)
-unsigned char ch;
+kd_senddata(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;
@@ -2260,10 +2222,10 @@ unsigned char ch;
*
*/
void
-kd_sendcmd(ch)
-unsigned char ch;
+kd_sendcmd(unsigned char ch)
{
- while (inb(K_STATUS) & K_IBUF_FUL);
+ while (inb(K_STATUS) & K_IBUF_FUL)
+ ;
outb(K_CMD, ch);
return;
}
@@ -2277,41 +2239,47 @@ unsigned char ch;
* read.
*/
unsigned char
-kd_getdata()
+kd_getdata(void)
{
- while ((inb(K_STATUS) & K_OBUF_FUL) == 0);
+ 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;
- 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));
}
void
-kd_cmdreg_write(val)
+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);
}
void
-kd_mouse_drain()
+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));
}
@@ -2322,8 +2290,7 @@ kd_mouse_drain()
* 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));
@@ -2336,8 +2303,7 @@ int newstate;
* a state vector.
*/
u_char
-state2leds(state)
-int state;
+state2leds(int state)
{
u_char result = 0;
@@ -2354,8 +2320,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
@@ -2370,7 +2335,7 @@ u_char val;
}
void
-kd_setleds2()
+kd_setleds2(void)
{
kd_senddata(kd_nextled);
}
@@ -2384,8 +2349,7 @@ kd_setleds2()
* lock anyway.
*/
void
-cnsetleds(val)
-u_char val;
+cnsetleds(u_char val)
{
kd_senddata(K_CMD_LEDS);
(void)kd_getdata(); /* XXX - assume is ACK */
@@ -2394,7 +2358,7 @@ u_char val;
}
void
-kdreboot()
+kdreboot(void)
{
(*kd_dreset)();
@@ -2413,7 +2377,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;
@@ -2507,14 +2471,18 @@ 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;
+ unsigned char start, stop;
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
@@ -2540,6 +2508,8 @@ kd_xga_init()
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,8 +2531,25 @@ kd_xga_init()
kd_lines = 25;
kd_cols = 80;
break;
- default:
- printf("kd: unknown screen type, defaulting to EGA\n");
+#endif
+ }
+
+ 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());
@@ -2580,7 +2567,7 @@ kd_xga_init()
*
*/
csrpos_t
-xga_getpos()
+xga_getpos(void)
{
unsigned char low;
@@ -2683,38 +2670,24 @@ char chattr;
* No-op reset routine for kd_dreset.
*/
static void
-kd_noopreset()
+kd_noopreset(void)
{
}
-
-/*
- * 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.
*/
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 */
- 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)
@@ -2736,13 +2709,14 @@ 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;
- 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);
@@ -2762,9 +2736,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;
@@ -2797,9 +2772,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;
@@ -2835,12 +2811,12 @@ 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 */
{
- register short i;
+ short i;
u_short clearval;
u_short clearbyte = (chattr == KA_REVERSE ? char_white : char_black);
@@ -2861,8 +2837,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);
@@ -2874,13 +2849,13 @@ 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;
- 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 */
@@ -2897,11 +2872,12 @@ 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 */
{
- register short xch, ych;
+ short xch, ych;
xch = (pos / ONE_SPACE) % kd_cols;
ych = pos / (ONE_SPACE * kd_cols);
@@ -2916,8 +2892,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);
}
@@ -3052,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)
diff --git a/i386/i386at/kd.h b/i386/i386at/kd.h
index 1d53538..4ac93c7 100644
--- a/i386/i386at/kd.h
+++ b/i386/i386at/kd.h
@@ -76,7 +76,10 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <sys/types.h>
#include <sys/time.h>
#include <device/cons.h>
-
+#include <device/io_req.h>
+#include <device/buf.h>
+#include <device/tty.h>
+#include <i386at/kdsoft.h>
/*
* Where memory for various graphics adapters starts.
@@ -110,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 */
@@ -359,10 +364,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 */
@@ -728,7 +733,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);
@@ -742,4 +747,53 @@ 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 */
+
+extern int kdopen(dev_t dev, int flag, io_req_t ior);
+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,
+ 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, vm_offset_t off, vm_prot_t 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);
+
+unsigned char kd_getdata(void);
+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_ */
diff --git a/i386/i386at/kd_event.c b/i386/i386at/kd_event.c
index 4d2ea00..b60118e 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;
@@ -96,7 +91,7 @@ static boolean_t initialized = FALSE;
*/
void
-kbdinit()
+kbdinit(void)
{
spl_t s = SPLKD();
@@ -115,9 +110,10 @@ kbdinit()
/*ARGSUSED*/
int
-kbdopen(dev, flags)
+kbdopen(dev, flags, ior)
dev_t dev;
int flags;
+ io_req_t ior;
{
spl_t o_pri = spltty();
kdinit();
@@ -135,9 +131,9 @@ kbdopen(dev, flags)
/*ARGSUSED*/
void
-kbdclose(dev, flags)
- dev_t dev;
- int flags;
+kbdclose(
+ dev_t dev,
+ int flags)
{
spl_t s = SPLKD();
@@ -147,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:
@@ -169,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:
@@ -187,9 +183,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);
}
@@ -201,16 +197,13 @@ 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;
- register io_req_t ior;
+kbdread(
+ 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 +226,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;
@@ -244,11 +237,10 @@ kbdread(dev, ior)
return (D_SUCCESS);
}
-boolean_t kbd_read_done(ior)
- register io_req_t ior;
+boolean_t kbd_read_done(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 +252,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;
@@ -281,8 +273,7 @@ boolean_t kbd_read_done(ior)
*/
void
-kd_enqsc(sc)
- Scancode sc;
+kd_enqsc(Scancode sc)
{
kd_event ev;
@@ -299,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");
@@ -308,7 +298,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);
}
@@ -319,9 +309,9 @@ int X_kdb_enter_len = 0, X_kdb_exit_len = 0;
void
kdb_in_out(p)
-u_int *p;
+const u_int *p;
{
-register int t = p[0];
+ int t = p[0];
switch (t & K_X_TYPE) {
case K_X_IN|K_X_BYTE:
@@ -351,9 +341,9 @@ register int t = p[0];
}
void
-X_kdb_enter()
+X_kdb_enter(void)
{
-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;
@@ -362,9 +352,9 @@ register u_int *u_ip, *endp;
}
void
-X_kdb_exit()
+X_kdb_exit(void)
{
-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;
@@ -373,9 +363,9 @@ register u_int *u_ip, *endp;
}
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;
@@ -386,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_event.h b/i386/i386at/kd_event.h
index 677af99..8b2d664 100644
--- a/i386/i386at/kd_event.h
+++ b/i386/i386at/kd_event.h
@@ -26,8 +26,37 @@
#ifndef _KD_EVENT_H_
#define _KD_EVENT_H_
+#include <sys/types.h>
+#include <device/io_req.h>
+#include <i386at/kd.h>
+
extern void X_kdb_enter (void);
extern void X_kdb_exit (void);
+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);
+
+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);
+
+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_ */
diff --git a/i386/i386at/kd_mouse.c b/i386/i386at/kd_mouse.c
index 6e7b68a..16241ef 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 */
@@ -114,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;
@@ -149,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);
@@ -164,6 +163,7 @@ mouseopen(dev, flags)
mousebufsize = 3;
serial_mouse_open(dev);
init_mouse_hw(dev&7, LC7);
+ break;
case MICROSOFT_MOUSE:
mousebufsize = 3;
serial_mouse_open(dev);
@@ -198,8 +198,7 @@ mouseopen(dev, flags)
}
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,12 +218,11 @@ 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 */
- extern void kdintr();
oldvect = ivect[mouse_pic];
ivect[mouse_pic] = kdintr;
@@ -239,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:
@@ -266,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;
@@ -285,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();
@@ -297,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,15 +317,13 @@ 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;
- register io_req_t ior;
+mouseread(
+ 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 +346,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;
@@ -361,11 +357,10 @@ mouseread(dev, ior)
return (D_SUCCESS);
}
-boolean_t mouse_read_done(ior)
- register io_req_t ior;
+boolean_t mouse_read_done(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 +372,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;
@@ -397,7 +392,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;
@@ -445,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);
@@ -527,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;
@@ -563,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;
@@ -656,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();
@@ -700,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();
@@ -732,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;
@@ -765,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;
@@ -776,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;
@@ -793,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");
@@ -809,7 +794,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);
}
diff --git a/i386/i386at/kd_mouse.h b/i386/i386at/kd_mouse.h
index baa51c8..a8a72a3 100644
--- a/i386/i386at/kd_mouse.h
+++ b/i386/i386at/kd_mouse.h
@@ -54,4 +54,17 @@ 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, io_req_t ior);
+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);
+
+void mouseintr(int unit);
+boolean_t mouse_read_done(io_req_t ior);
+
#endif /* _KD_MOUSE_H_ */
diff --git a/i386/i386at/kd_queue.c b/i386/i386at/kd_queue.c
index 2b83044..57d6fbf 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);
}
@@ -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/kd_queue.h b/i386/i386at/kd_queue.h
index c976acf..702efe8 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 <mach/std_types.h>
#include <i386at/kd.h>
@@ -76,6 +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_ */
diff --git a/i386/i386at/kdsoft.h b/i386/i386at/kdsoft.h
index 96e2df8..1dfd2b2 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/lpr.c b/i386/i386at/lpr.c
index c92795e..5c16b15 100644
--- a/i386/i386at/lpr.c
+++ b/i386/i386at/lpr.c
@@ -44,20 +44,12 @@
#include <i386/pio.h>
#include <chips/busses.h>
#include <i386at/autoconf.h>
-#include <i386at/lprreg.h>
+#include <i386at/lpr.h>
-
/*
* 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 };
@@ -71,7 +63,8 @@ int lpr_alive[NLPR];
int
lprprobe(port, dev)
-struct bus_device *dev;
+vm_offset_t port;
+struct bus_ctlr *dev;
{
u_short addr = (u_short) dev->address;
int unit = dev->unit;
@@ -113,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;
{
@@ -142,7 +135,7 @@ u_short addr;
void
lprclose(dev, flag)
-int dev;
+dev_t dev;
int flag;
{
int unit = minor(dev);
@@ -158,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);
@@ -166,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);
@@ -199,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);
@@ -218,10 +211,9 @@ natural_t count;
return (D_SUCCESS);
}
-void lprintr(unit)
-int unit;
+void lprintr(int unit)
{
- register struct tty *tp = &lpr_tty[unit];
+ struct tty *tp = &lpr_tty[unit];
if ((tp->t_state & TS_ISOPEN) == 0)
return;
@@ -233,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;
@@ -274,22 +265,22 @@ struct tty *tp;
}
void
-lprstop(tp, flags)
-register 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;
}
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/lprreg.h b/i386/i386at/lpr.h
similarity index 62%
rename from i386/i386at/lprreg.h
rename to i386/i386at/lpr.h
index c6fbed4..269fd64 100644
--- a/i386/i386at/lprreg.h
+++ b/i386/i386at/lpr.h
@@ -27,7 +27,40 @@
* 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(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);
+
+extern io_return_t
+lprgetstat(
+ dev_t dev,
+ int flavor,
+ int *data,
+ natural_t *count);
+
+extern io_return_t
+lprsetstat(
+ dev_t dev,
+ int flavor,
+ int *data,
+ natural_t count);
+
+void lprpr_addr(unsigned short addr);
+
+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 5e51676..f239afa 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/include/mach/gnumach.defs b/i386/i386at/mem.h
similarity index 58%
copy from include/mach/gnumach.defs
copy to i386/i386at/mem.h
index 7331334..0bc85ea 100644
--- a/include/mach/gnumach.defs
+++ b/i386/i386at/mem.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 Free Software Foundation
+ * 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
@@ -16,24 +16,9 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-subsystem
-#if KERNEL_SERVER
- KernelServer
-#endif /* KERNEL_SERVER */
-#if KERNEL_USER
- KernelUser
-#endif /* KERNEL_USER */
- gnumach 4200;
+#ifndef _MEM_H_
+#define _MEM_H_
-#include <mach/std_types.defs>
-#include <mach/mach_types.defs>
+extern int memmmap(dev_t dev, vm_offset_t off, vm_prot_t prot);
-type vm_cache_statistics_data_t = struct[11] of integer_t;
-
-/*
- * Return page cache statistics for the host on which the target task
- * resides.
- */
-routine vm_cache_statistics(
- target_task : vm_task_t;
- out vm_cache_stats : vm_cache_statistics_data_t);
+#endif /* _MEM_H_ */
diff --git a/i386/i386at/model_dep.c b/i386/i386at/model_dep.c
index d97f085..bc34c9b 100644
--- a/i386/i386at/model_dep.c
+++ b/i386/i386at/model_dep.c
@@ -48,6 +48,7 @@
#include <kern/debug.h>
#include <kern/mach_clock.h>
#include <kern/printf.h>
+#include <kern/startup.h>
#include <sys/time.h>
#include <sys/types.h>
#include <vm/vm_page.h>
@@ -67,6 +68,8 @@
#include <i386at/int_init.h>
#include <i386at/kd.h>
#include <i386at/rtc.h>
+#include <i386at/model_dep.h>
+#include <i386at/acpihalt.h>
#ifdef MACH_XEN
#include <xen/console.h>
#include <xen/store.h>
@@ -77,11 +80,22 @@
/* Location of the kernel's symbol table.
Both of these are 0 if none is available. */
#if MACH_KDB
+#include <ddb/db_sym.h>
+#include <i386/db_interface.h>
+
+/* a.out symbol table */
static vm_offset_t kern_sym_start, kern_sym_end;
-#else
+
+/* 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
-#endif
+#endif /* MACH_KDB */
/* These indicate the total extent of physical memory addresses we're using.
They are page-aligned. */
@@ -123,14 +137,7 @@ 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 */
+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;
@@ -139,8 +146,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.
*/
@@ -184,10 +189,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. */
@@ -201,7 +210,7 @@ void machine_idle (int cpu)
#endif /* MACH_HYP */
}
-void machine_relax ()
+void machine_relax (void)
{
asm volatile ("rep; nop" : : : "memory");
}
@@ -223,8 +232,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
@@ -233,10 +241,11 @@ void halt_all_cpus(reboot)
kdreboot();
}
else {
- rebootflag = 1;
+ rebootflag = TRUE;
#ifdef MACH_HYP
hyp_halt();
#endif /* MACH_HYP */
+ grub_acpi_halt();
printf("In tight loop: hit ctl-alt-del to reboot\n");
(void) spl0();
}
@@ -249,6 +258,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);
@@ -374,7 +388,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;
}
@@ -565,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 */
@@ -581,7 +606,14 @@ 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);
+ }
+
+ 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 */
@@ -620,15 +652,13 @@ void c_boot_entry(vm_offset_t bi)
#include <mach/time_value.h>
int
-timemmap(dev,off,prot)
+timemmap(dev, off, prot)
+ dev_t dev;
+ vm_offset_t off;
vm_prot_t 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)));
@@ -841,8 +871,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);
}
@@ -859,8 +888,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/include/mach/gnumach.defs b/i386/i386at/model_dep.h
similarity index 58%
copy from include/mach/gnumach.defs
copy to i386/i386at/model_dep.h
index 7331334..aa24032 100644
--- a/include/mach/gnumach.defs
+++ b/i386/i386at/model_dep.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 Free Software Foundation
+ * 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
@@ -16,24 +16,15 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-subsystem
-#if KERNEL_SERVER
- KernelServer
-#endif /* KERNEL_SERVER */
-#if KERNEL_USER
- KernelUser
-#endif /* KERNEL_USER */
- gnumach 4200;
+#ifndef _MODEL_DEP_H_
+#define _MODEL_DEP_H_
-#include <mach/std_types.defs>
-#include <mach/mach_types.defs>
+#include <mach/vm_prot.h>
-type vm_cache_statistics_data_t = struct[11] of integer_t;
+extern int timemmap(dev_t dev, vm_offset_t off, vm_prot_t prot);
-/*
- * Return page cache statistics for the host on which the target task
- * resides.
- */
-routine vm_cache_statistics(
- target_task : vm_task_t;
- out vm_cache_stats : vm_cache_statistics_data_t);
+void inittodr(void);
+
+boolean_t init_alloc_aligned(vm_size_t size, vm_offset_t *addrp);
+
+#endif /* _MODEL_DEP_H_ */
diff --git a/i386/i386at/pic_isa.c b/i386/i386at/pic_isa.c
index e48fb50..0b36534 100644
--- a/i386/i386at/pic_isa.c
+++ b/i386/i386at/pic_isa.c
@@ -28,10 +28,10 @@
#include <i386/ipl.h>
#include <i386/pic.h>
#include <i386/fpu.h>
+#include <i386/hardclock.h>
#include <i386at/kd.h>
/* These interrupts are always present */
-extern void hardclock();
void (*ivect[NINTR])() = {
/* 00 */ hardclock, /* always */
diff --git a/i386/i386at/rtc.c b/i386/i386at/rtc.c
index 6776801..946f08f 100644
--- a/i386/i386at/rtc.c
+++ b/i386/i386at/rtc.c
@@ -53,10 +53,10 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <i386/pio.h>
#include <i386at/rtc.h>
-static int first_rtcopen_ever = 1;
+static boolean_t first_rtcopen_ever = TRUE;
void
-rtcinit()
+rtcinit(void)
{
outb(RTC_ADDR, RTC_A);
outb(RTC_DATA, RTC_DIV2 | RTC_RATE6);
@@ -66,12 +66,11 @@ rtcinit()
int
-rtcget(regs)
-unsigned char *regs;
+rtcget(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);
@@ -83,14 +82,13 @@ unsigned char *regs;
}
void
-rtcput(regs)
-unsigned char *regs;
+rtcput(unsigned char *regs)
{
- register unsigned char x;
+ unsigned char x;
if (first_rtcopen_ever) {
rtcinit();
- first_rtcopen_ever = 0;
+ first_rtcopen_ever = FALSE;
}
outb(RTC_ADDR, RTC_B);
x = inb(RTC_DATA);
@@ -103,34 +101,29 @@ 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};
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;
@@ -172,7 +165,7 @@ readtodc(tp)
}
int
-writetodc()
+writetodc(void)
{
struct rtc_st rtclk;
time_t n;
diff --git a/i386/i386at/rtc.h b/i386/i386at/rtc.h
index ced39b9..97eabe9 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 */
@@ -114,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); \
@@ -127,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]);\
@@ -136,3 +139,5 @@ struct rtc_st {
extern int readtodc(u_int *tp);
extern int writetodc(void);
+
+#endif /* _RTC_H_ */
diff --git a/i386/include/mach/i386/asm.h b/i386/include/mach/i386/asm.h
index 3e3f48b..4e3b589 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/cthreads.h
b/i386/include/mach/i386/cthreads.h
index f9755b4..d2aa16f 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/i386/include/mach/i386/disk.h b/i386/include/mach/i386/disk.h
index 40ed4fa..1bbbbdf 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_ */
diff --git a/i386/include/mach/i386/mach_i386_types.h
b/i386/include/mach/i386/mach_i386_types.h
index b03c0b0..b055280 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 <i386/io_perm.h>
-#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_ */
diff --git a/i386/include/mach/i386/rpc.h b/i386/include/mach/i386/rpc.h
deleted file mode 100644
index 71d31fb..0000000
--- a/i386/include/mach/i386/rpc.h
+++ /dev/null
@@ -1,9 +0,0 @@
-
-struct rpc_csig_action
-{
-};
-
-struct rpc_csig_entry
-{
-};
-
diff --git a/i386/intel/pmap.c b/i386/intel/pmap.c
index 490c1d9..62b33cf 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
@@ -413,21 +413,20 @@ 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().
*/
pt_entry_t *kernel_page_dir;
-void pmap_remove_range(); /* forward */
-#if NCPUS > 1
-void signal_cpus(); /* forward */
-#endif /* NCPUS > 1 */
+/*
+ * 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(pmap_t pmap, vm_offset_t addr)
+pmap_pde(const pmap_t pmap, vm_offset_t addr)
{
if (pmap == kernel_pmap)
addr = kvtolin(addr);
@@ -442,7 +441,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;
@@ -459,10 +458,9 @@ pmap_pte(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)
{
- register pt_entry_t *pte, *epte;
+ pt_entry_t *pte, *epte;
int ctu, ctw;
/* check the use and wired counts */
@@ -496,13 +494,13 @@ 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)
- register vm_offset_t virt;
- register vm_offset_t start;
- register vm_offset_t end;
- register int prot;
+vm_offset_t pmap_map(
+ 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) {
@@ -519,15 +517,15 @@ 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)
- register vm_offset_t virt;
- register vm_offset_t start;
- register 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)
{
- 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];
@@ -580,7 +578,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.
@@ -781,6 +779,12 @@ void pmap_bootstrap()
}
for (; pte < ptable+NPTES; pte++)
{
+ 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;
+ win->vaddr = va;
+ }
WRITE_PTE(pte, 0);
va += INTEL_PGBYTES;
}
@@ -891,12 +895,41 @@ void pmap_clear_bootstrap_pagetable(pt_entry_t *base) {
}
#endif /* MACH_PV_PAGETABLES */
-void pmap_virtual_space(startp, endp)
- vm_offset_t *startp;
- vm_offset_t *endp;
+/*
+ * 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(
+ vm_offset_t *startp,
+ vm_offset_t *endp)
{
*startp = kernel_virtual_start;
- *endp = kernel_virtual_end;
+ *endp = kernel_virtual_end - PMAP_NMAPWINDOWS * PAGE_SIZE;
}
/*
@@ -904,11 +937,11 @@ 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)
{
- 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 */
@@ -926,7 +959,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.
@@ -968,8 +1001,7 @@ void pmap_init()
#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;
@@ -1003,10 +1035,10 @@ 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)
{
- register vm_page_t m;
- register vm_offset_t pa;
+ vm_page_t m;
+ vm_offset_t pa;
check_simple_locks();
@@ -1092,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;
@@ -1118,11 +1149,10 @@ 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)
{
- 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.
@@ -1198,13 +1228,12 @@ pmap_t pmap_create(size)
* no valid mappings.
*/
-void pmap_destroy(p)
- register pmap_t p;
+void pmap_destroy(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;
@@ -1265,8 +1294,7 @@ void pmap_destroy(p)
* Add a reference to the specified pmap.
*/
-void pmap_reference(p)
- register pmap_t p;
+void pmap_reference(pmap_t p)
{
int s;
if (p != PMAP_NULL) {
@@ -1291,13 +1319,13 @@ 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)
{
- register pt_entry_t *cpte;
+ pt_entry_t *cpte;
int num_removed, num_unwired;
int pai;
vm_offset_t pa;
@@ -1330,8 +1358,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 +1386,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 +1416,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) {
@@ -1447,13 +1475,14 @@ 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;
- 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;
@@ -1488,15 +1517,15 @@ 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;
- 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 +1571,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 +1600,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] |=
@@ -1608,7 +1637,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
@@ -1651,14 +1680,15 @@ 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)
{
- 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;
@@ -1757,16 +1787,16 @@ 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)
- register pmap_t pmap;
- vm_offset_t v;
- register 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)
{
- 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;
@@ -2059,14 +2089,14 @@ Retry:
* In/out conditions:
* The mapping must already exist in the pmap.
*/
-void pmap_change_wiring(map, v, wired)
- register pmap_t map;
- vm_offset_t v;
- boolean_t wired;
+void pmap_change_wiring(
+ 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
@@ -2114,13 +2144,13 @@ void pmap_change_wiring(map, v, wired)
* with the given map/virtual_address pair.
*/
-vm_offset_t pmap_extract(pmap, va)
- register pmap_t pmap;
- vm_offset_t va;
+vm_offset_t pmap_extract(
+ 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);
@@ -2150,9 +2180,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 */
@@ -2167,10 +2194,9 @@ 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)
{
- register pt_entry_t *pdp, *ptp;
+ pt_entry_t *pdp, *ptp;
pt_entry_t *eptp;
vm_offset_t pa;
int spl, wired;
@@ -2201,7 +2227,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;
@@ -2227,8 +2253,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;
@@ -2250,7 +2276,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);
@@ -2303,9 +2329,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 */
@@ -2378,30 +2401,27 @@ 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)
{
-#ifdef lint
- pmap++; start++; end++; pageable++;
-#endif /* lint */
}
/*
* 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;
- 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);
@@ -2432,7 +2452,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;
/*
@@ -2455,7 +2475,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)))
@@ -2479,15 +2499,15 @@ 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;
- 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);
@@ -2531,7 +2551,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);
@@ -2549,7 +2569,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) {
@@ -2570,8 +2590,7 @@ phys_attribute_test(phys, bits)
* Clear the modify bits on the specified physical page.
*/
-void pmap_clear_modify(phys)
- register vm_offset_t phys;
+void pmap_clear_modify(vm_offset_t phys)
{
phys_attribute_clear(phys, PHYS_MODIFIED);
}
@@ -2583,8 +2602,7 @@ void pmap_clear_modify(phys)
* by any physical maps.
*/
-boolean_t pmap_is_modified(phys)
- register vm_offset_t phys;
+boolean_t pmap_is_modified(vm_offset_t phys)
{
return (phys_attribute_test(phys, PHYS_MODIFIED));
}
@@ -2595,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);
}
@@ -2608,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));
}
@@ -2678,13 +2694,14 @@ 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)
{
- 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 */
@@ -2717,13 +2734,12 @@ void signal_cpus(use_list, pmap, start, end)
}
}
-void process_pmap_updates(my_pmap)
- register pmap_t my_pmap;
+void process_pmap_updates(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);
@@ -2748,9 +2764,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();
@@ -2806,7 +2822,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. */
}
@@ -2815,10 +2831,11 @@ 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;
+ 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;
diff --git a/i386/intel/pmap.h b/i386/intel/pmap.h
index 93293e3..382cd5f 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
@@ -227,7 +237,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.
@@ -282,7 +292,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 +334,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 +405,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); \
\
@@ -451,6 +461,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_ */
diff --git a/i386/intel/read_fault.c b/i386/intel/read_fault.c
index 762f60d..29f4439 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 */
@@ -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:
diff --git a/include/cache.h b/include/cache.h
new file mode 100644
index 0000000..6260366
--- /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 <http://www.gnu.org/licenses/>.
+ */
+
+#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_ */
diff --git a/include/device/device.defs b/include/device/device.defs
index d9234e3..5fdf1bd 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(
diff --git a/include/device/device_types.defs b/include/device/device_types.defs
index 79e4c5b..ff6cff6 100644
--- a/include/device/device_types.defs
+++ b/include/device/device_types.defs
@@ -39,6 +39,10 @@
#include <mach/std_types.defs>
+#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 */
;
diff --git a/include/device/device_types.h b/include/device/device_types.h
index caf4fc0..a6db051 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 */
diff --git a/include/device/tape_status.h b/include/device/tape_status.h
index 97cb098..603d76c 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/device/tty_status.h b/include/device/tty_status.h
index 15249a4..2eed5d0 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/alert.h b/include/mach/alert.h
index 8232f9e..e8eb371 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 d3e141f..7f14cc4 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 3164f04..bee7c25 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 <mach/default_pager_types.h>;
-#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 99e43ce..f5ce5a4 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/gnumach.defs b/include/mach/gnumach.defs
index 7331334..6cfbb0d 100644
--- a/include/mach/gnumach.defs
+++ b/include/mach/gnumach.defs
@@ -27,6 +27,7 @@ subsystem
#include <mach/std_types.defs>
#include <mach/mach_types.defs>
+#include <mach_debug/mach_debug_types.defs>
type vm_cache_statistics_data_t = struct[11] of integer_t;
@@ -37,3 +38,37 @@ 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);
+
+/*
+ * 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);
diff --git a/include/mach/mach_port.defs b/include/mach/mach_port.defs
index e1f45e3..c7e8526 100644
--- a/include/mach/mach_port.defs
+++ b/include/mach/mach_port.defs
@@ -342,5 +342,28 @@ 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 */
+/*
+ * 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/include/mach/mach_types.defs b/include/mach/mach_types.defs
index 607d5d9..bfce6cb 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 ea7989a..1ae36aa 100644
--- a/include/mach/memory_object.defs
+++ b/include/mach/memory_object.defs
@@ -42,6 +42,10 @@ subsystem
#include <mach/std_types.defs>
#include <mach/mach_types.defs>
+#ifdef MEMORY_OBJECT_IMPORTS
+MEMORY_OBJECT_IMPORTS
+#endif
+
#if SEQNOS
serverprefix seqnos_;
serverdemux seqnos_memory_object_server;
@@ -85,7 +89,14 @@ 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
+#ifdef MEMORY_OBJECT_DESTRUCTOR
+ destructor: MEMORY_OBJECT_DESTRUCTOR
+#endif
+ ;
#if SEQNOS
msgseqno seqno : mach_port_seqno_t;
#endif /* SEQNOS */
@@ -221,7 +232,14 @@ 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
+#ifdef MEMORY_OBJECT_DESTRUCTOR
+ destructor: MEMORY_OBJECT_DESTRUCTOR
+#endif
+ ;
#if SEQNOS
msgseqno seqno : mach_port_seqno_t;
#endif /* SEQNOS */
@@ -252,7 +270,14 @@ 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
+#ifdef MEMORY_OBJECT_DESTRUCTOR
+ destructor: MEMORY_OBJECT_DESTRUCTOR
+#endif
+ ;
#if SEQNOS
msgseqno seqno : mach_port_seqno_t;
#endif /* SEQNOS */
@@ -298,7 +323,14 @@ 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
+#ifdef MEMORY_OBJECT_DESTRUCTOR
+ destructor: MEMORY_OBJECT_DESTRUCTOR
+#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 0eac271..cfd54a4 100644
--- a/include/mach/memory_object_default.defs
+++ b/include/mach/memory_object_default.defs
@@ -40,6 +40,10 @@ subsystem
#include <mach/std_types.defs>
#include <mach/mach_types.defs>
+#ifdef MEMORY_OBJECT_IMPORTS
+MEMORY_OBJECT_IMPORTS
+#endif
+
#if SEQNOS
serverprefix seqnos_;
serverdemux seqnos_memory_object_default_server;
diff --git a/include/mach/message.h b/include/mach/message.h
index f78e978..0a7297e 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;
@@ -253,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
diff --git a/include/mach/multiboot.h b/include/mach/multiboot.h
index 3880fa8..b23df4a 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 e06f6b4..5e59d39 100644
--- a/include/mach/notify.defs
+++ b/include/mach/notify.defs
@@ -28,16 +28,30 @@ subsystem notify 64;
#include <mach/std_types.defs>
+#ifdef NOTIFY_IMPORTS
+NOTIFY_IMPORTS
+#endif
+
#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;
+ 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;
@@ -47,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 */
@@ -55,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 */
@@ -67,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 */
@@ -75,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 */
@@ -83,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 */
@@ -91,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/rpc.h b/include/mach/rpc.h
index d3098f8..36eb592 100644
--- a/include/mach/rpc.h
+++ b/include/mach/rpc.h
@@ -21,7 +21,6 @@
#include <mach/kern_return.h>
#include <mach/message.h>
-#include <mach/machine/rpc.h>
/*
* Description of a port passed up by the leaky-register RPC path
diff --git a/include/mach/version.h b/include/mach/version.h
index ec12ea7..3ef7859 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/include/mach_debug/mach_debug.defs
b/include/mach_debug/mach_debug.defs
index 053c3fe..fb6e3a9 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 */
diff --git a/include/mach_debug/mach_debug_types.defs
b/include/mach_debug/mach_debug_types.defs
index f60125a..d24b6f9 100644
--- a/include/mach_debug/mach_debug_types.defs
+++ b/include/mach_debug/mach_debug_types.defs
@@ -57,6 +57,8 @@ type vm_page_info_array_t = array[] of vm_page_info_t;
type symtab_name_t = (MACH_MSG_TYPE_STRING_C, 8*32);
+type kernel_debug_name_t = c_string[*: 64];
+
import <mach_debug/mach_debug_types.h>;
#endif /* _MACH_DEBUG_MACH_DEBUG_TYPES_DEFS_ */
diff --git a/include/mach_debug/mach_debug_types.h
b/include/mach_debug/mach_debug_types.h
index 5d4efcd..9c7d1fd 100644
--- a/include/mach_debug/mach_debug_types.h
+++ b/include/mach_debug/mach_debug_types.h
@@ -37,4 +37,15 @@
typedef char symtab_name_t[32];
+/*
+ * A fixed-length string data type intended for names given to
+ * kernel objects.
+ *
+ * Note that it is not guaranteed that the in-kernel data
+ * structure will hold KERNEL_DEBUG_NAME_MAX bytes. The given
+ * name will be truncated to fit into the target data structure.
+ */
+#define KERNEL_DEBUG_NAME_MAX (64)
+typedef char kernel_debug_name_t[KERNEL_DEBUG_NAME_MAX];
+
#endif /* _MACH_DEBUG_MACH_DEBUG_TYPES_H_ */
diff --git a/include/mach_debug/pc_info.h b/include/mach_debug/pc_info.h
index bc43fa8..912da9f 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/include/string.h b/include/string.h
index c77d387..c31b429 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/ipc/ipc_entry.c b/ipc/ipc_entry.c
index 3a06244..e78f74e 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;
@@ -839,14 +838,9 @@ 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,
+ const task_t task,
mach_port_t name)
{
ipc_space_t space = task->itk_space;
diff --git a/ipc/ipc_entry.h b/ipc/ipc_entry.h
index 6afa4f6..cb6d3f9 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_ */
diff --git a/ipc/ipc_hash.c b/ipc/ipc_hash.c
index 5eec58c..c2c6d6e 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) &&
@@ -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_init.c b/ipc/ipc_init.c
index ca7e791..debda47 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
@@ -108,7 +108,7 @@ ipc_bootstrap(void)
*/
void
-ipc_init()
+ipc_init(void)
{
vm_offset_t min, max;
diff --git a/ipc/ipc_kmsg.c b/ipc/ipc_kmsg.c
index 3ad274d..71a0d74 100644
--- a/ipc/ipc_kmsg.c
+++ b/ipc/ipc_kmsg.c
@@ -69,10 +69,6 @@
#include <ipc/ipc_print.h>
#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) )
@@ -222,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;
@@ -321,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;
@@ -365,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;
@@ -470,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;
@@ -504,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;
@@ -556,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;
@@ -593,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;
@@ -678,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;
@@ -1343,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;
@@ -1563,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;
@@ -1598,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);
@@ -1758,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;
@@ -1806,9 +1799,17 @@ ipc_kmsg_copyout_header(msg, space, notify)
} 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;
}
@@ -1904,10 +1905,18 @@ ipc_kmsg_copyout_header(msg, space, notify)
} 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;
}
@@ -1939,9 +1948,18 @@ ipc_kmsg_copyout_header(msg, space, notify)
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;
}
@@ -2231,9 +2249,16 @@ ipc_kmsg_copyout_header(msg, space, notify)
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;
}
@@ -2258,11 +2283,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;
@@ -2280,7 +2305,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 +2338,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;
@@ -2368,10 +2393,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;
@@ -2520,11 +2546,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;
@@ -2614,9 +2640,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;
@@ -2662,9 +2688,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:
@@ -2745,8 +2771,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",
@@ -2762,8 +2787,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_kmsg.h b/ipc/ipc_kmsg.h
index 8867310..07695fb 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 <ipc/ipc_kmsg_queue.h>
diff --git a/ipc/ipc_kmsg_queue.h b/ipc/ipc_kmsg_queue.h
index 51ccbe2..b4b3df1 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/ipc/ipc_machdep.h b/ipc/ipc_machdep.h
index e864c4b..c205ba4 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_ */
diff --git a/ipc/ipc_marequest.c b/ipc/ipc_marequest.c
index 06c53eb..ded1711 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 80a34d3..9138aec 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;
@@ -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_mqueue.h b/ipc/ipc_mqueue.h
index ef0f942..f8a2f1e 100644
--- a/ipc/ipc_mqueue.h
+++ b/ipc/ipc_mqueue.h
@@ -38,6 +38,7 @@
#include <kern/assert.h>
#include <kern/lock.h>
#include <kern/macro_help.h>
+#include <ipc/ipc_kmsg_queue.h>
#include <ipc/ipc_kmsg.h>
#include <ipc/ipc_thread.h>
diff --git a/ipc/ipc_notify.c b/ipc/ipc_notify.c
index 25fa421..df5f68b 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_object.c b/ipc/ipc_object.c
index b8cae8f..db6ef01 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;
}
@@ -1007,7 +1008,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_object.h b/ipc/ipc_object.h
index adf5bca..b83bb5a 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 b960739..89a5d67 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;
@@ -275,9 +274,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;
@@ -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;
@@ -425,6 +423,44 @@ ipc_port_set_seqno(port, seqno)
}
/*
+ * 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:
* Prepares a receive right for transmission/destruction.
@@ -493,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);
@@ -615,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)) {
@@ -1135,8 +1174,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;
@@ -1212,12 +1250,17 @@ ipc_port_dealloc_special(
void
ipc_port_print(port)
- ipc_port_t port;
+ const ipc_port_t port;
{
printf("port 0x%x\n", 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);
@@ -1240,7 +1283,9 @@ ipc_port_print(port)
printf(", sndrs=0x%x", port->ip_blocked.ithq_base);
printf(", kobj=0x%x\n", port->ip_kobject);
- indent -=2;
+ iprintf("protected_payload=%p\n", (void *) port->ip_protected_payload);
+
+ indent -= 2;
}
#endif /* MACH_KDB */
diff --git a/ipc/ipc_port.h b/ipc/ipc_port.h
index 27d2e49..6914c71 100644
--- a/ipc/ipc_port.h
+++ b/ipc/ipc_port.h
@@ -48,6 +48,7 @@
#include <ipc/ipc_mqueue.h>
#include <ipc/ipc_table.h>
#include <ipc/ipc_thread.h>
+#include <ipc/ipc_object.h>
#include "ipc_target.h"
#include <mach/rpc.h>
@@ -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
@@ -262,6 +264,12 @@ 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);
extern void
@@ -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)
+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);
+}
+
+static inline void
+ipc_port_flag_protected_payload_set(struct ipc_port *port)
+{
+ port->ip_target.ipt_object.io_bits |= IO_BITS_PROTECTED_PAYLOAD;
+}
+
+static 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/include/mach/gnumach.defs b/ipc/ipc_print.h
similarity index 58%
copy from include/mach/gnumach.defs
copy to ipc/ipc_print.h
index 7331334..5e8e4f3 100644
--- a/include/mach/gnumach.defs
+++ b/ipc/ipc_print.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 Free Software Foundation
+ * 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
@@ -16,24 +16,24 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-subsystem
-#if KERNEL_SERVER
- KernelServer
-#endif /* KERNEL_SERVER */
-#if KERNEL_USER
- KernelUser
-#endif /* KERNEL_USER */
- gnumach 4200;
+#ifndef _IPC_PRINT_H_
+#define _IPC_PRINT_H_
-#include <mach/std_types.defs>
-#include <mach/mach_types.defs>
+#if MACH_KDB
-type vm_cache_statistics_data_t = struct[11] of integer_t;
+#include <mach/mach_types.h>
+#include <mach/message.h>
+#include <ipc/ipc_types.h>
+#include <ipc/ipc_pset.h>
-/*
- * Return page cache statistics for the host on which the target task
- * resides.
- */
-routine vm_cache_statistics(
- target_task : vm_task_t;
- out vm_cache_stats : vm_cache_statistics_data_t);
+extern void ipc_port_print(const ipc_port_t);
+
+extern void ipc_pset_print(const ipc_pset_t);
+
+extern void ipc_kmsg_print(const 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 c016d27..884e897 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);
@@ -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 */
diff --git a/ipc/ipc_right.c b/ipc/ipc_right.c
index 41fe3de..503eb1f 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;
@@ -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) {
diff --git a/ipc/ipc_table.c b/ipc/ipc_table.c
index cbb6a89..90960a8 100644
--- a/ipc/ipc_table.c
+++ b/ipc/ipc_table.c
@@ -42,20 +42,11 @@
#include <kern/slab.h>
#include <vm/vm_kern.h>
-/*
- * 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;
-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(
diff --git a/ipc/ipc_table.h b/ipc/ipc_table.h
index 695adae..311b9a7 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
@@ -108,6 +110,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)))
diff --git a/ipc/ipc_thread.h b/ipc/ipc_thread.h
index fbeea46..008ab4a 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; \
diff --git a/ipc/mach_debug.c b/ipc/mach_debug.c
index 28dd693..eb52e1c 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 */
@@ -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,
@@ -603,8 +603,8 @@ mach_port_kernel_object(
return KERN_INVALID_RIGHT;
}
- *typep = (unsigned int) ip_kotype(port);
- *addrp = (vm_offset_t) port->ip_kobject;
+ *typep = ip_kotype(port);
+ *addrp = port->ip_kobject;
ip_unlock(port);
return KERN_SUCCESS;
}
diff --git a/ipc/mach_msg.c b/ipc/mach_msg.c
index 00ab085..1e122c7 100644
--- a/ipc/mach_msg.c
+++ b/ipc/mach_msg.c
@@ -46,6 +46,7 @@
#include <kern/printf.h>
#include <kern/sched_prim.h>
#include <kern/ipc_sched.h>
+#include <kern/exception.h>
#include <vm/vm_map.h>
#include <ipc/ipc_kmsg.h>
#include <ipc/ipc_marequest.h>
@@ -61,9 +62,6 @@
#include <machine/locore.h>
#include <machine/pcb.h>
-extern void exception_raise_continue();
-extern void exception_raise_continue_fast();
-
/*
* Routine: mach_msg_send
* Purpose:
@@ -90,12 +88,12 @@ extern void exception_raise_continue_fast();
*/
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();
@@ -172,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();
@@ -381,26 +379,26 @@ 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;
/* 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 +482,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 +515,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 +536,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 +551,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 +649,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 +671,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 +738,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 +763,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 +774,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 +839,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 +1072,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 +1089,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;
@@ -1134,11 +1132,19 @@ mach_msg_trap(msg, option, send_size, rcv_size,
rcv_name, time_out, notify)
} 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:
@@ -1148,7 +1154,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 */
@@ -1172,17 +1178,25 @@ mach_msg_trap(msg, option, send_size, rcv_size,
rcv_name, time_out, notify)
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;
}
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 */
@@ -1206,12 +1220,23 @@ mach_msg_trap(msg, option, send_size, rcv_size,
rcv_name, time_out, notify)
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),
@@ -1322,7 +1347,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 +1382,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.
@@ -1735,8 +1760,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 46cb4de..4ff39f2 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;
@@ -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(
@@ -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");
}
@@ -759,12 +759,10 @@ mach_port_mod_refs(
*/
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;
- 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;
@@ -803,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;
@@ -1367,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;
@@ -1421,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;
@@ -1459,19 +1457,19 @@ 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);
}
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;
@@ -1538,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;
@@ -1566,3 +1564,76 @@ mach_port_set_syscall_right(task, name)
}
#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;
+}
diff --git a/ipc/mach_port.h b/ipc/mach_port.h
index a82228f..c4d9a1c 100644
--- a/ipc/mach_port.h
+++ b/ipc/mach_port.h
@@ -43,6 +43,11 @@ mach_port_allocate (
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,
mach_port_t name);
@@ -54,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_ */
diff --git a/ipc/mach_rpc.c b/ipc/mach_rpc.c
index 7f5b2eb..6ca46cc 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;
@@ -141,7 +142,7 @@ mach_port_rpc_copy(portp, sact, dact)
}
kern_return_t
-mach_port_rpc_sig(space, name, buffer, buflen)
+mach_port_rpc_sig(const ipc_space_t space, const char *name, const char
*buffer, unsigned int buflen)
{
return KERN_FAILURE;
}
diff --git a/ipc/port.h b/ipc/port.h
index 6e9f77b..d6fb59b 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
*
diff --git a/kern/act.c b/kern/act.c
index 4c3839c..3186f7e 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();
@@ -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)
- register 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)
- register 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;
@@ -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;
@@ -1076,7 +1076,7 @@ void act_count()
ACT_STATIC_KLUDGE-i, ACT_STATIC_KLUDGE, ACT_STATIC_KLUDGE-amin);
}
-dump_act(act)
+void dump_act(act)
Act *act;
{
act_count();
@@ -1097,8 +1097,7 @@ dump_act(act)
#ifdef ACTWATCH
Act *
-get_next_act(sp)
- int sp;
+get_next_act(int sp)
{
static int i;
Act *act;
@@ -1114,6 +1113,6 @@ get_next_act(sp)
return act;
}
}
-#endif
+#endif /* ACTWATCH */
#endif /* MIGRATING_THREADS */
diff --git a/kern/act.h b/kern/act.h
index e064724..f46f53a 100644
--- a/kern/act.h
+++ b/kern/act.h
@@ -40,8 +40,6 @@
#include <kern/refcount.h>
#include <kern/queue.h>
-#include "act.h"/*XXX*/
-
struct task;
struct thread;
struct Act;
@@ -176,7 +174,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);
@@ -192,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/assert.h b/kern/assert.h
index 2829728..b074fbb 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 \
@@ -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/ast.c b/kern/ast.c
index 97da3ab..4b9d63d 100644
--- a/kern/ast.c
+++ b/kern/ast.c
@@ -56,10 +56,10 @@
volatile ast_t need_ast[NCPUS];
void
-ast_init()
+ast_init(void)
{
#ifndef MACHINE_AST
- register int i;
+ int i;
for (i=0; i<NCPUS; i++)
need_ast[i] = 0;
@@ -69,8 +69,8 @@ ast_init()
void
ast_taken(void)
{
- register thread_t self = current_thread();
- register ast_t reasons;
+ thread_t self = current_thread();
+ ast_t reasons;
/*
* Interrupts are still disabled.
@@ -114,12 +114,12 @@ ast_taken(void)
}
void
-ast_check()
+ast_check(void)
{
- register int mycpu = cpu_number();
- register processor_t myprocessor;
- register thread_t thread = current_thread();
- register run_queue_t rq;
+ int mycpu = cpu_number();
+ processor_t myprocessor;
+ thread_t thread = current_thread();
+ run_queue_t rq;
spl_t s = splsched();
/*
@@ -190,7 +190,7 @@ ast_check()
#endif /* MACH_FIXPRI */
rq = &(myprocessor->processor_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.
diff --git a/kern/boot_script.c b/kern/boot_script.c
index b2e9393..b245d1d 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);
}
@@ -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/boot_script.h b/kern/boot_script.h
index c5ad673..c007d77 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/bootstrap.c b/kern/bootstrap.c
index c98b0a2..4edae7b 100644
--- a/kern/bootstrap.c
+++ b/kern/bootstrap.c
@@ -37,6 +37,7 @@
#include <mach/message.h>
#include <machine/locore.h>
#include <machine/vm_param.h>
+#include <machine/pcb.h>
#include <ipc/ipc_port.h>
#include <ipc/mach_port.h>
#include <kern/debug.h>
@@ -81,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 */
@@ -106,7 +107,7 @@ task_insert_send_right(
return name;
}
-void bootstrap_create()
+void bootstrap_create(void)
{
int compat;
int n = 0;
@@ -149,18 +150,18 @@ void bootstrap_create()
}
else
{
- int i, losers, maxlen;
+ int i, losers;
/* 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));
@@ -240,15 +241,11 @@ void bootstrap_create()
}
#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)
{
@@ -256,7 +253,7 @@ void bootstrap_create()
++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);
@@ -318,7 +315,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 +335,7 @@ itoa(
*/
static void get_compat_strings(char *flags_str, char *root_str)
{
- register char *ip, *cp;
+ char *ip, *cp;
strcpy (root_str, "UNKNOWN");
@@ -519,16 +516,12 @@ 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)
{
vm_offset_t stack_base;
vm_size_t stack_size;
- register
char * arg_ptr;
int arg_count, envc;
int arg_len;
@@ -590,7 +583,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);
@@ -603,7 +596,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 *);
@@ -616,7 +609,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 *);
/*
@@ -627,7 +620,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 *);
@@ -640,12 +633,12 @@ 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 *));
}
static void
-user_bootstrap_compat()
+user_bootstrap_compat(void)
{
exec_info_t boot_exec_info;
@@ -747,7 +740,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;
@@ -807,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;
}
@@ -844,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;
}
diff --git a/include/mach/gnumach.defs b/kern/bootstrap.h
similarity index 58%
copy from include/mach/gnumach.defs
copy to kern/bootstrap.h
index 7331334..b8ed8d9 100644
--- a/include/mach/gnumach.defs
+++ b/kern/bootstrap.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 Free Software Foundation
+ * 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
@@ -16,24 +16,9 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-subsystem
-#if KERNEL_SERVER
- KernelServer
-#endif /* KERNEL_SERVER */
-#if KERNEL_USER
- KernelUser
-#endif /* KERNEL_USER */
- gnumach 4200;
+#ifndef _KERN_BOOTSTRAP_H_
+#define _KERN_BOOTSTRAP_H_
-#include <mach/std_types.defs>
-#include <mach/mach_types.defs>
+extern void bootstrap_create(void);
-type vm_cache_statistics_data_t = struct[11] of integer_t;
-
-/*
- * Return page cache statistics for the host on which the target task
- * resides.
- */
-routine vm_cache_statistics(
- target_task : vm_task_t;
- out vm_cache_stats : vm_cache_statistics_data_t);
+#endif /* _KERN_BOOTSTRAP_H_ */
diff --git a/kern/debug.c b/kern/debug.c
index 7f6e555..fd392d2 100644
--- a/kern/debug.c
+++ b/kern/debug.c
@@ -38,11 +38,7 @@
#include <machine/loose_ends.h>
#include <machine/model_dep.h>
-extern void cnputc();
-
-#if MACH_KDB
-extern int db_breakpoints_inserted;
-#endif
+#include <device/cons.h>
#if NCPUS>1
simple_lock_data_t Assert_print_lock; /* uninited, we take our chances */
@@ -55,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,14 +63,11 @@ Assert(char *exp, char *file, int line)
exp, file, line);
#endif
-#if MACH_KDB
- if (db_breakpoints_inserted)
-#endif
Debugger("assertion failure");
}
void SoftDebugger(message)
- char * message;
+ const char *message;
{
printf("Debugger invoked: %s\n", message);
@@ -106,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!");
@@ -199,14 +192,12 @@ 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);
}
+/* GCC references this for stack protection. */
unsigned char __stack_chk_guard [ sizeof (vm_offset_t) ] =
{
[ sizeof (vm_offset_t) - 3 ] = '\r',
diff --git a/kern/debug.h b/kern/debug.h
index e429bdd..6c8977b 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/elf-load.c b/kern/elf-load.c
index 1d103d3..441276e 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;
}
}
diff --git a/kern/eventcount.c b/kern/eventcount.c
index 6fcebff..a9d7bd4 100644
--- a/kern/eventcount.c
+++ b/kern/eventcount.c
@@ -53,13 +53,6 @@
#include <kern/eventcount.h>
-
-#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];
@@ -105,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;
@@ -130,7 +123,7 @@ void evc_notify_abort(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);
@@ -235,8 +228,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 +318,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.
@@ -347,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/eventcount.h b/kern/eventcount.h
index 6872a34..7cc8220 100644
--- a/kern/eventcount.h
+++ b/kern/eventcount.h
@@ -53,7 +53,12 @@ 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);
+#if NCPUS <= 1
+void simpler_thread_setrun(
+ thread_t th,
+ boolean_t may_preempt);
+#endif
#endif /* _KERN_EVENTCOUNT_H_ */
diff --git a/kern/exception.c b/kern/exception.c
index 453a075..7954fba 100644
--- a/kern/exception.c
+++ b/kern/exception.c
@@ -47,23 +47,12 @@
#include <kern/processor.h>
#include <kern/sched.h>
#include <kern/sched_prim.h>
+#include <kern/exception.h>
#include <mach/machine/vm_types.h>
-
-
-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();
+#include <machine/trap.h>
+#include <ddb/db_output.h>
boolean_t debug_user_with_kdb = FALSE;
#endif /* MACH_KDB */
@@ -93,11 +82,13 @@ 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)
{
- 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");
@@ -163,12 +154,14 @@ 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();
- 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.
@@ -228,9 +221,9 @@ exception_try_task(_exception, code, subcode)
*/
void
-exception_no_server()
+exception_no_server(void)
{
- register ipc_thread_t self = current_thread();
+ ipc_thread_t self = current_thread();
/*
* If this thread is being terminated, cooperate.
@@ -330,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;
@@ -428,7 +422,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 +484,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 +492,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 +603,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 +620,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 +704,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;
@@ -794,10 +788,9 @@ 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)
{
- register mig_reply_header_t *msg =
+ mig_reply_header_t *msg =
(mig_reply_header_t *) &kmsg->ikm_header;
kern_return_t kr;
@@ -839,7 +832,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;
@@ -871,10 +864,10 @@ exception_raise_continue()
*/
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;
@@ -954,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/exception.h b/kern/exception.h
new file mode 100644
index 0000000..55902dd
--- /dev/null
+++ b/kern/exception.h
@@ -0,0 +1,66 @@
+/*
+ * 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_
+
+#include <ipc/ipc_types.h>
+#include <ipc/ipc_kmsg.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_ */
diff --git a/kern/host.c b/kern/host.c
index 57a40b4..2855cd2 100644
--- a/kern/host.c
+++ b/kern/host.c
@@ -47,12 +47,12 @@
host_data_t realhost;
kern_return_t host_processors(
- host_t host,
+ const host_t host,
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;
@@ -95,12 +95,12 @@ 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)
{
- 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)
@@ -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)
{
@@ -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;
}
@@ -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 cd1c11a..a02eb6f 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_kobject.c b/kern/ipc_kobject.c
index 37d4eb9..bf22028 100644
--- a/kern/ipc_kobject.c
+++ b/kern/ipc_kobject.c
@@ -49,8 +49,21 @@
#include <vm/memory_object_proxy.h>
#include <device/ds_routines.h>
+#include <kern/mach.server.h>
+#include <ipc/mach_port.server.h>
+#include <kern/mach_host.server.h>
+#include <device/device.server.h>
+#include <device/device_pager.server.h>
+#include <kern/mach4.server.h>
+#include <kern/gnumach.server.h>
+
+#if MACH_DEBUG
+#include <kern/mach_debug.server.h>
+#endif
+
#if MACH_MACHINE_ROUTINES
#include <machine/machine_routines.h>
+#include MACHINE_SERVER_HEADER
#endif
@@ -146,21 +159,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
-
check_simple_locks();
if ((routine = mach_server_routine(&request->ikm_header)) != 0
|| (routine = mach_port_server_routine(&request->ikm_header)) != 0
diff --git a/kern/ipc_kobject.h b/kern/ipc_kobject.h
index cb79574..606a66a 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 <ipc/ipc_kmsg.h>
-#include <ipc/ipc_types.h>
-
#ifndef _KERN_IPC_KOBJECT_H_
#define _KERN_IPC_KOBJECT_H_
#include <mach/machine/vm_types.h>
+#include <ipc/ipc_types.h>
+#include <ipc/ipc_kmsg.h>
typedef vm_offset_t ipc_kobject_t;
diff --git a/kern/ipc_mig.c b/kern/ipc_mig.c
index e1532ac..41ebc94 100644
--- a/kern/ipc_mig.c
+++ b/kern/ipc_mig.c
@@ -37,6 +37,7 @@
#include <kern/task.h>
#include <kern/ipc_kobject.h>
#include <kern/ipc_tt.h>
+#include <kern/ipc_mig.h>
#include <vm/vm_map.h>
#include <vm/vm_user.h>
#include <ipc/port.h>
@@ -91,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;
{
@@ -109,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;
@@ -140,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();
@@ -271,10 +271,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:
*
@@ -284,28 +284,33 @@ mig_put_reply_port(
*
* len - Length of destination buffer.
*/
-void mig_strncpy(dest, src, len)
-char *dest, *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<len; i++)
- if (! (*dest++ = *src++))
- return;
+ for (i = 0; i < len; i++) {
+ if (! (*dest = *src))
+ break;
+ dest++;
+ src++;
+ }
- *dest = '\0';
- return;
+ return dest - dest_;
}
#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); \
@@ -327,11 +332,10 @@ MACRO_BEGIN
\
MACRO_END
device_t
-port_name_to_device(name)
- mach_port_t name;
+port_name_to_device(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 */
@@ -371,17 +375,16 @@ port_name_to_device(name)
}
thread_t
-port_name_to_thread(name)
- mach_port_t name;
+port_name_to_thread(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);
@@ -417,17 +420,16 @@ port_name_to_thread(name)
}
task_t
-port_name_to_task(name)
- mach_port_t name;
+port_name_to_task(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 +470,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);
@@ -513,17 +515,16 @@ port_name_to_map(
}
ipc_space_t
-port_name_to_space(name)
- mach_port_t name;
+port_name_to_space(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);
@@ -569,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;
@@ -586,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;
@@ -650,12 +649,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);
@@ -663,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;
@@ -677,19 +676,19 @@ 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;
}
-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;
@@ -704,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;
@@ -725,7 +724,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);
@@ -733,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;
@@ -749,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;
@@ -765,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;
@@ -798,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;
@@ -813,17 +810,17 @@ 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;
}
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;
@@ -839,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;
@@ -857,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;
@@ -896,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;
@@ -915,10 +911,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,
@@ -979,7 +971,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 +992,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;
diff --git a/kern/ipc_mig.h b/kern/ipc_mig.h
index f352bdc..6f063ec 100644
--- a/kern/ipc_mig.h
+++ b/kern/ipc_mig.h
@@ -27,6 +27,7 @@
#define _IPC_MIG_H_
#include <mach/std_types.h>
+#include <device/device_types.h>
/*
* Routine: mach_msg_send_from_kernel
@@ -58,8 +59,84 @@ 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);
+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/ipc_sched.c b/kern/ipc_sched.c
index 615ad60..d5b9263 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;
diff --git a/kern/ipc_tt.c b/kern/ipc_tt.c
index 6d32e5b..96737be 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;
@@ -387,9 +383,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());
@@ -424,10 +420,9 @@ retrieve_task_self_fast(
*/
ipc_port_t
-retrieve_thread_self_fast(thread)
- register thread_t thread;
+retrieve_thread_self_fast(thread_t thread)
{
- register ipc_port_t port;
+ ipc_port_t port;
assert(thread == current_thread());
@@ -648,9 +643,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;
@@ -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.c b/kern/lock.c
index 44d4448..fb5e344 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);
diff --git a/kern/lock.h b/kern/lock.h
index 4f38ea3..a6d286a 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/lock_mon.c b/kern/lock_mon.c
index 1450428..f6bbd5d 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 {
@@ -85,7 +84,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[];
@@ -94,8 +93,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) {
@@ -112,11 +111,11 @@ decl_simple_lock_data(, **lock)
}
-simple_lock(lock)
+void 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++;
@@ -131,11 +130,11 @@ 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)
{
- 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++;
@@ -151,12 +150,12 @@ decl_simple_lock_data(, *lock)
}
}
-simple_unlock(lock)
+void 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);
@@ -167,16 +166,13 @@ decl_simple_lock_data(, *lock)
}
}
-lip() {
+void lip(void) {
lis(4, 1, 0);
}
#define lock_info_sort lis
-unsigned scurval, ssum;
-struct lock_info *sli;
-
-lock_info_sort(arg, abs, count)
+void lock_info_sort(arg, abs, count)
{
struct lock_info *li, mean;
int bucket = 0;
@@ -215,9 +211,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;
@@ -257,7 +250,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;
@@ -271,7 +264,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;
@@ -299,11 +292,11 @@ struct lock_info *li;
* Measure lock/unlock operations
*/
-time_lock(loops)
+void time_lock(int loops)
{
decl_simple_lock_data(, lock)
- register time_stamp_t stamp;
- register int i;
+ time_stamp_t stamp;
+ int i;
if (!loops)
@@ -340,7 +333,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 +349,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) {
diff --git a/kern/mach_clock.c b/kern/mach_clock.c
index edf87f0..0a7458b 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
*
@@ -54,6 +54,7 @@
#include <kern/thread.h>
#include <kern/time_stamp.h>
#include <kern/timer.h>
+#include <kern/priority.h>
#include <vm/vm_kern.h>
#include <sys/time.h>
#include <machine/mach_param.h> /* HZ */
@@ -64,8 +65,6 @@
#include <kern/pc_sample.h>
#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) */
@@ -121,13 +120,13 @@ timer_elt_data_t timer_head; /* ordered list of
timeouts */
* the accuracy of the hardware clock.
*
*/
-void clock_interrupt(usec, usermode, basepri)
- register 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 */
{
- 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);
@@ -150,8 +149,7 @@ void clock_interrupt(usec, usermode, basepri)
* Increment the CPU time statistics.
*/
{
- extern void thread_quantum_update(); /* in priority.c */
- register int state;
+ int state;
if (usermode)
state = CPU_STATE_USER;
@@ -187,8 +185,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 +219,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;
@@ -272,15 +270,15 @@ void clock_interrupt(usec, usermode, basepri)
* and corrupts it.
*/
-void softclock()
+void softclock(void)
{
/*
* 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();
@@ -311,12 +309,12 @@ void softclock()
* telt timer element. Function and param are already set.
* interval time-out interval, in hz.
*/
-void set_timeout(telt, interval)
- register timer_elt_t telt; /* already loaded */
- register unsigned int interval;
+void set_timeout(
+ 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);
@@ -341,8 +339,7 @@ void set_timeout(telt, interval)
splx(s);
}
-boolean_t reset_timeout(telt)
- register timer_elt_t telt;
+boolean_t reset_timeout(timer_elt_t telt)
{
spl_t s;
@@ -362,7 +359,7 @@ boolean_t reset_timeout(telt)
}
}
-void init_timeout()
+void init_timeout(void)
{
simple_lock_init(&timer_lock);
queue_init(&timer_head.chain);
@@ -389,7 +386,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)
@@ -408,7 +405,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;
@@ -446,7 +443,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 */
{
@@ -492,7 +489,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)
@@ -501,13 +498,13 @@ void mapable_time_init()
update_mapped_time(&time);
}
-int timeopen()
+int timeopen(dev_t dev, int flag, io_req_t ior)
{
return(0);
}
-int timeclose()
+void timeclose(dev_t dev, int flag)
{
- return(0);
+ return;
}
/*
@@ -528,13 +525,13 @@ 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;
- register timer_elt_t elt;
+ timer_elt_t elt;
s = splsched();
simple_lock(&timer_lock);
@@ -557,11 +554,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 );
+ const void * param;
{
spl_t s;
- register timer_elt_t elt;
+ timer_elt_t elt;
s = splsched();
simple_lock(&timer_lock);
diff --git a/kern/mach_clock.h b/kern/mach_clock.h
index 4e4e8ff..89fd335 100644
--- a/kern/mach_clock.h
+++ b/kern/mach_clock.h
@@ -29,6 +29,10 @@
#include <mach/time_value.h>
#include <kern/host.h>
#include <kern/queue.h>
+#include <sys/types.h>
+
+struct io_req;
+typedef struct io_req *io_req_t;
/* Timers in kernel. */
@@ -102,6 +106,9 @@ 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(dev_t dev, int flag, io_req_t ior);
+extern void timeclose(dev_t dev, int flag);
#endif /* _KERN_MACH_CLOCK_H_ */
diff --git a/kern/mach_factor.c b/kern/mach_factor.c
index 558c4a0..debce0b 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])
diff --git a/kern/machine.c b/kern/machine.c
index c2a19b9..eced768 100644
--- a/kern/machine.c
+++ b/kern/machine.c
@@ -72,12 +72,11 @@ 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)
{
- 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);
@@ -102,12 +101,11 @@ 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)
{
- 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);
@@ -126,8 +124,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);
@@ -153,11 +151,11 @@ 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)
{
- register processor_set_t pset;
+ processor_set_t pset;
/*
* Processor must be in a processor set. Must lock its idle lock to
@@ -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,14 +313,11 @@ 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)
{
-#ifdef lint
- processor++; new_pset++; wait++;
-#endif
return KERN_FAILURE;
}
@@ -334,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;
@@ -364,12 +358,10 @@ processor_t processor;
/*
* action_thread() shuts down processors or changes their assignment.
*/
-void processor_doaction(); /* forward */
-
-void action_thread_continue()
+void action_thread_continue(void)
{
- register processor_t processor;
- register spl_t s;
+ processor_t processor;
+ spl_t s;
while (TRUE) {
s = splsched();
@@ -395,7 +387,7 @@ void action_thread_continue()
}
}
-void action_thread()
+void __attribute__((noreturn)) action_thread(void)
{
action_thread_continue();
/*NOTREACHED*/
@@ -406,21 +398,15 @@ 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)
-register processor_t processor;
+void processor_doaction(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 */
@@ -633,13 +619,10 @@ Restart_pset:
* running on the processor's shutdown stack.
*/
-#ifdef __GNUC__
-__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]);
@@ -663,23 +646,20 @@ register 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)
{
-#ifdef lint
- processor++; new_pset++; wait++;
-#endif /* lint */
return(KERN_FAILURE);
}
#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/machine.h b/kern/machine.h
index af2b7e9..c67213a 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/macro_help.h b/kern/macro_help.h
index a3d156b..7ce171f 100644
--- a/kern/macro_help.h
+++ b/kern/macro_help.h
@@ -37,13 +37,8 @@
#include <mach/boolean.h>
-#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/pc_sample.c b/kern/pc_sample.c
index 5700258..81b2056 100644
--- a/kern/pc_sample.c
+++ b/kern/pc_sample.c
@@ -43,12 +43,9 @@
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(
- register thread_t t,
- register sample_control_t *cp,
+ const thread_t t,
+ sample_control_t *cp,
sampled_pc_flavor_t flavor)
{
vm_offset_t pc;
@@ -244,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 */
@@ -253,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 */
@@ -262,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/printf.c b/kern/printf.c
index a3a771d..1db0d08 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;
}
@@ -615,13 +615,23 @@ 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;
- int maxlen;
+void safe_gets(
+ 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;
diff --git a/kern/printf.h b/kern/printf.h
index 8b4e760..0f8b328 100644
--- a/kern/printf.h
+++ b/kern/printf.h
@@ -40,6 +40,7 @@ extern void printnum (unsigned long u, int base,
vm_offset_t putc_arg);
extern int sprintf (char *buf, const char *fmt, ...);
+extern int snprintf (char *buf, size_t size, const char *fmt, ...);
extern int vsnprintf (char *buf, size_t size, const char *fmt, va_list args);
extern int printf (const char *fmt, ...);
diff --git a/kern/priority.c b/kern/priority.c
index 17541b8..587ea2f 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
*
@@ -74,16 +74,16 @@
* Called only from clock_interrupt().
*/
-void thread_quantum_update(mycpu, thread, nticks, state)
- register int mycpu;
- register thread_t thread;
- int nticks;
- int state;
+void thread_quantum_update(
+ 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;
diff --git a/include/mach/gnumach.defs b/kern/priority.h
similarity index 58%
copy from include/mach/gnumach.defs
copy to kern/priority.h
index 7331334..2da93eb 100644
--- a/include/mach/gnumach.defs
+++ b/kern/priority.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 Free Software Foundation
+ * 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
@@ -16,24 +16,13 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-subsystem
-#if KERNEL_SERVER
- KernelServer
-#endif /* KERNEL_SERVER */
-#if KERNEL_USER
- KernelUser
-#endif /* KERNEL_USER */
- gnumach 4200;
+#ifndef _KERN_PRIORITY_H_
+#define _KERN_PRIORITY_H_
-#include <mach/std_types.defs>
-#include <mach/mach_types.defs>
+extern void thread_quantum_update(
+ int mycpu,
+ thread_t thread,
+ int nticks,
+ int state);
-type vm_cache_statistics_data_t = struct[11] of integer_t;
-
-/*
- * Return page cache statistics for the host on which the target task
- * resides.
- */
-routine vm_cache_statistics(
- target_task : vm_task_t;
- out vm_cache_stats : vm_cache_statistics_data_t);
+#endif /* _KERN_PRIORITY_H_ */
diff --git a/kern/processor.c b/kern/processor.c
index 1986860..865c324 100644
--- a/kern/processor.c
+++ b/kern/processor.c
@@ -66,18 +66,11 @@ 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.
*/
void pset_sys_bootstrap(void)
{
- register int i;
+ int i;
pset_init(&default_pset);
default_pset.empty = FALSE;
@@ -109,8 +102,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 +131,7 @@ void pset_sys_init(void)
*/
void pset_init(
- register processor_set_t pset)
+ processor_set_t pset)
{
int i;
@@ -189,7 +182,7 @@ void pset_init(
*/
void processor_init(
- register processor_t pr,
+ processor_t pr,
int slot_num)
{
int i;
@@ -414,14 +407,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 +496,7 @@ void quantum_set(
processor_set_t pset)
{
#if NCPUS > 1
- register int i,ncpus;
+ int i, ncpus;
ncpus = pset->processor_count;
@@ -567,8 +560,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;
@@ -647,18 +640,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;
}
@@ -692,7 +679,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;
@@ -712,7 +699,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;
@@ -757,8 +744,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) {
@@ -828,8 +815,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) {
diff --git a/kern/processor.h b/kern/processor.h
index 9a6c944..b81526c 100644
--- a/kern/processor.h
+++ b/kern/processor.h
@@ -320,4 +320,10 @@ extern kern_return_t processor_set_threads(
natural_t *count);
#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_ */
diff --git a/kern/queue.c b/kern/queue.c
index 98b74c2..d9396e5 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;
diff --git a/kern/queue.h b/kern/queue.h
index 1846922..518084d 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) { \
@@ -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; \
diff --git a/kern/rbtree.h b/kern/rbtree.h
index 5a65d1e..f577f7e 100644
--- a/kern/rbtree.h
+++ b/kern/rbtree.h
@@ -32,7 +32,6 @@
#include <stddef.h>
#include <kern/assert.h>
#include <kern/macro_help.h>
-#include <kern/rbtree.h>
#include <sys/types.h>
#define structof(ptr, type, member) \
diff --git a/kern/refcount.h b/kern/refcount.h
index 7fd6cdf..74204d6 100644
--- a/kern/refcount.h
+++ b/kern/refcount.h
@@ -29,8 +29,6 @@
#include <kern/macro_help.h>
-#include "refcount.h" /*XXX*/
-
/* Unless the above include file specified otherwise,
use the system-independent (unoptimized) atomic reference counter. */
#ifndef MACHINE_REFCOUNT
@@ -65,6 +63,6 @@ typedef struct RefCount RefCount;
if (new_value == 0) { func; } \
MACRO_END
-#endif
+#endif /* MACHINE_REFCOUNT */
-#endif _KERN_REFCOUNT_H_
+#endif /* _KERN_REFCOUNT_H_ */
diff --git a/kern/sched.h b/kern/sched.h
index 942dd80..ea601c5 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, \
diff --git a/kern/sched_prim.c b/kern/sched_prim.c
index 46b5df4..66eb9c9 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
*
@@ -150,7 +140,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 +189,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 +205,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,12 +223,10 @@ void assert_wait(
event_t event,
boolean_t interruptible)
{
- register queue_t q;
- register int index;
- register thread_t thread;
-#if MACH_SLOCKS
- register simple_lock_t lock;
-#endif /* MACH_SLOCKS */
+ queue_t q;
+ int index;
+ thread_t thread;
+ decl_simple_lock_data( , *lock);
spl_t s;
thread = current_thread();
@@ -250,12 +238,10 @@ 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, (queue_entry_t) thread);
+ enqueue_tail(q, &(thread->links));
thread->wait_event = event;
if (interruptible)
thread->state |= TH_WAIT;
@@ -288,16 +274,14 @@ 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;
-#if MACH_SLOCKS
- register simple_lock_t lock;
-#endif /* MACH_SLOCKS */
- register event_t event;
+ int index;
+ queue_t q;
+ decl_simple_lock_data( , *lock);
+ event_t event;
spl_t s;
s = splsched();
@@ -316,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,
@@ -335,7 +317,7 @@ void clear_wait(
simple_unlock(lock);
}
if (event == 0) {
- register int state = thread->state;
+ int state = thread->state;
reset_timeout_check(&thread->timer);
@@ -376,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);
@@ -394,21 +376,17 @@ void thread_wakeup_prim(
boolean_t one_thread,
int result)
{
- register queue_t q;
- register int index;
- register thread_t thread, next_th;
-#if MACH_SLOCKS
- register simple_lock_t lock;
-#endif /* MACH_SLOCKS */
+ queue_t q;
+ int index;
+ thread_t thread, next_th;
+ decl_simple_lock_data( , *lock);
spl_t s;
- register int state;
+ 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)) {
@@ -490,8 +468,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;
@@ -509,9 +487,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 +501,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 +537,7 @@ thread_t thread_select(
}
}
else {
- register queue_t q;
+ queue_t q;
/*
* If there is a thread at hint, grab it,
@@ -622,9 +600,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 +807,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 +843,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 +884,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 +906,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 +1031,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 +1063,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 +1110,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 +1174,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) { \
@@ -1206,7 +1184,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 */ \
@@ -1220,7 +1198,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) { \
@@ -1229,7 +1207,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 */ \
@@ -1249,13 +1227,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 +1401,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 +1426,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 +1492,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 +1536,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;
@@ -1640,14 +1618,14 @@ int no_dispatch_count = 0;
* to execute.
*/
-void idle_thread_continue(void)
+void __attribute__((noreturn)) 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 +1724,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 +1775,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 +1878,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 +1942,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 {
@@ -2012,12 +1990,12 @@ void do_thread_scan(void)
#if DEBUG
void checkrq(
run_queue_t rq,
- char *msg)
+ const 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 +2026,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) {
diff --git a/kern/sched_prim.h b/kern/sched_prim.h
index 5311d16..fd989b6 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(void *param);
extern void update_priority(
thread_t thread);
extern void compute_my_priority(
@@ -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
@@ -132,13 +132,10 @@ extern void thread_timeout_setup(
* Machine-dependent code must define these functions.
*/
-extern void thread_bootstrap_return(void);
-extern void thread_exception_return(void);
-#ifdef __GNUC__
+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);
-#else
-extern void thread_syscall_return(kern_return_t);
-#endif
+
extern thread_t switch_context(
thread_t old_thread,
continuation_t continuation,
@@ -172,4 +169,16 @@ 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 */
+
+extern void idle_thread(void) __attribute__((noreturn));
+extern void sched_thread(void);
+
#endif /* _KERN_SCHED_PRIM_H_ */
diff --git a/kern/shuttle.h b/kern/shuttle.h
index e8e574b..0b1c2c5 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_ */
diff --git a/kern/slab.c b/kern/slab.c
index 47c2c8f..19ebfed 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.
@@ -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__, \
@@ -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:
@@ -702,9 +702,9 @@ 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 = optimal_embed;
+ int embed, optimal_embed = 0;
buf_size = cache->buf_size;
@@ -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;
@@ -1468,7 +1469,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)
diff --git a/kern/slab.h b/kern/slab.h
index b842fb7..c7be169 100644
--- a/kern/slab.h
+++ b/kern/slab.h
@@ -47,6 +47,7 @@
#ifndef _KERN_SLAB_H
#define _KERN_SLAB_H
+#include <cache.h>
#include <kern/lock.h>
#include <kern/list.h>
#include <kern/rbtree.h>
@@ -147,14 +148,20 @@ 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 32
+#define KMEM_CACHE_NAME_SIZE 24
/*
* 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
@@ -170,25 +177,27 @@ 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];
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.
diff --git a/kern/startup.c b/kern/startup.c
index 6dced43..71cd04d 100644
--- a/kern/startup.c
+++ b/kern/startup.c
@@ -47,43 +47,33 @@
#include <kern/thread_swap.h>
#include <kern/timer.h>
#include <kern/xpr.h>
+#include <kern/bootstrap.h>
#include <kern/time_stamp.h>
+#include <kern/startup.h>
#include <vm/vm_kern.h>
#include <vm/vm_map.h>
#include <vm/vm_object.h>
#include <vm/vm_page.h>
+#include <vm/vm_init.h>
+#include <vm/vm_pageout.h>
#include <machine/machspl.h>
#include <machine/pcb.h>
#include <machine/pmap.h>
#include <machine/model_dep.h>
#include <mach/version.h>
+#include <device/device_init.h>
-
-
-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_KDB
+#include <device/cons.h>
+#endif /* MACH_KDB */
#if ! MACH_KBD
-boolean_t reboot_on_panic = 1;
+boolean_t reboot_on_panic = TRUE;
#endif
#if NCPUS > 1
-extern void start_other_cpus();
-extern void action_thread();
+#include <machine/mp_desc.h>
+#include <kern/machine.h>
#endif /* NCPUS > 1 */
/* XX */
@@ -96,7 +86,7 @@ extern char *kernel_cmdline;
*
* Assumes that master_cpu is set.
*/
-void setup_main()
+void setup_main(void)
{
thread_t startup_thread;
@@ -113,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 */
@@ -165,7 +155,7 @@ void setup_main()
* Kick off the time-out driven routines by calling
* them the first time.
*/
- recompute_priorities();
+ recompute_priorities(NULL);
compute_mach_factor();
/*
@@ -208,9 +198,9 @@ 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)
{
- register int i;
+ int i;
/*
* Create the idle threads and the other
@@ -276,7 +266,7 @@ void start_kernel_threads()
}
#if NCPUS > 1
-void slave_main()
+void slave_main(void)
{
cpu_launch_first_thread(THREAD_NULL);
}
@@ -286,10 +276,9 @@ void slave_main()
* Start up the first thread on a CPU.
* First thread is specified for the master CPU.
*/
-void cpu_launch_first_thread(th)
- register thread_t th;
+void cpu_launch_first_thread(thread_t th)
{
- register int mycpu;
+ int mycpu;
mycpu = cpu_number();
diff --git a/include/mach/gnumach.defs b/kern/startup.h
similarity index 58%
copy from include/mach/gnumach.defs
copy to kern/startup.h
index 7331334..d924d15 100644
--- a/include/mach/gnumach.defs
+++ b/kern/startup.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 Free Software Foundation
+ * 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
@@ -16,24 +16,13 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-subsystem
-#if KERNEL_SERVER
- KernelServer
-#endif /* KERNEL_SERVER */
-#if KERNEL_USER
- KernelUser
-#endif /* KERNEL_USER */
- gnumach 4200;
+#ifndef _KERN_STARTUP_H_
+#define _KERN_STARTUP_H_
-#include <mach/std_types.defs>
-#include <mach/mach_types.defs>
+#include <kern/thread.h>
-type vm_cache_statistics_data_t = struct[11] of integer_t;
+extern void setup_main(void);
+void cpu_launch_first_thread(thread_t th);
+void start_kernel_threads(void);
-/*
- * Return page cache statistics for the host on which the target task
- * resides.
- */
-routine vm_cache_statistics(
- target_task : vm_task_t;
- out vm_cache_stats : vm_cache_statistics_data_t);
+#endif /* _KERN_STARTUP_H_ */
diff --git a/kern/strings.c b/kern/strings.c
index 3676f98..c77ae4f 100644
--- a/kern/strings.c
+++ b/kern/strings.c
@@ -53,12 +53,12 @@
* contents are identical upto the length of s1.
*/
-int
+int __attribute__ ((pure))
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++;
@@ -80,13 +80,13 @@ strcmp(
* comparison runs for at most "n" characters.
*/
-int
+int __attribute__ ((pure))
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--;
@@ -161,11 +161,11 @@ strncpy(
* the terminating null character.
*/
-size_t
+size_t __attribute__ ((pure))
strlen(
- register const char *string)
+ const char *string)
{
- register const char *ret = string;
+ const char *ret = string;
while (*string++ != '\0')
continue;
diff --git a/kern/syscall_emulation.c b/kern/syscall_emulation.c
index c1c3096..95e91d5 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)
{
}
@@ -68,10 +68,11 @@ void eml_init()
* vector.
*/
-void eml_task_reference(task, parent)
- task_t task, parent;
+void eml_task_reference(
+ task_t task,
+ task_t parent)
{
- register eml_dispatch_t eml;
+ eml_dispatch_t eml;
if (parent == TASK_NULL)
eml = EML_DISPATCH_NULL;
@@ -94,9 +95,9 @@ void eml_task_reference(task, parent)
*/
void eml_task_deallocate(task)
- task_t task;
+ const task_t task;
{
- register eml_dispatch_t eml;
+ eml_dispatch_t eml;
eml = task->eml_dispatch;
if (eml != EML_DISPATCH_NULL) {
@@ -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_emulation.h b/kern/syscall_emulation.h
index 501b0a8..bf20e44 100644
--- a/kern/syscall_emulation.h
+++ b/kern/syscall_emulation.h
@@ -33,6 +33,7 @@
#ifndef __ASSEMBLER__
#include <mach/machine/vm_types.h>
#include <kern/lock.h>
+#include <kern/task.h>
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/syscall_subr.c b/kern/syscall_subr.c
index ae2d7d7..3c369ef 100644
--- a/kern/syscall_subr.c
+++ b/kern/syscall_subr.c
@@ -48,8 +48,6 @@
#include <mach/policy.h>
#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).
@@ -63,12 +61,9 @@
* 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)
{
- register processor_t myprocessor;
+ processor_t myprocessor;
myprocessor = current_processor();
thread_syscall_return(myprocessor->runq.count > 0 ||
@@ -78,7 +73,7 @@ void swtch_continue(void)
boolean_t swtch(void)
{
- register processor_t myprocessor;
+ processor_t myprocessor;
#if NCPUS > 1
myprocessor = current_processor();
@@ -96,8 +91,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);
@@ -107,15 +102,10 @@ void swtch_pri_continue(void)
/*NOTREACHED*/
}
-boolean_t swtch_pri(pri)
- int pri;
+boolean_t swtch_pri(int pri)
{
- register thread_t thread = current_thread();
- register processor_t myprocessor;
-
-#ifdef lint
- pri++;
-#endif /* lint */
+ thread_t thread = current_thread();
+ processor_t myprocessor;
#if NCPUS > 1
myprocessor = current_processor();
@@ -142,7 +132,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
@@ -161,13 +151,13 @@ 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)
{
- register thread_t cur_thread = current_thread();
- register processor_t myprocessor;
+ thread_t cur_thread = current_thread();
+ processor_t myprocessor;
ipc_port_t port;
/*
@@ -208,8 +198,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;
/*
@@ -289,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)
-register 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;
@@ -327,8 +317,7 @@ mach_msg_timeout_t depress_time;
* Timeout routine for priority depression.
*/
void
-thread_depress_timeout(thread)
-register thread_t thread;
+thread_depress_timeout(thread_t thread)
{
spl_t s;
@@ -356,8 +345,7 @@ register thread_t thread;
* Prematurely abort priority depression if there is one.
*/
kern_return_t
-thread_depress_abort(thread)
-register thread_t thread;
+thread_depress_abort(thread_t thread)
{
spl_t s;
diff --git a/kern/syscall_subr.h b/kern/syscall_subr.h
index a2e3920..b6b61ab 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_ */
diff --git a/kern/syscall_sw.c b/kern/syscall_sw.c
index 607d843..a383e46 100644
--- a/kern/syscall_sw.c
+++ b/kern/syscall_sw.c
@@ -36,6 +36,8 @@
#include <mach/mach_traps.h>
#include <mach/message.h>
#include <kern/syscall_subr.h>
+#include <kern/ipc_mig.h>
+#include <kern/eventcount.h>
#include <ipc/mach_port.h>
@@ -56,41 +58,20 @@
* the positive numbers) are reserved for Unix.
*/
-int kern_invalid_debug = 0;
+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);
}
-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 */
diff --git a/kern/task.c b/kern/task.c
index 114dd31..20acc6a 100644
--- a/kern/task.c
+++ b/kern/task.c
@@ -37,6 +37,7 @@
#include <mach/vm_param.h>
#include <mach/task_info.h>
#include <mach/task_special_ports.h>
+#include <mach_debug/mach_debug_types.h>
#include <ipc/ipc_space.h>
#include <ipc/ipc_types.h>
#include <kern/debug.h>
@@ -45,18 +46,16 @@
#include <kern/slab.h>
#include <kern/kalloc.h>
#include <kern/processor.h>
+#include <kern/printf.h>
#include <kern/sched_prim.h> /* for thread_wakeup */
#include <kern/ipc_tt.h>
+#include <kern/syscall_emulation.h>
#include <vm/vm_kern.h> /* for kernel_map, ipc_kernel_map */
#include <machine/machspl.h> /* 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,
@@ -71,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(
@@ -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
@@ -167,6 +167,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;
@@ -181,10 +183,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 +212,7 @@ void task_deallocate(
}
void task_reference(
- register task_t task)
+ task_t task)
{
if (task == TASK_NULL)
return;
@@ -227,11 +229,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 +404,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 +443,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 +495,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 +626,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 +677,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 +719,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 +758,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;
@@ -764,7 +766,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;
@@ -772,7 +774,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;
@@ -780,8 +782,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 +839,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 +1057,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) {
@@ -1071,6 +1073,22 @@ task_priority(
}
/*
+ * 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:
*
* Attempt to free resources owned by tasks.
@@ -1078,7 +1096,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;
@@ -1209,6 +1227,6 @@ task_ras_control(
break;
}
task_unlock(task);
-#endif
+#endif /* FAST_TAS */
return ret;
}
diff --git a/kern/task.h b/kern/task.h
index 9bfea57..3c10dc0 100644
--- a/kern/task.h
+++ b/kern/task.h
@@ -39,6 +39,7 @@
#include <mach/time_value.h>
#include <mach/mach_param.h>
#include <mach/task_info.h>
+#include <mach_debug/mach_debug_types.h>
#include <kern/kern_types.h>
#include <kern/lock.h>
#include <kern/queue.h>
@@ -48,11 +49,22 @@
#include <vm/vm_types.h>
#include <machine/task.h>
+/*
+ * 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 */
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 +75,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 */
@@ -111,6 +121,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)
@@ -158,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);
/*
diff --git a/kern/thread.c b/kern/thread.c
index 79f526a..8474950 100644
--- a/kern/thread.c
+++ b/kern/thread.c
@@ -57,9 +57,11 @@
#include <kern/slab.h>
#include <kern/mach_clock.h>
#include <vm/vm_kern.h>
+#include <vm/vm_user.h>
#include <ipc/ipc_kmsg.h>
#include <ipc/ipc_port.h>
#include <ipc/mach_msg.h>
+#include <ipc/mach_port.h>
#include <machine/machspl.h> /* for splsched */
#include <machine/pcb.h>
#include <machine/thread.h> /* for MACHINE_STACK */
@@ -72,15 +74,10 @@ 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;
#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)
@@ -149,7 +146,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 +227,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 +250,7 @@ void stack_free(
void stack_collect(void)
{
- register vm_offset_t stack;
+ vm_offset_t stack;
spl_t s;
s = splsched();
@@ -285,7 +282,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 +395,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 +572,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 +707,7 @@ void thread_deallocate(
}
void thread_reference(
- register thread_t thread)
+ thread_t thread)
{
spl_t s;
@@ -744,10 +741,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)
@@ -850,6 +847,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:
*
@@ -859,7 +878,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 +920,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)
@@ -1104,7 +1123,7 @@ kern_return_t thread_halt(
}
}
-void walking_zombie(void)
+void __attribute__((noreturn)) walking_zombie(void)
{
panic("the zombie walks!");
}
@@ -1115,7 +1134,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) {
@@ -1130,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);
@@ -1169,7 +1188,7 @@ void thread_halt_self(void)
* suspends is maintained.
*/
void thread_hold(
- register thread_t thread)
+ thread_t thread)
{
spl_t s;
@@ -1191,11 +1210,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 +1314,7 @@ thread_dowait(
}
void thread_release(
- register thread_t thread)
+ thread_t thread)
{
spl_t s;
@@ -1314,9 +1333,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 +1379,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 +1417,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 +1441,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 +1462,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 +1474,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 +1560,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 +1602,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;
@@ -1674,10 +1693,10 @@ 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 (;;) {
- register thread_t thread;
+ thread_t thread;
spl_t s;
s = splsched();
@@ -1792,12 +1811,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 +2119,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 +2323,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 +2340,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 +2356,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 +2449,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 +2568,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) {
diff --git a/kern/thread.h b/kern/thread.h
index 3959dfc..d088c27 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(
@@ -338,14 +345,12 @@ 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),
void * arg);
-extern void reaper_thread(void);
+extern void reaper_thread(void) __attribute__((noreturn));
#if MACH_HOST
extern void thread_freeze(
@@ -384,4 +389,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_ */
diff --git a/kern/thread_swap.c b/kern/thread_swap.c
index f29bd5b..dc2924a 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:
@@ -97,7 +96,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;
@@ -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)
- register thread_t thread;
+void thread_doswapin(thread_t thread)
{
spl_t s;
@@ -154,10 +152,10 @@ 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 (;;) {
- register thread_t thread;
+ thread_t thread;
spl_t s;
s = splsched();
diff --git a/kern/thread_swap.h b/kern/thread_swap.h
index 3113030..9d64537 100644
--- a/kern/thread_swap.h
+++ b/kern/thread_swap.h
@@ -38,7 +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 thread_swapout(thread_t thread);
+extern void swapin_thread(void) __attribute__((noreturn));
#endif /* _KERN_THREAD_SWAP_H_ */
diff --git a/kern/time_stamp.c b/kern/time_stamp.c
index 22885b1..ee141a0 100644
--- a/kern/time_stamp.c
+++ b/kern/time_stamp.c
@@ -32,31 +32,18 @@
/*
* ts.c - kern_timestamp system call.
*/
-#ifdef multimax
-#include <mmax/timer.h>
-#endif /* multimax */
-
-
-
kern_return_t
-kern_timestamp(tsp)
-struct tsval *tsp;
+kern_timestamp(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,
+ if (copyout(&temp,
+ tsp,
sizeof(struct tsval)) != KERN_SUCCESS)
return(KERN_INVALID_ADDRESS);
return(KERN_SUCCESS);
@@ -66,10 +53,7 @@ struct tsval *tsp;
* Initialization procedure.
*/
-void timestamp_init()
+void timestamp_init(void)
{
-#ifdef multimax
-#else /* multimax */
ts_tick_count = 0;
-#endif /* multimax */
}
diff --git a/kern/timer.c b/kern/timer.c
index ec0524a..6d6517e 100644
--- a/kern/timer.c
+++ b/kern/timer.c
@@ -40,17 +40,15 @@
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
* serviced by the callout routine once an hour.
*/
-void init_timers()
+void init_timers(void)
{
- register int i;
- register timer_t this_timer;
+ int i;
+ timer_t this_timer;
/*
* Initialize all the kernel timers and start the one
@@ -68,9 +66,7 @@ void init_timers()
/*
* timer_init initializes a single timer.
*/
-void timer_init(this_timer)
-register
-timer_t this_timer;
+void timer_init(timer_t this_timer)
{
this_timer->low_bits = 0;
this_timer->high_bits = 0;
@@ -94,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;
@@ -108,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;
@@ -150,7 +144,7 @@ unsigned ts;
* user mode.
*/
void
-time_trap_uexit(ts)
+time_trap_uexit(int ts)
{
int elapsed;
int mycpu;
@@ -194,9 +188,9 @@ time_trap_uexit(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;
@@ -235,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;
@@ -282,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;
@@ -328,9 +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)
-register
-timer_t timer;
+void timer_normalize(timer_t timer)
{
unsigned int high_increment;
@@ -356,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;
@@ -390,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 */
@@ -409,10 +400,9 @@ timer_save_t save;
*/
void
-timer_read(timer, tv)
-timer_t timer;
-register
-time_value_t *tv;
+timer_read(
+ timer_t timer,
+ time_value_t *tv)
{
timer_save_data_t temp;
@@ -436,13 +426,13 @@ 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;
- register timer_t timer;
+ timer_t timer;
timer = &thread->user_timer;
timer_grab(timer, &temp);
@@ -470,13 +460,13 @@ 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;
- register timer_t timer;
+ timer_t timer;
timer = &thread->user_timer;
db_timer_grab(timer, &temp);
@@ -505,13 +495,12 @@ 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;
+timer_delta(
+ 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 +
diff --git a/kern/timer.h b/kern/timer.h
index 817fa35..57f017a 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) { \
@@ -182,4 +182,6 @@ MACRO_END
extern void init_timers(void);
+void timer_init(timer_t this_timer);
+
#endif /* _KERN_TIMER_H_ */
diff --git a/kern/xpr.c b/kern/xpr.c
index 465ba7b..46cb227 100644
--- a/kern/xpr.c
+++ b/kern/xpr.c
@@ -56,12 +56,16 @@ 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)
{
- 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))
@@ -115,7 +119,7 @@ void xprbootstrap(void)
* the previous buffer contents.
*/
- memset((char *) addr, 0, size);
+ memset((void *) addr, 0, size);
}
xprbase = (struct xprbuf *) addr;
@@ -132,9 +136,8 @@ void xprinit(void)
#if MACH_KDB
#include <machine/setjmp.h>
+#include <ddb/db_output.h>
-
-extern void db_printf();
extern jmp_buf_t *db_recover;
/*
@@ -145,16 +148,16 @@ 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;
struct xprbuf *last, *ptr;
- register struct xprbuf *x;
+ struct xprbuf *x;
int i;
- spl_t s;
+ spl_t s = s;
if (base == 0) {
base = xprbase;
diff --git a/linux/Makefrag.am b/linux/Makefrag.am
index 52d91d0..0973f11 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 \
diff --git a/linux/dev/drivers/block/ahci.c b/linux/dev/drivers/block/ahci.c
index 2c573ac..2b348e6 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<<PARTN_BITS)-1)
/* We need to use one DMA scatter element per physical page.
@@ -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;
}
}
diff --git a/linux/dev/drivers/block/floppy.c b/linux/dev/drivers/block/floppy.c
index 4c0977a..83d66f0 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 011b6f5..79a3646 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++)
@@ -1703,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;
diff --git a/linux/dev/include/linux/blk.h b/linux/dev/include/linux/blk.h
index 412b864..156d91c 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 e9a40d7..5bf0a28 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 740ebb5..37f7173 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);
diff --git a/linux/src/drivers/block/ide-cd.c b/linux/src/drivers/block/ide-cd.c
index e4548f5..020a831 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);
@@ -2638,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;
}
}
diff --git a/linux/src/drivers/block/ide.c b/linux/src/drivers/block/ide.c
index 0f3fd01..9b9ecc2 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;
}
/*
diff --git a/linux/src/drivers/net/sundance.c b/linux/src/drivers/net/sundance.c
index 47f32eb..3723164 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;
diff --git a/linux/src/drivers/net/tlan.c b/linux/src/drivers/net/tlan.c
index 11e12bb..fedc11f 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 5178ccf..da139ce 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
new file mode 100644
index 0000000..8d2f102
--- /dev/null
+++ b/linux/src/drivers/scsi/FlashPoint.c
@@ -0,0 +1,12156 @@
+/*
+
+ FlashPoint.c -- FlashPoint SCCB Manager for Linux
+
+ This file contains the FlashPoint SCCB Manager from BusLogic's FlashPoint
+ Driver Developer's Kit, with minor modifications by Leonard N. Zubkoff for
+ Linux compatibility. It was provided by BusLogic in the form of 16 separate
+ source files, which would have unnecessarily cluttered the scsi directory, so
+ the individual files have been combined into this single file.
+
+ Copyright 1995-1996 by Mylex Corporation. All Rights Reserved
+
+ This file is available under both the GNU General Public License
+ and a BSD-style copyright; see LICENSE.FlashPoint for details.
+
+*/
+
+
+#include <linux/config.h>
+
+
+#ifndef CONFIG_SCSI_OMIT_FLASHPOINT
+
+
+#define UNIX
+#define FW_TYPE _SCCB_MGR_
+#define MAX_CARDS 8
+#undef BUSTYPE_PCI
+
+
+#define OS_InPortByte(port) inb(port)
+#define OS_InPortWord(port) inw(port)
+#define OS_InPortLong(port) inl(port)
+#define OS_OutPortByte(port, value) outb(value, port)
+#define OS_OutPortWord(port, value) outw(value, port)
+#define OS_OutPortLong(port, value) outl(value, port)
+#define OS_Lock(x)
+#define OS_UnLock(x)
+
+
+/*
+ Define name replacements for compatibility with the Linux BusLogic Driver.
+*/
+
+#define SccbMgr_sense_adapter FlashPoint_ProbeHostAdapter
+#define SccbMgr_config_adapter FlashPoint_HardwareResetHostAdapter
+#define SccbMgr_unload_card FlashPoint_ReleaseHostAdapter
+#define SccbMgr_start_sccb FlashPoint_StartCCB
+#define SccbMgr_abort_sccb FlashPoint_AbortCCB
+#define SccbMgr_my_int FlashPoint_InterruptPending
+#define SccbMgr_isr FlashPoint_HandleInterrupt
+
+
+/*
+ Define name replacements to avoid kernel namespace pollution.
+*/
+
+#define BL_Card FPT_BL_Card
+#define BusMasterInit FPT_BusMasterInit
+#define CalcCrc16 FPT_CalcCrc16
+#define CalcLrc FPT_CalcLrc
+#define ChkIfChipInitialized FPT_ChkIfChipInitialized
+#define DiagBusMaster FPT_DiagBusMaster
+#define DiagEEPROM FPT_DiagEEPROM
+#define DiagXbow FPT_DiagXbow
+#define GetTarLun FPT_GetTarLun
+#define RNVRamData FPT_RNVRamData
+#define RdStack FPT_RdStack
+#define SccbMgrTableInitAll FPT_SccbMgrTableInitAll
+#define SccbMgrTableInitCard FPT_SccbMgrTableInitCard
+#define SccbMgrTableInitTarget FPT_SccbMgrTableInitTarget
+#define SccbMgr_bad_isr FPT_SccbMgr_bad_isr
+#define SccbMgr_scsi_reset FPT_SccbMgr_scsi_reset
+#define SccbMgr_timer_expired FPT_SccbMgr_timer_expired
+#define SendMsg FPT_SendMsg
+#define Wait FPT_Wait
+#define Wait1Second FPT_Wait1Second
+#define WrStack FPT_WrStack
+#define XbowInit FPT_XbowInit
+#define autoCmdCmplt FPT_autoCmdCmplt
+#define autoLoadDefaultMap FPT_autoLoadDefaultMap
+#define busMstrDataXferStart FPT_busMstrDataXferStart
+#define busMstrSGDataXferStart FPT_busMstrSGDataXferStart
+#define busMstrTimeOut FPT_busMstrTimeOut
+#define dataXferProcessor FPT_dataXferProcessor
+#define default_intena FPT_default_intena
+#define hostDataXferAbort FPT_hostDataXferAbort
+#define hostDataXferRestart FPT_hostDataXferRestart
+#define inisci FPT_inisci
+#define mbCards FPT_mbCards
+#define nvRamInfo FPT_nvRamInfo
+#define phaseBusFree FPT_phaseBusFree
+#define phaseChkFifo FPT_phaseChkFifo
+#define phaseCommand FPT_phaseCommand
+#define phaseDataIn FPT_phaseDataIn
+#define phaseDataOut FPT_phaseDataOut
+#define phaseDecode FPT_phaseDecode
+#define phaseIllegal FPT_phaseIllegal
+#define phaseMsgIn FPT_phaseMsgIn
+#define phaseMsgOut FPT_phaseMsgOut
+#define phaseStatus FPT_phaseStatus
+#define queueAddSccb FPT_queueAddSccb
+#define queueCmdComplete FPT_queueCmdComplete
+#define queueDisconnect FPT_queueDisconnect
+#define queueFindSccb FPT_queueFindSccb
+#define queueFlushSccb FPT_queueFlushSccb
+#define queueFlushTargSccb FPT_queueFlushTargSccb
+#define queueSearchSelect FPT_queueSearchSelect
+#define queueSelectFail FPT_queueSelectFail
+#define s_PhaseTbl FPT_s_PhaseTbl
+#define scamHAString FPT_scamHAString
+#define scamInfo FPT_scamInfo
+#define scarb FPT_scarb
+#define scasid FPT_scasid
+#define scbusf FPT_scbusf
+#define sccbMgrTbl FPT_sccbMgrTbl
+#define schkdd FPT_schkdd
+#define scini FPT_scini
+#define sciso FPT_sciso
+#define scmachid FPT_scmachid
+#define scsavdi FPT_scsavdi
+#define scsel FPT_scsel
+#define scsell FPT_scsell
+#define scsendi FPT_scsendi
+#define scvalq FPT_scvalq
+#define scwirod FPT_scwirod
+#define scwiros FPT_scwiros
+#define scwtsel FPT_scwtsel
+#define scxferc FPT_scxferc
+#define sdecm FPT_sdecm
+#define sfm FPT_sfm
+#define shandem FPT_shandem
+#define sinits FPT_sinits
+#define sisyncn FPT_sisyncn
+#define sisyncr FPT_sisyncr
+#define siwidn FPT_siwidn
+#define siwidr FPT_siwidr
+#define sres FPT_sres
+#define sresb FPT_sresb
+#define ssel FPT_ssel
+#define ssenss FPT_ssenss
+#define sssyncv FPT_sssyncv
+#define stsyncn FPT_stsyncn
+#define stwidn FPT_stwidn
+#define sxfrp FPT_sxfrp
+#define utilEERead FPT_utilEERead
+#define utilEEReadOrg FPT_utilEEReadOrg
+#define utilEESendCmdAddr FPT_utilEESendCmdAddr
+#define utilEEWrite FPT_utilEEWrite
+#define utilEEWriteOnOff FPT_utilEEWriteOnOff
+#define utilUpdateResidual FPT_utilUpdateResidual
+
+
+/*----------------------------------------------------------------------
+ *
+ *
+ * Copyright 1995-1996 by Mylex Corporation. All Rights Reserved
+ *
+ * This file is available under both the GNU General Public License
+ * and a BSD-style copyright; see LICENSE.FlashPoint for details.
+ *
+ * $Workfile: globals.h $
+ *
+ * Description: Common shared global defines.
+ *
+ * $Date: 1999/04/26 05:53:56 $
+ *
+ * $Revision: 1.1 $
+ *
+ *----------------------------------------------------------------------*/
+#ifndef __GLOBALS_H__
+#define __GLOBALS_H__
+
+#define _UCB_MGR_ 1
+#define _SCCB_MGR_ 2
+
+/*#include <osflags.h>*/
+
+#define MAX_CDBLEN 12
+
+#define SCAM_LEV_2 1
+
+#define CRCMASK 0xA001
+
+/* In your osflags.h file, please ENSURE that only ONE OS FLAG
+ is on at a time !!! Also, please make sure you turn set the
+ variable FW_TYPE to either _UCB_MGR_ or _SCCB_MGR_ !!! */
+
+#if defined(DOS) || defined(WIN95_16) || defined(OS2) || defined(OTHER_16)
+ #define COMPILER_16_BIT 1
+#elif defined(NETWARE) || defined(NT) || defined(WIN95_32) || defined(UNIX) ||
defined(OTHER_32) || defined(SOLARIS_REAL_MODE)
+ #define COMPILER_32_BIT 1
+#endif
+
+
+#define BL_VENDOR_ID 0x104B
+#define FP_DEVICE_ID 0x8130
+#define MM_DEVICE_ID 0x1040
+
+
+#ifndef FALSE
+#define FALSE 0
+#endif
+#ifndef TRUE
+#define TRUE (!(FALSE))
+#endif
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+#define FAILURE 0xFFFFFFFFL
+
+
+typedef unsigned char UCHAR;
+typedef unsigned short USHORT;
+typedef unsigned int UINT;
+typedef unsigned long ULONG;
+typedef unsigned char * PUCHAR;
+typedef unsigned short* PUSHORT;
+typedef unsigned long * PULONG;
+typedef void * PVOID;
+
+
+#if defined(COMPILER_16_BIT)
+typedef unsigned char far * uchar_ptr;
+typedef unsigned short far * ushort_ptr;
+typedef unsigned long far * ulong_ptr;
+#endif /* 16_BIT_COMPILER */
+
+#if defined(COMPILER_32_BIT)
+typedef unsigned char * uchar_ptr;
+typedef unsigned short * ushort_ptr;
+typedef unsigned long * ulong_ptr;
+#endif /* 32_BIT_COMPILER */
+
+
+/* NEW TYPE DEFINITIONS (shared with Mylex North)
+
+** Use following type defines to avoid confusion in 16 and 32-bit
+** environments. Avoid using 'int' as it denotes 16 bits in 16-bit
+** environment and 32 in 32-bit environments.
+
+*/
+
+#define s08bits char
+#define s16bits short
+#define s32bits long
+
+#define u08bits unsigned s08bits
+#define u16bits unsigned s16bits
+#define u32bits unsigned s32bits
+
+#if defined(COMPILER_16_BIT)
+
+typedef u08bits far * pu08bits;
+typedef u16bits far * pu16bits;
+typedef u32bits far * pu32bits;
+
+#endif /* COMPILER_16_BIT */
+
+#if defined(COMPILER_32_BIT)
+
+typedef u08bits * pu08bits;
+typedef u16bits * pu16bits;
+typedef u32bits * pu32bits;
+
+#endif /* COMPILER_32_BIT */
+
+
+#define BIT(x) ((UCHAR)(1<<(x))) /* single-bit mask in bit
position x */
+#define BITW(x) ((USHORT)(1<<(x))) /* single-bit mask in bit
position x */
+
+
+
+#if defined(DOS)
+/*#include <dos.h>*/
+ #undef inportb /* undefine for Borland Lib */
+ #undef inport /* they may have define I/O function in LIB */
+ #undef outportb
+ #undef outport
+
+ #define OS_InPortByte(ioport) inportb(ioport)
+ #define OS_InPortWord(ioport) inport(ioport)
+ #define OS_InPortLong(ioport) inportq(ioport, val)
+ #define OS_OutPortByte(ioport, val) outportb(ioport, val)
+ #define OS_OutPortWord(ioport, val) outport(ioport, val)
+ #define OS_OutPortLong(ioport) outportq(ioport, val)
+#endif /* DOS */
+
+#if defined(NETWARE) || defined(OTHER_32) || defined(OTHER_16)
+ extern u08bits OS_InPortByte(u32bits ioport);
+ extern u16bits OS_InPortWord(u32bits ioport);
+ extern u32bits OS_InPortLong(u32bits ioport);
+
+ extern OS_InPortByteBuffer(u32bits ioport, pu08bits buffer, u32bits
count);
+ extern OS_InPortWordBuffer(u32bits ioport, pu16bits buffer, u32bits
count);
+ extern OS_OutPortByte(u32bits ioport, u08bits val);
+ extern OS_OutPortWord(u32bits ioport, u16bits val);
+ extern OS_OutPortLong(u32bits ioport, u32bits val);
+ extern OS_OutPortByteBuffer(u32bits ioport, pu08bits buffer, u32bits
count);
+ extern OS_OutPortWordBuffer(u32bits ioport, pu16bits buffer, u32bits
count);
+#endif /* NETWARE || OTHER_32 || OTHER_16 */
+
+#if defined (NT) || defined(WIN95_32) || defined(WIN95_16)
+ #if defined(NT)
+
+ extern __declspec(dllimport) u08bits
ScsiPortReadPortUchar(pu08bits ioport);
+ extern __declspec(dllimport) u16bits
ScsiPortReadPortUshort(pu16bits ioport);
+ extern __declspec(dllimport) u32bits
ScsiPortReadPortUlong(pu32bits ioport);
+ extern __declspec(dllimport) void
ScsiPortWritePortUchar(pu08bits ioport, u08bits val);
+ extern __declspec(dllimport) void
ScsiPortWritePortUshort(pu16bits port, u16bits val);
+ extern __declspec(dllimport) void
ScsiPortWritePortUlong(pu32bits port, u32bits val);
+
+ #else
+
+ extern u08bits ScsiPortReadPortUchar(pu08bits ioport);
+ extern u16bits ScsiPortReadPortUshort(pu16bits ioport);
+ extern u32bits ScsiPortReadPortUlong(pu32bits ioport);
+ extern void ScsiPortWritePortUchar(pu08bits ioport, u08bits
val);
+ extern void ScsiPortWritePortUshort(pu16bits port, u16bits val);
+ extern void ScsiPortWritePortUlong(pu32bits port, u32bits val);
+ #endif
+
+
+ #define OS_InPortByte(ioport) ScsiPortReadPortUchar((pu08bits) ioport)
+ #define OS_InPortWord(ioport) ScsiPortReadPortUshort((pu16bits) ioport)
+ #define OS_InPortLong(ioport) ScsiPortReadPortUlong((pu32bits) ioport)
+
+ #define OS_OutPortByte(ioport, val) ScsiPortWritePortUchar((pu08bits)
ioport, (u08bits) val)
+ #define OS_OutPortWord(ioport, val) ScsiPortWritePortUshort((pu16bits)
ioport, (u16bits) val)
+ #define OS_OutPortLong(ioport, val) ScsiPortWritePortUlong((pu32bits)
ioport, (u32bits) val)
+ #define OS_OutPortByteBuffer(ioport, buffer, count) \
+ ScsiPortWritePortBufferUchar((pu08bits)&port, (pu08bits)
buffer, (u32bits) count)
+ #define OS_OutPortWordBuffer(ioport, buffer, count) \
+ ScsiPortWritePortBufferUshort((pu16bits)&port, (pu16bits)
buffer, (u32bits) count)
+
+ #define OS_Lock(x)
+ #define OS_UnLock(x)
+#endif /* NT || WIN95_32 || WIN95_16 */
+
+#if defined (UNIX) && !defined(OS_InPortByte)
+ #define OS_InPortByte(ioport) inb((u16bits)ioport)
+ #define OS_InPortWord(ioport) inw((u16bits)ioport)
+ #define OS_InPortLong(ioport) inl((u16bits)ioport)
+ #define OS_OutPortByte(ioport,val) outb((u16bits)ioport, (u08bits)val)
+ #define OS_OutPortWord(ioport,val) outw((u16bits)ioport, (u16bits)val)
+ #define OS_OutPortLong(ioport,val) outl((u16bits)ioport, (u32bits)val)
+
+ #define OS_Lock(x)
+ #define OS_UnLock(x)
+#endif /* UNIX */
+
+
+#if defined(OS2)
+ extern u08bits inb(u32bits ioport);
+ extern u16bits inw(u32bits ioport);
+ extern void outb(u32bits ioport, u08bits val);
+ extern void outw(u32bits ioport, u16bits val);
+
+ #define OS_InPortByte(ioport) inb(ioport)
+ #define OS_InPortWord(ioport) inw(ioport)
+ #define OS_OutPortByte(ioport, val) outb(ioport, val)
+ #define OS_OutPortWord(ioport, val) outw(ioport, val)
+ extern u32bits OS_InPortLong(u32bits ioport);
+ extern void OS_OutPortLong(u32bits ioport, u32bits val);
+
+ #define OS_Lock(x)
+ #define OS_UnLock(x)
+#endif /* OS2 */
+
+#if defined(SOLARIS_REAL_MODE)
+
+extern unsigned char inb(unsigned long ioport);
+extern unsigned short inw(unsigned long ioport);
+
+#define OS_InPortByte(ioport) inb(ioport)
+#define OS_InPortWord(ioport) inw(ioport)
+
+extern void OS_OutPortByte(unsigned long ioport, unsigned char val);
+extern void OS_OutPortWord(unsigned long ioport, unsigned short val);
+extern unsigned long OS_InPortLong(unsigned long ioport);
+extern void OS_OutPortLong(unsigned long ioport, unsigned long val);
+
+#define OS_Lock(x)
+#define OS_UnLock(x)
+
+#endif /* SOLARIS_REAL_MODE */
+
+#endif /* __GLOBALS_H__ */
+
+/*----------------------------------------------------------------------
+ *
+ *
+ * Copyright 1995-1996 by Mylex Corporation. All Rights Reserved
+ *
+ * This file is available under both the GNU General Public License
+ * and a BSD-style copyright; see LICENSE.FlashPoint for details.
+ *
+ * $Workfile: sccbmgr.h $
+ *
+ * Description: Common shared SCCB Interface defines and SCCB
+ * Manager specifics defines.
+ *
+ * $Date: 1999/04/26 05:53:56 $
+ *
+ * $Revision: 1.1 $
+ *
+ *----------------------------------------------------------------------*/
+
+#ifndef __SCCB_H__
+#define __SCCB_H__
+
+/*#include <osflags.h>*/
+/*#include <globals.h>*/
+
+#if defined(BUGBUG)
+#define debug_size 32
+#endif
+
+#if defined(DOS)
+
+ typedef struct _SCCB near *PSCCB;
+ #if (FW_TYPE == _SCCB_MGR_)
+ typedef void (*CALL_BK_FN)(PSCCB);
+ #endif
+
+#elif defined(OS2)
+
+ typedef struct _SCCB far *PSCCB;
+ #if (FW_TYPE == _SCCB_MGR_)
+ typedef void (far *CALL_BK_FN)(PSCCB);
+ #endif
+
+#else
+
+ typedef struct _SCCB *PSCCB;
+ #if (FW_TYPE == _SCCB_MGR_)
+ typedef void (*CALL_BK_FN)(PSCCB);
+ #endif
+
+#endif
+
+
+typedef struct SCCBMgr_info {
+ ULONG si_baseaddr;
+ UCHAR si_present;
+ UCHAR si_intvect;
+ UCHAR si_id;
+ UCHAR si_lun;
+ USHORT si_fw_revision;
+ USHORT si_per_targ_init_sync;
+ USHORT si_per_targ_fast_nego;
+ USHORT si_per_targ_ultra_nego;
+ USHORT si_per_targ_no_disc;
+ USHORT si_per_targ_wide_nego;
+ USHORT si_flags;
+ UCHAR si_card_family;
+ UCHAR si_bustype;
+ UCHAR si_card_model[3];
+ UCHAR si_relative_cardnum;
+ UCHAR si_reserved[4];
+ ULONG si_OS_reserved;
+ UCHAR si_XlatInfo[4];
+ ULONG si_reserved2[5];
+ ULONG si_secondary_range;
+} SCCBMGR_INFO;
+
+#if defined(DOS)
+ typedef SCCBMGR_INFO * PSCCBMGR_INFO;
+#else
+ #if defined (COMPILER_16_BIT)
+ typedef SCCBMGR_INFO far * PSCCBMGR_INFO;
+ #else
+ typedef SCCBMGR_INFO * PSCCBMGR_INFO;
+ #endif
+#endif // defined(DOS)
+
+
+
+
+#if (FW_TYPE==_SCCB_MGR_)
+ #define SCSI_PARITY_ENA 0x0001
+ #define LOW_BYTE_TERM 0x0010
+ #define HIGH_BYTE_TERM 0x0020
+ #define BUSTYPE_PCI 0x3
+#endif
+
+#define SUPPORT_16TAR_32LUN 0x0002
+#define SOFT_RESET 0x0004
+#define EXTENDED_TRANSLATION 0x0008
+#define POST_ALL_UNDERRRUNS 0x0040
+#define FLAG_SCAM_ENABLED 0x0080
+#define FLAG_SCAM_LEVEL2 0x0100
+
+
+
+
+#define HARPOON_FAMILY 0x02
+
+
+#define ISA_BUS_CARD 0x01
+#define EISA_BUS_CARD 0x02
+#define PCI_BUS_CARD 0x03
+#define VESA_BUS_CARD 0x04
+
+/* SCCB struc used for both SCCB and UCB manager compiles!
+ * The UCB Manager treats the SCCB as it's 'native hardware structure'
+ */
+
+
+#pragma pack(1)
+typedef struct _SCCB {
+ UCHAR OperationCode;
+ UCHAR ControlByte;
+ UCHAR CdbLength;
+ UCHAR RequestSenseLength;
+ ULONG DataLength;
+ ULONG DataPointer;
+ UCHAR CcbRes[2];
+ UCHAR HostStatus;
+ UCHAR TargetStatus;
+ UCHAR TargID;
+ UCHAR Lun;
+ UCHAR Cdb[12];
+ UCHAR CcbRes1;
+ UCHAR Reserved1;
+ ULONG Reserved2;
+ ULONG SensePointer;
+
+
+ CALL_BK_FN SccbCallback; /* VOID (*SccbCallback)(); */
+ ULONG SccbIOPort; /* Identifies board base port */
+ UCHAR SccbStatus;
+ UCHAR SCCBRes2;
+ USHORT SccbOSFlags;
+
+
+ ULONG Sccb_XferCnt; /* actual transfer count */
+ ULONG Sccb_ATC;
+ ULONG SccbVirtDataPtr; /* virtual addr for OS/2 */
+ ULONG Sccb_res1;
+ USHORT Sccb_MGRFlags;
+ USHORT Sccb_sgseg;
+ UCHAR Sccb_scsimsg; /* identify msg for selection */
+ UCHAR Sccb_tag;
+ UCHAR Sccb_scsistat;
+ UCHAR Sccb_idmsg; /* image of last msg in */
+ PSCCB Sccb_forwardlink;
+ PSCCB Sccb_backlink;
+ ULONG Sccb_savedATC;
+ UCHAR Save_Cdb[6];
+ UCHAR Save_CdbLen;
+ UCHAR Sccb_XferState;
+ ULONG Sccb_SGoffset;
+#if (FW_TYPE == _UCB_MGR_)
+ PUCB Sccb_ucb_ptr;
+#endif
+ } SCCB;
+
+#define SCCB_SIZE sizeof(SCCB)
+
+#pragma pack()
+
+
+
+#define SCSI_INITIATOR_COMMAND 0x00
+#define TARGET_MODE_COMMAND 0x01
+#define SCATTER_GATHER_COMMAND 0x02
+#define RESIDUAL_COMMAND 0x03
+#define RESIDUAL_SG_COMMAND 0x04
+#define RESET_COMMAND 0x81
+
+
+#define F_USE_CMD_Q 0x20 /*Inidcates TAGGED command. */
+#define TAG_TYPE_MASK 0xC0 /*Type of tag msg to send. */
+#define TAG_Q_MASK 0xE0
+#define SCCB_DATA_XFER_OUT 0x10 /* Write */
+#define SCCB_DATA_XFER_IN 0x08 /* Read */
+
+
+#define FOURTEEN_BYTES 0x00 /* Request Sense Buffer size */
+#define NO_AUTO_REQUEST_SENSE 0x01 /* No Request Sense Buffer */
+
+
+#define BUS_FREE_ST 0
+#define SELECT_ST 1
+#define SELECT_BDR_ST 2 /* Select w\ Bus Device Reset */
+#define SELECT_SN_ST 3 /* Select w\ Sync Nego */
+#define SELECT_WN_ST 4 /* Select w\ Wide Data Nego */
+#define SELECT_Q_ST 5 /* Select w\ Tagged Q'ing */
+#define COMMAND_ST 6
+#define DATA_OUT_ST 7
+#define DATA_IN_ST 8
+#define DISCONNECT_ST 9
+#define STATUS_ST 10
+#define ABORT_ST 11
+#define MESSAGE_ST 12
+
+
+#define F_HOST_XFER_DIR 0x01
+#define F_ALL_XFERRED 0x02
+#define F_SG_XFER 0x04
+#define F_AUTO_SENSE 0x08
+#define F_ODD_BALL_CNT 0x10
+#define F_NO_DATA_YET 0x80
+
+
+#define F_STATUSLOADED 0x01
+#define F_MSGLOADED 0x02
+#define F_DEV_SELECTED 0x04
+
+
+#define SCCB_COMPLETE 0x00 /* SCCB completed without error */
+#define SCCB_DATA_UNDER_RUN 0x0C
+#define SCCB_SELECTION_TIMEOUT 0x11 /* Set SCSI selection timed out */
+#define SCCB_DATA_OVER_RUN 0x12
+#define SCCB_UNEXPECTED_BUS_FREE 0x13 /* Target dropped SCSI BSY */
+#define SCCB_PHASE_SEQUENCE_FAIL 0x14 /* Target bus phase sequence failure
*/
+
+#define SCCB_INVALID_OP_CODE 0x16 /* SCCB invalid operation code */
+#define SCCB_INVALID_SCCB 0x1A /* Invalid SCCB - bad parameter */
+#define SCCB_GROSS_FW_ERR 0x27 /* Major problem! */
+#define SCCB_BM_ERR 0x30 /* BusMaster error. */
+#define SCCB_PARITY_ERR 0x34 /* SCSI parity error */
+
+
+
+#if (FW_TYPE==_UCB_MGR_)
+ #define HBA_AUTO_SENSE_FAIL 0x1B
+ #define HBA_TQ_REJECTED 0x1C
+ #define HBA_UNSUPORTED_MSG 0x1D
+ #define HBA_HW_ERROR 0x20
+ #define HBA_ATN_NOT_RESPONDED 0x21
+ #define HBA_SCSI_RESET_BY_ADAPTER 0x22
+ #define HBA_SCSI_RESET_BY_TARGET 0x23
+ #define HBA_WRONG_CONNECTION 0x24
+ #define HBA_BUS_DEVICE_RESET 0x25
+ #define HBA_ABORT_QUEUE 0x26
+
+#else // these are not defined in BUDI/UCB
+
+ #define SCCB_INVALID_DIRECTION 0x18 /* Invalid target direction */
+ #define SCCB_DUPLICATE_SCCB 0x19 /* Duplicate SCCB */
+ #define SCCB_SCSI_RST 0x35 /* SCSI RESET detected. */
+
+#endif // (FW_TYPE==_UCB_MGR_)
+
+
+#define SCCB_IN_PROCESS 0x00
+#define SCCB_SUCCESS 0x01
+#define SCCB_ABORT 0x02
+#define SCCB_NOT_FOUND 0x03
+#define SCCB_ERROR 0x04
+#define SCCB_INVALID 0x05
+
+#define SCCB_SIZE sizeof(SCCB)
+
+
+
+
+#if (FW_TYPE == _UCB_MGR_)
+ void SccbMgr_start_sccb(CARD_HANDLE pCurrCard, PUCB p_ucb);
+ s32bits SccbMgr_abort_sccb(CARD_HANDLE pCurrCard, PUCB p_ucb);
+ u08bits SccbMgr_my_int(CARD_HANDLE pCurrCard);
+ s32bits SccbMgr_isr(CARD_HANDLE pCurrCard);
+ void SccbMgr_scsi_reset(CARD_HANDLE pCurrCard);
+ void SccbMgr_timer_expired(CARD_HANDLE pCurrCard);
+ void SccbMgr_unload_card(CARD_HANDLE pCurrCard);
+ void SccbMgr_restore_foreign_state(CARD_HANDLE pCurrCard);
+ void SccbMgr_restore_native_state(CARD_HANDLE pCurrCard);
+ void SccbMgr_save_foreign_state(PADAPTER_INFO pAdapterInfo);
+
+#endif
+
+
+#if (FW_TYPE == _SCCB_MGR_)
+
+ #if defined (DOS)
+ int SccbMgr_sense_adapter(PSCCBMGR_INFO pCardInfo);
+ USHORT SccbMgr_config_adapter(PSCCBMGR_INFO pCardInfo);
+ void SccbMgr_start_sccb(USHORT pCurrCard, PSCCB p_SCCB);
+ int SccbMgr_abort_sccb(USHORT pCurrCard, PSCCB p_SCCB);
+ UCHAR SccbMgr_my_int(USHORT pCurrCard);
+ int SccbMgr_isr(USHORT pCurrCard);
+ void SccbMgr_scsi_reset(USHORT pCurrCard);
+ void SccbMgr_timer_expired(USHORT pCurrCard);
+ USHORT SccbMgr_status(USHORT pCurrCard);
+ void SccbMgr_unload_card(USHORT pCurrCard);
+
+ #else //non-DOS
+
+ int SccbMgr_sense_adapter(PSCCBMGR_INFO pCardInfo);
+ ULONG SccbMgr_config_adapter(PSCCBMGR_INFO pCardInfo);
+ void SccbMgr_start_sccb(ULONG pCurrCard, PSCCB p_SCCB);
+ int SccbMgr_abort_sccb(ULONG pCurrCard, PSCCB p_SCCB);
+ UCHAR SccbMgr_my_int(ULONG pCurrCard);
+ int SccbMgr_isr(ULONG pCurrCard);
+ void SccbMgr_scsi_reset(ULONG pCurrCard);
+ void SccbMgr_enable_int(ULONG pCurrCard);
+ void SccbMgr_disable_int(ULONG pCurrCard);
+ void SccbMgr_timer_expired(ULONG pCurrCard);
+ void SccbMgr_unload_card(ULONG pCurrCard);
+
+ #endif
+#endif // (FW_TYPE == _SCCB_MGR_)
+
+#endif /* __SCCB_H__ */
+
+/*----------------------------------------------------------------------
+ *
+ *
+ * Copyright 1995-1996 by Mylex Corporation. All Rights Reserved
+ *
+ * This file is available under both the GNU General Public License
+ * and a BSD-style copyright; see LICENSE.FlashPoint for details.
+ *
+ * $Workfile: blx30.h $
+ *
+ * Description: This module contains SCCB/UCB Manager implementation
+ * specific stuff.
+ *
+ * $Date: 1999/04/26 05:53:56 $
+ *
+ * $Revision: 1.1 $
+ *
+ *----------------------------------------------------------------------*/
+
+
+#ifndef __blx30_H__
+#define __blx30_H__
+
+/*#include <globals.h>*/
+
+#define ORION_FW_REV 3110
+
+
+
+
+#define HARP_REVD 1
+
+
+#if defined(DOS)
+#define QUEUE_DEPTH 8+1 /*1 for Normal disconnect 0 for Q'ing.
*/
+#else
+#define QUEUE_DEPTH 254+1 /*1 for Normal disconnect 32 for
Q'ing. */
+#endif // defined(DOS)
+
+#define MAX_MB_CARDS 4 /* Max.
no of cards suppoerted on Mother Board */
+
+#define WIDE_SCSI 1
+
+#if defined(WIDE_SCSI)
+ #if defined(DOS)
+ #define MAX_SCSI_TAR 16
+ #define MAX_LUN 8
+ #define LUN_MASK 0x07
+ #else
+ #define MAX_SCSI_TAR 16
+ #define MAX_LUN 32
+ #define LUN_MASK 0x1f
+
+ #endif
+#else
+ #define MAX_SCSI_TAR 8
+ #define MAX_LUN 8
+ #define LUN_MASK 0x07
+#endif
+
+#if defined(HARP_REVA)
+#define SG_BUF_CNT 15 /*Number of prefetched elements. */
+#else
+#define SG_BUF_CNT 16 /*Number of prefetched elements. */
+#endif
+
+#define SG_ELEMENT_SIZE 8 /*Eight byte per element. */
+#define SG_LOCAL_MASK 0x00000000L
+#define SG_ELEMENT_MASK 0xFFFFFFFFL
+
+
+#if (FW_TYPE == _UCB_MGR_)
+ #define OPC_DECODE_NORMAL 0x0f7f
+#endif // _UCB_MGR_
+
+
+
+#if defined(DOS)
+
+/*#include <dos.h>*/
+ #define RD_HARPOON(ioport) (OS_InPortByte(ioport))
+ #define RDW_HARPOON(ioport) (OS_InPortWord(ioport))
+ #define WR_HARPOON(ioport,val) (OS_OutPortByte(ioport,val))
+ #define WRW_HARPOON(ioport,val) (OS_OutPortWord(ioport,val))
+
+ #define RD_HARP32(port,offset,data) asm{db 66h; \
+ push ax; \
+ mov dx,port; \
+ add dx, offset; \
+ db 66h; \
+ in ax,dx; \
+ db 66h; \
+ mov word ptr data,ax;\
+ db 66h; \
+ pop ax}
+
+ #define WR_HARP32(port,offset,data) asm{db 66h; \
+ push ax; \
+ mov dx,port; \
+ add dx, offset; \
+ db 66h; \
+ mov ax,word ptr data;\
+ db 66h; \
+ out dx,ax; \
+ db 66h; \
+ pop ax}
+#endif /* DOS */
+
+#if defined(NETWARE) || defined(OTHER_32) || defined(OTHER_16)
+ #define RD_HARPOON(ioport) OS_InPortByte((unsigned long)ioport)
+ #define RDW_HARPOON(ioport) OS_InPortWord((unsigned long)ioport)
+ #define RD_HARP32(ioport,offset,data) (data = OS_InPortLong(ioport +
offset))
+ #define WR_HARPOON(ioport,val) OS_OutPortByte((ULONG)ioport,(UCHAR) val)
+ #define WRW_HARPOON(ioport,val)
OS_OutPortWord((ULONG)ioport,(USHORT)val)
+ #define WR_HARP32(ioport,offset,data) OS_OutPortLong((ioport +
offset), data)
+#endif /* NETWARE || OTHER_32 || OTHER_16 */
+
+#if defined(NT) || defined(WIN95_32) || defined(WIN95_16)
+ #define RD_HARPOON(ioport) OS_InPortByte((ULONG)ioport)
+ #define RDW_HARPOON(ioport) OS_InPortWord((ULONG)ioport)
+ #define RD_HARP32(ioport,offset,data) (data =
OS_InPortLong((ULONG)(ioport + offset)))
+ #define WR_HARPOON(ioport,val)
OS_OutPortByte((ULONG)ioport,(UCHAR) val)
+ #define WRW_HARPOON(ioport,val)
OS_OutPortWord((ULONG)ioport,(USHORT)val)
+ #define WR_HARP32(ioport,offset,data) OS_OutPortLong((ULONG)(ioport +
offset), data)
+#endif /* NT || WIN95_32 || WIN95_16 */
+
+#if defined (UNIX)
+ #define RD_HARPOON(ioport) OS_InPortByte((u32bits)ioport)
+ #define RDW_HARPOON(ioport) OS_InPortWord((u32bits)ioport)
+ #define RD_HARP32(ioport,offset,data) (data =
OS_InPortLong((u32bits)(ioport + offset)))
+ #define WR_HARPOON(ioport,val)
OS_OutPortByte((u32bits)ioport,(u08bits) val)
+ #define WRW_HARPOON(ioport,val)
OS_OutPortWord((u32bits)ioport,(u16bits)val)
+ #define WR_HARP32(ioport,offset,data) OS_OutPortLong((u32bits)(ioport
+ offset), data)
+#endif /* UNIX */
+
+#if defined(OS2)
+ #define RD_HARPOON(ioport) OS_InPortByte((unsigned long)ioport)
+ #define RDW_HARPOON(ioport) OS_InPortWord((unsigned long)ioport)
+ #define RD_HARP32(ioport,offset,data) (data =
OS_InPortLong((ULONG)(ioport + offset)))
+ #define WR_HARPOON(ioport,val)
OS_OutPortByte((ULONG)ioport,(UCHAR) val)
+ #define WRW_HARPOON(ioport,val)
OS_OutPortWord((ULONG)ioport,(USHORT)val)
+ #define WR_HARP32(ioport,offset,data) OS_OutPortLong(((ULONG)(ioport +
offset)), data)
+#endif /* OS2 */
+
+#if defined(SOLARIS_REAL_MODE)
+
+ #define RD_HARPOON(ioport) OS_InPortByte((unsigned long)ioport)
+ #define RDW_HARPOON(ioport) OS_InPortWord((unsigned long)ioport)
+ #define RD_HARP32(ioport,offset,data) (data =
OS_InPortLong((ULONG)(ioport + offset)))
+ #define WR_HARPOON(ioport,val)
OS_OutPortByte((ULONG)ioport,(UCHAR) val)
+ #define WRW_HARPOON(ioport,val)
OS_OutPortWord((ULONG)ioport,(USHORT)val)
+ #define WR_HARP32(ioport,offset,data) OS_OutPortLong((ULONG)(ioport +
offset), (ULONG)data)
+
+#endif /* SOLARIS_REAL_MODE */
+
+#endif /* __BLX30_H__ */
+
+
+/*----------------------------------------------------------------------
+ *
+ *
+ * Copyright 1995-1996 by Mylex Corporation. All Rights Reserved
+ *
+ * This file is available under both the GNU General Public License
+ * and a BSD-style copyright; see LICENSE.FlashPoint for details.
+ *
+ * $Workfile: target.h $
+ *
+ * Description: Definitions for Target related structures
+ *
+ * $Date: 1999/04/26 05:53:56 $
+ *
+ * $Revision: 1.1 $
+ *
+ *----------------------------------------------------------------------*/
+
+#ifndef __TARGET__
+#define __TARGET__
+
+/*#include <globals.h>*/
+/*#include <blx30.h>*/
+
+
+#define TAR_SYNC_MASK (BIT(7)+BIT(6))
+#define SYNC_UNKNOWN 0x00
+#define SYNC_TRYING BIT(6)
+#define SYNC_SUPPORTED (BIT(7)+BIT(6))
+
+#define TAR_WIDE_MASK (BIT(5)+BIT(4))
+#define WIDE_DISABLED 0x00
+#define WIDE_ENABLED BIT(4)
+#define WIDE_NEGOCIATED BIT(5)
+
+#define TAR_TAG_Q_MASK (BIT(3)+BIT(2))
+#define TAG_Q_UNKNOWN 0x00
+#define TAG_Q_TRYING BIT(2)
+#define TAG_Q_REJECT BIT(3)
+#define TAG_Q_SUPPORTED (BIT(3)+BIT(2))
+
+#define TAR_ALLOW_DISC BIT(0)
+
+
+#define EE_SYNC_MASK (BIT(0)+BIT(1))
+#define EE_SYNC_ASYNC 0x00
+#define EE_SYNC_5MB BIT(0)
+#define EE_SYNC_10MB BIT(1)
+#define EE_SYNC_20MB (BIT(0)+BIT(1))
+
+#define EE_ALLOW_DISC BIT(6)
+#define EE_WIDE_SCSI BIT(7)
+
+
+#if defined(DOS)
+ typedef struct SCCBMgr_tar_info near *PSCCBMgr_tar_info;
+
+#elif defined(OS2)
+ typedef struct SCCBMgr_tar_info far *PSCCBMgr_tar_info;
+
+#else
+ typedef struct SCCBMgr_tar_info *PSCCBMgr_tar_info;
+
+#endif
+
+
+typedef struct SCCBMgr_tar_info {
+
+ PSCCB TarSelQ_Head;
+ PSCCB TarSelQ_Tail;
+ UCHAR TarLUN_CA; /*Contingent Allgiance */
+ UCHAR TarTagQ_Cnt;
+ UCHAR TarSelQ_Cnt;
+ UCHAR TarStatus;
+ UCHAR TarEEValue;
+ UCHAR TarSyncCtrl;
+ UCHAR TarReserved[2]; /* for alignment */
+ UCHAR LunDiscQ_Idx[MAX_LUN];
+ UCHAR TarLUNBusy[MAX_LUN];
+} SCCBMGR_TAR_INFO;
+
+typedef struct NVRAMInfo {
+ UCHAR niModel;
/* Model No. of card */
+ UCHAR niCardNo;
/* Card no. */
+#if defined(DOS)
+ USHORT niBaseAddr;
/* Port Address of card */
+#else
+ ULONG niBaseAddr;
/* Port Address of card */
+#endif
+ UCHAR niSysConf;
/* Adapter Configuration byte - Byte 16 of eeprom map */
+ UCHAR niScsiConf;
/* SCSI Configuration byte - Byte 17 of eeprom map */
+ UCHAR niScamConf;
/* SCAM Configuration byte - Byte 20 of eeprom map */
+ UCHAR niAdapId;
/* Host Adapter ID - Byte 24 of eerpom map */
+ UCHAR niSyncTbl[MAX_SCSI_TAR / 2]; /* Sync/Wide byte of
targets */
+ UCHAR niScamTbl[MAX_SCSI_TAR][4]; /* Compressed Scam name
string of Targets */
+}NVRAMINFO;
+
+#if defined(DOS)
+typedef NVRAMINFO near *PNVRamInfo;
+#elif defined (OS2)
+typedef NVRAMINFO far *PNVRamInfo;
+#else
+typedef NVRAMINFO *PNVRamInfo;
+#endif
+
+#define MODEL_LT 1
+#define MODEL_DL 2
+#define MODEL_LW 3
+#define MODEL_DW 4
+
+
+typedef struct SCCBcard {
+ PSCCB currentSCCB;
+#if (FW_TYPE==_SCCB_MGR_)
+ PSCCBMGR_INFO cardInfo;
+#else
+ PADAPTER_INFO cardInfo;
+#endif
+
+#if defined(DOS)
+ USHORT ioPort;
+#else
+ ULONG ioPort;
+#endif
+
+ USHORT cmdCounter;
+ UCHAR discQCount;
+ UCHAR tagQ_Lst;
+ UCHAR cardIndex;
+ UCHAR scanIndex;
+ UCHAR globalFlags;
+ UCHAR ourId;
+ PNVRamInfo pNvRamInfo;
+ PSCCB discQ_Tbl[QUEUE_DEPTH];
+
+}SCCBCARD;
+
+#if defined(DOS)
+typedef struct SCCBcard near *PSCCBcard;
+#elif defined (OS2)
+typedef struct SCCBcard far *PSCCBcard;
+#else
+typedef struct SCCBcard *PSCCBcard;
+#endif
+
+
+#define F_TAG_STARTED 0x01
+#define F_CONLUN_IO 0x02
+#define F_DO_RENEGO 0x04
+#define F_NO_FILTER 0x08
+#define F_GREEN_PC 0x10
+#define F_HOST_XFER_ACT 0x20
+#define F_NEW_SCCB_CMD 0x40
+#define F_UPDATE_EEPROM 0x80
+
+
+#define ID_STRING_LENGTH 32
+#define TYPE_CODE0 0x63 /*Level2 Mstr (bits 7-6), */
+
+#define TYPE_CODE1 00 /*No ID yet */
+
+#define SLV_TYPE_CODE0 0xA3 /*Priority Bit set (bits 7-6), */
+
+#define ASSIGN_ID 0x00
+#define SET_P_FLAG 0x01
+#define CFG_CMPLT 0x03
+#define DOM_MSTR 0x0F
+#define SYNC_PTRN 0x1F
+
+#define ID_0_7 0x18
+#define ID_8_F 0x11
+#define ID_10_17 0x12
+#define ID_18_1F 0x0B
+#define MISC_CODE 0x14
+#define CLR_P_FLAG 0x18
+#define LOCATE_ON 0x12
+#define LOCATE_OFF 0x0B
+
+#define LVL_1_MST 0x00
+#define LVL_2_MST 0x40
+#define DOM_LVL_2 0xC0
+
+
+#define INIT_SELTD 0x01
+#define LEVEL2_TAR 0x02
+
+
+enum scam_id_st { ID0,ID1,ID2,ID3,ID4,ID5,ID6,ID7,ID8,ID9,ID10,ID11,ID12,
+ ID13,ID14,ID15,ID_UNUSED,ID_UNASSIGNED,ID_ASSIGNED,LEGACY,
+ CLR_PRIORITY,NO_ID_AVAIL };
+
+typedef struct SCCBscam_info {
+
+ UCHAR id_string[ID_STRING_LENGTH];
+ enum scam_id_st state;
+
+} SCCBSCAM_INFO, *PSCCBSCAM_INFO;
+
+#endif
+/*----------------------------------------------------------------------
+ *
+ *
+ * Copyright 1995-1996 by Mylex Corporation. All Rights Reserved
+ *
+ * This file is available under both the GNU General Public License
+ * and a BSD-style copyright; see LICENSE.FlashPoint for details.
+ *
+ * $Workfile: scsi2.h $
+ *
+ * Description: Register definitions for HARPOON ASIC.
+ *
+ * $Date: 1999/04/26 05:53:56 $
+ *
+ * $Revision: 1.1 $
+ *
+ *----------------------------------------------------------------------*/
+
+#ifndef __SCSI_H__
+#define __SCSI_H__
+
+
+
+#define SCSI_TEST_UNIT_READY 0x00
+#define SCSI_REZERO_UNIT 0x01
+#define SCSI_REQUEST_SENSE 0x03
+#define SCSI_FORMAT_UNIT 0x04
+#define SCSI_REASSIGN 0x07
+#define SCSI_READ 0x08
+#define SCSI_WRITE 0x0A
+#define SCSI_SEEK 0x0B
+#define SCSI_INQUIRY 0x12
+#define SCSI_MODE_SELECT 0x15
+#define SCSI_RESERVE_UNIT 0x16
+#define SCSI_RELEASE_UNIT 0x17
+#define SCSI_MODE_SENSE 0x1A
+#define SCSI_START_STOP_UNIT 0x1B
+#define SCSI_SEND_DIAGNOSTIC 0x1D
+#define SCSI_READ_CAPACITY 0x25
+#define SCSI_READ_EXTENDED 0x28
+#define SCSI_WRITE_EXTENDED 0x2A
+#define SCSI_SEEK_EXTENDED 0x2B
+#define SCSI_WRITE_AND_VERIFY 0x2E
+#define SCSI_VERIFY 0x2F
+#define SCSI_READ_DEFECT_DATA 0x37
+#define SCSI_WRITE_BUFFER 0x3B
+#define SCSI_READ_BUFFER 0x3C
+#define SCSI_RECV_DIAGNOSTIC 0x1C
+#define SCSI_READ_LONG 0x3E
+#define SCSI_WRITE_LONG 0x3F
+#define SCSI_LAST_SCSI_CMND SCSI_WRITE_LONG
+#define SCSI_INVALID_CMND 0xFF
+
+
+
+#define SSGOOD 0x00
+#define SSCHECK 0x02
+#define SSCOND_MET 0x04
+#define SSBUSY 0x08
+#define SSRESERVATION_CONFLICT 0x18
+#define SSCMD_TERM 0x22
+#define SSQ_FULL 0x28
+
+
+#define SKNO_SEN 0x00
+#define SKRECOV_ERR 0x01
+#define SKNOT_RDY 0x02
+#define SKMED_ERR 0x03
+#define SKHW_ERR 0x04
+#define SKILL_REQ 0x05
+#define SKUNIT_ATTN 0x06
+#define SKDATA_PROTECT 0x07
+#define SKBLNK_CHK 0x08
+#define SKCPY_ABORT 0x0A
+#define SKABORT_CMD 0x0B
+#define SKEQUAL 0x0C
+#define SKVOL_OVF 0x0D
+#define SKMIS_CMP 0x0E
+
+
+#define SMCMD_COMP 0x00
+#define SMEXT 0x01
+#define SMSAVE_DATA_PTR 0x02
+#define SMREST_DATA_PTR 0x03
+#define SMDISC 0x04
+#define SMINIT_DETEC_ERR 0x05
+#define SMABORT 0x06
+#define SMREJECT 0x07
+#define SMNO_OP 0x08
+#define SMPARITY 0x09
+#define SMDEV_RESET 0x0C
+#define SMABORT_TAG 0x0D
+#define SMINIT_RECOVERY 0x0F
+#define SMREL_RECOVERY 0x10
+
+#define SMIDENT 0x80
+#define DISC_PRIV 0x40
+
+
+#define SMSYNC 0x01
+#define SM10MBS 0x19 /* 100ns */
+#define SM5MBS 0x32 /* 200ns */
+#define SMOFFSET 0x0F /* Maxoffset value */
+#define SMWDTR 0x03
+#define SM8BIT 0x00
+#define SM16BIT 0x01
+#define SM32BIT 0x02
+#define SMIGNORWR 0x23 /* Ignore Wide Residue */
+
+
+#define ARBITRATION_DELAY 0x01 /* 2.4us using a 40Mhz clock */
+#define BUS_SETTLE_DELAY 0x01 /* 400ns */
+#define BUS_CLEAR_DELAY 0x01 /* 800ns */
+
+
+
+#define SPHASE_TO 0x0A /* 10 second timeout waiting for */
+#define SCMD_TO 0x0F /* Overall command timeout */
+
+
+
+#define SIX_BYTE_CMD 0x06
+#define TEN_BYTE_CMD 0x0A
+#define TWELVE_BYTE_CMD 0x0C
+
+#define ASYNC 0x00
+#define PERI25NS 0x06 /* 25/4ns to next clock for xbow. */
+#define SYNC10MBS 0x19
+#define SYNC5MBS 0x32
+#define MAX_OFFSET 0x0F /* Maxbyteoffset for Sync Xfers */
+
+#endif
+/*----------------------------------------------------------------------
+ *
+ *
+ * Copyright 1995-1996 by Mylex Corporation. All Rights Reserved
+ *
+ * This file is available under both the GNU General Public License
+ * and a BSD-style copyright; see LICENSE.FlashPoint for details.
+ *
+ * $Workfile: eeprom.h $
+ *
+ * Description: Definitions for EEPROM related structures
+ *
+ * $Date: 1999/04/26 05:53:56 $
+ *
+ * $Revision: 1.1 $
+ *
+ *----------------------------------------------------------------------*/
+
+#ifndef __EEPROM__
+#define __EEPROM__
+
+/*#include <globals.h>*/
+
+#define EEPROM_WD_CNT 256
+
+#define EEPROM_CHECK_SUM 0
+#define FW_SIGNATURE 2
+#define MODEL_NUMB_0 4
+#define MODEL_NUMB_1 5
+#define MODEL_NUMB_2 6
+#define MODEL_NUMB_3 7
+#define MODEL_NUMB_4 8
+#define MODEL_NUMB_5 9
+#define IO_BASE_ADDR 10
+#define IRQ_NUMBER 12
+#define PCI_INT_PIN 13
+#define BUS_DELAY 14 /*On time in byte 14 off delay in 15 */
+#define SYSTEM_CONFIG 16
+#define SCSI_CONFIG 17
+#define BIOS_CONFIG 18
+#define SPIN_UP_DELAY 19
+#define SCAM_CONFIG 20
+#define ADAPTER_SCSI_ID 24
+
+
+#define IGNORE_B_SCAN 32
+#define SEND_START_ENA 34
+#define DEVICE_ENABLE 36
+
+#define SYNC_RATE_TBL 38
+#define SYNC_RATE_TBL01 38
+#define SYNC_RATE_TBL23 40
+#define SYNC_RATE_TBL45 42
+#define SYNC_RATE_TBL67 44
+#define SYNC_RATE_TBL89 46
+#define SYNC_RATE_TBLab 48
+#define SYNC_RATE_TBLcd 50
+#define SYNC_RATE_TBLef 52
+
+
+
+#define EE_SCAMBASE 256
+
+
+
+ #define DOM_MASTER (BIT(0) + BIT(1))
+ #define SCAM_ENABLED BIT(2)
+ #define SCAM_LEVEL2 BIT(3)
+
+
+ #define RENEGO_ENA BITW(10)
+ #define CONNIO_ENA BITW(11)
+ #define GREEN_PC_ENA BITW(12)
+
+
+ #define AUTO_RATE_00 00
+ #define AUTO_RATE_05 01
+ #define AUTO_RATE_10 02
+ #define AUTO_RATE_20 03
+
+ #define WIDE_NEGO_BIT BIT(7)
+ #define DISC_ENABLE_BIT BIT(6)
+
+
+#endif
+/*----------------------------------------------------------------------
+ *
+ *
+ * Copyright 1995-1996 by Mylex Corporation. All Rights Reserved
+ *
+ * This file is available under both the GNU General Public License
+ * and a BSD-style copyright; see LICENSE.FlashPoint for details.
+ *
+ * $Workfile: harpoon.h $
+ *
+ * Description: Register definitions for HARPOON ASIC.
+ *
+ * $Date: 1999/04/26 05:53:56 $
+ *
+ * $Revision: 1.1 $
+ *
+ *----------------------------------------------------------------------*/
+
+
+/*#include <globals.h>*/
+
+#ifndef __HARPOON__
+#define __HARPOON__
+
+
+ #define hp_vendor_id_0 0x00 /* LSB */
+ #define ORION_VEND_0 0x4B
+
+ #define hp_vendor_id_1 0x01 /* MSB */
+ #define ORION_VEND_1 0x10
+
+ #define hp_device_id_0 0x02 /* LSB */
+ #define ORION_DEV_0 0x30
+
+ #define hp_device_id_1 0x03 /* MSB */
+ #define ORION_DEV_1 0x81
+
+ /* Sub Vendor ID and Sub Device ID only available in
+ Harpoon Version 2 and higher */
+
+ #define hp_sub_vendor_id_0 0x04 /* LSB */
+ #define hp_sub_vendor_id_1 0x05 /* MSB */
+ #define hp_sub_device_id_0 0x06 /* LSB */
+ #define hp_sub_device_id_1 0x07 /* MSB */
+
+
+ #define hp_dual_addr_lo 0x08
+ #define hp_dual_addr_lmi 0x09
+ #define hp_dual_addr_hmi 0x0A
+ #define hp_dual_addr_hi 0x0B
+
+ #define hp_semaphore 0x0C
+ #define SCCB_MGR_ACTIVE BIT(0)
+ #define TICKLE_ME BIT(1)
+ #define SCCB_MGR_PRESENT BIT(3)
+ #define BIOS_IN_USE BIT(4)
+
+ #define hp_user_defined_D 0x0D
+
+ #define hp_reserved_E 0x0E
+
+ #define hp_sys_ctrl 0x0F
+
+ #define STOP_CLK BIT(0) /*Turn off BusMaster Clock */
+ #define DRVR_RST BIT(1) /*Firmware Reset to 80C15 chip */
+ #define HALT_MACH BIT(3) /*Halt State Machine */
+ #define HARD_ABORT BIT(4) /*Hard Abort */
+ #define DIAG_MODE BIT(5) /*Diagnostic Mode */
+
+ #define BM_ABORT_TMOUT 0x50 /*Halt State machine time out */
+
+ #define hp_sys_cfg 0x10
+
+ #define DONT_RST_FIFO BIT(7) /*Don't reset FIFO */
+
+
+ #define hp_host_ctrl0 0x11
+
+ #define DUAL_ADDR_MODE BIT(0) /*Enable 64-bit addresses */
+ #define IO_MEM_SPACE BIT(1) /*I/O Memory Space */
+ #define RESOURCE_LOCK BIT(2) /*Enable Resource Lock */
+ #define IGNOR_ACCESS_ERR BIT(3) /*Ignore Access Error */
+ #define HOST_INT_EDGE BIT(4) /*Host interrupt level/edge mode sel
*/
+ #define SIX_CLOCKS BIT(5) /*6 Clocks between Strobe */
+ #define DMA_EVEN_PARITY BIT(6) /*Enable DMA Enen Parity */
+
+/*
+ #define BURST_MODE BIT(0)
+*/
+
+ #define hp_reserved_12 0x12
+
+ #define hp_host_blk_cnt 0x13
+
+ #define XFER_BLK1 0x00 /* 0 0 0 1 byte per block*/
+ #define XFER_BLK2 0x01 /* 0 0 1 2 byte per block*/
+ #define XFER_BLK4 0x02 /* 0 1 0 4 byte per block*/
+ #define XFER_BLK8 0x03 /* 0 1 1 8 byte per block*/
+ #define XFER_BLK16 0x04 /* 1 0 0 16 byte per block*/
+ #define XFER_BLK32 0x05 /* 1 0 1 32 byte per block*/
+ #define XFER_BLK64 0x06 /* 1 1 0 64 byte per block*/
+
+ #define BM_THRESHOLD 0x40 /* PCI mode can only xfer 16 bytes*/
+
+
+ #define hp_reserved_14 0x14
+ #define hp_reserved_15 0x15
+ #define hp_reserved_16 0x16
+
+ #define hp_int_mask 0x17
+
+ #define INT_CMD_COMPL BIT(0) /* DMA command complete */
+ #define INT_EXT_STATUS BIT(1) /* Extended Status Set */
+ #define INT_SCSI BIT(2) /* Scsi block interrupt */
+ #define INT_FIFO_RDY BIT(4) /* FIFO data ready */
+
+
+ #define hp_xfer_cnt_lo 0x18
+ #define hp_xfer_cnt_mi 0x19
+ #define hp_xfer_cnt_hi 0x1A
+ #define hp_xfer_cmd 0x1B
+
+ #define XFER_HOST_DMA 0x00 /* 0 0 0 Transfer Host -> DMA */
+ #define XFER_DMA_HOST 0x01 /* 0 0 1 Transfer DMA -> Host */
+ #define XFER_HOST_MPU 0x02 /* 0 1 0 Transfer Host -> MPU */
+ #define XFER_MPU_HOST 0x03 /* 0 1 1 Transfer MPU -> Host */
+ #define XFER_DMA_MPU 0x04 /* 1 0 0 Transfer DMA -> MPU */
+ #define XFER_MPU_DMA 0x05 /* 1 0 1 Transfer MPU -> DMA */
+ #define SET_SEMAPHORE 0x06 /* 1 1 0 Set Semaphore */
+ #define XFER_NOP 0x07 /* 1 1 1 Transfer NOP */
+ #define XFER_MB_MPU 0x06 /* 1 1 0 Transfer MB -> MPU */
+ #define XFER_MB_DMA 0x07 /* 1 1 1 Transfer MB -> DMA */
+
+
+ #define XFER_HOST_AUTO 0x00 /* 0 0 Auto Transfer Size */
+ #define XFER_HOST_8BIT 0x08 /* 0 1 8 BIT Transfer Size */
+ #define XFER_HOST_16BIT 0x10 /* 1 0 16 BIT Transfer Size */
+ #define XFER_HOST_32BIT 0x18 /* 1 1 32 BIT Transfer Size */
+
+ #define XFER_DMA_8BIT 0x20 /* 0 1 8 BIT Transfer Size */
+ #define XFER_DMA_16BIT 0x40 /* 1 0 16 BIT Transfer Size */
+
+ #define DISABLE_INT BIT(7) /*Do not interrupt at end of cmd. */
+
+ #define HOST_WRT_CMD ((DISABLE_INT + XFER_HOST_DMA +
XFER_HOST_AUTO + XFER_DMA_8BIT))
+ #define HOST_RD_CMD ((DISABLE_INT + XFER_DMA_HOST +
XFER_HOST_AUTO + XFER_DMA_8BIT))
+ #define WIDE_HOST_WRT_CMD ((DISABLE_INT + XFER_HOST_DMA +
XFER_HOST_AUTO + XFER_DMA_16BIT))
+ #define WIDE_HOST_RD_CMD ((DISABLE_INT + XFER_DMA_HOST +
XFER_HOST_AUTO + XFER_DMA_16BIT))
+
+ #define hp_host_addr_lo 0x1C
+ #define hp_host_addr_lmi 0x1D
+ #define hp_host_addr_hmi 0x1E
+ #define hp_host_addr_hi 0x1F
+
+ #define hp_pio_data 0x20
+ #define hp_reserved_21 0x21
+ #define hp_ee_ctrl 0x22
+
+ #define EXT_ARB_ACK BIT(7)
+ #define SCSI_TERM_ENA_H BIT(6) /* SCSI high byte terminator */
+ #define SEE_MS BIT(5)
+ #define SEE_CS BIT(3)
+ #define SEE_CLK BIT(2)
+ #define SEE_DO BIT(1)
+ #define SEE_DI BIT(0)
+
+ #define EE_READ 0x06
+ #define EE_WRITE 0x05
+ #define EWEN 0x04
+ #define EWEN_ADDR 0x03C0
+ #define EWDS 0x04
+ #define EWDS_ADDR 0x0000
+
+ #define hp_brdctl 0x23
+
+ #define DAT_7 BIT(7)
+ #define DAT_6 BIT(6)
+ #define DAT_5 BIT(5)
+ #define BRD_STB BIT(4)
+ #define BRD_CS BIT(3)
+ #define BRD_WR BIT(2)
+
+ #define hp_reserved_24 0x24
+ #define hp_reserved_25 0x25
+
+
+
+
+ #define hp_bm_ctrl 0x26
+
+ #define SCSI_TERM_ENA_L BIT(0) /*Enable/Disable external
terminators */
+ #define FLUSH_XFER_CNTR BIT(1) /*Flush transfer counter */
+ #define BM_XFER_MIN_8 BIT(2) /*Enable bus master transfer of 9 */
+ #define BIOS_ENA BIT(3) /*Enable BIOS/FLASH Enable */
+ #define FORCE1_XFER BIT(5) /*Always xfer one byte in byte mode
*/
+ #define FAST_SINGLE BIT(6) /*?? */
+
+ #define BMCTRL_DEFAULT (FORCE1_XFER|FAST_SINGLE|SCSI_TERM_ENA_L)
+
+ #define hp_reserved_27 0x27
+
+ #define hp_sg_addr 0x28
+ #define hp_page_ctrl 0x29
+
+ #define SCATTER_EN BIT(0)
+ #define SGRAM_ARAM BIT(1)
+ #define BIOS_SHADOW BIT(2)
+ #define G_INT_DISABLE BIT(3) /* Enable/Disable all Interrupts */
+ #define NARROW_SCSI_CARD BIT(4) /* NARROW/WIDE SCSI config pin */
+
+ #define hp_reserved_2A 0x2A
+ #define hp_pci_cmd_cfg 0x2B
+
+ #define IO_SPACE_ENA BIT(0) /*enable I/O space */
+ #define MEM_SPACE_ENA BIT(1) /*enable memory space */
+ #define BUS_MSTR_ENA BIT(2) /*enable bus master operation */
+ #define MEM_WI_ENA BIT(4) /*enable Write and Invalidate */
+ #define PAR_ERR_RESP BIT(6) /*enable parity error responce. */
+
+ #define hp_reserved_2C 0x2C
+
+ #define hp_pci_stat_cfg 0x2D
+
+ #define DATA_PARITY_ERR BIT(0)
+ #define REC_TARGET_ABORT BIT(4) /*received Target abort */
+ #define REC_MASTER_ABORT BIT(5) /*received Master abort */
+ #define SIG_SYSTEM_ERR BIT(6)
+ #define DETECTED_PAR_ERR BIT(7)
+
+ #define hp_reserved_2E 0x2E
+
+ #define hp_sys_status 0x2F
+
+ #define SLV_DATA_RDY BIT(0) /*Slave data ready */
+ #define XFER_CNT_ZERO BIT(1) /*Transfer counter = 0 */
+ #define BM_FIFO_EMPTY BIT(2) /*FIFO empty */
+ #define BM_FIFO_FULL BIT(3) /*FIFO full */
+ #define HOST_OP_DONE BIT(4) /*host operation done */
+ #define DMA_OP_DONE BIT(5) /*DMA operation done */
+ #define SLV_OP_DONE BIT(6) /*Slave operation done */
+ #define PWR_ON_FLAG BIT(7) /*Power on flag */
+
+ #define hp_reserved_30 0x30
+
+ #define hp_host_status0 0x31
+
+ #define HOST_TERM BIT(5) /*Host Terminal Count */
+ #define HOST_TRSHLD BIT(6) /*Host Threshold */
+ #define CONNECTED_2_HOST BIT(7) /*Connected to Host */
+
+ #define hp_reserved_32 0x32
+
+ #define hp_rev_num 0x33
+
+ #define REV_A_CONST 0x0E
+ #define REV_B_CONST 0x0E
+
+ #define hp_stack_data 0x34
+ #define hp_stack_addr 0x35
+
+ #define hp_ext_status 0x36
+
+ #define BM_FORCE_OFF BIT(0) /*Bus Master is forced to get off */
+ #define PCI_TGT_ABORT BIT(0) /*PCI bus master transaction aborted
*/
+ #define PCI_DEV_TMOUT BIT(1) /*PCI Device Time out */
+ #define FIFO_TC_NOT_ZERO BIT(2) /*FIFO or transfer counter not zero
*/
+ #define CHIP_RST_OCCUR BIT(3) /*Chip reset occurs */
+ #define CMD_ABORTED BIT(4) /*Command aborted */
+ #define BM_PARITY_ERR BIT(5) /*parity error on data received */
+ #define PIO_OVERRUN BIT(6) /*Slave data overrun */
+ #define BM_CMD_BUSY BIT(7) /*Bus master transfer command busy */
+ #define BAD_EXT_STATUS (BM_FORCE_OFF | PCI_DEV_TMOUT | CMD_ABORTED |
\
+ BM_PARITY_ERR | PIO_OVERRUN)
+
+ #define hp_int_status 0x37
+
+ #define BM_CMD_CMPL BIT(0) /*Bus Master command complete */
+ #define EXT_STATUS_ON BIT(1) /*Extended status is valid */
+ #define SCSI_INTERRUPT BIT(2) /*Global indication of a SCSI int. */
+ #define BM_FIFO_RDY BIT(4)
+ #define INT_ASSERTED BIT(5) /* */
+ #define SRAM_BUSY BIT(6) /*Scatter/Gather RAM busy */
+ #define CMD_REG_BUSY BIT(7)
+
+
+ #define hp_fifo_cnt 0x38
+ #define hp_curr_host_cnt 0x39
+ #define hp_reserved_3A 0x3A
+ #define hp_fifo_in_addr 0x3B
+
+ #define hp_fifo_out_addr 0x3C
+ #define hp_reserved_3D 0x3D
+ #define hp_reserved_3E 0x3E
+ #define hp_reserved_3F 0x3F
+
+
+
+ extern USHORT default_intena;
+
+ #define hp_intena 0x40
+
+ #define RESET BITW(7)
+ #define PROG_HLT BITW(6)
+ #define PARITY BITW(5)
+ #define FIFO BITW(4)
+ #define SEL BITW(3)
+ #define SCAM_SEL BITW(2)
+ #define RSEL BITW(1)
+ #define TIMEOUT BITW(0)
+ #define BUS_FREE BITW(15)
+ #define XFER_CNT_0 BITW(14)
+ #define PHASE BITW(13)
+ #define IUNKWN BITW(12)
+ #define ICMD_COMP BITW(11)
+ #define ITICKLE BITW(10)
+ #define IDO_STRT BITW(9)
+ #define ITAR_DISC BITW(8)
+ #define AUTO_INT
(BITW(12)+BITW(11)+BITW(10)+BITW(9)+BITW(8))
+ #define CLR_ALL_INT 0xFFFF
+ #define CLR_ALL_INT_1 0xFF00
+
+ #define hp_intstat 0x42
+
+ #define hp_scsisig 0x44
+
+ #define SCSI_SEL BIT(7)
+ #define SCSI_BSY BIT(6)
+ #define SCSI_REQ BIT(5)
+ #define SCSI_ACK BIT(4)
+ #define SCSI_ATN BIT(3)
+ #define SCSI_CD BIT(2)
+ #define SCSI_MSG BIT(1)
+ #define SCSI_IOBIT BIT(0)
+
+ #define S_SCSI_PHZ (BIT(2)+BIT(1)+BIT(0))
+ #define S_CMD_PH (BIT(2) )
+ #define S_MSGO_PH (BIT(2)+BIT(1) )
+ #define S_STAT_PH (BIT(2) +BIT(0))
+ #define S_MSGI_PH (BIT(2)+BIT(1)+BIT(0))
+ #define S_DATAI_PH ( BIT(0))
+ #define S_DATAO_PH 0x00
+ #define S_ILL_PH ( BIT(1) )
+
+ #define hp_scsictrl_0 0x45
+
+ #define NO_ARB BIT(7)
+ #define SEL_TAR BIT(6)
+ #define ENA_ATN BIT(4)
+ #define ENA_RESEL BIT(2)
+ #define SCSI_RST BIT(1)
+ #define ENA_SCAM_SEL BIT(0)
+
+
+
+ #define hp_portctrl_0 0x46
+
+ #define SCSI_PORT BIT(7)
+ #define SCSI_INBIT BIT(6)
+ #define DMA_PORT BIT(5)
+ #define DMA_RD BIT(4)
+ #define HOST_PORT BIT(3)
+ #define HOST_WRT BIT(2)
+ #define SCSI_BUS_EN BIT(1)
+ #define START_TO BIT(0)
+
+ #define hp_scsireset 0x47
+
+ #define SCSI_TAR BIT(7)
+ #define SCSI_INI BIT(6)
+ #define SCAM_EN BIT(5)
+ #define ACK_HOLD BIT(4)
+ #define DMA_RESET BIT(3)
+ #define HPSCSI_RESET BIT(2)
+ #define PROG_RESET BIT(1)
+ #define FIFO_CLR BIT(0)
+
+ #define hp_xfercnt_0 0x48
+ #define hp_xfercnt_1 0x49
+ #define hp_xfercnt_2 0x4A
+ #define hp_xfercnt_3 0x4B
+
+ #define hp_fifodata_0 0x4C
+ #define hp_fifodata_1 0x4D
+ #define hp_addstat 0x4E
+
+ #define SCAM_TIMER BIT(7)
+ #define AUTO_RUNNING BIT(6)
+ #define FAST_SYNC BIT(5)
+ #define SCSI_MODE8 BIT(3)
+ #define SCSI_PAR_ERR BIT(0)
+
+ #define hp_prgmcnt_0 0x4F
+
+ #define AUTO_PC_MASK 0x3F
+
+ #define hp_selfid_0 0x50
+ #define hp_selfid_1 0x51
+ #define hp_arb_id 0x52
+
+ #define ARB_ID (BIT(3) + BIT(2) + BIT(1) + BIT(0))
+
+ #define hp_select_id 0x53
+
+ #define RESEL_ID (BIT(7) + BIT(6) + BIT(5) + BIT(4))
+ #define SELECT_ID (BIT(3) + BIT(2) + BIT(1) + BIT(0))
+
+ #define hp_synctarg_base 0x54
+ #define hp_synctarg_12 0x54
+ #define hp_synctarg_13 0x55
+ #define hp_synctarg_14 0x56
+ #define hp_synctarg_15 0x57
+
+ #define hp_synctarg_8 0x58
+ #define hp_synctarg_9 0x59
+ #define hp_synctarg_10 0x5A
+ #define hp_synctarg_11 0x5B
+
+ #define hp_synctarg_4 0x5C
+ #define hp_synctarg_5 0x5D
+ #define hp_synctarg_6 0x5E
+ #define hp_synctarg_7 0x5F
+
+ #define hp_synctarg_0 0x60
+ #define hp_synctarg_1 0x61
+ #define hp_synctarg_2 0x62
+ #define hp_synctarg_3 0x63
+
+ #define RATE_20MB 0x00
+ #define RATE_10MB ( BIT(5))
+ #define RATE_6_6MB ( BIT(6) )
+ #define RATE_5MB ( BIT(6)+BIT(5))
+ #define RATE_4MB (BIT(7) )
+ #define RATE_3_33MB (BIT(7) +BIT(5))
+ #define RATE_2_85MB (BIT(7)+BIT(6) )
+ #define RATE_2_5MB (BIT(7)+BIT(5)+BIT(6))
+ #define NEXT_CLK BIT(5)
+ #define SLOWEST_SYNC (BIT(7)+BIT(6)+BIT(5))
+ #define NARROW_SCSI BIT(4)
+ #define SYNC_OFFSET (BIT(3) + BIT(2) + BIT(1) + BIT(0))
+ #define DEFAULT_ASYNC 0x00
+ #define DEFAULT_OFFSET 0x0F
+
+ #define hp_autostart_0 0x64
+ #define hp_autostart_1 0x65
+ #define hp_autostart_2 0x66
+ #define hp_autostart_3 0x67
+
+
+
+ #define DISABLE 0x00
+ #define AUTO_IMMED BIT(5)
+ #define SELECT BIT(6)
+ #define RESELECT (BIT(6)+BIT(5))
+ #define BUSFREE BIT(7)
+ #define XFER_0 (BIT(7)+BIT(5))
+ #define END_DATA (BIT(7)+BIT(6))
+ #define MSG_PHZ (BIT(7)+BIT(6)+BIT(5))
+
+ #define hp_gp_reg_0 0x68
+ #define hp_gp_reg_1 0x69
+ #define hp_gp_reg_2 0x6A
+ #define hp_gp_reg_3 0x6B
+
+ #define hp_seltimeout 0x6C
+
+
+ #define TO_2ms 0x54 /* 2.0503ms */
+ #define TO_4ms 0x67 /* 3.9959ms */
+
+ #define TO_5ms 0x03 /* 4.9152ms */
+ #define TO_10ms 0x07 /* 11.xxxms */
+ #define TO_250ms 0x99 /* 250.68ms */
+ #define TO_290ms 0xB1 /* 289.99ms */
+ #define TO_350ms 0xD6 /* 350.62ms */
+ #define TO_417ms 0xFF /* 417.79ms */
+
+ #define hp_clkctrl_0 0x6D
+
+ #define PWR_DWN BIT(6)
+ #define ACTdeassert BIT(4)
+ #define ATNonErr BIT(3)
+ #define CLK_30MHZ BIT(1)
+ #define CLK_40MHZ (BIT(1) + BIT(0))
+ #define CLK_50MHZ BIT(2)
+
+ #define CLKCTRL_DEFAULT (ACTdeassert | CLK_40MHZ)
+
+ #define hp_fiforead 0x6E
+ #define hp_fifowrite 0x6F
+
+ #define hp_offsetctr 0x70
+ #define hp_xferstat 0x71
+
+ #define FIFO_FULL BIT(7)
+ #define FIFO_EMPTY BIT(6)
+ #define FIFO_MASK 0x3F /* Mask for the FIFO count value. */
+ #define FIFO_LEN 0x20
+
+ #define hp_portctrl_1 0x72
+
+ #define EVEN_HOST_P BIT(5)
+ #define INVT_SCSI BIT(4)
+ #define CHK_SCSI_P BIT(3)
+ #define HOST_MODE8 BIT(0)
+ #define HOST_MODE16 0x00
+
+ #define hp_xfer_pad 0x73
+
+ #define ID_UNLOCK BIT(3)
+ #define XFER_PAD BIT(2)
+
+ #define hp_scsidata_0 0x74
+ #define hp_scsidata_1 0x75
+ #define hp_timer_0 0x76
+ #define hp_timer_1 0x77
+
+ #define hp_reserved_78 0x78
+ #define hp_reserved_79 0x79
+ #define hp_reserved_7A 0x7A
+ #define hp_reserved_7B 0x7B
+
+ #define hp_reserved_7C 0x7C
+ #define hp_reserved_7D 0x7D
+ #define hp_reserved_7E 0x7E
+ #define hp_reserved_7F 0x7F
+
+ #define hp_aramBase 0x80
+ #define BIOS_DATA_OFFSET 0x60
+ #define BIOS_RELATIVE_CARD 0x64
+
+
+
+
+ #define AUTO_LEN 0x80
+ #define AR0 0x00
+ #define AR1 BITW(8)
+ #define AR2 BITW(9)
+ #define AR3 (BITW(9) + BITW(8))
+ #define SDATA BITW(10)
+
+ #define NOP_OP 0x00 /* Nop command */
+
+ #define CRD_OP BITW(11) /* Cmp Reg. w/ Data */
+
+ #define CRR_OP BITW(12) /* Cmp Reg. w. Reg. */
+
+ #define CBE_OP (BITW(14)+BITW(12)+BITW(11)) /* Cmp SCSI cmd class &
Branch EQ */
+
+ #define CBN_OP (BITW(14)+BITW(13)) /* Cmp SCSI cmd class & Branch
NOT EQ */
+
+ #define CPE_OP (BITW(14)+BITW(11)) /* Cmp SCSI phs & Branch EQ */
+
+ #define CPN_OP (BITW(14)+BITW(12)) /* Cmp SCSI phs & Branch NOT EQ */
+
+
+ #define ADATA_OUT 0x00
+ #define ADATA_IN BITW(8)
+ #define ACOMMAND BITW(10)
+ #define ASTATUS (BITW(10)+BITW(8))
+ #define AMSG_OUT (BITW(10)+BITW(9))
+ #define AMSG_IN (BITW(10)+BITW(9)+BITW(8))
+ #define AILLEGAL (BITW(9)+BITW(8))
+
+
+ #define BRH_OP BITW(13) /* Branch */
+
+
+ #define ALWAYS 0x00
+ #define EQUAL BITW(8)
+ #define NOT_EQ BITW(9)
+
+ #define TCB_OP (BITW(13)+BITW(11)) /* Test condition & branch */
+
+
+ #define ATN_SET BITW(8)
+ #define ATN_RESET BITW(9)
+ #define XFER_CNT (BITW(9)+BITW(8))
+ #define FIFO_0 BITW(10)
+ #define FIFO_NOT0 (BITW(10)+BITW(8))
+ #define T_USE_SYNC0 (BITW(10)+BITW(9))
+
+
+ #define MPM_OP BITW(15) /* Match phase and move data */
+
+ #define MDR_OP (BITW(12)+BITW(11)) /* Move data to Reg. */
+
+ #define MRR_OP BITW(14) /* Move DReg. to Reg. */
+
+
+ #define S_IDREG (BIT(2)+BIT(1)+BIT(0))
+
+
+ #define D_AR0 0x00
+ #define D_AR1 BIT(0)
+ #define D_AR2 BIT(1)
+ #define D_AR3 (BIT(1) + BIT(0))
+ #define D_SDATA BIT(2)
+ #define D_BUCKET (BIT(2) + BIT(1) + BIT(0))
+
+
+ #define ADR_OP (BITW(13)+BITW(12)) /* Logical AND Reg. w. Data */
+
+ #define ADS_OP (BITW(14)+BITW(13)+BITW(12))
+
+ #define ODR_OP (BITW(13)+BITW(12)+BITW(11))
+
+ #define ODS_OP (BITW(14)+BITW(13)+BITW(12)+BITW(11))
+
+ #define STR_OP (BITW(15)+BITW(14)) /* Store to A_Reg. */
+
+ #define AINT_ENA1 0x00
+ #define AINT_STAT1 BITW(8)
+ #define ASCSI_SIG BITW(9)
+ #define ASCSI_CNTL (BITW(9)+BITW(8))
+ #define APORT_CNTL BITW(10)
+ #define ARST_CNTL (BITW(10)+BITW(8))
+ #define AXFERCNT0 (BITW(10)+BITW(9))
+ #define AXFERCNT1 (BITW(10)+BITW(9)+BITW(8))
+ #define AXFERCNT2 BITW(11)
+ #define AFIFO_DATA (BITW(11)+BITW(8))
+ #define ASCSISELID (BITW(11)+BITW(9))
+ #define ASCSISYNC0 (BITW(11)+BITW(9)+BITW(8))
+
+
+ #define RAT_OP (BITW(14)+BITW(13)+BITW(11))
+
+ #define SSI_OP (BITW(15)+BITW(11))
+
+
+ #define SSI_ITAR_DISC (ITAR_DISC >> 8)
+ #define SSI_IDO_STRT (IDO_STRT >> 8)
+ #define SSI_IDI_STRT (IDO_STRT >> 8)
+
+ #define SSI_ICMD_COMP (ICMD_COMP >> 8)
+ #define SSI_ITICKLE (ITICKLE >> 8)
+
+ #define SSI_IUNKWN (IUNKWN >> 8)
+ #define SSI_INO_CC (IUNKWN >> 8)
+ #define SSI_IRFAIL (IUNKWN >> 8)
+
+
+ #define NP 0x10 /*Next Phase */
+ #define NTCMD 0x02 /*Non- Tagged Command start */
+ #define CMDPZ 0x04 /*Command phase */
+ #define DINT 0x12 /*Data Out/In interrupt */
+ #define DI 0x13 /*Data Out */
+ #define MI 0x14 /*Message In */
+ #define DC 0x19 /*Disconnect Message */
+ #define ST 0x1D /*Status Phase */
+ #define UNKNWN 0x24 /*Unknown bus action */
+ #define CC 0x25 /*Command Completion failure */
+ #define TICK 0x26 /*New target reselected us. */
+ #define RFAIL 0x27 /*Reselection failed */
+ #define SELCHK 0x28 /*Select & Check SCSI ID latch reg */
+
+
+ #define ID_MSG_STRT hp_aramBase + 0x00
+ #define NON_TAG_ID_MSG hp_aramBase + 0x06
+ #define CMD_STRT hp_aramBase + 0x08
+ #define SYNC_MSGS hp_aramBase + 0x08
+
+
+
+
+
+ #define TAG_STRT 0x00
+ #define SELECTION_START 0x00
+ #define DISCONNECT_START 0x10/2
+ #define END_DATA_START 0x14/2
+ #define NONTAG_STRT 0x02/2
+ #define CMD_ONLY_STRT CMDPZ/2
+ #define TICKLE_STRT TICK/2
+ #define SELCHK_STRT SELCHK/2
+
+
+
+
+#define mEEPROM_CLK_DELAY(port) (RD_HARPOON(port+hp_intstat_1))
+
+#define mWAIT_10MS(port) (RD_HARPOON(port+hp_intstat_1))
+
+
+#define CLR_XFER_CNT(port) (WR_HARPOON(port+hp_xfercnt_0, 0x00))
+
+#define SET_XFER_CNT(port, data) (WR_HARP32(port,hp_xfercnt_0,data))
+
+#define GET_XFER_CNT(port, xfercnt) {RD_HARP32(port,hp_xfercnt_0,xfercnt);
xfercnt &= 0xFFFFFF;}
+/* #define GET_XFER_CNT(port, xfercnt) (xfercnt =
RD_HARPOON(port+hp_xfercnt_2), \
+ xfercnt <<= 16,\
+ xfercnt |=
RDW_HARPOON((USHORT)(port+hp_xfercnt_0)))
+ */
+#if defined(DOS)
+#define HP_SETUP_ADDR_CNT(port,addr,count)
(WRW_HARPOON((USHORT)(port+hp_host_addr_lo), (USHORT)(addr & 0x0000FFFFL)),\
+ addr >>= 16,\
+ WRW_HARPOON((USHORT)(port+hp_host_addr_hmi), (USHORT)(addr &
0x0000FFFFL)),\
+ WR_HARP32(port,hp_xfercnt_0,count),\
+ WRW_HARPOON((USHORT)(port+hp_xfer_cnt_lo), (USHORT)(count &
0x0000FFFFL)),\
+ count >>= 16,\
+ WR_HARPOON(port+hp_xfer_cnt_hi, (count & 0xFF)))
+#else
+#define HP_SETUP_ADDR_CNT(port,addr,count)
(WRW_HARPOON((port+hp_host_addr_lo), (USHORT)(addr & 0x0000FFFFL)),\
+ addr >>= 16,\
+ WRW_HARPOON((port+hp_host_addr_hmi), (USHORT)(addr & 0x0000FFFFL)),\
+ WR_HARP32(port,hp_xfercnt_0,count),\
+ WRW_HARPOON((port+hp_xfer_cnt_lo), (USHORT)(count & 0x0000FFFFL)),\
+ count >>= 16,\
+ WR_HARPOON(port+hp_xfer_cnt_hi, (count & 0xFF)))
+#endif
+
+#define ACCEPT_MSG(port) {while(RD_HARPOON(port+hp_scsisig) & SCSI_REQ){}\
+ WR_HARPOON(port+hp_scsisig, S_ILL_PH);}
+
+
+#define ACCEPT_MSG_ATN(port) {while(RD_HARPOON(port+hp_scsisig) & SCSI_REQ){}\
+ WR_HARPOON(port+hp_scsisig, (S_ILL_PH|SCSI_ATN));}
+
+#define ACCEPT_STAT(port) {while(RD_HARPOON(port+hp_scsisig) & SCSI_REQ){}\
+ WR_HARPOON(port+hp_scsisig, S_ILL_PH);}
+
+#define ACCEPT_STAT_ATN(port) {while(RD_HARPOON(port+hp_scsisig) & SCSI_REQ){}\
+ WR_HARPOON(port+hp_scsisig, (S_ILL_PH|SCSI_ATN));}
+
+#define DISABLE_AUTO(port) (WR_HARPOON(port+hp_scsireset, PROG_RESET),\
+ WR_HARPOON(port+hp_scsireset, 0x00))
+
+#define ARAM_ACCESS(p_port) (WR_HARPOON(p_port+hp_page_ctrl, \
+ (RD_HARPOON(p_port+hp_page_ctrl) | SGRAM_ARAM)))
+
+#define SGRAM_ACCESS(p_port) (WR_HARPOON(p_port+hp_page_ctrl, \
+ (RD_HARPOON(p_port+hp_page_ctrl) & ~SGRAM_ARAM)))
+
+#define MDISABLE_INT(p_port) (WR_HARPOON(p_port+hp_page_ctrl, \
+ (RD_HARPOON(p_port+hp_page_ctrl) |
G_INT_DISABLE)))
+
+#define MENABLE_INT(p_port) (WR_HARPOON(p_port+hp_page_ctrl, \
+ (RD_HARPOON(p_port+hp_page_ctrl) &
~G_INT_DISABLE)))
+
+
+
+#endif
+
+
+#if (FW_TYPE==_UCB_MGR_)
+void ReadNVRam(PSCCBcard pCurrCard,PUCB p_ucb);
+void WriteNVRam(PSCCBcard pCurrCard,PUCB p_ucb);
+void UpdateCheckSum(u32bits baseport);
+#endif // (FW_TYPE==_UCB_MGR_)
+
+#if defined(DOS)
+UCHAR sfm(USHORT port, PSCCB pcurrSCCB);
+void scsiStartAuto(USHORT port);
+UCHAR sisyncn(USHORT port, UCHAR p_card, UCHAR syncFlag);
+void ssel(USHORT port, UCHAR p_card);
+void sres(USHORT port, UCHAR p_card, PSCCBcard pCurrCard);
+void sdecm(UCHAR message, USHORT port, UCHAR p_card);
+void shandem(USHORT port, UCHAR p_card,PSCCB pCurrSCCB);
+void stsyncn(USHORT port, UCHAR p_card);
+void sisyncr(USHORT port,UCHAR sync_pulse, UCHAR offset);
+void sssyncv(USHORT p_port, UCHAR p_id, UCHAR p_sync_value, PSCCBMgr_tar_info
currTar_Info);
+void sresb(USHORT port, UCHAR p_card);
+void sxfrp(USHORT p_port, UCHAR p_card);
+void schkdd(USHORT port, UCHAR p_card);
+UCHAR RdStack(USHORT port, UCHAR index);
+void WrStack(USHORT portBase, UCHAR index, UCHAR data);
+UCHAR ChkIfChipInitialized(USHORT ioPort);
+
+#if defined(V302)
+UCHAR GetTarLun(USHORT port, UCHAR p_card, UCHAR our_target, PSCCBcard
pCurrCard, PUCHAR tag, PUCHAR lun);
+#endif
+
+void SendMsg(USHORT port, UCHAR message);
+void queueFlushTargSccb(UCHAR p_card, UCHAR thisTarg, UCHAR error_code);
+UCHAR scsellDOS(USHORT p_port, UCHAR targ_id);
+#else
+UCHAR sfm(ULONG port, PSCCB pcurrSCCB);
+void scsiStartAuto(ULONG port);
+UCHAR sisyncn(ULONG port, UCHAR p_card, UCHAR syncFlag);
+void ssel(ULONG port, UCHAR p_card);
+void sres(ULONG port, UCHAR p_card, PSCCBcard pCurrCard);
+void sdecm(UCHAR message, ULONG port, UCHAR p_card);
+void shandem(ULONG port, UCHAR p_card,PSCCB pCurrSCCB);
+void stsyncn(ULONG port, UCHAR p_card);
+void sisyncr(ULONG port,UCHAR sync_pulse, UCHAR offset);
+void sssyncv(ULONG p_port, UCHAR p_id, UCHAR p_sync_value, PSCCBMgr_tar_info
currTar_Info);
+void sresb(ULONG port, UCHAR p_card);
+void sxfrp(ULONG p_port, UCHAR p_card);
+void schkdd(ULONG port, UCHAR p_card);
+UCHAR RdStack(ULONG port, UCHAR index);
+void WrStack(ULONG portBase, UCHAR index, UCHAR data);
+UCHAR ChkIfChipInitialized(ULONG ioPort);
+
+#if defined(V302)
+UCHAR GetTarLun(ULONG port, UCHAR p_card, UCHAR our_target, PSCCBcard
pCurrCard, PUCHAR tar, PUCHAR lun);
+#endif
+
+void SendMsg(ULONG port, UCHAR message);
+void queueFlushTargSccb(UCHAR p_card, UCHAR thisTarg, UCHAR error_code);
+#endif
+
+void ssenss(PSCCBcard pCurrCard);
+void sinits(PSCCB p_sccb, UCHAR p_card);
+void RNVRamData(PNVRamInfo pNvRamInfo);
+
+#if defined(WIDE_SCSI)
+ #if defined(DOS)
+ UCHAR siwidn(USHORT port, UCHAR p_card);
+ void stwidn(USHORT port, UCHAR p_card);
+ void siwidr(USHORT port, UCHAR width);
+ #else
+ UCHAR siwidn(ULONG port, UCHAR p_card);
+ void stwidn(ULONG port, UCHAR p_card);
+ void siwidr(ULONG port, UCHAR width);
+ #endif
+#endif
+
+
+void queueSelectFail(PSCCBcard pCurrCard, UCHAR p_card);
+void queueDisconnect(PSCCB p_SCCB, UCHAR p_card);
+void queueCmdComplete(PSCCBcard pCurrCard, PSCCB p_SCCB, UCHAR p_card);
+void queueSearchSelect(PSCCBcard pCurrCard, UCHAR p_card);
+void queueFlushSccb(UCHAR p_card, UCHAR error_code);
+void queueAddSccb(PSCCB p_SCCB, UCHAR card);
+UCHAR queueFindSccb(PSCCB p_SCCB, UCHAR p_card);
+void utilUpdateResidual(PSCCB p_SCCB);
+USHORT CalcCrc16(UCHAR buffer[]);
+UCHAR CalcLrc(UCHAR buffer[]);
+
+
+#if defined(DOS)
+void Wait1Second(USHORT p_port);
+void Wait(USHORT p_port, UCHAR p_delay);
+void utilEEWriteOnOff(USHORT p_port,UCHAR p_mode);
+void utilEEWrite(USHORT p_port, USHORT ee_data, USHORT ee_addr);
+USHORT utilEERead(USHORT p_port, USHORT ee_addr);
+USHORT utilEEReadOrg(USHORT p_port, USHORT ee_addr);
+void utilEESendCmdAddr(USHORT p_port, UCHAR ee_cmd, USHORT ee_addr);
+#else
+void Wait1Second(ULONG p_port);
+void Wait(ULONG p_port, UCHAR p_delay);
+void utilEEWriteOnOff(ULONG p_port,UCHAR p_mode);
+void utilEEWrite(ULONG p_port, USHORT ee_data, USHORT ee_addr);
+USHORT utilEERead(ULONG p_port, USHORT ee_addr);
+USHORT utilEEReadOrg(ULONG p_port, USHORT ee_addr);
+void utilEESendCmdAddr(ULONG p_port, UCHAR ee_cmd, USHORT ee_addr);
+#endif
+
+
+
+#if defined(OS2)
+ void far phaseDataOut(ULONG port, UCHAR p_card);
+ void far phaseDataIn(ULONG port, UCHAR p_card);
+ void far phaseCommand(ULONG port, UCHAR p_card);
+ void far phaseStatus(ULONG port, UCHAR p_card);
+ void far phaseMsgOut(ULONG port, UCHAR p_card);
+ void far phaseMsgIn(ULONG port, UCHAR p_card);
+ void far phaseIllegal(ULONG port, UCHAR p_card);
+#else
+ #if defined(DOS)
+ void phaseDataOut(USHORT port, UCHAR p_card);
+ void phaseDataIn(USHORT port, UCHAR p_card);
+ void phaseCommand(USHORT port, UCHAR p_card);
+ void phaseStatus(USHORT port, UCHAR p_card);
+ void phaseMsgOut(USHORT port, UCHAR p_card);
+ void phaseMsgIn(USHORT port, UCHAR p_card);
+ void phaseIllegal(USHORT port, UCHAR p_card);
+ #else
+ void phaseDataOut(ULONG port, UCHAR p_card);
+ void phaseDataIn(ULONG port, UCHAR p_card);
+ void phaseCommand(ULONG port, UCHAR p_card);
+ void phaseStatus(ULONG port, UCHAR p_card);
+ void phaseMsgOut(ULONG port, UCHAR p_card);
+ void phaseMsgIn(ULONG port, UCHAR p_card);
+ void phaseIllegal(ULONG port, UCHAR p_card);
+ #endif
+#endif
+
+#if defined(DOS)
+void phaseDecode(USHORT port, UCHAR p_card);
+void phaseChkFifo(USHORT port, UCHAR p_card);
+void phaseBusFree(USHORT p_port, UCHAR p_card);
+#else
+void phaseDecode(ULONG port, UCHAR p_card);
+void phaseChkFifo(ULONG port, UCHAR p_card);
+void phaseBusFree(ULONG p_port, UCHAR p_card);
+#endif
+
+
+
+
+#if defined(DOS)
+void XbowInit(USHORT port, UCHAR scamFlg);
+void BusMasterInit(USHORT p_port);
+int DiagXbow(USHORT port);
+int DiagBusMaster(USHORT port);
+void DiagEEPROM(USHORT p_port);
+#else
+void XbowInit(ULONG port, UCHAR scamFlg);
+void BusMasterInit(ULONG p_port);
+int DiagXbow(ULONG port);
+int DiagBusMaster(ULONG port);
+void DiagEEPROM(ULONG p_port);
+#endif
+
+
+
+
+#if defined(DOS)
+void busMstrAbort(USHORT port);
+UCHAR busMstrTimeOut(USHORT port);
+void dataXferProcessor(USHORT port, PSCCBcard pCurrCard);
+void busMstrSGDataXferStart(USHORT port, PSCCB pCurrSCCB);
+void busMstrDataXferStart(USHORT port, PSCCB pCurrSCCB);
+void hostDataXferAbort(USHORT port, UCHAR p_card, PSCCB pCurrSCCB);
+#else
+void busMstrAbort(ULONG port);
+UCHAR busMstrTimeOut(ULONG port);
+void dataXferProcessor(ULONG port, PSCCBcard pCurrCard);
+void busMstrSGDataXferStart(ULONG port, PSCCB pCurrSCCB);
+void busMstrDataXferStart(ULONG port, PSCCB pCurrSCCB);
+void hostDataXferAbort(ULONG port, UCHAR p_card, PSCCB pCurrSCCB);
+#endif
+void hostDataXferRestart(PSCCB currSCCB);
+
+
+#if defined (DOS)
+UCHAR SccbMgr_bad_isr(USHORT p_port, UCHAR p_card, PSCCBcard pCurrCard, USHORT
p_int);
+#else
+UCHAR SccbMgr_bad_isr(ULONG p_port, UCHAR p_card, PSCCBcard pCurrCard, USHORT
p_int);
+
+#endif
+
+void SccbMgrTableInitAll(void);
+void SccbMgrTableInitCard(PSCCBcard pCurrCard, UCHAR p_card);
+void SccbMgrTableInitTarget(UCHAR p_card, UCHAR target);
+
+
+
+void scini(UCHAR p_card, UCHAR p_our_id, UCHAR p_power_up);
+
+#if defined(DOS)
+int scarb(USHORT p_port, UCHAR p_sel_type);
+void scbusf(USHORT p_port);
+void scsel(USHORT p_port);
+void scasid(UCHAR p_card, USHORT p_port);
+UCHAR scxferc(USHORT p_port, UCHAR p_data);
+UCHAR scsendi(USHORT p_port, UCHAR p_id_string[]);
+UCHAR sciso(USHORT p_port, UCHAR p_id_string[]);
+void scwirod(USHORT p_port, UCHAR p_data_bit);
+void scwiros(USHORT p_port, UCHAR p_data_bit);
+UCHAR scvalq(UCHAR p_quintet);
+UCHAR scsell(USHORT p_port, UCHAR targ_id);
+void scwtsel(USHORT p_port);
+void inisci(UCHAR p_card, USHORT p_port, UCHAR p_our_id);
+void scsavdi(UCHAR p_card, USHORT p_port);
+#else
+int scarb(ULONG p_port, UCHAR p_sel_type);
+void scbusf(ULONG p_port);
+void scsel(ULONG p_port);
+void scasid(UCHAR p_card, ULONG p_port);
+UCHAR scxferc(ULONG p_port, UCHAR p_data);
+UCHAR scsendi(ULONG p_port, UCHAR p_id_string[]);
+UCHAR sciso(ULONG p_port, UCHAR p_id_string[]);
+void scwirod(ULONG p_port, UCHAR p_data_bit);
+void scwiros(ULONG p_port, UCHAR p_data_bit);
+UCHAR scvalq(UCHAR p_quintet);
+UCHAR scsell(ULONG p_port, UCHAR targ_id);
+void scwtsel(ULONG p_port);
+void inisci(UCHAR p_card, ULONG p_port, UCHAR p_our_id);
+void scsavdi(UCHAR p_card, ULONG p_port);
+#endif
+UCHAR scmachid(UCHAR p_card, UCHAR p_id_string[]);
+
+
+#if defined(DOS)
+void autoCmdCmplt(USHORT p_port, UCHAR p_card);
+void autoLoadDefaultMap(USHORT p_port);
+#else
+void autoCmdCmplt(ULONG p_port, UCHAR p_card);
+void autoLoadDefaultMap(ULONG p_port);
+#endif
+
+
+
+#if (FW_TYPE==_SCCB_MGR_)
+ void OS_start_timer(unsigned long ioport, unsigned long timeout);
+ void OS_stop_timer(unsigned long ioport, unsigned long timeout);
+ void OS_disable_int(unsigned char intvec);
+ void OS_enable_int(unsigned char intvec);
+ void OS_delay(unsigned long count);
+ int OS_VirtToPhys(u32bits CardHandle, u32bits *physaddr, u32bits
*virtaddr);
+ #if !(defined(UNIX) || defined(OS2) || defined(SOLARIS_REAL_MODE))
+ void OS_Lock(PSCCBMGR_INFO pCardInfo);
+ void OS_UnLock(PSCCBMGR_INFO pCardInfo);
+#endif // if FW_TYPE == ...
+
+#endif
+
+extern SCCBCARD BL_Card[MAX_CARDS];
+extern SCCBMGR_TAR_INFO sccbMgrTbl[MAX_CARDS][MAX_SCSI_TAR];
+
+
+#if defined(OS2)
+ extern void (far *s_PhaseTbl[8]) (ULONG, UCHAR);
+#else
+ #if defined(DOS)
+ extern void (*s_PhaseTbl[8]) (USHORT, UCHAR);
+ #else
+ extern void (*s_PhaseTbl[8]) (ULONG, UCHAR);
+ #endif
+#endif
+
+extern SCCBSCAM_INFO scamInfo[MAX_SCSI_TAR];
+extern NVRAMINFO nvRamInfo[MAX_MB_CARDS];
+#if defined(DOS) || defined(OS2)
+extern UCHAR temp_id_string[ID_STRING_LENGTH];
+#endif
+extern UCHAR scamHAString[];
+
+
+extern UCHAR mbCards;
+#if defined(BUGBUG)
+extern UCHAR debug_int[MAX_CARDS][debug_size];
+extern UCHAR debug_index[MAX_CARDS];
+void Debug_Load(UCHAR p_card, UCHAR p_bug_data);
+#endif
+
+#if (FW_TYPE==_SCCB_MGR_)
+#if defined(DOS)
+ extern UCHAR first_time;
+#endif
+#endif /* (FW_TYPE==_SCCB_MGR_) */
+
+#if (FW_TYPE==_UCB_MGR_)
+#if defined(DOS)
+ extern u08bits first_time;
+#endif
+#endif /* (FW_TYPE==_UCB_MGR_) */
+
+#if defined(BUGBUG)
+void Debug_Load(UCHAR p_card, UCHAR p_bug_data);
+#endif
+
+extern unsigned int SccbGlobalFlags;
+
+
+/*----------------------------------------------------------------------
+ *
+ *
+ * Copyright 1995-1996 by Mylex Corporation. All Rights Reserved
+ *
+ * This file is available under both the GNU General Public License
+ * and a BSD-style copyright; see LICENSE.FlashPoint for details.
+ *
+ * $Workfile: sccb.c $
+ *
+ * Description: Functions relating to handling of the SCCB interface
+ * between the device driver and the HARPOON.
+ *
+ * $Date: 1999/04/26 05:53:56 $
+ *
+ * $Revision: 1.1 $
+ *
+ *----------------------------------------------------------------------*/
+
+/*#include <globals.h>*/
+
+#if (FW_TYPE==_UCB_MGR_)
+ /*#include <budi.h>*/
+ /*#include <budioctl.h>*/
+#endif
+
+/*#include <sccbmgr.h>*/
+/*#include <blx30.h>*/
+/*#include <target.h>*/
+/*#include <eeprom.h>*/
+/*#include <scsi2.h>*/
+/*#include <harpoon.h>*/
+
+
+
+#if (FW_TYPE==_SCCB_MGR_)
+#define mOS_Lock(card) OS_Lock((PSCCBMGR_INFO)(((PSCCBcard)card)->cardInfo))
+#define mOS_UnLock(card)
OS_UnLock((PSCCBMGR_INFO)(((PSCCBcard)card)->cardInfo))
+#else /* FW_TYPE==_UCB_MGR_ */
+#define mOS_Lock(card) OS_Lock((u32bits)(((PSCCBcard)card)->ioPort))
+#define mOS_UnLock(card) OS_UnLock((u32bits)(((PSCCBcard)card)->ioPort))
+#endif
+
+
+/*
+extern SCCBMGR_TAR_INFO sccbMgrTbl[MAX_CARDS][MAX_SCSI_TAR];
+extern SCCBCARD BL_Card[MAX_CARDS];
+
+extern NVRAMINFO nvRamInfo[MAX_MB_CARDS];
+extern UCHAR mbCards;
+
+#if defined (OS2)
+ extern void (far *s_PhaseTbl[8]) (ULONG, UCHAR);
+#else
+ #if defined(DOS)
+ extern void (*s_PhaseTbl[8]) (USHORT, UCHAR);
+ #else
+ extern void (*s_PhaseTbl[8]) (ULONG, UCHAR);
+ #endif
+#endif
+
+
+#if defined(BUGBUG)
+extern UCHAR debug_int[MAX_CARDS][debug_size];
+extern UCHAR debug_index[MAX_CARDS];
+void Debug_Load(UCHAR p_card, UCHAR p_bug_data);
+#endif
+*/
+
+#if (FW_TYPE==_SCCB_MGR_)
+
+/*---------------------------------------------------------------------
+ *
+ * Function: SccbMgr_sense_adapter
+ *
+ * Description: Setup and/or Search for cards and return info to caller.
+ *
+ *---------------------------------------------------------------------*/
+
+int SccbMgr_sense_adapter(PSCCBMGR_INFO pCardInfo)
+{
+#if defined(DOS)
+#else
+ static UCHAR first_time = 1;
+#endif
+
+ UCHAR i,j,id,ScamFlg;
+ USHORT temp,temp2,temp3,temp4,temp5,temp6;
+#if defined(DOS)
+ USHORT ioport;
+#else
+ ULONG ioport;
+#endif
+ PNVRamInfo pCurrNvRam;
+
+#if defined(DOS)
+ ioport = (USHORT)pCardInfo->si_baseaddr;
+#else
+ ioport = pCardInfo->si_baseaddr;
+#endif
+
+
+ if (RD_HARPOON(ioport+hp_vendor_id_0) != ORION_VEND_0)
+ return((int)FAILURE);
+
+ if ((RD_HARPOON(ioport+hp_vendor_id_1) != ORION_VEND_1))
+ return((int)FAILURE);
+
+ if ((RD_HARPOON(ioport+hp_device_id_0) != ORION_DEV_0))
+ return((int)FAILURE);
+
+ if ((RD_HARPOON(ioport+hp_device_id_1) != ORION_DEV_1))
+ return((int)FAILURE);
+
+
+ if (RD_HARPOON(ioport+hp_rev_num) != 0x0f){
+
+/* For new Harpoon then check for sub_device ID LSB
+ the bits(0-3) must be all ZERO for compatible with
+ current version of SCCBMgr, else skip this Harpoon
+ device. */
+
+ if (RD_HARPOON(ioport+hp_sub_device_id_0) & 0x0f)
+ return((int)FAILURE);
+ }
+
+ if (first_time)
+ {
+ SccbMgrTableInitAll();
+ first_time = 0;
+ mbCards = 0;
+ }
+
+ if(RdStack(ioport, 0) != 0x00) {
+ if(ChkIfChipInitialized(ioport) == FALSE)
+ {
+ pCurrNvRam = NULL;
+ WR_HARPOON(ioport+hp_semaphore, 0x00);
+ XbowInit(ioport, 0); /*Must Init the SCSI
before attempting */
+ DiagEEPROM(ioport);
+ }
+ else
+ {
+ if(mbCards < MAX_MB_CARDS) {
+ pCurrNvRam = &nvRamInfo[mbCards];
+ mbCards++;
+ pCurrNvRam->niBaseAddr = ioport;
+ RNVRamData(pCurrNvRam);
+ }else
+ return((int) FAILURE);
+ }
+ }else
+ pCurrNvRam = NULL;
+#if defined (NO_BIOS_OPTION)
+ pCurrNvRam = NULL;
+ XbowInit(ioport, 0); /*Must Init the SCSI before attempting
*/
+ DiagEEPROM(ioport);
+#endif /* No BIOS Option */
+
+ WR_HARPOON(ioport+hp_clkctrl_0, CLKCTRL_DEFAULT);
+ WR_HARPOON(ioport+hp_sys_ctrl, 0x00);
+
+ if(pCurrNvRam)
+ pCardInfo->si_id = pCurrNvRam->niAdapId;
+ else
+ pCardInfo->si_id = (UCHAR)(utilEERead(ioport, (ADAPTER_SCSI_ID/2)) &
+ (UCHAR)0x0FF);
+
+ pCardInfo->si_lun = 0x00;
+ pCardInfo->si_fw_revision = ORION_FW_REV;
+ temp2 = 0x0000;
+ temp3 = 0x0000;
+ temp4 = 0x0000;
+ temp5 = 0x0000;
+ temp6 = 0x0000;
+
+ for (id = 0; id < (16/2); id++) {
+
+ if(pCurrNvRam){
+ temp = (USHORT) pCurrNvRam->niSyncTbl[id];
+ temp = ((temp & 0x03) + ((temp << 4) & 0xc0)) +
+ (((temp << 4) & 0x0300) + ((temp << 8)
& 0xc000));
+ }else
+ temp = utilEERead(ioport, (USHORT)((SYNC_RATE_TBL/2)+id));
+
+ for (i = 0; i < 2; temp >>=8,i++) {
+
+ temp2 >>= 1;
+ temp3 >>= 1;
+ temp4 >>= 1;
+ temp5 >>= 1;
+ temp6 >>= 1;
+ switch (temp & 0x3)
+ {
+ case AUTO_RATE_20: /* Synchronous, 20 mega-transfers/second */
+ temp6 |= 0x8000; /* Fall through */
+ case AUTO_RATE_10: /* Synchronous, 10 mega-transfers/second */
+ temp5 |= 0x8000; /* Fall through */
+ case AUTO_RATE_05: /* Synchronous, 5 mega-transfers/second */
+ temp2 |= 0x8000; /* Fall through */
+ case AUTO_RATE_00: /* Asynchronous */
+ break;
+ }
+
+ if (temp & DISC_ENABLE_BIT)
+ temp3 |= 0x8000;
+
+ if (temp & WIDE_NEGO_BIT)
+ temp4 |= 0x8000;
+
+ }
+ }
+
+ pCardInfo->si_per_targ_init_sync = temp2;
+ pCardInfo->si_per_targ_no_disc = temp3;
+ pCardInfo->si_per_targ_wide_nego = temp4;
+ pCardInfo->si_per_targ_fast_nego = temp5;
+ pCardInfo->si_per_targ_ultra_nego = temp6;
+
+ if(pCurrNvRam)
+ i = pCurrNvRam->niSysConf;
+ else
+ i = (UCHAR)(utilEERead(ioport, (SYSTEM_CONFIG/2)));
+
+ if(pCurrNvRam)
+ ScamFlg = pCurrNvRam->niScamConf;
+ else
+ ScamFlg = (UCHAR) utilEERead(ioport, SCAM_CONFIG/2);
+
+ pCardInfo->si_flags = 0x0000;
+
+ if (i & 0x01)
+ pCardInfo->si_flags |= SCSI_PARITY_ENA;
+
+ if (!(i & 0x02))
+ pCardInfo->si_flags |= SOFT_RESET;
+
+ if (i & 0x10)
+ pCardInfo->si_flags |= EXTENDED_TRANSLATION;
+
+ if (ScamFlg & SCAM_ENABLED)
+ pCardInfo->si_flags |= FLAG_SCAM_ENABLED;
+
+ if (ScamFlg & SCAM_LEVEL2)
+ pCardInfo->si_flags |= FLAG_SCAM_LEVEL2;
+
+ j = (RD_HARPOON(ioport+hp_bm_ctrl) & ~SCSI_TERM_ENA_L);
+ if (i & 0x04) {
+ j |= SCSI_TERM_ENA_L;
+ }
+ WR_HARPOON(ioport+hp_bm_ctrl, j );
+
+ j = (RD_HARPOON(ioport+hp_ee_ctrl) & ~SCSI_TERM_ENA_H);
+ if (i & 0x08) {
+ j |= SCSI_TERM_ENA_H;
+ }
+ WR_HARPOON(ioport+hp_ee_ctrl, j );
+
+ if (!(RD_HARPOON(ioport+hp_page_ctrl) & NARROW_SCSI_CARD))
+
+ pCardInfo->si_flags |= SUPPORT_16TAR_32LUN;
+
+ pCardInfo->si_card_family = HARPOON_FAMILY;
+ pCardInfo->si_bustype = BUSTYPE_PCI;
+
+ if(pCurrNvRam){
+ pCardInfo->si_card_model[0] = '9';
+ switch(pCurrNvRam->niModel & 0x0f){
+ case MODEL_LT:
+ pCardInfo->si_card_model[1] = '3';
+ pCardInfo->si_card_model[2] = '0';
+ break;
+ case MODEL_LW:
+ pCardInfo->si_card_model[1] = '5';
+ pCardInfo->si_card_model[2] = '0';
+ break;
+ case MODEL_DL:
+ pCardInfo->si_card_model[1] = '3';
+ pCardInfo->si_card_model[2] = '2';
+ break;
+ case MODEL_DW:
+ pCardInfo->si_card_model[1] = '5';
+ pCardInfo->si_card_model[2] = '2';
+ break;
+ }
+ }else{
+ temp = utilEERead(ioport, (MODEL_NUMB_0/2));
+ pCardInfo->si_card_model[0] = (UCHAR)(temp >> 8);
+ temp = utilEERead(ioport, (MODEL_NUMB_2/2));
+
+ pCardInfo->si_card_model[1] = (UCHAR)(temp & 0x00FF);
+ pCardInfo->si_card_model[2] = (UCHAR)(temp >> 8);
+ }
+
+ if (pCardInfo->si_card_model[1] == '3')
+ {
+ if (RD_HARPOON(ioport+hp_ee_ctrl) & BIT(7))
+ pCardInfo->si_flags |= LOW_BYTE_TERM;
+ }
+ else if (pCardInfo->si_card_model[2] == '0')
+ {
+ temp = RD_HARPOON(ioport+hp_xfer_pad);
+ WR_HARPOON(ioport+hp_xfer_pad, (temp & ~BIT(4)));
+ if (RD_HARPOON(ioport+hp_ee_ctrl) & BIT(7))
+ pCardInfo->si_flags |= LOW_BYTE_TERM;
+ WR_HARPOON(ioport+hp_xfer_pad, (temp | BIT(4)));
+ if (RD_HARPOON(ioport+hp_ee_ctrl) & BIT(7))
+ pCardInfo->si_flags |= HIGH_BYTE_TERM;
+ WR_HARPOON(ioport+hp_xfer_pad, temp);
+ }
+ else
+ {
+ temp = RD_HARPOON(ioport+hp_ee_ctrl);
+ temp2 = RD_HARPOON(ioport+hp_xfer_pad);
+ WR_HARPOON(ioport+hp_ee_ctrl, (temp | SEE_CS));
+ WR_HARPOON(ioport+hp_xfer_pad, (temp2 | BIT(4)));
+ temp3 = 0;
+ for (i = 0; i < 8; i++)
+ {
+ temp3 <<= 1;
+ if (!(RD_HARPOON(ioport+hp_ee_ctrl) & BIT(7)))
+ temp3 |= 1;
+ WR_HARPOON(ioport+hp_xfer_pad, (temp2 & ~BIT(4)));
+ WR_HARPOON(ioport+hp_xfer_pad, (temp2 | BIT(4)));
+ }
+ WR_HARPOON(ioport+hp_ee_ctrl, temp);
+ WR_HARPOON(ioport+hp_xfer_pad, temp2);
+ if (!(temp3 & BIT(7)))
+ pCardInfo->si_flags |= LOW_BYTE_TERM;
+ if (!(temp3 & BIT(6)))
+ pCardInfo->si_flags |= HIGH_BYTE_TERM;
+ }
+
+
+ ARAM_ACCESS(ioport);
+
+ for ( i = 0; i < 4; i++ ) {
+
+ pCardInfo->si_XlatInfo[i] =
+ RD_HARPOON(ioport+hp_aramBase+BIOS_DATA_OFFSET+i);
+ }
+
+ /* return with -1 if no sort, else return with
+ logical card number sorted by BIOS (zero-based) */
+
+ pCardInfo->si_relative_cardnum =
+ (UCHAR)(RD_HARPOON(ioport+hp_aramBase+BIOS_RELATIVE_CARD)-1);
+
+ SGRAM_ACCESS(ioport);
+
+ s_PhaseTbl[0] = phaseDataOut;
+ s_PhaseTbl[1] = phaseDataIn;
+ s_PhaseTbl[2] = phaseIllegal;
+ s_PhaseTbl[3] = phaseIllegal;
+ s_PhaseTbl[4] = phaseCommand;
+ s_PhaseTbl[5] = phaseStatus;
+ s_PhaseTbl[6] = phaseMsgOut;
+ s_PhaseTbl[7] = phaseMsgIn;
+
+ pCardInfo->si_present = 0x01;
+
+#if defined(BUGBUG)
+
+
+ for (i = 0; i < MAX_CARDS; i++) {
+
+ for (id=0; id<debug_size; id++)
+ debug_int[i][id] = (UCHAR)0x00;
+ debug_index[i] = 0;
+ }
+
+#endif
+
+ return(0);
+}
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: SccbMgr_config_adapter
+ *
+ * Description: Setup adapter for normal operation (hard reset).
+ *
+ *---------------------------------------------------------------------*/
+
+#if defined(DOS)
+USHORT SccbMgr_config_adapter(PSCCBMGR_INFO pCardInfo)
+#else
+ULONG SccbMgr_config_adapter(PSCCBMGR_INFO pCardInfo)
+#endif
+{
+ PSCCBcard CurrCard = NULL;
+ PNVRamInfo pCurrNvRam;
+ UCHAR i,j,thisCard, ScamFlg;
+ USHORT temp,sync_bit_map,id;
+#if defined(DOS)
+ USHORT ioport;
+#else
+ ULONG ioport;
+#endif
+
+#if defined(DOS)
+ ioport = (USHORT)pCardInfo->si_baseaddr;
+#else
+ ioport = pCardInfo->si_baseaddr;
+#endif
+
+ for(thisCard =0; thisCard <= MAX_CARDS; thisCard++) {
+
+ if (thisCard == MAX_CARDS) {
+
+ return(FAILURE);
+ }
+
+ if (BL_Card[thisCard].ioPort == ioport) {
+
+ CurrCard = &BL_Card[thisCard];
+ SccbMgrTableInitCard(CurrCard,thisCard);
+ break;
+ }
+
+ else if (BL_Card[thisCard].ioPort == 0x00) {
+
+ BL_Card[thisCard].ioPort = ioport;
+ CurrCard = &BL_Card[thisCard];
+
+ if(mbCards)
+ for(i = 0; i < mbCards; i++){
+ if(CurrCard->ioPort ==
nvRamInfo[i].niBaseAddr)
+ CurrCard->pNvRamInfo =
&nvRamInfo[i];
+ }
+ SccbMgrTableInitCard(CurrCard,thisCard);
+ CurrCard->cardIndex = thisCard;
+ CurrCard->cardInfo = pCardInfo;
+
+ break;
+ }
+ }
+
+ pCurrNvRam = CurrCard->pNvRamInfo;
+
+ if(pCurrNvRam){
+ ScamFlg = pCurrNvRam->niScamConf;
+ }
+ else{
+ ScamFlg = (UCHAR) utilEERead(ioport, SCAM_CONFIG/2);
+ }
+
+
+ BusMasterInit(ioport);
+ XbowInit(ioport, ScamFlg);
+
+#if defined (NO_BIOS_OPTION)
+
+
+ if (DiagXbow(ioport)) return(FAILURE);
+ if (DiagBusMaster(ioport)) return(FAILURE);
+
+#endif /* No BIOS Option */
+
+ autoLoadDefaultMap(ioport);
+
+
+ for (i = 0,id = 0x01; i != pCardInfo->si_id; i++,id <<= 1){}
+
+ WR_HARPOON(ioport+hp_selfid_0, id);
+ WR_HARPOON(ioport+hp_selfid_1, 0x00);
+ WR_HARPOON(ioport+hp_arb_id, pCardInfo->si_id);
+ CurrCard->ourId = pCardInfo->si_id;
+
+ i = (UCHAR) pCardInfo->si_flags;
+ if (i & SCSI_PARITY_ENA)
+ WR_HARPOON(ioport+hp_portctrl_1,(HOST_MODE8 | CHK_SCSI_P));
+
+ j = (RD_HARPOON(ioport+hp_bm_ctrl) & ~SCSI_TERM_ENA_L);
+ if (i & LOW_BYTE_TERM)
+ j |= SCSI_TERM_ENA_L;
+ WR_HARPOON(ioport+hp_bm_ctrl, j);
+
+ j = (RD_HARPOON(ioport+hp_ee_ctrl) & ~SCSI_TERM_ENA_H);
+ if (i & HIGH_BYTE_TERM)
+ j |= SCSI_TERM_ENA_H;
+ WR_HARPOON(ioport+hp_ee_ctrl, j );
+
+
+ if (!(pCardInfo->si_flags & SOFT_RESET)) {
+
+ sresb(ioport,thisCard);
+
+ scini(thisCard, pCardInfo->si_id, 0);
+ }
+
+
+
+ if (pCardInfo->si_flags & POST_ALL_UNDERRRUNS)
+ CurrCard->globalFlags |= F_NO_FILTER;
+
+ if(pCurrNvRam){
+ if(pCurrNvRam->niSysConf & 0x10)
+ CurrCard->globalFlags |= F_GREEN_PC;
+ }
+ else{
+ if (utilEERead(ioport, (SYSTEM_CONFIG/2)) & GREEN_PC_ENA)
+ CurrCard->globalFlags |= F_GREEN_PC;
+ }
+
+ /* Set global flag to indicate Re-Negotiation to be done on all
+ ckeck condition */
+ if(pCurrNvRam){
+ if(pCurrNvRam->niScsiConf & 0x04)
+ CurrCard->globalFlags |= F_DO_RENEGO;
+ }
+ else{
+ if (utilEERead(ioport, (SCSI_CONFIG/2)) & RENEGO_ENA)
+ CurrCard->globalFlags |= F_DO_RENEGO;
+ }
+
+ if(pCurrNvRam){
+ if(pCurrNvRam->niScsiConf & 0x08)
+ CurrCard->globalFlags |= F_CONLUN_IO;
+ }
+ else{
+ if (utilEERead(ioport, (SCSI_CONFIG/2)) & CONNIO_ENA)
+ CurrCard->globalFlags |= F_CONLUN_IO;
+ }
+
+
+ temp = pCardInfo->si_per_targ_no_disc;
+
+ for (i = 0,id = 1; i < MAX_SCSI_TAR; i++, id <<= 1) {
+
+ if (temp & id)
+ sccbMgrTbl[thisCard][i].TarStatus |= TAR_ALLOW_DISC;
+ }
+
+ sync_bit_map = 0x0001;
+
+ for (id = 0; id < (MAX_SCSI_TAR/2); id++) {
+
+ if(pCurrNvRam){
+ temp = (USHORT) pCurrNvRam->niSyncTbl[id];
+ temp = ((temp & 0x03) + ((temp << 4) & 0xc0)) +
+ (((temp << 4) & 0x0300) + ((temp << 8)
& 0xc000));
+ }else
+ temp = utilEERead(ioport, (USHORT)((SYNC_RATE_TBL/2)+id));
+
+ for (i = 0; i < 2; temp >>=8,i++) {
+
+ if (pCardInfo->si_per_targ_init_sync & sync_bit_map) {
+
+ sccbMgrTbl[thisCard][id*2+i].TarEEValue = (UCHAR)temp;
+ }
+
+ else {
+ sccbMgrTbl[thisCard][id*2+i].TarStatus |= SYNC_SUPPORTED;
+ sccbMgrTbl[thisCard][id*2+i].TarEEValue =
+ (UCHAR)(temp & ~EE_SYNC_MASK);
+ }
+
+#if defined(WIDE_SCSI)
+/* if ((pCardInfo->si_per_targ_wide_nego & sync_bit_map) ||
+ (id*2+i >= 8)){
+*/
+ if (pCardInfo->si_per_targ_wide_nego & sync_bit_map){
+
+ sccbMgrTbl[thisCard][id*2+i].TarEEValue |= EE_WIDE_SCSI;
+
+ }
+
+ else { /* NARROW SCSI */
+ sccbMgrTbl[thisCard][id*2+i].TarStatus |= WIDE_NEGOCIATED;
+ }
+
+#else
+ sccbMgrTbl[thisCard][id*2+i].TarStatus |= WIDE_NEGOCIATED;
+#endif
+
+
+ sync_bit_map <<= 1;
+
+
+
+ }
+ }
+
+ WR_HARPOON((ioport+hp_semaphore),
+ (UCHAR)(RD_HARPOON((ioport+hp_semaphore)) | SCCB_MGR_PRESENT));
+
+#if defined(DOS)
+ return((USHORT)CurrCard);
+#else
+ return((ULONG)CurrCard);
+#endif
+}
+
+#else /* end (FW_TYPE==_SCCB_MGR_) */
+
+
+
+STATIC s16bits FP_PresenceCheck(PMGR_INFO pMgrInfo)
+{
+ PMGR_ENTRYPNTS pMgr_EntryPnts = &pMgrInfo->mi_Functions;
+
+ pMgr_EntryPnts->UCBMgr_probe_adapter = probe_adapter;
+ pMgr_EntryPnts->UCBMgr_init_adapter = init_adapter;
+ pMgr_EntryPnts->UCBMgr_start_UCB = SccbMgr_start_sccb;
+ pMgr_EntryPnts->UCBMgr_build_UCB = build_UCB;
+ pMgr_EntryPnts->UCBMgr_abort_UCB = SccbMgr_abort_sccb;
+ pMgr_EntryPnts->UCBMgr_my_int = SccbMgr_my_int;
+ pMgr_EntryPnts->UCBMgr_isr = SccbMgr_isr;
+ pMgr_EntryPnts->UCBMgr_scsi_reset = SccbMgr_scsi_reset;
+ pMgr_EntryPnts->UCBMgr_timer_expired = SccbMgr_timer_expired;
+#ifndef NO_IOCTLS
+ pMgr_EntryPnts->UCBMgr_unload_card = SccbMgr_unload_card;
+ pMgr_EntryPnts->UCBMgr_save_foreign_state =
+
SccbMgr_save_foreign_state;
+ pMgr_EntryPnts->UCBMgr_restore_foreign_state =
+
SccbMgr_restore_foreign_state;
+ pMgr_EntryPnts->UCBMgr_restore_native_state =
+
SccbMgr_restore_native_state;
+#endif /*NO_IOCTLS*/
+
+ pMgrInfo->mi_SGListFormat=0x01;
+ pMgrInfo->mi_DataPtrFormat=0x01;
+ pMgrInfo->mi_MaxSGElements= (u16bits) 0xffffffff;
+ pMgrInfo->mi_MgrPrivateLen=sizeof(SCCB);
+ pMgrInfo->mi_PCIVendorID=BL_VENDOR_ID;
+ pMgrInfo->mi_PCIDeviceID=FP_DEVICE_ID;
+ pMgrInfo->mi_MgrAttributes= ATTR_IO_MAPPED +
+
ATTR_PHYSICAL_ADDRESS +
+
ATTR_VIRTUAL_ADDRESS +
+
ATTR_OVERLAPPED_IO_IOCTLS_OK;
+ pMgrInfo->mi_IoRangeLen = 256;
+ return(0);
+}
+
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: probe_adapter
+ *
+ * Description: Setup and/or Search for cards and return info to caller.
+ *
+ *---------------------------------------------------------------------*/
+STATIC s32bits probe_adapter(PADAPTER_INFO pAdapterInfo)
+{
+ u16bits temp,temp2,temp3,temp4;
+ u08bits i,j,id;
+
+#if defined(DOS)
+#else
+ static u08bits first_time = 1;
+#endif
+ BASE_PORT ioport;
+ PNVRamInfo pCurrNvRam;
+
+ ioport = (BASE_PORT)pAdapterInfo->ai_baseaddr;
+
+
+
+ if (RD_HARPOON(ioport+hp_vendor_id_0) != ORION_VEND_0)
+ return(1);
+
+ if ((RD_HARPOON(ioport+hp_vendor_id_1) != ORION_VEND_1))
+ return(2);
+
+ if ((RD_HARPOON(ioport+hp_device_id_0) != ORION_DEV_0))
+ return(3);
+
+ if ((RD_HARPOON(ioport+hp_device_id_1) != ORION_DEV_1))
+ return(4);
+
+
+ if (RD_HARPOON(ioport+hp_rev_num) != 0x0f){
+
+
+/* For new Harpoon then check for sub_device ID LSB
+ the bits(0-3) must be all ZERO for compatible with
+ current version of SCCBMgr, else skip this Harpoon
+ device. */
+
+ if (RD_HARPOON(ioport+hp_sub_device_id_0) & 0x0f)
+ return(5);
+ }
+
+ if (first_time) {
+
+ SccbMgrTableInitAll();
+ first_time = 0;
+ mbCards = 0;
+ }
+
+ if(RdStack(ioport, 0) != 0x00) {
+ if(ChkIfChipInitialized(ioport) == FALSE)
+ {
+ pCurrNvRam = NULL;
+ WR_HARPOON(ioport+hp_semaphore, 0x00);
+ XbowInit(ioport, 0); /*Must Init the
SCSI before attempting */
+ DiagEEPROM(ioport);
+ }
+ else
+ {
+ if(mbCards < MAX_MB_CARDS) {
+ pCurrNvRam = &nvRamInfo[mbCards];
+ mbCards++;
+ pCurrNvRam->niBaseAddr = ioport;
+ RNVRamData(pCurrNvRam);
+ }else
+ return((int) FAILURE);
+ }
+ }else
+ pCurrNvRam = NULL;
+
+#if defined (NO_BIOS_OPTION)
+ pCurrNvRam = NULL;
+ XbowInit(ioport, 0); /*Must Init the SCSI before attempting
*/
+ DiagEEPROM(ioport);
+#endif /* No BIOS Option */
+
+ WR_HARPOON(ioport+hp_clkctrl_0, CLKCTRL_DEFAULT);
+ WR_HARPOON(ioport+hp_sys_ctrl, 0x00);
+
+ if(pCurrNvRam)
+ pAdapterInfo->ai_id = pCurrNvRam->niAdapId;
+ else
+ pAdapterInfo->ai_id = (u08bits)(utilEERead(ioport, (ADAPTER_SCSI_ID/2))
&
+ (u08bits)0x0FF);
+
+ pAdapterInfo->ai_lun = 0x00;
+ pAdapterInfo->ai_fw_revision[0] = '3';
+ pAdapterInfo->ai_fw_revision[1] = '1';
+ pAdapterInfo->ai_fw_revision[2] = '1';
+ pAdapterInfo->ai_fw_revision[3] = ' ';
+ pAdapterInfo->ai_NumChannels = 1;
+
+ temp2 = 0x0000;
+ temp3 = 0x0000;
+ temp4 = 0x0000;
+
+ for (id = 0; id < (16/2); id++) {
+
+ if(pCurrNvRam){
+ temp = (USHORT) pCurrNvRam->niSyncTbl[id];
+ temp = ((temp & 0x03) + ((temp << 4) & 0xc0)) +
+ (((temp << 4) & 0x0300) + ((temp << 8)
& 0xc000));
+ }else
+ temp = utilEERead(ioport, (u16bits)((SYNC_RATE_TBL/2)+id));
+
+ for (i = 0; i < 2; temp >>=8,i++) {
+
+ if ((temp & 0x03) != AUTO_RATE_00) {
+
+ temp2 >>= 0x01;
+ temp2 |= 0x8000;
+ }
+
+ else {
+ temp2 >>= 0x01;
+ }
+
+ if (temp & DISC_ENABLE_BIT) {
+
+ temp3 >>= 0x01;
+ temp3 |= 0x8000;
+ }
+
+ else {
+ temp3 >>= 0x01;
+ }
+
+ if (temp & WIDE_NEGO_BIT) {
+
+ temp4 >>= 0x01;
+ temp4 |= 0x8000;
+ }
+
+ else {
+ temp4 >>= 0x01;
+ }
+
+ }
+ }
+
+ pAdapterInfo->ai_per_targ_init_sync = temp2;
+ pAdapterInfo->ai_per_targ_no_disc = temp3;
+ pAdapterInfo->ai_per_targ_wide_nego = temp4;
+ if(pCurrNvRam)
+ i = pCurrNvRam->niSysConf;
+ else
+ i = (u08bits)(utilEERead(ioport, (SYSTEM_CONFIG/2)));
+
+ /*
+ ** interrupts always level-triggered for FlashPoint
+ */
+ pAdapterInfo->ai_stateinfo |= LEVEL_TRIG;
+
+ if (i & 0x01)
+ pAdapterInfo->ai_stateinfo |= SCSI_PARITY_ENA;
+
+ if (i & 0x02) /* SCSI Bus reset in AutoSCSI Set ? */
+ {
+ if(pCurrNvRam)
+ {
+ j = pCurrNvRam->niScamConf;
+ }
+ else
+ {
+ j = (u08bits) utilEERead(ioport, SCAM_CONFIG/2);
+ }
+ if(j & SCAM_ENABLED)
+ {
+ if(j & SCAM_LEVEL2)
+ {
+ pAdapterInfo->ai_stateinfo |= SCAM2_ENA;
+ }
+ else
+ {
+ pAdapterInfo->ai_stateinfo |= SCAM1_ENA;
+ }
+ }
+ }
+ j = (RD_HARPOON(ioport+hp_bm_ctrl) & ~SCSI_TERM_ENA_L);
+ if (i & 0x04) {
+ j |= SCSI_TERM_ENA_L;
+ pAdapterInfo->ai_stateinfo |= LOW_BYTE_TERM_ENA;
+ }
+ WR_HARPOON(ioport+hp_bm_ctrl, j );
+
+ j = (RD_HARPOON(ioport+hp_ee_ctrl) & ~SCSI_TERM_ENA_H);
+ if (i & 0x08) {
+ j |= SCSI_TERM_ENA_H;
+ pAdapterInfo->ai_stateinfo |= HIGH_BYTE_TERM_ENA;
+ }
+ WR_HARPOON(ioport+hp_ee_ctrl, j );
+
+ if(RD_HARPOON(ioport + hp_page_ctrl) & BIOS_SHADOW)
+ {
+ pAdapterInfo->ai_FlashRomSize = 64 * 1024; /* 64k ROM */
+ }
+ else
+ {
+ pAdapterInfo->ai_FlashRomSize = 32 * 1024; /* 32k ROM */
+ }
+
+ pAdapterInfo->ai_stateinfo |= (FAST20_ENA | TAG_QUEUE_ENA);
+ if (!(RD_HARPOON(ioport+hp_page_ctrl) & NARROW_SCSI_CARD))
+ {
+ pAdapterInfo->ai_attributes |= (WIDE_CAPABLE | FAST20_CAPABLE
+
| SCAM2_CAPABLE
+
| TAG_QUEUE_CAPABLE
+
| SUPRESS_UNDERRRUNS_CAPABLE
+
| SCSI_PARITY_CAPABLE);
+ pAdapterInfo->ai_MaxTarg = 16;
+ pAdapterInfo->ai_MaxLun = 32;
+ }
+ else
+ {
+ pAdapterInfo->ai_attributes |= (FAST20_CAPABLE | SCAM2_CAPABLE
+
| TAG_QUEUE_CAPABLE
+
| SUPRESS_UNDERRRUNS_CAPABLE
+
| SCSI_PARITY_CAPABLE);
+ pAdapterInfo->ai_MaxTarg = 8;
+ pAdapterInfo->ai_MaxLun = 8;
+ }
+
+ pAdapterInfo->ai_product_family = HARPOON_FAMILY;
+ pAdapterInfo->ai_HBAbustype = BUSTYPE_PCI;
+
+ for (i=0;i<CARD_MODEL_NAMELEN;i++)
+ {
+ pAdapterInfo->ai_card_model[i]=' '; /* initialize the ai_card_model */
+ }
+
+ if(pCurrNvRam){
+ pAdapterInfo->ai_card_model[0] = '9';
+ switch(pCurrNvRam->niModel & 0x0f){
+ case MODEL_LT:
+ pAdapterInfo->ai_card_model[1] = '3';
+ pAdapterInfo->ai_card_model[2] = '0';
+ break;
+ case MODEL_LW:
+ pAdapterInfo->ai_card_model[1] = '5';
+ pAdapterInfo->ai_card_model[2] = '0';
+ break;
+ case MODEL_DL:
+ pAdapterInfo->ai_card_model[1] = '3';
+ pAdapterInfo->ai_card_model[2] = '2';
+ break;
+ case MODEL_DW:
+ pAdapterInfo->ai_card_model[1] = '5';
+ pAdapterInfo->ai_card_model[2] = '2';
+ break;
+ }
+ }else{
+ temp = utilEERead(ioport, (MODEL_NUMB_0/2));
+ pAdapterInfo->ai_card_model[0] = (u08bits)(temp >> 8);
+ temp = utilEERead(ioport, (MODEL_NUMB_2/2));
+
+ pAdapterInfo->ai_card_model[1] = (u08bits)(temp & 0x00FF);
+ pAdapterInfo->ai_card_model[2] = (u08bits)(temp >> 8);
+ }
+
+
+
+ pAdapterInfo->ai_FiberProductType = 0;
+
+ pAdapterInfo->ai_secondary_range = 0;
+
+ for (i=0;i<WORLD_WIDE_NAMELEN;i++)
+ {
+ pAdapterInfo->ai_worldwidename[i]='\0';
+ }
+
+ for (i=0;i<VENDOR_NAMELEN;i++)
+ {
+ pAdapterInfo->ai_vendorstring[i]='\0';
+ }
+ pAdapterInfo->ai_vendorstring[0]='B';
+ pAdapterInfo->ai_vendorstring[1]='U';
+ pAdapterInfo->ai_vendorstring[2]='S';
+ pAdapterInfo->ai_vendorstring[3]='L';
+ pAdapterInfo->ai_vendorstring[4]='O';
+ pAdapterInfo->ai_vendorstring[5]='G';
+ pAdapterInfo->ai_vendorstring[6]='I';
+ pAdapterInfo->ai_vendorstring[7]='C';
+
+ for (i=0;i<FAMILY_NAMELEN;i++)
+ {
+ pAdapterInfo->ai_AdapterFamilyString[i]='\0';
+ }
+ pAdapterInfo->ai_AdapterFamilyString[0]='F';
+ pAdapterInfo->ai_AdapterFamilyString[1]='L';
+ pAdapterInfo->ai_AdapterFamilyString[2]='A';
+ pAdapterInfo->ai_AdapterFamilyString[3]='S';
+ pAdapterInfo->ai_AdapterFamilyString[4]='H';
+ pAdapterInfo->ai_AdapterFamilyString[5]='P';
+ pAdapterInfo->ai_AdapterFamilyString[6]='O';
+ pAdapterInfo->ai_AdapterFamilyString[7]='I';
+ pAdapterInfo->ai_AdapterFamilyString[8]='N';
+ pAdapterInfo->ai_AdapterFamilyString[9]='T';
+
+ ARAM_ACCESS(ioport);
+
+ for ( i = 0; i < 4; i++ ) {
+
+ pAdapterInfo->ai_XlatInfo[i] =
+ RD_HARPOON(ioport+hp_aramBase+BIOS_DATA_OFFSET+i);
+ }
+
+ /* return with -1 if no sort, else return with
+ logical card number sorted by BIOS (zero-based) */
+
+
+ pAdapterInfo->ai_relative_cardnum =
+ (u08bits)(RD_HARPOON(ioport+hp_aramBase+BIOS_RELATIVE_CARD)-1);
+
+ SGRAM_ACCESS(ioport);
+
+ s_PhaseTbl[0] = phaseDataOut;
+ s_PhaseTbl[1] = phaseDataIn;
+ s_PhaseTbl[2] = phaseIllegal;
+ s_PhaseTbl[3] = phaseIllegal;
+ s_PhaseTbl[4] = phaseCommand;
+ s_PhaseTbl[5] = phaseStatus;
+ s_PhaseTbl[6] = phaseMsgOut;
+ s_PhaseTbl[7] = phaseMsgIn;
+
+ pAdapterInfo->ai_present = 0x01;
+
+#if defined(BUGBUG)
+
+
+ for (i = 0; i < MAX_CARDS; i++) {
+
+ for (id=0; id<debug_size; id++)
+ debug_int[i][id] = (u08bits)0x00;
+ debug_index[i] = 0;
+ }
+
+#endif
+
+ return(0);
+}
+
+
+
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: init_adapter, exported to BUDI via UCBMgr_init_adapter entry
+ *
+ *
+ * Description: Setup adapter for normal operation (hard reset).
+ *
+ *---------------------------------------------------------------------*/
+STATIC CARD_HANDLE init_adapter(PADAPTER_INFO pCardInfo)
+{
+ PSCCBcard CurrCard;
+ PNVRamInfo pCurrNvRam;
+ u08bits i,j,thisCard, ScamFlg;
+ u16bits temp,sync_bit_map,id;
+ BASE_PORT ioport;
+
+ ioport = (BASE_PORT)pCardInfo->ai_baseaddr;
+
+ for(thisCard =0; thisCard <= MAX_CARDS; thisCard++) {
+
+ if (thisCard == MAX_CARDS) {
+
+ return(FAILURE);
+ }
+
+ if (BL_Card[thisCard].ioPort == ioport) {
+
+ CurrCard = &BL_Card[thisCard];
+ SccbMgrTableInitCard(CurrCard,thisCard);
+ break;
+ }
+
+ else if (BL_Card[thisCard].ioPort == 0x00) {
+
+ BL_Card[thisCard].ioPort = ioport;
+ CurrCard = &BL_Card[thisCard];
+
+ if(mbCards)
+ for(i = 0; i < mbCards; i++){
+ if(CurrCard->ioPort ==
nvRamInfo[i].niBaseAddr)
+ CurrCard->pNvRamInfo =
&nvRamInfo[i];
+ }
+ SccbMgrTableInitCard(CurrCard,thisCard);
+ CurrCard->cardIndex = thisCard;
+ CurrCard->cardInfo = pCardInfo;
+
+ break;
+ }
+ }
+
+ pCurrNvRam = CurrCard->pNvRamInfo;
+
+
+ if(pCurrNvRam){
+ ScamFlg = pCurrNvRam->niScamConf;
+ }
+ else{
+ ScamFlg = (UCHAR) utilEERead(ioport, SCAM_CONFIG/2);
+ }
+
+
+ BusMasterInit(ioport);
+ XbowInit(ioport, ScamFlg);
+
+#if defined (NO_BIOS_OPTION)
+
+
+ if (DiagXbow(ioport)) return(FAILURE);
+ if (DiagBusMaster(ioport)) return(FAILURE);
+
+#endif /* No BIOS Option */
+
+ autoLoadDefaultMap(ioport);
+
+
+ for (i = 0,id = 0x01; i != pCardInfo->ai_id; i++,id <<= 1){}
+
+ WR_HARPOON(ioport+hp_selfid_0, id);
+ WR_HARPOON(ioport+hp_selfid_1, 0x00);
+ WR_HARPOON(ioport+hp_arb_id, pCardInfo->ai_id);
+ CurrCard->ourId = (unsigned char) pCardInfo->ai_id;
+
+ i = (u08bits) pCardInfo->ai_stateinfo;
+ if (i & SCSI_PARITY_ENA)
+ WR_HARPOON(ioport+hp_portctrl_1,(HOST_MODE8 | CHK_SCSI_P));
+
+ j = (RD_HARPOON(ioport+hp_bm_ctrl) & ~SCSI_TERM_ENA_L);
+ if (i & LOW_BYTE_TERM_ENA)
+ j |= SCSI_TERM_ENA_L;
+ WR_HARPOON(ioport+hp_bm_ctrl, j);
+
+ j = (RD_HARPOON(ioport+hp_ee_ctrl) & ~SCSI_TERM_ENA_H);
+ if (i & HIGH_BYTE_TERM_ENA)
+ j |= SCSI_TERM_ENA_H;
+ WR_HARPOON(ioport+hp_ee_ctrl, j );
+
+
+ if (!(pCardInfo->ai_stateinfo & NO_RESET_IN_INIT)) {
+
+ sresb(ioport,thisCard);
+
+ scini(thisCard, (u08bits) pCardInfo->ai_id, 0);
+ }
+
+
+
+ if (pCardInfo->ai_stateinfo & SUPRESS_UNDERRRUNS_ENA)
+ CurrCard->globalFlags |= F_NO_FILTER;
+
+ if(pCurrNvRam){
+ if(pCurrNvRam->niSysConf & 0x10)
+ CurrCard->globalFlags |= F_GREEN_PC;
+ }
+ else{
+ if (utilEERead(ioport, (SYSTEM_CONFIG/2)) & GREEN_PC_ENA)
+ CurrCard->globalFlags |= F_GREEN_PC;
+ }
+
+ /* Set global flag to indicate Re-Negotiation to be done on all
+ ckeck condition */
+ if(pCurrNvRam){
+ if(pCurrNvRam->niScsiConf & 0x04)
+ CurrCard->globalFlags |= F_DO_RENEGO;
+ }
+ else{
+ if (utilEERead(ioport, (SCSI_CONFIG/2)) & RENEGO_ENA)
+ CurrCard->globalFlags |= F_DO_RENEGO;
+ }
+
+ if(pCurrNvRam){
+ if(pCurrNvRam->niScsiConf & 0x08)
+ CurrCard->globalFlags |= F_CONLUN_IO;
+ }
+ else{
+ if (utilEERead(ioport, (SCSI_CONFIG/2)) & CONNIO_ENA)
+ CurrCard->globalFlags |= F_CONLUN_IO;
+ }
+
+ temp = pCardInfo->ai_per_targ_no_disc;
+
+ for (i = 0,id = 1; i < MAX_SCSI_TAR; i++, id <<= 1) {
+
+ if (temp & id)
+ sccbMgrTbl[thisCard][i].TarStatus |= TAR_ALLOW_DISC;
+ }
+
+ sync_bit_map = 0x0001;
+
+ for (id = 0; id < (MAX_SCSI_TAR/2); id++){
+
+ if(pCurrNvRam){
+ temp = (USHORT) pCurrNvRam->niSyncTbl[id];
+ temp = ((temp & 0x03) + ((temp << 4) & 0xc0)) +
+ (((temp << 4) & 0x0300) + ((temp << 8)
& 0xc000));
+ }else
+ temp = utilEERead(ioport, (u16bits)((SYNC_RATE_TBL/2)+id));
+
+ for (i = 0; i < 2; temp >>=8,i++){
+
+ if (pCardInfo->ai_per_targ_init_sync & sync_bit_map){
+
+ sccbMgrTbl[thisCard][id*2+i].TarEEValue = (u08bits)temp;
+ }
+
+ else {
+ sccbMgrTbl[thisCard][id*2+i].TarStatus |= SYNC_SUPPORTED;
+ sccbMgrTbl[thisCard][id*2+i].TarEEValue =
+ (u08bits)(temp & ~EE_SYNC_MASK);
+ }
+
+#if defined(WIDE_SCSI)
+/* if ((pCardInfo->ai_per_targ_wide_nego & sync_bit_map) ||
+ (id*2+i >= 8)){
+*/
+ if (pCardInfo->ai_per_targ_wide_nego & sync_bit_map){
+
+ sccbMgrTbl[thisCard][id*2+i].TarEEValue |= EE_WIDE_SCSI;
+
+ }
+
+ else { /* NARROW SCSI */
+ sccbMgrTbl[thisCard][id*2+i].TarStatus |= WIDE_NEGOCIATED;
+ }
+
+#else
+ sccbMgrTbl[thisCard][id*2+i].TarStatus |= WIDE_NEGOCIATED;
+#endif
+
+
+ sync_bit_map <<= 1;
+ }
+ }
+
+
+ pCardInfo->ai_SGListFormat=0x01;
+ pCardInfo->ai_DataPtrFormat=0x01;
+ pCardInfo->ai_AEN_mask &= SCSI_RESET_COMPLETE;
+
+ WR_HARPOON((ioport+hp_semaphore),
+ (u08bits)(RD_HARPOON((ioport+hp_semaphore)) | SCCB_MGR_PRESENT));
+
+ return((u32bits)CurrCard);
+
+}
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: build_ucb, exported to BUDI via UCBMgr_build_ucb entry
+ *
+ * Description: prepare fw portion of ucb. do not start, resource not
guaranteed
+ * so don't manipulate anything that's derived from states which
+ * may change
+ *
+ *---------------------------------------------------------------------*/
+void build_UCB(CARD_HANDLE pCurrCard, PUCB p_ucb)
+{
+
+ u08bits thisCard;
+ u08bits i,j;
+
+ PSCCB p_sccb;
+
+
+ thisCard = ((PSCCBcard) pCurrCard)->cardIndex;
+
+
+ p_sccb=(PSCCB)p_ucb->UCB_MgrPrivatePtr;
+
+
+ p_sccb->Sccb_ucb_ptr=p_ucb;
+
+ switch (p_ucb->UCB_opcode & (OPC_DEVICE_RESET+OPC_XFER_SG+OPC_CHK_RESIDUAL))
+ {
+ case OPC_DEVICE_RESET:
+ p_sccb->OperationCode=RESET_COMMAND;
+ break;
+ case OPC_XFER_SG:
+ p_sccb->OperationCode=SCATTER_GATHER_COMMAND;
+ break;
+ case OPC_XFER_SG+OPC_CHK_RESIDUAL:
+ p_sccb->OperationCode=RESIDUAL_SG_COMMAND;
+ break;
+ case OPC_CHK_RESIDUAL:
+
+ p_sccb->OperationCode=RESIDUAL_COMMAND;
+ break;
+ default:
+ p_sccb->OperationCode=SCSI_INITIATOR_COMMAND;
+ break;
+ }
+
+ if (p_ucb->UCB_opcode & OPC_TQ_ENABLE)
+ {
+ p_sccb->ControlByte = (u08bits)((p_ucb->UCB_opcode & OPC_TQ_MASK)>>2) |
F_USE_CMD_Q;
+ }
+ else
+ {
+ p_sccb->ControlByte = 0;
+ }
+
+
+ p_sccb->CdbLength = (u08bits)p_ucb->UCB_cdblen;
+
+ if (p_ucb->UCB_opcode & OPC_NO_AUTO_SENSE)
+ {
+ p_sccb->RequestSenseLength = 0;
+ }
+ else
+ {
+ p_sccb->RequestSenseLength = (unsigned char) p_ucb->UCB_senselen;
+ }
+
+
+ if (p_ucb->UCB_opcode & OPC_XFER_SG)
+ {
+ p_sccb->DataPointer=p_ucb->UCB_virt_dataptr;
+ p_sccb->DataLength = (((u32bits)p_ucb->UCB_NumSgElements)<<3);
+ }
+ else
+ {
+ p_sccb->DataPointer=p_ucb->UCB_phys_dataptr;
+ p_sccb->DataLength=p_ucb->UCB_datalen;
+ };
+
+ p_sccb->HostStatus=0;
+ p_sccb->TargetStatus=0;
+ p_sccb->TargID=(unsigned char)p_ucb->UCB_targid;
+ p_sccb->Lun=(unsigned char) p_ucb->UCB_lun;
+ p_sccb->SccbIOPort=((PSCCBcard)pCurrCard)->ioPort;
+
+ j=p_ucb->UCB_cdblen;
+ for (i=0;i<j;i++)
+ {
+ p_sccb->Cdb[i] = p_ucb->UCB_cdb[i];
+ }
+
+ p_sccb->SensePointer=p_ucb->UCB_phys_senseptr;
+
+ sinits(p_sccb,thisCard);
+
+}
+#ifndef NO_IOCTLS
+
+/*---------------------------------------------------------------------
+ *
+ * Function: GetDevSyncRate
+ *
+ *---------------------------------------------------------------------*/
+STATIC int GetDevSyncRate(PSCCBcard pCurrCard,PUCB p_ucb)
+{
+ struct _SYNC_RATE_INFO * pSyncStr;
+ PSCCBMgr_tar_info currTar_Info;
+ BASE_PORT ioport;
+ u08bits scsiID, j;
+
+#if (FW_TYPE != _SCCB_MGR_)
+ if( p_ucb->UCB_targid >= pCurrCard->cardInfo->ai_MaxTarg )
+ {
+ return(1);
+ }
+#endif
+
+ ioport = pCurrCard->ioPort;
+ pSyncStr = (struct _SYNC_RATE_INFO *) p_ucb->UCB_virt_dataptr;
+ scsiID = (u08bits) p_ucb->UCB_targid;
+ currTar_Info = &sccbMgrTbl[pCurrCard->cardIndex][scsiID];
+ j = currTar_Info->TarSyncCtrl;
+
+ switch (currTar_Info->TarEEValue & EE_SYNC_MASK)
+ {
+ case EE_SYNC_ASYNC:
+ pSyncStr->RequestMegaXferRate = 0x00;
+ break;
+ case EE_SYNC_5MB:
+ pSyncStr->RequestMegaXferRate = (j & NARROW_SCSI) ? 50
: 100;
+ break;
+ case EE_SYNC_10MB:
+ pSyncStr->RequestMegaXferRate = (j & NARROW_SCSI) ? 100
: 200;
+ break;
+ case EE_SYNC_20MB:
+ pSyncStr->RequestMegaXferRate = (j & NARROW_SCSI) ? 200
: 400;
+ break;
+ }
+
+ switch ((j >> 5) & 0x07)
+ {
+ case 0x00:
+ if((j & 0x07) == 0x00)
+ {
+ pSyncStr->ActualMegaXferRate = 0x00; /*
Async Mode */
+ }
+ else
+ {
+ pSyncStr->ActualMegaXferRate = (j &
NARROW_SCSI) ? 200 : 400;
+ }
+ break;
+ case 0x01:
+ pSyncStr->ActualMegaXferRate = (j & NARROW_SCSI) ? 100
: 200;
+ break;
+ case 0x02:
+ pSyncStr->ActualMegaXferRate = (j & NARROW_SCSI) ? 66 :
122;
+ break;
+ case 0x03:
+ pSyncStr->ActualMegaXferRate = (j & NARROW_SCSI) ? 50 :
100;
+ break;
+ case 0x04:
+ pSyncStr->ActualMegaXferRate = (j & NARROW_SCSI) ? 40 :
80;
+ break;
+ case 0x05:
+ pSyncStr->ActualMegaXferRate = (j & NARROW_SCSI) ? 33 :
66;
+ break;
+ case 0x06:
+ pSyncStr->ActualMegaXferRate = (j & NARROW_SCSI) ? 28 :
56;
+ break;
+ case 0x07:
+ pSyncStr->ActualMegaXferRate = (j & NARROW_SCSI) ? 25 :
50;
+ break;
+ }
+ pSyncStr->NegotiatedOffset = j & 0x0f;
+
+ return(0);
+}
+
+/*---------------------------------------------------------------------
+ *
+ * Function: SetDevSyncRate
+ *
+ *---------------------------------------------------------------------*/
+STATIC int SetDevSyncRate(PSCCBcard pCurrCard, PUCB p_ucb)
+{
+ struct _SYNC_RATE_INFO * pSyncStr;
+ PSCCBMgr_tar_info currTar_Info;
+ BASE_PORT ioPort;
+ u08bits scsiID, i, j, syncVal;
+ u16bits syncOffset, actualXferRate;
+ union {
+ u08bits tempb[2];
+ u16bits tempw;
+ }temp2;
+
+#if (FW_TYPE != _SCCB_MGR_)
+ if( p_ucb->UCB_targid >= pCurrCard->cardInfo->ai_MaxTarg )
+ {
+ return(1);
+ }
+#endif
+
+ ioPort = pCurrCard->ioPort;
+ pSyncStr = (struct _SYNC_RATE_INFO *) p_ucb->UCB_virt_dataptr;
+ scsiID = (u08bits) p_ucb->UCB_targid;
+ currTar_Info = &sccbMgrTbl[pCurrCard->cardIndex][scsiID];
+ i = RD_HARPOON(ioPort+hp_xfer_pad); /* Save current value */
+ WR_HARPOON(ioPort+hp_xfer_pad, (i | ID_UNLOCK));
+ WR_HARPOON(ioPort+hp_select_id, ((scsiID << 4) | scsiID));
+ j = RD_HARPOON(ioPort+hp_synctarg_0);
+ WR_HARPOON(ioPort+hp_xfer_pad, i); /* restore value */
+
+ actualXferRate = pSyncStr->ActualMegaXferRate;
+ if(!(j & NARROW_SCSI))
+ {
+ actualXferRate <<= 1;
+ }
+ if(actualXferRate == 0x00)
+ {
+ syncVal = EE_SYNC_ASYNC; /* Async Mode */
+ }
+ if(actualXferRate == 0x0200)
+ {
+ syncVal = EE_SYNC_20MB; /* 20/40 MB
Mode */
+ }
+ if(actualXferRate > 0x0050 && actualXferRate < 0x0200 )
+ {
+ syncVal = EE_SYNC_10MB; /* 10/20 MB
Mode */
+ }
+ else
+ {
+ syncVal = EE_SYNC_5MB; /* 5/10 MB Mode
*/
+ }
+ if(currTar_Info->TarEEValue && EE_SYNC_MASK == syncVal)
+ return(0);
+ 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] = (!(EE_SYNC_MASK & temp2.tempb[0])) | syncVal;
+ }
+ else
+ {
+ temp2.tempb[1] = (!(EE_SYNC_MASK & temp2.tempb[1])) | syncVal;
+ }
+ utilEEWriteOnOff(ioPort, 1);
+ utilEEWrite(ioPort, temp2.tempw, syncOffset);
+ utilEEWriteOnOff(ioPort, 0);
+ UpdateCheckSum(ioPort);
+
+ return(0);
+}
+/*---------------------------------------------------------------------
+ *
+ * Function: GetDevWideMode
+ *
+ *---------------------------------------------------------------------*/
+int GetDevWideMode(PSCCBcard pCurrCard,PUCB p_ucb)
+{
+ u08bits *pData;
+
+ pData = (u08bits *)p_ucb->UCB_virt_dataptr;
+ if(sccbMgrTbl[pCurrCard->cardIndex][p_ucb->UCB_targid].TarEEValue
+ & EE_WIDE_SCSI)
+ {
+ *pData = 1;
+ }
+ else
+ {
+ *pData = 0;
+ }
+
+ return(0);
+}
+
+/*---------------------------------------------------------------------
+ *
+ * Function: SetDevWideMode
+ *
+ *---------------------------------------------------------------------*/
+int SetDevWideMode(PSCCBcard pCurrCard,PUCB p_ucb)
+{
+ u08bits *pData;
+ PSCCBMgr_tar_info currTar_Info;
+ BASE_PORT ioPort;
+ u08bits scsiID, scsiWideMode;
+ u16bits syncOffset;
+ union {
+ u08bits tempb[2];
+ u16bits tempw;
+ }temp2;
+
+#if (FW_TYPE != _SCCB_MGR_)
+ if( !(pCurrCard->cardInfo->ai_attributes & WIDE_CAPABLE) )
+ {
+ return(1);
+ }
+
+ if( p_ucb->UCB_targid >= pCurrCard->cardInfo->ai_MaxTarg )
+ {
+ return(1);
+ }
+#endif
+
+ ioPort = pCurrCard->ioPort;
+ pData = (u08bits *)p_ucb->UCB_virt_dataptr;
+ scsiID = (u08bits) p_ucb->UCB_targid;
+ currTar_Info = &sccbMgrTbl[pCurrCard->cardIndex][scsiID];
+
+ if(*pData)
+ {
+ if(currTar_Info->TarEEValue & EE_WIDE_SCSI)
+ {
+ return(0);
+ }
+ else
+ {
+ scsiWideMode = EE_WIDE_SCSI;
+ }
+ }
+ else
+ {
+ if(!(currTar_Info->TarEEValue & EE_WIDE_SCSI))
+ {
+ return(0);
+ }
+ else
+ {
+ scsiWideMode = 0;
+ }
+ }
+ 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] = (!(EE_WIDE_SCSI & temp2.tempb[0])) |
scsiWideMode;
+ }
+ else
+ {
+ temp2.tempb[1] = (!(EE_WIDE_SCSI & temp2.tempb[1])) |
scsiWideMode;
+ }
+ utilEEWriteOnOff(ioPort, 1);
+ utilEEWrite(ioPort, temp2.tempw, syncOffset);
+ utilEEWriteOnOff(ioPort, 0);
+ UpdateCheckSum(ioPort);
+
+ return(0);
+}
+
+/*---------------------------------------------------------------------
+ *
+ * Function: ReadNVRam
+ *
+ *---------------------------------------------------------------------*/
+void ReadNVRam(PSCCBcard pCurrCard,PUCB p_ucb)
+{
+ u08bits *pdata;
+ u16bits i,numwrds,numbytes,offset,temp;
+ u08bits OneMore = FALSE;
+#if defined(DOS)
+ u16bits ioport;
+#else
+ u32bits ioport;
+#endif
+
+ numbytes = (u16bits) p_ucb->UCB_datalen;
+ ioport = pCurrCard->ioPort;
+ pdata = (u08bits *) p_ucb->UCB_virt_dataptr;
+ offset = (u16bits) (p_ucb->UCB_IOCTLParams[0]);
+
+
+
+ if (offset & 0x1)
+ {
+ *((u16bits*) pdata) = utilEERead(ioport,(u16bits)((offset - 1) /
2)); /* 16 bit read */
+ *pdata = *(pdata + 1);
+ ++offset;
+ ++pdata;
+ --numbytes;
+ }
+
+ numwrds = numbytes / 2;
+ if (numbytes & 1)
+ OneMore = TRUE;
+
+ for (i = 0; i < numwrds; i++)
+ {
+ *((u16bits*) pdata) = utilEERead(ioport,(u16bits)(offset / 2));
+ pdata += 2;
+ offset += 2;
+ }
+ if (OneMore)
+ {
+ --pdata;
+ -- offset;
+ temp = utilEERead(ioport,(u16bits)(offset / 2));
+ *pdata = (u08bits) (temp);
+ }
+
+} /* end proc ReadNVRam */
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: WriteNVRam
+ *
+ *---------------------------------------------------------------------*/
+void WriteNVRam(PSCCBcard pCurrCard,PUCB p_ucb)
+{
+ u08bits *pdata;
+ u16bits i,numwrds,numbytes,offset, eeprom_end;
+ u08bits OneMore = FALSE;
+ union {
+ u08bits tempb[2];
+ u16bits tempw;
+ } temp2;
+
+#if defined(DOS)
+ u16bits ioport;
+#else
+ u32bits ioport;
+#endif
+
+ numbytes = (u16bits) p_ucb->UCB_datalen;
+ ioport = pCurrCard->ioPort;
+ pdata = (u08bits *) p_ucb->UCB_virt_dataptr;
+ offset = (u16bits) (p_ucb->UCB_IOCTLParams[0]);
+
+ if (RD_HARPOON(ioport+hp_page_ctrl) & NARROW_SCSI_CARD)
+ eeprom_end = 512;
+ else
+ eeprom_end = 768;
+
+ if(offset > eeprom_end)
+ return;
+
+ if((offset + numbytes) > eeprom_end)
+ numbytes = eeprom_end - offset;
+
+ utilEEWriteOnOff(ioport,1); /* Enable write access to the EEPROM */
+
+
+
+ if (offset & 0x1)
+ {
+ temp2.tempw = utilEERead(ioport,(u16bits)((offset - 1) / 2)); /* 16
bit read */
+ temp2.tempb[1] = *pdata;
+ utilEEWrite(ioport, temp2.tempw, (u16bits)((offset -1) / 2));
+ *pdata = *(pdata + 1);
+ ++offset;
+ ++pdata;
+ --numbytes;
+ }
+
+ numwrds = numbytes / 2;
+ if (numbytes & 1)
+ OneMore = TRUE;
+
+ for (i = 0; i < numwrds; i++)
+ {
+ utilEEWrite(ioport, *((pu16bits)pdata),(u16bits)(offset / 2));
+ pdata += 2;
+ offset += 2;
+ }
+ if (OneMore)
+ {
+
+ temp2.tempw = utilEERead(ioport,(u16bits)(offset / 2));
+ temp2.tempb[0] = *pdata;
+ utilEEWrite(ioport, temp2.tempw, (u16bits)(offset / 2));
+ }
+ utilEEWriteOnOff(ioport,0); /* Turn off write access */
+ UpdateCheckSum((u32bits)ioport);
+
+} /* end proc WriteNVRam */
+
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: UpdateCheckSum
+ *
+ * Description: Update Check Sum in EEPROM
+ *
+ *---------------------------------------------------------------------*/
+
+
+void UpdateCheckSum(u32bits baseport)
+{
+ USHORT i,sum_data, eeprom_end;
+
+ sum_data = 0x0000;
+
+
+ if (RD_HARPOON(baseport+hp_page_ctrl) & NARROW_SCSI_CARD)
+ eeprom_end = 512;
+ else
+ eeprom_end = 768;
+
+ for (i = 1; i < eeprom_end/2; i++)
+ {
+ sum_data += utilEERead(baseport, i);
+ }
+
+ utilEEWriteOnOff(baseport,1); /* Enable write access to the EEPROM */
+
+ utilEEWrite(baseport, sum_data, EEPROM_CHECK_SUM/2);
+ utilEEWriteOnOff(baseport,0); /* Turn off write access */
+}
+
+void SccbMgr_save_foreign_state(PADAPTER_INFO pAdapterInfo)
+{
+}
+
+
+void SccbMgr_restore_foreign_state(CARD_HANDLE pCurrCard)
+{
+}
+
+void SccbMgr_restore_native_state(CARD_HANDLE pCurrCard)
+{
+}
+
+#endif /* NO_IOCTLS */
+
+#endif /* (FW_TYPE==_UCB_MGR_) */
+
+#ifndef NO_IOCTLS
+#if (FW_TYPE==_UCB_MGR_)
+void SccbMgr_unload_card(CARD_HANDLE pCurrCard)
+#else
+#if defined(DOS)
+void SccbMgr_unload_card(USHORT pCurrCard)
+#else
+void SccbMgr_unload_card(ULONG pCurrCard)
+#endif
+#endif
+{
+ UCHAR i;
+#if defined(DOS)
+ USHORT portBase;
+ USHORT regOffset;
+#else
+ ULONG portBase;
+ ULONG regOffset;
+#endif
+ ULONG scamData;
+#if defined(OS2)
+ ULONG far *pScamTbl;
+#else
+ ULONG *pScamTbl;
+#endif
+ PNVRamInfo pCurrNvRam;
+
+ pCurrNvRam = ((PSCCBcard)pCurrCard)->pNvRamInfo;
+
+ if(pCurrNvRam){
+ WrStack(pCurrNvRam->niBaseAddr, 0, pCurrNvRam->niModel);
+ WrStack(pCurrNvRam->niBaseAddr, 1, pCurrNvRam->niSysConf);
+ WrStack(pCurrNvRam->niBaseAddr, 2, pCurrNvRam->niScsiConf);
+ WrStack(pCurrNvRam->niBaseAddr, 3, pCurrNvRam->niScamConf);
+ WrStack(pCurrNvRam->niBaseAddr, 4, pCurrNvRam->niAdapId);
+
+ for(i = 0; i < MAX_SCSI_TAR / 2; i++)
+ WrStack(pCurrNvRam->niBaseAddr, (UCHAR)(i+5),
pCurrNvRam->niSyncTbl[i]);
+
+ portBase = pCurrNvRam->niBaseAddr;
+
+ for(i = 0; i < MAX_SCSI_TAR; i++){
+ regOffset = hp_aramBase + 64 + i*4;
+#if defined(OS2)
+ pScamTbl = (ULONG far *) &pCurrNvRam->niScamTbl[i];
+#else
+ pScamTbl = (ULONG *) &pCurrNvRam->niScamTbl[i];
+#endif
+ scamData = *pScamTbl;
+ WR_HARP32(portBase, regOffset, scamData);
+ }
+
+ }else{
+ WrStack(((PSCCBcard)pCurrCard)->ioPort, 0, 0);
+ }
+}
+#endif /* NO_IOCTLS */
+
+
+void RNVRamData(PNVRamInfo pNvRamInfo)
+{
+ UCHAR i;
+#if defined(DOS)
+ USHORT portBase;
+ USHORT regOffset;
+#else
+ ULONG portBase;
+ ULONG regOffset;
+#endif
+ ULONG scamData;
+#if defined (OS2)
+ ULONG far *pScamTbl;
+#else
+ ULONG *pScamTbl;
+#endif
+
+ pNvRamInfo->niModel = RdStack(pNvRamInfo->niBaseAddr, 0);
+ pNvRamInfo->niSysConf = RdStack(pNvRamInfo->niBaseAddr, 1);
+ pNvRamInfo->niScsiConf = RdStack(pNvRamInfo->niBaseAddr, 2);
+ pNvRamInfo->niScamConf = RdStack(pNvRamInfo->niBaseAddr, 3);
+ pNvRamInfo->niAdapId = RdStack(pNvRamInfo->niBaseAddr, 4);
+
+ for(i = 0; i < MAX_SCSI_TAR / 2; i++)
+ pNvRamInfo->niSyncTbl[i] = RdStack(pNvRamInfo->niBaseAddr,
(UCHAR)(i+5));
+
+ portBase = pNvRamInfo->niBaseAddr;
+
+ for(i = 0; i < MAX_SCSI_TAR; i++){
+ regOffset = hp_aramBase + 64 + i*4;
+ RD_HARP32(portBase, regOffset, scamData);
+#if defined(OS2)
+ pScamTbl = (ULONG far *) &pNvRamInfo->niScamTbl[i];
+#else
+ pScamTbl = (ULONG *) &pNvRamInfo->niScamTbl[i];
+#endif
+ *pScamTbl = scamData;
+ }
+
+}
+
+#if defined(DOS)
+UCHAR RdStack(USHORT portBase, UCHAR index)
+#else
+UCHAR RdStack(ULONG portBase, UCHAR index)
+#endif
+{
+ WR_HARPOON(portBase + hp_stack_addr, index);
+ return(RD_HARPOON(portBase + hp_stack_data));
+}
+
+#if defined(DOS)
+void WrStack(USHORT portBase, UCHAR index, UCHAR data)
+#else
+void WrStack(ULONG portBase, UCHAR index, UCHAR data)
+#endif
+{
+ WR_HARPOON(portBase + hp_stack_addr, index);
+ WR_HARPOON(portBase + hp_stack_data, data);
+}
+
+
+#if (FW_TYPE==_UCB_MGR_)
+u08bits ChkIfChipInitialized(BASE_PORT ioPort)
+#else
+#if defined(DOS)
+UCHAR ChkIfChipInitialized(USHORT ioPort)
+#else
+UCHAR ChkIfChipInitialized(ULONG ioPort)
+#endif
+#endif
+{
+ if((RD_HARPOON(ioPort + hp_arb_id) & 0x0f) != RdStack(ioPort, 4))
+ return(FALSE);
+ if((RD_HARPOON(ioPort + hp_clkctrl_0) & CLKCTRL_DEFAULT)
+ !=
CLKCTRL_DEFAULT)
+ return(FALSE);
+ if((RD_HARPOON(ioPort + hp_seltimeout) == TO_250ms) ||
+ (RD_HARPOON(ioPort + hp_seltimeout) == TO_290ms))
+ return(TRUE);
+ return(FALSE);
+
+}
+/*---------------------------------------------------------------------
+ *
+ * Function: SccbMgr_start_sccb
+ *
+ * Description: Start a command pointed to by p_Sccb. When the
+ * command is completed it will be returned via the
+ * callback function.
+ *
+ *---------------------------------------------------------------------*/
+#if (FW_TYPE==_UCB_MGR_)
+void SccbMgr_start_sccb(CARD_HANDLE pCurrCard, PUCB p_ucb)
+#else
+#if defined(DOS)
+void SccbMgr_start_sccb(USHORT pCurrCard, PSCCB p_Sccb)
+#else
+void SccbMgr_start_sccb(ULONG pCurrCard, PSCCB p_Sccb)
+#endif
+#endif
+{
+#if defined(DOS)
+ USHORT ioport;
+#else
+ ULONG ioport;
+#endif
+ UCHAR thisCard, lun;
+ PSCCB pSaveSccb;
+ CALL_BK_FN callback;
+
+#if (FW_TYPE==_UCB_MGR_)
+ PSCCB p_Sccb;
+#endif
+
+ mOS_Lock((PSCCBcard)pCurrCard);
+ thisCard = ((PSCCBcard) pCurrCard)->cardIndex;
+ ioport = ((PSCCBcard) pCurrCard)->ioPort;
+
+#if (FW_TYPE==_UCB_MGR_)
+ p_Sccb = (PSCCB)p_ucb->UCB_MgrPrivatePtr;
+#endif
+
+ if((p_Sccb->TargID > MAX_SCSI_TAR) || (p_Sccb->Lun > MAX_LUN))
+ {
+
+#if (FW_TYPE==_UCB_MGR_)
+ p_ucb->UCB_hbastat = SCCB_COMPLETE;
+ p_ucb->UCB_status=SCCB_ERROR;
+ callback = (CALL_BK_FN)p_ucb->UCB_callback;
+ if (callback)
+ callback(p_ucb);
+#endif
+
+#if (FW_TYPE==_SCCB_MGR_)
+ p_Sccb->HostStatus = SCCB_COMPLETE;
+ p_Sccb->SccbStatus = SCCB_ERROR;
+ callback = (CALL_BK_FN)p_Sccb->SccbCallback;
+ if (callback)
+ callback(p_Sccb);
+#endif
+
+ mOS_UnLock((PSCCBcard)pCurrCard);
+ return;
+ }
+
+#if (FW_TYPE==_SCCB_MGR_)
+ sinits(p_Sccb,thisCard);
+#endif
+
+
+#if (FW_TYPE==_UCB_MGR_)
+#ifndef NO_IOCTLS
+
+ if (p_ucb->UCB_opcode & OPC_IOCTL)
+ {
+
+ switch (p_ucb->UCB_IOCTLCommand)
+ {
+ case READ_NVRAM:
+ ReadNVRam((PSCCBcard)pCurrCard,p_ucb);
+ p_ucb->UCB_status=UCB_SUCCESS;
+ callback = (CALL_BK_FN)p_ucb->UCB_callback;
+ if (callback)
+ callback(p_ucb);
+ mOS_UnLock((PSCCBcard)pCurrCard);
+ return;
+
+ case WRITE_NVRAM:
+ WriteNVRam((PSCCBcard)pCurrCard,p_ucb);
+ p_ucb->UCB_status=UCB_SUCCESS;
+ callback = (CALL_BK_FN)p_ucb->UCB_callback;
+ if (callback)
+ callback(p_ucb);
+ mOS_UnLock((PSCCBcard)pCurrCard);
+ return;
+
+ case SEND_SCSI_PASSTHRU:
+#if (FW_TYPE != _SCCB_MGR_)
+ if( p_ucb->UCB_targid >=
+
((PSCCBcard)pCurrCard)->cardInfo->ai_MaxTarg )
+ {
+ p_ucb->UCB_status = UCB_ERROR;
+ p_ucb->UCB_hbastat = HASTAT_HW_ERROR;
+ callback =
(CALL_BK_FN)p_ucb->UCB_callback;
+ if (callback)
+ callback(p_ucb);
+ mOS_UnLock((PSCCBcard)pCurrCard);
+ return;
+ }
+#endif
+ break;
+
+ case HARD_RESET:
+ p_ucb->UCB_status = UCB_INVALID;
+ callback = (CALL_BK_FN)p_ucb->UCB_callback;
+ if (callback)
+ callback(p_ucb);
+ mOS_UnLock((PSCCBcard)pCurrCard);
+ return;
+ case GET_DEVICE_SYNCRATE:
+ if( !GetDevSyncRate((PSCCBcard)pCurrCard,p_ucb)
)
+ {
+ p_ucb->UCB_status = UCB_SUCCESS;
+ }
+ else
+ {
+ p_ucb->UCB_status = UCB_ERROR;
+ p_ucb->UCB_hbastat = HASTAT_HW_ERROR;
+ }
+ callback = (CALL_BK_FN)p_ucb->UCB_callback;
+ if (callback)
+ callback(p_ucb);
+ mOS_UnLock((PSCCBcard)pCurrCard);
+ return;
+ case SET_DEVICE_SYNCRATE:
+ if( !SetDevSyncRate((PSCCBcard)pCurrCard,p_ucb)
)
+ {
+ p_ucb->UCB_status = UCB_SUCCESS;
+ }
+ else
+ {
+ p_ucb->UCB_status = UCB_ERROR;
+ p_ucb->UCB_hbastat = HASTAT_HW_ERROR;
+ }
+ callback = (CALL_BK_FN)p_ucb->UCB_callback;
+ if (callback)
+ callback(p_ucb);
+ mOS_UnLock((PSCCBcard)pCurrCard);
+ return;
+ case GET_WIDE_MODE:
+ if( !GetDevWideMode((PSCCBcard)pCurrCard,p_ucb)
)
+ {
+ p_ucb->UCB_status = UCB_SUCCESS;
+ }
+ else
+ {
+ p_ucb->UCB_status = UCB_ERROR;
+ p_ucb->UCB_hbastat = HASTAT_HW_ERROR;
+ }
+ callback = (CALL_BK_FN)p_ucb->UCB_callback;
+ if (callback)
+ callback(p_ucb);
+ mOS_UnLock((PSCCBcard)pCurrCard);
+ return;
+ case SET_WIDE_MODE:
+ if( !SetDevWideMode((PSCCBcard)pCurrCard,p_ucb)
)
+ {
+ p_ucb->UCB_status = UCB_SUCCESS;
+ }
+ else
+ {
+ p_ucb->UCB_status = UCB_ERROR;
+ p_ucb->UCB_hbastat = HASTAT_HW_ERROR;
+ }
+ callback = (CALL_BK_FN)p_ucb->UCB_callback;
+ if (callback)
+ callback(p_ucb);
+ mOS_UnLock((PSCCBcard)pCurrCard);
+ return;
+ default:
+ p_ucb->UCB_status=UCB_INVALID;
+ callback = (CALL_BK_FN)p_ucb->UCB_callback;
+ if (callback)
+ callback(p_ucb);
+ mOS_UnLock((PSCCBcard)pCurrCard);
+ return;
+ }
+ }
+#endif /* NO_IOCTLS */
+#endif /* (FW_TYPE==_UCB_MGR_) */
+
+
+ if (!((PSCCBcard) pCurrCard)->cmdCounter)
+ {
+ WR_HARPOON(ioport+hp_semaphore, (RD_HARPOON(ioport+hp_semaphore)
+ | SCCB_MGR_ACTIVE));
+
+ if (((PSCCBcard) pCurrCard)->globalFlags & F_GREEN_PC)
+ {
+ WR_HARPOON(ioport+hp_clkctrl_0, CLKCTRL_DEFAULT);
+ WR_HARPOON(ioport+hp_sys_ctrl, 0x00);
+ }
+ }
+
+ ((PSCCBcard)pCurrCard)->cmdCounter++;
+
+ if (RD_HARPOON(ioport+hp_semaphore) & BIOS_IN_USE) {
+
+ WR_HARPOON(ioport+hp_semaphore, (RD_HARPOON(ioport+hp_semaphore)
+ | TICKLE_ME));
+ if(p_Sccb->OperationCode == RESET_COMMAND)
+ {
+ pSaveSccb = ((PSCCBcard)
pCurrCard)->currentSCCB;
+ ((PSCCBcard) pCurrCard)->currentSCCB = p_Sccb;
+ queueSelectFail(&BL_Card[thisCard], thisCard);
+ ((PSCCBcard) pCurrCard)->currentSCCB =
pSaveSccb;
+ }
+ else
+ {
+ queueAddSccb(p_Sccb,thisCard);
+ }
+ }
+
+ else if ((RD_HARPOON(ioport+hp_page_ctrl) & G_INT_DISABLE)) {
+
+ if(p_Sccb->OperationCode == RESET_COMMAND)
+ {
+ pSaveSccb = ((PSCCBcard)
pCurrCard)->currentSCCB;
+ ((PSCCBcard) pCurrCard)->currentSCCB =
p_Sccb;
+ queueSelectFail(&BL_Card[thisCard],
thisCard);
+ ((PSCCBcard) pCurrCard)->currentSCCB =
pSaveSccb;
+ }
+ else
+ {
+ queueAddSccb(p_Sccb,thisCard);
+ }
+ }
+
+ else {
+
+ MDISABLE_INT(ioport);
+
+ if((((PSCCBcard) pCurrCard)->globalFlags & F_CONLUN_IO) &&
+ ((sccbMgrTbl[thisCard][p_Sccb->TargID].TarStatus &
TAR_TAG_Q_MASK) != TAG_Q_TRYING))
+ lun = p_Sccb->Lun;
+ else
+ lun = 0;
+ if ((((PSCCBcard) pCurrCard)->currentSCCB == NULL) &&
+ (sccbMgrTbl[thisCard][p_Sccb->TargID].TarSelQ_Cnt == 0) &&
+ (sccbMgrTbl[thisCard][p_Sccb->TargID].TarLUNBusy[lun]
+ == FALSE)) {
+
+ ((PSCCBcard) pCurrCard)->currentSCCB = p_Sccb;
+ mOS_UnLock((PSCCBcard)pCurrCard);
+#if defined(DOS)
+ ssel((USHORT)p_Sccb->SccbIOPort,thisCard);
+#else
+ ssel(p_Sccb->SccbIOPort,thisCard);
+#endif
+ mOS_Lock((PSCCBcard)pCurrCard);
+ }
+
+ else {
+
+ if(p_Sccb->OperationCode == RESET_COMMAND)
+ {
+ pSaveSccb = ((PSCCBcard)
pCurrCard)->currentSCCB;
+ ((PSCCBcard) pCurrCard)->currentSCCB =
p_Sccb;
+ queueSelectFail(&BL_Card[thisCard],
thisCard);
+ ((PSCCBcard) pCurrCard)->currentSCCB =
pSaveSccb;
+ }
+ else
+ {
+ queueAddSccb(p_Sccb,thisCard);
+ }
+ }
+
+
+ MENABLE_INT(ioport);
+ }
+
+ mOS_UnLock((PSCCBcard)pCurrCard);
+}
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: SccbMgr_abort_sccb
+ *
+ * Description: Abort the command pointed to by p_Sccb. When the
+ * command is completed it will be returned via the
+ * callback function.
+ *
+ *---------------------------------------------------------------------*/
+#if (FW_TYPE==_UCB_MGR_)
+s32bits SccbMgr_abort_sccb(CARD_HANDLE pCurrCard, PUCB p_ucb)
+#else
+#if defined(DOS)
+int SccbMgr_abort_sccb(USHORT pCurrCard, PSCCB p_Sccb)
+#else
+int SccbMgr_abort_sccb(ULONG pCurrCard, PSCCB p_Sccb)
+#endif
+#endif
+
+{
+#if defined(DOS)
+ USHORT ioport;
+#else
+ ULONG ioport;
+#endif
+
+ UCHAR thisCard;
+ CALL_BK_FN callback;
+ UCHAR TID;
+ PSCCB pSaveSCCB;
+ PSCCBMgr_tar_info currTar_Info;
+
+
+#if (FW_TYPE==_UCB_MGR_)
+ PSCCB p_Sccb;
+ p_Sccb=(PSCCB)p_ucb->UCB_MgrPrivatePtr;
+#endif
+
+ ioport = ((PSCCBcard) pCurrCard)->ioPort;
+
+ thisCard = ((PSCCBcard)pCurrCard)->cardIndex;
+
+ mOS_Lock((PSCCBcard)pCurrCard);
+
+ if (RD_HARPOON(ioport+hp_page_ctrl) & G_INT_DISABLE)
+ {
+ mOS_UnLock((PSCCBcard)pCurrCard);
+ }
+
+ else
+ {
+
+ if (queueFindSccb(p_Sccb,thisCard))
+ {
+
+ mOS_UnLock((PSCCBcard)pCurrCard);
+
+ ((PSCCBcard)pCurrCard)->cmdCounter--;
+
+ if (!((PSCCBcard)pCurrCard)->cmdCounter)
+
WR_HARPOON(ioport+hp_semaphore,(RD_HARPOON(ioport+hp_semaphore)
+ & (UCHAR)(~(SCCB_MGR_ACTIVE |
TICKLE_ME)) ));
+
+#if (FW_TYPE==_SCCB_MGR_)
+ p_Sccb->SccbStatus = SCCB_ABORT;
+ callback = p_Sccb->SccbCallback;
+ callback(p_Sccb);
+#else
+ p_ucb->UCB_status=SCCB_ABORT;
+ callback = (CALL_BK_FN)p_ucb->UCB_callback;
+ callback(p_ucb);
+#endif
+
+ return(0);
+ }
+
+ else
+ {
+ mOS_UnLock((PSCCBcard)pCurrCard);
+
+ if (((PSCCBcard)pCurrCard)->currentSCCB == p_Sccb)
+ {
+ p_Sccb->SccbStatus = SCCB_ABORT;
+ return(0);
+
+ }
+
+ else
+ {
+
+ TID = p_Sccb->TargID;
+
+
+ if(p_Sccb->Sccb_tag)
+ {
+ MDISABLE_INT(ioport);
+ if (((PSCCBcard)
pCurrCard)->discQ_Tbl[p_Sccb->Sccb_tag]==p_Sccb)
+ {
+ p_Sccb->SccbStatus = SCCB_ABORT;
+ p_Sccb->Sccb_scsistat =
ABORT_ST;
+#if (FW_TYPE==_UCB_MGR_)
+ p_ucb->UCB_status=SCCB_ABORT;
+#endif
+ p_Sccb->Sccb_scsimsg =
SMABORT_TAG;
+
+ if(((PSCCBcard)
pCurrCard)->currentSCCB == NULL)
+ {
+ ((PSCCBcard)
pCurrCard)->currentSCCB = p_Sccb;
+ ssel(ioport, thisCard);
+ }
+ else
+ {
+ pSaveSCCB =
((PSCCBcard) pCurrCard)->currentSCCB;
+ ((PSCCBcard)
pCurrCard)->currentSCCB = p_Sccb;
+
queueSelectFail((PSCCBcard) pCurrCard, thisCard);
+ ((PSCCBcard)
pCurrCard)->currentSCCB = pSaveSCCB;
+ }
+ }
+ MENABLE_INT(ioport);
+ return(0);
+ }
+ else
+ {
+ currTar_Info =
&sccbMgrTbl[thisCard][p_Sccb->TargID];
+
+
if(BL_Card[thisCard].discQ_Tbl[currTar_Info->LunDiscQ_Idx[p_Sccb->Lun]]
+ == p_Sccb)
+ {
+ p_Sccb->SccbStatus = SCCB_ABORT;
+ return(0);
+ }
+ }
+ }
+ }
+ }
+ return(-1);
+}
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: SccbMgr_my_int
+ *
+ * Description: Do a quick check to determine if there is a pending
+ * interrupt for this card and disable the IRQ Pin if so.
+ *
+ *---------------------------------------------------------------------*/
+#if (FW_TYPE==_UCB_MGR_)
+u08bits SccbMgr_my_int(CARD_HANDLE pCurrCard)
+#else
+#if defined(DOS)
+UCHAR SccbMgr_my_int(USHORT pCurrCard)
+#else
+UCHAR SccbMgr_my_int(ULONG pCurrCard)
+#endif
+#endif
+{
+#if defined(DOS)
+ USHORT ioport;
+#else
+ ULONG ioport;
+#endif
+
+ ioport = ((PSCCBcard)pCurrCard)->ioPort;
+
+ if (RD_HARPOON(ioport+hp_int_status) & INT_ASSERTED)
+ {
+
+#if defined(DOS)
+ MDISABLE_INT(ioport);
+#endif
+
+ return(TRUE);
+ }
+
+ else
+
+ return(FALSE);
+}
+
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: SccbMgr_isr
+ *
+ * Description: This is our entry point when an interrupt is generated
+ * by the card and the upper level driver passes it on to
+ * us.
+ *
+ *---------------------------------------------------------------------*/
+#if (FW_TYPE==_UCB_MGR_)
+s32bits SccbMgr_isr(CARD_HANDLE pCurrCard)
+#else
+#if defined(DOS)
+int SccbMgr_isr(USHORT pCurrCard)
+#else
+int SccbMgr_isr(ULONG pCurrCard)
+#endif
+#endif
+{
+ PSCCB currSCCB;
+ UCHAR thisCard,result,bm_status, bm_int_st;
+ USHORT hp_int;
+ UCHAR i, target;
+#if defined(DOS)
+ USHORT ioport;
+#else
+ ULONG ioport;
+#endif
+
+ mOS_Lock((PSCCBcard)pCurrCard);
+
+ thisCard = ((PSCCBcard)pCurrCard)->cardIndex;
+ ioport = ((PSCCBcard)pCurrCard)->ioPort;
+
+ MDISABLE_INT(ioport);
+
+#if defined(BUGBUG)
+ WR_HARPOON(ioport+hp_user_defined_D, RD_HARPOON(ioport+hp_int_status));
+#endif
+
+ if ((bm_int_st=RD_HARPOON(ioport+hp_int_status)) & EXT_STATUS_ON)
+ bm_status = RD_HARPOON(ioport+hp_ext_status) &
(UCHAR)BAD_EXT_STATUS;
+ else
+ bm_status = 0;
+
+ WR_HARPOON(ioport+hp_int_mask, (INT_CMD_COMPL | SCSI_INTERRUPT));
+
+ mOS_UnLock((PSCCBcard)pCurrCard);
+
+ while ((hp_int = RDW_HARPOON((ioport+hp_intstat)) & default_intena) |
+ bm_status)
+ {
+
+ currSCCB = ((PSCCBcard)pCurrCard)->currentSCCB;
+
+#if defined(BUGBUG)
+ Debug_Load(thisCard,(UCHAR) 0XFF);
+ Debug_Load(thisCard,bm_int_st);
+
+ Debug_Load(thisCard,hp_int_0);
+ Debug_Load(thisCard,hp_int_1);
+#endif
+
+
+ if (hp_int & (FIFO | TIMEOUT | RESET | SCAM_SEL) || bm_status) {
+ result =
SccbMgr_bad_isr(ioport,thisCard,((PSCCBcard)pCurrCard),hp_int);
+ WRW_HARPOON((ioport+hp_intstat), (FIFO | TIMEOUT | RESET | SCAM_SEL));
+ bm_status = 0;
+
+ if (result) {
+
+ mOS_Lock((PSCCBcard)pCurrCard);
+ MENABLE_INT(ioport);
+ mOS_UnLock((PSCCBcard)pCurrCard);
+ return(result);
+ }
+ }
+
+
+ else if (hp_int & ICMD_COMP) {
+
+ if ( !(hp_int & BUS_FREE) ) {
+ /* Wait for the BusFree before starting a new command. We
+ must also check for being reselected since the BusFree
+ may not show up if another device reselects us in 1.5us or
+ less. SRR Wednesday, 3/8/1995.
+ */
+ while (!(RDW_HARPOON((ioport+hp_intstat)) & (BUS_FREE | RSEL))) ;
+ }
+
+ if (((PSCCBcard)pCurrCard)->globalFlags & F_HOST_XFER_ACT)
+
+ phaseChkFifo(ioport, thisCard);
+
+/* WRW_HARPOON((ioport+hp_intstat),
+ (BUS_FREE | ICMD_COMP | ITAR_DISC | XFER_CNT_0));
+ */
+
+ WRW_HARPOON((ioport+hp_intstat), CLR_ALL_INT_1);
+
+ autoCmdCmplt(ioport,thisCard);
+
+ }
+
+
+ else if (hp_int & ITAR_DISC)
+ {
+
+ if (((PSCCBcard)pCurrCard)->globalFlags & F_HOST_XFER_ACT) {
+
+ phaseChkFifo(ioport, thisCard);
+
+ }
+
+ if (RD_HARPOON(ioport+hp_gp_reg_1) == SMSAVE_DATA_PTR) {
+
+ WR_HARPOON(ioport+hp_gp_reg_1, 0x00);
+ currSCCB->Sccb_XferState |= F_NO_DATA_YET;
+
+ currSCCB->Sccb_savedATC = currSCCB->Sccb_ATC;
+ }
+
+ currSCCB->Sccb_scsistat = DISCONNECT_ST;
+ queueDisconnect(currSCCB,thisCard);
+
+ /* Wait for the BusFree before starting a new command. We
+ must also check for being reselected since the BusFree
+ may not show up if another device reselects us in 1.5us or
+ less. SRR Wednesday, 3/8/1995.
+ */
+ while (!(RDW_HARPOON((ioport+hp_intstat)) & (BUS_FREE | RSEL)) &&
+ !((RDW_HARPOON((ioport+hp_intstat)) & PHASE) &&
+ RD_HARPOON((ioport+hp_scsisig)) ==
+ (SCSI_BSY | SCSI_REQ | SCSI_CD | SCSI_MSG | SCSI_IOBIT))) ;
+
+ /*
+ The additional loop exit condition above detects a timing problem
+ with the revision D/E harpoon chips. The caller should reset the
+ host adapter to recover when 0xFE is returned.
+ */
+ if (!(RDW_HARPOON((ioport+hp_intstat)) & (BUS_FREE | RSEL)))
+ {
+ mOS_Lock((PSCCBcard)pCurrCard);
+ MENABLE_INT(ioport);
+ mOS_UnLock((PSCCBcard)pCurrCard);
+ return 0xFE;
+ }
+
+ WRW_HARPOON((ioport+hp_intstat), (BUS_FREE | ITAR_DISC));
+
+
+ ((PSCCBcard)pCurrCard)->globalFlags |= F_NEW_SCCB_CMD;
+
+ }
+
+
+ else if (hp_int & RSEL) {
+
+ WRW_HARPOON((ioport+hp_intstat), (PROG_HLT | RSEL | PHASE |
BUS_FREE));
+
+ if (RDW_HARPOON((ioport+hp_intstat)) & ITAR_DISC)
+ {
+ if (((PSCCBcard)pCurrCard)->globalFlags & F_HOST_XFER_ACT)
+ {
+ phaseChkFifo(ioport, thisCard);
+ }
+
+ if (RD_HARPOON(ioport+hp_gp_reg_1) == SMSAVE_DATA_PTR)
+ {
+ WR_HARPOON(ioport+hp_gp_reg_1, 0x00);
+ currSCCB->Sccb_XferState |= F_NO_DATA_YET;
+ currSCCB->Sccb_savedATC = currSCCB->Sccb_ATC;
+ }
+
+ WRW_HARPOON((ioport+hp_intstat), (BUS_FREE | ITAR_DISC));
+ currSCCB->Sccb_scsistat = DISCONNECT_ST;
+ queueDisconnect(currSCCB,thisCard);
+ }
+
+ sres(ioport,thisCard,((PSCCBcard)pCurrCard));
+ phaseDecode(ioport,thisCard);
+
+ }
+
+
+ else if ((hp_int & IDO_STRT) && (!(hp_int & BUS_FREE)))
+ {
+
+ WRW_HARPOON((ioport+hp_intstat), (IDO_STRT | XFER_CNT_0));
+ phaseDecode(ioport,thisCard);
+
+ }
+
+
+ else if ( (hp_int & IUNKWN) || (hp_int & PROG_HLT) )
+ {
+ WRW_HARPOON((ioport+hp_intstat), (PHASE | IUNKWN |
PROG_HLT));
+ if ((RD_HARPOON(ioport+hp_prgmcnt_0) & (UCHAR)0x3f)<
(UCHAR)SELCHK)
+ {
+ phaseDecode(ioport,thisCard);
+ }
+ else
+ {
+ /* Harpoon problem some SCSI target device respond to selection
+ with short BUSY pulse (<400ns) this will make the Harpoon is not able
+ to latch the correct Target ID into reg. x53.
+ The work around require to correct this reg. But when write to this
+ reg. (0x53) also increment the FIFO write addr reg (0x6f), thus we
+ need to read this reg first then restore it later. After update to 0x53 */
+
+ i = (UCHAR)(RD_HARPOON(ioport+hp_fifowrite));
+ target = (UCHAR)(RD_HARPOON(ioport+hp_gp_reg_3));
+ WR_HARPOON(ioport+hp_xfer_pad, (UCHAR) ID_UNLOCK);
+ WR_HARPOON(ioport+hp_select_id, (UCHAR)(target |
target<<4));
+ WR_HARPOON(ioport+hp_xfer_pad, (UCHAR) 0x00);
+ WR_HARPOON(ioport+hp_fifowrite, i);
+ WR_HARPOON(ioport+hp_autostart_3,
(AUTO_IMMED+TAG_STRT));
+ }
+ }
+
+ else if (hp_int & XFER_CNT_0) {
+
+ WRW_HARPOON((ioport+hp_intstat), XFER_CNT_0);
+
+ schkdd(ioport,thisCard);
+
+ }
+
+
+ else if (hp_int & BUS_FREE) {
+
+ WRW_HARPOON((ioport+hp_intstat), BUS_FREE);
+
+ if (((PSCCBcard)pCurrCard)->globalFlags & F_HOST_XFER_ACT) {
+
+ hostDataXferAbort(ioport,thisCard,currSCCB);
+ }
+
+ phaseBusFree(ioport,thisCard);
+ }
+
+
+ else if (hp_int & ITICKLE) {
+
+ WRW_HARPOON((ioport+hp_intstat), ITICKLE);
+ ((PSCCBcard)pCurrCard)->globalFlags |= F_NEW_SCCB_CMD;
+ }
+
+
+
+ if (((PSCCBcard)pCurrCard)->globalFlags & F_NEW_SCCB_CMD) {
+
+
+ ((PSCCBcard)pCurrCard)->globalFlags &= ~F_NEW_SCCB_CMD;
+
+
+ if (((PSCCBcard)pCurrCard)->currentSCCB == NULL) {
+
+ queueSearchSelect(((PSCCBcard)pCurrCard),thisCard);
+ }
+
+ if (((PSCCBcard)pCurrCard)->currentSCCB != NULL) {
+ ((PSCCBcard)pCurrCard)->globalFlags &= ~F_NEW_SCCB_CMD;
+ ssel(ioport,thisCard);
+ }
+
+ break;
+
+ }
+
+ } /*end while */
+
+ mOS_Lock((PSCCBcard)pCurrCard);
+ MENABLE_INT(ioport);
+ mOS_UnLock((PSCCBcard)pCurrCard);
+
+ return(0);
+}
+
+/*---------------------------------------------------------------------
+ *
+ * Function: Sccb_bad_isr
+ *
+ * Description: Some type of interrupt has occurred which is slightly
+ * out of the ordinary. We will now decode it fully, in
+ * this routine. This is broken up in an attempt to save
+ * processing time.
+ *
+ *---------------------------------------------------------------------*/
+#if defined(DOS)
+UCHAR SccbMgr_bad_isr(USHORT p_port, UCHAR p_card, PSCCBcard pCurrCard, USHORT
p_int)
+#else
+UCHAR SccbMgr_bad_isr(ULONG p_port, UCHAR p_card, PSCCBcard pCurrCard, USHORT
p_int)
+#endif
+{
+#if defined(HARP_REVX)
+ ULONG timer;
+#endif
+UCHAR temp, ScamFlg;
+PSCCBMgr_tar_info currTar_Info;
+PNVRamInfo pCurrNvRam;
+
+
+ if (RD_HARPOON(p_port+hp_ext_status) &
+ (BM_FORCE_OFF | PCI_DEV_TMOUT | BM_PARITY_ERR | PIO_OVERRUN) )
+ {
+
+ if (pCurrCard->globalFlags & F_HOST_XFER_ACT)
+ {
+
+ hostDataXferAbort(p_port,p_card, pCurrCard->currentSCCB);
+ }
+
+ if (RD_HARPOON(p_port+hp_pci_stat_cfg) & REC_MASTER_ABORT)
+
+ {
+ WR_HARPOON(p_port+hp_pci_stat_cfg,
+ (RD_HARPOON(p_port+hp_pci_stat_cfg) & ~REC_MASTER_ABORT));
+
+ WR_HARPOON(p_port+hp_host_blk_cnt, 0x00);
+
+ }
+
+ if (pCurrCard->currentSCCB != NULL)
+ {
+
+ if (!pCurrCard->currentSCCB->HostStatus)
+ pCurrCard->currentSCCB->HostStatus = SCCB_BM_ERR;
+
+ sxfrp(p_port,p_card);
+
+ temp = (UCHAR)(RD_HARPOON(p_port+hp_ee_ctrl) &
+ (EXT_ARB_ACK |
SCSI_TERM_ENA_H));
+ WR_HARPOON(p_port+hp_ee_ctrl, ((UCHAR)temp | SEE_MS | SEE_CS));
+ WR_HARPOON(p_port+hp_ee_ctrl, temp);
+
+ if (!(RDW_HARPOON((p_port+hp_intstat)) & (BUS_FREE | RESET)))
+ {
+ phaseDecode(p_port,p_card);
+ }
+ }
+ }
+
+
+ else if (p_int & RESET)
+ {
+
+ WR_HARPOON(p_port+hp_clkctrl_0,
CLKCTRL_DEFAULT);
+ WR_HARPOON(p_port+hp_sys_ctrl, 0x00);
+ if (pCurrCard->currentSCCB != NULL) {
+
+ if (pCurrCard->globalFlags & F_HOST_XFER_ACT)
+
+ hostDataXferAbort(p_port,p_card, pCurrCard->currentSCCB);
+ }
+
+
+ DISABLE_AUTO(p_port);
+
+ sresb(p_port,p_card);
+
+ while(RD_HARPOON(p_port+hp_scsictrl_0) & SCSI_RST) {}
+
+ pCurrNvRam = pCurrCard->pNvRamInfo;
+ if(pCurrNvRam){
+ ScamFlg = pCurrNvRam->niScamConf;
+ }
+ else{
+ ScamFlg = (UCHAR) utilEERead(p_port,
SCAM_CONFIG/2);
+ }
+
+ XbowInit(p_port, ScamFlg);
+
+ scini(p_card, pCurrCard->ourId, 0);
+
+ return(0xFF);
+ }
+
+
+ else if (p_int & FIFO) {
+
+ WRW_HARPOON((p_port+hp_intstat), FIFO);
+
+#if defined(HARP_REVX)
+
+ for (timer=0x00FFFFFFL; timer != 0x00000000L; timer--) {
+
+ if (RD_HARPOON(p_port+hp_xferstat) & FIFO_EMPTY)
+ break;
+
+ if (RDW_HARPOON((p_port+hp_intstat)) & BUS_FREE)
+ break;
+ }
+
+
+ if ( (RD_HARPOON(p_port+hp_xferstat) & FIFO_EMPTY) &&
+ (RD_HARPOON(p_port+hp_fiforead) !=
+ RD_HARPOON(p_port+hp_fifowrite)) &&
+ (RD_HARPOON(p_port+hp_xfercnt_0))
+ )
+
+ WR_HARPOON((p_port+hp_xferstat), 0x01);
+
+/* else
+ */
+/* sxfrp(p_port,p_card);
+ */
+#else
+ if (pCurrCard->currentSCCB != NULL)
+ sxfrp(p_port,p_card);
+#endif
+ }
+
+ else if (p_int & TIMEOUT)
+ {
+
+ DISABLE_AUTO(p_port);
+
+ WRW_HARPOON((p_port+hp_intstat),
+ (PROG_HLT | TIMEOUT | SEL |BUS_FREE | PHASE | IUNKWN));
+
+ pCurrCard->currentSCCB->HostStatus = SCCB_SELECTION_TIMEOUT;
+
+
+ currTar_Info =
&sccbMgrTbl[p_card][pCurrCard->currentSCCB->TargID];
+ if((pCurrCard->globalFlags & F_CONLUN_IO) &&
+ ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) !=
TAG_Q_TRYING))
+ currTar_Info->TarLUNBusy[pCurrCard->currentSCCB->Lun] = FALSE;
+ else
+ currTar_Info->TarLUNBusy[0] = FALSE;
+
+
+ if (currTar_Info->TarEEValue & EE_SYNC_MASK)
+ {
+ currTar_Info->TarSyncCtrl = 0;
+ currTar_Info->TarStatus &= ~TAR_SYNC_MASK;
+ }
+
+ if (currTar_Info->TarEEValue & EE_WIDE_SCSI)
+ {
+ currTar_Info->TarStatus &= ~TAR_WIDE_MASK;
+ }
+
+ sssyncv(p_port, pCurrCard->currentSCCB->TargID,
NARROW_SCSI,currTar_Info);
+
+ queueCmdComplete(pCurrCard, pCurrCard->currentSCCB, p_card);
+
+ }
+
+#if defined(SCAM_LEV_2)
+
+ else if (p_int & SCAM_SEL)
+ {
+
+ scarb(p_port,LEVEL2_TAR);
+ scsel(p_port);
+ scasid(p_card, p_port);
+
+ scbusf(p_port);
+
+ WRW_HARPOON((p_port+hp_intstat), SCAM_SEL);
+ }
+#endif
+
+ return(0x00);
+}
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: SccbMgr_scsi_reset
+ *
+ * Description: A SCSI bus reset will be generated and all outstanding
+ * Sccbs will be returned via the callback.
+ *
+ *---------------------------------------------------------------------*/
+#if (FW_TYPE==_UCB_MGR_)
+void SccbMgr_scsi_reset(CARD_HANDLE pCurrCard)
+#else
+#if defined(DOS)
+void SccbMgr_scsi_reset(USHORT pCurrCard)
+#else
+void SccbMgr_scsi_reset(ULONG pCurrCard)
+#endif
+#endif
+{
+ UCHAR thisCard;
+
+ thisCard = ((PSCCBcard)pCurrCard)->cardIndex;
+
+ mOS_Lock((PSCCBcard)pCurrCard);
+
+ if (((PSCCBcard) pCurrCard)->globalFlags & F_GREEN_PC)
+ {
+ WR_HARPOON(((PSCCBcard) pCurrCard)->ioPort+hp_clkctrl_0,
CLKCTRL_DEFAULT);
+ WR_HARPOON(((PSCCBcard) pCurrCard)->ioPort+hp_sys_ctrl, 0x00);
+ }
+
+ sresb(((PSCCBcard)pCurrCard)->ioPort,thisCard);
+
+ if (RD_HARPOON(((PSCCBcard)pCurrCard)->ioPort+hp_ext_status) & BM_CMD_BUSY)
+ {
+ WR_HARPOON(((PSCCBcard) pCurrCard)->ioPort+hp_page_ctrl,
+ (RD_HARPOON(((PSCCBcard) pCurrCard)->ioPort+hp_page_ctrl)
+ & ~SCATTER_EN));
+
+ WR_HARPOON(((PSCCBcard) pCurrCard)->ioPort+hp_sg_addr,0x00);
+
+ ((PSCCBcard) pCurrCard)->globalFlags &= ~F_HOST_XFER_ACT;
+ busMstrTimeOut(((PSCCBcard) pCurrCard)->ioPort);
+
+ WR_HARPOON(((PSCCBcard) pCurrCard)->ioPort+hp_int_mask,
+ (INT_CMD_COMPL | SCSI_INTERRUPT));
+ }
+
+/*
+ if (utilEERead(((PSCCBcard)pCurrCard)->ioPort, (SCAM_CONFIG/2))
+ & SCAM_ENABLED)
+*/
+ scini(thisCard, ((PSCCBcard)pCurrCard)->ourId, 0);
+
+#if (FW_TYPE==_UCB_MGR_)
+ ((PSCCBcard)pCurrCard)->cardInfo->ai_AEN_routine(0x01,pCurrCard,0,0,0,0);
+#endif
+
+ mOS_UnLock((PSCCBcard)pCurrCard);
+}
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: SccbMgr_timer_expired
+ *
+ * Description: This function allow me to kill my own job that has not
+ * yet completed, and has cause a timeout to occur. This
+ * timeout has caused the upper level driver to call this
+ * function.
+ *
+ *---------------------------------------------------------------------*/
+
+#if (FW_TYPE==_UCB_MGR_)
+void SccbMgr_timer_expired(CARD_HANDLE pCurrCard)
+#else
+#if defined(DOS)
+void SccbMgr_timer_expired(USHORT pCurrCard)
+#else
+void SccbMgr_timer_expired(ULONG pCurrCard)
+#endif
+#endif
+{
+}
+
+#if defined(DOS)
+/*---------------------------------------------------------------------
+ *
+ * Function: SccbMgr_status
+ *
+ * Description: This function returns the number of outstanding SCCB's.
+ * This is specific to the DOS enviroment, which needs this
+ * to help them keep protected and real mode commands staight.
+ *
+ *---------------------------------------------------------------------*/
+
+USHORT SccbMgr_status(USHORT pCurrCard)
+{
+ return(BL_Card[pCurrCard].cmdCounter);
+}
+#endif
+
+/*---------------------------------------------------------------------
+ *
+ * Function: SccbMgrTableInit
+ *
+ * Description: Initialize all Sccb manager data structures.
+ *
+ *---------------------------------------------------------------------*/
+
+void SccbMgrTableInitAll()
+{
+ UCHAR thisCard;
+
+ for (thisCard = 0; thisCard < MAX_CARDS; thisCard++)
+ {
+ SccbMgrTableInitCard(&BL_Card[thisCard],thisCard);
+
+ BL_Card[thisCard].ioPort = 0x00;
+ BL_Card[thisCard].cardInfo = NULL;
+ BL_Card[thisCard].cardIndex = 0xFF;
+ BL_Card[thisCard].ourId = 0x00;
+ BL_Card[thisCard].pNvRamInfo = NULL;
+ }
+}
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: SccbMgrTableInit
+ *
+ * Description: Initialize all Sccb manager data structures.
+ *
+ *---------------------------------------------------------------------*/
+
+void SccbMgrTableInitCard(PSCCBcard pCurrCard, UCHAR p_card)
+{
+ UCHAR scsiID, qtag;
+
+ for (qtag = 0; qtag < QUEUE_DEPTH; qtag++)
+ {
+ BL_Card[p_card].discQ_Tbl[qtag] = NULL;
+ }
+
+ for (scsiID = 0; scsiID < MAX_SCSI_TAR; scsiID++)
+ {
+ sccbMgrTbl[p_card][scsiID].TarStatus = 0;
+ sccbMgrTbl[p_card][scsiID].TarEEValue = 0;
+ SccbMgrTableInitTarget(p_card, scsiID);
+ }
+
+ pCurrCard->scanIndex = 0x00;
+ pCurrCard->currentSCCB = NULL;
+ pCurrCard->globalFlags = 0x00;
+ pCurrCard->cmdCounter = 0x00;
+ pCurrCard->tagQ_Lst = 0x01;
+ pCurrCard->discQCount = 0;
+
+
+}
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: SccbMgrTableInit
+ *
+ * Description: Initialize all Sccb manager data structures.
+ *
+ *---------------------------------------------------------------------*/
+
+void SccbMgrTableInitTarget(UCHAR p_card, UCHAR target)
+{
+
+ UCHAR lun, qtag;
+ PSCCBMgr_tar_info currTar_Info;
+
+ currTar_Info = &sccbMgrTbl[p_card][target];
+
+ currTar_Info->TarSelQ_Cnt = 0;
+ currTar_Info->TarSyncCtrl = 0;
+
+ currTar_Info->TarSelQ_Head = NULL;
+ currTar_Info->TarSelQ_Tail = NULL;
+ currTar_Info->TarTagQ_Cnt = 0;
+ currTar_Info->TarLUN_CA = FALSE;
+
+
+ for (lun = 0; lun < MAX_LUN; lun++)
+ {
+ currTar_Info->TarLUNBusy[lun] = FALSE;
+ currTar_Info->LunDiscQ_Idx[lun] = 0;
+ }
+
+ for (qtag = 0; qtag < QUEUE_DEPTH; qtag++)
+ {
+ if(BL_Card[p_card].discQ_Tbl[qtag] != NULL)
+ {
+ if(BL_Card[p_card].discQ_Tbl[qtag]->TargID == target)
+ {
+ BL_Card[p_card].discQ_Tbl[qtag] = NULL;
+ BL_Card[p_card].discQCount--;
+ }
+ }
+ }
+}
+
+#if defined(BUGBUG)
+
+/*****************************************************************
+ * Save the current byte in the debug array
+ *****************************************************************/
+
+
+void Debug_Load(UCHAR p_card, UCHAR p_bug_data)
+{
+ debug_int[p_card][debug_index[p_card]] = p_bug_data;
+ debug_index[p_card]++;
+
+ if (debug_index[p_card] == debug_size)
+
+ debug_index[p_card] = 0;
+}
+
+#endif
+
+/*----------------------------------------------------------------------
+ *
+ *
+ * Copyright 1995-1996 by Mylex Corporation. All Rights Reserved
+ *
+ * This file is available under both the GNU General Public License
+ * and a BSD-style copyright; see LICENSE.FlashPoint for details.
+ *
+ * $Workfile: sccb_dat.c $
+ *
+ * Description: Functions relating to handling of the SCCB interface
+ * between the device driver and the HARPOON.
+ *
+ * $Date: 1999/04/26 05:53:56 $
+ *
+ * $Revision: 1.1 $
+ *
+ *----------------------------------------------------------------------*/
+
+/*#include <globals.h>*/
+
+#if (FW_TYPE==_UCB_MGR_)
+ /*#include <budi.h>*/
+#endif
+
+/*#include <sccbmgr.h>*/
+/*#include <blx30.h>*/
+/*#include <target.h>*/
+/*#include <harpoon.h>*/
+
+/*
+** IMPORTANT NOTE!!!
+**
+** You MUST preassign all data to a valid value or zero. This is
+** required due to the MS compiler bug under OS/2 and Solaris Real-Mode
+** driver environment.
+*/
+
+
+SCCBMGR_TAR_INFO sccbMgrTbl[MAX_CARDS][MAX_SCSI_TAR] = { { { 0 } } };
+SCCBCARD BL_Card[MAX_CARDS] = { { 0 } };
+SCCBSCAM_INFO scamInfo[MAX_SCSI_TAR] = { { { 0 } } };
+NVRAMINFO nvRamInfo[MAX_MB_CARDS] = { { 0 } };
+
+
+#if defined(OS2)
+void (far *s_PhaseTbl[8]) (ULONG, UCHAR) = { 0 };
+UCHAR temp_id_string[ID_STRING_LENGTH] = { 0 };
+#elif defined(SOLARIS_REAL_MODE) || defined(__STDC__)
+void (*s_PhaseTbl[8]) (ULONG, UCHAR) = { 0 };
+#else
+void (*s_PhaseTbl[8]) ();
+#endif
+
+#if defined(DOS)
+UCHAR first_time = 0;
+#endif
+
+UCHAR mbCards = 0;
+UCHAR scamHAString[] = {0x63, 0x07, 'B', 'U', 'S', 'L', 'O', 'G', 'I', 'C', \
+ ' ', 'B', 'T',
'-', '9', '3', '0', \
+ 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, \
+ 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20};
+
+USHORT default_intena = 0;
+
+#if defined(BUGBUG)
+UCHAR debug_int[MAX_CARDS][debug_size] = { 0 };
+UCHAR debug_index[MAX_CARDS] = { 0 };
+UCHAR reserved_1[3] = { 0 };
+#endif
+
+/*----------------------------------------------------------------------
+ *
+ *
+ * Copyright 1995-1996 by Mylex Corporation. All Rights Reserved
+ *
+ * This file is available under both the GNU General Public License
+ * and a BSD-style copyright; see LICENSE.FlashPoint for details.
+ *
+ * $Workfile: scsi.c $
+ *
+ * Description: Functions for handling SCSI bus functions such as
+ * selection/reselection, sync negotiation, message-in
+ * decoding.
+ *
+ * $Date: 1999/04/26 05:53:56 $
+ *
+ * $Revision: 1.1 $
+ *
+ *----------------------------------------------------------------------*/
+
+/*#include <globals.h>*/
+
+#if (FW_TYPE==_UCB_MGR_)
+ /*#include <budi.h>*/
+#endif
+
+/*#include <sccbmgr.h>*/
+/*#include <blx30.h>*/
+/*#include <target.h>*/
+/*#include <scsi2.h>*/
+/*#include <eeprom.h>*/
+/*#include <harpoon.h>*/
+
+
+/*
+extern SCCBCARD BL_Card[MAX_CARDS];
+extern SCCBMGR_TAR_INFO sccbMgrTbl[MAX_CARDS][MAX_SCSI_TAR];
+#if defined(BUGBUG)
+void Debug_Load(UCHAR p_card, UCHAR p_bug_data);
+#endif
+*/
+
+/*---------------------------------------------------------------------
+ *
+ * Function: sfetm
+ *
+ * Description: Read in a message byte from the SCSI bus, and check
+ * for a parity error.
+ *
+ *---------------------------------------------------------------------*/
+
+#if defined(DOS)
+UCHAR sfm(USHORT port, PSCCB pCurrSCCB)
+#else
+UCHAR sfm(ULONG port, PSCCB pCurrSCCB)
+#endif
+{
+ UCHAR message;
+ USHORT TimeOutLoop;
+
+ TimeOutLoop = 0;
+ while( (!(RD_HARPOON(port+hp_scsisig) & SCSI_REQ)) &&
+ (TimeOutLoop++ < 20000) ){}
+
+
+ WR_HARPOON(port+hp_portctrl_0, SCSI_PORT);
+
+ message = RD_HARPOON(port+hp_scsidata_0);
+
+ WR_HARPOON(port+hp_scsisig, SCSI_ACK + S_MSGI_PH);
+
+
+ if (TimeOutLoop > 20000)
+ message = 0x00; /* force message byte = 0 if Time Out on Req
*/
+
+ if ((RDW_HARPOON((port+hp_intstat)) & PARITY) &&
+ (RD_HARPOON(port+hp_addstat) & SCSI_PAR_ERR))
+ {
+ WR_HARPOON(port+hp_scsisig, (SCSI_ACK + S_ILL_PH));
+ WR_HARPOON(port+hp_xferstat, 0);
+ WR_HARPOON(port+hp_fiforead, 0);
+ WR_HARPOON(port+hp_fifowrite, 0);
+ if (pCurrSCCB != NULL)
+ {
+ pCurrSCCB->Sccb_scsimsg = SMPARITY;
+ }
+ message = 0x00;
+ do
+ {
+ ACCEPT_MSG_ATN(port);
+ TimeOutLoop = 0;
+ while( (!(RD_HARPOON(port+hp_scsisig) & SCSI_REQ)) &&
+ (TimeOutLoop++ < 20000) ){}
+ if (TimeOutLoop > 20000)
+ {
+ WRW_HARPOON((port+hp_intstat), PARITY);
+ return(message);
+ }
+ if ((RD_HARPOON(port+hp_scsisig) & S_SCSI_PHZ) !=
S_MSGI_PH)
+ {
+ WRW_HARPOON((port+hp_intstat), PARITY);
+ return(message);
+ }
+ WR_HARPOON(port+hp_portctrl_0, SCSI_PORT);
+
+ RD_HARPOON(port+hp_scsidata_0);
+
+ WR_HARPOON(port+hp_scsisig, (SCSI_ACK + S_ILL_PH));
+
+ }while(1);
+
+ }
+ WR_HARPOON(port+hp_scsisig, (SCSI_ACK + S_ILL_PH));
+ WR_HARPOON(port+hp_xferstat, 0);
+ WR_HARPOON(port+hp_fiforead, 0);
+ WR_HARPOON(port+hp_fifowrite, 0);
+ return(message);
+}
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: ssel
+ *
+ * Description: Load up automation and select target device.
+ *
+ *---------------------------------------------------------------------*/
+
+#if defined(DOS)
+void ssel(USHORT port, UCHAR p_card)
+#else
+void ssel(ULONG port, UCHAR p_card)
+#endif
+{
+
+#if defined(DOS)
+ UCHAR auto_loaded, i, target, *theCCB;
+#elif defined(OS2)
+ UCHAR auto_loaded, i, target;
+ UCHAR far *theCCB;
+#else
+ UCHAR auto_loaded, i, target, *theCCB;
+#endif
+
+#if defined(DOS)
+ USHORT cdb_reg;
+#else
+ ULONG cdb_reg;
+#endif
+ PSCCBcard CurrCard;
+ PSCCB currSCCB;
+ PSCCBMgr_tar_info currTar_Info;
+ UCHAR lastTag, lun;
+
+ CurrCard = &BL_Card[p_card];
+ currSCCB = CurrCard->currentSCCB;
+ target = currSCCB->TargID;
+ currTar_Info = &sccbMgrTbl[p_card][target];
+ lastTag = CurrCard->tagQ_Lst;
+
+ ARAM_ACCESS(port);
+
+
+ if ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) == TAG_Q_REJECT)
+ currSCCB->ControlByte &= ~F_USE_CMD_Q;
+
+ if(((CurrCard->globalFlags & F_CONLUN_IO) &&
+ ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) != TAG_Q_TRYING)))
+
+ lun = currSCCB->Lun;
+ else
+ lun = 0;
+
+
+#if defined(DOS)
+ currTar_Info->TarLUNBusy[lun] = TRUE;
+
+#else
+
+ if (CurrCard->globalFlags & F_TAG_STARTED)
+ {
+ if (!(currSCCB->ControlByte & F_USE_CMD_Q))
+ {
+ if ((currTar_Info->TarLUN_CA == FALSE)
+ && ((currTar_Info->TarStatus & TAR_TAG_Q_MASK)
+ == TAG_Q_TRYING))
+ {
+
+ if (currTar_Info->TarTagQ_Cnt !=0)
+ {
+ currTar_Info->TarLUNBusy[lun] = TRUE;
+ queueSelectFail(CurrCard,p_card);
+ SGRAM_ACCESS(port);
+ return;
+ }
+
+ else {
+ currTar_Info->TarLUNBusy[lun] = TRUE;
+ }
+
+ } /*End non-tagged */
+
+ else {
+ currTar_Info->TarLUNBusy[lun] = TRUE;
+ }
+
+ } /*!Use cmd Q Tagged */
+
+ else {
+ if (currTar_Info->TarLUN_CA == TRUE)
+ {
+ queueSelectFail(CurrCard,p_card);
+ SGRAM_ACCESS(port);
+ return;
+ }
+
+ currTar_Info->TarLUNBusy[lun] = TRUE;
+
+ } /*else use cmd Q tagged */
+
+ } /*if glob tagged started */
+
+ else {
+ currTar_Info->TarLUNBusy[lun] = TRUE;
+ }
+
+#endif /* DOS */
+
+
+
+ if((((CurrCard->globalFlags & F_CONLUN_IO) &&
+ ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) != TAG_Q_TRYING))
+ || (!(currSCCB->ControlByte & F_USE_CMD_Q))))
+ {
+ if(CurrCard->discQCount >= QUEUE_DEPTH)
+ {
+ currTar_Info->TarLUNBusy[lun] = TRUE;
+ queueSelectFail(CurrCard,p_card);
+ SGRAM_ACCESS(port);
+ return;
+ }
+ for (i = 1; i < QUEUE_DEPTH; i++)
+ {
+ if (++lastTag >= QUEUE_DEPTH) lastTag = 1;
+ if (CurrCard->discQ_Tbl[lastTag] == NULL)
+ {
+ CurrCard->tagQ_Lst = lastTag;
+ currTar_Info->LunDiscQ_Idx[lun] = lastTag;
+ CurrCard->discQ_Tbl[lastTag] = currSCCB;
+ CurrCard->discQCount++;
+ break;
+ }
+ }
+ if(i == QUEUE_DEPTH)
+ {
+ currTar_Info->TarLUNBusy[lun] = TRUE;
+ queueSelectFail(CurrCard,p_card);
+ SGRAM_ACCESS(port);
+ return;
+ }
+ }
+
+
+
+ auto_loaded = FALSE;
+
+ WR_HARPOON(port+hp_select_id, target);
+ WR_HARPOON(port+hp_gp_reg_3, target); /* Use by new automation logic */
+
+ if (currSCCB->OperationCode == RESET_COMMAND) {
+ WRW_HARPOON((port+ID_MSG_STRT), (MPM_OP+AMSG_OUT+
+ (currSCCB->Sccb_idmsg & ~DISC_PRIV)));
+
+ WRW_HARPOON((port+ID_MSG_STRT+2),BRH_OP+ALWAYS+NP);
+
+ currSCCB->Sccb_scsimsg = SMDEV_RESET;
+
+ WR_HARPOON(port+hp_autostart_3, (SELECT+SELCHK_STRT));
+ auto_loaded = TRUE;
+ currSCCB->Sccb_scsistat = SELECT_BDR_ST;
+
+ if (currTar_Info->TarEEValue & EE_SYNC_MASK)
+ {
+ currTar_Info->TarSyncCtrl = 0;
+ currTar_Info->TarStatus &= ~TAR_SYNC_MASK;
+ }
+
+#if defined(WIDE_SCSI)
+
+ if (currTar_Info->TarEEValue & EE_WIDE_SCSI)
+ {
+ currTar_Info->TarStatus &= ~TAR_WIDE_MASK;
+ }
+#endif
+
+ sssyncv(port, target, NARROW_SCSI,currTar_Info);
+ SccbMgrTableInitTarget(p_card, target);
+
+ }
+
+ else if(currSCCB->Sccb_scsistat == ABORT_ST)
+ {
+ WRW_HARPOON((port+ID_MSG_STRT), (MPM_OP+AMSG_OUT+
+
(currSCCB->Sccb_idmsg & ~DISC_PRIV)));
+
+ WRW_HARPOON((port+ID_MSG_STRT+2),BRH_OP+ALWAYS+CMDPZ);
+
+ WRW_HARPOON((port+SYNC_MSGS+0), (MPM_OP+AMSG_OUT+
+
(((UCHAR)(currSCCB->ControlByte & TAG_TYPE_MASK)
+ >> 6) |
(UCHAR)0x20)));
+ WRW_HARPOON((port+SYNC_MSGS+2),
+
(MPM_OP+AMSG_OUT+currSCCB->Sccb_tag));
+ WRW_HARPOON((port+SYNC_MSGS+4), (BRH_OP+ALWAYS+NP ));
+
+ WR_HARPOON(port+hp_autostart_3, (SELECT+SELCHK_STRT));
+ auto_loaded = TRUE;
+
+ }
+
+#if defined(WIDE_SCSI)
+
+
+ else if (!(currTar_Info->TarStatus & WIDE_NEGOCIATED)) {
+ auto_loaded = siwidn(port,p_card);
+ currSCCB->Sccb_scsistat = SELECT_WN_ST;
+ }
+
+#endif
+
+
+ else if (!((currTar_Info->TarStatus & TAR_SYNC_MASK)
+ == SYNC_SUPPORTED)) {
+ auto_loaded = sisyncn(port,p_card, FALSE);
+ currSCCB->Sccb_scsistat = SELECT_SN_ST;
+ }
+
+
+ if (!auto_loaded)
+ {
+
+#if !defined(DOS)
+ if (currSCCB->ControlByte & F_USE_CMD_Q)
+ {
+
+ CurrCard->globalFlags |= F_TAG_STARTED;
+
+ if ((currTar_Info->TarStatus & TAR_TAG_Q_MASK)
+ == TAG_Q_REJECT)
+ {
+ currSCCB->ControlByte &= ~F_USE_CMD_Q;
+
+ /* Fix up the start instruction with a jump to
+ Non-Tag-CMD handling */
+ WRW_HARPOON((port+ID_MSG_STRT),BRH_OP+ALWAYS+NTCMD);
+
+ WRW_HARPOON((port+NON_TAG_ID_MSG),
+ (MPM_OP+AMSG_OUT+currSCCB->Sccb_idmsg));
+
+ WR_HARPOON(port+hp_autostart_3, (SELECT+SELCHK_STRT));
+
+ /* Setup our STATE so we know what happend when
+ the wheels fall off. */
+ currSCCB->Sccb_scsistat = SELECT_ST;
+
+ currTar_Info->TarLUNBusy[lun] = TRUE;
+ }
+
+ else
+ {
+ WRW_HARPOON((port+ID_MSG_STRT),
(MPM_OP+AMSG_OUT+currSCCB->Sccb_idmsg));
+
+ WRW_HARPOON((port+ID_MSG_STRT+2), (MPM_OP+AMSG_OUT+
+ (((UCHAR)(currSCCB->ControlByte & TAG_TYPE_MASK)
+ >> 6) | (UCHAR)0x20)));
+
+ for (i = 1; i < QUEUE_DEPTH; i++)
+ {
+ if (++lastTag >= QUEUE_DEPTH) lastTag =
1;
+ if (CurrCard->discQ_Tbl[lastTag] ==
NULL)
+ {
+
WRW_HARPOON((port+ID_MSG_STRT+6),
+
(MPM_OP+AMSG_OUT+lastTag));
+ CurrCard->tagQ_Lst = lastTag;
+ currSCCB->Sccb_tag = lastTag;
+ CurrCard->discQ_Tbl[lastTag] =
currSCCB;
+ CurrCard->discQCount++;
+ break;
+ }
+ }
+
+
+ if ( i == QUEUE_DEPTH )
+ {
+ currTar_Info->TarLUNBusy[lun] = TRUE;
+ queueSelectFail(CurrCard,p_card);
+ SGRAM_ACCESS(port);
+ return;
+ }
+
+ currSCCB->Sccb_scsistat = SELECT_Q_ST;
+
+ WR_HARPOON(port+hp_autostart_3, (SELECT+SELCHK_STRT));
+ }
+ }
+
+ else
+ {
+#endif /* !DOS */
+
+ WRW_HARPOON((port+ID_MSG_STRT),BRH_OP+ALWAYS+NTCMD);
+
+ WRW_HARPOON((port+NON_TAG_ID_MSG),
+ (MPM_OP+AMSG_OUT+currSCCB->Sccb_idmsg));
+
+ currSCCB->Sccb_scsistat = SELECT_ST;
+
+ WR_HARPOON(port+hp_autostart_3, (SELECT+SELCHK_STRT));
+#if !defined(DOS)
+ }
+#endif
+
+
+#if defined(OS2)
+ theCCB = (UCHAR far *)&currSCCB->Cdb[0];
+#else
+ theCCB = (UCHAR *)&currSCCB->Cdb[0];
+#endif
+
+ cdb_reg = port + CMD_STRT;
+
+ for (i=0; i < currSCCB->CdbLength; i++)
+ {
+ WRW_HARPOON(cdb_reg, (MPM_OP + ACOMMAND + *theCCB));
+ cdb_reg +=2;
+ theCCB++;
+ }
+
+ if (currSCCB->CdbLength != TWELVE_BYTE_CMD)
+ WRW_HARPOON(cdb_reg, (BRH_OP+ALWAYS+ NP));
+
+ } /* auto_loaded */
+
+#if defined(WIDE_SCSI)
+ WRW_HARPOON((port+hp_fiforead), (USHORT) 0x00);
+ WR_HARPOON(port+hp_xferstat, 0x00);
+#endif
+
+ WRW_HARPOON((port+hp_intstat), (PROG_HLT | TIMEOUT | SEL | BUS_FREE));
+
+ WR_HARPOON(port+hp_portctrl_0,(SCSI_PORT));
+
+
+ if (!(currSCCB->Sccb_MGRFlags & F_DEV_SELECTED))
+ {
+ WR_HARPOON(port+hp_scsictrl_0, (SEL_TAR | ENA_ATN | ENA_RESEL |
ENA_SCAM_SEL));
+ }
+ else
+ {
+
+/* auto_loaded = (RD_HARPOON(port+hp_autostart_3) & (UCHAR)0x1F);
+ auto_loaded |= AUTO_IMMED; */
+ auto_loaded = AUTO_IMMED;
+
+ DISABLE_AUTO(port);
+
+ WR_HARPOON(port+hp_autostart_3, auto_loaded);
+ }
+
+ SGRAM_ACCESS(port);
+}
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: sres
+ *
+ * Description: Hookup the correct CCB and handle the incoming messages.
+ *
+ *---------------------------------------------------------------------*/
+
+#if defined(DOS)
+void sres(USHORT port, UCHAR p_card, PSCCBcard pCurrCard)
+#else
+void sres(ULONG port, UCHAR p_card, PSCCBcard pCurrCard)
+#endif
+{
+
+#if defined(V302)
+#ifdef DOS
+ UCHAR our_target,message, msgRetryCount;
+ extern UCHAR lun, tag;
+#else
+ UCHAR our_target,message,lun,tag, msgRetryCount;
+#endif
+
+#else /* V302 */
+ UCHAR our_target, message, lun = 0, tag, msgRetryCount;
+#endif /* V302 */
+
+
+ PSCCBMgr_tar_info currTar_Info;
+ PSCCB currSCCB;
+
+
+
+
+ if(pCurrCard->currentSCCB != NULL)
+ {
+ currTar_Info =
&sccbMgrTbl[p_card][pCurrCard->currentSCCB->TargID];
+ DISABLE_AUTO(port);
+
+
+ WR_HARPOON((port+hp_scsictrl_0),(ENA_RESEL | ENA_SCAM_SEL));
+
+
+ currSCCB = pCurrCard->currentSCCB;
+ if(currSCCB->Sccb_scsistat == SELECT_WN_ST)
+ {
+ currTar_Info->TarStatus &= ~TAR_WIDE_MASK;
+ currSCCB->Sccb_scsistat = BUS_FREE_ST;
+ }
+ if(currSCCB->Sccb_scsistat == SELECT_SN_ST)
+ {
+ currTar_Info->TarStatus &= ~TAR_SYNC_MASK;
+ currSCCB->Sccb_scsistat = BUS_FREE_ST;
+ }
+ if(((pCurrCard->globalFlags & F_CONLUN_IO) &&
+ ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) !=
TAG_Q_TRYING)))
+ {
+ currTar_Info->TarLUNBusy[currSCCB->Lun] = FALSE;
+ if(currSCCB->Sccb_scsistat != ABORT_ST)
+ {
+ pCurrCard->discQCount--;
+
pCurrCard->discQ_Tbl[currTar_Info->LunDiscQ_Idx[currSCCB->Lun]]
+
= NULL;
+ }
+ }
+ else
+ {
+ currTar_Info->TarLUNBusy[0] = FALSE;
+ if(currSCCB->Sccb_tag)
+ {
+ if(currSCCB->Sccb_scsistat != ABORT_ST)
+ {
+ pCurrCard->discQCount--;
+
pCurrCard->discQ_Tbl[currSCCB->Sccb_tag] = NULL;
+ }
+ }else
+ {
+ if(currSCCB->Sccb_scsistat != ABORT_ST)
+ {
+ pCurrCard->discQCount--;
+
pCurrCard->discQ_Tbl[currTar_Info->LunDiscQ_Idx[0]] = NULL;
+ }
+ }
+ }
+
+ queueSelectFail(&BL_Card[p_card],p_card);
+ }
+
+#if defined(WIDE_SCSI)
+ WRW_HARPOON((port+hp_fiforead), (USHORT) 0x00);
+#endif
+
+
+ our_target = (UCHAR)(RD_HARPOON(port+hp_select_id) >> 4);
+ currTar_Info = &sccbMgrTbl[p_card][our_target];
+
+
+ msgRetryCount = 0;
+ do
+ {
+
+#if defined(V302)
+
+ message = GetTarLun(port, p_card, our_target, pCurrCard, &tag,
&lun);
+
+#else /* V302 */
+
+ currTar_Info = &sccbMgrTbl[p_card][our_target];
+ tag = 0;
+
+
+ while(!(RD_HARPOON(port+hp_scsisig) & SCSI_REQ))
+ {
+ if (! (RD_HARPOON(port+hp_scsisig) & SCSI_BSY))
+ {
+
+ WRW_HARPOON((port+hp_intstat), PHASE);
+ return;
+ }
+ }
+
+ WRW_HARPOON((port+hp_intstat), PHASE);
+ if ((RD_HARPOON(port+hp_scsisig) & S_SCSI_PHZ) == S_MSGI_PH)
+ {
+
+ message = sfm(port,pCurrCard->currentSCCB);
+ if (message)
+ {
+
+ if (message <= (0x80 | LUN_MASK))
+ {
+ lun = message & (UCHAR)LUN_MASK;
+
+#if !defined(DOS)
+ if ((currTar_Info->TarStatus &
TAR_TAG_Q_MASK) == TAG_Q_TRYING)
+ {
+ if (currTar_Info->TarTagQ_Cnt
!= 0)
+ {
+
+ if
(!(currTar_Info->TarLUN_CA))
+ {
+
ACCEPT_MSG(port); /*Release the ACK for ID msg. */
+
+
+ message =
sfm(port,pCurrCard->currentSCCB);
+ if (message)
+ {
+
ACCEPT_MSG(port);
+ }
+
+ else
+ message = FALSE;
+
+ if(message !=
FALSE)
+ {
+ tag =
sfm(port,pCurrCard->currentSCCB);
+
+ if
(!(tag))
+
message = FALSE;
+ }
+
+ } /*C.A. exists! */
+
+ } /*End Q cnt != 0 */
+
+ } /*End Tag cmds supported! */
+#endif /* !DOS */
+
+ } /*End valid ID message. */
+
+ else
+ {
+
+ ACCEPT_MSG_ATN(port);
+ }
+
+ } /* End good id message. */
+
+ else
+ {
+
+ message = FALSE;
+ }
+ }
+ else
+ {
+ ACCEPT_MSG_ATN(port);
+
+ while (!(RDW_HARPOON((port+hp_intstat)) & (PHASE | RESET)) &&
+ !(RD_HARPOON(port+hp_scsisig) & SCSI_REQ) &&
+ (RD_HARPOON(port+hp_scsisig) & SCSI_BSY)) ;
+
+ return;
+ }
+
+#endif /* V302 */
+
+ if(message == FALSE)
+ {
+ msgRetryCount++;
+ if(msgRetryCount == 1)
+ {
+ SendMsg(port, SMPARITY);
+ }
+ else
+ {
+ SendMsg(port, SMDEV_RESET);
+
+ sssyncv(port, our_target,
NARROW_SCSI,currTar_Info);
+
+ if (sccbMgrTbl[p_card][our_target].TarEEValue &
EE_SYNC_MASK)
+ {
+
+
sccbMgrTbl[p_card][our_target].TarStatus &= ~TAR_SYNC_MASK;
+
+ }
+
+ if (sccbMgrTbl[p_card][our_target].TarEEValue &
EE_WIDE_SCSI)
+ {
+
+
sccbMgrTbl[p_card][our_target].TarStatus &= ~TAR_WIDE_MASK;
+ }
+
+
+ queueFlushTargSccb(p_card, our_target,
SCCB_COMPLETE);
+ SccbMgrTableInitTarget(p_card,our_target);
+ return;
+ }
+ }
+ }while(message == FALSE);
+
+
+
+ if(((pCurrCard->globalFlags & F_CONLUN_IO) &&
+ ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) != TAG_Q_TRYING)))
+ {
+ currTar_Info->TarLUNBusy[lun] = TRUE;
+ pCurrCard->currentSCCB =
pCurrCard->discQ_Tbl[currTar_Info->LunDiscQ_Idx[lun]];
+ if(pCurrCard->currentSCCB != NULL)
+ {
+ ACCEPT_MSG(port);
+ }
+ else
+ {
+ ACCEPT_MSG_ATN(port);
+ }
+ }
+ else
+ {
+ currTar_Info->TarLUNBusy[0] = TRUE;
+
+
+ if (tag)
+ {
+ if (pCurrCard->discQ_Tbl[tag] != NULL)
+ {
+ pCurrCard->currentSCCB =
pCurrCard->discQ_Tbl[tag];
+ currTar_Info->TarTagQ_Cnt--;
+ ACCEPT_MSG(port);
+ }
+ else
+ {
+ ACCEPT_MSG_ATN(port);
+ }
+ }else
+ {
+ pCurrCard->currentSCCB =
pCurrCard->discQ_Tbl[currTar_Info->LunDiscQ_Idx[0]];
+ if(pCurrCard->currentSCCB != NULL)
+ {
+ ACCEPT_MSG(port);
+ }
+ else
+ {
+ ACCEPT_MSG_ATN(port);
+ }
+ }
+ }
+
+ if(pCurrCard->currentSCCB != NULL)
+ {
+ if(pCurrCard->currentSCCB->Sccb_scsistat == ABORT_ST)
+ {
+ /* During Abort Tag command, the target could have got
re-selected
+ and completed the command. Check the select Q and
remove the CCB
+ if it is in the Select Q */
+ queueFindSccb(pCurrCard->currentSCCB, p_card);
+ }
+ }
+
+
+ while (!(RDW_HARPOON((port+hp_intstat)) & (PHASE | RESET)) &&
+ !(RD_HARPOON(port+hp_scsisig) & SCSI_REQ) &&
+ (RD_HARPOON(port+hp_scsisig) & SCSI_BSY)) ;
+}
+
+#if defined(V302)
+
+#if defined(DOS)
+UCHAR GetTarLun(USHORT port, UCHAR p_card, UCHAR our_target, PSCCBcard
pCurrCard, PUCHAR tag, PUCHAR lun)
+#else
+UCHAR GetTarLun(ULONG port, UCHAR p_card, UCHAR our_target, PSCCBcard
pCurrCard, PUCHAR tag, PUCHAR lun)
+#endif
+{
+ UCHAR message;
+ PSCCBMgr_tar_info currTar_Info;
+
+
+ currTar_Info = &sccbMgrTbl[p_card][our_target];
+ *tag = 0;
+
+
+ while(!(RD_HARPOON(port+hp_scsisig) & SCSI_REQ))
+ {
+ if (! (RD_HARPOON(port+hp_scsisig) & SCSI_BSY))
+ {
+
+ WRW_HARPOON((port+hp_intstat), PHASE);
+ return(TRUE);
+ }
+ }
+
+ WRW_HARPOON((port+hp_intstat), PHASE);
+ if ((RD_HARPOON(port+hp_scsisig) & S_SCSI_PHZ) == S_MSGI_PH)
+ {
+
+ message = sfm(port,pCurrCard->currentSCCB);
+ if (message)
+ {
+
+ if (message <= (0x80 | LUN_MASK))
+ {
+ *lun = message & (UCHAR)LUN_MASK;
+
+#if !defined(DOS)
+ if ((currTar_Info->TarStatus & TAR_TAG_Q_MASK)
== TAG_Q_TRYING)
+ {
+ if (currTar_Info->TarTagQ_Cnt != 0)
+ {
+
+ if (!(currTar_Info->TarLUN_CA))
+ {
+ ACCEPT_MSG(port);
/*Release the ACK for ID msg. */
+
+
+ message =
sfm(port,pCurrCard->currentSCCB);
+ if (message)
+ {
+
ACCEPT_MSG(port);
+ }
+
+ else
+ return(FALSE);
+
+ *tag =
sfm(port,pCurrCard->currentSCCB);
+
+ if (!(*tag))
return(FALSE);
+
+ } /*C.A. exists! */
+
+ } /*End Q cnt != 0 */
+
+ } /*End Tag cmds supported! */
+#endif /* !DOS */
+
+ } /*End valid ID message. */
+
+ else
+ {
+
+ ACCEPT_MSG_ATN(port);
+ }
+
+ } /* End good id message. */
+
+ else
+ {
+
+ return(FALSE);
+ }
+ }
+ else
+ {
+ ACCEPT_MSG_ATN(port);
+ return(TRUE);
+ }
+ return(TRUE);
+}
+
+#endif /* V302 */
+
+#if defined(DOS)
+void SendMsg(USHORT port, UCHAR message)
+#else
+void SendMsg(ULONG port, UCHAR message)
+#endif
+{
+ while(!(RD_HARPOON(port+hp_scsisig) & SCSI_REQ))
+ {
+ if (! (RD_HARPOON(port+hp_scsisig) & SCSI_BSY))
+ {
+
+ WRW_HARPOON((port+hp_intstat), PHASE);
+ return;
+ }
+ }
+
+ WRW_HARPOON((port+hp_intstat), PHASE);
+ if ((RD_HARPOON(port+hp_scsisig) & S_SCSI_PHZ) == S_MSGO_PH)
+ {
+ WRW_HARPOON((port+hp_intstat), (BUS_FREE | PHASE | XFER_CNT_0));
+
+
+ WR_HARPOON(port+hp_portctrl_0, SCSI_BUS_EN);
+
+ WR_HARPOON(port+hp_scsidata_0,message);
+
+ WR_HARPOON(port+hp_scsisig, (SCSI_ACK + S_ILL_PH));
+
+ ACCEPT_MSG(port);
+
+ WR_HARPOON(port+hp_portctrl_0, 0x00);
+
+ if ((message == SMABORT) || (message == SMDEV_RESET) ||
+ (message == SMABORT_TAG) )
+ {
+ while(!(RDW_HARPOON((port+hp_intstat)) & (BUS_FREE |
PHASE))) {}
+
+ if (RDW_HARPOON((port+hp_intstat)) & BUS_FREE)
+ {
+ WRW_HARPOON((port+hp_intstat), BUS_FREE);
+ }
+ }
+ }
+}
+
+/*---------------------------------------------------------------------
+ *
+ * Function: sdecm
+ *
+ * Description: Determine the proper responce to the message from the
+ * target device.
+ *
+ *---------------------------------------------------------------------*/
+#if defined(DOS)
+void sdecm(UCHAR message, USHORT port, UCHAR p_card)
+#else
+void sdecm(UCHAR message, ULONG port, UCHAR p_card)
+#endif
+{
+ PSCCB currSCCB;
+ PSCCBcard CurrCard;
+ PSCCBMgr_tar_info currTar_Info;
+
+ CurrCard = &BL_Card[p_card];
+ currSCCB = CurrCard->currentSCCB;
+
+ currTar_Info = &sccbMgrTbl[p_card][currSCCB->TargID];
+
+ if (message == SMREST_DATA_PTR)
+ {
+ if (!(currSCCB->Sccb_XferState & F_NO_DATA_YET))
+ {
+ currSCCB->Sccb_ATC = currSCCB->Sccb_savedATC;
+
+ hostDataXferRestart(currSCCB);
+ }
+
+ ACCEPT_MSG(port);
+ WR_HARPOON(port+hp_autostart_1, (AUTO_IMMED+DISCONNECT_START));
+ }
+
+ else if (message == SMCMD_COMP)
+ {
+
+
+ if (currSCCB->Sccb_scsistat == SELECT_Q_ST)
+ {
+ currTar_Info->TarStatus &= ~(UCHAR)TAR_TAG_Q_MASK;
+ currTar_Info->TarStatus |= (UCHAR)TAG_Q_REJECT;
+ }
+
+ ACCEPT_MSG(port);
+
+ }
+
+ else if ((message == SMNO_OP) || (message >= SMIDENT)
+ || (message == SMINIT_RECOVERY) || (message ==
SMREL_RECOVERY))
+ {
+
+ ACCEPT_MSG(port);
+ WR_HARPOON(port+hp_autostart_1, (AUTO_IMMED+DISCONNECT_START));
+ }
+
+ else if (message == SMREJECT)
+ {
+
+ if ((currSCCB->Sccb_scsistat == SELECT_SN_ST) ||
+ (currSCCB->Sccb_scsistat == SELECT_WN_ST) ||
+ ((currTar_Info->TarStatus & TAR_SYNC_MASK) ==
SYNC_TRYING ) ||
+ ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) ==
TAG_Q_TRYING ) )
+
+ {
+ WRW_HARPOON((port+hp_intstat), BUS_FREE);
+
+ ACCEPT_MSG(port);
+
+
+ while ((!(RD_HARPOON(port+hp_scsisig) & SCSI_REQ)) &&
+ (!(RDW_HARPOON((port+hp_intstat)) & BUS_FREE)))
{}
+
+ if(currSCCB->Lun == 0x00)
+ {
+ if ((currSCCB->Sccb_scsistat == SELECT_SN_ST))
+ {
+
+ currTar_Info->TarStatus |=
(UCHAR)SYNC_SUPPORTED;
+
+ currTar_Info->TarEEValue &=
~EE_SYNC_MASK;
+ }
+
+#if defined(WIDE_SCSI)
+ else if ((currSCCB->Sccb_scsistat ==
SELECT_WN_ST))
+ {
+
+
+ currTar_Info->TarStatus =
(currTar_Info->TarStatus &
+
~WIDE_ENABLED) | WIDE_NEGOCIATED;
+
+ currTar_Info->TarEEValue &=
~EE_WIDE_SCSI;
+
+ }
+#endif
+
+ else if ((currTar_Info->TarStatus &
TAR_TAG_Q_MASK) == TAG_Q_TRYING )
+ {
+ currTar_Info->TarStatus =
(currTar_Info->TarStatus &
+
~(UCHAR)TAR_TAG_Q_MASK) | TAG_Q_REJECT;
+
+
+ currSCCB->ControlByte &= ~F_USE_CMD_Q;
+ CurrCard->discQCount--;
+ CurrCard->discQ_Tbl[currSCCB->Sccb_tag]
= NULL;
+ currSCCB->Sccb_tag = 0x00;
+
+ }
+ }
+
+ if (RDW_HARPOON((port+hp_intstat)) & BUS_FREE)
+ {
+
+
+ if(currSCCB->Lun == 0x00)
+ {
+ WRW_HARPOON((port+hp_intstat),
BUS_FREE);
+ CurrCard->globalFlags |= F_NEW_SCCB_CMD;
+ }
+ }
+
+ else
+ {
+
+ if((CurrCard->globalFlags & F_CONLUN_IO) &&
+ ((currTar_Info->TarStatus &
TAR_TAG_Q_MASK) != TAG_Q_TRYING))
+ currTar_Info->TarLUNBusy[currSCCB->Lun]
= TRUE;
+ else
+ currTar_Info->TarLUNBusy[0] = TRUE;
+
+
+ currSCCB->ControlByte &= ~(UCHAR)F_USE_CMD_Q;
+
+ WR_HARPOON(port+hp_autostart_1,
(AUTO_IMMED+DISCONNECT_START));
+
+ }
+ }
+
+ else
+ {
+ ACCEPT_MSG(port);
+
+ while ((!(RD_HARPOON(port+hp_scsisig) & SCSI_REQ)) &&
+ (!(RDW_HARPOON((port+hp_intstat)) & BUS_FREE)))
{}
+
+ if (!(RDW_HARPOON((port+hp_intstat)) & BUS_FREE))
+ {
+ WR_HARPOON(port+hp_autostart_1,
(AUTO_IMMED+DISCONNECT_START));
+ }
+ }
+ }
+
+ else if (message == SMEXT)
+ {
+
+ ACCEPT_MSG(port);
+ shandem(port,p_card,currSCCB);
+ }
+
+ else if (message == SMIGNORWR)
+ {
+
+ ACCEPT_MSG(port); /* ACK the RESIDUE MSG */
+
+ message = sfm(port,currSCCB);
+
+ if(currSCCB->Sccb_scsimsg != SMPARITY)
+ ACCEPT_MSG(port);
+ WR_HARPOON(port+hp_autostart_1, (AUTO_IMMED+DISCONNECT_START));
+ }
+
+
+ else
+ {
+
+ currSCCB->HostStatus = SCCB_PHASE_SEQUENCE_FAIL;
+ currSCCB->Sccb_scsimsg = SMREJECT;
+
+ ACCEPT_MSG_ATN(port);
+ WR_HARPOON(port+hp_autostart_1, (AUTO_IMMED+DISCONNECT_START));
+ }
+}
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: shandem
+ *
+ * Description: Decide what to do with the extended message.
+ *
+ *---------------------------------------------------------------------*/
+#if defined(DOS)
+void shandem(USHORT port, UCHAR p_card, PSCCB pCurrSCCB)
+#else
+void shandem(ULONG port, UCHAR p_card, PSCCB pCurrSCCB)
+#endif
+{
+ UCHAR length,message;
+
+ length = sfm(port,pCurrSCCB);
+ if (length)
+ {
+
+ ACCEPT_MSG(port);
+ message = sfm(port,pCurrSCCB);
+ if (message)
+ {
+
+ if (message == SMSYNC)
+ {
+
+ if (length == 0x03)
+ {
+
+ ACCEPT_MSG(port);
+ stsyncn(port,p_card);
+ }
+ else
+ {
+
+ pCurrSCCB->Sccb_scsimsg = SMREJECT;
+ ACCEPT_MSG_ATN(port);
+ }
+ }
+#if defined(WIDE_SCSI)
+ else if (message == SMWDTR)
+ {
+
+ if (length == 0x02)
+ {
+
+ ACCEPT_MSG(port);
+ stwidn(port,p_card);
+ }
+ else
+ {
+
+ pCurrSCCB->Sccb_scsimsg = SMREJECT;
+ ACCEPT_MSG_ATN(port);
+
+ WR_HARPOON(port+hp_autostart_1,
(AUTO_IMMED+DISCONNECT_START));
+ }
+ }
+#endif
+ else
+ {
+
+ pCurrSCCB->Sccb_scsimsg = SMREJECT;
+ ACCEPT_MSG_ATN(port);
+
+ WR_HARPOON(port+hp_autostart_1,
(AUTO_IMMED+DISCONNECT_START));
+ }
+ }
+ else
+ {
+ if(pCurrSCCB->Sccb_scsimsg != SMPARITY)
+ ACCEPT_MSG(port);
+ WR_HARPOON(port+hp_autostart_1,
(AUTO_IMMED+DISCONNECT_START));
+ }
+ }else
+ {
+ if(pCurrSCCB->Sccb_scsimsg == SMPARITY)
+ WR_HARPOON(port+hp_autostart_1,
(AUTO_IMMED+DISCONNECT_START));
+ }
+}
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: sisyncn
+ *
+ * Description: Read in a message byte from the SCSI bus, and check
+ * for a parity error.
+ *
+ *---------------------------------------------------------------------*/
+
+#if defined(DOS)
+UCHAR sisyncn(USHORT port, UCHAR p_card, UCHAR syncFlag)
+#else
+UCHAR sisyncn(ULONG port, UCHAR p_card, UCHAR syncFlag)
+#endif
+{
+ PSCCB currSCCB;
+ PSCCBMgr_tar_info currTar_Info;
+
+ currSCCB = BL_Card[p_card].currentSCCB;
+ currTar_Info = &sccbMgrTbl[p_card][currSCCB->TargID];
+
+ if (!((currTar_Info->TarStatus & TAR_SYNC_MASK) == SYNC_TRYING)) {
+
+
+ WRW_HARPOON((port+ID_MSG_STRT),
+ (MPM_OP+AMSG_OUT+(currSCCB->Sccb_idmsg & ~(UCHAR)DISC_PRIV)));
+
+ WRW_HARPOON((port+ID_MSG_STRT+2),BRH_OP+ALWAYS+CMDPZ);
+
+ WRW_HARPOON((port+SYNC_MSGS+0), (MPM_OP+AMSG_OUT+SMEXT ));
+ WRW_HARPOON((port+SYNC_MSGS+2), (MPM_OP+AMSG_OUT+0x03 ));
+ WRW_HARPOON((port+SYNC_MSGS+4), (MPM_OP+AMSG_OUT+SMSYNC));
+
+
+ if ((currTar_Info->TarEEValue & EE_SYNC_MASK) == EE_SYNC_20MB)
+
+ WRW_HARPOON((port+SYNC_MSGS+6), (MPM_OP+AMSG_OUT+ 12));
+
+ else if ((currTar_Info->TarEEValue & EE_SYNC_MASK) == EE_SYNC_10MB)
+
+ WRW_HARPOON((port+SYNC_MSGS+6), (MPM_OP+AMSG_OUT+ 25));
+
+ else if ((currTar_Info->TarEEValue & EE_SYNC_MASK) == EE_SYNC_5MB)
+
+ WRW_HARPOON((port+SYNC_MSGS+6), (MPM_OP+AMSG_OUT+ 50));
+
+ else
+ WRW_HARPOON((port+SYNC_MSGS+6), (MPM_OP+AMSG_OUT+ 00));
+
+
+ WRW_HARPOON((port+SYNC_MSGS+8), (RAT_OP ));
+ WRW_HARPOON((port+SYNC_MSGS+10),(MPM_OP+AMSG_OUT+DEFAULT_OFFSET));
+ WRW_HARPOON((port+SYNC_MSGS+12),(BRH_OP+ALWAYS+NP ));
+
+
+ if(syncFlag == FALSE)
+ {
+ WR_HARPOON(port+hp_autostart_3, (SELECT+SELCHK_STRT));
+ currTar_Info->TarStatus = ((currTar_Info->TarStatus &
+ ~(UCHAR)TAR_SYNC_MASK) | (UCHAR)SYNC_TRYING);
+ }
+ else
+ {
+ WR_HARPOON(port+hp_autostart_3, (AUTO_IMMED +
CMD_ONLY_STRT));
+ }
+
+
+ return(TRUE);
+ }
+
+ else {
+
+ currTar_Info->TarStatus |= (UCHAR)SYNC_SUPPORTED;
+ currTar_Info->TarEEValue &= ~EE_SYNC_MASK;
+ return(FALSE);
+ }
+}
+
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: stsyncn
+ *
+ * Description: The has sent us a Sync Nego message so handle it as
+ * necessary.
+ *
+ *---------------------------------------------------------------------*/
+#if defined(DOS)
+void stsyncn(USHORT port, UCHAR p_card)
+#else
+void stsyncn(ULONG port, UCHAR p_card)
+#endif
+{
+ UCHAR sync_msg,offset,sync_reg,our_sync_msg;
+ PSCCB currSCCB;
+ PSCCBMgr_tar_info currTar_Info;
+
+ currSCCB = BL_Card[p_card].currentSCCB;
+ currTar_Info = &sccbMgrTbl[p_card][currSCCB->TargID];
+
+ sync_msg = sfm(port,currSCCB);
+
+ if((sync_msg == 0x00) && (currSCCB->Sccb_scsimsg == SMPARITY))
+ {
+ WR_HARPOON(port+hp_autostart_1, (AUTO_IMMED+DISCONNECT_START));
+ return;
+ }
+
+ ACCEPT_MSG(port);
+
+
+ offset = sfm(port,currSCCB);
+
+ if((offset == 0x00) && (currSCCB->Sccb_scsimsg == SMPARITY))
+ {
+ WR_HARPOON(port+hp_autostart_1, (AUTO_IMMED+DISCONNECT_START));
+ return;
+ }
+
+ if ((currTar_Info->TarEEValue & EE_SYNC_MASK) == EE_SYNC_20MB)
+
+ our_sync_msg = 12; /* Setup our Message to 20mb/s */
+
+ else if ((currTar_Info->TarEEValue & EE_SYNC_MASK) == EE_SYNC_10MB)
+
+ our_sync_msg = 25; /* Setup our Message to 10mb/s */
+
+ else if ((currTar_Info->TarEEValue & EE_SYNC_MASK) == EE_SYNC_5MB)
+
+ our_sync_msg = 50; /* Setup our Message to 5mb/s */
+ else
+
+ our_sync_msg = 0; /* Message = Async */
+
+ if (sync_msg < our_sync_msg) {
+ sync_msg = our_sync_msg; /*if faster, then set to max. */
+ }
+
+ if (offset == ASYNC)
+ sync_msg = ASYNC;
+
+ if (offset > MAX_OFFSET)
+ offset = MAX_OFFSET;
+
+ sync_reg = 0x00;
+
+ if (sync_msg > 12)
+
+ sync_reg = 0x20; /* Use 10MB/s */
+
+ if (sync_msg > 25)
+
+ sync_reg = 0x40; /* Use 6.6MB/s */
+
+ if (sync_msg > 38)
+
+ sync_reg = 0x60; /* Use 5MB/s */
+
+ if (sync_msg > 50)
+
+ sync_reg = 0x80; /* Use 4MB/s */
+
+ if (sync_msg > 62)
+
+ sync_reg = 0xA0; /* Use 3.33MB/s */
+
+ if (sync_msg > 75)
+
+ sync_reg = 0xC0; /* Use 2.85MB/s */
+
+ if (sync_msg > 87)
+
+ sync_reg = 0xE0; /* Use 2.5MB/s */
+
+ if (sync_msg > 100) {
+
+ sync_reg = 0x00; /* Use ASYNC */
+ offset = 0x00;
+ }
+
+
+#if defined(WIDE_SCSI)
+ if (currTar_Info->TarStatus & WIDE_ENABLED)
+
+ sync_reg |= offset;
+
+ else
+
+ sync_reg |= (offset | NARROW_SCSI);
+
+#else
+ sync_reg |= (offset | NARROW_SCSI);
+#endif
+
+ sssyncv(port,currSCCB->TargID,sync_reg,currTar_Info);
+
+
+ if (currSCCB->Sccb_scsistat == SELECT_SN_ST) {
+
+
+ ACCEPT_MSG(port);
+
+ currTar_Info->TarStatus = ((currTar_Info->TarStatus &
+ ~(UCHAR)TAR_SYNC_MASK) | (UCHAR)SYNC_SUPPORTED);
+
+ WR_HARPOON(port+hp_autostart_1, (AUTO_IMMED+DISCONNECT_START));
+ }
+
+ else {
+
+
+ ACCEPT_MSG_ATN(port);
+
+ sisyncr(port,sync_msg,offset);
+
+ currTar_Info->TarStatus = ((currTar_Info->TarStatus &
+ ~(UCHAR)TAR_SYNC_MASK) | (UCHAR)SYNC_SUPPORTED);
+ }
+}
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: sisyncr
+ *
+ * Description: Answer the targets sync message.
+ *
+ *---------------------------------------------------------------------*/
+#if defined(DOS)
+void sisyncr(USHORT port,UCHAR sync_pulse, UCHAR offset)
+#else
+void sisyncr(ULONG port,UCHAR sync_pulse, UCHAR offset)
+#endif
+{
+ ARAM_ACCESS(port);
+ WRW_HARPOON((port+SYNC_MSGS+0), (MPM_OP+AMSG_OUT+SMEXT ));
+ WRW_HARPOON((port+SYNC_MSGS+2), (MPM_OP+AMSG_OUT+0x03 ));
+ WRW_HARPOON((port+SYNC_MSGS+4), (MPM_OP+AMSG_OUT+SMSYNC));
+ WRW_HARPOON((port+SYNC_MSGS+6), (MPM_OP+AMSG_OUT+sync_pulse));
+ WRW_HARPOON((port+SYNC_MSGS+8), (RAT_OP ));
+ WRW_HARPOON((port+SYNC_MSGS+10),(MPM_OP+AMSG_OUT+offset));
+ WRW_HARPOON((port+SYNC_MSGS+12),(BRH_OP+ALWAYS+NP ));
+ SGRAM_ACCESS(port);
+
+ WR_HARPOON(port+hp_portctrl_0, SCSI_PORT);
+ WRW_HARPOON((port+hp_intstat), CLR_ALL_INT_1);
+
+ WR_HARPOON(port+hp_autostart_3, (AUTO_IMMED+CMD_ONLY_STRT));
+
+ while (!(RDW_HARPOON((port+hp_intstat)) & (BUS_FREE | AUTO_INT))) {}
+}
+
+
+
+#if defined(WIDE_SCSI)
+
+/*---------------------------------------------------------------------
+ *
+ * Function: siwidn
+ *
+ * Description: Read in a message byte from the SCSI bus, and check
+ * for a parity error.
+ *
+ *---------------------------------------------------------------------*/
+
+#if defined(DOS)
+UCHAR siwidn(USHORT port, UCHAR p_card)
+#else
+UCHAR siwidn(ULONG port, UCHAR p_card)
+#endif
+{
+ PSCCB currSCCB;
+ PSCCBMgr_tar_info currTar_Info;
+
+ currSCCB = BL_Card[p_card].currentSCCB;
+ currTar_Info = &sccbMgrTbl[p_card][currSCCB->TargID];
+
+ if (!((currTar_Info->TarStatus & TAR_WIDE_MASK) == WIDE_NEGOCIATED)) {
+
+
+ WRW_HARPOON((port+ID_MSG_STRT),
+ (MPM_OP+AMSG_OUT+(currSCCB->Sccb_idmsg &
~(UCHAR)DISC_PRIV)));
+
+ WRW_HARPOON((port+ID_MSG_STRT+2),BRH_OP+ALWAYS+CMDPZ);
+
+ WRW_HARPOON((port+SYNC_MSGS+0), (MPM_OP+AMSG_OUT+SMEXT ));
+ WRW_HARPOON((port+SYNC_MSGS+2), (MPM_OP+AMSG_OUT+0x02 ));
+ WRW_HARPOON((port+SYNC_MSGS+4), (MPM_OP+AMSG_OUT+SMWDTR));
+ WRW_HARPOON((port+SYNC_MSGS+6), (RAT_OP ));
+ WRW_HARPOON((port+SYNC_MSGS+8), (MPM_OP+AMSG_OUT+ SM16BIT));
+ WRW_HARPOON((port+SYNC_MSGS+10),(BRH_OP+ALWAYS+NP ));
+
+ WR_HARPOON(port+hp_autostart_3, (SELECT+SELCHK_STRT));
+
+
+ currTar_Info->TarStatus = ((currTar_Info->TarStatus &
+ ~(UCHAR)TAR_WIDE_MASK) | (UCHAR)WIDE_ENABLED);
+
+ return(TRUE);
+ }
+
+ else {
+
+ currTar_Info->TarStatus = ((currTar_Info->TarStatus &
+ ~(UCHAR)TAR_WIDE_MASK) | WIDE_NEGOCIATED);
+
+ currTar_Info->TarEEValue &= ~EE_WIDE_SCSI;
+ return(FALSE);
+ }
+}
+
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: stwidn
+ *
+ * Description: The has sent us a Wide Nego message so handle it as
+ * necessary.
+ *
+ *---------------------------------------------------------------------*/
+#if defined(DOS)
+void stwidn(USHORT port, UCHAR p_card)
+#else
+void stwidn(ULONG port, UCHAR p_card)
+#endif
+{
+ UCHAR width;
+ PSCCB currSCCB;
+ PSCCBMgr_tar_info currTar_Info;
+
+ currSCCB = BL_Card[p_card].currentSCCB;
+ currTar_Info = &sccbMgrTbl[p_card][currSCCB->TargID];
+
+ width = sfm(port,currSCCB);
+
+ if((width == 0x00) && (currSCCB->Sccb_scsimsg == SMPARITY))
+ {
+ WR_HARPOON(port+hp_autostart_1, (AUTO_IMMED+DISCONNECT_START));
+ return;
+ }
+
+
+ if (!(currTar_Info->TarEEValue & EE_WIDE_SCSI))
+ width = 0;
+
+ if (width) {
+ currTar_Info->TarStatus |= WIDE_ENABLED;
+ width = 0;
+ }
+ else {
+ width = NARROW_SCSI;
+ currTar_Info->TarStatus &= ~WIDE_ENABLED;
+ }
+
+
+ sssyncv(port,currSCCB->TargID,width,currTar_Info);
+
+
+ if (currSCCB->Sccb_scsistat == SELECT_WN_ST)
+ {
+
+
+
+ currTar_Info->TarStatus |= WIDE_NEGOCIATED;
+
+ if (!((currTar_Info->TarStatus & TAR_SYNC_MASK) == SYNC_SUPPORTED))
+ {
+ ACCEPT_MSG_ATN(port);
+ ARAM_ACCESS(port);
+ sisyncn(port,p_card, TRUE);
+ currSCCB->Sccb_scsistat = SELECT_SN_ST;
+ SGRAM_ACCESS(port);
+ }
+ else
+ {
+ ACCEPT_MSG(port);
+ WR_HARPOON(port+hp_autostart_1,
(AUTO_IMMED+DISCONNECT_START));
+ }
+ }
+
+ else {
+
+
+ ACCEPT_MSG_ATN(port);
+
+ if (currTar_Info->TarEEValue & EE_WIDE_SCSI)
+ width = SM16BIT;
+ else
+ width = SM8BIT;
+
+ siwidr(port,width);
+
+ currTar_Info->TarStatus |= (WIDE_NEGOCIATED | WIDE_ENABLED);
+ }
+}
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: siwidr
+ *
+ * Description: Answer the targets Wide nego message.
+ *
+ *---------------------------------------------------------------------*/
+#if defined(DOS)
+void siwidr(USHORT port, UCHAR width)
+#else
+void siwidr(ULONG port, UCHAR width)
+#endif
+{
+ ARAM_ACCESS(port);
+ WRW_HARPOON((port+SYNC_MSGS+0), (MPM_OP+AMSG_OUT+SMEXT ));
+ WRW_HARPOON((port+SYNC_MSGS+2), (MPM_OP+AMSG_OUT+0x02 ));
+ WRW_HARPOON((port+SYNC_MSGS+4), (MPM_OP+AMSG_OUT+SMWDTR));
+ WRW_HARPOON((port+SYNC_MSGS+6), (RAT_OP ));
+ WRW_HARPOON((port+SYNC_MSGS+8),(MPM_OP+AMSG_OUT+width));
+ WRW_HARPOON((port+SYNC_MSGS+10),(BRH_OP+ALWAYS+NP ));
+ SGRAM_ACCESS(port);
+
+ WR_HARPOON(port+hp_portctrl_0, SCSI_PORT);
+ WRW_HARPOON((port+hp_intstat), CLR_ALL_INT_1);
+
+ WR_HARPOON(port+hp_autostart_3, (AUTO_IMMED+CMD_ONLY_STRT));
+
+ while (!(RDW_HARPOON((port+hp_intstat)) & (BUS_FREE | AUTO_INT))) {}
+}
+
+#endif
+
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: sssyncv
+ *
+ * Description: Write the desired value to the Sync Register for the
+ * ID specified.
+ *
+ *---------------------------------------------------------------------*/
+#if defined(DOS)
+void sssyncv(USHORT p_port, UCHAR p_id, UCHAR p_sync_value,PSCCBMgr_tar_info
currTar_Info)
+#else
+void sssyncv(ULONG p_port, UCHAR p_id, UCHAR p_sync_value,PSCCBMgr_tar_info
currTar_Info)
+#endif
+{
+ UCHAR index;
+
+ index = p_id;
+
+ switch (index) {
+
+ case 0:
+ index = 12; /* hp_synctarg_0 */
+ break;
+ case 1:
+ index = 13; /* hp_synctarg_1 */
+ break;
+ case 2:
+ index = 14; /* hp_synctarg_2 */
+ break;
+ case 3:
+ index = 15; /* hp_synctarg_3 */
+ break;
+ case 4:
+ index = 8; /* hp_synctarg_4 */
+ break;
+ case 5:
+ index = 9; /* hp_synctarg_5 */
+ break;
+ case 6:
+ index = 10; /* hp_synctarg_6 */
+ break;
+ case 7:
+ index = 11; /* hp_synctarg_7 */
+ break;
+ case 8:
+ index = 4; /* hp_synctarg_8 */
+ break;
+ case 9:
+ index = 5; /* hp_synctarg_9 */
+ break;
+ case 10:
+ index = 6; /* hp_synctarg_10 */
+ break;
+ case 11:
+ index = 7; /* hp_synctarg_11 */
+ break;
+ case 12:
+ index = 0; /* hp_synctarg_12 */
+ break;
+ case 13:
+ index = 1; /* hp_synctarg_13 */
+ break;
+ case 14:
+ index = 2; /* hp_synctarg_14 */
+ break;
+ case 15:
+ index = 3; /* hp_synctarg_15 */
+
+ }
+
+ WR_HARPOON(p_port+hp_synctarg_base+index, p_sync_value);
+
+ currTar_Info->TarSyncCtrl = p_sync_value;
+}
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: sresb
+ *
+ * Description: Reset the desired card's SCSI bus.
+ *
+ *---------------------------------------------------------------------*/
+#if defined(DOS)
+void sresb(USHORT port, UCHAR p_card)
+#else
+void sresb(ULONG port, UCHAR p_card)
+#endif
+{
+ UCHAR scsiID, i;
+
+ PSCCBMgr_tar_info currTar_Info;
+
+ WR_HARPOON(port+hp_page_ctrl,
+ (RD_HARPOON(port+hp_page_ctrl) | G_INT_DISABLE));
+ WRW_HARPOON((port+hp_intstat), CLR_ALL_INT);
+
+ WR_HARPOON(port+hp_scsictrl_0, SCSI_RST);
+
+ scsiID = RD_HARPOON(port+hp_seltimeout);
+ WR_HARPOON(port+hp_seltimeout,TO_5ms);
+ WRW_HARPOON((port+hp_intstat), TIMEOUT);
+
+ WR_HARPOON(port+hp_portctrl_0,(SCSI_PORT | START_TO));
+
+ while (!(RDW_HARPOON((port+hp_intstat)) & TIMEOUT)) {}
+
+ WR_HARPOON(port+hp_seltimeout,scsiID);
+
+ WR_HARPOON(port+hp_scsictrl_0, ENA_SCAM_SEL);
+
+ Wait(port, TO_5ms);
+
+ WRW_HARPOON((port+hp_intstat), CLR_ALL_INT);
+
+ WR_HARPOON(port+hp_int_mask, (RD_HARPOON(port+hp_int_mask) | 0x00));
+
+ for (scsiID = 0; scsiID < MAX_SCSI_TAR; scsiID++)
+ {
+ currTar_Info = &sccbMgrTbl[p_card][scsiID];
+
+ if (currTar_Info->TarEEValue & EE_SYNC_MASK)
+ {
+ currTar_Info->TarSyncCtrl = 0;
+ currTar_Info->TarStatus &= ~TAR_SYNC_MASK;
+ }
+
+ if (currTar_Info->TarEEValue & EE_WIDE_SCSI)
+ {
+ currTar_Info->TarStatus &= ~TAR_WIDE_MASK;
+ }
+
+ sssyncv(port, scsiID, NARROW_SCSI,currTar_Info);
+
+ SccbMgrTableInitTarget(p_card, scsiID);
+ }
+
+ BL_Card[p_card].scanIndex = 0x00;
+ BL_Card[p_card].currentSCCB = NULL;
+ BL_Card[p_card].globalFlags &= ~(F_TAG_STARTED | F_HOST_XFER_ACT
+
| F_NEW_SCCB_CMD);
+ BL_Card[p_card].cmdCounter = 0x00;
+ BL_Card[p_card].discQCount = 0x00;
+ BL_Card[p_card].tagQ_Lst = 0x01;
+
+ for(i = 0; i < QUEUE_DEPTH; i++)
+ BL_Card[p_card].discQ_Tbl[i] = NULL;
+
+ WR_HARPOON(port+hp_page_ctrl,
+ (RD_HARPOON(port+hp_page_ctrl) & ~G_INT_DISABLE));
+
+}
+
+/*---------------------------------------------------------------------
+ *
+ * Function: ssenss
+ *
+ * Description: Setup for the Auto Sense command.
+ *
+ *---------------------------------------------------------------------*/
+void ssenss(PSCCBcard pCurrCard)
+{
+ UCHAR i;
+ PSCCB currSCCB;
+
+ currSCCB = pCurrCard->currentSCCB;
+
+
+ currSCCB->Save_CdbLen = currSCCB->CdbLength;
+
+ for (i = 0; i < 6; i++) {
+
+ currSCCB->Save_Cdb[i] = currSCCB->Cdb[i];
+ }
+
+ currSCCB->CdbLength = SIX_BYTE_CMD;
+ currSCCB->Cdb[0] = SCSI_REQUEST_SENSE;
+ currSCCB->Cdb[1] = currSCCB->Cdb[1] & (UCHAR)0xE0; /*Keep LUN. */
+ currSCCB->Cdb[2] = 0x00;
+ currSCCB->Cdb[3] = 0x00;
+ currSCCB->Cdb[4] = currSCCB->RequestSenseLength;
+ currSCCB->Cdb[5] = 0x00;
+
+ currSCCB->Sccb_XferCnt = (unsigned long)currSCCB->RequestSenseLength;
+
+ currSCCB->Sccb_ATC = 0x00;
+
+ currSCCB->Sccb_XferState |= F_AUTO_SENSE;
+
+ currSCCB->Sccb_XferState &= ~F_SG_XFER;
+
+ currSCCB->Sccb_idmsg = currSCCB->Sccb_idmsg & ~(UCHAR)DISC_PRIV;
+
+ currSCCB->ControlByte = 0x00;
+
+ currSCCB->Sccb_MGRFlags &= F_STATUSLOADED;
+}
+
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: sxfrp
+ *
+ * Description: Transfer data into the bit bucket until the device
+ * decides to switch phase.
+ *
+ *---------------------------------------------------------------------*/
+
+#if defined(DOS)
+void sxfrp(USHORT p_port, UCHAR p_card)
+#else
+void sxfrp(ULONG p_port, UCHAR p_card)
+#endif
+{
+ UCHAR curr_phz;
+
+
+ DISABLE_AUTO(p_port);
+
+ if (BL_Card[p_card].globalFlags & F_HOST_XFER_ACT) {
+
+ hostDataXferAbort(p_port,p_card,BL_Card[p_card].currentSCCB);
+
+ }
+
+ /* If the Automation handled the end of the transfer then do not
+ match the phase or we will get out of sync with the ISR. */
+
+ if (RDW_HARPOON((p_port+hp_intstat)) & (BUS_FREE | XFER_CNT_0 | AUTO_INT))
+ return;
+
+ WR_HARPOON(p_port+hp_xfercnt_0, 0x00);
+
+ curr_phz = RD_HARPOON(p_port+hp_scsisig) & (UCHAR)S_SCSI_PHZ;
+
+ WRW_HARPOON((p_port+hp_intstat), XFER_CNT_0);
+
+
+ WR_HARPOON(p_port+hp_scsisig, curr_phz);
+
+ while ( !(RDW_HARPOON((p_port+hp_intstat)) & (BUS_FREE | RESET)) &&
+ (curr_phz == (RD_HARPOON(p_port+hp_scsisig) & (UCHAR)S_SCSI_PHZ)) )
+ {
+ if (curr_phz & (UCHAR)SCSI_IOBIT)
+ {
+ WR_HARPOON(p_port+hp_portctrl_0, (SCSI_PORT | HOST_PORT | SCSI_INBIT));
+
+ if (!(RD_HARPOON(p_port+hp_xferstat) & FIFO_EMPTY))
+ {
+ RD_HARPOON(p_port+hp_fifodata_0);
+ }
+ }
+ else
+ {
+ WR_HARPOON(p_port+hp_portctrl_0, (SCSI_PORT | HOST_PORT | HOST_WRT));
+ if (RD_HARPOON(p_port+hp_xferstat) & FIFO_EMPTY)
+ {
+ WR_HARPOON(p_port+hp_fifodata_0,0xFA);
+ }
+ }
+ } /* End of While loop for padding data I/O phase */
+
+ while ( !(RDW_HARPOON((p_port+hp_intstat)) & (BUS_FREE | RESET)))
+ {
+ if (RD_HARPOON(p_port+hp_scsisig) & SCSI_REQ)
+ break;
+ }
+
+ WR_HARPOON(p_port+hp_portctrl_0, (SCSI_PORT | HOST_PORT | SCSI_INBIT));
+ while (!(RD_HARPOON(p_port+hp_xferstat) & FIFO_EMPTY))
+ {
+ RD_HARPOON(p_port+hp_fifodata_0);
+ }
+
+ if ( !(RDW_HARPOON((p_port+hp_intstat)) & (BUS_FREE | RESET)))
+ {
+ WR_HARPOON(p_port+hp_autostart_0, (AUTO_IMMED+DISCONNECT_START));
+ while (!(RDW_HARPOON((p_port+hp_intstat)) & AUTO_INT)) {}
+
+ if (RDW_HARPOON((p_port+hp_intstat)) & (ICMD_COMP | ITAR_DISC))
+ while (!(RDW_HARPOON((p_port+hp_intstat)) & (BUS_FREE | RSEL))) ;
+ }
+}
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: schkdd
+ *
+ * Description: Make sure data has been flushed from both FIFOs and abort
+ * the operations if necessary.
+ *
+ *---------------------------------------------------------------------*/
+
+#if defined(DOS)
+void schkdd(USHORT port, UCHAR p_card)
+#else
+void schkdd(ULONG port, UCHAR p_card)
+#endif
+{
+ USHORT TimeOutLoop;
+ UCHAR sPhase;
+
+ PSCCB currSCCB;
+
+ currSCCB = BL_Card[p_card].currentSCCB;
+
+
+ if ((currSCCB->Sccb_scsistat != DATA_OUT_ST) &&
+ (currSCCB->Sccb_scsistat != DATA_IN_ST)) {
+ return;
+ }
+
+
+
+ if (currSCCB->Sccb_XferState & F_ODD_BALL_CNT)
+ {
+
+ currSCCB->Sccb_ATC += (currSCCB->Sccb_XferCnt-1);
+
+ currSCCB->Sccb_XferCnt = 1;
+
+ currSCCB->Sccb_XferState &= ~F_ODD_BALL_CNT;
+ WRW_HARPOON((port+hp_fiforead), (USHORT) 0x00);
+ WR_HARPOON(port+hp_xferstat, 0x00);
+ }
+
+ else
+ {
+
+ currSCCB->Sccb_ATC += currSCCB->Sccb_XferCnt;
+
+ currSCCB->Sccb_XferCnt = 0;
+ }
+
+ if ((RDW_HARPOON((port+hp_intstat)) & PARITY) &&
+ (currSCCB->HostStatus == SCCB_COMPLETE)) {
+
+ currSCCB->HostStatus = SCCB_PARITY_ERR;
+ WRW_HARPOON((port+hp_intstat), PARITY);
+ }
+
+
+ hostDataXferAbort(port,p_card,currSCCB);
+
+
+ while (RD_HARPOON(port+hp_scsisig) & SCSI_ACK) {}
+
+ TimeOutLoop = 0;
+
+ while(RD_HARPOON(port+hp_xferstat) & FIFO_EMPTY)
+ {
+ if (RDW_HARPOON((port+hp_intstat)) & BUS_FREE) {
+ return;
+ }
+ if (RD_HARPOON(port+hp_offsetctr) & (UCHAR)0x1F) {
+ break;
+ }
+ if (RDW_HARPOON((port+hp_intstat)) & RESET) {
+ return;
+ }
+ if ((RD_HARPOON(port+hp_scsisig) & SCSI_REQ) || (TimeOutLoop++>0x3000) )
+ break;
+ }
+
+ sPhase = RD_HARPOON(port+hp_scsisig) & (SCSI_BSY | S_SCSI_PHZ);
+ if ((!(RD_HARPOON(port+hp_xferstat) & FIFO_EMPTY)) ||
+ (RD_HARPOON(port+hp_offsetctr) & (UCHAR)0x1F) ||
+ (sPhase == (SCSI_BSY | S_DATAO_PH)) ||
+ (sPhase == (SCSI_BSY | S_DATAI_PH)))
+ {
+
+ WR_HARPOON(port+hp_portctrl_0, SCSI_PORT);
+
+ if (!(currSCCB->Sccb_XferState & F_ALL_XFERRED))
+ {
+ if (currSCCB->Sccb_XferState & F_HOST_XFER_DIR) {
+ phaseDataIn(port,p_card);
+ }
+
+ else {
+ phaseDataOut(port,p_card);
+ }
+ }
+ else
+ {
+ sxfrp(port,p_card);
+ if (!(RDW_HARPOON((port+hp_intstat)) &
+ (BUS_FREE | ICMD_COMP | ITAR_DISC | RESET)))
+ {
+ WRW_HARPOON((port+hp_intstat), AUTO_INT);
+ phaseDecode(port,p_card);
+ }
+ }
+
+ }
+
+ else {
+ WR_HARPOON(port+hp_portctrl_0, 0x00);
+ }
+}
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: sinits
+ *
+ * Description: Setup SCCB manager fields in this SCCB.
+ *
+ *---------------------------------------------------------------------*/
+
+void sinits(PSCCB p_sccb, UCHAR p_card)
+{
+ PSCCBMgr_tar_info currTar_Info;
+
+ if((p_sccb->TargID > MAX_SCSI_TAR) || (p_sccb->Lun > MAX_LUN))
+ {
+ return;
+ }
+ currTar_Info = &sccbMgrTbl[p_card][p_sccb->TargID];
+
+ p_sccb->Sccb_XferState = 0x00;
+ p_sccb->Sccb_XferCnt = p_sccb->DataLength;
+
+ if ((p_sccb->OperationCode == SCATTER_GATHER_COMMAND) ||
+ (p_sccb->OperationCode == RESIDUAL_SG_COMMAND)) {
+
+ p_sccb->Sccb_SGoffset = 0;
+ p_sccb->Sccb_XferState = F_SG_XFER;
+ p_sccb->Sccb_XferCnt = 0x00;
+ }
+
+ if (p_sccb->DataLength == 0x00)
+
+ p_sccb->Sccb_XferState |= F_ALL_XFERRED;
+
+ if (p_sccb->ControlByte & F_USE_CMD_Q)
+ {
+ if ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) == TAG_Q_REJECT)
+ p_sccb->ControlByte &= ~F_USE_CMD_Q;
+
+ else
+ currTar_Info->TarStatus |= TAG_Q_TRYING;
+ }
+
+/* For !single SCSI device in system & device allow Disconnect
+ or command is tag_q type then send Cmd with Disconnect Enable
+ else send Cmd with Disconnect Disable */
+
+/*
+ if (((!(BL_Card[p_card].globalFlags & F_SINGLE_DEVICE)) &&
+ (currTar_Info->TarStatus & TAR_ALLOW_DISC)) ||
+ (currTar_Info->TarStatus & TAG_Q_TRYING)) {
+*/
+ if ((currTar_Info->TarStatus & TAR_ALLOW_DISC) ||
+ (currTar_Info->TarStatus & TAG_Q_TRYING)) {
+ p_sccb->Sccb_idmsg = (UCHAR)(SMIDENT | DISC_PRIV) | p_sccb->Lun;
+ }
+
+ else {
+
+ p_sccb->Sccb_idmsg = (UCHAR)SMIDENT | p_sccb->Lun;
+ }
+
+ p_sccb->HostStatus = 0x00;
+ p_sccb->TargetStatus = 0x00;
+ p_sccb->Sccb_tag = 0x00;
+ p_sccb->Sccb_MGRFlags = 0x00;
+ p_sccb->Sccb_sgseg = 0x00;
+ p_sccb->Sccb_ATC = 0x00;
+ p_sccb->Sccb_savedATC = 0x00;
+/*
+ p_sccb->SccbVirtDataPtr = 0x00;
+ p_sccb->Sccb_forwardlink = NULL;
+ p_sccb->Sccb_backlink = NULL;
+ */
+ p_sccb->Sccb_scsistat = BUS_FREE_ST;
+ p_sccb->SccbStatus = SCCB_IN_PROCESS;
+ p_sccb->Sccb_scsimsg = SMNO_OP;
+
+}
+
+
+/*----------------------------------------------------------------------
+ *
+ *
+ * Copyright 1995-1996 by Mylex Corporation. All Rights Reserved
+ *
+ * This file is available under both the GNU General Public License
+ * and a BSD-style copyright; see LICENSE.FlashPoint for details.
+ *
+ * $Workfile: phase.c $
+ *
+ * Description: Functions to intially handle the SCSI bus phase when
+ * the target asserts request (and the automation is not
+ * enabled to handle the situation).
+ *
+ * $Date: 1999/04/26 05:53:56 $
+ *
+ * $Revision: 1.1 $
+ *
+ *----------------------------------------------------------------------*/
+
+/*#include <globals.h>*/
+
+#if (FW_TYPE==_UCB_MGR_)
+ /*#include <budi.h>*/
+#endif
+
+/*#include <sccbmgr.h>*/
+/*#include <blx30.h>*/
+/*#include <target.h>*/
+/*#include <scsi2.h>*/
+/*#include <harpoon.h>*/
+
+
+/*
+extern SCCBCARD BL_Card[MAX_CARDS];
+extern SCCBMGR_TAR_INFO sccbMgrTbl[MAX_CARDS][MAX_SCSI_TAR];
+
+#if defined(OS2)
+ extern void (far *s_PhaseTbl[8]) (ULONG, UCHAR);
+#else
+ #if defined(DOS)
+ extern void (*s_PhaseTbl[8]) (USHORT, UCHAR);
+ #else
+ extern void (*s_PhaseTbl[8]) (ULONG, UCHAR);
+ #endif
+#endif
+*/
+
+/*---------------------------------------------------------------------
+ *
+ * Function: Phase Decode
+ *
+ * Description: Determine the phase and call the appropriate function.
+ *
+ *---------------------------------------------------------------------*/
+
+#if defined(DOS)
+void phaseDecode(USHORT p_port, UCHAR p_card)
+#else
+void phaseDecode(ULONG p_port, UCHAR p_card)
+#endif
+{
+ unsigned char phase_ref;
+#if defined(OS2)
+ void (far *phase) (ULONG, UCHAR);
+#else
+ #if defined(DOS)
+ void (*phase) (USHORT, UCHAR);
+ #else
+ void (*phase) (ULONG, UCHAR);
+ #endif
+#endif
+
+
+ DISABLE_AUTO(p_port);
+
+ phase_ref = (UCHAR) (RD_HARPOON(p_port+hp_scsisig) & S_SCSI_PHZ);
+
+ phase = s_PhaseTbl[phase_ref];
+
+ (*phase)(p_port, p_card); /* Call the correct phase func */
+}
+
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: Data Out Phase
+ *
+ * Description: Start up both the BusMaster and Xbow.
+ *
+ *---------------------------------------------------------------------*/
+
+#if defined(OS2)
+void far phaseDataOut(ULONG port, UCHAR p_card)
+#else
+#if defined(DOS)
+void phaseDataOut(USHORT port, UCHAR p_card)
+#else
+void phaseDataOut(ULONG port, UCHAR p_card)
+#endif
+#endif
+{
+
+ PSCCB currSCCB;
+
+ currSCCB = BL_Card[p_card].currentSCCB;
+ if (currSCCB == NULL)
+ {
+ return; /* Exit if No SCCB record */
+ }
+
+ currSCCB->Sccb_scsistat = DATA_OUT_ST;
+ currSCCB->Sccb_XferState &= ~(F_HOST_XFER_DIR | F_NO_DATA_YET);
+
+ WR_HARPOON(port+hp_portctrl_0, SCSI_PORT);
+
+ WRW_HARPOON((port+hp_intstat), XFER_CNT_0);
+
+ WR_HARPOON(port+hp_autostart_0, (END_DATA+END_DATA_START));
+
+ dataXferProcessor(port, &BL_Card[p_card]);
+
+#if defined(NOBUGBUG)
+ if (RDW_HARPOON((port+hp_intstat)) & XFER_CNT_0)
+ WRW_HARPOON((port+hp_intstat), XFER_CNT_0);
+
+#endif
+
+
+ if (currSCCB->Sccb_XferCnt == 0) {
+
+
+ if ((currSCCB->ControlByte & SCCB_DATA_XFER_OUT) &&
+ (currSCCB->HostStatus == SCCB_COMPLETE))
+ currSCCB->HostStatus = SCCB_DATA_OVER_RUN;
+
+ sxfrp(port,p_card);
+ if (!(RDW_HARPOON((port+hp_intstat)) & (BUS_FREE | RESET)))
+ phaseDecode(port,p_card);
+ }
+}
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: Data In Phase
+ *
+ * Description: Startup the BusMaster and the XBOW.
+ *
+ *---------------------------------------------------------------------*/
+
+#if defined(OS2)
+void far phaseDataIn(ULONG port, UCHAR p_card)
+#else
+#if defined(DOS)
+void phaseDataIn(USHORT port, UCHAR p_card)
+#else
+void phaseDataIn(ULONG port, UCHAR p_card)
+#endif
+#endif
+{
+
+ PSCCB currSCCB;
+
+ currSCCB = BL_Card[p_card].currentSCCB;
+
+ if (currSCCB == NULL)
+ {
+ return; /* Exit if No SCCB record */
+ }
+
+
+ currSCCB->Sccb_scsistat = DATA_IN_ST;
+ currSCCB->Sccb_XferState |= F_HOST_XFER_DIR;
+ currSCCB->Sccb_XferState &= ~F_NO_DATA_YET;
+
+ WR_HARPOON(port+hp_portctrl_0, SCSI_PORT);
+
+ WRW_HARPOON((port+hp_intstat), XFER_CNT_0);
+
+ WR_HARPOON(port+hp_autostart_0, (END_DATA+END_DATA_START));
+
+ dataXferProcessor(port, &BL_Card[p_card]);
+
+ if (currSCCB->Sccb_XferCnt == 0) {
+
+
+ if ((currSCCB->ControlByte & SCCB_DATA_XFER_IN) &&
+ (currSCCB->HostStatus == SCCB_COMPLETE))
+ currSCCB->HostStatus = SCCB_DATA_OVER_RUN;
+
+ sxfrp(port,p_card);
+ if (!(RDW_HARPOON((port+hp_intstat)) & (BUS_FREE | RESET)))
+ phaseDecode(port,p_card);
+
+ }
+}
+
+/*---------------------------------------------------------------------
+ *
+ * Function: Command Phase
+ *
+ * Description: Load the CDB into the automation and start it up.
+ *
+ *---------------------------------------------------------------------*/
+
+#if defined(OS2)
+void far phaseCommand(ULONG p_port, UCHAR p_card)
+#else
+#if defined(DOS)
+void phaseCommand(USHORT p_port, UCHAR p_card)
+#else
+void phaseCommand(ULONG p_port, UCHAR p_card)
+#endif
+#endif
+{
+ PSCCB currSCCB;
+#if defined(DOS)
+ USHORT cdb_reg;
+#else
+ ULONG cdb_reg;
+#endif
+ UCHAR i;
+
+ currSCCB = BL_Card[p_card].currentSCCB;
+
+ if (currSCCB->OperationCode == RESET_COMMAND) {
+
+ currSCCB->HostStatus = SCCB_PHASE_SEQUENCE_FAIL;
+ currSCCB->CdbLength = SIX_BYTE_CMD;
+ }
+
+ WR_HARPOON(p_port+hp_scsisig, 0x00);
+
+ ARAM_ACCESS(p_port);
+
+
+ cdb_reg = p_port + CMD_STRT;
+
+ for (i=0; i < currSCCB->CdbLength; i++) {
+
+ if (currSCCB->OperationCode == RESET_COMMAND)
+
+ WRW_HARPOON(cdb_reg, (MPM_OP + ACOMMAND + 0x00));
+
+ else
+ WRW_HARPOON(cdb_reg, (MPM_OP + ACOMMAND + currSCCB->Cdb[i]));
+ cdb_reg +=2;
+ }
+
+ if (currSCCB->CdbLength != TWELVE_BYTE_CMD)
+ WRW_HARPOON(cdb_reg, (BRH_OP+ALWAYS+ NP));
+
+ WR_HARPOON(p_port+hp_portctrl_0,(SCSI_PORT));
+
+ currSCCB->Sccb_scsistat = COMMAND_ST;
+
+ WR_HARPOON(p_port+hp_autostart_3, (AUTO_IMMED | CMD_ONLY_STRT));
+ SGRAM_ACCESS(p_port);
+}
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: Status phase
+ *
+ * Description: Bring in the status and command complete message bytes
+ *
+ *---------------------------------------------------------------------*/
+
+#if defined(OS2)
+void far phaseStatus(ULONG port, UCHAR p_card)
+#else
+#if defined(DOS)
+void phaseStatus(USHORT port, UCHAR p_card)
+#else
+void phaseStatus(ULONG port, UCHAR p_card)
+#endif
+#endif
+{
+ /* Start-up the automation to finish off this command and let the
+ isr handle the interrupt for command complete when it comes in.
+ We could wait here for the interrupt to be generated?
+ */
+
+ WR_HARPOON(port+hp_scsisig, 0x00);
+
+ WR_HARPOON(port+hp_autostart_0, (AUTO_IMMED+END_DATA_START));
+}
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: Phase Message Out
+ *
+ * Description: Send out our message (if we have one) and handle whatever
+ * else is involed.
+ *
+ *---------------------------------------------------------------------*/
+
+#if defined(OS2)
+void far phaseMsgOut(ULONG port, UCHAR p_card)
+#else
+#if defined(DOS)
+void phaseMsgOut(USHORT port, UCHAR p_card)
+#else
+void phaseMsgOut(ULONG port, UCHAR p_card)
+#endif
+#endif
+{
+ UCHAR message,scsiID;
+ PSCCB currSCCB;
+ PSCCBMgr_tar_info currTar_Info;
+
+ currSCCB = BL_Card[p_card].currentSCCB;
+
+ if (currSCCB != NULL) {
+
+ message = currSCCB->Sccb_scsimsg;
+ scsiID = currSCCB->TargID;
+
+ if (message == SMDEV_RESET)
+ {
+
+
+ currTar_Info = &sccbMgrTbl[p_card][scsiID];
+ currTar_Info->TarSyncCtrl = 0;
+ sssyncv(port, scsiID, NARROW_SCSI,currTar_Info);
+
+ if (sccbMgrTbl[p_card][scsiID].TarEEValue &
EE_SYNC_MASK)
+ {
+
+ sccbMgrTbl[p_card][scsiID].TarStatus &=
~TAR_SYNC_MASK;
+
+ }
+
+ if (sccbMgrTbl[p_card][scsiID].TarEEValue &
EE_WIDE_SCSI)
+ {
+
+ sccbMgrTbl[p_card][scsiID].TarStatus &=
~TAR_WIDE_MASK;
+ }
+
+
+ queueFlushSccb(p_card,SCCB_COMPLETE);
+ SccbMgrTableInitTarget(p_card,scsiID);
+ }
+ else if (currSCCB->Sccb_scsistat == ABORT_ST)
+ {
+ currSCCB->HostStatus = SCCB_COMPLETE;
+ if(BL_Card[p_card].discQ_Tbl[currSCCB->Sccb_tag] !=
NULL)
+ {
+ BL_Card[p_card].discQ_Tbl[currSCCB->Sccb_tag] =
NULL;
+ sccbMgrTbl[p_card][scsiID].TarTagQ_Cnt--;
+ }
+
+ }
+
+ else if (currSCCB->Sccb_scsistat < COMMAND_ST)
+ {
+
+
+ if(message == SMNO_OP)
+ {
+ currSCCB->Sccb_MGRFlags |= F_DEV_SELECTED;
+
+ ssel(port,p_card);
+ return;
+ }
+ }
+ else
+ {
+
+
+ if (message == SMABORT)
+
+ queueFlushSccb(p_card,SCCB_COMPLETE);
+ }
+
+ }
+ else
+ {
+ message = SMABORT;
+ }
+
+ WRW_HARPOON((port+hp_intstat), (BUS_FREE | PHASE | XFER_CNT_0));
+
+
+ WR_HARPOON(port+hp_portctrl_0, SCSI_BUS_EN);
+
+ WR_HARPOON(port+hp_scsidata_0,message);
+
+ WR_HARPOON(port+hp_scsisig, (SCSI_ACK + S_ILL_PH));
+
+ ACCEPT_MSG(port);
+
+ WR_HARPOON(port+hp_portctrl_0, 0x00);
+
+ if ((message == SMABORT) || (message == SMDEV_RESET) ||
+ (message == SMABORT_TAG) )
+ {
+
+ while(!(RDW_HARPOON((port+hp_intstat)) & (BUS_FREE | PHASE))) {}
+
+ if (RDW_HARPOON((port+hp_intstat)) & BUS_FREE)
+ {
+ WRW_HARPOON((port+hp_intstat), BUS_FREE);
+
+ if (currSCCB != NULL)
+ {
+
+ if((BL_Card[p_card].globalFlags & F_CONLUN_IO)
&&
+
((sccbMgrTbl[p_card][currSCCB->TargID].TarStatus & TAR_TAG_Q_MASK) !=
TAG_Q_TRYING))
+
sccbMgrTbl[p_card][currSCCB->TargID].TarLUNBusy[currSCCB->Lun] = FALSE;
+ else
+
sccbMgrTbl[p_card][currSCCB->TargID].TarLUNBusy[0] = FALSE;
+
+ queueCmdComplete(&BL_Card[p_card],currSCCB,
p_card);
+ }
+
+ else
+ {
+ BL_Card[p_card].globalFlags |= F_NEW_SCCB_CMD;
+ }
+ }
+
+ else
+ {
+
+ sxfrp(port,p_card);
+ }
+ }
+
+ else
+ {
+
+ if(message == SMPARITY)
+ {
+ currSCCB->Sccb_scsimsg = SMNO_OP;
+ WR_HARPOON(port+hp_autostart_1,
(AUTO_IMMED+DISCONNECT_START));
+ }
+ else
+ {
+ sxfrp(port,p_card);
+ }
+ }
+}
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: Message In phase
+ *
+ * Description: Bring in the message and determine what to do with it.
+ *
+ *---------------------------------------------------------------------*/
+
+#if defined(OS2)
+void far phaseMsgIn(ULONG port, UCHAR p_card)
+#else
+#if defined(DOS)
+void phaseMsgIn(USHORT port, UCHAR p_card)
+#else
+void phaseMsgIn(ULONG port, UCHAR p_card)
+#endif
+#endif
+{
+ UCHAR message;
+ PSCCB currSCCB;
+
+ currSCCB = BL_Card[p_card].currentSCCB;
+
+ if (BL_Card[p_card].globalFlags & F_HOST_XFER_ACT)
+ {
+
+ phaseChkFifo(port, p_card);
+ }
+
+ message = RD_HARPOON(port+hp_scsidata_0);
+ if ((message == SMDISC) || (message == SMSAVE_DATA_PTR))
+ {
+
+ WR_HARPOON(port+hp_autostart_1, (AUTO_IMMED+END_DATA_START));
+
+ }
+
+ else
+ {
+
+ message = sfm(port,currSCCB);
+ if (message)
+ {
+
+
+ sdecm(message,port,p_card);
+
+ }
+ else
+ {
+ if(currSCCB->Sccb_scsimsg != SMPARITY)
+ ACCEPT_MSG(port);
+ WR_HARPOON(port+hp_autostart_1,
(AUTO_IMMED+DISCONNECT_START));
+ }
+ }
+
+}
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: Illegal phase
+ *
+ * Description: Target switched to some illegal phase, so all we can do
+ * is report an error back to the host (if that is possible)
+ * and send an ABORT message to the misbehaving target.
+ *
+ *---------------------------------------------------------------------*/
+
+#if defined(OS2)
+void far phaseIllegal(ULONG port, UCHAR p_card)
+#else
+#if defined(DOS)
+void phaseIllegal(USHORT port, UCHAR p_card)
+#else
+void phaseIllegal(ULONG port, UCHAR p_card)
+#endif
+#endif
+{
+ PSCCB currSCCB;
+
+ currSCCB = BL_Card[p_card].currentSCCB;
+
+ WR_HARPOON(port+hp_scsisig, RD_HARPOON(port+hp_scsisig));
+ if (currSCCB != NULL) {
+
+ currSCCB->HostStatus = SCCB_PHASE_SEQUENCE_FAIL;
+ currSCCB->Sccb_scsistat = ABORT_ST;
+ currSCCB->Sccb_scsimsg = SMABORT;
+ }
+
+ ACCEPT_MSG_ATN(port);
+}
+
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: Phase Check FIFO
+ *
+ * Description: Make sure data has been flushed from both FIFOs and abort
+ * the operations if necessary.
+ *
+ *---------------------------------------------------------------------*/
+
+#if defined(DOS)
+void phaseChkFifo(USHORT port, UCHAR p_card)
+#else
+void phaseChkFifo(ULONG port, UCHAR p_card)
+#endif
+{
+ ULONG xfercnt;
+ PSCCB currSCCB;
+
+ currSCCB = BL_Card[p_card].currentSCCB;
+
+ if (currSCCB->Sccb_scsistat == DATA_IN_ST)
+ {
+
+ while((!(RD_HARPOON(port+hp_xferstat) & FIFO_EMPTY)) &&
+ (RD_HARPOON(port+hp_ext_status) & BM_CMD_BUSY)) {}
+
+
+ if (!(RD_HARPOON(port+hp_xferstat) & FIFO_EMPTY))
+ {
+ currSCCB->Sccb_ATC += currSCCB->Sccb_XferCnt;
+
+ currSCCB->Sccb_XferCnt = 0;
+
+ if ((RDW_HARPOON((port+hp_intstat)) & PARITY) &&
+ (currSCCB->HostStatus == SCCB_COMPLETE))
+ {
+ currSCCB->HostStatus = SCCB_PARITY_ERR;
+ WRW_HARPOON((port+hp_intstat), PARITY);
+ }
+
+ hostDataXferAbort(port,p_card,currSCCB);
+
+ dataXferProcessor(port, &BL_Card[p_card]);
+
+ while((!(RD_HARPOON(port+hp_xferstat) & FIFO_EMPTY)) &&
+ (RD_HARPOON(port+hp_ext_status) & BM_CMD_BUSY)) {}
+
+ }
+ } /*End Data In specific code. */
+
+
+
+#if defined(DOS)
+ asm { mov dx,port;
+ add dx,hp_xfercnt_2;
+ in al,dx;
+ dec dx;
+ xor ah,ah;
+ mov word ptr xfercnt+2,ax;
+ in al,dx;
+ dec dx;
+ mov ah,al;
+ in al,dx;
+ mov word ptr xfercnt,ax;
+ }
+#else
+ GET_XFER_CNT(port,xfercnt);
+#endif
+
+
+ WR_HARPOON(port+hp_xfercnt_0, 0x00);
+
+
+ WR_HARPOON(port+hp_portctrl_0, 0x00);
+
+ currSCCB->Sccb_ATC += (currSCCB->Sccb_XferCnt - xfercnt);
+
+ currSCCB->Sccb_XferCnt = xfercnt;
+
+ if ((RDW_HARPOON((port+hp_intstat)) & PARITY) &&
+ (currSCCB->HostStatus == SCCB_COMPLETE)) {
+
+ currSCCB->HostStatus = SCCB_PARITY_ERR;
+ WRW_HARPOON((port+hp_intstat), PARITY);
+ }
+
+
+ hostDataXferAbort(port,p_card,currSCCB);
+
+
+ WR_HARPOON(port+hp_fifowrite, 0x00);
+ WR_HARPOON(port+hp_fiforead, 0x00);
+ WR_HARPOON(port+hp_xferstat, 0x00);
+
+ WRW_HARPOON((port+hp_intstat), XFER_CNT_0);
+}
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: Phase Bus Free
+ *
+ * Description: We just went bus free so figure out if it was
+ * because of command complete or from a disconnect.
+ *
+ *---------------------------------------------------------------------*/
+#if defined(DOS)
+void phaseBusFree(USHORT port, UCHAR p_card)
+#else
+void phaseBusFree(ULONG port, UCHAR p_card)
+#endif
+{
+ PSCCB currSCCB;
+
+ currSCCB = BL_Card[p_card].currentSCCB;
+
+ if (currSCCB != NULL)
+ {
+
+ DISABLE_AUTO(port);
+
+
+ if (currSCCB->OperationCode == RESET_COMMAND)
+ {
+
+ if((BL_Card[p_card].globalFlags & F_CONLUN_IO) &&
+
((sccbMgrTbl[p_card][currSCCB->TargID].TarStatus & TAR_TAG_Q_MASK) !=
TAG_Q_TRYING))
+
sccbMgrTbl[p_card][currSCCB->TargID].TarLUNBusy[currSCCB->Lun] = FALSE;
+ else
+ sccbMgrTbl[p_card][currSCCB->TargID].TarLUNBusy[0] =
FALSE;
+
+ queueCmdComplete(&BL_Card[p_card], currSCCB, p_card);
+
+ queueSearchSelect(&BL_Card[p_card],p_card);
+
+ }
+
+ else if(currSCCB->Sccb_scsistat == SELECT_SN_ST)
+ {
+ sccbMgrTbl[p_card][currSCCB->TargID].TarStatus |=
+ (UCHAR)SYNC_SUPPORTED;
+ sccbMgrTbl[p_card][currSCCB->TargID].TarEEValue &= ~EE_SYNC_MASK;
+ }
+
+ else if(currSCCB->Sccb_scsistat == SELECT_WN_ST)
+ {
+ sccbMgrTbl[p_card][currSCCB->TargID].TarStatus =
+ (sccbMgrTbl[p_card][currSCCB->TargID].
+ TarStatus & ~WIDE_ENABLED) | WIDE_NEGOCIATED;
+
+ sccbMgrTbl[p_card][currSCCB->TargID].TarEEValue &= ~EE_WIDE_SCSI;
+ }
+
+#if !defined(DOS)
+ else if(currSCCB->Sccb_scsistat == SELECT_Q_ST)
+ {
+ /* Make sure this is not a phony BUS_FREE. If we were
+ reselected or if BUSY is NOT on then this is a
+ valid BUS FREE. SRR Wednesday, 5/10/1995. */
+
+ if ((!(RD_HARPOON(port+hp_scsisig) & SCSI_BSY)) ||
+ (RDW_HARPOON((port+hp_intstat)) & RSEL))
+ {
+ sccbMgrTbl[p_card][currSCCB->TargID].TarStatus &=
~TAR_TAG_Q_MASK;
+ sccbMgrTbl[p_card][currSCCB->TargID].TarStatus |= TAG_Q_REJECT;
+ }
+
+ else
+ {
+ return;
+ }
+ }
+#endif
+
+ else
+ {
+
+ currSCCB->Sccb_scsistat = BUS_FREE_ST;
+
+ if (!currSCCB->HostStatus)
+ {
+ currSCCB->HostStatus = SCCB_PHASE_SEQUENCE_FAIL;
+ }
+
+ if((BL_Card[p_card].globalFlags & F_CONLUN_IO) &&
+
((sccbMgrTbl[p_card][currSCCB->TargID].TarStatus & TAR_TAG_Q_MASK) !=
TAG_Q_TRYING))
+
sccbMgrTbl[p_card][currSCCB->TargID].TarLUNBusy[currSCCB->Lun] = FALSE;
+ else
+ sccbMgrTbl[p_card][currSCCB->TargID].TarLUNBusy[0] =
FALSE;
+
+ queueCmdComplete(&BL_Card[p_card], currSCCB, p_card);
+ return;
+ }
+
+
+ BL_Card[p_card].globalFlags |= F_NEW_SCCB_CMD;
+
+ } /*end if !=null */
+}
+
+
+
+
+/*----------------------------------------------------------------------
+ *
+ *
+ * Copyright 1995-1996 by Mylex Corporation. All Rights Reserved
+ *
+ * This file is available under both the GNU General Public License
+ * and a BSD-style copyright; see LICENSE.FlashPoint for details.
+ *
+ * $Workfile: automate.c $
+ *
+ * Description: Functions relating to programming the automation of
+ * the HARPOON.
+ *
+ * $Date: 1999/04/26 05:53:56 $
+ *
+ * $Revision: 1.1 $
+ *
+ *----------------------------------------------------------------------*/
+
+/*#include <globals.h>*/
+
+#if (FW_TYPE==_UCB_MGR_)
+ /*#include <budi.h>*/
+#endif
+
+/*#include <sccbmgr.h>*/
+/*#include <blx30.h>*/
+/*#include <target.h>*/
+/*#include <scsi2.h>*/
+/*#include <harpoon.h>*/
+
+/*
+extern SCCBCARD BL_Card[MAX_CARDS];
+extern SCCBMGR_TAR_INFO sccbMgrTbl[MAX_CARDS][MAX_SCSI_TAR];
+extern SCCBCARD BL_Card[MAX_CARDS];
+*/
+
+/*---------------------------------------------------------------------
+ *
+ * Function: Auto Load Default Map
+ *
+ * Description: Load the Automation RAM with the defualt map values.
+ *
+ *---------------------------------------------------------------------*/
+#if defined(DOS)
+void autoLoadDefaultMap(USHORT p_port)
+#else
+void autoLoadDefaultMap(ULONG p_port)
+#endif
+{
+#if defined(DOS)
+ USHORT map_addr;
+#else
+ ULONG map_addr;
+#endif
+
+ ARAM_ACCESS(p_port);
+ map_addr = p_port + hp_aramBase;
+
+ WRW_HARPOON(map_addr, (MPM_OP+AMSG_OUT+ 0xC0)); /*ID MESSAGE */
+ map_addr +=2;
+ WRW_HARPOON(map_addr, (MPM_OP+AMSG_OUT+ 0x20)); /*SIMPLE TAG QUEUEING MSG
*/
+ map_addr +=2;
+ WRW_HARPOON(map_addr, RAT_OP); /*RESET ATTENTION */
+ map_addr +=2;
+ WRW_HARPOON(map_addr, (MPM_OP+AMSG_OUT+ 0x00)); /*TAG ID MSG */
+ map_addr +=2;
+ WRW_HARPOON(map_addr, (MPM_OP+ACOMMAND+ 0x00)); /*CDB BYTE 0 */
+ map_addr +=2;
+ WRW_HARPOON(map_addr, (MPM_OP+ACOMMAND+ 0x00)); /*CDB BYTE 1 */
+ map_addr +=2;
+ WRW_HARPOON(map_addr, (MPM_OP+ACOMMAND+ 0x00)); /*CDB BYTE 2 */
+ map_addr +=2;
+ WRW_HARPOON(map_addr, (MPM_OP+ACOMMAND+ 0x00)); /*CDB BYTE 3 */
+ map_addr +=2;
+ WRW_HARPOON(map_addr, (MPM_OP+ACOMMAND+ 0x00)); /*CDB BYTE 4 */
+ map_addr +=2;
+ WRW_HARPOON(map_addr, (MPM_OP+ACOMMAND+ 0x00)); /*CDB BYTE 5 */
+ map_addr +=2;
+ WRW_HARPOON(map_addr, (MPM_OP+ACOMMAND+ 0x00)); /*CDB BYTE 6 */
+ map_addr +=2;
+ WRW_HARPOON(map_addr, (MPM_OP+ACOMMAND+ 0x00)); /*CDB BYTE 7 */
+ map_addr +=2;
+ WRW_HARPOON(map_addr, (MPM_OP+ACOMMAND+ 0x00)); /*CDB BYTE 8 */
+ map_addr +=2;
+ WRW_HARPOON(map_addr, (MPM_OP+ACOMMAND+ 0x00)); /*CDB BYTE 9 */
+ map_addr +=2;
+ WRW_HARPOON(map_addr, (MPM_OP+ACOMMAND+ 0x00)); /*CDB BYTE 10 */
+ map_addr +=2;
+ WRW_HARPOON(map_addr, (MPM_OP+ACOMMAND+ 0x00)); /*CDB BYTE 11 */
+ map_addr +=2;
+ WRW_HARPOON(map_addr, (CPE_OP+ADATA_OUT+ DINT)); /*JUMP IF DATA OUT */
+ map_addr +=2;
+ WRW_HARPOON(map_addr, (TCB_OP+FIFO_0+ DI)); /*JUMP IF NO DATA IN FIFO */
+ map_addr +=2; /*This means AYNC DATA IN */
+ WRW_HARPOON(map_addr, (SSI_OP+ SSI_IDO_STRT)); /*STOP AND INTERRUPT */
+ map_addr +=2;
+ WRW_HARPOON(map_addr, (CPE_OP+ADATA_IN+DINT)); /*JUMP IF NOT DATA IN PHZ
*/
+ map_addr +=2;
+ WRW_HARPOON(map_addr, (CPN_OP+AMSG_IN+ ST)); /*IF NOT MSG IN CHECK 4
DATA IN */
+ map_addr +=2;
+ WRW_HARPOON(map_addr, (CRD_OP+SDATA+ 0x02)); /*SAVE DATA PTR MSG? */
+ map_addr +=2;
+ WRW_HARPOON(map_addr, (BRH_OP+NOT_EQ+ DC)); /*GO CHECK FOR DISCONNECT
MSG */
+ map_addr +=2;
+ WRW_HARPOON(map_addr, (MRR_OP+SDATA+ D_AR1)); /*SAVE DATA PTRS MSG */
+ map_addr +=2;
+ WRW_HARPOON(map_addr, (CPN_OP+AMSG_IN+ ST)); /*IF NOT MSG IN CHECK DATA
IN */
+ map_addr +=2;
+ WRW_HARPOON(map_addr, (CRD_OP+SDATA+ 0x04)); /*DISCONNECT MSG? */
+ map_addr +=2;
+ WRW_HARPOON(map_addr, (BRH_OP+NOT_EQ+ UNKNWN));/*UKNKNOWN MSG */
+ map_addr +=2;
+ WRW_HARPOON(map_addr, (MRR_OP+SDATA+ D_BUCKET));/*XFER DISCONNECT MSG */
+ map_addr +=2;
+ WRW_HARPOON(map_addr, (SSI_OP+ SSI_ITAR_DISC));/*STOP AND
INTERRUPT */
+ map_addr +=2;
+ WRW_HARPOON(map_addr, (CPN_OP+ASTATUS+ UNKNWN));/*JUMP IF NOT STATUS PHZ.
*/
+ map_addr +=2;
+ WRW_HARPOON(map_addr, (MRR_OP+SDATA+ D_AR0)); /*GET STATUS BYTE */
+ map_addr +=2;
+ WRW_HARPOON(map_addr, (CPN_OP+AMSG_IN+ CC)); /*ERROR IF NOT MSG IN PHZ
*/
+ map_addr +=2;
+ WRW_HARPOON(map_addr, (CRD_OP+SDATA+ 0x00)); /*CHECK FOR CMD COMPLETE
MSG. */
+ map_addr +=2;
+ WRW_HARPOON(map_addr, (BRH_OP+NOT_EQ+ CC)); /*ERROR IF NOT CMD
COMPLETE MSG. */
+ map_addr +=2;
+ WRW_HARPOON(map_addr, (MRR_OP+SDATA+ D_BUCKET));/*GET CMD COMPLETE MSG */
+ map_addr +=2;
+ WRW_HARPOON(map_addr, (SSI_OP+ SSI_ICMD_COMP));/*END OF COMMAND */
+ map_addr +=2;
+
+ WRW_HARPOON(map_addr, (SSI_OP+ SSI_IUNKWN)); /*RECEIVED UNKNOWN MSG BYTE */
+ map_addr +=2;
+ WRW_HARPOON(map_addr, (SSI_OP+ SSI_INO_CC)); /*NO COMMAND COMPLETE AFTER
STATUS */
+ map_addr +=2;
+ WRW_HARPOON(map_addr, (SSI_OP+ SSI_ITICKLE)); /*BIOS Tickled the Mgr */
+ map_addr +=2;
+ WRW_HARPOON(map_addr, (SSI_OP+ SSI_IRFAIL)); /*EXPECTED ID/TAG MESSAGES
AND */
+ map_addr +=2; /* DIDN'T GET ONE */
+ WRW_HARPOON(map_addr, (CRR_OP+AR3+ S_IDREG)); /* comp SCSI SEL ID & AR3*/
+ map_addr +=2;
+ WRW_HARPOON(map_addr, (BRH_OP+EQUAL+ 0x00)); /*SEL ID OK then Conti. */
+ map_addr +=2;
+ WRW_HARPOON(map_addr, (SSI_OP+ SSI_INO_CC)); /*NO COMMAND COMPLETE AFTER
STATUS */
+
+
+
+ SGRAM_ACCESS(p_port);
+}
+
+/*---------------------------------------------------------------------
+ *
+ * Function: Auto Command Complete
+ *
+ * Description: Post command back to host and find another command
+ * to execute.
+ *
+ *---------------------------------------------------------------------*/
+
+#if defined(DOS)
+void autoCmdCmplt(USHORT p_port, UCHAR p_card)
+#else
+void autoCmdCmplt(ULONG p_port, UCHAR p_card)
+#endif
+{
+ PSCCB currSCCB;
+ UCHAR status_byte;
+
+ currSCCB = BL_Card[p_card].currentSCCB;
+
+ status_byte = RD_HARPOON(p_port+hp_gp_reg_0);
+
+ sccbMgrTbl[p_card][currSCCB->TargID].TarLUN_CA = FALSE;
+
+ if (status_byte != SSGOOD) {
+
+ if (status_byte == SSQ_FULL) {
+
+
+ if(((BL_Card[p_card].globalFlags & F_CONLUN_IO) &&
+
((sccbMgrTbl[p_card][currSCCB->TargID].TarStatus & TAR_TAG_Q_MASK) !=
TAG_Q_TRYING)))
+ {
+ sccbMgrTbl[p_card][currSCCB->TargID].TarLUNBusy[currSCCB->Lun]
= TRUE;
+ if(BL_Card[p_card].discQCount != 0)
+ BL_Card[p_card].discQCount--;
+
BL_Card[p_card].discQ_Tbl[sccbMgrTbl[p_card][currSCCB->TargID].LunDiscQ_Idx[currSCCB->Lun]]
= NULL;
+ }
+ else
+ {
+ sccbMgrTbl[p_card][currSCCB->TargID].TarLUNBusy[0] = TRUE;
+ if(currSCCB->Sccb_tag)
+ {
+ if(BL_Card[p_card].discQCount != 0)
+ BL_Card[p_card].discQCount--;
+
BL_Card[p_card].discQ_Tbl[currSCCB->Sccb_tag] = NULL;
+ }else
+ {
+ if(BL_Card[p_card].discQCount != 0)
+ BL_Card[p_card].discQCount--;
+
BL_Card[p_card].discQ_Tbl[sccbMgrTbl[p_card][currSCCB->TargID].LunDiscQ_Idx[0]]
= NULL;
+ }
+ }
+
+ currSCCB->Sccb_MGRFlags |= F_STATUSLOADED;
+
+ queueSelectFail(&BL_Card[p_card],p_card);
+
+ return;
+ }
+
+ if(currSCCB->Sccb_scsistat == SELECT_SN_ST)
+ {
+ sccbMgrTbl[p_card][currSCCB->TargID].TarStatus |=
+ (UCHAR)SYNC_SUPPORTED;
+
+ sccbMgrTbl[p_card][currSCCB->TargID].TarEEValue &= ~EE_SYNC_MASK;
+ BL_Card[p_card].globalFlags |= F_NEW_SCCB_CMD;
+
+ if(((BL_Card[p_card].globalFlags & F_CONLUN_IO) &&
+
((sccbMgrTbl[p_card][currSCCB->TargID].TarStatus & TAR_TAG_Q_MASK) !=
TAG_Q_TRYING)))
+ {
+ sccbMgrTbl[p_card][currSCCB->TargID].TarLUNBusy[currSCCB->Lun]
= TRUE;
+ if(BL_Card[p_card].discQCount != 0)
+ BL_Card[p_card].discQCount--;
+
BL_Card[p_card].discQ_Tbl[sccbMgrTbl[p_card][currSCCB->TargID].LunDiscQ_Idx[currSCCB->Lun]]
= NULL;
+ }
+ else
+ {
+ sccbMgrTbl[p_card][currSCCB->TargID].TarLUNBusy[0] = TRUE;
+ if(currSCCB->Sccb_tag)
+ {
+ if(BL_Card[p_card].discQCount != 0)
+ BL_Card[p_card].discQCount--;
+
BL_Card[p_card].discQ_Tbl[currSCCB->Sccb_tag] = NULL;
+ }else
+ {
+ if(BL_Card[p_card].discQCount != 0)
+ BL_Card[p_card].discQCount--;
+
BL_Card[p_card].discQ_Tbl[sccbMgrTbl[p_card][currSCCB->TargID].LunDiscQ_Idx[0]]
= NULL;
+ }
+ }
+ return;
+
+ }
+
+ if(currSCCB->Sccb_scsistat == SELECT_WN_ST)
+ {
+
+ sccbMgrTbl[p_card][currSCCB->TargID].TarStatus =
+ (sccbMgrTbl[p_card][currSCCB->TargID].
+ TarStatus & ~WIDE_ENABLED) | WIDE_NEGOCIATED;
+
+ sccbMgrTbl[p_card][currSCCB->TargID].TarEEValue &= ~EE_WIDE_SCSI;
+ BL_Card[p_card].globalFlags |= F_NEW_SCCB_CMD;
+
+ if(((BL_Card[p_card].globalFlags & F_CONLUN_IO) &&
+
((sccbMgrTbl[p_card][currSCCB->TargID].TarStatus & TAR_TAG_Q_MASK) !=
TAG_Q_TRYING)))
+ {
+ sccbMgrTbl[p_card][currSCCB->TargID].TarLUNBusy[currSCCB->Lun]
= TRUE;
+ if(BL_Card[p_card].discQCount != 0)
+ BL_Card[p_card].discQCount--;
+
BL_Card[p_card].discQ_Tbl[sccbMgrTbl[p_card][currSCCB->TargID].LunDiscQ_Idx[currSCCB->Lun]]
= NULL;
+ }
+ else
+ {
+ sccbMgrTbl[p_card][currSCCB->TargID].TarLUNBusy[0] = TRUE;
+ if(currSCCB->Sccb_tag)
+ {
+ if(BL_Card[p_card].discQCount != 0)
+ BL_Card[p_card].discQCount--;
+
BL_Card[p_card].discQ_Tbl[currSCCB->Sccb_tag] = NULL;
+ }else
+ {
+ if(BL_Card[p_card].discQCount != 0)
+ BL_Card[p_card].discQCount--;
+
BL_Card[p_card].discQ_Tbl[sccbMgrTbl[p_card][currSCCB->TargID].LunDiscQ_Idx[0]]
= NULL;
+ }
+ }
+ return;
+
+ }
+
+ if (status_byte == SSCHECK)
+ {
+ if(BL_Card[p_card].globalFlags & F_DO_RENEGO)
+ {
+ if
(sccbMgrTbl[p_card][currSCCB->TargID].TarEEValue & EE_SYNC_MASK)
+ {
+
sccbMgrTbl[p_card][currSCCB->TargID].TarStatus &= ~TAR_SYNC_MASK;
+ }
+ if
(sccbMgrTbl[p_card][currSCCB->TargID].TarEEValue & EE_WIDE_SCSI)
+ {
+
sccbMgrTbl[p_card][currSCCB->TargID].TarStatus &= ~TAR_WIDE_MASK;
+ }
+ }
+ }
+
+ if (!(currSCCB->Sccb_XferState & F_AUTO_SENSE)) {
+
+ currSCCB->SccbStatus = SCCB_ERROR;
+ currSCCB->TargetStatus = status_byte;
+
+ if (status_byte == SSCHECK) {
+
+ sccbMgrTbl[p_card][currSCCB->TargID].TarLUN_CA
+ = TRUE;
+
+
+#if (FW_TYPE==_SCCB_MGR_)
+ if (currSCCB->RequestSenseLength != NO_AUTO_REQUEST_SENSE) {
+
+ if (currSCCB->RequestSenseLength == 0)
+ currSCCB->RequestSenseLength = 14;
+
+ ssenss(&BL_Card[p_card]);
+ BL_Card[p_card].globalFlags |= F_NEW_SCCB_CMD;
+
+ if(((BL_Card[p_card].globalFlags &
F_CONLUN_IO) &&
+
((sccbMgrTbl[p_card][currSCCB->TargID].TarStatus & TAR_TAG_Q_MASK) !=
TAG_Q_TRYING)))
+ {
+
sccbMgrTbl[p_card][currSCCB->TargID].TarLUNBusy[currSCCB->Lun] = TRUE;
+ if(BL_Card[p_card].discQCount
!= 0)
+
BL_Card[p_card].discQCount--;
+
BL_Card[p_card].discQ_Tbl[sccbMgrTbl[p_card][currSCCB->TargID].LunDiscQ_Idx[currSCCB->Lun]]
= NULL;
+ }
+ else
+ {
+
sccbMgrTbl[p_card][currSCCB->TargID].TarLUNBusy[0] = TRUE;
+ if(currSCCB->Sccb_tag)
+ {
+
if(BL_Card[p_card].discQCount != 0)
+
BL_Card[p_card].discQCount--;
+
BL_Card[p_card].discQ_Tbl[currSCCB->Sccb_tag] = NULL;
+ }else
+ {
+
if(BL_Card[p_card].discQCount != 0)
+
BL_Card[p_card].discQCount--;
+
BL_Card[p_card].discQ_Tbl[sccbMgrTbl[p_card][currSCCB->TargID].LunDiscQ_Idx[0]]
= NULL;
+ }
+ }
+ return;
+ }
+#else
+ if ((!(currSCCB->Sccb_ucb_ptr->UCB_opcode &
OPC_NO_AUTO_SENSE)) &&
+ (currSCCB->RequestSenseLength))
+ {
+ ssenss(&BL_Card[p_card]);
+ BL_Card[p_card].globalFlags |=
F_NEW_SCCB_CMD;
+
+
if(((BL_Card[p_card].globalFlags & F_CONLUN_IO) &&
+
((sccbMgrTbl[p_card][currSCCB->TargID].TarStatus & TAR_TAG_Q_MASK) !=
TAG_Q_TRYING)))
+ {
+
sccbMgrTbl[p_card][currSCCB->TargID].TarLUNBusy[currSCCB->Lun] = TRUE;
+
if(BL_Card[p_card].discQCount != 0)
+
BL_Card[p_card].discQCount--;
+
BL_Card[p_card].discQ_Tbl[sccbMgrTbl[p_card][currSCCB->TargID].LunDiscQ_Idx[currSCCB->Lun]]
= NULL;
+ }
+ else
+ {
+
sccbMgrTbl[p_card][currSCCB->TargID].TarLUNBusy[0] = TRUE;
+ if(currSCCB->Sccb_tag)
+ {
+
if(BL_Card[p_card].discQCount != 0)
+
BL_Card[p_card].discQCount--;
+
BL_Card[p_card].discQ_Tbl[currSCCB->Sccb_tag] = NULL;
+ }else
+ {
+
if(BL_Card[p_card].discQCount != 0)
+
BL_Card[p_card].discQCount--;
+
BL_Card[p_card].discQ_Tbl[sccbMgrTbl[p_card][currSCCB->TargID].LunDiscQ_Idx[0]]
= NULL;
+ }
+ }
+ return;
+ }
+
+#endif
+ }
+ }
+ }
+
+
+ if((BL_Card[p_card].globalFlags & F_CONLUN_IO) &&
+ ((sccbMgrTbl[p_card][currSCCB->TargID].TarStatus &
TAR_TAG_Q_MASK) != TAG_Q_TRYING))
+ sccbMgrTbl[p_card][currSCCB->TargID].TarLUNBusy[currSCCB->Lun] =
FALSE;
+ else
+ sccbMgrTbl[p_card][currSCCB->TargID].TarLUNBusy[0] = FALSE;
+
+
+ queueCmdComplete(&BL_Card[p_card], currSCCB, p_card);
+}
+
+/*----------------------------------------------------------------------
+ *
+ *
+ * Copyright 1995-1996 by Mylex Corporation. All Rights Reserved
+ *
+ * This file is available under both the GNU General Public License
+ * and a BSD-style copyright; see LICENSE.FlashPoint for details.
+ *
+ * $Workfile: busmstr.c $
+ *
+ * Description: Functions to start, stop, and abort BusMaster operations.
+ *
+ * $Date: 1999/04/26 05:53:56 $
+ *
+ * $Revision: 1.1 $
+ *
+ *----------------------------------------------------------------------*/
+
+/*#include <globals.h>*/
+
+#if (FW_TYPE==_UCB_MGR_)
+ /*#include <budi.h>*/
+#endif
+
+/*#include <sccbmgr.h>*/
+/*#include <blx30.h>*/
+/*#include <target.h>*/
+/*#include <scsi2.h>*/
+/*#include <harpoon.h>*/
+
+
+/*
+extern SCCBCARD BL_Card[MAX_CARDS];
+extern SCCBMGR_TAR_INFO sccbMgrTbl[MAX_CARDS][MAX_SCSI_TAR];
+*/
+
+#define SHORT_WAIT 0x0000000F
+#define LONG_WAIT 0x0000FFFFL
+
+#if defined(BUGBUG)
+void Debug_Load(UCHAR p_card, UCHAR p_bug_data);
+#endif
+
+/*---------------------------------------------------------------------
+ *
+ * Function: Data Transfer Processor
+ *
+ * Description: This routine performs two tasks.
+ * (1) Start data transfer by calling HOST_DATA_XFER_START
+ * function. Once data transfer is started, (2) Depends
+ * on the type of data transfer mode Scatter/Gather mode
+ * or NON Scatter/Gather mode. In NON Scatter/Gather mode,
+ * this routine checks Sccb_MGRFlag (F_HOST_XFER_ACT bit) for
+ * data transfer done. In Scatter/Gather mode, this routine
+ * checks bus master command complete and dual rank busy
+ * bit to keep chaining SC transfer command. Similarly,
+ * in Scatter/Gather mode, it checks Sccb_MGRFlag
+ * (F_HOST_XFER_ACT bit) for data transfer done.
+ *
+ *---------------------------------------------------------------------*/
+
+#if defined(DOS)
+void dataXferProcessor(USHORT port, PSCCBcard pCurrCard)
+#else
+void dataXferProcessor(ULONG port, PSCCBcard pCurrCard)
+#endif
+{
+ PSCCB currSCCB;
+
+ currSCCB = pCurrCard->currentSCCB;
+
+ if (currSCCB->Sccb_XferState & F_SG_XFER)
+ {
+ if (pCurrCard->globalFlags & F_HOST_XFER_ACT)
+
+ {
+ currSCCB->Sccb_sgseg += (UCHAR)SG_BUF_CNT;
+ currSCCB->Sccb_SGoffset = 0x00;
+ }
+ pCurrCard->globalFlags |= F_HOST_XFER_ACT;
+
+ busMstrSGDataXferStart(port, currSCCB);
+ }
+
+ else
+ {
+ if (!(pCurrCard->globalFlags & F_HOST_XFER_ACT))
+ {
+ pCurrCard->globalFlags |= F_HOST_XFER_ACT;
+
+ busMstrDataXferStart(port, currSCCB);
+ }
+ }
+}
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: BusMaster Scatter Gather Data Transfer Start
+ *
+ * Description:
+ *
+ *---------------------------------------------------------------------*/
+#if defined(DOS)
+void busMstrSGDataXferStart(USHORT p_port, PSCCB pcurrSCCB)
+#else
+void busMstrSGDataXferStart(ULONG p_port, PSCCB pcurrSCCB)
+#endif
+{
+ ULONG count,addr,tmpSGCnt;
+ UINT sg_index;
+ UCHAR sg_count, i;
+#if defined(DOS)
+ USHORT reg_offset;
+#else
+ ULONG reg_offset;
+#endif
+
+
+ if (pcurrSCCB->Sccb_XferState & F_HOST_XFER_DIR) {
+
+ count = ((ULONG) HOST_RD_CMD)<<24;
+ }
+
+ else {
+ count = ((ULONG) HOST_WRT_CMD)<<24;
+ }
+
+ sg_count = 0;
+ tmpSGCnt = 0;
+ sg_index = pcurrSCCB->Sccb_sgseg;
+ reg_offset = hp_aramBase;
+
+
+ i = (UCHAR) (RD_HARPOON(p_port+hp_page_ctrl) &
~(SGRAM_ARAM|SCATTER_EN));
+
+
+ WR_HARPOON(p_port+hp_page_ctrl, i);
+
+ while ((sg_count < (UCHAR)SG_BUF_CNT) &&
+ ((ULONG)(sg_index * (UINT)SG_ELEMENT_SIZE) < pcurrSCCB->DataLength) ) {
+
+#if defined(COMPILER_16_BIT) && !defined(DOS)
+ tmpSGCnt += *(((ULONG far *)pcurrSCCB->DataPointer)+
+ (sg_index * 2));
+
+ count |= *(((ULONG far *)pcurrSCCB->DataPointer)+
+ (sg_index * 2));
+
+ addr = *(((ULONG far *)pcurrSCCB->DataPointer)+
+ ((sg_index * 2) + 1));
+
+#else
+ tmpSGCnt += *(((ULONG *)pcurrSCCB->DataPointer)+
+ (sg_index * 2));
+
+ count |= *(((ULONG *)pcurrSCCB->DataPointer)+
+ (sg_index * 2));
+
+ addr = *(((ULONG *)pcurrSCCB->DataPointer)+
+ ((sg_index * 2) + 1));
+#endif
+
+
+ if ((!sg_count) && (pcurrSCCB->Sccb_SGoffset)) {
+
+ addr += ((count & 0x00FFFFFFL) - pcurrSCCB->Sccb_SGoffset);
+ count = (count & 0xFF000000L) | pcurrSCCB->Sccb_SGoffset;
+
+ tmpSGCnt = count & 0x00FFFFFFL;
+ }
+
+ WR_HARP32(p_port,reg_offset,addr);
+ reg_offset +=4;
+
+ WR_HARP32(p_port,reg_offset,count);
+ reg_offset +=4;
+
+ count &= 0xFF000000L;
+ sg_index++;
+ sg_count++;
+
+ } /*End While */
+
+ pcurrSCCB->Sccb_XferCnt = tmpSGCnt;
+
+ WR_HARPOON(p_port+hp_sg_addr,(sg_count<<4));
+
+ if (pcurrSCCB->Sccb_XferState & F_HOST_XFER_DIR) {
+
+ WR_HARP32(p_port,hp_xfercnt_0,tmpSGCnt);
+
+
+ WR_HARPOON(p_port+hp_portctrl_0,(DMA_PORT | SCSI_PORT | SCSI_INBIT));
+ WR_HARPOON(p_port+hp_scsisig, S_DATAI_PH);
+ }
+
+ else {
+
+
+ if ((!(RD_HARPOON(p_port+hp_synctarg_0) & NARROW_SCSI)) &&
+ (tmpSGCnt & 0x000000001))
+ {
+
+ pcurrSCCB->Sccb_XferState |= F_ODD_BALL_CNT;
+ tmpSGCnt--;
+ }
+
+
+ WR_HARP32(p_port,hp_xfercnt_0,tmpSGCnt);
+
+ WR_HARPOON(p_port+hp_portctrl_0,(SCSI_PORT | DMA_PORT | DMA_RD));
+ WR_HARPOON(p_port+hp_scsisig, S_DATAO_PH);
+ }
+
+
+ WR_HARPOON(p_port+hp_page_ctrl, (UCHAR) (i | SCATTER_EN));
+
+}
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: BusMaster Data Transfer Start
+ *
+ * Description:
+ *
+ *---------------------------------------------------------------------*/
+#if defined(DOS)
+void busMstrDataXferStart(USHORT p_port, PSCCB pcurrSCCB)
+#else
+void busMstrDataXferStart(ULONG p_port, PSCCB pcurrSCCB)
+#endif
+{
+ ULONG addr,count;
+
+ if (!(pcurrSCCB->Sccb_XferState & F_AUTO_SENSE)) {
+
+ count = pcurrSCCB->Sccb_XferCnt;
+
+ addr = (ULONG) pcurrSCCB->DataPointer + pcurrSCCB->Sccb_ATC;
+ }
+
+ else {
+ addr = pcurrSCCB->SensePointer;
+ count = pcurrSCCB->RequestSenseLength;
+
+ }
+
+#if defined(DOS)
+ asm { mov dx,p_port;
+ mov ax,word ptr count;
+ add dx,hp_xfer_cnt_lo;
+ out dx,al;
+ inc dx;
+ xchg ah,al
+ out dx,al;
+ inc dx;
+ mov ax,word ptr count+2;
+ out dx,al;
+ inc dx;
+ inc dx;
+ mov ax,word ptr addr;
+ out dx,al;
+ inc dx;
+ xchg ah,al
+ out dx,al;
+ inc dx;
+ mov ax,word ptr addr+2;
+ out dx,al;
+ inc dx;
+ xchg ah,al
+ out dx,al;
+ }
+
+ WR_HARP32(p_port,hp_xfercnt_0,count);
+
+#else
+ HP_SETUP_ADDR_CNT(p_port,addr,count);
+#endif
+
+
+ if (pcurrSCCB->Sccb_XferState & F_HOST_XFER_DIR) {
+
+ WR_HARPOON(p_port+hp_portctrl_0,(DMA_PORT | SCSI_PORT | SCSI_INBIT));
+ WR_HARPOON(p_port+hp_scsisig, S_DATAI_PH);
+
+ WR_HARPOON(p_port+hp_xfer_cmd,
+ (XFER_DMA_HOST | XFER_HOST_AUTO | XFER_DMA_8BIT));
+ }
+
+ else {
+
+ WR_HARPOON(p_port+hp_portctrl_0,(SCSI_PORT | DMA_PORT | DMA_RD));
+ WR_HARPOON(p_port+hp_scsisig, S_DATAO_PH);
+
+ WR_HARPOON(p_port+hp_xfer_cmd,
+ (XFER_HOST_DMA | XFER_HOST_AUTO | XFER_DMA_8BIT));
+
+ }
+}
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: BusMaster Timeout Handler
+ *
+ * Description: This function is called after a bus master command busy time
+ * out is detected. This routines issue halt state machine
+ * with a software time out for command busy. If command busy
+ * is still asserted at the end of the time out, it issues
+ * hard abort with another software time out. It hard abort
+ * command busy is also time out, it'll just give up.
+ *
+ *---------------------------------------------------------------------*/
+#if defined(DOS)
+UCHAR busMstrTimeOut(USHORT p_port)
+#else
+UCHAR busMstrTimeOut(ULONG p_port)
+#endif
+{
+ ULONG timeout;
+
+ timeout = LONG_WAIT;
+
+ WR_HARPOON(p_port+hp_sys_ctrl, HALT_MACH);
+
+ while ((!(RD_HARPOON(p_port+hp_ext_status) & CMD_ABORTED)) && timeout--) {}
+
+
+
+ if (RD_HARPOON(p_port+hp_ext_status) & BM_CMD_BUSY) {
+ WR_HARPOON(p_port+hp_sys_ctrl, HARD_ABORT);
+
+ timeout = LONG_WAIT;
+ while ((RD_HARPOON(p_port+hp_ext_status) & BM_CMD_BUSY) && timeout--) {}
+ }
+
+ RD_HARPOON(p_port+hp_int_status); /*Clear command complete */
+
+ if (RD_HARPOON(p_port+hp_ext_status) & BM_CMD_BUSY) {
+ return(TRUE);
+ }
+
+ else {
+ return(FALSE);
+ }
+}
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: Host Data Transfer Abort
+ *
+ * Description: Abort any in progress transfer.
+ *
+ *---------------------------------------------------------------------*/
+#if defined(DOS)
+void hostDataXferAbort(USHORT port, UCHAR p_card, PSCCB pCurrSCCB)
+#else
+void hostDataXferAbort(ULONG port, UCHAR p_card, PSCCB pCurrSCCB)
+#endif
+{
+
+ ULONG timeout;
+ ULONG remain_cnt;
+ UINT sg_ptr;
+
+ BL_Card[p_card].globalFlags &= ~F_HOST_XFER_ACT;
+
+ if (pCurrSCCB->Sccb_XferState & F_AUTO_SENSE) {
+
+
+ if (!(RD_HARPOON(port+hp_int_status) & INT_CMD_COMPL)) {
+
+ WR_HARPOON(port+hp_bm_ctrl, (RD_HARPOON(port+hp_bm_ctrl) |
FLUSH_XFER_CNTR));
+ timeout = LONG_WAIT;
+
+ while ((RD_HARPOON(port+hp_ext_status) & BM_CMD_BUSY) && timeout--) {}
+
+ WR_HARPOON(port+hp_bm_ctrl, (RD_HARPOON(port+hp_bm_ctrl) &
~FLUSH_XFER_CNTR));
+
+ if (RD_HARPOON(port+hp_ext_status) & BM_CMD_BUSY) {
+
+ if (busMstrTimeOut(port)) {
+
+ if (pCurrSCCB->HostStatus == 0x00)
+
+ pCurrSCCB->HostStatus = SCCB_BM_ERR;
+
+ }
+
+ if (RD_HARPOON(port+hp_int_status) & INT_EXT_STATUS)
+
+ if (RD_HARPOON(port+hp_ext_status) & BAD_EXT_STATUS)
+
+ if (pCurrSCCB->HostStatus == 0x00)
+
+ {
+ pCurrSCCB->HostStatus = SCCB_BM_ERR;
+#if defined(BUGBUG)
+ WR_HARPOON(port+hp_dual_addr_lo,
+ RD_HARPOON(port+hp_ext_status));
+#endif
+ }
+ }
+ }
+ }
+
+ else if (pCurrSCCB->Sccb_XferCnt) {
+
+ if (pCurrSCCB->Sccb_XferState & F_SG_XFER) {
+
+
+ WR_HARPOON(port+hp_page_ctrl, (RD_HARPOON(port+hp_page_ctrl) &
+ ~SCATTER_EN));
+
+ WR_HARPOON(port+hp_sg_addr,0x00);
+
+ sg_ptr = pCurrSCCB->Sccb_sgseg + SG_BUF_CNT;
+
+ if (sg_ptr > (UINT)(pCurrSCCB->DataLength / SG_ELEMENT_SIZE)) {
+
+ sg_ptr = (UINT)(pCurrSCCB->DataLength / SG_ELEMENT_SIZE);
+ }
+
+ remain_cnt = pCurrSCCB->Sccb_XferCnt;
+
+ while (remain_cnt < 0x01000000L) {
+
+ sg_ptr--;
+
+#if defined(COMPILER_16_BIT) && !defined(DOS)
+ if (remain_cnt > (ULONG)(*(((ULONG far *)pCurrSCCB->
+ DataPointer) + (sg_ptr * 2)))) {
+
+ remain_cnt -= (ULONG)(*(((ULONG far *)pCurrSCCB->
+ DataPointer) + (sg_ptr * 2)));
+ }
+
+#else
+ if (remain_cnt > (ULONG)(*(((ULONG *)pCurrSCCB->
+ DataPointer) + (sg_ptr * 2)))) {
+
+ remain_cnt -= (ULONG)(*(((ULONG *)pCurrSCCB->
+ DataPointer) + (sg_ptr * 2)));
+ }
+#endif
+
+ else {
+
+ break;
+ }
+ }
+
+
+
+ if (remain_cnt < 0x01000000L) {
+
+
+ pCurrSCCB->Sccb_SGoffset = remain_cnt;
+
+ pCurrSCCB->Sccb_sgseg = (USHORT)sg_ptr;
+
+
+ if ((ULONG)(sg_ptr * SG_ELEMENT_SIZE) == pCurrSCCB->DataLength
+ && (remain_cnt == 0))
+
+ pCurrSCCB->Sccb_XferState |= F_ALL_XFERRED;
+ }
+
+ else {
+
+
+ if (pCurrSCCB->HostStatus == 0x00) {
+
+ pCurrSCCB->HostStatus = SCCB_GROSS_FW_ERR;
+ }
+ }
+ }
+
+
+ if (!(pCurrSCCB->Sccb_XferState & F_HOST_XFER_DIR)) {
+
+
+ if (RD_HARPOON(port+hp_ext_status) & BM_CMD_BUSY) {
+
+ busMstrTimeOut(port);
+ }
+
+ else {
+
+ if (RD_HARPOON(port+hp_int_status) & INT_EXT_STATUS) {
+
+ if (RD_HARPOON(port+hp_ext_status) & BAD_EXT_STATUS) {
+
+ if (pCurrSCCB->HostStatus == 0x00) {
+
+ pCurrSCCB->HostStatus = SCCB_BM_ERR;
+#if defined(BUGBUG)
+ WR_HARPOON(port+hp_dual_addr_lo,
+ RD_HARPOON(port+hp_ext_status));
+#endif
+ }
+ }
+ }
+
+ }
+ }
+
+ else {
+
+
+ if ((RD_HARPOON(port+hp_fifo_cnt)) >= BM_THRESHOLD) {
+
+ timeout = SHORT_WAIT;
+
+ while ((RD_HARPOON(port+hp_ext_status) & BM_CMD_BUSY) &&
+ ((RD_HARPOON(port+hp_fifo_cnt)) >= BM_THRESHOLD) &&
+ timeout--) {}
+ }
+
+ if (RD_HARPOON(port+hp_ext_status) & BM_CMD_BUSY) {
+
+ WR_HARPOON(port+hp_bm_ctrl, (RD_HARPOON(port+hp_bm_ctrl) |
+ FLUSH_XFER_CNTR));
+
+ timeout = LONG_WAIT;
+
+ while ((RD_HARPOON(port+hp_ext_status) & BM_CMD_BUSY) &&
+ timeout--) {}
+
+ WR_HARPOON(port+hp_bm_ctrl, (RD_HARPOON(port+hp_bm_ctrl) &
+ ~FLUSH_XFER_CNTR));
+
+
+ if (RD_HARPOON(port+hp_ext_status) & BM_CMD_BUSY) {
+
+ if (pCurrSCCB->HostStatus == 0x00) {
+
+ pCurrSCCB->HostStatus = SCCB_BM_ERR;
+ }
+
+ busMstrTimeOut(port);
+ }
+ }
+
+ if (RD_HARPOON(port+hp_int_status) & INT_EXT_STATUS) {
+
+ if (RD_HARPOON(port+hp_ext_status) & BAD_EXT_STATUS) {
+
+ if (pCurrSCCB->HostStatus == 0x00) {
+
+ pCurrSCCB->HostStatus = SCCB_BM_ERR;
+#if defined(BUGBUG)
+ WR_HARPOON(port+hp_dual_addr_lo,
+ RD_HARPOON(port+hp_ext_status));
+#endif
+ }
+ }
+ }
+ }
+
+ }
+
+ else {
+
+
+ if (RD_HARPOON(port+hp_ext_status) & BM_CMD_BUSY) {
+
+ timeout = LONG_WAIT;
+
+ while ((RD_HARPOON(port+hp_ext_status) & BM_CMD_BUSY) && timeout--) {}
+
+ if (RD_HARPOON(port+hp_ext_status) & BM_CMD_BUSY) {
+
+ if (pCurrSCCB->HostStatus == 0x00) {
+
+ pCurrSCCB->HostStatus = SCCB_BM_ERR;
+ }
+
+ busMstrTimeOut(port);
+ }
+ }
+
+
+ if (RD_HARPOON(port+hp_int_status) & INT_EXT_STATUS) {
+
+ if (RD_HARPOON(port+hp_ext_status) & BAD_EXT_STATUS) {
+
+ if (pCurrSCCB->HostStatus == 0x00) {
+
+ pCurrSCCB->HostStatus = SCCB_BM_ERR;
+#if defined(BUGBUG)
+ WR_HARPOON(port+hp_dual_addr_lo,
+ RD_HARPOON(port+hp_ext_status));
+#endif
+ }
+ }
+
+ }
+
+ if (pCurrSCCB->Sccb_XferState & F_SG_XFER) {
+
+ WR_HARPOON(port+hp_page_ctrl, (RD_HARPOON(port+hp_page_ctrl) &
+ ~SCATTER_EN));
+
+ WR_HARPOON(port+hp_sg_addr,0x00);
+
+ pCurrSCCB->Sccb_sgseg += SG_BUF_CNT;
+
+ pCurrSCCB->Sccb_SGoffset = 0x00;
+
+
+ if ((ULONG)(pCurrSCCB->Sccb_sgseg * SG_ELEMENT_SIZE) >=
+ pCurrSCCB->DataLength) {
+
+ pCurrSCCB->Sccb_XferState |= F_ALL_XFERRED;
+
+ pCurrSCCB->Sccb_sgseg = (USHORT)(pCurrSCCB->DataLength /
SG_ELEMENT_SIZE);
+
+ }
+ }
+
+ else {
+
+ if (!(pCurrSCCB->Sccb_XferState & F_AUTO_SENSE))
+
+ pCurrSCCB->Sccb_XferState |= F_ALL_XFERRED;
+ }
+ }
+
+ WR_HARPOON(port+hp_int_mask,(INT_CMD_COMPL | SCSI_INTERRUPT));
+}
+
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: Host Data Transfer Restart
+ *
+ * Description: Reset the available count due to a restore data
+ * pointers message.
+ *
+ *---------------------------------------------------------------------*/
+void hostDataXferRestart(PSCCB currSCCB)
+{
+ ULONG data_count;
+ UINT sg_index;
+#if defined(COMPILER_16_BIT) && !defined(DOS)
+ ULONG far *sg_ptr;
+#else
+ ULONG *sg_ptr;
+#endif
+
+ if (currSCCB->Sccb_XferState & F_SG_XFER) {
+
+ currSCCB->Sccb_XferCnt = 0;
+
+ sg_index = 0xffff; /*Index by long words into sg list. */
+ data_count = 0; /*Running count of SG xfer counts. */
+
+#if defined(COMPILER_16_BIT) && !defined(DOS)
+ sg_ptr = (ULONG far *)currSCCB->DataPointer;
+#else
+ sg_ptr = (ULONG *)currSCCB->DataPointer;
+#endif
+
+ while (data_count < currSCCB->Sccb_ATC) {
+
+ sg_index++;
+ data_count += *(sg_ptr+(sg_index * 2));
+ }
+
+ if (data_count == currSCCB->Sccb_ATC) {
+
+ currSCCB->Sccb_SGoffset = 0;
+ sg_index++;
+ }
+
+ else {
+ currSCCB->Sccb_SGoffset = data_count - currSCCB->Sccb_ATC;
+ }
+
+ currSCCB->Sccb_sgseg = (USHORT)sg_index;
+ }
+
+ else {
+ currSCCB->Sccb_XferCnt = currSCCB->DataLength - currSCCB->Sccb_ATC;
+ }
+}
+
+/*----------------------------------------------------------------------
+ *
+ *
+ * Copyright 1995-1996 by Mylex Corporation. All Rights Reserved
+ *
+ * This file is available under both the GNU General Public License
+ * and a BSD-style copyright; see LICENSE.FlashPoint for details.
+ *
+ * $Workfile: scam.c $
+ *
+ * Description: Functions relating to handling of the SCAM selection
+ * and the determination of the SCSI IDs to be assigned
+ * to all perspective SCSI targets.
+ *
+ * $Date: 1999/04/26 05:53:56 $
+ *
+ * $Revision: 1.1 $
+ *
+ *----------------------------------------------------------------------*/
+
+/*#include <globals.h>*/
+
+#if (FW_TYPE==_UCB_MGR_)
+ /*#include <budi.h>*/
+#endif
+
+/*#include <sccbmgr.h>*/
+/*#include <blx30.h>*/
+/*#include <target.h>*/
+/*#include <scsi2.h>*/
+/*#include <eeprom.h>*/
+/*#include <harpoon.h>*/
+
+
+
+/*
+extern SCCBMGR_TAR_INFO sccbMgrTbl[MAX_CARDS][MAX_SCSI_TAR];
+extern SCCBCARD BL_Card[MAX_CARDS];
+extern SCCBSCAM_INFO scamInfo[MAX_SCSI_TAR];
+extern NVRAMINFO nvRamInfo[MAX_MB_CARDS];
+#if defined(DOS) || defined(OS2)
+extern UCHAR temp_id_string[ID_STRING_LENGTH];
+#endif
+extern UCHAR scamHAString[];
+*/
+/*---------------------------------------------------------------------
+ *
+ * Function: scini
+ *
+ * Description: Setup all data structures necessary for SCAM selection.
+ *
+ *---------------------------------------------------------------------*/
+
+void scini(UCHAR p_card, UCHAR p_our_id, UCHAR p_power_up)
+{
+
+#if defined(SCAM_LEV_2)
+ UCHAR loser,assigned_id;
+#endif
+#if defined(DOS)
+
+ USHORT p_port;
+#else
+ ULONG p_port;
+#endif
+
+ UCHAR i,k,ScamFlg ;
+ PSCCBcard currCard;
+ PNVRamInfo pCurrNvRam;
+
+ currCard = &BL_Card[p_card];
+ p_port = currCard->ioPort;
+ pCurrNvRam = currCard->pNvRamInfo;
+
+
+ if(pCurrNvRam){
+ ScamFlg = pCurrNvRam->niScamConf;
+ i = pCurrNvRam->niSysConf;
+ }
+ else{
+ ScamFlg = (UCHAR) utilEERead(p_port, SCAM_CONFIG/2);
+ i = (UCHAR)(utilEERead(p_port, (SYSTEM_CONFIG/2)));
+ }
+ if(!(i & 0x02)) /* check if reset bus in AutoSCSI parameter set */
+ return;
+
+ inisci(p_card,p_port, p_our_id);
+
+ /* Force to wait 1 sec after SCSI bus reset. Some SCAM device FW
+ too slow to return to SCAM selection */
+
+ /* if (p_power_up)
+ Wait1Second(p_port);
+ else
+ Wait(p_port, TO_250ms); */
+
+ Wait1Second(p_port);
+
+#if defined(SCAM_LEV_2)
+
+ if ((ScamFlg & SCAM_ENABLED) && (ScamFlg & SCAM_LEVEL2))
+ {
+ while (!(scarb(p_port,INIT_SELTD))) {}
+
+ scsel(p_port);
+
+ do {
+ scxferc(p_port,SYNC_PTRN);
+ scxferc(p_port,DOM_MSTR);
+ loser = scsendi(p_port,&scamInfo[p_our_id].id_string[0]);
+ } while ( loser == 0xFF );
+
+ scbusf(p_port);
+
+ if ((p_power_up) && (!loser))
+ {
+ sresb(p_port,p_card);
+ Wait(p_port, TO_250ms);
+
+ while (!(scarb(p_port,INIT_SELTD))) {}
+
+ scsel(p_port);
+
+ do {
+ scxferc(p_port, SYNC_PTRN);
+ scxferc(p_port, DOM_MSTR);
+ loser = scsendi(p_port,&scamInfo[p_our_id].
+ id_string[0]);
+ } while ( loser == 0xFF );
+
+ scbusf(p_port);
+ }
+ }
+
+ else
+ {
+ loser = FALSE;
+ }
+
+
+ if (!loser)
+ {
+
+#endif /* SCAM_LEV_2 */
+
+ scamInfo[p_our_id].state = ID_ASSIGNED;
+
+
+ if (ScamFlg & SCAM_ENABLED)
+ {
+
+ for (i=0; i < MAX_SCSI_TAR; i++)
+ {
+ if ((scamInfo[i].state == ID_UNASSIGNED) ||
+ (scamInfo[i].state == ID_UNUSED))
+ {
+ if (scsell(p_port,i))
+ {
+ scamInfo[i].state = LEGACY;
+ if ((scamInfo[i].id_string[0] != 0xFF) ||
+ (scamInfo[i].id_string[1] != 0xFA))
+ {
+
+ scamInfo[i].id_string[0] = 0xFF;
+ scamInfo[i].id_string[1] = 0xFA;
+ if(pCurrNvRam == NULL)
+ currCard->globalFlags |= F_UPDATE_EEPROM;
+ }
+ }
+ }
+ }
+
+ sresb(p_port,p_card);
+ Wait1Second(p_port);
+ while (!(scarb(p_port,INIT_SELTD))) {}
+ scsel(p_port);
+ scasid(p_card, p_port);
+ }
+
+#if defined(SCAM_LEV_2)
+
+ }
+
+ else if ((loser) && (ScamFlg & SCAM_ENABLED))
+ {
+ scamInfo[p_our_id].id_string[0] = SLV_TYPE_CODE0;
+ assigned_id = FALSE;
+ scwtsel(p_port);
+
+ do {
+ while (scxferc(p_port,0x00) != SYNC_PTRN) {}
+
+ i = scxferc(p_port,0x00);
+ if (i == ASSIGN_ID)
+ {
+ if (!(scsendi(p_port,&scamInfo[p_our_id].id_string[0])))
+ {
+ i = scxferc(p_port,0x00);
+ if (scvalq(i))
+ {
+ k = scxferc(p_port,0x00);
+
+ if (scvalq(k))
+ {
+ currCard->ourId =
+ ((UCHAR)(i<<3)+(k & (UCHAR)7)) & (UCHAR) 0x3F;
+ inisci(p_card, p_port, p_our_id);
+ scamInfo[currCard->ourId].state = ID_ASSIGNED;
+ scamInfo[currCard->ourId].id_string[0]
+ = SLV_TYPE_CODE0;
+ assigned_id = TRUE;
+ }
+ }
+ }
+ }
+
+ else if (i == SET_P_FLAG)
+ {
+ if (!(scsendi(p_port,
+ &scamInfo[p_our_id].id_string[0])))
+ scamInfo[p_our_id].id_string[0] |= 0x80;
+ }
+ }while (!assigned_id);
+
+ while (scxferc(p_port,0x00) != CFG_CMPLT) {}
+ }
+
+#endif /* SCAM_LEV_2 */
+ if (ScamFlg & SCAM_ENABLED)
+ {
+ scbusf(p_port);
+ if (currCard->globalFlags & F_UPDATE_EEPROM)
+ {
+ scsavdi(p_card, p_port);
+ currCard->globalFlags &= ~F_UPDATE_EEPROM;
+ }
+ }
+
+
+#if defined(DOS)
+ for (i=0; i < MAX_SCSI_TAR; i++)
+ {
+ if (((ScamFlg & SCAM_ENABLED) && (scamInfo[i].state == LEGACY))
+ || (i != p_our_id))
+ {
+ scsellDOS(p_port,i);
+ }
+ }
+#endif
+
+/*
+ for (i=0,k=0; i < MAX_SCSI_TAR; i++)
+ {
+ if ((scamInfo[i].state == ID_ASSIGNED) ||
+ (scamInfo[i].state == LEGACY))
+ k++;
+ }
+
+ if (k==2)
+ currCard->globalFlags |= F_SINGLE_DEVICE;
+ else
+ currCard->globalFlags &= ~F_SINGLE_DEVICE;
+*/
+}
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: scarb
+ *
+ * Description: Gain control of the bus and wait SCAM select time (250ms)
+ *
+ *---------------------------------------------------------------------*/
+
+#if defined(DOS)
+int scarb(USHORT p_port, UCHAR p_sel_type)
+#else
+int scarb(ULONG p_port, UCHAR p_sel_type)
+#endif
+{
+ if (p_sel_type == INIT_SELTD)
+ {
+
+ while (RD_HARPOON(p_port+hp_scsisig) & (SCSI_SEL | SCSI_BSY)) {}
+
+
+ if (RD_HARPOON(p_port+hp_scsisig) & SCSI_SEL)
+ return(FALSE);
+
+ if (RD_HARPOON(p_port+hp_scsidata_0) != 00)
+ return(FALSE);
+
+ WR_HARPOON(p_port+hp_scsisig, (RD_HARPOON(p_port+hp_scsisig) |
SCSI_BSY));
+
+ if (RD_HARPOON(p_port+hp_scsisig) & SCSI_SEL) {
+
+ WR_HARPOON(p_port+hp_scsisig, (RD_HARPOON(p_port+hp_scsisig) &
+ ~SCSI_BSY));
+ return(FALSE);
+ }
+
+
+ WR_HARPOON(p_port+hp_scsisig, (RD_HARPOON(p_port+hp_scsisig) |
SCSI_SEL));
+
+ if (RD_HARPOON(p_port+hp_scsidata_0) != 00) {
+
+ WR_HARPOON(p_port+hp_scsisig, (RD_HARPOON(p_port+hp_scsisig) &
+ ~(SCSI_BSY | SCSI_SEL)));
+ return(FALSE);
+ }
+ }
+
+
+ WR_HARPOON(p_port+hp_clkctrl_0, (RD_HARPOON(p_port+hp_clkctrl_0)
+ & ~ACTdeassert));
+ WR_HARPOON(p_port+hp_scsireset, SCAM_EN);
+ WR_HARPOON(p_port+hp_scsidata_0, 0x00);
+#if defined(WIDE_SCSI)
+ WR_HARPOON(p_port+hp_scsidata_1, 0x00);
+#endif
+ WR_HARPOON(p_port+hp_portctrl_0, SCSI_BUS_EN);
+
+ WR_HARPOON(p_port+hp_scsisig, (RD_HARPOON(p_port+hp_scsisig) | SCSI_MSG));
+
+ WR_HARPOON(p_port+hp_scsisig, (RD_HARPOON(p_port+hp_scsisig)
+ & ~SCSI_BSY));
+
+ Wait(p_port,TO_250ms);
+
+ return(TRUE);
+}
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: scbusf
+ *
+ * Description: Release the SCSI bus and disable SCAM selection.
+ *
+ *---------------------------------------------------------------------*/
+
+#if defined(DOS)
+void scbusf(USHORT p_port)
+#else
+void scbusf(ULONG p_port)
+#endif
+{
+ WR_HARPOON(p_port+hp_page_ctrl,
+ (RD_HARPOON(p_port+hp_page_ctrl) | G_INT_DISABLE));
+
+
+ WR_HARPOON(p_port+hp_scsidata_0, 0x00);
+
+ WR_HARPOON(p_port+hp_portctrl_0, (RD_HARPOON(p_port+hp_portctrl_0)
+ & ~SCSI_BUS_EN));
+
+ WR_HARPOON(p_port+hp_scsisig, 0x00);
+
+
+ WR_HARPOON(p_port+hp_scsireset, (RD_HARPOON(p_port+hp_scsireset)
+ & ~SCAM_EN));
+
+ WR_HARPOON(p_port+hp_clkctrl_0, (RD_HARPOON(p_port+hp_clkctrl_0)
+ | ACTdeassert));
+
+#if defined(SCAM_LEV_2)
+ WRW_HARPOON((p_port+hp_intstat), (BUS_FREE | AUTO_INT | SCAM_SEL));
+#else
+ WRW_HARPOON((p_port+hp_intstat), (BUS_FREE | AUTO_INT));
+#endif
+
+ WR_HARPOON(p_port+hp_page_ctrl,
+ (RD_HARPOON(p_port+hp_page_ctrl) & ~G_INT_DISABLE));
+}
+
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: scasid
+ *
+ * Description: Assign an ID to all the SCAM devices.
+ *
+ *---------------------------------------------------------------------*/
+
+#if defined(DOS)
+void scasid(UCHAR p_card, USHORT p_port)
+#else
+void scasid(UCHAR p_card, ULONG p_port)
+#endif
+{
+#if defined(DOS) || defined(OS2)
+ /* Use external defined in global space area, instead of Stack
+ space. WIN/95 DOS doesnot work TINY mode. The OS doesnot intialize
+ SS equal to DS. Thus the array allocated on stack doesnot get
+ access correctly */
+#else
+ UCHAR temp_id_string[ID_STRING_LENGTH];
+#endif
+
+ UCHAR i,k,scam_id;
+ UCHAR crcBytes[3];
+ PNVRamInfo pCurrNvRam;
+ ushort_ptr pCrcBytes;
+
+ pCurrNvRam = BL_Card[p_card].pNvRamInfo;
+
+ i=FALSE;
+
+ while (!i)
+ {
+
+ for (k=0; k < ID_STRING_LENGTH; k++)
+ {
+ temp_id_string[k] = (UCHAR) 0x00;
+ }
+
+ scxferc(p_port,SYNC_PTRN);
+ scxferc(p_port,ASSIGN_ID);
+
+ if (!(sciso(p_port,&temp_id_string[0])))
+ {
+ if(pCurrNvRam){
+ pCrcBytes = (ushort_ptr)&crcBytes[0];
+ *pCrcBytes = CalcCrc16(&temp_id_string[0]);
+ crcBytes[2] = CalcLrc(&temp_id_string[0]);
+ temp_id_string[1] = crcBytes[2];
+ temp_id_string[2] = crcBytes[0];
+ temp_id_string[3] = crcBytes[1];
+ for(k = 4; k < ID_STRING_LENGTH; k++)
+ temp_id_string[k] = (UCHAR) 0x00;
+ }
+ i = scmachid(p_card,temp_id_string);
+
+ if (i == CLR_PRIORITY)
+ {
+ scxferc(p_port,MISC_CODE);
+ scxferc(p_port,CLR_P_FLAG);
+ i = FALSE; /*Not the last ID yet. */
+ }
+
+ else if (i != NO_ID_AVAIL)
+ {
+ if (i < 8 )
+ scxferc(p_port,ID_0_7);
+ else
+ scxferc(p_port,ID_8_F);
+
+ scam_id = (i & (UCHAR) 0x07);
+
+
+ for (k=1; k < 0x08; k <<= 1)
+ if (!( k & i ))
+ scam_id += 0x08; /*Count number of zeros in DB0-3. */
+
+ scxferc(p_port,scam_id);
+
+ i = FALSE; /*Not the last ID yet. */
+ }
+ }
+
+ else
+ {
+ i = TRUE;
+ }
+
+ } /*End while */
+
+ scxferc(p_port,SYNC_PTRN);
+ scxferc(p_port,CFG_CMPLT);
+}
+
+
+
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: scsel
+ *
+ * Description: Select all the SCAM devices.
+ *
+ *---------------------------------------------------------------------*/
+
+#if defined(DOS)
+void scsel(USHORT p_port)
+#else
+void scsel(ULONG p_port)
+#endif
+{
+
+ WR_HARPOON(p_port+hp_scsisig, SCSI_SEL);
+ scwiros(p_port, SCSI_MSG);
+
+ WR_HARPOON(p_port+hp_scsisig, (SCSI_SEL | SCSI_BSY));
+
+
+ WR_HARPOON(p_port+hp_scsisig, (SCSI_SEL | SCSI_BSY | SCSI_IOBIT | SCSI_CD));
+ WR_HARPOON(p_port+hp_scsidata_0, (UCHAR)(RD_HARPOON(p_port+hp_scsidata_0) |
+ (UCHAR)(BIT(7)+BIT(6))));
+
+
+ WR_HARPOON(p_port+hp_scsisig, (SCSI_BSY | SCSI_IOBIT | SCSI_CD));
+ scwiros(p_port, SCSI_SEL);
+
+ WR_HARPOON(p_port+hp_scsidata_0, (UCHAR)(RD_HARPOON(p_port+hp_scsidata_0) &
+ ~(UCHAR)BIT(6)));
+ scwirod(p_port, BIT(6));
+
+ WR_HARPOON(p_port+hp_scsisig, (SCSI_SEL | SCSI_BSY | SCSI_IOBIT | SCSI_CD));
+}
+
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: scxferc
+ *
+ * Description: Handshake the p_data (DB4-0) across the bus.
+ *
+ *---------------------------------------------------------------------*/
+
+#if defined(DOS)
+UCHAR scxferc(USHORT p_port, UCHAR p_data)
+#else
+UCHAR scxferc(ULONG p_port, UCHAR p_data)
+#endif
+{
+ UCHAR curr_data, ret_data;
+
+ curr_data = p_data | BIT(7) | BIT(5); /*Start with DB7 & DB5 asserted. */
+
+ WR_HARPOON(p_port+hp_scsidata_0, curr_data);
+
+ curr_data &= ~BIT(7);
+
+ WR_HARPOON(p_port+hp_scsidata_0, curr_data);
+
+ scwirod(p_port,BIT(7)); /*Wait for DB7 to be released. */
+ while (!(RD_HARPOON(p_port+hp_scsidata_0) & BIT(5)));
+
+ ret_data = (RD_HARPOON(p_port+hp_scsidata_0) & (UCHAR) 0x1F);
+
+ curr_data |= BIT(6);
+
+ WR_HARPOON(p_port+hp_scsidata_0, curr_data);
+
+ curr_data &= ~BIT(5);
+
+ WR_HARPOON(p_port+hp_scsidata_0, curr_data);
+
+ scwirod(p_port,BIT(5)); /*Wait for DB5 to be released. */
+
+ curr_data &= ~(BIT(4)|BIT(3)|BIT(2)|BIT(1)|BIT(0)); /*Release data bits */
+ curr_data |= BIT(7);
+
+ WR_HARPOON(p_port+hp_scsidata_0, curr_data);
+
+ curr_data &= ~BIT(6);
+
+ WR_HARPOON(p_port+hp_scsidata_0, curr_data);
+
+ scwirod(p_port,BIT(6)); /*Wait for DB6 to be released. */
+
+ return(ret_data);
+}
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: scsendi
+ *
+ * Description: Transfer our Identification string to determine if we
+ * will be the dominant master.
+ *
+ *---------------------------------------------------------------------*/
+
+#if defined(DOS)
+UCHAR scsendi(USHORT p_port, UCHAR p_id_string[])
+#else
+UCHAR scsendi(ULONG p_port, UCHAR p_id_string[])
+#endif
+{
+ UCHAR ret_data,byte_cnt,bit_cnt,defer;
+
+ defer = FALSE;
+
+ for (byte_cnt = 0; byte_cnt < ID_STRING_LENGTH; byte_cnt++) {
+
+ for (bit_cnt = 0x80; bit_cnt != 0 ; bit_cnt >>= 1) {
+
+ if (defer)
+ ret_data = scxferc(p_port,00);
+
+ else if (p_id_string[byte_cnt] & bit_cnt)
+
+ ret_data = scxferc(p_port,02);
+
+ else {
+
+ ret_data = scxferc(p_port,01);
+ if (ret_data & 02)
+ defer = TRUE;
+ }
+
+ if ((ret_data & 0x1C) == 0x10)
+ return(0x00); /*End of isolation stage, we won! */
+
+ if (ret_data & 0x1C)
+ return(0xFF);
+
+ if ((defer) && (!(ret_data & 0x1F)))
+ return(0x01); /*End of isolation stage, we lost. */
+
+ } /*bit loop */
+
+ } /*byte loop */
+
+ if (defer)
+ return(0x01); /*We lost */
+ else
+ return(0); /*We WON! Yeeessss! */
+}
+
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: sciso
+ *
+ * Description: Transfer the Identification string.
+ *
+ *---------------------------------------------------------------------*/
+
+#if defined(DOS)
+UCHAR sciso(USHORT p_port, UCHAR p_id_string[])
+#else
+UCHAR sciso(ULONG p_port, UCHAR p_id_string[])
+#endif
+{
+ UCHAR ret_data,the_data,byte_cnt,bit_cnt;
+
+ the_data = 0;
+
+ for (byte_cnt = 0; byte_cnt < ID_STRING_LENGTH; byte_cnt++) {
+
+ for (bit_cnt = 0; bit_cnt < 8; bit_cnt++) {
+
+ ret_data = scxferc(p_port,0);
+
+ if (ret_data & 0xFC)
+ return(0xFF);
+
+ else {
+
+ the_data <<= 1;
+ if (ret_data & BIT(1)) {
+ the_data |= 1;
+ }
+ }
+
+ if ((ret_data & 0x1F) == 0)
+ {
+/*
+ if(bit_cnt != 0 || bit_cnt != 8)
+ {
+ byte_cnt = 0;
+ bit_cnt = 0;
+ scxferc(p_port, SYNC_PTRN);
+ scxferc(p_port, ASSIGN_ID);
+ continue;
+ }
+*/
+ if (byte_cnt)
+ return(0x00);
+ else
+ return(0xFF);
+ }
+
+ } /*bit loop */
+
+ p_id_string[byte_cnt] = the_data;
+
+ } /*byte loop */
+
+ return(0);
+}
+
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: scwirod
+ *
+ * Description: Sample the SCSI data bus making sure the signal has been
+ * deasserted for the correct number of consecutive samples.
+ *
+ *---------------------------------------------------------------------*/
+
+#if defined(DOS)
+void scwirod(USHORT p_port, UCHAR p_data_bit)
+#else
+void scwirod(ULONG p_port, UCHAR p_data_bit)
+#endif
+{
+ UCHAR i;
+
+ i = 0;
+ while ( i < MAX_SCSI_TAR ) {
+
+ if (RD_HARPOON(p_port+hp_scsidata_0) & p_data_bit)
+
+ i = 0;
+
+ else
+
+ i++;
+
+ }
+}
+
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: scwiros
+ *
+ * Description: Sample the SCSI Signal lines making sure the signal has been
+ * deasserted for the correct number of consecutive samples.
+ *
+ *---------------------------------------------------------------------*/
+
+#if defined(DOS)
+void scwiros(USHORT p_port, UCHAR p_data_bit)
+#else
+void scwiros(ULONG p_port, UCHAR p_data_bit)
+#endif
+{
+ UCHAR i;
+
+ i = 0;
+ while ( i < MAX_SCSI_TAR ) {
+
+ if (RD_HARPOON(p_port+hp_scsisig) & p_data_bit)
+
+ i = 0;
+
+ else
+
+ i++;
+
+ }
+}
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: scvalq
+ *
+ * Description: Make sure we received a valid data byte.
+ *
+ *---------------------------------------------------------------------*/
+
+UCHAR scvalq(UCHAR p_quintet)
+{
+ UCHAR count;
+
+ for (count=1; count < 0x08; count<<=1) {
+ if (!(p_quintet & count))
+ p_quintet -= 0x80;
+ }
+
+ if (p_quintet & 0x18)
+ return(FALSE);
+
+ else
+ return(TRUE);
+}
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: scsell
+ *
+ * Description: Select the specified device ID using a selection timeout
+ * less than 4ms. If somebody responds then it is a legacy
+ * drive and this ID must be marked as such.
+ *
+ *---------------------------------------------------------------------*/
+
+#if defined(DOS)
+UCHAR scsell(USHORT p_port, UCHAR targ_id)
+#else
+UCHAR scsell(ULONG p_port, UCHAR targ_id)
+#endif
+{
+#if defined(DOS)
+ USHORT i;
+#else
+ ULONG i;
+#endif
+
+ WR_HARPOON(p_port+hp_page_ctrl,
+ (RD_HARPOON(p_port+hp_page_ctrl) | G_INT_DISABLE));
+
+ ARAM_ACCESS(p_port);
+
+ WR_HARPOON(p_port+hp_addstat,(RD_HARPOON(p_port+hp_addstat) | SCAM_TIMER));
+ WR_HARPOON(p_port+hp_seltimeout,TO_4ms);
+
+
+ for (i = p_port+CMD_STRT; i < p_port+CMD_STRT+12; i+=2) {
+ WRW_HARPOON(i, (MPM_OP+ACOMMAND));
+ }
+ WRW_HARPOON(i, (BRH_OP+ALWAYS+ NP));
+
+ WRW_HARPOON((p_port+hp_intstat),
+ (RESET | TIMEOUT | SEL | BUS_FREE | AUTO_INT));
+
+ WR_HARPOON(p_port+hp_select_id, targ_id);
+
+ WR_HARPOON(p_port+hp_portctrl_0, SCSI_PORT);
+ WR_HARPOON(p_port+hp_autostart_3, (SELECT | CMD_ONLY_STRT));
+ WR_HARPOON(p_port+hp_scsictrl_0, (SEL_TAR | ENA_RESEL));
+
+
+ while (!(RDW_HARPOON((p_port+hp_intstat)) &
+ (RESET | PROG_HLT | TIMEOUT | AUTO_INT))) {}
+
+ if (RDW_HARPOON((p_port+hp_intstat)) & RESET)
+ Wait(p_port, TO_250ms);
+
+ DISABLE_AUTO(p_port);
+
+ WR_HARPOON(p_port+hp_addstat,(RD_HARPOON(p_port+hp_addstat) & ~SCAM_TIMER));
+ WR_HARPOON(p_port+hp_seltimeout,TO_290ms);
+
+ SGRAM_ACCESS(p_port);
+
+ if (RDW_HARPOON((p_port+hp_intstat)) & (RESET | TIMEOUT) ) {
+
+ WRW_HARPOON((p_port+hp_intstat),
+ (RESET | TIMEOUT | SEL | BUS_FREE | PHASE));
+
+ WR_HARPOON(p_port+hp_page_ctrl,
+ (RD_HARPOON(p_port+hp_page_ctrl) & ~G_INT_DISABLE));
+
+ return(FALSE); /*No legacy device */
+ }
+
+ else {
+
+ while(!(RDW_HARPOON((p_port+hp_intstat)) & BUS_FREE)) {
+ if (RD_HARPOON(p_port+hp_scsisig) & SCSI_REQ)
+ {
+ WR_HARPOON(p_port+hp_scsisig, (SCSI_ACK
+ S_ILL_PH));
+ ACCEPT_MSG(p_port);
+ }
+ }
+
+ WRW_HARPOON((p_port+hp_intstat), CLR_ALL_INT_1);
+
+ WR_HARPOON(p_port+hp_page_ctrl,
+ (RD_HARPOON(p_port+hp_page_ctrl) & ~G_INT_DISABLE));
+
+ return(TRUE); /*Found one of them oldies! */
+ }
+}
+
+#if defined(DOS)
+/*---------------------------------------------------------------------
+ *
+ * Function: scsell for DOS
+ *
+ * Description: Select the specified device ID using a selection timeout
+ * less than 2ms. This was specially required to solve
+ * the problem with Plextor 12X CD-ROM drive. This drive
+ * was responding the Selection at the
end of 4ms and
+ * hanging the system.
+ *
+ *---------------------------------------------------------------------*/
+
+UCHAR scsellDOS(USHORT p_port, UCHAR targ_id)
+{
+ USHORT i;
+
+ WR_HARPOON(p_port+hp_page_ctrl,
+ (RD_HARPOON(p_port+hp_page_ctrl) | G_INT_DISABLE));
+
+ ARAM_ACCESS(p_port);
+
+ WR_HARPOON(p_port+hp_addstat,(RD_HARPOON(p_port+hp_addstat) | SCAM_TIMER));
+ WR_HARPOON(p_port+hp_seltimeout,TO_2ms);
+
+
+ for (i = p_port+CMD_STRT; i < p_port+CMD_STRT+12; i+=2) {
+ WRW_HARPOON(i, (MPM_OP+ACOMMAND));
+ }
+ WRW_HARPOON(i, (BRH_OP+ALWAYS+ NP));
+
+ WRW_HARPOON((p_port+hp_intstat),
+ (RESET | TIMEOUT | SEL | BUS_FREE | AUTO_INT));
+
+ WR_HARPOON(p_port+hp_select_id, targ_id);
+
+ WR_HARPOON(p_port+hp_portctrl_0, SCSI_PORT);
+ WR_HARPOON(p_port+hp_autostart_3, (SELECT | CMD_ONLY_STRT));
+ WR_HARPOON(p_port+hp_scsictrl_0, (SEL_TAR | ENA_RESEL));
+
+
+ while (!(RDW_HARPOON((p_port+hp_intstat)) &
+ (RESET | PROG_HLT | TIMEOUT | AUTO_INT))) {}
+
+ if (RDW_HARPOON((p_port+hp_intstat)) & RESET)
+ Wait(p_port, TO_250ms);
+
+ DISABLE_AUTO(p_port);
+
+ WR_HARPOON(p_port+hp_addstat,(RD_HARPOON(p_port+hp_addstat) & ~SCAM_TIMER));
+ WR_HARPOON(p_port+hp_seltimeout,TO_290ms);
+
+ SGRAM_ACCESS(p_port);
+
+ if (RDW_HARPOON((p_port+hp_intstat)) & (RESET | TIMEOUT) ) {
+
+ WRW_HARPOON((p_port+hp_intstat),
+ (RESET | TIMEOUT | SEL | BUS_FREE | PHASE));
+
+ WR_HARPOON(p_port+hp_page_ctrl,
+ (RD_HARPOON(p_port+hp_page_ctrl) & ~G_INT_DISABLE));
+
+ return(FALSE); /*No legacy device */
+ }
+
+ else {
+
+ while(!(RDW_HARPOON((p_port+hp_intstat)) & BUS_FREE)) {
+ if (RD_HARPOON(p_port+hp_scsisig) & SCSI_REQ)
+ {
+ WR_HARPOON(p_port+hp_scsisig, (SCSI_ACK
+ S_ILL_PH));
+ ACCEPT_MSG(p_port);
+ }
+ }
+
+ WRW_HARPOON((p_port+hp_intstat), CLR_ALL_INT_1);
+
+ WR_HARPOON(p_port+hp_page_ctrl,
+ (RD_HARPOON(p_port+hp_page_ctrl) & ~G_INT_DISABLE));
+
+ return(TRUE); /*Found one of them oldies! */
+ }
+}
+#endif /* DOS */
+
+/*---------------------------------------------------------------------
+ *
+ * Function: scwtsel
+ *
+ * Description: Wait to be selected by another SCAM initiator.
+ *
+ *---------------------------------------------------------------------*/
+
+#if defined(DOS)
+void scwtsel(USHORT p_port)
+#else
+void scwtsel(ULONG p_port)
+#endif
+{
+ while(!(RDW_HARPOON((p_port+hp_intstat)) & SCAM_SEL)) {}
+}
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: inisci
+ *
+ * Description: Setup the data Structure with the info from the EEPROM.
+ *
+ *---------------------------------------------------------------------*/
+
+#if defined(DOS)
+void inisci(UCHAR p_card, USHORT p_port, UCHAR p_our_id)
+#else
+void inisci(UCHAR p_card, ULONG p_port, UCHAR p_our_id)
+#endif
+{
+ UCHAR i,k,max_id;
+ USHORT ee_data;
+ PNVRamInfo pCurrNvRam;
+
+ pCurrNvRam = BL_Card[p_card].pNvRamInfo;
+
+ if (RD_HARPOON(p_port+hp_page_ctrl) & NARROW_SCSI_CARD)
+ max_id = 0x08;
+
+ else
+ max_id = 0x10;
+
+ if(pCurrNvRam){
+ for(i = 0; i < max_id; i++){
+
+ for(k = 0; k < 4; k++)
+ scamInfo[i].id_string[k] =
pCurrNvRam->niScamTbl[i][k];
+ for(k = 4; k < ID_STRING_LENGTH; k++)
+ scamInfo[i].id_string[k] = (UCHAR) 0x00;
+
+ if(scamInfo[i].id_string[0] == 0x00)
+ scamInfo[i].state = ID_UNUSED; /*Default to unused ID. */
+ else
+ scamInfo[i].state = ID_UNASSIGNED; /*Default to unassigned ID. */
+
+ }
+ }else {
+ for (i=0; i < max_id; i++)
+ {
+ for (k=0; k < ID_STRING_LENGTH; k+=2)
+ {
+ ee_data = utilEERead(p_port, (USHORT)((EE_SCAMBASE/2) +
+ (USHORT) (i*((USHORT)ID_STRING_LENGTH/2)) + (USHORT)(k/2)));
+ scamInfo[i].id_string[k] = (UCHAR) ee_data;
+ ee_data >>= 8;
+ scamInfo[i].id_string[k+1] = (UCHAR) ee_data;
+ }
+
+ if ((scamInfo[i].id_string[0] == 0x00) ||
+ (scamInfo[i].id_string[0] == 0xFF))
+
+ scamInfo[i].state = ID_UNUSED; /*Default to unused ID. */
+
+ else
+ scamInfo[i].state = ID_UNASSIGNED; /*Default to unassigned ID. */
+
+ }
+ }
+ for(k = 0; k < ID_STRING_LENGTH; k++)
+ scamInfo[p_our_id].id_string[k] = scamHAString[k];
+
+}
+
+/*---------------------------------------------------------------------
+ *
+ * Function: scmachid
+ *
+ * Description: Match the Device ID string with our values stored in
+ * the EEPROM.
+ *
+ *---------------------------------------------------------------------*/
+
+UCHAR scmachid(UCHAR p_card, UCHAR p_id_string[])
+{
+
+ UCHAR i,k,match;
+
+
+ for (i=0; i < MAX_SCSI_TAR; i++) {
+
+#if !defined(SCAM_LEV_2)
+ if (scamInfo[i].state == ID_UNASSIGNED)
+ {
+#endif
+ match = TRUE;
+
+ for (k=0; k < ID_STRING_LENGTH; k++)
+ {
+ if (p_id_string[k] != scamInfo[i].id_string[k])
+ match = FALSE;
+ }
+
+ if (match)
+ {
+ scamInfo[i].state = ID_ASSIGNED;
+ return(i);
+ }
+
+#if !defined(SCAM_LEV_2)
+ }
+#endif
+
+ }
+
+
+
+ if (p_id_string[0] & BIT(5))
+ i = 8;
+ else
+ i = MAX_SCSI_TAR;
+
+ if (((p_id_string[0] & 0x06) == 0x02) || ((p_id_string[0] & 0x06) == 0x04))
+ match = p_id_string[1] & (UCHAR) 0x1F;
+ else
+ match = 7;
+
+ while (i > 0)
+ {
+ i--;
+
+ if (scamInfo[match].state == ID_UNUSED)
+ {
+ for (k=0; k < ID_STRING_LENGTH; k++)
+ {
+ scamInfo[match].id_string[k] = p_id_string[k];
+ }
+
+ scamInfo[match].state = ID_ASSIGNED;
+
+ if(BL_Card[p_card].pNvRamInfo == NULL)
+ BL_Card[p_card].globalFlags |= F_UPDATE_EEPROM;
+ return(match);
+
+ }
+
+
+ match--;
+
+ if (match == 0xFF)
+ {
+ if (p_id_string[0] & BIT(5))
+ match = 7;
+ else
+ match = MAX_SCSI_TAR-1;
+ }
+ }
+
+
+
+ if (p_id_string[0] & BIT(7))
+ {
+ return(CLR_PRIORITY);
+ }
+
+
+ if (p_id_string[0] & BIT(5))
+ i = 8;
+ else
+ i = MAX_SCSI_TAR;
+
+ if (((p_id_string[0] & 0x06) == 0x02) || ((p_id_string[0] & 0x06) == 0x04))
+ match = p_id_string[1] & (UCHAR) 0x1F;
+ else
+ match = 7;
+
+ while (i > 0)
+ {
+
+ i--;
+
+ if (scamInfo[match].state == ID_UNASSIGNED)
+ {
+ for (k=0; k < ID_STRING_LENGTH; k++)
+ {
+ scamInfo[match].id_string[k] = p_id_string[k];
+ }
+
+ scamInfo[match].id_string[0] |= BIT(7);
+ scamInfo[match].state = ID_ASSIGNED;
+ if(BL_Card[p_card].pNvRamInfo == NULL)
+ BL_Card[p_card].globalFlags |= F_UPDATE_EEPROM;
+ return(match);
+
+ }
+
+
+ match--;
+
+ if (match == 0xFF)
+ {
+ if (p_id_string[0] & BIT(5))
+ match = 7;
+ else
+ match = MAX_SCSI_TAR-1;
+ }
+ }
+
+ return(NO_ID_AVAIL);
+}
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: scsavdi
+ *
+ * Description: Save off the device SCAM ID strings.
+ *
+ *---------------------------------------------------------------------*/
+
+#if defined(DOS)
+void scsavdi(UCHAR p_card, USHORT p_port)
+#else
+void scsavdi(UCHAR p_card, ULONG p_port)
+#endif
+{
+ UCHAR i,k,max_id;
+ USHORT ee_data,sum_data;
+
+
+ sum_data = 0x0000;
+
+ for (i = 1; i < EE_SCAMBASE/2; i++)
+ {
+ sum_data += utilEERead(p_port, i);
+ }
+
+
+ utilEEWriteOnOff(p_port,1); /* Enable write access to the EEPROM */
+
+ if (RD_HARPOON(p_port+hp_page_ctrl) & NARROW_SCSI_CARD)
+ max_id = 0x08;
+
+ else
+ max_id = 0x10;
+
+ for (i=0; i < max_id; i++)
+ {
+
+ for (k=0; k < ID_STRING_LENGTH; k+=2)
+ {
+ ee_data = scamInfo[i].id_string[k+1];
+ ee_data <<= 8;
+ ee_data |= scamInfo[i].id_string[k];
+ sum_data += ee_data;
+ utilEEWrite(p_port, ee_data, (USHORT)((EE_SCAMBASE/2) +
+ (USHORT)(i*((USHORT)ID_STRING_LENGTH/2)) + (USHORT)(k/2)));
+ }
+ }
+
+
+ utilEEWrite(p_port, sum_data, EEPROM_CHECK_SUM/2);
+ utilEEWriteOnOff(p_port,0); /* Turn off write access */
+}
+
+/*----------------------------------------------------------------------
+ *
+ *
+ * Copyright 1995-1996 by Mylex Corporation. All Rights Reserved
+ *
+ * This file is available under both the GNU General Public License
+ * and a BSD-style copyright; see LICENSE.FlashPoint for details.
+ *
+ * $Workfile: diagnose.c $
+ *
+ * Description: Diagnostic funtions for testing the integrity of
+ * the HARPOON.
+ *
+ * $Date: 1999/04/26 05:53:56 $
+ *
+ * $Revision: 1.1 $
+ *
+ *----------------------------------------------------------------------*/
+
+/*#include <globals.h>*/
+
+#if (FW_TYPE==_UCB_MGR_)
+ /*#include <budi.h>*/
+#endif
+
+/*#include <sccbmgr.h>*/
+/*#include <blx30.h>*/
+/*#include <target.h>*/
+/*#include <eeprom.h>*/
+/*#include <harpoon.h>*/
+
+/*---------------------------------------------------------------------
+ *
+ * Function: XbowInit
+ *
+ * Description: Setup the Xbow for normal operation.
+ *
+ *---------------------------------------------------------------------*/
+
+#if defined(DOS)
+void XbowInit(USHORT port, UCHAR ScamFlg)
+#else
+void XbowInit(ULONG port, UCHAR ScamFlg)
+#endif
+{
+UCHAR i;
+
+ i = RD_HARPOON(port+hp_page_ctrl);
+ WR_HARPOON(port+hp_page_ctrl, (UCHAR) (i | G_INT_DISABLE));
+
+ WR_HARPOON(port+hp_scsireset,0x00);
+ WR_HARPOON(port+hp_portctrl_1,HOST_MODE8);
+
+ WR_HARPOON(port+hp_scsireset,(DMA_RESET | HPSCSI_RESET | PROG_RESET | \
+ FIFO_CLR));
+
+ WR_HARPOON(port+hp_scsireset,SCSI_INI);
+
+ WR_HARPOON(port+hp_clkctrl_0,CLKCTRL_DEFAULT);
+
+ WR_HARPOON(port+hp_scsisig,0x00); /* Clear any signals we might */
+ WR_HARPOON(port+hp_scsictrl_0,ENA_SCAM_SEL);
+
+ WRW_HARPOON((port+hp_intstat), CLR_ALL_INT);
+
+#if defined(SCAM_LEV_2)
+ default_intena = RESET | RSEL | PROG_HLT | TIMEOUT |
+ BUS_FREE | XFER_CNT_0 | AUTO_INT;
+
+ if ((ScamFlg & SCAM_ENABLED) && (ScamFlg & SCAM_LEVEL2))
+ default_intena |= SCAM_SEL;
+
+#else
+ default_intena = RESET | RSEL | PROG_HLT | TIMEOUT |
+ BUS_FREE | XFER_CNT_0 | AUTO_INT;
+#endif
+ WRW_HARPOON((port+hp_intena), default_intena);
+
+ WR_HARPOON(port+hp_seltimeout,TO_290ms);
+
+ /* Turn on SCSI_MODE8 for narrow cards to fix the
+ strapping issue with the DUAL CHANNEL card */
+ if (RD_HARPOON(port+hp_page_ctrl) & NARROW_SCSI_CARD)
+ WR_HARPOON(port+hp_addstat,SCSI_MODE8);
+
+#if defined(NO_BIOS_OPTION)
+
+ WR_HARPOON(port+hp_synctarg_0,NARROW_SCSI);
+ WR_HARPOON(port+hp_synctarg_1,NARROW_SCSI);
+ WR_HARPOON(port+hp_synctarg_2,NARROW_SCSI);
+ WR_HARPOON(port+hp_synctarg_3,NARROW_SCSI);
+ WR_HARPOON(port+hp_synctarg_4,NARROW_SCSI);
+ WR_HARPOON(port+hp_synctarg_5,NARROW_SCSI);
+ WR_HARPOON(port+hp_synctarg_6,NARROW_SCSI);
+ WR_HARPOON(port+hp_synctarg_7,NARROW_SCSI);
+ WR_HARPOON(port+hp_synctarg_8,NARROW_SCSI);
+ WR_HARPOON(port+hp_synctarg_9,NARROW_SCSI);
+ WR_HARPOON(port+hp_synctarg_10,NARROW_SCSI);
+ WR_HARPOON(port+hp_synctarg_11,NARROW_SCSI);
+ WR_HARPOON(port+hp_synctarg_12,NARROW_SCSI);
+ WR_HARPOON(port+hp_synctarg_13,NARROW_SCSI);
+ WR_HARPOON(port+hp_synctarg_14,NARROW_SCSI);
+ WR_HARPOON(port+hp_synctarg_15,NARROW_SCSI);
+
+#endif
+ WR_HARPOON(port+hp_page_ctrl, i);
+
+}
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: BusMasterInit
+ *
+ * Description: Initialize the BusMaster for normal operations.
+ *
+ *---------------------------------------------------------------------*/
+
+#if defined(DOS)
+void BusMasterInit(USHORT p_port)
+#else
+void BusMasterInit(ULONG p_port)
+#endif
+{
+
+
+ WR_HARPOON(p_port+hp_sys_ctrl, DRVR_RST);
+ WR_HARPOON(p_port+hp_sys_ctrl, 0x00);
+
+ WR_HARPOON(p_port+hp_host_blk_cnt, XFER_BLK64);
+
+
+ WR_HARPOON(p_port+hp_bm_ctrl, (BMCTRL_DEFAULT));
+
+ WR_HARPOON(p_port+hp_ee_ctrl, (SCSI_TERM_ENA_H));
+
+
+#if defined(NT)
+
+ WR_HARPOON(p_port+hp_pci_cmd_cfg, (RD_HARPOON(p_port+hp_pci_cmd_cfg)
+ & ~MEM_SPACE_ENA));
+
+#endif
+
+ RD_HARPOON(p_port+hp_int_status); /*Clear interrupts. */
+ WR_HARPOON(p_port+hp_int_mask, (INT_CMD_COMPL | SCSI_INTERRUPT));
+ WR_HARPOON(p_port+hp_page_ctrl, (RD_HARPOON(p_port+hp_page_ctrl) &
+ ~SCATTER_EN));
+}
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: DiagXbow
+ *
+ * Description: Test Xbow integrity. Non-zero return indicates an error.
+ *
+ *---------------------------------------------------------------------*/
+
+#if defined(DOS)
+int DiagXbow(USHORT port)
+#else
+int DiagXbow(ULONG port)
+#endif
+{
+ unsigned char fifo_cnt,loop_cnt;
+
+ unsigned char fifodata[5];
+ fifodata[0] = 0x00;
+ fifodata[1] = 0xFF;
+ fifodata[2] = 0x55;
+ fifodata[3] = 0xAA;
+ fifodata[4] = 0x00;
+
+
+ WRW_HARPOON((port+hp_intstat), CLR_ALL_INT);
+ WRW_HARPOON((port+hp_intena), 0x0000);
+
+ WR_HARPOON(port+hp_seltimeout,TO_5ms);
+
+ WR_HARPOON(port+hp_portctrl_0,START_TO);
+
+
+ for(fifodata[4] = 0x01; fifodata[4] != (UCHAR) 0; fifodata[4] = fifodata[4]
<< 1) {
+
+ WR_HARPOON(port+hp_selfid_0,fifodata[4]);
+ WR_HARPOON(port+hp_selfid_1,fifodata[4]);
+
+ if ((RD_HARPOON(port+hp_selfid_0) != fifodata[4]) ||
+ (RD_HARPOON(port+hp_selfid_1) != fifodata[4]))
+ return(1);
+ }
+
+
+ for(loop_cnt = 0; loop_cnt < 4; loop_cnt++) {
+
+ WR_HARPOON(port+hp_portctrl_0,(HOST_PORT | HOST_WRT | START_TO));
+
+
+ for (fifo_cnt = 0; fifo_cnt < FIFO_LEN; fifo_cnt++) {
+
+ WR_HARPOON(port+hp_fifodata_0, fifodata[loop_cnt]);
+ }
+
+
+ if (!(RD_HARPOON(port+hp_xferstat) & FIFO_FULL))
+ return(1);
+
+
+ WR_HARPOON(port+hp_portctrl_0,(HOST_PORT | START_TO));
+
+ for (fifo_cnt = 0; fifo_cnt < FIFO_LEN; fifo_cnt++) {
+
+ if (RD_HARPOON(port+hp_fifodata_0) != fifodata[loop_cnt])
+ return(1);
+ }
+
+
+ if (!(RD_HARPOON(port+hp_xferstat) & FIFO_EMPTY))
+ return(1);
+ }
+
+
+ while(!(RDW_HARPOON((port+hp_intstat)) & TIMEOUT)) {}
+
+
+ WR_HARPOON(port+hp_seltimeout,TO_290ms);
+
+ WRW_HARPOON((port+hp_intstat), CLR_ALL_INT);
+
+ WRW_HARPOON((port+hp_intena), default_intena);
+
+ return(0);
+}
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: DiagBusMaster
+ *
+ * Description: Test BusMaster integrity. Non-zero return indicates an
+ * error.
+ *
+ *---------------------------------------------------------------------*/
+
+#if defined(DOS)
+int DiagBusMaster(USHORT port)
+#else
+int DiagBusMaster(ULONG port)
+#endif
+{
+ UCHAR testdata;
+
+ for(testdata = (UCHAR) 1; testdata != (UCHAR)0; testdata = testdata << 1) {
+
+ WR_HARPOON(port+hp_xfer_cnt_lo,testdata);
+ WR_HARPOON(port+hp_xfer_cnt_mi,testdata);
+ WR_HARPOON(port+hp_xfer_cnt_hi,testdata);
+ WR_HARPOON(port+hp_host_addr_lo,testdata);
+ WR_HARPOON(port+hp_host_addr_lmi,testdata);
+ WR_HARPOON(port+hp_host_addr_hmi,testdata);
+ WR_HARPOON(port+hp_host_addr_hi,testdata);
+
+ if ((RD_HARPOON(port+hp_xfer_cnt_lo) != testdata) ||
+ (RD_HARPOON(port+hp_xfer_cnt_mi) != testdata) ||
+ (RD_HARPOON(port+hp_xfer_cnt_hi) != testdata) ||
+ (RD_HARPOON(port+hp_host_addr_lo) != testdata) ||
+ (RD_HARPOON(port+hp_host_addr_lmi) != testdata) ||
+ (RD_HARPOON(port+hp_host_addr_hmi) != testdata) ||
+ (RD_HARPOON(port+hp_host_addr_hi) != testdata))
+
+ return(1);
+ }
+ RD_HARPOON(port+hp_int_status); /*Clear interrupts. */
+ return(0);
+}
+
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: DiagEEPROM
+ *
+ * Description: Verfiy checksum and 'Key' and initialize the EEPROM if
+ * neccessary.
+ *
+ *---------------------------------------------------------------------*/
+
+#if defined(DOS)
+void DiagEEPROM(USHORT p_port)
+#else
+void DiagEEPROM(ULONG p_port)
+#endif
+
+{
+ USHORT index,temp,max_wd_cnt;
+
+ if (RD_HARPOON(p_port+hp_page_ctrl) & NARROW_SCSI_CARD)
+ max_wd_cnt = EEPROM_WD_CNT;
+ else
+ max_wd_cnt = EEPROM_WD_CNT * 2;
+
+ temp = utilEERead(p_port, FW_SIGNATURE/2);
+
+ if (temp == 0x4641) {
+
+ for (index = 2; index < max_wd_cnt; index++) {
+
+ temp += utilEERead(p_port, index);
+
+ }
+
+ if (temp == utilEERead(p_port, EEPROM_CHECK_SUM/2)) {
+
+ return; /*EEPROM is Okay so return now! */
+ }
+ }
+
+
+ utilEEWriteOnOff(p_port,(UCHAR)1);
+
+ for (index = 0; index < max_wd_cnt; index++) {
+
+ utilEEWrite(p_port, 0x0000, index);
+ }
+
+ temp = 0;
+
+ utilEEWrite(p_port, 0x4641, FW_SIGNATURE/2);
+ temp += 0x4641;
+ utilEEWrite(p_port, 0x3920, MODEL_NUMB_0/2);
+ temp += 0x3920;
+ utilEEWrite(p_port, 0x3033, MODEL_NUMB_2/2);
+ temp += 0x3033;
+ utilEEWrite(p_port, 0x2020, MODEL_NUMB_4/2);
+ temp += 0x2020;
+ utilEEWrite(p_port, 0x70D3, SYSTEM_CONFIG/2);
+ temp += 0x70D3;
+ utilEEWrite(p_port, 0x0010, BIOS_CONFIG/2);
+ temp += 0x0010;
+ utilEEWrite(p_port, 0x0003, SCAM_CONFIG/2);
+ temp += 0x0003;
+ utilEEWrite(p_port, 0x0007, ADAPTER_SCSI_ID/2);
+ temp += 0x0007;
+
+ utilEEWrite(p_port, 0x0000, IGNORE_B_SCAN/2);
+ temp += 0x0000;
+ utilEEWrite(p_port, 0x0000, SEND_START_ENA/2);
+ temp += 0x0000;
+ utilEEWrite(p_port, 0x0000, DEVICE_ENABLE/2);
+ temp += 0x0000;
+
+ utilEEWrite(p_port, 0x4242, SYNC_RATE_TBL01/2);
+ temp += 0x4242;
+ utilEEWrite(p_port, 0x4242, SYNC_RATE_TBL23/2);
+ temp += 0x4242;
+ utilEEWrite(p_port, 0x4242, SYNC_RATE_TBL45/2);
+ temp += 0x4242;
+ utilEEWrite(p_port, 0x4242, SYNC_RATE_TBL67/2);
+ temp += 0x4242;
+ utilEEWrite(p_port, 0x4242, SYNC_RATE_TBL89/2);
+ temp += 0x4242;
+ utilEEWrite(p_port, 0x4242, SYNC_RATE_TBLab/2);
+ temp += 0x4242;
+ utilEEWrite(p_port, 0x4242, SYNC_RATE_TBLcd/2);
+ temp += 0x4242;
+ utilEEWrite(p_port, 0x4242, SYNC_RATE_TBLef/2);
+ temp += 0x4242;
+
+
+ utilEEWrite(p_port, 0x6C46, 64/2); /*PRODUCT ID */
+ temp += 0x6C46;
+ utilEEWrite(p_port, 0x7361, 66/2); /* FlashPoint LT */
+ temp += 0x7361;
+ utilEEWrite(p_port, 0x5068, 68/2);
+ temp += 0x5068;
+ utilEEWrite(p_port, 0x696F, 70/2);
+ temp += 0x696F;
+ utilEEWrite(p_port, 0x746E, 72/2);
+ temp += 0x746E;
+ utilEEWrite(p_port, 0x4C20, 74/2);
+ temp += 0x4C20;
+ utilEEWrite(p_port, 0x2054, 76/2);
+ temp += 0x2054;
+ utilEEWrite(p_port, 0x2020, 78/2);
+ temp += 0x2020;
+
+ index = ((EE_SCAMBASE/2)+(7*16));
+ utilEEWrite(p_port, (0x0700+TYPE_CODE0), index);
+ temp += (0x0700+TYPE_CODE0);
+ index++;
+ utilEEWrite(p_port, 0x5542, index); /*Vendor ID code */
+ temp += 0x5542; /* BUSLOGIC */
+ index++;
+ utilEEWrite(p_port, 0x4C53, index);
+ temp += 0x4C53;
+ index++;
+ utilEEWrite(p_port, 0x474F, index);
+ temp += 0x474F;
+ index++;
+ utilEEWrite(p_port, 0x4349, index);
+ temp += 0x4349;
+ index++;
+ utilEEWrite(p_port, 0x5442, index); /*Vendor unique code */
+ temp += 0x5442; /* BT- 930 */
+ index++;
+ utilEEWrite(p_port, 0x202D, index);
+ temp += 0x202D;
+ index++;
+ utilEEWrite(p_port, 0x3339, index);
+ temp += 0x3339;
+ index++; /*Serial # */
+ utilEEWrite(p_port, 0x2030, index); /* 01234567 */
+ temp += 0x2030;
+ index++;
+ utilEEWrite(p_port, 0x5453, index);
+ temp += 0x5453;
+ index++;
+ utilEEWrite(p_port, 0x5645, index);
+ temp += 0x5645;
+ index++;
+ utilEEWrite(p_port, 0x2045, index);
+ temp += 0x2045;
+ index++;
+ utilEEWrite(p_port, 0x202F, index);
+ temp += 0x202F;
+ index++;
+ utilEEWrite(p_port, 0x4F4A, index);
+ temp += 0x4F4A;
+ index++;
+ utilEEWrite(p_port, 0x204E, index);
+ temp += 0x204E;
+ index++;
+ utilEEWrite(p_port, 0x3539, index);
+ temp += 0x3539;
+
+
+
+ utilEEWrite(p_port, temp, EEPROM_CHECK_SUM/2);
+
+ utilEEWriteOnOff(p_port,(UCHAR)0);
+
+}
+
+
+/*----------------------------------------------------------------------
+ *
+ *
+ * Copyright 1995-1996 by Mylex Corporation. All Rights Reserved
+ *
+ * This file is available under both the GNU General Public License
+ * and a BSD-style copyright; see LICENSE.FlashPoint for details.
+ *
+ * $Workfile: utility.c $
+ *
+ * Description: Utility functions relating to queueing and EEPROM
+ * manipulation and any other garbage functions.
+ *
+ * $Date: 1999/04/26 05:53:56 $
+ *
+ * $Revision: 1.1 $
+ *
+ *----------------------------------------------------------------------*/
+/*#include <globals.h>*/
+
+#if (FW_TYPE==_UCB_MGR_)
+ /*#include <budi.h>*/
+#endif
+
+/*#include <sccbmgr.h>*/
+/*#include <blx30.h>*/
+/*#include <target.h>*/
+/*#include <scsi2.h>*/
+/*#include <harpoon.h>*/
+
+
+/*
+extern SCCBCARD BL_Card[MAX_CARDS];
+extern SCCBMGR_TAR_INFO sccbMgrTbl[MAX_CARDS][MAX_SCSI_TAR];
+extern unsigned int SccbGlobalFlags;
+*/
+
+/*---------------------------------------------------------------------
+ *
+ * Function: Queue Search Select
+ *
+ * Description: Try to find a new command to execute.
+ *
+ *---------------------------------------------------------------------*/
+
+void queueSearchSelect(PSCCBcard pCurrCard, UCHAR p_card)
+{
+ UCHAR scan_ptr, lun;
+ PSCCBMgr_tar_info currTar_Info;
+ PSCCB pOldSccb;
+
+ scan_ptr = pCurrCard->scanIndex;
+ do
+ {
+ currTar_Info = &sccbMgrTbl[p_card][scan_ptr];
+ if((pCurrCard->globalFlags & F_CONLUN_IO) &&
+ ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) !=
TAG_Q_TRYING))
+ {
+ if (currTar_Info->TarSelQ_Cnt != 0)
+ {
+
+ scan_ptr++;
+ if (scan_ptr == MAX_SCSI_TAR)
+ scan_ptr = 0;
+
+ for(lun=0; lun < MAX_LUN; lun++)
+ {
+ if(currTar_Info->TarLUNBusy[lun] ==
FALSE)
+ {
+
+ pCurrCard->currentSCCB =
currTar_Info->TarSelQ_Head;
+ pOldSccb = NULL;
+
+ while((pCurrCard->currentSCCB
!= NULL) &&
+ (lun !=
pCurrCard->currentSCCB->Lun))
+ {
+ pOldSccb =
pCurrCard->currentSCCB;
+ pCurrCard->currentSCCB
= (PSCCB)(pCurrCard->currentSCCB)->
+
Sccb_forwardlink;
+ }
+ if(pCurrCard->currentSCCB ==
NULL)
+ continue;
+ if(pOldSccb != NULL)
+ {
+
pOldSccb->Sccb_forwardlink = (PSCCB)(pCurrCard->currentSCCB)->
+
Sccb_forwardlink;
+ pOldSccb->Sccb_backlink
= (PSCCB)(pCurrCard->currentSCCB)->
+
Sccb_backlink;
+
currTar_Info->TarSelQ_Cnt--;
+ }
+ else
+ {
+
currTar_Info->TarSelQ_Head = (PSCCB)(pCurrCard->currentSCCB)->Sccb_forwardlink;
+
+ if
(currTar_Info->TarSelQ_Head == NULL)
+ {
+
currTar_Info->TarSelQ_Tail = NULL;
+
currTar_Info->TarSelQ_Cnt = 0;
+ }
+ else
+ {
+
currTar_Info->TarSelQ_Cnt--;
+
currTar_Info->TarSelQ_Head->Sccb_backlink = (PSCCB)NULL;
+ }
+ }
+ pCurrCard->scanIndex = scan_ptr;
+
+ pCurrCard->globalFlags |=
F_NEW_SCCB_CMD;
+
+ break;
+ }
+ }
+ }
+
+ else
+ {
+ scan_ptr++;
+ if (scan_ptr == MAX_SCSI_TAR) {
+ scan_ptr = 0;
+ }
+ }
+
+ }
+ else
+ {
+ if ((currTar_Info->TarSelQ_Cnt != 0) &&
+ (currTar_Info->TarLUNBusy[0] == FALSE))
+ {
+
+ pCurrCard->currentSCCB =
currTar_Info->TarSelQ_Head;
+
+ currTar_Info->TarSelQ_Head =
(PSCCB)(pCurrCard->currentSCCB)->Sccb_forwardlink;
+
+ if (currTar_Info->TarSelQ_Head == NULL)
+ {
+ currTar_Info->TarSelQ_Tail = NULL;
+ currTar_Info->TarSelQ_Cnt = 0;
+ }
+ else
+ {
+ currTar_Info->TarSelQ_Cnt--;
+
currTar_Info->TarSelQ_Head->Sccb_backlink = (PSCCB)NULL;
+ }
+
+ scan_ptr++;
+ if (scan_ptr == MAX_SCSI_TAR)
+ scan_ptr = 0;
+
+ pCurrCard->scanIndex = scan_ptr;
+
+ pCurrCard->globalFlags |= F_NEW_SCCB_CMD;
+
+ break;
+ }
+
+ else
+ {
+ scan_ptr++;
+ if (scan_ptr == MAX_SCSI_TAR)
+ {
+ scan_ptr = 0;
+ }
+ }
+ }
+ } while (scan_ptr != pCurrCard->scanIndex);
+}
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: Queue Select Fail
+ *
+ * Description: Add the current SCCB to the head of the Queue.
+ *
+ *---------------------------------------------------------------------*/
+
+void queueSelectFail(PSCCBcard pCurrCard, UCHAR p_card)
+{
+ UCHAR thisTarg;
+ PSCCBMgr_tar_info currTar_Info;
+
+ if (pCurrCard->currentSCCB != NULL)
+ {
+ thisTarg = (UCHAR)(((PSCCB)(pCurrCard->currentSCCB))->TargID);
+ currTar_Info = &sccbMgrTbl[p_card][thisTarg];
+
+ pCurrCard->currentSCCB->Sccb_backlink = (PSCCB)NULL;
+
+ pCurrCard->currentSCCB->Sccb_forwardlink = currTar_Info->TarSelQ_Head;
+
+ if (currTar_Info->TarSelQ_Cnt == 0)
+ {
+ currTar_Info->TarSelQ_Tail = pCurrCard->currentSCCB;
+ }
+
+ else
+ {
+ currTar_Info->TarSelQ_Head->Sccb_backlink =
pCurrCard->currentSCCB;
+ }
+
+
+ currTar_Info->TarSelQ_Head = pCurrCard->currentSCCB;
+
+ pCurrCard->currentSCCB = NULL;
+ currTar_Info->TarSelQ_Cnt++;
+ }
+}
+/*---------------------------------------------------------------------
+ *
+ * Function: Queue Command Complete
+ *
+ * Description: Call the callback function with the current SCCB.
+ *
+ *---------------------------------------------------------------------*/
+
+void queueCmdComplete(PSCCBcard pCurrCard, PSCCB p_sccb, UCHAR p_card)
+{
+
+#if (FW_TYPE==_UCB_MGR_)
+
+ u08bits SCSIcmd;
+ CALL_BK_FN callback;
+ PSCCBMgr_tar_info currTar_Info;
+
+ PUCB p_ucb;
+ p_ucb=p_sccb->Sccb_ucb_ptr;
+
+ SCSIcmd = p_sccb->Cdb[0];
+
+
+ if (!(p_sccb->Sccb_XferState & F_ALL_XFERRED))
+ {
+
+ if ((p_ucb->UCB_opcode & OPC_CHK_UNDER_OVER_RUN) &&
+ (p_sccb->HostStatus == SCCB_COMPLETE) &&
+ (p_sccb->TargetStatus != SSCHECK))
+
+ if ((SCSIcmd == SCSI_READ) ||
+ (SCSIcmd == SCSI_WRITE) ||
+ (SCSIcmd == SCSI_READ_EXTENDED) ||
+ (SCSIcmd == SCSI_WRITE_EXTENDED) ||
+ (SCSIcmd == SCSI_WRITE_AND_VERIFY) ||
+ (SCSIcmd == SCSI_START_STOP_UNIT) ||
+ (pCurrCard->globalFlags & F_NO_FILTER)
+ )
+ p_sccb->HostStatus = SCCB_DATA_UNDER_RUN;
+ }
+
+ p_ucb->UCB_status=SCCB_SUCCESS;
+
+ if ((p_ucb->UCB_hbastat=p_sccb->HostStatus) ||
(p_ucb->UCB_scsistat=p_sccb->TargetStatus))
+ {
+ p_ucb->UCB_status=SCCB_ERROR;
+ }
+
+ if ((p_sccb->OperationCode == RESIDUAL_SG_COMMAND) ||
+ (p_sccb->OperationCode == RESIDUAL_COMMAND))
+ {
+
+ utilUpdateResidual(p_sccb);
+
+ p_ucb->UCB_datalen=p_sccb->DataLength;
+ }
+
+ pCurrCard->cmdCounter--;
+ if (!pCurrCard->cmdCounter)
+ {
+
+ if (pCurrCard->globalFlags & F_GREEN_PC)
+ {
+ WR_HARPOON(pCurrCard->ioPort+hp_clkctrl_0,(PWR_DWN |
CLKCTRL_DEFAULT));
+ WR_HARPOON(pCurrCard->ioPort+hp_sys_ctrl, STOP_CLK);
+ }
+
+ WR_HARPOON(pCurrCard->ioPort+hp_semaphore,
+ (RD_HARPOON(pCurrCard->ioPort+hp_semaphore) & ~SCCB_MGR_ACTIVE));
+ }
+
+ if(pCurrCard->discQCount != 0)
+ {
+ currTar_Info = &sccbMgrTbl[p_card][p_sccb->TargID];
+ if(((pCurrCard->globalFlags & F_CONLUN_IO) &&
+ ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) !=
TAG_Q_TRYING)))
+ {
+ pCurrCard->discQCount--;
+
pCurrCard->discQ_Tbl[currTar_Info->LunDiscQ_Idx[p_sccb->Lun]] = NULL;
+ }
+ else
+ {
+ if(p_sccb->Sccb_tag)
+ {
+ pCurrCard->discQCount--;
+ pCurrCard->discQ_Tbl[p_sccb->Sccb_tag] = NULL;
+ }else
+ {
+ pCurrCard->discQCount--;
+
pCurrCard->discQ_Tbl[currTar_Info->LunDiscQ_Idx[0]] = NULL;
+ }
+ }
+
+ }
+ callback = (CALL_BK_FN)p_ucb->UCB_callback;
+ callback(p_ucb);
+ pCurrCard->globalFlags |= F_NEW_SCCB_CMD;
+ pCurrCard->currentSCCB = NULL;
+}
+
+
+
+
+#else
+
+ UCHAR i, SCSIcmd;
+ CALL_BK_FN callback;
+ PSCCBMgr_tar_info currTar_Info;
+
+ SCSIcmd = p_sccb->Cdb[0];
+
+
+ if (!(p_sccb->Sccb_XferState & F_ALL_XFERRED)) {
+
+ if ((p_sccb->ControlByte & (SCCB_DATA_XFER_OUT | SCCB_DATA_XFER_IN))
&&
+ (p_sccb->HostStatus == SCCB_COMPLETE)
&&
+ (p_sccb->TargetStatus != SSCHECK))
+
+ if ((SCSIcmd == SCSI_READ) ||
+ (SCSIcmd == SCSI_WRITE) ||
+ (SCSIcmd == SCSI_READ_EXTENDED) ||
+ (SCSIcmd == SCSI_WRITE_EXTENDED) ||
+ (SCSIcmd == SCSI_WRITE_AND_VERIFY) ||
+ (SCSIcmd == SCSI_START_STOP_UNIT) ||
+ (pCurrCard->globalFlags & F_NO_FILTER)
+ )
+ p_sccb->HostStatus = SCCB_DATA_UNDER_RUN;
+ }
+
+
+ if(p_sccb->SccbStatus == SCCB_IN_PROCESS)
+ {
+ if (p_sccb->HostStatus || p_sccb->TargetStatus)
+ p_sccb->SccbStatus = SCCB_ERROR;
+ else
+ p_sccb->SccbStatus = SCCB_SUCCESS;
+ }
+
+ if (p_sccb->Sccb_XferState & F_AUTO_SENSE) {
+
+ p_sccb->CdbLength = p_sccb->Save_CdbLen;
+ for (i=0; i < 6; i++) {
+ p_sccb->Cdb[i] = p_sccb->Save_Cdb[i];
+ }
+ }
+
+ if ((p_sccb->OperationCode == RESIDUAL_SG_COMMAND) ||
+ (p_sccb->OperationCode == RESIDUAL_COMMAND)) {
+
+ utilUpdateResidual(p_sccb);
+ }
+
+ pCurrCard->cmdCounter--;
+ if (!pCurrCard->cmdCounter) {
+
+ if (pCurrCard->globalFlags & F_GREEN_PC) {
+ WR_HARPOON(pCurrCard->ioPort+hp_clkctrl_0,(PWR_DWN |
CLKCTRL_DEFAULT));
+ WR_HARPOON(pCurrCard->ioPort+hp_sys_ctrl, STOP_CLK);
+ }
+
+ WR_HARPOON(pCurrCard->ioPort+hp_semaphore,
+ (RD_HARPOON(pCurrCard->ioPort+hp_semaphore) & ~SCCB_MGR_ACTIVE));
+
+ }
+
+ if(pCurrCard->discQCount != 0)
+ {
+ currTar_Info = &sccbMgrTbl[p_card][p_sccb->TargID];
+ if(((pCurrCard->globalFlags & F_CONLUN_IO) &&
+ ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) !=
TAG_Q_TRYING)))
+ {
+ pCurrCard->discQCount--;
+
pCurrCard->discQ_Tbl[currTar_Info->LunDiscQ_Idx[p_sccb->Lun]] = NULL;
+ }
+ else
+ {
+ if(p_sccb->Sccb_tag)
+ {
+ pCurrCard->discQCount--;
+ pCurrCard->discQ_Tbl[p_sccb->Sccb_tag] = NULL;
+ }else
+ {
+ pCurrCard->discQCount--;
+
pCurrCard->discQ_Tbl[currTar_Info->LunDiscQ_Idx[0]] = NULL;
+ }
+ }
+
+ }
+
+ callback = (CALL_BK_FN)p_sccb->SccbCallback;
+ callback(p_sccb);
+ pCurrCard->globalFlags |= F_NEW_SCCB_CMD;
+ pCurrCard->currentSCCB = NULL;
+}
+#endif /* ( if FW_TYPE==...) */
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: Queue Disconnect
+ *
+ * Description: Add SCCB to our disconnect array.
+ *
+ *---------------------------------------------------------------------*/
+void queueDisconnect(PSCCB p_sccb, UCHAR p_card)
+{
+ PSCCBMgr_tar_info currTar_Info;
+
+ currTar_Info = &sccbMgrTbl[p_card][p_sccb->TargID];
+
+ if(((BL_Card[p_card].globalFlags & F_CONLUN_IO) &&
+ ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) != TAG_Q_TRYING)))
+ {
+
BL_Card[p_card].discQ_Tbl[currTar_Info->LunDiscQ_Idx[p_sccb->Lun]] = p_sccb;
+ }
+ else
+ {
+ if (p_sccb->Sccb_tag)
+ {
+ BL_Card[p_card].discQ_Tbl[p_sccb->Sccb_tag] = p_sccb;
+ sccbMgrTbl[p_card][p_sccb->TargID].TarLUNBusy[0] =
FALSE;
+ sccbMgrTbl[p_card][p_sccb->TargID].TarTagQ_Cnt++;
+ }else
+ {
+
BL_Card[p_card].discQ_Tbl[currTar_Info->LunDiscQ_Idx[0]] = p_sccb;
+ }
+ }
+ BL_Card[p_card].currentSCCB = NULL;
+}
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: Queue Flush SCCB
+ *
+ * Description: Flush all SCCB's back to the host driver for this target.
+ *
+ *---------------------------------------------------------------------*/
+
+void queueFlushSccb(UCHAR p_card, UCHAR error_code)
+{
+ UCHAR qtag,thisTarg;
+ PSCCB currSCCB;
+ PSCCBMgr_tar_info currTar_Info;
+
+ currSCCB = BL_Card[p_card].currentSCCB;
+ if(currSCCB != NULL)
+ {
+ thisTarg = (UCHAR)currSCCB->TargID;
+ currTar_Info = &sccbMgrTbl[p_card][thisTarg];
+
+ for (qtag=0; qtag<QUEUE_DEPTH; qtag++) {
+
+ if (BL_Card[p_card].discQ_Tbl[qtag] &&
+
(BL_Card[p_card].discQ_Tbl[qtag]->TargID == thisTarg))
+ {
+
+ BL_Card[p_card].discQ_Tbl[qtag]->HostStatus =
(UCHAR)error_code;
+
+
queueCmdComplete(&BL_Card[p_card],BL_Card[p_card].discQ_Tbl[qtag], p_card);
+
+ BL_Card[p_card].discQ_Tbl[qtag] = NULL;
+ currTar_Info->TarTagQ_Cnt--;
+
+ }
+ }
+ }
+
+}
+
+/*---------------------------------------------------------------------
+ *
+ * Function: Queue Flush Target SCCB
+ *
+ * Description: Flush all SCCB's back to the host driver for this target.
+ *
+ *---------------------------------------------------------------------*/
+
+void queueFlushTargSccb(UCHAR p_card, UCHAR thisTarg, UCHAR error_code)
+{
+ UCHAR qtag;
+ PSCCBMgr_tar_info currTar_Info;
+
+ currTar_Info = &sccbMgrTbl[p_card][thisTarg];
+
+ for (qtag=0; qtag<QUEUE_DEPTH; qtag++) {
+
+ if (BL_Card[p_card].discQ_Tbl[qtag] &&
+ (BL_Card[p_card].discQ_Tbl[qtag]->TargID ==
thisTarg))
+ {
+
+ BL_Card[p_card].discQ_Tbl[qtag]->HostStatus =
(UCHAR)error_code;
+
+
queueCmdComplete(&BL_Card[p_card],BL_Card[p_card].discQ_Tbl[qtag], p_card);
+
+ BL_Card[p_card].discQ_Tbl[qtag] = NULL;
+ currTar_Info->TarTagQ_Cnt--;
+
+ }
+ }
+
+}
+
+
+
+
+
+void queueAddSccb(PSCCB p_SCCB, UCHAR p_card)
+{
+ PSCCBMgr_tar_info currTar_Info;
+ currTar_Info = &sccbMgrTbl[p_card][p_SCCB->TargID];
+
+ p_SCCB->Sccb_forwardlink = NULL;
+
+ p_SCCB->Sccb_backlink = currTar_Info->TarSelQ_Tail;
+
+ if (currTar_Info->TarSelQ_Cnt == 0) {
+
+ currTar_Info->TarSelQ_Head = p_SCCB;
+ }
+
+ else {
+
+ currTar_Info->TarSelQ_Tail->Sccb_forwardlink = p_SCCB;
+ }
+
+
+ currTar_Info->TarSelQ_Tail = p_SCCB;
+ currTar_Info->TarSelQ_Cnt++;
+}
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: Queue Find SCCB
+ *
+ * Description: Search the target select Queue for this SCCB, and
+ * remove it if found.
+ *
+ *---------------------------------------------------------------------*/
+
+UCHAR queueFindSccb(PSCCB p_SCCB, UCHAR p_card)
+{
+ PSCCB q_ptr;
+ PSCCBMgr_tar_info currTar_Info;
+
+ currTar_Info = &sccbMgrTbl[p_card][p_SCCB->TargID];
+
+ q_ptr = currTar_Info->TarSelQ_Head;
+
+ while(q_ptr != NULL) {
+
+ if (q_ptr == p_SCCB) {
+
+
+ if (currTar_Info->TarSelQ_Head == q_ptr) {
+
+ currTar_Info->TarSelQ_Head = q_ptr->Sccb_forwardlink;
+ }
+
+ if (currTar_Info->TarSelQ_Tail == q_ptr) {
+
+ currTar_Info->TarSelQ_Tail = q_ptr->Sccb_backlink;
+ }
+
+ if (q_ptr->Sccb_forwardlink != NULL) {
+ q_ptr->Sccb_forwardlink->Sccb_backlink =
q_ptr->Sccb_backlink;
+ }
+
+ if (q_ptr->Sccb_backlink != NULL) {
+ q_ptr->Sccb_backlink->Sccb_forwardlink =
q_ptr->Sccb_forwardlink;
+ }
+
+ currTar_Info->TarSelQ_Cnt--;
+
+ return(TRUE);
+ }
+
+ else {
+ q_ptr = q_ptr->Sccb_forwardlink;
+ }
+ }
+
+
+ return(FALSE);
+
+}
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: Utility Update Residual Count
+ *
+ * Description: Update the XferCnt to the remaining byte count.
+ * If we transferred all the data then just write zero.
+ * If Non-SG transfer then report Total Cnt - Actual Transfer
+ * Cnt. For SG transfers add the count fields of all
+ * remaining SG elements, as well as any partial remaining
+ * element.
+ *
+ *---------------------------------------------------------------------*/
+
+void utilUpdateResidual(PSCCB p_SCCB)
+{
+ ULONG partial_cnt;
+ UINT sg_index;
+#if defined(COMPILER_16_BIT) && !defined(DOS)
+ ULONG far *sg_ptr;
+#else
+ ULONG *sg_ptr;
+#endif
+
+ if (p_SCCB->Sccb_XferState & F_ALL_XFERRED) {
+
+ p_SCCB->DataLength = 0x0000;
+ }
+
+ else if (p_SCCB->Sccb_XferState & F_SG_XFER) {
+
+ partial_cnt = 0x0000;
+
+ sg_index = p_SCCB->Sccb_sgseg;
+
+#if defined(COMPILER_16_BIT) && !defined(DOS)
+ sg_ptr = (ULONG far *)p_SCCB->DataPointer;
+#else
+ sg_ptr = (ULONG *)p_SCCB->DataPointer;
+#endif
+
+ if (p_SCCB->Sccb_SGoffset) {
+
+ partial_cnt = p_SCCB->Sccb_SGoffset;
+ sg_index++;
+ }
+
+ while ( ((ULONG)sg_index * (ULONG)SG_ELEMENT_SIZE) <
+ p_SCCB->DataLength ) {
+
+ partial_cnt += *(sg_ptr+(sg_index * 2));
+ sg_index++;
+ }
+
+ p_SCCB->DataLength = partial_cnt;
+ }
+
+ else {
+
+ p_SCCB->DataLength -= p_SCCB->Sccb_ATC;
+ }
+}
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: Wait 1 Second
+ *
+ * Description: Wait for 1 second.
+ *
+ *---------------------------------------------------------------------*/
+
+#if defined(DOS)
+void Wait1Second(USHORT p_port)
+#else
+void Wait1Second(ULONG p_port)
+#endif
+{
+ UCHAR i;
+
+ for(i=0; i < 4; i++) {
+
+ Wait(p_port, TO_250ms);
+
+ if ((RD_HARPOON(p_port+hp_scsictrl_0) & SCSI_RST))
+ break;
+
+ if((RDW_HARPOON((p_port+hp_intstat)) & SCAM_SEL))
+ break;
+ }
+}
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: Wait
+ *
+ * Description: Wait the desired delay.
+ *
+ *---------------------------------------------------------------------*/
+
+#if defined(DOS)
+void Wait(USHORT p_port, UCHAR p_delay)
+#else
+void Wait(ULONG p_port, UCHAR p_delay)
+#endif
+{
+ UCHAR old_timer;
+ UCHAR green_flag;
+
+ old_timer = RD_HARPOON(p_port+hp_seltimeout);
+
+ green_flag=RD_HARPOON(p_port+hp_clkctrl_0);
+ WR_HARPOON(p_port+hp_clkctrl_0, CLKCTRL_DEFAULT);
+
+ WR_HARPOON(p_port+hp_seltimeout,p_delay);
+ WRW_HARPOON((p_port+hp_intstat), TIMEOUT);
+ WRW_HARPOON((p_port+hp_intena), (default_intena & ~TIMEOUT));
+
+
+ WR_HARPOON(p_port+hp_portctrl_0,
+ (RD_HARPOON(p_port+hp_portctrl_0) | START_TO));
+
+ while (!(RDW_HARPOON((p_port+hp_intstat)) & TIMEOUT)) {
+
+ if ((RD_HARPOON(p_port+hp_scsictrl_0) & SCSI_RST))
+ break;
+
+ if ((RDW_HARPOON((p_port+hp_intstat)) & SCAM_SEL))
+ break;
+ }
+
+ WR_HARPOON(p_port+hp_portctrl_0,
+ (RD_HARPOON(p_port+hp_portctrl_0) & ~START_TO));
+
+ WRW_HARPOON((p_port+hp_intstat), TIMEOUT);
+ WRW_HARPOON((p_port+hp_intena), default_intena);
+
+ WR_HARPOON(p_port+hp_clkctrl_0,green_flag);
+
+ WR_HARPOON(p_port+hp_seltimeout,old_timer);
+}
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: Enable/Disable Write to EEPROM
+ *
+ * Description: The EEPROM must first be enabled for writes
+ * A total of 9 clocks are needed.
+ *
+ *---------------------------------------------------------------------*/
+
+#if defined(DOS)
+void utilEEWriteOnOff(USHORT p_port,UCHAR p_mode)
+#else
+void utilEEWriteOnOff(ULONG p_port,UCHAR p_mode)
+#endif
+{
+ UCHAR ee_value;
+
+ ee_value = (UCHAR)(RD_HARPOON(p_port+hp_ee_ctrl) & (EXT_ARB_ACK |
SCSI_TERM_ENA_H));
+
+ if (p_mode)
+
+ utilEESendCmdAddr(p_port, EWEN, EWEN_ADDR);
+
+ else
+
+
+ utilEESendCmdAddr(p_port, EWDS, EWDS_ADDR);
+
+ WR_HARPOON(p_port+hp_ee_ctrl, (ee_value | SEE_MS)); /*Turn off CS */
+ WR_HARPOON(p_port+hp_ee_ctrl, ee_value); /*Turn off Master Select */
+}
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: Write EEPROM
+ *
+ * Description: Write a word to the EEPROM at the specified
+ * address.
+ *
+ *---------------------------------------------------------------------*/
+
+#if defined(DOS)
+void utilEEWrite(USHORT p_port, USHORT ee_data, USHORT ee_addr)
+#else
+void utilEEWrite(ULONG p_port, USHORT ee_data, USHORT ee_addr)
+#endif
+{
+
+ UCHAR ee_value;
+ USHORT i;
+
+ ee_value = (UCHAR)((RD_HARPOON(p_port+hp_ee_ctrl) & (EXT_ARB_ACK |
SCSI_TERM_ENA_H))|
+ (SEE_MS | SEE_CS));
+
+
+
+ utilEESendCmdAddr(p_port, EE_WRITE, ee_addr);
+
+
+ ee_value |= (SEE_MS + SEE_CS);
+
+ for(i = 0x8000; i != 0; i>>=1) {
+
+ if (i & ee_data)
+ ee_value |= SEE_DO;
+ else
+ ee_value &= ~SEE_DO;
+
+ WR_HARPOON(p_port+hp_ee_ctrl, ee_value);
+ WR_HARPOON(p_port+hp_ee_ctrl, ee_value);
+ ee_value |= SEE_CLK; /* Clock data! */
+ WR_HARPOON(p_port+hp_ee_ctrl, ee_value);
+ WR_HARPOON(p_port+hp_ee_ctrl, ee_value);
+ ee_value &= ~SEE_CLK;
+ WR_HARPOON(p_port+hp_ee_ctrl, ee_value);
+ WR_HARPOON(p_port+hp_ee_ctrl, ee_value);
+ }
+ ee_value &= (EXT_ARB_ACK | SCSI_TERM_ENA_H);
+ WR_HARPOON(p_port+hp_ee_ctrl, (ee_value | SEE_MS));
+
+ Wait(p_port, TO_10ms);
+
+ WR_HARPOON(p_port+hp_ee_ctrl, (ee_value | SEE_MS | SEE_CS)); /* Set CS to
EEPROM */
+ WR_HARPOON(p_port+hp_ee_ctrl, (ee_value | SEE_MS)); /* Turn off CS */
+ WR_HARPOON(p_port+hp_ee_ctrl, ee_value); /* Turn off Master Select */
+}
+
+/*---------------------------------------------------------------------
+ *
+ * Function: Read EEPROM
+ *
+ * Description: Read a word from the EEPROM at the desired
+ * address.
+ *
+ *---------------------------------------------------------------------*/
+
+#if defined(DOS)
+USHORT utilEERead(USHORT p_port, USHORT ee_addr)
+#else
+USHORT utilEERead(ULONG p_port, USHORT ee_addr)
+#endif
+{
+ USHORT i, ee_data1, ee_data2;
+
+ i = 0;
+ ee_data1 = utilEEReadOrg(p_port, ee_addr);
+ do
+ {
+ ee_data2 = utilEEReadOrg(p_port, ee_addr);
+
+ if(ee_data1 == ee_data2)
+ return(ee_data1);
+
+ ee_data1 = ee_data2;
+ i++;
+
+ }while(i < 4);
+
+ return(ee_data1);
+}
+
+/*---------------------------------------------------------------------
+ *
+ * Function: Read EEPROM Original
+ *
+ * Description: Read a word from the EEPROM at the desired
+ * address.
+ *
+ *---------------------------------------------------------------------*/
+
+#if defined(DOS)
+USHORT utilEEReadOrg(USHORT p_port, USHORT ee_addr)
+#else
+USHORT utilEEReadOrg(ULONG p_port, USHORT ee_addr)
+#endif
+{
+
+ UCHAR ee_value;
+ USHORT i, ee_data;
+
+ ee_value = (UCHAR)((RD_HARPOON(p_port+hp_ee_ctrl) & (EXT_ARB_ACK |
SCSI_TERM_ENA_H))|
+ (SEE_MS | SEE_CS));
+
+
+ utilEESendCmdAddr(p_port, EE_READ, ee_addr);
+
+
+ ee_value |= (SEE_MS + SEE_CS);
+ ee_data = 0;
+
+ for(i = 1; i <= 16; i++) {
+
+ ee_value |= SEE_CLK; /* Clock data! */
+ WR_HARPOON(p_port+hp_ee_ctrl, ee_value);
+ WR_HARPOON(p_port+hp_ee_ctrl, ee_value);
+ ee_value &= ~SEE_CLK;
+ WR_HARPOON(p_port+hp_ee_ctrl, ee_value);
+ WR_HARPOON(p_port+hp_ee_ctrl, ee_value);
+
+ ee_data <<= 1;
+
+ if (RD_HARPOON(p_port+hp_ee_ctrl) & SEE_DI)
+ ee_data |= 1;
+ }
+
+ ee_value &= ~(SEE_MS + SEE_CS);
+ WR_HARPOON(p_port+hp_ee_ctrl, (ee_value | SEE_MS)); /*Turn off CS */
+ WR_HARPOON(p_port+hp_ee_ctrl, ee_value); /*Turn off Master Select */
+
+ return(ee_data);
+}
+
+
+/*---------------------------------------------------------------------
+ *
+ * Function: Send EE command and Address to the EEPROM
+ *
+ * Description: Transfers the correct command and sends the address
+ * to the eeprom.
+ *
+ *---------------------------------------------------------------------*/
+
+#if defined(DOS)
+void utilEESendCmdAddr(USHORT p_port, UCHAR ee_cmd, USHORT ee_addr)
+#else
+void utilEESendCmdAddr(ULONG p_port, UCHAR ee_cmd, USHORT ee_addr)
+#endif
+{
+ UCHAR ee_value;
+ UCHAR narrow_flg;
+
+ USHORT i;
+
+
+ narrow_flg= (UCHAR)(RD_HARPOON(p_port+hp_page_ctrl) & NARROW_SCSI_CARD);
+
+
+ ee_value = SEE_MS;
+ WR_HARPOON(p_port+hp_ee_ctrl, ee_value);
+
+ ee_value |= SEE_CS; /* Set CS to EEPROM */
+ WR_HARPOON(p_port+hp_ee_ctrl, ee_value);
+
+
+ for(i = 0x04; i != 0; i>>=1) {
+
+ if (i & ee_cmd)
+ ee_value |= SEE_DO;
+ else
+ ee_value &= ~SEE_DO;
+
+ WR_HARPOON(p_port+hp_ee_ctrl, ee_value);
+ WR_HARPOON(p_port+hp_ee_ctrl, ee_value);
+ ee_value |= SEE_CLK; /* Clock data! */
+ WR_HARPOON(p_port+hp_ee_ctrl, ee_value);
+ WR_HARPOON(p_port+hp_ee_ctrl, ee_value);
+ ee_value &= ~SEE_CLK;
+ WR_HARPOON(p_port+hp_ee_ctrl, ee_value);
+ WR_HARPOON(p_port+hp_ee_ctrl, ee_value);
+ }
+
+
+ if (narrow_flg)
+ i = 0x0080;
+
+ else
+ i = 0x0200;
+
+
+ while (i != 0) {
+
+ if (i & ee_addr)
+ ee_value |= SEE_DO;
+ else
+ ee_value &= ~SEE_DO;
+
+ WR_HARPOON(p_port+hp_ee_ctrl, ee_value);
+ WR_HARPOON(p_port+hp_ee_ctrl, ee_value);
+ ee_value |= SEE_CLK; /* Clock data! */
+ WR_HARPOON(p_port+hp_ee_ctrl, ee_value);
+ WR_HARPOON(p_port+hp_ee_ctrl, ee_value);
+ ee_value &= ~SEE_CLK;
+ WR_HARPOON(p_port+hp_ee_ctrl, ee_value);
+ WR_HARPOON(p_port+hp_ee_ctrl, ee_value);
+
+ i >>= 1;
+ }
+}
+
+USHORT CalcCrc16(UCHAR buffer[])
+{
+ USHORT crc=0;
+ int i,j;
+ USHORT ch;
+ for (i=0; i < ID_STRING_LENGTH; i++)
+ {
+ ch = (USHORT) buffer[i];
+ for(j=0; j < 8; j++)
+ {
+ if ((crc ^ ch) & 1)
+ crc = (crc >> 1) ^ CRCMASK;
+ else
+ crc >>= 1;
+ ch >>= 1;
+ }
+ }
+ return(crc);
+}
+
+UCHAR CalcLrc(UCHAR buffer[])
+{
+ int i;
+ UCHAR lrc;
+ lrc = 0;
+ for(i = 0; i < ID_STRING_LENGTH; i++)
+ lrc ^= buffer[i];
+ return(lrc);
+}
+
+
+
+/*
+ The following inline definitions avoid type conflicts.
+*/
+
+static inline unsigned char
+FlashPoint__ProbeHostAdapter(FlashPoint_Info_T *FlashPointInfo)
+{
+ return FlashPoint_ProbeHostAdapter((PSCCBMGR_INFO) FlashPointInfo);
+}
+
+
+static inline FlashPoint_CardHandle_T
+FlashPoint__HardwareResetHostAdapter(FlashPoint_Info_T *FlashPointInfo)
+{
+ return FlashPoint_HardwareResetHostAdapter((PSCCBMGR_INFO) FlashPointInfo);
+}
+
+static inline void
+FlashPoint__ReleaseHostAdapter(FlashPoint_CardHandle_T CardHandle)
+{
+ FlashPoint_ReleaseHostAdapter(CardHandle);
+}
+
+
+static inline void
+FlashPoint__StartCCB(FlashPoint_CardHandle_T CardHandle, BusLogic_CCB_T *CCB)
+{
+ FlashPoint_StartCCB(CardHandle, (PSCCB) CCB);
+}
+
+
+static inline void
+FlashPoint__AbortCCB(FlashPoint_CardHandle_T CardHandle, BusLogic_CCB_T *CCB)
+{
+ FlashPoint_AbortCCB(CardHandle, (PSCCB) CCB);
+}
+
+
+static inline boolean
+FlashPoint__InterruptPending(FlashPoint_CardHandle_T CardHandle)
+{
+ return FlashPoint_InterruptPending(CardHandle);
+}
+
+
+static inline int
+FlashPoint__HandleInterrupt(FlashPoint_CardHandle_T CardHandle)
+{
+ return FlashPoint_HandleInterrupt(CardHandle);
+}
+
+
+#define FlashPoint_ProbeHostAdapter FlashPoint__ProbeHostAdapter
+#define FlashPoint_HardwareResetHostAdapter
FlashPoint__HardwareResetHostAdapter
+#define FlashPoint_ReleaseHostAdapter FlashPoint__ReleaseHostAdapter
+#define FlashPoint_StartCCB FlashPoint__StartCCB
+#define FlashPoint_AbortCCB FlashPoint__AbortCCB
+#define FlashPoint_InterruptPending FlashPoint__InterruptPending
+#define FlashPoint_HandleInterrupt FlashPoint__HandleInterrupt
+
+
+/*
+ FlashPoint_InquireTargetInfo returns the Synchronous Period, Synchronous
+ Offset, and Wide Transfers Active information for TargetID on CardHandle.
+*/
+
+void FlashPoint_InquireTargetInfo(FlashPoint_CardHandle_T CardHandle,
+ int TargetID,
+ unsigned char *SynchronousPeriod,
+ unsigned char *SynchronousOffset,
+ unsigned char *WideTransfersActive)
+{
+ SCCBMGR_TAR_INFO *TargetInfo =
+ &sccbMgrTbl[((SCCBCARD *)CardHandle)->cardIndex][TargetID];
+ if ((TargetInfo->TarSyncCtrl & SYNC_OFFSET) > 0)
+ {
+ *SynchronousPeriod = 5 * ((TargetInfo->TarSyncCtrl >> 5) + 1);
+ *SynchronousOffset = TargetInfo->TarSyncCtrl & SYNC_OFFSET;
+ }
+ else
+ {
+ *SynchronousPeriod = 0;
+ *SynchronousOffset = 0;
+ }
+ *WideTransfersActive = (TargetInfo->TarSyncCtrl & NARROW_SCSI ? 0 : 1);
+}
+
+
+#else /* CONFIG_SCSI_OMIT_FLASHPOINT */
+
+
+/*
+ Define prototypes for the FlashPoint SCCB Manager Functions.
+*/
+
+extern unsigned char FlashPoint_ProbeHostAdapter(FlashPoint_Info_T *);
+extern FlashPoint_CardHandle_T
+ FlashPoint_HardwareResetHostAdapter(FlashPoint_Info_T *);
+extern void FlashPoint_StartCCB(FlashPoint_CardHandle_T, BusLogic_CCB_T *);
+extern int FlashPoint_AbortCCB(FlashPoint_CardHandle_T, BusLogic_CCB_T *);
+extern boolean FlashPoint_InterruptPending(FlashPoint_CardHandle_T);
+extern int FlashPoint_HandleInterrupt(FlashPoint_CardHandle_T);
+extern void FlashPoint_ReleaseHostAdapter(FlashPoint_CardHandle_T);
+extern void FlashPoint_InquireTargetInfo(FlashPoint_CardHandle_T,
+ int, unsigned char *,
+ unsigned char *, unsigned char *);
+
+
+#endif /* CONFIG_SCSI_OMIT_FLASHPOINT */
diff --git a/linux/src/drivers/scsi/NCR5380.c b/linux/src/drivers/scsi/NCR5380.c
index 295f2ad..4f085e9 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/eata_pio_proc.c
b/linux/src/drivers/scsi/eata_pio_proc.c
new file mode 100644
index 0000000..54783f2
--- /dev/null
+++ b/linux/src/drivers/scsi/eata_pio_proc.c
@@ -0,0 +1,135 @@
+
+/*
+ * eata_set_info
+ * buffer : pointer to the data that has been written to the hostfile
+ * length : number of bytes written to the hostfile
+ * HBA_ptr: pointer to the Scsi_Host struct
+ */
+int eata_pio_set_info(char *buffer, int length, struct Scsi_Host *HBA_ptr)
+{
+ DBG(DBG_PROC_WRITE, printk("%s\n", buffer));
+ return(-ENOSYS); /* Currently this is a no-op */
+}
+
+/*
+ * eata_proc_info
+ * inout : decides on the direction of the dataflow and the meaning of the
+ * variables
+ * buffer: If inout==FALSE data is being written to it else read from it
+ * *start: If inout==FALSE start of the valid data in the buffer
+ * offset: If inout==FALSE offset from the beginning of the imaginary file
+ * from which we start writing into the buffer
+ * length: If inout==FALSE max number of bytes to be written into the buffer
+ * else number of bytes in the buffer
+ */
+int eata_pio_proc_info(char *buffer, char **start, off_t offset, int length,
+ int hostno, int inout)
+{
+
+ Scsi_Device *scd;
+ struct Scsi_Host *HBA_ptr;
+ static u8 buff[512];
+ int i;
+ int size, len = 0;
+ off_t begin = 0;
+ off_t pos = 0;
+
+ HBA_ptr = first_HBA;
+ for (i = 1; i <= registered_HBAs; i++) {
+ if (HBA_ptr->host_no == hostno)
+ break;
+ HBA_ptr = SD(HBA_ptr)->next;
+ }
+
+ if(inout == TRUE) /* Has data been written to the file ? */
+ return(eata_pio_set_info(buffer, length, HBA_ptr));
+
+ if (offset == 0)
+ memset(buff, 0, sizeof(buff));
+
+ size = sprintf(buffer+len, "EATA (Extended Attachment) PIO driver version:
"
+ "%d.%d%s\n",VER_MAJOR, VER_MINOR, VER_SUB);
+ len += size; pos = begin + len;
+ size = sprintf(buffer + len, "queued commands: %10ld\n"
+ "processed interrupts:%10ld\n", queue_counter, int_counter);
+ len += size; pos = begin + len;
+
+ size = sprintf(buffer + len, "\nscsi%-2d: HBA %.10s\n",
+ HBA_ptr->host_no, SD(HBA_ptr)->name);
+ len += size;
+ pos = begin + len;
+ size = sprintf(buffer + len, "Firmware revision: v%s\n",
+ SD(HBA_ptr)->revision);
+ len += size;
+ pos = begin + len;
+ size = sprintf(buffer + len, "IO: PIO\n");
+ len += size;
+ pos = begin + len;
+ size = sprintf(buffer + len, "Base IO : %#.4x\n", (u32) HBA_ptr->base);
+ len += size;
+ pos = begin + len;
+ size = sprintf(buffer + len, "Host Bus: %s\n",
+ (SD(HBA_ptr)->bustype == 'P')?"PCI ":
+ (SD(HBA_ptr)->bustype == 'E')?"EISA":"ISA ");
+
+ len += size;
+ pos = begin + len;
+
+ if (pos < offset) {
+ len = 0;
+ begin = pos;
+ }
+ if (pos > offset + length)
+ goto stop_output;
+
+ scd = scsi_devices;
+
+ size = sprintf(buffer+len,"Attached devices: %s\n", (scd)?"":"none");
+ len += size;
+ pos = begin + len;
+
+ while (scd) {
+ if (scd->host == HBA_ptr) {
+ proc_print_scsidevice(scd, buffer, &size, len);
+ len += size;
+ pos = begin + len;
+
+ if (pos < offset) {
+ len = 0;
+ begin = pos;
+ }
+ if (pos > offset + length)
+ goto stop_output;
+ }
+ scd = scd->next;
+ }
+
+ stop_output:
+ DBG(DBG_PROC, printk("2pos: %ld offset: %ld len: %d\n", pos, offset, len));
+ *start=buffer+(offset-begin); /* Start of wanted data */
+ len-=(offset-begin); /* Start slop */
+ if(len>length)
+ len = length; /* Ending slop */
+ DBG(DBG_PROC, printk("3pos: %ld offset: %ld len: %d\n", pos, offset, len));
+
+ return (len);
+}
+
+/*
+ * Overrides for Emacs so that we follow Linus's tabbing style.
+ * Emacs will notice this stuff at the end of the file and automatically
+ * adjust the settings for this buffer only. This must remain at the end
+ * of the file.
+ * ---------------------------------------------------------------------------
+ * Local variables:
+ * c-indent-level: 4
+ * c-brace-imaginary-offset: 0
+ * c-brace-offset: -4
+ * c-argdecl-indent: 4
+ * c-label-offset: -4
+ * c-continued-statement-offset: 4
+ * c-continued-brace-offset: 0
+ * tab-width: 8
+ * End:
+ */
+
diff --git a/linux/src/drivers/scsi/scsiiom.c b/linux/src/drivers/scsi/scsiiom.c
new file mode 100644
index 0000000..97801d7
--- /dev/null
+++ b/linux/src/drivers/scsi/scsiiom.c
@@ -0,0 +1,1540 @@
+/***********************************************************************
+ * FILE NAME : SCSIIOM.C *
+ * BY : C.L. Huang, address@hidden *
+ * Description: Device Driver for Tekram DC-390 (T) PCI SCSI *
+ * Bus Master Host Adapter *
+ ***********************************************************************/
+
+
+static USHORT
+DC390_StartSCSI( PACB pACB, PDCB pDCB, PSRB pSRB )
+{
+ USHORT ioport, rc;
+ UCHAR bval, bval1, i, cnt;
+ PUCHAR ptr;
+ ULONG wlval;
+
+ pSRB->TagNumber = 31;
+ ioport = pACB->IOPortBase;
+ bval = pDCB->UnitSCSIID;
+ outb(bval,ioport+Scsi_Dest_ID);
+ bval = pDCB->SyncPeriod;
+ outb(bval,ioport+Sync_Period);
+ bval = pDCB->SyncOffset;
+ outb(bval,ioport+Sync_Offset);
+ bval = pDCB->CtrlR1;
+ outb(bval,ioport+CtrlReg1);
+ bval = pDCB->CtrlR3;
+ outb(bval,ioport+CtrlReg3);
+ bval = pDCB->CtrlR4;
+ outb(bval,ioport+CtrlReg4);
+ bval = CLEAR_FIFO_CMD; /* Flush FIFO */
+ outb(bval,ioport+ScsiCmd);
+
+ pSRB->ScsiPhase = SCSI_NOP0;
+ bval = pDCB->IdentifyMsg;
+ if( !(pDCB->SyncMode & EN_ATN_STOP) )
+ {
+ if( (pSRB->CmdBlock[0] == INQUIRY) ||
+ (pSRB->CmdBlock[0] == REQUEST_SENSE) ||
+ (pSRB->SRBFlag & AUTO_REQSENSE) )
+ {
+ bval &= 0xBF; /* NO disconnection */
+ outb(bval,ioport+ScsiFifo);
+ bval1 = SELECT_W_ATN;
+ pSRB->SRBState = SRB_START_;
+ if( pDCB->SyncMode & SYNC_ENABLE )
+ {
+ if( !(pDCB->IdentifyMsg & 7) ||
+ (pSRB->CmdBlock[0] != INQUIRY) )
+ {
+ bval1 = SEL_W_ATN_STOP;
+ pSRB->SRBState = SRB_MSGOUT;
+ }
+ }
+ }
+ else
+ {
+ if(pDCB->SyncMode & EN_TAG_QUEUING)
+ {
+ outb(bval,ioport+ScsiFifo);
+ bval = MSG_SIMPLE_QTAG;
+ outb(bval,ioport+ScsiFifo);
+ wlval = 1;
+ bval = 0;
+ while( wlval & pDCB->TagMask )
+ {
+ wlval = wlval << 1;
+ bval++;
+ }
+ outb(bval,ioport+ScsiFifo);
+ pDCB->TagMask |= wlval;
+ pSRB->TagNumber = bval;
+ bval1 = SEL_W_ATN2;
+ pSRB->SRBState = SRB_START_;
+ }
+ else
+ {
+ outb(bval,ioport+ScsiFifo);
+ bval1 = SELECT_W_ATN;
+ pSRB->SRBState = SRB_START_;
+ }
+ }
+
+ if( pSRB->SRBFlag & AUTO_REQSENSE )
+ {
+ bval = REQUEST_SENSE;
+ outb(bval,ioport+ScsiFifo);
+ bval = pDCB->IdentifyMsg << 5;
+ outb(bval,ioport+ScsiFifo);
+ bval = 0;
+ outb(bval,ioport+ScsiFifo);
+ outb(bval,ioport+ScsiFifo);
+ bval = sizeof(pSRB->pcmd->sense_buffer);
+ outb(bval,ioport+ScsiFifo);
+ bval = 0;
+ outb(bval,ioport+ScsiFifo);
+ }
+ else
+ {
+ cnt = pSRB->ScsiCmdLen;
+ ptr = (PUCHAR) pSRB->CmdBlock;
+ for(i=0; i<cnt; i++)
+ {
+ bval = *ptr++;
+ outb(bval,ioport+ScsiFifo);
+ }
+ }
+ }
+ else /* ATN_STOP */
+ {
+ if( (pSRB->CmdBlock[0] == INQUIRY) ||
+ (pSRB->CmdBlock[0] == REQUEST_SENSE) ||
+ (pSRB->SRBFlag & AUTO_REQSENSE) )
+ {
+ bval &= 0xBF;
+ outb(bval,ioport+ScsiFifo);
+ bval1 = SELECT_W_ATN;
+ pSRB->SRBState = SRB_START_;
+ if( pDCB->SyncMode & SYNC_ENABLE )
+ {
+ if( !(pDCB->IdentifyMsg & 7) ||
+ (pSRB->CmdBlock[0] != INQUIRY) )
+ {
+ bval1 = SEL_W_ATN_STOP;
+ pSRB->SRBState = SRB_MSGOUT;
+ }
+ }
+ }
+ else
+ {
+ if(pDCB->SyncMode & EN_TAG_QUEUING)
+ {
+ outb(bval,ioport+ScsiFifo);
+ pSRB->MsgOutBuf[0] = MSG_SIMPLE_QTAG;
+ wlval = 1;
+ bval = 0;
+ while( wlval & pDCB->TagMask )
+ {
+ wlval = wlval << 1;
+ bval++;
+ }
+ pDCB->TagMask |= wlval;
+ pSRB->TagNumber = bval;
+ pSRB->MsgOutBuf[1] = bval;
+ pSRB->MsgCnt = 2;
+ bval1 = SEL_W_ATN_STOP;
+ pSRB->SRBState = SRB_START_;
+ }
+ else
+ {
+ outb(bval,ioport+ScsiFifo);
+ pSRB->MsgOutBuf[0] = MSG_NOP;
+ pSRB->MsgCnt = 1;
+ pSRB->SRBState = SRB_START_;
+ bval1 = SEL_W_ATN_STOP;
+ }
+ }
+ }
+ bval = inb( ioport+Scsi_Status );
+ if( bval & INTERRUPT )
+ {
+ pSRB->SRBState = SRB_READY;
+ pDCB->TagMask &= ~( 1 << pSRB->TagNumber );
+ rc = 1;
+ }
+ else
+ {
+ pSRB->ScsiPhase = SCSI_NOP1;
+ pACB->pActiveDCB = pDCB;
+ pDCB->pActiveSRB = pSRB;
+ rc = 0;
+ outb(bval1,ioport+ScsiCmd);
+ }
+ return( rc );
+}
+
+
+#ifndef VERSION_ELF_1_2_13
+static void
+DC390_Interrupt( int irq, void *dev_id, struct pt_regs *regs)
+#else
+static void
+DC390_Interrupt( int irq, struct pt_regs *regs)
+#endif
+{
+ PACB pACB;
+ PDCB pDCB;
+ PSRB pSRB;
+ USHORT ioport = 0;
+ USHORT phase, i;
+ void (*stateV)( PACB, PSRB, PUCHAR );
+ UCHAR istate = 0;
+ UCHAR sstatus=0, istatus;
+
+ pACB = pACB_start;
+ if( pACB == NULL )
+ return;
+ for( i=0; i < adapterCnt; i++ )
+ {
+ if( pACB->IRQLevel == (UCHAR) irq )
+ {
+ ioport = pACB->IOPortBase;
+ sstatus = inb( ioport+Scsi_Status );
+ if( sstatus & INTERRUPT )
+ break;
+ else
+ pACB = pACB->pNextACB;
+ }
+ else
+ {
+ pACB = pACB->pNextACB;
+ }
+ }
+
+#ifdef DC390_DEBUG1
+ printk("sstatus=%2x,",sstatus);
+#endif
+
+ if( pACB == (PACB )-1 )
+ {
+ printk("DC390: Spurious interrupt detected!\n");
+ return;
+ }
+
+ istate = inb( ioport+Intern_State );
+ istatus = inb( ioport+INT_Status );
+
+#ifdef DC390_DEBUG1
+ printk("Istatus=%2x,",istatus);
+#endif
+
+ if(istatus & DISCONNECTED)
+ {
+ DC390_Disconnect( pACB );
+ return;
+ }
+
+ if(istatus & RESELECTED)
+ {
+ DC390_Reselect( pACB );
+ return;
+ }
+
+ if(istatus & INVALID_CMD)
+ {
+ DC390_InvalidCmd( pACB );
+ return;
+ }
+
+ if(istatus & SCSI_RESET)
+ {
+ DC390_ScsiRstDetect( pACB );
+ return;
+ }
+
+ if( istatus & (SUCCESSFUL_OP+SERVICE_REQUEST) )
+ {
+ pDCB = pACB->pActiveDCB;
+ pSRB = pDCB->pActiveSRB;
+ if( pDCB )
+ {
+ if( pDCB->DCBFlag & ABORT_DEV_ )
+ EnableMsgOut( pACB, pSRB );
+ }
+
+ phase = (USHORT) pSRB->ScsiPhase;
+ stateV = (void *) DC390_phase0[phase];
+ stateV( pACB, pSRB, &sstatus );
+
+ pSRB->ScsiPhase = sstatus & 7;
+ phase = (USHORT) sstatus & 7;
+ stateV = (void *) DC390_phase1[phase];
+ stateV( pACB, pSRB, &sstatus );
+ }
+}
+
+
+static void
+DC390_DataOut_0( PACB pACB, PSRB pSRB, PUCHAR psstatus)
+{
+ UCHAR sstatus, bval;
+ USHORT ioport;
+ PSGL psgl;
+ ULONG ResidCnt, xferCnt;
+
+ ioport = pACB->IOPortBase;
+ sstatus = *psstatus;
+
+ if( !(pSRB->SRBState & SRB_XFERPAD) )
+ {
+ if( sstatus & PARITY_ERR )
+ pSRB->SRBStatus |= PARITY_ERROR;
+
+ if( sstatus & COUNT_2_ZERO )
+ {
+ bval = inb(ioport+DMA_Status);
+ while( !(bval & DMA_XFER_DONE) )
+ bval = inb(ioport+DMA_Status);
+ pSRB->TotalXferredLen += pSRB->SGToBeXferLen;
+ pSRB->SGIndex++;
+ if( pSRB->SGIndex < pSRB->SGcount )
+ {
+ pSRB->pSegmentList++;
+ psgl = pSRB->pSegmentList;
+
+#ifndef VERSION_ELF_1_2_13
+ pSRB->SGPhysAddr = virt_to_phys( psgl->address );
+#else
+ pSRB->SGPhysAddr = (ULONG) psgl->address;
+#endif
+ pSRB->SGToBeXferLen = (ULONG) psgl->length;
+ }
+ else
+ pSRB->SGToBeXferLen = 0;
+ }
+ else
+ {
+ bval = inb( ioport+Current_Fifo );
+ bval &= 0x1f;
+ ResidCnt = (ULONG) inb(ioport+CtcReg_High);
+ ResidCnt = ResidCnt << 8;
+ ResidCnt |= (ULONG) inb(ioport+CtcReg_Mid);
+ ResidCnt = ResidCnt << 8;
+ ResidCnt |= (ULONG) inb(ioport+CtcReg_Low);
+ ResidCnt += (ULONG) bval;
+
+ xferCnt = pSRB->SGToBeXferLen - ResidCnt;
+ pSRB->SGPhysAddr += xferCnt;
+ pSRB->TotalXferredLen += xferCnt;
+ pSRB->SGToBeXferLen = ResidCnt;
+ }
+ }
+ bval = WRITE_DIRECTION+DMA_IDLE_CMD;
+ outb( bval, ioport+DMA_Cmd);
+}
+
+static void
+DC390_DataIn_0( PACB pACB, PSRB pSRB, PUCHAR psstatus)
+{
+ UCHAR sstatus, bval;
+ USHORT i, ioport, residual;
+ PSGL psgl;
+ ULONG ResidCnt, xferCnt;
+ PUCHAR ptr;
+
+
+ ioport = pACB->IOPortBase;
+ sstatus = *psstatus;
+
+ if( !(pSRB->SRBState & SRB_XFERPAD) )
+ {
+ if( sstatus & PARITY_ERR )
+ pSRB->SRBStatus |= PARITY_ERROR;
+
+ if( sstatus & COUNT_2_ZERO )
+ {
+ bval = inb(ioport+DMA_Status);
+ while( !(bval & DMA_XFER_DONE) )
+ bval = inb(ioport+DMA_Status);
+
+ bval = READ_DIRECTION+DMA_IDLE_CMD;
+ outb( bval, ioport+DMA_Cmd);
+
+ pSRB->TotalXferredLen += pSRB->SGToBeXferLen;
+ pSRB->SGIndex++;
+ if( pSRB->SGIndex < pSRB->SGcount )
+ {
+ pSRB->pSegmentList++;
+ psgl = pSRB->pSegmentList;
+
+#ifndef VERSION_ELF_1_2_13
+ pSRB->SGPhysAddr = virt_to_phys( psgl->address );
+#else
+ pSRB->SGPhysAddr = (ULONG) psgl->address;
+#endif
+ pSRB->SGToBeXferLen = (ULONG) psgl->length;
+ }
+ else
+ pSRB->SGToBeXferLen = 0;
+ }
+ else /* phase changed */
+ {
+ residual = 0;
+ bval = inb(ioport+Current_Fifo);
+ while( bval & 0x1f )
+ {
+ if( (bval & 0x1f) == 1 )
+ {
+ for(i=0; i< 0x100; i++)
+ {
+ bval = inb(ioport+Current_Fifo);
+ if( !(bval & 0x1f) )
+ goto din_1;
+ else if( i == 0x0ff )
+ {
+ residual = 1; /* ;1 residual byte */
+ goto din_1;
+ }
+ }
+ }
+ else
+ bval = inb(ioport+Current_Fifo);
+ }
+din_1:
+ bval = READ_DIRECTION+DMA_BLAST_CMD;
+ outb(bval, ioport+DMA_Cmd);
+ for(i=0; i<0x8000; i++)
+ {
+ bval = inb(ioport+DMA_Status);
+ if(bval & BLAST_COMPLETE)
+ break;
+ }
+ bval = READ_DIRECTION+DMA_IDLE_CMD;
+ outb(bval, ioport+DMA_Cmd);
+
+ ResidCnt = (ULONG) inb(ioport+CtcReg_High);
+ ResidCnt = ResidCnt << 8;
+ ResidCnt |= (ULONG) inb(ioport+CtcReg_Mid);
+ ResidCnt = ResidCnt << 8;
+ ResidCnt |= (ULONG) inb(ioport+CtcReg_Low);
+
+ xferCnt = pSRB->SGToBeXferLen - ResidCnt;
+ pSRB->SGPhysAddr += xferCnt;
+ pSRB->TotalXferredLen += xferCnt;
+ pSRB->SGToBeXferLen = ResidCnt;
+
+ if( residual )
+ {
+ bval = inb(ioport+ScsiFifo); /* get residual byte */
+#ifndef VERSION_ELF_1_2_13
+ ptr = (PUCHAR) phys_to_virt( pSRB->SGPhysAddr );
+#else
+ ptr = (PUCHAR) pSRB->SGPhysAddr;
+#endif
+ *ptr = bval;
+ pSRB->SGPhysAddr++;
+ pSRB->TotalXferredLen++;
+ pSRB->SGToBeXferLen--;
+ }
+ }
+ }
+}
+
+static void
+DC390_Command_0( PACB pACB, PSRB pSRB, PUCHAR psstatus)
+{
+}
+
+static void
+DC390_Status_0( PACB pACB, PSRB pSRB, PUCHAR psstatus)
+{
+ UCHAR bval;
+ USHORT ioport;
+
+ ioport = pACB->IOPortBase;
+ bval = inb(ioport+ScsiFifo);
+ pSRB->TargetStatus = bval;
+ bval++;
+ bval = inb(ioport+ScsiFifo); /* get message */
+ pSRB->EndMessage = bval;
+
+ *psstatus = SCSI_NOP0;
+ pSRB->SRBState = SRB_COMPLETED;
+ bval = MSG_ACCEPTED_CMD;
+ outb(bval, ioport+ScsiCmd);
+}
+
+static void
+DC390_MsgOut_0( PACB pACB, PSRB pSRB, PUCHAR psstatus)
+{
+ if( pSRB->SRBState & (SRB_UNEXPECT_RESEL+SRB_ABORT_SENT) )
+ *psstatus = SCSI_NOP0;
+}
+
+static void
+DC390_MsgIn_0( PACB pACB, PSRB pSRB, PUCHAR psstatus)
+{
+ UCHAR bval;
+ USHORT ioport, wval, wval1;
+ PDCB pDCB;
+ PSRB psrb;
+
+ ioport = pACB->IOPortBase;
+ pDCB = pACB->pActiveDCB;
+
+ bval = inb( ioport+ScsiFifo );
+ if( !(pSRB->SRBState & SRB_MSGIN_MULTI) )
+ {
+ if(bval == MSG_DISCONNECT)
+ {
+ pSRB->SRBState = SRB_DISCONNECT;
+ }
+ else if( bval == MSG_SAVE_PTR )
+ goto min6;
+ else if( (bval == MSG_EXTENDED) || ((bval >= MSG_SIMPLE_QTAG) &&
+ (bval <= MSG_ORDER_QTAG)) )
+ {
+ pSRB->SRBState |= SRB_MSGIN_MULTI;
+ pSRB->MsgInBuf[0] = bval;
+ pSRB->MsgCnt = 1;
+ pSRB->pMsgPtr = &pSRB->MsgInBuf[1];
+ }
+ else if(bval == MSG_REJECT_)
+ {
+ bval = RESET_ATN_CMD;
+ outb(bval, ioport+ScsiCmd);
+ if( pSRB->SRBState & DO_SYNC_NEGO)
+ goto set_async;
+ }
+ else if( bval == MSG_RESTORE_PTR)
+ goto min6;
+ else
+ goto min6;
+ }
+ else
+ { /* minx: */
+
+ *pSRB->pMsgPtr = bval;
+ pSRB->MsgCnt++;
+ pSRB->pMsgPtr++;
+ if( (pSRB->MsgInBuf[0] >= MSG_SIMPLE_QTAG) &&
+ (pSRB->MsgInBuf[0] <= MSG_ORDER_QTAG) )
+ {
+ if( pSRB->MsgCnt == 2)
+ {
+ pSRB->SRBState = 0;
+ bval = pSRB->MsgInBuf[1];
+ pSRB = pDCB->pGoingSRB;
+ psrb = pDCB->pGoingLast;
+ if( pSRB )
+ {
+ for( ;; )
+ {
+ if(pSRB->TagNumber != bval)
+ {
+ if( pSRB == psrb )
+ goto mingx0;
+ pSRB = pSRB->pNextSRB;
+ }
+ else
+ break;
+ }
+ if( pDCB->DCBFlag & ABORT_DEV_ )
+ {
+ pSRB->SRBState = SRB_ABORT_SENT;
+ EnableMsgOut( pACB, pSRB );
+ }
+ if( !(pSRB->SRBState & SRB_DISCONNECT) )
+ goto mingx0;
+ pDCB->pActiveSRB = pSRB;
+ pSRB->SRBState = SRB_DATA_XFER;
+ }
+ else
+ {
+mingx0:
+ pSRB = pACB->pTmpSRB;
+ pSRB->SRBState = SRB_UNEXPECT_RESEL;
+ pDCB->pActiveSRB = pSRB;
+ pSRB->MsgOutBuf[0] = MSG_ABORT_TAG;
+ EnableMsgOut2( pACB, pSRB );
+ }
+ }
+ }
+ else if( (pSRB->MsgInBuf[0] == MSG_EXTENDED) && (pSRB->MsgCnt == 5) )
+ {
+ pSRB->SRBState &= ~(SRB_MSGIN_MULTI+DO_SYNC_NEGO);
+ if( (pSRB->MsgInBuf[1] != 3) || (pSRB->MsgInBuf[2] != 1) )
+ { /* reject_msg: */
+ pSRB->MsgCnt = 1;
+ pSRB->MsgInBuf[0] = MSG_REJECT_;
+ bval = SET_ATN_CMD;
+ outb(bval, ioport+ScsiCmd);
+ }
+ else if( !(pSRB->MsgInBuf[3]) || !(pSRB->MsgInBuf[4]) )
+ {
+set_async:
+ pDCB = pSRB->pSRBDCB;
+ pDCB->SyncMode &= ~(SYNC_ENABLE+SYNC_NEGO_DONE);
+ pDCB->SyncPeriod = 0;
+ pDCB->SyncOffset = 0;
+ pDCB->CtrlR3 = FAST_CLK; /* ;non_fast */
+ pDCB->CtrlR4 &= 0x3f;
+ pDCB->CtrlR4 |= EATER_25NS; /* ; 25ns glitch eater */
+ goto re_prog;
+ }
+ else
+ { /* set_sync: */
+
+ pDCB = pSRB->pSRBDCB;
+ pDCB->SyncMode |= SYNC_ENABLE+SYNC_NEGO_DONE;
+ pDCB->SyncOffset &= 0x0f0;
+ pDCB->SyncOffset |= pSRB->MsgInBuf[4];
+ pDCB->NegoPeriod = pSRB->MsgInBuf[3];
+ wval = (USHORT) pSRB->MsgInBuf[3];
+ wval = wval << 2;
+ wval--;
+ wval1 = wval / 25;
+ if( (wval1 * 25) != wval)
+ wval1++;
+ bval = FAST_CLK+FAST_SCSI;
+ pDCB->CtrlR4 &= 0x3f;
+ if(wval1 >= 8)
+ {
+ wval1--;
+ bval = FAST_CLK; /* ;fast clock/normal scsi */
+ pDCB->CtrlR4 |= EATER_25NS; /* ;25 ns glitch eater */
+ }
+ pDCB->CtrlR3 = bval;
+ pDCB->SyncPeriod = (UCHAR)wval1;
+re_prog:
+ bval = pDCB->SyncPeriod;
+ outb(bval, ioport+Sync_Period);
+ bval = pDCB->SyncOffset;
+ outb(bval, ioport+Sync_Offset);
+ bval = pDCB->CtrlR3;
+ outb(bval, ioport+CtrlReg3);
+ bval = pDCB->CtrlR4;
+ outb(bval, ioport+CtrlReg4);
+ SetXferRate( pACB, pDCB);
+ }
+ }
+ }
+min6:
+ *psstatus = SCSI_NOP0;
+ bval = MSG_ACCEPTED_CMD;
+ outb(bval, ioport+ScsiCmd);
+}
+
+static void
+DataIO_Comm( PACB pACB, PSRB pSRB, UCHAR ioDir)
+{
+ PSGL psgl;
+ UCHAR bval;
+ USHORT ioport;
+ ULONG lval;
+
+
+ ioport = pACB->IOPortBase;
+ if( pSRB->SGIndex < pSRB->SGcount )
+ {
+ bval = DMA_IDLE_CMD | ioDir; /* ;+EN_DMA_INT */
+ outb( bval, ioport+DMA_Cmd);
+ if( !pSRB->SGToBeXferLen )
+ {
+ psgl = pSRB->pSegmentList;
+#ifndef VERSION_ELF_1_2_13
+ pSRB->SGPhysAddr = virt_to_phys( psgl->address );
+#else
+ pSRB->SGPhysAddr = (ULONG) psgl->address;
+#endif
+ pSRB->SGToBeXferLen = (ULONG) psgl->length;
+ }
+ lval = pSRB->SGToBeXferLen;
+ bval = (UCHAR) lval;
+ outb(bval,ioport+CtcReg_Low);
+ lval = lval >> 8;
+ bval = (UCHAR) lval;
+ outb(bval,ioport+CtcReg_Mid);
+ lval = lval >> 8;
+ bval = (UCHAR) lval;
+ outb(bval,ioport+CtcReg_High);
+
+ lval = pSRB->SGToBeXferLen;
+ outl(lval, ioport+DMA_XferCnt);
+
+ lval = pSRB->SGPhysAddr;
+ outl( lval, ioport+DMA_XferAddr);
+
+ bval = DMA_COMMAND+INFO_XFER_CMD;
+ outb(bval, ioport+ScsiCmd);
+
+ pSRB->SRBState = SRB_DATA_XFER;
+
+ bval = DMA_IDLE_CMD | ioDir; /* ;+EN_DMA_INT */
+ outb(bval, ioport+DMA_Cmd);
+
+ bval = DMA_START_CMD | ioDir; /* ;+EN_DMA_INT */
+ outb(bval, ioport+DMA_Cmd);
+ }
+ else /* xfer pad */
+ {
+ if( pSRB->SGcount )
+ {
+ pSRB->AdaptStatus = H_OVER_UNDER_RUN;
+ pSRB->SRBStatus |= OVER_RUN;
+ }
+ bval = 0;
+ outb(bval,ioport+CtcReg_Low);
+ outb(bval,ioport+CtcReg_Mid);
+ outb(bval,ioport+CtcReg_High);
+
+ pSRB->SRBState |= SRB_XFERPAD;
+ bval = DMA_COMMAND+XFER_PAD_BYTE;
+ outb(bval, ioport+ScsiCmd);
+/*
+ bval = DMA_IDLE_CMD | ioDir; ;+EN_DMA_INT
+ outb(bval, ioport+DMA_Cmd);
+ bval = DMA_START_CMD | ioDir; ;+EN_DMA_INT
+ outb(bval, ioport+DMA_Cmd);
+*/
+ }
+}
+
+
+static void
+DC390_DataOutPhase( PACB pACB, PSRB pSRB, PUCHAR psstatus)
+{
+ UCHAR ioDir;
+
+ ioDir = WRITE_DIRECTION;
+ DataIO_Comm( pACB, pSRB, ioDir);
+}
+
+static void
+DC390_DataInPhase( PACB pACB, PSRB pSRB, PUCHAR psstatus)
+{
+ UCHAR ioDir;
+
+ ioDir = READ_DIRECTION;
+ DataIO_Comm( pACB, pSRB, ioDir);
+}
+
+static void
+DC390_CommandPhase( PACB pACB, PSRB pSRB, PUCHAR psstatus)
+{
+ PDCB pDCB;
+ UCHAR bval;
+ PUCHAR ptr;
+ USHORT ioport, i, cnt;
+
+
+ ioport = pACB->IOPortBase;
+ bval = RESET_ATN_CMD;
+ outb(bval, ioport+ScsiCmd);
+ bval = CLEAR_FIFO_CMD;
+ outb(bval, ioport+ScsiCmd);
+ if( !(pSRB->SRBFlag & AUTO_REQSENSE) )
+ {
+ cnt = (USHORT) pSRB->ScsiCmdLen;
+ ptr = (PUCHAR) pSRB->CmdBlock;
+ for(i=0; i < cnt; i++)
+ {
+ outb(*ptr, ioport+ScsiFifo);
+ ptr++;
+ }
+ }
+ else
+ {
+ bval = REQUEST_SENSE;
+ outb(bval, ioport+ScsiFifo);
+ pDCB = pACB->pActiveDCB;
+ bval = pDCB->IdentifyMsg << 5;
+ outb(bval, ioport+ScsiFifo);
+ bval = 0;
+ outb(bval, ioport+ScsiFifo);
+ outb(bval, ioport+ScsiFifo);
+ bval = sizeof(pSRB->pcmd->sense_buffer);
+ outb(bval, ioport+ScsiFifo);
+ bval = 0;
+ outb(bval, ioport+ScsiFifo);
+ }
+ pSRB->SRBState = SRB_COMMAND;
+ bval = INFO_XFER_CMD;
+ outb(bval, ioport+ScsiCmd);
+}
+
+static void
+DC390_StatusPhase( PACB pACB, PSRB pSRB, PUCHAR psstatus)
+{
+ UCHAR bval;
+ USHORT ioport;
+
+ ioport = pACB->IOPortBase;
+ bval = CLEAR_FIFO_CMD;
+ outb(bval, ioport+ScsiCmd);
+ pSRB->SRBState = SRB_STATUS;
+ bval = INITIATOR_CMD_CMPLTE;
+ outb(bval, ioport+ScsiCmd);
+}
+
+static void
+DC390_MsgOutPhase( PACB pACB, PSRB pSRB, PUCHAR psstatus)
+{
+ UCHAR bval;
+ USHORT ioport, i, cnt;
+ PUCHAR ptr;
+ PDCB pDCB;
+
+ ioport = pACB->IOPortBase;
+ bval = CLEAR_FIFO_CMD;
+ outb(bval, ioport+ScsiCmd);
+ pDCB = pACB->pActiveDCB;
+ if( !(pSRB->SRBState & SRB_MSGOUT) )
+ {
+ cnt = pSRB->MsgCnt;
+ if( cnt )
+ {
+ ptr = (PUCHAR) pSRB->MsgOutBuf;
+ for(i=0; i < cnt; i++)
+ {
+ outb(*ptr, ioport+ScsiFifo);
+ ptr++;
+ }
+ pSRB->MsgCnt = 0;
+ if( (pDCB->DCBFlag & ABORT_DEV_) &&
+ (pSRB->MsgOutBuf[0] == MSG_ABORT) )
+ pSRB->SRBState = SRB_ABORT_SENT;
+ }
+ else
+ {
+ bval = MSG_ABORT; /* ??? MSG_NOP */
+ if( (pSRB->CmdBlock[0] == INQUIRY ) ||
+ (pSRB->CmdBlock[0] == REQUEST_SENSE) ||
+ (pSRB->SRBFlag & AUTO_REQSENSE) )
+ {
+ if( pDCB->SyncMode & SYNC_ENABLE )
+ goto mop1;
+ }
+ outb(bval, ioport+ScsiFifo);
+ }
+ bval = INFO_XFER_CMD;
+ outb( bval, ioport+ScsiCmd);
+ }
+ else
+ {
+mop1:
+ bval = MSG_EXTENDED;
+ outb(bval, ioport+ScsiFifo);
+ bval = 3; /* ;length of extended msg */
+ outb(bval, ioport+ScsiFifo);
+ bval = 1; /* ; sync nego */
+ outb(bval, ioport+ScsiFifo);
+ bval = pDCB->NegoPeriod;
+ outb(bval, ioport+ScsiFifo);
+ bval = SYNC_NEGO_OFFSET;
+ outb(bval, ioport+ScsiFifo);
+ pSRB->SRBState |= DO_SYNC_NEGO;
+ bval = INFO_XFER_CMD;
+ outb(bval, ioport+ScsiCmd);
+ }
+}
+
+static void
+DC390_MsgInPhase( PACB pACB, PSRB pSRB, PUCHAR psstatus)
+{
+ UCHAR bval;
+ USHORT ioport;
+
+ ioport = pACB->IOPortBase;
+ bval = CLEAR_FIFO_CMD;
+ outb(bval, ioport+ScsiCmd);
+ if( !(pSRB->SRBState & SRB_MSGIN) )
+ {
+ pSRB->SRBState &= SRB_DISCONNECT;
+ pSRB->SRBState |= SRB_MSGIN;
+ }
+ bval = INFO_XFER_CMD;
+ outb(bval, ioport+ScsiCmd);
+}
+
+static void
+DC390_Nop_0( PACB pACB, PSRB pSRB, PUCHAR psstatus)
+{
+}
+
+static void
+DC390_Nop_1( PACB pACB, PSRB pSRB, PUCHAR psstatus)
+{
+}
+
+
+static void
+SetXferRate( PACB pACB, PDCB pDCB )
+{
+ UCHAR bval;
+ USHORT cnt, i;
+ PDCB ptr;
+
+ if( !(pDCB->IdentifyMsg & 0x07) )
+ {
+ if( pACB->scan_devices )
+ {
+ CurrSyncOffset = pDCB->SyncOffset;
+ }
+ else
+ {
+ ptr = pACB->pLinkDCB;
+ cnt = pACB->DeviceCnt;
+ bval = pDCB->UnitSCSIID;
+ for(i=0; i<cnt; i++)
+ {
+ if( ptr->UnitSCSIID == bval )
+ {
+ ptr->SyncPeriod = pDCB->SyncPeriod;
+ ptr->SyncOffset = pDCB->SyncOffset;
+ ptr->CtrlR3 = pDCB->CtrlR3;
+ ptr->CtrlR4 = pDCB->CtrlR4;
+ ptr->SyncMode = pDCB->SyncMode;
+ }
+ ptr = ptr->pNextDCB;
+ }
+ }
+ }
+ return;
+}
+
+
+static void
+DC390_Disconnect( PACB pACB )
+{
+ PDCB pDCB;
+ PSRB pSRB, psrb;
+ ULONG flags;
+ USHORT ioport, i, cnt;
+ UCHAR bval;
+
+#ifdef DC390_DEBUG0
+ printk("DISC,");
+#endif
+
+ save_flags(flags);
+ cli();
+ ioport = pACB->IOPortBase;
+ pDCB = pACB->pActiveDCB;
+ if (!pDCB)
+ {
+#ifdef DC390_DEBUG0
+ printk("ACB:%08lx->ActiveDCB:%08lx !,",(ULONG)pACB,(ULONG)pDCB);
+#endif
+ restore_flags(flags); return;
+ }
+ pSRB = pDCB->pActiveSRB;
+ pACB->pActiveDCB = 0;
+ pSRB->ScsiPhase = SCSI_NOP0;
+ bval = EN_SEL_RESEL;
+ outb(bval, ioport+ScsiCmd);
+ if( pSRB->SRBState & SRB_UNEXPECT_RESEL )
+ {
+ pSRB->SRBState = 0;
+ DoWaitingSRB( pACB );
+ }
+ else if( pSRB->SRBState & SRB_ABORT_SENT )
+ {
+ pDCB->TagMask = 0;
+ pDCB->DCBFlag = 0;
+ cnt = pDCB->GoingSRBCnt;
+ pDCB->GoingSRBCnt = 0;
+ pSRB = pDCB->pGoingSRB;
+ for( i=0; i < cnt; i++)
+ {
+ psrb = pSRB->pNextSRB;
+ pSRB->pNextSRB = pACB->pFreeSRB;
+ pACB->pFreeSRB = pSRB;
+ pSRB = psrb;
+ }
+ pDCB->pGoingSRB = 0;
+ DoWaitingSRB( pACB );
+ }
+ else
+ {
+ if( (pSRB->SRBState & (SRB_START_+SRB_MSGOUT)) ||
+ !(pSRB->SRBState & (SRB_DISCONNECT+SRB_COMPLETED)) )
+ { /* Selection time out */
+ if( !(pACB->scan_devices) )
+ {
+ pSRB->SRBState = SRB_READY;
+ RewaitSRB( pDCB, pSRB);
+ }
+ else
+ {
+ pSRB->TargetStatus = SCSI_STAT_SEL_TIMEOUT;
+ goto disc1;
+ }
+ }
+ else if( pSRB->SRBState & SRB_DISCONNECT )
+ {
+ DoWaitingSRB( pACB );
+ }
+ else if( pSRB->SRBState & SRB_COMPLETED )
+ {
+disc1:
+ if(pDCB->MaxCommand > 1)
+ {
+ bval = pSRB->TagNumber;
+ pDCB->TagMask &= (~(1 << bval)); /* free tag mask */
+ }
+ pDCB->pActiveSRB = 0;
+ pSRB->SRBState = SRB_FREE;
+ SRBdone( pACB, pDCB, pSRB);
+ }
+ }
+ restore_flags(flags);
+ return;
+}
+
+
+static void
+DC390_Reselect( PACB pACB )
+{
+ PDCB pDCB, pdcb;
+ PSRB pSRB;
+ USHORT ioport, wval;
+ UCHAR bval, bval1;
+
+
+#ifdef DC390_DEBUG0
+ printk("RSEL,");
+#endif
+ ioport = pACB->IOPortBase;
+ pDCB = pACB->pActiveDCB;
+ if( pDCB )
+ { /* Arbitration lost but Reselection win */
+ pSRB = pDCB->pActiveSRB;
+ if( !( pACB->scan_devices ) )
+ {
+ pSRB->SRBState = SRB_READY;
+ RewaitSRB( pDCB, pSRB);
+ }
+ }
+ bval = inb(ioport+ScsiFifo); /* get ID */
+ bval = bval ^ pACB->HostID_Bit;
+ wval = 0;
+ bval1 = 1;
+ for(;;)
+ {
+ if( !(bval & bval1) )
+ {
+ bval1 = bval1 << 1;
+ wval++;
+ }
+ else
+ break;
+ }
+ wval |= ( (USHORT) inb(ioport+ScsiFifo) & 7) << 8; /* get LUN */
+ pDCB = pACB->pLinkDCB;
+ pdcb = pDCB;
+ while( wval != *((PUSHORT) &pDCB->UnitSCSIID) )
+ {
+ pDCB = pDCB->pNextDCB;
+ if( pDCB == pdcb )
+ return;
+ }
+ pACB->pActiveDCB = pDCB;
+ if( pDCB->SyncMode & EN_TAG_QUEUING )
+ {
+ pSRB = pACB->pTmpSRB;
+ pDCB->pActiveSRB = pSRB;
+ }
+ else
+ {
+ pSRB = pDCB->pActiveSRB;
+ if( !pSRB || !(pSRB->SRBState & SRB_DISCONNECT) )
+ {
+ pSRB= pACB->pTmpSRB;
+ pSRB->SRBState = SRB_UNEXPECT_RESEL;
+ pDCB->pActiveSRB = pSRB;
+ EnableMsgOut( pACB, pSRB );
+ }
+ else
+ {
+ if( pDCB->DCBFlag & ABORT_DEV_ )
+ {
+ pSRB->SRBState = SRB_ABORT_SENT;
+ EnableMsgOut( pACB, pSRB );
+ }
+ else
+ pSRB->SRBState = SRB_DATA_XFER;
+ }
+ }
+ pSRB->ScsiPhase = SCSI_NOP0;
+ bval = pDCB->UnitSCSIID;
+ outb( bval, ioport+Scsi_Dest_ID);
+ bval = pDCB->SyncPeriod;
+ outb(bval, ioport+Sync_Period);
+ bval = pDCB->SyncOffset;
+ outb( bval, ioport+Sync_Offset);
+ bval = pDCB->CtrlR1;
+ outb(bval, ioport+CtrlReg1);
+ bval = pDCB->CtrlR3;
+ outb(bval, ioport+CtrlReg3);
+ bval = pDCB->CtrlR4; /* ; Glitch eater */
+ outb(bval, ioport+CtrlReg4);
+ bval = MSG_ACCEPTED_CMD; /* ;to rls the /ACK signal */
+ outb(bval, ioport+ScsiCmd);
+}
+
+
+static void
+SRBdone( PACB pACB, PDCB pDCB, PSRB pSRB )
+{
+ PSRB psrb;
+ UCHAR bval, bval1, i, j, status;
+ PSCSICMD pcmd;
+ PSCSI_INQDATA ptr;
+ USHORT disable_tag;
+ ULONG flags;
+ PSGL ptr2;
+ ULONG swlval;
+
+ pcmd = pSRB->pcmd;
+ status = pSRB->TargetStatus;
+ if(pSRB->SRBFlag & AUTO_REQSENSE)
+ {
+ pSRB->SRBFlag &= ~AUTO_REQSENSE;
+ pSRB->AdaptStatus = 0;
+ pSRB->TargetStatus = SCSI_STAT_CHECKCOND;
+ if(status == SCSI_STAT_CHECKCOND)
+ {
+ pcmd->result = DID_BAD_TARGET << 16;
+ goto ckc_e;
+ }
+ if(pSRB->RetryCnt == 0)
+ {
+ *((PULONG) &(pSRB->CmdBlock[0])) = pSRB->Segment0[0];
+ pSRB->TotalXferredLen = pSRB->Segment1[1];
+ if( (pSRB->TotalXferredLen) &&
+ (pSRB->TotalXferredLen >= pcmd->underflow) )
+ pcmd->result |= (DID_OK << 16);
+ else
+ pcmd->result = (DRIVER_SENSE << 24) | (DRIVER_OK << 16) |
+ SCSI_STAT_CHECKCOND;
+#ifdef DC390_DEBUG0
+ printk("Cmd=%2x,Result=%8x,XferL=%8x,",pSRB->CmdBlock[0],
+ (UINT) pcmd->result, (UINT) pSRB->TotalXferredLen);
+#endif
+ goto ckc_e;
+ }
+ else
+ {
+ pSRB->RetryCnt--;
+ pSRB->AdaptStatus = 0;
+ pSRB->TargetStatus = 0;
+ *((PULONG) &(pSRB->CmdBlock[0])) = pSRB->Segment0[0];
+ *((PULONG) &(pSRB->CmdBlock[4])) = pSRB->Segment0[1];
+ if( pSRB->CmdBlock[0] == TEST_UNIT_READY )
+ {
+ pcmd->result = (DRIVER_SENSE << 24) | (DRIVER_OK << 16) |
+ SCSI_STAT_CHECKCOND;
+ goto ckc_e;
+ }
+ pcmd->result |= (DRIVER_SENSE << 24);
+ pSRB->SGcount = (UCHAR) pSRB->Segment1[0];
+ pSRB->ScsiCmdLen = (UCHAR) (pSRB->Segment1[0] >> 8);
+ pSRB->SGIndex = 0;
+ pSRB->TotalXferredLen = 0;
+ pSRB->SGToBeXferLen = 0;
+ if( pcmd->use_sg )
+ pSRB->pSegmentList = (PSGL) pcmd->request_buffer;
+ else if( pcmd->request_buffer )
+ {
+ pSRB->pSegmentList = (PSGL) &pSRB->Segmentx;
+ pSRB->Segmentx.address = (PUCHAR) pcmd->request_buffer;
+ pSRB->Segmentx.length = pcmd->request_bufflen;
+ }
+ if( DC390_StartSCSI( pACB, pDCB, pSRB ) )
+ RewaitSRB( pDCB, pSRB );
+ return;
+ }
+ }
+ if( status )
+ {
+ if( status == SCSI_STAT_CHECKCOND)
+ {
+ if( (pSRB->SGIndex < pSRB->SGcount) && (pSRB->SGcount) &&
(pSRB->SGToBeXferLen) )
+ {
+ bval = pSRB->SGcount;
+ swlval = 0;
+ ptr2 = pSRB->pSegmentList;
+ for( i=pSRB->SGIndex; i < bval; i++)
+ {
+ swlval += ptr2->length;
+ ptr2++;
+ }
+#ifdef DC390_DEBUG0
+ printk("XferredLen=%8x,NotXferLen=%8x,",
+ (UINT) pSRB->TotalXferredLen, (UINT) swlval);
+#endif
+ }
+ RequestSense( pACB, pDCB, pSRB );
+ return;
+ }
+ else if( status == SCSI_STAT_QUEUEFULL )
+ {
+ bval = (UCHAR) pDCB->GoingSRBCnt;
+ bval--;
+ pDCB->MaxCommand = bval;
+ RewaitSRB( pDCB, pSRB );
+ pSRB->AdaptStatus = 0;
+ pSRB->TargetStatus = 0;
+ return;
+ }
+ else if(status == SCSI_STAT_SEL_TIMEOUT)
+ {
+ pSRB->AdaptStatus = H_SEL_TIMEOUT;
+ pSRB->TargetStatus = 0;
+ pcmd->result = DID_BAD_TARGET << 16;
+ }
+ else
+ {
+ pSRB->AdaptStatus = 0;
+ if( pSRB->RetryCnt )
+ {
+ pSRB->RetryCnt--;
+ pSRB->TargetStatus = 0;
+ pSRB->SGIndex = 0;
+ pSRB->TotalXferredLen = 0;
+ pSRB->SGToBeXferLen = 0;
+ if( pcmd->use_sg )
+ pSRB->pSegmentList = (PSGL) pcmd->request_buffer;
+ else if( pcmd->request_buffer )
+ {
+ pSRB->pSegmentList = (PSGL) &pSRB->Segmentx;
+ pSRB->Segmentx.address = (PUCHAR) pcmd->request_buffer;
+ pSRB->Segmentx.length = pcmd->request_bufflen;
+ }
+ if( DC390_StartSCSI( pACB, pDCB, pSRB ) )
+ RewaitSRB( pDCB, pSRB );
+ return;
+ }
+ else
+ {
+ pcmd->result |= (DID_ERROR << 16) | (ULONG) (pSRB->EndMessage
<< 8) |
+ (ULONG) status;
+ }
+ }
+ }
+ else
+ {
+ status = pSRB->AdaptStatus;
+ if(status & H_OVER_UNDER_RUN)
+ {
+ pSRB->TargetStatus = 0;
+ pcmd->result |= (DID_OK << 16) | (pSRB->EndMessage << 8);
+ }
+ else if( pSRB->SRBStatus & PARITY_ERROR)
+ {
+ pcmd->result |= (DID_PARITY << 16) | (pSRB->EndMessage << 8);
+ }
+ else /* No error */
+ {
+ pSRB->AdaptStatus = 0;
+ pSRB->TargetStatus = 0;
+ pcmd->result |= (DID_OK << 16);
+ }
+ }
+
+ckc_e:
+ if( pACB->scan_devices )
+ {
+ if( pSRB->CmdBlock[0] == TEST_UNIT_READY )
+ {
+ if(pcmd->result != (DID_OK << 16))
+ {
+ if( pcmd->result & SCSI_STAT_CHECKCOND )
+ {
+ goto RTN_OK;
+ }
+ else
+ {
+ pACB->DCBmap[pcmd->target] &= ~(1 << pcmd->lun);
+ pPrevDCB->pNextDCB = pACB->pLinkDCB;
+ if( (pcmd->target == pACB->max_id) &&
+ ((pcmd->lun == 0) || (pcmd->lun == pACB->max_lun)) )
+ {
+ pACB->scan_devices = 0;
+ }
+ }
+ }
+ else
+ {
+RTN_OK:
+ pPrevDCB->pNextDCB = pDCB;
+ pDCB->pNextDCB = pACB->pLinkDCB;
+ if( (pcmd->target == pACB->max_id) && (pcmd->lun ==
pACB->max_lun) )
+ pACB->scan_devices = END_SCAN;
+ }
+ }
+ else if( pSRB->CmdBlock[0] == INQUIRY )
+ {
+ if( (pcmd->target == pACB->max_id) &&
+ (pcmd->lun == pACB->max_lun) )
+ {
+ pACB->scan_devices = 0;
+ }
+ ptr = (PSCSI_INQDATA) (pcmd->request_buffer);
+ if( pcmd->use_sg )
+ ptr = (PSCSI_INQDATA) (((PSGL) ptr)->address);
+ bval1 = ptr->DevType & SCSI_DEVTYPE;
+ if(bval1 == SCSI_NODEV)
+ {
+ pACB->DCBmap[pcmd->target] &= ~(1 << pcmd->lun);
+ pPrevDCB->pNextDCB = pACB->pLinkDCB;
+ }
+ else
+ {
+ pACB->DeviceCnt++;
+ pPrevDCB = pDCB;
+ pACB->pDCB_free = (PDCB) ((ULONG) (pACB->pDCB_free) + sizeof(
DC390_DCB ));
+ pDCB->DevType = bval1;
+ if(bval1 == TYPE_DISK || bval1 == TYPE_MOD)
+ {
+ if( (((ptr->Vers & 0x07) >= 2) || ((ptr->RDF & 0x0F) == 2))
&&
+ (ptr->Flags & SCSI_INQ_CMDQUEUE) &&
+ (pDCB->DevMode & TAG_QUEUING_) &&
+ (pDCB->DevMode & EN_DISCONNECT_) )
+ {
+ disable_tag = 0;
+ for(i=0; i<BADDEVCNT; i++)
+ {
+ for(j=0; j<28; j++)
+ {
+ if( ((PUCHAR)ptr)[8+j] != baddevname1[i][j])
+ break;
+ }
+ if(j == 28)
+ {
+ disable_tag = 1;
+ break;
+ }
+ }
+
+ if( !disable_tag )
+ {
+ pDCB->MaxCommand = pACB->TagMaxNum;
+ pDCB->SyncMode |= EN_TAG_QUEUING;
+ pDCB->TagMask = 0;
+ }
+ else
+ {
+ pDCB->SyncMode |= EN_ATN_STOP;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ save_flags( flags );
+ cli();
+/* ReleaseSRB( pDCB, pSRB ); */
+
+ if(pSRB == pDCB->pGoingSRB )
+ {
+ pDCB->pGoingSRB = pSRB->pNextSRB;
+ }
+ else
+ {
+ psrb = pDCB->pGoingSRB;
+ while( psrb->pNextSRB != pSRB )
+ psrb = psrb->pNextSRB;
+ psrb->pNextSRB = pSRB->pNextSRB;
+ if( pSRB == pDCB->pGoingLast )
+ pDCB->pGoingLast = psrb;
+ }
+ pSRB->pNextSRB = pACB->pFreeSRB;
+ pACB->pFreeSRB = pSRB;
+ pDCB->GoingSRBCnt--;
+
+ DoWaitingSRB( pACB );
+ restore_flags(flags);
+
+/* Notify cmd done */
+ pcmd->scsi_done( pcmd );
+
+ if( pDCB->QIORBCnt )
+ DoNextCmd( pACB, pDCB );
+ return;
+}
+
+
+static void
+DoingSRB_Done( PACB pACB )
+{
+ PDCB pDCB, pdcb;
+ PSRB psrb, psrb2;
+ USHORT cnt, i;
+ PSCSICMD pcmd;
+
+ pDCB = pACB->pLinkDCB;
+ pdcb = pDCB;
+ do
+ {
+ cnt = pdcb->GoingSRBCnt;
+ psrb = pdcb->pGoingSRB;
+ for( i=0; i<cnt; i++)
+ {
+ psrb2 = psrb->pNextSRB;
+ pcmd = psrb->pcmd;
+ pcmd->result = DID_RESET << 16;
+
+/* ReleaseSRB( pDCB, pSRB ); */
+
+ psrb->pNextSRB = pACB->pFreeSRB;
+ pACB->pFreeSRB = psrb;
+
+ pcmd->scsi_done( pcmd );
+ psrb = psrb2;
+ }
+ pdcb->GoingSRBCnt = 0;;
+ pdcb->pGoingSRB = NULL;
+ pdcb->TagMask = 0;
+ pdcb = pdcb->pNextDCB;
+ }
+ while( pdcb != pDCB );
+}
+
+
+static void
+DC390_ResetSCSIBus( PACB pACB )
+{
+ USHORT ioport;
+ UCHAR bval;
+ ULONG flags;
+
+ save_flags(flags);
+ cli();
+ pACB->ACBFlag |= RESET_DEV;
+ ioport = pACB->IOPortBase;
+
+ bval = DMA_IDLE_CMD;
+ outb(bval,ioport+DMA_Cmd);
+
+ bval = RST_SCSI_BUS_CMD;
+ outb(bval,ioport+ScsiCmd);
+
+ restore_flags(flags);
+ return;
+}
+
+
+static void
+DC390_ScsiRstDetect( PACB pACB )
+{
+ ULONG wlval, flags;
+ USHORT ioport;
+ UCHAR bval;
+
+#ifdef DC390_DEBUG0
+ printk("RST_DETEC");
+#endif
+ save_flags(flags);
+ sti();
+ wlval = jiffies + HZ;
+ while( jiffies < wlval ); /* delay 1 sec */
+
+ cli();
+ ioport = pACB->IOPortBase;
+ bval = DMA_IDLE_CMD;
+ outb(bval,ioport+DMA_Cmd);
+ bval = CLEAR_FIFO_CMD;
+ outb(bval,ioport+ScsiCmd);
+
+ if( pACB->ACBFlag & RESET_DEV )
+ pACB->ACBFlag |= RESET_DONE;
+ else
+ {
+ pACB->ACBFlag |= RESET_DETECT;
+
+ ResetDevParam( pACB );
+/* DoingSRB_Done( pACB ); ???? */
+ RecoverSRB( pACB );
+ pACB->pActiveDCB = NULL;
+ pACB->ACBFlag = 0;
+ DoWaitingSRB( pACB );
+ }
+ restore_flags(flags);
+ return;
+}
+
+
+static void
+RequestSense( PACB pACB, PDCB pDCB, PSRB pSRB )
+{
+ PSCSICMD pcmd;
+
+ pSRB->SRBFlag |= AUTO_REQSENSE;
+ pSRB->Segment0[0] = *((PULONG) &(pSRB->CmdBlock[0]));
+ pSRB->Segment0[1] = *((PULONG) &(pSRB->CmdBlock[4]));
+ pSRB->Segment1[0] = (ULONG) ((pSRB->ScsiCmdLen << 8) + pSRB->SGcount);
+ pSRB->Segment1[1] = pSRB->TotalXferredLen;
+ pSRB->AdaptStatus = 0;
+ pSRB->TargetStatus = 0;
+
+ pcmd = pSRB->pcmd;
+
+ pSRB->Segmentx.address = (PUCHAR) &(pcmd->sense_buffer);
+ pSRB->Segmentx.length = sizeof(pcmd->sense_buffer);
+ pSRB->pSegmentList = &pSRB->Segmentx;
+ pSRB->SGcount = 1;
+ pSRB->SGIndex = 0;
+
+ *((PULONG) &(pSRB->CmdBlock[0])) = 0x00000003;
+ pSRB->CmdBlock[1] = pDCB->IdentifyMsg << 5;
+ *((PUSHORT) &(pSRB->CmdBlock[4])) = sizeof(pcmd->sense_buffer);
+ pSRB->ScsiCmdLen = 6;
+
+ pSRB->TotalXferredLen = 0;
+ pSRB->SGToBeXferLen = 0;
+ if( DC390_StartSCSI( pACB, pDCB, pSRB ) )
+ RewaitSRB( pDCB, pSRB );
+}
+
+
+static void
+EnableMsgOut2( PACB pACB, PSRB pSRB )
+{
+ USHORT ioport;
+ UCHAR bval;
+
+ ioport = pACB->IOPortBase;
+ pSRB->MsgCnt = 1;
+ bval = SET_ATN_CMD;
+ outb(bval, ioport+ScsiCmd);
+}
+
+
+static void
+EnableMsgOut( PACB pACB, PSRB pSRB )
+{
+ pSRB->MsgOutBuf[0] = MSG_ABORT;
+ EnableMsgOut2( pACB, pSRB );
+}
+
+
+static void
+DC390_InvalidCmd( PACB pACB )
+{
+ UCHAR bval;
+ USHORT ioport;
+ PSRB pSRB;
+
+ pSRB = pACB->pActiveDCB->pActiveSRB;
+ if( pSRB->SRBState & (SRB_START_+SRB_MSGOUT) )
+ {
+ ioport = pACB->IOPortBase;
+ bval = CLEAR_FIFO_CMD;
+ outb(bval,(ioport+ScsiCmd));
+ }
+}
+
diff --git a/linux/src/drivers/scsi/t128.c b/linux/src/drivers/scsi/t128.c
index d4c7452..198e910 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++;
diff --git a/util/atoi.c b/util/atoi.c
index 64816b9..e56f50d 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 921b1e8..47adb42 100644
--- a/util/atoi.h
+++ b/util/atoi.h
@@ -62,6 +62,6 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <sys/types.h>
#define MACH_ATOI_DEFAULT -1
-extern int mach_atoi (u_char *, int *);
+extern int mach_atoi (const u_char *, int *);
#endif /* _UTIL_ATOI_H_ */
diff --git a/version.m4 b/version.m4
index 4e1a2fd..941e436 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.4+git20141107])
m4_define([AC_PACKAGE_BUGREPORT],address@hidden)
m4_define([AC_PACKAGE_TARNAME],[gnumach])
diff --git a/vm/memory_object.c b/vm/memory_object.c
index e281c6a..097ed23 100644
--- a/vm/memory_object.c
+++ b/vm/memory_object.c
@@ -82,24 +82,19 @@ 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)
- register
- vm_object_t object;
- register
- 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;
- register
vm_page_t m;
- register
vm_page_t data_m;
vm_size_t original_length;
vm_offset_t original_offset;
@@ -307,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);
@@ -337,16 +329,11 @@ 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;
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) {
@@ -370,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;
@@ -406,7 +393,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
@@ -453,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
@@ -656,19 +642,17 @@ 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)
- register vm_object_t object;
- register vm_offset_t offset;
- register 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)
{
- 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;
@@ -720,8 +704,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); \
\
@@ -892,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);
@@ -959,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;
@@ -995,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);
@@ -1041,7 +1022,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;
@@ -1123,7 +1104,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 4fed312..a64bfcc 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 f4be0d0..dc0ea74 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 <ipc/ipc_types.h>
#include <mach/boolean.h>
@@ -30,19 +30,8 @@
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,
- 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,
- 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);
-#endif /* _VM_MEMORY_OBJECT_PROXT_H_ */
+#endif /* _VM_MEMORY_OBJECT_PROXY_H_ */
diff --git a/vm/pmap.h b/vm/pmap.h
index 59fd03a..134f9c6 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
*/
@@ -205,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_debug.c b/vm/vm_debug.c
index 0af58b6..227090e 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;
@@ -404,7 +403,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,
@@ -434,7 +433,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 e9643ff..2e2593b 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;
@@ -97,8 +95,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;
@@ -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 7e84961..686156c 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;
@@ -125,9 +123,9 @@ void vm_fault_init(void)
* "object" must be locked.
*/
void
-vm_fault_cleanup(object, top_page)
- register vm_object_t object;
- register 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);
@@ -204,33 +202,26 @@ 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. */
{
- 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;
@@ -239,7 +230,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)
@@ -357,7 +348,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;
/*
@@ -1094,7 +1085,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,9 +1132,9 @@ vm_fault_return_t vm_fault_page(first_object,
first_offset,
*/
void
-vm_fault_continue()
+vm_fault_continue(void)
{
- 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,
@@ -1154,14 +1145,13 @@ vm_fault_continue()
/*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? */
@@ -1173,11 +1163,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;
/*
@@ -1253,7 +1242,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;
/*
@@ -1307,7 +1296,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;
/*
@@ -1490,7 +1479,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);
@@ -1501,21 +1490,19 @@ kern_return_t vm_fault(map, vaddr, fault_type,
change_wiring,
return(kr);
}
-kern_return_t vm_fault_wire_fast();
-
/*
* vm_fault_wire:
*
* 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)
{
- 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);
@@ -1544,14 +1531,14 @@ 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)
{
- 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);
@@ -1633,14 +1620,14 @@ 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;
- register vm_page_t m;
+ vm_page_t m;
vm_prot_t prot;
vm_stat.faults++; /* needs lock XXX */
@@ -1782,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;
@@ -1825,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;
@@ -2022,13 +2000,11 @@ 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)
- register
- 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 */
{
- register
vm_page_t dst_page;
#define interruptible FALSE /* XXX */
diff --git a/vm/vm_fault.h b/vm/vm_fault.h
index 0492ccf..7fdbc41 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_ */
diff --git a/vm/vm_init.c b/vm/vm_init.c
index 89eb098..3d1081c 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/include/mach/gnumach.defs b/vm/vm_init.h
similarity index 58%
copy from include/mach/gnumach.defs
copy to vm/vm_init.h
index 7331334..42ef48b 100644
--- a/include/mach/gnumach.defs
+++ b/vm/vm_init.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 Free Software Foundation
+ * 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
@@ -16,24 +16,10 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-subsystem
-#if KERNEL_SERVER
- KernelServer
-#endif /* KERNEL_SERVER */
-#if KERNEL_USER
- KernelUser
-#endif /* KERNEL_USER */
- gnumach 4200;
+#ifndef _VM_VM_INIT_H_
+#define _VM_VM_INIT_H_
-#include <mach/std_types.defs>
-#include <mach/mach_types.defs>
+extern void vm_mem_init(void);
+extern void vm_mem_bootstrap(void);
-type vm_cache_statistics_data_t = struct[11] of integer_t;
-
-/*
- * Return page cache statistics for the host on which the target task
- * resides.
- */
-routine vm_cache_statistics(
- target_task : vm_task_t;
- out vm_cache_stats : vm_cache_statistics_data_t);
+#endif /* _VM_VM_INIT_H_ */
diff --git a/vm/vm_kern.c b/vm/vm_kern.c
index fd46e98..b997cb5 100644
--- a/vm/vm_kern.c
+++ b/vm/vm_kern.c
@@ -42,6 +42,7 @@
#include <kern/assert.h>
#include <kern/debug.h>
#include <kern/lock.h>
+#include <kern/slab.h>
#include <kern/thread.h>
#include <kern/printf.h>
#include <vm/pmap.h>
@@ -62,9 +63,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
*
@@ -82,15 +80,14 @@ extern void kmem_remap_pages();
*/
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;
@@ -180,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;
@@ -253,15 +250,18 @@ 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;
+ 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) {
@@ -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,14 +359,15 @@ 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;
vm_offset_t addr;
+ unsigned int attempts;
kern_return_t kr;
/*
@@ -385,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;
}
@@ -429,17 +440,18 @@ kmem_alloc(map, addrp, size)
* 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;
vm_object_t object;
vm_map_entry_t oldentry, newentry;
+ unsigned int attempts;
kern_return_t kr;
oldmin = trunc_page(oldaddr);
@@ -451,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;
}
@@ -519,14 +541,15 @@ kern_return_t kmem_realloc(map, oldaddr, oldsize,
newaddrp, newsize)
*/
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;
vm_offset_t addr;
+ unsigned int attempts;
kern_return_t kr;
/*
@@ -537,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;
}
@@ -591,14 +624,15 @@ kmem_alloc_wired(map, addrp, size)
*/
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;
vm_offset_t addr;
+ unsigned int attempts;
kern_return_t kr;
if ((size & (size - 1)) != 0)
@@ -612,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;
}
@@ -665,10 +709,10 @@ kmem_alloc_aligned(map, addrp, size)
*/
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;
@@ -696,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;
@@ -714,11 +758,12 @@ kmem_free(map, addr, size)
* a submap.
*/
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;
+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.
@@ -726,7 +771,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);
@@ -769,11 +814,12 @@ kmem_alloc_pages(object, offset, start, end, protection)
* a submap.
*/
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;
+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.
@@ -781,7 +827,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);
@@ -827,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;
@@ -845,7 +893,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,
@@ -869,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);
@@ -907,21 +955,19 @@ 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;
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);
@@ -1013,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.
@@ -1035,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 */
@@ -1061,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_kern.h b/vm/vm_kern.h
index 22b7c12..0869217 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_ */
diff --git a/vm/vm_map.c b/vm/vm_map.c
index 2be7147..6b13724 100644
--- a/vm/vm_map.c
+++ b/vm/vm_map.c
@@ -58,20 +58,6 @@
#include <vm/vm_print.h>
#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
@@ -210,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);
@@ -243,12 +228,13 @@ 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)
{
- 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 +258,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;
+ const 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 +287,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;
+ const 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;
@@ -386,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)
- register vm_map_t map;
+void vm_map_reference(vm_map_t map)
{
if (map == VM_MAP_NULL)
return;
@@ -404,10 +389,9 @@ void vm_map_reference(map)
* destroying it if no references remain.
* The map should not be locked.
*/
-void vm_map_deallocate(map)
- register vm_map_t map;
+void vm_map_deallocate(vm_map_t map)
{
- register int c;
+ int c;
if (map == VM_MAP_NULL)
return;
@@ -449,13 +433,13 @@ 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)
- register vm_map_t map;
- register 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 */
{
- 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
@@ -506,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;
@@ -533,17 +518,17 @@ 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)
- register 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 */
{
- 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 +547,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.
@@ -687,8 +672,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
@@ -705,19 +690,16 @@ int 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;
- register
- vm_offset_t addr;
- register
- vm_offset_t end_addr;
- register
- 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) {
- register vm_page_t m;
+ vm_page_t m;
vm_object_lock(object);
vm_object_paging_begin(object);
@@ -766,27 +748,22 @@ 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)
- register
- 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)
{
- 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 +809,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 +957,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);
@@ -1051,14 +1028,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) \
@@ -1069,12 +1044,12 @@ void _vm_map_copy_clip_start();
* This routine is called only when it is known that
* 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;
+void _vm_map_clip_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 --
@@ -1106,14 +1081,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) \
@@ -1124,12 +1097,12 @@ void _vm_map_copy_clip_end();
* This routine is called only when it is known that
* 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;
+void _vm_map_clip_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
@@ -1184,15 +1157,15 @@ 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)
- register vm_map_t map;
- register vm_offset_t start;
- register 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;
- 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);
@@ -1232,15 +1205,15 @@ 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)
- 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;
+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)
{
- 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);
@@ -1320,13 +1293,13 @@ 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)
- register vm_map_t map;
- register vm_offset_t start;
- register vm_offset_t end;
- register 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)
{
- register vm_map_entry_t entry;
+ vm_map_entry_t entry;
vm_map_entry_t temp_entry;
vm_map_lock(map);
@@ -1369,14 +1342,14 @@ 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)
- 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;
+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)
{
- register vm_map_entry_t entry;
+ vm_map_entry_t entry;
vm_map_entry_t start_entry;
vm_map_lock(map);
@@ -1618,12 +1591,12 @@ 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;
+void vm_map_entry_delete(
+ 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;
@@ -1702,10 +1675,10 @@ void vm_map_entry_delete(map, entry)
* map.
*/
-kern_return_t vm_map_delete(map, start, end)
- register vm_map_t map;
- register vm_offset_t start;
- register 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;
@@ -1785,12 +1758,12 @@ 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)
- register vm_map_t map;
- register vm_offset_t start;
- register vm_offset_t end;
+kern_return_t vm_map_remove(
+ 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);
@@ -1808,12 +1781,11 @@ 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)
{
- 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++) {
@@ -1855,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;
@@ -1901,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)
@@ -1943,7 +1913,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);
@@ -1978,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;
@@ -2025,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)
@@ -2082,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;
@@ -2459,19 +2428,16 @@ 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)
- register
- vm_map_t dst_map;
- vm_offset_t *dst_addr; /* OUT */
- register
- 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;
vm_offset_t start;
vm_offset_t vm_copy_start;
vm_map_entry_t last;
- register
vm_map_entry_t entry;
/*
@@ -2617,9 +2583,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 +2597,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.
@@ -2716,19 +2682,16 @@ 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)
- register
- vm_map_t dst_map;
- vm_offset_t *dst_addr; /* OUT */
- register
- 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;
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;
@@ -3106,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
@@ -3125,7 +3088,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 +3154,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 +3168,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? */
@@ -3472,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 */
@@ -3517,12 +3476,12 @@ 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 */
- 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.
@@ -3573,27 +3532,23 @@ 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;
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 +3882,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;
@@ -4104,18 +4059,14 @@ 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;
- 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);
@@ -4378,21 +4329,20 @@ 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 */
- register vm_offset_t vaddr;
- register 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 */
{
- 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: ;
@@ -4560,11 +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)
- register
- vm_map_t map;
- register
- vm_map_version_t *version; /* REF */
+boolean_t vm_map_verify(
+ vm_map_t map,
+ vm_map_version_t *version) /* REF */
{
boolean_t result;
@@ -4593,24 +4541,19 @@ 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;
- register
vm_map_entry_t entry;
- register
vm_offset_t tmp_offset;
vm_offset_t start;
@@ -4667,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;
@@ -4728,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;
@@ -4758,10 +4701,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;
+void vm_map_print(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));
@@ -4827,7 +4769,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;
@@ -4887,6 +4829,6 @@ void vm_map_copy_print(copy)
break;
}
- indent -=2;
+ indent -= 2;
}
#endif /* MACH_KDB */
diff --git a/vm/vm_map.h b/vm/vm_map.h
index 5fdac4e..b8103eb 100644
--- a/vm/vm_map.h
+++ b/vm/vm_map.h
@@ -55,7 +55,7 @@
#include <kern/macro_help.h>
/* TODO: make it dynamic */
-#define KENTRY_DATA_SIZE (64*PAGE_SIZE)
+#define KENTRY_DATA_SIZE (256*PAGE_SIZE)
/*
* Types defined:
@@ -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 */
};
@@ -437,6 +440,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
*/
@@ -538,6 +558,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_ */
diff --git a/vm/vm_object.c b/vm/vm_object.c
index 18a909f..582487e 100644
--- a/vm/vm_object.c
+++ b/vm/vm_object.c
@@ -59,14 +59,6 @@
#include <ddb/db_output.h>
#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
@@ -233,7 +225,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 +237,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 +345,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 +368,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;
@@ -530,8 +522,6 @@ void vm_object_deallocate(
}
}
-boolean_t vm_object_terminate_remove_all = FALSE;
-
/*
* Routine: vm_object_terminate
* Purpose:
@@ -546,10 +536,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 +742,6 @@ void memory_object_release(
void vm_object_abort_activity(
vm_object_t object)
{
- register
vm_page_t p;
vm_page_t next;
@@ -806,17 +795,12 @@ 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)
{
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;
@@ -892,9 +876,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();
@@ -931,8 +915,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,
@@ -954,8 +938,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;
@@ -986,7 +970,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) {
@@ -1023,11 +1007,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;
@@ -1073,7 +1057,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,
@@ -1127,7 +1110,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);
@@ -1247,8 +1229,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 */
@@ -1257,10 +1237,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;
@@ -1623,7 +1599,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,
@@ -1736,8 +1711,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;
@@ -2009,7 +1984,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;
@@ -2227,7 +2201,6 @@ restart:
* daemon will be using this routine.
*/
void vm_object_pager_create(
- register
vm_object_t object)
{
ipc_port_t pager;
@@ -2372,14 +2345,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;
@@ -2749,11 +2722,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.
@@ -2814,7 +2787,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,
@@ -2823,10 +2796,6 @@ boolean_t vm_object_coalesce(
{
vm_size_t newsize;
-#ifdef lint
- next_offset++;
-#endif /* lint */
-
if (next_object != VM_OBJECT_NULL) {
return FALSE;
}
@@ -2980,9 +2949,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;
diff --git a/vm/vm_object.h b/vm/vm_object.h
index adeff65..5c42f56 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
*/
diff --git a/vm/vm_page.h b/vm/vm_page.h
index 4536d1c..4fe1b41 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) */
@@ -92,14 +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) */
-#ifdef ns32000
- int pad; /* extra space for ns32000 bit ops */
-#endif /* ns32000 */
-
- 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) */
@@ -112,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) */
@@ -156,11 +149,6 @@ 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
int vm_page_fictitious_count;/* How many fictitious pages are free? */
@@ -247,8 +235,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,
diff --git a/vm/vm_pageout.c b/vm/vm_pageout.c
index 661675f..ecedb57 100644
--- a/vm/vm_pageout.c
+++ b/vm/vm_pageout.c
@@ -52,7 +52,6 @@
#include <vm/vm_page.h>
#include <vm/vm_pageout.h>
#include <machine/locore.h>
-#include <machine/vm_tuning.h>
@@ -98,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 */
/*
@@ -107,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,
@@ -133,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 */
/*
@@ -145,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 */
/*
@@ -157,12 +156,9 @@
*/
#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 */
-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;
@@ -230,16 +226,16 @@ 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)
- register vm_page_t m;
- vm_offset_t paging_offset;
- register 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)
{
- 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);
@@ -417,15 +413,15 @@ 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)
- register 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;
- 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;
@@ -511,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;
@@ -559,8 +555,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 +574,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);
@@ -857,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.
@@ -888,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.
@@ -910,12 +906,13 @@ void vm_pageout_continue()
}
}
-void vm_pageout()
+void vm_pageout(void)
{
int free_after_reserve;
current_thread()->vm_privilege = TRUE;
stack_privilege(current_thread());
+ thread_set_own_priority(0);
/*
* Initialize some paging parameters.
diff --git a/vm/vm_pageout.h b/vm/vm_pageout.h
index d41ee30..ea6cfaf 100644
--- a/vm/vm_pageout.h
+++ b/vm/vm_pageout.h
@@ -44,4 +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) __attribute__((noreturn));
+
+extern void vm_pageout_continue(void) __attribute__((noreturn));
+
+extern void vm_pageout_scan_continue(void) __attribute__((noreturn));
+
#endif /* _VM_VM_PAGEOUT_H_ */
diff --git a/include/mach/gnumach.defs b/vm/vm_print.h
similarity index 58%
copy from include/mach/gnumach.defs
copy to vm/vm_print.h
index 7331334..eab534e 100644
--- a/include/mach/gnumach.defs
+++ b/vm/vm_print.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 Free Software Foundation
+ * 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
@@ -16,24 +16,25 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-subsystem
-#if KERNEL_SERVER
- KernelServer
-#endif /* KERNEL_SERVER */
-#if KERNEL_USER
- KernelUser
-#endif /* KERNEL_USER */
- gnumach 4200;
+#ifndef VM_PRINT_H
+#define VM_PRINT_H
-#include <mach/std_types.defs>
-#include <mach/mach_types.defs>
+#include <vm/vm_map.h>
+#include <machine/db_machdep.h>
-type vm_cache_statistics_data_t = struct[11] of integer_t;
+/* 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(const vm_map_copy_t);
+
+#include <vm/vm_object.h>
+
+extern void vm_object_print(vm_object_t);
+
+#include <vm/vm_page.h>
+
+extern void vm_page_print(const vm_page_t);
+
+#endif /* VM_PRINT_H */
-/*
- * Return page cache statistics for the host on which the target task
- * resides.
- */
-routine vm_cache_statistics(
- target_task : vm_task_t;
- out vm_cache_stats : vm_cache_statistics_data_t);
diff --git a/vm/vm_resident.c b/vm/vm_resident.c
index 7906b58..fa02cbc 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.
@@ -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);
@@ -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)
@@ -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);
@@ -1505,10 +1505,10 @@ 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", (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);
}
diff --git a/vm/vm_resident.h b/vm/vm_resident.h
index 67f1807..e8bf681 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_ */
diff --git a/vm/vm_user.c b/vm/vm_user.c
index 6fe398e..1d8f37b 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)
- register vm_map_t map;
- register vm_offset_t *addr;
- register 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)
- register 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)
- register 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)
- register 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,15 +217,13 @@ 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 */
{
- extern kern_return_t vm_map_machine_attribute();
-
if (map == VM_MAP_NULL)
return(KERN_INVALID_ARGUMENT);
@@ -237,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;
@@ -261,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;
@@ -274,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;
@@ -306,26 +304,19 @@ 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)
{
- register
vm_object_t object;
- register
kern_return_t result;
if ((target_map == VM_MAP_NULL) ||
@@ -345,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)) {
@@ -415,8 +409,8 @@ 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;
- register vm_map_t map;
+ const host_t host;
+ vm_map_t map;
vm_offset_t start;
vm_size_t size;
vm_prot_t access;
diff --git a/xen/block.c b/xen/block.c
index 3e4ce7c..d98b31e 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. */
@@ -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/console.c b/xen/console.c
index 884376f..313b934 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) {
diff --git a/xen/console.h b/xen/console.h
index ad171a4..061ba28 100644
--- a/xen/console.h
+++ b/xen/console.h
@@ -21,7 +21,9 @@
#include <machine/xen.h>
#include <string.h>
+#include <mach/port.h>
#include <device/cons.h>
+#include <device/io_req.h>
#define hyp_console_write(str, len) hyp_console_io (CONSOLEIO_write, (len),
kvtolin(str))
@@ -37,4 +39,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 */
diff --git a/xen/grant.c b/xen/grant.c
index 3d5c3fe..ae3a7bf 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;
diff --git a/xen/net.c b/xen/net.c
index fb26471..5564365 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
diff --git a/xen/time.c b/xen/time.c
index a11e7eb..4ebe91f 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) {
@@ -107,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)
--
Alioth's /usr/local/bin/git-commit-notice on
/srv/git.debian.org/git/pkg-hurd/gnumach.git