From d7e50217d7adf6e52786a38bcaa4cd698cb9a79e Mon Sep 17 00:00:00 2001
From: Apple <opensource@apple.com>
Date: Thu, 18 Sep 2003 00:00:31 +0000
Subject: [PATCH] xnu-344.21.73.tar.gz

---
 APPLE_LICENSE                                 |  513 +-
 EXTERNAL_HEADERS/ar.h                         |   23 +-
 EXTERNAL_HEADERS/architecture/byte_order.h    |   23 +-
 EXTERNAL_HEADERS/architecture/i386/asm_help.h |   23 +-
 .../architecture/i386/byte_order.h            |   23 +-
 EXTERNAL_HEADERS/architecture/i386/cpu.h      |   23 +-
 EXTERNAL_HEADERS/architecture/i386/desc.h     |   23 +-
 EXTERNAL_HEADERS/architecture/i386/fpu.h      |   23 +-
 EXTERNAL_HEADERS/architecture/i386/frame.h    |   23 +-
 EXTERNAL_HEADERS/architecture/i386/io.h       |   23 +-
 EXTERNAL_HEADERS/architecture/i386/reg_help.h |   23 +-
 EXTERNAL_HEADERS/architecture/i386/sel.h      |   23 +-
 EXTERNAL_HEADERS/architecture/i386/table.h    |   23 +-
 EXTERNAL_HEADERS/architecture/i386/tss.h      |   23 +-
 EXTERNAL_HEADERS/architecture/ppc/asm_help.h  |   23 +-
 .../architecture/ppc/basic_regs.h             |   23 +-
 .../architecture/ppc/byte_order.h             |   23 +-
 EXTERNAL_HEADERS/architecture/ppc/cframe.h    |   23 +-
 EXTERNAL_HEADERS/architecture/ppc/fp_regs.h   |   23 +-
 .../architecture/ppc/macro_help.h             |   23 +-
 .../architecture/ppc/pseudo_inst.h            |   23 +-
 EXTERNAL_HEADERS/architecture/ppc/reg_help.h  |   23 +-
 EXTERNAL_HEADERS/bsd/i386/ansi.h              |   23 +-
 EXTERNAL_HEADERS/bsd/i386/limits.h            |   23 +-
 EXTERNAL_HEADERS/bsd/ppc/ansi.h               |   23 +-
 EXTERNAL_HEADERS/bsd/ppc/limits.h             |   23 +-
 EXTERNAL_HEADERS/mach-o/fat.h                 |   23 +-
 EXTERNAL_HEADERS/mach-o/kld.h                 |   23 +-
 EXTERNAL_HEADERS/mach-o/loader.h              |   23 +-
 EXTERNAL_HEADERS/mach-o/nlist.h               |   23 +-
 EXTERNAL_HEADERS/mach-o/reloc.h               |   23 +-
 EXTERNAL_HEADERS/machine/limits.h             |   23 +-
 EXTERNAL_HEADERS/stdarg.h                     |   23 +-
 Makefile                                      |    3 +-
 bsd/conf/MASTER                               |    4 +
 bsd/conf/files                                |    3 +
 bsd/conf/param.c                              |   23 +-
 bsd/conf/version.minor                        |    2 +-
 bsd/conf/version.variant                      |    1 +
 bsd/dev/busvar.h                              |   23 +-
 bsd/dev/disk.h                                |   23 +-
 bsd/dev/disk_label.h                          |   23 +-
 bsd/dev/i386/conf.c                           |   23 +-
 bsd/dev/i386/cons.c                           |   23 +-
 bsd/dev/i386/cons.h                           |   23 +-
 bsd/dev/i386/kern_machdep.c                   |   23 +-
 bsd/dev/i386/km.c                             |   23 +-
 bsd/dev/i386/lock_stubs.c                     |   23 +-
 bsd/dev/i386/mem.c                            |   23 +-
 bsd/dev/i386/memmove.c                        |   23 +-
 bsd/dev/i386/pci_device.h                     |   23 +-
 bsd/dev/i386/pio.h                            |   25 +-
 bsd/dev/i386/sel.h                            |   23 +-
 bsd/dev/i386/sel_inline.h                     |   23 +-
 bsd/dev/i386/stubs.c                          |   23 +-
 bsd/dev/i386/table_inline.h                   |   23 +-
 bsd/dev/i386/unix_signal.c                    |   29 +-
 bsd/dev/i386/unix_startup.c                   |   23 +-
 bsd/dev/kmreg_com.h                           |   23 +-
 bsd/dev/ldd.h                                 |   23 +-
 bsd/dev/memdev.c                              |  575 ++
 bsd/dev/memdev.h                              |   17 +
 bsd/dev/ppc/conf.c                            |   23 +-
 bsd/dev/ppc/cons.c                            |   23 +-
 bsd/dev/ppc/cons.h                            |   23 +-
 bsd/dev/ppc/ffs.c                             |   23 +-
 bsd/dev/ppc/ffs.s                             |   23 +-
 bsd/dev/ppc/kern_machdep.c                    |   67 +-
 bsd/dev/ppc/km.c                              |   23 +-
 bsd/dev/ppc/machdep.c                         |   23 +-
 bsd/dev/ppc/mem.c                             |   58 +-
 bsd/dev/ppc/memmove.c                         |   23 +-
 bsd/dev/ppc/nvram.c                           |   23 +-
 bsd/dev/ppc/ppc_init.c                        |   23 +-
 bsd/dev/ppc/stubs.c                           |   55 +-
 bsd/dev/ppc/systemcalls.c                     |   70 +-
 bsd/dev/ppc/unix_signal.c                     |  415 +-
 bsd/dev/ppc/unix_startup.c                    |   31 +-
 bsd/dev/ppc/xsumas.s                          |   23 +-
 .../include/WindowsTypesForMac.h              |   23 +-
 bsd/dev/random/YarrowCoreLib/include/yarrow.h |   23 +-
 .../YarrowCoreLib/include/yarrowUtils.h       |   23 +-
 bsd/dev/random/YarrowCoreLib/port/smf.c       |   23 +-
 .../random/YarrowCoreLib/src/assertverify.h   |   23 +-
 bsd/dev/random/YarrowCoreLib/src/comp.c       |   23 +-
 bsd/dev/random/YarrowCoreLib/src/comp.h       |   23 +-
 .../random/YarrowCoreLib/src/entropysources.h |   23 +-
 bsd/dev/random/YarrowCoreLib/src/macOnly.h    |   23 +-
 bsd/dev/random/YarrowCoreLib/src/prng.c       |   23 +-
 bsd/dev/random/YarrowCoreLib/src/prng.h       |   23 +-
 bsd/dev/random/YarrowCoreLib/src/prngpriv.h   |   23 +-
 bsd/dev/random/YarrowCoreLib/src/sha1mod.c    |   23 +-
 bsd/dev/random/YarrowCoreLib/src/sha1mod.h    |   23 +-
 bsd/dev/random/YarrowCoreLib/src/smf.h        |   23 +-
 .../random/YarrowCoreLib/src/userdefines.h    |   23 +-
 .../random/YarrowCoreLib/src/yarrowUtils.c    |   23 +-
 bsd/dev/random/randomdev.c                    |   23 +-
 bsd/dev/random/randomdev.h                    |   23 +-
 bsd/dev/vn/shadow.c                           |   23 +-
 bsd/dev/vn/shadow.h                           |   23 +-
 bsd/hfs/MacOSStubs.c                          |   23 +-
 bsd/hfs/hfs.h                                 |   26 +-
 bsd/hfs/hfs_attrlist.c                        |   23 +-
 bsd/hfs/hfs_attrlist.h                        |   23 +-
 bsd/hfs/hfs_btreeio.c                         |   23 +-
 bsd/hfs/hfs_catalog.c                         |   23 +-
 bsd/hfs/hfs_catalog.h                         |   23 +-
 bsd/hfs/hfs_chash.c                           |   25 +-
 bsd/hfs/hfs_cnode.c                           |   43 +-
 bsd/hfs/hfs_cnode.h                           |   23 +-
 bsd/hfs/hfs_dbg.h                             |   23 +-
 bsd/hfs/hfs_encodinghint.c                    |   23 +-
 bsd/hfs/hfs_encodings.c                       |   23 +-
 bsd/hfs/hfs_encodings.h                       |   23 +-
 bsd/hfs/hfs_endian.c                          |   23 +-
 bsd/hfs/hfs_endian.h                          |   23 +-
 bsd/hfs/hfs_format.h                          |   23 +-
 bsd/hfs/hfs_link.c                            |   27 +-
 bsd/hfs/hfs_lockf.c                           |   23 +-
 bsd/hfs/hfs_lockf.h                           |   23 +-
 bsd/hfs/hfs_lookup.c                          |   23 +-
 bsd/hfs/hfs_macos_defs.h                      |   23 +-
 bsd/hfs/hfs_mount.h                           |   23 +-
 bsd/hfs/hfs_quota.c                           |  124 +-
 bsd/hfs/hfs_quota.h                           |   23 +-
 bsd/hfs/hfs_readwrite.c                       |   40 +-
 bsd/hfs/hfs_search.c                          |   23 +-
 bsd/hfs/hfs_vfsops.c                          |   40 +-
 bsd/hfs/hfs_vfsutils.c                        |   56 +-
 bsd/hfs/hfs_vnops.c                           |  647 +-
 bsd/hfs/hfscommon/BTree/BTree.c               |   23 +-
 bsd/hfs/hfscommon/BTree/BTreeAllocate.c       |   23 +-
 bsd/hfs/hfscommon/BTree/BTreeMiscOps.c        |   23 +-
 bsd/hfs/hfscommon/BTree/BTreeNodeOps.c        |   23 +-
 bsd/hfs/hfscommon/BTree/BTreeScanner.c        |   23 +-
 bsd/hfs/hfscommon/BTree/BTreeTreeOps.c        |   23 +-
 bsd/hfs/hfscommon/Catalog/Catalog.c           |   23 +-
 bsd/hfs/hfscommon/Catalog/CatalogIterators.c  |   23 +-
 bsd/hfs/hfscommon/Catalog/CatalogUtilities.c  |   23 +-
 bsd/hfs/hfscommon/Catalog/FileIDsServices.c   |   23 +-
 bsd/hfs/hfscommon/Misc/BTreeWrapper.c         |   23 +-
 bsd/hfs/hfscommon/Misc/FileExtentMapping.c    |   23 +-
 bsd/hfs/hfscommon/Misc/VolumeAllocation.c     |   23 +-
 .../hfscommon/Unicode/UCStringCompareData.h   |   23 +-
 bsd/hfs/hfscommon/Unicode/UnicodeWrappers.c   |   23 +-
 bsd/hfs/hfscommon/headers/BTreeScanner.h      |   23 +-
 bsd/hfs/hfscommon/headers/BTreesInternal.h    |   23 +-
 bsd/hfs/hfscommon/headers/BTreesPrivate.h     |   23 +-
 bsd/hfs/hfscommon/headers/CatalogPrivate.h    |   23 +-
 bsd/hfs/hfscommon/headers/FileMgrInternal.h   |   23 +-
 .../hfscommon/headers/HFSUnicodeWrappers.h    |   23 +-
 bsd/hfs/rangelist.c                           |   23 +-
 bsd/hfs/rangelist.h                           |   23 +-
 bsd/i386/cpu.h                                |   23 +-
 bsd/i386/disklabel.h                          |   23 +-
 bsd/i386/endian.h                             |   23 +-
 bsd/i386/exec.h                               |   23 +-
 bsd/i386/label_t.h                            |   23 +-
 bsd/i386/param.h                              |   23 +-
 bsd/i386/profile.h                            |   23 +-
 bsd/i386/psl.h                                |   23 +-
 bsd/i386/ptrace.h                             |   23 +-
 bsd/i386/reboot.h                             |   23 +-
 bsd/i386/reg.h                                |   23 +-
 bsd/i386/setjmp.h                             |   23 +-
 bsd/i386/signal.h                             |   23 +-
 bsd/i386/spl.h                                |   23 +-
 bsd/i386/table.h                              |   23 +-
 bsd/i386/types.h                              |   23 +-
 bsd/i386/ucontext.h                           |   30 +-
 bsd/i386/user.h                               |   23 +-
 bsd/i386/vmparam.h                            |   23 +-
 bsd/if/ppc/if_en.c                            |   23 +-
 bsd/if/ppc/if_en.h                            |   23 +-
 bsd/if/ppc/mace.c                             |   23 +-
 bsd/if/ppc/mace.h                             |   23 +-
 bsd/isofs/cd9660/cd9660_bmap.c                |   23 +-
 bsd/isofs/cd9660/cd9660_lookup.c              |   23 +-
 bsd/isofs/cd9660/cd9660_mount.h               |   23 +-
 bsd/isofs/cd9660/cd9660_node.c                |   23 +-
 bsd/isofs/cd9660/cd9660_node.h                |   23 +-
 bsd/isofs/cd9660/cd9660_rrip.c                |   23 +-
 bsd/isofs/cd9660/cd9660_rrip.h                |   23 +-
 bsd/isofs/cd9660/cd9660_util.c                |   23 +-
 bsd/isofs/cd9660/cd9660_vfsops.c              |   23 +-
 bsd/isofs/cd9660/cd9660_vnops.c               |   23 +-
 bsd/isofs/cd9660/iso.h                        |   23 +-
 bsd/isofs/cd9660/iso_rrip.h                   |   23 +-
 bsd/kern/ast.h                                |   23 +-
 bsd/kern/bsd_init.c                           |   36 +-
 bsd/kern/bsd_stubs.c                          |   25 +-
 bsd/kern/init_sysent.c                        |   38 +-
 bsd/kern/kdebug.c                             |   34 +-
 bsd/kern/kern_acct.c                          |   23 +-
 bsd/kern/kern_clock.c                         |   23 +-
 bsd/kern/kern_control.c                       |   23 +-
 bsd/kern/kern_core.c                          |   30 +-
 bsd/kern/kern_descrip.c                       |   42 +-
 bsd/kern/kern_event.c                         |   23 +-
 bsd/kern/kern_exec.c                          |   45 +-
 bsd/kern/kern_exit.c                          |   23 +-
 bsd/kern/kern_fork.c                          |   25 +-
 bsd/kern/kern_ktrace.c                        |   23 +-
 bsd/kern/kern_lock.c                          |   23 +-
 bsd/kern/kern_malloc.c                        |   33 +-
 bsd/kern/kern_mib.c                           |  365 +-
 bsd/kern/kern_mman.c                          |   59 +-
 bsd/kern/kern_newsysctl.c                     |  407 +-
 bsd/kern/kern_panicinfo.c                     |   23 +-
 bsd/kern/kern_pcsamples.c                     |   23 +-
 bsd/kern/kern_physio.c                        |   23 +-
 bsd/kern/kern_proc.c                          |   23 +-
 bsd/kern/kern_prot.c                          |   23 +-
 bsd/kern/kern_resource.c                      |   31 +-
 bsd/kern/kern_shutdown.c                      |   23 +-
 bsd/kern/kern_sig.c                           |   30 +-
 bsd/kern/kern_subr.c                          |   50 +-
 bsd/kern/kern_symfile.c                       |   35 +-
 bsd/kern/kern_synch.c                         |   23 +-
 bsd/kern/kern_sysctl.c                        |  131 +-
 bsd/kern/kern_time.c                          |   23 +-
 bsd/kern/kern_xxx.c                           |   23 +-
 bsd/kern/mach_fat.c                           |   25 +-
 bsd/kern/mach_header.c                        |   23 +-
 bsd/kern/mach_header.h                        |   23 +-
 bsd/kern/mach_loader.c                        |  139 +-
 bsd/kern/mach_loader.h                        |   26 +-
 bsd/kern/mach_process.c                       |   46 +-
 bsd/kern/netboot.c                            |   23 +-
 bsd/kern/posix_sem.c                          |   23 +-
 bsd/kern/posix_shm.c                          |   29 +-
 bsd/kern/preload.h                            |   23 +-
 bsd/kern/qsort.c                              |   23 +-
 bsd/kern/spl.c                                |   23 +-
 bsd/kern/subr_log.c                           |   23 +-
 bsd/kern/subr_prf.c                           |   23 +-
 bsd/kern/subr_prof.c                          |   23 +-
 bsd/kern/subr_xxx.c                           |   23 +-
 bsd/kern/sys_domain.c                         |   23 +-
 bsd/kern/sys_generic.c                        |   26 +-
 bsd/kern/sys_socket.c                         |   23 +-
 bsd/kern/syscalls.c                           |   33 +-
 bsd/kern/sysctl_init.c                        |  107 +-
 bsd/kern/sysv_ipc.c                           |   23 +-
 bsd/kern/sysv_msg.c                           |   23 +-
 bsd/kern/sysv_sem.c                           |   23 +-
 bsd/kern/sysv_shm.c                           |   33 +-
 bsd/kern/tty.c                                |   23 +-
 bsd/kern/tty_compat.c                         |   23 +-
 bsd/kern/tty_conf.c                           |   23 +-
 bsd/kern/tty_pty.c                            |   23 +-
 bsd/kern/tty_subr.c                           |   23 +-
 bsd/kern/tty_tb.c                             |   23 +-
 bsd/kern/tty_tty.c                            |   23 +-
 bsd/kern/ubc_subr.c                           |   43 +-
 bsd/kern/uipc_domain.c                        |   23 +-
 bsd/kern/uipc_mbuf.c                          |   61 +-
 bsd/kern/uipc_mbuf2.c                         |   23 +-
 bsd/kern/uipc_proto.c                         |   23 +-
 bsd/kern/uipc_socket.c                        |   23 +-
 bsd/kern/uipc_socket2.c                       |   23 +-
 bsd/kern/uipc_syscalls.c                      |   23 +-
 bsd/kern/uipc_usrreq.c                        |   23 +-
 bsd/libkern/bcd.c                             |   23 +-
 bsd/libkern/bcmp.c                            |   23 +-
 bsd/libkern/inet_ntoa.c                       |   23 +-
 bsd/libkern/libkern.h                         |   23 +-
 bsd/libkern/locc.c                            |   23 +-
 bsd/libkern/random.c                          |   23 +-
 bsd/libkern/rindex.c                          |   23 +-
 bsd/libkern/scanc.c                           |   23 +-
 bsd/libkern/skpc.c                            |   23 +-
 bsd/libkern/strtol.c                          |   23 +-
 bsd/machine/ansi.h                            |   23 +-
 bsd/machine/byte_order.h                      |   23 +-
 bsd/machine/cons.h                            |   23 +-
 bsd/machine/cpu.h                             |   23 +-
 bsd/machine/disklabel.h                       |   23 +-
 bsd/machine/endian.h                          |   23 +-
 bsd/machine/exec.h                            |   23 +-
 bsd/machine/label_t.h                         |   23 +-
 bsd/machine/param.h                           |   23 +-
 bsd/machine/proc.h                            |   23 +-
 bsd/machine/profile.h                         |   23 +-
 bsd/machine/psl.h                             |   23 +-
 bsd/machine/ptrace.h                          |   23 +-
 bsd/machine/reboot.h                          |   23 +-
 bsd/machine/reg.h                             |   23 +-
 bsd/machine/setjmp.h                          |   23 +-
 bsd/machine/signal.h                          |   23 +-
 bsd/machine/spl.h                             |   23 +-
 bsd/machine/table.h                           |   23 +-
 bsd/machine/trap.h                            |   23 +-
 bsd/machine/types.h                           |   23 +-
 bsd/machine/ucontext.h                        |   23 +-
 bsd/machine/unix_traps.h                      |   23 +-
 bsd/machine/user.h                            |   23 +-
 bsd/machine/vmparam.h                         |   23 +-
 bsd/miscfs/deadfs/dead_vnops.c                |   23 +-
 bsd/miscfs/devfs/devfs.h                      |   23 +-
 bsd/miscfs/devfs/devfs_proto.h                |   29 +-
 bsd/miscfs/devfs/devfs_tree.c                 |   38 +-
 bsd/miscfs/devfs/devfs_vfsops.c               |   23 +-
 bsd/miscfs/devfs/devfs_vnops.c                |   23 +-
 bsd/miscfs/devfs/devfsdefs.h                  |   23 +-
 bsd/miscfs/fdesc/fdesc.h                      |   23 +-
 bsd/miscfs/fdesc/fdesc_vfsops.c               |   23 +-
 bsd/miscfs/fdesc/fdesc_vnops.c                |   23 +-
 bsd/miscfs/fifofs/fifo.h                      |   23 +-
 bsd/miscfs/fifofs/fifo_vnops.c                |   23 +-
 bsd/miscfs/nullfs/null.h                      |   23 +-
 bsd/miscfs/nullfs/null_subr.c                 |   23 +-
 bsd/miscfs/nullfs/null_vfsops.c               |   23 +-
 bsd/miscfs/nullfs/null_vnops.c                |   23 +-
 bsd/miscfs/specfs/spec_vnops.c                |   23 +-
 bsd/miscfs/specfs/specdev.h                   |   23 +-
 bsd/miscfs/synthfs/synthfs.h                  |   23 +-
 bsd/miscfs/synthfs/synthfs_util.c             |   23 +-
 bsd/miscfs/synthfs/synthfs_vfsops.c           |   23 +-
 bsd/miscfs/synthfs/synthfs_vnops.c            |   23 +-
 bsd/miscfs/union/union.h                      |   23 +-
 bsd/miscfs/union/union_subr.c                 |   23 +-
 bsd/miscfs/union/union_vfsops.c               |   23 +-
 bsd/miscfs/union/union_vnops.c                |   23 +-
 bsd/miscfs/volfs/volfs.h                      |   23 +-
 bsd/miscfs/volfs/volfs_vfsops.c               |   23 +-
 bsd/miscfs/volfs/volfs_vnops.c                |   23 +-
 bsd/net/bpf.c                                 |   23 +-
 bsd/net/bpf.h                                 |   23 +-
 bsd/net/bpf_compat.h                          |   23 +-
 bsd/net/bpf_filter.c                          |   23 +-
 bsd/net/bpfdesc.h                             |   23 +-
 bsd/net/bridge.c                              |   23 +-
 bsd/net/bridge.h                              |   23 +-
 bsd/net/bsd_comp.c                            |   23 +-
 bsd/net/dlil.c                                |   23 +-
 bsd/net/dlil.h                                |   23 +-
 bsd/net/dlil_pvt.h                            |   23 +-
 bsd/net/ether_at_pr_module.c                  |   23 +-
 bsd/net/ether_if_module.c                     |   41 +-
 bsd/net/ether_inet6_pr_module.c               |   23 +-
 bsd/net/ether_inet_pr_module.c                |   23 +-
 bsd/net/etherdefs.h                           |   23 +-
 bsd/net/ethernet.h                            |   23 +-
 bsd/net/if.c                                  |   25 +-
 bsd/net/if.h                                  |   25 +-
 bsd/net/if_arp.h                              |   23 +-
 bsd/net/if_atm.h                              |   23 +-
 bsd/net/if_disc.c                             |   23 +-
 bsd/net/if_dl.h                               |   23 +-
 bsd/net/if_dummy.c                            |   23 +-
 bsd/net/if_ethersubr.c                        |   23 +-
 bsd/net/if_faith.c                            |   23 +-
 bsd/net/if_fddisubr.c                         |   23 +-
 bsd/net/if_gif.c                              |   23 +-
 bsd/net/if_gif.h                              |   23 +-
 bsd/net/if_llc.h                              |   23 +-
 bsd/net/if_loop.c                             |   23 +-
 bsd/net/if_media.c                            |   23 +-
 bsd/net/if_media.h                            |   23 +-
 bsd/net/if_mib.c                              |   23 +-
 bsd/net/if_mib.h                              |   23 +-
 bsd/net/if_ppp.h                              |   23 +-
 bsd/net/if_pppvar.h                           |   23 +-
 bsd/net/if_slvar.h                            |   23 +-
 bsd/net/if_sppp.h                             |   23 +-
 bsd/net/if_tun.c                              |   23 +-
 bsd/net/if_tun.h                              |   23 +-
 bsd/net/if_tunvar.h                           |   23 +-
 bsd/net/if_types.h                            |   23 +-
 bsd/net/if_var.h                              |   23 +-
 bsd/net/if_vlan.c                             |   23 +-
 bsd/net/if_vlan_var.h                         |   23 +-
 bsd/net/kext_net.c                            |   23 +-
 bsd/net/kext_net.h                            |   23 +-
 bsd/net/ndrv.c                                |   23 +-
 bsd/net/ndrv.h                                |   23 +-
 bsd/net/ndrv_var.h                            |   23 +-
 bsd/net/net_osdep.c                           |   23 +-
 bsd/net/net_osdep.h                           |   23 +-
 bsd/net/netisr.c                              |   23 +-
 bsd/net/netisr.h                              |   23 +-
 bsd/net/pfkeyv2.h                             |   23 +-
 bsd/net/ppp_comp.h                            |   23 +-
 bsd/net/ppp_deflate.c                         |   23 +-
 bsd/net/ppp_defs.h                            |   23 +-
 bsd/net/radix.c                               |   23 +-
 bsd/net/radix.h                               |   23 +-
 bsd/net/raw_cb.c                              |   23 +-
 bsd/net/raw_cb.h                              |   23 +-
 bsd/net/raw_usrreq.c                          |   23 +-
 bsd/net/route.c                               |   23 +-
 bsd/net/route.h                               |   23 +-
 bsd/net/rtsock.c                              |   23 +-
 bsd/net/rtsock_mip.c                          |   23 +-
 bsd/net/slcompress.c                          |   23 +-
 bsd/net/slcompress.h                          |   23 +-
 bsd/net/slip.h                                |   23 +-
 bsd/net/zlib.c                                |   23 +-
 bsd/netat/adsp.c                              |   23 +-
 bsd/netat/adsp.h                              |   27 +-
 bsd/netat/adsp_CLDeny.c                       |   23 +-
 bsd/netat/adsp_CLListen.c                     |   23 +-
 bsd/netat/adsp_Close.c                        |   23 +-
 bsd/netat/adsp_Control.c                      |   23 +-
 bsd/netat/adsp_Init.c                         |   23 +-
 bsd/netat/adsp_InitGlobals.c                  |   23 +-
 bsd/netat/adsp_NewCID.c                       |   23 +-
 bsd/netat/adsp_Open.c                         |   23 +-
 bsd/netat/adsp_Options.c                      |   23 +-
 bsd/netat/adsp_Packet.c                       |   23 +-
 bsd/netat/adsp_Read.c                         |   23 +-
 bsd/netat/adsp_RxAttn.c                       |   23 +-
 bsd/netat/adsp_RxData.c                       |   23 +-
 bsd/netat/adsp_Status.c                       |   23 +-
 bsd/netat/adsp_Timer.c                        |   23 +-
 bsd/netat/adsp_TimerElem.c                    |   23 +-
 bsd/netat/adsp_Write.c                        |   23 +-
 bsd/netat/adsp_attention.c                    |   23 +-
 bsd/netat/adsp_internal.h                     |   23 +-
 bsd/netat/adsp_misc.c                         |   23 +-
 bsd/netat/adsp_reset.c                        |   23 +-
 bsd/netat/adsp_stream.c                       |   23 +-
 bsd/netat/appletalk.h                         |   23 +-
 bsd/netat/asp.h                               |   23 +-
 bsd/netat/asp_proto.c                         |  129 +-
 bsd/netat/at.c                                |   23 +-
 bsd/netat/at_aarp.h                           |   23 +-
 bsd/netat/at_config.h                         |   23 +-
 bsd/netat/at_ddp_brt.h                        |   23 +-
 bsd/netat/at_pat.h                            |   23 +-
 bsd/netat/at_pcb.c                            |   23 +-
 bsd/netat/at_pcb.h                            |   23 +-
 bsd/netat/at_proto.c                          |   23 +-
 bsd/netat/at_snmp.h                           |   23 +-
 bsd/netat/at_var.h                            |   23 +-
 bsd/netat/atp.h                               |   23 +-
 bsd/netat/atp_alloc.c                         |   23 +-
 bsd/netat/atp_misc.c                          |   23 +-
 bsd/netat/atp_open.c                          |   23 +-
 bsd/netat/atp_read.c                          |   23 +-
 bsd/netat/atp_write.c                         |  396 +-
 bsd/netat/aurp.h                              |   23 +-
 bsd/netat/aurp_aurpd.c                        |   23 +-
 bsd/netat/aurp_cfg.c                          |   23 +-
 bsd/netat/aurp_gdata.c                        |   23 +-
 bsd/netat/aurp_misc.c                         |   23 +-
 bsd/netat/aurp_open.c                         |   23 +-
 bsd/netat/aurp_rd.c                           |   23 +-
 bsd/netat/aurp_ri.c                           |   23 +-
 bsd/netat/aurp_rx.c                           |   23 +-
 bsd/netat/aurp_tickle.c                       |   23 +-
 bsd/netat/aurp_tx.c                           |   23 +-
 bsd/netat/aurp_zi.c                           |   23 +-
 bsd/netat/ddp.c                               |   23 +-
 bsd/netat/ddp.h                               |   23 +-
 bsd/netat/ddp_aarp.c                          |   23 +-
 bsd/netat/ddp_aep.c                           |   23 +-
 bsd/netat/ddp_brt.c                           |   23 +-
 bsd/netat/ddp_lap.c                           |   23 +-
 bsd/netat/ddp_nbp.c                           |   23 +-
 bsd/netat/ddp_proto.c                         |   23 +-
 bsd/netat/ddp_r_rtmp.c                        |   23 +-
 bsd/netat/ddp_r_zip.c                         |   23 +-
 bsd/netat/ddp_rtmp.c                          |   23 +-
 bsd/netat/ddp_rtmptable.c                     |   23 +-
 bsd/netat/ddp_sip.c                           |   23 +-
 bsd/netat/ddp_usrreq.c                        |   23 +-
 bsd/netat/debug.h                             |   23 +-
 bsd/netat/drv_dep.c                           |   23 +-
 bsd/netat/ep.h                                |   23 +-
 bsd/netat/lap.h                               |   23 +-
 bsd/netat/nbp.h                               |   23 +-
 bsd/netat/pap.h                               |   23 +-
 bsd/netat/routing_tables.h                    |   23 +-
 bsd/netat/rtmp.h                              |   23 +-
 bsd/netat/sys_dep.c                           |   26 +-
 bsd/netat/sys_glue.c                          |   23 +-
 bsd/netat/sysglue.h                           |   23 +-
 bsd/netat/zip.h                               |   23 +-
 bsd/netinet/bootp.h                           |   23 +-
 bsd/netinet/dhcp.h                            |   25 +-
 bsd/netinet/dhcp_options.h                    |   25 +-
 bsd/netinet/icmp6.h                           |   23 +-
 bsd/netinet/icmp_var.h                        |   23 +-
 bsd/netinet/if_atm.c                          |   23 +-
 bsd/netinet/if_atm.h                          |   23 +-
 bsd/netinet/if_ether.c                        |   45 +-
 bsd/netinet/if_ether.h                        |   23 +-
 bsd/netinet/if_fddi.h                         |   23 +-
 bsd/netinet/if_tun.h                          |   23 +-
 bsd/netinet/igmp.c                            |   23 +-
 bsd/netinet/igmp.h                            |   23 +-
 bsd/netinet/igmp_var.h                        |   23 +-
 bsd/netinet/in.c                              |   23 +-
 bsd/netinet/in.h                              |   23 +-
 bsd/netinet/in_bootp.c                        |   23 +-
 bsd/netinet/in_cksum.c                        |   23 +-
 bsd/netinet/in_gif.c                          |   23 +-
 bsd/netinet/in_gif.h                          |   23 +-
 bsd/netinet/in_pcb.c                          |   23 +-
 bsd/netinet/in_pcb.h                          |   23 +-
 bsd/netinet/in_proto.c                        |   23 +-
 bsd/netinet/in_rmx.c                          |   23 +-
 bsd/netinet/in_systm.h                        |   23 +-
 bsd/netinet/in_var.h                          |   31 +-
 bsd/netinet/ip.h                              |   23 +-
 bsd/netinet/ip6.h                             |   23 +-
 bsd/netinet/ip_compat.h                       |   23 +-
 bsd/netinet/ip_divert.c                       |   23 +-
 bsd/netinet/ip_dummynet.c                     |   23 +-
 bsd/netinet/ip_dummynet.h                     |   23 +-
 bsd/netinet/ip_ecn.c                          |   23 +-
 bsd/netinet/ip_ecn.h                          |   23 +-
 bsd/netinet/ip_encap.c                        |   23 +-
 bsd/netinet/ip_encap.h                        |   23 +-
 bsd/netinet/ip_flow.c                         |   23 +-
 bsd/netinet/ip_flow.h                         |   23 +-
 bsd/netinet/ip_fw.h                           |   23 +-
 bsd/netinet/ip_icmp.c                         |   23 +-
 bsd/netinet/ip_icmp.h                         |   23 +-
 bsd/netinet/ip_input.c                        |   23 +-
 bsd/netinet/ip_mroute.c                       |   23 +-
 bsd/netinet/ip_mroute.h                       |   23 +-
 bsd/netinet/ip_output.c                       |   23 +-
 bsd/netinet/ip_var.h                          |   23 +-
 bsd/netinet/raw_ip.c                          |   23 +-
 bsd/netinet/tcp.h                             |   23 +-
 bsd/netinet/tcp_debug.c                       |   23 +-
 bsd/netinet/tcp_debug.h                       |   23 +-
 bsd/netinet/tcp_fsm.h                         |   23 +-
 bsd/netinet/tcp_input.c                       |   60 +-
 bsd/netinet/tcp_output.c                      |   46 +-
 bsd/netinet/tcp_seq.h                         |   23 +-
 bsd/netinet/tcp_subr.c                        |   26 +-
 bsd/netinet/tcp_timer.c                       |   23 +-
 bsd/netinet/tcp_timer.h                       |   23 +-
 bsd/netinet/tcp_usrreq.c                      |   23 +-
 bsd/netinet/tcp_var.h                         |   24 +-
 bsd/netinet/tcpip.h                           |   23 +-
 bsd/netinet/udp.h                             |   23 +-
 bsd/netinet/udp_usrreq.c                      |   23 +-
 bsd/netinet/udp_var.h                         |   23 +-
 bsd/netinet6/ip6_fw.h                         |   23 +-
 bsd/netinet6/ipsec.c                          |    2 +-
 bsd/nfs/krpc.h                                |   23 +-
 bsd/nfs/krpc_subr.c                           |   56 +-
 bsd/nfs/nfs.h                                 |   23 +-
 bsd/nfs/nfs_bio.c                             |   23 +-
 bsd/nfs/nfs_boot.c                            |  169 +-
 bsd/nfs/nfs_node.c                            |   23 +-
 bsd/nfs/nfs_nqlease.c                         |   23 +-
 bsd/nfs/nfs_serv.c                            |   23 +-
 bsd/nfs/nfs_socket.c                          |   37 +-
 bsd/nfs/nfs_srvcache.c                        |   23 +-
 bsd/nfs/nfs_subs.c                            |   23 +-
 bsd/nfs/nfs_syscalls.c                        |   23 +-
 bsd/nfs/nfs_vfsops.c                          |   92 +-
 bsd/nfs/nfs_vnops.c                           |   23 +-
 bsd/nfs/nfsdiskless.h                         |   28 +-
 bsd/nfs/nfsm_subs.h                           |   23 +-
 bsd/nfs/nfsmount.h                            |   23 +-
 bsd/nfs/nfsnode.h                             |   23 +-
 bsd/nfs/nfsproto.h                            |   23 +-
 bsd/nfs/nfsrtt.h                              |   23 +-
 bsd/nfs/nfsrvcache.h                          |   23 +-
 bsd/nfs/nqnfs.h                               |   23 +-
 bsd/nfs/rpcv2.h                               |   24 +-
 bsd/nfs/xdr_subs.h                            |   23 +-
 bsd/ppc/cpu.h                                 |   23 +-
 bsd/ppc/disklabel.h                           |   23 +-
 bsd/ppc/endian.h                              |   23 +-
 bsd/ppc/exec.h                                |   23 +-
 bsd/ppc/label_t.h                             |   23 +-
 bsd/ppc/param.h                               |   23 +-
 bsd/ppc/profile.h                             |   23 +-
 bsd/ppc/psl.h                                 |   23 +-
 bsd/ppc/ptrace.h                              |   23 +-
 bsd/ppc/reboot.h                              |   23 +-
 bsd/ppc/reg.h                                 |   23 +-
 bsd/ppc/setjmp.h                              |   23 +-
 bsd/ppc/signal.h                              |   23 +-
 bsd/ppc/spl.h                                 |   23 +-
 bsd/ppc/table.h                               |   23 +-
 bsd/ppc/types.h                               |   23 +-
 bsd/ppc/ucontext.h                            |   33 +-
 bsd/ppc/user.h                                |   23 +-
 bsd/ppc/vmparam.h                             |   23 +-
 bsd/sys/acct.h                                |   23 +-
 bsd/sys/appleapiopts.h                        |   23 +-
 bsd/sys/attr.h                                |   23 +-
 bsd/sys/buf.h                                 |   23 +-
 bsd/sys/callout.h                             |   23 +-
 bsd/sys/cdefs.h                               |   23 +-
 bsd/sys/clist.h                               |   23 +-
 bsd/sys/conf.h                                |   23 +-
 bsd/sys/dir.h                                 |   23 +-
 bsd/sys/dirent.h                              |   23 +-
 bsd/sys/disk.h                                |   23 +-
 bsd/sys/disklabel.h                           |   23 +-
 bsd/sys/disktab.h                             |   23 +-
 bsd/sys/dkstat.h                              |   23 +-
 bsd/sys/dmap.h                                |   23 +-
 bsd/sys/domain.h                              |   23 +-
 bsd/sys/errno.h                               |   23 +-
 bsd/sys/ev.h                                  |   23 +-
 bsd/sys/exec.h                                |   23 +-
 bsd/sys/fcntl.h                               |   23 +-
 bsd/sys/file.h                                |   35 +-
 bsd/sys/filedesc.h                            |   23 +-
 bsd/sys/filio.h                               |   23 +-
 bsd/sys/fsctl.h                               |   23 +-
 bsd/sys/gmon.h                                |   23 +-
 bsd/sys/ioccom.h                              |   23 +-
 bsd/sys/ioctl.h                               |   23 +-
 bsd/sys/ioctl_compat.h                        |   23 +-
 bsd/sys/ipc.h                                 |   23 +-
 bsd/sys/kdebug.h                              |   24 +-
 bsd/sys/kern_control.h                        |   23 +-
 bsd/sys/kern_event.h                          |   23 +-
 bsd/sys/kernel.h                              |   23 +-
 bsd/sys/ktrace.h                              |   23 +-
 bsd/sys/linker_set.h                          |   23 +-
 bsd/sys/loadable_fs.h                         |   23 +-
 bsd/sys/lock.h                                |   23 +-
 bsd/sys/lockf.h                               |   23 +-
 bsd/sys/mach_swapon.h                         |   23 +-
 bsd/sys/malloc.h                              |   33 +-
 bsd/sys/mbuf.h                                |   23 +-
 bsd/sys/mman.h                                |   23 +-
 bsd/sys/mount.h                               |   23 +-
 bsd/sys/msg.h                                 |   23 +-
 bsd/sys/msgbuf.h                              |   23 +-
 bsd/sys/mtio.h                                |   23 +-
 bsd/sys/namei.h                               |   23 +-
 bsd/sys/netport.h                             |   23 +-
 bsd/sys/param.h                               |   23 +-
 bsd/sys/paths.h                               |   23 +-
 bsd/sys/poll.h                                |   23 +-
 bsd/sys/proc.h                                |   23 +-
 bsd/sys/protosw.h                             |   23 +-
 bsd/sys/ptrace.h                              |   23 +-
 bsd/sys/queue.h                               |   23 +-
 bsd/sys/quota.h                               |   27 +-
 bsd/sys/random.h                              |   23 +-
 bsd/sys/reboot.h                              |   23 +-
 bsd/sys/resource.h                            |   23 +-
 bsd/sys/resourcevar.h                         |   23 +-
 bsd/sys/select.h                              |   23 +-
 bsd/sys/sem.h                                 |   23 +-
 bsd/sys/semaphore.h                           |   23 +-
 bsd/sys/shm.h                                 |   23 +-
 bsd/sys/signal.h                              |   29 +-
 bsd/sys/signalvar.h                           |   24 +-
 bsd/sys/socket.h                              |   23 +-
 bsd/sys/socketvar.h                           |   23 +-
 bsd/sys/sockio.h                              |   25 +-
 bsd/sys/stat.h                                |   23 +-
 bsd/sys/subr_prf.h                            |   23 +-
 bsd/sys/sys_domain.h                          |   23 +-
 bsd/sys/syscall.h                             |   31 +-
 bsd/sys/sysctl.h                              |  126 +-
 bsd/sys/syslimits.h                           |   23 +-
 bsd/sys/syslog.h                              |   23 +-
 bsd/sys/systm.h                               |   23 +-
 bsd/sys/table.h                               |   23 +-
 bsd/sys/termios.h                             |   23 +-
 bsd/sys/time.h                                |   23 +-
 bsd/sys/timeb.h                               |   23 +-
 bsd/sys/times.h                               |   23 +-
 bsd/sys/tprintf.h                             |   23 +-
 bsd/sys/trace.h                               |   23 +-
 bsd/sys/tty.h                                 |   23 +-
 bsd/sys/ttychars.h                            |   23 +-
 bsd/sys/ttycom.h                              |   23 +-
 bsd/sys/ttydefaults.h                         |   23 +-
 bsd/sys/ttydev.h                              |   23 +-
 bsd/sys/types.h                               |   23 +-
 bsd/sys/ubc.h                                 |   26 +-
 bsd/sys/ucontext.h                            |   35 +-
 bsd/sys/ucred.h                               |   23 +-
 bsd/sys/uio.h                                 |   24 +-
 bsd/sys/un.h                                  |   23 +-
 bsd/sys/unistd.h                              |   23 +-
 bsd/sys/unpcb.h                               |   23 +-
 bsd/sys/user.h                                |   23 +-
 bsd/sys/utfconv.h                             |   23 +-
 bsd/sys/utsname.h                             |   23 +-
 bsd/sys/ux_exception.h                        |   23 +-
 bsd/sys/vadvise.h                             |   23 +-
 bsd/sys/vcmd.h                                |   23 +-
 bsd/sys/version.h                             |   23 +-
 bsd/sys/vlimit.h                              |   23 +-
 bsd/sys/vm.h                                  |   23 +-
 bsd/sys/vmmeter.h                             |   23 +-
 bsd/sys/vmparam.h                             |   23 +-
 bsd/sys/vnioctl.h                             |    2 +-
 bsd/sys/vnode.h                               |   23 +-
 bsd/sys/vnode_if.h                            |   23 +-
 bsd/sys/vstat.h                               |   23 +-
 bsd/sys/wait.h                                |   23 +-
 bsd/ufs/ffs/ffs_alloc.c                       |   23 +-
 bsd/ufs/ffs/ffs_balloc.c                      |   23 +-
 bsd/ufs/ffs/ffs_extern.h                      |   23 +-
 bsd/ufs/ffs/ffs_inode.c                       |   23 +-
 bsd/ufs/ffs/ffs_subr.c                        |   23 +-
 bsd/ufs/ffs/ffs_tables.c                      |   23 +-
 bsd/ufs/ffs/ffs_vfsops.c                      |   23 +-
 bsd/ufs/ffs/ffs_vnops.c                       |   23 +-
 bsd/ufs/ffs/fs.h                              |   23 +-
 bsd/ufs/mfs/mfs_extern.h                      |   23 +-
 bsd/ufs/mfs/mfs_vfsops.c                      |   23 +-
 bsd/ufs/mfs/mfs_vnops.c                       |   23 +-
 bsd/ufs/mfs/mfsiom.h                          |   23 +-
 bsd/ufs/mfs/mfsnode.h                         |   23 +-
 bsd/ufs/ufs/dinode.h                          |   23 +-
 bsd/ufs/ufs/dir.h                             |   23 +-
 bsd/ufs/ufs/inode.h                           |   23 +-
 bsd/ufs/ufs/lockf.h                           |   23 +-
 bsd/ufs/ufs/quota.h                           |   23 +-
 bsd/ufs/ufs/ufs_bmap.c                        |   23 +-
 bsd/ufs/ufs/ufs_byte_order.c                  |   23 +-
 bsd/ufs/ufs/ufs_byte_order.h                  |   23 +-
 bsd/ufs/ufs/ufs_extern.h                      |   23 +-
 bsd/ufs/ufs/ufs_ihash.c                       |   23 +-
 bsd/ufs/ufs/ufs_inode.c                       |   23 +-
 bsd/ufs/ufs/ufs_lockf.c                       |   23 +-
 bsd/ufs/ufs/ufs_lookup.c                      |   23 +-
 bsd/ufs/ufs/ufs_quota.c                       |   23 +-
 bsd/ufs/ufs/ufs_readwrite.c                   |   27 +-
 bsd/ufs/ufs/ufs_vfsops.c                      |   23 +-
 bsd/ufs/ufs/ufs_vnops.c                       |   23 +-
 bsd/ufs/ufs/ufsmount.h                        |   23 +-
 bsd/uxkern/ux_exception.c                     |   23 +-
 bsd/vfs/vfs_bio.c                             |   29 +-
 bsd/vfs/vfs_cache.c                           |   23 +-
 bsd/vfs/vfs_cluster.c                         |  882 +-
 bsd/vfs/vfs_conf.c                            |   23 +-
 bsd/vfs/vfs_init.c                            |   23 +-
 bsd/vfs/vfs_journal.c                         |   77 +-
 bsd/vfs/vfs_journal.h                         |   23 +-
 bsd/vfs/vfs_lookup.c                          |   23 +-
 bsd/vfs/vfs_quota.c                           |   88 +-
 bsd/vfs/vfs_subr.c                            |   23 +-
 bsd/vfs/vfs_support.c                         |   23 +-
 bsd/vfs/vfs_support.h                         |   23 +-
 bsd/vfs/vfs_syscalls.c                        |   53 +-
 bsd/vfs/vfs_utfconv.c                         |   23 +-
 bsd/vfs/vfs_utfconvdata.h                     |   23 +-
 bsd/vfs/vfs_vnops.c                           |   23 +-
 bsd/vfs/vnode_if.c                            |   23 +-
 bsd/vm/dp_backing_file.c                      |   23 +-
 bsd/vm/vm_pageout.h                           |   23 +-
 bsd/vm/vm_pager.h                             |   23 +-
 bsd/vm/vm_unix.c                              |  181 +-
 bsd/vm/vnode_pager.c                          |   25 +-
 bsd/vm/vnode_pager.h                          |   23 +-
 config/Makefile                               |   46 +
 config/System.kext/Contents/Info.plist        |   30 +
 .../PlugIns/AppleNMI.kext/Contents/Info.plist |   28 +
 .../Contents/Info.plist                       |   30 +
 .../BSDKernel.kext/Contents/Info.plist        |   30 +
 .../IOADBFamily.kext/Contents/Info.plist      |   30 +
 .../PlugIns/IOKit.kext/Contents/Info.plist    |   30 +
 .../IONVRAMFamily.kext/Contents/Info.plist    |   30 +
 .../Contents/Info.plist                       |   30 +
 .../PlugIns/Libkern.kext/Contents/Info.plist  |   30 +
 .../PlugIns/Mach.kext/Contents/Info.plist     |   30 +
 .../drvAppleI386Generic/AppleI386CPU.cpp      |   23 +-
 .../drvAppleI386Generic/AppleI386CPU.h        |   23 +-
 .../AppleI386PlatformExpert.cpp               |   23 +-
 .../AppleI386PlatformExpert.h                 |   23 +-
 .../AppleIntelClassicPIC.h                    |   23 +-
 .../drvAppleIntelClassicPIC/PIC8259.cpp       |   23 +-
 .../drvAppleIntelClock/AppleIntelClock.h      |   23 +-
 .../drvAppleIntelClock/IntelClock.cpp         |   23 +-
 .../platform/drvAppleMacIO/AppleMacIO.cpp     |   42 +-
 .../Drivers/platform/drvAppleNMI/AppleNMI.cpp |   35 +-
 .../platform/drvAppleNVRAM/AppleNVRAM.cpp     |   23 +-
 .../platform/drvAppleNVRAM/AppleNVRAM.h       |   23 +-
 .../drvApplePMU/IOPMUADBController.cpp        |   23 +-
 .../platform/drvApplePMU/IOPMUADBController.h |   23 +-
 .../drvApplePlatformExpert/AppleCPU.cpp       |   23 +-
 .../drvApplePlatformExpert/AppleCPU.h         |   23 +-
 .../ApplePlatformExpert.cpp                   |   25 +-
 .../drvAppleRootDomain/RootDomain.cpp         |   23 +-
 .../RootDomainUserClient.cpp                  |   23 +-
 .../drvAppleRootDomain/RootDomainUserClient.h |   23 +-
 .../GenericInterruptController.cpp            |   23 +-
 .../GenericInterruptController.h              |   23 +-
 iokit/Families/IOADBBus/IOADBBus.cpp          |   23 +-
 iokit/Families/IOADBBus/IOADBBusPriv.h        |   23 +-
 iokit/Families/IOADBBus/IOADBController.cpp   |   23 +-
 .../IOADBBus/IOADBControllerUserClient.cpp    |   23 +-
 .../IOADBBus/IOADBControllerUserClient.h      |   23 +-
 iokit/Families/IOADBBus/IOADBDevice.cpp       |   23 +-
 iokit/Families/IONVRAM/IONVRAMController.cpp  |   23 +-
 .../IOSystemManagement/IOWatchDogTimer.cpp    |   29 +-
 iokit/IOKit/IOBSD.h                           |   23 +-
 iokit/IOKit/IOBufferMemoryDescriptor.h        |   33 +-
 iokit/IOKit/IOCPU.h                           |   23 +-
 iokit/IOKit/IOCatalogue.h                     |   23 +-
 iokit/IOKit/IOCommand.h                       |   23 +-
 iokit/IOKit/IOCommandGate.h                   |   23 +-
 iokit/IOKit/IOCommandPool.h                   |   23 +-
 iokit/IOKit/IOCommandQueue.h                  |   23 +-
 iokit/IOKit/IOConditionLock.h                 |   23 +-
 iokit/IOKit/IODataQueue.h                     |   23 +-
 iokit/IOKit/IODataQueueShared.h               |   23 +-
 iokit/IOKit/IODeviceMemory.h                  |   23 +-
 iokit/IOKit/IODeviceTreeSupport.h             |   23 +-
 iokit/IOKit/IOEventSource.h                   |   23 +-
 iokit/IOKit/IOFilterInterruptEventSource.h    |   23 +-
 iokit/IOKit/IOInterruptController.h           |   23 +-
 iokit/IOKit/IOInterruptEventSource.h          |   23 +-
 iokit/IOKit/IOInterrupts.h                    |   23 +-
 iokit/IOKit/IOKitDebug.h                      |   36 +-
 iokit/IOKit/IOKitKeys.h                       |   23 +-
 iokit/IOKit/IOKitServer.h                     |   23 +-
 iokit/IOKit/IOLib.h                           |  105 +-
 iokit/IOKit/IOLocks.h                         |   23 +-
 iokit/IOKit/IOMapper.h                        |  131 +
 iokit/IOKit/IOMemoryCursor.h                  |   23 +-
 iokit/IOKit/IOMemoryDescriptor.h              |  222 +-
 iokit/IOKit/IOMessage.h                       |   23 +-
 iokit/IOKit/IOMultiMemoryDescriptor.h         |   23 +-
 iokit/IOKit/IONVRAM.h                         |   23 +-
 iokit/IOKit/IONotifier.h                      |   23 +-
 iokit/IOKit/IOPlatformExpert.h                |   25 +-
 iokit/IOKit/IORangeAllocator.h                |   23 +-
 iokit/IOKit/IORegistryEntry.h                 |   23 +-
 iokit/IOKit/IOReturn.h                        |   23 +-
 iokit/IOKit/IOService.h                       |   24 +-
 iokit/IOKit/IOServicePM.h                     |   23 +-
 iokit/IOKit/IOSharedLock.h                    |   23 +-
 iokit/IOKit/IOSyncer.h                        |   23 +-
 iokit/IOKit/IOTimeStamp.h                     |   23 +-
 iokit/IOKit/IOTimerEventSource.h              |   23 +-
 iokit/IOKit/IOTypes.h                         |   37 +-
 iokit/IOKit/IOUserClient.h                    |   23 +-
 iokit/IOKit/IOWorkLoop.h                      |   23 +-
 iokit/IOKit/Makefile                          |    1 -
 iokit/IOKit/OSMessageNotification.h           |   23 +-
 iokit/IOKit/adb/IOADBBus.h                    |   23 +-
 iokit/IOKit/adb/IOADBController.h             |   23 +-
 iokit/IOKit/adb/IOADBDevice.h                 |   23 +-
 iokit/IOKit/adb/IOADBLib.h                    |   23 +-
 iokit/IOKit/adb/adb.h                         |   23 +-
 iokit/IOKit/assert.h                          |   23 +-
 iokit/IOKit/i386/IOSharedLockImp.h            |   23 +-
 iokit/IOKit/machine/IOSharedLockImp.h         |   23 +-
 iokit/IOKit/nvram/IONVRAMController.h         |   23 +-
 iokit/IOKit/pci/IOAGPDevice.h                 |  192 -
 iokit/IOKit/pci/IOPCIBridge.h                 |  271 -
 iokit/IOKit/pci/IOPCIDevice.h                 |  373 +-
 iokit/IOKit/pci/Makefile                      |   34 -
 iokit/IOKit/platform/AppleMacIO.h             |   23 +-
 iokit/IOKit/platform/AppleMacIODevice.h       |   23 +-
 iokit/IOKit/platform/AppleNMI.h               |   23 +-
 iokit/IOKit/platform/ApplePlatformExpert.h    |   23 +-
 iokit/IOKit/power/IOPwrController.h           |   23 +-
 iokit/IOKit/ppc/IODBDMA.h                     |   23 +-
 iokit/IOKit/ppc/IOSharedLockImp.h             |  173 +-
 iokit/IOKit/pwr_mgt/IOPM.h                    |   23 +-
 iokit/IOKit/pwr_mgt/IOPMLibDefs.h             |   23 +-
 iokit/IOKit/pwr_mgt/IOPMPagingPlexus.h        |   23 +-
 iokit/IOKit/pwr_mgt/IOPMPowerSource.h         |   23 +-
 iokit/IOKit/pwr_mgt/IOPMPowerSourceList.h     |   23 +-
 iokit/IOKit/pwr_mgt/IOPMPrivate.h             |   23 +-
 iokit/IOKit/pwr_mgt/IOPMchangeNoteList.h      |   23 +-
 iokit/IOKit/pwr_mgt/IOPMinformee.h            |   23 +-
 iokit/IOKit/pwr_mgt/IOPMinformeeList.h        |   23 +-
 iokit/IOKit/pwr_mgt/IOPMlog.h                 |   23 +-
 iokit/IOKit/pwr_mgt/IOPMpmChild.h             |   23 +-
 iokit/IOKit/pwr_mgt/IOPMpowerState.h          |   23 +-
 iokit/IOKit/pwr_mgt/IOPowerConnection.h       |   23 +-
 iokit/IOKit/pwr_mgt/RootDomain.h              |   23 +-
 iokit/IOKit/rtc/IORTCController.h             |   23 +-
 iokit/IOKit/system.h                          |   25 +-
 .../IOKit/system_management/IOWatchDogTimer.h |   29 +-
 iokit/Kernel/IOBufferMemoryDescriptor.cpp     |  162 +-
 iokit/Kernel/IOCPU.cpp                        |   49 +-
 iokit/Kernel/IOCatalogue.cpp                  |   23 +-
 iokit/Kernel/IOCommand.cpp                    |   23 +-
 iokit/Kernel/IOCommandGate.cpp                |   23 +-
 iokit/Kernel/IOCommandPool.cpp                |   23 +-
 iokit/Kernel/IOCommandQueue.cpp               |   23 +-
 iokit/Kernel/IOConditionLock.cpp              |   23 +-
 iokit/Kernel/IODataQueue.cpp                  |   27 +-
 iokit/Kernel/IODeviceMemory.cpp               |   30 +-
 iokit/Kernel/IODeviceTreeSupport.cpp          |   30 +-
 iokit/Kernel/IOEventSource.cpp                |   23 +-
 iokit/Kernel/IOFilterInterruptEventSource.cpp |   23 +-
 iokit/Kernel/IOInterruptController.cpp        |   50 +-
 iokit/Kernel/IOInterruptEventSource.cpp       |   23 +-
 iokit/Kernel/IOKitDebug.cpp                   |   78 +-
 iokit/Kernel/IOLib.c                          |  168 +-
 iokit/Kernel/IOLocks.cpp                      |   23 +-
 iokit/Kernel/IOMapper.cpp                     |  389 +
 iokit/Kernel/IOMemoryCursor.cpp               |   35 +-
 iokit/Kernel/IOMemoryDescriptor.cpp           | 1610 ++--
 iokit/Kernel/IOMultiMemoryDescriptor.cpp      |   23 +-
 iokit/Kernel/IONVRAM.cpp                      |   72 +-
 iokit/Kernel/IOPMPagingPlexus.cpp             |   23 +-
 iokit/Kernel/IOPMPowerSource.cpp              |   23 +-
 iokit/Kernel/IOPMPowerSourceList.cpp          |   23 +-
 iokit/Kernel/IOPMchangeNoteList.cpp           |   23 +-
 iokit/Kernel/IOPMinformee.cpp                 |   23 +-
 iokit/Kernel/IOPMinformeeList.cpp             |   23 +-
 iokit/Kernel/IOPMpmChild.cpp                  |   23 +-
 iokit/Kernel/IOPlatformExpert.cpp             |   59 +-
 iokit/Kernel/IOPowerConnection.cpp            |   23 +-
 iokit/Kernel/IORangeAllocator.cpp             |   23 +-
 iokit/Kernel/IORegistryEntry.cpp              |   23 +-
 iokit/Kernel/IOService.cpp                    |   23 +-
 iokit/Kernel/IOServicePM.cpp                  |  107 +-
 iokit/Kernel/IOServicePrivate.h               |   23 +-
 iokit/Kernel/IOStartIOKit.cpp                 |   31 +-
 iokit/Kernel/IOStringFuncs.c                  |   23 +-
 iokit/Kernel/IOSyncer.cpp                     |   23 +-
 iokit/Kernel/IOTimerEventSource.cpp           |   23 +-
 iokit/Kernel/IOUserClient.cpp                 |   63 +-
 iokit/Kernel/IOWorkLoop.cpp                   |   23 +-
 iokit/Kernel/PMmisc.cpp                       |   23 +-
 iokit/Kernel/i386/IOAsmSupport.s              |   23 +-
 iokit/Kernel/i386/IOSharedLock.s              |   23 +-
 iokit/Kernel/ppc/IOAsmSupport.s               |   23 +-
 iokit/Kernel/ppc/IODBDMA.cpp                  |   23 +-
 iokit/Kernel/ppc/IOSharedLock.s               |   23 +-
 iokit/KernelConfigTables.cpp                  |   43 +-
 iokit/Tests/TestCollections.cpp               |   23 +-
 iokit/Tests/TestContainers.cpp                |   23 +-
 iokit/Tests/TestDevice.cpp                    |   23 +-
 iokit/Tests/Tests.cpp                         |   23 +-
 iokit/Tests/Tests.h                           |   23 +-
 iokit/bsddev/IOKitBSDInit.cpp                 |  111 +-
 iokit/bsddev/IOKitBSDInit.h                   |   23 +-
 iokit/conf/Makefile.template                  |    5 +-
 iokit/conf/files                              |    1 +
 iokit/conf/version.minor                      |    2 +-
 iokit/conf/version.variant                    |    1 +
 iokit/include/DeviceTree.h                    |   23 +-
 .../architecture/i386/kernBootStruct.h        |   23 +-
 iokit/include/architecture/i386/pio.h         |   25 +-
 iokit/include/assert.h                        |   23 +-
 iokit/include/bsddev/EventShmemLock.h         |   23 +-
 iokit/include/bsddev/ev_keymap.h              |   23 +-
 iokit/include/bsddev/ev_types.h               |   23 +-
 iokit/include/bsddev/event.h                  |   23 +-
 iokit/include/bsddev/evio.h                   |   23 +-
 iokit/include/bsddev/evsio.h                  |   23 +-
 iokit/include/bsddev/i386/EventShmemLock.h    |   23 +-
 iokit/include/bsddev/i386/event.h             |   23 +-
 iokit/include/bsddev/i386/evio.h              |   23 +-
 iokit/include/bsddev/i386/evsio.h             |   23 +-
 iokit/include/bsddev/machine/EventShmemLock.h |   23 +-
 iokit/include/bsddev/machine/event.h          |   23 +-
 iokit/include/bsddev/machine/evio.h           |   23 +-
 iokit/include/bsddev/machine/evsio.h          |   23 +-
 iokit/include/bsddev/ppc/EventShmemLock.h     |   23 +-
 iokit/include/bsddev/ppc/event.h              |   23 +-
 iokit/include/bsddev/ppc/evio.h               |   23 +-
 iokit/include/bsddev/ppc/evsio.h              |   23 +-
 iokit/include/drivers/event_status_driver.h   |   23 +-
 iokit/include/mach/mach.h                     |   23 +-
 iokit/mach-o/mach_header.h                    |   23 +-
 libkern/c++/OSArray.cpp                       |   37 +-
 libkern/c++/OSBoolean.cpp                     |   23 +-
 libkern/c++/OSCPPDebug.cpp                    |   23 +-
 libkern/c++/OSCollection.cpp                  |   23 +-
 libkern/c++/OSCollectionIterator.cpp          |   25 +-
 libkern/c++/OSData.cpp                        |   73 +-
 libkern/c++/OSDictionary.cpp                  |   43 +-
 libkern/c++/OSIterator.cpp                    |   23 +-
 libkern/c++/OSMetaClass.cpp                   |   23 +-
 libkern/c++/OSNumber.cpp                      |   27 +-
 libkern/c++/OSObject.cpp                      |   23 +-
 libkern/c++/OSOrderedSet.cpp                  |   25 +-
 libkern/c++/OSRuntime.cpp                     |   23 +-
 libkern/c++/OSSerialize.cpp                   |   31 +-
 libkern/c++/OSSet.cpp                         |   43 +-
 libkern/c++/OSString.cpp                      |   29 +-
 libkern/c++/OSSymbol.cpp                      |   23 +-
 libkern/c++/OSUnserialize.cpp                 |   23 +-
 libkern/c++/OSUnserializeXML.cpp              |   23 +-
 .../test1.kmodproj/test1_main.cpp             |   23 +-
 .../test1.kmodproj/test1_main.h               |   23 +-
 .../test2.kmodproj/test2_main.cpp             |   23 +-
 libkern/conf/version.minor                    |    2 +-
 libkern/conf/version.variant                  |    1 +
 libkern/gen/OSAtomicOperations.c              |   23 +-
 libkern/i386/OSAtomic.c                       |   23 +-
 libkern/i386/OSAtomic.s                       |   23 +-
 libkern/kmod/c_start.c                        |   23 +-
 libkern/kmod/c_stop.c                         |   23 +-
 libkern/kmod/cplus_start.c                    |   23 +-
 libkern/kmod/cplus_stop.c                     |   23 +-
 libkern/libkern/OSAtomic.h                    |   23 +-
 libkern/libkern/OSBase.h                      |   23 +-
 libkern/libkern/OSByteOrder.h                 |   23 +-
 libkern/libkern/OSReturn.h                    |   23 +-
 libkern/libkern/OSTypes.h                     |   23 +-
 libkern/libkern/c++/OSArray.h                 |   23 +-
 libkern/libkern/c++/OSBoolean.h               |   23 +-
 libkern/libkern/c++/OSCPPDebug.h              |   23 +-
 libkern/libkern/c++/OSCollection.h            |   23 +-
 libkern/libkern/c++/OSCollectionIterator.h    |   23 +-
 libkern/libkern/c++/OSContainers.h            |   23 +-
 libkern/libkern/c++/OSData.h                  |   36 +-
 libkern/libkern/c++/OSDictionary.h            |   23 +-
 libkern/libkern/c++/OSIterator.h              |   23 +-
 libkern/libkern/c++/OSLib.h                   |   23 +-
 libkern/libkern/c++/OSMetaClass.h             |   23 +-
 libkern/libkern/c++/OSNumber.h                |   23 +-
 libkern/libkern/c++/OSObject.h                |   23 +-
 libkern/libkern/c++/OSOrderedSet.h            |   23 +-
 libkern/libkern/c++/OSSerialize.h             |   23 +-
 libkern/libkern/c++/OSSet.h                   |   23 +-
 libkern/libkern/c++/OSString.h                |   23 +-
 libkern/libkern/c++/OSSymbol.h                |   23 +-
 libkern/libkern/c++/OSUnserialize.h           |   23 +-
 libkern/libkern/i386/OSByteOrder.h            |   23 +-
 libkern/libkern/machine/OSByteOrder.h         |   23 +-
 libkern/libkern/ppc/OSByteOrder.h             |   23 +-
 libkern/mach-o/loader.h                       |   23 +-
 libkern/mach-o/mach_header.h                  |   23 +-
 libkern/ppc/OSAtomic.s                        |   53 +-
 libkern/ppc/bcmp.s                            |   23 +-
 libkern/ppc/memcmp.s                          |   23 +-
 libkern/ppc/strlen.s                          |   23 +-
 libsa/bootstrap.cpp                           |   29 +-
 libsa/bsearch.c                               |   23 +-
 libsa/c++rem3.h                               |   21 +-
 libsa/catalogue.cpp                           |   23 +-
 libsa/conf/version.minor                      |    2 +-
 libsa/conf/version.variant                    |    1 +
 libsa/i386/setjmp.s                           |   23 +-
 libsa/kld_patch.c                             |   25 +-
 libsa/kld_patch.h                             |   21 +-
 libsa/kmod.cpp                                |   41 +-
 libsa/libsa/i386/setjmp.h                     |   25 +-
 libsa/libsa/mach/mach.h                       |    2 +-
 libsa/libsa/malloc.h                          |   11 +-
 libsa/libsa/ppc/setjmp.h                      |   23 +-
 libsa/libsa/setjmp.h                          |   23 +-
 libsa/libsa/stdlib.h                          |    8 +-
 libsa/libsa/unistd.h                          |    2 +-
 libsa/libsa/vers_rsrc.h                       |    2 +-
 libsa/mach.c                                  |   23 +-
 libsa/mach_loader.h                           |   23 +-
 libsa/malloc.c                                |  632 +-
 libsa/malloc_debug_stuff                      |    4 +-
 libsa/malloc_unused                           |    2 +-
 libsa/misc.c                                  |   23 +-
 libsa/mkext.c                                 |   25 +-
 libsa/ppc/setjmp.s                            |   23 +-
 libsa/sort.c                                  |   23 +-
 libsa/strrchr.c                               |   21 +-
 libsa/strstr.c                                |   21 +-
 makedefs/MakeInc.def                          |    6 +-
 makedefs/MakeInc.rule                         |   12 +-
 osfmk/Makefile                                |    3 +
 .../UserNotification/KUNCUserNotifications.c  |   23 +-
 .../UserNotification/KUNCUserNotifications.h  |   29 +-
 osfmk/UserNotification/UNDReply.defs          |   29 +-
 osfmk/UserNotification/UNDRequest.defs        |   29 +-
 osfmk/UserNotification/UNDTypes.defs          |   29 +-
 osfmk/UserNotification/UNDTypes.h             |   29 +-
 osfmk/conf/files.i386                         |    2 +
 osfmk/conf/files.ppc                          |   45 +-
 osfmk/conf/kernelversion.minor                |    2 +-
 osfmk/conf/kernelversion.variant              |    1 +
 osfmk/conf/version.minor                      |    2 +-
 osfmk/conf/version.variant                    |    2 +-
 osfmk/ddb/db_access.c                         |   65 +-
 osfmk/ddb/db_access.h                         |   23 +-
 osfmk/ddb/db_aout.c                           |   23 +-
 osfmk/ddb/db_aout.h                           |   23 +-
 osfmk/ddb/db_break.c                          |   29 +-
 osfmk/ddb/db_break.h                          |   25 +-
 osfmk/ddb/db_coff.h                           |   23 +-
 osfmk/ddb/db_command.c                        |   88 +-
 osfmk/ddb/db_command.h                        |   25 +-
 osfmk/ddb/db_cond.c                           |   23 +-
 osfmk/ddb/db_cond.h                           |   23 +-
 osfmk/ddb/db_examine.c                        |  281 +-
 osfmk/ddb/db_examine.h                        |   23 +-
 osfmk/ddb/db_expr.c                           |  121 +-
 osfmk/ddb/db_expr.h                           |   23 +-
 osfmk/ddb/db_ext_symtab.c                     |   90 +-
 osfmk/ddb/db_input.c                          |   25 +-
 osfmk/ddb/db_input.h                          |   23 +-
 osfmk/ddb/db_lex.c                            |   23 +-
 osfmk/ddb/db_lex.h                            |   25 +-
 osfmk/ddb/db_macro.c                          |   99 +-
 osfmk/ddb/db_macro.h                          |   23 +-
 osfmk/ddb/db_output.c                         |   34 +-
 osfmk/ddb/db_output.h                         |   25 +-
 osfmk/ddb/db_print.c                          |   31 +-
 osfmk/ddb/db_print.h                          |   25 +-
 osfmk/ddb/db_run.c                            |   23 +-
 osfmk/ddb/db_run.h                            |   23 +-
 osfmk/ddb/db_sym.c                            |  341 +-
 osfmk/ddb/db_sym.h                            |   25 +-
 osfmk/ddb/db_task_thread.c                    |   92 +-
 osfmk/ddb/db_task_thread.h                    |   25 +-
 osfmk/ddb/db_trap.c                           |   23 +-
 osfmk/ddb/db_trap.h                           |   23 +-
 osfmk/ddb/db_variables.c                      |  155 +-
 osfmk/ddb/db_variables.h                      |   25 +-
 osfmk/ddb/db_watch.c                          |   31 +-
 osfmk/ddb/db_watch.h                          |   25 +-
 osfmk/ddb/db_write_cmd.c                      |   25 +-
 osfmk/ddb/db_write_cmd.h                      |   23 +-
 osfmk/ddb/makedis.c                           |   23 +-
 osfmk/ddb/nlist.h                             |   23 +-
 osfmk/ddb/orig/db_print.c                     |   25 +-
 osfmk/ddb/stab.h                              |   23 +-
 osfmk/ddb/tr.c                                |   23 +-
 osfmk/ddb/tr.h                                |   23 +-
 osfmk/default_pager/default_pager.c           |   27 +-
 osfmk/default_pager/default_pager_alerts.defs |   23 +-
 osfmk/default_pager/default_pager_internal.h  |   23 +-
 osfmk/default_pager/default_pager_object.defs |   23 +-
 osfmk/default_pager/default_pager_types.defs  |   23 +-
 osfmk/default_pager/default_pager_types.h     |   23 +-
 osfmk/default_pager/diag.h                    |   23 +-
 osfmk/default_pager/dp_backing_store.c        |  296 +-
 osfmk/default_pager/dp_memory_object.c        |   53 +-
 osfmk/device/device.defs                      |   23 +-
 osfmk/device/device_init.c                    |   23 +-
 osfmk/device/device_port.h                    |   23 +-
 osfmk/device/device_types.defs                |   23 +-
 osfmk/device/device_types.h                   |   23 +-
 osfmk/device/iokit_rpc.c                      |  135 +-
 osfmk/device/subrs.c                          |   23 +-
 osfmk/i386/AT386/asm_startup.h                |   23 +-
 osfmk/i386/AT386/autoconf.c                   |   23 +-
 osfmk/i386/AT386/bbclock.c                    |   23 +-
 osfmk/i386/AT386/bbclock_entries.h            |   23 +-
 osfmk/i386/AT386/conf.c                       |   23 +-
 osfmk/i386/AT386/config.h                     |   23 +-
 osfmk/i386/AT386/cram.h                       |   25 +-
 osfmk/i386/AT386/himem.c                      |   23 +-
 osfmk/i386/AT386/himem.h                      |   23 +-
 osfmk/i386/AT386/iso_scan_font.h              |   23 +-
 osfmk/i386/AT386/kernBootStruct.h             |   23 +-
 osfmk/i386/AT386/misc_protos.h                |   23 +-
 osfmk/i386/AT386/model_dep.c                  |   29 +-
 osfmk/i386/AT386/mp/boot.h                    |   25 +-
 osfmk/i386/AT386/mp/mp.c                      |   23 +-
 osfmk/i386/AT386/mp/mp.h                      |   23 +-
 osfmk/i386/AT386/mp/mp_events.h               |   23 +-
 osfmk/i386/AT386/mp/mp_v1_1.c                 |   23 +-
 osfmk/i386/AT386/mp/mp_v1_1.h                 |   23 +-
 osfmk/i386/AT386/mp/slave_boot.s              |   23 +-
 osfmk/i386/AT386/physmem_entries.h            |   23 +-
 osfmk/i386/AT386/rtc.h                        |   25 +-
 osfmk/i386/AT386/video_console.c              |   23 +-
 osfmk/i386/AT386/video_console.h              |   23 +-
 osfmk/i386/Makefile                           |   12 +-
 osfmk/i386/_setjmp.s                          |   23 +-
 osfmk/i386/apic.h                             |   23 +-
 osfmk/i386/arch_types.h                       |   23 +-
 osfmk/i386/asm.h                              |   23 +-
 osfmk/i386/ast.h                              |   23 +-
 osfmk/i386/ast_check.c                        |   25 +-
 osfmk/i386/ast_types.h                        |   25 +-
 osfmk/i386/bcopy.s                            |   23 +-
 osfmk/i386/bsd_i386.c                         |   23 +-
 osfmk/i386/bzero.s                            |   23 +-
 osfmk/i386/commpage/commpage.c                |   35 +
 osfmk/i386/commpage/commpage.h                |   31 +
 osfmk/i386/cpu.c                              |   23 +-
 osfmk/i386/cpu_capabilities.h                 |   59 +
 osfmk/i386/cpu_data.h                         |   23 +-
 osfmk/i386/cpu_number.h                       |   23 +-
 osfmk/i386/cpuid.c                            |  773 +-
 osfmk/i386/cpuid.h                            |  190 +-
 osfmk/i386/cswitch.s                          |   23 +-
 osfmk/i386/db_disasm.c                        |   23 +-
 osfmk/i386/db_gcc_aout.c                      |   23 +-
 osfmk/i386/db_interface.c                     |   23 +-
 osfmk/i386/db_machdep.h                       |   23 +-
 osfmk/i386/db_trace.c                         |   23 +-
 osfmk/i386/eflags.h                           |   23 +-
 osfmk/i386/endian.h                           |   23 +-
 osfmk/i386/exec.h                             |   23 +-
 osfmk/i386/flipc_page.h                       |   23 +-
 osfmk/i386/fpu.c                              |   23 +-
 osfmk/i386/fpu.h                              |   23 +-
 osfmk/i386/gcc.s                              |   23 +-
 osfmk/i386/gdb_defs.h                         |   23 +-
 osfmk/i386/gdt.c                              |   23 +-
 osfmk/i386/genassym.c                         |   23 +-
 osfmk/i386/hardclock.c                        |   23 +-
 osfmk/i386/hardclock_entries.h                |   23 +-
 osfmk/i386/hi_res_clock.h                     |   23 +-
 osfmk/i386/hi_res_clock_map.c                 |   23 +-
 osfmk/i386/hw_lock_types.h                    |   23 +-
 osfmk/i386/i386_lock.s                        |   23 +-
 osfmk/i386/idt.s                              |   23 +-
 osfmk/i386/intel_read_fault.h                 |   23 +-
 osfmk/i386/io_emulate.c                       |   23 +-
 osfmk/i386/io_emulate.h                       |   23 +-
 osfmk/i386/io_map.c                           |   23 +-
 osfmk/i386/io_map_entries.h                   |   23 +-
 osfmk/i386/io_port.h                          |   23 +-
 osfmk/i386/iopb.c                             |   23 +-
 osfmk/i386/iopb.h                             |   23 +-
 osfmk/i386/iopb_entries.h                     |   23 +-
 osfmk/i386/ipl.h                              |   23 +-
 osfmk/i386/ktss.c                             |   23 +-
 osfmk/i386/ldt.c                              |   23 +-
 osfmk/i386/lock.h                             |   23 +-
 osfmk/i386/locore.s                           |   96 +-
 osfmk/i386/loose_ends.c                       |   60 +-
 osfmk/i386/mach_param.h                       |   25 +-
 osfmk/i386/machdep_call.c                     |   23 +-
 osfmk/i386/machdep_call.h                     |   23 +-
 osfmk/i386/machine_routines.c                 |   45 +-
 osfmk/i386/machine_routines.h                 |  118 +-
 osfmk/i386/machine_routines_asm.s             |  274 +-
 osfmk/i386/machine_rpc.h                      |   23 +-
 osfmk/i386/machlimits.h                       |   23 +-
 osfmk/i386/machparam.h                        |   25 +-
 osfmk/i386/misc_protos.h                      |   23 +-
 osfmk/i386/mp_desc.c                          |   23 +-
 osfmk/i386/mp_desc.h                          |   23 +-
 osfmk/i386/net_filter.c                       |   23 +-
 osfmk/i386/ntoh.h                             |   23 +-
 osfmk/i386/ntoh.s                             |   25 +-
 osfmk/i386/pcb.c                              |   23 +-
 osfmk/i386/phys.c                             |   23 +-
 osfmk/i386/pic.h                              |   23 +-
 osfmk/i386/pio.h                              |   23 +-
 osfmk/i386/pit.h                              |   23 +-
 osfmk/i386/pmap.c                             |   77 +-
 osfmk/i386/pmap.h                             |   33 +-
 osfmk/i386/proc_reg.h                         |   23 +-
 osfmk/i386/read_fault.c                       |   23 +-
 osfmk/i386/rtclock.c                          |   23 +-
 osfmk/i386/rtclock_entries.h                  |   23 +-
 osfmk/i386/sched_param.h                      |   25 +-
 osfmk/i386/seg.h                              |   23 +-
 osfmk/i386/setjmp.h                           |   25 +-
 osfmk/i386/setjmp.s                           |   23 +-
 osfmk/i386/stab.h                             |   23 +-
 osfmk/i386/start.s                            |   23 +-
 osfmk/i386/task.h                             |   25 +-
 osfmk/i386/thread.h                           |   23 +-
 osfmk/i386/thread_act.h                       |   23 +-
 osfmk/i386/timer.h                            |   23 +-
 osfmk/i386/trap.c                             |   23 +-
 osfmk/i386/trap.h                             |   23 +-
 osfmk/i386/tss.h                              |   23 +-
 osfmk/i386/user_ldt.c                         |   23 +-
 osfmk/i386/user_ldt.h                         |   23 +-
 osfmk/i386/vm_tuning.h                        |   25 +-
 osfmk/i386/xpr.h                              |   23 +-
 osfmk/ipc/ipc_entry.c                         |   23 +-
 osfmk/ipc/ipc_entry.h                         |   23 +-
 osfmk/ipc/ipc_hash.c                          |   23 +-
 osfmk/ipc/ipc_hash.h                          |   23 +-
 osfmk/ipc/ipc_init.c                          |   23 +-
 osfmk/ipc/ipc_init.h                          |   25 +-
 osfmk/ipc/ipc_kmsg.c                          |   44 +-
 osfmk/ipc/ipc_kmsg.h                          |   23 +-
 osfmk/ipc/ipc_machdep.h                       |   23 +-
 osfmk/ipc/ipc_mqueue.c                        |   23 +-
 osfmk/ipc/ipc_mqueue.h                        |   23 +-
 osfmk/ipc/ipc_notify.c                        |   23 +-
 osfmk/ipc/ipc_notify.h                        |   23 +-
 osfmk/ipc/ipc_object.c                        |   23 +-
 osfmk/ipc/ipc_object.h                        |   23 +-
 osfmk/ipc/ipc_port.c                          |   25 +-
 osfmk/ipc/ipc_port.h                          |   23 +-
 osfmk/ipc/ipc_print.h                         |   23 +-
 osfmk/ipc/ipc_pset.c                          |   23 +-
 osfmk/ipc/ipc_pset.h                          |   23 +-
 osfmk/ipc/ipc_right.c                         |   23 +-
 osfmk/ipc/ipc_right.h                         |   23 +-
 osfmk/ipc/ipc_space.c                         |   23 +-
 osfmk/ipc/ipc_space.h                         |   23 +-
 osfmk/ipc/ipc_splay.c                         |   23 +-
 osfmk/ipc/ipc_splay.h                         |   23 +-
 osfmk/ipc/ipc_table.c                         |   23 +-
 osfmk/ipc/ipc_table.h                         |   33 +-
 osfmk/ipc/ipc_types.h                         |   23 +-
 osfmk/ipc/mach_debug.c                        |   35 +-
 osfmk/ipc/mach_msg.c                          |   29 +-
 osfmk/ipc/mach_port.c                         |   31 +-
 osfmk/ipc/mig_log.c                           |   23 +-
 osfmk/ipc/port.h                              |   23 +-
 osfmk/kdp/kdp.c                               |   23 +-
 osfmk/kdp/kdp.h                               |   23 +-
 osfmk/kdp/kdp_en_debugger.h                   |   23 +-
 osfmk/kdp/kdp_internal.h                      |   23 +-
 osfmk/kdp/kdp_private.h                       |   23 +-
 osfmk/kdp/kdp_protocol.h                      |   23 +-
 osfmk/kdp/kdp_udp.c                           |   25 +-
 osfmk/kdp/kdp_udp.h                           |   23 +-
 osfmk/kdp/ml/i386/kdp_machdep.c               |   23 +-
 osfmk/kdp/ml/i386/kdp_vm.c                    |   23 +-
 osfmk/kdp/ml/ppc/kdp_asm.s                    |   39 +-
 osfmk/kdp/ml/ppc/kdp_machdep.c                |  149 +-
 osfmk/kdp/ml/ppc/kdp_misc.s                   |  103 +-
 osfmk/kdp/ml/ppc/kdp_vm.c                     |  181 +-
 osfmk/kdp/pe/POWERMAC/kdp_mace.c              |  672 --
 osfmk/kdp/pe/POWERMAC/kdp_mace.h              |  389 -
 osfmk/kern/assert.h                           |   23 +-
 osfmk/kern/ast.c                              |   23 +-
 osfmk/kern/ast.h                              |   23 +-
 osfmk/kern/bits.c                             |   23 +-
 osfmk/kern/bsd_kern.c                         |   34 +-
 osfmk/kern/call_entry.h                       |   23 +-
 osfmk/kern/clock.c                            |   23 +-
 osfmk/kern/clock.h                            |   27 +-
 osfmk/kern/counters.c                         |   25 +-
 osfmk/kern/counters.h                         |   25 +-
 osfmk/kern/cpu_data.c                         |   23 +-
 osfmk/kern/cpu_data.h                         |   23 +-
 osfmk/kern/cpu_number.h                       |   23 +-
 osfmk/kern/debug.c                            |   23 +-
 osfmk/kern/debug.h                            |   23 +-
 osfmk/kern/etap.c                             |   23 +-
 osfmk/kern/etap_macros.h                      |   23 +-
 osfmk/kern/etap_map.c                         |   23 +-
 osfmk/kern/etap_map.h                         |   23 +-
 osfmk/kern/etap_options.h                     |   23 +-
 osfmk/kern/etap_pool.c                        |   23 +-
 osfmk/kern/etap_pool.h                        |   23 +-
 osfmk/kern/exception.c                        |   24 +-
 osfmk/kern/exception.h                        |   23 +-
 osfmk/kern/host.c                             |   25 +-
 osfmk/kern/host.h                             |   23 +-
 osfmk/kern/host_statistics.h                  |   23 +-
 osfmk/kern/ipc_clock.c                        |   23 +-
 osfmk/kern/ipc_host.c                         |   23 +-
 osfmk/kern/ipc_host.h                         |   23 +-
 osfmk/kern/ipc_kobject.c                      |   23 +-
 osfmk/kern/ipc_kobject.h                      |   23 +-
 osfmk/kern/ipc_mig.c                          |   23 +-
 osfmk/kern/ipc_mig.h                          |   23 +-
 osfmk/kern/ipc_sync.c                         |   23 +-
 osfmk/kern/ipc_sync.h                         |   23 +-
 osfmk/kern/ipc_tt.c                           |   24 +-
 osfmk/kern/ipc_tt.h                           |   23 +-
 osfmk/kern/kalloc.c                           |   29 +-
 osfmk/kern/kalloc.h                           |   23 +-
 osfmk/kern/kern_print.h                       |   23 +-
 osfmk/kern/kern_types.h                       |   23 +-
 osfmk/kern/kmod.c                             |   29 +-
 osfmk/kern/ledger.c                           |   23 +-
 osfmk/kern/ledger.h                           |   23 +-
 osfmk/kern/lock.c                             |   43 +-
 osfmk/kern/lock.h                             |   23 +-
 osfmk/kern/lock_mon.c                         |   23 +-
 osfmk/kern/mach_clock.c                       |   23 +-
 osfmk/kern/mach_factor.c                      |   23 +-
 osfmk/kern/mach_param.h                       |   23 +-
 osfmk/kern/machine.c                          |   30 +-
 osfmk/kern/machine.h                          |   23 +-
 osfmk/kern/macro_help.h                       |   23 +-
 osfmk/kern/misc_protos.h                      |   25 +-
 osfmk/kern/mk_sp.c                            |   23 +-
 osfmk/kern/mk_sp.h                            |   23 +-
 osfmk/kern/mk_timer.c                         |   23 +-
 osfmk/kern/mk_timer.h                         |   23 +-
 osfmk/kern/norma_protos.h                     |   23 +-
 osfmk/kern/printf.c                           |   42 +-
 osfmk/kern/priority.c                         |   23 +-
 osfmk/kern/processor.c                        |   23 +-
 osfmk/kern/processor.h                        |   23 +-
 osfmk/kern/profile.c                          |   23 +-
 osfmk/kern/profile.h                          |   23 +-
 osfmk/kern/queue.c                            |   25 +-
 osfmk/kern/queue.h                            |   23 +-
 osfmk/kern/sched.h                            |   23 +-
 osfmk/kern/sched_prim.c                       |   29 +-
 osfmk/kern/sched_prim.h                       |   23 +-
 osfmk/kern/simple_lock.h                      |   23 +-
 osfmk/kern/simple_lock_types.h                |   23 +-
 osfmk/kern/spl.c                              |   23 +-
 osfmk/kern/spl.h                              |   23 +-
 osfmk/kern/sscanf.c                           |   23 +-
 osfmk/kern/startup.c                          |   40 +-
 osfmk/kern/startup.h                          |   23 +-
 osfmk/kern/sync_lock.c                        |   23 +-
 osfmk/kern/sync_lock.h                        |   23 +-
 osfmk/kern/sync_sema.c                        |   23 +-
 osfmk/kern/sync_sema.h                        |   23 +-
 osfmk/kern/syscall_emulation.c                |   35 +-
 osfmk/kern/syscall_emulation.h                |   23 +-
 osfmk/kern/syscall_subr.c                     |   23 +-
 osfmk/kern/syscall_subr.h                     |   23 +-
 osfmk/kern/syscall_sw.c                       |   23 +-
 osfmk/kern/syscall_sw.h                       |   23 +-
 osfmk/kern/task.c                             |   52 +-
 osfmk/kern/task.h                             |   26 +-
 osfmk/kern/task_policy.c                      |   23 +-
 osfmk/kern/task_swap.c                        |   23 +-
 osfmk/kern/task_swap.h                        |   25 +-
 osfmk/kern/thread.c                           |   29 +-
 osfmk/kern/thread.h                           |   23 +-
 osfmk/kern/thread_act.c                       |   23 +-
 osfmk/kern/thread_act.h                       |   23 +-
 osfmk/kern/thread_call.c                      |   23 +-
 osfmk/kern/thread_call.h                      |   23 +-
 osfmk/kern/thread_policy.c                    |   23 +-
 osfmk/kern/thread_swap.c                      |   23 +-
 osfmk/kern/thread_swap.h                      |   23 +-
 osfmk/kern/time_out.h                         |   23 +-
 osfmk/kern/timer.c                            |   23 +-
 osfmk/kern/timer.h                            |   23 +-
 osfmk/kern/timer_call.c                       |   23 +-
 osfmk/kern/timer_call.h                       |   23 +-
 osfmk/kern/wait_queue.c                       |   26 +-
 osfmk/kern/wait_queue.h                       |   23 +-
 osfmk/kern/xpr.c                              |   25 +-
 osfmk/kern/xpr.h                              |   25 +-
 osfmk/kern/zalloc.c                           |   79 +-
 osfmk/kern/zalloc.h                           |   23 +-
 osfmk/libsa/ctype.h                           |   23 +-
 osfmk/libsa/errno.h                           |   23 +-
 osfmk/libsa/float.h                           |   23 +-
 osfmk/libsa/i386/float.h                      |   23 +-
 osfmk/libsa/i386/math.h                       |   23 +-
 osfmk/libsa/i386/stdarg.h                     |   23 +-
 osfmk/libsa/i386/types.h                      |   23 +-
 osfmk/libsa/i386/va_list.h                    |   23 +-
 osfmk/libsa/ieeefloat.h                       |   23 +-
 osfmk/libsa/machine/stdarg.h                  |   23 +-
 osfmk/libsa/machine/stdarg_apple.h            |   23 +-
 osfmk/libsa/machine/types.h                   |   23 +-
 osfmk/libsa/machine/va_list.h                 |   23 +-
 osfmk/libsa/math.h                            |   23 +-
 osfmk/libsa/ppc/float.h                       |   23 +-
 osfmk/libsa/ppc/math.h                        |   25 +-
 osfmk/libsa/ppc/stdarg.h                      |   23 +-
 osfmk/libsa/ppc/stdarg_apple.h                |   23 +-
 osfmk/libsa/ppc/types.h                       |   23 +-
 osfmk/libsa/ppc/va_list.h                     |   23 +-
 osfmk/libsa/stdarg.h                          |   23 +-
 osfmk/libsa/stdio.h                           |   23 +-
 osfmk/libsa/stdlib.h                          |   23 +-
 osfmk/libsa/string.h                          |   23 +-
 osfmk/libsa/sys/timers.h                      |   23 +-
 osfmk/libsa/types.h                           |   23 +-
 osfmk/libsa/va_list.h                         |   23 +-
 osfmk/mach-o/loader.h                         |   23 +-
 osfmk/mach-o/mach_header.c                    |   23 +-
 osfmk/mach-o/mach_header.h                    |   23 +-
 osfmk/mach/alert.h                            |   23 +-
 osfmk/mach/boolean.h                          |   25 +-
 osfmk/mach/boot_info.h                        |   25 +-
 osfmk/mach/bootstrap.h                        |   23 +-
 osfmk/mach/clock.defs                         |   23 +-
 osfmk/mach/clock_priv.defs                    |   23 +-
 osfmk/mach/clock_reply.defs                   |   23 +-
 osfmk/mach/clock_types.defs                   |   23 +-
 osfmk/mach/clock_types.h                      |   23 +-
 osfmk/mach/error.h                            |   25 +-
 osfmk/mach/etap.h                             |   23 +-
 osfmk/mach/etap_events.h                      |   23 +-
 osfmk/mach/events_info.h                      |   23 +-
 osfmk/mach/exc.defs                           |   23 +-
 osfmk/mach/exception.h                        |   23 +-
 osfmk/mach/exception_types.h                  |   23 +-
 osfmk/mach/flipc_cb.h                         |   23 +-
 osfmk/mach/flipc_debug.h                      |   23 +-
 osfmk/mach/flipc_device.h                     |   23 +-
 osfmk/mach/flipc_locks.h                      |   23 +-
 osfmk/mach/flipc_types.h                      |   25 +-
 osfmk/mach/host_info.h                        |   23 +-
 osfmk/mach/host_priv.defs                     |   23 +-
 osfmk/mach/host_reboot.h                      |   23 +-
 osfmk/mach/host_security.defs                 |   23 +-
 osfmk/mach/i386/boolean.h                     |   25 +-
 osfmk/mach/i386/exception.h                   |   25 +-
 osfmk/mach/i386/flipc_dep.h                   |   23 +-
 osfmk/mach/i386/fp_reg.h                      |   25 +-
 osfmk/mach/i386/kern_return.h                 |   25 +-
 osfmk/mach/i386/mach_i386.defs                |   25 +-
 osfmk/mach/i386/mach_i386_types.h             |   23 +-
 osfmk/mach/i386/machine_types.defs            |   23 +-
 osfmk/mach/i386/ndr_def.h                     |   23 +-
 osfmk/mach/i386/processor_info.h              |   23 +-
 osfmk/mach/i386/rpc.h                         |   23 +-
 osfmk/mach/i386/syscall_sw.h                  |   25 +-
 osfmk/mach/i386/thread_state.h                |   23 +-
 osfmk/mach/i386/thread_status.h               |   23 +-
 osfmk/mach/i386/vm_param.h                    |   25 +-
 osfmk/mach/i386/vm_types.h                    |   23 +-
 osfmk/mach/kern_return.h                      |   23 +-
 osfmk/mach/kmod.h                             |   23 +-
 osfmk/mach/ledger.defs                        |   23 +-
 osfmk/mach/lock_set.defs                      |   23 +-
 osfmk/mach/mach.h                             |   23 +-
 osfmk/mach/mach_host.defs                     |   23 +-
 osfmk/mach/mach_interface.h                   |   23 +-
 osfmk/mach/mach_norma.defs                    |   25 +-
 osfmk/mach/mach_param.h                       |   25 +-
 osfmk/mach/mach_port.defs                     |   23 +-
 osfmk/mach/mach_syscalls.h                    |   23 +-
 osfmk/mach/mach_time.h                        |   23 +-
 osfmk/mach/mach_traps.h                       |   23 +-
 osfmk/mach/mach_types.defs                    |   23 +-
 osfmk/mach/mach_types.h                       |   23 +-
 osfmk/mach/machine.h                          |   24 +-
 osfmk/mach/machine/asm.h                      |   23 +-
 osfmk/mach/machine/boolean.h                  |   23 +-
 osfmk/mach/machine/exception.h                |   23 +-
 osfmk/mach/machine/kern_return.h              |   23 +-
 osfmk/mach/machine/machine_types.defs         |   23 +-
 osfmk/mach/machine/ndr_def.h                  |   23 +-
 osfmk/mach/machine/processor_info.h           |   23 +-
 osfmk/mach/machine/rpc.h                      |   23 +-
 osfmk/mach/machine/syscall_sw.h               |   23 +-
 osfmk/mach/machine/thread_state.h             |   23 +-
 osfmk/mach/machine/thread_status.h            |   23 +-
 osfmk/mach/machine/vm_param.h                 |   23 +-
 osfmk/mach/machine/vm_types.h                 |   23 +-
 osfmk/mach/memory_object.defs                 |   23 +-
 osfmk/mach/memory_object.h                    |   23 +-
 osfmk/mach/memory_object_control.defs         |   25 +-
 osfmk/mach/memory_object_default.defs         |   23 +-
 osfmk/mach/memory_object_name.defs            |   23 +-
 osfmk/mach/memory_object_types.h              |  102 +-
 osfmk/mach/message.h                          |   23 +-
 osfmk/mach/mig.h                              |   23 +-
 osfmk/mach/mig_errors.h                       |   23 +-
 osfmk/mach/mig_log.h                          |   23 +-
 osfmk/mach/mk_timer.h                         |   23 +-
 osfmk/mach/mk_traps.h                         |   23 +-
 osfmk/mach/msg_type.h                         |   25 +-
 osfmk/mach/ndr.h                              |   23 +-
 osfmk/mach/norma_special_ports.h              |   23 +-
 osfmk/mach/notify.defs                        |   23 +-
 osfmk/mach/notify.h                           |   23 +-
 osfmk/mach/policy.h                           |   23 +-
 osfmk/mach/port.h                             |   23 +-
 osfmk/mach/ppc/boolean.h                      |   25 +-
 osfmk/mach/ppc/exception.h                    |   24 +-
 osfmk/mach/ppc/kern_return.h                  |   25 +-
 osfmk/mach/ppc/machine_types.defs             |   23 +-
 osfmk/mach/ppc/ndr_def.h                      |   23 +-
 osfmk/mach/ppc/processor_info.h               |   29 +-
 osfmk/mach/ppc/rpc.h                          |   23 +-
 osfmk/mach/ppc/syscall_sw.h                   |   26 +-
 osfmk/mach/ppc/thread_state.h                 |   23 +-
 osfmk/mach/ppc/thread_status.h                |   99 +-
 osfmk/mach/ppc/vm_param.h                     |   31 +-
 osfmk/mach/ppc/vm_types.h                     |   32 +-
 osfmk/mach/processor.defs                     |   23 +-
 osfmk/mach/processor_info.h                   |   23 +-
 osfmk/mach/processor_set.defs                 |   23 +-
 osfmk/mach/prof.defs                          |   25 +-
 osfmk/mach/prof_types.h                       |   23 +-
 osfmk/mach/rpc.h                              |   23 +-
 osfmk/mach/semaphore.defs                     |   23 +-
 osfmk/mach/semaphore.h                        |   23 +-
 osfmk/mach/shared_memory_server.h             |   23 +-
 osfmk/mach/std_types.defs                     |   23 +-
 osfmk/mach/std_types.h                        |   23 +-
 osfmk/mach/sync.defs                          |   23 +-
 osfmk/mach/sync_policy.h                      |   23 +-
 osfmk/mach/syscall_sw.h                       |   23 +-
 osfmk/mach/task.defs                          |   23 +-
 osfmk/mach/task_info.h                        |   23 +-
 osfmk/mach/task_ledger.h                      |   23 +-
 osfmk/mach/task_policy.h                      |   23 +-
 osfmk/mach/task_special_ports.h               |   23 +-
 osfmk/mach/thread_act.defs                    |   23 +-
 osfmk/mach/thread_info.h                      |   23 +-
 osfmk/mach/thread_policy.h                    |   23 +-
 osfmk/mach/thread_special_ports.h             |   23 +-
 osfmk/mach/thread_status.h                    |   23 +-
 osfmk/mach/thread_switch.h                    |   23 +-
 osfmk/mach/time_value.h                       |   23 +-
 osfmk/mach/upl.defs                           |   23 +-
 osfmk/mach/vm_attributes.h                    |   23 +-
 osfmk/mach/vm_behavior.h                      |   23 +-
 osfmk/mach/vm_inherit.h                       |   23 +-
 osfmk/mach/vm_map.defs                        |   23 +-
 osfmk/mach/vm_param.h                         |  160 +-
 osfmk/mach/vm_prot.h                          |   23 +-
 osfmk/mach/vm_region.h                        |   23 +-
 osfmk/mach/vm_statistics.h                    |   23 +-
 osfmk/mach/vm_sync.h                          |   23 +-
 osfmk/mach/vm_types.h                         |   51 +-
 osfmk/mach_debug/hash_info.h                  |   25 +-
 osfmk/mach_debug/ipc_info.h                   |   25 +-
 osfmk/mach_debug/mach_debug.h                 |   23 +-
 osfmk/mach_debug/mach_debug_types.defs        |   25 +-
 osfmk/mach_debug/mach_debug_types.h           |   23 +-
 osfmk/mach_debug/page_info.h                  |   25 +-
 osfmk/mach_debug/vm_info.h                    |   23 +-
 osfmk/mach_debug/zone_info.h                  |   25 +-
 osfmk/machine/Makefile                        |    5 +
 osfmk/machine/asm.h                           |   23 +-
 osfmk/machine/ast.h                           |   23 +-
 osfmk/machine/ast_types.h                     |   23 +-
 osfmk/machine/commpage.h                      |   43 +
 osfmk/machine/cpu_capabilities.h              |   40 +
 osfmk/machine/cpu_data.h                      |   23 +-
 osfmk/machine/cpu_number.h                    |   23 +-
 osfmk/machine/db_machdep.h                    |   23 +-
 osfmk/machine/disk.h                          |   23 +-
 osfmk/machine/endian.h                        |   23 +-
 osfmk/machine/gdb_defs.h                      |   23 +-
 osfmk/machine/hw_lock_types.h                 |   23 +-
 osfmk/machine/io_map_entries.h                |   23 +-
 osfmk/machine/iobus.h                         |   23 +-
 osfmk/machine/kgdb_defs.h                     |   23 +-
 osfmk/machine/kgdb_setjmp.h                   |   23 +-
 osfmk/machine/lock.h                          |   23 +-
 osfmk/machine/mach_param.h                    |   23 +-
 osfmk/machine/machine_routines.h              |   23 +-
 osfmk/machine/machine_rpc.h                   |   23 +-
 osfmk/machine/machlimits.h                    |   23 +-
 osfmk/machine/machparam.h                     |   23 +-
 osfmk/machine/pmap.h                          |   23 +-
 osfmk/machine/sched_param.h                   |   23 +-
 osfmk/machine/setjmp.h                        |   23 +-
 osfmk/machine/spl.h                           |   23 +-
 osfmk/machine/task.h                          |   23 +-
 osfmk/machine/thread.h                        |   23 +-
 osfmk/machine/thread_act.h                    |   23 +-
 osfmk/machine/timer.h                         |   23 +-
 osfmk/machine/trap.h                          |   23 +-
 osfmk/machine/vm_tuning.h                     |   23 +-
 osfmk/machine/xpr.h                           |   23 +-
 osfmk/ppc/AltiAssist.s                        |   29 +-
 osfmk/ppc/Diagnostics.c                       |  213 +-
 osfmk/ppc/Diagnostics.h                       |   44 +-
 osfmk/ppc/Emulate.s                           |  473 +-
 osfmk/ppc/Emulate64.s                         |  945 ++
 osfmk/ppc/Firmware.h                          |   38 +-
 osfmk/ppc/Firmware.s                          |  781 +-
 osfmk/ppc/FirmwareC.c                         |   40 +-
 osfmk/ppc/FirmwareCalls.h                     |   28 +-
 osfmk/ppc/MPinterfaces.s                      |   23 +-
 osfmk/ppc/Makefile                            |   10 +-
 osfmk/ppc/POWERMAC/dbdma.c                    |   23 +-
 osfmk/ppc/POWERMAC/dbdma.h                    |   23 +-
 osfmk/ppc/POWERMAC/mp/MPPlugIn.h              |  346 -
 osfmk/ppc/POWERMAC/mp/MP_2p.s                 | 2409 -----
 osfmk/ppc/POWERMAC/mp/mp.c                    |   32 -
 osfmk/ppc/POWERMAC/mp/mp.h                    |   47 -
 osfmk/ppc/POWERMAC/scc_8530.h                 |   23 +-
 osfmk/ppc/POWERMAC/serial_io.c                |  256 +-
 osfmk/ppc/POWERMAC/serial_io.h                |   38 +-
 osfmk/ppc/POWERMAC/video_console.c            |  173 +-
 osfmk/ppc/POWERMAC/video_console.h            |   25 +-
 osfmk/ppc/POWERMAC/video_console_entries.h    |   23 +-
 osfmk/ppc/POWERMAC/video_scroll.s             |   77 +-
 osfmk/ppc/PPCcalls.c                          |   25 +-
 osfmk/ppc/PPCcalls.h                          |   45 +-
 osfmk/ppc/Performance.h                       |   23 +-
 osfmk/ppc/Performance.s                       |   24 +-
 osfmk/ppc/PseudoKernel.c                      |   44 +-
 osfmk/ppc/PseudoKernel.h                      |   23 +-
 osfmk/ppc/_setjmp.s                           |   23 +-
 osfmk/ppc/aligned_data.s                      |  115 +-
 osfmk/ppc/asm.h                               |  179 +-
 osfmk/ppc/ast.h                               |   23 +-
 osfmk/ppc/ast_types.h                         |   23 +-
 osfmk/ppc/atomic_switch.h                     |   23 +-
 osfmk/ppc/atomic_switch.s                     |   51 +-
 osfmk/ppc/bat_init.c                          |   23 +-
 osfmk/ppc/bcopy.s                             |  591 +-
 osfmk/ppc/bcopytest.c                         |  626 ++
 osfmk/ppc/bits.s                              |   23 +-
 osfmk/ppc/boot.h                              |   23 +-
 osfmk/ppc/bsd_asm.s                           |  129 -
 osfmk/ppc/bsd_ppc.c                           |  280 -
 osfmk/ppc/bzero.s                             |  568 +-
 osfmk/ppc/cache.s                             |  436 +-
 osfmk/ppc/clock.h                             |   23 +-
 osfmk/ppc/commpage/bcopy_64.s                 |  301 +
 osfmk/ppc/commpage/bcopy_970.s                |  592 ++
 osfmk/ppc/commpage/bcopy_g3.s                 |  274 +
 osfmk/ppc/commpage/bcopy_g4.s                 |  621 ++
 osfmk/ppc/commpage/bigcopy_970.s              |  499 ++
 osfmk/ppc/commpage/bzero_128.s                |  156 +
 osfmk/ppc/commpage/bzero_32.s                 |  128 +
 osfmk/ppc/commpage/cacheflush.s               |  100 +
 osfmk/ppc/commpage/commpage.c                 |  492 +
 osfmk/ppc/commpage/commpage.h                 |   78 +
 osfmk/ppc/commpage/commpage_asm.s             |  256 +
 osfmk/ppc/commpage/gettimeofday.s             |  212 +
 osfmk/ppc/commpage/mach_absolute_time.s       |   68 +
 osfmk/ppc/commpage/pthread.s                  |  103 +
 osfmk/ppc/commpage/spinlocks.s                |  238 +
 osfmk/ppc/conf.c                              |   23 +-
 osfmk/ppc/console_feed.c                      |   23 +-
 osfmk/ppc/console_feed_entries.h              |   23 +-
 osfmk/ppc/cpu.c                               |  130 +-
 osfmk/ppc/cpu_capabilities.h                  |  160 +
 osfmk/ppc/cpu_data.h                          |   35 +-
 osfmk/ppc/cpu_number.h                        |   23 +-
 osfmk/ppc/cswtch.s                            | 2302 +++--
 osfmk/ppc/db_asm.s                            |   87 +-
 osfmk/ppc/db_disasm.c                         |   24 +-
 osfmk/ppc/db_interface.c                      |  222 +-
 osfmk/ppc/db_low_trace.c                      |  746 +-
 osfmk/ppc/db_low_trace.h                      |   34 +-
 osfmk/ppc/db_machdep.h                        |   38 +-
 osfmk/ppc/db_trace.c                          |  240 +-
 osfmk/ppc/endian.h                            |   23 +-
 osfmk/ppc/exception.h                         |  396 +-
 osfmk/ppc/fpu_protos.h                        |   23 +-
 osfmk/ppc/genassym.c                          |  732 +-
 osfmk/ppc/hardclock_entries.h                 |   23 +-
 osfmk/ppc/hexfont.h                           |   23 +-
 osfmk/ppc/hw_counters.h                       |   80 -
 osfmk/ppc/hw_exception.s                      |  964 +-
 osfmk/ppc/hw_lock.s                           | 2334 +++--
 osfmk/ppc/hw_lock_types.h                     |   23 +-
 osfmk/ppc/hw_perfmon.c                        |  945 ++
 osfmk/ppc/hw_perfmon.h                        |  119 +
 osfmk/ppc/hw_perfmon_mmcr.h                   |  183 +
 osfmk/ppc/hw_vm.s                             | 7975 +++++++++++------
 osfmk/ppc/instrumentation.h                   |   58 +
 osfmk/ppc/interrupt.c                         |   37 +-
 osfmk/ppc/io_map.c                            |   89 +-
 osfmk/ppc/io_map_entries.h                    |   24 +-
 osfmk/ppc/iso_font.h                          |   23 +-
 osfmk/ppc/lock.h                              |   48 +-
 osfmk/ppc/low_trace.h                         |   61 +-
 osfmk/ppc/lowglobals.h                        |   79 +
 osfmk/ppc/lowmem_vectors.s                    | 3778 +++++---
 osfmk/ppc/mach_param.h                        |   25 +-
 osfmk/ppc/machine_cpu.h                       |   23 +-
 osfmk/ppc/machine_routines.c                  |  124 +-
 osfmk/ppc/machine_routines.h                  |   95 +-
 osfmk/ppc/machine_routines_asm.s              | 1023 ++-
 osfmk/ppc/machine_rpc.h                       |   23 +-
 osfmk/ppc/machlimits.h                        |   23 +-
 osfmk/ppc/machparam.h                         |   23 +-
 osfmk/ppc/mappings.c                          | 1913 ++--
 osfmk/ppc/mappings.h                          |  380 +-
 osfmk/ppc/mem.c                               |   91 -
 osfmk/ppc/mem.h                               |   30 +-
 osfmk/ppc/misc.c                              |   23 +-
 osfmk/ppc/misc_asm.s                          |   76 +-
 osfmk/ppc/misc_protos.h                       |   38 +-
 osfmk/ppc/model_dep.c                         |   80 +-
 osfmk/ppc/movc.s                              | 1341 +--
 osfmk/ppc/mp.h                                |   23 +-
 osfmk/ppc/net_filter.c                        |  750 --
 osfmk/ppc/new_screen.h                        |   23 +-
 osfmk/ppc/notify_interrupt.c                  |  209 -
 osfmk/ppc/pcb.c                               |  261 +-
 osfmk/ppc/pmap.c                              | 2138 ++---
 osfmk/ppc/pmap.h                              |  201 +-
 osfmk/ppc/pmap_internals.h                    |  125 -
 osfmk/ppc/ppc_disasm.i                        |   20 +-
 osfmk/ppc/ppc_init.c                          |  302 +-
 osfmk/ppc/ppc_vm_init.c                       |  454 +-
 osfmk/ppc/proc_reg.h                          |  385 +-
 osfmk/ppc/rtclock.c                           |   92 +-
 osfmk/ppc/savearea.c                          |   85 +-
 osfmk/ppc/savearea.h                          |  276 +-
 osfmk/ppc/savearea_asm.s                      | 1704 ++--
 osfmk/ppc/sched_param.h                       |   23 +-
 osfmk/ppc/screen_switch.h                     |   23 +-
 osfmk/ppc/serial_console.c                    |   25 +-
 osfmk/ppc/serial_defs.h                       |   23 +-
 osfmk/ppc/setjmp.h                            |   23 +-
 osfmk/ppc/skiplists.s                         | 1304 +++
 osfmk/ppc/spec_reg.h                          |   33 +-
 osfmk/ppc/start.s                             | 1067 ++-
 osfmk/ppc/status.c                            |  535 +-
 osfmk/ppc/task.h                              |   25 +-
 osfmk/ppc/testjump.c                          |   23 +-
 osfmk/ppc/thread.h                            |   23 +-
 osfmk/ppc/thread_act.h                        |   68 +-
 osfmk/ppc/trap.c                              |  295 +-
 osfmk/ppc/trap.h                              |   28 +-
 osfmk/ppc/vm_tuning.h                         |   23 +-
 osfmk/ppc/vmachmon.c                          |  674 +-
 osfmk/ppc/vmachmon.h                          |  358 +-
 osfmk/ppc/vmachmon_asm.s                      | 1836 +++-
 osfmk/ppc/xpr.h                               |   23 +-
 osfmk/profiling/i386/profile-asm.s            |   23 +-
 osfmk/profiling/i386/profile-md.c             |   23 +-
 osfmk/profiling/i386/profile-md.h             |   23 +-
 osfmk/profiling/machine/profile-md.h          |   23 +-
 osfmk/profiling/ppc/profile-md.h              |   23 +-
 osfmk/profiling/profile-internal.h            |   23 +-
 osfmk/profiling/profile-kgmon.c               |   23 +-
 osfmk/profiling/profile-mk.c                  |   23 +-
 osfmk/profiling/profile-mk.h                  |   23 +-
 osfmk/sys/scsi.h                              |   23 +-
 osfmk/sys/sdi.h                               |   23 +-
 osfmk/sys/sdi_edt.h                           |   23 +-
 osfmk/sys/syslog.h                            |   25 +-
 osfmk/sys/time.h                              |   23 +-
 osfmk/sys/tm.h                                |   23 +-
 osfmk/sys/types.h                             |   23 +-
 osfmk/sys/varargs.h                           |   25 +-
 osfmk/sys/version.h                           |   23 +-
 osfmk/vm/bsd_vm.c                             |   23 +-
 osfmk/vm/cpm.h                                |   23 +-
 osfmk/vm/device_vm.c                          |   27 +-
 osfmk/vm/memory_object.c                      |   49 +-
 osfmk/vm/memory_object.h                      |   23 +-
 osfmk/vm/pmap.h                               |   84 +-
 osfmk/vm/task_working_set.c                   |  116 +-
 osfmk/vm/task_working_set.h                   |   27 +-
 osfmk/vm/vm_debug.c                           |   41 +-
 osfmk/vm/vm_debug.h                           |   23 +-
 osfmk/vm/vm_external.c                        |   29 +-
 osfmk/vm/vm_external.h                        |   25 +-
 osfmk/vm/vm_fault.c                           |  106 +-
 osfmk/vm/vm_fault.h                           |   23 +-
 osfmk/vm/vm_init.c                            |   26 +-
 osfmk/vm/vm_init.h                            |   23 +-
 osfmk/vm/vm_kern.c                            |   54 +-
 osfmk/vm/vm_kern.h                            |   23 +-
 osfmk/vm/vm_map.c                             |  326 +-
 osfmk/vm/vm_map.h                             |   29 +-
 osfmk/vm/vm_object.c                          |  281 +-
 osfmk/vm/vm_object.h                          |   23 +-
 osfmk/vm/vm_page.h                            |   31 +-
 osfmk/vm/vm_pageout.c                         | 1369 ++-
 osfmk/vm/vm_pageout.h                         |   33 +-
 osfmk/vm/vm_print.h                           |   30 +-
 osfmk/vm/vm_resident.c                        |  220 +-
 osfmk/vm/vm_shared_memory_server.c            |  377 +-
 osfmk/vm/vm_shared_memory_server.h            |   52 +-
 osfmk/vm/vm_user.c                            |  533 +-
 pexpert/conf/version.minor                    |    2 +-
 pexpert/conf/version.variant                  |    1 +
 pexpert/gen/bootargs.c                        |   29 +-
 pexpert/gen/device_tree.c                     |   23 +-
 pexpert/gen/pe_gen.c                          |   29 +-
 pexpert/i386/boot_images.h                    |   23 +-
 pexpert/i386/fakePPCDeviceTree.c              |   23 +-
 pexpert/i386/fakePPCDeviceTree.h              |   23 +-
 pexpert/i386/fakePPCStructs.h                 |   23 +-
 pexpert/i386/kd.c                             |   23 +-
 pexpert/i386/kdasm.s                          |   23 +-
 pexpert/i386/pe_bootargs.c                    |   23 +-
 pexpert/i386/pe_identify_machine.c            |   38 +-
 pexpert/i386/pe_init.c                        |   23 +-
 pexpert/i386/pe_interrupt.c                   |   23 +-
 pexpert/i386/pe_kprintf.c                     |   23 +-
 pexpert/i386/pe_misc.s                        |   23 +-
 pexpert/i386/pe_spl.c                         |   23 +-
 pexpert/i386/text_console.c                   |   23 +-
 pexpert/i386/video_console.h                  |   23 +-
 pexpert/pexpert/boot.h                        |   23 +-
 pexpert/pexpert/device_tree.h                 |   23 +-
 pexpert/pexpert/i386/boot.h                   |   23 +-
 pexpert/pexpert/i386/fb_entries.h             |   23 +-
 pexpert/pexpert/i386/kd_entries.h             |   23 +-
 pexpert/pexpert/i386/kdsoft.h                 |   23 +-
 pexpert/pexpert/i386/protos.h                 |   23 +-
 pexpert/pexpert/machine/boot.h                |   23 +-
 pexpert/pexpert/machine/protos.h              |   23 +-
 pexpert/pexpert/pe_images.h                   |   23 +-
 pexpert/pexpert/pexpert.h                     |   36 +-
 pexpert/pexpert/ppc/boot.h                    |   26 +-
 pexpert/pexpert/ppc/dbdma.h                   |   23 +-
 pexpert/pexpert/ppc/interrupts.h              |   23 +-
 pexpert/pexpert/ppc/powermac.h                |   23 +-
 pexpert/pexpert/ppc/protos.h                  |  115 +-
 pexpert/pexpert/protos.h                      |   23 +-
 pexpert/ppc/pe_bootargs.c                     |   23 +-
 pexpert/ppc/pe_clock_speed.c                  |   37 +-
 pexpert/ppc/pe_clock_speed_asm.s              |   23 +-
 pexpert/ppc/pe_identify_machine.c             |  173 +-
 pexpert/ppc/pe_init.c                         |   32 +-
 pexpert/ppc/pe_kprintf.c                      |   47 +-
 pexpert/ppc/pe_misc.s                         |   23 +-
 1878 files changed, 66727 insertions(+), 46818 deletions(-)
 create mode 100644 bsd/dev/memdev.c
 create mode 100644 bsd/dev/memdev.h
 create mode 100644 config/Makefile
 create mode 100644 config/System.kext/Contents/Info.plist
 create mode 100644 config/System.kext/Contents/PlugIns/AppleNMI.kext/Contents/Info.plist
 create mode 100644 config/System.kext/Contents/PlugIns/ApplePlatformFamily.kext/Contents/Info.plist
 create mode 100644 config/System.kext/Contents/PlugIns/BSDKernel.kext/Contents/Info.plist
 create mode 100644 config/System.kext/Contents/PlugIns/IOADBFamily.kext/Contents/Info.plist
 create mode 100644 config/System.kext/Contents/PlugIns/IOKit.kext/Contents/Info.plist
 create mode 100644 config/System.kext/Contents/PlugIns/IONVRAMFamily.kext/Contents/Info.plist
 create mode 100644 config/System.kext/Contents/PlugIns/IOSystemManagement.kext/Contents/Info.plist
 create mode 100644 config/System.kext/Contents/PlugIns/Libkern.kext/Contents/Info.plist
 create mode 100644 config/System.kext/Contents/PlugIns/Mach.kext/Contents/Info.plist
 create mode 100644 iokit/IOKit/IOMapper.h
 delete mode 100644 iokit/IOKit/pci/IOAGPDevice.h
 delete mode 100644 iokit/IOKit/pci/IOPCIBridge.h
 delete mode 100644 iokit/IOKit/pci/Makefile
 create mode 100644 iokit/Kernel/IOMapper.cpp
 create mode 100644 osfmk/i386/commpage/commpage.c
 create mode 100644 osfmk/i386/commpage/commpage.h
 create mode 100644 osfmk/i386/cpu_capabilities.h
 delete mode 100644 osfmk/kdp/pe/POWERMAC/kdp_mace.c
 delete mode 100644 osfmk/kdp/pe/POWERMAC/kdp_mace.h
 create mode 100644 osfmk/machine/commpage.h
 create mode 100644 osfmk/machine/cpu_capabilities.h
 create mode 100644 osfmk/ppc/Emulate64.s
 delete mode 100644 osfmk/ppc/POWERMAC/mp/MPPlugIn.h
 delete mode 100644 osfmk/ppc/POWERMAC/mp/MP_2p.s
 delete mode 100644 osfmk/ppc/POWERMAC/mp/mp.c
 delete mode 100644 osfmk/ppc/POWERMAC/mp/mp.h
 create mode 100644 osfmk/ppc/bcopytest.c
 delete mode 100644 osfmk/ppc/bsd_asm.s
 delete mode 100644 osfmk/ppc/bsd_ppc.c
 create mode 100644 osfmk/ppc/commpage/bcopy_64.s
 create mode 100644 osfmk/ppc/commpage/bcopy_970.s
 create mode 100644 osfmk/ppc/commpage/bcopy_g3.s
 create mode 100644 osfmk/ppc/commpage/bcopy_g4.s
 create mode 100644 osfmk/ppc/commpage/bigcopy_970.s
 create mode 100644 osfmk/ppc/commpage/bzero_128.s
 create mode 100644 osfmk/ppc/commpage/bzero_32.s
 create mode 100644 osfmk/ppc/commpage/cacheflush.s
 create mode 100644 osfmk/ppc/commpage/commpage.c
 create mode 100644 osfmk/ppc/commpage/commpage.h
 create mode 100644 osfmk/ppc/commpage/commpage_asm.s
 create mode 100644 osfmk/ppc/commpage/gettimeofday.s
 create mode 100644 osfmk/ppc/commpage/mach_absolute_time.s
 create mode 100644 osfmk/ppc/commpage/pthread.s
 create mode 100644 osfmk/ppc/commpage/spinlocks.s
 create mode 100644 osfmk/ppc/cpu_capabilities.h
 delete mode 100644 osfmk/ppc/hw_counters.h
 create mode 100644 osfmk/ppc/hw_perfmon.c
 create mode 100644 osfmk/ppc/hw_perfmon.h
 create mode 100644 osfmk/ppc/hw_perfmon_mmcr.h
 create mode 100644 osfmk/ppc/instrumentation.h
 create mode 100644 osfmk/ppc/lowglobals.h
 delete mode 100644 osfmk/ppc/mem.c
 delete mode 100644 osfmk/ppc/net_filter.c
 delete mode 100644 osfmk/ppc/notify_interrupt.c
 delete mode 100644 osfmk/ppc/pmap_internals.h
 create mode 100644 osfmk/ppc/skiplists.s

diff --git a/APPLE_LICENSE b/APPLE_LICENSE
index a0a84169d..fe81a60ca 100644
--- a/APPLE_LICENSE
+++ b/APPLE_LICENSE
@@ -1,26 +1,19 @@
 APPLE PUBLIC SOURCE LICENSE
-Version 1.1 - April 19,1999
+Version 2.0 - August 6, 2003
 
 Please read this License carefully before downloading this software.
-By downloading and using this software, you are agreeing to be bound
-by the terms of this License.  If you do not or cannot agree to the
-terms of this License, please do not download or use the software.
-
-1. General; Definitions.  This License applies to any program or other
-work which Apple Computer, Inc. ("Apple") publicly announces as
-subject to this Apple Public Source License and which contains a
-notice placed by Apple identifying such program or work as "Original
-Code" and stating that it is subject to the terms of this Apple Public
-Source License version 1.1 (or subsequent version thereof), as it may
-be revised from time to time by Apple ("License").  As used in this
-License:
-
-1.1 "Affected Original Code" means only those specific portions of
-Original Code that allegedly infringe upon any party's intellectual
-property rights or are otherwise the subject of a claim of
-infringement.
-
-1.2 "Applicable Patent Rights" mean: (a) in the case where Apple is
+By downloading or using this software, you are agreeing to be bound by
+the terms of this License. If you do not or cannot agree to the terms
+of this License, please do not download or use the software.
+
+1. General; Definitions. This License applies to any program or other
+work which Apple Computer, Inc. ("Apple") makes publicly available and
+which contains a notice placed by Apple identifying such program or
+work as "Original Code" and stating that it is subject to the terms of
+this Apple Public Source License version 2.0 ("License"). As used in
+this License:
+
+1.1 "Applicable Patent Rights" mean: (a) in the case where Apple is
 the grantor of rights, (i) claims of patents that are now or hereafter
 acquired, owned by or assigned to Apple and (ii) that cover subject
 matter contained in the Original Code, but only to the extent
@@ -30,22 +23,27 @@ rights, (i) claims of patents that are now or hereafter acquired,
 owned by or assigned to You and (ii) that cover subject matter in Your
 Modifications, taken alone or in combination with Original Code.
 
+1.2 "Contributor" means any person or entity that creates or
+contributes to the creation of Modifications.
+
 1.3 "Covered Code" means the Original Code, Modifications, the
 combination of Original Code and any Modifications, and/or any
 respective portions thereof.
 
-1.4 "Deploy" means to use, sublicense or distribute Covered Code other
-than for Your internal research and development (R&D), and includes
-without limitation, any and all internal use or distribution of
-Covered Code within Your business or organization except for R&D use,
-as well as direct or indirect sublicensing or distribution of Covered
-Code by You to any third party in any form or manner.
+1.4 "Externally Deploy" means: (a) to sublicense, distribute or
+otherwise make Covered Code available, directly or indirectly, to
+anyone other than You; and/or (b) to use Covered Code, alone or as
+part of a Larger Work, in any way to provide a service, including but
+not limited to delivery of content, through electronic communication
+with a client other than You.
 
 1.5 "Larger Work" means a work which combines Covered Code or portions
 thereof with code not governed by the terms of this License.
 
 1.6 "Modifications" mean any addition to, deletion from, and/or change
-to, the substance and/or structure of Covered Code.  When code is
+to, the substance and/or structure of the Original Code, any previous
+Modifications, the combination of Original Code and any previous
+Modifications, and/or any respective portions thereof. When code is
 released as a series of files, a Modification is: (a) any addition to
 or deletion from the contents of a file containing Covered Code;
 and/or (b) any new file or other representation of computer program
@@ -66,7 +64,7 @@ scripts used to control compilation and installation of an executable
 (object code).
 
 1.9 "You" or "Your" means an individual or a legal entity exercising
-rights under this License.  For legal entities, "You" or "Your"
+rights under this License. For legal entities, "You" or "Your"
 includes any entity which controls, is controlled by, or is under
 common control with, You, where "control" means (a) the power, direct
 or indirect, to cause the direction or management of such entity,
@@ -74,258 +72,253 @@ whether by contract or otherwise, or (b) ownership of fifty percent
 (50%) or more of the outstanding shares or beneficial ownership of
 such entity.
 
-2. Permitted Uses; Conditions & Restrictions.  Subject to the terms
+2. Permitted Uses; Conditions & Restrictions. Subject to the terms
 and conditions of this License, Apple hereby grants You, effective on
 the date You accept this License and download the Original Code, a
-world-wide, royalty-free, non- exclusive license, to the extent of
+world-wide, royalty-free, non-exclusive license, to the extent of
 Apple's Applicable Patent Rights and copyrights covering the Original
 Code, to do the following:
 
-2.1 You may use, copy, modify and distribute Original Code, with or
-without Modifications, solely for Your internal research and
-development, provided that You must in each instance:
-
-(a) retain and reproduce in all copies of Original Code the copyright
-and other proprietary notices and disclaimers of Apple as they appear
-in the Original Code, and keep intact all notices in the Original Code
-that refer to this License;
-
-(b) include a copy of this License with every copy of Source Code of
-Covered Code and documentation You distribute, and You may not offer
-or impose any terms on such Source Code that alter or restrict this
-License or the recipients' rights hereunder, except as permitted under
-Section 6; and
-
-(c) completely and accurately document all Modifications that you have
-made and the date of each such Modification, designate the version of
-the Original Code you used, prominently include a file carrying such
-information with the Modifications, and duplicate the notice in
-Exhibit A in each file of the Source Code of all such Modifications.
-
-2.2 You may Deploy Covered Code, provided that You must in each
-  instance:
-
-(a) satisfy all the conditions of Section 2.1 with respect to the
-Source Code of the Covered Code;
-
-(b) make all Your Deployed Modifications publicly available in Source
-Code form via electronic distribution (e.g. download from a web site)
-under the terms of this License and subject to the license grants set
-forth in Section 3 below, and any additional terms You may choose to
-offer under Section 6.  You must continue to make the Source Code of
-Your Deployed Modifications available for as long as you Deploy the
-Covered Code or twelve (12) months from the date of initial
-Deployment, whichever is longer;
-
-(c) if You Deploy Covered Code containing Modifications made by You,
-inform others of how to obtain those Modifications by filling out and
-submitting the information found at
-http://www.apple.com/publicsource/modifications.html, if available;
-and
-
-(d) if You Deploy Covered Code in object code, executable form only,
-include a prominent notice, in the code itself as well as in related
-documentation, stating that Source Code of the Covered Code is
-available under the terms of this License with information on how and
-where to obtain such Source Code.
-
-3. Your Grants.  In consideration of, and as a condition to, the
-licenses granted to You under this License:
-
-(a) You hereby grant to Apple and all third parties a non-exclusive,
-royalty-free license, under Your Applicable Patent Rights and other
-intellectual property rights owned or controlled by You, to use,
-reproduce, modify, distribute and Deploy Your Modifications of the
-same scope and extent as Apple's licenses under Sections 2.1 and 2.2;
-and
-
-(b) You hereby grant to Apple and its subsidiaries a non-exclusive,
-worldwide, royalty-free, perpetual and irrevocable license, under Your
-Applicable Patent Rights and other intellectual property rights owned
-or controlled by You, to use, reproduce, execute, compile, display,
-perform, modify or have modified (for Apple and/or its subsidiaries),
-sublicense and distribute Your Modifications, in any form, through
-multiple tiers of distribution.
-
-4. Larger Works.  You may create a Larger Work by combining Covered
+2.1 Unmodified Code. You may use, reproduce, display, perform,
+internally distribute within Your organization, and Externally Deploy
+verbatim, unmodified copies of the Original Code, for commercial or
+non-commercial purposes, provided that in each instance:
+
+(a) You must retain and reproduce in all copies of Original Code the
+copyright and other proprietary notices and disclaimers of Apple as
+they appear in the Original Code, and keep intact all notices in the
+Original Code that refer to this License; and
+
+(b) You must include a copy of this License with every copy of Source
+Code of Covered Code and documentation You distribute or Externally
+Deploy, and You may not offer or impose any terms on such Source Code
+that alter or restrict this License or the recipients' rights
+hereunder, except as permitted under Section 6.
+
+2.2 Modified Code. You may modify Covered Code and use, reproduce,
+display, perform, internally distribute within Your organization, and
+Externally Deploy Your Modifications and Covered Code, for commercial
+or non-commercial purposes, provided that in each instance You also
+meet all of these conditions:
+
+(a) You must satisfy all the conditions of Section 2.1 with respect to
+the Source Code of the Covered Code;
+
+(b) You must duplicate, to the extent it does not already exist, the
+notice in Exhibit A in each file of the Source Code of all Your
+Modifications, and cause the modified files to carry prominent notices
+stating that You changed the files and the date of any change; and
+
+(c) If You Externally Deploy Your Modifications, You must make
+Source Code of all Your Externally Deployed Modifications either
+available to those to whom You have Externally Deployed Your
+Modifications, or publicly available. Source Code of Your Externally
+Deployed Modifications must be released under the terms set forth in
+this License, including the license grants set forth in Section 3
+below, for as long as you Externally Deploy the Covered Code or twelve
+(12) months from the date of initial External Deployment, whichever is
+longer. You should preferably distribute the Source Code of Your
+Externally Deployed Modifications electronically (e.g. download from a
+web site).
+
+2.3 Distribution of Executable Versions. In addition, if You
+Externally Deploy Covered Code (Original Code and/or Modifications) in
+object code, executable form only, You must include a prominent
+notice, in the code itself as well as in related documentation,
+stating that Source Code of the Covered Code is available under the
+terms of this License with information on how and where to obtain such
+Source Code.
+
+2.4 Third Party Rights. You expressly acknowledge and agree that
+although Apple and each Contributor grants the licenses to their
+respective portions of the Covered Code set forth herein, no
+assurances are provided by Apple or any Contributor that the Covered
+Code does not infringe the patent or other intellectual property
+rights of any other entity. Apple and each Contributor disclaim any
+liability to You for claims brought by any other entity based on
+infringement of intellectual property rights or otherwise. As a
+condition to exercising the rights and licenses granted hereunder, You
+hereby assume sole responsibility to secure any other intellectual
+property rights needed, if any. For example, if a third party patent
+license is required to allow You to distribute the Covered Code, it is
+Your responsibility to acquire that license before distributing the
+Covered Code.
+
+3. Your Grants. In consideration of, and as a condition to, the
+licenses granted to You under this License, You hereby grant to any
+person or entity receiving or distributing Covered Code under this
+License a non-exclusive, royalty-free, perpetual, irrevocable license,
+under Your Applicable Patent Rights and other intellectual property
+rights (other than patent) owned or controlled by You, to use,
+reproduce, display, perform, modify, sublicense, distribute and
+Externally Deploy Your Modifications of the same scope and extent as
+Apple's licenses under Sections 2.1 and 2.2 above.
+
+4. Larger Works. You may create a Larger Work by combining Covered
 Code with other code not governed by the terms of this License and
-distribute the Larger Work as a single product.  In each such
-instance, You must make sure the requirements of this License are
-fulfilled for the Covered Code or any portion thereof.
+distribute the Larger Work as a single product. In each such instance,
+You must make sure the requirements of this License are fulfilled for
+the Covered Code or any portion thereof.
 
-5. Limitations on Patent License.  Except as expressly stated in
+5. Limitations on Patent License. Except as expressly stated in
 Section 2, no other patent rights, express or implied, are granted by
-Apple herein.  Modifications and/or Larger Works may require
-additional patent licenses from Apple which Apple may grant in its
-sole discretion.
-
-6. Additional Terms.  You may choose to offer, and to charge a fee
-for, warranty, support, indemnity or liability obligations and/or
-other rights consistent with the scope of the license granted herein
-("Additional Terms") to one or more recipients of Covered
-Code. However, You may do so only on Your own behalf and as Your sole
-responsibility, and not on behalf of Apple. You must obtain the
-recipient's agreement that any such Additional Terms are offered by
-You alone, and You hereby agree to indemnify, defend and hold Apple
-harmless for any liability incurred by or claims asserted against
-Apple by reason of any such Additional Terms.
-
-7. Versions of the License.  Apple may publish revised and/or new
-versions of this License from time to time.  Each version will be
-given a distinguishing version number.  Once Original Code has been
-published under a particular version of this License, You may continue
-to use it under the terms of that version. You may also choose to use
-such Original Code under the terms of any subsequent version of this
-License published by Apple.  No one other than Apple has the right to
+Apple herein. Modifications and/or Larger Works may require additional
+patent licenses from Apple which Apple may grant in its sole
+discretion.
+
+6. Additional Terms. You may choose to offer, and to charge a fee for,
+warranty, support, indemnity or liability obligations and/or other
+rights consistent with the scope of the license granted herein
+("Additional Terms") to one or more recipients of Covered Code.
+However, You may do so only on Your own behalf and as Your sole
+responsibility, and not on behalf of Apple or any Contributor. You
+must obtain the recipient's agreement that any such Additional Terms
+are offered by You alone, and You hereby agree to indemnify, defend
+and hold Apple and every Contributor harmless for any liability
+incurred by or claims asserted against Apple or such Contributor by
+reason of any such Additional Terms.
+
+7. Versions of the License. Apple may publish revised and/or new
+versions of this License from time to time. Each version will be given
+a distinguishing version number. Once Original Code has been published
+under a particular version of this License, You may continue to use it
+under the terms of that version. You may also choose to use such
+Original Code under the terms of any subsequent version of this
+License published by Apple. No one other than Apple has the right to
 modify the terms applicable to Covered Code created under this
 License.
 
-8. NO WARRANTY OR SUPPORT.  The Original Code may contain in whole or
-in part pre-release, untested, or not fully tested works.  The
-Original Code may contain errors that could cause failures or loss of
-data, and may be incomplete or contain inaccuracies.  You expressly
-acknowledge and agree that use of the Original Code, or any portion
-thereof, is at Your sole and entire risk.  THE ORIGINAL CODE IS
-PROVIDED "AS IS" AND WITHOUT WARRANTY, UPGRADES OR SUPPORT OF ANY KIND
-AND APPLE AND APPLE'S LICENSOR(S) (FOR THE PURPOSES OF SECTIONS 8 AND
-9, APPLE AND APPLE'S LICENSOR(S) ARE COLLECTIVELY REFERRED TO AS
-"APPLE") EXPRESSLY DISCLAIM ALL WARRANTIES AND/OR CONDITIONS, EXPRESS
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-AND/OR CONDITIONS OF MERCHANTABILITY OR SATISFACTORY QUALITY AND
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
-RIGHTS.  APPLE DOES NOT WARRANT THAT THE FUNCTIONS CONTAINED IN THE
-ORIGINAL CODE WILL MEET YOUR REQUIREMENTS, OR THAT THE OPERATION OF
-THE ORIGINAL CODE WILL BE UNINTERRUPTED OR ERROR- FREE, OR THAT
-DEFECTS IN THE ORIGINAL CODE WILL BE CORRECTED.  NO ORAL OR WRITTEN
-INFORMATION OR ADVICE GIVEN BY APPLE OR AN APPLE AUTHORIZED
-REPRESENTATIVE SHALL CREATE A WARRANTY OR IN ANY WAY INCREASE THE
-SCOPE OF THIS WARRANTY.  You acknowledge that the Original Code is not
-intended for use in the operation of nuclear facilities, aircraft
-navigation, communication systems, or air traffic control machines in
-which case the failure of the Original Code could lead to death,
-personal injury, or severe physical or environmental damage.
-
-9. Liability.
-
-9.1 Infringement.  If any portion of, or functionality implemented by,
-the Original Code becomes the subject of a claim of infringement,
-Apple may, at its option: (a) attempt to procure the rights necessary
-for Apple and You to continue using the Affected Original Code; (b)
-modify the Affected Original Code so that it is no longer infringing;
-or (c) suspend Your rights to use, reproduce, modify, sublicense and
-distribute the Affected Original Code until a final determination of
-the claim is made by a court or governmental administrative agency of
-competent jurisdiction and Apple lifts the suspension as set forth
-below.  Such suspension of rights will be effective immediately upon
-Apple's posting of a notice to such effect on the Apple web site that
-is used for implementation of this License.  Upon such final
-determination being made, if Apple is legally able, without the
-payment of a fee or royalty, to resume use, reproduction,
-modification, sublicensing and distribution of the Affected Original
-Code, Apple will lift the suspension of rights to the Affected
-Original Code by posting a notice to such effect on the Apple web site
-that is used for implementation of this License.  If Apple suspends
-Your rights to Affected Original Code, nothing in this License shall
-be construed to restrict You, at Your option and subject to applicable
-law, from replacing the Affected Original Code with non-infringing
-code or independently negotiating for necessary rights from such third
-party.
-
-9.2 LIMITATION OF LIABILITY.  UNDER NO CIRCUMSTANCES SHALL APPLE BE
-LIABLE FOR ANY INCIDENTAL, SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES
-ARISING OUT OF OR RELATING TO THIS LICENSE OR YOUR USE OR INABILITY TO
-USE THE ORIGINAL CODE, OR ANY PORTION THEREOF, WHETHER UNDER A THEORY
-OF CONTRACT, WARRANTY, TORT (INCLUDING NEGLIGENCE), PRODUCTS LIABILITY
-OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGES AND NOTWITHSTANDING THE FAILURE OF ESSENTIAL PURPOSE OF
-ANY REMEDY.  In no event shall Apple's total liability to You for all
-damages under this License exceed the amount of fifty dollars
-($50.00).
-
-10. Trademarks.  This License does not grant any rights to use the
-trademarks or trade names "Apple", "Apple Computer", "Mac OS X", "Mac
-OS X Server" or any other trademarks or trade names belonging to Apple
-(collectively "Apple Marks") and no Apple Marks may be used to endorse
-or promote products derived from the Original Code other than as
-permitted by and in strict compliance at all times with Apple's third
-party trademark usage guidelines which are posted at
-http://www.apple.com/legal/guidelinesfor3rdparties.html.
-
-11. Ownership.  Apple retains all rights, title and interest in and to
-the Original Code and any Modifications made by or on behalf of Apple
-("Apple Modifications"), and such Apple Modifications will not be
-automatically subject to this License.  Apple may, at its sole
-discretion, choose to license such Apple Modifications under this
-License, or on different terms from those contained in this License or
-may choose not to license them at all.  Apple's development, use,
-reproduction, modification, sublicensing and distribution of Covered
-Code will not be subject to this License.
+8. NO WARRANTY OR SUPPORT. The Covered Code may contain in whole or in
+part pre-release, untested, or not fully tested works. The Covered
+Code may contain errors that could cause failures or loss of data, and
+may be incomplete or contain inaccuracies. You expressly acknowledge
+and agree that use of the Covered Code, or any portion thereof, is at
+Your sole and entire risk. THE COVERED CODE IS PROVIDED "AS IS" AND
+WITHOUT WARRANTY, UPGRADES OR SUPPORT OF ANY KIND AND APPLE AND
+APPLE'S LICENSOR(S) (COLLECTIVELY REFERRED TO AS "APPLE" FOR THE
+PURPOSES OF SECTIONS 8 AND 9) AND ALL CONTRIBUTORS EXPRESSLY DISCLAIM
+ALL WARRANTIES AND/OR CONDITIONS, EXPRESS OR IMPLIED, INCLUDING, BUT
+NOT LIMITED TO, THE IMPLIED WARRANTIES AND/OR CONDITIONS OF
+MERCHANTABILITY, OF SATISFACTORY QUALITY, OF FITNESS FOR A PARTICULAR
+PURPOSE, OF ACCURACY, OF QUIET ENJOYMENT, AND NONINFRINGEMENT OF THIRD
+PARTY RIGHTS. APPLE AND EACH CONTRIBUTOR DOES NOT WARRANT AGAINST
+INTERFERENCE WITH YOUR ENJOYMENT OF THE COVERED CODE, THAT THE
+FUNCTIONS CONTAINED IN THE COVERED CODE WILL MEET YOUR REQUIREMENTS,
+THAT THE OPERATION OF THE COVERED CODE WILL BE UNINTERRUPTED OR
+ERROR-FREE, OR THAT DEFECTS IN THE COVERED CODE WILL BE CORRECTED. NO
+ORAL OR WRITTEN INFORMATION OR ADVICE GIVEN BY APPLE, AN APPLE
+AUTHORIZED REPRESENTATIVE OR ANY CONTRIBUTOR SHALL CREATE A WARRANTY.
+You acknowledge that the Covered Code is not intended for use in the
+operation of nuclear facilities, aircraft navigation, communication
+systems, or air traffic control machines in which case the failure of
+the Covered Code could lead to death, personal injury, or severe
+physical or environmental damage.
+
+9. LIMITATION OF LIABILITY. TO THE EXTENT NOT PROHIBITED BY LAW, IN NO
+EVENT SHALL APPLE OR ANY CONTRIBUTOR BE LIABLE FOR ANY INCIDENTAL,
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING
+TO THIS LICENSE OR YOUR USE OR INABILITY TO USE THE COVERED CODE, OR
+ANY PORTION THEREOF, WHETHER UNDER A THEORY OF CONTRACT, WARRANTY,
+TORT (INCLUDING NEGLIGENCE), PRODUCTS LIABILITY OR OTHERWISE, EVEN IF
+APPLE OR SUCH CONTRIBUTOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES AND NOTWITHSTANDING THE FAILURE OF ESSENTIAL PURPOSE OF ANY
+REMEDY. SOME JURISDICTIONS DO NOT ALLOW THE LIMITATION OF LIABILITY OF
+INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS LIMITATION MAY NOT APPLY
+TO YOU. In no event shall Apple's total liability to You for all
+damages (other than as may be required by applicable law) under this
+License exceed the amount of fifty dollars ($50.00).
+
+10. Trademarks. This License does not grant any rights to use the
+trademarks or trade names "Apple", "Apple Computer", "Mac", "Mac OS",
+"QuickTime", "QuickTime Streaming Server" or any other trademarks,
+service marks, logos or trade names belonging to Apple (collectively
+"Apple Marks") or to any trademark, service mark, logo or trade name
+belonging to any Contributor. You agree not to use any Apple Marks in
+or as part of the name of products derived from the Original Code or
+to endorse or promote products derived from the Original Code other
+than as expressly permitted by and in strict compliance at all times
+with Apple's third party trademark usage guidelines which are posted
+at http://www.apple.com/legal/guidelinesfor3rdparties.html.
+
+11. Ownership. Subject to the licenses granted under this License,
+each Contributor retains all rights, title and interest in and to any
+Modifications made by such Contributor. Apple retains all rights,
+title and interest in and to the Original Code and any Modifications
+made by or on behalf of Apple ("Apple Modifications"), and such Apple
+Modifications will not be automatically subject to this License. Apple
+may, at its sole discretion, choose to license such Apple
+Modifications under this License, or on different terms from those
+contained in this License or may choose not to license them at all.
 
 12. Termination.
 
-12.1 Termination.  This License and the rights granted hereunder will
-   terminate:
+12.1 Termination. This License and the rights granted hereunder will
+terminate:
 
 (a) automatically without notice from Apple if You fail to comply with
 any term(s) of this License and fail to cure such breach within 30
-days of becoming aware of such breach; (b) immediately in the event of
-the circumstances described in Section 13.5(b); or (c) automatically
-without notice from Apple if You, at any time during the term of this
-License, commence an action for patent infringement against Apple.
-
-12.2 Effect of Termination.  Upon termination, You agree to
-immediately stop any further use, reproduction, modification,
-sublicensing and distribution of the Covered Code and to destroy all
-copies of the Covered Code that are in your possession or control.
-All sublicenses to the Covered Code which have been properly granted
-prior to termination shall survive any termination of this License.
-Provisions which, by their nature, should remain in effect beyond the
-termination of this License shall survive, including but not limited
-to Sections 3, 5, 8, 9, 10, 11, 12.2 and 13.  Neither party will be
-liable to the other for compensation, indemnity or damages of any sort
-solely as a result of terminating this License in accordance with its
-terms, and termination of this License will be without prejudice to
-any other right or remedy of either party.
-
-13.  Miscellaneous.
-
-13.1 Government End Users.  The Covered Code is a "commercial item" as
-defined in FAR 2.101.  Government software and technical data rights
-in the Covered Code include only those rights customarily provided to
-the public as defined in this License. This customary commercial
-license in technical data and software is provided in accordance with
-FAR 12.211 (Technical Data) and 12.212 (Computer Software) and, for
+days of becoming aware of such breach;
+
+(b) immediately in the event of the circumstances described in Section
+13.5(b); or
+
+(c) automatically without notice from Apple if You, at any time during
+the term of this License, commence an action for patent infringement
+against Apple; provided that Apple did not first commence
+an action for patent infringement against You in that instance.
+
+12.2 Effect of Termination. Upon termination, You agree to immediately
+stop any further use, reproduction, modification, sublicensing and
+distribution of the Covered Code. All sublicenses to the Covered Code
+which have been properly granted prior to termination shall survive
+any termination of this License. Provisions which, by their nature,
+should remain in effect beyond the termination of this License shall
+survive, including but not limited to Sections 3, 5, 8, 9, 10, 11,
+12.2 and 13. No party will be liable to any other for compensation,
+indemnity or damages of any sort solely as a result of terminating
+this License in accordance with its terms, and termination of this
+License will be without prejudice to any other right or remedy of
+any party.
+
+13. Miscellaneous.
+
+13.1 Government End Users. The Covered Code is a "commercial item" as
+defined in FAR 2.101. Government software and technical data rights in
+the Covered Code include only those rights customarily provided to the
+public as defined in this License. This customary commercial license
+in technical data and software is provided in accordance with FAR
+12.211 (Technical Data) and 12.212 (Computer Software) and, for
 Department of Defense purchases, DFAR 252.227-7015 (Technical Data --
 Commercial Items) and 227.7202-3 (Rights in Commercial Computer
-Software or Computer Software Documentation).  Accordingly, all U.S.
+Software or Computer Software Documentation). Accordingly, all U.S.
 Government End Users acquire Covered Code with only those rights set
 forth herein.
 
-13.2 Relationship of Parties.  This License will not be construed as
+13.2 Relationship of Parties. This License will not be construed as
 creating an agency, partnership, joint venture or any other form of
-legal association between You and Apple, and You will not represent to
-the contrary, whether expressly, by implication, appearance or
-otherwise.
+legal association between or among You, Apple or any Contributor, and
+You will not represent to the contrary, whether expressly, by
+implication, appearance or otherwise.
 
-13.3 Independent Development.  Nothing in this License will impair
+13.3 Independent Development. Nothing in this License will impair
 Apple's right to acquire, license, develop, have others develop for
 it, market and/or distribute technology or products that perform the
 same or similar functions as, or otherwise compete with,
 Modifications, Larger Works, technology or products that You may
 develop, produce, market or distribute.
 
-13.4 Waiver; Construction.  Failure by Apple to enforce any provision
-of this License will not be deemed a waiver of future enforcement of
-that or any other provision.  Any law or regulation which provides
-that the language of a contract shall be construed against the drafter
-will not apply to this License.
+13.4 Waiver; Construction. Failure by Apple or any Contributor to
+enforce any provision of this License will not be deemed a waiver of
+future enforcement of that or any other provision. Any law or
+regulation which provides that the language of a contract shall be
+construed against the drafter will not apply to this License.
 
-13.5 Severability.  (a) If for any reason a court of competent
+13.5 Severability. (a) If for any reason a court of competent
 jurisdiction finds any provision of this License, or portion thereof,
 to be unenforceable, that provision of the License will be enforced to
 the maximum extent permissible so as to effect the economic benefits
 and intent of the parties, and the remainder of this License will
-continue in full force and effect.  (b) Notwithstanding the foregoing,
+continue in full force and effect. (b) Notwithstanding the foregoing,
 if applicable law prohibits or restricts You from fully and/or
 specifically complying with Sections 2 and/or 3 or prevents the
 enforceability of either of those Sections, this License will
@@ -333,7 +326,7 @@ immediately terminate and You must immediately discontinue any use of
 the Covered Code and destroy all copies of it that are in your
 possession or control.
 
-13.6 Dispute Resolution.  Any litigation or other dispute resolution
+13.6 Dispute Resolution. Any litigation or other dispute resolution
 between You and Apple relating to this License shall take place in the
 Northern District of California, and You and Apple hereby consent to
 the personal jurisdiction of, and venue in, the state and federal
@@ -341,9 +334,9 @@ courts within that District with respect to this License. The
 application of the United Nations Convention on Contracts for the
 International Sale of Goods is expressly excluded.
 
-13.7 Entire Agreement; Governing Law.  This License constitutes the
+13.7 Entire Agreement; Governing Law. This License constitutes the
 entire agreement between the parties with respect to the subject
-matter hereof.  This License shall be governed by the laws of the
+matter hereof. This License shall be governed by the laws of the
 United States and the State of California, except that body of
 California law concerning conflicts of law.
 
@@ -355,18 +348,20 @@ connexes soient rediges en anglais.
 
 EXHIBIT A.
 
-"Portions Copyright (c) 1999-2000 Apple Computer, Inc.  All Rights
-Reserved.  This file contains Original Code and/or Modifications of
-Original Code as defined in and that are subject to the Apple Public
-Source License Version 1.1 (the "License").  You may not use this file
-except in compliance with the License.  Please obtain a copy of the
-License at http://www.apple.com/publicsource and read it before using
-this file.
+"Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights
+Reserved.
+
+This file contains Original Code and/or Modifications of Original Code
+as defined in and that are subject to the Apple Public Source License
+Version 2.0 (the 'License'). You may not use this file except in
+compliance with the License. Please obtain a copy of the License at
+http://www.opensource.apple.com/apsl/ and read it before using this
+file.
 
 The Original Code and all software distributed under the License are
-distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
 EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
 INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT.  Please see the
-License for the specific language governing rights and limitations
-under the License."
+FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+Please see the License for the specific language governing rights and
+limitations under the License."
diff --git a/EXTERNAL_HEADERS/ar.h b/EXTERNAL_HEADERS/ar.h
index def1c4320..a0a7c9a8d 100644
--- a/EXTERNAL_HEADERS/ar.h
+++ b/EXTERNAL_HEADERS/ar.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/EXTERNAL_HEADERS/architecture/byte_order.h b/EXTERNAL_HEADERS/architecture/byte_order.h
index b39c272cb..6e6fd4c3a 100644
--- a/EXTERNAL_HEADERS/architecture/byte_order.h
+++ b/EXTERNAL_HEADERS/architecture/byte_order.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/EXTERNAL_HEADERS/architecture/i386/asm_help.h b/EXTERNAL_HEADERS/architecture/i386/asm_help.h
index 0da8f189c..a401c2004 100644
--- a/EXTERNAL_HEADERS/architecture/i386/asm_help.h
+++ b/EXTERNAL_HEADERS/architecture/i386/asm_help.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/EXTERNAL_HEADERS/architecture/i386/byte_order.h b/EXTERNAL_HEADERS/architecture/i386/byte_order.h
index 6b1bb5ed9..f2f54d624 100644
--- a/EXTERNAL_HEADERS/architecture/i386/byte_order.h
+++ b/EXTERNAL_HEADERS/architecture/i386/byte_order.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/EXTERNAL_HEADERS/architecture/i386/cpu.h b/EXTERNAL_HEADERS/architecture/i386/cpu.h
index 5db7029a3..53dc18972 100644
--- a/EXTERNAL_HEADERS/architecture/i386/cpu.h
+++ b/EXTERNAL_HEADERS/architecture/i386/cpu.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/EXTERNAL_HEADERS/architecture/i386/desc.h b/EXTERNAL_HEADERS/architecture/i386/desc.h
index 4d3c62cac..7d7d174f1 100644
--- a/EXTERNAL_HEADERS/architecture/i386/desc.h
+++ b/EXTERNAL_HEADERS/architecture/i386/desc.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/EXTERNAL_HEADERS/architecture/i386/fpu.h b/EXTERNAL_HEADERS/architecture/i386/fpu.h
index a353a12b1..e584e5efb 100644
--- a/EXTERNAL_HEADERS/architecture/i386/fpu.h
+++ b/EXTERNAL_HEADERS/architecture/i386/fpu.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/EXTERNAL_HEADERS/architecture/i386/frame.h b/EXTERNAL_HEADERS/architecture/i386/frame.h
index ec5604667..71e222c5a 100644
--- a/EXTERNAL_HEADERS/architecture/i386/frame.h
+++ b/EXTERNAL_HEADERS/architecture/i386/frame.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/EXTERNAL_HEADERS/architecture/i386/io.h b/EXTERNAL_HEADERS/architecture/i386/io.h
index 2fe56c292..478d89525 100644
--- a/EXTERNAL_HEADERS/architecture/i386/io.h
+++ b/EXTERNAL_HEADERS/architecture/i386/io.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/EXTERNAL_HEADERS/architecture/i386/reg_help.h b/EXTERNAL_HEADERS/architecture/i386/reg_help.h
index 89dc49a08..44d2595c3 100644
--- a/EXTERNAL_HEADERS/architecture/i386/reg_help.h
+++ b/EXTERNAL_HEADERS/architecture/i386/reg_help.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/EXTERNAL_HEADERS/architecture/i386/sel.h b/EXTERNAL_HEADERS/architecture/i386/sel.h
index 8588273e5..67cadccb7 100644
--- a/EXTERNAL_HEADERS/architecture/i386/sel.h
+++ b/EXTERNAL_HEADERS/architecture/i386/sel.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/EXTERNAL_HEADERS/architecture/i386/table.h b/EXTERNAL_HEADERS/architecture/i386/table.h
index cba52e414..4af4ebb01 100644
--- a/EXTERNAL_HEADERS/architecture/i386/table.h
+++ b/EXTERNAL_HEADERS/architecture/i386/table.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/EXTERNAL_HEADERS/architecture/i386/tss.h b/EXTERNAL_HEADERS/architecture/i386/tss.h
index 68c902900..33a31347b 100644
--- a/EXTERNAL_HEADERS/architecture/i386/tss.h
+++ b/EXTERNAL_HEADERS/architecture/i386/tss.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/EXTERNAL_HEADERS/architecture/ppc/asm_help.h b/EXTERNAL_HEADERS/architecture/ppc/asm_help.h
index 9d8181e21..9365bbd61 100644
--- a/EXTERNAL_HEADERS/architecture/ppc/asm_help.h
+++ b/EXTERNAL_HEADERS/architecture/ppc/asm_help.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/EXTERNAL_HEADERS/architecture/ppc/basic_regs.h b/EXTERNAL_HEADERS/architecture/ppc/basic_regs.h
index f902cb084..d2d21cdeb 100644
--- a/EXTERNAL_HEADERS/architecture/ppc/basic_regs.h
+++ b/EXTERNAL_HEADERS/architecture/ppc/basic_regs.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/EXTERNAL_HEADERS/architecture/ppc/byte_order.h b/EXTERNAL_HEADERS/architecture/ppc/byte_order.h
index 77927e97a..0bb1a4e61 100644
--- a/EXTERNAL_HEADERS/architecture/ppc/byte_order.h
+++ b/EXTERNAL_HEADERS/architecture/ppc/byte_order.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/EXTERNAL_HEADERS/architecture/ppc/cframe.h b/EXTERNAL_HEADERS/architecture/ppc/cframe.h
index 80a08ab6c..5dd724d29 100644
--- a/EXTERNAL_HEADERS/architecture/ppc/cframe.h
+++ b/EXTERNAL_HEADERS/architecture/ppc/cframe.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/EXTERNAL_HEADERS/architecture/ppc/fp_regs.h b/EXTERNAL_HEADERS/architecture/ppc/fp_regs.h
index 51b78d404..2cee79352 100644
--- a/EXTERNAL_HEADERS/architecture/ppc/fp_regs.h
+++ b/EXTERNAL_HEADERS/architecture/ppc/fp_regs.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/EXTERNAL_HEADERS/architecture/ppc/macro_help.h b/EXTERNAL_HEADERS/architecture/ppc/macro_help.h
index 17152ca39..f42f1fd69 100644
--- a/EXTERNAL_HEADERS/architecture/ppc/macro_help.h
+++ b/EXTERNAL_HEADERS/architecture/ppc/macro_help.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/EXTERNAL_HEADERS/architecture/ppc/pseudo_inst.h b/EXTERNAL_HEADERS/architecture/ppc/pseudo_inst.h
index c2514014e..b6ade988d 100644
--- a/EXTERNAL_HEADERS/architecture/ppc/pseudo_inst.h
+++ b/EXTERNAL_HEADERS/architecture/ppc/pseudo_inst.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/EXTERNAL_HEADERS/architecture/ppc/reg_help.h b/EXTERNAL_HEADERS/architecture/ppc/reg_help.h
index d9d1b5ec9..0508de67e 100644
--- a/EXTERNAL_HEADERS/architecture/ppc/reg_help.h
+++ b/EXTERNAL_HEADERS/architecture/ppc/reg_help.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/EXTERNAL_HEADERS/bsd/i386/ansi.h b/EXTERNAL_HEADERS/bsd/i386/ansi.h
index 5689939b2..8bb3e31af 100644
--- a/EXTERNAL_HEADERS/bsd/i386/ansi.h
+++ b/EXTERNAL_HEADERS/bsd/i386/ansi.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/EXTERNAL_HEADERS/bsd/i386/limits.h b/EXTERNAL_HEADERS/bsd/i386/limits.h
index 64eecd5a2..721d6a909 100644
--- a/EXTERNAL_HEADERS/bsd/i386/limits.h
+++ b/EXTERNAL_HEADERS/bsd/i386/limits.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/EXTERNAL_HEADERS/bsd/ppc/ansi.h b/EXTERNAL_HEADERS/bsd/ppc/ansi.h
index 8e1d219a4..e9c40a6b1 100644
--- a/EXTERNAL_HEADERS/bsd/ppc/ansi.h
+++ b/EXTERNAL_HEADERS/bsd/ppc/ansi.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/EXTERNAL_HEADERS/bsd/ppc/limits.h b/EXTERNAL_HEADERS/bsd/ppc/limits.h
index a5bc0b5df..fd1035805 100644
--- a/EXTERNAL_HEADERS/bsd/ppc/limits.h
+++ b/EXTERNAL_HEADERS/bsd/ppc/limits.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/EXTERNAL_HEADERS/mach-o/fat.h b/EXTERNAL_HEADERS/mach-o/fat.h
index 3558e4acf..3c6728cdd 100644
--- a/EXTERNAL_HEADERS/mach-o/fat.h
+++ b/EXTERNAL_HEADERS/mach-o/fat.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/EXTERNAL_HEADERS/mach-o/kld.h b/EXTERNAL_HEADERS/mach-o/kld.h
index 4a63602cf..02e7b69e9 100644
--- a/EXTERNAL_HEADERS/mach-o/kld.h
+++ b/EXTERNAL_HEADERS/mach-o/kld.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/EXTERNAL_HEADERS/mach-o/loader.h b/EXTERNAL_HEADERS/mach-o/loader.h
index 4bd6bf4d6..f4d37ef7d 100644
--- a/EXTERNAL_HEADERS/mach-o/loader.h
+++ b/EXTERNAL_HEADERS/mach-o/loader.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/EXTERNAL_HEADERS/mach-o/nlist.h b/EXTERNAL_HEADERS/mach-o/nlist.h
index 91763d098..2eb7d09af 100644
--- a/EXTERNAL_HEADERS/mach-o/nlist.h
+++ b/EXTERNAL_HEADERS/mach-o/nlist.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/EXTERNAL_HEADERS/mach-o/reloc.h b/EXTERNAL_HEADERS/mach-o/reloc.h
index 8b8e29273..c6ecf13b7 100644
--- a/EXTERNAL_HEADERS/mach-o/reloc.h
+++ b/EXTERNAL_HEADERS/mach-o/reloc.h
@@ -3,21 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * Portions Copyright (c) 1999 Apple Computer, Inc.  All Rights
- * Reserved.  This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License").  You may not use this file
- * except in compliance with the License.  Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
  * 
  * The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/EXTERNAL_HEADERS/machine/limits.h b/EXTERNAL_HEADERS/machine/limits.h
index 2c5eac77a..671a768a7 100644
--- a/EXTERNAL_HEADERS/machine/limits.h
+++ b/EXTERNAL_HEADERS/machine/limits.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/EXTERNAL_HEADERS/stdarg.h b/EXTERNAL_HEADERS/stdarg.h
index dc927b294..8ca01ae59 100644
--- a/EXTERNAL_HEADERS/stdarg.h
+++ b/EXTERNAL_HEADERS/stdarg.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/Makefile b/Makefile
index 5adbd70ba..d843488d3 100644
--- a/Makefile
+++ b/Makefile
@@ -50,7 +50,8 @@ INST_SUBDIRS =	\
 	libsa   \
 	iokit	\
 	osfmk	\
-	bsd
+	bsd	\
+	config
 
 INSTALL_FILE_LIST= \
 	mach_kernel
diff --git a/bsd/conf/MASTER b/bsd/conf/MASTER
index aa6d7ff53..93d21615c 100644
--- a/bsd/conf/MASTER
+++ b/bsd/conf/MASTER
@@ -246,6 +246,10 @@ pseudo-device	pty	128 init pty_init
 # vnode device
 pseudo-device	vndevice	4	init	vndevice_init
 
+#
+# memory device
+pseudo-device	mdevdevice	1	init	mdevinit
+
 #
 #
 # packet filter device
diff --git a/bsd/conf/files b/bsd/conf/files
index 817d99f42..485ece605 100644
--- a/bsd/conf/files
+++ b/bsd/conf/files
@@ -115,6 +115,9 @@ bsd/dev/random/YarrowCoreLib/src/comp.c				standard
 bsd/dev/random/YarrowCoreLib/src/prng.c				standard
 bsd/dev/random/YarrowCoreLib/src/sha1mod.c			standard
 bsd/dev/random/YarrowCoreLib/src/yarrowUtils.c		standard
+
+bsd/dev/memdev.c				standard
+
 bsd/dev/vn/vn.c				optional vndevice
 bsd/dev/vn/shadow.c			optional vndevice
 
diff --git a/bsd/conf/param.c b/bsd/conf/param.c
index 9de9d895c..6594795be 100644
--- a/bsd/conf/param.c
+++ b/bsd/conf/param.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/conf/version.minor b/bsd/conf/version.minor
index 0cfbf0888..7f8f011eb 100644
--- a/bsd/conf/version.minor
+++ b/bsd/conf/version.minor
@@ -1 +1 @@
-2
+7
diff --git a/bsd/conf/version.variant b/bsd/conf/version.variant
index e69de29bb..7ed6ff82d 100644
--- a/bsd/conf/version.variant
+++ b/bsd/conf/version.variant
@@ -0,0 +1 @@
+5
diff --git a/bsd/dev/busvar.h b/bsd/dev/busvar.h
index e6508ebed..303e450ad 100644
--- a/bsd/dev/busvar.h
+++ b/bsd/dev/busvar.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/dev/disk.h b/bsd/dev/disk.h
index f174e4ef1..8d672d97c 100644
--- a/bsd/dev/disk.h
+++ b/bsd/dev/disk.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/dev/disk_label.h b/bsd/dev/disk_label.h
index 460b5bc9f..20e7a0ece 100644
--- a/bsd/dev/disk_label.h
+++ b/bsd/dev/disk_label.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/dev/i386/conf.c b/bsd/dev/i386/conf.c
index f06b30fc6..854d04873 100644
--- a/bsd/dev/i386/conf.c
+++ b/bsd/dev/i386/conf.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/dev/i386/cons.c b/bsd/dev/i386/cons.c
index 118878bd1..c2122a600 100644
--- a/bsd/dev/i386/cons.c
+++ b/bsd/dev/i386/cons.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/dev/i386/cons.h b/bsd/dev/i386/cons.h
index 00d91a155..67a391a83 100644
--- a/bsd/dev/i386/cons.h
+++ b/bsd/dev/i386/cons.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/dev/i386/kern_machdep.c b/bsd/dev/i386/kern_machdep.c
index 0c3684b58..b6fcf37a6 100644
--- a/bsd/dev/i386/kern_machdep.c
+++ b/bsd/dev/i386/kern_machdep.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/dev/i386/km.c b/bsd/dev/i386/km.c
index ff1fa1978..2ce9ce21c 100644
--- a/bsd/dev/i386/km.c
+++ b/bsd/dev/i386/km.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/dev/i386/lock_stubs.c b/bsd/dev/i386/lock_stubs.c
index 2b207335a..f25fd3533 100644
--- a/bsd/dev/i386/lock_stubs.c
+++ b/bsd/dev/i386/lock_stubs.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/dev/i386/mem.c b/bsd/dev/i386/mem.c
index 5c3422a64..233b59643 100644
--- a/bsd/dev/i386/mem.c
+++ b/bsd/dev/i386/mem.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/dev/i386/memmove.c b/bsd/dev/i386/memmove.c
index 12b0e2070..fdbc131e1 100644
--- a/bsd/dev/i386/memmove.c
+++ b/bsd/dev/i386/memmove.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/dev/i386/pci_device.h b/bsd/dev/i386/pci_device.h
index 92f6a0905..b14176bdb 100644
--- a/bsd/dev/i386/pci_device.h
+++ b/bsd/dev/i386/pci_device.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/dev/i386/pio.h b/bsd/dev/i386/pio.h
index 66992563d..d99fe9d80 100644
--- a/bsd/dev/i386/pio.h
+++ b/bsd/dev/i386/pio.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/dev/i386/sel.h b/bsd/dev/i386/sel.h
index 3d8824286..4470c297a 100644
--- a/bsd/dev/i386/sel.h
+++ b/bsd/dev/i386/sel.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/dev/i386/sel_inline.h b/bsd/dev/i386/sel_inline.h
index e972af7b5..ad551474b 100644
--- a/bsd/dev/i386/sel_inline.h
+++ b/bsd/dev/i386/sel_inline.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/dev/i386/stubs.c b/bsd/dev/i386/stubs.c
index a4a7ad113..beb116a10 100644
--- a/bsd/dev/i386/stubs.c
+++ b/bsd/dev/i386/stubs.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/dev/i386/table_inline.h b/bsd/dev/i386/table_inline.h
index a4bb2937a..b89102144 100644
--- a/bsd/dev/i386/table_inline.h
+++ b/bsd/dev/i386/table_inline.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/dev/i386/unix_signal.c b/bsd/dev/i386/unix_signal.c
index 0c06ff2fd..6cd4684f3 100644
--- a/bsd/dev/i386/unix_signal.c
+++ b/bsd/dev/i386/unix_signal.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -60,6 +63,10 @@
 
 #define	NULL_SEG	0
 
+/* Signal handler flavors supported */
+/* These defns should match the Libc implmn */
+#define UC_TRAD			1
+
 /*
  * Send an interrupt to process.
  *
@@ -113,7 +120,7 @@ sendsig(p, catcher, sig, mask, code)
 	/* Handler should call sigreturn to get out of it */
 	frame.retaddr = 0xffffffff;	
 	frame.catcher = catcher;
-	frame.sigstyle = 1;
+	frame.sigstyle = UC_TRAD;
 	frame.sig = sig;
 
 	if (sig == SIGILL || sig == SIGFPE) {
diff --git a/bsd/dev/i386/unix_startup.c b/bsd/dev/i386/unix_startup.c
index f341af01a..9437554c7 100644
--- a/bsd/dev/i386/unix_startup.c
+++ b/bsd/dev/i386/unix_startup.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/dev/kmreg_com.h b/bsd/dev/kmreg_com.h
index 1d4a7224f..f9f16eef5 100644
--- a/bsd/dev/kmreg_com.h
+++ b/bsd/dev/kmreg_com.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/dev/ldd.h b/bsd/dev/ldd.h
index 9e33d5123..1995216ed 100644
--- a/bsd/dev/ldd.h
+++ b/bsd/dev/ldd.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/dev/memdev.c b/bsd/dev/memdev.c
new file mode 100644
index 000000000..bc41c0d44
--- /dev/null
+++ b/bsd/dev/memdev.c
@@ -0,0 +1,575 @@
+/*
+ * Copyright (c) 1988 University of Utah.
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * from: Utah Hdr: vn.c 1.13 94/04/02
+ *
+ *	from: @(#)vn.c	8.6 (Berkeley) 4/1/94
+ * $FreeBSD: src/sys/dev/vn/vn.c,v 1.105.2.4 2001/11/18 07:11:00 dillon Exp $
+ */
+
+/*
+ * RAM disk driver.
+ *
+ * Block interface to a ramdisk.  
+ *
+ */
+
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/mount.h>
+#include <sys/namei.h>
+#include <sys/proc.h>
+#include <sys/buf.h>
+#include <sys/malloc.h>
+#include <sys/mount.h>
+#include <sys/vnode.h>
+#include <sys/fcntl.h>
+#include <sys/conf.h>
+#include <dev/disk.h>
+#include <sys/stat.h>
+
+#include <sys/vm.h>
+
+#include <vm/vm_pager.h>
+#include <vm/vm_pageout.h>
+#include <mach/memory_object_types.h>
+
+#include <miscfs/devfs/devfs.h>
+
+static open_close_fcn_t		mdevopen;
+static open_close_fcn_t		mdevclose;
+static psize_fcn_t		mdevsize;
+static strategy_fcn_t		mdevstrategy;
+static int mdevbioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p);
+static int mdevcioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p);
+static int mdevrw(dev_t dev, struct uio *uio, int ioflag);
+static char *nonspace(char *pos, char *end);
+static char *getspace(char *pos, char *end);
+static char *cvtnum(char *pos, char *end, unsigned int *num);
+
+/*
+ * cdevsw
+ *	D_DISK		we want to look like a disk
+ *	D_CANFREE	We support B_FREEBUF
+ */
+
+static struct bdevsw mdevbdevsw = {
+	/* open */	mdevopen,
+	/* close */	mdevclose,
+	/* strategy */	mdevstrategy,
+	/* ioctl */	mdevbioctl,
+	/* dump */	eno_dump,
+	/* psize */	mdevsize,
+	/* flags */	D_DISK,
+};
+
+static struct cdevsw mdevcdevsw = {
+	/* open */	mdevopen,
+	/* close */	mdevclose,
+	/* read */	mdevrw,
+	/* write */	mdevrw,
+	/* ioctl */	mdevcioctl,
+	/* stop */	eno_stop,
+	/* reset */	eno_reset,
+	/* ttys */	0,
+	/* select */	eno_select,
+	/* mmap */	eno_mmap,
+	/* strategy */	eno_strat,
+	/* getc */	eno_getc,
+	/* putc */	eno_putc,
+	/* flags */	D_DISK,
+};
+
+struct mdev {
+	vm_offset_t	mdBase;		/* file size in bytes */
+	uint32_t	mdSize;		/* file size in bytes */
+	int			mdFlags;	/* flags */
+	int			mdSecsize;	/* sector size */
+	int			mdBDev;		/* Block device number */
+	int			mdCDev;		/* Character device number */
+	void *		mdbdevb;
+	void *		mdcdevb;
+} mdev[16];
+
+/* mdFlags */
+#define mdInited	0x01	/* This device defined */
+#define	mdRO		0x02	/* This device is read-only */
+#define	mdPhys		0x04	/* This device is in physical memory */
+
+int mdevBMajor = -1;
+int mdevCMajor = -1;
+
+static int mdevioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p, int is_char);
+dev_t mdevadd(int devid, ppnum_t base, unsigned int size, int phys);
+dev_t mdevlookup(int devid);
+
+static	int mdevclose(dev_t dev, int flags, int devtype, struct proc *p) {
+	return (0);
+}
+
+static	int mdevopen(dev_t dev, int flags, int devtype, struct proc *p) {
+	
+	int devid;
+
+	devid = minor(dev);									/* Get minor device number */
+
+	if (devid > 16) return (ENXIO);						/* Not valid */
+
+	if ((flags & FWRITE) && (mdev[devid].mdFlags & mdRO)) return (EACCES);	/* Currently mounted RO */
+
+	return(0);
+}
+
+static int mdevrw(dev_t dev, struct uio *uio, int ioflag) {
+	int 			status;
+	int 			unit;
+	addr64_t		mdata;
+	int devid;
+	enum uio_seg saveflag;
+
+	devid = minor(dev);									/* Get minor device number */
+
+	if (devid > 16) return (ENXIO);						/* Not valid */
+	if (!(mdev[devid].mdFlags & mdInited))  return (ENXIO);	/* Have we actually been defined yet? */
+
+	mdata = ((addr64_t)mdev[devid].mdBase << 12) + uio->uio_offset;	/* Point to the area in "file" */
+	
+	saveflag = uio->uio_segflg;							/* Remember what the request is */
+	if (mdev[devid].mdFlags & mdPhys) uio->uio_segflg = UIO_PHYS_USERSPACE;	/* Make sure we are moving from physical ram if physical device */
+	status = uiomove64(mdata, uio->uio_resid, uio);		/* Move the data */
+	uio->uio_segflg = saveflag;							/* Restore the flag */
+
+	return (status);
+}
+
+static void mdevstrategy(struct buf *bp) {
+	int unmap;
+	unsigned int sz, left, lop, csize;
+	kern_return_t ret;
+	vm_offset_t vaddr, blkoff;
+	struct buf *tbuf;
+	int devid;
+	addr64_t paddr, fvaddr;
+	ppnum_t pp;
+
+	devid = minor(bp->b_dev);							/* Get minor device number */
+
+	if ((mdev[devid].mdFlags & mdInited) == 0) {		/* Have we actually been defined yet? */
+		bp->b_error = ENXIO;
+		bp->b_flags |= B_ERROR;
+		biodone(bp);
+		return;
+	}
+
+	bp->b_resid = bp->b_bcount;							/* Set byte count */
+	
+	blkoff = bp->b_blkno * mdev[devid].mdSecsize;		/* Get offset into file */
+
+/*
+ *	Note that reading past end is an error, but reading at end is an EOF.  For these
+ *	we just return with b_resid == b_bcount.
+ */
+
+	if (blkoff >= (mdev[devid].mdSize << 12)) {			/* Are they trying to read/write at/after end? */
+		if(blkoff != (mdev[devid].mdSize << 12)) {		/* Are we trying to read after EOF? */
+			bp->b_error = EINVAL;						/* Yeah, this is an error */
+			bp->b_flags |= B_ERROR | B_INVAL;
+		}
+		biodone(bp);									/* Return */
+		return;
+	}
+
+	if ((blkoff + bp->b_bcount) > (mdev[devid].mdSize << 12)) {		/* Will this read go past end? */
+		bp->b_bcount = ((mdev[devid].mdSize << 12) - blkoff);	/* Yes, trim to max */
+	}
+
+	vaddr = 0;											/* Assume not mapped yet */
+	unmap = 0;
+
+	if (bp->b_flags & B_VECTORLIST) {					/* Do we have a list of UPLs? */
+		tbuf = (struct buf *)bp->b_real_bp;				/* Get this for C's inadequacies */
+		if((bp->b_flags & B_NEED_IODONE) &&				/* If we have a UPL, is it already mapped? */
+		  tbuf && 
+		  tbuf->b_data) {
+			vaddr = tbuf->b_data;						/* We already have this mapped in, get base address */
+		}
+		else {											/* Not mapped yet */										
+			ret = ubc_upl_map(bp->b_pagelist, &vaddr);	/* Map it in */
+			if(ret != KERN_SUCCESS) panic("ramstrategy: ubc_upl_map failed, rc = %08X\n", ret);
+			unmap = 1;									/* Remember to unmap later */
+		}
+		vaddr = vaddr += bp->b_uploffset;				/* Calculate actual vaddr */
+	}
+	else vaddr = bp->b_data;							/* No UPL, we already have address */
+	
+	fvaddr = (mdev[devid].mdBase << 12) + blkoff;		/* Point to offset into ram disk */
+	
+	if(bp->b_flags & B_READ) {							/* Is this a read? */
+		if(!(mdev[devid].mdFlags & mdPhys)) {			/* Physical mapped disk? */
+			bcopy((void *)fvaddr, (void *)vaddr, bp->b_bcount);	/* This is virtual, just get the data */
+		}
+		else {
+			left = bp->b_bcount;						/* Init the amount left to copy */
+			while(left) {								/* Go until it is all copied */
+				
+				lop = min((4096 - (vaddr & 4095)), (4096 - (fvaddr & 4095)));	/* Get smallest amount left on sink and source */
+				csize = min(lop, left);					/* Don't move more than we need to */
+				
+				pp = pmap_find_phys(kernel_pmap, (addr64_t)((unsigned int)vaddr));	/* Get the sink physical address */
+				if(!pp) {								/* Not found, what gives? */
+					panic("mdevstrategy: sink address %016llX not mapped\n", (addr64_t)((unsigned int)vaddr));
+				}
+				paddr = (addr64_t)(((addr64_t)pp << 12) | (addr64_t)(vaddr & 4095));	/* Get actual address */
+				bcopy_phys(fvaddr, paddr, csize);		/* Copy this on in */
+				mapping_set_mod(paddr >> 12);			/* Make sure we know that it is modified */
+				
+				left = left - csize;					/* Calculate what is left */
+				vaddr = vaddr + csize;					/* Move to next sink address */
+				fvaddr = fvaddr + csize;				/* Bump to next physical address */
+			}
+		}
+	}
+	else {												/* This is a write */
+		if(!(mdev[devid].mdFlags & mdPhys)) {			/* Physical mapped disk? */
+			bcopy((void *)vaddr, (void *)fvaddr, bp->b_bcount);	/* This is virtual, just put the data */
+		}
+		else {
+			left = bp->b_bcount;						/* Init the amount left to copy */
+			while(left) {								/* Go until it is all copied */
+				
+				lop = min((4096 - (vaddr & 4095)), (4096 - (fvaddr & 4095)));	/* Get smallest amount left on sink and source */
+				csize = min(lop, left);					/* Don't move more than we need to */
+				
+				pp = pmap_find_phys(kernel_pmap, (addr64_t)((unsigned int)vaddr));	/* Get the source physical address */
+				if(!pp) {								/* Not found, what gives? */
+					panic("mdevstrategy: source address %016llX not mapped\n", (addr64_t)((unsigned int)vaddr));
+				}
+				paddr = (addr64_t)(((addr64_t)pp << 12) | (addr64_t)(vaddr & 4095));	/* Get actual address */
+			
+				bcopy_phys(paddr, fvaddr, csize);		/* Move this on out */
+				
+				left = left - csize;					/* Calculate what is left */
+				vaddr = vaddr + csize;					/* Move to next sink address */
+				fvaddr = fvaddr + csize;				/* Bump to next physical address */
+			}
+		}
+	}
+	
+	if (unmap) {										/* Do we need to unmap this? */
+		ubc_upl_unmap(bp->b_pagelist);					/* Yes, unmap it */
+	}
+
+	bp->b_resid = 0;									/* Nothing more to do */	
+	biodone(bp);										/* Say we've finished */
+}
+
+static int mdevbioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) {
+	return (mdevioctl(dev, cmd, data, flag, p, 0));
+}
+
+static int mdevcioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) {
+	return (mdevioctl(dev, cmd, data, flag, p, 1));
+}
+
+static int mdevioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p, int is_char) {
+
+	int error;
+	u_long *f;
+	u_int64_t *o;
+	int devid;
+
+	devid = minor(dev);									/* Get minor device number */
+
+	if (devid > 16) return (ENXIO);						/* Not valid */
+
+	error = suser(p->p_ucred, &p->p_acflag);			/* Are we superman? */
+	if (error) return (error);							/* Nope... */
+
+	f = (u_long*)data;
+	o = (u_int64_t *)data;
+
+	switch (cmd) {
+
+		case DKIOCGETMAXBLOCKCOUNTREAD:
+			*o = 32;
+			break;
+		
+		case DKIOCGETMAXBLOCKCOUNTWRITE:
+			*o = 32;
+			break;
+		
+		case DKIOCGETMAXSEGMENTCOUNTREAD:
+			*o = 32;
+			break;
+		
+		case DKIOCGETMAXSEGMENTCOUNTWRITE:
+			*o = 32;
+			break;
+		
+		case DKIOCGETBLOCKSIZE:
+			*f = mdev[devid].mdSecsize;
+			break;
+		
+		case DKIOCSETBLOCKSIZE:
+			if (is_char) return (ENODEV);				/* We can only do this for a block */
+
+			if (*f < DEV_BSIZE) return (EINVAL);		/* Too short? */
+
+			mdev[devid].mdSecsize = *f;					/* set the new block size */
+			break;
+			
+		case DKIOCISWRITABLE:
+			*f = 1;
+			break;
+			
+		case DKIOCGETBLOCKCOUNT32:
+			if(!(mdev[devid].mdFlags & mdInited)) return (ENXIO);
+			*f = ((mdev[devid].mdSize << 12) + mdev[devid].mdSecsize - 1) / mdev[devid].mdSecsize;
+			break;
+			
+		case DKIOCGETBLOCKCOUNT64:
+			if(!(mdev[devid].mdFlags & mdInited)) return (ENXIO);
+			*o = ((mdev[devid].mdSize << 12) + mdev[devid].mdSecsize - 1) / mdev[devid].mdSecsize;
+			break;
+			
+		default:
+			error = ENOTTY;
+			break;
+	}
+	return(error);
+}
+
+
+static	int mdevsize(dev_t dev) {
+
+	int devid;
+
+	devid = minor(dev);									/* Get minor device number */
+	if (devid > 16) return (ENXIO);						/* Not valid */
+
+	if ((mdev[devid].mdFlags & mdInited) == 0) return(-1);		/* Not inited yet */
+
+	return(mdev[devid].mdSecsize);
+}
+
+
+void mdevinit(int cnt) {
+
+	int devid, phys;
+	ppnum_t base;
+	unsigned int size;
+	char *ba, *lp;
+	dev_t dev;
+	
+	
+	ba = PE_boot_args();								/* Get the boot arguments */
+	lp = ba + 256;										/* Point to the end */
+		
+	while(1) {											/* Step through, looking for our keywords */
+		phys = 0;										/* Assume virtual memory device */
+		ba = nonspace(ba, lp);							/* Find non-space */
+		if(ba >= lp) return;							/* We are done if no more... */
+		if(((ba[0] != 'v') && (ba[0] != 'p'))  
+		  || (ba[1] != 'm') || (ba[2] != 'd') || (ba[4] != '=')
+		  || (ba[3] < '0') || (ba[3] > 'f') 
+		  || ((ba[3] > '9') && (ba[3] < 'a'))) {		/* Is this of form "vmdx=" or "pmdx=" where x is hex digit? */
+			
+			ba = getspace(ba, lp);						/* Find next white space or end */
+			continue;									/* Start looking for the next one */
+		}
+		
+		if(ba[0] == 'p') phys = 1;						/* Set physical memory disk */
+		
+		devid = ba[3] & 0xF;							/* Assume digit */
+		if(ba[3] > '9') devid += 9;						/* Adjust for hex digits */
+	
+		ba = &ba[5];									/* Step past keyword */
+		ba = cvtnum(ba, lp, &base);						/* Convert base of memory disk */
+		if(ba >= lp) return;							/* Malformed one at the end, leave */
+		if(ba[0] != '.') continue;						/* If not length separater, try next... */
+		if(base & 0xFFF) continue;						/* Only allow page aligned stuff */
+	
+		ba++;											/* Step past '.' */
+		ba = cvtnum(ba, lp, &size);						/* Try to convert it */
+		if(!size || (size & 0xFFF)) continue;			/* Allow only non-zer page size multiples */
+		if(ba < lp) {									/* If we are not at end, check end character */
+			if((ba[0] != ' ') && (ba[0] != 0)) continue;	/* End must be null or space */
+		}
+		
+		dev = mdevadd(devid, base >> 12, size >> 12, phys);	/* Go add the device */ 
+	}
+
+	return;
+
+}
+
+char *nonspace(char *pos, char *end) {					/* Find next non-space in string */
+
+	if(pos >= end) return end;							/* Don't go past end */
+	if(pos[0] == 0) return end;							/* If at null, make end */
+	
+	while(1) {											/* Keep going */
+		if(pos[0] != ' ') return pos;					/* Leave if we found one */
+		pos++;											/* Stop */
+		if(pos >= end) return end;						/* Quit if we run off end */
+	}
+}
+
+char *getspace(char *pos, char *end) {					/* Find next non-space in string */
+
+	while(1) {											/* Keep going */
+		if(pos >= end) return end;						/* Don't go past end */
+		if(pos[0] == 0) return end;						/* Leave if we hit null */
+		if(pos[0] == ' ') return pos;					/* Leave if we found one */
+		pos++;											/* Stop */
+	}
+}
+
+char *cvtnum(char *pos, char *end, unsigned int *num) {		/* Convert to a number */
+
+	int rad, dig;
+	
+	*num = 0;											/* Set answer to 0 to start */	
+	rad = 10;
+
+	if(pos >= end) return end;							/* Don't go past end */
+	if(pos[0] == 0) return end;							/* If at null, make end */
+	
+	if(pos[0] == '0' && ((pos[1] == 'x') || (pos[1] == 'x'))) {	/* A hex constant? */
+		rad = 16;
+		pos += 2;										/* Point to the number */
+	}
+	
+	while(1) {											/* Convert it */
+		
+		if(pos >= end) return end;						/* Don't go past end */
+		if(pos[0] == 0) return end;						/* If at null, make end */
+		if(pos[0] < '0') return pos;					/* Leave if non-digit */
+		dig = pos[0] & 0xF;								/* Extract digit */
+		if(pos[0] > '9') {								/* Is it bigger than 9? */
+			if(rad == 10) return pos;					/* Leave if not base 10 */
+			if(!(((pos[0] >= 'A') && (pos[0] <= 'F')) 
+			  || ((pos[0] >= 'a') && (pos[0] <= 'f')))) return pos;	/* Leave if bogus char */
+			 dig = dig + 9;								/* Adjust for character */
+		}
+		*num = (*num * rad) + dig;						/* Accumulate the number */
+		pos++;											/* Step on */
+	}
+}
+
+dev_t mdevadd(int devid, ppnum_t base, unsigned int size, int phys) {
+	
+	int i;
+	
+	if(devid < 0) {
+
+		devid = -1;
+		for(i = 0; i < 16; i++) {						/* Search all known memory devices */
+			if(!(mdev[i].mdFlags & mdInited)) {			/* Is this a free one? */
+				if(devid < 0)devid = i;					/* Remember first free one */
+				continue;								/* Skip check */
+			}
+			if(!(((base + size -1 ) < mdev[i].mdBase) || ((mdev[i].mdBase + mdev[i].mdSize - 1) < base))) {	/* Is there any overlap? */
+				panic("mdevadd: attempt to add overlapping memory device at %08X-%08X\n", mdev[i].mdBase, mdev[i].mdBase + mdev[i].mdSize - 1);
+			}
+		}
+		if(devid < 0) {									/* Do we have free slots? */
+			panic("mdevadd: attempt to add more than 16 memory devices\n");
+		}
+	}
+	else {
+		if(devid >= 16) {								/* Giving us something bogus? */
+			panic("mdevadd: attempt to explicitly add a bogus memory device: &08X\n", devid);
+		}
+		if(mdev[devid].mdFlags &mdInited) {				/* Already there? */
+			panic("mdevadd: attempt to explicitly add a previously defined memory device: &08X\n", devid);
+		}
+	}
+	
+	if(mdevBMajor < 0) {								/* Have we gotten a major number yet? */
+		mdevBMajor = bdevsw_add(-1, &mdevbdevsw);		/* Add to the table and figure out a major number */
+		if (mdevBMajor < 0) {
+			printf("mdevadd: error - bdevsw_add() returned %d\n", mdevBMajor);
+			return -1;
+		}
+	}
+	
+	if(mdevCMajor < 0) {								/* Have we gotten a major number yet? */
+		mdevCMajor = cdevsw_add_with_bdev(-1, &mdevcdevsw, mdevBMajor);		/* Add to the table and figure out a major number */
+		if (mdevCMajor < 0) {
+			printf("ramdevice_init: error - cdevsw_add() returned %d\n", mdevCMajor);
+			return -1;
+		}
+	}
+
+	mdev[devid].mdBDev = makedev(mdevBMajor, devid);	/* Get the device number */
+	mdev[devid].mdbdevb = devfs_make_node(mdev[devid].mdBDev, DEVFS_BLOCK,	/* Make the node */
+						  UID_ROOT, GID_OPERATOR, 
+						  0600, "md%d", devid);
+	if (mdev[devid].mdbdevb == NULL) {					/* Did we make one? */
+		printf("mdevadd: devfs_make_node for block failed!\n");
+		return -1;										/* Nope... */
+	}
+
+	mdev[devid].mdCDev = makedev(mdevCMajor, devid);	/* Get the device number */
+	mdev[devid].mdcdevb = devfs_make_node(mdev[devid].mdCDev, DEVFS_CHAR,		/* Make the node */
+						  UID_ROOT, GID_OPERATOR, 
+						  0600, "rmd%d", devid);
+	if (mdev[devid].mdcdevb == NULL) {					/* Did we make one? */
+		printf("mdevadd: devfs_make_node for character failed!\n");
+		return -1;										/* Nope... */
+	}
+	
+	mdev[devid].mdBase = base;							/* Set the base address of ram disk */
+	mdev[devid].mdSize = size;							/* Set the length of the ram disk */
+	mdev[devid].mdSecsize = DEV_BSIZE;					/* Set starting block size */
+	if(phys) mdev[devid].mdFlags |= mdPhys;				/* Show that we are in physical memory */
+	mdev[devid].mdFlags |= mdInited;					/* Show we are all set up */
+	printf("Added memory device md%x/rmd%x (%08X/%08X) at %08X for %08X\n", 
+		devid, devid, mdev[devid].mdBDev, mdev[devid].mdCDev, base << 12, size << 12);
+	return mdev[devid].mdBDev;
+}
+
+
+dev_t mdevlookup(int devid) {
+	
+	if((devid < 0) || (devid > 15)) return -1;			/* Filter any bogus requests */
+	if(!(mdev[devid].mdFlags & mdInited)) return -1;	/* This one hasn't been defined */
+	return mdev[devid].mdBDev;							/* Return the device number */
+}
diff --git a/bsd/dev/memdev.h b/bsd/dev/memdev.h
new file mode 100644
index 000000000..a07b5d2a6
--- /dev/null
+++ b/bsd/dev/memdev.h
@@ -0,0 +1,17 @@
+
+#ifndef _SYS_MEMDEV_H_
+#define _SYS_MEMDEV_H_
+
+#include <sys/appleapiopts.h>
+
+#ifdef KERNEL_PRIVATE
+
+#ifdef __APPLE_API_PRIVATE
+
+void mdevinit(vm_offset_t base, unsigned int size);
+
+#endif /* __APPLE_API_PRIVATE */
+
+#endif KERNEL_PRIVATE
+
+#endif	/* _SYS_MEMDEV_H_*/
diff --git a/bsd/dev/ppc/conf.c b/bsd/dev/ppc/conf.c
index bfe8c9a0c..ba13fc3ee 100644
--- a/bsd/dev/ppc/conf.c
+++ b/bsd/dev/ppc/conf.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/dev/ppc/cons.c b/bsd/dev/ppc/cons.c
index 26290d9a3..148e5f668 100644
--- a/bsd/dev/ppc/cons.c
+++ b/bsd/dev/ppc/cons.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/dev/ppc/cons.h b/bsd/dev/ppc/cons.h
index 00d91a155..67a391a83 100644
--- a/bsd/dev/ppc/cons.h
+++ b/bsd/dev/ppc/cons.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/dev/ppc/ffs.c b/bsd/dev/ppc/ffs.c
index fa02a4795..63bb63a08 100644
--- a/bsd/dev/ppc/ffs.c
+++ b/bsd/dev/ppc/ffs.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/dev/ppc/ffs.s b/bsd/dev/ppc/ffs.s
index 75ec0dea4..dd076c4d0 100644
--- a/bsd/dev/ppc/ffs.s
+++ b/bsd/dev/ppc/ffs.s
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/dev/ppc/kern_machdep.c b/bsd/dev/ppc/kern_machdep.c
index 38a00cc3c..6f9d2a154 100644
--- a/bsd/dev/ppc/kern_machdep.c
+++ b/bsd/dev/ppc/kern_machdep.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -52,18 +55,11 @@ check_cpu_subtype(cpu_subtype_t cpu_subtype)
 	if (cpu_subtype == ms->cpu_subtype)
 		return (TRUE);
 
-	if (cpu_subtype == CPU_SUBTYPE_POWERPC_601)
-		return (FALSE);
-
 	switch (cpu_subtype) {
+		case CPU_SUBTYPE_POWERPC_970:
 		case CPU_SUBTYPE_POWERPC_7450:
 		case CPU_SUBTYPE_POWERPC_7400:
 		case CPU_SUBTYPE_POWERPC_750:
-		case CPU_SUBTYPE_POWERPC_604e:
-		case CPU_SUBTYPE_POWERPC_604:
-		case CPU_SUBTYPE_POWERPC_603ev:
-		case CPU_SUBTYPE_POWERPC_603e:
-		case CPU_SUBTYPE_POWERPC_603:
 		case CPU_SUBTYPE_POWERPC_ALL:
 			return (TRUE);
 	}
@@ -90,43 +86,32 @@ grade_cpu_subtype(cpu_subtype_t cpu_subtype)
 	 * cctools project.  As of 2/16/98 this is what has been agreed upon for
 	 * the PowerPC subtypes.  If an exact match is not found the subtype will
 	 * be picked from the following order:
-	 *		7400, 750, 604e, 604, 603ev, 603e, 603, ALL
+	 *		970, 7450, 7400, 750, ALL
 	 * Note the 601 is NOT in the list above.  It is only picked via an exact
 	 * match. For details see Radar 2213821.
 	 *
 	 * To implement this function to follow what was agreed upon above, we use
-	 * the fact there are currently 10 different subtypes.  Exact matches return
-	 * the value 10, the value 0 is returned for 601 that is not an exact match,
-	 * and the values 9 thru 1 are returned for the subtypes listed in the order
-	 * above.
+	 * the fact there are currently 4 different subtypes.  Exact matches return
+	 * the value 6, and the values 5 thru 1 are returned for the
+	 * subtypes listed in the order above.
 	 */
 	if (ms->cpu_subtype == cpu_subtype)
-		return 10;
-	if (cpu_subtype == CPU_SUBTYPE_POWERPC_601)
-		return 0;
+		return 6;
 	switch (cpu_subtype) {
-		case CPU_SUBTYPE_POWERPC_7450:
-			return 9;
-		case CPU_SUBTYPE_POWERPC_7400:
-			return 8;
-		case CPU_SUBTYPE_POWERPC_750:
-			return 7;
-		case CPU_SUBTYPE_POWERPC_604e:
-			return 6;
-		case CPU_SUBTYPE_POWERPC_604:
+		case CPU_SUBTYPE_POWERPC_970:
 			return 5;
-		case CPU_SUBTYPE_POWERPC_603ev:
+		case CPU_SUBTYPE_POWERPC_7450:
 			return 4;
-		case CPU_SUBTYPE_POWERPC_603e:
+		case CPU_SUBTYPE_POWERPC_7400:
 			return 3;
-		case CPU_SUBTYPE_POWERPC_603:
+		case CPU_SUBTYPE_POWERPC_750:
 			return 2;
 		case CPU_SUBTYPE_POWERPC_ALL:
 			return 1;
 	}
 	/*
-	 * If we get here it is because it is a cpusubtype we don't support (602 and
-	 * 620) or new cpusubtype that was added since this code was written.  Both
+	 * If we get here it is because it is a cpusubtype we don't support
+	 * or a new cpusubtype that was added since this code was written.  Both
 	 * will be considered unacceptable.
 	 */
 	return 0;
@@ -141,7 +126,7 @@ kernacc(
 	off_t base;
 	off_t end;
     
-	base = trunc_page(start);
+	base = trunc_page_64(start);
 	end = start + len;
 	
 	while (base < end) {
diff --git a/bsd/dev/ppc/km.c b/bsd/dev/ppc/km.c
index 9bf068b0b..4885c7abb 100644
--- a/bsd/dev/ppc/km.c
+++ b/bsd/dev/ppc/km.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/dev/ppc/machdep.c b/bsd/dev/ppc/machdep.c
index 6e44b5eb9..8b4d93f15 100644
--- a/bsd/dev/ppc/machdep.c
+++ b/bsd/dev/ppc/machdep.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/dev/ppc/mem.c b/bsd/dev/ppc/mem.c
index ba9a0f800..7bd8b66f7 100644
--- a/bsd/dev/ppc/mem.c
+++ b/bsd/dev/ppc/mem.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -86,7 +89,6 @@
 
 static caddr_t devzerobuf;
 
-extern vm_offset_t mem_actual;
 extern pmap_t kernel_pmap;
 
 mmread(dev, uio)
@@ -112,6 +114,7 @@ mmrw(dev, uio, rw)
 {
 	register int o;
 	register u_int c, v;
+	addr64_t vll;
 	register struct iovec *iov;
 	int error = 0;
 	vm_offset_t	where;
@@ -132,45 +135,48 @@ mmrw(dev, uio, rw)
 
 /* minor device 0 is physical memory */
 		case 0:
-			v = trunc_page(uio->uio_offset);
-			if (uio->uio_offset >= ((dgWork.dgFlags & enaDiagDM) ? mem_actual : mem_size))
+			vll = trunc_page_64(uio->uio_offset);
+			if(((vll >> 31) == 1) || vll >= ((dgWork.dgFlags & enaDiagDM) ? mem_actual : max_mem))
 				goto fault;
 
-			size= PAGE_SIZE;
-
 			if(dgWork.dgFlags & enaDiagDM) {			/* Can we really get all memory? */
-				if (kmem_alloc_pageable(kernel_map, &where, size) != KERN_SUCCESS) {
+				if (kmem_alloc_pageable(kernel_map, &where, PAGE_SIZE) != KERN_SUCCESS) {
 					goto fault;
 				}
 				else {
-					(void)mapping_make(kernel_pmap, 0, where, v, 
-						VM_PROT_READ, 2, 0);	/* Map it in for the moment */
+					addr64_t collad;
+					
+					collad = mapping_make(kernel_pmap, (addr64_t)where, (ppnum_t)(vll >> 12), 0, 1, VM_PROT_READ);	/* Map it in for the moment */
+					if(collad) {						/* See if it failed (shouldn't happen)  */
+						kmem_free(kernel_map, where, PAGE_SIZE);	/* Toss the page */
+						goto fault;						/* Kill the transfer */
+					}
 				}
 			}
 			else {
-				if (kmem_alloc(kernel_map, &where, size) 
+				if (kmem_alloc(kernel_map, &where, 4096) 
 					!= KERN_SUCCESS) {
 					goto fault;
 				}
 			}
-			o = uio->uio_offset - v;
+			o = uio->uio_offset - vll;
 			c = min(PAGE_SIZE - o, (u_int)iov->iov_len);
-			error = uiomove((caddr_t) (where + o), c, uio);
+			error = uiomove((where + o), c, uio);
 
-			if(dgWork.dgFlags & enaDiagDM) (void)mapping_remove(kernel_pmap, where);	/* Unmap it */
+			if(dgWork.dgFlags & enaDiagDM) (void)mapping_remove(kernel_pmap, (addr64_t)where);	/* Unmap it */
 			kmem_free(kernel_map, where, PAGE_SIZE);
 			continue;
 
 		/* minor device 1 is kernel memory */
 		case 1:
 			/* Do some sanity checking */
-			if (((caddr_t)uio->uio_offset >= VM_MAX_KERNEL_ADDRESS) ||
-				((caddr_t)uio->uio_offset <= VM_MIN_KERNEL_ADDRESS))
+			if (((addr64_t)uio->uio_offset > vm_last_addr) ||
+				((addr64_t)uio->uio_offset < VM_MIN_KERNEL_ADDRESS))
 				goto fault;
 			c = iov->iov_len;
-			if (!kernacc((caddr_t)uio->uio_offset, c))
+			if (!kernacc(uio->uio_offset, c))
 				goto fault;
-			error = uiomove((caddr_t)uio->uio_offset, (int)c, uio);
+			error = uiomove64(uio->uio_offset, (int)c, uio);
 			continue;
 
 		/* minor device 2 is EOF/RATHOLE */
diff --git a/bsd/dev/ppc/memmove.c b/bsd/dev/ppc/memmove.c
index e36599aa8..93a384550 100644
--- a/bsd/dev/ppc/memmove.c
+++ b/bsd/dev/ppc/memmove.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/dev/ppc/nvram.c b/bsd/dev/ppc/nvram.c
index d4900147f..0f7506319 100644
--- a/bsd/dev/ppc/nvram.c
+++ b/bsd/dev/ppc/nvram.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/dev/ppc/ppc_init.c b/bsd/dev/ppc/ppc_init.c
index 293ac2a6a..85e0df882 100644
--- a/bsd/dev/ppc/ppc_init.c
+++ b/bsd/dev/ppc/ppc_init.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/dev/ppc/stubs.c b/bsd/dev/ppc/stubs.c
index 630a1b0b6..9ba788aee 100644
--- a/bsd/dev/ppc/stubs.c
+++ b/bsd/dev/ppc/stubs.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -39,38 +42,6 @@
 #include <vm/vm_map.h>
 
 
-/* 
- * copy a null terminated string from the kernel address space into
- * the user address space.
- *   - if the user is denied write access, return EFAULT.
- *   - if the end of string isn't found before
- *     maxlen bytes are copied,  return ENAMETOOLONG,
- *     indicating an incomplete copy.
- *   - otherwise, return 0, indicating success.
- * the number of bytes copied is always returned in lencopied.
- */
-int
-copyoutstr(from, to, maxlen, lencopied)
-    void * from, * to;
-    size_t maxlen, *lencopied;
-{
-	int slen,len,error=0;
-
-	/* XXX Must optimize this */
-
-	slen = strlen(from) + 1;
-	if (slen > maxlen)
-		error = ENAMETOOLONG;
-
-	len = min(maxlen,slen);
-	if (copyout(from, to, len))
-		error = EFAULT;
-	*lencopied = len;
-
-	return error;
-}
-
-
 /* 
  * copy a null terminated string from one point to another in 
  * the kernel address space.
diff --git a/bsd/dev/ppc/systemcalls.c b/bsd/dev/ppc/systemcalls.c
index e84fd36dc..2387c0a80 100644
--- a/bsd/dev/ppc/systemcalls.c
+++ b/bsd/dev/ppc/systemcalls.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -24,6 +27,7 @@
 #include <kern/thread.h>
 #include <kern/thread_act.h>
 #include <kern/assert.h>
+#include <kern/clock.h>
 #include <mach/machine/thread_status.h>
 #include <ppc/savearea.h>
 
@@ -46,8 +50,8 @@ extern struct savearea *
 find_user_regs(
 	thread_act_t act);
 
-extern enter_funnel_section(funnel_t *funnel_lock);
-extern exit_funnel_section(funnel_t *funnel_lock);
+extern void enter_funnel_section(funnel_t *funnel_lock);
+extern void exit_funnel_section(void);
 
 /*
  * Function:	unix_syscall
@@ -78,7 +82,7 @@ unix_syscall(
 	else
 		proc = current_proc();
 
-	flavor = (regs->save_r0 == NULL)? 1: 0;
+	flavor = (((unsigned int)regs->save_r0) == NULL)? 1: 0;
 
 	uthread->uu_ar0 = (int *)regs;
 
@@ -161,7 +165,7 @@ unix_syscall(
 		regs->save_srr0 -= 8;
 	} else if (error != EJUSTRETURN) {
 		if (error) {
-			regs->save_r3 = error;
+			regs->save_r3 = (long long)error;
 			/* set the "pc" to execute cerror routine */
 			regs->save_srr0 -= 4;
 		} else { /* (not error) */
@@ -174,10 +178,7 @@ unix_syscall(
 	if (KTRPOINT(proc, KTR_SYSRET))
 		ktrsysret(proc, code, error, uthread->uu_rval[0], funnel_type);
 
-	if(funnel_type == KERNEL_FUNNEL) 
-		 exit_funnel_section(kernel_flock);
-	else if (funnel_type == NETWORK_FUNNEL)
-		 exit_funnel_section(network_flock);
+	 exit_funnel_section();
 
 	if (kdebug_enable && (code != 180)) {
 		KERNEL_DEBUG_CONSTANT(BSDDBG_CODE(DBG_BSD_EXCP_SC, code) | DBG_FUNC_END,
@@ -211,7 +212,7 @@ unix_syscall_return(error)
 		regs->save_srr0 -= 8;
 	} else if (error != EJUSTRETURN) {
 		if (error) {
-			regs->save_r3 = error;
+			regs->save_r3 = (long long)error;
 			/* set the "pc" to execute cerror routine */
 			regs->save_srr0 -= 4;
 		} else { /* (not error) */
@@ -233,10 +234,7 @@ unix_syscall_return(error)
 	if (KTRPOINT(proc, KTR_SYSRET))
 		ktrsysret(proc, code, error, uthread->uu_rval[0], funnel_type);
 
-	if(funnel_type == KERNEL_FUNNEL) 
-		 exit_funnel_section(kernel_flock);
-	else if (funnel_type == NETWORK_FUNNEL)
-		 exit_funnel_section(network_flock);
+	 exit_funnel_section();
 
 	if (kdebug_enable && (code != 180)) {
 		KERNEL_DEBUG_CONSTANT(BSDDBG_CODE(DBG_BSD_EXCP_SC, code) | DBG_FUNC_END,
@@ -260,31 +258,29 @@ struct gettimeofday_args{
 	struct timeval *tp;
 	struct timezone *tzp;
 };
-/*  NOTE THIS implementation is for  ppc architectures only */
+/*  NOTE THIS implementation is for  ppc architectures only.
+ *  It is infrequently called, since the commpage intercepts
+ *  most calls in user mode.
+ */
 int
 ppc_gettimeofday(p, uap, retval)
 	struct proc *p;
 	register struct gettimeofday_args *uap;
 	register_t *retval;
 {
-	struct timeval atv;
 	int error = 0;
-	struct timezone ltz;
-	//struct savearea *child_state;
-	extern simple_lock_data_t tz_slock;
-
-	if (uap->tp) {
-		microtime(&atv);
-		retval[0] = atv.tv_sec;
-		retval[1] = atv.tv_usec;
-	}
+
+	if (uap->tp)
+		clock_gettimeofday(&retval[0], &retval[1]);
 	
 	if (uap->tzp) {
-		usimple_lock(&tz_slock);
+        	struct timezone ltz;
+        	extern simple_lock_data_t tz_slock;
+        
+    		usimple_lock(&tz_slock);
 		ltz = tz;
 		usimple_unlock(&tz_slock);
-		error = copyout((caddr_t)&ltz, (caddr_t)uap->tzp,
-		    sizeof (tz));
+		error = copyout((caddr_t)&ltz, (caddr_t)uap->tzp, sizeof (tz));
 	}
 
 	return(error);
diff --git a/bsd/dev/ppc/unix_signal.c b/bsd/dev/ppc/unix_signal.c
index bc2a1f20f..941ae0fe6 100644
--- a/bsd/dev/ppc/unix_signal.c
+++ b/bsd/dev/ppc/unix_signal.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -38,7 +41,6 @@
 #include <kern/thread.h>
 #include <kern/thread_act.h>
 #include <mach/ppc/thread_status.h>
-#define __ELF__ 0
 #include <ppc/proc_reg.h>
 
 #define	C_REDZONE_LEN		224
@@ -47,6 +49,41 @@
 #define	C_LINKAGE_LEN		48
 #define TRUNC_DOWN(a,b,c)  (((((unsigned)a)-(b))/(c)) * (c))
 
+/*
+ * The stack layout possibilities (info style); This needs to mach with signal trampoline code
+ *
+ * Traditional:			1
+ * Traditional64:		20
+ * Traditional64with vec:	25
+ * 32bit context		30
+ * 32bit context with vector	35
+ * 64bit context		40
+ * 64bit context with vector	45
+ * Dual context			50
+ * Dual context with vector	55
+ *
+ */
+ 
+#define UC_TRAD			1
+#define UC_TRAD64		20
+#define UC_TRAD64_VEC		25
+#define UC_FLAVOR		30
+#define UC_FLAVOR_VEC		35
+#define UC_FLAVOR64		40
+#define UC_FLAVOR64_VEC		45
+#define UC_DUAL			50
+#define UC_DUAL_VEC		55
+
+ /* The following are valid mcontext sizes */
+#define UC_FLAVOR_SIZE ((PPC_THREAD_STATE_COUNT + PPC_EXCEPTION_STATE_COUNT + PPC_FLOAT_STATE_COUNT) * sizeof(int))
+
+#define UC_FLAVOR_VEC_SIZE ((PPC_THREAD_STATE_COUNT + PPC_EXCEPTION_STATE_COUNT + PPC_FLOAT_STATE_COUNT + PPC_VECTOR_STATE_COUNT) * sizeof(int))
+
+#define UC_FLAVOR64_SIZE ((PPC_THREAD_STATE64_COUNT + PPC_EXCEPTION_STATE64_COUNT + PPC_FLOAT_STATE_COUNT) * sizeof(int))
+
+#define UC_FLAVOR64_VEC_SIZE ((PPC_THREAD_STATE64_COUNT + PPC_EXCEPTION_STATE64_COUNT + PPC_FLOAT_STATE_COUNT + PPC_VECTOR_STATE_COUNT) * sizeof(int))
+
+
 /*
  * Arrange for this process to run a signal handler
  */
@@ -59,6 +96,7 @@ sendsig(p, catcher, sig, mask, code)
 	u_long code;
 {
 	struct mcontext mctx, *p_mctx;
+	struct mcontext64 mctx64, *p_mctx64;
 	struct ucontext uctx, *p_uctx;
 	siginfo_t sinfo, *p_sinfo;
 	struct sigacts *ps = p->p_sigacts;
@@ -69,42 +107,115 @@ sendsig(p, catcher, sig, mask, code)
 	thread_act_t th_act;
 	struct uthread *ut;
 	unsigned long paramp,linkp;
-	int infostyle = 1;
+	int infostyle = UC_TRAD;
+	int dualcontext =0;
 	sig_t trampact;
 	int vec_used = 0;
 	int stack_size = 0;
 	int stack_flags = 0;
+	void * tstate;
+	int flavor;
+        int ctx32 = 1;
+	int is_64signalregset(void);
 
 	th_act = current_act();
 	ut = get_bsdthread_info(th_act);
 
-	state_count = PPC_EXCEPTION_STATE_COUNT;
-	if (act_machine_get_state(th_act, PPC_EXCEPTION_STATE, &mctx.es, &state_count)  != KERN_SUCCESS) {
-		goto bad;
-	}	
+	
+	if (p->p_sigacts->ps_siginfo & sigmask(sig)) {
+		infostyle = UC_FLAVOR;
+        }
+	if(is_64signalregset() && (infostyle == UC_FLAVOR)) {
+		dualcontext = 1;
+		infostyle = UC_DUAL;	
+	}
+	if (p->p_sigacts->ps_64regset & sigmask(sig))  {
+		dualcontext = 0;
+                ctx32 = 0;
+		infostyle = UC_FLAVOR64;
+	}
+        if (is_64signalregset() && (infostyle == UC_TRAD)) {
+                ctx32=0;
+ 		infostyle = UC_TRAD64;
+       }
+	
+	/* I need this for SIGINFO anyway */
+	flavor = PPC_THREAD_STATE;
+	tstate = (void *)&mctx.ss;
 	state_count = PPC_THREAD_STATE_COUNT;
-	if (act_machine_get_state(th_act, PPC_THREAD_STATE, &mctx.ss, &state_count)  != KERN_SUCCESS) {
-		goto bad;
-	}	
-	state_count = PPC_FLOAT_STATE_COUNT;
-	if (act_machine_get_state(th_act, PPC_FLOAT_STATE, &mctx.fs, &state_count)  != KERN_SUCCESS) {
+	if (thread_getstatus(th_act, flavor, (thread_state_t)tstate, &state_count)  != KERN_SUCCESS)
 		goto bad;
-	}	
+
+	if ((ctx32 == 0) || dualcontext) {
+		flavor = PPC_THREAD_STATE64;
+		tstate = (void *)&mctx64.ss;
+		state_count = PPC_THREAD_STATE64_COUNT;
+                if (thread_getstatus(th_act, flavor, (thread_state_t)tstate, &state_count)  != KERN_SUCCESS)
+                    goto bad;
+	}
+
+        if ((ctx32 == 1) || dualcontext) {
+                flavor = PPC_EXCEPTION_STATE;
+		tstate = (void *)&mctx.es;
+		state_count = PPC_EXCEPTION_STATE_COUNT;
+                if (thread_getstatus(th_act, flavor, (thread_state_t)tstate, &state_count)  != KERN_SUCCESS)
+                    goto bad;
+       } 
+       
+	if ((ctx32 == 0) || dualcontext) {
+ 		flavor = PPC_EXCEPTION_STATE64;
+		tstate = (void *)&mctx64.es;
+		state_count = PPC_EXCEPTION_STATE64_COUNT;
+       
+                if (thread_getstatus(th_act, flavor, (thread_state_t)tstate, &state_count)  != KERN_SUCCESS)
+                    goto bad;
+                
+        }
+       
+
+        if ((ctx32 == 1) || dualcontext) {
+                flavor = PPC_FLOAT_STATE;
+		tstate = (void *)&mctx.fs;
+		state_count = PPC_FLOAT_STATE_COUNT;
+                if (thread_getstatus(th_act, flavor, (thread_state_t)tstate, &state_count)  != KERN_SUCCESS)
+                    goto bad;
+       } 
+       
+	if ((ctx32 == 0) || dualcontext) {
+ 		flavor = PPC_FLOAT_STATE;
+		tstate = (void *)&mctx64.fs;
+		state_count = PPC_FLOAT_STATE_COUNT;
+                       if (thread_getstatus(th_act, flavor, (thread_state_t)tstate, &state_count)  != KERN_SUCCESS)
+                    goto bad;
+                
+        }
+
 
 	vec_save(th_act);
 	if (find_user_vec(th_act)) {
 		vec_used = 1;
-		state_count = PPC_VECTOR_STATE_COUNT;
-		if (act_machine_get_state(th_act, PPC_VECTOR_STATE, &mctx.vs, &state_count)  != KERN_SUCCESS) {
-			goto bad;
-		}	
-		
-	}
+
+                if ((ctx32 == 1) || dualcontext) {
+                    flavor = PPC_VECTOR_STATE;
+                    tstate = (void *)&mctx.vs;
+                    state_count = PPC_VECTOR_STATE_COUNT;
+                    if (thread_getstatus(th_act, flavor, (thread_state_t)tstate, &state_count)  != KERN_SUCCESS)
+                    goto bad;
+                    infostyle += 5;
+            } 
+       
+            if ((ctx32 == 0) || dualcontext) {
+                    flavor = PPC_VECTOR_STATE;
+                    tstate = (void *)&mctx64.vs;
+                    state_count = PPC_VECTOR_STATE_COUNT;
+                    if (thread_getstatus(th_act, flavor, (thread_state_t)tstate, &state_count)  != KERN_SUCCESS)
+                        goto bad;
+                    infostyle += 5;
+           }
+	}  
 
 	trampact = ps->ps_trampact[sig];
 	oonstack = ps->ps_sigstk.ss_flags & SA_ONSTACK;
-	if (p->p_sigacts->ps_siginfo & sigmask(sig))
-		infostyle = 2;
 
 	/* figure out where our new stack lives */
 	if ((ps->ps_flags & SAS_ALTSTACK) && !oonstack &&
@@ -114,13 +225,30 @@ sendsig(p, catcher, sig, mask, code)
 		stack_size = ps->ps_sigstk.ss_size;
 		ps->ps_sigstk.ss_flags |= SA_ONSTACK;
 	}
-	else
-		sp = mctx.ss.r1;
+	else {
+		if (ctx32 == 0)
+			sp = (unsigned int)mctx64.ss.r1;
+		else
+			sp = mctx.ss.r1;
+	}
 
+	
+	/* put siginfo on top */
+        
 	/* preserve RED ZONE area */
 	sp = TRUNC_DOWN(sp, C_REDZONE_LEN, C_STK_ALIGN);
 
-	/* context goes first on stack */
+        /* next are the saved registers */
+        if ((ctx32 == 0) || dualcontext) {
+            sp -= sizeof(*p_mctx64);
+            p_mctx64 = (struct mcontext64 *)sp;
+        }
+        if ((ctx32 == 1) || dualcontext) {
+            sp -= sizeof(*p_mctx);
+            p_mctx = (struct mcontext *)sp;
+        }    
+        
+        /* context goes first on stack */
 	sp -= sizeof(*p_uctx);
 	p_uctx = (struct ucontext *) sp;
 
@@ -128,13 +256,9 @@ sendsig(p, catcher, sig, mask, code)
 	sp -= sizeof(*p_sinfo);
 	p_sinfo = (siginfo_t *) sp;
 
-	/* next are the saved registers */
-	sp -= sizeof(*p_mctx);
-	p_mctx = (struct mcontext *)sp;
-
 	/* C calling conventions, create param save and linkage
-	 *  areas
-	 */
+	*  areas
+	*/
 
 	sp = TRUNC_DOWN(sp, C_PARAMSAVE_LEN, C_STK_ALIGN);
 	paramp = sp;
@@ -149,14 +273,25 @@ sendsig(p, catcher, sig, mask, code)
 		uctx.uc_stack.ss_flags |= SS_ONSTACK;
 		
 	uctx.uc_link = 0;
-	uctx.uc_mcsize = (size_t)((PPC_EXCEPTION_STATE_COUNT + PPC_THREAD_STATE_COUNT + PPC_FLOAT_STATE_COUNT) * sizeof(int));
+	if (ctx32 == 0)
+		uctx.uc_mcsize = (size_t)((PPC_EXCEPTION_STATE64_COUNT + PPC_THREAD_STATE64_COUNT + PPC_FLOAT_STATE_COUNT) * sizeof(int));
+	else
+		uctx.uc_mcsize = (size_t)((PPC_EXCEPTION_STATE_COUNT + PPC_THREAD_STATE_COUNT + PPC_FLOAT_STATE_COUNT) * sizeof(int));
+	
 	if (vec_used) 
 		uctx.uc_mcsize += (size_t)(PPC_VECTOR_STATE_COUNT * sizeof(int));
-	uctx.uc_mcontext = p_mctx;
+        
+	if (ctx32 == 0)
+             uctx.uc_mcontext = (void *)p_mctx64;
+       else
+            uctx.uc_mcontext = (void *)p_mctx;
 
 	/* setup siginfo */
 	bzero((caddr_t)&sinfo, sizeof(siginfo_t));
 	sinfo.si_signo = sig;
+	sinfo.si_addr = (void *)mctx.ss.srr0;
+	sinfo.pad[0] = (unsigned int)mctx.ss.r1;
+
 	switch (sig) {
 		case SIGCHLD:
 			sinfo.si_pid = p->si_pid;
@@ -230,13 +365,23 @@ sendsig(p, catcher, sig, mask, code)
 			break;
 	}
 
+
 	/* copy info out to user space */
 	if (copyout((caddr_t)&uctx, (caddr_t)p_uctx, sizeof(struct ucontext)))
 		goto bad;
 	if (copyout((caddr_t)&sinfo, (caddr_t)p_sinfo, sizeof(siginfo_t)))
 		goto bad;
-	if (copyout((caddr_t)&mctx, (caddr_t)p_mctx, uctx.uc_mcsize))
+        if ((ctx32 == 0) || dualcontext) {
+		tstate = &mctx64;
+            if (copyout((caddr_t)tstate, (caddr_t)p_mctx64, uctx.uc_mcsize))
 		goto bad;
+        }
+        if ((ctx32 == 1) || dualcontext) {
+		tstate = &mctx;
+            if (copyout((caddr_t)tstate, (caddr_t)p_mctx, uctx.uc_mcsize))
+		goto bad;
+        }    
+
 
 	/* Place our arguments in arg registers: rtm dependent */
 
@@ -250,10 +395,9 @@ sendsig(p, catcher, sig, mask, code)
 	mctx.ss.srr1 = get_msr_exportmask();	/* MSR_EXPORT_MASK_SET */
 	mctx.ss.r1 = sp;
 	state_count = PPC_THREAD_STATE_COUNT;
-	if (act_machine_set_state(th_act, PPC_THREAD_STATE, &mctx.ss, &state_count)  != KERN_SUCCESS) {
+	if (thread_setstatus(th_act, PPC_THREAD_STATE, &mctx.ss, &state_count)  != KERN_SUCCESS) {
 		goto bad;
 	}	
-
 	return;
 
 bad:
@@ -277,8 +421,121 @@ bad:
  * psl to gain improper priviledges or to cause
  * a machine fault.
  */
+
+#define FOR64_TRANSITION 1
+
+#ifdef FOR64_TRANSITION
+
+struct osigreturn_args {
+	struct ucontext *uctx;
+};
+
+/* ARGSUSED */
+int
+osigreturn(p, uap, retval)
+	struct proc *p;
+	struct osigreturn_args *uap;
+	int *retval;
+{
+	struct ucontext uctx;
+	struct ucontext *p_uctx;
+	struct mcontext64 mctx64;
+	struct mcontext64 *p_64mctx;
+	struct mcontext  *p_mctx;
+	int error;
+	thread_act_t th_act;
+	struct sigacts *ps = p->p_sigacts;
+	sigset_t mask;	
+	register sig_t action;
+	unsigned long state_count;
+	unsigned int state_flavor;
+	struct uthread * ut;
+	int vec_used = 0;
+	void *tsptr, *fptr, *vptr, *mactx;
+	void ppc_checkthreadstate(void *, int);
+
+	th_act = current_act();
+	/* lets use the larger one */
+	mactx = (void *)&mctx64;
+
+	ut = (struct uthread *)get_bsdthread_info(th_act);
+	if (error = copyin(uap->uctx, &uctx, sizeof(struct ucontext))) {
+		return(error);
+	}
+	if (error = copyin(uctx.uc_mcontext, mactx, uctx.uc_mcsize)) {
+		return(error);
+	}
+	
+	if (uctx.uc_onstack & 01)
+			p->p_sigacts->ps_sigstk.ss_flags |= SA_ONSTACK;
+	else
+		p->p_sigacts->ps_sigstk.ss_flags &= ~SA_ONSTACK;
+
+	ut->uu_sigmask = uctx.uc_sigmask & ~sigcantmask;
+	if (ut->uu_siglist & ~ut->uu_sigmask)
+		signal_setast(current_act());	
+
+	vec_used = 0;
+	switch (uctx.uc_mcsize)  {
+		case UC_FLAVOR64_VEC_SIZE :
+			vec_used = 1;
+		case UC_FLAVOR64_SIZE : {
+			p_64mctx = (struct mcontext64 *)mactx;	
+			tsptr = (void *)&p_64mctx->ss;
+			fptr = (void *)&p_64mctx->fs;
+			vptr = (void *)&p_64mctx->vs;
+			state_flavor = PPC_THREAD_STATE64;
+			state_count = PPC_THREAD_STATE64_COUNT;
+			}
+			break;
+		case UC_FLAVOR_VEC_SIZE :
+			vec_used = 1;
+		case UC_FLAVOR_SIZE:
+		default: {
+			p_mctx = (struct mcontext *)mactx;	
+			tsptr = (void *)&p_mctx->ss;
+			fptr = (void *)&p_mctx->fs;
+			vptr = (void *)&p_mctx->vs;
+			state_flavor = PPC_THREAD_STATE;
+			state_count = PPC_THREAD_STATE_COUNT;
+		}
+		break;
+	} /* switch () */
+
+	/* validate the thread state, set/reset appropriate mode bits in srr1 */
+	(void)ppc_checkthreadstate(tsptr, state_flavor);
+
+	if (thread_setstatus(th_act, state_flavor, tsptr, &state_count)  != KERN_SUCCESS) {
+		return(EINVAL);
+	}	
+
+	state_count = PPC_FLOAT_STATE_COUNT;
+	if (thread_setstatus(th_act, PPC_FLOAT_STATE, fptr, &state_count)  != KERN_SUCCESS) {
+		return(EINVAL);
+	}	
+
+	mask = sigmask(SIGFPE);
+	if (((ut->uu_sigmask & mask) == 0) && (p->p_sigcatch & mask) && ((p->p_sigignore & mask) == 0)) {
+		action = ps->ps_sigact[SIGFPE];
+		if((action != SIG_DFL) && (action != SIG_IGN)) {
+			thread_enable_fpe(th_act, 1);
+		}
+	}
+
+	if (vec_used) {
+		state_count = PPC_VECTOR_STATE_COUNT;
+		if (thread_setstatus(th_act, PPC_VECTOR_STATE, vptr, &state_count)  != KERN_SUCCESS) {
+			return(EINVAL);
+		}	
+	}
+	return (EJUSTRETURN);
+}
+
+#endif /* FOR64_TRANSITION */
+
 struct sigreturn_args {
 	struct ucontext *uctx;
+        int infostyle;
 };
 
 /* ARGSUSED */
@@ -288,19 +545,23 @@ sigreturn(p, uap, retval)
 	struct sigreturn_args *uap;
 	int *retval;
 {
-	struct ucontext uctx, *p_uctx;
-	struct mcontext mctx, *p_mctx;
+	struct ucontext uctx;
+	struct ucontext *p_uctx;
+        char mactx[sizeof(struct mcontext64)];
+	struct mcontext  *p_mctx;
+	struct mcontext64 *p_64mctx;
 	int error;
 	thread_act_t th_act;
-	struct ppc_float_state fs;
-	struct ppc_exception_state es;
 	struct sigacts *ps = p->p_sigacts;
 	sigset_t mask;	
 	register sig_t action;
 	unsigned long state_count;
-	unsigned int nbits, rbits;
+	unsigned int state_flavor;
 	struct uthread * ut;
 	int vec_used = 0;
+	void *tsptr, *fptr, *vptr;
+        int infostyle = uap->infostyle;
+	void ppc_checkthreadstate(void *, int);
 
 	th_act = current_act();
 
@@ -308,7 +569,9 @@ sigreturn(p, uap, retval)
 	if (error = copyin(uap->uctx, &uctx, sizeof(struct ucontext))) {
 		return(error);
 	}
-	if (error = copyin(uctx.uc_mcontext, &mctx, sizeof(struct mcontext))) {
+        
+        
+	if (error = copyin(uctx.uc_mcontext, mactx, uctx.uc_mcsize)) {
 		return(error);
 	}
 	
@@ -316,32 +579,49 @@ sigreturn(p, uap, retval)
 			p->p_sigacts->ps_sigstk.ss_flags |= SA_ONSTACK;
 	else
 		p->p_sigacts->ps_sigstk.ss_flags &= ~SA_ONSTACK;
-	ut->uu_sigmask = uctx.uc_sigmask & ~sigcantmask;
-
 
+	ut->uu_sigmask = uctx.uc_sigmask & ~sigcantmask;
 	if (ut->uu_siglist & ~ut->uu_sigmask)
 		signal_setast(current_act());	
 
-	nbits = get_msr_nbits();
-	rbits = get_msr_rbits();
-	/* adjust the critical fields */
-	/* make sure naughty bits are off */
-	mctx.ss.srr1 &= ~(nbits);
-	/* make sure necessary bits are on */
-	mctx.ss.srr1 |= (rbits);
+	vec_used = 0;
+	switch (infostyle)  {
+                case UC_FLAVOR64_VEC:
+                case UC_TRAD64_VEC:
+                                vec_used = 1;
+                case UC_TRAD64:
+		case UC_FLAVOR64:  {
+                            p_64mctx = (struct mcontext64 *)mactx;	
+                            tsptr = (void *)&p_64mctx->ss;
+                            fptr = (void *)&p_64mctx->fs;
+                            vptr = (void *)&p_64mctx->vs;
+                            state_flavor = PPC_THREAD_STATE64;
+                            state_count = PPC_THREAD_STATE64_COUNT;
+                    } 
+                    break;
+		case UC_FLAVOR_VEC :
+                                vec_used = 1;
+		case UC_FLAVOR :
+		default: {
+			p_mctx = (struct mcontext *)mactx;	
+			tsptr = (void *)&p_mctx->ss;
+			fptr = (void *)&p_mctx->fs;
+			vptr = (void *)&p_mctx->vs;
+			state_flavor = PPC_THREAD_STATE;
+			state_count = PPC_THREAD_STATE_COUNT;
+		}
+		break;
+	} /* switch () */
 
-	state_count = (size_t)((PPC_EXCEPTION_STATE_COUNT + PPC_THREAD_STATE_COUNT + PPC_FLOAT_STATE_COUNT) * sizeof(int));
+	/* validate the thread state, set/reset appropriate mode bits in srr1 */
+	(void)ppc_checkthreadstate(tsptr, state_flavor);
 
-	if (uctx.uc_mcsize > state_count)
-		vec_used = 1;
-
-	state_count = PPC_THREAD_STATE_COUNT;
-	if (act_machine_set_state(th_act, PPC_THREAD_STATE, &mctx.ss, &state_count)  != KERN_SUCCESS) {
+	if (thread_setstatus(th_act, state_flavor, tsptr, &state_count)  != KERN_SUCCESS) {
 		return(EINVAL);
 	}	
 
 	state_count = PPC_FLOAT_STATE_COUNT;
-	if (act_machine_set_state(th_act, PPC_FLOAT_STATE, &mctx.fs, &state_count)  != KERN_SUCCESS) {
+	if (thread_setstatus(th_act, PPC_FLOAT_STATE, fptr, &state_count)  != KERN_SUCCESS) {
 		return(EINVAL);
 	}	
 
@@ -355,11 +635,10 @@ sigreturn(p, uap, retval)
 
 	if (vec_used) {
 		state_count = PPC_VECTOR_STATE_COUNT;
-		if (act_machine_set_state(th_act, PPC_VECTOR_STATE, &mctx.vs, &state_count)  != KERN_SUCCESS) {
+		if (thread_setstatus(th_act, PPC_VECTOR_STATE, vptr, &state_count)  != KERN_SUCCESS) {
 			return(EINVAL);
 		}	
 	}
-
 	return (EJUSTRETURN);
 }
 
diff --git a/bsd/dev/ppc/unix_startup.c b/bsd/dev/ppc/unix_startup.c
index 531a75a0b..1b84c433d 100644
--- a/bsd/dev/ppc/unix_startup.c
+++ b/bsd/dev/ppc/unix_startup.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -65,7 +68,7 @@ bsd_startupearly()
 	kern_return_t	ret;
 
 	if (nbuf == 0)
-		nbuf = atop(mem_size / 100); /* 1% */
+		nbuf = atop_64(sane_size / 100); /* Get 1% of ram, but no more than we can map */
 	if (nbuf > 8192)
 		nbuf = 8192;
 	if (nbuf < 256)
@@ -79,7 +82,7 @@ bsd_startupearly()
 		niobuf = 128;
 
 	size = (nbuf + niobuf) * sizeof (struct buf);
-	size = round_page(size);
+	size = round_page_32(size);
 
 	ret = kmem_suballoc(kernel_map,
 			&firstaddr,
@@ -103,13 +106,13 @@ bsd_startupearly()
 	buf = (struct buf * )firstaddr;
 	bzero(buf,size);
 
-	if ((mem_size > (64 * 1024 * 1024)) || ncl) {
+	if ((sane_size > (64 * 1024 * 1024)) || ncl) {
 		int scale;
 		extern u_long tcp_sendspace;
 		extern u_long tcp_recvspace;
 
 		if ((nmbclusters = ncl) == 0) {
-			if ((nmbclusters = ((mem_size / 16) / MCLBYTES)) > 16384)
+			if ((nmbclusters = ((sane_size / 16) / MCLBYTES)) > 16384)
 				nmbclusters = 16384;
 		}
 		if ((scale = nmbclusters / NMBCLUSTERS) > 1) {
diff --git a/bsd/dev/ppc/xsumas.s b/bsd/dev/ppc/xsumas.s
index c83a688f1..765e56af6 100644
--- a/bsd/dev/ppc/xsumas.s
+++ b/bsd/dev/ppc/xsumas.s
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/dev/random/YarrowCoreLib/include/WindowsTypesForMac.h b/bsd/dev/random/YarrowCoreLib/include/WindowsTypesForMac.h
index bdab3ea8a..42b82b3d3 100644
--- a/bsd/dev/random/YarrowCoreLib/include/WindowsTypesForMac.h
+++ b/bsd/dev/random/YarrowCoreLib/include/WindowsTypesForMac.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/dev/random/YarrowCoreLib/include/yarrow.h b/bsd/dev/random/YarrowCoreLib/include/yarrow.h
index af6b23bf1..001d7b686 100644
--- a/bsd/dev/random/YarrowCoreLib/include/yarrow.h
+++ b/bsd/dev/random/YarrowCoreLib/include/yarrow.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/dev/random/YarrowCoreLib/include/yarrowUtils.h b/bsd/dev/random/YarrowCoreLib/include/yarrowUtils.h
index c25314991..f21180bf5 100644
--- a/bsd/dev/random/YarrowCoreLib/include/yarrowUtils.h
+++ b/bsd/dev/random/YarrowCoreLib/include/yarrowUtils.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/dev/random/YarrowCoreLib/port/smf.c b/bsd/dev/random/YarrowCoreLib/port/smf.c
index 838a87601..fff85ddd9 100644
--- a/bsd/dev/random/YarrowCoreLib/port/smf.c
+++ b/bsd/dev/random/YarrowCoreLib/port/smf.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/dev/random/YarrowCoreLib/src/assertverify.h b/bsd/dev/random/YarrowCoreLib/src/assertverify.h
index feff7245c..7b775cb73 100644
--- a/bsd/dev/random/YarrowCoreLib/src/assertverify.h
+++ b/bsd/dev/random/YarrowCoreLib/src/assertverify.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/dev/random/YarrowCoreLib/src/comp.c b/bsd/dev/random/YarrowCoreLib/src/comp.c
index 91c1844a0..f3f54b57e 100644
--- a/bsd/dev/random/YarrowCoreLib/src/comp.c
+++ b/bsd/dev/random/YarrowCoreLib/src/comp.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/dev/random/YarrowCoreLib/src/comp.h b/bsd/dev/random/YarrowCoreLib/src/comp.h
index e264e2c00..941261cf5 100644
--- a/bsd/dev/random/YarrowCoreLib/src/comp.h
+++ b/bsd/dev/random/YarrowCoreLib/src/comp.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/dev/random/YarrowCoreLib/src/entropysources.h b/bsd/dev/random/YarrowCoreLib/src/entropysources.h
index ad9cfb2ec..a51ddc995 100644
--- a/bsd/dev/random/YarrowCoreLib/src/entropysources.h
+++ b/bsd/dev/random/YarrowCoreLib/src/entropysources.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/dev/random/YarrowCoreLib/src/macOnly.h b/bsd/dev/random/YarrowCoreLib/src/macOnly.h
index ea1d86b42..c05e53e9c 100644
--- a/bsd/dev/random/YarrowCoreLib/src/macOnly.h
+++ b/bsd/dev/random/YarrowCoreLib/src/macOnly.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/dev/random/YarrowCoreLib/src/prng.c b/bsd/dev/random/YarrowCoreLib/src/prng.c
index fa4ab5fec..aaf58cbaa 100644
--- a/bsd/dev/random/YarrowCoreLib/src/prng.c
+++ b/bsd/dev/random/YarrowCoreLib/src/prng.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/dev/random/YarrowCoreLib/src/prng.h b/bsd/dev/random/YarrowCoreLib/src/prng.h
index 8524068a6..5c344fae4 100644
--- a/bsd/dev/random/YarrowCoreLib/src/prng.h
+++ b/bsd/dev/random/YarrowCoreLib/src/prng.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/dev/random/YarrowCoreLib/src/prngpriv.h b/bsd/dev/random/YarrowCoreLib/src/prngpriv.h
index e2919d0d2..c8b3eb115 100644
--- a/bsd/dev/random/YarrowCoreLib/src/prngpriv.h
+++ b/bsd/dev/random/YarrowCoreLib/src/prngpriv.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/dev/random/YarrowCoreLib/src/sha1mod.c b/bsd/dev/random/YarrowCoreLib/src/sha1mod.c
index 03dfa5a23..109199df6 100644
--- a/bsd/dev/random/YarrowCoreLib/src/sha1mod.c
+++ b/bsd/dev/random/YarrowCoreLib/src/sha1mod.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/dev/random/YarrowCoreLib/src/sha1mod.h b/bsd/dev/random/YarrowCoreLib/src/sha1mod.h
index 839168e8b..3ac950048 100644
--- a/bsd/dev/random/YarrowCoreLib/src/sha1mod.h
+++ b/bsd/dev/random/YarrowCoreLib/src/sha1mod.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/dev/random/YarrowCoreLib/src/smf.h b/bsd/dev/random/YarrowCoreLib/src/smf.h
index 538b815f4..07de90a39 100644
--- a/bsd/dev/random/YarrowCoreLib/src/smf.h
+++ b/bsd/dev/random/YarrowCoreLib/src/smf.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/dev/random/YarrowCoreLib/src/userdefines.h b/bsd/dev/random/YarrowCoreLib/src/userdefines.h
index 9ca48cc25..61e1c339a 100644
--- a/bsd/dev/random/YarrowCoreLib/src/userdefines.h
+++ b/bsd/dev/random/YarrowCoreLib/src/userdefines.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/dev/random/YarrowCoreLib/src/yarrowUtils.c b/bsd/dev/random/YarrowCoreLib/src/yarrowUtils.c
index a441c2780..a47ff7dcf 100644
--- a/bsd/dev/random/YarrowCoreLib/src/yarrowUtils.c
+++ b/bsd/dev/random/YarrowCoreLib/src/yarrowUtils.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/dev/random/randomdev.c b/bsd/dev/random/randomdev.c
index f7830f40e..96f997e24 100644
--- a/bsd/dev/random/randomdev.c
+++ b/bsd/dev/random/randomdev.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/dev/random/randomdev.h b/bsd/dev/random/randomdev.h
index efa6703e9..25e3e274e 100644
--- a/bsd/dev/random/randomdev.h
+++ b/bsd/dev/random/randomdev.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/dev/vn/shadow.c b/bsd/dev/vn/shadow.c
index aef372aae..20b78be74 100644
--- a/bsd/dev/vn/shadow.c
+++ b/bsd/dev/vn/shadow.c
@@ -4,19 +4,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/dev/vn/shadow.h b/bsd/dev/vn/shadow.h
index 074ba9e4c..c536eaadd 100644
--- a/bsd/dev/vn/shadow.h
+++ b/bsd/dev/vn/shadow.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/hfs/MacOSStubs.c b/bsd/hfs/MacOSStubs.c
index 1dd6e6860..41bd02c82 100644
--- a/bsd/hfs/MacOSStubs.c
+++ b/bsd/hfs/MacOSStubs.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/hfs/hfs.h b/bsd/hfs/hfs.h
index b82adcf2e..1cfb21d13 100644
--- a/bsd/hfs/hfs.h
+++ b/bsd/hfs/hfs.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -489,6 +492,9 @@ extern void hfs_setencodingbits(struct hfsmount *hfsmp, u_int32_t encoding);
 
 extern void replace_desc(struct cnode *cp, struct cat_desc *cdp);
 
+extern int hfs_namecmp(const char *, size_t, const char *, size_t);
+
+
 #endif /* __APPLE_API_PRIVATE */
 #endif /* KERNEL */
 #endif /* __HFS__ */
diff --git a/bsd/hfs/hfs_attrlist.c b/bsd/hfs/hfs_attrlist.c
index f53d05e3f..b52bed88f 100644
--- a/bsd/hfs/hfs_attrlist.c
+++ b/bsd/hfs/hfs_attrlist.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/hfs/hfs_attrlist.h b/bsd/hfs/hfs_attrlist.h
index e5da460ee..c3ba90752 100644
--- a/bsd/hfs/hfs_attrlist.h
+++ b/bsd/hfs/hfs_attrlist.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/hfs/hfs_btreeio.c b/bsd/hfs/hfs_btreeio.c
index a70290d05..3f7c3cc0c 100644
--- a/bsd/hfs/hfs_btreeio.c
+++ b/bsd/hfs/hfs_btreeio.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/hfs/hfs_catalog.c b/bsd/hfs/hfs_catalog.c
index 769576d7e..32bc234de 100644
--- a/bsd/hfs/hfs_catalog.c
+++ b/bsd/hfs/hfs_catalog.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/hfs/hfs_catalog.h b/bsd/hfs/hfs_catalog.h
index da27320b1..8ed86ba31 100644
--- a/bsd/hfs/hfs_catalog.h
+++ b/bsd/hfs/hfs_catalog.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/hfs/hfs_chash.c b/bsd/hfs/hfs_chash.c
index 5cc8d871d..eb2204aa8 100644
--- a/bsd/hfs/hfs_chash.c
+++ b/bsd/hfs/hfs_chash.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -137,7 +140,7 @@ loop:
 			(void)tsleep((caddr_t)cp, PINOD, "hfs_chashget-2", 0);
 			goto loop;
 		}
-		if (cp->c_flag & C_NOEXISTS)
+		if (cp->c_flag & (C_NOEXISTS | C_DELETED))
 			continue;
 
 		/*
diff --git a/bsd/hfs/hfs_cnode.c b/bsd/hfs/hfs_cnode.c
index 65617595f..e1549bab5 100644
--- a/bsd/hfs/hfs_cnode.c
+++ b/bsd/hfs/hfs_cnode.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -82,15 +85,14 @@ hfs_inactive(ap)
 		++forkcount;
 
 	/* If needed, get rid of any fork's data for a deleted file */
-	if ((cp->c_flag & C_DELETED) &&
-	    vp->v_type == VREG &&
-	    (VTOF(vp)->ff_blocks != 0)) {			
-		error = VOP_TRUNCATE(vp, (off_t)0, IO_NDELAY, NOCRED, p);
-		truncated = 1;
-		// have to do this to prevent the lost ubc_info panic
-		SET(cp->c_flag, C_TRANSIT);
+	if ((vp->v_type == VREG) && (cp->c_flag & C_DELETED)) {
+		if (VTOF(vp)->ff_blocks != 0) {
+			error = VOP_TRUNCATE(vp, (off_t)0, IO_NDELAY, NOCRED, p);
+			if (error)
+				goto out;
+			truncated = 1;
+		}
 		recycle = 1;
-		if (error) goto out;
 	}
 
 	/*
@@ -145,8 +147,7 @@ hfs_inactive(ap)
 		if (error) goto out;
 
 #if QUOTA
-		if (!hfs_getinoquota(cp))
-			(void)hfs_chkiq(cp, -1, NOCRED, 0);
+		(void)hfs_chkiq(cp, -1, NOCRED, 0);
 #endif /* QUOTA */
 
 		cp->c_mode = 0;
@@ -265,7 +266,7 @@ hfs_reclaim(ap)
 #if QUOTA
 		for (i = 0; i < MAXQUOTAS; i++) {
 			if (cp->c_dquot[i] != NODQUOT) {
-				dqrele(vp, cp->c_dquot[i]);
+				dqreclaim(vp, cp->c_dquot[i]);
 				cp->c_dquot[i] = NODQUOT;
 			}
 		}
diff --git a/bsd/hfs/hfs_cnode.h b/bsd/hfs/hfs_cnode.h
index 998514360..eeaee0617 100644
--- a/bsd/hfs/hfs_cnode.h
+++ b/bsd/hfs/hfs_cnode.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/hfs/hfs_dbg.h b/bsd/hfs/hfs_dbg.h
index 0b4942f36..101f17baa 100644
--- a/bsd/hfs/hfs_dbg.h
+++ b/bsd/hfs/hfs_dbg.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/hfs/hfs_encodinghint.c b/bsd/hfs/hfs_encodinghint.c
index c82f1a148..630779e24 100644
--- a/bsd/hfs/hfs_encodinghint.c
+++ b/bsd/hfs/hfs_encodinghint.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/hfs/hfs_encodings.c b/bsd/hfs/hfs_encodings.c
index 185e14503..fdf03bc70 100644
--- a/bsd/hfs/hfs_encodings.c
+++ b/bsd/hfs/hfs_encodings.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/hfs/hfs_encodings.h b/bsd/hfs/hfs_encodings.h
index 233af5ba7..d637fdaa2 100644
--- a/bsd/hfs/hfs_encodings.h
+++ b/bsd/hfs/hfs_encodings.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/hfs/hfs_endian.c b/bsd/hfs/hfs_endian.c
index 89809b608..47bb66a7f 100644
--- a/bsd/hfs/hfs_endian.c
+++ b/bsd/hfs/hfs_endian.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/hfs/hfs_endian.h b/bsd/hfs/hfs_endian.h
index a1b91fdf9..96e121b6e 100644
--- a/bsd/hfs/hfs_endian.h
+++ b/bsd/hfs/hfs_endian.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/hfs/hfs_format.h b/bsd/hfs/hfs_format.h
index a8833dedd..2bb4ae55b 100644
--- a/bsd/hfs/hfs_format.h
+++ b/bsd/hfs/hfs_format.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/hfs/hfs_link.c b/bsd/hfs/hfs_link.c
index 97a36516c..602e96380 100644
--- a/bsd/hfs/hfs_link.c
+++ b/bsd/hfs/hfs_link.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -294,7 +297,9 @@ hfs_link(ap)
 	if (hfsmp->jnl) {
 	    if (journal_start_transaction(hfsmp->jnl) != 0) {
 			hfs_global_shared_lock_release(hfsmp);
-			return EINVAL;
+			VOP_ABORTOP(tdvp, cnp);
+			error = EINVAL;  /* cannot link to a special file */
+			goto out1;
 	    }
 	}
 
diff --git a/bsd/hfs/hfs_lockf.c b/bsd/hfs/hfs_lockf.c
index 63c1c0cb4..2d2e07091 100644
--- a/bsd/hfs/hfs_lockf.c
+++ b/bsd/hfs/hfs_lockf.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/hfs/hfs_lockf.h b/bsd/hfs/hfs_lockf.h
index 0ae8db758..426fe11ca 100644
--- a/bsd/hfs/hfs_lockf.h
+++ b/bsd/hfs/hfs_lockf.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/hfs/hfs_lookup.c b/bsd/hfs/hfs_lookup.c
index db88b99c0..c4013f4c3 100644
--- a/bsd/hfs/hfs_lookup.c
+++ b/bsd/hfs/hfs_lookup.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/hfs/hfs_macos_defs.h b/bsd/hfs/hfs_macos_defs.h
index 33461cc17..ba73a15ef 100644
--- a/bsd/hfs/hfs_macos_defs.h
+++ b/bsd/hfs/hfs_macos_defs.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/hfs/hfs_mount.h b/bsd/hfs/hfs_mount.h
index 502926a42..38aac250e 100644
--- a/bsd/hfs/hfs_mount.h
+++ b/bsd/hfs/hfs_mount.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/hfs/hfs_quota.c b/bsd/hfs/hfs_quota.c
index 61b0b83cd..c486d3a1c 100644
--- a/bsd/hfs/hfs_quota.c
+++ b/bsd/hfs/hfs_quota.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -131,7 +134,7 @@ hfs_chkdq(cp, change, cred, flags)
 	register struct dquot *dq;
 	register int i;
 	int64_t ncurbytes;
-	int error;
+	int error=0;
 	struct proc *p;
 
 #if DIAGNOSTIC
@@ -161,25 +164,29 @@ hfs_chkdq(cp, change, cred, flags)
 	p = current_proc();
 	if (cred == NOCRED)
 		cred = kernproc->p_ucred;
-	if ((flags & FORCE) == 0 && ((cred->cr_uid != 0) || (p->p_flag & P_FORCEQUOTA))) {
+	if ((cred->cr_uid != 0) || (p->p_flag & P_FORCEQUOTA)) {
 		for (i = 0; i < MAXQUOTAS; i++) {
 			if ((dq = cp->c_dquot[i]) == NODQUOT)
 				continue;
-			if (error = hfs_chkdqchg(cp, change, cred, i))
-				return (error);
+			error = hfs_chkdqchg(cp, change, cred, i);
+			if (error) {
+				break;
+			}
 		}
 	}
-	for (i = 0; i < MAXQUOTAS; i++) {
-		if ((dq = cp->c_dquot[i]) == NODQUOT)
-			continue;
-		while (dq->dq_flags & DQ_LOCK) {
-			dq->dq_flags |= DQ_WANT;
-			sleep((caddr_t)dq, PINOD+1);
+	if ((flags & FORCE) || error == 0) {
+		for (i = 0; i < MAXQUOTAS; i++) {
+			if ((dq = cp->c_dquot[i]) == NODQUOT)
+				continue;
+			while (dq->dq_flags & DQ_LOCK) {
+				dq->dq_flags |= DQ_WANT;
+				sleep((caddr_t)dq, PINOD+1);
+			}
+			dq->dq_curbytes += change;
+			dq->dq_flags |= DQ_MOD;
 		}
-		dq->dq_curbytes += change;
-		dq->dq_flags |= DQ_MOD;
 	}
-	return (0);
+	return (error);
 }
 
 /*
@@ -203,7 +210,7 @@ hfs_chkdqchg(cp, change, cred, type)
 	if (ncurbytes >= dq->dq_bhardlimit && dq->dq_bhardlimit) {
 		if ((dq->dq_flags & DQ_BLKS) == 0 &&
 		    cp->c_uid == cred->cr_uid) {
-#if 1	
+#if 0	
 			printf("\n%s: write failed, %s disk limit reached\n",
 			    vp->v_mount->mnt_stat.f_mntonname,
 			    quotatypes[type]);
@@ -220,7 +227,7 @@ hfs_chkdqchg(cp, change, cred, type)
 		if (dq->dq_curbytes < dq->dq_bsoftlimit) {
 			dq->dq_btime = time.tv_sec +
 			    VFSTOHFS(vp->v_mount)->hfs_qfiles[type].qf_btime;
-#if 1
+#if 0
 			if (cp->c_uid == cred->cr_uid)
 				printf("\n%s: warning, %s %s\n",
 				    vp->v_mount->mnt_stat.f_mntonname,
@@ -231,7 +238,7 @@ hfs_chkdqchg(cp, change, cred, type)
 		if (time.tv_sec > dq->dq_btime) {
 			if ((dq->dq_flags & DQ_BLKS) == 0 &&
 			    cp->c_uid == cred->cr_uid) {
-#if 1
+#if 0
 				printf("\n%s: write failed, %s %s\n",
 				    vp->v_mount->mnt_stat.f_mntonname,
 				    quotatypes[type],
@@ -257,7 +264,7 @@ hfs_chkiq(cp, change, cred, flags)
 {
 	register struct dquot *dq;
 	register int i;
-	int ncurinodes, error;
+	int ncurinodes, error=0;
 	struct proc *p;
 
 #if DIAGNOSTIC
@@ -287,25 +294,29 @@ hfs_chkiq(cp, change, cred, flags)
 	p = current_proc();
 	if (cred == NOCRED)
 		cred = kernproc->p_ucred;
-	if ((flags & FORCE) == 0 && ((cred->cr_uid != 0) || (p->p_flag & P_FORCEQUOTA))) {
+	if ((cred->cr_uid != 0) || (p->p_flag & P_FORCEQUOTA)) {
 		for (i = 0; i < MAXQUOTAS; i++) {
 			if ((dq = cp->c_dquot[i]) == NODQUOT)
 				continue;
-			if (error = hfs_chkiqchg(cp, change, cred, i))
-				return (error);
+			error = hfs_chkiqchg(cp, change, cred, i);
+			if (error) {
+				break;
+			}
 		}
 	}
-	for (i = 0; i < MAXQUOTAS; i++) {
-		if ((dq = cp->c_dquot[i]) == NODQUOT)
-			continue;
-		while (dq->dq_flags & DQ_LOCK) {
-			dq->dq_flags |= DQ_WANT;
-			sleep((caddr_t)dq, PINOD+1);
+	if ((flags & FORCE) || error == 0) { 
+		for (i = 0; i < MAXQUOTAS; i++) {
+			if ((dq = cp->c_dquot[i]) == NODQUOT)
+				continue;
+			while (dq->dq_flags & DQ_LOCK) {
+				dq->dq_flags |= DQ_WANT;
+				sleep((caddr_t)dq, PINOD+1);
+			}
+			dq->dq_curinodes += change;
+			dq->dq_flags |= DQ_MOD;
 		}
-		dq->dq_curinodes += change;
-		dq->dq_flags |= DQ_MOD;
 	}
-	return (0);
+	return (error);
 }
 
 /*
@@ -329,7 +340,7 @@ hfs_chkiqchg(cp, change, cred, type)
 	if (ncurinodes >= dq->dq_ihardlimit && dq->dq_ihardlimit) {
 		if ((dq->dq_flags & DQ_INODS) == 0 &&
 		    cp->c_uid == cred->cr_uid) {
-#if 1
+#if 0
 			printf("\n%s: write failed, %s cnode limit reached\n",
 			    vp->v_mount->mnt_stat.f_mntonname,
 			    quotatypes[type]);
@@ -346,7 +357,7 @@ hfs_chkiqchg(cp, change, cred, type)
 		if (dq->dq_curinodes < dq->dq_isoftlimit) {
 			dq->dq_itime = time.tv_sec +
 			    VFSTOHFS(vp->v_mount)->hfs_qfiles[type].qf_itime;
-#if 1
+#if 0
 			if (cp->c_uid == cred->cr_uid)
 				printf("\n%s: warning, %s %s\n",
 				    vp->v_mount->mnt_stat.f_mntonname,
@@ -357,7 +368,7 @@ hfs_chkiqchg(cp, change, cred, type)
 		if (time.tv_sec > dq->dq_itime) {
 			if ((dq->dq_flags & DQ_INODS) == 0 &&
 			    cp->c_uid == cred->cr_uid) {
-#if 1
+#if 0
 				printf("\n%s: write failed, %s %s\n",
 				    vp->v_mount->mnt_stat.f_mntonname,
 				    quotatypes[type],
@@ -489,6 +500,12 @@ hfs_quotaoff(p, mp, type)
 	if ((qvp = hfsmp->hfs_qfiles[type].qf_vp) == NULLVP)
 		return (0);
 	hfsmp->hfs_qfiles[type].qf_qflags |= QTF_CLOSING;
+
+	/*
+	 * Sync out any orpaned dirty dquot entries.
+	 */
+	dqsync_orphans(&hfsmp->hfs_qfiles[type]);
+
 	/*
 	 * Search vnodes associated with this mount point,
 	 * deleting any references to quota file being closed.
@@ -673,6 +690,14 @@ hfs_qsync(mp)
 			break;
 	if (i == MAXQUOTAS)
 		return (0);
+
+	/*
+	 * Sync out any orpaned dirty dquot entries.
+	 */
+	for (i = 0; i < MAXQUOTAS; i++)
+		if (hfsmp->hfs_qfiles[i].qf_vp != NULLVP)
+			dqsync_orphans(&hfsmp->hfs_qfiles[i]);
+
 	/*
 	 * Search vnodes associated with this mount point,
 	 * synchronizing any modified dquot structures.
@@ -682,9 +707,11 @@ again:
 	for (vp = mp->mnt_vnodelist.lh_first; vp != NULL; vp = nextvp) {
 		if (vp->v_mount != mp)
 			goto again;
+
 		nextvp = vp->v_mntvnodes.le_next;
 		simple_lock(&vp->v_interlock);
 		simple_unlock(&mntvnode_slock);
+
 		error = vget(vp, LK_EXCLUSIVE | LK_NOWAIT | LK_INTERLOCK, p);
 		if (error) {
 			simple_lock(&mntvnode_slock);
@@ -692,6 +719,19 @@ again:
 				goto again;
 			continue;
 		}
+
+		// Make sure that this is really an hfs vnode.
+		//
+		if (   vp->v_mount != mp
+			|| vp->v_type == VNON
+			|| vp->v_tag != VT_HFS
+			|| VTOC(vp) == NULL) {
+			
+			vput(vp);
+			simple_lock(&mntvnode_slock);
+			goto again;
+		}
+
 		for (i = 0; i < MAXQUOTAS; i++) {
 			dq = VTOC(vp)->c_dquot[i];
 			if (dq != NODQUOT && (dq->dq_flags & DQ_MOD))
diff --git a/bsd/hfs/hfs_quota.h b/bsd/hfs/hfs_quota.h
index 2b4ded302..c3dac3283 100644
--- a/bsd/hfs/hfs_quota.h
+++ b/bsd/hfs/hfs_quota.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/hfs/hfs_readwrite.c b/bsd/hfs/hfs_readwrite.c
index 6f0311411..8bde675da 100644
--- a/bsd/hfs/hfs_readwrite.c
+++ b/bsd/hfs/hfs_readwrite.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -998,6 +1001,7 @@ hfs_cmap(ap)
 		return (0);
 
 	p = current_proc();
+  retry:
 	if (fp->ff_unallocblocks) {
 		lockExtBtree = 1;
 
@@ -1036,6 +1040,22 @@ hfs_cmap(ap)
 	if (fp->ff_unallocblocks) {
 		SInt64 reqbytes, actbytes;
 
+		//
+		// Make sure we have a transaction.  It's possible
+		// that we came in and fp->ff_unallocblocks was zero
+		// but during the time we blocked acquiring the extents
+		// btree, ff_unallocblocks became non-zero and so we
+		// will need to start a transaction.
+		//
+		if (hfsmp->jnl && started_tr == 0) {
+		    if (lockExtBtree) {
+			(void) hfs_metafilelocking(hfsmp, kHFSExtentsFileID, LK_RELEASE, p);
+			lockExtBtree = 0;
+		    }
+    
+		    goto retry;
+		}
+
 		reqbytes = (SInt64)fp->ff_unallocblocks *
 		             (SInt64)HFSTOVCB(hfsmp)->blockSize;
 		/*
diff --git a/bsd/hfs/hfs_search.c b/bsd/hfs/hfs_search.c
index 84aecbb01..589e04431 100644
--- a/bsd/hfs/hfs_search.c
+++ b/bsd/hfs/hfs_search.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  *
diff --git a/bsd/hfs/hfs_vfsops.c b/bsd/hfs/hfs_vfsops.c
index cff8a45ec..513f49ca6 100644
--- a/bsd/hfs/hfs_vfsops.c
+++ b/bsd/hfs/hfs_vfsops.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -1587,7 +1590,12 @@ loop:
 
 		// restart our whole search if this guy is locked
 		// or being reclaimed.
-		if (cp == NULL || vp->v_flag & (VXLOCK|VORECLAIM)) {
+		// XXXdbg - at some point this should go away or we
+		//          need to change all file systems to have
+		//          this same code.  vget() should never return
+		//          success if either of these conditions is
+		//          true.
+		if (vp->v_tag != VT_HFS || cp == NULL) {
 			simple_unlock(&vp->v_interlock);
 			continue;
 		}
@@ -1841,7 +1849,11 @@ hfs_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
 		struct cat_attr jnl_attr, jinfo_attr;
 		struct cat_fork jnl_fork, jinfo_fork;
 		void *jnl = NULL;
-		
+
+		/* Only root can enable journaling */
+        if (current_proc()->p_ucred->cr_uid != 0) {
+			return (EPERM);
+		}
 		hfsmp = VTOHFS(vp);
 		if (hfsmp->hfs_fs_ronly) {
 			return EROFS;
@@ -1923,6 +1935,10 @@ hfs_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
 		void *jnl;
 		int retval;
 		
+		/* Only root can disable journaling */
+        if (current_proc()->p_ucred->cr_uid != 0) {
+			return (EPERM);
+		}
 		hfsmp = VTOHFS(vp);
 		if (hfsmp->jnl == NULL) {
 			return EINVAL;
diff --git a/bsd/hfs/hfs_vfsutils.c b/bsd/hfs/hfs_vfsutils.c
index 386acae02..63aa2a90e 100644
--- a/bsd/hfs/hfs_vfsutils.c
+++ b/bsd/hfs/hfs_vfsutils.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -1261,6 +1264,39 @@ hfs_relnamehints(struct cnode *dcp)
 }
 
 
+/*
+ * Perform a case-insensitive compare of two UTF-8 filenames.
+ *
+ * Returns 0 if the strings match.
+ */
+__private_extern__
+int
+hfs_namecmp(const char *str1, size_t len1, const char *str2, size_t len2)
+{
+	u_int16_t *ustr1, *ustr2;
+	size_t ulen1, ulen2;
+	size_t maxbytes;
+	int cmp = -1;
+
+	if (len1 != len2)
+		return (cmp);
+
+	maxbytes = kHFSPlusMaxFileNameChars << 1;
+	MALLOC(ustr1, u_int16_t *, maxbytes << 1, M_TEMP, M_WAITOK);
+	ustr2 = ustr1 + (maxbytes >> 1);
+
+	if (utf8_decodestr(str1, len1, ustr1, &ulen1, maxbytes, ':', 0) != 0)
+		goto out;
+	if (utf8_decodestr(str2, len2, ustr2, &ulen2, maxbytes, ':', 0) != 0)
+		goto out;
+	
+	cmp = FastUnicodeCompare(ustr1, ulen1>>1, ustr2, ulen2>>1);
+out:
+	FREE(ustr1, M_TEMP);
+	return (cmp);
+}
+
+
 __private_extern__
 int
 hfs_early_journal_init(struct hfsmount *hfsmp, HFSPlusVolumeHeader *vhp,
diff --git a/bsd/hfs/hfs_vnops.c b/bsd/hfs/hfs_vnops.c
index 0080c1400..b53d8eb2f 100644
--- a/bsd/hfs/hfs_vnops.c
+++ b/bsd/hfs/hfs_vnops.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -58,6 +61,8 @@
 
 extern uid_t console_user;
 
+extern unsigned long strtoul(const char *, char **, int);
+
 /* Global vfs data structures for hfs */
 
 
@@ -1076,6 +1081,23 @@ hfs_exchange(ap)
 
 	hfs_chashinsert(from_cp);
 	hfs_chashinsert(to_cp);
+
+	/*
+	 * When a file moves out of "Cleanup At Startup"
+	 * we can drop its NODUMP status.
+	 */
+	if ((from_cp->c_flags & UF_NODUMP) &&
+	    (from_cp->c_parentcnid != to_cp->c_parentcnid)) {
+		from_cp->c_flags &= ~UF_NODUMP;
+		from_cp->c_flag |= C_CHANGE;
+	}
+
+	if ((to_cp->c_flags & UF_NODUMP) &&
+	    (to_cp->c_parentcnid != from_cp->c_parentcnid)) {
+		to_cp->c_flags &= ~UF_NODUMP;
+		to_cp->c_flag |= C_CHANGE;
+	}
+
 Err_Exit:
 	if (to_rvp)
 		vrele(to_rvp);
@@ -1155,8 +1177,11 @@ hfs_fsync(ap)
 	 * When MNT_WAIT is requested and the zero fill timeout
 	 * has expired then we must explicitly zero out any areas
 	 * that are currently marked invalid (holes).
+	 *
+	 * Files with NODUMP can bypass zero filling here.
 	 */
 	if ((wait || (cp->c_flag & C_ZFWANTSYNC)) &&
+	    ((cp->c_flags & UF_NODUMP) == 0) &&
 	    UBCINFOEXISTS(vp) && (fp = VTOF(vp)) &&
 	    cp->c_zftimeout != 0) {
 		int devblksize;
@@ -1437,6 +1462,10 @@ hfs_rmdir(ap)
 		return (EINVAL);	/* cannot remove "." */
 	}
 
+#if QUOTA
+	(void)hfs_getinoquota(cp);
+#endif
+
 	// XXXdbg
 	hfs_global_shared_lock_acquire(hfsmp);
 	grabbed_lock = 1;
@@ -1480,8 +1509,7 @@ hfs_rmdir(ap)
 	if (error) goto out;
 
 #if QUOTA
-	if (!hfs_getinoquota(cp))
-		(void)hfs_chkiq(cp, -1, NOCRED, 0);
+	(void)hfs_chkiq(cp, -1, NOCRED, 0);
 #endif /* QUOTA */
 
 	/* The parent lost a child */
@@ -1612,6 +1640,10 @@ hfs_remove(ap)
 		goto out;
 	}
 
+#if QUOTA
+	(void)hfs_getinoquota(cp);
+#endif /* QUOTA */
+
 	// XXXdbg
 	hfs_global_shared_lock_acquire(hfsmp);
 	grabbed_lock = 1;
@@ -1675,15 +1707,8 @@ hfs_remove(ap)
 			cp->c_mode = 0;            /* Suppress VOP_UPDATES */
 			error = VOP_TRUNCATE(rvp, (off_t)0, IO_NDELAY, NOCRED, p);
 			cp->c_mode = mode;
-			if (error && !dataforkbusy)
+			if (error)
 				goto out;
-			else {
-				/*
-				 * XXX could also force an update on vp
-				 * and fail the remove.
-				 */
-				error = 0;
-			}
 			truncated = 1;
 		}
 	}
@@ -1813,10 +1838,11 @@ hfs_remove(ap)
 
 	} else /* Not busy */ {
 
-		if (vp->v_type == VDIR && cp->c_entries > 0)
-			panic("hfs_remove: attempting to delete a non-empty directory!");
-		if (vp->v_type != VDIR && cp->c_blocks > 0)
-			panic("hfs_remove: attempting to delete a non-empty file!");
+		if (cp->c_blocks > 0) {
+			printf("hfs_remove: attempting to delete a non-empty file!");
+			error = EBUSY;
+			goto out;
+		}
 
 		/* Lock catalog b-tree */
 		error = hfs_metafilelocking(hfsmp, kHFSCatalogFileID, LK_EXCLUSIVE, p);
@@ -1825,7 +1851,7 @@ hfs_remove(ap)
 
 		error = cat_delete(hfsmp, &cp->c_desc, &cp->c_attr);
 
-		if (error && error != ENXIO && truncated) {
+		if (error && error != ENXIO && error != ENOENT && truncated) {
 			if ((cp->c_datafork && cp->c_datafork->ff_data.cf_size != 0) ||
 				(cp->c_rsrcfork && cp->c_rsrcfork->ff_data.cf_size != 0)) {
 				panic("hfs: remove: couldn't delete a truncated file! (%d, data sz %lld; rsrc sz %lld)",
@@ -1841,8 +1867,7 @@ hfs_remove(ap)
 		if (error) goto out;
 
 #if QUOTA
-		if (!hfs_getinoquota(cp))
-			(void)hfs_chkiq(cp, -1, NOCRED, 0);
+		(void)hfs_chkiq(cp, -1, NOCRED, 0);
 #endif /* QUOTA */
 
 		cp->c_mode = 0;
@@ -1870,6 +1895,14 @@ hfs_remove(ap)
 	tv = time;
 	(void) VOP_UPDATE(dvp, &tv, &tv, 0);
 
+	// XXXdbg
+	if (started_tr) {
+	    journal_end_transaction(hfsmp->jnl);
+	}
+	if (grabbed_lock) {
+		hfs_global_shared_lock_release(hfsmp);
+	}
+
 	if (rvp)
 		vrele(rvp);
 	VOP_UNLOCK(vp, 0, p);
@@ -1880,14 +1913,6 @@ hfs_remove(ap)
 	vrele(vp);
 	vput(dvp);
 
-	// XXXdbg
-	if (started_tr) {
-	    journal_end_transaction(hfsmp->jnl);
-	}
-	if (grabbed_lock) {
-		hfs_global_shared_lock_release(hfsmp);
-	}
-
 	return (0);
 
 out:
@@ -1960,6 +1985,9 @@ replace_desc(struct cnode *cp, struct cat_desc *cdp)
  *
  * When the target is a directory, hfs_rename must ensure
  * that it is empty.
+ *
+ * The rename system call is responsible for freeing
+ * the pathname buffers (ie no need to call VOP_ABORTOP).
  */
 
 static int
@@ -1979,50 +2007,52 @@ hfs_rename(ap)
 	struct vnode *fdvp = ap->a_fdvp;
 	struct componentname *tcnp = ap->a_tcnp;
 	struct componentname *fcnp = ap->a_fcnp;
+	struct proc *p = fcnp->cn_proc;
 	struct cnode *fcp = NULL;
 	struct cnode *fdcp = NULL;
-	struct cnode *tdcp = NULL;
-	struct cnode *tcp = NULL;
+	struct cnode *tdcp = VTOC(tdvp);
 	struct cat_desc from_desc;
 	struct cat_desc to_desc;
 	struct cat_desc out_desc;
 	struct hfsmount *hfsmp;
-	struct proc *p = fcnp->cn_proc;
 	struct timeval tv;
-	int retval = 0, started_tr = 0, grabbed_lock = 0;
-	int fdvp_locked = 0;
-	int fvp_locked = 0;
-	cnid_t oldparent = 0;
-	cnid_t newparent = 0;
+	int fdvp_locked, fvp_locked, tdvp_locked;
+	int tvp_deleted;
+	int started_tr = 0, grabbed_lock = 0;
+	int error = 0;
+
+	hfsmp = VTOHFS(tdvp);
+
+	/* Establish our vnode lock state. */
+	tdvp_locked = 1;
+	fdvp_locked = 0;
+	fvp_locked = 0;
+	tvp_deleted = 0;
 
-	// XXXdbg
-	if (fvp) 
-	    hfsmp = VTOHFS(fvp);
-	else if (tvp)
-	    hfsmp = VTOHFS(tvp);
-	else
-	    hfsmp = NULL;
-	
-#if HFS_DIAGNOSTIC
-    if ((tcnp->cn_flags & HASBUF) == 0 ||
-        (fcnp->cn_flags & HASBUF) == 0)
-        panic("hfs_rename: no name");
-#endif
 	/*
 	 * When fvp matches tvp they must be case variants
-	 * or hard links, and if they are in the same directory then
-	 * tvp really doesn't exist (see VFS rename).
-	 * XXX Hard link rename is still broken/ignored.  If they are
-	 * in different directories then we must have hard links.
-	 * Comments further down describe behaviour of hard links in same dir.
-	 * Note case insensitivity was and still is presumed.
+	 * or hard links.
+	 *
+	 * For the hardlink case there can be an extra ref on fvp.
 	 */
 	if (fvp == tvp) {
-		if (fdvp != tdvp) {
-			retval = 0;
-			goto abortop;
+		if (VOP_ISLOCKED(fvp) &&
+			(VTOC(fvp)->c_lock.lk_lockholder == p->p_pid) &&
+			(VTOC(fvp)->c_lock.lk_lockthread == current_thread())) {
+			fvp_locked = 1;
+			vrele(fvp);  /* drop the extra ref */
 		}
 		tvp = NULL;
+		/*
+		 * If this a hard link and its not a case
+		 * variant then keep tvp around for removal.
+		 */
+		if ((VTOC(fvp)->c_flag & C_HARDLINK) &&
+		    ((fdvp != tdvp) ||
+		     (hfs_namecmp(fcnp->cn_nameptr, fcnp->cn_namelen,
+		                  tcnp->cn_nameptr, tcnp->cn_namelen) != 0))) {
+			tvp = fvp;
+		}
 	}
         
 	/*
@@ -2030,194 +2060,200 @@ hfs_rename(ap)
 	 */
 	if ((fvp->v_mount != tdvp->v_mount) ||
 	    (tvp && (fvp->v_mount != tvp->v_mount))) {
-		retval = EXDEV;
-		goto abortop;
+		error = EXDEV;
+		goto out;
 	}
 
 	/*
-	 * Make sure a remove of "to" vnode is permitted.
+	 * Make sure "from" vnode and its parent are changeable.
 	 */
-	if (tvp && ((VTOC(tvp)->c_flags & (IMMUTABLE | APPEND)) ||
-	    (VTOC(tdvp)->c_flags & APPEND))) {
-		retval = EPERM;
-		goto abortop;
+	if ((VTOC(fvp)->c_flags & (IMMUTABLE | APPEND)) ||
+	    (VTOC(fdvp)->c_flags & APPEND)) {
+		error = EPERM;
+		goto out;
 	}
 
 	/*
-	 * Make sure "from" vnode and its parent are changeable.
+	 * Be sure we are not renaming ".", "..", or an alias of ".".
 	 */
-	fdcp = VTOC(fdvp);
-	fcp = VTOC(fvp);
-	oldparent = fdcp->c_cnid;
-	if ((fcp->c_flags & (IMMUTABLE | APPEND)) || (fdcp->c_flags & APPEND)) {
-		retval = EPERM;
-		goto abortop;
-	}
-
-	if (fcp->c_parentcnid != fdcp->c_cnid) {
-		retval = EINVAL;
-		goto abortop;
+	if ((fvp->v_type == VDIR) &&
+	    (((fcnp->cn_namelen == 1) && (fcnp->cn_nameptr[0] == '.')) ||
+	      (fdvp == fvp) ||
+	      (fcnp->cn_flags&ISDOTDOT))) {
+			error = EINVAL;
+			goto out;
 	}
 
 	/*
-	 * Check if names already match...
-	 * XXX The name being checked is from fcp rather than fcnp!  If
-	 * there are hard links, fcp yields the name which was
-	 * most recently looked up (yes that design is vulnerable to races)
-	 * and the name most recently looked up was the target, so they
-	 * compare equal and we ignore the rename.  XXX
+	 * If the destination parent directory is "sticky", then the
+	 * user must own the parent directory, or the destination of
+	 * the rename, otherwise the destination may not be changed
+	 * (except by root). This implements append-only directories.
+	 *
+	 * Note that checks for immutable, write access, and a non-empty
+	 * target are done by the call to VOP_REMOVE.
 	 */
-	if (fvp == ap->a_tvp &&
-	    (bcmp(fcp->c_desc.cd_nameptr, tcnp->cn_nameptr,
-	     fcp->c_desc.cd_namelen) == 0)) {
-		retval = 0;
-		goto abortop;
+	if (tvp && (tdcp->c_mode & S_ISTXT) &&
+	    (tcnp->cn_cred->cr_uid != 0) &&
+	    (tcnp->cn_cred->cr_uid != tdcp->c_uid) &&
+	    (hfs_owner_rights(hfsmp, VTOC(tvp)->c_uid, tcnp->cn_cred, p, false)) ) {
+			error = EPERM;
+			goto out;
 	}
 
-	/* XXX This doesn't make sense for HFS...
+	/*
+	 * All done with preflighting.
+	 *
+	 * We now break the call into two transactions:
+	 * 1 - Remove the destionation (if any) using VOP_REMOVE,
+	 * which in itself is a complete transaction.
+	 *
+	 * 2 - Rename source to destination.
 	 * 
-	 * Be sure we are not renaming ".", "..", or an alias of ".". This
-	 * leads to a crippled directory tree.	It's pretty tough to do a
-	 * "ls" or "pwd" with the "." directory entry missing, and "cd .."
-	 * doesn't work if the ".." entry is missing.
+	 * Since all the preflighting is done, we assume that a
+	 * rename failure is unlikely once part 1 is complete.
+	 * Breaking rename into two transactions buys us a much
+	 * simpler implementation with respect to the locking
+	 * protocol.  There are only 3 vnodes to worry about
+	 * locking in the correct order (instead of 4).
 	 */
-	if (fvp->v_type == VDIR) {
-		if ((fcnp->cn_namelen == 1 && fcnp->cn_nameptr[0] == '.')
-			|| fdcp == fcp
-			|| (fcnp->cn_flags&ISDOTDOT)
-			|| (fcp->c_flag & C_RENAME)) {
-			retval = EINVAL;
-			goto abortop;
-		}
-		fcp->c_flag |= C_RENAME;
-	}
 
-	/* XXX UFS does vrele(fdvp) here */
+	/*
+	 * Part 1 - If the destination exists then it needs to be removed.
+	 */
+	if (tvp) {
+		/*
+		 * VOP_REMOVE will vput tdvp so we better bump its
+		 * ref count and relockit, always set tvp to NULL
+		 * afterwards to indicate that we're done with it.
+		 */
+		VREF(tdvp);
 
-	/* From now on use bad instead of abort to exit */
+		if (tvp == fvp) {
+			if (fvp_locked) {
+				VREF(fvp);
+			} else {
+				error = vget(fvp, LK_EXCLUSIVE | LK_RETRY, p);
+				if (error)
+					goto out;
+				fvp_locked = 1;
+			}
+		} else {
+			cache_purge(tvp);
+		}
 
-	tdcp = VTOC(tdvp);
-	if (tvp)
-		tcp = VTOC(tvp);
+		/* Clear SAVENAME to keep VOP_REMOVE from smashing tcnp. */
+		tcnp->cn_flags &= ~SAVENAME;
 
-	newparent = tdcp->c_cnid;
-	
-	// XXXdbg - don't allow renaming the journal or journal_info_block
-	if (hfsmp->jnl && fcp->c_datafork) {
-		struct HFSPlusExtentDescriptor *extd;
-			
-		extd = &fcp->c_datafork->ff_data.cf_extents[0];
-		if (extd->startBlock == HFSTOVCB(hfsmp)->vcbJinfoBlock || extd->startBlock == hfsmp->jnl_start) {
-			retval = EPERM;
-			goto bad;
-		}
-	}
+		if (tvp->v_type == VDIR)
+			error = VOP_RMDIR(tdvp, tvp, tcnp);
+		else
+			error = VOP_REMOVE(tdvp, tvp, tcnp);
 
-	if (hfsmp->jnl && tcp && tcp->c_datafork) {
-		struct HFSPlusExtentDescriptor *extd;
-			
-		extd = &tcp->c_datafork->ff_data.cf_extents[0];
-		if (extd->startBlock == HFSTOVCB(hfsmp)->vcbJinfoBlock || extd->startBlock == hfsmp->jnl_start) {
-			retval = EPERM;
-			goto bad;
-		}
-	}
+		/* Get lock states back in sync. */
+		tdvp_locked = 0;
+		if (tvp == fvp)
+			fvp_locked = 0;	
+		tvp = NULL;	/* all done with tvp */
+		tvp_deleted = 1;
 
-	retval = VOP_ACCESS(fvp, VWRITE, tcnp->cn_cred, tcnp->cn_proc);
-	if ((fvp->v_type == VDIR) && (newparent != oldparent)) {
-		if (retval)		/* write access check above */
-			goto bad;
+		if (error)
+			goto out;  /* couldn't remove destination! */
 	}
-	retval = 0;  /* Reset value from above, we dont care about it anymore */
-	
-	/* XXX
-	 * Prevent lock heirarchy violation (deadlock):
-	 *
-	 * If fdvp is the parent of tdvp then we must drop
-	 * tdvp lock before aquiring the lock for fdvp.
+	/*
+	 * All done with tvp.
 	 *
-	 * XXXdbg - moved this to happen up here *before* we
-	 *          start a transaction.  otherwise we can
-	 *          deadlock because the vnode layer may get
-	 *          this lock for someone else and then they'll
-	 *          never be able to start a transaction.
+	 * For POSIX compliance, if tvp was removed the only 
+	 * error we can return from this point on is EIO.
+	 */  
+
+	/*
+	 * Part 2 - rename source to destination
 	 */
-	if (newparent != oldparent) {
-	    if (fdcp->c_cnid == tdcp->c_parentcnid) {
-			vput(tdvp);
-			vn_lock(fdvp, LK_EXCLUSIVE | LK_RETRY, p);
-			vget(tdvp, LK_EXCLUSIVE | LK_RETRY, p);
-	    } else {
-			vn_lock(fdvp, LK_EXCLUSIVE | LK_RETRY, p);
-		}
-	}
-	fdvp_locked = 1;
-	if ((retval = vn_lock(fvp, LK_EXCLUSIVE | LK_RETRY, p)))
-		goto bad;
-	fvp_locked = 1;
-	
-	// XXXdbg
-	hfs_global_shared_lock_acquire(hfsmp);
-	grabbed_lock = 1;
-	if (hfsmp->jnl) {
-	    if ((retval = journal_start_transaction(hfsmp->jnl)) != 0) {
-			goto bad;
-	    }
-		started_tr = 1;
-	}
 
 	/*
-	 * If the destination exists, then be sure its type (file or dir)
-	 * matches that of the source.	And, if it is a directory make sure
-	 * it is empty.	 Then delete the destination.
+	 * Lock the vnodes before starting a journal transaction.
 	 */
-	if (tvp) {
+	if (fdvp != tdvp) {
 		/*
-		 * If the parent directory is "sticky", then the user must
-		 * own the parent directory, or the destination of the rename,
-		 * otherwise the destination may not be changed (except by
-		 * root). This implements append-only directories.
+		 * fvp is a child and must be locked last.
 		 */
-		if ((tdcp->c_mode & S_ISTXT) && (tcnp->cn_cred->cr_uid != 0) &&
-		    tcnp->cn_cred->cr_uid != tdcp->c_uid &&
-		    tcnp->cn_cred->cr_uid != tcp->c_uid) {
-			retval = EPERM;
-			goto bad;
+		if (fvp_locked) {
+			VOP_UNLOCK(fvp, 0, p);
+			fvp_locked = 0;
 		}
-
 		/*
-		 * Target must be empty if a directory.
+		 *	If fdvp is the parent of tdvp then it needs to be locked first.
 		 */
-		if (S_ISDIR(tcp->c_mode) && (tcp->c_nlink > 2)) {
-				retval = ENOTEMPTY;
-				goto bad;
-		}
+		if ((VTOC(fdvp)->c_cnid == VTOC(tdvp)->c_parentcnid)) {
+			if (tdvp_locked) {
+				VOP_UNLOCK(tdvp, 0, p);
+				tdvp_locked = 0;
+			}
+			if ((error = vn_lock(fdvp, LK_EXCLUSIVE | LK_RETRY, p)))
+				goto out;
+			fdvp_locked = 1;
+			if ((error = vn_lock(tdvp, LK_EXCLUSIVE | LK_RETRY, p)))
+				goto out;
+			tdvp_locked = 1;
 
-		/*
-		 * VOP_REMOVE will vput tdvp so we better bump 
-		 * its ref count and relockit, always set tvp to
-		 * NULL afterwards to indicate that were done with it.
-		 */
-		VREF(tdvp);
+		} else /* Lock tdvp then fdvp */ {
+			if (!tdvp_locked) {
+				if ((error = vn_lock(tdvp, LK_EXCLUSIVE | LK_RETRY, p)))
+					goto out;
+				tdvp_locked = 1;
+			}
+			if ((error = vn_lock(fdvp, LK_EXCLUSIVE | LK_RETRY, p)))
+				goto out;
+			fdvp_locked = 1;
+		}
+	} else if (!tdvp_locked) {
+			/*
+			 * fvp is a child and must be locked last.
+			 */
+			if (fvp_locked) {
+				VOP_UNLOCK(fvp, 0, p);
+				fvp_locked = 0;
+			}
+			if ((error = vn_lock(tdvp, LK_EXCLUSIVE | LK_RETRY, p)))
+				goto out;
+			tdvp_locked = 1;
+	}
 
-		cache_purge(tvp);
-            
-		tcnp->cn_flags &= ~SAVENAME;
+	/* Now its safe to lock fvp */
+	if (!fvp_locked) {
+		if (error = vn_lock(fvp, LK_EXCLUSIVE | LK_RETRY, p))
+			goto out;
+		fvp_locked = 1;
+	}
 
-		if (tvp->v_type == VDIR)
-			retval = VOP_RMDIR(tdvp, tvp, tcnp);
-		else
-			retval = VOP_REMOVE(tdvp, tvp, tcnp);
+	fdcp = VTOC(fdvp);
+	fcp = VTOC(fvp);
 
-		(void) vn_lock(tdvp, LK_EXCLUSIVE | LK_RETRY, p);
-		tvp = NULL;
-		tcp = NULL;		
-		if (retval)
-			goto bad;
+	/*
+	 * When a file moves out of "Cleanup At Startup"
+	 * we can drop its NODUMP status.
+	 */
+	if ((fcp->c_flags & UF_NODUMP) &&
+	    (fvp->v_type == VREG) &&
+	    (fdvp != tdvp) &&
+	    (fdcp->c_desc.cd_nameptr != NULL) &&
+	    (strcmp(fdcp->c_desc.cd_nameptr, "Cleanup At Startup") == 0)) {
+		fcp->c_flags &= ~UF_NODUMP;
+		fcp->c_flag |= C_CHANGE;
+		tv = time;
+		(void) VOP_UPDATE(fvp, &tv, &tv, 0);
+	}
 
+	hfs_global_shared_lock_acquire(hfsmp);
+	grabbed_lock = 1;
+	if (hfsmp->jnl) {
+	    if ((error = journal_start_transaction(hfsmp->jnl)) != 0) {
+			goto out;
+	    }
+		started_tr = 1;
 	}
 
-	/* remove the existing entry from the namei cache: */
 	cache_purge(fvp);
 
 	bzero(&from_desc, sizeof(from_desc));
@@ -2226,6 +2262,7 @@ hfs_rename(ap)
 	from_desc.cd_parentcnid = fdcp->c_cnid;
 	from_desc.cd_flags = fcp->c_desc.cd_flags & ~(CD_HASBUF | CD_DECOMPOSED);
 	from_desc.cd_cnid = fcp->c_cnid;
+
 	bzero(&to_desc, sizeof(to_desc));
 	to_desc.cd_nameptr = tcnp->cn_nameptr;
 	to_desc.cd_namelen = tcnp->cn_namelen;
@@ -2234,63 +2271,47 @@ hfs_rename(ap)
 	to_desc.cd_cnid = fcp->c_cnid;
 
 	/* Lock catalog b-tree */
-	retval = hfs_metafilelocking(hfsmp, kHFSCatalogFileID, LK_EXCLUSIVE, p);
-	if (retval) {
-		 goto bad;
- 	}
-	retval = cat_rename(hfsmp, &from_desc, &tdcp->c_desc,
-						&to_desc, &out_desc);
+	error = hfs_metafilelocking(hfsmp, kHFSCatalogFileID, LK_EXCLUSIVE, p);
+	if (error)
+		 goto out;
+
+	error = cat_rename(hfsmp, &from_desc, &tdcp->c_desc, &to_desc, &out_desc);
 
 	/* Unlock catalog b-tree */
 	(void) hfs_metafilelocking(hfsmp, kHFSCatalogFileID, LK_RELEASE, p);
+	if (error)
+		goto out;
 
-	if (newparent != oldparent) {
-		VOP_UNLOCK(fdvp, 0, p);
-		fdvp_locked = 0;
-	}
-
-	if (retval)  goto bad;
-
-	/* update cnode's catalog descriptor */
+	/* Update cnode's catalog descriptor */
    	replace_desc(fcp, &out_desc);
 
-	fcp->c_flag &= ~C_RENAME;
+	hfs_volupdate(hfsmp, fvp->v_type == VDIR ? VOL_RMDIR : VOL_RMFILE,
+	              (fdcp->c_cnid == kHFSRootFolderID));
+	hfs_volupdate(hfsmp, fvp->v_type == VDIR ? VOL_MKDIR : VOL_MKFILE,
+	              (tdcp->c_cnid == kHFSRootFolderID));
+
+	VOP_UNLOCK(fvp, 0, p);
+	fcp = NULL;
+	fvp_locked = 0;
+	/* All done with fvp. */  
 
-	/*
-	 * Time stamp both parent directories.
-	 * Note that if this is a rename within the same directory,
-	 * (where tdcp == fdcp)
-	 * the code below is still safe and correct.
-	 */
-	if (fdcp->c_nlink > 0)
-		fdcp->c_nlink--;
-	if (fdcp->c_entries > 0)
-		fdcp->c_entries--;
-	tdcp->c_nlink++;
-	tdcp->c_entries++;
-	fdcp->c_flag |= C_CHANGE | C_UPDATE;
-	tdcp->c_flag |= C_CHANGE | C_UPDATE;
+	/* Update both parent directories. */
 	tv = time;
-	CTIMES(fdcp, &tv, &tv);
-	CTIMES(tdcp, &tv, &tv);
-	tdcp->c_childhint = out_desc.cd_hint;	/* Cache directory's location */
-
-	// make sure both directories get updated on disk.
 	if (fdvp != tdvp) {
+		tdcp->c_nlink++;
+		tdcp->c_entries++;
+		if (fdcp->c_nlink > 0)
+			fdcp->c_nlink--;
+		if (fdcp->c_entries > 0)
+			fdcp->c_entries--;
+		fdcp->c_flag |= C_CHANGE | C_UPDATE;
 		(void) VOP_UPDATE(fdvp, &tv, &tv, 0);
 	}
+	tdcp->c_childhint = out_desc.cd_hint;	/* Cache directory's location */
+	tdcp->c_flag |= C_CHANGE | C_UPDATE;
 	(void) VOP_UPDATE(tdvp, &tv, &tv, 0);
 
-	hfs_volupdate(hfsmp, fvp->v_type == VDIR ? VOL_RMDIR : VOL_RMFILE,
-		(fdcp->c_cnid == kHFSRootFolderID));
-	hfs_volupdate(hfsmp, fvp->v_type == VDIR ? VOL_MKDIR : VOL_MKFILE,
-		(tdcp->c_cnid == kHFSRootFolderID));
-
-	vput(tdvp);
-	vrele(fdvp);
-	vput(fvp);
-
-	// XXXdbg
+out:
 	if (started_tr) {
 	    journal_end_transaction(hfsmp->jnl);
 	}
@@ -2298,59 +2319,30 @@ hfs_rename(ap)
 		hfs_global_shared_lock_release(hfsmp);
 	}
 
-	return (0);
-
-bad:
-	if (fcp)
-		fcp->c_flag &= ~C_RENAME;
-
-	// XXXdbg make sure both directories get updated on disk.
-	if (fdvp != tdvp) {
-		(void) VOP_UPDATE(fdvp, &tv, &tv, 0);
+	if (fvp_locked) {
+		VOP_UNLOCK(fvp, 0, p);
 	}
-	(void) VOP_UPDATE(tdvp, &tv, &tv, 0);
-
-	if (tdvp == tvp)
-		vrele(tdvp);
-	else
-		vput(tdvp);
-	if (tvp)
-		vput(tvp);
-
-	if (fdvp_locked)
-		vput(fdvp);
-	else
-		vrele(fdvp);
-
-	if (fvp_locked)
-		vput(fvp);
-	else
-		vrele(fvp);
-
-	// XXXdbg
-	if (started_tr) {
-	    journal_end_transaction(hfsmp->jnl);
+	if (fdvp_locked) {
+		VOP_UNLOCK(fdvp, 0, p);
 	}
-	if (grabbed_lock) {
-		hfs_global_shared_lock_release(hfsmp);
+	if (tdvp_locked) {
+		VOP_UNLOCK(tdvp, 0, p);
+	}
+	if (tvp && (tvp != fvp)) {
+		if (tvp != tdvp)
+			VOP_UNLOCK(tvp, 0, p);
+		vrele(tvp);
 	}
 
-	return (retval);
-
-abortop:
-
-	VOP_ABORTOP(tdvp, tcnp);
-	if (tdvp == tvp)
-		vrele(tdvp);
-	else
-		vput(tdvp);
-	if (tvp)
-		vput(tvp);
-	VOP_ABORTOP(fdvp, fcnp);
-	vrele(fdvp);
 	vrele(fvp);
+	vrele(fdvp);
+	vrele(tdvp);
 
-	return (retval);
+	/* After tvp is removed the only acceptable error is EIO */
+	if ((error == ENOSPC) && tvp_deleted)
+		error = EIO;
+
+	return (error);
 }
 
 
@@ -2451,14 +2443,17 @@ hfs_symlink(ap)
 	fp = VTOF(vp);
 	fp->ff_clumpsize = VTOVCB(vp)->blockSize;
 
+#if QUOTA
+	(void)hfs_getinoquota(VTOC(vp));
+#endif /* QUOTA */
+
 	// XXXdbg
 	hfs_global_shared_lock_acquire(hfsmp);
 	if (hfsmp->jnl) {
 	    if ((error = journal_start_transaction(hfsmp->jnl)) != 0) {
 			hfs_global_shared_lock_release(hfsmp);
-			VOP_ABORTOP(ap->a_dvp, ap->a_cnp);
-			vput(ap->a_dvp);
-			return (error);
+			vput(vp);
+			return error;
 	    }
 	}
 
@@ -2791,8 +2786,10 @@ hfs_abortop(ap)
 		struct componentname *a_cnp;
 	} */ *ap;
 {
-	if ((ap->a_cnp->cn_flags & (HASBUF | SAVESTART)) == HASBUF)
+	if ((ap->a_cnp->cn_flags & (HASBUF | SAVESTART)) == HASBUF) {
 		FREE_ZONE(ap->a_cnp->cn_pnbuf, ap->a_cnp->cn_pnlen, M_NAMEI);
+		ap->a_cnp->cn_flags &= ~HASBUF;
+	}
 
 	return (0);
 }
@@ -3403,6 +3400,7 @@ hfs_makenode(mode, dvp, vpp, cnp)
 	    (error = hfs_chkiq(cp, 1, cnp->cn_cred, FORCE))) {
 		if ((cnp->cn_flags & (HASBUF | SAVESTART)) == HASBUF) {
 			FREE_ZONE(cnp->cn_pnbuf, cnp->cn_pnlen, M_NAMEI);
+			cnp->cn_flags &= ~HASBUF;
 		}
 		if (tvp->v_type == VDIR)
 			VOP_RMDIR(dvp,tvp, cnp);
@@ -3436,7 +3434,38 @@ exit:
 
 	if ((cnp->cn_flags & (HASBUF | SAVESTART)) == HASBUF)
         	FREE_ZONE(cnp->cn_pnbuf, cnp->cn_pnlen, M_NAMEI);
-	vput(dvp);
+
+	/*
+	 * Check if a file is located in the "Cleanup At Startup"
+	 * directory.  If it is then tag it as NODUMP so that we
+	 * can be lazy about zero filling data holes.
+	 */
+	if ((error == 0) && (vnodetype == VREG) &&
+	    (dcp->c_desc.cd_nameptr != NULL) &&
+	    (strcmp(dcp->c_desc.cd_nameptr, "Cleanup At Startup") == 0)) {
+	   	struct vnode *ddvp;
+		cnid_t parid;
+
+		parid = dcp->c_parentcnid;
+		vput(dvp);
+		dvp = NULL;
+
+		/*
+		 * The parent of "Cleanup At Startup" should
+		 * have the ASCII name of the userid.
+		 */
+		if (VFS_VGET(HFSTOVFS(hfsmp), &parid, &ddvp) == 0) {
+			if (VTOC(ddvp)->c_desc.cd_nameptr &&
+			    (cp->c_uid == strtoul(VTOC(ddvp)->c_desc.cd_nameptr, 0, 0))) {
+				cp->c_flags |= UF_NODUMP;
+				cp->c_flag |= C_CHANGE;
+			}
+			vput(ddvp);
+		}
+	}
+
+	if (dvp)
+		vput(dvp);
 
 	// XXXdbg
 	if (started_tr) {
diff --git a/bsd/hfs/hfscommon/BTree/BTree.c b/bsd/hfs/hfscommon/BTree/BTree.c
index 65c12839f..0061a3900 100644
--- a/bsd/hfs/hfscommon/BTree/BTree.c
+++ b/bsd/hfs/hfscommon/BTree/BTree.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/hfs/hfscommon/BTree/BTreeAllocate.c b/bsd/hfs/hfscommon/BTree/BTreeAllocate.c
index a902d5087..557cd19cf 100644
--- a/bsd/hfs/hfscommon/BTree/BTreeAllocate.c
+++ b/bsd/hfs/hfscommon/BTree/BTreeAllocate.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/hfs/hfscommon/BTree/BTreeMiscOps.c b/bsd/hfs/hfscommon/BTree/BTreeMiscOps.c
index 7d56bf4f8..bd4282a12 100644
--- a/bsd/hfs/hfscommon/BTree/BTreeMiscOps.c
+++ b/bsd/hfs/hfscommon/BTree/BTreeMiscOps.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/hfs/hfscommon/BTree/BTreeNodeOps.c b/bsd/hfs/hfscommon/BTree/BTreeNodeOps.c
index fe9b141df..e8d8f091e 100644
--- a/bsd/hfs/hfscommon/BTree/BTreeNodeOps.c
+++ b/bsd/hfs/hfscommon/BTree/BTreeNodeOps.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/hfs/hfscommon/BTree/BTreeScanner.c b/bsd/hfs/hfscommon/BTree/BTreeScanner.c
index 8cc50aaa1..a406754bf 100644
--- a/bsd/hfs/hfscommon/BTree/BTreeScanner.c
+++ b/bsd/hfs/hfscommon/BTree/BTreeScanner.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  *
diff --git a/bsd/hfs/hfscommon/BTree/BTreeTreeOps.c b/bsd/hfs/hfscommon/BTree/BTreeTreeOps.c
index 3a8463911..5268c653c 100644
--- a/bsd/hfs/hfscommon/BTree/BTreeTreeOps.c
+++ b/bsd/hfs/hfscommon/BTree/BTreeTreeOps.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/hfs/hfscommon/Catalog/Catalog.c b/bsd/hfs/hfscommon/Catalog/Catalog.c
index e7134028f..17c35c795 100644
--- a/bsd/hfs/hfscommon/Catalog/Catalog.c
+++ b/bsd/hfs/hfscommon/Catalog/Catalog.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/hfs/hfscommon/Catalog/CatalogIterators.c b/bsd/hfs/hfscommon/Catalog/CatalogIterators.c
index 56751bc4b..c3a385c90 100644
--- a/bsd/hfs/hfscommon/Catalog/CatalogIterators.c
+++ b/bsd/hfs/hfscommon/Catalog/CatalogIterators.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/hfs/hfscommon/Catalog/CatalogUtilities.c b/bsd/hfs/hfscommon/Catalog/CatalogUtilities.c
index d1a43afb8..85cdddbf8 100644
--- a/bsd/hfs/hfscommon/Catalog/CatalogUtilities.c
+++ b/bsd/hfs/hfscommon/Catalog/CatalogUtilities.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/hfs/hfscommon/Catalog/FileIDsServices.c b/bsd/hfs/hfscommon/Catalog/FileIDsServices.c
index 44e5996a0..2481b7463 100644
--- a/bsd/hfs/hfscommon/Catalog/FileIDsServices.c
+++ b/bsd/hfs/hfscommon/Catalog/FileIDsServices.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/hfs/hfscommon/Misc/BTreeWrapper.c b/bsd/hfs/hfscommon/Misc/BTreeWrapper.c
index 767e54bec..bb2a1b5ff 100644
--- a/bsd/hfs/hfscommon/Misc/BTreeWrapper.c
+++ b/bsd/hfs/hfscommon/Misc/BTreeWrapper.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/hfs/hfscommon/Misc/FileExtentMapping.c b/bsd/hfs/hfscommon/Misc/FileExtentMapping.c
index 6831d79c0..7a38d6d71 100644
--- a/bsd/hfs/hfscommon/Misc/FileExtentMapping.c
+++ b/bsd/hfs/hfscommon/Misc/FileExtentMapping.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/hfs/hfscommon/Misc/VolumeAllocation.c b/bsd/hfs/hfscommon/Misc/VolumeAllocation.c
index 4fe649921..8908358e5 100644
--- a/bsd/hfs/hfscommon/Misc/VolumeAllocation.c
+++ b/bsd/hfs/hfscommon/Misc/VolumeAllocation.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/hfs/hfscommon/Unicode/UCStringCompareData.h b/bsd/hfs/hfscommon/Unicode/UCStringCompareData.h
index b975465d3..71aa61c3e 100644
--- a/bsd/hfs/hfscommon/Unicode/UCStringCompareData.h
+++ b/bsd/hfs/hfscommon/Unicode/UCStringCompareData.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/hfs/hfscommon/Unicode/UnicodeWrappers.c b/bsd/hfs/hfscommon/Unicode/UnicodeWrappers.c
index 1e02d0932..efd8b8a4c 100644
--- a/bsd/hfs/hfscommon/Unicode/UnicodeWrappers.c
+++ b/bsd/hfs/hfscommon/Unicode/UnicodeWrappers.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/hfs/hfscommon/headers/BTreeScanner.h b/bsd/hfs/hfscommon/headers/BTreeScanner.h
index ce9cf3002..7bcec7273 100644
--- a/bsd/hfs/hfscommon/headers/BTreeScanner.h
+++ b/bsd/hfs/hfscommon/headers/BTreeScanner.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  *
diff --git a/bsd/hfs/hfscommon/headers/BTreesInternal.h b/bsd/hfs/hfscommon/headers/BTreesInternal.h
index 4ae9e7ad3..1657de34d 100644
--- a/bsd/hfs/hfscommon/headers/BTreesInternal.h
+++ b/bsd/hfs/hfscommon/headers/BTreesInternal.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/hfs/hfscommon/headers/BTreesPrivate.h b/bsd/hfs/hfscommon/headers/BTreesPrivate.h
index 805c86346..d9beee4ac 100644
--- a/bsd/hfs/hfscommon/headers/BTreesPrivate.h
+++ b/bsd/hfs/hfscommon/headers/BTreesPrivate.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/hfs/hfscommon/headers/CatalogPrivate.h b/bsd/hfs/hfscommon/headers/CatalogPrivate.h
index 4fce1168a..9c51d65f1 100644
--- a/bsd/hfs/hfscommon/headers/CatalogPrivate.h
+++ b/bsd/hfs/hfscommon/headers/CatalogPrivate.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/hfs/hfscommon/headers/FileMgrInternal.h b/bsd/hfs/hfscommon/headers/FileMgrInternal.h
index 519cd4965..2ed9ad24f 100644
--- a/bsd/hfs/hfscommon/headers/FileMgrInternal.h
+++ b/bsd/hfs/hfscommon/headers/FileMgrInternal.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/hfs/hfscommon/headers/HFSUnicodeWrappers.h b/bsd/hfs/hfscommon/headers/HFSUnicodeWrappers.h
index 56a7e4bdd..3d986f9a2 100644
--- a/bsd/hfs/hfscommon/headers/HFSUnicodeWrappers.h
+++ b/bsd/hfs/hfscommon/headers/HFSUnicodeWrappers.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/hfs/rangelist.c b/bsd/hfs/rangelist.c
index cc062004f..fb5072a42 100644
--- a/bsd/hfs/rangelist.c
+++ b/bsd/hfs/rangelist.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/hfs/rangelist.h b/bsd/hfs/rangelist.h
index 86b4c0c06..8b55318c4 100644
--- a/bsd/hfs/rangelist.h
+++ b/bsd/hfs/rangelist.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/i386/cpu.h b/bsd/i386/cpu.h
index fbace41fc..f7eabe824 100644
--- a/bsd/i386/cpu.h
+++ b/bsd/i386/cpu.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/i386/disklabel.h b/bsd/i386/disklabel.h
index 97cab07c3..38a2c3856 100644
--- a/bsd/i386/disklabel.h
+++ b/bsd/i386/disklabel.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/i386/endian.h b/bsd/i386/endian.h
index 2d9a1d3a1..f512aa169 100644
--- a/bsd/i386/endian.h
+++ b/bsd/i386/endian.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/i386/exec.h b/bsd/i386/exec.h
index 237ecd5fc..6e20fd83f 100644
--- a/bsd/i386/exec.h
+++ b/bsd/i386/exec.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/i386/label_t.h b/bsd/i386/label_t.h
index f47065aff..45d567a35 100644
--- a/bsd/i386/label_t.h
+++ b/bsd/i386/label_t.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/i386/param.h b/bsd/i386/param.h
index f5e43d3f6..084e9f30f 100644
--- a/bsd/i386/param.h
+++ b/bsd/i386/param.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/i386/profile.h b/bsd/i386/profile.h
index c3dd8dea3..e7711c564 100644
--- a/bsd/i386/profile.h
+++ b/bsd/i386/profile.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/i386/psl.h b/bsd/i386/psl.h
index bea431e18..52db82da7 100644
--- a/bsd/i386/psl.h
+++ b/bsd/i386/psl.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/i386/ptrace.h b/bsd/i386/ptrace.h
index 32cbfbbb4..f63ccbd6e 100644
--- a/bsd/i386/ptrace.h
+++ b/bsd/i386/ptrace.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/i386/reboot.h b/bsd/i386/reboot.h
index dad563257..ff84a0128 100644
--- a/bsd/i386/reboot.h
+++ b/bsd/i386/reboot.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/i386/reg.h b/bsd/i386/reg.h
index 35bb1130d..1bc1848f2 100644
--- a/bsd/i386/reg.h
+++ b/bsd/i386/reg.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/i386/setjmp.h b/bsd/i386/setjmp.h
index b2584eb47..8de839793 100644
--- a/bsd/i386/setjmp.h
+++ b/bsd/i386/setjmp.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/i386/signal.h b/bsd/i386/signal.h
index 3c73b16a9..5f9f0d985 100644
--- a/bsd/i386/signal.h
+++ b/bsd/i386/signal.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/i386/spl.h b/bsd/i386/spl.h
index 0f6be5565..6ca195efe 100644
--- a/bsd/i386/spl.h
+++ b/bsd/i386/spl.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/i386/table.h b/bsd/i386/table.h
index f55484ddc..b15eafe5d 100644
--- a/bsd/i386/table.h
+++ b/bsd/i386/table.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/i386/types.h b/bsd/i386/types.h
index f370e9bf1..b3c08099b 100644
--- a/bsd/i386/types.h
+++ b/bsd/i386/types.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/i386/ucontext.h b/bsd/i386/ucontext.h
index 0256c0f53..4af2eb278 100644
--- a/bsd/i386/ucontext.h
+++ b/bsd/i386/ucontext.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -40,6 +43,13 @@ struct mcontext {
 
 typedef struct mcontext * mcontext_t;
 
+struct mcontext64 {
+	struct sigcontext sc;
+};
+#define I386_MCONTEXT64_SIZE	sizeof(struct mcontext64)	
+
+typedef struct mcontext64 * mcontext64_t;
+
 #endif /* __APPLE_API_UNSTABLE */
 
 #endif /* _I386_UCONTEXT_H_ */
diff --git a/bsd/i386/user.h b/bsd/i386/user.h
index edc737230..e1b856fba 100644
--- a/bsd/i386/user.h
+++ b/bsd/i386/user.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/i386/vmparam.h b/bsd/i386/vmparam.h
index a1c9daeec..b8603cf7f 100644
--- a/bsd/i386/vmparam.h
+++ b/bsd/i386/vmparam.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/if/ppc/if_en.c b/bsd/if/ppc/if_en.c
index a1b2a1b96..3df54955d 100644
--- a/bsd/if/ppc/if_en.c
+++ b/bsd/if/ppc/if_en.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/if/ppc/if_en.h b/bsd/if/ppc/if_en.h
index 8e56ff533..7654c2933 100644
--- a/bsd/if/ppc/if_en.h
+++ b/bsd/if/ppc/if_en.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/if/ppc/mace.c b/bsd/if/ppc/mace.c
index b66ddd3e9..40921aeff 100644
--- a/bsd/if/ppc/mace.c
+++ b/bsd/if/ppc/mace.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/if/ppc/mace.h b/bsd/if/ppc/mace.h
index c439e4ccc..bb82bb51e 100644
--- a/bsd/if/ppc/mace.h
+++ b/bsd/if/ppc/mace.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/isofs/cd9660/cd9660_bmap.c b/bsd/isofs/cd9660/cd9660_bmap.c
index f031630e2..b0d7d4601 100644
--- a/bsd/isofs/cd9660/cd9660_bmap.c
+++ b/bsd/isofs/cd9660/cd9660_bmap.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/isofs/cd9660/cd9660_lookup.c b/bsd/isofs/cd9660/cd9660_lookup.c
index 1c20c4b21..ba3050e95 100644
--- a/bsd/isofs/cd9660/cd9660_lookup.c
+++ b/bsd/isofs/cd9660/cd9660_lookup.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/isofs/cd9660/cd9660_mount.h b/bsd/isofs/cd9660/cd9660_mount.h
index caa7e5c85..8be4d3706 100644
--- a/bsd/isofs/cd9660/cd9660_mount.h
+++ b/bsd/isofs/cd9660/cd9660_mount.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/isofs/cd9660/cd9660_node.c b/bsd/isofs/cd9660/cd9660_node.c
index f9e201a32..b9b0cdcce 100644
--- a/bsd/isofs/cd9660/cd9660_node.c
+++ b/bsd/isofs/cd9660/cd9660_node.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/isofs/cd9660/cd9660_node.h b/bsd/isofs/cd9660/cd9660_node.h
index 78f1239c3..57318b873 100644
--- a/bsd/isofs/cd9660/cd9660_node.h
+++ b/bsd/isofs/cd9660/cd9660_node.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/isofs/cd9660/cd9660_rrip.c b/bsd/isofs/cd9660/cd9660_rrip.c
index f73a873cd..25b2b6979 100644
--- a/bsd/isofs/cd9660/cd9660_rrip.c
+++ b/bsd/isofs/cd9660/cd9660_rrip.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/isofs/cd9660/cd9660_rrip.h b/bsd/isofs/cd9660/cd9660_rrip.h
index 4a3c17192..746963246 100644
--- a/bsd/isofs/cd9660/cd9660_rrip.h
+++ b/bsd/isofs/cd9660/cd9660_rrip.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/isofs/cd9660/cd9660_util.c b/bsd/isofs/cd9660/cd9660_util.c
index ace849705..dc724462a 100644
--- a/bsd/isofs/cd9660/cd9660_util.c
+++ b/bsd/isofs/cd9660/cd9660_util.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/isofs/cd9660/cd9660_vfsops.c b/bsd/isofs/cd9660/cd9660_vfsops.c
index b053db39e..929eb5446 100644
--- a/bsd/isofs/cd9660/cd9660_vfsops.c
+++ b/bsd/isofs/cd9660/cd9660_vfsops.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/isofs/cd9660/cd9660_vnops.c b/bsd/isofs/cd9660/cd9660_vnops.c
index 3f199bacc..aa94424e6 100644
--- a/bsd/isofs/cd9660/cd9660_vnops.c
+++ b/bsd/isofs/cd9660/cd9660_vnops.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/isofs/cd9660/iso.h b/bsd/isofs/cd9660/iso.h
index 1b69d791c..5cbf9b001 100644
--- a/bsd/isofs/cd9660/iso.h
+++ b/bsd/isofs/cd9660/iso.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/isofs/cd9660/iso_rrip.h b/bsd/isofs/cd9660/iso_rrip.h
index 5081d1bdc..87e58b794 100644
--- a/bsd/isofs/cd9660/iso_rrip.h
+++ b/bsd/isofs/cd9660/iso_rrip.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/kern/ast.h b/bsd/kern/ast.h
index f2b6aa07e..ae121ed84 100644
--- a/bsd/kern/ast.h
+++ b/bsd/kern/ast.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/kern/bsd_init.c b/bsd/kern/bsd_init.c
index 1b81ced7b..cd7fbbc45 100644
--- a/bsd/kern/bsd_init.c
+++ b/bsd/kern/bsd_init.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -117,7 +120,6 @@
 #include <mach/shared_memory_server.h>
 #include <vm/vm_shared_memory_server.h>
 
-extern shared_region_mapping_t       system_shared_region;
 extern int app_profile;		/* on/off switch for pre-heat cache */
 
 char    copyright[] =
@@ -412,6 +414,7 @@ bsd_init()
 	 */
 	s = splimp();
 	sysctl_register_fixed(); 
+	sysctl_mib_init();
 	dlil_init();
 	socketinit();
 	domaininit();
@@ -527,6 +530,7 @@ bsdinit_task(void)
 	struct uthread *ut;
 	kern_return_t	kr;
 	thread_act_t th_act;
+	shared_region_mapping_t system_region;
 
 	proc_name("init", p);
 
@@ -556,8 +560,14 @@ bsdinit_task(void)
 	bsd_hardclockinit = 1;	/* Start bsd hardclock */
 	bsd_init_task = get_threadtask(th_act);
 	init_task_failure_data[0] = 0;
-	shared_region_mapping_ref(system_shared_region);
-	vm_set_shared_region(get_threadtask(th_act), system_shared_region);
+	system_region = lookup_default_shared_region(
+			ENV_DEFAULT_ROOT, ENV_DEFAULT_SYSTEM);
+        if (system_region == NULL) {
+		shared_file_boot_time_init(
+			ENV_DEFAULT_ROOT, ENV_DEFAULT_SYSTEM);
+	} else {
+		vm_set_shared_region(get_threadtask(th_act), system_region);
+	}
 	load_init_program(p);
 	/* turn on app-profiling i.e. pre-heating */
 	app_profile = 1;
diff --git a/bsd/kern/bsd_stubs.c b/bsd/kern/bsd_stubs.c
index bfe0a85c4..8a41d1d8d 100644
--- a/bsd/kern/bsd_stubs.c
+++ b/bsd/kern/bsd_stubs.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -120,7 +123,7 @@ bdevsw_add(int index, struct bdevsw * bsw)
 	struct bdevsw *devsw;
 
 	if (index == -1) {
-	    devsw = bdevsw;
+	    devsw = &bdevsw[1];		/* Start at slot 1 - this is a hack to fix the index=1 hack */
 	    /* yes, start at 1 to avoid collision with volfs (Radar 2842228) */
 	    for(index=1; index < nblkdev; index++, devsw++) {
 		if(memcmp((char *)devsw, 
diff --git a/bsd/kern/init_sysent.c b/bsd/kern/init_sysent.c
index b6fc75287..4f1fc3c27 100644
--- a/bsd/kern/init_sysent.c
+++ b/bsd/kern/init_sysent.c
@@ -1,21 +1,24 @@
 /*
- * Copyright (c) 1995-1999, 2000-2002 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1995-1999, 2000-2003 Apple Computer, Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -124,6 +127,9 @@ int	setpriority();
 int	socket();
 int	connect();
 int	getpriority();
+#ifdef __ppc__
+int	osigreturn();
+#endif
 int	sigreturn();
 int	bind();
 int	setsockopt();
@@ -423,7 +429,11 @@ struct sysent sysent[] = {
 	sysp(getpriority,2),	/* 100 = getpriority */
 	comaptnet(send,4),		/* 101 = old send */
 	comaptnet(recv,4),		/* 102 = old recv */
-	syss(sigreturn,1),		/* 103 = sigreturn */
+#ifdef __ppc__
+	syss(osigreturn,1),		/* 103 = sigreturn ; compat for jaguar*/
+#else
+	syss(sigreturn,1),		/* 103 = sigreturn  */
+#endif
 	sysnets(bind,3),		/* 104 = bind */
 	sysnets(setsockopt,5),	/* 105 = setsockopt */
 	sysnets(listen,2),		/* 106 = listen */
@@ -517,7 +527,11 @@ struct sysent sysent[] = {
 	syss(setgid,1),			/* 181 */
 	syss(setegid,1),		/* 182 */
 	syss(seteuid,1),		/* 183 */
+#ifdef __ppc__
+	syss(sigreturn, 2),		/* 184 = nosys */
+#else
 	syss(nosys,0),			/* 184 = nosys */
+#endif
 	syss(nosys,0),			/* 185 = nosys */
 	syss(nosys,0),			/* 186 = nosys */
 	syss(nosys,0),			/* 187 = nosys */
diff --git a/bsd/kern/kdebug.c b/bsd/kern/kdebug.c
index 82c594c8b..1e09d8bce 100644
--- a/bsd/kern/kdebug.c
+++ b/bsd/kern/kdebug.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -1022,9 +1025,9 @@ struct proc *p, *curproc;
 		      kdbg_mapinit();
 		  break;
 		case KERN_KDSETBUF:
-		  /* We allow a maximum buffer size of 25% of memory */
+		  /* We allow a maximum buffer size of 25% of either ram or max mapped address, whichever is smaller */
 		  /* 'value' is the desired number of trace entries */
-		        max_entries = (mem_size/4) / sizeof(kd_buf);
+		        max_entries = (sane_size/4) / sizeof(kd_buf);
 			if (value <= max_entries)
 				nkdbufs = value;
 			else
@@ -1201,3 +1204,10 @@ kd_buf * my_kd_bufptr;
 	} /* end if count */
 	return (EINVAL);
 }
+
+unsigned char *getProcName(struct proc *proc);
+unsigned char *getProcName(struct proc *proc) {
+
+	return &proc->p_comm;	/* Return pointer to the proc name */
+
+}
diff --git a/bsd/kern/kern_acct.c b/bsd/kern/kern_acct.c
index 3654a9dc8..05b719d21 100644
--- a/bsd/kern/kern_acct.c
+++ b/bsd/kern/kern_acct.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/kern/kern_clock.c b/bsd/kern/kern_clock.c
index a1b35394e..25c65d595 100644
--- a/bsd/kern/kern_clock.c
+++ b/bsd/kern/kern_clock.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/kern/kern_control.c b/bsd/kern/kern_control.c
index 6e3288a6a..7319540f5 100644
--- a/bsd/kern/kern_control.c
+++ b/bsd/kern/kern_control.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/kern/kern_core.c b/bsd/kern/kern_core.c
index ebab0fa6e..4ef5b24ce 100644
--- a/bsd/kern/kern_core.c
+++ b/bsd/kern/kern_core.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -65,9 +68,10 @@ typedef struct {
 mythread_state_flavor_t thread_flavor_array[]={
 		{PPC_THREAD_STATE , PPC_THREAD_STATE_COUNT},
 		{PPC_FLOAT_STATE, PPC_FLOAT_STATE_COUNT}, 
-		{PPC_EXCEPTION_STATE, PPC_EXCEPTION_STATE_COUNT}
+		{PPC_EXCEPTION_STATE, PPC_EXCEPTION_STATE_COUNT},
+		{PPC_VECTOR_STATE, PPC_VECTOR_STATE_COUNT}
 		};
-int mynum_flavors=3;
+int mynum_flavors=4;
 #elif defined (__i386__)
 mythread_state_flavor_t thread_flavor_array [] = { 
 		{i386_THREAD_STATE, i386_THREAD_STATE_COUNT},
@@ -252,7 +256,7 @@ coredump(p)
 	mh->sizeofcmds = command_size;
 
 	hoffset = sizeof(struct mach_header);	/* offset into header */
-	foffset = round_page(header_size);	/* offset into file */
+	foffset = round_page_32(header_size);	/* offset into file */
 	vmoffset = VM_MIN_ADDRESS;		/* offset into VM */
 	/* We use to check for an error, here, now we try and get 
 	 * as much as we can
diff --git a/bsd/kern/kern_descrip.c b/bsd/kern/kern_descrip.c
index 0b8a16e32..b1f7469d4 100644
--- a/bsd/kern/kern_descrip.c
+++ b/bsd/kern/kern_descrip.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -305,12 +308,12 @@ fcntl(p, uap, retval)
 			return (0);
 		}
 		if ((long)uap->arg <= 0) {
-			uap->arg = (void *)(-(long)(uap->arg));
+			uap->arg = (int)(-(long)(uap->arg));
 		} else {
 			struct proc *p1 = pfind((long)uap->arg);
 			if (p1 == 0)
 				return (ESRCH);
-			uap->arg = (void *)(long)p1->p_pgrp->pg_id;
+			uap->arg = (int)p1->p_pgrp->pg_id;
 		}
 		return (fo_ioctl(fp, (int)TIOCSPGRP, (caddr_t)&uap->arg, p));
 
@@ -505,7 +508,7 @@ fcntl(p, uap, retval)
 		if (error = copyin((caddr_t)uap->arg,
 					(caddr_t)&ra_struct, sizeof (ra_struct)))
 			return(error);
-		return (VOP_IOCTL(vp, 1, &ra_struct, 0, fp->f_cred, p));
+		return (VOP_IOCTL(vp, 1, (caddr_t)&ra_struct, 0, fp->f_cred, p));
 
 	case F_READBOOTSTRAP:
 	case F_WRITEBOOTSTRAP:
@@ -535,7 +538,7 @@ fcntl(p, uap, retval)
 			if (error)
 				return (error);
 			error = VOP_IOCTL(vp, (uap->cmd == F_WRITEBOOTSTRAP) ? 3 : 2,
-					&fbt_struct, 0, fp->f_cred, p);
+					(caddr_t)&fbt_struct, 0, fp->f_cred, p);
 			VOP_UNLOCK(vp,0,p);
 		}
 		return(error);
@@ -953,9 +956,10 @@ ffree(fp)
 		crfree(cred);
 	}
 
-	fp->f_count = 0;
-
 	nfiles--;
+	memset(fp, 0xff, sizeof *fp);
+	fp->f_count = (short)0xffff;
+
 	FREE_ZONE(fp, sizeof *fp, M_FILE);
 }
 
@@ -1301,6 +1305,8 @@ dupfdopen(fdp, indx, dfd, mode, error)
 int
 fref(struct file *fp)
 {
+	if (fp->f_count == (short)0xffff)
+		return (-1);
 	if (++fp->f_count <= 0)
 		panic("fref: f_count");
 	return ((int)fp->f_count);
@@ -1309,6 +1315,8 @@ fref(struct file *fp)
 static int 
 frele_internal(struct file *fp)
 {
+	if (fp->f_count == (short)0xffff)
+		panic("frele: stale");
 	if (--fp->f_count < 0)
 		panic("frele: count < 0");
 	return ((int)fp->f_count);
@@ -1344,6 +1352,8 @@ frele(struct file *fp)
 int
 fcount(struct file *fp)
 {
+	if (fp->f_count == (short)0xffff)
+		panic("fcount: stale");
 	return ((int)fp->f_count);
 }
 
diff --git a/bsd/kern/kern_event.c b/bsd/kern/kern_event.c
index aa0d6326f..f298f525b 100644
--- a/bsd/kern/kern_event.c
+++ b/bsd/kern/kern_event.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  *
diff --git a/bsd/kern/kern_exec.c b/bsd/kern/kern_exec.c
index 6eb6ebe8f..88b0a60c3 100644
--- a/bsd/kern/kern_exec.c
+++ b/bsd/kern/kern_exec.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -166,7 +169,7 @@ execve(p, uap, retval)
 	vm_map_t old_map;
 	vm_map_t map;
 	int i;
-	boolean_t		new_shared_regions = FALSE;
+	boolean_t		clean_regions = FALSE;
 	union {
 		/* #! and name of interpreter */
 		char			ex_shell[SHSIZE];
@@ -532,23 +535,11 @@ again:
 	VOP_UNLOCK(vp, 0, p);
 	if(ws_cache_name) {
 		tws_handle_startup_file(task, cred->cr_uid, 
-			ws_cache_name, vp, &new_shared_regions);
-	}
-	if (new_shared_regions) {
-		shared_region_mapping_t	new_shared_region;
-		shared_region_mapping_t	old_shared_region;
-	
-		if (shared_file_create_system_region(&new_shared_region))
-			panic("couldn't create system_shared_region\n");
-
-		vm_get_shared_region(task, &old_shared_region);
-		vm_set_shared_region(task, new_shared_region);
-
-		shared_region_mapping_dealloc(old_shared_region);
+			ws_cache_name, vp, &clean_regions);
 	}
 
 	lret = load_machfile(vp, mach_header, arch_offset,
-				arch_size, &load_result, thr_act, map);
+		arch_size, &load_result, thr_act, map, clean_regions);
 
 	if (lret != LOAD_SUCCESS) {
 		error = load_return_to_errno(lret);
@@ -841,8 +832,8 @@ create_unix_stack(map, user_stack, customstack, p)
 
 	p->user_stack = user_stack;
 	if (!customstack) {
-		size = round_page(unix_stack_size(p));
-		addr = trunc_page(user_stack - size);
+		size = round_page_64(unix_stack_size(p));
+		addr = trunc_page_32(user_stack - size);
 		return (vm_allocate(map,&addr, size, FALSE));
 	} else
 		return(KERN_SUCCESS);
diff --git a/bsd/kern/kern_exit.c b/bsd/kern/kern_exit.c
index 3f6aa7236..25dc9ef71 100644
--- a/bsd/kern/kern_exit.c
+++ b/bsd/kern/kern_exit.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/kern/kern_fork.c b/bsd/kern/kern_fork.c
index c34b51b31..da5fec8f8 100644
--- a/bsd/kern/kern_fork.c
+++ b/bsd/kern/kern_fork.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -242,6 +245,7 @@ procdup(
 	thread_act_t		thread;
 	task_t			task;
  	kern_return_t	result;
+ 	pmap_t			pmap;
 	extern task_t kernel_task;
 
 	if (parent->task == kernel_task)
@@ -255,6 +259,7 @@ procdup(
 	set_bsdtask_info(task, child);
 	if (child->p_nice != 0)
 		resetpriority(child);
+		
 	result = thread_create(task, &thread);
 	if (result != KERN_SUCCESS)
 	    printf("fork/procdup: thread_create failed. Code: 0x%x\n", result);
diff --git a/bsd/kern/kern_ktrace.c b/bsd/kern/kern_ktrace.c
index a4ccca92a..2a4d1c3d3 100644
--- a/bsd/kern/kern_ktrace.c
+++ b/bsd/kern/kern_ktrace.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/kern/kern_lock.c b/bsd/kern/kern_lock.c
index d8ba1e858..25f845707 100644
--- a/bsd/kern/kern_lock.c
+++ b/bsd/kern/kern_lock.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/kern/kern_malloc.c b/bsd/kern/kern_malloc.c
index cf158f9b2..6af52d4ee 100644
--- a/bsd/kern/kern_malloc.c
+++ b/bsd/kern/kern_malloc.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -90,6 +93,8 @@
 #include <nfs/nfsmount.h>
 #include <nfs/nqnfs.h>
 
+#include <vfs/vfs_journal.h>
+
 #include <mach/mach_types.h>
 
 #include <kern/zalloc.h>
@@ -205,7 +210,8 @@ struct kmzones {
 	0,		KMZ_MALLOC,		/* 88 M_IP6MISC */
 	0,		KMZ_MALLOC,		/* 89 M_TSEGQ */
 	0,		KMZ_MALLOC,		/* 90 M_IGMP */
-
+	SOS(journal),     KMZ_CREATEZONE,     /* 91 M_JNL_JNL */
+	SOS(transaction), KMZ_CREATEZONE,     /* 92 M_JNL_TR */
 #undef	SOS
 #undef	SOX
 };
@@ -219,6 +225,11 @@ kmeminit(void)
 {
 	struct kmzones	*kmz;
 
+	if ((sizeof(kmzones)/sizeof(kmzones[0])) != (sizeof(memname)/sizeof(memname[0]))) {
+		panic("kmeminit: kmzones has %d elements but memname has %d\n",
+			  (sizeof(kmzones)/sizeof(kmzones[0])), (sizeof(memname)/sizeof(memname[0])));
+	}
+
 	kmz = kmzones;
 	while (kmz < &kmzones[M_LAST]) {
 /* XXX */
diff --git a/bsd/kern/kern_mib.c b/bsd/kern/kern_mib.c
index d6c43effe..42db0d01a 100644
--- a/bsd/kern/kern_mib.c
+++ b/bsd/kern/kern_mib.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -71,6 +74,41 @@
 #include <machine/smp.h>
 #endif
 
+#include <sys/param.h>  /* XXX prune includes */
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/malloc.h>
+#include <sys/proc.h>
+#include <sys/file.h>
+#include <sys/vnode.h>
+#include <sys/unistd.h>
+#include <sys/buf.h>
+#include <sys/ioctl.h>
+#include <sys/namei.h>
+#include <sys/tty.h>
+#include <sys/disklabel.h>
+#include <sys/vm.h>
+#include <sys/sysctl.h>
+#include <sys/user.h>
+#include <mach/machine.h>
+#include <mach/mach_types.h>
+#include <mach/vm_param.h>
+#include <kern/task.h>
+#include <vm/vm_kern.h>
+#include <mach/host_info.h>
+
+extern vm_map_t bsd_pageable_map;
+
+#include <sys/mount.h>
+#include <sys/kdebug.h>
+
+#include <IOKit/IOPlatformExpert.h>
+#include <pexpert/pexpert.h>
+
+#include <machine/machine_routines.h>
+#include <machine/cpu_capabilities.h>
+
+
 SYSCTL_NODE(, 0,	  sysctl, CTLFLAG_RW, 0,
 	"Sysctl internal magic");
 SYSCTL_NODE(, CTL_KERN,	  kern,   CTLFLAG_RW, 0,
@@ -90,3 +128,310 @@ SYSCTL_NODE(, CTL_MACHDEP, machdep, CTLFLAG_RW, 0,
 SYSCTL_NODE(, CTL_USER,	  user,   CTLFLAG_RW, 0,
 	"user-level");
 
+#define SYSCTL_RETURN(r, x)	SYSCTL_OUT(r, &x, sizeof(x))
+
+/******************************************************************************
+ * hw.* MIB
+ */
+
+#define CTLHW_RETQUAD	(1 << 31)
+
+/*
+ * Supporting some variables requires us to do "real" work.  We 
+ * gather some of that here.
+ */
+static int
+sysctl_hw_generic SYSCTL_HANDLER_ARGS
+{
+	char dummy[65];
+	int  epochTemp;
+	extern int vm_page_wire_count;
+	ml_cpu_info_t cpu_info;
+	int val, doquad;
+	long long qval;
+
+	/*
+	 * Test and mask off the 'return quad' flag.
+	 * Note that only some things here support it.
+	 */
+	doquad = arg2 & CTLHW_RETQUAD;
+	arg2 &= ~CTLHW_RETQUAD;
+
+	ml_cpu_get_info(&cpu_info);
+
+	/*
+	 * Handle various OIDs.
+	 *
+	 * OIDs that can return int or quad set val and qval and then break.
+	 * Errors and int-only values return inline.
+	 */
+	switch (arg2) {
+	case HW_NCPU:
+		{
+		host_basic_info_data_t hinfo;
+		kern_return_t kret;
+		int count = HOST_BASIC_INFO_COUNT;
+#define BSD_HOST 1
+
+			kret = host_info(BSD_HOST, HOST_BASIC_INFO, &hinfo, &count);
+			if (kret == KERN_SUCCESS) {
+				return(SYSCTL_RETURN(req, hinfo.max_cpus));
+			} else {
+				return(EINVAL);
+			}
+		}
+	case HW_AVAILCPU:
+		{
+		host_basic_info_data_t hinfo;
+		kern_return_t kret;
+		int count = HOST_BASIC_INFO_COUNT;
+#define BSD_HOST 1
+
+			kret = host_info(BSD_HOST, HOST_BASIC_INFO, &hinfo, &count);
+			if (kret == KERN_SUCCESS) {
+				return(SYSCTL_RETURN(req, hinfo.avail_cpus));
+			} else {
+				return(EINVAL);
+			}
+		}
+	case HW_CACHELINE:
+		val = cpu_info.cache_line_size;
+		qval = (long long)val;
+		break;
+	case HW_L1ICACHESIZE:
+		val = cpu_info.l1_icache_size;
+		qval = (long long)val;
+		break;
+	case HW_L1DCACHESIZE:
+		val = cpu_info.l1_dcache_size;
+		qval = (long long)val;
+		break;
+	case HW_L2CACHESIZE:
+		if (cpu_info.l2_cache_size == 0xFFFFFFFF)
+			return(EINVAL);
+		val = cpu_info.l2_cache_size;
+		qval = (long long)val;
+		break;
+	case HW_L3CACHESIZE:
+		if (cpu_info.l3_cache_size == 0xFFFFFFFF)
+			return(EINVAL);
+		val = cpu_info.l3_cache_size;
+		qval = (long long)val;
+		break;
+
+		/*
+		 * Deprecated variables.  We still support these for
+		 * backwards compatibility purposes only.
+		 */
+	case HW_MACHINE:
+		bzero(dummy, sizeof(dummy));
+		if(!PEGetMachineName(dummy,64))
+			return(EINVAL);
+		dummy[64] = 0;
+		return(SYSCTL_OUT(req, dummy, strlen(dummy) + 1));
+	case HW_MODEL:
+		bzero(dummy, sizeof(dummy));
+		if(!PEGetModelName(dummy,64))
+			return(EINVAL);
+		dummy[64] = 0;
+		return(SYSCTL_OUT(req, dummy, strlen(dummy) + 1));
+	case HW_USERMEM:
+		{
+		int usermem = mem_size - vm_page_wire_count * page_size;
+
+			return(SYSCTL_RETURN(req, usermem));
+		}
+	case HW_EPOCH:
+	        epochTemp = PEGetPlatformEpoch();
+		if (epochTemp == -1)
+			return(EINVAL);
+		return(SYSCTL_RETURN(req, epochTemp));
+	case HW_VECTORUNIT:
+		return(SYSCTL_RETURN(req, cpu_info.vector_unit));
+	case HW_L2SETTINGS:
+		if (cpu_info.l2_cache_size == 0xFFFFFFFF)
+			return(EINVAL);
+		return(SYSCTL_RETURN(req, cpu_info.l2_settings));
+	case HW_L3SETTINGS:
+		if (cpu_info.l3_cache_size == 0xFFFFFFFF)
+			return(EINVAL);
+		return(SYSCTL_RETURN(req, cpu_info.l3_settings));
+	default:
+		return(ENOTSUP);
+	}
+	/*
+	 * Callers may come to us with either int or quad buffers.
+	 */
+	if (doquad) {
+		return(SYSCTL_RETURN(req, qval));
+	}
+	return(SYSCTL_RETURN(req, val));
+}
+
+/*
+ * hw.* MIB variables.
+ */
+SYSCTL_PROC    (_hw, HW_NCPU, ncpu, CTLTYPE_INT  | CTLFLAG_RD | CTLFLAG_KERN, 0, HW_NCPU, sysctl_hw_generic, "I", "");
+SYSCTL_PROC    (_hw, HW_AVAILCPU, activecpu, CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_KERN, 0, HW_AVAILCPU, sysctl_hw_generic, "I", "");
+SYSCTL_INT     (_hw, HW_BYTEORDER, byteorder, CTLFLAG_RD | CTLFLAG_KERN, NULL, BYTE_ORDER, "");
+SYSCTL_INT     (_hw, OID_AUTO, cputype, CTLFLAG_RD | CTLFLAG_KERN, &machine_slot[0].cpu_type, 0, "");
+SYSCTL_INT     (_hw, OID_AUTO, cpusubtype, CTLFLAG_RD | CTLFLAG_KERN, &machine_slot[0].cpu_subtype, 0, "");
+SYSCTL_INT2QUAD(_hw, OID_AUTO, pagesize, CTLFLAG_RD | CTLFLAG_KERN, &page_size, "");
+SYSCTL_QUAD    (_hw, OID_AUTO, busfrequency, CTLFLAG_RD | CTLFLAG_KERN, &gPEClockFrequencyInfo.bus_frequency_hz, "");
+SYSCTL_QUAD    (_hw, OID_AUTO, busfrequency_min, CTLFLAG_RD | CTLFLAG_KERN, &gPEClockFrequencyInfo.bus_frequency_min_hz, "");
+SYSCTL_QUAD    (_hw, OID_AUTO, busfrequency_max, CTLFLAG_RD | CTLFLAG_KERN, &gPEClockFrequencyInfo.bus_frequency_max_hz, "");
+SYSCTL_QUAD    (_hw, OID_AUTO, cpufrequency, CTLFLAG_RD | CTLFLAG_KERN, &gPEClockFrequencyInfo.cpu_frequency_hz, "");
+SYSCTL_QUAD    (_hw, OID_AUTO, cpufrequency_min, CTLFLAG_RD | CTLFLAG_KERN, &gPEClockFrequencyInfo.cpu_frequency_min_hz, "");
+SYSCTL_QUAD    (_hw, OID_AUTO, cpufrequency_max, CTLFLAG_RD | CTLFLAG_KERN, &gPEClockFrequencyInfo.cpu_frequency_max_hz, "");
+SYSCTL_PROC    (_hw, OID_AUTO, cachelinesize, CTLTYPE_QUAD | CTLFLAG_RD | CTLFLAG_KERN, 0, HW_CACHELINE | CTLHW_RETQUAD, sysctl_hw_generic, "Q", "");
+SYSCTL_PROC    (_hw, OID_AUTO, l1icachesize, CTLTYPE_QUAD | CTLFLAG_RD | CTLFLAG_KERN, 0, HW_L1ICACHESIZE | CTLHW_RETQUAD, sysctl_hw_generic, "Q", "");
+SYSCTL_PROC    (_hw, OID_AUTO, l1dcachesize, CTLTYPE_QUAD | CTLFLAG_RD | CTLFLAG_KERN, 0, HW_L1DCACHESIZE | CTLHW_RETQUAD, sysctl_hw_generic, "Q", "");
+SYSCTL_PROC    (_hw, OID_AUTO, l2cachesize, CTLTYPE_QUAD | CTLFLAG_RD | CTLFLAG_KERN, 0, HW_L2CACHESIZE | CTLHW_RETQUAD, sysctl_hw_generic, "Q", "");
+SYSCTL_PROC    (_hw, OID_AUTO, l3cachesize, CTLTYPE_QUAD | CTLFLAG_RD | CTLFLAG_KERN, 0, HW_L3CACHESIZE | CTLHW_RETQUAD, sysctl_hw_generic, "Q", "");
+SYSCTL_INT2QUAD(_hw, OID_AUTO, tbfrequency, CTLFLAG_RD | CTLFLAG_KERN, &gPEClockFrequencyInfo.timebase_frequency_hz, "");
+SYSCTL_QUAD    (_hw, HW_MEMSIZE, memsize, CTLFLAG_RD | CTLFLAG_KERN, &max_mem, "");
+
+/*
+ * Optional features can register nodes below hw.optional.
+ *
+ * If the feature is not present, the node should either not be registered,
+ * or it should return -1.  If the feature is present, the node should return
+ * 0.  If the feature is present and its use is advised, the node should 
+ * return 1.
+ */
+SYSCTL_NODE(_hw, OID_AUTO, optional, CTLFLAG_RW, NULL, "optional features");
+
+SYSCTL_INT(_hw_optional, OID_AUTO, floatingpoint, CTLFLAG_RD | CTLFLAG_KERN, 0, 1, "");	/* always set */
+
+/*
+ * Deprecated variables.  These are supported for backwards compatibility
+ * purposes only.  The MASKED flag requests that the variables not be
+ * printed by sysctl(8) and similar utilities.
+ *
+ * The variables named *_compat here are int-sized versions of variables
+ * that are now exported as quads.  The int-sized versions are normally
+ * looked up only by number, wheras the quad-sized versions should be
+ * looked up by name.
+ *
+ * The *_compat nodes are *NOT* visible within the kernel.
+ */
+SYSCTL_INT (_hw, HW_PAGESIZE,     pagesize_compat, CTLFLAG_RD | CTLFLAG_MASKED, &page_size, 0, "");
+SYSCTL_INT (_hw, HW_BUS_FREQ,     busfrequency_compat, CTLFLAG_RD | CTLFLAG_MASKED, &gPEClockFrequencyInfo.bus_clock_rate_hz, 0, "");
+SYSCTL_INT (_hw, HW_CPU_FREQ,     cpufrequency_compat, CTLFLAG_RD | CTLFLAG_MASKED, &gPEClockFrequencyInfo.cpu_clock_rate_hz, 0, "");
+SYSCTL_PROC(_hw, HW_CACHELINE,    cachelinesize_compat, CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MASKED, 0, HW_CACHELINE, sysctl_hw_generic, "I", "");
+SYSCTL_PROC(_hw, HW_L1ICACHESIZE, l1icachesize_compat, CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MASKED, 0, HW_L1ICACHESIZE, sysctl_hw_generic, "I", "");
+SYSCTL_PROC(_hw, HW_L1DCACHESIZE, l1dcachesize_compat, CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MASKED, 0, HW_L1DCACHESIZE, sysctl_hw_generic, "I", "");
+SYSCTL_PROC(_hw, HW_L2CACHESIZE,  l2cachesize_compat, CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MASKED, 0, HW_L2CACHESIZE, sysctl_hw_generic, "I", "");
+SYSCTL_PROC(_hw, HW_L3CACHESIZE,  l3cachesize_compat, CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MASKED, 0, HW_L3CACHESIZE, sysctl_hw_generic, "I", "");
+SYSCTL_INT (_hw, HW_TB_FREQ,      tbfrequency_compat, CTLFLAG_RD | CTLFLAG_MASKED, &gPEClockFrequencyInfo.timebase_frequency_hz, 0, "");
+SYSCTL_PROC(_hw, HW_MACHINE,      machine, CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MASKED, 0, HW_MACHINE, sysctl_hw_generic, "A", "");
+SYSCTL_PROC(_hw, HW_MODEL,        model, CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MASKED, 0, HW_MODEL, sysctl_hw_generic, "A", "");
+SYSCTL_INT (_hw, HW_PHYSMEM,      physmem, CTLFLAG_RD | CTLFLAG_MASKED, &mem_size, 0, "");
+SYSCTL_PROC(_hw, HW_USERMEM,      usermem, CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MASKED, 0, HW_USERMEM,	sysctl_hw_generic, "I", "");
+SYSCTL_PROC(_hw, HW_EPOCH,        epoch, CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MASKED, 0, HW_EPOCH, sysctl_hw_generic, "I", "");
+SYSCTL_PROC(_hw, HW_VECTORUNIT,   vectorunit, CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MASKED, 0, HW_VECTORUNIT, sysctl_hw_generic, "I", "");
+SYSCTL_PROC(_hw, HW_L2SETTINGS,   l2settings, CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MASKED, 0, HW_L2SETTINGS, sysctl_hw_generic, "I", "");
+SYSCTL_PROC(_hw, HW_L3SETTINGS,   l3settings, CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MASKED, 0, HW_L3SETTINGS, sysctl_hw_generic, "I", "");
+
+/******************************************************************************
+ * Generic MIB initialisation.
+ *
+ * This is a hack, and should be replaced with SYSINITs
+ * at some point.
+ */
+void
+sysctl_mib_init(void)
+{
+	
+	/*
+	 * Populate the optional portion of the hw.* MIB.
+	 *
+	 * XXX This could be broken out into parts of the code
+	 *     that actually directly relate to the functions in
+	 *     question.
+	 */
+#ifdef __ppc__
+	{
+		static int altivec_flag = -1;
+		static SYSCTL_INT(_hw_optional, OID_AUTO, altivec, CTLFLAG_RD | CTLFLAG_NOAUTO | CTLFLAG_KERN, &altivec_flag, 0, "");
+
+		if (_cpu_capabilities & kHasAltivec) {
+			altivec_flag = 1;
+			sysctl_register_oid(&sysctl__hw_optional_altivec);
+		}
+	}
+	{
+		static int graphicsops_flag = -1;
+		static SYSCTL_INT(_hw_optional, OID_AUTO, graphicsops, CTLFLAG_RD | CTLFLAG_NOAUTO | CTLFLAG_KERN, &graphicsops_flag, 0, "");
+
+		if (_cpu_capabilities & kHasGraphicsOps) {
+			graphicsops_flag = 1;
+			sysctl_register_oid(&sysctl__hw_optional_graphicsops);
+		}		
+	}
+	{
+		static int x64bitops_flag = -1;
+		static SYSCTL_INT(_hw_optional, OID_AUTO, 64bitops, CTLFLAG_RD | CTLFLAG_NOAUTO | CTLFLAG_KERN, &x64bitops_flag, 0, "");
+
+		if (_cpu_capabilities & k64Bit) {
+			x64bitops_flag = 1;
+			sysctl_register_oid(&sysctl__hw_optional_64bitops);
+		}		
+	}
+	{
+		static int fsqrt_flag = -1;
+		static SYSCTL_INT(_hw_optional, OID_AUTO, fsqrt, CTLFLAG_RD | CTLFLAG_NOAUTO | CTLFLAG_KERN, &fsqrt_flag, 0, "");
+
+		if (_cpu_capabilities & kHasFsqrt) {
+			fsqrt_flag = 1;
+			sysctl_register_oid(&sysctl__hw_optional_fsqrt);
+		}		
+	}
+	{
+		static int stfiwx_flag = -1;
+		static SYSCTL_INT(_hw_optional, OID_AUTO, stfiwx, CTLFLAG_RD | CTLFLAG_NOAUTO | CTLFLAG_KERN, &stfiwx_flag, 0, "");
+
+		if (_cpu_capabilities & kHasStfiwx) {
+			stfiwx_flag = 1;
+			sysctl_register_oid(&sysctl__hw_optional_stfiwx);
+		}		
+	}
+	{
+		static int dcba_flag = -1;
+		static SYSCTL_INT(_hw_optional, OID_AUTO, dcba, CTLFLAG_RD | CTLFLAG_NOAUTO | CTLFLAG_KERN, &dcba_flag, 0, "");
+
+		if (_cpu_capabilities & kDcbaAvailable)
+			dcba_flag = 0;
+		if (_cpu_capabilities & kDcbaRecommended)
+			dcba_flag = 1;
+		if (dcba_flag >= 0)
+			sysctl_register_oid(&sysctl__hw_optional_dcba);
+	}
+	{
+		static int datastreams_flag = -1;
+		static SYSCTL_INT(_hw_optional, OID_AUTO, datastreams, CTLFLAG_RD | CTLFLAG_NOAUTO | CTLFLAG_KERN, &datastreams_flag, 0, "");
+
+		if (_cpu_capabilities & kDataStreamsAvailable)
+			datastreams_flag = 0;
+		if (_cpu_capabilities & kDataStreamsRecommended)
+			datastreams_flag = 1;
+		if (datastreams_flag >= 0)
+			sysctl_register_oid(&sysctl__hw_optional_datastreams);
+	}
+	{
+		static int dcbtstreams_flag = -1;
+		static SYSCTL_INT(_hw_optional, OID_AUTO, dcbtstreams, CTLFLAG_RD | CTLFLAG_NOAUTO | CTLFLAG_KERN, &dcbtstreams_flag, 0, "");
+
+		if (_cpu_capabilities & kDcbtStreamsAvailable)
+			dcbtstreams_flag = 0;
+		if (_cpu_capabilities & kDcbtStreamsRecommended)
+			dcbtstreams_flag = 1;
+		if (dcbtstreams_flag >= 0)
+			sysctl_register_oid(&sysctl__hw_optional_dcbtstreams);
+	}
+#else
+# warning we do not support this platform yet
+#endif /* __ppc__ */
+
+
+}
diff --git a/bsd/kern/kern_mman.c b/bsd/kern/kern_mman.c
index 3febc75bf..2d03d5f13 100644
--- a/bsd/kern/kern_mman.c
+++ b/bsd/kern/kern_mman.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -243,7 +246,7 @@ mmap(p, uap, retval)
 
 	/* Adjust size for rounding (on both ends). */
 	user_size += pageoff;			/* low end... */
-	user_size = (vm_size_t) round_page(user_size);	/* hi end */
+	user_size = (vm_size_t) round_page_32(user_size);	/* hi end */
 
 
 	/*
@@ -277,8 +280,8 @@ mmap(p, uap, retval)
 	 * There should really be a pmap call to determine a reasonable
 	 * location.
 	 */
-	else if (addr < round_page(p->p_vmspace->vm_daddr + MAXDSIZ))
-		addr = round_page(p->p_vmspace->vm_daddr + MAXDSIZ);
+	else if (addr < round_page_32(p->p_vmspace->vm_daddr + MAXDSIZ))
+		addr = round_page_32(p->p_vmspace->vm_daddr + MAXDSIZ);
 
 #endif
 
@@ -371,7 +374,7 @@ mmap(p, uap, retval)
 	 *	We bend a little - round the start and end addresses
 	 *	to the nearest page boundary.
 	 */
-	user_size = round_page(user_size);
+	user_size = round_page_32(user_size);
 
 	if (file_pos & PAGE_MASK_64)
 		return (EINVAL);
@@ -380,9 +383,9 @@ mmap(p, uap, retval)
 
 	if ((flags & MAP_FIXED) == 0) {
 		find_space = TRUE;
-		user_addr = round_page(user_addr); 
+		user_addr = round_page_32(user_addr); 
 	} else {
-		if (user_addr != trunc_page(user_addr))
+		if (user_addr != trunc_page_32(user_addr))
 			return (EINVAL);
 		find_space = FALSE;
 		(void) vm_deallocate(user_map, user_addr, user_size);
@@ -507,7 +510,7 @@ msync(p, uap, retval)
 	pageoff = (addr & PAGE_MASK);
 	addr -= pageoff;
 	size = uap->len;
-	size = (vm_size_t) round_page(size);
+	size = (vm_size_t) round_page_32(size);
 	flags = uap->flags;
 
 	if (addr + size < addr)
@@ -587,7 +590,7 @@ munmap(p, uap, retval)
 
 	user_addr -= pageoff;
 	user_size += pageoff;
-	user_size = round_page(user_size);
+	user_size = round_page_32(user_size);
 	if (user_addr + user_size < user_addr)
 		return(EINVAL);
 
@@ -651,7 +654,7 @@ mprotect(p, uap, retval)
 	pageoff = (user_addr & PAGE_MASK);
 	user_addr -= pageoff;
 	user_size += pageoff;
-	user_size = round_page(user_size);
+	user_size = round_page_32(user_size);
 	if (user_addr + user_size < user_addr)
 		return(EINVAL);
 
@@ -694,7 +697,7 @@ minherit(p, uap, retval)
 	pageoff = (addr & PAGE_MASK);
 	addr -= pageoff;
 	size += pageoff;
-	size = (vm_size_t) round_page(size);
+	size = (vm_size_t) round_page_32(size);
 	if (addr + size < addr)
 		return(EINVAL);
 
@@ -744,8 +747,8 @@ madvise(p, uap, retval)
 	 * Since this routine is only advisory, we default to conservative
 	 * behavior.
 	 */
-	start = trunc_page((vm_offset_t) uap->addr);
-	end = round_page((vm_offset_t) uap->addr + uap->len);
+	start = trunc_page_32((vm_offset_t) uap->addr);
+	end = round_page_32((vm_offset_t) uap->addr + uap->len);
 	
 	user_map = current_map();
 
@@ -809,8 +812,8 @@ mincore(p, uap, retval)
 	 * Make sure that the addresses presented are valid for user
 	 * mode.
 	 */
-	first_addr = addr = trunc_page((vm_offset_t) uap->addr);
-	end = addr + (vm_size_t)round_page(uap->len);
+	first_addr = addr = trunc_page_32((vm_offset_t) uap->addr);
+	end = addr + (vm_size_t)round_page_32(uap->len);
 
 	if (VM_MAX_ADDRESS > 0 && end > VM_MAX_ADDRESS)
 		return (EINVAL);
@@ -910,7 +913,7 @@ mlock(p, uap, retval)
 	pageoff = (addr & PAGE_MASK);
 	addr -= pageoff;
 	size += pageoff;
-	size = (vm_size_t) round_page(size);
+	size = (vm_size_t) round_page_32(size);
 
 	/* disable wrap around */
 	if (addr + size < addr)
@@ -959,7 +962,7 @@ munlock(p, uap, retval)
 	pageoff = (addr & PAGE_MASK);
 	addr -= pageoff;
 	size += pageoff;
-	size = (vm_size_t) round_page(size);
+	size = (vm_size_t) round_page_32(size);
 
 	/* disable wrap around */
 	if (addr + size < addr)
@@ -1099,7 +1102,7 @@ kern_return_t map_fd_funneled(
 		printf("map_fd: file offset not page aligned(%d : %s)\n",p->p_pid, p->p_comm);
 		return (KERN_INVALID_ARGUMENT);
 	}
-	map_size = round_page(size);
+	map_size = round_page_32(size);
 
 	/*
 	 * Allow user to map in a zero length file.
@@ -1132,7 +1135,7 @@ kern_return_t map_fd_funneled(
 		vm_map_copy_t	tmp;
 
 		if (copyin(va, &dst_addr, sizeof (dst_addr))	||
-					trunc_page(dst_addr) != dst_addr) {
+					trunc_page_32(dst_addr) != dst_addr) {
 			(void) vm_map_remove(
 					my_map,
 					map_addr, map_addr + map_size,
diff --git a/bsd/kern/kern_newsysctl.c b/bsd/kern/kern_newsysctl.c
index 399bbdb92..09da4572b 100644
--- a/bsd/kern/kern_newsysctl.c
+++ b/bsd/kern/kern_newsysctl.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -93,6 +96,33 @@ static struct sysctl_lock {
 	int	sl_locked;
 } memlock;
 
+/*
+ * XXX this does not belong here
+ */
+static funnel_t *
+spl_kernel_funnel(void)
+{
+	funnel_t *cfunnel;
+
+	cfunnel = thread_funnel_get();
+	if (cfunnel != kernel_flock) {
+		if (cfunnel != NULL)
+			thread_funnel_set(cfunnel, FALSE);
+		thread_funnel_set(kernel_flock, TRUE);
+	}
+	return(cfunnel);
+}
+
+static void
+splx_kernel_funnel(funnel_t *saved)
+{
+	if (saved != kernel_flock) {
+		thread_funnel_set(kernel_flock, FALSE);
+		if (saved != NULL) 
+			thread_funnel_set(saved, TRUE);
+	}
+}
+
 static int sysctl_root SYSCTL_HANDLER_ARGS;
 
 struct sysctl_oid_list sysctl__children; /* root list */
@@ -109,6 +139,9 @@ void sysctl_register_oid(struct sysctl_oid *oidp)
 	struct sysctl_oid *p;
 	struct sysctl_oid *q;
 	int n;
+	funnel_t *fnl;
+
+	fnl = spl_kernel_funnel();
 
 	/*
 	 * If this oid has a number OID_AUTO, give it a number which
@@ -139,11 +172,17 @@ void sysctl_register_oid(struct sysctl_oid *oidp)
 		SLIST_INSERT_AFTER(q, oidp, oid_link);
 	else
 		SLIST_INSERT_HEAD(parent, oidp, oid_link);
+
+	splx_kernel_funnel(fnl);
 }
 
 void sysctl_unregister_oid(struct sysctl_oid *oidp)
 {
+	funnel_t *fnl;
+
+	fnl = spl_kernel_funnel();
 	SLIST_REMOVE(oidp->oid_parent, oidp, sysctl_oid, oid_link);
+	splx_kernel_funnel(fnl);
 }
 
 /*
@@ -581,6 +620,64 @@ sysctl_handle_long SYSCTL_HANDLER_ARGS
 	return (error);
 }
 
+/*
+ * Handle a quad, signed or unsigned.  arg1 points to it.
+ */
+
+int
+sysctl_handle_quad SYSCTL_HANDLER_ARGS
+{
+	int error = 0;
+
+	if (!arg1)
+		return (EINVAL);
+	error = SYSCTL_OUT(req, arg1, sizeof(long long));
+
+	if (error || !req->newptr)
+		return (error);
+
+	error = SYSCTL_IN(req, arg1, sizeof(long long));
+	return (error);
+}
+
+/*
+ * Expose an int value as a quad.
+ *
+ * This interface allows us to support interfaces defined
+ * as using quad values while the implementation is still
+ * using ints.
+ */
+int
+sysctl_handle_int2quad SYSCTL_HANDLER_ARGS
+{
+	int error = 0;
+	long long val;
+	int newval;
+
+	if (!arg1)
+		return (EINVAL);
+	val = (long long)*(int *)arg1;
+	error = SYSCTL_OUT(req, &val, sizeof(long long));
+
+	if (error || !req->newptr)
+		return (error);
+
+	error = SYSCTL_IN(req, &val, sizeof(long long));
+	if (!error) {
+		/*
+		 * Value must be representable; check by
+		 * casting and then casting back.
+		 */
+		newval = (int)val;
+		if ((long long)newval != val) {
+			error = ERANGE;
+		} else {
+			*(int *)arg1 = newval;
+		}
+	}
+	return (error);
+}
+
 /*
  * Handle our generic '\0' terminated 'C' string.
  * Two cases:
@@ -631,7 +728,6 @@ sysctl_handle_opaque SYSCTL_HANDLER_ARGS
 
 /*
  * Transfer functions to/from kernel space.
- * XXX: rather untested at this point
  */
 static int
 sysctl_old_kernel(struct sysctl_req *req, const void *p, size_t l)
@@ -643,11 +739,8 @@ sysctl_old_kernel(struct sysctl_req *req, const void *p, size_t l)
 		i = l;
 		if (i > req->oldlen - req->oldidx)
 			i = req->oldlen - req->oldidx;
-		if (i > 0) {
-			error = copyout((void*)p, (char *)req->oldptr + req->oldidx, i);
-			if (error)
-			    return error;
-		}
+		if (i > 0)
+			bcopy((void*)p, (char *)req->oldptr + req->oldidx, i);
 	}
 	req->oldidx += l;
 	if (req->oldptr && i != l)
@@ -662,38 +755,40 @@ sysctl_new_kernel(struct sysctl_req *req, void *p, size_t l)
 		return 0;
 	if (req->newlen - req->newidx < l)
 		return (EINVAL);
-	copyin((char *)req->newptr + req->newidx, p, l);
+	bcopy((char *)req->newptr + req->newidx, p, l);
 	req->newidx += l;
 	return (0);
 }
 
 int
-kernel_sysctl(struct proc *p, int *name, u_int namelen, void *old, size_t *oldlenp, void *new, size_t newlen, size_t *retval)
+kernel_sysctl(struct proc *p, int *name, u_int namelen, void *old, size_t *oldlenp, void *new, size_t newlen)
 {
 	int error = 0;
 	struct sysctl_req req;
+	funnel_t *fnl;
 
+	/*
+	 * Construct request.
+	 */
 	bzero(&req, sizeof req);
-
 	req.p = p;
-
-	if (oldlenp) {
+	if (oldlenp)
 		req.oldlen = *oldlenp;
-	}
-
-	if (old) {
+	if (old)
 		req.oldptr= old;
-	}
-
 	if (newlen) {
 		req.newlen = newlen;
 		req.newptr = new;
 	}
-
 	req.oldfunc = sysctl_old_kernel;
 	req.newfunc = sysctl_new_kernel;
 	req.lock = 1;
 
+	/*
+	 * Locking.  Tree traversal always begins with the kernel funnel held.
+	 */
+	fnl = spl_kernel_funnel();
+
 	/* XXX this should probably be done in a general way */
 	while (memlock.sl_lock) {
 		memlock.sl_want = 1;
@@ -702,8 +797,10 @@ kernel_sysctl(struct proc *p, int *name, u_int namelen, void *old, size_t *oldle
 	}
 	memlock.sl_lock = 1;
 
+	/* make the request */
 	error = sysctl_root(0, name, namelen, &req);
 
+	/* unlock memory if required */
 	if (req.lock == 2)
 		vsunlock(req.oldptr, req.oldlen, B_WRITE);
 
@@ -714,15 +811,17 @@ kernel_sysctl(struct proc *p, int *name, u_int namelen, void *old, size_t *oldle
 		wakeup((caddr_t)&memlock);
 	}
 
+	/*
+	 * Undo locking.
+	 */
+	splx_kernel_funnel(fnl);
+
 	if (error && error != ENOMEM)
 		return (error);
 
-	if (retval) {
-		if (req.oldptr && req.oldidx > req.oldlen)
-			*retval = req.oldlen;
-		else
-			*retval = req.oldidx;
-	}
+	if (oldlenp)
+		*oldlenp = req.oldidx;
+
 	return (error);
 }
 
@@ -814,6 +913,13 @@ found:
 		return (EPERM);
 	}
 
+	/*
+	 * If we're inside the kernel, the OID must be marked as kernel-valid.
+	 * XXX This mechanism for testing is bad.
+	 */
+	if ((req->oldfunc == sysctl_old_kernel) && !(oid->oid_kind & CTLFLAG_KERN))
+		return(EPERM);
+
 	/* Most likely only root can write */
 	if (!(oid->oid_kind & CTLFLAG_ANYBODY) &&
 	    req->newptr && req->p &&
@@ -946,214 +1052,55 @@ userland_sysctl(struct proc *p, int *name, u_int namelen, void *old, size_t *old
 	}
 	return (error);
 }
-#if 0
-
-#if COMPAT_43
-#include <sys/socket.h>
-#include <vm/vm_param.h>
-
-#define	KINFO_PROC		(0<<8)
-#define	KINFO_RT		(1<<8)
-#define	KINFO_VNODE		(2<<8)
-#define	KINFO_FILE		(3<<8)
-#define	KINFO_METER		(4<<8)
-#define	KINFO_LOADAVG		(5<<8)
-#define	KINFO_CLOCKRATE		(6<<8)
-
-/* Non-standard BSDI extension - only present on their 4.3 net-2 releases */
-#define	KINFO_BSDI_SYSINFO	(101<<8)
 
 /*
- * XXX this is bloat, but I hope it's better here than on the potentially
- * limited kernel stack...  -Peter
- */
-
-static struct {
-	int	bsdi_machine;		/* "i386" on BSD/386 */
-/*      ^^^ this is an offset to the string, relative to the struct start */
-	char	*pad0;
-	long	pad1;
-	long	pad2;
-	long	pad3;
-	u_long	pad4;
-	u_long	pad5;
-	u_long	pad6;
-
-	int	bsdi_ostype;		/* "BSD/386" on BSD/386 */
-	int	bsdi_osrelease;		/* "1.1" on BSD/386 */
-	long	pad7;
-	long	pad8;
-	char	*pad9;
-
-	long	pad10;
-	long	pad11;
-	int	pad12;
-	long	pad13;
-	quad_t	pad14;
-	long	pad15;
-
-	struct	timeval pad16;
-	/* we dont set this, because BSDI's uname used gethostname() instead */
-	int	bsdi_hostname;		/* hostname on BSD/386 */
-
-	/* the actual string data is appended here */
-
-} bsdi_si;
-/*
- * this data is appended to the end of the bsdi_si structure during copyout.
- * The "char *" offsets are relative to the base of the bsdi_si struct.
- * This contains "FreeBSD\02.0-BUILT-nnnnnn\0i386\0", and these strings
- * should not exceed the length of the buffer here... (or else!! :-)
+ * Kernel versions of the userland sysctl helper functions.
+ *
+ * These allow sysctl to be used in the same fashion in both
+ * userland and the kernel.
+ *
+ * Note that some sysctl handlers use copyin/copyout, which
+ * may not work correctly.
  */
-static char bsdi_strings[80];	/* It had better be less than this! */
-
-#ifndef _SYS_SYSPROTO_H_
-struct getkerninfo_args {
-	int	op;
-	char	*where;
-	size_t	*size;
-	int	arg;
-};
-#endif
 
-int
-ogetkerninfo(struct proc *p, struct getkerninfo_args *uap)
+static int
+sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, size_t newlen)
 {
-	int error, name[6];
-	size_t size;
-
-	switch (uap->op & 0xff00) {
-
-	case KINFO_RT:
-		name[0] = CTL_NET;
-		name[1] = PF_ROUTE;
-		name[2] = 0;
-		name[3] = (uap->op & 0xff0000) >> 16;
-		name[4] = uap->op & 0xff;
-		name[5] = uap->arg;
-		error = userland_sysctl(p, name, 6, uap->where, uap->size,
-			0, 0, 0, &size);
-		break;
-
-	case KINFO_VNODE:
-		name[0] = CTL_KERN;
-		name[1] = KERN_VNODE;
-		error = userland_sysctl(p, name, 2, uap->where, uap->size,
-			0, 0, 0, &size);
-		break;
-
-	case KINFO_PROC:
-		name[0] = CTL_KERN;
-		name[1] = KERN_PROC;
-		name[2] = uap->op & 0xff;
-		name[3] = uap->arg;
-		error = userland_sysctl(p, name, 4, uap->where, uap->size,
-			0, 0, 0, &size);
-		break;
-
-	case KINFO_FILE:
-		name[0] = CTL_KERN;
-		name[1] = KERN_FILE;
-		error = userland_sysctl(p, name, 2, uap->where, uap->size,
-			0, 0, 0, &size);
-		break;
-
-	case KINFO_METER:
-		name[0] = CTL_VM;
-		name[1] = VM_METER;
-		error = userland_sysctl(p, name, 2, uap->where, uap->size,
-			0, 0, 0, &size);
-		break;
-
-	case KINFO_LOADAVG:
-		name[0] = CTL_VM;
-		name[1] = VM_LOADAVG;
-		error = userland_sysctl(p, name, 2, uap->where, uap->size,
-			0, 0, 0, &size);
-		break;
-
-	case KINFO_CLOCKRATE:
-		name[0] = CTL_KERN;
-		name[1] = KERN_CLOCKRATE;
-		error = userland_sysctl(p, name, 2, uap->where, uap->size,
-			0, 0, 0, &size);
-		break;
-
-	case KINFO_BSDI_SYSINFO: {
-		/*
-		 * this is pretty crude, but it's just enough for uname()
-		 * from BSDI's 1.x libc to work.
-		 *
-		 * In particular, it doesn't return the same results when
-		 * the supplied buffer is too small.  BSDI's version apparently
-		 * will return the amount copied, and set the *size to how
-		 * much was needed.  The emulation framework here isn't capable
-		 * of that, so we just set both to the amount copied.
-		 * BSDI's 2.x product apparently fails with ENOMEM in this
-		 * scenario.
-		 */
-
-		u_int needed;
-		u_int left;
-		char *s;
-
-		bzero((char *)&bsdi_si, sizeof(bsdi_si));
-		bzero(bsdi_strings, sizeof(bsdi_strings));
 
-		s = bsdi_strings;
-
-		bsdi_si.bsdi_ostype = (s - bsdi_strings) + sizeof(bsdi_si);
-		strcpy(s, ostype);
-		s += strlen(s) + 1;
-
-		bsdi_si.bsdi_osrelease = (s - bsdi_strings) + sizeof(bsdi_si);
-		strcpy(s, osrelease);
-		s += strlen(s) + 1;
-
-		bsdi_si.bsdi_machine = (s - bsdi_strings) + sizeof(bsdi_si);
-		strcpy(s, machine);
-		s += strlen(s) + 1;
-
-		needed = sizeof(bsdi_si) + (s - bsdi_strings);
-
-		if (uap->where == NULL) {
-			/* process is asking how much buffer to supply.. */
-			size = needed;
-			error = 0;
-			break;
-		}
+	return(kernel_sysctl(current_proc(), name, namelen, oldp, oldlenp, newp, newlen));
+}
 
+static int
+sysctlnametomib(const char *name, int *mibp, size_t *sizep)
+{
+	int oid[2];
+	int error;
 
-		/* if too much buffer supplied, trim it down */
-		if (size > needed)
-			size = needed;
+	/* magic service node */
+	oid[0] = 0;
+	oid[1] = 3;
 
-		/* how much of the buffer is remaining */
-		left = size;
+	/* look up OID for name */
+	*sizep *= sizeof(int);
+	error = sysctl(oid, 2, mibp, sizep, (void *)name, strlen(name));
+	*sizep /= sizeof(int);
+	return(error);
+}
 
-		if ((error = copyout((char *)&bsdi_si, uap->where, left)) != 0)
-			break;
+int
+sysctlbyname(const char *name, void *oldp, size_t *oldlenp, void *newp, size_t newlen)
+{
+	int oid[CTL_MAXNAME + 2];
+	int error;
+	size_t oidlen;
 
-		/* is there any point in continuing? */
-		if (left > sizeof(bsdi_si)) {
-			left -= sizeof(bsdi_si);
-			error = copyout(&bsdi_strings,
-					uap->where + sizeof(bsdi_si), left);
-		}
-		break;
-	}
+	/* look up the OID */
+	oidlen = CTL_MAXNAME;
+	error = sysctlnametomib(name, oid, &oidlen);
 
-	default:
-		return (EOPNOTSUPP);
-	}
-	if (error)
-		return (error);
-	p->p_retval[0] = size;
-	if (uap->size)
-		error = copyout((caddr_t)&size, (caddr_t)uap->size,
-		    sizeof(size));
-	return (error);
+	/* now use the OID */
+	if (error == 0)
+		error = sysctl(oid, oidlen, oldp, oldlenp, newp, newlen);
+	return(error);
 }
-#endif /* COMPAT_43 */
 
-#endif
diff --git a/bsd/kern/kern_panicinfo.c b/bsd/kern/kern_panicinfo.c
index 62f79dafe..db92fb59a 100644
--- a/bsd/kern/kern_panicinfo.c
+++ b/bsd/kern/kern_panicinfo.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/kern/kern_pcsamples.c b/bsd/kern/kern_pcsamples.c
index 7d338236a..9a0a3ced5 100644
--- a/bsd/kern/kern_pcsamples.c
+++ b/bsd/kern/kern_pcsamples.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/kern/kern_physio.c b/bsd/kern/kern_physio.c
index c4f2415f5..def3db886 100644
--- a/bsd/kern/kern_physio.c
+++ b/bsd/kern/kern_physio.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/kern/kern_proc.c b/bsd/kern/kern_proc.c
index 97f98cc1d..125fde90a 100644
--- a/bsd/kern/kern_proc.c
+++ b/bsd/kern/kern_proc.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/kern/kern_prot.c b/bsd/kern/kern_prot.c
index 66c98a137..2cd41c3b1 100644
--- a/bsd/kern/kern_prot.c
+++ b/bsd/kern/kern_prot.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/kern/kern_resource.c b/bsd/kern/kern_resource.c
index 5a41676e2..0e54ed45d 100644
--- a/bsd/kern/kern_resource.c
+++ b/bsd/kern/kern_resource.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -350,14 +353,14 @@ dosetrlimit(p, which, limp)
 			
 			if (limp->rlim_cur > alimp->rlim_cur) {
 				/* grow stack */
-				size = round_page(limp->rlim_cur);
-				size -= round_page(alimp->rlim_cur);
+				size = round_page_64(limp->rlim_cur);
+				size -= round_page_64(alimp->rlim_cur);
 
 #if STACK_GROWTH_UP
 				/* go to top of current stack */
-				addr = trunc_page(p->user_stack + alimp->rlim_cur);
+				addr = trunc_page((unsigned int)(p->user_stack + alimp->rlim_cur));
 #else STACK_GROWTH_UP
-				addr = trunc_page(p->user_stack - alimp->rlim_cur);
+				addr = trunc_page_32((unsigned int)(p->user_stack - alimp->rlim_cur));
 				addr -= size;
 #endif /* STACK_GROWTH_UP */
 				if (vm_allocate(current_map(),
diff --git a/bsd/kern/kern_shutdown.c b/bsd/kern/kern_shutdown.c
index 45697a58d..809b9c6d3 100644
--- a/bsd/kern/kern_shutdown.c
+++ b/bsd/kern/kern_shutdown.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/kern/kern_sig.c b/bsd/kern/kern_sig.c
index 21c9358d9..546bfdf5c 100644
--- a/bsd/kern/kern_sig.c
+++ b/bsd/kern/kern_sig.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -287,6 +290,8 @@ sigaction(p, uap, retval)
 			sa->sa_flags |= SA_SIGINFO;
 		if (ps->ps_signodefer & bit)
 			sa->sa_flags |= SA_NODEFER;
+		if (ps->ps_64regset & bit)
+			sa->sa_flags |= SA_64REGSET;
 		if ((signum == SIGCHLD) && (p->p_flag & P_NOCLDSTOP))
 			sa->sa_flags |= SA_NOCLDSTOP;
 		if ((signum == SIGCHLD) && (p->p_flag & P_NOCLDWAIT))
@@ -430,6 +435,10 @@ setsigvec(p, signum, sa)
 		ps->ps_siginfo |= bit;
 	else
 		ps->ps_siginfo &= ~bit;
+	if (sa->sa_flags & SA_64REGSET)
+		ps->ps_64regset |= bit;
+	else
+		ps->ps_64regset &= ~bit;
 	if ((sa->sa_flags & SA_RESTART) == 0)
 		ps->ps_sigintr |= bit;
 	else
@@ -2130,6 +2139,7 @@ issignal(p)
 				do_bsdexception(EXC_SOFTWARE, EXC_SOFT_SIGNAL, signum);
 				signal_lock(p);
 			} else {
+//				panic("Unsupportef gdb option \n");;
 				pp->si_pid = p->p_pid;
 				pp->si_status = p->p_xstat;
 				pp->si_code = CLD_TRAPPED;
diff --git a/bsd/kern/kern_subr.c b/bsd/kern/kern_subr.c
index be0f738ff..7e94acb9c 100644
--- a/bsd/kern/kern_subr.c
+++ b/bsd/kern/kern_subr.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -65,6 +68,7 @@
 #include <sys/proc.h>
 #include <sys/malloc.h>
 #include <sys/queue.h>
+#include <vm/pmap.h>
 
 #include <kdebug.h>
 
@@ -72,12 +76,17 @@
 #define DBG_UIO_COPYOUT 16
 #define DBG_UIO_COPYIN  17
 
-
 int
 uiomove(cp, n, uio)
 	register caddr_t cp;
 	register int n;
 	register struct uio *uio;
+{
+	return uiomove64((addr64_t)((unsigned int)cp), n, uio);
+}
+
+int
+uiomove64(addr64_t cp, int n, struct uio *uio)
 {
 	register struct iovec *iov;
 	u_int cnt;
@@ -107,22 +116,22 @@ uiomove(cp, n, uio)
 			if (uio->uio_rw == UIO_READ)
 			  {
 			        KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, DBG_UIO_COPYOUT)) | DBG_FUNC_START,
-					 cp, iov->iov_base, cnt, 0,0);
+					 (caddr_t)cp, iov->iov_base, cnt, 0,0);
 
-				error = copyout(cp, iov->iov_base, cnt);
+				error = copyout((caddr_t)cp, iov->iov_base, cnt);
 
 			        KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, DBG_UIO_COPYOUT)) | DBG_FUNC_END,
-					 cp, iov->iov_base, cnt, 0,0);
+					 (caddr_t)cp, iov->iov_base, cnt, 0,0);
 			  }
 			else
 			  {
 			        KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, DBG_UIO_COPYIN)) | DBG_FUNC_START,
-					 iov->iov_base, cp, cnt, 0,0);
+					 iov->iov_base, (caddr_t)cp, cnt, 0,0);
 
-			        error = copyin(iov->iov_base, cp, cnt);
+			        error = copyin(iov->iov_base, (caddr_t)cp, cnt);
 
 			        KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, DBG_UIO_COPYIN)) | DBG_FUNC_END,
-					 iov->iov_base, cp, cnt, 0,0);
+					 iov->iov_base, (caddr_t)cp, cnt, 0,0);
 			  }
 			if (error)
 				return (error);
@@ -143,8 +152,8 @@ uiomove(cp, n, uio)
 			        KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, DBG_UIO_COPYOUT)) | DBG_FUNC_START,
 					 cp, iov->iov_base, cnt, 1,0);
 
-				error = copyp2v(cp, iov->iov_base, cnt);
-
+				if (error = copypv((addr64_t)cp, (addr64_t)((unsigned int)iov->iov_base), cnt, cppvPsrc | cppvNoRefSrc)) 	/* Copy physical to virtual */
+				        error = EFAULT;
 
 			        KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, DBG_UIO_COPYOUT)) | DBG_FUNC_END,
 					 cp, iov->iov_base, cnt, 1,0);
@@ -154,7 +163,8 @@ uiomove(cp, n, uio)
 			        KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, DBG_UIO_COPYIN)) | DBG_FUNC_START,
 					 iov->iov_base, cp, cnt, 1,0);
 
-				panic("copyv2p not implemented yet\n");
+				if (error = copypv((addr64_t)((unsigned int)iov->iov_base), (addr64_t)cp, cnt, cppvPsnk | cppvNoRefSrc | cppvNoModSnk))	/* Copy virtual to physical */
+				        error = EFAULT;
 
 			        KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, DBG_UIO_COPYIN)) | DBG_FUNC_END,
 					 iov->iov_base, cp, cnt, 1,0);
diff --git a/bsd/kern/kern_symfile.c b/bsd/kern/kern_symfile.c
index f4607b9d3..4fd60fab2 100644
--- a/bsd/kern/kern_symfile.c
+++ b/bsd/kern/kern_symfile.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -109,13 +112,13 @@ static int output_kernel_symbols(struct proc *p)
 				(void **)&orig_mh, &orig_mhsize);
     if (rc_mh && orig_mh)
 	IODTFreeLoaderInfo("Kernel-__HEADER",
-			    (void *)orig_mh, round_page(orig_mhsize));
+			    (void *)orig_mh, round_page_32(orig_mhsize));
 
     rc_sc = IODTGetLoaderInfo("Kernel-__SYMTAB",
 				(void **) &orig_st, &orig_st_size);
     if (rc_sc && orig_st)
 	IODTFreeLoaderInfo("Kernel-__SYMTAB",
-			    (void *)orig_st, round_page(orig_st_size));
+			    (void *)orig_st, round_page_32(orig_st_size));
 
     if (pcred->p_svuid != pcred->p_ruid || pcred->p_svgid != pcred->p_rgid)
 	goto out;
@@ -204,7 +207,7 @@ static int output_kernel_symbols(struct proc *p)
     mh->flags      = orig_mh->flags;
 
     // Initialise the current file offset and addr
-    offset = round_page(header_size);
+    offset = round_page_32(header_size);
     addr = (caddr_t) const_text->addr;	// Load address of __TEXT,__const
 
     /*
@@ -217,7 +220,7 @@ static int output_kernel_symbols(struct proc *p)
     sg->vmaddr   = (unsigned long) addr;
     sg->vmsize   = const_text->size;
     sg->fileoff  = 0;
-    sg->filesize = const_text->size + round_page(header_size);
+    sg->filesize = const_text->size + round_page_32(header_size);
     sg->maxprot  = 0;
     sg->initprot = 0;
     sg->flags    = 0;
@@ -234,7 +237,7 @@ static int output_kernel_symbols(struct proc *p)
 	    const_text = se;
 	}
     }
-    offset = round_page((vm_address_t) offset);
+    offset = round_page_32((vm_address_t) offset);
 
     // Now copy of the __DATA segment load command, the image need
     // not be stored to disk nobody needs it, yet!
@@ -255,7 +258,7 @@ static int output_kernel_symbols(struct proc *p)
 	se->offset = offset;
 	se->nreloc = 0;
     }
-    offset = round_page(offset);
+    offset = round_page_32(offset);
 
 
     /*
diff --git a/bsd/kern/kern_synch.c b/bsd/kern/kern_synch.c
index f7d68435f..06f1d4591 100644
--- a/bsd/kern/kern_synch.c
+++ b/bsd/kern/kern_synch.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/kern/kern_sysctl.c b/bsd/kern/kern_sysctl.c
index 6aefc6796..58551e20f 100644
--- a/bsd/kern/kern_sysctl.c
+++ b/bsd/kern/kern_sysctl.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -97,7 +100,6 @@ extern vm_map_t bsd_pageable_map;
 #endif
 
 sysctlfn kern_sysctl;
-sysctlfn hw_sysctl;
 #ifdef DEBUG
 sysctlfn debug_sysctl;
 #endif
@@ -213,9 +215,6 @@ __sysctl(p, uap, retval)
 			&& (name[1] != KERN_PROC))
 			dolock = 0;
 		break;
-	case CTL_HW:
-		fn = hw_sysctl;
-		break;
 	case CTL_VM:
 		fn = vm_sysctl;
 		break;
@@ -450,100 +449,6 @@ kern_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
 	/* NOTREACHED */
 }
 
-/*
- * hardware related system variables.
- */
-hw_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
-	int *name;
-	u_int namelen;
-	void *oldp;
-	size_t *oldlenp;
-	void *newp;
-	size_t newlen;
-	struct proc *p;
-{
-	char dummy[65];
-	int  epochTemp;
-	extern int vm_page_wire_count;
-#if __ppc__
-	ml_ppc_cpu_info_t cpu_info;
-
-	ml_ppc_get_info(&cpu_info);
-#endif
-
-	/* all sysctl names at this level are terminal */
-	if (namelen != 1)
-		return (ENOTDIR);		/* overloaded */
-
-	switch (name[0]) {
-	case HW_MACHINE:
-		if(!PEGetMachineName(dummy,64))
-			return(EINVAL);
-		return (sysctl_rdstring(oldp, oldlenp, newp, dummy));
-	case HW_MODEL:
-		if(!PEGetModelName(dummy,64))
-			return(EINVAL);
-		return (sysctl_rdstring(oldp, oldlenp, newp, dummy));
-	case HW_NCPU:
-		{
-		int numcpus=1;
-		host_basic_info_data_t hinfo;
-		kern_return_t kret;
-		int count= HOST_BASIC_INFO_COUNT;
-#define BSD_HOST 1
-
-			kret = host_info(BSD_HOST, HOST_BASIC_INFO, &hinfo, &count);
-			if (kret == KERN_SUCCESS) {
-				numcpus = hinfo.avail_cpus;
-				return (sysctl_rdint(oldp, oldlenp, newp, numcpus));
-			} else {
-				return(EINVAL);
-			}
-		}
-	case HW_BYTEORDER:
-		return (sysctl_rdint(oldp, oldlenp, newp, BYTE_ORDER));
-	case HW_PHYSMEM:
-		return (sysctl_rdint(oldp, oldlenp, newp, mem_size));
-	case HW_USERMEM:
-		return (sysctl_rdint(oldp, oldlenp, newp,
-		    (mem_size - vm_page_wire_count * page_size)));
-	case HW_PAGESIZE:
-		return (sysctl_rdint(oldp, oldlenp, newp, page_size));
-	case HW_EPOCH:
-	        epochTemp = PEGetPlatformEpoch();
-		if (epochTemp == -1) return(EINVAL);
-		return (sysctl_rdint(oldp, oldlenp, newp, epochTemp));
-	case HW_BUS_FREQ:
-		return (sysctl_rdint(oldp, oldlenp, newp, gPEClockFrequencyInfo.bus_clock_rate_hz));
-	case HW_CPU_FREQ:
-		return (sysctl_rdint(oldp, oldlenp, newp, gPEClockFrequencyInfo.cpu_clock_rate_hz));
-#if __ppc__
-	case HW_VECTORUNIT:
-		return (sysctl_rdint(oldp, oldlenp, newp, cpu_info.vector_unit));
-	case HW_CACHELINE:
-		return (sysctl_rdint(oldp, oldlenp, newp, cpu_info.cache_line_size));
-	case HW_L1ICACHESIZE:
-		return (sysctl_rdint(oldp, oldlenp, newp, cpu_info.l1_icache_size));
-	case HW_L1DCACHESIZE:
-		return (sysctl_rdint(oldp, oldlenp, newp, cpu_info.l1_dcache_size));
-	case HW_L2SETTINGS:
-		if (cpu_info.l2_cache_size == 0xFFFFFFFF) return(EINVAL);
-		return (sysctl_rdint(oldp, oldlenp, newp, cpu_info.l2_settings));
-	case HW_L2CACHESIZE:
-		if (cpu_info.l2_cache_size == 0xFFFFFFFF) return(EINVAL);
-		return (sysctl_rdint(oldp, oldlenp, newp, cpu_info.l2_cache_size));
-	case HW_L3SETTINGS:
-		if (cpu_info.l3_cache_size == 0xFFFFFFFF) return(EINVAL);
-		return (sysctl_rdint(oldp, oldlenp, newp, cpu_info.l3_settings));
-	case HW_L3CACHESIZE:
-		if (cpu_info.l3_cache_size == 0xFFFFFFFF) return(EINVAL);
-		return (sysctl_rdint(oldp, oldlenp, newp, cpu_info.l3_cache_size));
-#endif
-	default:
-		return (EOPNOTSUPP);
-	}
-}
-
 #ifdef DEBUG
 /*
  * Debugging related system variables.
@@ -1211,20 +1116,20 @@ sysctl_procargs(name, namelen, where, sizep, cur_proc)
 		goto restart;
 	}
 
-	ret = kmem_alloc(kernel_map, &copy_start, round_page(arg_size));
+	ret = kmem_alloc(kernel_map, &copy_start, round_page_32(arg_size));
 	if (ret != KERN_SUCCESS) {
 		task_deallocate(task);
 		return(ENOMEM);
 	}
 
 	proc_map = get_task_map(task);
-	copy_end = round_page(copy_start + arg_size);
+	copy_end = round_page_32(copy_start + arg_size);
 
-	if( vm_map_copyin(proc_map, trunc_page(arg_addr), round_page(arg_size), 
+	if( vm_map_copyin(proc_map, trunc_page(arg_addr), round_page_32(arg_size), 
 			FALSE, &tmp) != KERN_SUCCESS) {
 			task_deallocate(task);
 			kmem_free(kernel_map, copy_start,
-					round_page(arg_size));
+					round_page_32(arg_size));
 			return (EIO);
 	}
 
@@ -1237,7 +1142,7 @@ sysctl_procargs(name, namelen, where, sizep, cur_proc)
 	if( vm_map_copy_overwrite(kernel_map, copy_start, 
 		tmp, FALSE) != KERN_SUCCESS) {
 			kmem_free(kernel_map, copy_start,
-					round_page(arg_size));
+					round_page_32(arg_size));
 			return (EIO);
 	}
 
diff --git a/bsd/kern/kern_time.c b/bsd/kern/kern_time.c
index d41be2383..c31bbb507 100644
--- a/bsd/kern/kern_time.c
+++ b/bsd/kern/kern_time.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/kern/kern_xxx.c b/bsd/kern/kern_xxx.c
index 7da98c9ee..49d35c157 100644
--- a/bsd/kern/kern_xxx.c
+++ b/bsd/kern/kern_xxx.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/kern/mach_fat.c b/bsd/kern/mach_fat.c
index 6c25ae9d4..6ccadf16e 100644
--- a/bsd/kern/mach_fat.c
+++ b/bsd/kern/mach_fat.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -104,7 +107,7 @@ fatfile_getarch(
 	/*
 	 * 	Round size of fat_arch structures up to page boundry.
 	 */
-	size = round_page(end_of_archs);
+	size = round_page_32(end_of_archs);
 	if (size <= 0)
 		return(LOAD_BADMACHO);
 
diff --git a/bsd/kern/mach_header.c b/bsd/kern/mach_header.c
index fe3c02312..2510daa92 100644
--- a/bsd/kern/mach_header.c
+++ b/bsd/kern/mach_header.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/kern/mach_header.h b/bsd/kern/mach_header.h
index 1e4cbeaba..fecf4daec 100644
--- a/bsd/kern/mach_header.h
+++ b/bsd/kern/mach_header.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/kern/mach_loader.c b/bsd/kern/mach_loader.c
index 0a9956125..7de9bed8c 100644
--- a/bsd/kern/mach_loader.c
+++ b/bsd/kern/mach_loader.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -74,7 +77,8 @@ parse_machfile(
 	unsigned long		file_offset,
 	unsigned long		macho_size,
 	int					depth,
-	load_result_t		*result
+	load_result_t		*result,
+	boolean_t		clean_regions
 ),
 load_segment(
 	struct segment_command	*scp,
@@ -118,7 +122,8 @@ load_dylinker(
 	vm_map_t				map,
 	thread_act_t			thr_act,
 	int						depth,
-	load_result_t			*result
+	load_result_t			*result,
+	boolean_t			clean_regions
 ),
 get_macho_vnode(
 	char				*path,
@@ -136,7 +141,8 @@ load_machfile(
 	unsigned long		macho_size,
 	load_result_t		*result,
 	thread_act_t 		thr_act,
-	vm_map_t 			new_map
+	vm_map_t 		new_map,
+	boolean_t		clean_regions
 )
 {
 	pmap_t			pmap;
@@ -165,20 +171,22 @@ load_machfile(
 				TRUE); /**** FIXME ****/
 	} else
 		map = new_map;
-
+		
 	if (!result)
 		result = &myresult;
 
 	*result = (load_result_t) { 0 };
 
 	lret = parse_machfile(vp, map, thr_act, header, file_offset, macho_size,
-			     0, result);
+			     0, result, clean_regions);
 
 	if (lret != LOAD_SUCCESS) {
-		if (create_map)
+		if (create_map) {
 			vm_map_deallocate(map);	/* will lose pmap reference too */
+		}
 		return(lret);
 	}
+
 	/*
 	 *	Commit to new map.  First make sure that the current
 	 *	users of the task get done with it, and that we clean
@@ -208,7 +216,6 @@ load_machfile(
 }
 
 int	dylink_test = 1;
-extern	vm_offset_t	system_shared_region;
 
 static
 load_return_t
@@ -220,7 +227,8 @@ parse_machfile(
 	unsigned long		file_offset,
 	unsigned long		macho_size,
 	int			depth,
-	load_result_t		*result
+	load_result_t		*result,
+	boolean_t		clean_regions
 )
 {
 	struct machine_slot	*ms;
@@ -228,7 +236,7 @@ parse_machfile(
 	struct load_command	*lcp, *next;
 	struct dylinker_command	*dlp = 0;
 	void *			pager;
-	load_return_t		ret;
+	load_return_t		ret = LOAD_SUCCESS;
 	vm_offset_t		addr, kl_addr;
 	vm_size_t		size,kl_size;
 	int			offset;
@@ -296,7 +304,7 @@ parse_machfile(
 	/*
 	 *	Round size of Mach-O commands up to page boundry.
 	 */
-	size = round_page(sizeof (struct mach_header) + header->sizeofcmds);
+	size = round_page_32(sizeof (struct mach_header) + header->sizeofcmds);
 	if (size <= 0)
 		return(LOAD_BADMACHO);
 
@@ -373,13 +381,13 @@ parse_machfile(
 			case LC_LOAD_DYLINKER:
 				if (pass != 2)
 					break;
-				if (depth == 1 || dlp == 0)
+				if ((depth == 1) && (dlp == 0))
 					dlp = (struct dylinker_command *)lcp;
 				else
 					ret = LOAD_FAILURE;
 				break;
 			default:
-				ret = KERN_SUCCESS;/* ignore other stuff */
+				ret = LOAD_SUCCESS;/* ignore other stuff */
 			}
 			if (ret != LOAD_SUCCESS)
 				break;
@@ -387,7 +395,7 @@ parse_machfile(
 		if (ret != LOAD_SUCCESS)
 			break;
 	}
-	if (ret == LOAD_SUCCESS && dlp != 0) {
+	if ((ret == LOAD_SUCCESS) && (depth == 1)) {
 		vm_offset_t addr;
 		shared_region_mapping_t shared_region;
 		struct shared_region_task_mappings	map_info;
@@ -405,33 +413,91 @@ RedoLookup:
 			&(map_info.client_base),
 			&(map_info.alternate_base),
 			&(map_info.alternate_next), 
+			&(map_info.fs_base),
+			&(map_info.system),
 			&(map_info.flags), &next);
 
-		if((map_info.self != (vm_offset_t)system_shared_region) &&
-			(map_info.flags & SHARED_REGION_SYSTEM)) {
-			shared_region_mapping_ref(system_shared_region);
-			vm_set_shared_region(task, system_shared_region);
-			shared_region_mapping_dealloc(
+		if((map_info.flags & SHARED_REGION_FULL) ||
+			(map_info.flags & SHARED_REGION_STALE)) {
+			shared_region_mapping_t system_region;
+			system_region = lookup_default_shared_region(
+				map_info.fs_base, map_info.system);
+			if((map_info.self != (vm_offset_t)system_region) &&
+				(map_info.flags & SHARED_REGION_SYSTEM)) {
+			   if(system_region == NULL) {
+				shared_file_boot_time_init(
+					map_info.fs_base, map_info.system);
+			   } else {
+			   	vm_set_shared_region(task, system_region);
+			   }
+			   shared_region_mapping_dealloc(
 					(shared_region_mapping_t)map_info.self);
-			goto RedoLookup;
+			   goto RedoLookup;
+			} else if (map_info.flags & SHARED_REGION_SYSTEM) {
+			      shared_region_mapping_dealloc(system_region);
+			      shared_file_boot_time_init(
+					map_info.fs_base, map_info.system);
+			      shared_region_mapping_dealloc(
+				     (shared_region_mapping_t)map_info.self);
+			} else {
+			      shared_region_mapping_dealloc(system_region);
+			}
 		}
 
 
 		if (dylink_test) {
 			p->p_flag |=  P_NOSHLIB; /* no shlibs in use */
 			addr = map_info.client_base;
-			vm_map(map, &addr, map_info.text_size, 0, 
+			if(clean_regions) {
+			   vm_map(map, &addr, map_info.text_size, 
+				0, SHARED_LIB_ALIAS,
+				map_info.text_region, 0, FALSE,
+				VM_PROT_READ, VM_PROT_READ, VM_INHERIT_SHARE);
+			} else {
+			   vm_map(map, &addr, map_info.text_size, 0, 
 				(VM_MEMORY_SHARED_PMAP << 24) 
 						| SHARED_LIB_ALIAS,
 				map_info.text_region, 0, FALSE,
 				VM_PROT_READ, VM_PROT_READ, VM_INHERIT_SHARE);
+			}
 			addr = map_info.client_base + map_info.text_size;
 			vm_map(map, &addr, map_info.data_size, 
 				0, SHARED_LIB_ALIAS,
 				map_info.data_region, 0, TRUE,
 				VM_PROT_READ, VM_PROT_READ, VM_INHERIT_SHARE);
+	
+			while (next) {
+		           /* this should be fleshed out for the general case */
+			   /* but this is not necessary for now.  Indeed we   */
+			   /* are handling the com page inside of the         */
+			   /* shared_region mapping create calls for now for  */
+			   /* simplicities sake.  If more general support is  */
+			   /* needed the code to manipulate the shared range  */
+			   /* chain can be pulled out and moved to the callers*/
+			   shared_region_mapping_info(next,
+				&(map_info.text_region),   
+				&(map_info.text_size),
+				&(map_info.data_region),
+				&(map_info.data_size),
+				&(map_info.region_mappings),
+				&(map_info.client_base),
+				&(map_info.alternate_base),
+				&(map_info.alternate_next), 
+				&(map_info.fs_base),
+				&(map_info.system),
+				&(map_info.flags), &next);
+
+			   addr = map_info.client_base;
+			   vm_map(map, &addr, map_info.text_size, 
+				0, SHARED_LIB_ALIAS,
+				map_info.text_region, 0, FALSE,
+				VM_PROT_READ, VM_PROT_READ, VM_INHERIT_SHARE);
+			}
 		}
-		ret = load_dylinker(dlp, map, thr_act, depth, result);
+        if (dlp != 0) {
+            ret = load_dylinker(dlp, map, thr_act, 
+                        depth, result, clean_regions);
+        }
 	}
 
 	if (kl_addr )
@@ -475,15 +541,15 @@ load_segment(
 	if (scp->fileoff + scp->filesize > macho_size)
 		return (LOAD_BADMACHO);
 
-	seg_size = round_page(scp->vmsize);
+	seg_size = round_page_32(scp->vmsize);
 	if (seg_size == 0)
 		return(KERN_SUCCESS);
 
 	/*
 	 *	Round sizes to page size.
 	 */
-	map_size = round_page(scp->filesize);
-	map_addr = trunc_page(scp->vmaddr);
+	map_size = round_page_32(scp->filesize);
+	map_addr = trunc_page_32(scp->vmaddr);
 
 	map_offset = pager_offset + scp->fileoff;
 
@@ -780,7 +846,8 @@ load_dylinker(
 	vm_map_t		map,
 	thread_act_t	thr_act,
 	int			depth,
-	load_result_t		*result
+	load_result_t		*result,
+	boolean_t		clean_regions
 )
 {
 	char			*name;
@@ -821,7 +888,7 @@ load_dylinker(
 
 	ret = parse_machfile(vp, copy_map, thr_act, &header,
 				file_offset, macho_size,
-				depth, &myresult);
+				depth, &myresult, clean_regions);
 
 	if (ret)
 		goto out;
diff --git a/bsd/kern/mach_loader.h b/bsd/kern/mach_loader.h
index 26cb05e9a..9c7b1171e 100644
--- a/bsd/kern/mach_loader.h
+++ b/bsd/kern/mach_loader.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -59,7 +62,8 @@ load_return_t load_machfile(
 	unsigned long		macho_size,
 	load_result_t		*result,
 	thread_act_t		thr_act,
-	vm_map_t			map);
+	vm_map_t		map,
+	boolean_t		clean_regions);
 
 #define LOAD_SUCCESS		0
 #define LOAD_BADARCH		1	/* CPU type/subtype not found */
diff --git a/bsd/kern/mach_process.c b/bsd/kern/mach_process.c
index e7df848de..8e6a05af4 100644
--- a/bsd/kern/mach_process.c
+++ b/bsd/kern/mach_process.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -114,7 +117,7 @@ ptrace(p, uap, retval)
 	int		*locr0;
 	int error = 0;
 #if defined(ppc)
-	struct ppc_thread_state statep;
+	struct ppc_thread_state64 statep;
 #elif	defined(i386)
 	struct i386_saved_state statep;
 #else
@@ -288,8 +291,8 @@ ptrace(p, uap, retval)
 			goto errorLabel;
 		}	
 #elif defined(ppc)
-		state_count = PPC_THREAD_STATE_COUNT;
-		if (thread_getstatus(th_act, PPC_THREAD_STATE, &statep, &state_count)  != KERN_SUCCESS) {
+		state_count = PPC_THREAD_STATE64_COUNT;
+		if (thread_getstatus(th_act, PPC_THREAD_STATE64, &statep, &state_count)  != KERN_SUCCESS) {
 			goto errorLabel;
 		}	
 #else
@@ -303,9 +306,9 @@ ptrace(p, uap, retval)
 		if (!ALIGNED((int)uap->addr, sizeof(int)))
 			return (ERESTART);
 
-		statep.srr0 = (int)uap->addr;
-		state_count = PPC_THREAD_STATE_COUNT;
-		if (thread_setstatus(th_act, PPC_THREAD_STATE, &statep, &state_count)  != KERN_SUCCESS) {
+		statep.srr0 = (uint64_t)((uint32_t)uap->addr);
+		state_count = PPC_THREAD_STATE64_COUNT;
+		if (thread_setstatus(th_act, PPC_THREAD_STATE64, &statep, &state_count)  != KERN_SUCCESS) {
 			goto errorLabel;
 		}	
 #undef 	ALIGNED
@@ -321,8 +324,8 @@ ptrace(p, uap, retval)
 			psignal_lock(t, uap->data, 0);
                 }
 #if defined(ppc)
-		state_count = PPC_THREAD_STATE_COUNT;
-		if (thread_getstatus(th_act, PPC_THREAD_STATE, &statep, &state_count)  != KERN_SUCCESS) {
+		state_count = PPC_THREAD_STATE64_COUNT;
+		if (thread_getstatus(th_act, PPC_THREAD_STATE64, &statep, &state_count)  != KERN_SUCCESS) {
 			goto errorLabel;
 		}	
 #endif
@@ -346,8 +349,8 @@ ptrace(p, uap, retval)
 #endif
 		}
 #if defined (ppc)
-		state_count = PPC_THREAD_STATE_COUNT;
-		if (thread_setstatus(th_act, PPC_THREAD_STATE, &statep, &state_count)  != KERN_SUCCESS) {
+		state_count = PPC_THREAD_STATE64_COUNT;
+		if (thread_setstatus(th_act, PPC_THREAD_STATE64, &statep, &state_count)  != KERN_SUCCESS) {
 			goto errorLabel;
 		}	
 #endif
@@ -356,7 +359,8 @@ ptrace(p, uap, retval)
 		t->p_stat = SRUN;
 		if (t->sigwait) {
 			wakeup((caddr_t)&(t->sigwait));
-			task_release(task);
+			if ((t->p_flag & P_SIGEXC) == 0)
+				task_release(task);
 		}
 		break;
 		
diff --git a/bsd/kern/netboot.c b/bsd/kern/netboot.c
index 4043bc9d3..ce58ad619 100644
--- a/bsd/kern/netboot.c
+++ b/bsd/kern/netboot.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/kern/posix_sem.c b/bsd/kern/posix_sem.c
index 05f946900..56b920a4f 100644
--- a/bsd/kern/posix_sem.c
+++ b/bsd/kern/posix_sem.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/kern/posix_shm.c b/bsd/kern/posix_shm.c
index 1b25d26ac..952b28833 100644
--- a/bsd/kern/posix_shm.c
+++ b/bsd/kern/posix_shm.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -507,7 +510,7 @@ pshm_truncate(p, fp, fd, length, retval)
 		return(EINVAL);
 	}
 
-	size = round_page (length);
+	size = round_page_64(length);
 	kret = vm_allocate(current_map(), &user_addr, size, TRUE);
 	if (kret != KERN_SUCCESS) 
 		goto out;
@@ -661,9 +664,9 @@ pshm_mmap(struct proc *p, struct mmap_args *uap, register_t *retval, struct file
 
 	if ((flags & MAP_FIXED) == 0) {
 		find_space = TRUE;
-		user_addr = round_page(user_addr); 
+		user_addr = round_page_32(user_addr); 
 	} else {
-		if (user_addr != trunc_page(user_addr))
+		if (user_addr != trunc_page_32(user_addr))
 			return (EINVAL);
 		find_space = FALSE;
 		(void) vm_deallocate(user_map, user_addr, user_size);
diff --git a/bsd/kern/preload.h b/bsd/kern/preload.h
index 7db056c43..f0be62518 100644
--- a/bsd/kern/preload.h
+++ b/bsd/kern/preload.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/kern/qsort.c b/bsd/kern/qsort.c
index d1505f175..d0424e501 100644
--- a/bsd/kern/qsort.c
+++ b/bsd/kern/qsort.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/kern/spl.c b/bsd/kern/spl.c
index 4ab15677d..9b0c38f06 100644
--- a/bsd/kern/spl.c
+++ b/bsd/kern/spl.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/kern/subr_log.c b/bsd/kern/subr_log.c
index 4a4a9a06a..6703f0c19 100644
--- a/bsd/kern/subr_log.c
+++ b/bsd/kern/subr_log.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/kern/subr_prf.c b/bsd/kern/subr_prf.c
index 68867e8ea..200115441 100644
--- a/bsd/kern/subr_prf.c
+++ b/bsd/kern/subr_prf.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/kern/subr_prof.c b/bsd/kern/subr_prof.c
index 2fcd135c7..4b84e1430 100644
--- a/bsd/kern/subr_prof.c
+++ b/bsd/kern/subr_prof.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/kern/subr_xxx.c b/bsd/kern/subr_xxx.c
index 503401a6c..fdf8a35ef 100644
--- a/bsd/kern/subr_xxx.c
+++ b/bsd/kern/subr_xxx.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/kern/sys_domain.c b/bsd/kern/sys_domain.c
index ab3f62847..1fc9ee12a 100644
--- a/bsd/kern/sys_domain.c
+++ b/bsd/kern/sys_domain.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  *
diff --git a/bsd/kern/sys_generic.c b/bsd/kern/sys_generic.c
index e02a30b86..eb721f871 100644
--- a/bsd/kern/sys_generic.c
+++ b/bsd/kern/sys_generic.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -124,7 +127,8 @@ holdfp(fdp, fd, flag)
 		(fp->f_flag & flag) == 0) {
 			return (NULL);
 	}
-	fref(fp);
+	if (fref(fp) == -1)
+		return (NULL);
 	return (fp);   
 }
 
diff --git a/bsd/kern/sys_socket.c b/bsd/kern/sys_socket.c
index c276ed036..a215a42bc 100644
--- a/bsd/kern/sys_socket.c
+++ b/bsd/kern/sys_socket.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/kern/syscalls.c b/bsd/kern/syscalls.c
index 27d915a0a..8c641bf49 100644
--- a/bsd/kern/syscalls.c
+++ b/bsd/kern/syscalls.c
@@ -1,21 +1,24 @@
 /*
- * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -125,7 +128,11 @@ char *syscallnames[] = {
 	"getpriority",		/* 100 = getpriority */
 	"old_send",			/* 101 = old send */
 	"old_recv",			/* 102 = old recv */
+#ifdef __ppc__
+	"osigreturn",		/* 103 = sigreturn */
+#else
 	"sigreturn",		/* 103 = sigreturn */
+#endif
 	"bind",				/* 104 = bind */
 	"setsockopt",		/* 105 = setsockopt */
 	"listen",			/* 106 = listen */
@@ -206,7 +213,11 @@ char *syscallnames[] = {
 	"setgid",			/* 181 = setgid */
 	"setegid",			/* 182 = setegid */
 	"seteuid",			/* 183 = seteuid */
+#ifdef __ppc__
+	"sigreturn",			/* 184 = sigreturn */
+#else
 	"#184",				/* 184 = nosys */
+#endif
 	"#185",				/* 185 = nosys */
 	"#186",				/* 186 = nosys */
 	"#187",				/* 187 = nosys */
diff --git a/bsd/kern/sysctl_init.c b/bsd/kern/sysctl_init.c
index 3b659c97e..af57f1457 100644
--- a/bsd/kern/sysctl_init.c
+++ b/bsd/kern/sysctl_init.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -38,6 +41,47 @@ extern struct sysctl_oid sysctl__debug_ttydebug;
 #endif
 #endif
 
+extern struct sysctl_oid sysctl__hw_machine;
+extern struct sysctl_oid sysctl__hw_model;
+extern struct sysctl_oid sysctl__hw_ncpu;
+extern struct sysctl_oid sysctl__hw_activecpu;
+extern struct sysctl_oid sysctl__hw_byteorder;
+extern struct sysctl_oid sysctl__hw_cputype;
+extern struct sysctl_oid sysctl__hw_cpusubtype;
+extern struct sysctl_oid sysctl__hw_physmem;
+extern struct sysctl_oid sysctl__hw_usermem;
+extern struct sysctl_oid sysctl__hw_pagesize;
+extern struct sysctl_oid sysctl__hw_epoch;
+extern struct sysctl_oid sysctl__hw_vectorunit;
+extern struct sysctl_oid sysctl__hw_busfrequency;
+extern struct sysctl_oid sysctl__hw_busfrequency_min;
+extern struct sysctl_oid sysctl__hw_busfrequency_max;
+extern struct sysctl_oid sysctl__hw_cpufrequency;
+extern struct sysctl_oid sysctl__hw_cpufrequency_min;
+extern struct sysctl_oid sysctl__hw_cpufrequency_max;
+extern struct sysctl_oid sysctl__hw_cachelinesize;
+extern struct sysctl_oid sysctl__hw_l1icachesize;
+extern struct sysctl_oid sysctl__hw_l1dcachesize;
+extern struct sysctl_oid sysctl__hw_l2settings;
+extern struct sysctl_oid sysctl__hw_l2cachesize;
+extern struct sysctl_oid sysctl__hw_l3settings;
+extern struct sysctl_oid sysctl__hw_l3cachesize;
+extern struct sysctl_oid sysctl__hw_tbfrequency;
+extern struct sysctl_oid sysctl__hw_memsize;
+
+extern struct sysctl_oid sysctl__hw_optional;
+extern struct sysctl_oid sysctl__hw_optional_floatingpoint;
+
+extern struct sysctl_oid sysctl__hw_pagesize_compat;
+extern struct sysctl_oid sysctl__hw_busfrequency_compat;
+extern struct sysctl_oid sysctl__hw_cpufrequency_compat;
+extern struct sysctl_oid sysctl__hw_cachelinesize_compat;
+extern struct sysctl_oid sysctl__hw_l1icachesize_compat;
+extern struct sysctl_oid sysctl__hw_l1dcachesize_compat;
+extern struct sysctl_oid sysctl__hw_l2cachesize_compat;
+extern struct sysctl_oid sysctl__hw_l3cachesize_compat;
+extern struct sysctl_oid sysctl__hw_tbfrequency_compat;
+
 extern struct sysctl_oid sysctl__kern_sysv_shmmax;
 extern struct sysctl_oid sysctl__kern_sysv_shmmin;
 extern struct sysctl_oid sysctl__kern_sysv_shmmni;
@@ -115,6 +159,7 @@ extern struct sysctl_oid sysctl__net_inet_tcp_keepintvl;
 extern struct sysctl_oid sysctl__net_inet_tcp_mssdflt;
 extern struct sysctl_oid sysctl__net_inet_tcp_recvspace;
 extern struct sysctl_oid sysctl__net_inet_tcp_sendspace;
+extern struct sysctl_oid sysctl__net_inet_tcp_slowlink_wsize;
 extern struct sysctl_oid sysctl__net_inet_tcp_blackhole;
 extern struct sysctl_oid sysctl__net_inet_tcp_tcp_lq_overflow;
 extern struct sysctl_oid sysctl__net_inet_tcp_path_mtu_discovery;
@@ -383,6 +428,47 @@ struct sysctl_oid *newsysctl_list[] =
     ,&sysctl__kern_ipc_somaxconn
     ,&sysctl__kern_ipc_sosendminchain
     ,&sysctl__kern_ipc_maxsockets
+
+    ,&sysctl__hw_machine
+    ,&sysctl__hw_model
+    ,&sysctl__hw_ncpu
+    ,&sysctl__hw_activecpu
+    ,&sysctl__hw_byteorder
+    ,&sysctl__hw_cputype
+    ,&sysctl__hw_cpusubtype
+    ,&sysctl__hw_physmem
+    ,&sysctl__hw_usermem
+    ,&sysctl__hw_pagesize
+    ,&sysctl__hw_epoch
+    ,&sysctl__hw_vectorunit
+    ,&sysctl__hw_busfrequency
+    ,&sysctl__hw_busfrequency_min
+    ,&sysctl__hw_busfrequency_max
+    ,&sysctl__hw_cpufrequency
+    ,&sysctl__hw_cpufrequency_min
+    ,&sysctl__hw_cpufrequency_max
+    ,&sysctl__hw_cachelinesize
+    ,&sysctl__hw_l1icachesize
+    ,&sysctl__hw_l1dcachesize
+    ,&sysctl__hw_l2settings
+    ,&sysctl__hw_l2cachesize
+    ,&sysctl__hw_l3settings
+    ,&sysctl__hw_l3cachesize
+    ,&sysctl__hw_tbfrequency
+    ,&sysctl__hw_memsize
+    ,&sysctl__hw_optional
+    ,&sysctl__hw_optional_floatingpoint
+
+    ,&sysctl__hw_pagesize_compat
+    ,&sysctl__hw_busfrequency_compat
+    ,&sysctl__hw_cpufrequency_compat
+    ,&sysctl__hw_cachelinesize_compat
+    ,&sysctl__hw_l1icachesize_compat
+    ,&sysctl__hw_l1dcachesize_compat
+    ,&sysctl__hw_l2cachesize_compat
+    ,&sysctl__hw_l3cachesize_compat
+    ,&sysctl__hw_tbfrequency_compat
+
     ,&sysctl__net_inet_icmp_icmplim
     ,&sysctl__net_inet_icmp_maskrepl
     ,&sysctl__net_inet_icmp_bmcastecho
@@ -442,6 +528,7 @@ struct sysctl_oid *newsysctl_list[] =
     ,&sysctl__net_inet_tcp_mssdflt
     ,&sysctl__net_inet_tcp_recvspace
     ,&sysctl__net_inet_tcp_sendspace
+    ,&sysctl__net_inet_tcp_slowlink_wsize
     ,&sysctl__net_inet_tcp_blackhole
     ,&sysctl__net_inet_tcp_tcp_lq_overflow
     ,&sysctl__net_inet_tcp_path_mtu_discovery
diff --git a/bsd/kern/sysv_ipc.c b/bsd/kern/sysv_ipc.c
index e39505b70..9b63e4fa1 100644
--- a/bsd/kern/sysv_ipc.c
+++ b/bsd/kern/sysv_ipc.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/kern/sysv_msg.c b/bsd/kern/sysv_msg.c
index dc3ca0a81..55080db24 100644
--- a/bsd/kern/sysv_msg.c
+++ b/bsd/kern/sysv_msg.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/kern/sysv_sem.c b/bsd/kern/sysv_sem.c
index 7061dadc1..7270428f8 100644
--- a/bsd/kern/sysv_sem.c
+++ b/bsd/kern/sysv_sem.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/kern/sysv_shm.c b/bsd/kern/sysv_shm.c
index c86c5d590..52ec26805 100644
--- a/bsd/kern/sysv_shm.c
+++ b/bsd/kern/sysv_shm.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -170,7 +173,7 @@ shm_deallocate_segment(shmseg)
 	char * ptr;
 
 	shm_handle = shmseg->shm_internal;
-	size = round_page(shmseg->shm_segsz);
+	size = round_page_32(shmseg->shm_segsz);
 	mach_destroy_memory_entry(shm_handle->shm_object);
 	FREE((caddr_t)shm_handle, M_SHM);
 	shmseg->shm_internal = NULL;
@@ -190,7 +193,7 @@ shm_delete_mapping(p, shmmap_s)
 
 	segnum = IPCID_TO_IX(shmmap_s->shmid);
 	shmseg = &shmsegs[segnum];
-	size = round_page(shmseg->shm_segsz);
+	size = round_page_32(shmseg->shm_segsz);
 	result = vm_deallocate(current_map(), shmmap_s->va, size);
 	if (result != KERN_SUCCESS)
 		return EINVAL;
@@ -279,7 +282,7 @@ shmat(p, uap, retval)
 	}
 	if (i >= shminfo.shmseg)
 		return EMFILE;
-	size = round_page(shmseg->shm_segsz);
+	size = round_page_32(shmseg->shm_segsz);
 	prot = VM_PROT_READ;
 	if ((uap->shmflg & SHM_RDONLY) == 0)
 		prot |= VM_PROT_WRITE;
@@ -293,7 +296,7 @@ shmat(p, uap, retval)
 		else
 			return EINVAL;
 	} else {
-		attach_va = round_page(uap->shmaddr);
+		attach_va = round_page_32((unsigned int)uap->shmaddr);
 	}
 
 	shm_handle = shmseg->shm_internal;
@@ -522,7 +525,7 @@ shmget_allocate_segment(p, uap, mode, retval)
 		return EINVAL;
 	if (shm_nused >= shminfo.shmmni) /* any shmids left? */
 		return ENOSPC;
-	size = round_page(uap->size);
+	size = round_page_32(uap->size);
 	if (shm_committed + btoc(size) > shminfo.shmall)
 		return ENOMEM;
 	if (shm_last_free < 0) {
diff --git a/bsd/kern/tty.c b/bsd/kern/tty.c
index dee8138ff..c03484cec 100644
--- a/bsd/kern/tty.c
+++ b/bsd/kern/tty.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/kern/tty_compat.c b/bsd/kern/tty_compat.c
index cf6e818b1..e8cfe55a2 100644
--- a/bsd/kern/tty_compat.c
+++ b/bsd/kern/tty_compat.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/kern/tty_conf.c b/bsd/kern/tty_conf.c
index bb4a8c9c0..69b0c5bfd 100644
--- a/bsd/kern/tty_conf.c
+++ b/bsd/kern/tty_conf.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/kern/tty_pty.c b/bsd/kern/tty_pty.c
index 43386b2a6..34dc94304 100644
--- a/bsd/kern/tty_pty.c
+++ b/bsd/kern/tty_pty.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/kern/tty_subr.c b/bsd/kern/tty_subr.c
index 9bc116f30..8e2bf4d9f 100644
--- a/bsd/kern/tty_subr.c
+++ b/bsd/kern/tty_subr.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/kern/tty_tb.c b/bsd/kern/tty_tb.c
index c04197e24..b52c16c03 100644
--- a/bsd/kern/tty_tb.c
+++ b/bsd/kern/tty_tb.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/kern/tty_tty.c b/bsd/kern/tty_tty.c
index 359d71096..608db3a28 100644
--- a/bsd/kern/tty_tty.c
+++ b/bsd/kern/tty_tty.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/kern/ubc_subr.c b/bsd/kern/ubc_subr.c
index 47cb041ab..d5154c5d8 100644
--- a/bsd/kern/ubc_subr.c
+++ b/bsd/kern/ubc_subr.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -587,6 +590,9 @@ ubc_getobject(struct vnode *vp, int flags)
 	if (UBCINVALID(vp))
 		return (0);
 
+	if (flags & UBC_FOR_PAGEOUT)
+	        return(vp->v_ubcinfo->ui_control);
+
 	if ((recursed = ubc_busy(vp)) == 0)
 		return (0);
 
@@ -1163,7 +1169,7 @@ ubc_page_op(
 	struct vnode 	*vp,
 	off_t		f_offset,
 	int		ops,
-	vm_offset_t	*phys_entryp,
+	ppnum_t	*phys_entryp,
 	int		*flagsp)
 {
 	memory_object_control_t		control;
@@ -1189,14 +1195,21 @@ ubc_create_upl(
 	int				uplflags)
 {
 	memory_object_control_t		control;
-	int							count;
-	off_t						file_offset;
-	kern_return_t				kr;
+	int				count;
+	int                             ubcflags;
+	off_t				file_offset;
+	kern_return_t			kr;
 	
 	if (bufsize & 0xfff)
 		return KERN_INVALID_ARGUMENT;
 
-	control = ubc_getobject(vp, UBC_FLAGS_NONE);
+	if (uplflags & UPL_FOR_PAGEOUT) {
+		uplflags &= ~UPL_FOR_PAGEOUT;
+	        ubcflags  =  UBC_FOR_PAGEOUT;
+	} else
+	        ubcflags = UBC_FLAGS_NONE;
+
+	control = ubc_getobject(vp, ubcflags);
 	if (control == MEMORY_OBJECT_CONTROL_NULL)
 		return KERN_INVALID_ARGUMENT;
 
diff --git a/bsd/kern/uipc_domain.c b/bsd/kern/uipc_domain.c
index efb0a3cd6..94912be8f 100644
--- a/bsd/kern/uipc_domain.c
+++ b/bsd/kern/uipc_domain.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/kern/uipc_mbuf.c b/bsd/kern/uipc_mbuf.c
index 0eed25410..5c6bc12ec 100644
--- a/bsd/kern/uipc_mbuf.c
+++ b/bsd/kern/uipc_mbuf.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -79,10 +82,14 @@
 #include <kern/kern_types.h>
 #include <kern/sched_prim.h>
 
+#include <IOKit/IOMapper.h>
+
 #define _MCLREF(p)       (++mclrefcnt[mtocl(p)])
 #define _MCLUNREF(p)     (--mclrefcnt[mtocl(p)] == 0)
 
-extern  kernel_pmap;    /* The kernel's pmap */
+extern pmap_t kernel_pmap;    /* The kernel's pmap */
+/* kernel translater */
+extern ppnum_t pmap_find_phys(pmap_t pmap, addr64_t va);
 
 decl_simple_lock_data(, mbuf_slock);
 struct mbuf 	*mfree;		/* mbuf free list */
@@ -92,6 +99,7 @@ int		m_want;		/* sleepers on mbufs */
 extern int	nmbclusters;	/* max number of mapped clusters */
 short		*mclrefcnt; 	/* mapped cluster reference counts */
 int             *mcl_paddr;
+static ppnum_t mcl_paddr_base;	/* Handle returned by IOMapper::iovmAlloc() */
 union mcluster 	*mclfree;	/* mapped cluster free list */
 int		max_linkhdr;	/* largest link-level header */
 int		max_protohdr;	/* largest protocol header */
@@ -165,10 +173,11 @@ mbinit()
 {
 	int s,m;
 	int initmcl = 32;
+        int mcl_pages;
 
 	if (nclpp)
 		return;
-	nclpp = round_page(MCLBYTES) / MCLBYTES;	/* see mbufgc() */
+	nclpp = round_page_32(MCLBYTES) / MCLBYTES;	/* see mbufgc() */
 	if (nclpp < 1) nclpp = 1;
 	MBUF_LOCKINIT();
 //	NETISR_LOCKINIT();
@@ -188,11 +197,14 @@ mbinit()
 	for (m = 0; m < nmbclusters; m++)
 		mclrefcnt[m] = -1;
 
-	MALLOC(mcl_paddr, int *, (nmbclusters/(PAGE_SIZE/CLBYTES)) * sizeof (int),
-					M_TEMP, M_WAITOK);
+        /* Calculate the number of pages assigned to the cluster pool */
+        mcl_pages = nmbclusters/(PAGE_SIZE/CLBYTES);
+	MALLOC(mcl_paddr, int *, mcl_pages * sizeof(int), M_TEMP, M_WAITOK);
 	if (mcl_paddr == 0)
 		panic("mbinit1");
-	bzero((char *)mcl_paddr, (nmbclusters/(PAGE_SIZE/CLBYTES)) * sizeof (int));
+        /* Register with the I/O Bus mapper */
+        mcl_paddr_base = IOMapperIOVMAlloc(mcl_pages);
+	bzero((char *)mcl_paddr, mcl_pages * sizeof(int));
 
 	embutl = (union mcluster *)((unsigned char *)mbutl + (nmbclusters * MCLBYTES));
 
@@ -233,11 +245,11 @@ m_clalloc(ncl, nowait)
 
 	if (ncl < i) 
 		ncl = i;
-	size = round_page(ncl * MCLBYTES);
+	size = round_page_32(ncl * MCLBYTES);
 	mcl = (union mcluster *)kmem_mb_alloc(mb_map, size);
 
 	if (mcl == 0 && ncl > 1) {
-		size = round_page(MCLBYTES); /* Try for 1 if failed */
+		size = round_page_32(MCLBYTES); /* Try for 1 if failed */
 		mcl = (union mcluster *)kmem_mb_alloc(mb_map, size);
 	}
 
@@ -247,8 +259,19 @@ m_clalloc(ncl, nowait)
 		for (i = 0; i < ncl; i++) {
 			if (++mclrefcnt[mtocl(mcl)] != 0)
 				panic("m_clalloc already there");
-			if (((int)mcl & PAGE_MASK) == 0)
-			        mcl_paddr[((char *)mcl - (char *)mbutl)/PAGE_SIZE] = pmap_extract(kernel_pmap, (char *)mcl);
+			if (((int)mcl & PAGE_MASK) == 0) {
+                                ppnum_t offset = ((char *)mcl - (char *)mbutl)/PAGE_SIZE;
+                                ppnum_t new_page = pmap_find_phys(kernel_pmap, (vm_address_t) mcl);
+
+                                /*
+                                 * In the case of no mapper being available
+                                 * the following code nops and returns the
+                                 * input page, if there is a mapper the I/O
+                                 * page appropriate is returned.
+                                 */
+                                new_page = IOMapperInsertPage(mcl_paddr_base, offset, new_page);
+			        mcl_paddr[offset] = new_page << 12;
+                        }
 
 			mcl->mcl_next = mclfree;
 			mclfree = mcl++;
diff --git a/bsd/kern/uipc_mbuf2.c b/bsd/kern/uipc_mbuf2.c
index 02b4f8f4b..cc6064fb0 100644
--- a/bsd/kern/uipc_mbuf2.c
+++ b/bsd/kern/uipc_mbuf2.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/kern/uipc_proto.c b/bsd/kern/uipc_proto.c
index 1d31b684a..1ae186343 100644
--- a/bsd/kern/uipc_proto.c
+++ b/bsd/kern/uipc_proto.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/kern/uipc_socket.c b/bsd/kern/uipc_socket.c
index 813dcf564..5572ca926 100644
--- a/bsd/kern/uipc_socket.c
+++ b/bsd/kern/uipc_socket.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/kern/uipc_socket2.c b/bsd/kern/uipc_socket2.c
index ae6a6cc9d..735acaf4c 100644
--- a/bsd/kern/uipc_socket2.c
+++ b/bsd/kern/uipc_socket2.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/kern/uipc_syscalls.c b/bsd/kern/uipc_syscalls.c
index 228d2d62a..7e73f9ff1 100644
--- a/bsd/kern/uipc_syscalls.c
+++ b/bsd/kern/uipc_syscalls.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/kern/uipc_usrreq.c b/bsd/kern/uipc_usrreq.c
index 905652bee..d8022230c 100644
--- a/bsd/kern/uipc_usrreq.c
+++ b/bsd/kern/uipc_usrreq.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/libkern/bcd.c b/bsd/libkern/bcd.c
index 02f3fde8b..2fd9ca185 100644
--- a/bsd/libkern/bcd.c
+++ b/bsd/libkern/bcd.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/libkern/bcmp.c b/bsd/libkern/bcmp.c
index e315fee7d..fc12cc186 100644
--- a/bsd/libkern/bcmp.c
+++ b/bsd/libkern/bcmp.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/libkern/inet_ntoa.c b/bsd/libkern/inet_ntoa.c
index 0925e8a3c..3cef4257d 100644
--- a/bsd/libkern/inet_ntoa.c
+++ b/bsd/libkern/inet_ntoa.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/libkern/libkern.h b/bsd/libkern/libkern.h
index 16c005525..03bb9d470 100644
--- a/bsd/libkern/libkern.h
+++ b/bsd/libkern/libkern.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/libkern/locc.c b/bsd/libkern/locc.c
index 29572e4ee..871ea09c3 100644
--- a/bsd/libkern/locc.c
+++ b/bsd/libkern/locc.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/libkern/random.c b/bsd/libkern/random.c
index 8a002af2c..85c22265b 100644
--- a/bsd/libkern/random.c
+++ b/bsd/libkern/random.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/libkern/rindex.c b/bsd/libkern/rindex.c
index a8d4044a0..d53735d42 100644
--- a/bsd/libkern/rindex.c
+++ b/bsd/libkern/rindex.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/libkern/scanc.c b/bsd/libkern/scanc.c
index 5be4e6f2f..0926a31b4 100644
--- a/bsd/libkern/scanc.c
+++ b/bsd/libkern/scanc.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/libkern/skpc.c b/bsd/libkern/skpc.c
index 68110e8a5..7e502bd3d 100644
--- a/bsd/libkern/skpc.c
+++ b/bsd/libkern/skpc.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/libkern/strtol.c b/bsd/libkern/strtol.c
index 440d7e587..8ef9aeffb 100644
--- a/bsd/libkern/strtol.c
+++ b/bsd/libkern/strtol.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/machine/ansi.h b/bsd/machine/ansi.h
index 8f34cdd79..4162f0e9e 100644
--- a/bsd/machine/ansi.h
+++ b/bsd/machine/ansi.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/machine/byte_order.h b/bsd/machine/byte_order.h
index c100caa6f..3cabac9f5 100644
--- a/bsd/machine/byte_order.h
+++ b/bsd/machine/byte_order.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/machine/cons.h b/bsd/machine/cons.h
index c68a4af46..b04e01d2e 100644
--- a/bsd/machine/cons.h
+++ b/bsd/machine/cons.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/machine/cpu.h b/bsd/machine/cpu.h
index 36ca09b25..53c9f1224 100644
--- a/bsd/machine/cpu.h
+++ b/bsd/machine/cpu.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/machine/disklabel.h b/bsd/machine/disklabel.h
index fed73e500..492731dd3 100644
--- a/bsd/machine/disklabel.h
+++ b/bsd/machine/disklabel.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/machine/endian.h b/bsd/machine/endian.h
index 4aa1ad8f4..3c2da9bbe 100644
--- a/bsd/machine/endian.h
+++ b/bsd/machine/endian.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/machine/exec.h b/bsd/machine/exec.h
index 979093289..de38ac74a 100644
--- a/bsd/machine/exec.h
+++ b/bsd/machine/exec.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/machine/label_t.h b/bsd/machine/label_t.h
index 094c204ac..4c0d966aa 100644
--- a/bsd/machine/label_t.h
+++ b/bsd/machine/label_t.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/machine/param.h b/bsd/machine/param.h
index 4ee6af0fd..b52d93e9e 100644
--- a/bsd/machine/param.h
+++ b/bsd/machine/param.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/machine/proc.h b/bsd/machine/proc.h
index 47a46df41..bf096995f 100644
--- a/bsd/machine/proc.h
+++ b/bsd/machine/proc.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/machine/profile.h b/bsd/machine/profile.h
index 94c316745..4c466cb00 100644
--- a/bsd/machine/profile.h
+++ b/bsd/machine/profile.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/machine/psl.h b/bsd/machine/psl.h
index e9763e864..e04c95016 100644
--- a/bsd/machine/psl.h
+++ b/bsd/machine/psl.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/machine/ptrace.h b/bsd/machine/ptrace.h
index f2abe2b6a..c592b07b6 100644
--- a/bsd/machine/ptrace.h
+++ b/bsd/machine/ptrace.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/machine/reboot.h b/bsd/machine/reboot.h
index 368fa0aad..7f2c9ad83 100644
--- a/bsd/machine/reboot.h
+++ b/bsd/machine/reboot.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/machine/reg.h b/bsd/machine/reg.h
index add5145e2..5625d60a7 100644
--- a/bsd/machine/reg.h
+++ b/bsd/machine/reg.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/machine/setjmp.h b/bsd/machine/setjmp.h
index c39a8ea77..810db580e 100644
--- a/bsd/machine/setjmp.h
+++ b/bsd/machine/setjmp.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/machine/signal.h b/bsd/machine/signal.h
index b7c7300f1..a4abaf398 100644
--- a/bsd/machine/signal.h
+++ b/bsd/machine/signal.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/machine/spl.h b/bsd/machine/spl.h
index 89d75fad5..0bc27a097 100644
--- a/bsd/machine/spl.h
+++ b/bsd/machine/spl.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/machine/table.h b/bsd/machine/table.h
index e71d1101c..77cab6a33 100644
--- a/bsd/machine/table.h
+++ b/bsd/machine/table.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/machine/trap.h b/bsd/machine/trap.h
index 6dd0fe1c7..66238013d 100644
--- a/bsd/machine/trap.h
+++ b/bsd/machine/trap.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/machine/types.h b/bsd/machine/types.h
index f5ade7c2f..f4c9dabb6 100644
--- a/bsd/machine/types.h
+++ b/bsd/machine/types.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/machine/ucontext.h b/bsd/machine/ucontext.h
index 56cf8137d..841eacda9 100644
--- a/bsd/machine/ucontext.h
+++ b/bsd/machine/ucontext.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/machine/unix_traps.h b/bsd/machine/unix_traps.h
index fc94186c8..aa0e26734 100644
--- a/bsd/machine/unix_traps.h
+++ b/bsd/machine/unix_traps.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/machine/user.h b/bsd/machine/user.h
index 4aaf1bbf0..8cab8fa00 100644
--- a/bsd/machine/user.h
+++ b/bsd/machine/user.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/machine/vmparam.h b/bsd/machine/vmparam.h
index d1375d280..0697581d5 100644
--- a/bsd/machine/vmparam.h
+++ b/bsd/machine/vmparam.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/miscfs/deadfs/dead_vnops.c b/bsd/miscfs/deadfs/dead_vnops.c
index aaca316c9..eb08dc1ab 100644
--- a/bsd/miscfs/deadfs/dead_vnops.c
+++ b/bsd/miscfs/deadfs/dead_vnops.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/miscfs/devfs/devfs.h b/bsd/miscfs/devfs/devfs.h
index c76d8544a..a896e0cf0 100644
--- a/bsd/miscfs/devfs/devfs.h
+++ b/bsd/miscfs/devfs/devfs.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/miscfs/devfs/devfs_proto.h b/bsd/miscfs/devfs/devfs_proto.h
index 3683d6b57..3703d3642 100644
--- a/bsd/miscfs/devfs/devfs_proto.h
+++ b/bsd/miscfs/devfs/devfs_proto.h
@@ -2,21 +2,24 @@
  * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
- *
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- *
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * 
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
- *
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ * 
  * @APPLE_LICENSE_HEADER_END@
  */
 /* THIS FILE HAS BEEN PRODUCED AUTOMATICALLY */
diff --git a/bsd/miscfs/devfs/devfs_tree.c b/bsd/miscfs/devfs/devfs_tree.c
index 9707f8a9c..b380cb3aa 100644
--- a/bsd/miscfs/devfs/devfs_tree.c
+++ b/bsd/miscfs/devfs/devfs_tree.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -745,6 +748,7 @@ devfs_remove(void *dirent_p)
 	devnode_t * dnp = ((devdirent_t *)dirent_p)->de_dnp;
 	devnode_t * dnp2;
 	boolean_t   funnel_state;
+	boolean_t   lastlink;
 
 	funnel_state = thread_funnel_set(kernel_flock, TRUE);
 
@@ -765,8 +769,11 @@ devfs_remove(void *dirent_p)
 		dnp->dn_nextsibling->dn_prevsiblingp = &(dnp->dn_nextsibling);
 		dnp2->dn_nextsibling = dnp2;
 		dnp2->dn_prevsiblingp = &(dnp2->dn_nextsibling);
-		while(dnp2->dn_linklist) {
-			dev_free_name(dnp2->dn_linklist);
+		if(dnp2->dn_linklist) {
+			do {
+				lastlink = (1 == dnp2->dn_links);
+				dev_free_name(dnp2->dn_linklist);
+			} while (!lastlink);
 		}
 	}
 
@@ -775,8 +782,11 @@ devfs_remove(void *dirent_p)
 	 * If we are not running in SPLIT_DEVS mode, then
 	 * THIS is what gets rid of the propogated nodes.
 	 */
-	while(dnp->dn_linklist) {
-		dev_free_name(dnp->dn_linklist);
+	if(dnp->dn_linklist) {
+		do {
+			lastlink = (1 == dnp->dn_links);
+			dev_free_name(dnp->dn_linklist);
+		} while (!lastlink);
 	}
 	DEVFS_UNLOCK(0);
 out:
diff --git a/bsd/miscfs/devfs/devfs_vfsops.c b/bsd/miscfs/devfs/devfs_vfsops.c
index 136dc458e..84cc758ae 100644
--- a/bsd/miscfs/devfs/devfs_vfsops.c
+++ b/bsd/miscfs/devfs/devfs_vfsops.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/miscfs/devfs/devfs_vnops.c b/bsd/miscfs/devfs/devfs_vnops.c
index 6c25d8044..5db06b9ce 100644
--- a/bsd/miscfs/devfs/devfs_vnops.c
+++ b/bsd/miscfs/devfs/devfs_vnops.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/miscfs/devfs/devfsdefs.h b/bsd/miscfs/devfs/devfsdefs.h
index e6f299f3d..118576cdc 100644
--- a/bsd/miscfs/devfs/devfsdefs.h
+++ b/bsd/miscfs/devfs/devfsdefs.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/miscfs/fdesc/fdesc.h b/bsd/miscfs/fdesc/fdesc.h
index a2c8ec310..6c14f2c75 100644
--- a/bsd/miscfs/fdesc/fdesc.h
+++ b/bsd/miscfs/fdesc/fdesc.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/miscfs/fdesc/fdesc_vfsops.c b/bsd/miscfs/fdesc/fdesc_vfsops.c
index 0afbec394..1d26b20e9 100644
--- a/bsd/miscfs/fdesc/fdesc_vfsops.c
+++ b/bsd/miscfs/fdesc/fdesc_vfsops.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/miscfs/fdesc/fdesc_vnops.c b/bsd/miscfs/fdesc/fdesc_vnops.c
index 0ad6d806e..466921d5b 100644
--- a/bsd/miscfs/fdesc/fdesc_vnops.c
+++ b/bsd/miscfs/fdesc/fdesc_vnops.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/miscfs/fifofs/fifo.h b/bsd/miscfs/fifofs/fifo.h
index 1d212b694..cbf2fa30b 100644
--- a/bsd/miscfs/fifofs/fifo.h
+++ b/bsd/miscfs/fifofs/fifo.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/miscfs/fifofs/fifo_vnops.c b/bsd/miscfs/fifofs/fifo_vnops.c
index 93c037e3d..446c8216b 100644
--- a/bsd/miscfs/fifofs/fifo_vnops.c
+++ b/bsd/miscfs/fifofs/fifo_vnops.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/miscfs/nullfs/null.h b/bsd/miscfs/nullfs/null.h
index a4ccc0e36..84e0fdf85 100644
--- a/bsd/miscfs/nullfs/null.h
+++ b/bsd/miscfs/nullfs/null.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/miscfs/nullfs/null_subr.c b/bsd/miscfs/nullfs/null_subr.c
index 133cdb932..47f2d3095 100644
--- a/bsd/miscfs/nullfs/null_subr.c
+++ b/bsd/miscfs/nullfs/null_subr.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/miscfs/nullfs/null_vfsops.c b/bsd/miscfs/nullfs/null_vfsops.c
index 66f61af3d..31aee4055 100644
--- a/bsd/miscfs/nullfs/null_vfsops.c
+++ b/bsd/miscfs/nullfs/null_vfsops.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/miscfs/nullfs/null_vnops.c b/bsd/miscfs/nullfs/null_vnops.c
index fecb1278a..0bb2b76e0 100644
--- a/bsd/miscfs/nullfs/null_vnops.c
+++ b/bsd/miscfs/nullfs/null_vnops.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/miscfs/specfs/spec_vnops.c b/bsd/miscfs/specfs/spec_vnops.c
index f44cd9323..d5efd260b 100644
--- a/bsd/miscfs/specfs/spec_vnops.c
+++ b/bsd/miscfs/specfs/spec_vnops.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/miscfs/specfs/specdev.h b/bsd/miscfs/specfs/specdev.h
index 6db592f44..bcaf8d9fd 100644
--- a/bsd/miscfs/specfs/specdev.h
+++ b/bsd/miscfs/specfs/specdev.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/miscfs/synthfs/synthfs.h b/bsd/miscfs/synthfs/synthfs.h
index 28a85f8b2..32b92db24 100644
--- a/bsd/miscfs/synthfs/synthfs.h
+++ b/bsd/miscfs/synthfs/synthfs.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/miscfs/synthfs/synthfs_util.c b/bsd/miscfs/synthfs/synthfs_util.c
index 814536547..a712ff879 100644
--- a/bsd/miscfs/synthfs/synthfs_util.c
+++ b/bsd/miscfs/synthfs/synthfs_util.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/miscfs/synthfs/synthfs_vfsops.c b/bsd/miscfs/synthfs/synthfs_vfsops.c
index 6d32cacb0..525a0a3ee 100644
--- a/bsd/miscfs/synthfs/synthfs_vfsops.c
+++ b/bsd/miscfs/synthfs/synthfs_vfsops.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/miscfs/synthfs/synthfs_vnops.c b/bsd/miscfs/synthfs/synthfs_vnops.c
index a009e147a..64afea17a 100644
--- a/bsd/miscfs/synthfs/synthfs_vnops.c
+++ b/bsd/miscfs/synthfs/synthfs_vnops.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/miscfs/union/union.h b/bsd/miscfs/union/union.h
index 147df4c7f..f7ee5f221 100644
--- a/bsd/miscfs/union/union.h
+++ b/bsd/miscfs/union/union.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/miscfs/union/union_subr.c b/bsd/miscfs/union/union_subr.c
index 8f5ce12ac..85c41ad1e 100644
--- a/bsd/miscfs/union/union_subr.c
+++ b/bsd/miscfs/union/union_subr.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/miscfs/union/union_vfsops.c b/bsd/miscfs/union/union_vfsops.c
index 2ddfa135b..06578a15a 100644
--- a/bsd/miscfs/union/union_vfsops.c
+++ b/bsd/miscfs/union/union_vfsops.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/miscfs/union/union_vnops.c b/bsd/miscfs/union/union_vnops.c
index df60cb8a6..e8a9f20a1 100644
--- a/bsd/miscfs/union/union_vnops.c
+++ b/bsd/miscfs/union/union_vnops.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/miscfs/volfs/volfs.h b/bsd/miscfs/volfs/volfs.h
index 92ea0b2ad..86d2aa74f 100644
--- a/bsd/miscfs/volfs/volfs.h
+++ b/bsd/miscfs/volfs/volfs.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/miscfs/volfs/volfs_vfsops.c b/bsd/miscfs/volfs/volfs_vfsops.c
index 096873b7f..b4aee57e5 100644
--- a/bsd/miscfs/volfs/volfs_vfsops.c
+++ b/bsd/miscfs/volfs/volfs_vfsops.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/miscfs/volfs/volfs_vnops.c b/bsd/miscfs/volfs/volfs_vnops.c
index 0f5c6ecb8..881614d21 100644
--- a/bsd/miscfs/volfs/volfs_vnops.c
+++ b/bsd/miscfs/volfs/volfs_vnops.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/bpf.c b/bsd/net/bpf.c
index 4c75819d5..9f99cabae 100644
--- a/bsd/net/bpf.c
+++ b/bsd/net/bpf.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/bpf.h b/bsd/net/bpf.h
index 6f3afea4d..8e611be77 100644
--- a/bsd/net/bpf.h
+++ b/bsd/net/bpf.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/bpf_compat.h b/bsd/net/bpf_compat.h
index ddec919d9..9897ce8ec 100644
--- a/bsd/net/bpf_compat.h
+++ b/bsd/net/bpf_compat.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/bpf_filter.c b/bsd/net/bpf_filter.c
index 102e3c492..8a8c5c19c 100644
--- a/bsd/net/bpf_filter.c
+++ b/bsd/net/bpf_filter.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/bpfdesc.h b/bsd/net/bpfdesc.h
index b8f80bb63..686be6c2d 100644
--- a/bsd/net/bpfdesc.h
+++ b/bsd/net/bpfdesc.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/bridge.c b/bsd/net/bridge.c
index 2f364dee5..1d6e46361 100644
--- a/bsd/net/bridge.c
+++ b/bsd/net/bridge.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/bridge.h b/bsd/net/bridge.h
index a9c6b277d..28a78c7b6 100644
--- a/bsd/net/bridge.h
+++ b/bsd/net/bridge.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/bsd_comp.c b/bsd/net/bsd_comp.c
index d81e66f93..825478370 100644
--- a/bsd/net/bsd_comp.c
+++ b/bsd/net/bsd_comp.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/dlil.c b/bsd/net/dlil.c
index a534c0852..88afe0401 100644
--- a/bsd/net/dlil.c
+++ b/bsd/net/dlil.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/dlil.h b/bsd/net/dlil.h
index 1727d78ff..5a34f2823 100644
--- a/bsd/net/dlil.h
+++ b/bsd/net/dlil.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/dlil_pvt.h b/bsd/net/dlil_pvt.h
index 91da52b03..c2594730a 100644
--- a/bsd/net/dlil_pvt.h
+++ b/bsd/net/dlil_pvt.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/ether_at_pr_module.c b/bsd/net/ether_at_pr_module.c
index d811b9c33..5cecfe47e 100644
--- a/bsd/net/ether_at_pr_module.c
+++ b/bsd/net/ether_at_pr_module.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/ether_if_module.c b/bsd/net/ether_if_module.c
index 27e9dd8b8..4710f419b 100644
--- a/bsd/net/ether_if_module.c
+++ b/bsd/net/ether_if_module.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -332,6 +335,24 @@ int ether_demux(ifp, m, frame_header, proto)
             m->m_flags |= M_BCAST;
         else
             m->m_flags |= M_MCAST;
+    } else {
+        /*
+         * When the driver is put into promiscuous mode we may receive unicast
+         * frames that are not intended for our interfaces.  They are filtered
+         * here to keep them from traveling further up the stack to code that
+         * is not expecting them or prepared to deal with them.  In the near
+         * future, the filtering done here will be moved even further down the
+         * stack into the IONetworkingFamily, preventing even interface
+         * filter NKE's from receiving promiscuous packets.  Please use BPF.
+         */
+        #define ETHER_CMP(x, y) ( ((u_int16_t *) x)[0] != ((u_int16_t *) y)[0] || \
+                                  ((u_int16_t *) x)[1] != ((u_int16_t *) y)[1] || \
+                                  ((u_int16_t *) x)[2] != ((u_int16_t *) y)[2] )
+    
+        if (ETHER_CMP(eh->ether_dhost, ((struct arpcom *) ifp)->ac_enaddr)) {
+            m_freem(m);
+            return EJUSTRETURN;
+        }
     }
     
     data = mtod(m, u_int8_t*);
diff --git a/bsd/net/ether_inet6_pr_module.c b/bsd/net/ether_inet6_pr_module.c
index 9764e8a97..65901c1eb 100644
--- a/bsd/net/ether_inet6_pr_module.c
+++ b/bsd/net/ether_inet6_pr_module.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/ether_inet_pr_module.c b/bsd/net/ether_inet_pr_module.c
index 59d7a8d49..f181de956 100644
--- a/bsd/net/ether_inet_pr_module.c
+++ b/bsd/net/ether_inet_pr_module.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/etherdefs.h b/bsd/net/etherdefs.h
index 6e577eb14..d321eb7bb 100644
--- a/bsd/net/etherdefs.h
+++ b/bsd/net/etherdefs.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/ethernet.h b/bsd/net/ethernet.h
index accdc05d0..86f3152b9 100644
--- a/bsd/net/ethernet.h
+++ b/bsd/net/ethernet.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/if.c b/bsd/net/if.c
index 17213f3db..1f10ed96f 100644
--- a/bsd/net/if.c
+++ b/bsd/net/if.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -1394,6 +1397,6 @@ void if_rtproto_del(struct ifnet *ifp, int protocol)
 	
         struct radix_node_head  *rnh;
 
-	if (((rnh = rt_tables[protocol]) != NULL) && (ifp != NULL)) 
+	if ((protocol <= AF_MAX) && ((rnh = rt_tables[protocol]) != NULL) && (ifp != NULL))
 		(void) rnh->rnh_walktree(rnh, if_rtdel, ifp);
 }
diff --git a/bsd/net/if.h b/bsd/net/if.h
index 793a9aa88..f572ff980 100644
--- a/bsd/net/if.h
+++ b/bsd/net/if.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -119,7 +122,7 @@
 #define IFEF_DVR_REENTRY_OK	0x20	/* When set, driver may be reentered from its own thread */
 #define IFEF_INUSE	0x40000000 /* DLIL ifnet recycler, ifnet in use */
 #define IFEF_REUSE	0x20000000 /* DLIL ifnet recycler, ifnet is not new */
-#endif KERNEL_PRIVATE
+#endif /* KERNEL_PRIVATE */
 
 
 /* flags set internally only: */
diff --git a/bsd/net/if_arp.h b/bsd/net/if_arp.h
index af389b6a5..9718e6291 100644
--- a/bsd/net/if_arp.h
+++ b/bsd/net/if_arp.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/if_atm.h b/bsd/net/if_atm.h
index b9d1420eb..cccc59b6d 100644
--- a/bsd/net/if_atm.h
+++ b/bsd/net/if_atm.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/if_disc.c b/bsd/net/if_disc.c
index c8c266bc4..b2cc2c053 100644
--- a/bsd/net/if_disc.c
+++ b/bsd/net/if_disc.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/if_dl.h b/bsd/net/if_dl.h
index 16201a909..8ff1d49a1 100644
--- a/bsd/net/if_dl.h
+++ b/bsd/net/if_dl.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/if_dummy.c b/bsd/net/if_dummy.c
index 50ce06568..7079e75d5 100644
--- a/bsd/net/if_dummy.c
+++ b/bsd/net/if_dummy.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/if_ethersubr.c b/bsd/net/if_ethersubr.c
index 892d07158..7e6c57d76 100644
--- a/bsd/net/if_ethersubr.c
+++ b/bsd/net/if_ethersubr.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/if_faith.c b/bsd/net/if_faith.c
index 9c9d4ebe7..feed430a3 100644
--- a/bsd/net/if_faith.c
+++ b/bsd/net/if_faith.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/if_fddisubr.c b/bsd/net/if_fddisubr.c
index dd1ef3a32..2b0498da7 100644
--- a/bsd/net/if_fddisubr.c
+++ b/bsd/net/if_fddisubr.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/if_gif.c b/bsd/net/if_gif.c
index 6ada7aa5e..b8b75f002 100644
--- a/bsd/net/if_gif.c
+++ b/bsd/net/if_gif.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/if_gif.h b/bsd/net/if_gif.h
index a74b84a4e..a41683a5e 100644
--- a/bsd/net/if_gif.h
+++ b/bsd/net/if_gif.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/if_llc.h b/bsd/net/if_llc.h
index 8f077d367..16b8b3ef9 100644
--- a/bsd/net/if_llc.h
+++ b/bsd/net/if_llc.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/if_loop.c b/bsd/net/if_loop.c
index 6c90a9cca..ca5e52385 100644
--- a/bsd/net/if_loop.c
+++ b/bsd/net/if_loop.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/if_media.c b/bsd/net/if_media.c
index ed5ec87ab..249f394e1 100644
--- a/bsd/net/if_media.c
+++ b/bsd/net/if_media.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/if_media.h b/bsd/net/if_media.h
index f17ed30fa..e0cc044fa 100644
--- a/bsd/net/if_media.h
+++ b/bsd/net/if_media.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/if_mib.c b/bsd/net/if_mib.c
index fc94438fe..483d739fb 100644
--- a/bsd/net/if_mib.c
+++ b/bsd/net/if_mib.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/if_mib.h b/bsd/net/if_mib.h
index dc7417e89..9ccd0c316 100644
--- a/bsd/net/if_mib.h
+++ b/bsd/net/if_mib.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/if_ppp.h b/bsd/net/if_ppp.h
index 9d5f7cd36..214c79784 100644
--- a/bsd/net/if_ppp.h
+++ b/bsd/net/if_ppp.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/if_pppvar.h b/bsd/net/if_pppvar.h
index ec688a95b..d7a6ee6ad 100644
--- a/bsd/net/if_pppvar.h
+++ b/bsd/net/if_pppvar.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/if_slvar.h b/bsd/net/if_slvar.h
index cb3132ef1..fcc06b056 100644
--- a/bsd/net/if_slvar.h
+++ b/bsd/net/if_slvar.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/if_sppp.h b/bsd/net/if_sppp.h
index f0b6435bc..597945542 100644
--- a/bsd/net/if_sppp.h
+++ b/bsd/net/if_sppp.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/if_tun.c b/bsd/net/if_tun.c
index 8ed3afd27..9fad082c3 100644
--- a/bsd/net/if_tun.c
+++ b/bsd/net/if_tun.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/if_tun.h b/bsd/net/if_tun.h
index 23731386f..e04bbe362 100644
--- a/bsd/net/if_tun.h
+++ b/bsd/net/if_tun.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/if_tunvar.h b/bsd/net/if_tunvar.h
index 9b93e0867..1f834c306 100644
--- a/bsd/net/if_tunvar.h
+++ b/bsd/net/if_tunvar.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/if_types.h b/bsd/net/if_types.h
index befa53907..c780dcf73 100644
--- a/bsd/net/if_types.h
+++ b/bsd/net/if_types.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/if_var.h b/bsd/net/if_var.h
index 3209d2b07..2c69ea514 100644
--- a/bsd/net/if_var.h
+++ b/bsd/net/if_var.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/if_vlan.c b/bsd/net/if_vlan.c
index 2bc498376..1ca909292 100644
--- a/bsd/net/if_vlan.c
+++ b/bsd/net/if_vlan.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/if_vlan_var.h b/bsd/net/if_vlan_var.h
index 6fe422d45..338d6ef87 100644
--- a/bsd/net/if_vlan_var.h
+++ b/bsd/net/if_vlan_var.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/kext_net.c b/bsd/net/kext_net.c
index fe79fa1c5..e360fd7d4 100644
--- a/bsd/net/kext_net.c
+++ b/bsd/net/kext_net.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/kext_net.h b/bsd/net/kext_net.h
index ebe88e6c3..dc134d2f1 100644
--- a/bsd/net/kext_net.h
+++ b/bsd/net/kext_net.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/ndrv.c b/bsd/net/ndrv.c
index 8c65a8faa..4707ef7c5 100644
--- a/bsd/net/ndrv.c
+++ b/bsd/net/ndrv.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/ndrv.h b/bsd/net/ndrv.h
index 0824dafca..d8c9a4928 100644
--- a/bsd/net/ndrv.h
+++ b/bsd/net/ndrv.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/ndrv_var.h b/bsd/net/ndrv_var.h
index 74f8aaf2b..dd00bbeb2 100644
--- a/bsd/net/ndrv_var.h
+++ b/bsd/net/ndrv_var.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/net_osdep.c b/bsd/net/net_osdep.c
index 8d2f62168..11835f8c4 100644
--- a/bsd/net/net_osdep.c
+++ b/bsd/net/net_osdep.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/net_osdep.h b/bsd/net/net_osdep.h
index e350606ac..df43e22e3 100644
--- a/bsd/net/net_osdep.h
+++ b/bsd/net/net_osdep.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/netisr.c b/bsd/net/netisr.c
index 2ae5be8eb..cb5d3d84d 100644
--- a/bsd/net/netisr.c
+++ b/bsd/net/netisr.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/netisr.h b/bsd/net/netisr.h
index 8f4e03ba8..47b4b349b 100644
--- a/bsd/net/netisr.h
+++ b/bsd/net/netisr.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/pfkeyv2.h b/bsd/net/pfkeyv2.h
index 4b9ec8d8c..14d610ea6 100644
--- a/bsd/net/pfkeyv2.h
+++ b/bsd/net/pfkeyv2.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/ppp_comp.h b/bsd/net/ppp_comp.h
index 475e85e67..4423a6b8b 100644
--- a/bsd/net/ppp_comp.h
+++ b/bsd/net/ppp_comp.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/ppp_deflate.c b/bsd/net/ppp_deflate.c
index 7d28a5b41..d05231e03 100644
--- a/bsd/net/ppp_deflate.c
+++ b/bsd/net/ppp_deflate.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/ppp_defs.h b/bsd/net/ppp_defs.h
index 416aa9ede..e07ea776f 100644
--- a/bsd/net/ppp_defs.h
+++ b/bsd/net/ppp_defs.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/radix.c b/bsd/net/radix.c
index cfe854974..1fb667e17 100644
--- a/bsd/net/radix.c
+++ b/bsd/net/radix.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/radix.h b/bsd/net/radix.h
index 833e9f714..1f0ccf517 100644
--- a/bsd/net/radix.h
+++ b/bsd/net/radix.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/raw_cb.c b/bsd/net/raw_cb.c
index 105ef13c8..b844434ff 100644
--- a/bsd/net/raw_cb.c
+++ b/bsd/net/raw_cb.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/raw_cb.h b/bsd/net/raw_cb.h
index d047ae38f..10082327c 100644
--- a/bsd/net/raw_cb.h
+++ b/bsd/net/raw_cb.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/raw_usrreq.c b/bsd/net/raw_usrreq.c
index 5e8a246a9..217d0c6d2 100644
--- a/bsd/net/raw_usrreq.c
+++ b/bsd/net/raw_usrreq.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/route.c b/bsd/net/route.c
index 5cebf16f6..ea463b5ef 100644
--- a/bsd/net/route.c
+++ b/bsd/net/route.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/route.h b/bsd/net/route.h
index cd5060001..8c887994c 100644
--- a/bsd/net/route.h
+++ b/bsd/net/route.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/rtsock.c b/bsd/net/rtsock.c
index 5a8dbbe7a..ae49c24c5 100644
--- a/bsd/net/rtsock.c
+++ b/bsd/net/rtsock.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/rtsock_mip.c b/bsd/net/rtsock_mip.c
index 6a6662206..eccfc1dd6 100644
--- a/bsd/net/rtsock_mip.c
+++ b/bsd/net/rtsock_mip.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/slcompress.c b/bsd/net/slcompress.c
index 47108b410..aa8f53f40 100644
--- a/bsd/net/slcompress.c
+++ b/bsd/net/slcompress.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/slcompress.h b/bsd/net/slcompress.h
index b784ad8db..8cea51dda 100644
--- a/bsd/net/slcompress.h
+++ b/bsd/net/slcompress.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/slip.h b/bsd/net/slip.h
index 7a8c06c66..acb6273f8 100644
--- a/bsd/net/slip.h
+++ b/bsd/net/slip.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/net/zlib.c b/bsd/net/zlib.c
index 948f9298d..5d0935e67 100644
--- a/bsd/net/zlib.c
+++ b/bsd/net/zlib.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/adsp.c b/bsd/netat/adsp.c
index 02d01c963..056255a65 100644
--- a/bsd/netat/adsp.c
+++ b/bsd/netat/adsp.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/adsp.h b/bsd/netat/adsp.h
index 9da7c99c0..bd044d6c1 100644
--- a/bsd/netat/adsp.h
+++ b/bsd/netat/adsp.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -473,7 +476,7 @@ typedef struct {
 } DDP_FRAME;
 
 #define DDPS_FRAME_LEN     5
-#endif NOT_USED
+#endif /* NOT_USED */
 
 typedef struct {
   ua_short   ddpx_length;            /* length and hop count        */
@@ -591,7 +594,7 @@ typedef struct
    u_char  ResponderLink;
    u_char  data[1];
 } RESPONDER_FRAME;
-#endif NOT_USED
+#endif /* NOT_USED */
 
 /*
  * ADSP Frame
diff --git a/bsd/netat/adsp_CLDeny.c b/bsd/netat/adsp_CLDeny.c
index 9d6a9b7e7..8addcbfc8 100644
--- a/bsd/netat/adsp_CLDeny.c
+++ b/bsd/netat/adsp_CLDeny.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/adsp_CLListen.c b/bsd/netat/adsp_CLListen.c
index f4f33f25d..04ad111e8 100644
--- a/bsd/netat/adsp_CLListen.c
+++ b/bsd/netat/adsp_CLListen.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/adsp_Close.c b/bsd/netat/adsp_Close.c
index d7e276e70..d2e9bbb75 100644
--- a/bsd/netat/adsp_Close.c
+++ b/bsd/netat/adsp_Close.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/adsp_Control.c b/bsd/netat/adsp_Control.c
index 69221b4fb..598df1417 100644
--- a/bsd/netat/adsp_Control.c
+++ b/bsd/netat/adsp_Control.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/adsp_Init.c b/bsd/netat/adsp_Init.c
index b6ab21997..8be1c25a5 100644
--- a/bsd/netat/adsp_Init.c
+++ b/bsd/netat/adsp_Init.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/adsp_InitGlobals.c b/bsd/netat/adsp_InitGlobals.c
index e15b0b74b..d3ee093fc 100644
--- a/bsd/netat/adsp_InitGlobals.c
+++ b/bsd/netat/adsp_InitGlobals.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/adsp_NewCID.c b/bsd/netat/adsp_NewCID.c
index 0e15ee0a8..998d9ffdc 100644
--- a/bsd/netat/adsp_NewCID.c
+++ b/bsd/netat/adsp_NewCID.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/adsp_Open.c b/bsd/netat/adsp_Open.c
index d73e2ee94..244164204 100644
--- a/bsd/netat/adsp_Open.c
+++ b/bsd/netat/adsp_Open.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/adsp_Options.c b/bsd/netat/adsp_Options.c
index 5e302bcaa..f2d263456 100644
--- a/bsd/netat/adsp_Options.c
+++ b/bsd/netat/adsp_Options.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/adsp_Packet.c b/bsd/netat/adsp_Packet.c
index 2b9a8f0ff..67c52d0aa 100644
--- a/bsd/netat/adsp_Packet.c
+++ b/bsd/netat/adsp_Packet.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/adsp_Read.c b/bsd/netat/adsp_Read.c
index fba5e4191..5cd49bfbf 100644
--- a/bsd/netat/adsp_Read.c
+++ b/bsd/netat/adsp_Read.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/adsp_RxAttn.c b/bsd/netat/adsp_RxAttn.c
index 8f62c8c1a..0da1ec0d5 100644
--- a/bsd/netat/adsp_RxAttn.c
+++ b/bsd/netat/adsp_RxAttn.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/adsp_RxData.c b/bsd/netat/adsp_RxData.c
index 94d7f64d9..96280bb61 100644
--- a/bsd/netat/adsp_RxData.c
+++ b/bsd/netat/adsp_RxData.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/adsp_Status.c b/bsd/netat/adsp_Status.c
index 46880508b..0b49fda3f 100644
--- a/bsd/netat/adsp_Status.c
+++ b/bsd/netat/adsp_Status.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/adsp_Timer.c b/bsd/netat/adsp_Timer.c
index fe092e0b1..f84909360 100644
--- a/bsd/netat/adsp_Timer.c
+++ b/bsd/netat/adsp_Timer.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/adsp_TimerElem.c b/bsd/netat/adsp_TimerElem.c
index d7f61ac14..1da85f127 100644
--- a/bsd/netat/adsp_TimerElem.c
+++ b/bsd/netat/adsp_TimerElem.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/adsp_Write.c b/bsd/netat/adsp_Write.c
index 9a170cf50..d71e24c29 100644
--- a/bsd/netat/adsp_Write.c
+++ b/bsd/netat/adsp_Write.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/adsp_attention.c b/bsd/netat/adsp_attention.c
index 18ce61f65..80e52686d 100644
--- a/bsd/netat/adsp_attention.c
+++ b/bsd/netat/adsp_attention.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/adsp_internal.h b/bsd/netat/adsp_internal.h
index 268cbe068..ec42e4b9c 100644
--- a/bsd/netat/adsp_internal.h
+++ b/bsd/netat/adsp_internal.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/adsp_misc.c b/bsd/netat/adsp_misc.c
index 8ee925709..7a6c1f5f3 100644
--- a/bsd/netat/adsp_misc.c
+++ b/bsd/netat/adsp_misc.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/adsp_reset.c b/bsd/netat/adsp_reset.c
index bcb738907..b8e8e4293 100644
--- a/bsd/netat/adsp_reset.c
+++ b/bsd/netat/adsp_reset.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/adsp_stream.c b/bsd/netat/adsp_stream.c
index 13811b3a8..2eea18fd4 100644
--- a/bsd/netat/adsp_stream.c
+++ b/bsd/netat/adsp_stream.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/appletalk.h b/bsd/netat/appletalk.h
index 7fbc4e38e..d6e0c2e1b 100644
--- a/bsd/netat/appletalk.h
+++ b/bsd/netat/appletalk.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/asp.h b/bsd/netat/asp.h
index a18a74d85..99cdc5536 100644
--- a/bsd/netat/asp.h
+++ b/bsd/netat/asp.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/asp_proto.c b/bsd/netat/asp_proto.c
index c495412de..f9e0cb956 100644
--- a/bsd/netat/asp_proto.c
+++ b/bsd/netat/asp_proto.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -1912,8 +1915,8 @@ asp_putnext(gref, mproto)
 
 int ASPputmsg(gref_t *gref, strbuf_t *ctlptr, strbuf_t *datptr, gbuf_t *mreq, int flags, int *errp)
 {
-    int s, i, err, len;
-    gbuf_t *mioc, *mdata, *mx;
+    int s, i, err, len, offset, remain, size, copy_len;
+    gbuf_t *mioc, *mdata, *mx, *m0;
     ioc_t *iocbp;
     strbuf_t ctlbuf;
     strbuf_t datbuf;
@@ -1927,6 +1930,7 @@ int ASPputmsg(gref_t *gref, strbuf_t *ctlptr, strbuf_t *datptr, gbuf_t *mreq, in
     asp_word_t *awp;
     union asp_primitives *primitives;
     unsigned short tid;
+    caddr_t		dataptr;
     
     if ((scb = (asp_scb_t *)gref->info) == 0) {
 		dPrintf(D_M_ASP, D_L_ERROR,
@@ -1988,46 +1992,77 @@ int ASPputmsg(gref_t *gref, strbuf_t *ctlptr, strbuf_t *datptr, gbuf_t *mreq, in
 		("ASPputmsg: %s\n", aspCmdStr(Primitive)));
 
     /*
-     * allocate buffer and copy in the data content
+     * copy in the data content into multiple mbuf clusters if
+     * required.  ATP now expects reply data to be placed in
+     * standard clusters, not the large external clusters that
+     * were used previously.
      */
-    len = (Primitive == ASPFUNC_CmdReply) ? 0 : aspCMDsize;
+         
+    /* set offset for use by some commands */
+    offset = (Primitive == ASPFUNC_CmdReply) ? 0 : aspCMDsize;
+	size = 0;
+    if (mreq != NULL) {
+        /* The data from the in-kernel call for use by AFP is passed
+         * in as one large external cluster.  This needs to be copied
+         * to a chain of standard clusters.
+         */
+        remain = gbuf_len(mreq);
+        dataptr = mtod(mreq, caddr_t);
+    } else {
+    	/* copyin from user space */
+    	remain = datbuf.len; 
+    	dataptr = (caddr_t)datbuf.buf;  
+    }	
     
-    if (!(mdata = gbuf_alloc_wait(datbuf.len+len, TRUE))) {
+    /* allocate first buffer */
+    if (!(mdata = gbuf_alloc_wait((remain + offset > MCLBYTES ? MCLBYTES : remain + offset), TRUE))) {
         /* error return should not be possible */
         err = ENOBUFS;
         gbuf_freem(mioc);
         goto l_err;
     }
-    gbuf_wset(mdata, (datbuf.len+len));
+    gbuf_wset(mdata, 0);		/* init length to zero */
     gbuf_cont(mioc) = mdata;
-    
-    if (mreq != NULL) {
-        /* being called from kernel space */
-        gbuf_t *tmp = mreq;
-        unsigned long offset = 0;
-        
-        /* copy afp cmd data from the passed in mbufs to mdata.  I cant
-        chain mreq to mdata since the rest of this code assumes
-        just one big mbuf with space in front for the BDS */
-        offset = len;
-        while (tmp != NULL) {
-            bcopy (gbuf_rptr(tmp), (gbuf_rptr(mdata) + offset), gbuf_len(tmp));
-            offset += gbuf_len(tmp);
-            tmp = gbuf_cont(tmp);           /* on to next mbuf in chain */
-        }
-        
-        /* all data copied out of mreq so free it */
-        gbuf_freem(mreq);
-    } else {
-        /* being called from user space */
-        if ((err = copyin((caddr_t)datbuf.buf,
-                  (caddr_t)(gbuf_rptr(mdata)+len), datbuf.len)) != 0) {
-            gbuf_freem(mioc);
-            goto l_err;
-        }
-    }
 
-    switch (Primitive) {
+	while (remain) {
+		if (remain + offset > MCLBYTES)
+			copy_len = MCLBYTES - offset;
+		else
+			copy_len = remain;
+		remain -= copy_len;
+		if (mreq != NULL)
+			bcopy (dataptr, (gbuf_rptr(mdata) + offset), copy_len);
+		else if ((err = copyin(dataptr, (caddr_t)(gbuf_rptr(mdata) + offset), copy_len)) != 0) {
+			gbuf_freem(mioc);
+			goto l_err;
+		}
+		gbuf_wset(mdata, (copy_len + offset));
+		size += copy_len + offset;
+		dataptr += copy_len;
+		offset = 0;
+		if (remain) {
+			/* allocate the next mbuf */
+			if ((gbuf_cont(mdata) = m_get((M_WAIT), MSG_DATA)) == 0) {
+				err = ENOBUFS;
+				gbuf_freem(mioc);
+				goto l_err;
+			}
+			mdata = gbuf_cont(mdata);
+			MCLGET(mdata, M_WAIT);
+			if (!(mdata->m_flags & M_EXT)) {
+				err = ENOBUFS;
+				gbuf_freem(mioc);
+				goto l_err;
+			}
+		}
+	}
+	mdata = gbuf_cont(mioc);			/* code further on down expects this to b e set */
+	mdata->m_pkthdr.len = size;			/* set packet hdr len */
+
+	if (mreq != 0)
+		gbuf_freem(mreq);
+
+   	switch (Primitive) {
 
     case ASPFUNC_Command:
     case ASPFUNC_Write:
@@ -2144,16 +2179,20 @@ int ASPputmsg(gref_t *gref, strbuf_t *ctlptr, strbuf_t *datptr, gbuf_t *mreq, in
             atp->xo = 1;
             atp->xo_relt = 1;
         }
+        /* setup the atpBDS struct - only the length field is used,
+         * except for the first one which contains the bds count in
+         * bdsDataSz.
+         */
         atpBDS = (struct atpBDS *)gbuf_wptr(mioc);
         msize = mdata ? gbuf_msgsize(mdata) : 0;
-       for (nbds=0; (nbds < ATP_TRESP_MAX) && (msize > 0); nbds++) {
+       	for (nbds=0; (nbds < ATP_TRESP_MAX) && (msize > 0); nbds++) {
             len = msize < ATP_DATA_SIZE ? msize : ATP_DATA_SIZE;
             msize -= ATP_DATA_SIZE;
             *(long *)atpBDS[nbds].bdsUserData = 0;
             UAL_ASSIGN(atpBDS[nbds].bdsBuffAddr, 1);
             UAS_ASSIGN(atpBDS[nbds].bdsBuffSz, len);
         }
-        UAS_ASSIGN(atpBDS[0].bdsDataSz, nbds);
+       	UAS_ASSIGN(atpBDS[0].bdsDataSz, nbds);
         *(long *)atpBDS[0].bdsUserData = (long)result;
         *(long *)atp->user_bytes = (long)result;
         gbuf_winc(mioc,atpBDSsize);
diff --git a/bsd/netat/at.c b/bsd/netat/at.c
index 089fd3889..c333d15bc 100644
--- a/bsd/netat/at.c
+++ b/bsd/netat/at.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/at_aarp.h b/bsd/netat/at_aarp.h
index c7fd53524..3f8bc1754 100644
--- a/bsd/netat/at_aarp.h
+++ b/bsd/netat/at_aarp.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/at_config.h b/bsd/netat/at_config.h
index b9f6abef3..0db48f512 100644
--- a/bsd/netat/at_config.h
+++ b/bsd/netat/at_config.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/at_ddp_brt.h b/bsd/netat/at_ddp_brt.h
index 0b40c9893..d656851c4 100644
--- a/bsd/netat/at_ddp_brt.h
+++ b/bsd/netat/at_ddp_brt.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/at_pat.h b/bsd/netat/at_pat.h
index 107b3857d..5c4e707d5 100644
--- a/bsd/netat/at_pat.h
+++ b/bsd/netat/at_pat.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/at_pcb.c b/bsd/netat/at_pcb.c
index 7c120650e..de172f33b 100644
--- a/bsd/netat/at_pcb.c
+++ b/bsd/netat/at_pcb.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/at_pcb.h b/bsd/netat/at_pcb.h
index 9a4d4297a..bc4e32554 100644
--- a/bsd/netat/at_pcb.h
+++ b/bsd/netat/at_pcb.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/at_proto.c b/bsd/netat/at_proto.c
index 3a8cb6055..016a603e2 100644
--- a/bsd/netat/at_proto.c
+++ b/bsd/netat/at_proto.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/at_snmp.h b/bsd/netat/at_snmp.h
index 5e4bcb09e..fcfd083cc 100644
--- a/bsd/netat/at_snmp.h
+++ b/bsd/netat/at_snmp.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/at_var.h b/bsd/netat/at_var.h
index 40c0fe696..943ee75da 100644
--- a/bsd/netat/at_var.h
+++ b/bsd/netat/at_var.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/atp.h b/bsd/netat/atp.h
index 6eb0af457..00de460c5 100644
--- a/bsd/netat/atp.h
+++ b/bsd/netat/atp.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/atp_alloc.c b/bsd/netat/atp_alloc.c
index 98ebd3d46..ef41fc928 100644
--- a/bsd/netat/atp_alloc.c
+++ b/bsd/netat/atp_alloc.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/atp_misc.c b/bsd/netat/atp_misc.c
index f8d34a439..1878d68b2 100644
--- a/bsd/netat/atp_misc.c
+++ b/bsd/netat/atp_misc.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/atp_open.c b/bsd/netat/atp_open.c
index 5271592ab..c0fdc869c 100644
--- a/bsd/netat/atp_open.c
+++ b/bsd/netat/atp_open.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/atp_read.c b/bsd/netat/atp_read.c
index 12f93ee1c..5013d2a3f 100644
--- a/bsd/netat/atp_read.c
+++ b/bsd/netat/atp_read.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/atp_write.c b/bsd/netat/atp_write.c
index 4fea05d13..1c3e4df3f 100644
--- a/bsd/netat/atp_write.c
+++ b/bsd/netat/atp_write.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -452,11 +455,11 @@ void atp_send_replies(atp, rcbp)
      register struct atp_rcb   *rcbp;
 {       register gbuf_t *m;
 	register int     i, len;
-	int              s_gen, s, cnt;
+	int              s_gen, s, cnt, err, offset, space;
 	unsigned char *m0_rptr = NULL, *m0_wptr = NULL;
 	register at_atp_t *athp;
 	register struct atpBDS *bdsp;
-	register gbuf_t *m2, *m1, *m0, *m3;
+	register gbuf_t *m2, *m1, *m0, *mhdr;
 	caddr_t lastPage;
 	gbuf_t *mprev, *mlist = 0;
 	at_socket src_socket = (at_socket)atp->atp_socket_no;
@@ -494,109 +497,67 @@ void atp_send_replies(atp, rcbp)
 
 	m = rcbp->rc_xmt;
 	m0 = gbuf_cont(m);
-	if (m0) {
-		m0_rptr = gbuf_rptr(m0);
-		m0_wptr = gbuf_wptr(m0);
-	}
 	if (gbuf_len(m) > TOTAL_ATP_HDR_SIZE)
 	  	bdsp = (struct atpBDS *)(AT_ATP_HDR(m)->data);
 	else
 		bdsp = 0;
-
+	offset = 0;
+	if (m0)
+		space = gbuf_msgsize(m0);
 	for (i = 0; i < cnt; i++) {
-	  if (rcbp->rc_snd[i] == 0) {
-		if ((len = UAS_VALUE(bdsp->bdsBuffSz)))
-			gbuf_rinc(m0,len);
-
-	  } else {
-	        m2 = rc_xmt[i];
-		gbuf_rinc(m2,AT_WR_OFFSET);
-		gbuf_wset(m2,TOTAL_ATP_HDR_SIZE);
-		*(struct ddp_atp *)(gbuf_rptr(m2))= *(struct ddp_atp *)(gbuf_rptr(m));
-		athp = AT_ATP_HDR(m2);
-		ATP_CLEAR_CONTROL(athp);
-		athp->cmd = ATP_CMD_TRESP;
-		athp->bitmap = i;
-		if (i == (cnt - 1))
-		        athp->eom = 1; /* for the last fragment */
-		if (bdsp)
-		  	UAL_UAL(athp->user_bytes, bdsp->bdsUserData);
-
-		if (bdsp)
-		  if (len = UAS_VALUE(bdsp->bdsBuffSz)) { /* copy in data */
-		    if (m0 && gbuf_len(m0)) {
-		      if ((m1 = gbuf_dupb(m0)) == NULL) {
-				for (i = 0; i < cnt; i++)
-					if (rc_xmt[i])
-						gbuf_freem(rc_xmt[i]);
-				gbuf_rptr(m0) = m0_rptr;
-				gbuf_wset(m0,(m0_wptr-m0_rptr));
-				goto nothing_to_send;
+		if (rcbp->rc_snd[i] == 0) {
+			if ((len = UAS_VALUE(bdsp->bdsBuffSz))) {
+				offset += len;
+				space -= len;
 			}
-			gbuf_wset(m1,len);
-			gbuf_rinc(m0,len);
-			if ((len = gbuf_len(m0)) < 0) {
-				gbuf_rdec(m0,len);
-				gbuf_wdec(m1,len);
-				if (!append_copy((struct mbuf *)m1, 
-						 (struct mbuf *)gbuf_cont(m0), FALSE)) {
-				  for (i = 0; i < cnt; i++)
-					if (rc_xmt[i])
-						gbuf_freem(rc_xmt[i]);
-				  gbuf_rptr(m0) = m0_rptr;
-				  gbuf_wset(m0,(m0_wptr-m0_rptr));
-				  goto nothing_to_send;
+		} else {
+			mhdr = rc_xmt[i];
+			/* setup header fields */
+			gbuf_rinc(mhdr,AT_WR_OFFSET);
+			gbuf_wset(mhdr,TOTAL_ATP_HDR_SIZE);
+			*(struct ddp_atp *)(gbuf_rptr(mhdr))= *(struct ddp_atp *)(gbuf_rptr(m));
+			athp = AT_ATP_HDR(mhdr);
+			ATP_CLEAR_CONTROL(athp);
+			athp->cmd = ATP_CMD_TRESP;
+			athp->bitmap = i;
+			if (i == (cnt - 1))
+				athp->eom = 1; /* for the last fragment */
+			if (bdsp) {
+				UAL_UAL(athp->user_bytes, bdsp->bdsUserData);
+				if ((len = UAS_VALUE(bdsp->bdsBuffSz)) && m0 != 0 && space > 0) {
+					if ((m1 = m_copym(m0, offset, len, M_DONTWAIT)) == 0) {
+						for (i = 0; i < cnt; i++)
+							if (rc_xmt[i])
+								gbuf_freem(rc_xmt[i]);
+						goto nothing_to_send;
+					}
+					offset += len;
+					space -= len;
+					gbuf_cont(mhdr) = m1;
 				}
-			} else
-				gbuf_cont(m1) = 0;
-			gbuf_cont(m2) = m1;
+			}	
 				
-			/* temp fix for page boundary problem  - bug# 2703163 */
-			lastPage = (caddr_t)((int)(gbuf_wptr(m1) - 1) & ~PAGE_MASK);  			/* 4k page of last byte */
-			if (lastPage != (caddr_t)((int)(gbuf_rptr(m1)) & ~PAGE_MASK)) {			/* 1st byte and last on same page ? */
-				if ((m3 = gbuf_dupb(m1)) == NULL) {
-					for (i = 0; i < cnt; i++)
-						if (rc_xmt[i])
-							gbuf_freem(rc_xmt[i]);
-					(gbuf_rptr(m0)) = m0_rptr;
-					gbuf_wset(m0, (m0_wptr - m0_rptr));
-					goto nothing_to_send;
-				}
-				(gbuf_rptr(m3)) = lastPage;						/* new mbuf starts at beginning of page */
-				gbuf_wset(m3, (gbuf_wptr(m1) - lastPage));		/* len = remaining data crossing over page boundary */
-				gbuf_wset(m1, (lastPage - (gbuf_rptr(m1))));	/* adjust len of m1 */
-				(gbuf_cont(m1)) = m3;
-				(gbuf_cont(m3)) = 0;
-			}
-		  }
+			AT_DDP_HDR(mhdr)->src_socket = src_socket;
+			dPrintf(D_M_ATP_LOW, D_L_OUTPUT,
+				("atp_send_replies: %d, socket=%d, size=%d\n",
+				i, atp->atp_socket_no, gbuf_msgsize(gbuf_cont(m2))));
+	
+			if (mlist)
+				gbuf_next(mprev) = mhdr;
+			else
+				mlist = mhdr;
+			mprev = mhdr;
+	
+			rcbp->rc_snd[i] = 0;
+			rcbp->rc_not_sent_bitmap &= ~atp_mask[i];
+			if (rcbp->rc_not_sent_bitmap == 0)
+				break;
 		}
-
-	  AT_DDP_HDR(m2)->src_socket = src_socket;
-	  dPrintf(D_M_ATP_LOW, D_L_OUTPUT,
-		("atp_send_replies: %d, socket=%d, size=%d\n",
-		i, atp->atp_socket_no, gbuf_msgsize(gbuf_cont(m2))));
-
-	  if (mlist)
-	  	gbuf_next(mprev) = m2;
-	  else
-	  	mlist = m2;
-	  mprev = m2;
-
-	  rcbp->rc_snd[i] = 0;
-	  rcbp->rc_not_sent_bitmap &= ~atp_mask[i];
-	  if (rcbp->rc_not_sent_bitmap == 0)
-	  	break;
-	  }
-	  /*
-	   * on to the next frag
-	   */
-	  bdsp++;
+	  	/*
+	   	 * on to the next frag
+	   	 */
+	  	bdsp++;
 	}
-	if (m0) {
-		gbuf_rptr(m0) = m0_rptr;
-		gbuf_wset(m0,(m0_wptr-m0_rptr));
-	}
-
 	if (mlist) {
 		ATENABLE(s, atp->atp_lock);
 		DDP_OUTPUT(mlist);
@@ -703,6 +664,11 @@ atp_pack_bdsp(trp, bdsp)
 } /* atp_pack_bdsp */
 
 
+/* create an mbuf chain with mbuf packet headers for each ATP response packet
+ * to be sent.  m contains the DDP hdr, ATP hdr, and and array of atpBDS structs.  
+ * chained to m is an mbuf that contians the actual data pointed to by the atpBDS
+ * structs.
+ */
 static int
 atp_unpack_bdsp(atp, m, rcbp, cnt, wait)
 	struct atp_state *atp;
@@ -711,17 +677,19 @@ atp_unpack_bdsp(atp, m, rcbp, cnt, wait)
     register int    cnt, wait;
 {
 	register struct atpBDS *bdsp;
-	register gbuf_t        *m2, *m1, *m0, *m3;
-	caddr_t lastPage;
-        register at_atp_t        *athp;
-	register int  i, len, s_gen;
-	at_socket src_socket;
-	struct   ddp_atp {
+	register	 gbuf_t        *m2, *m1, *m0, *mhdr;
+	caddr_t 	lastPage;
+    at_atp_t    *athp;
+	int  		i, len, s_gen;
+	at_socket 	src_socket;
+	
+	struct ddp_atp {
 	         char    ddp_atp_hdr[TOTAL_ATP_HDR_SIZE];
 	};
-	gbuf_t *mprev, *mlist = 0;
-	gbuf_t *rc_xmt[ATP_TRESP_MAX];
-	unsigned char *m0_rptr, *m0_wptr;
+	gbuf_t 			*mprev, *mlist = 0;
+	gbuf_t 			*rc_xmt[ATP_TRESP_MAX];
+	unsigned char 	*m0_rptr, *m0_wptr;
+	int				err, offset, space;
 
 	/*
 	 * get the user data structure pointer
@@ -787,101 +755,70 @@ atp_unpack_bdsp(atp, m, rcbp, cnt, wait)
 		goto l_send;
 	}
 
+	/* create an array of mbuf packet headers for the packets to be sent
+	 * to contain the atp and ddp headers with room at the front for the
+	 * datalink header.
+	 */
 	for (i = 0; i < cnt; i++) {
 	        /* all hdrs, packet data and dst addr storage */
 		if ((rc_xmt[i] = 
-		     gbuf_alloc_wait(AT_WR_OFFSET+TOTAL_ATP_HDR_SIZE,
-				     wait)) == NULL) {
-			for (cnt = 0; cnt < i; cnt++)
-				if (rc_xmt[cnt])
-					gbuf_freeb(rc_xmt[cnt]);
-			return 0;
+		     gbuf_alloc_wait(AT_WR_OFFSET+TOTAL_ATP_HDR_SIZE, wait)) == NULL) {
+				for (cnt = 0; cnt < i; cnt++)
+					if (rc_xmt[cnt])
+						gbuf_freeb(rc_xmt[cnt]);
+				return 0;
 		}
 	}
-	if (m0) {
-	  	m0_rptr = gbuf_rptr(m0);
-		m0_wptr = gbuf_wptr(m0);
-	}
 
-	for (i = 0; i < cnt; i++) {
-	        m2 = rc_xmt[i];
-		gbuf_rinc(m2,AT_WR_OFFSET);
-		gbuf_wset(m2,TOTAL_ATP_HDR_SIZE);
-		*(struct ddp_atp *)(gbuf_rptr(m2))= *(struct ddp_atp *)(gbuf_rptr(m));
-		athp = AT_ATP_HDR(m2);
+	/* run through the atpBDS structs and create an mbuf for the data
+	 * portion of each packet to be sent.  these get chained to the mbufs
+	 * containing the ATP and DDP headers.  this code assumes that no ATP
+	 * packet is contained in more than 2 mbufs (e.i crosses mbuf boundary
+	 * no more than one time).
+	 */
+	offset = 0;
+	if (m0)
+		space = gbuf_msgsize(m0);
+	for (i = 0; i < cnt; i++) {			/* for each hdr mbuf */
+	    mhdr = rc_xmt[i];
+	    /* setup header fields */
+		gbuf_rinc(mhdr,AT_WR_OFFSET);
+		gbuf_wset(mhdr,TOTAL_ATP_HDR_SIZE);
+		*(struct ddp_atp *)(gbuf_rptr(mhdr))= *(struct ddp_atp *)(gbuf_rptr(m));
+		athp = AT_ATP_HDR(mhdr);
 		ATP_CLEAR_CONTROL(athp);
 		athp->cmd = ATP_CMD_TRESP;
 		athp->bitmap = i;
 		if (i == (cnt - 1))
 			athp->eom = 1; /* for the last fragment */
 		UAL_UAL(athp->user_bytes, bdsp->bdsUserData);
-
-		if ((len = UAS_VALUE(bdsp->bdsBuffSz))) { /* copy in data */
-		  if (m0 && gbuf_len(m0)) {
-		  	if ((m1 = gbuf_dupb_wait(m0, wait)) == NULL) {
+		
+		if ((len = UAS_VALUE(bdsp->bdsBuffSz)) != 0  && m0 != 0 && space > 0) {		
+			if ((m1 = m_copym(m0, offset, len, wait)) == 0) {
 				for (i = 0; i < cnt; i++)
 					if (rc_xmt[i])
 						gbuf_freem(rc_xmt[i]);
-				gbuf_rptr(m0) = m0_rptr;
-				gbuf_wset(m0,(m0_wptr-m0_rptr));
 				return 0;
 			}
-			gbuf_wset(m1,len); /* *** m1 is first len bytes of m0? *** */
-			gbuf_rinc(m0,len);
-			if ((len = gbuf_len(m0)) < 0) {
-				gbuf_rdec(m0,len);
-				gbuf_wdec(m1,len);
-				if (!append_copy((struct mbuf *)m1, 
-						 (struct mbuf *)gbuf_cont(m0), wait)) {
-				  for (i = 0; i < cnt; i++)
-				    	if (rc_xmt[i])
-						gbuf_freem(rc_xmt[i]);
-				  gbuf_rptr(m0) = m0_rptr;
-				  gbuf_wset(m0,(m0_wptr-m0_rptr));
-				  return 0;
-				}
-			} else
-				gbuf_cont(m1) = 0;
-			gbuf_cont(m2) = m1;
-			
-			/* temp fix for page boundary problem  - bug# 2703163 */
-			lastPage = (caddr_t)((int)(gbuf_wptr(m1) - 1) & ~PAGE_MASK);  			/* 4k page of last byte */
-			if (lastPage != (caddr_t)((int)(gbuf_rptr(m1)) & ~PAGE_MASK)) {			/* 1st byte and last on same page ? */
-				if ((m3 = gbuf_dupb_wait(m1, wait)) == NULL) {
-					for (i = 0; i < cnt; i++)
-						if (rc_xmt[i])
-							gbuf_freem(rc_xmt[i]);
-					(gbuf_rptr(m0)) = m0_rptr;
-					gbuf_wset(m0, (m0_wptr - m0_rptr));
-					return 0;
-				}
-				(gbuf_rptr(m3)) = lastPage;						/* new mbuf starts at beginning of page */
-				gbuf_wset(m3, (gbuf_wptr(m1) - lastPage));		/* len = remaining data crossing over page boundary */
-				gbuf_wset(m1, (lastPage - (gbuf_rptr(m1))));		/* adjust len of m1 */
-				(gbuf_cont(m1)) = m3;
-				(gbuf_cont(m3)) = 0;
-			}
-		  }
+			gbuf_cont(mhdr) = m1;
+			space -= len;
+			offset += len;
 		}
-
-		AT_DDP_HDR(m2)->src_socket = src_socket;
+				
+		AT_DDP_HDR(mhdr)->src_socket = src_socket;
 		dPrintf(D_M_ATP_LOW,D_L_INFO,
 			("atp_unpack_bdsp %d, socket=%d, size=%d, cnt=%d\n",
-			i,atp->atp_socket_no,gbuf_msgsize(gbuf_cont(m2)),cnt));
+			i,atp->atp_socket_no,gbuf_msgsize(gbuf_cont(mhdr)),cnt));
 		if (mlist)
-			gbuf_next(mprev) = m2;
+			gbuf_next(mprev) = mhdr;
 		else
-			mlist = m2;
-		mprev = m2;
+			mlist = mhdr;
+		mprev = mhdr;
 		/*
 		 * on to the next frag
 		 */
 		bdsp++;
 	}
-	if (m0) {
-	  	gbuf_rptr(m0) = m0_rptr;
-		gbuf_wset(m0,(m0_wptr-m0_rptr));
-	}
 	/*
 	 * send the message
 	 */
@@ -898,6 +835,7 @@ l_send:
 
 	DDP_OUTPUT(mlist);
 	return 0;
+
 } /* atp_unpack_bdsp */
 
 #define ATP_SOCKET_LAST  (DDP_SOCKET_LAST-6)
@@ -1680,6 +1618,14 @@ _ATPsndreq(fd, buf, len, nowait, err, proc)
 	return (int)tid;
 } /* _ATPsndreq */
 
+
+/* 	entry point for ATP send response.  respbuf contains a DDP hdr,
+ *	ATP hdr, and atpBDS array.  The bdsDataSz field of the first atpBDS
+ *	struct contains the number of atpBDS structs in the array. resplen
+ *	contains the len of the data in respbuf and datalen contains the
+ * 	len of the data buffer holding the response packets which the atpBDS
+ *	struct entries point to.
+ */
 int
 _ATPsndrsp(fd, respbuff, resplen, datalen, err, proc)
 	int fd;
@@ -1689,15 +1635,18 @@ _ATPsndrsp(fd, respbuff, resplen, datalen, err, proc)
 	int *err;
 	void *proc;
 {
-	gref_t *gref;
-	int s, rc;
-	long bufaddr;
-	gbuf_t *m, *mdata;
-	register short len;
-	register int size;
-	register struct atp_state *atp;
-	register struct atpBDS *bdsp;
-	register char *buf;
+	gref_t 		*gref;
+	int 		s, rc;
+	long 		bufaddr;
+	gbuf_t 		*m, *mdata;
+	short 		space;
+	int 		size;
+	struct atp_state *atp;
+	struct atpBDS *bdsp;
+	u_int16_t	*bufsz;
+	char 		*buf;
+	int			bds_cnt, count, len;
+	caddr_t		dataptr;
 
 	if ((*err = atalk_getref(0, fd, &gref, proc)) != 0)
 		return -1;
@@ -1725,33 +1674,68 @@ _ATPsndrsp(fd, respbuff, resplen, datalen, err, proc)
 	gbuf_wset(m,resplen);
 	((at_ddp_t *)gbuf_rptr(m))->src_node = 0;
 	bdsp = (struct atpBDS *)(gbuf_rptr(m) + TOTAL_ATP_HDR_SIZE);
-	if ((resplen == TOTAL_ATP_HDR_SIZE) || ((len = UAS_VALUE(bdsp->bdsDataSz)) == 1))
-		len = 0;
-	else
-		len = 16 * sizeof(gbuf_t);
 
 	/*
-	 * allocate buffer and copy in the response data
+	 * allocate buffers and copy in the response data.
+	 * note that only the size field of the atpBDS field
+	 * is used internally in the kernel.
 	 */
-	if ((mdata = gbuf_alloc_wait(datalen+len, TRUE)) == 0) {
-	        gbuf_freem(m);
+	bds_cnt = get_bds_entries(m);		/* count of # entries */
+	/* check correctness of parameters */
+	if (bds_cnt > ATP_TRESP_MAX) {
+	    gbuf_freem(m);
+		*err = EINVAL;
+		return -1;
+	}
+	
+	for (size = 0, count = 0; count < bds_cnt; count++) {
+		size += UAS_VALUE(bdsp[count].bdsBuffSz);
+	}
+	if (size > datalen) {				
+	    gbuf_freem(m);
+		*err = EINVAL;
+		return -1;
+	}
+	
+	/* get the first mbuf */
+	if ((mdata = gbuf_alloc_wait((space = (size > MCLBYTES ? MCLBYTES : size)), TRUE)) == 0) {
+	    gbuf_freem(m);
 		*err = ENOMEM;
 		return -1;
 	}
 	gbuf_cont(m) = mdata;
-	for (size=0; bdsp < (struct atpBDS *)gbuf_wptr(m); bdsp++) {
-		if ((bufaddr = UAL_VALUE(bdsp->bdsBuffAddr)) != 0) {
-			len = UAS_VALUE(bdsp->bdsBuffSz);
-			buf = (char *)bufaddr;
-			if ((*err = copyin((caddr_t)buf,
-					(caddr_t)&gbuf_rptr(mdata)[size], len)) != 0) {
+	dataptr = mtod(mdata, caddr_t);
+	for (count = 0; count < bds_cnt; bdsp++, count++) {
+		if ((bufaddr = UAL_VALUE(bdsp->bdsBuffAddr)) != 0 && 
+				(len = UAS_VALUE(bdsp->bdsBuffSz)) != 0) {
+			if (len > space) {											/* enough room ? */
+				gbuf_wset(mdata, dataptr - mtod(mdata, caddr_t)); 		/* set len of last mbuf */
+				/* allocate the next mbuf */
+				if ((gbuf_cont(mdata) = m_get((M_WAIT), MSG_DATA)) == 0) {
+					gbuf_freem(m);
+					*err = ENOMEM;
+					return -1;
+				}
+				mdata = gbuf_cont(mdata);	
+				MCLGET(mdata, M_WAIT);
+				if (!(mdata->m_flags & M_EXT)) {
+					m_freem(m);
+					return(NULL);
+				}
+				dataptr = mtod(mdata, caddr_t);
+				space = MCLBYTES;
+			}
+			/* do the copyin */
+			if ((*err = copyin((caddr_t)bufaddr, dataptr, len)) != 0) {
 				gbuf_freem(m);
 				return -1;
 			}
-			size += len;
+			dataptr += len;
+			space -= len;
 		}
 	}
-	gbuf_wset(mdata,size);
+	gbuf_wset(mdata, dataptr - mtod(mdata, caddr_t)); 		/* set len of last mbuf */
+	gbuf_cont(m)->m_pkthdr.len = size;						/* set packet hdr len */
 
 	atp_send_rsp(gref, m, TRUE);
 	return 0;
diff --git a/bsd/netat/aurp.h b/bsd/netat/aurp.h
index 9bc832279..df08f3def 100644
--- a/bsd/netat/aurp.h
+++ b/bsd/netat/aurp.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/aurp_aurpd.c b/bsd/netat/aurp_aurpd.c
index 870403244..02a387be2 100644
--- a/bsd/netat/aurp_aurpd.c
+++ b/bsd/netat/aurp_aurpd.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/aurp_cfg.c b/bsd/netat/aurp_cfg.c
index bc7de2587..3cc415f0e 100644
--- a/bsd/netat/aurp_cfg.c
+++ b/bsd/netat/aurp_cfg.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/aurp_gdata.c b/bsd/netat/aurp_gdata.c
index fa15fbcf4..8a070c427 100644
--- a/bsd/netat/aurp_gdata.c
+++ b/bsd/netat/aurp_gdata.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/aurp_misc.c b/bsd/netat/aurp_misc.c
index 662499730..73b38e284 100644
--- a/bsd/netat/aurp_misc.c
+++ b/bsd/netat/aurp_misc.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/aurp_open.c b/bsd/netat/aurp_open.c
index 948ccda85..4bda301fd 100644
--- a/bsd/netat/aurp_open.c
+++ b/bsd/netat/aurp_open.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/aurp_rd.c b/bsd/netat/aurp_rd.c
index 1140a2bf3..13a532699 100644
--- a/bsd/netat/aurp_rd.c
+++ b/bsd/netat/aurp_rd.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/aurp_ri.c b/bsd/netat/aurp_ri.c
index b0a492ca6..9d64f0a35 100644
--- a/bsd/netat/aurp_ri.c
+++ b/bsd/netat/aurp_ri.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/aurp_rx.c b/bsd/netat/aurp_rx.c
index 5d5c43a3a..0e5405b3d 100644
--- a/bsd/netat/aurp_rx.c
+++ b/bsd/netat/aurp_rx.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/aurp_tickle.c b/bsd/netat/aurp_tickle.c
index ce8772d0f..10d9debf0 100644
--- a/bsd/netat/aurp_tickle.c
+++ b/bsd/netat/aurp_tickle.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/aurp_tx.c b/bsd/netat/aurp_tx.c
index c6c4ce658..a2e3d64ab 100644
--- a/bsd/netat/aurp_tx.c
+++ b/bsd/netat/aurp_tx.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/aurp_zi.c b/bsd/netat/aurp_zi.c
index 33d051d03..cf4aa830a 100644
--- a/bsd/netat/aurp_zi.c
+++ b/bsd/netat/aurp_zi.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/ddp.c b/bsd/netat/ddp.c
index 93da77ebf..d9d669763 100644
--- a/bsd/netat/ddp.c
+++ b/bsd/netat/ddp.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/ddp.h b/bsd/netat/ddp.h
index ad79d612b..d02c3e34f 100644
--- a/bsd/netat/ddp.h
+++ b/bsd/netat/ddp.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/ddp_aarp.c b/bsd/netat/ddp_aarp.c
index 430432ea6..cbb18fc4d 100644
--- a/bsd/netat/ddp_aarp.c
+++ b/bsd/netat/ddp_aarp.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/ddp_aep.c b/bsd/netat/ddp_aep.c
index 77e78451e..86ec871ec 100644
--- a/bsd/netat/ddp_aep.c
+++ b/bsd/netat/ddp_aep.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/ddp_brt.c b/bsd/netat/ddp_brt.c
index 22f0d103d..961d535e4 100644
--- a/bsd/netat/ddp_brt.c
+++ b/bsd/netat/ddp_brt.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/ddp_lap.c b/bsd/netat/ddp_lap.c
index 2cdddeb8d..8418e61af 100644
--- a/bsd/netat/ddp_lap.c
+++ b/bsd/netat/ddp_lap.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/ddp_nbp.c b/bsd/netat/ddp_nbp.c
index 1bfec9e17..f1452676d 100644
--- a/bsd/netat/ddp_nbp.c
+++ b/bsd/netat/ddp_nbp.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/ddp_proto.c b/bsd/netat/ddp_proto.c
index 7a6298a4d..7504e4874 100644
--- a/bsd/netat/ddp_proto.c
+++ b/bsd/netat/ddp_proto.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/ddp_r_rtmp.c b/bsd/netat/ddp_r_rtmp.c
index 666a59998..a239df24b 100644
--- a/bsd/netat/ddp_r_rtmp.c
+++ b/bsd/netat/ddp_r_rtmp.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/ddp_r_zip.c b/bsd/netat/ddp_r_zip.c
index 12d6aee82..1169c8f40 100644
--- a/bsd/netat/ddp_r_zip.c
+++ b/bsd/netat/ddp_r_zip.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/ddp_rtmp.c b/bsd/netat/ddp_rtmp.c
index c1b40b63e..489870e2e 100644
--- a/bsd/netat/ddp_rtmp.c
+++ b/bsd/netat/ddp_rtmp.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/ddp_rtmptable.c b/bsd/netat/ddp_rtmptable.c
index aaefa9ae8..cd1bfd49b 100644
--- a/bsd/netat/ddp_rtmptable.c
+++ b/bsd/netat/ddp_rtmptable.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/ddp_sip.c b/bsd/netat/ddp_sip.c
index 766eabace..bbaf35d93 100644
--- a/bsd/netat/ddp_sip.c
+++ b/bsd/netat/ddp_sip.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/ddp_usrreq.c b/bsd/netat/ddp_usrreq.c
index 7d327ab60..215a72510 100644
--- a/bsd/netat/ddp_usrreq.c
+++ b/bsd/netat/ddp_usrreq.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/debug.h b/bsd/netat/debug.h
index 34c8517f5..84070755d 100644
--- a/bsd/netat/debug.h
+++ b/bsd/netat/debug.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/drv_dep.c b/bsd/netat/drv_dep.c
index 64ecd48be..8cb5e1483 100644
--- a/bsd/netat/drv_dep.c
+++ b/bsd/netat/drv_dep.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/ep.h b/bsd/netat/ep.h
index 2f46f707b..47405c959 100644
--- a/bsd/netat/ep.h
+++ b/bsd/netat/ep.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/lap.h b/bsd/netat/lap.h
index aec11df28..cffc56a02 100644
--- a/bsd/netat/lap.h
+++ b/bsd/netat/lap.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/nbp.h b/bsd/netat/nbp.h
index 8c77bed8b..0996ff069 100644
--- a/bsd/netat/nbp.h
+++ b/bsd/netat/nbp.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/pap.h b/bsd/netat/pap.h
index 6abed58d8..1686a79ea 100644
--- a/bsd/netat/pap.h
+++ b/bsd/netat/pap.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/routing_tables.h b/bsd/netat/routing_tables.h
index 5376ab6a7..29f2a74b9 100644
--- a/bsd/netat/routing_tables.h
+++ b/bsd/netat/routing_tables.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/rtmp.h b/bsd/netat/rtmp.h
index 8f7365b21..a878976ef 100644
--- a/bsd/netat/rtmp.h
+++ b/bsd/netat/rtmp.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/sys_dep.c b/bsd/netat/sys_dep.c
index a5d17dc84..c522f9ccb 100644
--- a/bsd/netat/sys_dep.c
+++ b/bsd/netat/sys_dep.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -321,7 +324,8 @@ struct proc *proc;
 	       return EBADF;
 	  }
      }
-     if ((*grefp = (gref_t *)fp->f_data) == 0) {
+     *grefp = (gref_t *)fp->f_data;
+     if (*grefp == 0 || *grefp == (gref_t *)(-1)) {
 	  thread_funnel_switch(KERNEL_FUNNEL, NETWORK_FUNNEL);
 	  return EBADF;
      }
diff --git a/bsd/netat/sys_glue.c b/bsd/netat/sys_glue.c
index b546b7c2f..c8a0f1149 100644
--- a/bsd/netat/sys_glue.c
+++ b/bsd/netat/sys_glue.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/sysglue.h b/bsd/netat/sysglue.h
index 62afbde1f..0c7d82bb9 100644
--- a/bsd/netat/sysglue.h
+++ b/bsd/netat/sysglue.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netat/zip.h b/bsd/netat/zip.h
index 457c246cb..80d163657 100644
--- a/bsd/netat/zip.h
+++ b/bsd/netat/zip.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netinet/bootp.h b/bsd/netinet/bootp.h
index 4de5d87cd..0dee811ba 100644
--- a/bsd/netinet/bootp.h
+++ b/bsd/netinet/bootp.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netinet/dhcp.h b/bsd/netinet/dhcp.h
index 6ce2c61c7..f9ea9bdbc 100644
--- a/bsd/netinet/dhcp.h
+++ b/bsd/netinet/dhcp.h
@@ -8,19 +8,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -83,4 +86,4 @@ typedef int32_t			dhcp_lease_t;     /* relative time */
 
 #define DHCP_FLAGS_BROADCAST	((u_short)0x0001)
 
-#endif _NETINET_DHCP_H
+#endif /* _NETINET_DHCP_H */
diff --git a/bsd/netinet/dhcp_options.h b/bsd/netinet/dhcp_options.h
index 0b5020d11..47c4c6966 100644
--- a/bsd/netinet/dhcp_options.h
+++ b/bsd/netinet/dhcp_options.h
@@ -7,19 +7,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -195,4 +198,4 @@ boolean_t		dhcpol_parse_vendor(dhcpol_t * vendor,
 					    unsigned char * err);
 void			dhcpol_print(dhcpol_t * list);
 #endif /* __APPLE_API_PRIVATE */
-#endif _NETINET_DHCP_OPTIONS_H
+#endif /* _NETINET_DHCP_OPTIONS_H */
diff --git a/bsd/netinet/icmp6.h b/bsd/netinet/icmp6.h
index 0a3f67a7f..428caa828 100644
--- a/bsd/netinet/icmp6.h
+++ b/bsd/netinet/icmp6.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netinet/icmp_var.h b/bsd/netinet/icmp_var.h
index 56005f1ab..96a28ce5d 100644
--- a/bsd/netinet/icmp_var.h
+++ b/bsd/netinet/icmp_var.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netinet/if_atm.c b/bsd/netinet/if_atm.c
index f4639f632..5b2a9bfee 100644
--- a/bsd/netinet/if_atm.c
+++ b/bsd/netinet/if_atm.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netinet/if_atm.h b/bsd/netinet/if_atm.h
index 9c31d421b..094b306db 100644
--- a/bsd/netinet/if_atm.h
+++ b/bsd/netinet/if_atm.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netinet/if_ether.c b/bsd/netinet/if_ether.c
index 07e99d6eb..55f109aae 100644
--- a/bsd/netinet/if_ether.c
+++ b/bsd/netinet/if_ether.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -642,9 +645,31 @@ in_arpinput(m)
 		return;
 	}
 	if (isaddr.s_addr == myaddr.s_addr) {
+		struct kev_msg        ev_msg;
+		struct kev_in_collision	*in_collision;
+		u_char	storage[sizeof(struct kev_in_collision) + 6];
+		in_collision = (struct kev_in_collision*)storage;
+		
 		log(LOG_ERR,
 			"duplicate IP address %s sent from ethernet address %s\n",
 			inet_ntoa(isaddr), ether_sprintf(buf, ea->arp_sha));
+		
+		/* Send a kernel event so anyone can learn of the conflict */
+		in_collision->link_data.if_family = ac->ac_if.if_family;
+		in_collision->link_data.if_unit = ac->ac_if.if_unit;
+		strncpy(&in_collision->link_data.if_name[0], ac->ac_if.if_name, IFNAMSIZ);
+		in_collision->ia_ipaddr = isaddr;
+		in_collision->hw_len = ETHER_ADDR_LEN;
+		bcopy((caddr_t)ea->arp_sha, (caddr_t)in_collision->hw_addr, sizeof(ea->arp_sha));
+		ev_msg.vendor_code = KEV_VENDOR_APPLE;
+		ev_msg.kev_class = KEV_NETWORK_CLASS;
+		ev_msg.kev_subclass = KEV_INET_SUBCLASS;
+		ev_msg.event_code = KEV_INET_ARPCOLLISION;
+		ev_msg.dv[0].data_ptr = in_collision;
+		ev_msg.dv[0].data_length = sizeof(struct kev_in_collision) + 6;
+		ev_msg.dv[1].data_length = 0;
+		kev_post_msg(&ev_msg);
+		
 		itaddr = myaddr;
 		goto reply;
 	}
diff --git a/bsd/netinet/if_ether.h b/bsd/netinet/if_ether.h
index 0d9799b6b..2f42b36de 100644
--- a/bsd/netinet/if_ether.h
+++ b/bsd/netinet/if_ether.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netinet/if_fddi.h b/bsd/netinet/if_fddi.h
index dd33f7311..c250256eb 100644
--- a/bsd/netinet/if_fddi.h
+++ b/bsd/netinet/if_fddi.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netinet/if_tun.h b/bsd/netinet/if_tun.h
index 6ffd6734b..dacb125dd 100644
--- a/bsd/netinet/if_tun.h
+++ b/bsd/netinet/if_tun.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netinet/igmp.c b/bsd/netinet/igmp.c
index 3dd855ca8..58abc8d35 100644
--- a/bsd/netinet/igmp.c
+++ b/bsd/netinet/igmp.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netinet/igmp.h b/bsd/netinet/igmp.h
index dc62c7da5..563a14c78 100644
--- a/bsd/netinet/igmp.h
+++ b/bsd/netinet/igmp.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netinet/igmp_var.h b/bsd/netinet/igmp_var.h
index 8d440ff63..e73a9c76e 100644
--- a/bsd/netinet/igmp_var.h
+++ b/bsd/netinet/igmp_var.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netinet/in.c b/bsd/netinet/in.c
index c950c9931..b26199f21 100644
--- a/bsd/netinet/in.c
+++ b/bsd/netinet/in.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netinet/in.h b/bsd/netinet/in.h
index 7fcd67541..1634fe316 100644
--- a/bsd/netinet/in.h
+++ b/bsd/netinet/in.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netinet/in_bootp.c b/bsd/netinet/in_bootp.c
index d203b0e77..041d9e5ca 100644
--- a/bsd/netinet/in_bootp.c
+++ b/bsd/netinet/in_bootp.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netinet/in_cksum.c b/bsd/netinet/in_cksum.c
index 9d349d7b5..850273c86 100644
--- a/bsd/netinet/in_cksum.c
+++ b/bsd/netinet/in_cksum.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netinet/in_gif.c b/bsd/netinet/in_gif.c
index 1971b49bc..c1386fc43 100644
--- a/bsd/netinet/in_gif.c
+++ b/bsd/netinet/in_gif.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netinet/in_gif.h b/bsd/netinet/in_gif.h
index e6d09d293..8c0f62b00 100644
--- a/bsd/netinet/in_gif.h
+++ b/bsd/netinet/in_gif.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netinet/in_pcb.c b/bsd/netinet/in_pcb.c
index bc9d086db..3e1a98d30 100644
--- a/bsd/netinet/in_pcb.c
+++ b/bsd/netinet/in_pcb.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netinet/in_pcb.h b/bsd/netinet/in_pcb.h
index 38acfdf50..c01f8d8b6 100644
--- a/bsd/netinet/in_pcb.h
+++ b/bsd/netinet/in_pcb.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netinet/in_proto.c b/bsd/netinet/in_proto.c
index ad4409a07..c0608d1dc 100644
--- a/bsd/netinet/in_proto.c
+++ b/bsd/netinet/in_proto.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netinet/in_rmx.c b/bsd/netinet/in_rmx.c
index c307be910..bd8e20902 100644
--- a/bsd/netinet/in_rmx.c
+++ b/bsd/netinet/in_rmx.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netinet/in_systm.h b/bsd/netinet/in_systm.h
index 347a460e3..a29822d24 100644
--- a/bsd/netinet/in_systm.h
+++ b/bsd/netinet/in_systm.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netinet/in_var.h b/bsd/netinet/in_var.h
index 0c9d8c829..16baa2c15 100644
--- a/bsd/netinet/in_var.h
+++ b/bsd/netinet/in_var.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -115,6 +118,13 @@ struct kev_in_data {
 	struct  in_addr ia_dstaddr;
 };
 
+struct kev_in_collision {
+	struct	net_event_data	link_data;	/* link colliding arp was received on */
+	struct	in_addr	ia_ipaddr;	/* IP address we and another node are using */
+	u_char	hw_len;	/* length of hardware address */
+	u_char	hw_addr[0];	/* variable length hardware address */
+};
+
 
 /*
  * Define inet event subclass and specific inet events.
@@ -128,6 +138,7 @@ struct kev_in_data {
 #define KEV_INET_SIFDSTADDR   4
 #define KEV_INET_SIFBRDADDR   5
 #define KEV_INET_SIFNETMASK   6
+#define KEV_INET_ARPCOLLISION 7	/* use kev_in_collision */
 #endif /* __APPLE__ */
 
 /*
diff --git a/bsd/netinet/ip.h b/bsd/netinet/ip.h
index 8f19e94a6..29fed9041 100644
--- a/bsd/netinet/ip.h
+++ b/bsd/netinet/ip.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netinet/ip6.h b/bsd/netinet/ip6.h
index 6a3b65785..38060eb93 100644
--- a/bsd/netinet/ip6.h
+++ b/bsd/netinet/ip6.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netinet/ip_compat.h b/bsd/netinet/ip_compat.h
index a39802e7f..eac9e37e1 100644
--- a/bsd/netinet/ip_compat.h
+++ b/bsd/netinet/ip_compat.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netinet/ip_divert.c b/bsd/netinet/ip_divert.c
index 546df390c..512c65ca7 100644
--- a/bsd/netinet/ip_divert.c
+++ b/bsd/netinet/ip_divert.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netinet/ip_dummynet.c b/bsd/netinet/ip_dummynet.c
index 0979e45d3..c43d86ce7 100644
--- a/bsd/netinet/ip_dummynet.c
+++ b/bsd/netinet/ip_dummynet.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netinet/ip_dummynet.h b/bsd/netinet/ip_dummynet.h
index 9a13ae239..b61f4a8c9 100644
--- a/bsd/netinet/ip_dummynet.h
+++ b/bsd/netinet/ip_dummynet.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netinet/ip_ecn.c b/bsd/netinet/ip_ecn.c
index 2dfc497e8..1599ac4bf 100644
--- a/bsd/netinet/ip_ecn.c
+++ b/bsd/netinet/ip_ecn.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netinet/ip_ecn.h b/bsd/netinet/ip_ecn.h
index 4aa2132c5..d00a74ec7 100644
--- a/bsd/netinet/ip_ecn.h
+++ b/bsd/netinet/ip_ecn.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netinet/ip_encap.c b/bsd/netinet/ip_encap.c
index e4c9c7c9b..5ae39bb90 100644
--- a/bsd/netinet/ip_encap.c
+++ b/bsd/netinet/ip_encap.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netinet/ip_encap.h b/bsd/netinet/ip_encap.h
index a1c472e22..81c8b7ce0 100644
--- a/bsd/netinet/ip_encap.h
+++ b/bsd/netinet/ip_encap.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netinet/ip_flow.c b/bsd/netinet/ip_flow.c
index 8e0ac3cc5..70233a1d5 100644
--- a/bsd/netinet/ip_flow.c
+++ b/bsd/netinet/ip_flow.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netinet/ip_flow.h b/bsd/netinet/ip_flow.h
index 23c25d366..86abb56a1 100644
--- a/bsd/netinet/ip_flow.h
+++ b/bsd/netinet/ip_flow.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netinet/ip_fw.h b/bsd/netinet/ip_fw.h
index 41eae12e2..ce42111f8 100644
--- a/bsd/netinet/ip_fw.h
+++ b/bsd/netinet/ip_fw.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netinet/ip_icmp.c b/bsd/netinet/ip_icmp.c
index 461ba6b00..fb9424877 100644
--- a/bsd/netinet/ip_icmp.c
+++ b/bsd/netinet/ip_icmp.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netinet/ip_icmp.h b/bsd/netinet/ip_icmp.h
index 22e119eb1..fec3d5d96 100644
--- a/bsd/netinet/ip_icmp.h
+++ b/bsd/netinet/ip_icmp.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netinet/ip_input.c b/bsd/netinet/ip_input.c
index ce9949bdd..bd5edb4fb 100644
--- a/bsd/netinet/ip_input.c
+++ b/bsd/netinet/ip_input.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netinet/ip_mroute.c b/bsd/netinet/ip_mroute.c
index b522d5f95..6668caa0e 100644
--- a/bsd/netinet/ip_mroute.c
+++ b/bsd/netinet/ip_mroute.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netinet/ip_mroute.h b/bsd/netinet/ip_mroute.h
index a667f4ea4..b5cc0f0de 100644
--- a/bsd/netinet/ip_mroute.h
+++ b/bsd/netinet/ip_mroute.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netinet/ip_output.c b/bsd/netinet/ip_output.c
index eaff4fc2d..e365ce7f1 100644
--- a/bsd/netinet/ip_output.c
+++ b/bsd/netinet/ip_output.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netinet/ip_var.h b/bsd/netinet/ip_var.h
index ce1742029..635f33548 100644
--- a/bsd/netinet/ip_var.h
+++ b/bsd/netinet/ip_var.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netinet/raw_ip.c b/bsd/netinet/raw_ip.c
index cf4f38aa6..f524dd41a 100644
--- a/bsd/netinet/raw_ip.c
+++ b/bsd/netinet/raw_ip.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netinet/tcp.h b/bsd/netinet/tcp.h
index 39efb3d79..85ea2021a 100644
--- a/bsd/netinet/tcp.h
+++ b/bsd/netinet/tcp.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netinet/tcp_debug.c b/bsd/netinet/tcp_debug.c
index a7043db15..48608fc80 100644
--- a/bsd/netinet/tcp_debug.c
+++ b/bsd/netinet/tcp_debug.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netinet/tcp_debug.h b/bsd/netinet/tcp_debug.h
index 76a05474e..5a7e5872e 100644
--- a/bsd/netinet/tcp_debug.h
+++ b/bsd/netinet/tcp_debug.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netinet/tcp_fsm.h b/bsd/netinet/tcp_fsm.h
index e4a2e6826..7b9b0732d 100644
--- a/bsd/netinet/tcp_fsm.h
+++ b/bsd/netinet/tcp_fsm.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netinet/tcp_input.c b/bsd/netinet/tcp_input.c
index eb294a6a2..c2925621e 100644
--- a/bsd/netinet/tcp_input.c
+++ b/bsd/netinet/tcp_input.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -71,6 +74,7 @@
 #include <kern/cpu_number.h>	/* before tcp_seq.h, for tcp_random18() */
 
 #include <net/if.h>
+#include <net/if_types.h>
 #include <net/route.h>
 
 #include <netinet/in.h>
@@ -158,6 +162,11 @@ SYSCTL_INT(_net_inet_tcp, OID_AUTO, drop_synfin, CTLFLAG_RW,
     &drop_synfin, 0, "Drop TCP packets with SYN+FIN set");
 #endif
 
+__private_extern__ int slowlink_wsize = 8192;
+SYSCTL_INT(_net_inet_tcp, OID_AUTO, slowlink_wsize, CTLFLAG_RW,
+	&slowlink_wsize, 0, "Maximum advertised window size for slowlink");
+
+
 u_long tcp_now;
 struct inpcbhead tcb;
 #define	tcb6	tcb  /* for KAME src sync over BSD*'s */
@@ -1135,6 +1144,10 @@ findpcb:
 	win = sbspace(&so->so_rcv);
 	if (win < 0)
 		win = 0;
+	else {	/* clip rcv window to 4K for modems */
+		if (tp->t_flags & TF_SLOWLINK && slowlink_wsize > 0)
+			win = min(win, slowlink_wsize);
+	}
 	tp->rcv_wnd = imax(win, (int)(tp->rcv_adv - tp->rcv_nxt));
 	}
 
@@ -1317,7 +1330,10 @@ findpcb:
 			 * here.  Even if we requested window scaling, it will
 			 * become effective only later when our SYN is acked.
 			 */
-			tp->rcv_adv += min(tp->rcv_wnd, TCP_MAXWIN);
+			if (tp->t_flags & TF_SLOWLINK && slowlink_wsize > 0) /* clip window size for for slow link */
+				tp->rcv_adv += min(tp->rcv_wnd, slowlink_wsize);
+			else 
+				tp->rcv_adv += min(tp->rcv_wnd, TCP_MAXWIN);
 			tcpstat.tcps_connects++;
 			soisconnected(so);
 			tp->t_timer[TCPT_KEEP] = tcp_keepinit;
@@ -2116,10 +2132,10 @@ process_ACK:
 			tp->snd_wnd -= acked;
 			ourfinisacked = 0;
 		}
-		sowwakeup(so);
 		tp->snd_una = th->th_ack;
 		if (SEQ_LT(tp->snd_nxt, tp->snd_una))
 			tp->snd_nxt = tp->snd_una;
+		sowwakeup(so);
 
 		switch (tp->t_state) {
 
@@ -2841,6 +2857,16 @@ tcp_mss(tp, offer)
 		return;
 	}
 	ifp = rt->rt_ifp;
+	/*
+	 * Slower link window correction:
+	 * If a value is specificied for slowlink_wsize use it for PPP links
+	 * believed to be on a serial modem (speed <128Kbps). Excludes 9600bps as
+	 * it is the default value adversized by pseudo-devices over ppp.
+	 */
+	if (ifp->if_type == IFT_PPP && slowlink_wsize > 0 && 
+	    ifp->if_baudrate > 9600 && ifp->if_baudrate <= 128000) {
+		tp->t_flags |= TF_SLOWLINK;
+	}
 	so = inp->inp_socket;
 
 	taop = rmx_taop(rt->rt_rmx);
@@ -3047,6 +3073,16 @@ tcp_mssopt(tp)
 			isipv6 ? tcp_v6mssdflt :
 #endif /* INET6 */
 			tcp_mssdflt;
+	/*
+	 * Slower link window correction:
+	 * If a value is specificied for slowlink_wsize use it for PPP links
+	 * believed to be on a serial modem (speed <128Kbps). Excludes 9600bps as
+	 * it is the default value adversized by pseudo-devices over ppp.
+	 */
+	if (rt->rt_ifp->if_type == IFT_PPP && slowlink_wsize > 0 && 
+	    rt->rt_ifp->if_baudrate > 9600 && rt->rt_ifp->if_baudrate <= 128000) {
+		tp->t_flags |= TF_SLOWLINK;
+	}
 
 	return rt->rt_ifp->if_mtu - min_protoh;
 }
diff --git a/bsd/netinet/tcp_output.c b/bsd/netinet/tcp_output.c
index d3e5558d3..2bfc95262 100644
--- a/bsd/netinet/tcp_output.c
+++ b/bsd/netinet/tcp_output.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -113,7 +116,7 @@ int ss_fltsz = 1;
 SYSCTL_INT(_net_inet_tcp, OID_AUTO, slowstart_flightsize, CTLFLAG_RW,
 	&ss_fltsz, 1, "Slow start flight size");
 
-int ss_fltsz_local = TCP_MAXWIN;               /* something large */
+int ss_fltsz_local = 4; /* starts with four segments max */
 SYSCTL_INT(_net_inet_tcp, OID_AUTO, local_slowstart_flightsize, CTLFLAG_RW,
 	&ss_fltsz_local, 1, "Slow start flight size for local networks");
 
@@ -129,6 +132,8 @@ struct	mbuf *m_copym_with_hdrs __P((struct mbuf*, int, int, int, struct mbuf**,
 extern int ipsec_bypass;
 #endif
 
+extern int slowlink_wsize;	/* window correction for slow links */
+
 /*
  * Tcp output routine: figure out what should be sent and send it.
  */
@@ -219,6 +224,8 @@ again:
 	sendalot = 0;
 	off = tp->snd_nxt - tp->snd_una;
 	win = min(tp->snd_wnd, tp->snd_cwnd);
+	if (tp->t_flags & TF_SLOWLINK && slowlink_wsize > 0)
+		win = min(win, slowlink_wsize);
 
 	flags = tcp_outflags[tp->t_state];
 	/*
@@ -325,7 +332,10 @@ again:
 	if (SEQ_LT(tp->snd_nxt + len, tp->snd_una + so->so_snd.sb_cc))
 		flags &= ~TH_FIN;
 
-	win = sbspace(&so->so_rcv);
+	if (tp->t_flags & TF_SLOWLINK && slowlink_wsize > 0 )	/* Clips window size for slow links */
+		win = min(sbspace(&so->so_rcv), slowlink_wsize);
+	else
+		win = sbspace(&so->so_rcv);
 
 	/*
 	 * Sender silly window avoidance.  If connection is idle
@@ -795,9 +805,17 @@ send:
 		win = 0;
 	if (win < (long)(tp->rcv_adv - tp->rcv_nxt))
 		win = (long)(tp->rcv_adv - tp->rcv_nxt);
-	if (win > (long)TCP_MAXWIN << tp->rcv_scale)
+	if (tp->t_flags & TF_SLOWLINK && slowlink_wsize > 0) {
+		if (win > (long)slowlink_wsize) 
+			win = slowlink_wsize;
+		th->th_win = htons((u_short) (win>>tp->rcv_scale));
+	}
+	else {
+
+		if (win > (long)TCP_MAXWIN << tp->rcv_scale)
 		win = (long)TCP_MAXWIN << tp->rcv_scale;
-	th->th_win = htons((u_short) (win>>tp->rcv_scale));
+		th->th_win = htons((u_short) (win>>tp->rcv_scale));
+	}
 	if (SEQ_GT(tp->snd_up, tp->snd_nxt)) {
 		th->th_urp = htons((u_short)(tp->snd_up - tp->snd_nxt));
 		th->th_flags |= TH_URG;
diff --git a/bsd/netinet/tcp_seq.h b/bsd/netinet/tcp_seq.h
index 57f1c9262..f566d4360 100644
--- a/bsd/netinet/tcp_seq.h
+++ b/bsd/netinet/tcp_seq.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netinet/tcp_subr.c b/bsd/netinet/tcp_subr.c
index 1fccf314b..cee36d93b 100644
--- a/bsd/netinet/tcp_subr.c
+++ b/bsd/netinet/tcp_subr.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -246,6 +249,9 @@ tcp_init()
 	tcp_keepintvl = TCPTV_KEEPINTVL;
 	tcp_maxpersistidle = TCPTV_KEEP_IDLE;
 	tcp_msl = TCPTV_MSL;
+	read_random(&tcp_now, sizeof(tcp_now));
+	tcp_now  = tcp_now & 0x7fffffffffffffff; /* Starts tcp internal 500ms clock at a random value */
+
 
 	LIST_INIT(&tcb);
 	tcbinfo.listhead = &tcb;
diff --git a/bsd/netinet/tcp_timer.c b/bsd/netinet/tcp_timer.c
index e0c303b40..3d92a0d82 100644
--- a/bsd/netinet/tcp_timer.c
+++ b/bsd/netinet/tcp_timer.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netinet/tcp_timer.h b/bsd/netinet/tcp_timer.h
index a8f55353c..dea6ce3c0 100644
--- a/bsd/netinet/tcp_timer.h
+++ b/bsd/netinet/tcp_timer.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netinet/tcp_usrreq.c b/bsd/netinet/tcp_usrreq.c
index d68e6f45d..cc9202e54 100644
--- a/bsd/netinet/tcp_usrreq.c
+++ b/bsd/netinet/tcp_usrreq.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netinet/tcp_var.h b/bsd/netinet/tcp_var.h
index 5c1742366..d48a74f15 100644
--- a/bsd/netinet/tcp_var.h
+++ b/bsd/netinet/tcp_var.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -127,6 +130,7 @@ struct tcpcb {
 #define	TF_MORETOCOME	0x10000		/* More data to be appended to sock */
 #define	TF_LQ_OVERFLOW	0x20000		/* listen queue overflow */
 #define	TF_RXWIN0SENT	0x40000		/* sent a receiver win 0 in response */
+#define	TF_SLOWLINK	0x80000		/* route is a on a modem speed link */
 
 	int	t_force;		/* 1 if forcing out a byte */
 
diff --git a/bsd/netinet/tcpip.h b/bsd/netinet/tcpip.h
index 79410f82d..22bb6b578 100644
--- a/bsd/netinet/tcpip.h
+++ b/bsd/netinet/tcpip.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netinet/udp.h b/bsd/netinet/udp.h
index 9fa2bb55e..18ed8c194 100644
--- a/bsd/netinet/udp.h
+++ b/bsd/netinet/udp.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netinet/udp_usrreq.c b/bsd/netinet/udp_usrreq.c
index 4dde880ce..5cf04b960 100644
--- a/bsd/netinet/udp_usrreq.c
+++ b/bsd/netinet/udp_usrreq.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netinet/udp_var.h b/bsd/netinet/udp_var.h
index 4c2976f31..31fc99c35 100644
--- a/bsd/netinet/udp_var.h
+++ b/bsd/netinet/udp_var.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netinet6/ip6_fw.h b/bsd/netinet6/ip6_fw.h
index ea7b3fe75..eb41437f4 100644
--- a/bsd/netinet6/ip6_fw.h
+++ b/bsd/netinet6/ip6_fw.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/netinet6/ipsec.c b/bsd/netinet6/ipsec.c
index 9991df62f..5c14febec 100644
--- a/bsd/netinet6/ipsec.c
+++ b/bsd/netinet6/ipsec.c
@@ -3384,7 +3384,7 @@ ipsec_copypkt(m)
 			 */
 			if (
 				n->m_ext.ext_free ||
-				mclrefcnt[mtocl(n->m_ext.ext_buf)] > 1
+				m_mclhasreference(n)
 			    )
 			{
 				int remain, copied;
diff --git a/bsd/nfs/krpc.h b/bsd/nfs/krpc.h
index 16fe898a8..945154c7f 100644
--- a/bsd/nfs/krpc.h
+++ b/bsd/nfs/krpc.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/nfs/krpc_subr.c b/bsd/nfs/krpc_subr.c
index 98a7eee68..f1412b99f 100644
--- a/bsd/nfs/krpc_subr.c
+++ b/bsd/nfs/krpc_subr.c
@@ -1,21 +1,24 @@
 /*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -401,13 +404,40 @@ krpc_call(sa, prog, vers, func, data, from_p)
 			if (reply->rp_astatus != 0) {
 				error = ntohl(reply->rp_u.rpu_errno);
 				printf("rpc denied, error=%d\n", error);
-				continue;
+				/* convert rpc error to errno */
+				switch (error) {
+				case RPC_MISMATCH:
+					error = ERPCMISMATCH;
+					break;
+				case RPC_AUTHERR:
+					error = EAUTH;
+					break;
+				}
+				goto out;
 			}
 
 			/* Did the call succeed? */
 			if ((error = ntohl(reply->rp_u.rpu_ok.rp_rstatus)) != 0) {
 				printf("rpc status=%d\n", error);
-				continue;
+				/* convert rpc error to errno */
+				switch (error) {
+				case RPC_PROGUNAVAIL:
+					error = EPROGUNAVAIL;
+					break;
+				case RPC_PROGMISMATCH:
+					error = EPROGMISMATCH;
+					break;
+				case RPC_PROCUNAVAIL:
+					error = EPROCUNAVAIL;
+					break;
+				case RPC_GARBAGE:
+					error = EINVAL;
+					break;
+				case RPC_SYSTEM_ERR:
+					error = EIO;
+					break;
+				}
+				goto out;
 			}
 
 			goto gotreply;	/* break two levels */
diff --git a/bsd/nfs/nfs.h b/bsd/nfs/nfs.h
index 6d5967414..b8d810f11 100644
--- a/bsd/nfs/nfs.h
+++ b/bsd/nfs/nfs.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/nfs/nfs_bio.c b/bsd/nfs/nfs_bio.c
index 4b77d6637..7f41efe13 100644
--- a/bsd/nfs/nfs_bio.c
+++ b/bsd/nfs/nfs_bio.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/nfs/nfs_boot.c b/bsd/nfs/nfs_boot.c
index 0590f4c49..cec8ac1e8 100644
--- a/bsd/nfs/nfs_boot.c
+++ b/bsd/nfs/nfs_boot.c
@@ -1,21 +1,24 @@
 /*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -130,6 +133,14 @@ int nfs_boot_init(nd, procp)
 	panic("nfs_boot_init: no ether");
 }
 
+int nfs_boot_getfh(nd, procp, v3)
+	struct nfs_diskless *nd;
+	struct proc *procp;
+	int v3;
+{
+	panic("nfs_boot_getfh: no ether");
+}
+
 #else /* NETHER */
 
 /*
@@ -159,11 +170,11 @@ static int bp_getfile __P((struct sockaddr_in *bpsin, char *key,
 	struct sockaddr_in *mdsin, char *servname, char *path));
 
 /* mountd RPC */
-static int md_mount __P((struct sockaddr_in *mdsin, char *path,
-	u_char *fh));
+static int md_mount __P((struct sockaddr_in *mdsin, char *path, int v3,
+	u_char *fhp, u_long *fhlenp));
 
 /* other helpers */
-static int get_file_handle __P((char *pathname, struct nfs_dlmount *ndmntp));
+static int get_file_handle __P((struct nfs_dlmount *ndmntp));
 
 
 #define IP_FORMAT	"%d.%d.%d.%d"
@@ -191,25 +202,24 @@ nfs_boot_init(nd, procp)
 	boolean_t		do_bpgetfile = TRUE;
 	int 			error = 0;
 	struct in_addr 		my_ip;
-	char * 			root_path = NULL;
 	struct sockaddr_in *	sin_p;
 
 	/* by this point, networking must already have been configured */
 	if (netboot_iaddr(&my_ip) == FALSE) {
 	    printf("nfs_boot: networking is not initialized\n");
 	    error = ENXIO;
-	    goto failed;
+	    goto failed_noswitch;
 	}
 
 	/* get the root path information */
-	MALLOC(root_path, char *, MAXPATHLEN, M_TEMP, M_WAITOK);
+	MALLOC_ZONE(nd->nd_root.ndm_path, char *, MAXPATHLEN, M_NAMEI, M_WAITOK);
 	sin_p = &nd->nd_root.ndm_saddr;
 	bzero((caddr_t)sin_p, sizeof(*sin_p));
 	sin_p->sin_len = sizeof(*sin_p);
 	sin_p->sin_family = AF_INET;
 	if (netboot_rootpath(&sin_p->sin_addr, nd->nd_root.ndm_host, 
 			     sizeof(nd->nd_root.ndm_host),
-			     root_path, MAXPATHLEN) == TRUE) {
+			     nd->nd_root.ndm_path, MAXPATHLEN) == TRUE) {
 	    do_bpgetfile = FALSE;
 	    do_bpwhoami = FALSE;
 	}
@@ -244,68 +254,90 @@ nfs_boot_init(nd, procp)
 	}
 	if (do_bpgetfile) {
 		error = bp_getfile(&bp_sin, "root", &nd->nd_root.ndm_saddr,
-				   nd->nd_root.ndm_host, root_path);
+				   nd->nd_root.ndm_host, nd->nd_root.ndm_path);
 		if (error) {
 			printf("nfs_boot: bootparam get root: %d\n", error);
 			goto failed;
 		}
 	}
-	
-	error = get_file_handle(root_path, &nd->nd_root);
-	if (error) {
-		printf("nfs_boot: get_file_handle() root failed, %d\n", error);
-		goto failed;
-	}
 
 #if !defined(NO_MOUNT_PRIVATE) 
 	if (do_bpgetfile) { /* get private path */
-		char * private_path = NULL;
-		
-		MALLOC(private_path, char *, MAXPATHLEN, M_TEMP, M_WAITOK);
+		MALLOC_ZONE(nd->nd_private.ndm_path, char *, MAXPATHLEN, M_NAMEI, M_WAITOK);
 		error = bp_getfile(&bp_sin, "private", 
 				   &nd->nd_private.ndm_saddr,
-				   nd->nd_private.ndm_host, private_path);
+				   nd->nd_private.ndm_host,
+				   nd->nd_private.ndm_path);
 		if (!error) {
 			char * check_path = NULL;
 			
-			MALLOC(check_path, char *, MAXPATHLEN, M_TEMP, M_WAITOK);
-			sprintf(check_path, "%s/private", root_path);
+			MALLOC_ZONE(check_path, char *, MAXPATHLEN, M_NAMEI, M_WAITOK);
+			snprintf(check_path, MAXPATHLEN, "%s/private", nd->nd_root.ndm_path);
 			if ((nd->nd_root.ndm_saddr.sin_addr.s_addr 
 			     == nd->nd_private.ndm_saddr.sin_addr.s_addr)
-			    && (strcmp(check_path, private_path) == 0)) {
+			    && (strcmp(check_path, nd->nd_private.ndm_path) == 0)) {
 				/* private path is prefix of root path, don't mount */
 				nd->nd_private.ndm_saddr.sin_addr.s_addr = 0;
 			}
-			else {
-				error = get_file_handle(private_path, 
-							&nd->nd_private);
-				if (error) {
-					printf("nfs_boot: get_file_handle() private failed, %d\n", error);
-					goto failed;
-				}
-			}
-			_FREE(check_path, M_TEMP);
+			FREE_ZONE(check_path, MAXPATHLEN, M_NAMEI);
 		}
 		else { 
 			/* private key not defined, don't mount */
 			nd->nd_private.ndm_saddr.sin_addr.s_addr = 0;
 		}
-		_FREE(private_path, M_TEMP);
 	}
 	else {
 		error = 0;
 	}
+#endif NO_MOUNT_PRIVATE
+failed:
+	thread_funnel_switch(NETWORK_FUNNEL, KERNEL_FUNNEL);
+failed_noswitch:
+	return (error);
+}
+
+/*
+ * Called with a partially initialized nfs_diskless struct
+ * with file handles to be filled in.
+ */
+int
+nfs_boot_getfh(nd, procp, v3)
+	struct nfs_diskless *nd;
+	struct proc *procp;
+	int v3;
+{
+	int error = 0;
+
+	thread_funnel_switch(KERNEL_FUNNEL, NETWORK_FUNNEL);
+	
+	nd->nd_root.ndm_nfsv3 = v3;
+	error = get_file_handle(&nd->nd_root);
+	if (error) {
+		printf("nfs_boot: get_file_handle(v%d) root failed, %d\n",
+			v3 ? 3 : 2, error);
+		goto failed;
+	}
+
+#if !defined(NO_MOUNT_PRIVATE) 
+	if (nd->nd_private.ndm_saddr.sin_addr.s_addr) {
+		/* get private file handle */
+		nd->nd_private.ndm_nfsv3 = v3;
+		error = get_file_handle(&nd->nd_private);
+		if (error) {
+			printf("nfs_boot: get_file_handle(v%d) private failed, %d\n",
+				v3 ? 3 : 2, error);
+			goto failed;
+		}
+	}
 #endif NO_MOUNT_PRIVATE
  failed:
 	thread_funnel_switch(NETWORK_FUNNEL, KERNEL_FUNNEL);
-	_FREE(root_path, M_TEMP);
 	return (error);
 }
 
 static int
-get_file_handle(pathname, ndmntp)
- 	char 		   *pathname;	/* path on server */
-	struct nfs_dlmount *ndmntp;	/* output */
+get_file_handle(ndmntp)
+	struct nfs_dlmount *ndmntp;
 {
 	char *sp, *dp, *endp;
 	int error;
@@ -314,7 +346,8 @@ get_file_handle(pathname, ndmntp)
 	 * Get file handle for "key" (root or swap)
 	 * using RPC to mountd/mount
 	 */
-	error = md_mount(&ndmntp->ndm_saddr, pathname, ndmntp->ndm_fh);
+	error = md_mount(&ndmntp->ndm_saddr, ndmntp->ndm_path, ndmntp->ndm_nfsv3,
+			ndmntp->ndm_fh, &ndmntp->ndm_fhlen);
 	if (error)
 		return (error);
 
@@ -323,7 +356,7 @@ get_file_handle(pathname, ndmntp)
 	endp = dp + MNAMELEN - 1;
 	dp += strlen(dp);
 	*dp++ = ':';
-	for (sp = pathname; *sp && dp < endp;)
+	for (sp = ndmntp->ndm_path; *sp && dp < endp;)
 		*dp++ = *sp++;
 	*dp = '\0';
 	return (0);
@@ -647,22 +680,25 @@ out:
  * Also, sets sin->sin_port to the NFS service port.
  */
 static int
-md_mount(mdsin, path, fhp)
+md_mount(mdsin, path, v3, fhp, fhlenp)
 	struct sockaddr_in *mdsin;		/* mountd server address */
 	char *path;
+	int v3;
 	u_char *fhp;
+	u_long *fhlenp;
 {
 	/* The RPC structures */
 	struct rpc_string *str;
 	struct rdata {
 		u_long	errno;
-		u_char	fh[NFSX_V2FH];
+		u_char	data[NFSX_V3FHMAX + sizeof(u_long)];
 	} *rdata;
 	struct mbuf *m;
 	int error, mlen, slen;
+	int mntversion = v3 ? RPCMNT_VER3 : RPCMNT_VER1;
 
 	/* Get port number for MOUNTD. */
-	error = krpc_portmap(mdsin, RPCPROG_MNT, RPCMNT_VER1,
+	error = krpc_portmap(mdsin, RPCPROG_MNT, mntversion,
 						 &mdsin->sin_port);
 	if (error) return error;
 
@@ -677,22 +713,43 @@ md_mount(mdsin, path, fhp)
 	bcopy(path, str->data, slen);
 
 	/* Do RPC to mountd. */
-	error = krpc_call(mdsin, RPCPROG_MNT, RPCMNT_VER1,
+	error = krpc_call(mdsin, RPCPROG_MNT, mntversion,
 			RPCMNT_MOUNT, &m, NULL);
 	if (error)
 		return error;	/* message already freed */
 
+	/*
+	 * the reply must be long enough to hold the errno plus either of:
+	 * + a v2 filehandle
+	 * + a v3 filehandle length + a v3 filehandle
+	 */
 	mlen = m->m_len;
-	if (mlen < sizeof(*rdata))
+	if (mlen < sizeof(u_long))
 		goto bad;
 	rdata = mtod(m, struct rdata *);
 	error = ntohl(rdata->errno);
 	if (error)
-		goto bad;
-	bcopy(rdata->fh, fhp, NFSX_V2FH);
+		goto out;
+	if (v3) {
+		u_long fhlen;
+		u_char *fh;
+		if (mlen < sizeof(u_long)*2)
+			goto bad;
+		fhlen = ntohl(*(u_long*)rdata->data);
+		fh = rdata->data + sizeof(u_long);
+		if (mlen < (sizeof(u_long)*2 + fhlen))
+			goto bad;
+		bcopy(fh, fhp, fhlen);
+		*fhlenp = fhlen;
+	} else {
+		if (mlen < (sizeof(u_long) + NFSX_V2FH))
+			goto bad;
+		bcopy(rdata->data, fhp, NFSX_V2FH);
+		*fhlenp = NFSX_V2FH;
+	}
 
 	/* Set port number for NFS use. */
-	error = krpc_portmap(mdsin, NFS_PROG, NFS_VER2,
+	error = krpc_portmap(mdsin, NFS_PROG, v3 ? NFS_VER3 : NFS_VER2,
 						 &mdsin->sin_port);
 	goto out;
 
diff --git a/bsd/nfs/nfs_node.c b/bsd/nfs/nfs_node.c
index f12696b36..8a9c0835b 100644
--- a/bsd/nfs/nfs_node.c
+++ b/bsd/nfs/nfs_node.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/nfs/nfs_nqlease.c b/bsd/nfs/nfs_nqlease.c
index 758242702..d390c9e92 100644
--- a/bsd/nfs/nfs_nqlease.c
+++ b/bsd/nfs/nfs_nqlease.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/nfs/nfs_serv.c b/bsd/nfs/nfs_serv.c
index f03085e4e..7526e755d 100644
--- a/bsd/nfs/nfs_serv.c
+++ b/bsd/nfs/nfs_serv.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/nfs/nfs_socket.c b/bsd/nfs/nfs_socket.c
index 8038b43a6..f2ee753a3 100644
--- a/bsd/nfs/nfs_socket.c
+++ b/bsd/nfs/nfs_socket.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -993,6 +996,10 @@ nfs_reply(myrep)
 			FSDBG(530, myrep->r_xid, myrep, nmp, error);
 			nfs_rcvunlock(&nmp->nm_flag);
 
+			/* Bailout asap if nfsmount struct gone (unmounted). */
+			if (!myrep->r_nmp || !nmp->nm_so)
+				return (ECONNABORTED);
+
 			/*
 			 * Ignore routing errors on connectionless protocols??
 			 */
@@ -1996,9 +2003,17 @@ static int
 nfs_rcvlock(rep)
 	register struct nfsreq *rep;
 {
-	register int *flagp = &rep->r_nmp->nm_flag;
+	register int *flagp;
 	int slpflag, slptimeo = 0;
 
+	/* make sure we still have our mountpoint */
+	if (!rep->r_nmp) {
+		if (rep->r_mrep != NULL)
+			return (EALREADY);
+		return (ECONNABORTED);
+	}
+
+	flagp = &rep->r_nmp->nm_flag;
 	FSDBG_TOP(534, rep->r_xid, rep, rep->r_nmp, *flagp);
 	if (*flagp & NFSMNT_INT)
 		slpflag = PCATCH;
diff --git a/bsd/nfs/nfs_srvcache.c b/bsd/nfs/nfs_srvcache.c
index 9e7007ddb..c0b926a4c 100644
--- a/bsd/nfs/nfs_srvcache.c
+++ b/bsd/nfs/nfs_srvcache.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/nfs/nfs_subs.c b/bsd/nfs/nfs_subs.c
index fbd22ed2e..1e341e73e 100644
--- a/bsd/nfs/nfs_subs.c
+++ b/bsd/nfs/nfs_subs.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/nfs/nfs_syscalls.c b/bsd/nfs/nfs_syscalls.c
index 852257d43..f29b5c80e 100644
--- a/bsd/nfs/nfs_syscalls.c
+++ b/bsd/nfs/nfs_syscalls.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/nfs/nfs_vfsops.c b/bsd/nfs/nfs_vfsops.c
index 44faf37c5..cda27c84d 100644
--- a/bsd/nfs/nfs_vfsops.c
+++ b/bsd/nfs/nfs_vfsops.c
@@ -1,21 +1,24 @@
 /*
- * Copyright (c) 2000-2001 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -163,34 +166,6 @@ struct vfsops nfs_vfsops = {
 VFS_SET(nfs_vfsops, nfs, MOUNT_NFS, VFCF_NETWORK);
 #endif
 
-/*
- * This structure must be filled in by a primary bootstrap or bootstrap
- * server for a diskless/dataless machine. It is initialized below just
- * to ensure that it is allocated to initialized data (.data not .bss).
- */
-struct nfs_diskless nfs_diskless = { 0 };
-int nfs_diskless_valid = 0;
-
-/* XXX CSM 11/25/97 Upgrade sysctl.h someday */
-#ifdef notyet
-SYSCTL_INT(_vfs_nfs, OID_AUTO, diskless_valid, CTLFLAG_RD, 
-	&nfs_diskless_valid, 0, "");
-
-SYSCTL_STRING(_vfs_nfs, OID_AUTO, diskless_rootpath, CTLFLAG_RD,
-	nfs_diskless.root_hostnam, 0, "");
-
-SYSCTL_OPAQUE(_vfs_nfs, OID_AUTO, diskless_rootaddr, CTLFLAG_RD,
-	&nfs_diskless.root_saddr, sizeof nfs_diskless.root_saddr,
-	"%Ssockaddr_in", "");
-
-SYSCTL_STRING(_vfs_nfs, OID_AUTO, diskless_swappath, CTLFLAG_RD,
-	nfs_diskless.swap_hostnam, 0, "");
-
-SYSCTL_OPAQUE(_vfs_nfs, OID_AUTO, diskless_swapaddr, CTLFLAG_RD,
-	&nfs_diskless.swap_saddr, sizeof nfs_diskless.swap_saddr, 
-	"%Ssockaddr_in","");
-#endif
-
 
 void nfsargs_ntoh __P((struct nfs_args *));
 static int
@@ -222,7 +197,7 @@ static int nfs_iosize(nmp)
 	iosize = max(nmp->nm_rsize, nmp->nm_wsize);
 	if (iosize < PAGE_SIZE)
 		iosize = PAGE_SIZE;
-	return (trunc_page(iosize));
+	return (trunc_page_32(iosize));
 }
 
 static void nfs_convert_oargs(args,oargs)
@@ -413,6 +388,7 @@ nfs_mountroot()
 	struct mount *mppriv;
 	struct vnode *vppriv;
 #endif /* NO_MOUNT_PRIVATE */
+	int v3;
 
 	procp = current_proc(); /* XXX */
 
@@ -427,6 +403,20 @@ nfs_mountroot()
 		panic("nfs_boot_init failed with %d\n", error);
 	}
 
+	/* try NFSv3 first, if that fails then try NFSv2 */
+	v3 = 1;
+
+tryagain:
+	error = nfs_boot_getfh(&nd, procp, v3);
+	if (error) {
+		if (v3) {
+			printf("nfs_boot_getfh(v3) failed with %d, trying v2...\n", error);
+			v3 = 0;
+			goto tryagain;
+		}
+		panic("nfs_boot_getfh(v2) failed with %d\n", error);
+	}
+
 	/*
 	 * Create the root mount point.
 	 */
@@ -435,7 +425,12 @@ nfs_mountroot()
 #else
 	if (error = nfs_mount_diskless(&nd.nd_root, "/", NULL, &vp, &mp)) {
 #endif /* NO_MOUNT_PRIVATE */
-		panic("nfs_mount_diskless failed with %d\n", error);
+		if (v3) {
+			printf("nfs_mount_diskless(v3) failed with %d, trying v2...\n", error);
+			v3 = 0;
+			goto tryagain;
+		}
+		panic("nfs_mount_diskless root failed with %d\n", error);
 	}
 	printf("root on %s\n", (char *)&nd.nd_root.ndm_host);
 
@@ -450,7 +445,7 @@ nfs_mountroot()
 	    error = nfs_mount_diskless_private(&nd.nd_private, "/private",
 					       NULL, &vppriv, &mppriv);
 	    if (error) {
-		panic("nfs_mount_diskless failed with %d\n", error);
+		panic("nfs_mount_diskless private failed with %d\n", error);
 	    }
 	    printf("private on %s\n", (char *)&nd.nd_private.ndm_host);
 	    
@@ -462,6 +457,11 @@ nfs_mountroot()
 
 #endif /* NO_MOUNT_PRIVATE */
 
+	if (nd.nd_root.ndm_path)
+		FREE_ZONE(nd.nd_root.ndm_path, MAXPATHLEN, M_NAMEI);
+	if (nd.nd_private.ndm_path)
+		FREE_ZONE(nd.nd_private.ndm_path, MAXPATHLEN, M_NAMEI);
+
 	/* Get root attributes (for the time). */
 	error = VOP_GETATTR(vp, &attr, procp->p_ucred, procp);
 	if (error) panic("nfs_mountroot: getattr for root");
@@ -501,9 +501,11 @@ nfs_mount_diskless(ndmntp, mntname, mntflag, vpp, mpp)
 	args.addrlen  = args.addr->sa_len;
 	args.sotype   = SOCK_DGRAM;
 	args.fh       = ndmntp->ndm_fh;
-	args.fhsize   = NFSX_V2FH; /* need to try v3, then v2 */
+	args.fhsize   = ndmntp->ndm_fhlen;
 	args.hostname = ndmntp->ndm_host;
 	args.flags    = NFSMNT_RESVPORT;
+	if (ndmntp->ndm_nfsv3)
+		args.flags |= NFSMNT_NFSV3;
 
 	MGET(m, M_DONTWAIT, MT_SONAME);
 	bcopy((caddr_t)args.addr, mtod(m, caddr_t), 
@@ -631,9 +633,11 @@ nfs_mount_diskless_private(ndmntp, mntname, mntflag, vpp, mpp)
 	args.addrlen  = args.addr->sa_len;
 	args.sotype   = SOCK_DGRAM;
 	args.fh       = ndmntp->ndm_fh;
-	args.fhsize   = NFSX_V2FH;
+	args.fhsize   = ndmntp->ndm_fhlen;
 	args.hostname = ndmntp->ndm_host;
 	args.flags    = NFSMNT_RESVPORT;
+	if (ndmntp->ndm_nfsv3)
+		args.flags |= NFSMNT_NFSV3;
 
 	MGET(m, M_DONTWAIT, MT_SONAME);
 	bcopy((caddr_t)args.addr, mtod(m, caddr_t), 
diff --git a/bsd/nfs/nfs_vnops.c b/bsd/nfs/nfs_vnops.c
index e8c78eee8..dcc4d31dc 100644
--- a/bsd/nfs/nfs_vnops.c
+++ b/bsd/nfs/nfs_vnops.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/nfs/nfsdiskless.h b/bsd/nfs/nfsdiskless.h
index 59f987e22..2e1925fe6 100644
--- a/bsd/nfs/nfsdiskless.h
+++ b/bsd/nfs/nfsdiskless.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -109,7 +112,10 @@ struct nfsv3_diskless {
 struct nfs_dlmount {
 	struct sockaddr_in ndm_saddr;  		/* Address of file server */
 	char		ndm_host[MNAMELEN]; 	/* Host name for mount pt */
-	u_char		ndm_fh[NFSX_V2FH]; 		/* The file's file handle */
+	char		*ndm_path; 		/* path name for mount pt */
+	u_long		ndm_nfsv3;		/* NFSv3 or NFSv2? */
+	u_long		ndm_fhlen;		/* length of file handle */
+	u_char		ndm_fh[NFSX_V3FHMAX];	/* The file's file handle */
 };
 
 /*
diff --git a/bsd/nfs/nfsm_subs.h b/bsd/nfs/nfsm_subs.h
index e9c810e2b..5156591a9 100644
--- a/bsd/nfs/nfsm_subs.h
+++ b/bsd/nfs/nfsm_subs.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/nfs/nfsmount.h b/bsd/nfs/nfsmount.h
index 92d69f7a5..efa40d2f8 100644
--- a/bsd/nfs/nfsmount.h
+++ b/bsd/nfs/nfsmount.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/nfs/nfsnode.h b/bsd/nfs/nfsnode.h
index 820c68f79..cd3a8d080 100644
--- a/bsd/nfs/nfsnode.h
+++ b/bsd/nfs/nfsnode.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/nfs/nfsproto.h b/bsd/nfs/nfsproto.h
index cd63a0996..8b077777d 100644
--- a/bsd/nfs/nfsproto.h
+++ b/bsd/nfs/nfsproto.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/nfs/nfsrtt.h b/bsd/nfs/nfsrtt.h
index 1cebaf787..ea332a885 100644
--- a/bsd/nfs/nfsrtt.h
+++ b/bsd/nfs/nfsrtt.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/nfs/nfsrvcache.h b/bsd/nfs/nfsrvcache.h
index 1e7f97766..cd645ae24 100644
--- a/bsd/nfs/nfsrvcache.h
+++ b/bsd/nfs/nfsrvcache.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/nfs/nqnfs.h b/bsd/nfs/nqnfs.h
index bb432511a..243b7e0ee 100644
--- a/bsd/nfs/nqnfs.h
+++ b/bsd/nfs/nqnfs.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/nfs/rpcv2.h b/bsd/nfs/rpcv2.h
index d8a2618fe..a3698081e 100644
--- a/bsd/nfs/rpcv2.h
+++ b/bsd/nfs/rpcv2.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -99,6 +102,7 @@
 #define	RPC_PROGMISMATCH	2
 #define	RPC_PROCUNAVAIL	3
 #define	RPC_GARBAGE	4		/* I like this one */
+#define	RPC_SYSTEM_ERR	5
 #define	RPC_MISMATCH	0
 #define	RPC_AUTHERR	1
 
diff --git a/bsd/nfs/xdr_subs.h b/bsd/nfs/xdr_subs.h
index e786cb8c7..68a9e9659 100644
--- a/bsd/nfs/xdr_subs.h
+++ b/bsd/nfs/xdr_subs.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/ppc/cpu.h b/bsd/ppc/cpu.h
index 5aa43232f..a3f7405c5 100644
--- a/bsd/ppc/cpu.h
+++ b/bsd/ppc/cpu.h
@@ -4,19 +4,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/ppc/disklabel.h b/bsd/ppc/disklabel.h
index 02a84a604..e79f38d9e 100644
--- a/bsd/ppc/disklabel.h
+++ b/bsd/ppc/disklabel.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/ppc/endian.h b/bsd/ppc/endian.h
index 984cdb588..5071eba4c 100644
--- a/bsd/ppc/endian.h
+++ b/bsd/ppc/endian.h
@@ -4,19 +4,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/ppc/exec.h b/bsd/ppc/exec.h
index 339bac2c7..021019a0d 100644
--- a/bsd/ppc/exec.h
+++ b/bsd/ppc/exec.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/ppc/label_t.h b/bsd/ppc/label_t.h
index d4a45ac77..10a60d0e9 100644
--- a/bsd/ppc/label_t.h
+++ b/bsd/ppc/label_t.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/ppc/param.h b/bsd/ppc/param.h
index 96e29404a..ac6477555 100644
--- a/bsd/ppc/param.h
+++ b/bsd/ppc/param.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/ppc/profile.h b/bsd/ppc/profile.h
index a7263bd42..b8bba099e 100644
--- a/bsd/ppc/profile.h
+++ b/bsd/ppc/profile.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/ppc/psl.h b/bsd/ppc/psl.h
index 7e081d882..647db5225 100644
--- a/bsd/ppc/psl.h
+++ b/bsd/ppc/psl.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/ppc/ptrace.h b/bsd/ppc/ptrace.h
index 769354c3f..0641cc9b0 100644
--- a/bsd/ppc/ptrace.h
+++ b/bsd/ppc/ptrace.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/ppc/reboot.h b/bsd/ppc/reboot.h
index 0a47e6a49..90a5fc2f0 100644
--- a/bsd/ppc/reboot.h
+++ b/bsd/ppc/reboot.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/ppc/reg.h b/bsd/ppc/reg.h
index 58f1be653..5f1a7381f 100644
--- a/bsd/ppc/reg.h
+++ b/bsd/ppc/reg.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/ppc/setjmp.h b/bsd/ppc/setjmp.h
index f7b318d92..417a2d6ae 100644
--- a/bsd/ppc/setjmp.h
+++ b/bsd/ppc/setjmp.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/ppc/signal.h b/bsd/ppc/signal.h
index ef4138630..4605ff844 100644
--- a/bsd/ppc/signal.h
+++ b/bsd/ppc/signal.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/ppc/spl.h b/bsd/ppc/spl.h
index 01d0c0b21..8731f1e74 100644
--- a/bsd/ppc/spl.h
+++ b/bsd/ppc/spl.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/ppc/table.h b/bsd/ppc/table.h
index ff4d1dc34..34fdb9460 100644
--- a/bsd/ppc/table.h
+++ b/bsd/ppc/table.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/ppc/types.h b/bsd/ppc/types.h
index f370e9bf1..b3c08099b 100644
--- a/bsd/ppc/types.h
+++ b/bsd/ppc/types.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/ppc/ucontext.h b/bsd/ppc/ucontext.h
index c2d9d31fb..fb311c5b6 100644
--- a/bsd/ppc/ucontext.h
+++ b/bsd/ppc/ucontext.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -37,4 +40,14 @@ struct mcontext {
 
 typedef struct mcontext  * mcontext_t;
 
+struct mcontext64 {
+	ppc_exception_state_t	es;
+	ppc_thread_state64_t	ss;
+	ppc_float_state_t	fs;
+	ppc_vector_state_t	vs;
+};
+#define PPC_MCONTEXT64_SIZE	(PPC_THREAD_STATE64_COUNT + PPC_FLOAT_STATE_COUNT + PPC_EXCEPTION_STATE_COUNT + PPC_VECTOR_STATE_COUNT) * sizeof(int)
+
+typedef struct mcontext64  * mcontext64_t;
+
 #endif /* _PPC_UCONTEXT_H_ */
diff --git a/bsd/ppc/user.h b/bsd/ppc/user.h
index 5914cf757..5d27318eb 100644
--- a/bsd/ppc/user.h
+++ b/bsd/ppc/user.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/ppc/vmparam.h b/bsd/ppc/vmparam.h
index 90db43aba..790696cfe 100644
--- a/bsd/ppc/vmparam.h
+++ b/bsd/ppc/vmparam.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/acct.h b/bsd/sys/acct.h
index 01aa44369..4d1e97a9a 100644
--- a/bsd/sys/acct.h
+++ b/bsd/sys/acct.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/appleapiopts.h b/bsd/sys/appleapiopts.h
index 2ecde9dee..3a40f59ca 100644
--- a/bsd/sys/appleapiopts.h
+++ b/bsd/sys/appleapiopts.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/attr.h b/bsd/sys/attr.h
index 732410ea6..a4b0b3dae 100644
--- a/bsd/sys/attr.h
+++ b/bsd/sys/attr.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/buf.h b/bsd/sys/buf.h
index d051d11f0..9fb7de80a 100644
--- a/bsd/sys/buf.h
+++ b/bsd/sys/buf.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/callout.h b/bsd/sys/callout.h
index 61c4dee0b..309765328 100644
--- a/bsd/sys/callout.h
+++ b/bsd/sys/callout.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/cdefs.h b/bsd/sys/cdefs.h
index 7f5bb8b99..af2221256 100644
--- a/bsd/sys/cdefs.h
+++ b/bsd/sys/cdefs.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/clist.h b/bsd/sys/clist.h
index 64cb2eaea..a29bef8fd 100644
--- a/bsd/sys/clist.h
+++ b/bsd/sys/clist.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/conf.h b/bsd/sys/conf.h
index d3b213bf0..0f2305936 100644
--- a/bsd/sys/conf.h
+++ b/bsd/sys/conf.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/dir.h b/bsd/sys/dir.h
index 112b8526c..f484ab100 100644
--- a/bsd/sys/dir.h
+++ b/bsd/sys/dir.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/dirent.h b/bsd/sys/dirent.h
index 8dc0359cc..61877ae36 100644
--- a/bsd/sys/dirent.h
+++ b/bsd/sys/dirent.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/disk.h b/bsd/sys/disk.h
index 65a4bffdd..8edb0f368 100644
--- a/bsd/sys/disk.h
+++ b/bsd/sys/disk.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/disklabel.h b/bsd/sys/disklabel.h
index 4fa09f226..27ffecdef 100644
--- a/bsd/sys/disklabel.h
+++ b/bsd/sys/disklabel.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/disktab.h b/bsd/sys/disktab.h
index 4df1f84f7..890cb5893 100644
--- a/bsd/sys/disktab.h
+++ b/bsd/sys/disktab.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/dkstat.h b/bsd/sys/dkstat.h
index b0b256936..992dc2744 100644
--- a/bsd/sys/dkstat.h
+++ b/bsd/sys/dkstat.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/dmap.h b/bsd/sys/dmap.h
index 3234c4d5d..249d7b303 100644
--- a/bsd/sys/dmap.h
+++ b/bsd/sys/dmap.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/domain.h b/bsd/sys/domain.h
index e6a75966c..a622b61d5 100644
--- a/bsd/sys/domain.h
+++ b/bsd/sys/domain.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/errno.h b/bsd/sys/errno.h
index c82770b59..4318fc90a 100644
--- a/bsd/sys/errno.h
+++ b/bsd/sys/errno.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/ev.h b/bsd/sys/ev.h
index 16757b77f..30ee688f4 100644
--- a/bsd/sys/ev.h
+++ b/bsd/sys/ev.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/exec.h b/bsd/sys/exec.h
index 5d4fb571e..a0dd04095 100644
--- a/bsd/sys/exec.h
+++ b/bsd/sys/exec.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/fcntl.h b/bsd/sys/fcntl.h
index 6e274f663..ba9033ac1 100644
--- a/bsd/sys/fcntl.h
+++ b/bsd/sys/fcntl.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/file.h b/bsd/sys/file.h
index 7d6ace763..8a29f42f6 100644
--- a/bsd/sys/file.h
+++ b/bsd/sys/file.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -63,6 +66,7 @@
 #include <sys/unistd.h>
 
 #ifdef KERNEL
+#include <sys/errno.h>
 #include <sys/queue.h>
 #include <sys/cdefs.h>
 
@@ -100,7 +104,7 @@ struct file {
 		int	(*fo_close)	__P((struct file *fp, struct proc *p));
 	} *f_ops;
 	off_t	f_offset;
-	caddr_t	f_data;		/* vnode or socket */
+	caddr_t	f_data;		/* vnode or socket or SHM or semaphore */
 };
 
 #ifdef __APPLE_API_PRIVATE
@@ -130,7 +134,8 @@ fo_read(struct file *fp, struct uio *uio, struct ucred *cred, int flags, struct
 {
 	int error;
 
-	fref(fp);
+	if ((error = fref(fp)) == -1)
+		return (EBADF);
 	error = (*fp->f_ops->fo_read)(fp, uio, cred, flags, p);
 	frele(fp);
 	return (error);
@@ -141,7 +146,8 @@ fo_write(struct file *fp, struct uio *uio, struct ucred *cred, int flags, struct
 {
 	int error;
 
-	fref(fp);
+	if ((error = fref(fp)) == -1)
+		return (EBADF);
 	error = (*fp->f_ops->fo_write)(fp, uio, cred, flags, p);
 	frele(fp);
 	return (error);
@@ -152,7 +158,8 @@ fo_ioctl(struct file *fp, u_long com, caddr_t data, struct proc *p)
 {
 	int error;   
 
-	fref(fp);
+	if ((error = fref(fp)) == -1)
+		return (EBADF);
 	error = (*fp->f_ops->fo_ioctl)(fp, com, data, p);
 	frele(fp);
 	return (error);
diff --git a/bsd/sys/filedesc.h b/bsd/sys/filedesc.h
index 2353a06e2..63a254366 100644
--- a/bsd/sys/filedesc.h
+++ b/bsd/sys/filedesc.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/filio.h b/bsd/sys/filio.h
index 10465cc8e..16fb12a5c 100644
--- a/bsd/sys/filio.h
+++ b/bsd/sys/filio.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/fsctl.h b/bsd/sys/fsctl.h
index 63198c7ec..2e09af2ed 100644
--- a/bsd/sys/fsctl.h
+++ b/bsd/sys/fsctl.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/gmon.h b/bsd/sys/gmon.h
index b368a1fd2..d4671a6ec 100644
--- a/bsd/sys/gmon.h
+++ b/bsd/sys/gmon.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/ioccom.h b/bsd/sys/ioccom.h
index 00e87d9aa..03968274a 100644
--- a/bsd/sys/ioccom.h
+++ b/bsd/sys/ioccom.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/ioctl.h b/bsd/sys/ioctl.h
index a9dfad6b3..7d398a291 100644
--- a/bsd/sys/ioctl.h
+++ b/bsd/sys/ioctl.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/ioctl_compat.h b/bsd/sys/ioctl_compat.h
index 9ff3a2bc1..ae5422533 100644
--- a/bsd/sys/ioctl_compat.h
+++ b/bsd/sys/ioctl_compat.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/ipc.h b/bsd/sys/ipc.h
index 5c642955e..78632ace0 100644
--- a/bsd/sys/ipc.h
+++ b/bsd/sys/ipc.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/kdebug.h b/bsd/sys/kdebug.h
index 305ac531d..1cc5d2979 100644
--- a/bsd/sys/kdebug.h
+++ b/bsd/sys/kdebug.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -88,6 +91,7 @@ __BEGIN_DECLS
 #define	DBG_MACH_EXCP_DECI	0x09	/* Decrementer Interrupt */
 #define	DBG_MACH_EXCP_SC	0x0C	/* System Calls */
 #define	DBG_MACH_EXCP_TRACE	0x0D	/* Trace exception */
+#define	DBG_MACH_EXCP_EMUL	0x0E	/* Instruction emulated */
 #define	DBG_MACH_IHDLR		0x10	/* Interrupt Handlers */
 #define	DBG_MACH_IPC		0x20	/* Inter Process Comm */
 #define	DBG_MACH_VM		0x30	/* Virtual Memory */
diff --git a/bsd/sys/kern_control.h b/bsd/sys/kern_control.h
index 04b37c06a..ea9091fec 100644
--- a/bsd/sys/kern_control.h
+++ b/bsd/sys/kern_control.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/kern_event.h b/bsd/sys/kern_event.h
index 5a232c02a..84a496f1d 100644
--- a/bsd/sys/kern_event.h
+++ b/bsd/sys/kern_event.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/kernel.h b/bsd/sys/kernel.h
index 420f56e2d..2c37bce7d 100644
--- a/bsd/sys/kernel.h
+++ b/bsd/sys/kernel.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/ktrace.h b/bsd/sys/ktrace.h
index ce39adb2d..c280945a4 100644
--- a/bsd/sys/ktrace.h
+++ b/bsd/sys/ktrace.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/linker_set.h b/bsd/sys/linker_set.h
index 25776d91a..807a982e7 100644
--- a/bsd/sys/linker_set.h
+++ b/bsd/sys/linker_set.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/loadable_fs.h b/bsd/sys/loadable_fs.h
index 1d198c74d..eef7692bd 100644
--- a/bsd/sys/loadable_fs.h
+++ b/bsd/sys/loadable_fs.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/lock.h b/bsd/sys/lock.h
index de18dd2d1..c08bdc006 100644
--- a/bsd/sys/lock.h
+++ b/bsd/sys/lock.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/lockf.h b/bsd/sys/lockf.h
index 0c3339c78..226b91aba 100644
--- a/bsd/sys/lockf.h
+++ b/bsd/sys/lockf.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/mach_swapon.h b/bsd/sys/mach_swapon.h
index fcba2d61b..18fccd5f1 100644
--- a/bsd/sys/mach_swapon.h
+++ b/bsd/sys/mach_swapon.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/malloc.h b/bsd/sys/malloc.h
index 751de10e5..781ce11a0 100644
--- a/bsd/sys/malloc.h
+++ b/bsd/sys/malloc.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -164,9 +167,10 @@
 #define M_IP6MISC	88	/* IPv6 misc. memory */
 #define M_TSEGQ		89	/* TCP segment queue entry */
 #define M_IGMP		90
-#define M_JOURNAL       91      /* VFS Journaling code */
+#define M_JNL_JNL   91  /* Journaling: "struct journal" */
+#define M_JNL_TR    92  /* Journaling: "struct transaction" */ 
 
-#define	M_LAST		92	/* Must be last type + 1 */
+#define	M_LAST		93	/* Must be last type + 1 */
 
 /* Strings corresponding to types of memory */
 /* Must be in synch with the #defines above */
@@ -256,13 +260,14 @@
 	"DEVFS",	/* 82 M_DEVFS */ \
 	"IpFw/IpAcct",	/* 83 M_IPFW */ \
 	"UDF node",	/* 84 M_UDFNODE */ \
-	"UDF mount"	/* 85 M_UDFMNT */ \
+	"UDF mount",	/* 85 M_UDFMNT */ \
 	"IPv6 NDP",	/* 86 M_IP6NDP */ \
 	"IPv6 options",	/* 87 M_IP6OPT */ \
 	"IPv6 Misc",	/* 88 M_IP6MISC */\
 	"TCP Segment Q",/* 89 M_TSEGQ */\
 	"IGMP state",	/* 90 M_IGMP */\
-	"Journaling"    /* 91 M_JOURNAL */\
+	"Journal",    /* 91 M_JNL_JNL */\
+	"Transaction"    /* 92 M_JNL_TR */\
 }
 
 struct kmemstats {
diff --git a/bsd/sys/mbuf.h b/bsd/sys/mbuf.h
index 360b80d91..8de818489 100644
--- a/bsd/sys/mbuf.h
+++ b/bsd/sys/mbuf.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/mman.h b/bsd/sys/mman.h
index 57faf0299..255f6bab3 100644
--- a/bsd/sys/mman.h
+++ b/bsd/sys/mman.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/mount.h b/bsd/sys/mount.h
index 2b8e1e05c..dbb687214 100644
--- a/bsd/sys/mount.h
+++ b/bsd/sys/mount.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/msg.h b/bsd/sys/msg.h
index 76e3f1c27..7621a0966 100644
--- a/bsd/sys/msg.h
+++ b/bsd/sys/msg.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/msgbuf.h b/bsd/sys/msgbuf.h
index 15e2dcb86..2465b7ecb 100644
--- a/bsd/sys/msgbuf.h
+++ b/bsd/sys/msgbuf.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/mtio.h b/bsd/sys/mtio.h
index ab2f39e65..36636f58e 100644
--- a/bsd/sys/mtio.h
+++ b/bsd/sys/mtio.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/namei.h b/bsd/sys/namei.h
index 552dc822b..40faa46e9 100644
--- a/bsd/sys/namei.h
+++ b/bsd/sys/namei.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/netport.h b/bsd/sys/netport.h
index 177eeb37a..2734fd7d2 100644
--- a/bsd/sys/netport.h
+++ b/bsd/sys/netport.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/param.h b/bsd/sys/param.h
index f8ee80b46..af0d5d043 100644
--- a/bsd/sys/param.h
+++ b/bsd/sys/param.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/paths.h b/bsd/sys/paths.h
index 6078c7d7c..83b56cc8d 100644
--- a/bsd/sys/paths.h
+++ b/bsd/sys/paths.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/poll.h b/bsd/sys/poll.h
index 443469915..281cac737 100644
--- a/bsd/sys/poll.h
+++ b/bsd/sys/poll.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/proc.h b/bsd/sys/proc.h
index de6dcb887..28a52f1e8 100644
--- a/bsd/sys/proc.h
+++ b/bsd/sys/proc.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/protosw.h b/bsd/sys/protosw.h
index 80c1a3120..5d9c54bed 100644
--- a/bsd/sys/protosw.h
+++ b/bsd/sys/protosw.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/ptrace.h b/bsd/sys/ptrace.h
index 3ae7cdadb..134b2e48c 100644
--- a/bsd/sys/ptrace.h
+++ b/bsd/sys/ptrace.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/queue.h b/bsd/sys/queue.h
index bd4b21341..d326aed3d 100644
--- a/bsd/sys/queue.h
+++ b/bsd/sys/queue.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/quota.h b/bsd/sys/quota.h
index 470d04dc1..765ba3ac3 100644
--- a/bsd/sys/quota.h
+++ b/bsd/sys/quota.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -268,7 +271,7 @@ struct dquot {
 	u_int16_t dq_type;		/* quota type of this dquot */
 	u_int32_t dq_id;		/* identifier this applies to */
 	u_int32_t dq_index;		/* index into quota file */
-        struct	quotafile *dq_qfile;	/* quota file that this is taken from */
+	struct	quotafile *dq_qfile;	/* quota file that this is taken from */
 	struct	dqblk dq_dqb;		/* actual usage & quotas */
 };
 /*
@@ -318,7 +321,9 @@ int	dqget(struct vnode *, u_long, struct quotafile *, int, struct dquot **);
 void	dqinit(void);
 void	dqref(struct dquot *);
 void	dqrele(struct vnode *, struct dquot *);
+void	dqreclaim(struct vnode *, struct dquot *);
 int	dqsync(struct vnode *, struct dquot *);
+void	dqsync_orphans(struct quotafile *);
 __END_DECLS
 
 #endif /* KERNEL */
diff --git a/bsd/sys/random.h b/bsd/sys/random.h
index c8976a552..6b1dbe8c9 100644
--- a/bsd/sys/random.h
+++ b/bsd/sys/random.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/reboot.h b/bsd/sys/reboot.h
index a312ed635..de402586e 100644
--- a/bsd/sys/reboot.h
+++ b/bsd/sys/reboot.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/resource.h b/bsd/sys/resource.h
index e2f12be0f..df6c74927 100644
--- a/bsd/sys/resource.h
+++ b/bsd/sys/resource.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/resourcevar.h b/bsd/sys/resourcevar.h
index 77b30d6fd..33f1e2210 100644
--- a/bsd/sys/resourcevar.h
+++ b/bsd/sys/resourcevar.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/select.h b/bsd/sys/select.h
index 8c67dc5c5..775c58d1c 100644
--- a/bsd/sys/select.h
+++ b/bsd/sys/select.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/sem.h b/bsd/sys/sem.h
index ebcb13955..9aa6bd8ef 100644
--- a/bsd/sys/sem.h
+++ b/bsd/sys/sem.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/semaphore.h b/bsd/sys/semaphore.h
index 16e0dfc5c..75ca1c01d 100644
--- a/bsd/sys/semaphore.h
+++ b/bsd/sys/semaphore.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/shm.h b/bsd/sys/shm.h
index af9c1f1cc..f6f43f5f8 100644
--- a/bsd/sys/shm.h
+++ b/bsd/sys/shm.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/signal.h b/bsd/sys/signal.h
index 36d5872eb..c2af5f2d7 100644
--- a/bsd/sys/signal.h
+++ b/bsd/sys/signal.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -131,6 +134,8 @@
 #endif
 
 #ifndef _ANSI_SOURCE
+#include <sys/types.h>
+
 typedef unsigned int sigset_t;
 
 union sigval {
@@ -155,7 +160,7 @@ typedef struct __siginfo {
 	void	*si_addr;		/* faulting instruction */
 	union sigval si_value;		/* signal value */
 	long	si_band;		/* band event for SIGPOLL */
-	int	pad[7];			/* RFU */
+	unsigned int	pad[7];		/* Reserved for Future Use */
 } siginfo_t;
 
 /* 
@@ -241,6 +246,8 @@ struct	sigaction {
 #define	SA_NOCLDWAIT	0x0020	/* don't keep zombies around */
 #define	SA_SIGINFO	0x0040	/* signal handler with SA_SIGINFO args */
 #define	SA_USERTRAMP	0x0100	/* do not bounce off kernel's sigtramp */
+/* This will provide 64bit register set in a 32bit user address space */
+#define	SA_64REGSET	0x0200	/* signal handler with SA_SIGINFO args with 64bit regs information */
 #endif
 #define SA_NOCLDSTOP	0x0008	/* do not generate SIGCHLD on child stop */
 
diff --git a/bsd/sys/signalvar.h b/bsd/sys/signalvar.h
index 68199f53e..beb83e255 100644
--- a/bsd/sys/signalvar.h
+++ b/bsd/sys/signalvar.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -86,6 +89,7 @@ struct	sigacts {
 	int	ps_code;		/* for core dump/debugger XXX */
 	int	ps_addr;		/* for core dump/debugger XXX */
 	sigset_t ps_usertramp;		/* SunOS compat; libc sigtramp XXX */
+	sigset_t ps_64regset;		/* signals that want SA_EXSIGINFO args */
 };
 
 /* signal flags */
diff --git a/bsd/sys/socket.h b/bsd/sys/socket.h
index 3790d7305..2a0db2834 100644
--- a/bsd/sys/socket.h
+++ b/bsd/sys/socket.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/socketvar.h b/bsd/sys/socketvar.h
index bf767c249..e60037bba 100644
--- a/bsd/sys/socketvar.h
+++ b/bsd/sys/socketvar.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/sockio.h b/bsd/sys/sockio.h
index 964cce9cb..723e3e75b 100644
--- a/bsd/sys/sockio.h
+++ b/bsd/sys/sockio.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -136,7 +139,7 @@
  */
 #define	SIOCPROTOATTACH	_IOWR('i', 80, struct ifreq)	/* attach proto to interface */
 #define	SIOCPROTODETACH	_IOWR('i', 81, struct ifreq)	/* detach proto from interface */
-#endif KERNEL_PRIVATE
+#endif /* KERNEL_PRIVATE */
 
 #define	SIOCGIFASYNCMAP _IOWR('i', 124, struct ifreq)	/* get ppp asyncmap */
 #define	SIOCSIFASYNCMAP _IOW('i', 125, struct ifreq)	/* set ppp asyncmap */
diff --git a/bsd/sys/stat.h b/bsd/sys/stat.h
index 22c79a223..b92ffb717 100644
--- a/bsd/sys/stat.h
+++ b/bsd/sys/stat.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/subr_prf.h b/bsd/sys/subr_prf.h
index 830ea6a74..81296de75 100644
--- a/bsd/sys/subr_prf.h
+++ b/bsd/sys/subr_prf.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/sys_domain.h b/bsd/sys/sys_domain.h
index b9582eca3..521e961ff 100644
--- a/bsd/sys/sys_domain.h
+++ b/bsd/sys/sys_domain.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/syscall.h b/bsd/sys/syscall.h
index ade503bb6..f8aa3cce0 100644
--- a/bsd/sys/syscall.h
+++ b/bsd/sys/syscall.h
@@ -1,21 +1,24 @@
 /*
- * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -136,7 +139,9 @@
 #define	SYS_getpriority	100
 				/* 101 is old send */
 				/* 102 is old recv */
+#ifndef __ppc__
 #define	SYS_sigreturn	103
+#endif
 #define	SYS_bind	104
 #define	SYS_setsockopt	105
 #define	SYS_listen	106
@@ -217,7 +222,9 @@
 #define	SYS_setgid	181
 #define	SYS_setegid	182
 #define	SYS_seteuid	183
-				/* 184 is unused */
+#ifdef __ppc__
+#define	SYS_sigreturn	184
+#endif
 				/* 185 is unused */
 				/* 186 is unused */
 				/* 187 is unused */
diff --git a/bsd/sys/sysctl.h b/bsd/sys/sysctl.h
index 300072522..8af90d6ed 100644
--- a/bsd/sys/sysctl.h
+++ b/bsd/sys/sysctl.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -111,6 +114,9 @@ struct ctlname {
 #define CTLFLAG_NOLOCK	0x20000000	/* XXX Don't Lock */
 #define CTLFLAG_ANYBODY	0x10000000	/* All users can set this var */
 #define CTLFLAG_SECURE	0x08000000	/* Permit set only if securelevel<=0 */
+#define CTLFLAG_MASKED	0x04000000	/* deprecated variable, do not display */
+#define CTLFLAG_NOAUTO	0x02000000	/* do not auto-register */
+#define CTLFLAG_KERN	0x01000000	/* valid inside the kernel */
 
 /*
  * USE THIS instead of a hardwired number from the categories below
@@ -166,7 +172,9 @@ struct sysctl_oid {
 
 int sysctl_handle_int SYSCTL_HANDLER_ARGS;
 int sysctl_handle_long SYSCTL_HANDLER_ARGS;
-int sysctl_handle_intptr SYSCTL_HANDLER_ARGS;
+int sysctl_handle_quad SYSCTL_HANDLER_ARGS;
+int sysctl_handle_int2quad SYSCTL_HANDLER_ARGS;
+/*int sysctl_handle_intptr SYSCTL_HANDLER_ARGS; XXX not implemented */
 int sysctl_handle_string SYSCTL_HANDLER_ARGS;
 int sysctl_handle_opaque SYSCTL_HANDLER_ARGS;
 
@@ -209,6 +217,16 @@ void sysctl_unregister_oid(struct sysctl_oid *oidp);
 	SYSCTL_OID(parent, nbr, name, CTLTYPE_INT|access, \
 		ptr, 0, sysctl_handle_long, "L", descr)
 
+/* Oid for a quad.  The pointer must be non NULL. */
+#define SYSCTL_QUAD(parent, nbr, name, access, ptr, descr) \
+	SYSCTL_OID(parent, nbr, name, CTLTYPE_QUAD|access, \
+		ptr, 0, sysctl_handle_quad, "Q", descr)
+
+/* Oid for a int returned as quad.  The pointer must be non NULL. */
+#define SYSCTL_INT2QUAD(parent, nbr, name, access, ptr, descr) \
+	SYSCTL_OID(parent, nbr, name, CTLTYPE_QUAD|access, \
+		ptr, 0, sysctl_handle_int2quad, "Q", descr)
+
 /* Oid for an opaque object.  Specified by a pointer and a length. */
 #define SYSCTL_OPAQUE(parent, nbr, name, access, ptr, len, fmt, descr) \
 	SYSCTL_OID(parent, nbr, name, CTLTYPE_OPAQUE|access, \
@@ -495,7 +513,10 @@ struct kinfo_proc {
 #define HW_L2CACHESIZE	20		/* int: L2 Cache Size in Bytes */
 #define HW_L3SETTINGS	21		/* int: L3 Cache Settings */
 #define HW_L3CACHESIZE	22		/* int: L3 Cache Size in Bytes */
-#define	HW_MAXID	23		/* number of valid hw ids */
+#define HW_TB_FREQ	23		/* int: Bus Frequency */
+#define HW_MEMSIZE	24		/* uint64_t: physical ram size */
+#define HW_AVAILCPU	25		/* int: number of available CPUs */
+#define	HW_MAXID	26		/* number of valid hw ids */
 
 #define CTL_HW_NAMES { \
 	{ 0, 0 }, \
@@ -520,9 +541,73 @@ struct kinfo_proc {
 	{ "l2settings", CTLTYPE_INT }, \
 	{ "l2cachesize", CTLTYPE_INT }, \
 	{ "l3settings", CTLTYPE_INT }, \
-	{ "l3cachesize", CTLTYPE_INT } \
+	{ "l3cachesize", CTLTYPE_INT }, \
+	{ "tbfrequency", CTLTYPE_INT }, \
+	{ "memsize", CTLTYPE_QUAD }, \
+	{ "availcpu", CTLTYPE_INT } \
 }
 
+/*
+ * These are the support HW selectors for sysctlbyname.  Parameters that are byte count or frequencies are 64 bit numbers.
+ * All other parameters are 32 bit numbers.
+ *
+ *   hw.memsize                - The number of bytes of physical memory in the system.
+ *
+ *   hw.ncpu                   - The number maximum number of processor that could be available this boot.
+ *                               Use this value for sizing of static per processor arrays; i.e. processor load statistics.
+ *
+ *   hw.activecpu              - The number of cpus currently available for executing threads.
+ *                               Use this number to determine the number threads to create in SMP aware applications.
+ *                               This number can change when power management modes are changed.
+ *   
+ *   hw.tbfrequency            - This gives the time base frequency used by the OS and is the basis of all timing services.
+ *                               In general is is better to use mach's or higher level timing services, but this value
+ *                               is needed to convert the PPC Time Base registers to real time.
+ *
+ *   hw.cpufrequency           - These values provide the current, min and max cpu frequency.  The min and max are for
+ *   hw.cpufrequency_max       - all power management modes.  The current frequency is the max frequency in the current mode.
+ *   hw.cpufrequency_min       - All frequencies are in Hz.
+ *
+ *   hw.busfrequency           - These values provide the current, min and max bus frequency.  The min and max are for
+ *   hw.busfrequency_max       - all power management modes.  The current frequency is the max frequency in the current mode.
+ *   hw.busfrequency_min       - All frequencies are in Hz.
+ *
+ *   hw.cputype                - These values provide the mach-o cpu type and subtype.  A complete list is in <mach/machine.h>
+ *   hw.cpusubtype             - These values should be used to determine what processor family the running cpu is from so that
+ *                               the best binary can be chosen, or the best dynamic code generated.  They should not be used
+ *                               to determine if a given processor feature is available.
+ *
+ *   hw.byteorder              - Gives the byte order of the processor.  4321 for big endian, 1234 for little.
+ *
+ *   hw.pagesize               - Gives the size in bytes of the pages used by the processor and VM system.
+ *
+ *   hw.cachelinesize          - Gives the size in bytes of the processor's cache lines.
+ *                               This value should be use to control the strides of loops that use cache control instructions
+ *                               like dcbz, dcbt or dcbst.
+ *
+ *   hw.l1dcachesize           - These values provide the size in bytes of the L1, L2 and L3 caches.  If a cache is not present
+ *   hw.l1icachesize           - then the selector will return and error.
+ *   hw.l2cachesize            -
+ *   hw.l3cachesize            -
+ *
+ *
+ * These are the selectors for optional processor features.  Selectors that return errors are not support on the system.
+ * Supported features will return 1 if they are recommended or 0 if they are supported but are not expected to help performance.
+ * Future versions of these selectors may return larger values as necessary so it is best to test for non zero.
+ *
+ *   hw.optional.floatingpoint - Floating Point Instructions
+ *   hw.optional.altivec       - AltiVec Instructions
+ *   hw.optional.graphicsops   - Graphics Operations
+ *   hw.optional.64bitops      - 64-bit Instructions
+ *   hw.optional.fsqrt         - HW Floating Point Square Root Instruction
+ *   hw.optional.stfiwx        - Store Floating Point as Integer Word Indexed Instructions
+ *   hw.optional.dcba          - Data Cache Block Allocate Instruction
+ *   hw.optional.datastreams   - Data Streams Instructions
+ *   hw.optional.dcbtstreams   - Data Cache Block Touch Steams Instruction Form
+ *
+ */
+
+
 /*
  * CTL_USER definitions
  */
@@ -630,12 +715,21 @@ struct linker_set;
 
 void	sysctl_register_set(struct linker_set *lsp);
 void	sysctl_unregister_set(struct linker_set *lsp);
+void	sysctl_mib_init(void);
 int	kernel_sysctl(struct proc *p, int *name, u_int namelen, void *old,
-		      size_t *oldlenp, void *new, size_t newlen,
-		      size_t *retval);
+		      size_t *oldlenp, void *newp, size_t newlen);
 int	userland_sysctl(struct proc *p, int *name, u_int namelen, void *old,
-			size_t *oldlenp, int inkernel, void *new, size_t newlen,
+			size_t *oldlenp, int inkernel, void *newp, size_t newlen,
 			size_t *retval);
+
+/*
+ * Sysctl handling within the kernel.
+ *
+ * May be called with either or no funnel held; will take and
+ * switch funnels as required.
+ */
+int	sysctlbyname __P((const char *, void *, size_t *, void *, size_t));
+
 /*
  * Internal sysctl function calling convention:
  *
diff --git a/bsd/sys/syslimits.h b/bsd/sys/syslimits.h
index a43c854a1..54f538e54 100644
--- a/bsd/sys/syslimits.h
+++ b/bsd/sys/syslimits.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/syslog.h b/bsd/sys/syslog.h
index eae10fa0e..1f8032e3a 100644
--- a/bsd/sys/syslog.h
+++ b/bsd/sys/syslog.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/systm.h b/bsd/sys/systm.h
index 3110e2679..ea1c0642c 100644
--- a/bsd/sys/systm.h
+++ b/bsd/sys/systm.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/table.h b/bsd/sys/table.h
index a59713b4e..7095a6519 100644
--- a/bsd/sys/table.h
+++ b/bsd/sys/table.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/termios.h b/bsd/sys/termios.h
index 71afa6606..1d9e959c1 100644
--- a/bsd/sys/termios.h
+++ b/bsd/sys/termios.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/time.h b/bsd/sys/time.h
index 65b5c52db..cc790bf23 100644
--- a/bsd/sys/time.h
+++ b/bsd/sys/time.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/timeb.h b/bsd/sys/timeb.h
index 9277d37d7..6ccac0769 100644
--- a/bsd/sys/timeb.h
+++ b/bsd/sys/timeb.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/times.h b/bsd/sys/times.h
index 01d0a3734..744582da3 100644
--- a/bsd/sys/times.h
+++ b/bsd/sys/times.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/tprintf.h b/bsd/sys/tprintf.h
index 8eaa93748..df5509fec 100644
--- a/bsd/sys/tprintf.h
+++ b/bsd/sys/tprintf.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/trace.h b/bsd/sys/trace.h
index c77ef1ca8..6ae28ba2c 100644
--- a/bsd/sys/trace.h
+++ b/bsd/sys/trace.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/tty.h b/bsd/sys/tty.h
index c24e3083b..379e0a1bb 100644
--- a/bsd/sys/tty.h
+++ b/bsd/sys/tty.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/ttychars.h b/bsd/sys/ttychars.h
index 15a12df1a..55aeabafc 100644
--- a/bsd/sys/ttychars.h
+++ b/bsd/sys/ttychars.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/ttycom.h b/bsd/sys/ttycom.h
index 5baac4b80..c9c6172c5 100644
--- a/bsd/sys/ttycom.h
+++ b/bsd/sys/ttycom.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/ttydefaults.h b/bsd/sys/ttydefaults.h
index b11fbb6d3..05ceaecb5 100644
--- a/bsd/sys/ttydefaults.h
+++ b/bsd/sys/ttydefaults.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/ttydev.h b/bsd/sys/ttydev.h
index 82a1ef4b9..220fa2eff 100644
--- a/bsd/sys/ttydev.h
+++ b/bsd/sys/ttydev.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/types.h b/bsd/sys/types.h
index 8ff840d65..44328bf2b 100644
--- a/bsd/sys/types.h
+++ b/bsd/sys/types.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/ubc.h b/bsd/sys/ubc.h
index e6a2a189d..24058f37a 100644
--- a/bsd/sys/ubc.h
+++ b/bsd/sys/ubc.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -109,7 +112,7 @@ int	ubc_release_named __P((struct vnode *));
 int	ubc_invalidate __P((struct vnode *, off_t, size_t));
 int	ubc_isinuse __P((struct vnode *, int));
 
-int	ubc_page_op __P((struct vnode *, off_t, int, vm_offset_t *, int *));
+int	ubc_page_op __P((struct vnode *, off_t, int, ppnum_t *, int *));
 
 /* cluster IO routines */
 int	cluster_read __P((struct vnode *, struct uio *, off_t, int, int));
@@ -161,6 +164,7 @@ __END_DECLS
 /* Flags for ubc_getobject() */
 #define UBC_FLAGS_NONE		0x0000
 #define UBC_HOLDOBJECT		0x0001
+#define UBC_FOR_PAGEOUT         0x0002
 
 #endif /* __APPLE_API_EVOLVING */
 
diff --git a/bsd/sys/ucontext.h b/bsd/sys/ucontext.h
index e66df1e4c..993d22487 100644
--- a/bsd/sys/ucontext.h
+++ b/bsd/sys/ucontext.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -34,6 +37,18 @@ struct ucontext {
 	mcontext_t	uc_mcontext;	/* machine specific context */
 };
 
+
 typedef struct ucontext ucontext_t;
 
+struct ucontext64 {
+	int		uc_onstack;
+	sigset_t	uc_sigmask;	/* signal mask used by this context */
+	stack_t 	uc_stack;	/* stack used by this context */
+	struct ucontext	*uc_link;	/* pointer to resuming context */
+	size_t		uc_mcsize;	/* size of the machine context passed in */
+	mcontext64_t	uc_mcontext64;	/* machine specific context */
+};
+
+typedef struct ucontext64 ucontext64_t;
+
 #endif /* _SYS_UCONTEXT_H_ */
diff --git a/bsd/sys/ucred.h b/bsd/sys/ucred.h
index 0c5032116..23e739a7f 100644
--- a/bsd/sys/ucred.h
+++ b/bsd/sys/ucred.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/uio.h b/bsd/sys/uio.h
index c9bd96de6..f6e3b0bc1 100644
--- a/bsd/sys/uio.h
+++ b/bsd/sys/uio.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -95,6 +98,7 @@ struct uio {
 #define UIO_SMALLIOV	8		/* 8 on stack, else malloc */
 
 extern int uiomove __P((caddr_t cp, int n, struct uio *uio));
+extern int uiomove64 __P((unsigned long long cp, int n, struct uio *uio));
 extern int ureadc __P((int c, struct uio *uio));
 extern int uwritec __P((struct uio *uio));
 
diff --git a/bsd/sys/un.h b/bsd/sys/un.h
index e3e4cdb5c..8a7ec3130 100644
--- a/bsd/sys/un.h
+++ b/bsd/sys/un.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/unistd.h b/bsd/sys/unistd.h
index 252212434..00199aa57 100644
--- a/bsd/sys/unistd.h
+++ b/bsd/sys/unistd.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/unpcb.h b/bsd/sys/unpcb.h
index 408cc93d1..91a92b79a 100644
--- a/bsd/sys/unpcb.h
+++ b/bsd/sys/unpcb.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/user.h b/bsd/sys/user.h
index a9c3a236c..099080040 100644
--- a/bsd/sys/user.h
+++ b/bsd/sys/user.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/utfconv.h b/bsd/sys/utfconv.h
index 0af9b52f4..9c0a4af89 100644
--- a/bsd/sys/utfconv.h
+++ b/bsd/sys/utfconv.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/utsname.h b/bsd/sys/utsname.h
index 35779be0d..dd5e94c4a 100644
--- a/bsd/sys/utsname.h
+++ b/bsd/sys/utsname.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/ux_exception.h b/bsd/sys/ux_exception.h
index 2b55b6cb5..106553691 100644
--- a/bsd/sys/ux_exception.h
+++ b/bsd/sys/ux_exception.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/vadvise.h b/bsd/sys/vadvise.h
index 09ee127ca..69b1a261b 100644
--- a/bsd/sys/vadvise.h
+++ b/bsd/sys/vadvise.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/vcmd.h b/bsd/sys/vcmd.h
index 9e5b596cd..36e6c062f 100644
--- a/bsd/sys/vcmd.h
+++ b/bsd/sys/vcmd.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/version.h b/bsd/sys/version.h
index 308e5f5f4..ab489356a 100644
--- a/bsd/sys/version.h
+++ b/bsd/sys/version.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/vlimit.h b/bsd/sys/vlimit.h
index 5c0f0b617..e140df777 100644
--- a/bsd/sys/vlimit.h
+++ b/bsd/sys/vlimit.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/vm.h b/bsd/sys/vm.h
index 1718e1369..72eab024a 100644
--- a/bsd/sys/vm.h
+++ b/bsd/sys/vm.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/vmmeter.h b/bsd/sys/vmmeter.h
index 0564670bc..021dbfbbe 100644
--- a/bsd/sys/vmmeter.h
+++ b/bsd/sys/vmmeter.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/vmparam.h b/bsd/sys/vmparam.h
index d3ada1c8d..e0ac04c78 100644
--- a/bsd/sys/vmparam.h
+++ b/bsd/sys/vmparam.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/vnioctl.h b/bsd/sys/vnioctl.h
index 6e8e15e8c..8c37314c7 100644
--- a/bsd/sys/vnioctl.h
+++ b/bsd/sys/vnioctl.h
@@ -89,6 +89,6 @@ struct vn_ioctl {
 
 #endif /* __APPLE_API_PRIVATE */
 
-#endif KERNEL_PRIVATE
+#endif /* KERNEL_PRIVATE */
 
 #endif	/* _SYS_VNIOCTL_H_*/
diff --git a/bsd/sys/vnode.h b/bsd/sys/vnode.h
index 5023c875c..0ddf130b7 100644
--- a/bsd/sys/vnode.h
+++ b/bsd/sys/vnode.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/vnode_if.h b/bsd/sys/vnode_if.h
index 5c7ae1a39..4231e640a 100644
--- a/bsd/sys/vnode_if.h
+++ b/bsd/sys/vnode_if.h
@@ -4,19 +4,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/vstat.h b/bsd/sys/vstat.h
index 83b87ed23..cff3f73cb 100644
--- a/bsd/sys/vstat.h
+++ b/bsd/sys/vstat.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/sys/wait.h b/bsd/sys/wait.h
index 76bf41a3b..ae0aee701 100644
--- a/bsd/sys/wait.h
+++ b/bsd/sys/wait.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/ufs/ffs/ffs_alloc.c b/bsd/ufs/ffs/ffs_alloc.c
index f14ac29f9..7671afb01 100644
--- a/bsd/ufs/ffs/ffs_alloc.c
+++ b/bsd/ufs/ffs/ffs_alloc.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/ufs/ffs/ffs_balloc.c b/bsd/ufs/ffs/ffs_balloc.c
index 38cf2b72a..bfd05cd9e 100644
--- a/bsd/ufs/ffs/ffs_balloc.c
+++ b/bsd/ufs/ffs/ffs_balloc.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/ufs/ffs/ffs_extern.h b/bsd/ufs/ffs/ffs_extern.h
index 635f8cb32..8ac5276f5 100644
--- a/bsd/ufs/ffs/ffs_extern.h
+++ b/bsd/ufs/ffs/ffs_extern.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/ufs/ffs/ffs_inode.c b/bsd/ufs/ffs/ffs_inode.c
index d4f2c7bde..0ffc112e2 100644
--- a/bsd/ufs/ffs/ffs_inode.c
+++ b/bsd/ufs/ffs/ffs_inode.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/ufs/ffs/ffs_subr.c b/bsd/ufs/ffs/ffs_subr.c
index c023a273d..9c466e0b6 100644
--- a/bsd/ufs/ffs/ffs_subr.c
+++ b/bsd/ufs/ffs/ffs_subr.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/ufs/ffs/ffs_tables.c b/bsd/ufs/ffs/ffs_tables.c
index b0bec64c9..b69512673 100644
--- a/bsd/ufs/ffs/ffs_tables.c
+++ b/bsd/ufs/ffs/ffs_tables.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/ufs/ffs/ffs_vfsops.c b/bsd/ufs/ffs/ffs_vfsops.c
index e91a041f7..6e58add47 100644
--- a/bsd/ufs/ffs/ffs_vfsops.c
+++ b/bsd/ufs/ffs/ffs_vfsops.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/ufs/ffs/ffs_vnops.c b/bsd/ufs/ffs/ffs_vnops.c
index 9e94eb2bd..b095c6dd2 100644
--- a/bsd/ufs/ffs/ffs_vnops.c
+++ b/bsd/ufs/ffs/ffs_vnops.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/ufs/ffs/fs.h b/bsd/ufs/ffs/fs.h
index 6af966450..cffa4fad4 100644
--- a/bsd/ufs/ffs/fs.h
+++ b/bsd/ufs/ffs/fs.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/ufs/mfs/mfs_extern.h b/bsd/ufs/mfs/mfs_extern.h
index 5d402c2b5..88fbd483b 100644
--- a/bsd/ufs/mfs/mfs_extern.h
+++ b/bsd/ufs/mfs/mfs_extern.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/ufs/mfs/mfs_vfsops.c b/bsd/ufs/mfs/mfs_vfsops.c
index 73c989e87..71ae15bad 100644
--- a/bsd/ufs/mfs/mfs_vfsops.c
+++ b/bsd/ufs/mfs/mfs_vfsops.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/ufs/mfs/mfs_vnops.c b/bsd/ufs/mfs/mfs_vnops.c
index e1e11248a..81e4dad8a 100644
--- a/bsd/ufs/mfs/mfs_vnops.c
+++ b/bsd/ufs/mfs/mfs_vnops.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/ufs/mfs/mfsiom.h b/bsd/ufs/mfs/mfsiom.h
index de9788fa4..2f18cb18d 100644
--- a/bsd/ufs/mfs/mfsiom.h
+++ b/bsd/ufs/mfs/mfsiom.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/ufs/mfs/mfsnode.h b/bsd/ufs/mfs/mfsnode.h
index d1e5e9f91..a95554a9f 100644
--- a/bsd/ufs/mfs/mfsnode.h
+++ b/bsd/ufs/mfs/mfsnode.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/ufs/ufs/dinode.h b/bsd/ufs/ufs/dinode.h
index 09ff1dfc9..edce2e444 100644
--- a/bsd/ufs/ufs/dinode.h
+++ b/bsd/ufs/ufs/dinode.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/ufs/ufs/dir.h b/bsd/ufs/ufs/dir.h
index 9a86ec824..e61d32d01 100644
--- a/bsd/ufs/ufs/dir.h
+++ b/bsd/ufs/ufs/dir.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/ufs/ufs/inode.h b/bsd/ufs/ufs/inode.h
index f81ae2b19..b35cf294f 100644
--- a/bsd/ufs/ufs/inode.h
+++ b/bsd/ufs/ufs/inode.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/ufs/ufs/lockf.h b/bsd/ufs/ufs/lockf.h
index 92121a1f5..692e66c6c 100644
--- a/bsd/ufs/ufs/lockf.h
+++ b/bsd/ufs/ufs/lockf.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/ufs/ufs/quota.h b/bsd/ufs/ufs/quota.h
index 13de74d26..7012452e5 100644
--- a/bsd/ufs/ufs/quota.h
+++ b/bsd/ufs/ufs/quota.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/ufs/ufs/ufs_bmap.c b/bsd/ufs/ufs/ufs_bmap.c
index 86cf8a596..e4bace9f0 100644
--- a/bsd/ufs/ufs/ufs_bmap.c
+++ b/bsd/ufs/ufs/ufs_bmap.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/ufs/ufs/ufs_byte_order.c b/bsd/ufs/ufs/ufs_byte_order.c
index 0dc96b141..d39a6e610 100644
--- a/bsd/ufs/ufs/ufs_byte_order.c
+++ b/bsd/ufs/ufs/ufs_byte_order.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/ufs/ufs/ufs_byte_order.h b/bsd/ufs/ufs/ufs_byte_order.h
index 12dd0badc..e3cf36ef1 100644
--- a/bsd/ufs/ufs/ufs_byte_order.h
+++ b/bsd/ufs/ufs/ufs_byte_order.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/ufs/ufs/ufs_extern.h b/bsd/ufs/ufs/ufs_extern.h
index 7e7488fd5..33b9c783f 100644
--- a/bsd/ufs/ufs/ufs_extern.h
+++ b/bsd/ufs/ufs/ufs_extern.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/ufs/ufs/ufs_ihash.c b/bsd/ufs/ufs/ufs_ihash.c
index a3da69ee5..4bb6c9b8f 100644
--- a/bsd/ufs/ufs/ufs_ihash.c
+++ b/bsd/ufs/ufs/ufs_ihash.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/ufs/ufs/ufs_inode.c b/bsd/ufs/ufs/ufs_inode.c
index 90e6d8f93..d53a319e5 100644
--- a/bsd/ufs/ufs/ufs_inode.c
+++ b/bsd/ufs/ufs/ufs_inode.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/ufs/ufs/ufs_lockf.c b/bsd/ufs/ufs/ufs_lockf.c
index 4f4a71933..887ca3b8a 100644
--- a/bsd/ufs/ufs/ufs_lockf.c
+++ b/bsd/ufs/ufs/ufs_lockf.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/ufs/ufs/ufs_lookup.c b/bsd/ufs/ufs/ufs_lookup.c
index 1b7fc0cd0..302cb32de 100644
--- a/bsd/ufs/ufs/ufs_lookup.c
+++ b/bsd/ufs/ufs/ufs_lookup.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/ufs/ufs/ufs_quota.c b/bsd/ufs/ufs/ufs_quota.c
index e17245068..5048b1725 100644
--- a/bsd/ufs/ufs/ufs_quota.c
+++ b/bsd/ufs/ufs/ufs_quota.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/ufs/ufs/ufs_readwrite.c b/bsd/ufs/ufs/ufs_readwrite.c
index 0953dc8ce..f1b21eda6 100644
--- a/bsd/ufs/ufs/ufs_readwrite.c
+++ b/bsd/ufs/ufs/ufs_readwrite.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -665,11 +668,11 @@ ffs_pageout(ap)
 	}
         
 
-	error = cluster_pageout(vp, pl, pl_offset, f_offset, round_page(xfer_size), ip->i_size, devBlockSize, flags);
+	error = cluster_pageout(vp, pl, pl_offset, f_offset, round_page_32(xfer_size), ip->i_size, devBlockSize, flags);
 
 	if(save_error) {
 		lupl_offset = size - save_size;
-		resid = round_page(save_size);
+		resid = round_page_32(save_size);
 		if (!nocommit)
 			ubc_upl_abort_range(pl, lupl_offset, resid,
 				UPL_ABORT_FREE_ON_EMPTY);
diff --git a/bsd/ufs/ufs/ufs_vfsops.c b/bsd/ufs/ufs/ufs_vfsops.c
index daebf5e5a..b4b60ec2f 100644
--- a/bsd/ufs/ufs/ufs_vfsops.c
+++ b/bsd/ufs/ufs/ufs_vfsops.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/ufs/ufs/ufs_vnops.c b/bsd/ufs/ufs/ufs_vnops.c
index 1d1e6ec0e..903e31fe5 100644
--- a/bsd/ufs/ufs/ufs_vnops.c
+++ b/bsd/ufs/ufs/ufs_vnops.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/ufs/ufs/ufsmount.h b/bsd/ufs/ufs/ufsmount.h
index a54746310..dc14f0631 100644
--- a/bsd/ufs/ufs/ufsmount.h
+++ b/bsd/ufs/ufs/ufsmount.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/uxkern/ux_exception.c b/bsd/uxkern/ux_exception.c
index 2b6a4750d..6dcad81dc 100644
--- a/bsd/uxkern/ux_exception.c
+++ b/bsd/uxkern/ux_exception.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/vfs/vfs_bio.c b/bsd/vfs/vfs_bio.c
index 57c206760..8dd451fae 100644
--- a/bsd/vfs/vfs_bio.c
+++ b/bsd/vfs/vfs_bio.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -2030,7 +2033,7 @@ free_io_buf(bp)
 
 typedef long long blsize_t;
 
-blsize_t MAXNBUF; /* initialize to (mem_size / PAGE_SIZE) */
+blsize_t MAXNBUF; /* initialize to (sane_size / PAGE_SIZE) */
 /* Global tunable limits */
 blsize_t nbufh;			/* number of buffer headers */
 blsize_t nbuflow;		/* minimum number of buffer headers required */
@@ -2126,11 +2129,11 @@ bufq_balance_thread_init()
 	if (bufqscanwait++ == 0) {
 
 		/* Initalize globals */
-		MAXNBUF = (mem_size / PAGE_SIZE);
+		MAXNBUF = (sane_size / PAGE_SIZE);
 		nbufh = nbuf;
 		nbuflow = min(nbufh, 100);
 		nbufhigh = min(MAXNBUF, max(nbufh, 2048));
-		nbuftarget = (mem_size >> 5) / PAGE_SIZE;
+		nbuftarget = (sane_size >> 5) / PAGE_SIZE;
 		nbuftarget = max(nbuflow, nbuftarget);
 		nbuftarget = min(nbufhigh, nbuftarget);
 
diff --git a/bsd/vfs/vfs_cache.c b/bsd/vfs/vfs_cache.c
index f0d8f2618..e4b72f554 100644
--- a/bsd/vfs/vfs_cache.c
+++ b/bsd/vfs/vfs_cache.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/vfs/vfs_cluster.c b/bsd/vfs/vfs_cluster.c
index 49b0938bb..ec2eaf7f4 100644
--- a/bsd/vfs/vfs_cluster.c
+++ b/bsd/vfs/vfs_cluster.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -81,12 +84,12 @@
 #define CL_DEV_MEMORY 0x200
 #define CL_PRESERVE   0x400
 
+
 struct clios {
-        u_int  io_completed;
-        u_int  io_issued;
-        off_t  io_offset;
-        int    io_error;
-        int    io_wanted;
+        u_int  io_completed;       /* amount of io that has currently completed */
+        u_int  io_issued;          /* amount of io that was successfully issued */
+        int    io_error;           /* error code of first error encountered */
+        int    io_wanted;          /* someone is sleeping waiting for a change in state */
 };
 
 
@@ -106,7 +109,7 @@ static int cluster_phys_read(struct vnode *vp, struct uio *uio,
 static int cluster_phys_write(struct vnode *vp, struct uio *uio,
 		off_t newEOF, int devblocksize, int flags);
 static int cluster_align_phys_io(struct vnode *vp, struct uio *uio,
-                vm_offset_t usr_paddr, int xsize, int devblocksize, int flags);
+                addr64_t usr_paddr, int xsize, int devblocksize, int flags);
 static int cluster_push_x(struct vnode *vp, off_t EOF, daddr_t first, daddr_t last, int can_delay);
 static int cluster_try_push(struct vnode *vp, off_t newEOF, int can_delay, int push_all);
 
@@ -128,7 +131,6 @@ cluster_iodone(bp)
 	int         total_resid;
 	int         upl_offset;
 	int         zero_offset;
-	int         l_blkno;
 	upl_t       upl;
 	struct buf *cbp;
 	struct buf *cbp_head;
@@ -169,13 +171,9 @@ cluster_iodone(bp)
 	real_bp    = cbp->b_real_bp;
 	vp         = cbp->b_vp;
 	zero_offset= cbp->b_validend;
-	l_blkno    = cbp->b_lblkno;
 	iostate    = (struct clios *)cbp->b_iostate;
 
 	while (cbp) {
-		if (cbp->b_vectorcount > 1)
-		        _FREE(cbp->b_vectorlist, M_SEGMENT);
-
 		if ((cbp->b_flags & B_ERROR) && error == 0)
 		        error = cbp->b_error;
 
@@ -196,22 +194,20 @@ cluster_iodone(bp)
 		wakeup((caddr_t)&vp->v_numoutput);
 	}
 	if (iostate) {
-	        if (error) {
-		        off_t   error_offset;
-
-			error_offset = (off_t)l_blkno * PAGE_SIZE_64;
+	        /*
+		 * someone has issued multiple I/Os asynchrounsly
+		 * and is waiting for them to complete (streaming)
+		 */
+	        if (error && iostate->io_error == 0)
+		        iostate->io_error = error;
 
-		        if (iostate->io_error == 0) {
-			        iostate->io_error = error;
-				iostate->io_offset = error_offset;
-			} else {
-			        if (error_offset < iostate->io_offset)
-				        iostate->io_offset = error_offset;
-			}
-		}
 		iostate->io_completed += total_size;
 
 		if (iostate->io_wanted) {
+		        /*
+		         * someone is waiting for the state of
+			 * this io stream to change
+			 */
 		        iostate->io_wanted = 0;
 			wakeup((caddr_t)&iostate->io_wanted);
 		}
@@ -324,7 +320,6 @@ cluster_io(vp, upl, upl_offset, f_offset, non_rounded_size, devblocksize, flags,
 	struct clios *iostate;
 {
 	struct buf   *cbp;
-	struct iovec *iovp;
 	u_int         size;
 	u_int         io_size;
 	int           io_flags;
@@ -386,8 +381,7 @@ cluster_io(vp, upl, upl_offset, f_offset, non_rounded_size, devblocksize, flags,
 	        zero_offset = upl_offset + non_rounded_size;
 	}
 	while (size) {
-		int vsize;
-		int i;
+		int i; 
 		int pl_index;
 		int pg_resid;
 		int num_contig;
@@ -531,31 +525,14 @@ cluster_io(vp, upl, upl_offset, f_offset, non_rounded_size, devblocksize, flags,
 		        real_bp->b_blkno = blkno;
 		}
 
-		if (pg_count > 1) {
-			if (pg_count > max_vectors) {
-				io_size -= (pg_count - max_vectors) * PAGE_SIZE;
+		if (pg_count > max_vectors) {
+		        io_size -= (pg_count - max_vectors) * PAGE_SIZE;
 
-				if (io_size < 0) {
-				        io_size = PAGE_SIZE - pg_offset;
-					pg_count = 1;
-				} else
-					pg_count = max_vectors;
-			}
-		        /* 
-			 * we need to allocate space for the vector list
-			 */
-			if (pg_count > 1) {
-			        iovp = (struct iovec *)_MALLOC(sizeof(struct iovec) * pg_count,
-							       M_SEGMENT, M_NOWAIT);
-			
-				if (iovp == (struct iovec *) 0) {
-				        /*
-					 * if the allocation fails, then throttle down to a single page
-					 */
-				        io_size = PAGE_SIZE - pg_offset;
-					pg_count = 1;
-				}
-			}
+			if (io_size < 0) {
+			        io_size = PAGE_SIZE - pg_offset;
+				pg_count = 1;
+			} else
+			        pg_count = max_vectors;
 		}
 
 		/* Throttle the speculative IO */
@@ -566,53 +543,9 @@ cluster_io(vp, upl, upl_offset, f_offset, non_rounded_size, devblocksize, flags,
 
 		cbp = alloc_io_buf(vp, priv);
 
-		if (pg_count == 1)
-		        /*
-			 * we use the io vector that's reserved in the buffer header
-			 * this insures we can always issue an I/O even in a low memory
-			 * condition that prevents the _MALLOC from succeeding... this
-			 * is necessary to prevent deadlocks with the pager
-			 */
-			iovp = (struct iovec *)(&cbp->b_vects[0]);
-
-		cbp->b_vectorlist  = (void *)iovp;
-		cbp->b_vectorcount = pg_count;
-
-		if (flags & CL_DEV_MEMORY) {
-
-			iovp->iov_len  = io_size;
-		        iovp->iov_base = (caddr_t)upl_phys_page(pl, 0);
-
-			if (iovp->iov_base == (caddr_t) 0) {
-			        free_io_buf(cbp);
-				error = EINVAL;
-			} else
-			        iovp->iov_base += upl_offset;
-		} else {
-
-		  for (i = 0, vsize = io_size; i < pg_count; i++, iovp++) {
-		        int     psize;
-
-			psize = PAGE_SIZE - pg_offset;
-
-			if (psize > vsize)
-			        psize = vsize;
 
-			iovp->iov_len  = psize;
-		        iovp->iov_base = (caddr_t)upl_phys_page(pl, pl_index + i);
-
-			if (iovp->iov_base == (caddr_t) 0) {
-				if (pg_count > 1)
-				        _FREE(cbp->b_vectorlist, M_SEGMENT);
-			        free_io_buf(cbp);
-
-				error = EINVAL;
-				break;
-			}
-			iovp->iov_base += pg_offset;
-			pg_offset = 0;
-
-			if (flags & CL_PAGEOUT) {
+		if (flags & CL_PAGEOUT) {
+		        for (i = 0; i < pg_count; i++) {
 			        int         s;
 				struct buf *bp;
 
@@ -628,12 +561,7 @@ cluster_io(vp, upl, upl_offset, f_offset, non_rounded_size, devblocksize, flags,
 				}
 				splx(s);
 			}
-			vsize -= psize;
-		    }
 		}
-		if (error)
-		        break;
-
 		if (flags & CL_ASYNC) {
 			cbp->b_flags |= (B_CALL | B_ASYNC);
 		        cbp->b_iodone = (void *)cluster_iodone;
@@ -648,6 +576,10 @@ cluster_io(vp, upl, upl_offset, f_offset, non_rounded_size, devblocksize, flags,
 		cbp->b_trans_next = (struct buf *)0;
 
 		if (cbp->b_iostate = (void *)iostate)
+		        /*
+			 * caller wants to track the state of this
+			 * io... bump the amount issued against this stream
+			 */
 		        iostate->io_issued += io_size;
 
 		if (flags & CL_READ)
@@ -737,8 +669,6 @@ start_io:
 	        for (cbp = cbp_head; cbp;) {
 			struct buf * cbp_next;
  
-		        if (cbp->b_vectorcount > 1)
-			        _FREE(cbp->b_vectorlist, M_SEGMENT);
 			upl_offset -= cbp->b_bcount;
 			size       += cbp->b_bcount;
 			io_size    += cbp->b_bcount;
@@ -748,13 +678,20 @@ start_io:
 			cbp = cbp_next;
 		}
 		if (iostate) {
-		        if (iostate->io_error == 0) {
+		        /*
+			 * update the error condition for this stream
+			 * since we never really issued the io
+			 * just go ahead and adjust it back
+			 */
+		        if (iostate->io_error == 0)
 			        iostate->io_error = error;
-				iostate->io_offset = f_offset - (off_t)io_size;
-			}
 			iostate->io_issued -= io_size;
 
 			if (iostate->io_wanted) {
+			        /*
+				 * someone is waiting for the state of
+				 * this io stream to change
+				 */
 			        iostate->io_wanted = 0;
 				wakeup((caddr_t)&iostate->io_wanted);
 			}
@@ -1241,6 +1178,7 @@ cluster_nocopy_write(vp, uio, newEOF, devblocksize, flags)
 	vm_offset_t      upl_offset;
 	off_t            max_io_size;
 	int              io_size;
+	int              io_flag;
 	int              upl_size;
 	int              upl_needed_size;
 	int              pages_in_pl;
@@ -1248,8 +1186,10 @@ cluster_nocopy_write(vp, uio, newEOF, devblocksize, flags)
 	kern_return_t    kret;
 	struct iovec     *iov;
 	int              i;
+	int              first = 1;
 	int              force_data_sync;
 	int              error  = 0;
+	struct clios     iostate;
 
 	KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, 75)) | DBG_FUNC_START,
 		     (int)uio->uio_offset, (int)uio->uio_resid, 
@@ -1263,152 +1203,182 @@ cluster_nocopy_write(vp, uio, newEOF, devblocksize, flags)
 	 */
 	cluster_try_push(vp, newEOF, 0, 1);
 
+	iostate.io_completed = 0;
+	iostate.io_issued = 0;
+	iostate.io_error = 0;
+	iostate.io_wanted = 0;
+
 	iov = uio->uio_iov;
 
 	while (uio->uio_resid && uio->uio_offset < newEOF && error == 0) {
-	  io_size = uio->uio_resid;
-
-          if (io_size > (MAX_UPL_TRANSFER * PAGE_SIZE))
-            io_size = MAX_UPL_TRANSFER * PAGE_SIZE;
+	        io_size = uio->uio_resid;
 
-	  upl_offset = (vm_offset_t)iov->iov_base & PAGE_MASK_64;
-	  upl_needed_size = (upl_offset + io_size + (PAGE_SIZE -1)) & ~PAGE_MASK;
-
-	  KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, 76)) | DBG_FUNC_START,
-		       (int)upl_offset, upl_needed_size, (int)iov->iov_base, io_size, 0);
-
-	  for (force_data_sync = 0; force_data_sync < 3; force_data_sync++)
-	    {
-	      pages_in_pl = 0;
-	      upl_size = upl_needed_size;
-	      upl_flags = UPL_FILE_IO | UPL_COPYOUT_FROM | UPL_NO_SYNC |
-		          UPL_CLEAN_IN_PLACE | UPL_SET_INTERNAL;
+		if (io_size > (MAX_UPL_TRANSFER * PAGE_SIZE))
+		        io_size = MAX_UPL_TRANSFER * PAGE_SIZE;
 
-	      kret = vm_map_get_upl(current_map(),
-				    (vm_offset_t)iov->iov_base & ~PAGE_MASK,
-				    &upl_size,
-					&upl, 
-					NULL, 
-					&pages_in_pl,
-					&upl_flags,
-					force_data_sync);
+		if (first) {
+	                if (io_size > (MAX_UPL_TRANSFER * PAGE_SIZE) / 4)
+		                io_size = (MAX_UPL_TRANSFER * PAGE_SIZE) / 8;
+			first = 0;
+		}
+		upl_offset = (vm_offset_t)iov->iov_base & PAGE_MASK_64;
+		upl_needed_size = (upl_offset + io_size + (PAGE_SIZE -1)) & ~PAGE_MASK;
+
+		KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, 76)) | DBG_FUNC_START,
+			     (int)upl_offset, upl_needed_size, (int)iov->iov_base, io_size, 0);
+
+		for (force_data_sync = 0; force_data_sync < 3; force_data_sync++) {
+		        pages_in_pl = 0;
+			upl_size = upl_needed_size;
+			upl_flags = UPL_FILE_IO | UPL_COPYOUT_FROM | UPL_NO_SYNC |
+		                    UPL_CLEAN_IN_PLACE | UPL_SET_INTERNAL;
+
+			kret = vm_map_get_upl(current_map(),
+					      (vm_offset_t)iov->iov_base & ~PAGE_MASK,
+					      &upl_size,
+					      &upl, 
+					      NULL, 
+					      &pages_in_pl,
+					      &upl_flags,
+					      force_data_sync);
+
+			if (kret != KERN_SUCCESS) {
+			        KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, 76)) | DBG_FUNC_END,
+					     0, 0, 0, kret, 0);
 
-	      if (kret != KERN_SUCCESS)
-		{
-		  KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, 76)) | DBG_FUNC_END,
-			       0, 0, 0, kret, 0);
+				/*
+				 * cluster_nocopy_write: failed to get pagelist
+				 *
+				 * we may have already spun some portion of this request
+				 * off as async requests... we need to wait for the I/O
+				 * to complete before returning
+				 */
+				goto wait_for_writes;
+			}
+			pl = UPL_GET_INTERNAL_PAGE_LIST(upl);
+			pages_in_pl = upl_size / PAGE_SIZE;
 
-		  KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, 75)) | DBG_FUNC_END,
-			       (int)uio->uio_offset, (int)uio->uio_resid, kret, 1, 0);
+			for (i = 0; i < pages_in_pl; i++) {
+			        if (!upl_valid_page(pl, i))
+				        break;		  
+			}
+			if (i == pages_in_pl)
+			        break;
 
-		  /* cluster_nocopy_write: failed to get pagelist */
-		  /* do not return kret here */
-		  return(0);
+			/*
+			 * didn't get all the pages back that we
+			 * needed... release this upl and try again
+			 */
+			ubc_upl_abort_range(upl, (upl_offset & ~PAGE_MASK), upl_size, 
+					    UPL_ABORT_FREE_ON_EMPTY);
 		}
+		if (force_data_sync >= 3) {
+		        KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, 76)) | DBG_FUNC_END,
+				     i, pages_in_pl, upl_size, kret, 0);
 
-	      pl = UPL_GET_INTERNAL_PAGE_LIST(upl);
-	      pages_in_pl = upl_size / PAGE_SIZE;
-
-	      for(i=0; i < pages_in_pl; i++)
-		{
-		  if (!upl_valid_page(pl, i))
-		    break;		  
+			/*
+			 * for some reason, we couldn't acquire a hold on all
+			 * the pages needed in the user's address space
+			 *
+			 * we may have already spun some portion of this request
+			 * off as async requests... we need to wait for the I/O
+			 * to complete before returning
+			 */
+			goto wait_for_writes;
 		}
 
-	      if (i == pages_in_pl)
-		break;
-
-		ubc_upl_abort_range(upl, (upl_offset & ~PAGE_MASK), upl_size, 
-				UPL_ABORT_FREE_ON_EMPTY);
-	    }
-
-	  if (force_data_sync >= 3)
-	    {
-	      KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, 76)) | DBG_FUNC_END,
-			   i, pages_in_pl, upl_size, kret, 0);
-
-	      KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, 75)) | DBG_FUNC_END,
-			   (int)uio->uio_offset, (int)uio->uio_resid, kret, 2, 0);
-	      return(0);
-	    }
-
-	  /*
-	   * Consider the possibility that upl_size wasn't satisfied.
-	   */
-	  if (upl_size != upl_needed_size)
-	    io_size = (upl_size - (int)upl_offset) & ~PAGE_MASK;
-
-	  KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, 76)) | DBG_FUNC_END,
-		       (int)upl_offset, upl_size, (int)iov->iov_base, io_size, 0);		       
-
-	  if (io_size == 0)
-	    {
-	      ubc_upl_abort_range(upl, (upl_offset & ~PAGE_MASK), upl_size, 
-				   UPL_ABORT_FREE_ON_EMPTY);
-	      KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, 75)) | DBG_FUNC_END,
-		     (int)uio->uio_offset, uio->uio_resid, 0, 3, 0);
+		/*
+		 * Consider the possibility that upl_size wasn't satisfied.
+		 */
+		if (upl_size != upl_needed_size)
+		        io_size = (upl_size - (int)upl_offset) & ~PAGE_MASK;
 
-	      return(0);
-	    }
+		KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, 76)) | DBG_FUNC_END,
+			     (int)upl_offset, upl_size, (int)iov->iov_base, io_size, 0);		       
 
-	  /*
-	   * Now look for pages already in the cache
-	   * and throw them away.
-	   */
+		if (io_size == 0) {
+		        ubc_upl_abort_range(upl, (upl_offset & ~PAGE_MASK), upl_size, 
+					    UPL_ABORT_FREE_ON_EMPTY);
 
-	  upl_f_offset = uio->uio_offset;   /* this is page aligned in the file */
-	  max_io_size = io_size;
+			/*
+			 * we may have already spun some portion of this request
+			 * off as async requests... we need to wait for the I/O
+			 * to complete before returning
+			 */
+			goto wait_for_writes;
+		}
+		/*
+		 * Now look for pages already in the cache
+		 * and throw them away.
+		 */
 
-	  while (max_io_size) {
+		upl_f_offset = uio->uio_offset;   /* this is page aligned in the file */
+		max_io_size = io_size;
 
-	    /*
-	     * Flag UPL_POP_DUMP says if the page is found
-	     * in the page cache it must be thrown away.
-	     */
-	    ubc_page_op(vp, 
-			upl_f_offset,
-			UPL_POP_SET | UPL_POP_BUSY | UPL_POP_DUMP,
-			0, 0);
-	    max_io_size  -= PAGE_SIZE;
-	    upl_f_offset += PAGE_SIZE;
-	  }
-
-	  /*
-	   * issue a synchronous write to cluster_io
-	   */
+		while (max_io_size) {
+		        /*
+			 * Flag UPL_POP_DUMP says if the page is found
+			 * in the page cache it must be thrown away.
+			 */
+		        ubc_page_op(vp, 
+				    upl_f_offset,
+				    UPL_POP_SET | UPL_POP_BUSY | UPL_POP_DUMP,
+				    0, 0);
+			max_io_size  -= PAGE_SIZE_64;
+			upl_f_offset += PAGE_SIZE_64;
+		}
+		/*
+		 * we want push out these writes asynchronously so that we can overlap
+		 * the preparation of the next I/O
+		 * if there are already too many outstanding writes
+		 * wait until some complete before issuing the next
+		 */
+		while ((iostate.io_issued - iostate.io_completed) > (2 * MAX_UPL_TRANSFER * PAGE_SIZE)) {
+	                iostate.io_wanted = 1;
+			tsleep((caddr_t)&iostate.io_wanted, PRIBIO + 1, "cluster_nocopy_write", 0);
+		}	
+		if (iostate.io_error) {
+		        /*
+			 * one of the earlier writes we issued ran into a hard error
+			 * don't issue any more writes, cleanup the UPL
+			 * that was just created but not used, then
+			 * go wait for all writes that are part of this stream
+			 * to complete before returning the error to the caller
+			 */
+		        ubc_upl_abort_range(upl, (upl_offset & ~PAGE_MASK), upl_size, 
+					    UPL_ABORT_FREE_ON_EMPTY);
 
-	  KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, 77)) | DBG_FUNC_START,
-		       (int)upl_offset, (int)uio->uio_offset, io_size, 0, 0);
+		        goto wait_for_writes;
+	        }
+		io_flag = CL_ASYNC | CL_PRESERVE | CL_COMMIT;
 
-	  error = cluster_io(vp, upl, upl_offset, uio->uio_offset,
-			     io_size, devblocksize, 0, (struct buf *)0, (struct clios *)0);
+		KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, 77)) | DBG_FUNC_START,
+			     (int)upl_offset, (int)uio->uio_offset, io_size, io_flag, 0);
 
-	  if (error == 0) {
-	    /*
-	     * The cluster_io write completed successfully,
-	     * update the uio structure.
-	     */
-	    iov->iov_base += io_size;
-	    iov->iov_len -= io_size;
-	    uio->uio_resid -= io_size;
-	    uio->uio_offset += io_size;
-	  }
-	  /*
-	   * always 'commit' the I/O via the abort primitive whether the I/O
-	   * succeeded cleanly or not... this is necessary to insure that 
-	   * we preserve the state of the DIRTY flag on the pages used to
-	   * provide the data for the I/O... the state of this flag SHOULD
-	   * NOT be changed by a write
-	   */
-	  ubc_upl_abort_range(upl, (upl_offset & ~PAGE_MASK), upl_size, 
-			      UPL_ABORT_FREE_ON_EMPTY);
+		error = cluster_io(vp, upl, upl_offset, uio->uio_offset,
+				   io_size, devblocksize, io_flag, (struct buf *)0, &iostate);
 
+		iov->iov_len    -= io_size;
+		iov->iov_base   += io_size;
+		uio->uio_resid  -= io_size;
+		uio->uio_offset += io_size;
 
-	  KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, 77)) | DBG_FUNC_END,
-		       (int)upl_offset, (int)uio->uio_offset, (int)uio->uio_resid, error, 0);
+		KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, 77)) | DBG_FUNC_END,
+			     (int)upl_offset, (int)uio->uio_offset, (int)uio->uio_resid, error, 0);
 
 	} /* end while */
 
+wait_for_writes:
+	/*
+	 * make sure all async writes issued as part of this stream
+	 * have completed before we return
+	 */
+	while (iostate.io_issued != iostate.io_completed) {
+	        iostate.io_wanted = 1;
+		tsleep((caddr_t)&iostate.io_wanted, PRIBIO + 1, "cluster_nocopy_write", 0);
+	}	
+	if (iostate.io_error)
+		error = iostate.io_error;
 
 	KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, 75)) | DBG_FUNC_END,
 		     (int)uio->uio_offset, (int)uio->uio_resid, error, 4, 0);
@@ -1426,7 +1396,7 @@ cluster_phys_write(vp, uio, newEOF, devblocksize, flags)
 	int          flags;
 {
 	upl_page_info_t *pl;
-	vm_offset_t      src_paddr;
+	addr64_t	     src_paddr;
  	upl_t            upl;
 	vm_offset_t      upl_offset;
 	int              tail_size;
@@ -1477,7 +1447,7 @@ cluster_phys_write(vp, uio, newEOF, devblocksize, flags)
 	}
 	pl = ubc_upl_pageinfo(upl);
 
-	src_paddr = (vm_offset_t)upl_phys_page(pl, 0) + ((vm_offset_t)iov->iov_base & PAGE_MASK);
+	src_paddr = (((addr64_t)(int)upl_phys_page(pl, 0)) << 12) + ((addr64_t)iov->iov_base & PAGE_MASK);
 
 	while (((uio->uio_offset & (devblocksize - 1)) || io_size < devblocksize) && io_size) {
 	        int   head_size;
@@ -2267,8 +2237,8 @@ cluster_read_x(vp, uio, filesize, devblocksize, flags)
 				     (int)uio->uio_offset, io_size, uio->uio_resid, 0, 0);
 
 			while (io_size && retval == 0) {
-			        int         xsize;
-				vm_offset_t paddr;
+			    int		xsize;
+				ppnum_t paddr;
 
 				if (ubc_page_op(vp,
 						upl_f_offset,
@@ -2281,7 +2251,7 @@ cluster_read_x(vp, uio, filesize, devblocksize, flags)
 				if (xsize > io_size)
 				        xsize = io_size;
 
-				retval = uiomove((caddr_t)(paddr + start_offset), xsize, uio);
+				retval = uiomove64((addr64_t)(((addr64_t)paddr << 12) + start_offset), xsize, uio);
 
 				ubc_page_op(vp, upl_f_offset,
 					    UPL_POP_CLR | UPL_POP_BUSY, 0, 0);
@@ -2442,14 +2412,14 @@ cluster_read_x(vp, uio, filesize, devblocksize, flags)
 				while (val_size && retval == 0) {
 	 				int   	  csize;
 					int       i;
-					caddr_t   paddr;
+					addr64_t	paddr;
 
 					i = offset / PAGE_SIZE;
 					csize = min(PAGE_SIZE - start_offset, val_size);
 
-				        paddr = (caddr_t)upl_phys_page(pl, i) + start_offset;
+					paddr = ((addr64_t)upl_phys_page(pl, i) << 12) + start_offset;
 
-					retval = uiomove(paddr, csize, uio);
+					retval = uiomove64(paddr, csize, uio);
 
 					val_size    -= csize;
 					offset      += csize;
@@ -2591,15 +2561,16 @@ cluster_nocopy_read(vp, uio, filesize, devblocksize, flags)
 	int              upl_size;
 	int              upl_needed_size;
 	int              pages_in_pl;
-	vm_offset_t      paddr;
+	ppnum_t		     paddr;
 	int              upl_flags;
 	kern_return_t    kret;
 	int              segflg;
 	struct iovec     *iov;
 	int              i;
 	int              force_data_sync;
-	int              error  = 0;
 	int              retval = 0;
+	int              first = 1;
+	struct clios     iostate;
 
 	KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, 70)) | DBG_FUNC_START,
 		     (int)uio->uio_offset, uio->uio_resid, (int)filesize, devblocksize, 0);
@@ -2611,203 +2582,225 @@ cluster_nocopy_read(vp, uio, filesize, devblocksize, flags)
 	 *  -- the resid will not exceed iov_len
 	 */
 
+	iostate.io_completed = 0;
+	iostate.io_issued = 0;
+	iostate.io_error = 0;
+	iostate.io_wanted = 0;
+
 	iov = uio->uio_iov;
+
 	while (uio->uio_resid && uio->uio_offset < filesize && retval == 0) {
 
-	  max_io_size = filesize - uio->uio_offset;
+	        max_io_size = filesize - uio->uio_offset;
 
-	  if (max_io_size < (off_t)((unsigned int)uio->uio_resid))
-	      io_size = max_io_size;
-	  else
-	      io_size = uio->uio_resid;
+		if (max_io_size < (off_t)((unsigned int)uio->uio_resid))
+		        io_size = max_io_size;
+		else
+		        io_size = uio->uio_resid;
 
-	  /*
-	   * We don't come into this routine unless
-	   * UIO_USERSPACE is set.
-	   */
-	  segflg = uio->uio_segflg;
+		/*
+		 * We don't come into this routine unless
+		 * UIO_USERSPACE is set.
+		 */
+		segflg = uio->uio_segflg;
 
-	  uio->uio_segflg = UIO_PHYS_USERSPACE;
+		uio->uio_segflg = UIO_PHYS_USERSPACE;
 
-	  /*
-	   * First look for pages already in the cache
-	   * and move them to user space.
-	   */
-	  while (io_size && (retval == 0)) {
-	    upl_f_offset = uio->uio_offset;
+		/*
+		 * First look for pages already in the cache
+		 * and move them to user space.
+		 */
+		while (io_size && (retval == 0)) {
+		        upl_f_offset = uio->uio_offset;
 
-	    /*
-	     * If this call fails, it means the page is not
-	     * in the page cache.
-	     */
-	    if (ubc_page_op(vp, upl_f_offset,
-			    UPL_POP_SET | UPL_POP_BUSY, &paddr, 0) != KERN_SUCCESS)
-	      break;
+			/*
+			 * If this call fails, it means the page is not
+			 * in the page cache.
+			 */
+			if (ubc_page_op(vp, upl_f_offset,
+					UPL_POP_SET | UPL_POP_BUSY, &paddr, 0) != KERN_SUCCESS)
+			        break;
 
-	    retval = uiomove((caddr_t)(paddr), PAGE_SIZE, uio);
+			retval = uiomove64((addr64_t)paddr << 12, PAGE_SIZE, uio);
 				
-	    ubc_page_op(vp, upl_f_offset, 
-			UPL_POP_CLR | UPL_POP_BUSY, 0, 0);
+			ubc_page_op(vp, upl_f_offset, 
+				    UPL_POP_CLR | UPL_POP_BUSY, 0, 0);
 		  
-	    io_size     -= PAGE_SIZE;
-	    KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, 71)) | DBG_FUNC_NONE,
-			   (int)uio->uio_offset, io_size, uio->uio_resid, 0, 0);
-	  }
-
-	  uio->uio_segflg = segflg;
+			io_size -= PAGE_SIZE;
+			KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, 71)) | DBG_FUNC_NONE,
+				     (int)uio->uio_offset, io_size, uio->uio_resid, 0, 0);
+		}
+		uio->uio_segflg = segflg;
 			
-	  if (retval)
-	    {
-	      KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, 70)) | DBG_FUNC_END,
-			   (int)uio->uio_offset, uio->uio_resid, 2, retval, 0);	      
-	      return(retval);
-	    }
-
-	  /* If we are already finished with this read, then return */
-	  if (io_size == 0)
-	    {
-
-	      KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, 70)) | DBG_FUNC_END,
-			   (int)uio->uio_offset, uio->uio_resid, 3, io_size, 0);
-	      return(0);
-	    }
-
-	  max_io_size = io_size;
-	  if (max_io_size > (MAX_UPL_TRANSFER * PAGE_SIZE))
-	    max_io_size = MAX_UPL_TRANSFER * PAGE_SIZE;
-
-	  start_upl_f_offset = uio->uio_offset;   /* this is page aligned in the file */
-	  upl_f_offset = start_upl_f_offset;
-	  io_size = 0;
-
-	  while(io_size < max_io_size)
-	    {
-
-	      if(ubc_page_op(vp, upl_f_offset,
-				UPL_POP_SET | UPL_POP_BUSY, &paddr, 0) == KERN_SUCCESS)
-	      {
-			ubc_page_op(vp, upl_f_offset,
-			    UPL_POP_CLR | UPL_POP_BUSY, 0, 0);
-			break;
-	      }
-
-		  /*
-		   * Build up the io request parameters.
-		   */
-
-		  io_size += PAGE_SIZE;
-		  upl_f_offset += PAGE_SIZE;
+		if (retval) {
+			/*
+			 * we may have already spun some portion of this request
+			 * off as async requests... we need to wait for the I/O
+			 * to complete before returning
+			 */
+			goto wait_for_reads;
 		}
+		/*
+		 * If we are already finished with this read, then return
+		 */
+		if (io_size == 0) {
+			/*
+			 * we may have already spun some portion of this request
+			 * off as async requests... we need to wait for the I/O
+			 * to complete before returning
+			 */
+			goto wait_for_reads;
+		}
+		max_io_size = io_size;
+
+		if (max_io_size > (MAX_UPL_TRANSFER * PAGE_SIZE))
+		        max_io_size = MAX_UPL_TRANSFER * PAGE_SIZE;
+		if (first) {
+	                if (max_io_size > (MAX_UPL_TRANSFER * PAGE_SIZE) / 4)
+		                max_io_size = (MAX_UPL_TRANSFER * PAGE_SIZE) / 8;
+			first = 0;
+		}
+		start_upl_f_offset = uio->uio_offset;   /* this is page aligned in the file */
+		upl_f_offset = start_upl_f_offset;
+		io_size = 0;
 
-	      if (io_size == 0)
-		return(retval);
+		while (io_size < max_io_size) {
+		        if (ubc_page_op(vp, upl_f_offset,
+					UPL_POP_SET | UPL_POP_BUSY, &paddr, 0) == KERN_SUCCESS) {
+			        ubc_page_op(vp, upl_f_offset,
+					    UPL_POP_CLR | UPL_POP_BUSY, 0, 0);
+				break;
+			}
+			/*
+			 * Build up the io request parameters.
+			 */
+			io_size += PAGE_SIZE_64;
+			upl_f_offset += PAGE_SIZE_64;
+		}
+		if (io_size == 0)
+			/*
+			 * we may have already spun some portion of this request
+			 * off as async requests... we need to wait for the I/O
+			 * to complete before returning
+			 */
+			goto wait_for_reads;
 
-	  upl_offset = (vm_offset_t)iov->iov_base & PAGE_MASK_64;
-	  upl_needed_size = (upl_offset + io_size + (PAGE_SIZE -1)) & ~PAGE_MASK;
+		upl_offset = (vm_offset_t)iov->iov_base & PAGE_MASK_64;
+		upl_needed_size = (upl_offset + io_size + (PAGE_SIZE -1)) & ~PAGE_MASK;
 
-	  KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, 72)) | DBG_FUNC_START,
-		       (int)upl_offset, upl_needed_size, (int)iov->iov_base, io_size, 0);
+		KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, 72)) | DBG_FUNC_START,
+			     (int)upl_offset, upl_needed_size, (int)iov->iov_base, io_size, 0);
 
-	  for (force_data_sync = 0; force_data_sync < 3; force_data_sync++)
-	    {
-	      pages_in_pl = 0;
-	      upl_size = upl_needed_size;
-	      upl_flags = UPL_FILE_IO | UPL_NO_SYNC | UPL_CLEAN_IN_PLACE | UPL_SET_INTERNAL;
+		for (force_data_sync = 0; force_data_sync < 3; force_data_sync++) {
+		        pages_in_pl = 0;
+			upl_size = upl_needed_size;
+			upl_flags = UPL_FILE_IO | UPL_NO_SYNC | UPL_CLEAN_IN_PLACE | UPL_SET_INTERNAL;
 
-	      kret = vm_map_get_upl(current_map(),
-				    (vm_offset_t)iov->iov_base & ~PAGE_MASK,
-				    &upl_size, &upl, NULL, &pages_in_pl, &upl_flags, force_data_sync);
+			kret = vm_map_get_upl(current_map(),
+					      (vm_offset_t)iov->iov_base & ~PAGE_MASK,
+					      &upl_size, &upl, NULL, &pages_in_pl, &upl_flags, force_data_sync);
 
-	      if (kret != KERN_SUCCESS)
-		{
-		  KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, 72)) | DBG_FUNC_END,
-			       (int)upl_offset, upl_size, io_size, kret, 0);
+			if (kret != KERN_SUCCESS) {
+			        KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, 72)) | DBG_FUNC_END,
+					     (int)upl_offset, upl_size, io_size, kret, 0);
 		  
-		  KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, 70)) | DBG_FUNC_END,
-			       (int)uio->uio_offset, uio->uio_resid, 4, retval, 0);
-
-		  /* cluster_nocopy_read: failed to get pagelist */
-		  /* do not return kret here */
-		  return(retval);
-		}
+				/*
+				 * cluster_nocopy_read: failed to get pagelist
+				 *
+				 * we may have already spun some portion of this request
+				 * off as async requests... we need to wait for the I/O
+				 * to complete before returning
+				 */
+				goto wait_for_reads;
+			}
+			pages_in_pl = upl_size / PAGE_SIZE;
+			pl = UPL_GET_INTERNAL_PAGE_LIST(upl);
 
-	      pages_in_pl = upl_size / PAGE_SIZE;
-	      pl = UPL_GET_INTERNAL_PAGE_LIST(upl);
+			for (i = 0; i < pages_in_pl; i++) {
+			        if (!upl_valid_page(pl, i))
+				        break;		  
+			}
+			if (i == pages_in_pl)
+			        break;
 
-	      for(i=0; i < pages_in_pl; i++)
-		{
-		  if (!upl_valid_page(pl, i))
-		    break;		  
+			ubc_upl_abort_range(upl, (upl_offset & ~PAGE_MASK), upl_size, 
+					    UPL_ABORT_FREE_ON_EMPTY);
 		}
-	      if (i == pages_in_pl)
-		break;
-
-	      ubc_upl_abort_range(upl, (upl_offset & ~PAGE_MASK), upl_size, 
-				  UPL_ABORT_FREE_ON_EMPTY);
-	    }
-
-	  if (force_data_sync >= 3)
-	    {
-		  KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, 72)) | DBG_FUNC_END,
-			       (int)upl_offset, upl_size, io_size, kret, 0);
+		if (force_data_sync >= 3) {
+		        KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, 72)) | DBG_FUNC_END,
+				     (int)upl_offset, upl_size, io_size, kret, 0);
 		  
-		  KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, 70)) | DBG_FUNC_END,
-			       (int)uio->uio_offset, uio->uio_resid, 5, retval, 0);
-	      return(retval);
-	    }
-	  /*
-	   * Consider the possibility that upl_size wasn't satisfied.
-	   */
-	  if (upl_size != upl_needed_size)
-	    io_size = (upl_size - (int)upl_offset) & ~PAGE_MASK;
-
-	  if (io_size == 0)
-	    {
-	      ubc_upl_abort_range(upl, (upl_offset & ~PAGE_MASK), upl_size, 
-				   UPL_ABORT_FREE_ON_EMPTY);
-	      return(retval);
-	    }
-
-	  KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, 72)) | DBG_FUNC_END,
-		       (int)upl_offset, upl_size, io_size, kret, 0);
-
-	  /*
-	   * issue a synchronous read to cluster_io
-	   */
+			goto wait_for_reads;
+		}
+		/*
+		 * Consider the possibility that upl_size wasn't satisfied.
+		 */
+		if (upl_size != upl_needed_size)
+		        io_size = (upl_size - (int)upl_offset) & ~PAGE_MASK;
 
-	  KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, 73)) | DBG_FUNC_START,
-		       (int)upl, (int)upl_offset, (int)start_upl_f_offset, io_size, 0);
+		if (io_size == 0) {
+		        ubc_upl_abort_range(upl, (upl_offset & ~PAGE_MASK), upl_size, 
+					    UPL_ABORT_FREE_ON_EMPTY);
+			goto wait_for_reads;
+		}
+		KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, 72)) | DBG_FUNC_END,
+			     (int)upl_offset, upl_size, io_size, kret, 0);
 
-	  error = cluster_io(vp, upl, upl_offset, start_upl_f_offset,
-			     io_size, devblocksize, CL_READ| CL_NOZERO, (struct buf *)0,  (struct clios *)0);
+		/*
+		 * request asynchronously so that we can overlap
+		 * the preparation of the next I/O
+		 * if there are already too many outstanding reads
+		 * wait until some have completed before issuing the next read
+		 */
+		while ((iostate.io_issued - iostate.io_completed) > (2 * MAX_UPL_TRANSFER * PAGE_SIZE)) {
+	                iostate.io_wanted = 1;
+			tsleep((caddr_t)&iostate.io_wanted, PRIBIO + 1, "cluster_nocopy_read", 0);
+		}	
+		if (iostate.io_error) {
+		        /*
+			 * one of the earlier reads we issued ran into a hard error
+			 * don't issue any more reads, cleanup the UPL
+			 * that was just created but not used, then
+			 * go wait for any other reads to complete before
+			 * returning the error to the caller
+			 */
+		        ubc_upl_abort_range(upl, (upl_offset & ~PAGE_MASK), upl_size, 
+					    UPL_ABORT_FREE_ON_EMPTY);
 
-	  if (error == 0) {
-	    /*
-	     * The cluster_io read completed successfully,
-	     * update the uio structure and commit.
-	     */
+		        goto wait_for_reads;
+	        }
+		KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, 73)) | DBG_FUNC_START,
+			     (int)upl, (int)upl_offset, (int)start_upl_f_offset, io_size, 0);
 
-	    ubc_upl_commit_range(upl, (upl_offset & ~PAGE_MASK), upl_size, 
-					UPL_COMMIT_SET_DIRTY | UPL_COMMIT_FREE_ON_EMPTY);
-	    
-	    iov->iov_base += io_size;
-	    iov->iov_len -= io_size;
-	    uio->uio_resid -= io_size;
-	    uio->uio_offset += io_size;
-	  }
-	  else {
-	    ubc_upl_abort_range(upl, (upl_offset & ~PAGE_MASK), upl_size, 
-				   UPL_ABORT_FREE_ON_EMPTY);
-	  }
+		retval = cluster_io(vp, upl, upl_offset, start_upl_f_offset,
+				   io_size, devblocksize,
+				   CL_PRESERVE | CL_COMMIT | CL_READ | CL_ASYNC | CL_NOZERO,
+				   (struct buf *)0, &iostate);
 
-	  KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, 73)) | DBG_FUNC_END,
-		       (int)upl, (int)uio->uio_offset, (int)uio->uio_resid, error, 0);
+		/*
+		 * update the uio structure
+		 */
+		iov->iov_base   += io_size;
+		iov->iov_len    -= io_size;
+		uio->uio_resid  -= io_size;
+		uio->uio_offset += io_size;
 
-	  if (retval == 0)
-	    retval = error;
+		KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, 73)) | DBG_FUNC_END,
+			     (int)upl, (int)uio->uio_offset, (int)uio->uio_resid, retval, 0);
 
 	} /* end while */
 
+wait_for_reads:
+	/*
+	 * make sure all async reads that are part of this stream
+	 * have completed before we return
+	 */
+	while (iostate.io_issued != iostate.io_completed) {
+	        iostate.io_wanted = 1;
+		tsleep((caddr_t)&iostate.io_wanted, PRIBIO + 1, "cluster_nocopy_read", 0);
+	}	
+	if (iostate.io_error)
+		retval = iostate.io_error;
 
 	KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, 70)) | DBG_FUNC_END,
 		     (int)uio->uio_offset, (int)uio->uio_resid, 6, retval, 0);
@@ -2816,7 +2809,6 @@ cluster_nocopy_read(vp, uio, filesize, devblocksize, flags)
 }
 
 
-
 static int
 cluster_phys_read(vp, uio, filesize, devblocksize, flags)
 	struct vnode *vp;
@@ -2828,7 +2820,7 @@ cluster_phys_read(vp, uio, filesize, devblocksize, flags)
 	upl_page_info_t *pl;
 	upl_t            upl;
 	vm_offset_t      upl_offset;
-	vm_offset_t      dst_paddr;
+	addr64_t	     dst_paddr;
 	off_t            max_size;
 	int              io_size;
 	int              tail_size;
@@ -2884,7 +2876,7 @@ cluster_phys_read(vp, uio, filesize, devblocksize, flags)
 	}
 	pl = ubc_upl_pageinfo(upl);
 
-	dst_paddr = (vm_offset_t)upl_phys_page(pl, 0) + ((vm_offset_t)iov->iov_base & PAGE_MASK);
+	dst_paddr = (((addr64_t)(int)upl_phys_page(pl, 0)) << 12) + ((addr64_t)iov->iov_base & PAGE_MASK);
 
 	while (((uio->uio_offset & (devblocksize - 1)) || io_size < devblocksize) && io_size) {
 	        int   head_size;
@@ -2926,7 +2918,7 @@ cluster_phys_read(vp, uio, filesize, devblocksize, flags)
 		 * the commit after all the I/O has completed
 		 * since its all issued against the same UPL
 		 * if there are already too many outstanding reads
-		 * throttle back until we reach a more reasonable level
+		 * wait until some have completed before issuing the next
 		 */
 		while ((iostate.io_issued - iostate.io_completed) > (2 * MAX_UPL_TRANSFER * PAGE_SIZE)) {
 	                iostate.io_wanted = 1;
@@ -2951,8 +2943,8 @@ cluster_phys_read(vp, uio, filesize, devblocksize, flags)
 		}
 	}
 	/*
-	 * make sure any async reads have completed before
-	 * we proceed
+	 * make sure all async reads that are part of this stream
+	 * have completed before we proceed
 	 */
 	while (iostate.io_issued != iostate.io_completed) {
 	        iostate.io_wanted = 1;
@@ -3404,12 +3396,12 @@ cluster_push_x(vp, EOF, first, last, can_delay)
 
 
 static int
-cluster_align_phys_io(struct vnode *vp, struct uio *uio, vm_offset_t usr_paddr, int xsize, int devblocksize, int flags)
+cluster_align_phys_io(struct vnode *vp, struct uio *uio, addr64_t usr_paddr, int xsize, int devblocksize, int flags)
 {
         struct iovec     *iov;
         upl_page_info_t  *pl;
         upl_t            upl;
-        vm_offset_t      ubc_paddr;
+        addr64_t	     ubc_paddr;
         kern_return_t    kret;
         int              error = 0;
 
@@ -3437,27 +3429,35 @@ cluster_align_phys_io(struct vnode *vp, struct uio *uio, vm_offset_t usr_paddr,
                           return(error);
                 }
         }
-        ubc_paddr = (vm_offset_t)upl_phys_page(pl, 0) + (int)(uio->uio_offset & PAGE_MASK_64);
-
-	if (flags & CL_READ)
-	        copyp2p(ubc_paddr, usr_paddr, xsize, 2);
-	else
-	        copyp2p(usr_paddr, ubc_paddr, xsize, 1);
-
-	if ( !(flags & CL_READ) || upl_dirty_page(pl, 0)) {
-                /*
-                 * issue a synchronous write to cluster_io
-                 */
-                error = cluster_io(vp, upl, 0, uio->uio_offset & ~PAGE_MASK_64, PAGE_SIZE, devblocksize,
-				   0, (struct buf *)0, (struct clios *)0);
-	}
-	if (error == 0) {
-	        uio->uio_offset += xsize;
-		iov->iov_base   += xsize;
-		iov->iov_len    -= xsize;
-		uio->uio_resid  -= xsize;
-	}
-	ubc_upl_abort_range(upl, 0, PAGE_SIZE, UPL_ABORT_DUMP_PAGES | UPL_ABORT_FREE_ON_EMPTY);
+        ubc_paddr = ((addr64_t)upl_phys_page(pl, 0) << 12) + (addr64_t)(uio->uio_offset & PAGE_MASK_64);
 
-        return (error);
+/*
+ *		NOTE:  There is no prototype for the following in BSD. It, and the definitions
+ *		of the defines for cppvPsrc, cppvPsnk, cppvFsnk, and cppvFsrc will be found in
+ *		osfmk/ppc/mappings.h.  They are not included here because there appears to be no
+ *		way to do so without exporting them to kexts as well.
+ */
+		if (flags & CL_READ)
+//			copypv(ubc_paddr, usr_paddr, xsize, cppvPsrc | cppvPsnk | cppvFsnk);	/* Copy physical to physical and flush the destination */
+			copypv(ubc_paddr, usr_paddr, xsize,        2 |        1 |        4);	/* Copy physical to physical and flush the destination */
+		else
+//			copypv(ubc_paddr, usr_paddr, xsize, cppvPsrc | cppvPsnk | cppvFsrc);	/* Copy physical to physical and flush the source */
+			copypv(ubc_paddr, usr_paddr, xsize,        2 |        1 |        8);	/* Copy physical to physical and flush the source */
+	
+		if ( !(flags & CL_READ) || upl_dirty_page(pl, 0)) {
+			/*
+			* issue a synchronous write to cluster_io
+			*/
+			error = cluster_io(vp, upl, 0, uio->uio_offset & ~PAGE_MASK_64, PAGE_SIZE, devblocksize,
+				0, (struct buf *)0, (struct clios *)0);
+		}
+		if (error == 0) {
+			uio->uio_offset += xsize;
+			iov->iov_base   += xsize;
+			iov->iov_len    -= xsize;
+			uio->uio_resid  -= xsize;
+		}
+		ubc_upl_abort_range(upl, 0, PAGE_SIZE, UPL_ABORT_DUMP_PAGES | UPL_ABORT_FREE_ON_EMPTY);
+	
+		return (error);
 }
diff --git a/bsd/vfs/vfs_conf.c b/bsd/vfs/vfs_conf.c
index c306b1aa5..3b83965b0 100644
--- a/bsd/vfs/vfs_conf.c
+++ b/bsd/vfs/vfs_conf.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/vfs/vfs_init.c b/bsd/vfs/vfs_init.c
index 536623adc..6d84b356a 100644
--- a/bsd/vfs/vfs_init.c
+++ b/bsd/vfs/vfs_init.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/vfs/vfs_journal.c b/bsd/vfs/vfs_journal.c
index 2acb4fab2..c6a73d7a7 100644
--- a/bsd/vfs/vfs_journal.c
+++ b/bsd/vfs/vfs_journal.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -309,7 +312,7 @@ free_old_stuff(journal *jnl)
 
     for(tr=jnl->tr_freeme; tr; tr=next) {
 		next = tr->next;
-		kmem_free(kernel_map, (vm_offset_t)tr, sizeof(transaction));
+		FREE_ZONE(tr, sizeof(transaction), M_JNL_TR);
     }
 
     jnl->tr_freeme = NULL;
@@ -507,7 +510,6 @@ update_fs_block(journal *jnl, void *block_ptr, off_t fs_block, size_t bsize)
 
     if ((ret = VOP_BWRITE(oblock_bp)) != 0) {
 		printf("jnl: update_fs_block: failed to update block %lld (ret %d)\n", fs_block,ret);
-		brelse(oblock_bp);
 		return ret;
     }
 
@@ -757,9 +759,7 @@ journal_create(struct vnode *jvp,
 		return NULL;
     }
 
-    if (kmem_alloc(kernel_map, (vm_offset_t *)&jnl, sizeof(struct journal))) {
-		return NULL;
-    }
+    MALLOC_ZONE(jnl, struct journal *, sizeof(struct journal), M_JNL_JNL, M_WAITOK);
     memset(jnl, 0, sizeof(*jnl));
 
     jnl->jdev         = jvp;
@@ -811,7 +811,7 @@ journal_create(struct vnode *jvp,
     kmem_free(kernel_map, (vm_offset_t)jnl->header_buf, phys_blksz);
   bad_kmem_alloc:
     jnl->jhdr = NULL;
-	kmem_free(kernel_map, (vm_offset_t)jnl, sizeof(struct journal));
+	FREE_ZONE(jnl, sizeof(struct journal), M_JNL_JNL);
     return NULL;
 }
 
@@ -848,9 +848,7 @@ journal_open(struct vnode *jvp,
 		return NULL;
     }
 
-    if (kmem_alloc(kernel_map, (vm_offset_t *)&jnl, sizeof(struct journal))) {
-		return NULL;
-    }
+    MALLOC_ZONE(jnl, struct journal *, sizeof(struct journal), M_JNL_JNL, M_WAITOK);
     memset(jnl, 0, sizeof(*jnl));
 
     jnl->jdev         = jvp;
@@ -989,7 +987,7 @@ journal_open(struct vnode *jvp,
 	}
     kmem_free(kernel_map, (vm_offset_t)jnl->header_buf, phys_blksz);
   bad_kmem_alloc:
-	kmem_free(kernel_map, (vm_offset_t)jnl, sizeof(struct journal));
+	FREE_ZONE(jnl, sizeof(struct journal), M_JNL_JNL);
     return NULL;    
 }
 
@@ -1044,7 +1042,7 @@ journal_close(journal *jnl)
 			if (jnl->flush) {
 				jnl->flush(jnl->flush_arg);
 			}
-	
+			tsleep((caddr_t)jnl, PRIBIO, "jnl_close", 1);
 		}
 
 		if (*start != *end) {
@@ -1084,7 +1082,7 @@ journal_close(journal *jnl)
     jnl->jhdr = (void *)0xbeefbabe;
 
     semaphore_destroy(kernel_task, jnl->jsem);
-	kmem_free(kernel_map, (vm_offset_t)jnl, sizeof(struct journal));
+	FREE_ZONE(jnl, sizeof(struct journal), M_JNL_JNL);
 }
 
 static void
@@ -1141,6 +1139,8 @@ check_free_space(journal *jnl, int desired_size)
 //	   desired_size, free_space(jnl));
     
     while (1) {
+		int old_start_empty;
+
 		if (counter++ == 5000) {
 			dump_journal(jnl);
 			panic("jnl: check_free_space: buffer flushing isn't working "
@@ -1161,6 +1161,7 @@ check_free_space(journal *jnl, int desired_size)
 		// here's where we lazily bump up jnl->jhdr->start.  we'll consume
 		// entries until there is enough space for the next transaction.
 		//
+		old_start_empty = 1;
 		simple_lock(&jnl->old_start_lock);
 		for(i=0; i < sizeof(jnl->old_start)/sizeof(jnl->old_start[0]); i++) {
 			int   counter;
@@ -1184,6 +1185,7 @@ check_free_space(journal *jnl, int desired_size)
 				continue;
 			}
 
+			old_start_empty   = 0;
 			jnl->jhdr->start  = jnl->old_start[i];
 			jnl->old_start[i] = 0;
 			if (free_space(jnl) > desired_size) {
@@ -1196,6 +1198,19 @@ check_free_space(journal *jnl, int desired_size)
 		// if we bumped the start, loop and try again
 		if (i < sizeof(jnl->old_start)/sizeof(jnl->old_start[0])) {
 			continue;
+		} else if (old_start_empty) {
+			//
+			// if there is nothing in old_start anymore then we can
+			// bump the jhdr->start to be the same as active_start
+			// since it is possible there was only one very large
+			// transaction in the old_start array.  if we didn't do
+			// this then jhdr->start would never get updated and we
+			// would wind up looping until we hit the panic at the
+			// start of the loop.
+			//
+			jnl->jhdr->start = jnl->active_start;
+			write_journal_header(jnl);
+			continue;
 		}
 
 
@@ -1268,16 +1283,12 @@ journal_start_transaction(journal *jnl)
 		return 0;
     }
 
-    if (kmem_alloc(kernel_map, (vm_offset_t *)&tr, sizeof(transaction))) {
-		printf("jnl: start transaction failed: no mem\n");
-		ret = ENOMEM;
-		goto bad_start;
-    }
+	MALLOC_ZONE(tr, transaction *, sizeof(transaction), M_JNL_TR, M_WAITOK);
     memset(tr, 0, sizeof(transaction));
 
     tr->tbuffer_size = jnl->tbuffer_size;
     if (kmem_alloc(kernel_map, (vm_offset_t *)&tr->tbuffer, tr->tbuffer_size)) {
-		kmem_free(kernel_map, (vm_offset_t)tr, sizeof(transaction));
+		FREE_ZONE(tr, sizeof(transaction), M_JNL_TR);
 		printf("jnl: start transaction failed: no tbuffer mem\n");
 		ret = ENOMEM;
 		goto bad_start;
@@ -1873,6 +1884,9 @@ end_transaction(transaction *tr, int force_it)
 			} else {
 				printf("jnl: end_transaction: could not find block %Ld vp 0x%x!\n",
 					   blhdr->binfo[i].bnum, blhdr->binfo[i].bp);
+				if (bp) {
+					brelse(bp);
+				}
 			}
 		}
 
@@ -1918,7 +1932,7 @@ abort_transaction(journal *jnl, transaction *tr)
 							 blhdr->binfo[i].bp->b_bufsize,
 							 NOCRED,
 							 &bp);
-			if (ret == 0 && bp != NULL) {
+			if (ret == 0) {
 				if (bp != blhdr->binfo[i].bp) {
 					panic("jnl: abort_tr: got back a different bp! (bp 0x%x should be 0x%x, jnl 0x%x\n",
 						  bp, blhdr->binfo[i].bp, jnl);
@@ -1934,6 +1948,9 @@ abort_transaction(journal *jnl, transaction *tr)
 			} else {
 				printf("jnl: abort_tr: could not find block %Ld vp 0x%x!\n",
 					   blhdr->binfo[i].bnum, blhdr->binfo[i].bp);
+				if (bp) {
+					brelse(bp);
+				}
 			}
 		}
 
@@ -1947,7 +1964,7 @@ abort_transaction(journal *jnl, transaction *tr)
     tr->tbuffer     = NULL;
     tr->blhdr       = NULL;
     tr->total_bytes = 0xdbadc0de;
-	kmem_free(kernel_map, (vm_offset_t)tr, sizeof(transaction));
+	FREE_ZONE(tr, sizeof(transaction), M_JNL_TR);
 }
 
 
diff --git a/bsd/vfs/vfs_journal.h b/bsd/vfs/vfs_journal.h
index 523ba7d52..9551218a0 100644
--- a/bsd/vfs/vfs_journal.h
+++ b/bsd/vfs/vfs_journal.h
@@ -4,19 +4,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/vfs/vfs_lookup.c b/bsd/vfs/vfs_lookup.c
index 9d8aea299..189de5062 100644
--- a/bsd/vfs/vfs_lookup.c
+++ b/bsd/vfs/vfs_lookup.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/vfs/vfs_quota.c b/bsd/vfs/vfs_quota.c
index 36f4fb89a..c60bb78ed 100644
--- a/bsd/vfs/vfs_quota.c
+++ b/bsd/vfs/vfs_quota.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -87,6 +90,11 @@ u_long dqhash;
 TAILQ_HEAD(dqfreelist, dquot) dqfreelist;
 long numdquot, desireddquot = DQUOTINC;
 
+/*
+ * Dquot dirty orphans list.
+ */
+TAILQ_HEAD(dqdirtylist, dquot) dqdirtylist;
+
 
 static int dqlookup(struct quotafile *, u_long, struct	dqblk *, u_int32_t *);
 
@@ -100,6 +108,7 @@ dqinit()
 
 	dqhashtbl = hashinit(desiredvnodes, M_DQUOT, &dqhash);
 	TAILQ_INIT(&dqfreelist);
+	TAILQ_INIT(&dqdirtylist);
 }
 
 
@@ -236,8 +245,12 @@ dqget(vp, id, qfp, type, dqp)
 		 * Cache hit with no references.  Take
 		 * the structure off the free list.
 		 */
-		if (dq->dq_cnt == 0)
-			TAILQ_REMOVE(&dqfreelist, dq, dq_freelist);
+		if (dq->dq_cnt == 0) {
+			if (dq->dq_flags & DQ_MOD)
+				TAILQ_REMOVE(&dqdirtylist, dq, dq_freelist);
+			else
+				TAILQ_REMOVE(&dqfreelist, dq, dq_freelist);
+		}
 		DQREF(dq);
 		*dqp = dq;
 		return (0);
@@ -425,6 +438,57 @@ dqrele(vp, dq)
 	TAILQ_INSERT_TAIL(&dqfreelist, dq, dq_freelist);
 }
 
+/*
+ * Release a reference to a dquot but don't do any I/O.
+ */
+void
+dqreclaim(vp, dq)
+	struct vnode *vp;
+	register struct dquot *dq;
+{
+	if (dq == NODQUOT)
+		return;
+
+	if (--dq->dq_cnt > 0)
+		return;
+
+	if (dq->dq_flags & DQ_MOD)
+		TAILQ_INSERT_TAIL(&dqdirtylist, dq, dq_freelist);
+	else
+		TAILQ_INSERT_TAIL(&dqfreelist, dq, dq_freelist);
+}
+
+/*
+ * Update a quota file's orphaned disk quotas.
+ */
+void
+dqsync_orphans(qfp)
+	struct quotafile *qfp;
+{
+	struct dquot *dq;
+
+  loop:
+	TAILQ_FOREACH(dq, &dqdirtylist, dq_freelist) {
+		if ((dq->dq_flags & DQ_MOD) == 0)
+			panic("dqsync_orphans: dirty dquot isn't");
+		if (dq->dq_cnt != 0)
+			panic("dqsync_orphans: dquot in use");
+
+		if (dq->dq_qfile == qfp) {
+			TAILQ_REMOVE(&dqdirtylist, dq, dq_freelist);
+
+			dq->dq_cnt++;
+			(void) dqsync(NULLVP, dq);
+			dq->dq_cnt--;
+
+			if ((dq->dq_cnt == 0) && (dq->dq_flags & DQ_MOD) == 0)
+				TAILQ_INSERT_TAIL(&dqfreelist, dq, dq_freelist);
+
+			goto loop;
+		}
+	}
+}
+
 /*
  * Update the disk quota in the quota file.
  */
diff --git a/bsd/vfs/vfs_subr.c b/bsd/vfs/vfs_subr.c
index ce79f9d4d..742af69fd 100644
--- a/bsd/vfs/vfs_subr.c
+++ b/bsd/vfs/vfs_subr.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/vfs/vfs_support.c b/bsd/vfs/vfs_support.c
index 3eeabf3ef..c74bde6fa 100644
--- a/bsd/vfs/vfs_support.c
+++ b/bsd/vfs/vfs_support.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/vfs/vfs_support.h b/bsd/vfs/vfs_support.h
index 7eac9f21e..19e2e42eb 100644
--- a/bsd/vfs/vfs_support.h
+++ b/bsd/vfs/vfs_support.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/vfs/vfs_syscalls.c b/bsd/vfs/vfs_syscalls.c
index b76cdabb2..e8f562103 100644
--- a/bsd/vfs/vfs_syscalls.c
+++ b/bsd/vfs/vfs_syscalls.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -143,24 +146,28 @@ mount(p, uap, retval)
 			return (EINVAL);
 		}
 		mp = vp->v_mount;
-		flag = mp->mnt_flag;
+
+		if (vfs_busy(mp, LK_NOWAIT, 0, p)) {
+			vput(vp);
+			return (EBUSY);
+		}
 		/*
 		 * We only allow the filesystem to be reloaded if it
 		 * is currently mounted read-only.
 		 */
 		if ((uap->flags & MNT_RELOAD) &&
 		    ((mp->mnt_flag & MNT_RDONLY) == 0)) {
+		        vfs_unbusy(mp, p);
 			vput(vp);
 			return (EOPNOTSUPP);	/* Needs translation */
 		}
-		mp->mnt_flag |=
-		    uap->flags & (MNT_RELOAD | MNT_FORCE | MNT_UPDATE);
 		/*
 		 * Only root, or the user that did the original mount is
 		 * permitted to update it.
 		 */
 		if (mp->mnt_stat.f_owner != p->p_ucred->cr_uid &&
 		    (error = suser(p->p_ucred, &p->p_acflag))) {
+		        vfs_unbusy(mp, p);
 			vput(vp);
 			return (error);
 		}
@@ -171,18 +178,21 @@ mount(p, uap, retval)
 		 */
 		if (p->p_ucred->cr_uid != 0) {
 			if (uap->flags & MNT_EXPORTED) {
+			        vfs_unbusy(mp, p);
 				vput(vp);
 				return (EPERM);
 			}
 			uap->flags |= MNT_NOSUID | MNT_NODEV;
-			if (flag & MNT_NOEXEC)
+			if (mp->mnt_flag & MNT_NOEXEC)
 				uap->flags |= MNT_NOEXEC;
 		}
-		if (vfs_busy(mp, LK_NOWAIT, 0, p)) {
-			vput(vp);
-			return (EBUSY);
-		}
+		flag = mp->mnt_flag;
+
+		mp->mnt_flag |=
+		    uap->flags & (MNT_RELOAD | MNT_FORCE | MNT_UPDATE);
+
 		VOP_UNLOCK(vp, 0, p);
+
 		goto update;
 	}
 	/*
@@ -296,7 +306,8 @@ update:
 	 * Mount the filesystem.
 	 */
 	error = VFS_MOUNT(mp, uap->path, uap->data, &nd, p);
-	if (mp->mnt_flag & MNT_UPDATE) {
+
+	if (uap->flags & MNT_UPDATE) {
 		vrele(vp);
 		if (mp->mnt_kern_flag & MNTK_WANTRDWR)
 			mp->mnt_flag &= ~MNT_RDONLY;
@@ -324,6 +335,7 @@ update:
 		vp->v_mountedhere =mp;
 		simple_unlock(&vp->v_interlock);
 		simple_lock(&mountlist_slock);
+
 		CIRCLEQ_INSERT_TAIL(&mountlist, mp, mnt_list);
 		simple_unlock(&mountlist_slock);
 		checkdirs(vp);
@@ -544,6 +556,7 @@ dounmount(mp, flags, p)
 	/* increment the operations count */
 	if (!error)
 		vfs_nummntops++;
+
 	CIRCLEQ_REMOVE(&mountlist, mp, mnt_list);
 	if ((coveredvp = mp->mnt_vnodecovered) != NULLVP) {
 		coveredvp->v_mountedhere = (struct mount *)0;
@@ -941,7 +954,7 @@ chroot(p, uap, retval)
 		shared_regions_active = TRUE;
 	}
 
-	if(error = clone_system_shared_regions(shared_regions_active)) {
+	if(error = clone_system_shared_regions(shared_regions_active, nd.ni_vp)) {
 		vrele(nd.ni_vp);
 		return (error);
 	}
diff --git a/bsd/vfs/vfs_utfconv.c b/bsd/vfs/vfs_utfconv.c
index d2623589b..7d2e88396 100644
--- a/bsd/vfs/vfs_utfconv.c
+++ b/bsd/vfs/vfs_utfconv.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/vfs/vfs_utfconvdata.h b/bsd/vfs/vfs_utfconvdata.h
index bc0c675fe..9d82343d0 100644
--- a/bsd/vfs/vfs_utfconvdata.h
+++ b/bsd/vfs/vfs_utfconvdata.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/vfs/vfs_vnops.c b/bsd/vfs/vfs_vnops.c
index e186fb484..40177b401 100644
--- a/bsd/vfs/vfs_vnops.c
+++ b/bsd/vfs/vfs_vnops.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/vfs/vnode_if.c b/bsd/vfs/vnode_if.c
index cfaf2ed72..3a5438e57 100644
--- a/bsd/vfs/vnode_if.c
+++ b/bsd/vfs/vnode_if.c
@@ -4,19 +4,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/vm/dp_backing_file.c b/bsd/vm/dp_backing_file.c
index e1ff49d7b..f6823f6fe 100644
--- a/bsd/vm/dp_backing_file.c
+++ b/bsd/vm/dp_backing_file.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/vm/vm_pageout.h b/bsd/vm/vm_pageout.h
index 4a473fd46..3fb32bcb8 100644
--- a/bsd/vm/vm_pageout.h
+++ b/bsd/vm/vm_pageout.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/vm/vm_pager.h b/bsd/vm/vm_pager.h
index 6a12dde49..2c4246a44 100644
--- a/bsd/vm/vm_pager.h
+++ b/bsd/vm/vm_pager.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/bsd/vm/vm_unix.c b/bsd/vm/vm_unix.c
index 0656cfdad..be634ec2b 100644
--- a/bsd/vm/vm_unix.c
+++ b/bsd/vm/vm_unix.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -66,7 +69,6 @@
 #include <vm/vm_shared_memory_server.h>
 
 
-extern shared_region_mapping_t	system_shared_region;
 extern zone_t lsf_zone;
 
 useracc(addr, len, prot)
@@ -76,7 +78,7 @@ useracc(addr, len, prot)
 {
 	return (vm_map_check_protection(
 			current_map(),
-			trunc_page(addr), round_page(addr+len),
+			trunc_page_32((unsigned int)addr), round_page_32((unsigned int)(addr+len)),
 			prot == B_READ ? VM_PROT_READ : VM_PROT_WRITE));
 }
 
@@ -85,8 +87,8 @@ vslock(addr, len)
 	int	len;
 {
 kern_return_t kret;
-	kret = vm_map_wire(current_map(), trunc_page(addr),
-			round_page(addr+len), 
+	kret = vm_map_wire(current_map(), trunc_page_32((unsigned int)addr),
+			round_page_32((unsigned int)(addr+len)), 
 			VM_PROT_READ | VM_PROT_WRITE ,FALSE);
 
 	switch (kret) {
@@ -117,7 +119,7 @@ vsunlock(addr, len, dirtied)
 #if FIXME  /* [ */
 	if (dirtied) {
 		pmap = get_task_pmap(current_task());
-		for (vaddr = trunc_page(addr); vaddr < round_page(addr+len);
+		for (vaddr = trunc_page((unsigned int)(addr)); vaddr < round_page((unsigned int)(addr+len));
 				vaddr += PAGE_SIZE) {
 			paddr = pmap_extract(pmap, vaddr);
 			pg = PHYS_TO_VM_PAGE(paddr);
@@ -128,8 +130,8 @@ vsunlock(addr, len, dirtied)
 #ifdef	lint
 	dirtied++;
 #endif	/* lint */
-	kret = vm_map_unwire(current_map(), trunc_page(addr),
-				round_page(addr+len), FALSE);
+	kret = vm_map_unwire(current_map(), trunc_page_32((unsigned int)(addr)),
+				round_page_32((unsigned int)(addr+len)), FALSE);
 	switch (kret) {
 	case KERN_SUCCESS:
 		return (0);
@@ -389,12 +391,33 @@ load_shared_file(
         }
 
 	if(local_flags & QUERY_IS_SYSTEM_REGION) {
+			shared_region_mapping_t	default_shared_region;
 			vm_get_shared_region(current_task(), &shared_region);
-			if (shared_region == system_shared_region) {
+			task_mapping_info.self = (vm_offset_t)shared_region;
+
+			shared_region_mapping_info(shared_region, 
+					&(task_mapping_info.text_region), 
+					&(task_mapping_info.text_size),
+					&(task_mapping_info.data_region), 
+					&(task_mapping_info.data_size), 
+					&(task_mapping_info.region_mappings),
+					&(task_mapping_info.client_base), 
+					&(task_mapping_info.alternate_base),
+					&(task_mapping_info.alternate_next), 
+					&(task_mapping_info.fs_base),
+					&(task_mapping_info.system),
+					&(task_mapping_info.flags), &next);
+
+			default_shared_region =
+				lookup_default_shared_region(
+					ENV_DEFAULT_ROOT, 
+					task_mapping_info.system);
+			if (shared_region == default_shared_region) {
 				local_flags = SYSTEM_REGION_BACKED;
 			} else {
 				local_flags = 0;
 			}
+			shared_region_mapping_dealloc(default_shared_region);
 			error = 0;
 			error = copyout(&local_flags, flags, sizeof (int));
 			goto lsf_bailout;
@@ -455,28 +478,6 @@ load_shared_file(
 		goto lsf_bailout_free_vput;
 	}
 
-	vm_get_shared_region(current_task(), &shared_region);
-	if(shared_region == system_shared_region) {
-		default_regions = 1;
-	}
-	if(((vp->v_mount != rootvnode->v_mount)
-			&& (shared_region == system_shared_region)) 
-		&& (lsf_mapping_pool_gauge() < 75)) {
-				/* We don't want to run out of shared memory */
-				/* map entries by starting too many private versions */
-				/* of the shared library structures */
-		int	error;
-       		if(p->p_flag & P_NOSHLIB) {
-				error = clone_system_shared_regions(FALSE);
-        		} else {
-				error = clone_system_shared_regions(TRUE);
-        		}
-		if (error) {
-			goto lsf_bailout_free_vput;
-		}
-		local_flags = local_flags & ~NEW_LOCAL_SHARED_REGIONS;
-		vm_get_shared_region(current_task(), &shared_region);
-	}
 #ifdef notdef
 	if(vattr.va_size != mapped_file_size) {
 		error = EINVAL;
@@ -490,13 +491,13 @@ load_shared_file(
 	/* load alternate regions if the caller has requested.  */
 	/* Note: the new regions are "clean slates" */
 	if (local_flags & NEW_LOCAL_SHARED_REGIONS) {
-		error = clone_system_shared_regions(FALSE);
+		error = clone_system_shared_regions(FALSE, ENV_DEFAULT_ROOT);
 		if (error) {
 			goto lsf_bailout_free_vput;
 		}
-		vm_get_shared_region(current_task(), &shared_region);
 	}
 
+	vm_get_shared_region(current_task(), &shared_region);
 	task_mapping_info.self = (vm_offset_t)shared_region;
 
 	shared_region_mapping_info(shared_region, 
@@ -508,8 +509,54 @@ load_shared_file(
 			&(task_mapping_info.client_base), 
 			&(task_mapping_info.alternate_base),
 			&(task_mapping_info.alternate_next), 
+			&(task_mapping_info.fs_base),
+			&(task_mapping_info.system),
 			&(task_mapping_info.flags), &next);
 
+	{
+		shared_region_mapping_t	default_shared_region;
+		default_shared_region =
+			lookup_default_shared_region(
+				ENV_DEFAULT_ROOT, 
+				task_mapping_info.system);
+		if(shared_region == default_shared_region) {
+			default_regions = 1;
+		}
+		shared_region_mapping_dealloc(default_shared_region);
+	}
+	/* If we are running on a removable file system we must not */
+	/* be in a set of shared regions or the file system will not */
+	/* be removable. */
+	if(((vp->v_mount != rootvnode->v_mount) && (default_regions)) 
+		&& (lsf_mapping_pool_gauge() < 75)) {
+				/* We don't want to run out of shared memory */
+				/* map entries by starting too many private versions */
+				/* of the shared library structures */
+		int	error;
+       		if(p->p_flag & P_NOSHLIB) {
+				error = clone_system_shared_regions(FALSE, ENV_DEFAULT_ROOT);
+       		} else {
+				error = clone_system_shared_regions(TRUE, ENV_DEFAULT_ROOT);
+       		}
+		if (error) {
+			goto lsf_bailout_free_vput;
+		}
+		local_flags = local_flags & ~NEW_LOCAL_SHARED_REGIONS;
+		vm_get_shared_region(current_task(), &shared_region);
+		shared_region_mapping_info(shared_region, 
+			&(task_mapping_info.text_region), 
+			&(task_mapping_info.text_size),
+			&(task_mapping_info.data_region), 
+			&(task_mapping_info.data_size), 
+			&(task_mapping_info.region_mappings),
+			&(task_mapping_info.client_base), 
+			&(task_mapping_info.alternate_base),
+			&(task_mapping_info.alternate_next), 
+			&(task_mapping_info.fs_base),
+			&(task_mapping_info.system),
+			&(task_mapping_info.flags), &next);
+	}
+
 	/*  This is a work-around to allow executables which have been */
 	/*  built without knowledge of the proper shared segment to    */
 	/*  load.  This code has been architected as a shared region   */
@@ -689,24 +736,8 @@ new_system_shared_regions(
 		return EINVAL;
 	}
 
-	/* get current shared region info for  */
-	/* restoration after new system shared */
-	/* regions are in place */
-	vm_get_shared_region(current_task(), &regions);
-
-	/* usually only called at boot time    */
-	/* shared_file_boot_time_init creates  */
-	/* a new set of system shared regions  */
-	/* and places them as the system       */
-	/* shared regions.                     */
-	shared_file_boot_time_init();
-
-	/* set current task back to its        */
-	/* original regions.                   */
-	vm_get_shared_region(current_task(), &new_regions);
-	shared_region_mapping_dealloc(new_regions);
-
-	vm_set_shared_region(current_task(), regions);
+	/* clear all of our existing defaults */
+	remove_all_shared_regions();
 
 	*retval = 0;
 	return 0;
@@ -715,7 +746,7 @@ new_system_shared_regions(
 
 
 int
-clone_system_shared_regions(shared_regions_active)
+clone_system_shared_regions(shared_regions_active, base_vnode)
 {
 	shared_region_mapping_t	new_shared_region;
 	shared_region_mapping_t	next;
@@ -725,8 +756,6 @@ clone_system_shared_regions(shared_regions_active)
 
 	struct proc	*p;
 
-	if (shared_file_create_system_region(&new_shared_region))
-		return (ENOMEM);
 	vm_get_shared_region(current_task(), &old_shared_region);
 	old_info.self = (vm_offset_t)old_shared_region;
 	shared_region_mapping_info(old_shared_region,
@@ -738,7 +767,27 @@ clone_system_shared_regions(shared_regions_active)
 		&(old_info.client_base),
 		&(old_info.alternate_base),
 		&(old_info.alternate_next), 
+		&(old_info.fs_base),
+		&(old_info.system),
 		&(old_info.flags), &next);
+	if ((shared_regions_active) ||
+		(base_vnode == ENV_DEFAULT_ROOT)) {
+	   if (shared_file_create_system_region(&new_shared_region))
+		return (ENOMEM);
+	} else {
+	   new_shared_region = 
+		lookup_default_shared_region(
+			base_vnode, old_info.system);
+	   if(new_shared_region == NULL) {
+		shared_file_boot_time_init(
+			base_vnode, old_info.system);
+		vm_get_shared_region(current_task(), &new_shared_region);
+	   } else {
+		vm_set_shared_region(current_task(), new_shared_region);
+	   }
+	   if(old_shared_region)
+		shared_region_mapping_dealloc(old_shared_region);
+	}
 	new_info.self = (vm_offset_t)new_shared_region;
 	shared_region_mapping_info(new_shared_region,
 		&(new_info.text_region),   
@@ -749,6 +798,8 @@ clone_system_shared_regions(shared_regions_active)
 		&(new_info.client_base),
 		&(new_info.alternate_base),
 		&(new_info.alternate_next), 
+		&(new_info.fs_base),
+		&(new_info.system),
 		&(new_info.flags), &next);
 	if(shared_regions_active) {
 	   if(vm_region_clone(old_info.text_region, new_info.text_region)) {
@@ -1214,7 +1265,7 @@ bsd_read_page_cache_file(
 				(caddr_t) *buffer, profile_size, 
 				profile, UIO_SYSSPACE, IO_NODELOCKED, 
 				p->p_ucred, &resid, p);
-			if(error) {
+			if((error) || (profile_size == resid)) {
 				VOP_UNLOCK(names_vp, 0, p);
 				VOP_UNLOCK(data_vp, 0, p);
 				bsd_close_page_cache_files(uid_files);
@@ -1337,7 +1388,7 @@ bsd_search_page_cache_data_base(
 				(caddr_t)(local_buf + resid_off),
 				size, file_off + resid_off, UIO_SYSSPACE, 
 				IO_NODELOCKED, p->p_ucred, &resid, p);
-			if(error) {
+			if((error) || (size == resid)) {
 				if(local_buf != NULL) {
 					kmem_free(kernel_map, 
 						(vm_offset_t)local_buf, 
diff --git a/bsd/vm/vnode_pager.c b/bsd/vm/vnode_pager.c
index 387b0995f..8b1be2843 100644
--- a/bsd/vm/vnode_pager.c
+++ b/bsd/vm/vnode_pager.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -134,7 +137,7 @@ vnode_pageout(struct vnode *vp,
 
 		goto out;
 	}
-	ubc_create_upl(vp, f_offset, isize, &vpupl, &pl, UPL_COPYOUT_FROM);
+	ubc_create_upl(vp, f_offset, isize, &vpupl, &pl, UPL_FOR_PAGEOUT | UPL_COPYOUT_FROM);
 
 	if (vpupl == (upl_t) 0) {
 		result = error = PAGER_ABSENT;
diff --git a/bsd/vm/vnode_pager.h b/bsd/vm/vnode_pager.h
index 45b21e9fb..18621f853 100644
--- a/bsd/vm/vnode_pager.h
+++ b/bsd/vm/vnode_pager.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/config/Makefile b/config/Makefile
new file mode 100644
index 000000000..5e4c73ade
--- /dev/null
+++ b/config/Makefile
@@ -0,0 +1,46 @@
+export MakeInc_cmd=${SRCROOT}/makedefs/MakeInc.cmd
+export MakeInc_def=${SRCROOT}/makedefs/MakeInc.def
+export MakeInc_rule=${SRCROOT}/makedefs/MakeInc.rule
+export MakeInc_dir=${SRCROOT}/makedefs/MakeInc.dir
+
+
+include $(MakeInc_cmd)
+include $(MakeInc_def)
+
+ALL_SUBDIRS = 
+
+INSTINC_SUBDIRS = 
+
+INSTINC_SUBDIRS_PPC = 
+
+INSTINC_SUBDIRS_I386 = 
+
+EXPINC_SUBDIRS = 
+
+EXPINC_SUBDIRS_PPC =  
+
+EXPINC_SUBDIRS_I386 = 
+
+COMP_SUBDIRS = 
+
+INST_SUBDIRS =	
+
+INSTALL_DATA_LIST= \
+	System.kext/Contents/Info.plist \
+	System.kext/Contents/PlugIns/AppleNMI.kext/Contents/Info.plist \
+	System.kext/Contents/PlugIns/ApplePlatformFamily.kext/Contents/Info.plist \
+	System.kext/Contents/PlugIns/BSDKernel.kext/Contents/Info.plist \
+	System.kext/Contents/PlugIns/IOADBFamily.kext/Contents/Info.plist \
+	System.kext/Contents/PlugIns/IOKit.kext/Contents/Info.plist \
+	System.kext/Contents/PlugIns/IONVRAMFamily.kext/Contents/Info.plist \
+	System.kext/Contents/PlugIns/IOSystemManagement.kext/Contents/Info.plist \
+	System.kext/Contents/PlugIns/Libkern.kext/Contents/Info.plist \
+	System.kext/Contents/PlugIns/Mach.kext/Contents/Info.plist
+
+INSTALL_DATA_DIR= \
+	/System/Library/Extensions/
+
+INSTMAN_SUBDIRS = 
+
+include $(MakeInc_rule)
+include $(MakeInc_dir)
diff --git a/config/System.kext/Contents/Info.plist b/config/System.kext/Contents/Info.plist
new file mode 100644
index 000000000..08e58bfb8
--- /dev/null
+++ b/config/System.kext/Contents/Info.plist
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>CFBundleDevelopmentRegion</key>
+	<string>English</string>
+	<key>CFBundleGetInfoString</key>
+	<string>System Resource Pseudoextension, Apple Computer Inc, 6.7.5</string>
+	<key>CFBundleIdentifier</key>
+	<string>com.apple.kernel</string>
+	<key>CFBundleInfoDictionaryVersion</key>
+	<string>6.0</string>
+	<key>CFBundleName</key>
+	<string>System Resource Pseudoextension</string>
+	<key>CFBundlePackageType</key>
+	<string>KEXT</string>
+	<key>CFBundleShortVersionString</key>
+	<string>6.7.5</string>
+	<key>CFBundleSignature</key>
+	<string>????</string>
+	<key>CFBundleVersion</key>
+	<string>6.7.5</string>
+	<key>OSBundleCompatibleVersion</key>
+	<string>6.7.5</string>
+	<key>OSBundleRequired</key>
+	<string>Root</string>
+	<key>OSKernelResource</key>
+	<true/>
+</dict>
+</plist>
diff --git a/config/System.kext/Contents/PlugIns/AppleNMI.kext/Contents/Info.plist b/config/System.kext/Contents/PlugIns/AppleNMI.kext/Contents/Info.plist
new file mode 100644
index 000000000..2d73cf673
--- /dev/null
+++ b/config/System.kext/Contents/PlugIns/AppleNMI.kext/Contents/Info.plist
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>CFBundleDevelopmentRegion</key>
+	<string>English</string>
+	<key>CFBundleGetInfoString</key>
+	<string>AppleNMI Pseudoextension, Apple Computer Inc, 6.7.5</string>
+	<key>CFBundleIdentifier</key>
+	<string>com.apple.driver.AppleNMI</string>
+	<key>CFBundleInfoDictionaryVersion</key>
+	<string>6.0</string>
+	<key>CFBundleName</key>
+	<string>AppleNMI Pseudoextension</string>
+	<key>CFBundlePackageType</key>
+	<string>KEXT</string>
+	<key>CFBundleShortVersionString</key>
+	<string>6.7.5</string>
+	<key>CFBundleSignature</key>
+	<string>????</string>
+	<key>CFBundleVersion</key>
+	<string>6.7.5</string>
+	<key>OSBundleRequired</key>
+	<string>Root</string>
+	<key>OSKernelResource</key>
+	<true/>
+</dict>
+</plist>
diff --git a/config/System.kext/Contents/PlugIns/ApplePlatformFamily.kext/Contents/Info.plist b/config/System.kext/Contents/PlugIns/ApplePlatformFamily.kext/Contents/Info.plist
new file mode 100644
index 000000000..d24c1fbe4
--- /dev/null
+++ b/config/System.kext/Contents/PlugIns/ApplePlatformFamily.kext/Contents/Info.plist
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>CFBundleDevelopmentRegion</key>
+	<string>English</string>
+	<key>CFBundleGetInfoString</key>
+	<string>Apple Platform Family Pseudoextension, Apple Computer Inc, 6.7.5</string>
+	<key>CFBundleIdentifier</key>
+	<string>com.apple.iokit.ApplePlatformFamily</string>
+	<key>CFBundleInfoDictionaryVersion</key>
+	<string>6.0</string>
+	<key>CFBundleName</key>
+	<string>Apple Platform Family Pseudoextension</string>
+	<key>CFBundlePackageType</key>
+	<string>KEXT</string>
+	<key>CFBundleShortVersionString</key>
+	<string>6.7.5</string>
+	<key>CFBundleSignature</key>
+	<string>????</string>
+	<key>CFBundleVersion</key>
+	<string>6.7.5</string>
+	<key>OSBundleCompatibleVersion</key>
+	<string>1.0</string>
+	<key>OSBundleRequired</key>
+	<string>Root</string>
+	<key>OSKernelResource</key>
+	<true/>
+</dict>
+</plist>
diff --git a/config/System.kext/Contents/PlugIns/BSDKernel.kext/Contents/Info.plist b/config/System.kext/Contents/PlugIns/BSDKernel.kext/Contents/Info.plist
new file mode 100644
index 000000000..7962bb0dd
--- /dev/null
+++ b/config/System.kext/Contents/PlugIns/BSDKernel.kext/Contents/Info.plist
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>CFBundleDevelopmentRegion</key>
+	<string>English</string>
+	<key>CFBundleGetInfoString</key>
+	<string>BSD Kernel Pseudoextension, Apple Computer Inc, 6.7.5</string>
+	<key>CFBundleIdentifier</key>
+	<string>com.apple.kernel.bsd</string>
+	<key>CFBundleInfoDictionaryVersion</key>
+	<string>6.0</string>
+	<key>CFBundleName</key>
+	<string>BSD Kernel Pseudoextension</string>
+	<key>CFBundlePackageType</key>
+	<string>KEXT</string>
+	<key>CFBundleShortVersionString</key>
+	<string>6.7.5</string>
+	<key>CFBundleSignature</key>
+	<string>????</string>
+	<key>CFBundleVersion</key>
+	<string>6.7.5</string>
+	<key>OSBundleCompatibleVersion</key>
+	<string>1.1</string>
+	<key>OSBundleRequired</key>
+	<string>Root</string>
+	<key>OSKernelResource</key>
+	<true/>
+</dict>
+</plist>
diff --git a/config/System.kext/Contents/PlugIns/IOADBFamily.kext/Contents/Info.plist b/config/System.kext/Contents/PlugIns/IOADBFamily.kext/Contents/Info.plist
new file mode 100644
index 000000000..0971c3ebd
--- /dev/null
+++ b/config/System.kext/Contents/PlugIns/IOADBFamily.kext/Contents/Info.plist
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>CFBundleDevelopmentRegion</key>
+	<string>English</string>
+	<key>CFBundleGetInfoString</key>
+	<string>ADB Family Pseudoextension, Apple Computer Inc, 6.7.5</string>
+	<key>CFBundleIdentifier</key>
+	<string>com.apple.iokit.IOADBFamily</string>
+	<key>CFBundleInfoDictionaryVersion</key>
+	<string>6.0</string>
+	<key>CFBundleName</key>
+	<string>ADB Family Pseudoextension</string>
+	<key>CFBundlePackageType</key>
+	<string>KEXT</string>
+	<key>CFBundleShortVersionString</key>
+	<string>6.7.5</string>
+	<key>CFBundleSignature</key>
+	<string>????</string>
+	<key>CFBundleVersion</key>
+	<string>6.7.5</string>
+	<key>OSBundleCompatibleVersion</key>
+	<string>1.0.0b1</string>
+	<key>OSBundleRequired</key>
+	<string>Root</string>
+	<key>OSKernelResource</key>
+	<true/>
+</dict>
+</plist>
diff --git a/config/System.kext/Contents/PlugIns/IOKit.kext/Contents/Info.plist b/config/System.kext/Contents/PlugIns/IOKit.kext/Contents/Info.plist
new file mode 100644
index 000000000..d9a5b7a6b
--- /dev/null
+++ b/config/System.kext/Contents/PlugIns/IOKit.kext/Contents/Info.plist
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>CFBundleDevelopmentRegion</key>
+	<string>English</string>
+	<key>CFBundleGetInfoString</key>
+	<string>I/O Kit Pseudoextension, Apple Computer Inc, 6.7.5</string>
+	<key>CFBundleIdentifier</key>
+	<string>com.apple.kernel.iokit</string>
+	<key>CFBundleInfoDictionaryVersion</key>
+	<string>6.0</string>
+	<key>CFBundleName</key>
+	<string>I/O Kit Pseudoextension</string>
+	<key>CFBundlePackageType</key>
+	<string>KEXT</string>
+	<key>CFBundleShortVersionString</key>
+	<string>6.7.5</string>
+	<key>CFBundleSignature</key>
+	<string>????</string>
+	<key>CFBundleVersion</key>
+	<string>6.7.5</string>
+	<key>OSBundleCompatibleVersion</key>
+	<string>1.0.0b1</string>
+	<key>OSBundleRequired</key>
+	<string>Root</string>
+	<key>OSKernelResource</key>
+	<true/>
+</dict>
+</plist>
diff --git a/config/System.kext/Contents/PlugIns/IONVRAMFamily.kext/Contents/Info.plist b/config/System.kext/Contents/PlugIns/IONVRAMFamily.kext/Contents/Info.plist
new file mode 100644
index 000000000..bcbfb9cff
--- /dev/null
+++ b/config/System.kext/Contents/PlugIns/IONVRAMFamily.kext/Contents/Info.plist
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>CFBundleDevelopmentRegion</key>
+	<string>English</string>
+	<key>CFBundleGetInfoString</key>
+	<string>AppleNMI Pseudoextension, Apple Computer Inc, 6.7.5</string>
+	<key>CFBundleIdentifier</key>
+	<string>com.apple.iokit.IONVRAMFamily</string>
+	<key>CFBundleInfoDictionaryVersion</key>
+	<string>6.0</string>
+	<key>CFBundleName</key>
+	<string>NVRAM Family Pseudoextension</string>
+	<key>CFBundlePackageType</key>
+	<string>KEXT</string>
+	<key>CFBundleShortVersionString</key>
+	<string>6.7.5</string>
+	<key>CFBundleSignature</key>
+	<string>????</string>
+	<key>CFBundleVersion</key>
+	<string>6.7.5</string>
+	<key>OSBundleCompatibleVersion</key>
+	<string>1.1</string>
+	<key>OSBundleRequired</key>
+	<string>Root</string>
+	<key>OSKernelResource</key>
+	<true/>
+</dict>
+</plist>
diff --git a/config/System.kext/Contents/PlugIns/IOSystemManagement.kext/Contents/Info.plist b/config/System.kext/Contents/PlugIns/IOSystemManagement.kext/Contents/Info.plist
new file mode 100644
index 000000000..d91cd7683
--- /dev/null
+++ b/config/System.kext/Contents/PlugIns/IOSystemManagement.kext/Contents/Info.plist
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>CFBundleDevelopmentRegion</key>
+	<string>English</string>
+	<key>CFBundleGetInfoString</key>
+	<string>System Management Pseudoextension, Apple Computer Inc, 6.7.5</string>
+	<key>CFBundleIdentifier</key>
+	<string>com.apple.iokit.IOSystemManagementFamily</string>
+	<key>CFBundleInfoDictionaryVersion</key>
+	<string>6.0</string>
+	<key>CFBundleName</key>
+	<string>System Management Pseudoextension</string>
+	<key>CFBundlePackageType</key>
+	<string>KEXT</string>
+	<key>CFBundleShortVersionString</key>
+	<string>6.7.5</string>
+	<key>CFBundleSignature</key>
+	<string>????</string>
+	<key>CFBundleVersion</key>
+	<string>6.7.5</string>
+	<key>OSBundleCompatibleVersion</key>
+	<string>1.0.0b1</string>
+	<key>OSBundleRequired</key>
+	<string>Root</string>
+	<key>OSKernelResource</key>
+	<true/>
+</dict>
+</plist>
diff --git a/config/System.kext/Contents/PlugIns/Libkern.kext/Contents/Info.plist b/config/System.kext/Contents/PlugIns/Libkern.kext/Contents/Info.plist
new file mode 100644
index 000000000..507f1c9db
--- /dev/null
+++ b/config/System.kext/Contents/PlugIns/Libkern.kext/Contents/Info.plist
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>CFBundleDevelopmentRegion</key>
+	<string>English</string>
+	<key>CFBundleGetInfoString</key>
+	<string>Libkern Pseudoextension, Apple Computer Inc, 6.7.5</string>
+	<key>CFBundleIdentifier</key>
+	<string>com.apple.kernel.libkern</string>
+	<key>CFBundleInfoDictionaryVersion</key>
+	<string>6.0</string>
+	<key>CFBundleName</key>
+	<string>Libkern Pseudoextension</string>
+	<key>CFBundlePackageType</key>
+	<string>KEXT</string>
+	<key>CFBundleShortVersionString</key>
+	<string>6.7.5</string>
+	<key>CFBundleSignature</key>
+	<string>????</string>
+	<key>CFBundleVersion</key>
+	<string>6.7.5</string>
+	<key>OSBundleCompatibleVersion</key>
+	<string>1.0.0b1</string>
+	<key>OSBundleRequired</key>
+	<string>Root</string>
+	<key>OSKernelResource</key>
+	<true/>
+</dict>
+</plist>
diff --git a/config/System.kext/Contents/PlugIns/Mach.kext/Contents/Info.plist b/config/System.kext/Contents/PlugIns/Mach.kext/Contents/Info.plist
new file mode 100644
index 000000000..f1eb10424
--- /dev/null
+++ b/config/System.kext/Contents/PlugIns/Mach.kext/Contents/Info.plist
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>CFBundleDevelopmentRegion</key>
+	<string>English</string>
+	<key>CFBundleGetInfoString</key>
+	<string>Mach Kernel Pseudoextension, Apple Computer Inc, 6.7.5</string>
+	<key>CFBundleIdentifier</key>
+	<string>com.apple.kernel.mach</string>
+	<key>CFBundleInfoDictionaryVersion</key>
+	<string>6.0</string>
+	<key>CFBundleName</key>
+	<string>Mach Kernel Pseudoextension</string>
+	<key>CFBundlePackageType</key>
+	<string>KEXT</string>
+	<key>CFBundleShortVersionString</key>
+	<string>6.7.5</string>
+	<key>CFBundleSignature</key>
+	<string>????</string>
+	<key>CFBundleVersion</key>
+	<string>6.7.5</string>
+	<key>OSBundleCompatibleVersion</key>
+	<string>1.0.0b1</string>
+	<key>OSBundleRequired</key>
+	<string>Root</string>
+	<key>OSKernelResource</key>
+	<true/>
+</dict>
+</plist>
diff --git a/iokit/Drivers/platform/drvAppleI386Generic/AppleI386CPU.cpp b/iokit/Drivers/platform/drvAppleI386Generic/AppleI386CPU.cpp
index 5c68f58cb..72ada3cc2 100644
--- a/iokit/Drivers/platform/drvAppleI386Generic/AppleI386CPU.cpp
+++ b/iokit/Drivers/platform/drvAppleI386Generic/AppleI386CPU.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Drivers/platform/drvAppleI386Generic/AppleI386CPU.h b/iokit/Drivers/platform/drvAppleI386Generic/AppleI386CPU.h
index 9595ec031..2fbf2413d 100644
--- a/iokit/Drivers/platform/drvAppleI386Generic/AppleI386CPU.h
+++ b/iokit/Drivers/platform/drvAppleI386Generic/AppleI386CPU.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Drivers/platform/drvAppleI386Generic/AppleI386PlatformExpert.cpp b/iokit/Drivers/platform/drvAppleI386Generic/AppleI386PlatformExpert.cpp
index 0eeb0a275..b0f943b7c 100644
--- a/iokit/Drivers/platform/drvAppleI386Generic/AppleI386PlatformExpert.cpp
+++ b/iokit/Drivers/platform/drvAppleI386Generic/AppleI386PlatformExpert.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Drivers/platform/drvAppleI386Generic/AppleI386PlatformExpert.h b/iokit/Drivers/platform/drvAppleI386Generic/AppleI386PlatformExpert.h
index 8abc03e8d..874921600 100644
--- a/iokit/Drivers/platform/drvAppleI386Generic/AppleI386PlatformExpert.h
+++ b/iokit/Drivers/platform/drvAppleI386Generic/AppleI386PlatformExpert.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Drivers/platform/drvAppleIntelClassicPIC/AppleIntelClassicPIC.h b/iokit/Drivers/platform/drvAppleIntelClassicPIC/AppleIntelClassicPIC.h
index b032e4dfe..3eacd086d 100644
--- a/iokit/Drivers/platform/drvAppleIntelClassicPIC/AppleIntelClassicPIC.h
+++ b/iokit/Drivers/platform/drvAppleIntelClassicPIC/AppleIntelClassicPIC.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Drivers/platform/drvAppleIntelClassicPIC/PIC8259.cpp b/iokit/Drivers/platform/drvAppleIntelClassicPIC/PIC8259.cpp
index c6eaaea34..bc080d0e9 100644
--- a/iokit/Drivers/platform/drvAppleIntelClassicPIC/PIC8259.cpp
+++ b/iokit/Drivers/platform/drvAppleIntelClassicPIC/PIC8259.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Drivers/platform/drvAppleIntelClock/AppleIntelClock.h b/iokit/Drivers/platform/drvAppleIntelClock/AppleIntelClock.h
index 30a0ba5f6..c2e84c0b8 100644
--- a/iokit/Drivers/platform/drvAppleIntelClock/AppleIntelClock.h
+++ b/iokit/Drivers/platform/drvAppleIntelClock/AppleIntelClock.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Drivers/platform/drvAppleIntelClock/IntelClock.cpp b/iokit/Drivers/platform/drvAppleIntelClock/IntelClock.cpp
index 3de76178e..413f90e69 100644
--- a/iokit/Drivers/platform/drvAppleIntelClock/IntelClock.cpp
+++ b/iokit/Drivers/platform/drvAppleIntelClock/IntelClock.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Drivers/platform/drvAppleMacIO/AppleMacIO.cpp b/iokit/Drivers/platform/drvAppleMacIO/AppleMacIO.cpp
index 062a140d0..c145435f0 100644
--- a/iokit/Drivers/platform/drvAppleMacIO/AppleMacIO.cpp
+++ b/iokit/Drivers/platform/drvAppleMacIO/AppleMacIO.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -266,17 +269,28 @@ OSMetaClassDefineReservedUnused(AppleMacIODevice,  3);
 bool AppleMacIODevice::compareName( OSString * name,
 					OSString ** matched = 0 ) const
 {
-    return( ((AppleMacIO *)getProvider())->
-		compareNubName( this, name, matched ));
+  return (IODTCompareNubName(this, name, matched) ||
+	  IORegistryEntry::compareName(name, matched));
 }
 
 IOService * AppleMacIODevice::matchLocation( IOService * /* client */ )
 {
-      return( this );
+  return this;
 }
 
 IOReturn AppleMacIODevice::getResources( void )
 {
-    return( ((AppleMacIO *)getProvider())->getNubResources( this ));
+  IOService *macIO = this;
+  
+  if (getDeviceMemory() != 0) return kIOReturnSuccess;
+  
+  while (macIO && ((macIO = macIO->getProvider()) != 0))
+    if (strcmp("mac-io", macIO->getName()) == 0) break;
+  
+  if (macIO == 0) return kIOReturnError;
+  
+  IODTResolveAddressing(this, "reg", macIO->getDeviceMemoryWithIndex(0));
+  
+  return kIOReturnSuccess;
 }
 
diff --git a/iokit/Drivers/platform/drvAppleNMI/AppleNMI.cpp b/iokit/Drivers/platform/drvAppleNMI/AppleNMI.cpp
index 00deddd4f..74ceaaa95 100644
--- a/iokit/Drivers/platform/drvAppleNMI/AppleNMI.cpp
+++ b/iokit/Drivers/platform/drvAppleNMI/AppleNMI.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -133,12 +136,12 @@ IOReturn AppleNMI::powerStateWillChangeTo ( IOPMPowerFlags theFlags, unsigned lo
 
             // Mask NMI and change from edge to level whilst sleeping (copied directly from OS9 code)
             nmiIntSourceAddr = (volatile unsigned long *)kExtInt9_NMIIntSource;
-            nmiIntSource = *nmiIntSourceAddr;
+            nmiIntSource = ml_phys_read(nmiIntSourceAddr);
             nmiIntSource |= kNMIIntLevelMask;
-            *nmiIntSourceAddr = nmiIntSource;
+            ml_phys_write(nmiIntSourceAddr, nmiIntSource);
             eieio();
             nmiIntSource |= kNMIIntMask;
-            *nmiIntSourceAddr = nmiIntSource;
+            ml_phys_write(nmiIntSourceAddr, nmiIntSource);
             eieio();
         }
         else
@@ -147,12 +150,12 @@ IOReturn AppleNMI::powerStateWillChangeTo ( IOPMPowerFlags theFlags, unsigned lo
 
             // Unmask NMI and change back to edge (copied directly from OS9 code)
             nmiIntSourceAddr = (volatile unsigned long *)kExtInt9_NMIIntSource;
-            nmiIntSource = *nmiIntSourceAddr;
+            nmiIntSource = ml_phys_read(nmiIntSourceAddr);
             nmiIntSource &= ~kNMIIntLevelMask;
-            *nmiIntSourceAddr = nmiIntSource;
+            ml_phys_write(nmiIntSourceAddr, nmiIntSource);
             eieio();
             nmiIntSource &= ~kNMIIntMask;
-            *nmiIntSourceAddr = nmiIntSource;
+            ml_phys_write(nmiIntSourceAddr, nmiIntSource);
             eieio();
         }
     }
diff --git a/iokit/Drivers/platform/drvAppleNVRAM/AppleNVRAM.cpp b/iokit/Drivers/platform/drvAppleNVRAM/AppleNVRAM.cpp
index 27b69da0e..b7855b79e 100644
--- a/iokit/Drivers/platform/drvAppleNVRAM/AppleNVRAM.cpp
+++ b/iokit/Drivers/platform/drvAppleNVRAM/AppleNVRAM.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Drivers/platform/drvAppleNVRAM/AppleNVRAM.h b/iokit/Drivers/platform/drvAppleNVRAM/AppleNVRAM.h
index 63ee60261..37c828246 100644
--- a/iokit/Drivers/platform/drvAppleNVRAM/AppleNVRAM.h
+++ b/iokit/Drivers/platform/drvAppleNVRAM/AppleNVRAM.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Drivers/platform/drvApplePMU/IOPMUADBController.cpp b/iokit/Drivers/platform/drvApplePMU/IOPMUADBController.cpp
index 978cedac4..f71f313da 100644
--- a/iokit/Drivers/platform/drvApplePMU/IOPMUADBController.cpp
+++ b/iokit/Drivers/platform/drvApplePMU/IOPMUADBController.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Drivers/platform/drvApplePMU/IOPMUADBController.h b/iokit/Drivers/platform/drvApplePMU/IOPMUADBController.h
index 697967eff..90fc0b6d9 100644
--- a/iokit/Drivers/platform/drvApplePMU/IOPMUADBController.h
+++ b/iokit/Drivers/platform/drvApplePMU/IOPMUADBController.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Drivers/platform/drvApplePlatformExpert/AppleCPU.cpp b/iokit/Drivers/platform/drvApplePlatformExpert/AppleCPU.cpp
index 274cafce8..1b825dd19 100644
--- a/iokit/Drivers/platform/drvApplePlatformExpert/AppleCPU.cpp
+++ b/iokit/Drivers/platform/drvApplePlatformExpert/AppleCPU.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Drivers/platform/drvApplePlatformExpert/AppleCPU.h b/iokit/Drivers/platform/drvApplePlatformExpert/AppleCPU.h
index 7338ade5b..76803c1c7 100644
--- a/iokit/Drivers/platform/drvApplePlatformExpert/AppleCPU.h
+++ b/iokit/Drivers/platform/drvApplePlatformExpert/AppleCPU.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Drivers/platform/drvApplePlatformExpert/ApplePlatformExpert.cpp b/iokit/Drivers/platform/drvApplePlatformExpert/ApplePlatformExpert.cpp
index f14b821bb..8df491dc5 100644
--- a/iokit/Drivers/platform/drvApplePlatformExpert/ApplePlatformExpert.cpp
+++ b/iokit/Drivers/platform/drvApplePlatformExpert/ApplePlatformExpert.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -59,7 +62,7 @@ bool ApplePlatformExpert::start( IOService * provider )
     setBootROMType(kBootROMTypeOldWorld);
     
     // Get the Rom Minor Version from the 68k ROM.
-    romVersion = ml_phys_read(0xffc00010) & 0x0000ffff;
+    romVersion = ml_phys_read_64(0xffc00010ULL) & 0x0000ffff;
     provider->setProperty("rom-version", &romVersion, sizeof(romVersion));
   }
   
diff --git a/iokit/Drivers/platform/drvAppleRootDomain/RootDomain.cpp b/iokit/Drivers/platform/drvAppleRootDomain/RootDomain.cpp
index 4378b4ee7..b97de6a8f 100644
--- a/iokit/Drivers/platform/drvAppleRootDomain/RootDomain.cpp
+++ b/iokit/Drivers/platform/drvAppleRootDomain/RootDomain.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Drivers/platform/drvAppleRootDomain/RootDomainUserClient.cpp b/iokit/Drivers/platform/drvAppleRootDomain/RootDomainUserClient.cpp
index 35fd5aa28..e49d3b293 100644
--- a/iokit/Drivers/platform/drvAppleRootDomain/RootDomainUserClient.cpp
+++ b/iokit/Drivers/platform/drvAppleRootDomain/RootDomainUserClient.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Drivers/platform/drvAppleRootDomain/RootDomainUserClient.h b/iokit/Drivers/platform/drvAppleRootDomain/RootDomainUserClient.h
index 28bf6c707..98e0b1328 100644
--- a/iokit/Drivers/platform/drvAppleRootDomain/RootDomainUserClient.h
+++ b/iokit/Drivers/platform/drvAppleRootDomain/RootDomainUserClient.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Examples/drvGenericInterruptController/GenericInterruptController.cpp b/iokit/Examples/drvGenericInterruptController/GenericInterruptController.cpp
index 2f2271ca4..2aa0ce051 100644
--- a/iokit/Examples/drvGenericInterruptController/GenericInterruptController.cpp
+++ b/iokit/Examples/drvGenericInterruptController/GenericInterruptController.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Examples/drvGenericInterruptController/GenericInterruptController.h b/iokit/Examples/drvGenericInterruptController/GenericInterruptController.h
index 7b9fce561..f2e2efe7a 100644
--- a/iokit/Examples/drvGenericInterruptController/GenericInterruptController.h
+++ b/iokit/Examples/drvGenericInterruptController/GenericInterruptController.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Families/IOADBBus/IOADBBus.cpp b/iokit/Families/IOADBBus/IOADBBus.cpp
index 5baf7ae9f..0d506b9f4 100644
--- a/iokit/Families/IOADBBus/IOADBBus.cpp
+++ b/iokit/Families/IOADBBus/IOADBBus.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Families/IOADBBus/IOADBBusPriv.h b/iokit/Families/IOADBBus/IOADBBusPriv.h
index c3fff4024..50efd8276 100644
--- a/iokit/Families/IOADBBus/IOADBBusPriv.h
+++ b/iokit/Families/IOADBBus/IOADBBusPriv.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Families/IOADBBus/IOADBController.cpp b/iokit/Families/IOADBBus/IOADBController.cpp
index 76ff4cdf4..306b18db3 100644
--- a/iokit/Families/IOADBBus/IOADBController.cpp
+++ b/iokit/Families/IOADBBus/IOADBController.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Families/IOADBBus/IOADBControllerUserClient.cpp b/iokit/Families/IOADBBus/IOADBControllerUserClient.cpp
index 4d1502e91..2fbaac9dd 100644
--- a/iokit/Families/IOADBBus/IOADBControllerUserClient.cpp
+++ b/iokit/Families/IOADBBus/IOADBControllerUserClient.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Families/IOADBBus/IOADBControllerUserClient.h b/iokit/Families/IOADBBus/IOADBControllerUserClient.h
index 9035f3bef..7ed5863a7 100644
--- a/iokit/Families/IOADBBus/IOADBControllerUserClient.h
+++ b/iokit/Families/IOADBBus/IOADBControllerUserClient.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Families/IOADBBus/IOADBDevice.cpp b/iokit/Families/IOADBBus/IOADBDevice.cpp
index 999517b5a..6a5855e15 100644
--- a/iokit/Families/IOADBBus/IOADBDevice.cpp
+++ b/iokit/Families/IOADBBus/IOADBDevice.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Families/IONVRAM/IONVRAMController.cpp b/iokit/Families/IONVRAM/IONVRAMController.cpp
index 78d7ff9f1..f5552c348 100644
--- a/iokit/Families/IONVRAM/IONVRAMController.cpp
+++ b/iokit/Families/IONVRAM/IONVRAMController.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Families/IOSystemManagement/IOWatchDogTimer.cpp b/iokit/Families/IOSystemManagement/IOWatchDogTimer.cpp
index a7ea145a1..f6f864ac5 100644
--- a/iokit/Families/IOSystemManagement/IOWatchDogTimer.cpp
+++ b/iokit/Families/IOSystemManagement/IOWatchDogTimer.cpp
@@ -2,21 +2,24 @@
  * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
- *
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- *
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * 
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
- *
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ * 
  * @APPLE_LICENSE_HEADER_END@
  */
 
diff --git a/iokit/IOKit/IOBSD.h b/iokit/IOKit/IOBSD.h
index 005faf0c3..d84f51108 100644
--- a/iokit/IOKit/IOBSD.h
+++ b/iokit/IOKit/IOBSD.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/IOBufferMemoryDescriptor.h b/iokit/IOKit/IOBufferMemoryDescriptor.h
index 4e40b5a8b..810c087a7 100644
--- a/iokit/IOKit/IOBufferMemoryDescriptor.h
+++ b/iokit/IOKit/IOBufferMemoryDescriptor.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -25,7 +28,6 @@
 #include <IOKit/IOMemoryDescriptor.h>
 
 enum {
-    kIOMemoryDirectionMask		= 0x0000000f,
     kIOMemoryPhysicallyContiguous	= 0x00000010,
     kIOMemoryPageable	      		= 0x00000020,
     kIOMemorySharingTypeMask		= 0x000f0000,
@@ -237,15 +239,6 @@ public:
      * will not copy past the end of the memory descriptor's current capacity.
      */
     virtual bool appendBytes(const void *bytes, vm_size_t withLength);
-
-    /*
-     * getPhysicalSegment:
-     *
-     * Get the physical address of the buffer, relative to the current position.
-     * If the current position is at the end of the buffer, a zero is returned.
-     */
-    virtual IOPhysicalAddress getPhysicalSegment(IOByteCount offset,
-						 IOByteCount * length);    
 };
 
 #endif /* !_IOBUFFERMEMORYDESCRIPTOR_H */
diff --git a/iokit/IOKit/IOCPU.h b/iokit/IOKit/IOCPU.h
index c78ea6ac0..2b13e0b0f 100644
--- a/iokit/IOKit/IOCPU.h
+++ b/iokit/IOKit/IOCPU.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/IOCatalogue.h b/iokit/IOKit/IOCatalogue.h
index 9cfa1bf6b..7905d86db 100644
--- a/iokit/IOKit/IOCatalogue.h
+++ b/iokit/IOKit/IOCatalogue.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/IOCommand.h b/iokit/IOKit/IOCommand.h
index f6e58d2e0..4f42779ce 100644
--- a/iokit/IOKit/IOCommand.h
+++ b/iokit/IOKit/IOCommand.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/IOCommandGate.h b/iokit/IOKit/IOCommandGate.h
index 1bb549d8c..8d6677c4c 100644
--- a/iokit/IOKit/IOCommandGate.h
+++ b/iokit/IOKit/IOCommandGate.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/IOCommandPool.h b/iokit/IOKit/IOCommandPool.h
index 7703d3d6a..2b6f44f3b 100644
--- a/iokit/IOKit/IOCommandPool.h
+++ b/iokit/IOKit/IOCommandPool.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/IOCommandQueue.h b/iokit/IOKit/IOCommandQueue.h
index 8b7f3dfdf..8e9cbff52 100644
--- a/iokit/IOKit/IOCommandQueue.h
+++ b/iokit/IOKit/IOCommandQueue.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/IOConditionLock.h b/iokit/IOKit/IOConditionLock.h
index 2bfef6f18..e16142d7e 100644
--- a/iokit/IOKit/IOConditionLock.h
+++ b/iokit/IOKit/IOConditionLock.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/IODataQueue.h b/iokit/IOKit/IODataQueue.h
index 6445ba5e8..25b560a3b 100644
--- a/iokit/IOKit/IODataQueue.h
+++ b/iokit/IOKit/IODataQueue.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/IODataQueueShared.h b/iokit/IOKit/IODataQueueShared.h
index 6e853785e..80aa499b4 100644
--- a/iokit/IOKit/IODataQueueShared.h
+++ b/iokit/IOKit/IODataQueueShared.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/IODeviceMemory.h b/iokit/IOKit/IODeviceMemory.h
index 7c72d0524..1bc1174cb 100644
--- a/iokit/IOKit/IODeviceMemory.h
+++ b/iokit/IOKit/IODeviceMemory.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/IODeviceTreeSupport.h b/iokit/IOKit/IODeviceTreeSupport.h
index 7287f9e22..fb89c5133 100644
--- a/iokit/IOKit/IODeviceTreeSupport.h
+++ b/iokit/IOKit/IODeviceTreeSupport.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/IOEventSource.h b/iokit/IOKit/IOEventSource.h
index 6136c93ae..347ed40d9 100644
--- a/iokit/IOKit/IOEventSource.h
+++ b/iokit/IOKit/IOEventSource.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/IOFilterInterruptEventSource.h b/iokit/IOKit/IOFilterInterruptEventSource.h
index 0c554524c..6886c459e 100644
--- a/iokit/IOKit/IOFilterInterruptEventSource.h
+++ b/iokit/IOKit/IOFilterInterruptEventSource.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/IOInterruptController.h b/iokit/IOKit/IOInterruptController.h
index 4b4216b9b..9653330eb 100644
--- a/iokit/IOKit/IOInterruptController.h
+++ b/iokit/IOKit/IOInterruptController.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/IOInterruptEventSource.h b/iokit/IOKit/IOInterruptEventSource.h
index 9fff5fecb..22d9930bf 100644
--- a/iokit/IOKit/IOInterruptEventSource.h
+++ b/iokit/IOKit/IOInterruptEventSource.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/IOInterrupts.h b/iokit/IOKit/IOInterrupts.h
index 547f190ad..45c8f6795 100644
--- a/iokit/IOKit/IOInterrupts.h
+++ b/iokit/IOKit/IOInterrupts.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/IOKitDebug.h b/iokit/IOKit/IOKitDebug.h
index 5211cb95f..082bd8ba6 100644
--- a/iokit/IOKit/IOKitDebug.h
+++ b/iokit/IOKit/IOKitDebug.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -51,11 +54,7 @@ private:
 			UInt32 value, const char * name );
 };
 
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
+#endif	__cplusplus
 
 enum {
 // loggage
@@ -76,12 +75,17 @@ enum {
     kIOLogMemory 	= 0x00004000ULL,
 
 // debug aids - change behaviour
-    kIONoFreeObjects 	= 0x00100000ULL
+    kIONoFreeObjects 	= 0x00100000ULL,
+    kIOLogSynchronous   = 0x00200000ULL,	// IOLog completes synchrounsly
 };
 
 extern SInt64	gIOKitDebug;
 extern char 	iokit_version[];
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 struct IORegistryPlane;
 extern void	IOPrintPlane( const struct IORegistryPlane * plane );
 extern void	OSPrintMemory( void );
diff --git a/iokit/IOKit/IOKitKeys.h b/iokit/IOKit/IOKitKeys.h
index 65fe7197d..2825c1b97 100644
--- a/iokit/IOKit/IOKitKeys.h
+++ b/iokit/IOKit/IOKitKeys.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/IOKitServer.h b/iokit/IOKit/IOKitServer.h
index 08fc0dc2a..9a2e9c2fe 100644
--- a/iokit/IOKit/IOKitServer.h
+++ b/iokit/IOKit/IOKitServer.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/IOLib.h b/iokit/IOKit/IOLib.h
index 962443ddc..3c42748a7 100644
--- a/iokit/IOKit/IOLib.h
+++ b/iokit/IOKit/IOLib.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -33,6 +36,8 @@
 #error IOLib.h is for kernel use only
 #endif
 
+#include <sys/cdefs.h>
+
 #include <sys/appleapiopts.h>
 
 #include <IOKit/system.h>
@@ -43,9 +48,7 @@
 
 #include <libkern/OSAtomic.h>
 
-#ifdef __cplusplus
-extern "C" {
-#endif
+__BEGIN_DECLS
 
 #include <kern/thread_call.h>
 #include <kern/clock.h>
@@ -143,6 +146,78 @@ void IOFreePageable(void * address, vm_size_t size);
 #define IONew(type,number)        (type*)IOMalloc(sizeof(type) * (number) )
 #define IODelete(ptr,type,number) IOFree( (ptr) , sizeof(type) * (number) )
 
+/////////////////////////////////////////////////////////////////////////////
+//
+//
+//	These functions are now implemented in IOMapper.cpp
+//
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/*! @function IOMappedRead8
+    @abstract Read one byte from the desired "Physical" IOSpace address.
+    @discussion Read one byte from the desired "Physical" IOSpace address.  This function allows the developer to read an address returned from any memory descriptor's getPhysicalSegment routine.  It can then be used by segmenting a physical page slightly to tag the physical page with its kernel space virtual address.  
+    @param address The desired address, as returned by IOMemoryDescriptor::getPhysicalSegment.
+    @result Data contained at that location */
+
+UInt8 IOMappedRead8(IOPhysicalAddress address);
+
+/*! @function IOMappedRead16
+    @abstract Read two bytes from the desired "Physical" IOSpace address.
+    @discussion Read two bytes from the desired "Physical" IOSpace address.  This function allows the developer to read an address returned from any memory descriptor's getPhysicalSegment routine.  It can then be used by segmenting a physical page slightly to tag the physical page with its kernel space virtual address.  
+    @param address The desired address, as returned by IOMemoryDescriptor::getPhysicalSegment.
+    @result Data contained at that location */
+
+UInt16 IOMappedRead16(IOPhysicalAddress address);
+
+/*! @function IOMappedRead32
+    @abstract Read four bytes from the desired "Physical" IOSpace address.
+    @discussion Read four bytes from the desired "Physical" IOSpace address.  This function allows the developer to read an address returned from any memory descriptor's getPhysicalSegment routine.  It can then be used by segmenting a physical page slightly to tag the physical page with its kernel space virtual address.  
+    @param address The desired address, as returned by IOMemoryDescriptor::getPhysicalSegment.
+    @result Data contained at that location */
+
+UInt32 IOMappedRead32(IOPhysicalAddress address);
+
+/*! @function IOMappedRead64
+    @abstract Read eight bytes from the desired "Physical" IOSpace address.
+    @discussion Read eight bytes from the desired "Physical" IOSpace address.  This function allows the developer to read an address returned from any memory descriptor's getPhysicalSegment routine.  It can then be used by segmenting a physical page slightly to tag the physical page with its kernel space virtual address.  
+    @param address The desired address, as returned by IOMemoryDescriptor::getPhysicalSegment.
+    @result Data contained at that location */
+
+UInt64 IOMappedRead64(IOPhysicalAddress address);
+
+/*! @function IOMappedWrite8
+    @abstract Write one byte to the desired "Physical" IOSpace address.
+    @discussion Write one byte to the desired "Physical" IOSpace address.  This function allows the developer to write to an address returned from any memory descriptor's getPhysicalSegment routine.
+    @param address The desired address, as returned by IOMemoryDescriptor::getPhysicalSegment.
+    @param value Data to be writen to the desired location */
+
+void IOMappedWrite8(IOPhysicalAddress address, UInt8 value);
+
+/*! @function IOMappedWrite16
+    @abstract Write two bytes to the desired "Physical" IOSpace address.
+    @discussion Write two bytes to the desired "Physical" IOSpace address.  This function allows the developer to write to an address returned from any memory descriptor's getPhysicalSegment routine.
+    @param address The desired address, as returned by IOMemoryDescriptor::getPhysicalSegment.
+    @param value Data to be writen to the desired location */
+
+void IOMappedWrite16(IOPhysicalAddress address, UInt16 value);
+
+/*! @function IOMappedWrite32
+    @abstract Write four bytes to the desired "Physical" IOSpace address.
+    @discussion Write four bytes to the desired "Physical" IOSpace address.  This function allows the developer to write to an address returned from any memory descriptor's getPhysicalSegment routine.
+    @param address The desired address, as returned by IOMemoryDescriptor::getPhysicalSegment.
+    @param value Data to be writen to the desired location */
+
+void IOMappedWrite32(IOPhysicalAddress address, UInt32 value);
+
+/*! @function IOMappedWrite64
+    @abstract Write eight bytes to the desired "Physical" IOSpace address.
+    @discussion Write eight bytes to the desired "Physical" IOSpace address.  This function allows the developer to write to an address returned from any memory descriptor's getPhysicalSegment routine.
+    @param address The desired address, as returned by IOMemoryDescriptor::getPhysicalSegment.
+    @param value Data to be writen to the desired location */
+
+void IOMappedWrite64(IOPhysicalAddress address, UInt64 value);
+
 /*! @function IOSetProcessorCacheMode
     @abstract Sets the processor cache mode for mapped memory.
     @discussion This function sets the cache mode of an already mapped & wired memory range. Note this may not be supported on I/O mappings or shared memory - it is far preferable to set the cache mode as mappings are created with the IOMemoryDescriptor::map method.
@@ -289,8 +364,6 @@ extern mach_timespec_t IOZeroTvalspec;
 
 #endif /* __APPLE_API_OBSOLETE */
 
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
+__END_DECLS
 
 #endif /* !__IOKIT_IOLIB_H */
diff --git a/iokit/IOKit/IOLocks.h b/iokit/IOKit/IOLocks.h
index c966aba8c..cc8bde3ae 100644
--- a/iokit/IOKit/IOLocks.h
+++ b/iokit/IOKit/IOLocks.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/IOMapper.h b/iokit/IOKit/IOMapper.h
new file mode 100644
index 000000000..14b9d3dd8
--- /dev/null
+++ b/iokit/IOKit/IOMapper.h
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c) 1998-2003 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ * 
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ * 
+ * @APPLE_LICENSE_HEADER_END@
+ */
+
+#ifndef __IOKIT_IOMAPPER_H
+#define __IOKIT_IOMAPPER_H
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+#include <IOKit/IOTypes.h>
+#include <mach/vm_types.h>
+
+// These are C accessors to the system mapper for non-IOKit clients
+ppnum_t IOMapperIOVMAlloc(unsigned pages);
+void IOMapperIOVMFree(ppnum_t addr, unsigned pages);
+
+ppnum_t IOMapperInsertPage(ppnum_t addr, unsigned offset, ppnum_t page);
+void IOMapperInsertPPNPages(ppnum_t addr, unsigned offset,
+                            ppnum_t *pageList, unsigned pageCount);
+void IOMapperInsertUPLPages(ppnum_t addr, unsigned offset,
+                            upl_page_info_t *pageList, unsigned pageCount);
+__END_DECLS
+
+#if __cplusplus
+
+#include <IOKit/IOService.h>
+#include <IOKit/IOMemoryDescriptor.h>
+
+class OSData;
+
+class IOMapper : public IOService
+{
+    OSDeclareAbstractStructors(IOMapper);
+
+    // Give the platform expert access to setMapperRequired();
+    friend class IOPlatformExpert;
+
+private:
+    enum SystemMapperState {
+        kNoMapper  = 0,
+        kUnknown   = 1,
+        kHasMapper = 2,	// Any other value is pointer to a live mapper
+        kWaitMask  = 3,
+    };
+protected:
+    void *fTable;
+    ppnum_t fTablePhys;
+    IOItemCount fTableSize;
+    OSData *fTableHandle;
+    bool fIsSystem;
+
+    virtual bool start(IOService *provider);
+    virtual void free();
+
+    static void setMapperRequired(bool hasMapper);
+    static void waitForSystemMapper();
+
+    virtual bool initHardware(IOService *provider) = 0;
+
+    virtual bool allocTable(IOByteCount size);
+
+public:
+    // Static routines capable of allocating tables that are physically
+    // contiguous in real memory space.
+    static OSData * NewARTTable(IOByteCount size,
+                                void ** virtAddrP, ppnum_t *physAddrP);
+    static void FreeARTTable(OSData *handle, IOByteCount size);
+
+
+    // To get access to the system mapper IOMapper::gSystem 
+    static IOMapper *gSystem;
+
+    virtual ppnum_t iovmAlloc(IOItemCount pages) = 0;
+    virtual void iovmFree(ppnum_t addr, IOItemCount pages) = 0;
+
+    virtual void iovmInsert(ppnum_t addr, IOItemCount offset, ppnum_t page) = 0;
+    virtual void iovmInsert(ppnum_t addr, IOItemCount offset,
+                            ppnum_t *pageList, IOItemCount pageCount);
+    virtual void iovmInsert(ppnum_t addr, IOItemCount offset,
+                            upl_page_info_t *pageList, IOItemCount pageCount);
+    static void checkForSystemMapper()
+        { if ((vm_address_t) gSystem & kWaitMask) waitForSystemMapper(); };
+
+    // Function will panic if the given address is not found in a valid
+    // iovm mapping.
+    virtual addr64_t mapAddr(IOPhysicalAddress addr) = 0;
+
+private:
+    OSMetaClassDeclareReservedUnused(IOMapper, 0);
+    OSMetaClassDeclareReservedUnused(IOMapper, 1);
+    OSMetaClassDeclareReservedUnused(IOMapper, 2);
+    OSMetaClassDeclareReservedUnused(IOMapper, 3);
+    OSMetaClassDeclareReservedUnused(IOMapper, 4);
+    OSMetaClassDeclareReservedUnused(IOMapper, 5);
+    OSMetaClassDeclareReservedUnused(IOMapper, 6);
+    OSMetaClassDeclareReservedUnused(IOMapper, 7);
+    OSMetaClassDeclareReservedUnused(IOMapper, 8);
+    OSMetaClassDeclareReservedUnused(IOMapper, 9);
+    OSMetaClassDeclareReservedUnused(IOMapper, 10);
+    OSMetaClassDeclareReservedUnused(IOMapper, 11);
+    OSMetaClassDeclareReservedUnused(IOMapper, 12);
+    OSMetaClassDeclareReservedUnused(IOMapper, 13);
+    OSMetaClassDeclareReservedUnused(IOMapper, 14);
+    OSMetaClassDeclareReservedUnused(IOMapper, 15);
+};
+
+#endif /* __cplusplus */
+
+#endif /* !__IOKIT_IOMAPPER_H */
diff --git a/iokit/IOKit/IOMemoryCursor.h b/iokit/IOKit/IOMemoryCursor.h
index 9f866e1b4..dc255b38c 100644
--- a/iokit/IOKit/IOMemoryCursor.h
+++ b/iokit/IOKit/IOMemoryCursor.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/IOMemoryDescriptor.h b/iokit/IOKit/IOMemoryDescriptor.h
index 0212d3947..eb138fc03 100644
--- a/iokit/IOKit/IOMemoryDescriptor.h
+++ b/iokit/IOKit/IOMemoryDescriptor.h
@@ -3,28 +3,37 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
 #ifndef _IOMEMORYDESCRIPTOR_H
 #define _IOMEMORYDESCRIPTOR_H
 
+#include <sys/cdefs.h>
+
 #include <IOKit/IOTypes.h>
 #include <libkern/c++/OSContainers.h>
 
+__BEGIN_DECLS
+#include <mach/memory_object_types.h>
+__END_DECLS
+
 struct IOPhysicalRange
 {
     IOPhysicalAddress	address;
@@ -32,6 +41,7 @@ struct IOPhysicalRange
 };
 
 class IOMemoryMap;
+class IOMapper;
 
 /*
  * Direction of transfer, with respect to the described memory.
@@ -41,9 +51,30 @@ enum IODirection
     kIODirectionNone  = 0x0,	//                    same as VM_PROT_NONE
     kIODirectionIn    = 0x1,	// User land 'read',  same as VM_PROT_READ
     kIODirectionOut   = 0x2,	// User land 'write', same as VM_PROT_WRITE
-    kIODirectionOutIn = kIODirectionIn | kIODirectionOut,
+    kIODirectionOutIn = kIODirectionOut | kIODirectionIn,
+    kIODirectionInOut = kIODirectionIn  | kIODirectionOut
+};
+
+/*
+ * IOOptionBits used in the second withRanges variant
+ */
+enum {
+    kIOMemoryDirectionMask	= 0x00000007,
+    kIOMemoryAutoPrepare	= 0x00000008,	// Shared with Buffer MD
+    
+    kIOMemoryTypeVirtual	= 0x00000010,
+    kIOMemoryTypePhysical	= 0x00000020,
+    kIOMemoryTypeUPL		= 0x00000030,
+    kIOMemoryTypeMask		= 0x000000f0,
+
+    kIOMemoryAsReference	= 0x00000100,
+    kIOMemoryBufferPageable	= 0x00000400,
+    kIOMemoryDontMap		= 0x00000800,
 };
 
+#define kIOMapperNone	((IOMapper *) -1)
+#define kIOMapperSystem	((IOMapper *) 0)
+
 /*! @class IOMemoryDescriptor : public OSObject
     @abstract An abstract base class defining common methods for describing physical or virtual memory.
     @discussion The IOMemoryDescriptor object represents a buffer or range of memory, specified as one or more physical or virtual address ranges. It contains methods to return the memory's physically contiguous segments (fragments), for use with the IOMemoryCursor, and methods to map the memory into any address space with caching and placed mapping options. */
@@ -75,7 +106,7 @@ protected:
     IOOptionBits 	_flags;
     void *		_memEntry;
 
-    IODirection         _direction;        /* direction of transfer */
+    IODirection         _direction;        /* DEPRECATED: use _flags instead. direction of transfer */
     IOByteCount         _length;           /* length of all ranges */
     IOOptionBits 	_tag;
 
@@ -83,11 +114,26 @@ public:
 
     virtual IOPhysicalAddress getSourceSegment( IOByteCount offset,
 						IOByteCount * length );
+    OSMetaClassDeclareReservedUsed(IOMemoryDescriptor, 0);
+
+/*! @function initWithOptions
+    @abstract Master initialiser for all variants of memory descriptors.  For a more complete description see IOMemoryDescriptor::withOptions.
+    @discussion Note this function can be used to re-init a previously created memory descriptor.
+    @result true on success, false on failure. */
+    virtual bool initWithOptions(void *		buffers,
+                                 UInt32		count,
+                                 UInt32		offset,
+                                 task_t		task,
+                                 IOOptionBits	options,
+                                 IOMapper *	mapper = 0);
+    OSMetaClassDeclareReservedUsed(IOMemoryDescriptor, 1);
+
+    virtual addr64_t IOMemoryDescriptor::getPhysicalSegment64( IOByteCount offset,
+								IOByteCount * length );
+    OSMetaClassDeclareReservedUsed(IOMemoryDescriptor, 2);
 
 private:
-    OSMetaClassDeclareReservedUsed(IOMemoryDescriptor, 0);
-    OSMetaClassDeclareReservedUnused(IOMemoryDescriptor, 1);
-    OSMetaClassDeclareReservedUnused(IOMemoryDescriptor, 2);
+
     OSMetaClassDeclareReservedUnused(IOMemoryDescriptor, 3);
     OSMetaClassDeclareReservedUnused(IOMemoryDescriptor, 4);
     OSMetaClassDeclareReservedUnused(IOMemoryDescriptor, 5);
@@ -157,11 +203,42 @@ public:
     @param asReference If false, the IOMemoryDescriptor object will make a copy of the ranges array, otherwise, the array will be used in situ, avoiding an extra allocation.
     @result The created IOMemoryDescriptor on success, to be released by the caller, or zero on failure. */
 
-     static IOMemoryDescriptor * withRanges(IOVirtualRange *	ranges,
-                                            UInt32		withCount,
-                                            IODirection		withDirection,
-                                            task_t            withTask,
-                                            bool		asReference = false);
+     static IOMemoryDescriptor * withRanges(IOVirtualRange * ranges,
+                                            UInt32           withCount,
+                                            IODirection      withDirection,
+                                            task_t           withTask,
+                                            bool             asReference = false);
+
+/*! @function withOptions
+    @abstract Master initialiser for all variants of memory descriptors.
+    @discussion This method creates and initializes an IOMemoryDescriptor for memory it has three main variants: Virtual, Physical & mach UPL.  These variants are selected with the options parameter, see below.  This memory descriptor needs to be prepared before it can be used to extract data from the memory described.  However we temporarily have setup a mechanism that automatically prepares kernel_task memory descriptors at creation time.
+
+
+    @param buffers A pointer to an array of IOVirtualRanges or IOPhysicalRanges if the options:type is Virtual or Physical.  For type UPL it is a upl_t returned by the mach/memory_object_types.h apis, primarily used internally by the UBC.
+
+    @param count options:type = Virtual or Physical count contains a count of the number of entires in the buffers array.  For options:type = UPL this field contains a total length.
+
+    @param offset Only used when options:type = UPL, in which case this field contains an offset for the memory within the buffers upl.
+
+    @param task Only used options:type = Virtual, The task each of the virtual ranges are mapped into.
+
+    @param options
+        kIOMemoryDirectionMask (options:direction)	This nibble indicates the I/O direction to be associated with the descriptor, which may affect the operation of the prepare and complete methods on some architectures. 
+        kIOMemoryTypeMask (options:type)	kIOMemoryTypeVirtual, kIOMemoryTypePhysical, kIOMemoryTypeUPL Indicates that what type of memory basic memory descriptor to use.  This sub-field also controls the interpretation of the buffers, count, offset & task parameters.
+        kIOMemoryAsReference	For options:type = Virtual or Physical this indicate that the memory descriptor need not copy the ranges array into local memory.  This is an optimisation to try to minimise unnecessary allocations.
+        kIOMemoryBufferPageable	Only used by the IOBufferMemoryDescriptor as an indication that the kernel virtual memory is in fact pageable and we need to use the kernel pageable submap rather than the default map.
+        kIOMemoryNoAutoPrepare	Indicates that the temporary AutoPrepare of kernel_task memory should not be performed.
+    
+    @param mapper Which IOMapper should be used to map the in-memory physical addresses into I/O space addresses.  Defaults to 0 which indicates that the system mapper is to be used, if present.  
+
+    @result The created IOMemoryDescriptor on success, to be released by the caller, or zero on failure. */
+
+    static IOMemoryDescriptor *withOptions(void *	buffers,
+                                           UInt32	count,
+                                           UInt32	offset,
+                                           task_t	task,
+                                           IOOptionBits	options,
+                                           IOMapper *	mapper = 0);
 
 /*! @function withPhysicalRanges
     @abstract Create an IOMemoryDescriptor to describe one or more physical ranges.
@@ -175,7 +252,7 @@ public:
     static IOMemoryDescriptor * withPhysicalRanges(
                                             IOPhysicalRange *	ranges,
                                             UInt32		withCount,
-                                            IODirection		withDirection,
+                                            IODirection 	withDirection,
                                             bool		asReference = false);
 
 /*! @function withSubRange
@@ -187,10 +264,10 @@ public:
     @param withDirection An I/O direction to be associated with the descriptor, which may affect the operation of the prepare and complete methods on some architectures. This is used over the direction of the parent descriptor.
     @result The created IOMemoryDescriptor on success, to be released by the caller, or zero on failure. */
 
-    static IOMemoryDescriptor *	withSubRange(IOMemoryDescriptor *	of,
-					     IOByteCount		offset,
-					     IOByteCount		length,
-                                             IODirection		withDirection);
+    static IOMemoryDescriptor *	withSubRange(IOMemoryDescriptor *of,
+					     IOByteCount offset,
+					     IOByteCount length,
+                                             IODirection withDirection);
 
 /*! @function initWithAddress
     @abstract Initialize or reinitialize an IOMemoryDescriptor to describe one virtual range of the kernel task.
@@ -241,11 +318,11 @@ public:
     @param asReference If false, the IOMemoryDescriptor object will make a copy of the ranges array, otherwise, the array will be used in situ, avoiding an extra allocation.
     @result true on success, false on failure. */
 
-    virtual bool initWithRanges(        IOVirtualRange * ranges,
-                                        UInt32           withCount,
-                                        IODirection      withDirection,
-                                        task_t           withTask,
-                                        bool             asReference = false) = 0;
+    virtual bool initWithRanges(IOVirtualRange * ranges,
+                                UInt32           withCount,
+                                IODirection      withDirection,
+                                task_t           withTask,
+                                bool             asReference = false) = 0;
 
 /*! @function initWithPhysicalRanges
     @abstract Initialize or reinitialize an IOMemoryDescriptor to describe one or more physical ranges.
@@ -336,7 +413,7 @@ public:
 
 /*! @function prepare
     @abstract Prepare the memory for an I/O transfer.
-    @discussion This involves paging in the memory, if necessary, and wiring it down for the duration of the transfer.  The complete() method completes the processing of the memory after the I/O transfer finishes.  This method needn't called for non-pageable memory.
+    @discussion This involves paging in the memory, if necessary, and wiring it down for the duration of the transfer.  The complete() method completes the processing of the memory after the I/O transfer finishes.  Note that the prepare call is not thread safe and it is expected that the client will more easily be able to guarantee single threading a particular memory descriptor.
     @param forDirection The direction of the I/O just completed, or kIODirectionNone for the direction specified by the memory descriptor.
     @result An IOReturn code. */
 
@@ -344,8 +421,8 @@ public:
 
 /*! @function complete
     @abstract Complete processing of the memory after an I/O transfer finishes.
-    @discussion This method should not be called unless a prepare was previously issued; the prepare() and complete() must occur in pairs, before and after an I/O transfer involving pageable memory.
-    @param forDirection The direction of the I/O just completed, or kIODirectionNone for the direction specified by the memory descriptor.
+    @discussion This method should not be called unless a prepare was previously issued; the prepare() and complete() must occur in pairs, before and after an I/O transfer involving pageable memory.  In 10.3 or greater systems the direction argument to complete is not longer respected.  The direction is totally determined at prepare() time.
+    @param forDirection DEPRECATED The direction of the I/O just completed, or kIODirectionNone for the direction specified by the memory descriptor.
     @result An IOReturn code. */
 
     virtual IOReturn complete(IODirection forDirection = kIODirectionNone) = 0;
@@ -510,7 +587,7 @@ public:
 
     virtual IOReturn 		unmap() = 0;
 
-    virtual void 			taskDied() = 0;
+    virtual void		taskDied() = 0;
 };
 
 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@@ -521,8 +598,11 @@ public:
 // might be created by IOMemoryDescriptor::withAddress(), but there should be 
 // no need to reference as anything but a generic IOMemoryDescriptor *.
 
+// Also these flags should not overlap with the options to
+//	IOMemoryDescriptor::initWithRanges(... IOOptionsBits options);
+
 enum {
-    kIOMemoryRequiresWire	= 0x00000001
+    kIOMemoryPreparedReadOnly	= 0x00008000,
 };
 
 class IOGeneralMemoryDescriptor : public IOMemoryDescriptor
@@ -531,8 +611,8 @@ class IOGeneralMemoryDescriptor : public IOMemoryDescriptor
 
 protected:
     union {
-    IOVirtualRange *	v;
-    IOPhysicalRange *	p;
+        IOVirtualRange *  v;
+        IOPhysicalRange * p;
     }			_ranges;            /* list of address ranges */
     unsigned		_rangesCount;       /* number of address ranges in list */
     bool		_rangesIsAllocated; /* is list allocated by us? */
@@ -540,48 +620,70 @@ protected:
     task_t		_task;               /* task where all ranges are mapped to */
 
     union {
-    IOVirtualRange	v;
-    IOPhysicalRange	p;
+        IOVirtualRange	v;
+        IOPhysicalRange	p;
     }			_singleRange;	   /* storage space for a single range */
 
     unsigned		_wireCount;        /* number of outstanding wires */
 
-    vm_address_t	_cachedVirtualAddress;  /* a cached virtual-to-physical */
-    IOPhysicalAddress	_cachedPhysicalAddress; /*    mapping, for optimization */
+    /* DEPRECATED */ vm_address_t _cachedVirtualAddress;  /* a cached virtual-to-physical */
+
+    /* DEPRECATED */ IOPhysicalAddress	_cachedPhysicalAddress;
 
     bool		_initialized;      /* has superclass been initialized? */
 
     virtual void free();
 
-protected:
+
+private:
+    // Internal API may be made virtual at some time in the future.
+    IOReturn wireVirtual(IODirection forDirection);
+
     /* DEPRECATED */ IOByteCount _position; /* absolute position over all ranges */
     /* DEPRECATED */ virtual void setPosition(IOByteCount position);
 
-private:
-    /* DEPRECATED */ unsigned    _positionAtIndex;  /* range #n in which position is now */
-    /* DEPRECATED */ IOByteCount _positionAtOffset; /* relative position within range #n */
+/*
+ * DEPRECATED IOByteCount _positionAtIndex; // relative position within range #n
+ *
+ * Re-use the _positionAtIndex as a count of the number of pages in
+ * this memory descriptor.  Convieniently vm_address_t is an unsigned integer
+ * type so I can get away without having to change the type.
+ */
+    unsigned int		_pages;
+
+/* DEPRECATED */ unsigned    _positionAtOffset;  //range #n in which position is now
+
     OSData *_memoryEntries;
 
     /* DEPRECATED */ vm_offset_t _kernPtrAligned;
     /* DEPRECATED */ unsigned    _kernPtrAtIndex;
     /* DEPRECATED */ IOByteCount  _kernSize;
+
     /* DEPRECATED */ virtual void mapIntoKernel(unsigned rangeIndex);
     /* DEPRECATED */ virtual void unmapFromKernel();
-    inline vm_map_t getMapForTask( task_t task, vm_address_t address );
 
 public:
     /*
      * IOMemoryDescriptor required methods
      */
 
-    virtual bool initWithAddress(void *       address,
-                                 IOByteCount    withLength,
-                                 IODirection  withDirection);
+    // Master initaliser
+    virtual bool initWithOptions(void *		buffers,
+                                 UInt32		count,
+                                 UInt32		offset,
+                                 task_t		task,
+                                 IOOptionBits	options,
+                                 IOMapper *	mapper = 0);
 
-    virtual bool initWithAddress(vm_address_t address,
+    // Secondary initialisers
+    virtual bool initWithAddress(void *		address,
+                                 IOByteCount	withLength,
+                                 IODirection	withDirection);
+
+    virtual bool initWithAddress(vm_address_t	address,
                                  IOByteCount    withLength,
-                                 IODirection  withDirection,
-                                 task_t       withTask);
+                                 IODirection	withDirection,
+                                 task_t		withTask);
 
     virtual bool initWithPhysicalAddress(
 				 IOPhysicalAddress	address,
@@ -640,10 +742,6 @@ protected:
 
     virtual void free();
 
-    virtual bool initSubRange( IOMemoryDescriptor * parent,
-				IOByteCount offset, IOByteCount length,
-				IODirection withDirection );
-
     virtual bool initWithAddress(void *       address,
                                  IOByteCount    withLength,
                                  IODirection  withDirection);
@@ -676,6 +774,18 @@ protected:
     IOMemoryDescriptor::withSubRange;
 
 public:
+    /*
+     * Initialize or reinitialize an IOSubMemoryDescriptor to describe
+     * a subrange of an existing descriptor.
+     *
+     * An IOSubMemoryDescriptor can be re-used by calling initSubRange
+     * again on an existing instance -- note that this behavior is not
+     * commonly supported in other IOKit classes, although it is here.
+     */
+    virtual bool initSubRange( IOMemoryDescriptor * parent,
+				IOByteCount offset, IOByteCount length,
+				IODirection withDirection );
+
     /*
      * IOMemoryDescriptor required methods
      */
diff --git a/iokit/IOKit/IOMessage.h b/iokit/IOKit/IOMessage.h
index d5bd33e9e..5df7bffe2 100644
--- a/iokit/IOKit/IOMessage.h
+++ b/iokit/IOKit/IOMessage.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/IOMultiMemoryDescriptor.h b/iokit/IOKit/IOMultiMemoryDescriptor.h
index 1032842a6..7fdafe43d 100644
--- a/iokit/IOKit/IOMultiMemoryDescriptor.h
+++ b/iokit/IOKit/IOMultiMemoryDescriptor.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/IONVRAM.h b/iokit/IOKit/IONVRAM.h
index 1e09641a7..e3e177248 100644
--- a/iokit/IOKit/IONVRAM.h
+++ b/iokit/IOKit/IONVRAM.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/IONotifier.h b/iokit/IOKit/IONotifier.h
index 24e3d2560..5487dc1b4 100644
--- a/iokit/IOKit/IONotifier.h
+++ b/iokit/IOKit/IONotifier.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/IOPlatformExpert.h b/iokit/IOKit/IOPlatformExpert.h
index fadb9eea5..e5ad2a89e 100644
--- a/iokit/IOKit/IOPlatformExpert.h
+++ b/iokit/IOKit/IOPlatformExpert.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -60,6 +63,8 @@ extern void PESetGMTTimeOfDay( long secs );
 #ifdef __cplusplus
 } /* extern "C" */
 
+#define kIOPlatformMapperPresentKey "IOPlatformMapperPresent"
+
 extern OSSymbol * gPlatformInterruptControllerName;
 
 class IORangeAllocator;
diff --git a/iokit/IOKit/IORangeAllocator.h b/iokit/IOKit/IORangeAllocator.h
index 761084e84..a0f2aeaa6 100644
--- a/iokit/IOKit/IORangeAllocator.h
+++ b/iokit/IOKit/IORangeAllocator.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/IORegistryEntry.h b/iokit/IOKit/IORegistryEntry.h
index 315945052..daa978ddf 100644
--- a/iokit/IOKit/IORegistryEntry.h
+++ b/iokit/IOKit/IORegistryEntry.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/IOReturn.h b/iokit/IOKit/IOReturn.h
index 6664ca437..ae96524e4 100644
--- a/iokit/IOKit/IOReturn.h
+++ b/iokit/IOKit/IOReturn.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/IOService.h b/iokit/IOKit/IOService.h
index 4e7111324..e9f15a5c5 100644
--- a/iokit/IOKit/IOService.h
+++ b/iokit/IOKit/IOService.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -1835,6 +1838,7 @@ private:
     bool responseValid ( unsigned long x );
     IOReturn allowCancelCommon ( void );
     void computeDesiredState ( void );
+    void rebuildChildClampBits ( void );
 };
 
 #endif /* ! _IOKIT_IOSERVICE_H */
diff --git a/iokit/IOKit/IOServicePM.h b/iokit/IOKit/IOServicePM.h
index 965201f2a..29a6039b8 100644
--- a/iokit/IOKit/IOServicePM.h
+++ b/iokit/IOKit/IOServicePM.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/IOSharedLock.h b/iokit/IOKit/IOSharedLock.h
index 0f9e7bf33..803ec162c 100644
--- a/iokit/IOKit/IOSharedLock.h
+++ b/iokit/IOKit/IOSharedLock.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/IOSyncer.h b/iokit/IOKit/IOSyncer.h
index 3bb2df5ac..1db552785 100644
--- a/iokit/IOKit/IOSyncer.h
+++ b/iokit/IOKit/IOSyncer.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/IOTimeStamp.h b/iokit/IOKit/IOTimeStamp.h
index cf07474f8..0821db947 100644
--- a/iokit/IOKit/IOTimeStamp.h
+++ b/iokit/IOKit/IOTimeStamp.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/IOTimerEventSource.h b/iokit/IOKit/IOTimerEventSource.h
index fd7335821..a55753bc8 100644
--- a/iokit/IOKit/IOTimerEventSource.h
+++ b/iokit/IOKit/IOTimerEventSource.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/IOTypes.h b/iokit/IOKit/IOTypes.h
index 6a5f344f2..c7f5e05e8 100644
--- a/iokit/IOKit/IOTypes.h
+++ b/iokit/IOKit/IOTypes.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -168,19 +171,21 @@ enum {
     kIODefaultCache		= 0,
     kIOInhibitCache		= 1,
     kIOWriteThruCache		= 2,
-    kIOCopybackCache		= 3
+    kIOCopybackCache		= 3,
+    kIOWriteCombineCache	= 4
 };
 
 // IOMemory mapping options
 enum {
     kIOMapAnywhere		= 0x00000001,
 
-    kIOMapCacheMask		= 0x00000300,
+    kIOMapCacheMask		= 0x00000700,
     kIOMapCacheShift		= 8,
-    kIOMapDefaultCache		= kIODefaultCache   << kIOMapCacheShift,
-    kIOMapInhibitCache		= kIOInhibitCache   << kIOMapCacheShift,
-    kIOMapWriteThruCache	= kIOWriteThruCache << kIOMapCacheShift,
-    kIOMapCopybackCache		= kIOCopybackCache  << kIOMapCacheShift,
+    kIOMapDefaultCache		= kIODefaultCache      << kIOMapCacheShift,
+    kIOMapInhibitCache		= kIOInhibitCache      << kIOMapCacheShift,
+    kIOMapWriteThruCache	= kIOWriteThruCache    << kIOMapCacheShift,
+    kIOMapCopybackCache		= kIOCopybackCache     << kIOMapCacheShift,
+    kIOMapWriteCombineCache	= kIOWriteCombineCache << kIOMapCacheShift,
 
     kIOMapUserOptionsMask	= 0x00000fff,
 
diff --git a/iokit/IOKit/IOUserClient.h b/iokit/IOKit/IOUserClient.h
index df0686394..117db5259 100644
--- a/iokit/IOKit/IOUserClient.h
+++ b/iokit/IOKit/IOUserClient.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/IOWorkLoop.h b/iokit/IOKit/IOWorkLoop.h
index f3c6e1a1e..21bfe7abc 100644
--- a/iokit/IOKit/IOWorkLoop.h
+++ b/iokit/IOKit/IOWorkLoop.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/Makefile b/iokit/IOKit/Makefile
index 9368f3eff..2ae91e0c7 100644
--- a/iokit/IOKit/Makefile
+++ b/iokit/IOKit/Makefile
@@ -13,7 +13,6 @@ include $(MakeInc_def)
 INSTINC_SUBDIRS = \
         adb \
 	nvram \
-        pci \
 	platform \
 	power \
 	pwr_mgt \
diff --git a/iokit/IOKit/OSMessageNotification.h b/iokit/IOKit/OSMessageNotification.h
index 74bcb1f64..a6cfe2003 100644
--- a/iokit/IOKit/OSMessageNotification.h
+++ b/iokit/IOKit/OSMessageNotification.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/adb/IOADBBus.h b/iokit/IOKit/adb/IOADBBus.h
index e7cf3317d..4f8c3fb48 100644
--- a/iokit/IOKit/adb/IOADBBus.h
+++ b/iokit/IOKit/adb/IOADBBus.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/adb/IOADBController.h b/iokit/IOKit/adb/IOADBController.h
index 886f9529f..886fb3fda 100644
--- a/iokit/IOKit/adb/IOADBController.h
+++ b/iokit/IOKit/adb/IOADBController.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/adb/IOADBDevice.h b/iokit/IOKit/adb/IOADBDevice.h
index c8c1d7c13..71c697131 100644
--- a/iokit/IOKit/adb/IOADBDevice.h
+++ b/iokit/IOKit/adb/IOADBDevice.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/adb/IOADBLib.h b/iokit/IOKit/adb/IOADBLib.h
index b5b519f64..1e50fb6fb 100644
--- a/iokit/IOKit/adb/IOADBLib.h
+++ b/iokit/IOKit/adb/IOADBLib.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/adb/adb.h b/iokit/IOKit/adb/adb.h
index e296be557..1c923e9ac 100644
--- a/iokit/IOKit/adb/adb.h
+++ b/iokit/IOKit/adb/adb.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/assert.h b/iokit/IOKit/assert.h
index 575395cc1..475b60aca 100644
--- a/iokit/IOKit/assert.h
+++ b/iokit/IOKit/assert.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/i386/IOSharedLockImp.h b/iokit/IOKit/i386/IOSharedLockImp.h
index 00eb2dfdb..0478bc429 100644
--- a/iokit/IOKit/i386/IOSharedLockImp.h
+++ b/iokit/IOKit/i386/IOSharedLockImp.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/machine/IOSharedLockImp.h b/iokit/IOKit/machine/IOSharedLockImp.h
index 543a83ed4..e20600024 100644
--- a/iokit/IOKit/machine/IOSharedLockImp.h
+++ b/iokit/IOKit/machine/IOSharedLockImp.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/nvram/IONVRAMController.h b/iokit/IOKit/nvram/IONVRAMController.h
index eccee0bc4..a1f605bf3 100644
--- a/iokit/IOKit/nvram/IONVRAMController.h
+++ b/iokit/IOKit/nvram/IONVRAMController.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/pci/IOAGPDevice.h b/iokit/IOKit/pci/IOAGPDevice.h
deleted file mode 100644
index 06c58dd5f..000000000
--- a/iokit/IOKit/pci/IOAGPDevice.h
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
- *
- * @APPLE_LICENSE_HEADER_START@
- * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
- * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
- * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
- * 
- * @APPLE_LICENSE_HEADER_END@
- */
-/*
- * Copyright (c) 1999 Apple Computer, Inc.  All rights reserved. 
- *
- * HISTORY
- *
- */
-
-
-#ifndef _IOKIT_IOAGPDEVICE_H
-#define _IOKIT_IOAGPDEVICE_H
-
-#include <IOKit/IORangeAllocator.h>
-#include <IOKit/pci/IOPCIDevice.h>
-
-/* Definitions of AGP config registers */
-enum {
-    kIOPCIConfigAGPStatusOffset	 = 4,
-    kIOPCIConfigAGPCommandOffset = 8
-};
-
-/* Definitions of AGP Command & Status registers */
-enum {
-    kIOAGPRequestQueueMask	= 0xff000000,
-    kIOAGPSideBandAddresssing	= 0x00000200,
-    kIOAGPEnable		= 0x00000100,
-    kIOAGP4GbAddressing		= 0x00000020,
-    kIOAGPFastWrite		= 0x00000010,
-    kIOAGP4xDataRate		= 0x00000004,
-    kIOAGP2xDataRate		= 0x00000002,
-    kIOAGP1xDataRate		= 0x00000001
-};
-
-enum {
-    kIOAGPGartInvalidate	= 0x00000001
-};
-
-// getAGPStatus() defines
-enum {
-    kIOAGPDefaultStatus		= 0
-};
-enum {
-    kIOAGPIdle			= 0x00000001,
-    kIOAGPInvalidGARTEntry	= 0x00000002,
-    kIOAGPAccessOutOfRange	= 0x00000004
-};
-
-#define kIOAGPBusFlagsKey	"IOAGPFlags"
-enum {
-    kIOAGPGartIdleInvalidate	= 0x00000001
-};
-
-// masterState
-enum {
-    kIOAGPStateEnabled		= 0x00000001,
-    kIOAGPStateEnablePending	= 0x00010000
-};
-
-
-/*! @class IOAGPDevice : public IOPCIDevice
-    @abstract An IOService class representing an AGP master device.
-    @discussion The discovery of an AGP master device by the PCI bus family results in an instance of the IOAGPDevice being created and published. It provides services specific to AGP, in addition to the PCI services supplied by its superclass IOPCIDevice. */
-
-class IOAGPDevice : public IOPCIDevice
-{
-    OSDeclareDefaultStructors(IOAGPDevice)
-
-protected:
-
-/*! @struct ExpansionData
-    @discussion This structure will be used to expand the capablilties of the IOWorkLoop in the future.
-    */    
-    struct ExpansionData { };
-
-/*! @var reserved
-    Reserved for future use.  (Internal use only)  */
-    ExpansionData *reserved;
-
-public:
-    UInt32	masterState;
-    UInt8	masterAGPRegisters;
-
-/*! @function createAGPSpace
-    @abstract Allocates the AGP space, and enables AGP transactions on the master and slave.
-    @discussion This method should be called by the driver for the AGP master device  to set the size of the space and enable AGP transactions. It will destroy any AGP space currently allocated.
-    @param options No options are currently defined, pass zero.
-    @param address The physical range allocated for the AGP space is passed back to the caller.
-    @param length An in/out parameter - the caller sets the devices maximum AGP addressing and the actual size created is passed back.
-    @result An IOReturn code indicating success or failure. */
-
-    virtual IOReturn createAGPSpace( IOOptionBits options,
-				    IOPhysicalAddress * address, 
-				    IOPhysicalLength * length );
-
-/*! @function destroyAGPSpace
-    @abstract Destroys the AGP space, and disables AGP transactions on the master and slave.
-    @discussion This method should be called by the driver to shutdown AGP transactions and release resources. */
-
-    virtual IOReturn destroyAGPSpace( void );
-
-/*! @function getAGPRangeAllocator
-    @abstract Accessor to obtain the AGP range allocator.
-    @discussion To allocate ranges in AGP space, obtain a range allocator for the space with this method. It is retained while the space is created (until destroyAGPSpace is called) and should not be released by the caller.
-    @result A pointer to the range allocator for the AGP space. */
-
-    virtual IORangeAllocator * getAGPRangeAllocator( void );
-
-/*! @function getAGPStatus
-    @abstract Returns the current state of the AGP bus.
-    @discussion Returns state bits for the AGP bus. Only one type of status is currently defined. 
-    @param which Type of status - only kIOAGPDefaultStatus is currently valid.
-    @result Mask of status bits for the AGP bus. */
-
-    virtual IOOptionBits getAGPStatus( IOOptionBits which = kIOAGPDefaultStatus );
-
-/*! @function commitAGPMemory
-    @abstract Makes memory addressable by AGP transactions.
-    @discussion Makes the memory described by the IOMemoryDescriptor object addressable by AGP by entering its pages into the GART array, given an offset into AGP space supplied by the caller (usually allocated by the AGP range allocator). It  is the callers responsibility to prepare non-kernel pageable memory before calling this method, with IOMemoryDescriptor::prepare.
-    @param memory A IOMemoryDescriptor object describing the memory to add to the GART.
-    @param agpOffset An offset into AGP space that the caller has allocated - usually allocated by the AGP range allocator.
-    @param options Pass kIOAGPGartInvalidate if the AGP target should invalidate any GART TLB.
-    @result An IOReturn code indicating success or failure. */
-
-    virtual IOReturn commitAGPMemory( IOMemoryDescriptor * memory,
-					IOByteCount agpOffset,
-					IOOptionBits options = 0 );
-
-/*! @function releaseAGPMemory
-    @abstract Releases memory addressable by AGP transactions.
-    @discussion Makes the memory described by the IOMemoryDescriptor object unaddressable by AGP by removing its pages from the GART array, given an offset into AGP space supplied by the caller (usually allocated by the AGP range allocator). It  is the callers responsibility to complete non-kernel pageable memory before calling this method, with IOMemoryDescriptor::complete.
-    @param memory A IOMemoryDescriptor object describing the memory to remove from the GART.
-    @param agpOffset An offset into AGP space that the caller has allocated - usually allocated by the AGP range allocator.
-    @param options Pass kIOAGPGartInvalidate if the AGP target should invalidate any GART TLB.
-    @result An IOReturn code indicating success or failure. */
-
-    virtual IOReturn releaseAGPMemory( IOMemoryDescriptor * memory, 
-					IOByteCount agpOffset,
-					IOOptionBits options = 0 );
-
-    virtual IOReturn resetAGP( IOOptionBits options = 0 );
-
-/*! @function getAGPSpace
-    @abstract Returns the allocated AGP space.
-    @discussion This method can be called by the driver for the AGP master device to retrieve the physical address and size of the space created with createAGPSpace.
-    @param address The physical range allocated for the AGP space is passed back to the caller. Zero may be pased if the address is not needed by the caller.
-    @param length The size of the the AGP space created is passed back. Zero may be pased if the length is not needed by the caller.
-    @result An IOReturn code indicating success or failure. */
-
-    virtual IOReturn getAGPSpace( IOPhysicalAddress * address, 
-				    IOPhysicalLength * length );
-
-    // Unused Padding
-    OSMetaClassDeclareReservedUnused(IOAGPDevice,  0);
-    OSMetaClassDeclareReservedUnused(IOAGPDevice,  1);
-    OSMetaClassDeclareReservedUnused(IOAGPDevice,  2);
-    OSMetaClassDeclareReservedUnused(IOAGPDevice,  3);
-    OSMetaClassDeclareReservedUnused(IOAGPDevice,  4);
-    OSMetaClassDeclareReservedUnused(IOAGPDevice,  5);
-    OSMetaClassDeclareReservedUnused(IOAGPDevice,  6);
-    OSMetaClassDeclareReservedUnused(IOAGPDevice,  7);
-    OSMetaClassDeclareReservedUnused(IOAGPDevice,  8);
-    OSMetaClassDeclareReservedUnused(IOAGPDevice,  9);
-    OSMetaClassDeclareReservedUnused(IOAGPDevice, 10);
-    OSMetaClassDeclareReservedUnused(IOAGPDevice, 11);
-    OSMetaClassDeclareReservedUnused(IOAGPDevice, 12);
-    OSMetaClassDeclareReservedUnused(IOAGPDevice, 13);
-    OSMetaClassDeclareReservedUnused(IOAGPDevice, 14);
-    OSMetaClassDeclareReservedUnused(IOAGPDevice, 15);
-    OSMetaClassDeclareReservedUnused(IOAGPDevice, 16);
-};
-
-#endif /* ! _IOKIT_IOAGPDEVICE_H */
diff --git a/iokit/IOKit/pci/IOPCIBridge.h b/iokit/IOKit/pci/IOPCIBridge.h
deleted file mode 100644
index 9cfe7a8bd..000000000
--- a/iokit/IOKit/pci/IOPCIBridge.h
+++ /dev/null
@@ -1,271 +0,0 @@
-/*
- * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
- *
- * @APPLE_LICENSE_HEADER_START@
- * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
- * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
- * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
- * 
- * @APPLE_LICENSE_HEADER_END@
- */
-/*
- * Copyright (c) 1998-2000 Apple Computer, Inc.  All rights reserved. 
- *
- * HISTORY
- *
- */
-
-
-#ifndef _IOKIT_IOPCIBRIDGE_H
-#define _IOKIT_IOPCIBRIDGE_H
-
-#include <IOKit/IOService.h>
-#include <IOKit/IODeviceMemory.h>
-#include <IOKit/pci/IOAGPDevice.h>
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
-class IOPCIBridge : public IOService
-{
-    friend class IOPCIDevice;
-
-    OSDeclareAbstractStructors(IOPCIBridge)
-
-private:
-    IORegistryEntry * findMatching( OSIterator * in, IOPCIAddressSpace space );
-    void publishNubs( OSIterator * kids, UInt32 index );
-    virtual bool isDTNub( IOPCIDevice * nub );
-    static void nvLocation( IORegistryEntry * entry,
-	UInt8 * busNum, UInt8 * deviceNum, UInt8 * functionNum );
-
-protected:
-    IORangeAllocator *	bridgeMemoryRanges;
-    IORangeAllocator *	bridgeIORanges;
-
-/*! @struct ExpansionData
-    @discussion This structure will be used to expand the capablilties of the IOWorkLoop in the future.
-    */    
-    struct ExpansionData { };
-
-/*! @var reserved
-    Reserved for future use.  (Internal use only)  */
-    ExpansionData *reserved;
-
-protected:
-    virtual void probeBus( IOService * provider, UInt8 busNum );
-
-    virtual UInt8 firstBusNum( void );
-    virtual UInt8 lastBusNum( void );
-
-    virtual void spaceFromProperties( OSDictionary * propTable,
-					IOPCIAddressSpace * space );
-    virtual OSDictionary * constructProperties( IOPCIAddressSpace space );
-
-    virtual IOPCIDevice * createNub( OSDictionary * from );
-
-    virtual bool initializeNub( IOPCIDevice * nub, OSDictionary * from );
-
-    virtual bool publishNub( IOPCIDevice * nub, UInt32 index );
-
-    virtual bool addBridgeMemoryRange( IOPhysicalAddress start,
-				 	IOPhysicalLength length, bool host );
-
-    virtual bool addBridgeIORange( IOByteCount start, IOByteCount length );
-
-    virtual bool constructRange( IOPCIAddressSpace * flags,
-                                 IOPhysicalAddress phys, IOPhysicalLength len,
-                                 OSArray * array );
-
-    virtual bool matchNubWithPropertyTable( IOService * nub,
-					    OSDictionary * propertyTable,
-                                            SInt32 * score );
-
-    virtual bool compareNubName( const IOService * nub, OSString * name,
-				 OSString ** matched = 0 ) const;
-
-    virtual bool pciMatchNub( IOPCIDevice * nub,
-                                OSDictionary * table, SInt32 * score);
-
-    virtual bool matchKeys( IOPCIDevice * nub, const char * keys,
-				UInt32 defaultMask, UInt8 regNum );
-
-    virtual IOReturn getNubResources( IOService * nub );
-
-    virtual IOReturn getNubAddressing( IOPCIDevice * nub );
-
-    virtual IOReturn getDTNubAddressing( IOPCIDevice * nub );
-
-public:
-
-    virtual bool start( IOService * provider );
-
-    virtual bool configure( IOService * provider );
-
-    /* * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
-    virtual IODeviceMemory * ioDeviceMemory( void ) = 0;
-
-    virtual UInt32 configRead32( IOPCIAddressSpace space, UInt8 offset ) = 0;
-    virtual void configWrite32( IOPCIAddressSpace space,
-					UInt8 offset, UInt32 data ) = 0;
-    virtual UInt16 configRead16( IOPCIAddressSpace space, UInt8 offset ) = 0;
-    virtual void configWrite16( IOPCIAddressSpace space,
-					UInt8 offset, UInt16 data ) = 0;
-    virtual UInt8 configRead8( IOPCIAddressSpace space, UInt8 offset ) = 0;
-    virtual void configWrite8( IOPCIAddressSpace space,
-					UInt8 offset, UInt8 data ) = 0;
-
-    virtual IOPCIAddressSpace getBridgeSpace( void ) = 0;
-
-    virtual UInt32 findPCICapability( IOPCIAddressSpace space,
-                                      UInt8 capabilityID, UInt8 * offset = 0 );
-
-    virtual IOReturn setDevicePowerState( IOPCIDevice * device,
-                                          unsigned long whatToDo );
-    virtual IOReturn saveDeviceState( IOPCIDevice * device,
-                                      IOOptionBits options = 0 );
-    virtual IOReturn restoreDeviceState( IOPCIDevice * device,
-                                         IOOptionBits options = 0 );
-
-    /* * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
-    virtual IOReturn createAGPSpace( IOAGPDevice * master,
-				     IOOptionBits options,
-				     IOPhysicalAddress * address, 
-				     IOPhysicalLength * length );
-
-    virtual IOReturn destroyAGPSpace( IOAGPDevice * master );
-
-    virtual IORangeAllocator * getAGPRangeAllocator( IOAGPDevice * master );
-
-    virtual IOOptionBits getAGPStatus( IOAGPDevice * master,
-				       IOOptionBits options = 0 );
-    virtual IOReturn resetAGPDevice( IOAGPDevice * master,
-                                     IOOptionBits options = 0 );
-
-    virtual IOReturn getAGPSpace( IOAGPDevice * master,
-                                  IOPhysicalAddress * address, 
-				  IOPhysicalLength * length );
-
-    virtual IOReturn commitAGPMemory( IOAGPDevice * master, 
-				      IOMemoryDescriptor * memory,
-				      IOByteCount agpOffset,
-				      IOOptionBits options );
-
-    virtual IOReturn releaseAGPMemory(  IOAGPDevice * master, 
-				      	IOMemoryDescriptor * memory, 
-					IOByteCount agpOffset,
-					IOOptionBits options );
-
-    // Unused Padding
-    OSMetaClassDeclareReservedUnused(IOPCIBridge,  0);
-    OSMetaClassDeclareReservedUnused(IOPCIBridge,  1);
-    OSMetaClassDeclareReservedUnused(IOPCIBridge,  2);
-    OSMetaClassDeclareReservedUnused(IOPCIBridge,  3);
-    OSMetaClassDeclareReservedUnused(IOPCIBridge,  4);
-    OSMetaClassDeclareReservedUnused(IOPCIBridge,  5);
-    OSMetaClassDeclareReservedUnused(IOPCIBridge,  6);
-    OSMetaClassDeclareReservedUnused(IOPCIBridge,  7);
-    OSMetaClassDeclareReservedUnused(IOPCIBridge,  8);
-    OSMetaClassDeclareReservedUnused(IOPCIBridge,  9);
-    OSMetaClassDeclareReservedUnused(IOPCIBridge, 10);
-    OSMetaClassDeclareReservedUnused(IOPCIBridge, 11);
-    OSMetaClassDeclareReservedUnused(IOPCIBridge, 12);
-    OSMetaClassDeclareReservedUnused(IOPCIBridge, 13);
-    OSMetaClassDeclareReservedUnused(IOPCIBridge, 14);
-    OSMetaClassDeclareReservedUnused(IOPCIBridge, 15);
-    OSMetaClassDeclareReservedUnused(IOPCIBridge, 16);
-    OSMetaClassDeclareReservedUnused(IOPCIBridge, 17);
-    OSMetaClassDeclareReservedUnused(IOPCIBridge, 18);
-    OSMetaClassDeclareReservedUnused(IOPCIBridge, 19);
-    OSMetaClassDeclareReservedUnused(IOPCIBridge, 20);
-    OSMetaClassDeclareReservedUnused(IOPCIBridge, 21);
-    OSMetaClassDeclareReservedUnused(IOPCIBridge, 22);
-    OSMetaClassDeclareReservedUnused(IOPCIBridge, 23);
-    OSMetaClassDeclareReservedUnused(IOPCIBridge, 24);
-    OSMetaClassDeclareReservedUnused(IOPCIBridge, 25);
-    OSMetaClassDeclareReservedUnused(IOPCIBridge, 26);
-    OSMetaClassDeclareReservedUnused(IOPCIBridge, 27);
-    OSMetaClassDeclareReservedUnused(IOPCIBridge, 28);
-    OSMetaClassDeclareReservedUnused(IOPCIBridge, 29);
-    OSMetaClassDeclareReservedUnused(IOPCIBridge, 30);
-    OSMetaClassDeclareReservedUnused(IOPCIBridge, 31);
-};
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
-#define kIOPCIBridgeRegs (32)
-
-class IOPCI2PCIBridge : public IOPCIBridge
-{
-    OSDeclareDefaultStructors(IOPCI2PCIBridge)
-
-private:
-
-    IOPCIDevice * bridgeDevice;
-    UInt32        bridgeState[kIOPCIBridgeRegs];
-
-protected:
-/*! @struct ExpansionData
-    @discussion This structure will be used to expand the capablilties of the IOWorkLoop in the future.
-    */    
-    struct ExpansionData { };
-
-/*! @var reserved
-    Reserved for future use.  (Internal use only)  */
-    ExpansionData *reserved;
-
-    virtual UInt8 firstBusNum( void );
-    virtual UInt8 lastBusNum( void );
-
-public:
-    virtual IOService * probe(	IOService * 	provider,
-                                SInt32 *	score );
-
-    virtual bool configure( IOService * provider );
-
-    virtual void saveBridgeState( void );
-
-    virtual void restoreBridgeState( void );
-
-    virtual bool publishNub( IOPCIDevice * nub, UInt32 index );
-
-    virtual IODeviceMemory * ioDeviceMemory( void );
-
-    virtual IOPCIAddressSpace getBridgeSpace( void );
-
-    virtual UInt32 configRead32( IOPCIAddressSpace space, UInt8 offset );
-    virtual void configWrite32( IOPCIAddressSpace space,
-					UInt8 offset, UInt32 data );
-    virtual UInt16 configRead16( IOPCIAddressSpace space, UInt8 offset );
-    virtual void configWrite16( IOPCIAddressSpace space,
-					UInt8 offset, UInt16 data );
-    virtual UInt8 configRead8( IOPCIAddressSpace space, UInt8 offset );
-    virtual void configWrite8( IOPCIAddressSpace space,
-					UInt8 offset, UInt8 data );
-
-    // Unused Padding
-    OSMetaClassDeclareReservedUnused(IOPCI2PCIBridge,  0);
-    OSMetaClassDeclareReservedUnused(IOPCI2PCIBridge,  1);
-    OSMetaClassDeclareReservedUnused(IOPCI2PCIBridge,  2);
-    OSMetaClassDeclareReservedUnused(IOPCI2PCIBridge,  3);
-    OSMetaClassDeclareReservedUnused(IOPCI2PCIBridge,  4);
-    OSMetaClassDeclareReservedUnused(IOPCI2PCIBridge,  5);
-    OSMetaClassDeclareReservedUnused(IOPCI2PCIBridge,  6);
-    OSMetaClassDeclareReservedUnused(IOPCI2PCIBridge,  7);
-    OSMetaClassDeclareReservedUnused(IOPCI2PCIBridge,  8);
-};
-
-#endif /* ! _IOKIT_IOPCIBRIDGE_H */
diff --git a/iokit/IOKit/pci/IOPCIDevice.h b/iokit/IOKit/pci/IOPCIDevice.h
index 158e85a2a..0d340006e 100644
--- a/iokit/IOKit/pci/IOPCIDevice.h
+++ b/iokit/IOKit/pci/IOPCIDevice.h
@@ -3,110 +3,33 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
-/*
- * Copyright (c) 1998 Apple Computer, Inc.  All rights reserved. 
- *
- * HISTORY
- *
- */
-
 
 #ifndef _IOKIT_IOPCIDEVICE_H
 #define _IOKIT_IOPCIDEVICE_H
 
-#include <IOKit/IOService.h>
-
-/* Definitions of PCI Config Registers */
-enum {
-    kIOPCIConfigVendorID		= 0x00,
-    kIOPCIConfigDeviceID		= 0x02,
-    kIOPCIConfigCommand			= 0x04,
-    kIOPCIConfigStatus			= 0x06,
-    kIOPCIConfigRevisionID		= 0x08,
-    kIOPCIConfigClassCode		= 0x09,
-    kIOPCIConfigCacheLineSize		= 0x0C,
-    kIOPCIConfigLatencyTimer		= 0x0D,
-    kIOPCIConfigHeaderType		= 0x0E,
-    kIOPCIConfigBIST			= 0x0F,
-    kIOPCIConfigBaseAddress0		= 0x10,
-    kIOPCIConfigBaseAddress1		= 0x14,
-    kIOPCIConfigBaseAddress2		= 0x18,
-    kIOPCIConfigBaseAddress3		= 0x1C,
-    kIOPCIConfigBaseAddress4		= 0x20,
-    kIOPCIConfigBaseAddress5		= 0x24,
-    kIOPCIConfigCardBusCISPtr		= 0x28,
-    kIOPCIConfigSubSystemVendorID	= 0x2C,
-    kIOPCIConfigSubSystemID		= 0x2E,
-    kIOPCIConfigExpansionROMBase	= 0x30,
-    kIOPCIConfigCapabilitiesPtr		= 0x34,
-    kIOPCIConfigInterruptLine		= 0x3C,
-    kIOPCIConfigInterruptPin		= 0x3D,
-    kIOPCIConfigMinimumGrant		= 0x3E,
-    kIOPCIConfigMaximumLatency		= 0x3F
-};
-
-/* Definitions of Capabilities PCI Config Register */
-enum {
-    kIOPCICapabilityIDOffset		= 0x00,
-    kIOPCINextCapabilityOffset		= 0x01,
-    kIOPCIPowerManagementCapability	= 0x01,
-    kIOPCIAGPCapability        		= 0x02
-};
-
-/* Space definitions */
-enum {
-    kIOPCIConfigSpace		= 0,
-    kIOPCIIOSpace		= 1,
-    kIOPCI32BitMemorySpace	= 2,
-    kIOPCI64BitMemorySpace	= 3
-};
-
-/* Command register definitions */
-enum {
-    kIOPCICommandIOSpace		= 0x0001,
-    kIOPCICommandMemorySpace		= 0x0002,
-    kIOPCICommandBusMaster		= 0x0004,
-    kIOPCICommandSpecialCycles		= 0x0008,
-    kIOPCICommandMemWrInvalidate	= 0x0010,
-    kIOPCICommandPaletteSnoop		= 0x0020,
-    kIOPCICommandParityError		= 0x0040,
-    kIOPCICommandAddressStepping	= 0x0080,
-    kIOPCICommandSERR			= 0x0100,
-    kIOPCICommandFastBack2Back		= 0x0200
-};
+#warning IOPCIDevice.h moved to IOPCIFamily project
+#warning IOPCIDevice.h will be removed from xnu; do not edit or add new usage
 
-/* Status register definitions */
-enum {
-    kIOPCIStatusCapabilities		= 0x0010,
-    kIOPCIStatusPCI66			= 0x0020,
-    kIOPCIStatusUDF			= 0x0040,
-    kIOPCIStatusFastBack2Back		= 0x0080,
-    kIOPCIStatusDevSel0			= 0x0000,
-    kIOPCIStatusDevSel1			= 0x0200,
-    kIOPCIStatusDevSel2			= 0x0400,
-    kIOPCIStatusDevSel3			= 0x0600,
-    kIOPCIStatusTargetAbortCapable	= 0x0800,
-    kIOPCIStatusTargetAbortActive	= 0x1000,
-    kIOPCIStatusMasterAbortActive	= 0x2000,
-    kIOPCIStatusSERRActive		= 0x4000,
-    kIOPCIStatusParityErrActive		= 0x8000
-};
+#include <IOKit/IOService.h>
 
 union IOPCIAddressSpace {
     UInt32		bits;
@@ -135,91 +58,6 @@ union IOPCIAddressSpace {
     } s;
 };
 
-struct IOPCIPhysicalAddress {
-    IOPCIAddressSpace	physHi;
-    UInt32		physMid;
-    UInt32		physLo;
-    UInt32		lengthHi;
-    UInt32		lengthLo;
-};
-
-// IOPCIDevice matching property names
-#define kIOPCIMatchKey			"IOPCIMatch"
-#define kIOPCIPrimaryMatchKey		"IOPCIPrimaryMatch"
-#define kIOPCISecondaryMatchKey		"IOPCISecondaryMatch"
-#define kIOPCIClassMatchKey		"IOPCIClassMatch"
-
-// property to control PCI default config space save on sleep
-#define kIOPMPCIConfigSpaceVolatileKey	"IOPMPCIConfigSpaceVolatile"
-
-enum {
-    kIOPCIDevicePowerStateCount = 3,
-    kIOPCIDeviceOffState	= 0,
-    kIOPCIDeviceOnState		= 2
-};
-
-/*! @class IOPCIDevice : public IOService
-    @abstract An IOService class representing a PCI device.
-    @discussion The discovery of an PCI device by the PCI bus family results in an instance of the IOPCIDevice being created and published. It provides services for looking up and mapping memory mapped hardware, and access to the PCI configuration and I/O spaces. 
-
-<br><br>Matching Supported by IOPCIDevice<br><br>
-
-Two types of matching are available, OpenFirmware name matching and PCI register matching. Currently, only one of these two matching schemes can be used in the same property table.
-
-<br><br>OpenFirmware Name Matching<br><br>
-
-IOService performs matching based on the IONameMatch property (see IOService). IOPCIDevices created with OpenFirmware device tree entries will name match based on the standard OpenFirmware name matching properties.
-
-<br><br>PCI Register Matching<br><br>
-
-A PCI device driver can also match on the values of certain config space registers.
-
-In each case, several matching values can be specified, and an optional mask for the value of the config space register may follow the value, preceded by an '&' character.
-<br>
-<br>
-	kIOPCIMatchKey, "IOPCIMatch"
-<br>
-The kIOPCIMatchKey property matches the vendor and device ID (0x00) register, or the subsystem register (0x2c).
-<br>
-<br>
-	kIOPCIPrimaryMatchKey, "IOPCIPrimaryMatch"
-<br>
-The kIOPCIPrimaryMatchKey property matches the vendor and device ID (0x00) register.
-<br>
-<br>
-	kIOPCISecondaryMatchKey, "IOPCISecondaryMatch"
-<br>
-The kIOPCISecondaryMatchKey property matches the subsystem register (0x2c).
-<br>
-<br>
-	kIOPCIClassMatchKey, "IOPCIClassMatch"
-<br>
-The kIOPCIClassMatchKey property matches the class code register (0x08). The default mask for this register is 0xffffff00.
-<br>
-<br>
-Examples:
-<br>
-<br>
-      &ltkey&gtIOPCIMatch&lt/key&gt		<br>
-	&ltstring&gt0x00261011&lt/string&gt
-<br>
-Matches a device whose vendor ID is 0x1011, and device ID is 0x0026, including subsystem IDs.
-<br>
-<br>
-      &ltkey&gtIOPCIMatch&lt/key&gt		<br>
-	&ltstring&gt0x00789004&0x00ffffff 0x78009004&0x0xff00ffff&lt/string&gt
-<br>
-Matches with any device with a vendor ID of 0x9004, and a device ID of 0xzz78 or 0x78zz, where 'z' is don't care.
-<br>
-<br>
-      &ltkey&gtIOPCIClassMatch&lt/key&gt	<br>
-	&ltstring&gt0x02000000&0xffff0000&lt/string&gt
-<br>
-<br>
-Matches a device whose class code is 0x0200zz, an ethernet device.
-
-*/
-
 class IOPCIDevice : public IOService
 {
     OSDeclareDefaultStructors(IOPCIDevice)
@@ -232,21 +70,15 @@ protected:
     IOMemoryMap *	ioMap;
     OSObject *          slotNameProperty;
 
-/*! @struct ExpansionData
-    @discussion This structure will be used to expand the capablilties of the IOWorkLoop in the future.
-    */    
     struct ExpansionData { };
 
-/*! @var reserved
-    Reserved for future use.  (Internal use only)  */
     ExpansionData *reserved;
 
 public:
-    IOPCIAddressSpace	space;
+    IOPCIAddressSpace   space;
     UInt32	*	savedConfig;
 
 public:
-    /* IOService/IORegistryEntry methods */
 
     virtual bool attach( IOService * provider );
     virtual void detach( IOService * provider );
@@ -269,206 +101,36 @@ public:
     virtual void configWrite8( IOPCIAddressSpace space,
 					UInt8 offset, UInt8 data );
 
-/*! @function configRead32
-    @abstract Reads a 32-bit value from the PCI device's configuration space.
-    @discussion This method reads a 32-bit configuration space register on the device and returns its value.
-    @param offset An 8-bit offset into configuration space, of which bits 0-1 are ignored.
-    @result An 32-bit value in host byte order (big endian on PPC). */
-
     virtual UInt32 configRead32( UInt8 offset );
-
-/*! @function configRead16
-    @abstract Reads a 16-bit value from the PCI device's configuration space.
-    @discussion This method reads a 16-bit configuration space register on the device and returns its value.
-    @param offset An 8-bit offset into configuration space, of which bit 0 is ignored.
-    @result An 16-bit value in host byte order (big endian on PPC). */
-
     virtual UInt16 configRead16( UInt8 offset );
-
-/*! @function configRead8
-    @abstract Reads a 8-bit value from the PCI device's configuration space.
-    @discussion This method reads a 8-bit configuration space register on the device and returns its value.
-    @param offset An 8-bit offset into configuration space.
-    @result An 8-bit value. */
-
     virtual UInt8 configRead8( UInt8 offset );
-
-/*! @function configWrite32
-    @abstract Writes a 32-bit value to the PCI device's configuration space.
-    @discussion This method write a 32-bit value to a configuration space register on the device.
-    @param offset An 8-bit offset into configuration space, of which bits 0-1 are ignored.
-    @param data An 32-bit value to be written in host byte order (big endian on PPC). */
-
     virtual void configWrite32( UInt8 offset, UInt32 data );
-
-/*! @function configWrite16
-    @abstract Writes a 16-bit value to the PCI device's configuration space.
-    @discussion This method write a 16-bit value to a configuration space register on the device.
-    @param offset An 8-bit offset into configuration space, of which bit 0 is ignored.
-    @param data An 16-bit value to be written in host byte order (big endian on PPC). */
-
     virtual void configWrite16( UInt8 offset, UInt16 data );
-
-/*! @function configWrite8
-    @abstract Writes a 8-bit value to the PCI device's configuration space.
-    @discussion This method write a 8-bit value to a configuration space register on the device.
-    @param offset An 8-bit offset into configuration space.
-    @param data An 8-bit value to be written. */
-
     virtual void configWrite8( UInt8 offset, UInt8 data );
 
     virtual IOReturn saveDeviceState( IOOptionBits options = 0 );
     virtual IOReturn restoreDeviceState( IOOptionBits options = 0 );
-
-/*! @function setConfigBits
-    @abstract Sets masked bits in a configuration space register.
-    @discussion This method sets masked bits in a configuration space register on the device by reading and writing the register. The value of the masked bits before the write is returned.
-    @param offset An 8-bit offset into configuration space, of which bits 0-1 are ignored.
-    @param mask An 32-bit mask indicating which bits in the value parameter are valid.
-    @param data An 32-bit value to be written in host byte order (big endian on PPC).
-    @result The value of the register masked with the mask before the write. */
-    
     virtual UInt32 setConfigBits( UInt8 offset, UInt32 mask, UInt32 value );
 
-/*! @function setMemoryEnable
-    @abstract Sets the device's memory space response.
-    @discussion This method sets the memory space response bit in the device's command config space register to the passed value, and returns the previous state of the enable.
-    @param enable True or false to enable or disable the memory space response.
-    @result True if the memory space response was previously enabled, false otherwise. */
-
     virtual bool setMemoryEnable( bool enable );
-
-/*! @function setIOEnable
-    @abstract Sets the device's I/O space response.
-    @discussion This method sets the I/O space response bit in the device's command config space register to the passed value, and returns the previous state of the enable. The exclusive option allows only one exclusive device on the bus to be enabled concurrently, this should be only for temporary access.
-    @param enable True or false to enable or disable the I/O space response.
-    @param exclusive If true, only one setIOEnable with the exclusive flag set will be allowed at a time on the bus, this should be only for temporary access.
-    @result True if the I/O space response was previously enabled, false otherwise. */
-
     virtual bool setIOEnable( bool enable, bool exclusive = false );
-
-/*! @function setBusMasterEnable
-    @abstract Sets the device's bus master enable.
-    @discussion This method sets the bus master enable bit in the device's command config space register to the passed value, and returns the previous state of the enable.
-    @param enable True or false to enable or disable bus mastering.
-    @result True if bus mastering was previously enabled, false otherwise. */
-
     virtual bool setBusMasterEnable( bool enable );
-
-/*! @function findPCICapability
-    @abstract Search configuration space for a PCI capability register.
-    @discussion This method searchs the device's config space for a PCI capability register matching the passed capability ID, if the device supports PCI capabilities.
-    @param capabilityID An 8-bit PCI capability ID.
-    @param offset An optional pointer to return the offset into config space where the capability was found.
-    @result The 32-bit value of the capability register if one was found, zero otherwise. */
-
     virtual UInt32 findPCICapability( UInt8 capabilityID, UInt8 * offset = 0 );
-
-/*! @function getBusNumber
-    @abstract Accessor to return the PCI device's assigned bus number.
-    @discussion This method is an accessor to return the PCI device's assigned bus number.
-    @result The 8-bit value of device's PCI bus number. */
-
     virtual UInt8 getBusNumber( void );
-
-/*! @function getDeviceNumber
-    @abstract Accessor to return the PCI device's device number.
-    @discussion This method is an accessor to return the PCI device's device number.
-    @result The 5-bit value of device's device number. */
-
     virtual UInt8 getDeviceNumber( void );
-
-/*! @function getFunctionNumber
-    @abstract Accessor to return the PCI device's function number.
-    @discussion This method is an accessor to return the PCI device's function number.
-    @result The 3-bit value of device's function number. */
-
     virtual UInt8 getFunctionNumber( void );
-
-    /* Device memory accessors */
-
-/*! @function getDeviceMemoryWithRegister
-    @abstract Returns an instance of IODeviceMemory representing one of the device's memory mapped ranges.
-    @discussion This method will return a pointer to an instance of IODeviceMemory for the physical memory range that was assigned to the configuration space base address register passed in. It is analogous to IOService::getDeviceMemoryWithIndex.
-    @param reg The 8-bit configuration space register that is the base address register for the desired range.
-    @result A pointer to an instance of IODeviceMemory, or zero no such range was found. The IODeviceMemory is retained by the provider, so is valid while attached, or while any mappings to it exist. It should not be released by the caller. */
-
     virtual IODeviceMemory * getDeviceMemoryWithRegister( UInt8 reg );
-
-/*! @function mapDeviceMemoryWithRegister
-    @abstract Maps a physical range of the device.
-    @discussion This method will create a mapping for the IODeviceMemory for the physical memory range that was assigned to the configuration space base address register passed in, with IODeviceMemory::map(options). The mapping is represented by the returned instance of IOMemoryMap, which should not be released until the mapping is no longer required. This method is analogous to IOService::mapDeviceMemoryWithIndex.
-    @param reg The 8-bit configuration space register that is the base address register for the desired range.
-    @param options Options to be passed to the IOMemoryDescriptor::map() method.
-    @result An instance of IOMemoryMap, or zero if the index is beyond the count available. The mapping should be released only when access to it is no longer required. */
-
     virtual IOMemoryMap * mapDeviceMemoryWithRegister( UInt8 reg,
 						IOOptionBits options = 0 );
-
-/*! @function ioDeviceMemory
-    @abstract Accessor to the I/O space aperture for the bus.
-    @discussion This method will return a reference to the IODeviceMemory for the I/O aperture of the bus the device is on.
-    @result A pointer to an IODeviceMemory object for the I/O aperture. The IODeviceMemory is retained by the provider, so is valid while attached, or while any mappings to it exist. It should not be released by the caller. */
-
     virtual IODeviceMemory * ioDeviceMemory( void );
-
-    /* I/O space accessors */
-
-/*! @function ioWrite32
-    @abstract Writes a 32-bit value to an I/O space aperture.
-    @discussion This method will write a 32-bit value to a 4 byte aligned offset in an I/O space aperture. If a map object is passed in, the value is written relative to it, otherwise to the value is written relative to the I/O space aperture for the bus. This function encapsulates the differences between architectures in generating I/O space operations. An eieio instruction is included on PPC.
-    @param offset An offset into a bus or device's I/O space aperture.
-    @param value The value to be written in host byte order (big endian on PPC).
-    @param map If the offset is relative to the beginning of a device's aperture, an IOMemoryMap object for that object should be passed in. Otherwise, passing zero will write the value relative to the beginning of the bus' I/O space. */
-
     virtual void ioWrite32( UInt16 offset, UInt32 value,
 				IOMemoryMap * map = 0 );
-
-/*! @function ioWrite16
-    @abstract Writes a 16-bit value to an I/O space aperture.
-    @discussion This method will write a 16-bit value to a 2 byte aligned offset in an I/O space aperture. If a map object is passed in, the value is written relative to it, otherwise to the value is written relative to the I/O space aperture for the bus. This function encapsulates the differences between architectures in generating I/O space operations. An eieio instruction is included on PPC.
-    @param offset An offset into a bus or device's I/O space aperture.
-    @param value The value to be written in host byte order (big endian on PPC).
-    @param map If the offset is relative to the beginning of a device's aperture, an IOMemoryMap object for that object should be passed in. Otherwise, passing zero will write the value relative to the beginning of the bus' I/O space. */
-
     virtual void ioWrite16( UInt16 offset, UInt16 value,
 				IOMemoryMap * map = 0 );
-
-/*! @function ioWrite8
-    @abstract Writes a 8-bit value to an I/O space aperture.
-    @discussion This method will write a 8-bit value to an offset in an I/O space aperture. If a map object is passed in, the value is written relative to it, otherwise to the value is written relative to the I/O space aperture for the bus. This function encapsulates the differences between architectures in generating I/O space operations. An eieio instruction is included on PPC.
-    @param offset An offset into a bus or device's I/O space aperture.
-    @param value The value to be written in host byte order (big endian on PPC).
-    @param map If the offset is relative to the beginning of a device's aperture, an IOMemoryMap object for that object should be passed in. Otherwise, passing zero will write the value relative to the beginning of the bus' I/O space. */
-
     virtual void ioWrite8( UInt16 offset, UInt8 value,
 				IOMemoryMap * map = 0 );
-
-/*! @function ioRead32
-    @abstract Reads a 32-bit value from an I/O space aperture.
-    @discussion This method will read a 32-bit value from a 4 byte aligned offset in an I/O space aperture. If a map object is passed in, the value is read relative to it, otherwise to the value is read relative to the I/O space aperture for the bus. This function encapsulates the differences between architectures in generating I/O space operations. An eieio instruction is included on PPC.
-    @param offset An offset into a bus or device's I/O space aperture.
-    @param map If the offset is relative to the beginning of a device's aperture, an IOMemoryMap object for that object should be passed in. Otherwise, passing zero will write the value relative to the beginning of the bus' I/O space.
-    @result The value read in host byte order (big endian on PPC). */
-
     virtual UInt32 ioRead32( UInt16 offset, IOMemoryMap * map = 0 );
-
-/*! @function ioRead16
-    @abstract Reads a 16-bit value from an I/O space aperture.
-    @discussion This method will read a 16-bit value from a 2 byte aligned offset in an I/O space aperture. If a map object is passed in, the value is read relative to it, otherwise to the value is read relative to the I/O space aperture for the bus. This function encapsulates the differences between architectures in generating I/O space operations. An eieio instruction is included on PPC.
-    @param offset An offset into a bus or device's I/O space aperture.
-    @param map If the offset is relative to the beginning of a device's aperture, an IOMemoryMap object for that object should be passed in. Otherwise, passing zero will write the value relative to the beginning of the bus' I/O space.
-    @result The value read in host byte order (big endian on PPC). */
-
     virtual UInt16 ioRead16( UInt16 offset, IOMemoryMap * map = 0 );
-
-/*! @function ioRead8
-    @abstract Reads a 8-bit value from an I/O space aperture.
-    @discussion This method will read a 8-bit value from an offset in an I/O space aperture. If a map object is passed in, the value is read relative to it, otherwise to the value is read relative to the I/O space aperture for the bus. This function encapsulates the differences between architectures in generating I/O space operations. An eieio instruction is included on PPC.
-    @param offset An offset into a bus or device's I/O space aperture.
-    @param map If the offset is relative to the beginning of a device's aperture, an IOMemoryMap object for that object should be passed in. Otherwise, passing zero will write the value relative to the beginning of the bus' I/O space.
-    @result The value read. */
-
     virtual UInt8 ioRead8( UInt16 offset, IOMemoryMap * map = 0 );
 
     // Unused Padding
@@ -491,4 +153,3 @@ public:
 };
 
 #endif /* ! _IOKIT_IOPCIDEVICE_H */
-
diff --git a/iokit/IOKit/pci/Makefile b/iokit/IOKit/pci/Makefile
deleted file mode 100644
index ba1f3c6e2..000000000
--- a/iokit/IOKit/pci/Makefile
+++ /dev/null
@@ -1,34 +0,0 @@
-export MakeInc_cmd=${SRCROOT}/makedefs/MakeInc.cmd
-export MakeInc_def=${SRCROOT}/makedefs/MakeInc.def
-export MakeInc_rule=${SRCROOT}/makedefs/MakeInc.rule
-export MakeInc_dir=${SRCROOT}/makedefs/MakeInc.dir
-
-IOKIT_FRAMEDIR = $(FRAMEDIR)/IOKit.framework/Versions/A
-export INCDIR = $(IOKIT_FRAMEDIR)/Headers
-export LCLDIR = $(IOKIT_FRAMEDIR)/PrivateHeaders
-
-include $(MakeInc_cmd)
-include $(MakeInc_def)
-
-MI_DIR = pci
-NOT_EXPORT_HEADERS = 
-
-INSTINC_SUBDIRS =
-INSTINC_SUBDIRS_PPC =
-INSTINC_SUBDIRS_I386 =
-
-EXPINC_SUBDIRS = ${INSTINC_SUBDIRS}
-EXPINC_SUBDIRS_PPC = ${INSTINC_SUBDIRS_PPC}
-EXPINC_SUBDIRS_I386 = ${INSTINC_SUBDIRS_I386}
-
-ALL_HEADERS = $(shell (cd $(SOURCE); echo *.h))
-
-INSTALL_MI_LIST	= 
-INSTALL_MI_LCL_LIST = ""
-INSTALL_MI_DIR = $(MI_DIR)
-
-EXPORT_MI_LIST	= $(filter-out $(NOT_EXPORT_HEADERS), $(ALL_HEADERS))
-EXPORT_MI_DIR = IOKit/$(MI_DIR)
-
-include $(MakeInc_rule)
-include $(MakeInc_dir)
diff --git a/iokit/IOKit/platform/AppleMacIO.h b/iokit/IOKit/platform/AppleMacIO.h
index 553246eab..0024154ae 100644
--- a/iokit/IOKit/platform/AppleMacIO.h
+++ b/iokit/IOKit/platform/AppleMacIO.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/platform/AppleMacIODevice.h b/iokit/IOKit/platform/AppleMacIODevice.h
index 51f9abd39..b3b487a8a 100644
--- a/iokit/IOKit/platform/AppleMacIODevice.h
+++ b/iokit/IOKit/platform/AppleMacIODevice.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/platform/AppleNMI.h b/iokit/IOKit/platform/AppleNMI.h
index 713259f6a..9f0be7f6e 100644
--- a/iokit/IOKit/platform/AppleNMI.h
+++ b/iokit/IOKit/platform/AppleNMI.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/platform/ApplePlatformExpert.h b/iokit/IOKit/platform/ApplePlatformExpert.h
index a684a5b73..0a6cc5061 100644
--- a/iokit/IOKit/platform/ApplePlatformExpert.h
+++ b/iokit/IOKit/platform/ApplePlatformExpert.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/power/IOPwrController.h b/iokit/IOKit/power/IOPwrController.h
index 82eb90e1e..2edf8063e 100644
--- a/iokit/IOKit/power/IOPwrController.h
+++ b/iokit/IOKit/power/IOPwrController.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/ppc/IODBDMA.h b/iokit/IOKit/ppc/IODBDMA.h
index 496efe363..4c12490f6 100644
--- a/iokit/IOKit/ppc/IODBDMA.h
+++ b/iokit/IOKit/ppc/IODBDMA.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/ppc/IOSharedLockImp.h b/iokit/IOKit/ppc/IOSharedLockImp.h
index 01bb64e76..c6c062fd5 100644
--- a/iokit/IOKit/ppc/IOSharedLockImp.h
+++ b/iokit/IOKit/ppc/IOSharedLockImp.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -93,33 +96,47 @@
 
 #ifndef KERNEL
 LEAF(_ev_lock)
-	li	a6,1			// lock value
-	lwarx	a7,0,a0			// CEMV10
-9:
-	sync
-	lwarx	a7,0,a0			// read the lock
-	cmpwi	cr0,a7,0		// is it busy?
-	bne-	9b 			// yes, spin
-	sync
-	stwcx.	a6,0,a0			// try to get the lock
-	bne-	9b 			// failed, try again
-	isync
-	blr				// got it, return
+
+		li		a6,1			// lock value
+		
+8:		lwz		a7,0(a0)		// Get lock word
+		mr.		a7,a7			// Is it held?
+		bne--	8b				// Yup...
+
+9:		lwarx	a7,0,a0			// read the lock
+		mr.		a7,a7			// Is it held?
+		bne--	7f				// yes, kill reservation
+		stwcx.	a6,0,a0			// try to get the lock
+		bne--	9b 				// failed, try again
+		isync
+		blr						// got it, return
+		
+7:		li		a7,-4			// Point to a spot in the red zone
+		stwcx.	a7,a7,r1		// Kill reservation
+		b		8b				// Go wait some more...
+		
+		
 END(_ev_lock)
 
 LEAF(_IOSpinLock)
-	li	a6,1			// lock value
-	lwarx	a7,0,a0			// CEMV10
-9:
-	sync
-	lwarx	a7,0,a0			// read the lock
-	cmpwi	cr0,a7,0		// is it busy?
-	bne-	9b			// yes, spin
-	sync
-	stwcx.	a6,0,a0			// try to get the lock
-	bne-	9b			// failed, try again
-	isync
-	blr				// got it, return
+
+		li		a6,1			// lock value
+		
+8:		lwz		a7,0(a0)		// Get lock word
+		mr.		a7,a7			// Is it held?
+		bne--	8b				// Yup...
+
+9:		lwarx	a7,0,a0			// read the lock
+		mr.		a7,a7			// Is it held?
+		bne--	7f				// yes, kill reservation
+		stwcx.	a6,0,a0			// try to get the lock
+		bne--	9b 				// failed, try again
+		isync
+		blr						// got it, return
+		
+7:		li		a7,-4			// Point to a spot in the red zone
+		stwcx.	a7,a7,r1		// Kill reservation
+		b		8b				// Go wait some more...
 END(_IOSpinLock)
 #endif
 
@@ -156,45 +173,61 @@ END(_IOSpinUnlock)
  */
 
 LEAF(_ev_try_lock)
-	li	a6,1			// lock value
-        DISABLE_PREEMPTION()
-	lwarx	a7,0,a0			// CEMV10
-8:
-	sync
-	lwarx	a7,0,a0			// read the lock
-	cmpwi	cr0,a7,0		// is it busy?
-	bne-	9f			// yes, give up
-	sync
-	stwcx.	a6,0,a0			// try to get the lock
-	bne-	8b			// failed, try again
-	li	a0,1			// return TRUE
-	isync
-	blr
-9:
-	ENABLE_PREEMPTION()
-	li	a0,0			// return FALSE
-	blr
+	
+		DISABLE_PREEMPTION()
+
+		li		a6,1			// lock value
+		
+		lwz		a7,0(a0)		// Get lock word
+		mr.		a7,a7			// Is it held?
+		bne--	6f				// Yup...
+
+9:		lwarx	a7,0,a0			// read the lock
+		mr.		a7,a7			// Is it held?
+		bne--	7f				// yes, kill reservation
+		stwcx.	a6,0,a0			// try to get the lock
+		bne--	9b 				// failed, try again
+		li		a0,1			// return TRUE
+		isync
+		blr						// got it, return
+		
+7:		li		a7,-4			// Point to a spot in the red zone
+		stwcx.	a7,a7,r1		// Kill reservation
+
+6:
+		ENABLE_PREEMPTION()
+		li	a0,0				// return FALSE
+		blr
+		
 END(_ev_try_lock)
 
 LEAF(_IOTrySpinLock)
-	li	a6,1			// lock value
-        DISABLE_PREEMPTION()
-	lwarx	a7,0,a0			// CEMV10
-8:
-	sync
-	lwarx	a7,0,a0			// read the lock
-	cmpwi	cr0,a7,0		// is it busy?
-	bne-	9f			// yes, give up
-	sync
-	stwcx.	a6,0,a0			// try to get the lock
-	bne-	8b			// failed, try again
-	li	a0,1			// return TRUE
-	isync
-	blr
-9:
-	ENABLE_PREEMPTION()
-	li	a0,0			// return FALSE
-	blr
+	
+		DISABLE_PREEMPTION()
+
+		li		a6,1			// lock value
+		
+		lwz		a7,0(a0)		// Get lock word
+		mr.		a7,a7			// Is it held?
+		bne--	6f				// Yup...
+
+9:		lwarx	a7,0,a0			// read the lock
+		mr.		a7,a7			// Is it held?
+		bne--	7f				// yes, kill reservation
+		stwcx.	a6,0,a0			// try to get the lock
+		bne--	9b 				// failed, try again
+		li		a0,1			// return TRUE
+		isync
+		blr						// got it, return
+		
+7:		li		a7,-4			// Point to a spot in the red zone
+		stwcx.	a7,a7,r1		// Kill reservation
+
+6:
+		ENABLE_PREEMPTION()
+		li	a0,0				// return FALSE
+		blr
+		
 END(_IOTrySpinLock)
 
 #endif /* ! _IOKIT_IOSHAREDLOCKIMP_H */
diff --git a/iokit/IOKit/pwr_mgt/IOPM.h b/iokit/IOKit/pwr_mgt/IOPM.h
index 9f113545a..d873fa815 100644
--- a/iokit/IOKit/pwr_mgt/IOPM.h
+++ b/iokit/IOKit/pwr_mgt/IOPM.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/pwr_mgt/IOPMLibDefs.h b/iokit/IOKit/pwr_mgt/IOPMLibDefs.h
index a1546528c..aa88aea5d 100644
--- a/iokit/IOKit/pwr_mgt/IOPMLibDefs.h
+++ b/iokit/IOKit/pwr_mgt/IOPMLibDefs.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/pwr_mgt/IOPMPagingPlexus.h b/iokit/IOKit/pwr_mgt/IOPMPagingPlexus.h
index 0840c4c3a..f1f4e75f8 100644
--- a/iokit/IOKit/pwr_mgt/IOPMPagingPlexus.h
+++ b/iokit/IOKit/pwr_mgt/IOPMPagingPlexus.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/pwr_mgt/IOPMPowerSource.h b/iokit/IOKit/pwr_mgt/IOPMPowerSource.h
index db54beff3..4deaf8ad7 100644
--- a/iokit/IOKit/pwr_mgt/IOPMPowerSource.h
+++ b/iokit/IOKit/pwr_mgt/IOPMPowerSource.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/pwr_mgt/IOPMPowerSourceList.h b/iokit/IOKit/pwr_mgt/IOPMPowerSourceList.h
index e46736196..b2082d286 100644
--- a/iokit/IOKit/pwr_mgt/IOPMPowerSourceList.h
+++ b/iokit/IOKit/pwr_mgt/IOPMPowerSourceList.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/pwr_mgt/IOPMPrivate.h b/iokit/IOKit/pwr_mgt/IOPMPrivate.h
index 000070686..ede7da358 100644
--- a/iokit/IOKit/pwr_mgt/IOPMPrivate.h
+++ b/iokit/IOKit/pwr_mgt/IOPMPrivate.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/pwr_mgt/IOPMchangeNoteList.h b/iokit/IOKit/pwr_mgt/IOPMchangeNoteList.h
index ce8b9090e..d213b7b43 100644
--- a/iokit/IOKit/pwr_mgt/IOPMchangeNoteList.h
+++ b/iokit/IOKit/pwr_mgt/IOPMchangeNoteList.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/pwr_mgt/IOPMinformee.h b/iokit/IOKit/pwr_mgt/IOPMinformee.h
index bab21e8a3..c56a373b2 100644
--- a/iokit/IOKit/pwr_mgt/IOPMinformee.h
+++ b/iokit/IOKit/pwr_mgt/IOPMinformee.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/pwr_mgt/IOPMinformeeList.h b/iokit/IOKit/pwr_mgt/IOPMinformeeList.h
index 608a93d4a..d014d1c2e 100644
--- a/iokit/IOKit/pwr_mgt/IOPMinformeeList.h
+++ b/iokit/IOKit/pwr_mgt/IOPMinformeeList.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/pwr_mgt/IOPMlog.h b/iokit/IOKit/pwr_mgt/IOPMlog.h
index 401197aeb..afcfccb86 100644
--- a/iokit/IOKit/pwr_mgt/IOPMlog.h
+++ b/iokit/IOKit/pwr_mgt/IOPMlog.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/pwr_mgt/IOPMpmChild.h b/iokit/IOKit/pwr_mgt/IOPMpmChild.h
index 6df79af9b..3f1dc568b 100644
--- a/iokit/IOKit/pwr_mgt/IOPMpmChild.h
+++ b/iokit/IOKit/pwr_mgt/IOPMpmChild.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/pwr_mgt/IOPMpowerState.h b/iokit/IOKit/pwr_mgt/IOPMpowerState.h
index ff0c89e97..d3405b111 100644
--- a/iokit/IOKit/pwr_mgt/IOPMpowerState.h
+++ b/iokit/IOKit/pwr_mgt/IOPMpowerState.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/pwr_mgt/IOPowerConnection.h b/iokit/IOKit/pwr_mgt/IOPowerConnection.h
index c24469971..215343b30 100644
--- a/iokit/IOKit/pwr_mgt/IOPowerConnection.h
+++ b/iokit/IOKit/pwr_mgt/IOPowerConnection.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/pwr_mgt/RootDomain.h b/iokit/IOKit/pwr_mgt/RootDomain.h
index acbb27fc5..880d63bd9 100644
--- a/iokit/IOKit/pwr_mgt/RootDomain.h
+++ b/iokit/IOKit/pwr_mgt/RootDomain.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/rtc/IORTCController.h b/iokit/IOKit/rtc/IORTCController.h
index 6cbf02ef9..5ef8ee353 100644
--- a/iokit/IOKit/rtc/IORTCController.h
+++ b/iokit/IOKit/rtc/IORTCController.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/IOKit/system.h b/iokit/IOKit/system.h
index ce7ba1154..c7524f6b1 100644
--- a/iokit/IOKit/system.h
+++ b/iokit/IOKit/system.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -83,6 +86,8 @@ void panic(const char * msg, ...);
  */
 extern void invalidate_icache(vm_offset_t addr, unsigned cnt, int phys);
 extern void flush_dcache(vm_offset_t addr, unsigned count, int phys);
+extern void invalidate_icache64(addr64_t addr, unsigned cnt, int phys);
+extern void flush_dcache64(addr64_t addr, unsigned count, int phys);
 
 __END_DECLS
 
diff --git a/iokit/IOKit/system_management/IOWatchDogTimer.h b/iokit/IOKit/system_management/IOWatchDogTimer.h
index 9fc09fe98..2da29d6a3 100644
--- a/iokit/IOKit/system_management/IOWatchDogTimer.h
+++ b/iokit/IOKit/system_management/IOWatchDogTimer.h
@@ -2,21 +2,24 @@
  * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
- *
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- *
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * 
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
- *
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ * 
  * @APPLE_LICENSE_HEADER_END@
  */
 
diff --git a/iokit/Kernel/IOBufferMemoryDescriptor.cpp b/iokit/Kernel/IOBufferMemoryDescriptor.cpp
index d09defb1e..c7a521d10 100644
--- a/iokit/Kernel/IOBufferMemoryDescriptor.cpp
+++ b/iokit/Kernel/IOBufferMemoryDescriptor.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -28,9 +31,9 @@
 __BEGIN_DECLS
 void ipc_port_release_send(ipc_port_t port);
 #include <vm/pmap.h>
-__END_DECLS
 
-extern "C" vm_map_t IOPageableMapForAddress( vm_address_t address );
+vm_map_t IOPageableMapForAddress( vm_address_t address );
+__END_DECLS
 
 #define super IOGeneralMemoryDescriptor
 OSDefineMetaClassAndStructors(IOBufferMemoryDescriptor,
@@ -87,6 +90,7 @@ bool IOBufferMemoryDescriptor::initWithOptions(
 			       task_t	    inTask)
 {
     vm_map_t map = 0;
+    IOOptionBits iomdOptions = kIOMemoryAsReference | kIOMemoryTypeVirtual;
 
     if (!capacity)
         return false;
@@ -97,6 +101,9 @@ bool IOBufferMemoryDescriptor::initWithOptions(
     _physSegCount = 0;
     _buffer	  = 0;
 
+    // Grab the direction and the Auto Prepare bits from the Buffer MD options
+    iomdOptions  |= options & (kIOMemoryDirectionMask | kIOMemoryAutoPrepare);
+
     if ((options & kIOMemorySharingTypeMask) && (alignment < page_size))
         alignment = page_size;
 
@@ -106,6 +113,7 @@ bool IOBufferMemoryDescriptor::initWithOptions(
     _alignment = alignment;
     if (options & kIOMemoryPageable)
     {
+        iomdOptions |= kIOMemoryBufferPageable;
 	if (inTask == kernel_task)
 	{
 	    /* Allocate some kernel address space. */
@@ -125,19 +133,24 @@ bool IOBufferMemoryDescriptor::initWithOptions(
 	    map = get_task_map(inTask);
 	    vm_map_reference(map);
 	    reserved->map = map;
-	    kr = vm_allocate( map, (vm_address_t *) &_buffer, round_page(capacity),
+	    kr = vm_allocate( map, (vm_address_t *) &_buffer, round_page_32(capacity),
 				VM_FLAGS_ANYWHERE | VM_MAKE_TAG(VM_MEMORY_IOKIT) );
 	    if( KERN_SUCCESS != kr)
 		return( false );
 
 	    // we have to make sure that these pages don't get copied on fork.
-	    kr = vm_inherit( map, (vm_address_t) _buffer, round_page(capacity), VM_INHERIT_NONE);
+	    kr = vm_inherit( map, (vm_address_t) _buffer, round_page_32(capacity), VM_INHERIT_NONE);
 	    if( KERN_SUCCESS != kr)
 		return( false );
 	}
     }
     else 
     {
+        // @@@ gvdl: Need to remove this
+        // Buffer should never auto prepare they should be prepared explicitly
+        // But it never was enforced so what are you going to do?
+        iomdOptions |= kIOMemoryAutoPrepare;
+
 	/* Allocate a wired-down buffer inside kernel space. */
 	if (options & kIOMemoryPhysicallyContiguous)
 	    _buffer = IOMallocContiguous(capacity, alignment, 0);
@@ -153,26 +166,50 @@ bool IOBufferMemoryDescriptor::initWithOptions(
     _singleRange.v.address = (vm_address_t) _buffer;
     _singleRange.v.length  = capacity;
 
-    if (!super::initWithRanges(&_singleRange.v,	1,
-                                (IODirection) (options & kIOMemoryDirectionMask),
-                                inTask, true))
+    if (!super::initWithOptions(&_singleRange.v, 1, 0,
+                               inTask, iomdOptions, /* System mapper */ 0))
 	return false;
 
-    if (options & kIOMemoryPageable)
-    {
-        _flags |= kIOMemoryRequiresWire;
-
+    if (options & kIOMemoryPageable) {
         kern_return_t kr;
         ipc_port_t sharedMem = (ipc_port_t) _memEntry;
-        vm_size_t size = round_page(_ranges.v[0].length);
+        vm_size_t size = round_page_32(_ranges.v[0].length);
 
         // must create the entry before any pages are allocated
         if( 0 == sharedMem) {
+
+            // set memory entry cache
+            vm_prot_t memEntryCacheMode = VM_PROT_READ | VM_PROT_WRITE;
+            switch (options & kIOMapCacheMask)
+            {
+		case kIOMapInhibitCache:
+                    SET_MAP_MEM(MAP_MEM_IO, memEntryCacheMode);
+                    break;
+	
+		case kIOMapWriteThruCache:
+                    SET_MAP_MEM(MAP_MEM_WTHRU, memEntryCacheMode);
+                    break;
+
+		case kIOMapWriteCombineCache:
+                    SET_MAP_MEM(MAP_MEM_WCOMB, memEntryCacheMode);
+                    break;
+
+		case kIOMapCopybackCache:
+                    SET_MAP_MEM(MAP_MEM_COPYBACK, memEntryCacheMode);
+                    break;
+
+		case kIOMapDefaultCache:
+		default:
+                    SET_MAP_MEM(MAP_MEM_NOOP, memEntryCacheMode);
+                    break;
+            }
+
             kr = mach_make_memory_entry( map,
                         &size, _ranges.v[0].address,
-                        VM_PROT_READ | VM_PROT_WRITE, &sharedMem,
+                        memEntryCacheMode, &sharedMem,
                         NULL );
-            if( (KERN_SUCCESS == kr) && (size != round_page(_ranges.v[0].length))) {
+
+            if( (KERN_SUCCESS == kr) && (size != round_page_32(_ranges.v[0].length))) {
                 ipc_port_release_send( sharedMem );
                 kr = kIOReturnVMError;
             }
@@ -181,23 +218,6 @@ bool IOBufferMemoryDescriptor::initWithOptions(
             _memEntry = (void *) sharedMem;
         }
     }
-    else
-    {
-        /* Precompute virtual-to-physical page mappings. */
-        vm_address_t inBuffer = (vm_address_t) _buffer;
-        _physSegCount = atop(trunc_page(inBuffer + capacity - 1) -
-                            trunc_page(inBuffer)) + 1;
-        _physAddrs = IONew(IOPhysicalAddress, _physSegCount);
-        if (!_physAddrs)
-            return false;
-    
-        inBuffer = trunc_page(inBuffer);
-        for (unsigned i = 0; i < _physSegCount; i++) {
-            _physAddrs[i] = pmap_extract(get_task_pmap(kernel_task), inBuffer);
-            assert(_physAddrs[i]); /* supposed to be wired */
-            inBuffer += page_size;
-        }
-    }
 
     setLength(capacity);
     
@@ -208,7 +228,7 @@ IOBufferMemoryDescriptor * IOBufferMemoryDescriptor::inTaskWithOptions(
 					    task_t       inTask,
                                             IOOptionBits options,
                                             vm_size_t    capacity,
-                                            vm_offset_t  alignment = 1)
+                                            vm_offset_t  alignment)
 {
     IOBufferMemoryDescriptor *me = new IOBufferMemoryDescriptor;
     
@@ -230,7 +250,7 @@ bool IOBufferMemoryDescriptor::initWithOptions(
 IOBufferMemoryDescriptor * IOBufferMemoryDescriptor::withOptions(
                                             IOOptionBits options,
                                             vm_size_t    capacity,
-                                            vm_offset_t  alignment = 1)
+                                            vm_offset_t  alignment)
 {
     IOBufferMemoryDescriptor *me = new IOBufferMemoryDescriptor;
     
@@ -313,15 +333,14 @@ IOBufferMemoryDescriptor::withBytes(const void * inBytes,
  */
 void IOBufferMemoryDescriptor::free()
 {
+    // Cache all of the relevant information on the stack for use
+    // after we call super::free()!
     IOOptionBits options   = _options;
     vm_size_t    size	   = _capacity;
     void *       buffer	   = _buffer;
     vm_map_t	 map	   = 0;
     vm_offset_t  alignment = _alignment;
 
-    if (_physAddrs)
-        IODelete(_physAddrs, IOPhysicalAddress, _physSegCount);
-
     if (reserved)
     {
 	map = reserved->map;
@@ -336,7 +355,7 @@ void IOBufferMemoryDescriptor::free()
         if (options & kIOMemoryPageable)
 	{
 	    if (map)
-		vm_deallocate(map, (vm_address_t) buffer, round_page(size));
+		vm_deallocate(map, (vm_address_t) buffer, round_page_32(size));
 	    else
 	       IOFreePageable(buffer, size);
 	}
@@ -438,55 +457,6 @@ IOBufferMemoryDescriptor::getBytesNoCopy(vm_size_t start, vm_size_t withLength)
     return 0;
 }
 
-/*
- * getPhysicalSegment:
- *
- * Get the physical address of the buffer, relative to the current position.
- * If the current position is at the end of the buffer, a zero is returned.
- */
-IOPhysicalAddress
-IOBufferMemoryDescriptor::getPhysicalSegment(IOByteCount offset,
-					IOByteCount * lengthOfSegment)
-{
-    IOPhysicalAddress physAddr;
-
-    if( offset != _position)
-	setPosition( offset );
-
-    assert(_position <= _length);
-
-    /* Fail gracefully if the position is at (or past) the end-of-buffer. */
-    if (_position >= _length) {
-        *lengthOfSegment = 0;
-        return 0;
-    }
-
-    if (_options & kIOMemoryPageable) {
-        physAddr = super::getPhysicalSegment(offset, lengthOfSegment);
-
-    } else {
-        /* Compute the largest contiguous physical length possible. */
-        vm_address_t actualPos  = _singleRange.v.address + _position;
-        vm_address_t actualPage = trunc_page(actualPos);
-        unsigned     physInd    = atop(actualPage-trunc_page(_singleRange.v.address));
-    
-        vm_size_t physicalLength = actualPage + page_size - actualPos;
-        for (unsigned index = physInd + 1; index < _physSegCount &&
-            _physAddrs[index] == _physAddrs[index-1] + page_size; index++) {
-            physicalLength += page_size;
-        }
-    
-        /* Clip contiguous physical length at the end-of-buffer. */
-        if (physicalLength > _length - _position)
-            physicalLength = _length - _position;
-    
-        *lengthOfSegment = physicalLength;
-        physAddr = _physAddrs[physInd] + (actualPos - actualPage);
-    }
-
-    return physAddr;
-}
-
 OSMetaClassDefineReservedUsed(IOBufferMemoryDescriptor, 0);
 OSMetaClassDefineReservedUnused(IOBufferMemoryDescriptor, 1);
 OSMetaClassDefineReservedUnused(IOBufferMemoryDescriptor, 2);
diff --git a/iokit/Kernel/IOCPU.cpp b/iokit/Kernel/IOCPU.cpp
index 750bc5fbd..57017a819 100644
--- a/iokit/Kernel/IOCPU.cpp
+++ b/iokit/Kernel/IOCPU.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -142,7 +145,7 @@ void IOCPU::initCPUs(void)
 
 bool IOCPU::start(IOService *provider)
 {
-  OSData *busFrequency, *cpuFrequency, *decFrequency;
+  OSData *busFrequency, *cpuFrequency, *timebaseFrequency;
   
   if (!super::start(provider)) return false;
   
@@ -153,16 +156,24 @@ bool IOCPU::start(IOService *provider)
   
   gIOCPUs->setObject(this);
   
-  // Correct the bus, cpu and dec frequencies in the device tree.
-  busFrequency = OSData::withBytesNoCopy((void *)&gPEClockFrequencyInfo.bus_clock_rate_hz, 4);
-  cpuFrequency = OSData::withBytesNoCopy((void *)&gPEClockFrequencyInfo.cpu_clock_rate_hz, 4);
-  decFrequency = OSData::withBytesNoCopy((void *)&gPEClockFrequencyInfo.dec_clock_rate_hz, 4);
+  // Correct the bus, cpu and timebase frequencies in the device tree.
+  if (gPEClockFrequencyInfo.bus_frequency_hz < 0x100000000ULL) 
+    busFrequency = OSData::withBytesNoCopy((void *)((char *)&gPEClockFrequencyInfo.bus_frequency_hz + 4), 4);
+  else
+    busFrequency = OSData::withBytesNoCopy((void *)&gPEClockFrequencyInfo.bus_clock_rate_hz, 8);
   provider->setProperty("bus-frequency", busFrequency);
-  provider->setProperty("clock-frequency", cpuFrequency);
-  provider->setProperty("timebase-frequency", decFrequency);
   busFrequency->release();
+    
+  if (gPEClockFrequencyInfo.cpu_frequency_hz < 0x100000000ULL) 
+    cpuFrequency = OSData::withBytesNoCopy((void *)((char *)&gPEClockFrequencyInfo.cpu_frequency_hz + 4), 4);
+  else
+    cpuFrequency = OSData::withBytesNoCopy((void *)&gPEClockFrequencyInfo.cpu_clock_rate_hz, 8);
+  provider->setProperty("clock-frequency", cpuFrequency);
   cpuFrequency->release();
-  decFrequency->release();
+  
+  timebaseFrequency = OSData::withBytesNoCopy((void *)&gPEClockFrequencyInfo.timebase_frequency_hz, 4);
+  provider->setProperty("timebase-frequency", timebaseFrequency);
+  timebaseFrequency->release();
   
   setProperty("IOCPUID", (UInt32)this, 32);
   
@@ -301,6 +312,8 @@ IOReturn IOCPUInterruptController::initCPUInterruptController(int sources)
     }
   }
   
+  ml_init_max_cpus(numCPUs);
+  
   return kIOReturnSuccess;
 }
 
diff --git a/iokit/Kernel/IOCatalogue.cpp b/iokit/Kernel/IOCatalogue.cpp
index 14dabbd65..4c8e3b1b5 100644
--- a/iokit/Kernel/IOCatalogue.cpp
+++ b/iokit/Kernel/IOCatalogue.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Kernel/IOCommand.cpp b/iokit/Kernel/IOCommand.cpp
index f9dbc1d33..76c8a06a7 100644
--- a/iokit/Kernel/IOCommand.cpp
+++ b/iokit/Kernel/IOCommand.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Kernel/IOCommandGate.cpp b/iokit/Kernel/IOCommandGate.cpp
index 53a99baa9..73a7cc98e 100644
--- a/iokit/Kernel/IOCommandGate.cpp
+++ b/iokit/Kernel/IOCommandGate.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Kernel/IOCommandPool.cpp b/iokit/Kernel/IOCommandPool.cpp
index c50a61636..5b927cc30 100644
--- a/iokit/Kernel/IOCommandPool.cpp
+++ b/iokit/Kernel/IOCommandPool.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Kernel/IOCommandQueue.cpp b/iokit/Kernel/IOCommandQueue.cpp
index e5439a542..fe1a10eec 100644
--- a/iokit/Kernel/IOCommandQueue.cpp
+++ b/iokit/Kernel/IOCommandQueue.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Kernel/IOConditionLock.cpp b/iokit/Kernel/IOConditionLock.cpp
index f8fec3768..680f0a6af 100644
--- a/iokit/Kernel/IOConditionLock.cpp
+++ b/iokit/Kernel/IOConditionLock.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Kernel/IODataQueue.cpp b/iokit/Kernel/IODataQueue.cpp
index f2461d512..3c7c3df10 100644
--- a/iokit/Kernel/IODataQueue.cpp
+++ b/iokit/Kernel/IODataQueue.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -71,7 +74,7 @@ Boolean IODataQueue::initWithCapacity(UInt32 size)
         return false;
     }
 
-    dataQueue = (IODataQueueMemory *)IOMallocAligned(round_page(size + DATA_QUEUE_MEMORY_HEADER_SIZE), PAGE_SIZE);
+    dataQueue = (IODataQueueMemory *)IOMallocAligned(round_page_32(size + DATA_QUEUE_MEMORY_HEADER_SIZE), PAGE_SIZE);
     if (dataQueue == 0) {
         return false;
     }
@@ -91,7 +94,7 @@ Boolean IODataQueue::initWithEntries(UInt32 numEntries, UInt32 entrySize)
 void IODataQueue::free()
 {
     if (dataQueue) {
-        IOFreeAligned(dataQueue, round_page(dataQueue->queueSize + DATA_QUEUE_MEMORY_HEADER_SIZE));
+        IOFreeAligned(dataQueue, round_page_32(dataQueue->queueSize + DATA_QUEUE_MEMORY_HEADER_SIZE));
     }
 
     super::free();
diff --git a/iokit/Kernel/IODeviceMemory.cpp b/iokit/Kernel/IODeviceMemory.cpp
index d33ccf99a..dbd731921 100644
--- a/iokit/Kernel/IODeviceMemory.cpp
+++ b/iokit/Kernel/IODeviceMemory.cpp
@@ -3,29 +3,25 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
-/*
- * Copyright (c) 1998 Apple Computer, Inc.  All rights reserved. 
- *
- * HISTORY
- * 23 Nov 98 sdouglas created.
- * 30 Sep 99 sdouglas, merged IODeviceMemory into IOMemoryDescriptor.
- */
 
 #include <IOKit/IODeviceMemory.h>
 
diff --git a/iokit/Kernel/IODeviceTreeSupport.cpp b/iokit/Kernel/IODeviceTreeSupport.cpp
index 6d9eb7f61..9aa3b9457 100644
--- a/iokit/Kernel/IODeviceTreeSupport.cpp
+++ b/iokit/Kernel/IODeviceTreeSupport.cpp
@@ -3,29 +3,27 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
 /*
  * Copyright (c) 1998 Apple Computer, Inc.  All rights reserved. 
- *
- * HISTORY
- * 23 Nov 98 sdouglas, created from IODeviceTreeBus.m, & MacOS exp mgr.
- * 05 Apr 99 sdouglas, add interrupt mapping.
- *
  */
 
 #include <IOKit/IODeviceTreeSupport.h>
@@ -193,7 +191,7 @@ IODeviceTreeAlloc( void * dtTop )
         // free original device tree
         DTInit(0);
         IODTFreeLoaderInfo( "DeviceTree",
-			(void *)dtMap[0], round_page(dtMap[1]) );
+			(void *)dtMap[0], round_page_32(dtMap[1]) );
     }
 
     // adjust tree
diff --git a/iokit/Kernel/IOEventSource.cpp b/iokit/Kernel/IOEventSource.cpp
index 44bdcf52e..6ddbac302 100644
--- a/iokit/Kernel/IOEventSource.cpp
+++ b/iokit/Kernel/IOEventSource.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Kernel/IOFilterInterruptEventSource.cpp b/iokit/Kernel/IOFilterInterruptEventSource.cpp
index 0869ec7de..708b9c90c 100644
--- a/iokit/Kernel/IOFilterInterruptEventSource.cpp
+++ b/iokit/Kernel/IOFilterInterruptEventSource.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Kernel/IOInterruptController.cpp b/iokit/Kernel/IOInterruptController.cpp
index bd3baa04d..1bef319c7 100644
--- a/iokit/Kernel/IOInterruptController.cpp
+++ b/iokit/Kernel/IOInterruptController.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -96,10 +99,10 @@ IOReturn IOInterruptController::registerInterrupt(IOService *nub, int source,
       originalNub = vector->nub;
       originalSource = vector->source;
       
-      // Save the dis/enable state for the original consumer's interrupt.
-      // Then disable the source
-      wasDisabledSoft = vector->interruptDisabledSoft;
-      disableInterrupt(originalNub, originalSource);
+      // Physically disable the interrupt, but mark it as being enables in the hardware.
+      // The interruptDisabledSoft now indicates the driver's request for enablement.
+      disableVectorHard(vectorNumber, vector);
+      vector->interruptDisabledHard = 0;
       
       // Initialize the new shared interrupt controller.
       error = vector->sharedController->initInterruptController(this,
@@ -125,7 +128,17 @@ IOReturn IOInterruptController::registerInterrupt(IOService *nub, int source,
       // put the original consumor's interrupt back to normal and
       // get rid of whats left of the shared controller.
       if (error != kIOReturnSuccess) {
+	// Save the driver's interrupt enablement state.
+	wasDisabledSoft = vector->interruptDisabledSoft;
+	
+	// Make the interrupt really hard disabled.
+	vector->interruptDisabledSoft = 1;
+	vector->interruptDisabledHard = 1;
+	
+	// Enable the original consumer's interrupt if needed.
+	if (!wasDisabledSoft) originalNub->enableInterrupt(originalSource);
         enableInterrupt(originalNub, originalSource);
+	
         vector->sharedController->release();
         vector->sharedController = 0;
         IOUnlock(vector->interruptLock);
@@ -139,6 +152,13 @@ IOReturn IOInterruptController::registerInterrupt(IOService *nub, int source,
       vector->target  = vector->sharedController;
       vector->refCon  = 0;
       
+      // Save the driver's interrupt enablement state.
+      wasDisabledSoft = vector->interruptDisabledSoft;
+      
+      // Make the interrupt really hard disabled.
+      vector->interruptDisabledSoft = 1;
+      vector->interruptDisabledHard = 1;
+      
       // Enable the original consumer's interrupt if needed.
       if (!wasDisabledSoft) originalNub->enableInterrupt(originalSource);
     }
@@ -399,7 +419,7 @@ IOReturn IOSharedInterruptController::initInterruptController(IOInterruptControl
   }
   
   // Allocate the memory for the vectors
-  numVectors = 8; // For now a constant number.
+  numVectors = 32; // For now a constant number.
   vectors = (IOInterruptVector *)IOMalloc(numVectors * sizeof(IOInterruptVector));
   if (vectors == NULL) {
     IOFree(_interruptSources, sizeof(IOInterruptSource));
diff --git a/iokit/Kernel/IOInterruptEventSource.cpp b/iokit/Kernel/IOInterruptEventSource.cpp
index a6b0034f4..cbdd0aa6a 100644
--- a/iokit/Kernel/IOInterruptEventSource.cpp
+++ b/iokit/Kernel/IOInterruptEventSource.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Kernel/IOKitDebug.cpp b/iokit/Kernel/IOKitDebug.cpp
index b694bcbb3..970a4bd2a 100644
--- a/iokit/Kernel/IOKitDebug.cpp
+++ b/iokit/Kernel/IOKitDebug.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -81,6 +84,61 @@ void IOPrintPlane( const IORegistryPlane * plane )
     iter->release();
 }
 
+void dbugprintf(char *fmt, ...);
+void db_dumpiojunk( const IORegistryPlane * plane );
+
+void db_piokjunk(void) {
+
+	dbugprintf("\nDT plane:\n");
+	db_dumpiojunk( gIODTPlane );
+	dbugprintf("\n\nService plane:\n");
+	db_dumpiojunk( gIOServicePlane );
+    dbugprintf("\n\n"
+	    "ivar kalloc()       0x%08x\n"
+	    "malloc()            0x%08x\n"
+            "containers kalloc() 0x%08x\n"
+	    "IOMalloc()          0x%08x\n"
+            "----------------------------------------\n",
+	    debug_ivars_size,
+            debug_malloc_size,
+            debug_container_malloc_size,
+            debug_iomalloc_size
+            );
+
+}
+
+
+void db_dumpiojunk( const IORegistryPlane * plane )
+{
+    IORegistryEntry *		next;
+    IORegistryIterator * 	iter;
+    OSOrderedSet *		all;
+    char			format[] = "%xxxs";
+    IOService *			service;
+
+    iter = IORegistryIterator::iterateOver( plane );
+
+    all = iter->iterateAll();
+    if( all) {
+        dbugprintf("Count %d\n", all->getCount() );
+        all->release();
+    } else dbugprintf("Empty\n");
+
+    iter->reset();
+    while( (next = iter->getNextObjectRecursive())) {
+		sprintf( format + 1, "%ds", 2 * next->getDepth( plane ));
+		dbugprintf( format, "");
+		dbugprintf( "%s", next->getName( plane ));
+		if( (next->getLocation( plane )))
+				dbugprintf("@%s", next->getLocation( plane ));
+		dbugprintf(" <class %s", next->getMetaClass()->getClassName());
+			if( (service = OSDynamicCast(IOService, next)))
+				dbugprintf(", busy %ld", service->getBusyState());
+		dbugprintf( ">\n");
+    }
+    iter->release();
+}
+
 void IOPrintMemory( void )
 {
 
diff --git a/iokit/Kernel/IOLib.c b/iokit/Kernel/IOLib.c
index 4eb08077e..f89aa4fbb 100644
--- a/iokit/Kernel/IOLib.c
+++ b/iokit/Kernel/IOLib.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -36,10 +39,14 @@
 
 #include <IOKit/IOReturn.h>
 #include <IOKit/IOLib.h> 
+#include <IOKit/IOMapper.h>
 #include <IOKit/IOKitDebug.h> 
 
 mach_timespec_t IOZeroTvalspec = { 0, 0 };
 
+extern ppnum_t pmap_find_phys(pmap_t pmap, addr64_t va);
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
 
 /*
  * Global variables for use by iLogger
@@ -58,9 +65,11 @@ void *_giDebugReserved2		= NULL;
  */
 
 static IOThreadFunc threadArgFcn;
-static void * threadArgArg;
-static lock_t * threadArgLock;
+static void *       threadArgArg;
+static lock_t *     threadArgLock;
 
+static queue_head_t gIOMallocContiguousEntries;
+static mutex_t *    gIOMallocContiguousEntriesLock;
 
 enum { kIOMaxPageableMaps = 16 };
 enum { kIOPageableMapSize = 16 * 1024 * 1024 };
@@ -79,6 +88,7 @@ static struct {
     mutex_t *	lock;
 } gIOKitPageableSpace;
 
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
 
 void IOLibInit(void)
 {
@@ -106,6 +116,9 @@ void IOLibInit(void)
     gIOKitPageableSpace.hint		= 0;
     gIOKitPageableSpace.count		= 1;
 
+    gIOMallocContiguousEntriesLock 	= mutex_alloc( 0 );
+    queue_init( &gIOMallocContiguousEntries );
+
     libInitialized = true;
 }
 
@@ -272,6 +285,14 @@ void IOFreeAligned(void * address, vm_size_t size)
 
 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
 
+struct _IOMallocContiguousEntry
+{
+    void *		virtual;
+    ppnum_t		ioBase;
+    queue_chain_t	link;
+};
+typedef struct _IOMallocContiguousEntry _IOMallocContiguousEntry;
+
 void * IOMallocContiguous(vm_size_t size, vm_size_t alignment,
 			   IOPhysicalAddress * physicalAddress)
 {
@@ -280,6 +301,7 @@ void * IOMallocContiguous(vm_size_t size, vm_size_t alignment,
     vm_address_t	allocationAddress;
     vm_size_t		adjustedSize;
     vm_offset_t		alignMask;
+    ppnum_t		pagenum;
 
     if (size == 0)
         return 0;
@@ -289,15 +311,24 @@ void * IOMallocContiguous(vm_size_t size, vm_size_t alignment,
     alignMask = alignment - 1;
     adjustedSize = (2 * size) + sizeof(vm_size_t) + sizeof(vm_address_t);
 
-    if (adjustedSize >= page_size) {
-
-        kr = kmem_alloc_contig(kernel_map, &address, size,
-				alignMask, 0);
+    if (adjustedSize >= page_size)
+    {
+	adjustedSize = size;
+	if (adjustedSize > page_size)
+	{
+	    kr = kmem_alloc_contig(kernel_map, &address, size,
+				    alignMask, 0);
+	}
+	else
+	{
+	    kr = kernel_memory_allocate(kernel_map, &address,
+					size, alignMask, 0);
+	}
 	if (KERN_SUCCESS != kr)
 	    address = 0;
-
-    } else {
-
+    }
+    else
+    {
 	adjustedSize += alignMask;
         allocationAddress = (vm_address_t) kalloc(adjustedSize);
 
@@ -307,8 +338,8 @@ void * IOMallocContiguous(vm_size_t size, vm_size_t alignment,
                     + (sizeof(vm_size_t) + sizeof(vm_address_t)))
                     & (~alignMask);
 
-            if (atop(address) != atop(address + size - 1))
-                address = round_page(address);
+            if (atop_32(address) != atop_32(address + size - 1))
+                address = round_page_32(address);
 
             *((vm_size_t *)(address - sizeof(vm_size_t)
                             - sizeof(vm_address_t))) = adjustedSize;
@@ -318,9 +349,49 @@ void * IOMallocContiguous(vm_size_t size, vm_size_t alignment,
 	    address = 0;
     }
 
-    if( address && physicalAddress)
-	*physicalAddress = (IOPhysicalAddress) pmap_extract( kernel_pmap,
-								 address );
+    /* Do we want a physical address? */
+    if (address && physicalAddress)
+    {
+	do
+	{
+	    /* Get the physical page */
+	    pagenum = pmap_find_phys(kernel_pmap, (addr64_t) address);
+	    if(pagenum)
+	    {
+		IOByteCount offset;
+		ppnum_t base;
+    
+		base = IOMapperIOVMAlloc((size + PAGE_MASK) >> PAGE_SHIFT);
+		if (base)
+		{
+		    _IOMallocContiguousEntry *
+		    entry = IONew(_IOMallocContiguousEntry, 1);
+		    if (!entry)
+		    {
+			IOFreeContiguous((void *) address, size);
+			address = 0;
+			break;
+		    }
+		    entry->virtual = (void *) address;
+		    entry->ioBase  = base;
+		    mutex_lock(gIOMallocContiguousEntriesLock);
+		    queue_enter( &gIOMallocContiguousEntries, entry, 
+				_IOMallocContiguousEntry *, link );
+		    mutex_unlock(gIOMallocContiguousEntriesLock);
+    
+		    *physicalAddress = (IOPhysicalAddress)((base << PAGE_SHIFT) | (address & PAGE_MASK));
+		    for (offset = 0; offset < ((size + PAGE_MASK) >> PAGE_SHIFT); offset++, pagenum++)
+			IOMapperInsertPage( base, offset, pagenum );
+		}
+		else
+		    *physicalAddress = (IOPhysicalAddress)((pagenum << PAGE_SHIFT) | (address & PAGE_MASK));
+	    } 
+	    else
+		/* Did not find, return 0 */
+		*physicalAddress = (IOPhysicalAddress) 0;
+	}
+	while (false);
+    }
 
     assert(0 == (address & alignMask));
 
@@ -334,14 +405,35 @@ void * IOMallocContiguous(vm_size_t size, vm_size_t alignment,
 
 void IOFreeContiguous(void * address, vm_size_t size)
 {
-    vm_address_t	allocationAddress;
-    vm_size_t		adjustedSize;
+    vm_address_t	       allocationAddress;
+    vm_size_t		       adjustedSize;
+    _IOMallocContiguousEntry * entry;
+    ppnum_t		       base = 0;
 
     if( !address)
 	return;
 
     assert(size);
 
+    mutex_lock(gIOMallocContiguousEntriesLock);
+    queue_iterate( &gIOMallocContiguousEntries, entry,
+		    _IOMallocContiguousEntry *, link )
+    {
+	if( entry->virtual == address ) {
+	    base = entry->ioBase;
+	    queue_remove( &gIOMallocContiguousEntries, entry,
+			    _IOMallocContiguousEntry *, link );
+	    break;
+	}
+    }
+    mutex_unlock(gIOMallocContiguousEntriesLock);
+
+    if (base)
+    {
+	IOMapperIOVMFree(base, (size + PAGE_MASK) >> PAGE_SHIFT);
+	IODelete(entry, _IOMallocContiguousEntry, 1);
+    }
+
     adjustedSize = (2 * size) + sizeof(vm_size_t) + sizeof(vm_address_t);
     if (adjustedSize >= page_size) {
 
@@ -466,7 +558,7 @@ void * IOMallocPageable(vm_size_t size, vm_size_t alignment)
 
 #if IOALLOCDEBUG
     if( ref.address)
-       debug_iomalloc_size += round_page(size);
+       debug_iomalloc_size += round_page_32(size);
 #endif
 
     return( (void *) ref.address );
@@ -499,7 +591,7 @@ void IOFreePageable(void * address, vm_size_t size)
         kmem_free( map, (vm_offset_t) address, size);
 
 #if IOALLOCDEBUG
-    debug_iomalloc_size -= round_page(size);
+    debug_iomalloc_size -= round_page_32(size);
 #endif
 }
 
@@ -507,30 +599,34 @@ void IOFreePageable(void * address, vm_size_t size)
 
 extern kern_return_t IOMapPages(vm_map_t map, vm_offset_t va, vm_offset_t pa,
 			vm_size_t length, unsigned int options);
+extern kern_return_t IOUnmapPages(vm_map_t map, vm_offset_t va, vm_size_t length);
 
 IOReturn IOSetProcessorCacheMode( task_t task, IOVirtualAddress address,
 				  IOByteCount length, IOOptionBits cacheMode )
 {
     IOReturn	ret = kIOReturnSuccess;
-    vm_offset_t	physAddr;
+    ppnum_t	pagenum;
 
     if( task != kernel_task)
 	return( kIOReturnUnsupported );
 
-    length = round_page(address + length) - trunc_page( address );
-    address = trunc_page( address );
+    length = round_page_32(address + length) - trunc_page_32( address );
+    address = trunc_page_32( address );
 
     // make map mode
     cacheMode = (cacheMode << kIOMapCacheShift) & kIOMapCacheMask;
 
     while( (kIOReturnSuccess == ret) && (length > 0) ) {
 
-	physAddr = pmap_extract( kernel_pmap, address );
-	if( physAddr)
-            ret = IOMapPages( get_task_map(task), address, physAddr, page_size, cacheMode );
-	else
+	// Get the physical page number
+	pagenum = pmap_find_phys(kernel_pmap, (addr64_t)address);
+	if( pagenum) {
+            ret = IOUnmapPages( get_task_map(task), address, page_size );
+	    ret = IOMapPages( get_task_map(task), address, pagenum << PAGE_SHIFT, page_size, cacheMode );
+	} else
 	    ret = kIOReturnVMError;
 
+	address += page_size;
 	length -= page_size;
     }
 
@@ -545,7 +641,7 @@ IOReturn IOFlushProcessorCache( task_t task, IOVirtualAddress address,
 	return( kIOReturnUnsupported );
 
 #if __ppc__
-    flush_dcache( (vm_offset_t) address, (unsigned) length, false );
+    flush_dcache64( (addr64_t) address, (unsigned) length, false );
 #endif
 
     return( kIOReturnSuccess );
diff --git a/iokit/Kernel/IOLocks.cpp b/iokit/Kernel/IOLocks.cpp
index 43884bfb3..56ea0e40a 100644
--- a/iokit/Kernel/IOLocks.cpp
+++ b/iokit/Kernel/IOLocks.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Kernel/IOMapper.cpp b/iokit/Kernel/IOMapper.cpp
new file mode 100644
index 000000000..c1795da6c
--- /dev/null
+++ b/iokit/Kernel/IOMapper.cpp
@@ -0,0 +1,389 @@
+/*
+ * Copyright (c) 1998-2003 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ * 
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ * 
+ * @APPLE_LICENSE_HEADER_END@
+ */
+#include <IOKit/IOLib.h>
+#include <IOKit/IOMapper.h>
+#include <libkern/c++/OSData.h>
+
+#define super IOService
+OSDefineMetaClassAndAbstractStructors(IOMapper, IOService);
+
+OSMetaClassDefineReservedUnused(IOMapper, 0);
+OSMetaClassDefineReservedUnused(IOMapper, 1);
+OSMetaClassDefineReservedUnused(IOMapper, 2);
+OSMetaClassDefineReservedUnused(IOMapper, 3);
+OSMetaClassDefineReservedUnused(IOMapper, 4);
+OSMetaClassDefineReservedUnused(IOMapper, 5);
+OSMetaClassDefineReservedUnused(IOMapper, 6);
+OSMetaClassDefineReservedUnused(IOMapper, 7);
+OSMetaClassDefineReservedUnused(IOMapper, 8);
+OSMetaClassDefineReservedUnused(IOMapper, 9);
+OSMetaClassDefineReservedUnused(IOMapper, 10);
+OSMetaClassDefineReservedUnused(IOMapper, 11);
+OSMetaClassDefineReservedUnused(IOMapper, 12);
+OSMetaClassDefineReservedUnused(IOMapper, 13);
+OSMetaClassDefineReservedUnused(IOMapper, 14);
+OSMetaClassDefineReservedUnused(IOMapper, 15);
+
+IOMapper * IOMapper::gSystem = (IOMapper *) IOMapper::kUnknown;
+
+class IOMapperLock {
+    IOLock *fWaitLock;
+public:
+    IOMapperLock() { fWaitLock = IOLockAlloc(); };
+    ~IOMapperLock() { IOLockFree(fWaitLock); };
+
+    void lock()   { IOLockLock(fWaitLock); };
+    void unlock() { IOLockUnlock(fWaitLock); };
+    void sleep(void *event)  { IOLockSleep(fWaitLock, event, THREAD_UNINT); };
+    void wakeup(void *event) { IOLockWakeup(fWaitLock, event, false); };
+};
+
+static IOMapperLock sMapperLock;
+
+bool IOMapper::start(IOService *provider)
+{
+    if (!super::start(provider))
+        return false;
+
+    if (!initHardware(provider))
+        return false;
+
+    if (fIsSystem) { 
+        sMapperLock.lock();
+        IOMapper::gSystem = this;
+        sMapperLock.wakeup(&IOMapper::gSystem);
+        sMapperLock.unlock();
+    }
+
+    return true;
+}
+
+bool IOMapper::allocTable(IOByteCount size)
+{
+    assert(!fTable);
+
+    fTableSize = size;
+    fTableHandle = NewARTTable(size, &fTable, &fTablePhys);
+    return fTableHandle != 0;
+}
+
+void IOMapper::free()
+{
+    if (fTableHandle) {
+        FreeARTTable(fTableHandle, fTableSize);
+        fTableHandle = 0;
+    }
+
+    super::free();
+}
+
+void IOMapper::setMapperRequired(bool hasMapper)
+{
+    if (hasMapper)
+        IOMapper::gSystem = (IOMapper *) kHasMapper;
+    else {
+        sMapperLock.lock();
+        IOMapper::gSystem = (IOMapper *) kNoMapper;
+        sMapperLock.unlock();
+        sMapperLock.wakeup(&IOMapper::gSystem);
+    }
+}
+
+void IOMapper::waitForSystemMapper()
+{
+    sMapperLock.lock();
+    while ((vm_address_t) IOMapper::gSystem & kWaitMask)
+        sMapperLock.sleep(&IOMapper::gSystem);
+    sMapperLock.unlock();
+}
+
+void IOMapper::iovmInsert(ppnum_t addr, IOItemCount offset,
+                            ppnum_t *pageList, IOItemCount pageCount)
+{
+    while (pageCount--)
+        iovmInsert(addr, offset++, *pageList++);
+}
+
+void IOMapper::iovmInsert(ppnum_t addr, IOItemCount offset,
+                            upl_page_info_t *pageList, IOItemCount pageCount)
+{
+    for (IOItemCount i = 0; i < pageCount; i++)
+        iovmInsert(addr, offset + i, pageList[i].phys_addr);
+}
+
+struct ARTTableData {
+    void *v;
+    upl_t u[0];
+};
+#define getARTDataP(data) ((ARTTableData *) (data)->getBytesNoCopy())
+
+OSData *
+IOMapper::NewARTTable(IOByteCount size,
+                      void ** virtAddrP, ppnum_t *physAddrP)
+{
+    OSData *ret;
+    kern_return_t kr;
+    vm_address_t startUpl;
+    ARTTableData *dataP;
+    unsigned int dataSize;
+    upl_page_info_t *pl = 0;
+
+    // Each UPL can deal with about one meg at the moment
+    size = round_page_32(size);
+    dataSize = sizeof(ARTTableData) + sizeof(upl_t) * size / (1024 * 1024);
+    ret = OSData::withCapacity(dataSize);
+    if (!ret)
+        return 0;
+
+    // Append 0's to the buffer, in-other-words reset to nulls.
+    ret->appendBytes(NULL, sizeof(ARTTableData));
+    dataP = getARTDataP(ret);
+
+    kr = kmem_alloc_contig(kernel_map, &startUpl, size, PAGE_MASK, 0);
+    if (kr)
+        return 0;
+
+    dataP->v = (void *) startUpl;
+
+    do {
+        upl_t iopl;
+        int upl_flags = UPL_SET_INTERNAL | UPL_SET_LITE
+                      | UPL_SET_IO_WIRE | UPL_COPYOUT_FROM;
+        vm_size_t iopl_size = size;
+
+        kr = vm_map_get_upl(kernel_map,
+                            startUpl,
+                            &iopl_size,
+                            &iopl,
+                            0,
+                            0,
+                            &upl_flags,
+                            0);
+        if (kr) {
+            panic("IOMapper:vm_map_get_upl returned 0x%x\n");
+            goto bail;
+        }
+
+        if (!ret->appendBytes(&iopl, sizeof(upl_t)))
+            goto bail;
+            
+        startUpl += iopl_size;
+        size -= iopl_size;
+    } while(size);
+
+    // Need to re-establish the dataP as the OSData may have grown.
+    dataP = getARTDataP(ret);
+
+    // Now grab the page entry of the first page and get its phys addr
+    pl = UPL_GET_INTERNAL_PAGE_LIST(dataP->u[0]);
+    *physAddrP = pl->phys_addr;
+    *virtAddrP = dataP->v;
+
+    return ret;
+
+bail:
+    FreeARTTable(ret, size);
+    return 0;
+}
+
+void IOMapper::FreeARTTable(OSData *artHandle, IOByteCount size)
+{
+    assert(artHandle);
+
+    ARTTableData *dataP = getARTDataP(artHandle);
+
+    int numupls = ((artHandle->getLength() - sizeof(*dataP)) / sizeof(upl_t));
+    for (int i = 0; i < numupls; i++)
+        kernel_upl_abort(dataP->u[i], 0);
+
+    if (dataP->v) {
+        size = round_page_32(size);
+        kmem_free(kernel_map, (vm_address_t) dataP->v, size);
+    }
+    artHandle->release();
+}
+
+__BEGIN_DECLS
+
+// These are C accessors to the system mapper for non-IOKit clients
+ppnum_t IOMapperIOVMAlloc(unsigned pages)
+{
+    IOMapper::checkForSystemMapper();
+
+    if (IOMapper::gSystem)
+        return IOMapper::gSystem->iovmAlloc((IOItemCount) pages);
+    else
+        return 0;
+}
+
+void IOMapperIOVMFree(ppnum_t addr, unsigned pages)
+{
+    if (IOMapper::gSystem)
+        IOMapper::gSystem->iovmFree(addr, (IOItemCount) pages);
+}
+
+ppnum_t IOMapperInsertPage(ppnum_t addr, unsigned offset, ppnum_t page)
+{
+    if (IOMapper::gSystem) {
+        IOMapper::gSystem->iovmInsert(addr, (IOItemCount) offset, page);
+        return addr + offset;
+    }
+    else
+        return page;
+}
+
+void IOMapperInsertPPNPages(ppnum_t addr, unsigned offset,
+                            ppnum_t *pageList, unsigned pageCount)
+{
+    if (!IOMapper::gSystem)
+        panic("IOMapperInsertPPNPages no system mapper");
+    else
+        assert(!((vm_address_t) IOMapper::gSystem & 3));
+
+    IOMapper::gSystem->
+        iovmInsert(addr, (IOItemCount) offset, pageList, pageCount);
+}
+
+void IOMapperInsertUPLPages(ppnum_t addr, unsigned offset,
+                            upl_page_info_t *pageList, unsigned pageCount)
+{
+    if (!IOMapper::gSystem)
+        panic("IOMapperInsertUPLPages no system mapper");
+    else
+        assert(!((vm_address_t) IOMapper::gSystem & 3));
+
+    IOMapper::gSystem->iovmInsert(addr,
+                                 (IOItemCount) offset,
+                                  pageList,
+                                  (IOItemCount) pageCount);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//
+//	IOLib.h APIs
+//
+//
+/////////////////////////////////////////////////////////////////////////////
+
+#include <machine/machine_routines.h>
+
+UInt8 IOMappedRead8(IOPhysicalAddress address)
+{
+    IOMapper::checkForSystemMapper();
+
+    if (IOMapper::gSystem) {
+        addr64_t addr = IOMapper::gSystem->mapAddr(address);
+        return (UInt8) ml_phys_read_byte_64(addr);
+    }
+    else
+        return (UInt8) ml_phys_read_byte((vm_offset_t) address);
+}
+
+UInt16 IOMappedRead16(IOPhysicalAddress address)
+{
+    IOMapper::checkForSystemMapper();
+
+    if (IOMapper::gSystem) {
+        addr64_t addr = IOMapper::gSystem->mapAddr(address);
+        return (UInt16) ml_phys_read_half_64(addr);
+    }
+    else
+        return (UInt16) ml_phys_read_half((vm_offset_t) address);
+}
+
+UInt32 IOMappedRead32(IOPhysicalAddress address)
+{
+    IOMapper::checkForSystemMapper();
+
+    if (IOMapper::gSystem) {
+        addr64_t addr = IOMapper::gSystem->mapAddr(address);
+	return (UInt32) ml_phys_read_word_64(addr);
+    }
+    else
+        return (UInt32) ml_phys_read_word((vm_offset_t) address);
+}
+
+UInt64 IOMappedRead64(IOPhysicalAddress address)
+{
+    IOMapper::checkForSystemMapper();
+
+    if (IOMapper::gSystem) {
+        addr64_t addr = IOMapper::gSystem->mapAddr(address);
+        return (UInt64) ml_phys_read_double_64(addr);
+    }
+    else
+        return (UInt64) ml_phys_read_double((vm_offset_t) address);
+}
+
+void IOMappedWrite8(IOPhysicalAddress address, UInt8 value)
+{
+    IOMapper::checkForSystemMapper();
+
+    if (IOMapper::gSystem) {
+        addr64_t addr = IOMapper::gSystem->mapAddr(address);
+        ml_phys_write_byte_64(addr, value);
+    }
+    else
+        ml_phys_write_byte((vm_offset_t) address, value);
+}
+
+void IOMappedWrite16(IOPhysicalAddress address, UInt16 value)
+{
+    IOMapper::checkForSystemMapper();
+
+    if (IOMapper::gSystem) {
+        addr64_t addr = IOMapper::gSystem->mapAddr(address);
+        ml_phys_write_half_64(addr, value);
+    }
+    else
+        ml_phys_write_half((vm_offset_t) address, value);
+}
+
+void IOMappedWrite32(IOPhysicalAddress address, UInt32 value)
+{
+    IOMapper::checkForSystemMapper();
+
+    if (IOMapper::gSystem) {
+        addr64_t addr = IOMapper::gSystem->mapAddr(address);
+        ml_phys_write_word_64(addr, value);
+    }
+    else
+        ml_phys_write_word((vm_offset_t) address, value);
+}
+
+void IOMappedWrite64(IOPhysicalAddress address, UInt64 value)
+{
+    IOMapper::checkForSystemMapper();
+
+    if (IOMapper::gSystem) {
+        addr64_t addr = IOMapper::gSystem->mapAddr(address);
+        ml_phys_write_double_64(addr, value);
+    }
+    else
+        ml_phys_write_double((vm_offset_t) address, value);
+}
+
+__END_DECLS
diff --git a/iokit/Kernel/IOMemoryCursor.cpp b/iokit/Kernel/IOMemoryCursor.cpp
index b0da5f75a..2125a5f67 100644
--- a/iokit/Kernel/IOMemoryCursor.cpp
+++ b/iokit/Kernel/IOMemoryCursor.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -61,6 +64,18 @@ IOMemoryCursor::initWithSpecification(SegmentFunction  inSegFunc,
                                       IOPhysicalLength inMaxTransferSize,
                                       IOPhysicalLength inAlignment)
 {
+// @@@ gvdl: Remove me
+#if 1
+static UInt sMaxDBDMASegment;
+if (!sMaxDBDMASegment) {
+    sMaxDBDMASegment = (UInt) -1;
+    if (PE_parse_boot_arg("mseg", &sMaxDBDMASegment))
+        IOLog("Setting MaxDBDMASegment to %d\n", sMaxDBDMASegment);
+}
+
+if (inMaxSegmentSize > sMaxDBDMASegment) inMaxSegmentSize = sMaxDBDMASegment;
+#endif
+
     if (!super::init())
         return false;
 
diff --git a/iokit/Kernel/IOMemoryDescriptor.cpp b/iokit/Kernel/IOMemoryDescriptor.cpp
index 20b05f3e1..12ace713b 100644
--- a/iokit/Kernel/IOMemoryDescriptor.cpp
+++ b/iokit/Kernel/IOMemoryDescriptor.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -25,11 +28,14 @@
  * HISTORY
  *
  */
+// 45678901234567890123456789012345678901234567890123456789012345678901234567890
+#include <sys/cdefs.h>
 
 #include <IOKit/assert.h>
 #include <IOKit/system.h>
 #include <IOKit/IOLib.h>
 #include <IOKit/IOMemoryDescriptor.h>
+#include <IOKit/IOMapper.h>
 
 #include <IOKit/IOKitDebug.h>
 
@@ -42,15 +48,16 @@
 
 __BEGIN_DECLS
 #include <vm/pmap.h>
+#include <mach/memory_object_types.h>
 #include <device/device_port.h>
-void bcopy_phys(char *from, char *to, int size);
-void pmap_enter(pmap_t pmap, vm_offset_t va, vm_offset_t pa,
-                vm_prot_t prot, unsigned int flags, boolean_t wired);
+
 #ifndef i386
-struct phys_entry      *pmap_find_physentry(vm_offset_t pa);
+struct phys_entry      *pmap_find_physentry(ppnum_t pa);
 #endif
 void ipc_port_release_send(ipc_port_t port);
-vm_offset_t vm_map_get_phys_page(vm_map_t map, vm_offset_t offset);
+
+/* Copy between a physical page and a virtual address in the given vm_map */
+kern_return_t copypv(addr64_t source, addr64_t sink, unsigned int size, int which);
 
 memory_object_t
 device_pager_setup(
@@ -65,7 +72,7 @@ kern_return_t
 device_pager_populate_object(
 	memory_object_t		pager,
 	vm_object_offset_t	offset,
-	vm_offset_t		phys_addr,
+	ppnum_t			phys_addr,
 	vm_size_t		size);
 
 /*
@@ -80,8 +87,18 @@ extern kern_return_t vm_fault(
 		pmap_t		caller_pmap,
 		vm_offset_t	caller_pmap_addr);
 
+unsigned int  IOTranslateCacheBits(struct phys_entry *pp);
+
+vm_map_t IOPageableMapForAddress( vm_address_t address );
+
+typedef kern_return_t (*IOIteratePageableMapsCallback)(vm_map_t map, void * ref);
+
+kern_return_t IOIteratePageableMaps(vm_size_t size,
+                    IOIteratePageableMapsCallback callback, void * ref);
 __END_DECLS
 
+static IOMapper * gIOSystemMapper;
+
 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
 
 OSDefineMetaClassAndAbstractStructors( IOMemoryDescriptor, OSObject )
@@ -90,17 +107,6 @@ OSDefineMetaClassAndAbstractStructors( IOMemoryDescriptor, OSObject )
 
 OSDefineMetaClassAndStructors(IOGeneralMemoryDescriptor, IOMemoryDescriptor)
 
-extern "C" {
-
-vm_map_t IOPageableMapForAddress( vm_address_t address );
-
-typedef kern_return_t (*IOIteratePageableMapsCallback)(vm_map_t map, void * ref);
-
-kern_return_t IOIteratePageableMaps(vm_size_t size,
-                    IOIteratePageableMapsCallback callback, void * ref);
-
-}
-
 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
 
 static IORecursiveLock * gIOMemoryLock;
@@ -113,37 +119,7 @@ static IORecursiveLock * gIOMemoryLock;
 
 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
 
-inline vm_map_t IOGeneralMemoryDescriptor::getMapForTask( task_t task, vm_address_t address )
-{
-    if( (task == kernel_task) && (kIOMemoryRequiresWire & _flags))
-        return( IOPageableMapForAddress( address ) );
-    else
-        return( get_task_map( task ));
-}
-
-inline vm_offset_t pmap_extract_safe(task_t task, vm_offset_t va)
-{
-    vm_offset_t pa = pmap_extract(get_task_pmap(task), va);
-
-    if ( pa == 0 )
-    {
-        pa = vm_map_get_phys_page(get_task_map(task), trunc_page(va));
-        if ( pa )  pa += va - trunc_page(va);
-    }
-
-    return pa;
-}
-
-inline void bcopy_phys_safe(char * from, char * to, int size)
-{
-    boolean_t enabled = ml_set_interrupts_enabled(FALSE);
-
-    bcopy_phys(from, to, size);
-
-    ml_set_interrupts_enabled(enabled);
-}
-
-#define next_page(a) ( trunc_page(a) + page_size )
+#define next_page(a) ( trunc_page_32(a) + PAGE_SIZE )
 
 
 extern "C" {
@@ -206,13 +182,23 @@ kern_return_t device_close(
  */
 IOMemoryDescriptor *
 IOMemoryDescriptor::withAddress(void *      address,
-                                IOByteCount   withLength,
-                                IODirection withDirection)
+                                IOByteCount   length,
+                                IODirection direction)
+{
+    return IOMemoryDescriptor::
+        withAddress((vm_address_t) address, length, direction, kernel_task);
+}
+
+IOMemoryDescriptor *
+IOMemoryDescriptor::withAddress(vm_address_t address,
+                                IOByteCount  length,
+                                IODirection  direction,
+                                task_t       task)
 {
     IOGeneralMemoryDescriptor * that = new IOGeneralMemoryDescriptor;
     if (that)
     {
-	if (that->initWithAddress(address, withLength, withDirection))
+	if (that->initWithAddress(address, length, direction, task))
 	    return that;
 
         that->release();
@@ -221,15 +207,32 @@ IOMemoryDescriptor::withAddress(void *      address,
 }
 
 IOMemoryDescriptor *
-IOMemoryDescriptor::withAddress(vm_address_t address,
-                                IOByteCount  withLength,
-                                IODirection  withDirection,
-                                task_t       withTask)
+IOMemoryDescriptor::withPhysicalAddress(
+				IOPhysicalAddress	address,
+				IOByteCount		length,
+				IODirection      	direction )
+{
+    IOGeneralMemoryDescriptor *self = new IOGeneralMemoryDescriptor;
+    if (self
+    && !self->initWithPhysicalAddress(address, length, direction)) {
+        self->release();
+        return 0;
+    }
+
+    return self;
+}
+
+IOMemoryDescriptor *
+IOMemoryDescriptor::withRanges(	IOVirtualRange * ranges,
+				UInt32           withCount,
+				IODirection      direction,
+				task_t           task,
+				bool             asReference)
 {
     IOGeneralMemoryDescriptor * that = new IOGeneralMemoryDescriptor;
     if (that)
     {
-	if (that->initWithAddress(address, withLength, withDirection, withTask))
+	if (that->initWithRanges(ranges, withCount, direction, task, asReference))
 	    return that;
 
         that->release();
@@ -237,16 +240,6 @@ IOMemoryDescriptor::withAddress(vm_address_t address,
     return 0;
 }
 
-IOMemoryDescriptor *
-IOMemoryDescriptor::withPhysicalAddress(
-				IOPhysicalAddress	address,
-				IOByteCount		withLength,
-				IODirection      	withDirection )
-{
-    return( IOMemoryDescriptor::withAddress( address, withLength,
-					withDirection, (task_t) 0  ));
-}
-
 
 /*
  * withRanges:
@@ -257,33 +250,48 @@ IOMemoryDescriptor::withPhysicalAddress(
  * Passing the ranges as a reference will avoid an extra allocation.
  */
 IOMemoryDescriptor *
-IOMemoryDescriptor::withRanges(	IOVirtualRange * ranges,
-				UInt32           withCount,
-				IODirection      withDirection,
-				task_t           withTask,
-				bool             asReference = false)
+IOMemoryDescriptor::withOptions(void *		buffers,
+                                UInt32		count,
+                                UInt32		offset,
+                                task_t		task,
+                                IOOptionBits	opts,
+                                IOMapper *	mapper)
 {
-    IOGeneralMemoryDescriptor * that = new IOGeneralMemoryDescriptor;
-    if (that)
-    {
-	if (that->initWithRanges(ranges, withCount, withDirection, withTask, asReference))
-	    return that;
+    IOGeneralMemoryDescriptor *self = new IOGeneralMemoryDescriptor;
 
-        that->release();
+    if (self
+    && !self->initWithOptions(buffers, count, offset, task, opts, mapper))
+    {
+        self->release();
+        return 0;
     }
+
+    return self;
+}
+
+// Can't leave abstract but this should never be used directly,
+bool IOMemoryDescriptor::initWithOptions(void *		buffers,
+                                         UInt32		count,
+                                         UInt32		offset,
+                                         task_t		task,
+                                         IOOptionBits	options,
+                                         IOMapper *	mapper)
+{
+    // @@@ gvdl: Should I panic?
+    panic("IOMD::initWithOptions called\n");
     return 0;
 }
 
 IOMemoryDescriptor *
 IOMemoryDescriptor::withPhysicalRanges(	IOPhysicalRange * ranges,
                                         UInt32          withCount,
-                                        IODirection     withDirection,
-                                        bool            asReference = false)
+                                        IODirection     direction,
+                                        bool            asReference)
 {
     IOGeneralMemoryDescriptor * that = new IOGeneralMemoryDescriptor;
     if (that)
     {
-	if (that->initWithPhysicalRanges(ranges, withCount, withDirection, asReference))
+	if (that->initWithPhysicalRanges(ranges, withCount, direction, asReference))
 	    return that;
 
         that->release();
@@ -295,15 +303,15 @@ IOMemoryDescriptor *
 IOMemoryDescriptor::withSubRange(IOMemoryDescriptor *	of,
 				IOByteCount		offset,
 				IOByteCount		length,
-				IODirection		withDirection)
+				IODirection		direction)
 {
-    IOSubMemoryDescriptor * that = new IOSubMemoryDescriptor;
+    IOSubMemoryDescriptor *self = new IOSubMemoryDescriptor;
 
-    if (that && !that->initSubRange(of, offset, length, withDirection)) {
-        that->release();
-	that = 0;
+    if (self && !self->initSubRange(of, offset, length, direction)) {
+        self->release();
+	self = 0;
     }
-    return that;
+    return self;
 }
 
 /*
@@ -353,29 +361,123 @@ IOGeneralMemoryDescriptor::initWithPhysicalAddress(
     return initWithPhysicalRanges( &_singleRange.p, 1, withDirection, true);
 }
 
+bool
+IOGeneralMemoryDescriptor::initWithPhysicalRanges(
+                                IOPhysicalRange * ranges,
+                                UInt32            count,
+                                IODirection       direction,
+                                bool              reference)
+{
+    IOOptionBits mdOpts = direction | kIOMemoryTypePhysical;
+
+    if (reference)
+        mdOpts |= kIOMemoryAsReference;
+
+    return initWithOptions(ranges, count, 0, 0, mdOpts, /* mapper */ 0);
+}
+
+bool
+IOGeneralMemoryDescriptor::initWithRanges(
+                                   IOVirtualRange * ranges,
+                                   UInt32           count,
+                                   IODirection      direction,
+                                   task_t           task,
+                                   bool             reference)
+{
+    IOOptionBits mdOpts = direction;
+
+    if (reference)
+        mdOpts |= kIOMemoryAsReference;
+
+    if (task) {
+        mdOpts |= kIOMemoryTypeVirtual;
+        if (task == kernel_task)
+            mdOpts |= kIOMemoryAutoPrepare;
+    }
+    else
+        mdOpts |= kIOMemoryTypePhysical;
+
+    // @@@ gvdl: Need to remove this
+    // Auto-prepare if this is a kernel memory descriptor as very few
+    // clients bother to prepare() kernel memory.
+    // But it has been enforced so what are you going to do?
+    
+    return initWithOptions(ranges, count, 0, task, mdOpts, /* mapper */ 0);
+}
+
 /*
- * initWithRanges:
+ * initWithOptions:
  *
- * Initialize an IOMemoryDescriptor. The buffer is made up of several
- * virtual address ranges, from a given task
+ *  IOMemoryDescriptor. The buffer is made up of several virtual address ranges,
+ * from a given task or several physical ranges or finally an UPL from the ubc
+ * system.
  *
  * Passing the ranges as a reference will avoid an extra allocation.
  *
- * An IOMemoryDescriptor can be re-used by calling initWithAddress or
- * initWithRanges again on an existing instance -- note this behavior
- * is not commonly supported in other I/O Kit classes, although it is
- * supported here.
+ * An IOMemoryDescriptor can be re-used by calling initWithOptions again on an
+ * existing instance -- note this behavior is not commonly supported in other
+ * I/O Kit classes, although it is supported here.
  */
+
+enum ioPLBlockFlags {
+    kIOPLOnDevice  = 0x00000001,
+    kIOPLExternUPL = 0x00000002,
+};
+
+struct ioPLBlock {
+    upl_t fIOPL;
+    vm_address_t fIOMDOffset;	// The offset of this iopl in descriptor
+    vm_offset_t fPageInfo;	// Pointer to page list or index into it
+    ppnum_t fMappedBase;	// Page number of first page in this iopl
+    unsigned int fPageOffset;	// Offset within first page of iopl
+    unsigned int fFlags;	// Flags
+};
+
+struct ioGMDData {
+    IOMapper *fMapper;
+    unsigned int fPageCnt;
+    upl_page_info_t fPageList[0];	// @@@ gvdl need to get rid of this
+                                        //  should be able to use upl directly
+    ioPLBlock fBlocks[0];
+};
+
+#define getDataP(osd)	((ioGMDData *) (osd)->getBytesNoCopy())
+#define getIOPLList(d)	((ioPLBlock *) &(d->fPageList[d->fPageCnt]))
+#define getNumIOPL(d,len)	\
+    ((len - ((char *) getIOPLList(d) - (char *) d)) / sizeof(ioPLBlock))
+#define getPageList(d)	(&(d->fPageList[0]))
+#define computeDataSize(p, u) \
+    (sizeof(ioGMDData) + p * sizeof(upl_page_info_t) + u * sizeof(ioPLBlock))
+
 bool
-IOGeneralMemoryDescriptor::initWithRanges(
-                                   IOVirtualRange * ranges,
-                                   UInt32           withCount,
-                                   IODirection      withDirection,
-                                   task_t           withTask,
-                                   bool             asReference = false)
-{
-    assert(ranges);
-    assert(withCount);
+IOGeneralMemoryDescriptor::initWithOptions(void *	buffers,
+                                           UInt32	count,
+                                           UInt32	offset,
+                                           task_t	task,
+                                           IOOptionBits	options,
+                                           IOMapper *	mapper)
+{
+
+    switch (options & kIOMemoryTypeMask) {
+    case kIOMemoryTypeVirtual:
+        assert(task);
+        if (!task)
+            return false;
+        else
+            break;
+
+    case kIOMemoryTypePhysical:		// Neither Physical nor UPL should have a task
+	mapper = kIOMapperNone;
+    case kIOMemoryTypeUPL:
+        assert(!task);
+        break;
+    default:
+panic("IOGMD::iWO(): bad type");	// @@@ gvdl: for testing
+        return false;	/* bad argument */
+    }
+
+    assert(buffers);
+    assert(count);
 
     /*
      * We can check the _initialized  instance variable before having ever set
@@ -383,20 +485,12 @@ IOGeneralMemoryDescriptor::initWithRanges(
      * variables are zeroed on an object's allocation.
      */
 
-    if (_initialized == false)
-    {
-        if (super::init() == false)  return false;
-        _initialized = true;
-    }
-    else
-    {
+    if (_initialized) {
         /*
          * An existing memory descriptor is being retargeted to point to
          * somewhere else.  Clean up our present state.
          */
 
-        assert(_wireCount == 0);
-
         while (_wireCount)
             complete();
         if (_kernPtrAligned)
@@ -404,54 +498,140 @@ IOGeneralMemoryDescriptor::initWithRanges(
         if (_ranges.v && _rangesIsAllocated)
             IODelete(_ranges.v, IOVirtualRange, _rangesCount);
     }
+    else {
+        if (!super::init())
+            return false;
+        _initialized = true;
+    }
 
-    /*
-     * Initialize the memory descriptor.
-     */
+    // Grab the appropriate mapper
+    if (mapper == kIOMapperNone)
+        mapper = 0;	// No Mapper
+    else if (!mapper) {
+        IOMapper::checkForSystemMapper();
+        gIOSystemMapper = mapper = IOMapper::gSystem;
+    }
+
+    _flags		   = options;
+    _task                  = task;
 
-    _ranges.v              = 0;
-    _rangesCount           = withCount;
-    _rangesIsAllocated     = asReference ? false : true;
-    _direction             = withDirection;
-    _length                = 0;
-    _task                  = withTask;
+    // DEPRECATED variable initialisation
+    _direction             = (IODirection) (_flags & kIOMemoryDirectionMask);
     _position              = 0;
-    _positionAtIndex       = 0;
-    _positionAtOffset      = 0;
     _kernPtrAligned        = 0;
     _cachedPhysicalAddress = 0;
     _cachedVirtualAddress  = 0;
-    _flags		   = 0;
 
-    if (withTask && (withTask != kernel_task))
-        _flags |= kIOMemoryRequiresWire;
+    if ( (options & kIOMemoryTypeMask) == kIOMemoryTypeUPL) {
 
-    if (asReference)
-        _ranges.v = ranges;
-    else
-    {
-        _ranges.v = IONew(IOVirtualRange, withCount);
-        if (_ranges.v == 0)  return false;
-        bcopy(/* from */ ranges, _ranges.v, withCount * sizeof(IOVirtualRange));
-    } 
+        ioGMDData *dataP;
+        unsigned int dataSize = computeDataSize(/* pages */ 0, /* upls */ 1);
 
-    for (unsigned index = 0; index < _rangesCount; index++)
-    {
-        _length += _ranges.v[index].length;
+        if (!_memoryEntries) {
+            _memoryEntries = OSData::withCapacity(dataSize);
+            if (!_memoryEntries)
+                return false;
+        }
+        else if (!_memoryEntries->initWithCapacity(dataSize))
+            return false;
+
+        _memoryEntries->appendBytes(0, sizeof(ioGMDData));
+        dataP = getDataP(_memoryEntries);
+        dataP->fMapper = mapper;
+        dataP->fPageCnt = 0;
+
+        _wireCount++;	// UPLs start out life wired
+
+        _length    = count;
+        _pages    += atop_32(offset + count + PAGE_MASK) - atop_32(offset);
+
+        ioPLBlock iopl;
+        upl_page_info_t *pageList = UPL_GET_INTERNAL_PAGE_LIST((upl_t) buffers);
+
+        iopl.fIOPL = (upl_t) buffers;
+        // Set the flag kIOPLOnDevice convieniently equal to 1
+        iopl.fFlags  = pageList->device | kIOPLExternUPL;
+        iopl.fIOMDOffset = 0;
+        if (!pageList->device) {
+            // @@@ gvdl: Ask JoeS are the pages contiguious with the list?
+            // or there a chance that we may be inserting 0 phys_addrs?
+            // Pre-compute the offset into the UPL's page list
+            pageList = &pageList[atop_32(offset)];
+            offset &= PAGE_MASK;
+            if (mapper) {
+                iopl.fMappedBase = mapper->iovmAlloc(_pages);
+                mapper->iovmInsert(iopl.fMappedBase, 0, pageList, _pages);
+            }
+	    else
+		iopl.fMappedBase = 0;
+        }
+	else
+	    iopl.fMappedBase = 0;
+        iopl.fPageInfo = (vm_address_t) pageList;
+        iopl.fPageOffset = offset;
+
+        _memoryEntries->appendBytes(&iopl, sizeof(iopl));
     }
+    else {	/* kIOMemoryTypeVirtual | kIOMemoryTypePhysical */
+        IOVirtualRange *ranges = (IOVirtualRange *) buffers;
 
-    return true;
-}
+        /*
+         * Initialize the memory descriptor.
+         */
 
-bool
-IOGeneralMemoryDescriptor::initWithPhysicalRanges(	IOPhysicalRange * ranges,
-                                        	UInt32           withCount,
-                                        	IODirection      withDirection,
-                                        	bool             asReference = false)
-{
-#warning assuming virtual, physical addresses same size
-    return( initWithRanges( (IOVirtualRange *) ranges,
-			withCount, withDirection, (task_t) 0, asReference ));
+        _length			= 0;
+        _pages			= 0;
+        for (unsigned ind = 0; ind < count; ind++) {
+            IOVirtualRange cur = ranges[ind];
+    
+            _length += cur.length;
+            _pages += atop_32(cur.address + cur.length + PAGE_MASK)
+                   -  atop_32(cur.address);
+        }
+
+        _ranges.v		= 0;
+        _rangesIsAllocated	= !(options & kIOMemoryAsReference);
+        _rangesCount		= count;
+
+        if (options & kIOMemoryAsReference)
+            _ranges.v = ranges;
+        else {
+            _ranges.v = IONew(IOVirtualRange, count);
+            if (!_ranges.v)
+                return false;
+            bcopy(/* from */ ranges, _ranges.v,
+                  count * sizeof(IOVirtualRange));
+        } 
+
+        // Auto-prepare memory at creation time.
+        // Implied completion when descriptor is free-ed
+        if ( (options & kIOMemoryTypeMask) == kIOMemoryTypePhysical)
+            _wireCount++;	// Physical MDs are start out wired
+        else { /* kIOMemoryTypeVirtual */
+            ioGMDData *dataP;
+            unsigned int dataSize =
+                computeDataSize(_pages, /* upls */ _rangesCount * 2);
+
+            if (!_memoryEntries) {
+                _memoryEntries = OSData::withCapacity(dataSize);
+                if (!_memoryEntries)
+                    return false;
+            }
+            else if (!_memoryEntries->initWithCapacity(dataSize))
+                return false;
+    
+            _memoryEntries->appendBytes(0, sizeof(ioGMDData));
+            dataP = getDataP(_memoryEntries);
+            dataP->fMapper = mapper;
+            dataP->fPageCnt = _pages;
+
+            if ((_flags & kIOMemoryAutoPrepare)
+             && prepare() != kIOReturnSuccess)
+                return false;
+        }
+    }
+
+    return true;
 }
 
 /*
@@ -468,101 +648,33 @@ void IOGeneralMemoryDescriptor::free()
 
     while (_wireCount)
         complete();
+    if (_memoryEntries)
+        _memoryEntries->release();
+
     if (_kernPtrAligned)
         unmapFromKernel();
     if (_ranges.v && _rangesIsAllocated)
         IODelete(_ranges.v, IOVirtualRange, _rangesCount);
 
-    if( reserved && reserved->devicePager)
-	device_pager_deallocate( reserved->devicePager );
+    if (reserved && reserved->devicePager)
+	device_pager_deallocate( (memory_object_t) reserved->devicePager );
 
-    // memEntry holds a ref on the device pager which owns reserved (ExpansionData)
-    // so no reserved access after this point
-    if( _memEntry)
+    // memEntry holds a ref on the device pager which owns reserved
+    // (ExpansionData) so no reserved access after this point
+    if (_memEntry)
         ipc_port_release_send( (ipc_port_t) _memEntry );
+
     super::free();
 }
 
 /* DEPRECATED */ void IOGeneralMemoryDescriptor::unmapFromKernel()
 /* DEPRECATED */ {
-/* DEPRECATED */     kern_return_t krtn;
-/* DEPRECATED */     vm_offset_t off;
-/* DEPRECATED */     // Pull the shared pages out of the task map
-/* DEPRECATED */     // Do we need to unwire it first?
-/* DEPRECATED */     for ( off = 0; off < _kernSize; off += page_size )
-/* DEPRECATED */     {
-/* DEPRECATED */ 	pmap_change_wiring(
-/* DEPRECATED */ 			kernel_pmap,
-/* DEPRECATED */ 			_kernPtrAligned + off,
-/* DEPRECATED */ 			FALSE);
-/* DEPRECATED */ 
-/* DEPRECATED */ 	pmap_remove(
-/* DEPRECATED */ 			kernel_pmap,
-/* DEPRECATED */ 			_kernPtrAligned + off,
-/* DEPRECATED */ 			_kernPtrAligned + off + page_size);
-/* DEPRECATED */     }
-/* DEPRECATED */     // Free the former shmem area in the task
-/* DEPRECATED */     krtn = vm_deallocate(kernel_map,
-/* DEPRECATED */ 			_kernPtrAligned,
-/* DEPRECATED */ 			_kernSize );
-/* DEPRECATED */     assert(krtn == KERN_SUCCESS);
-/* DEPRECATED */     _kernPtrAligned = 0;
+                    panic("IOGMD::unmapFromKernel deprecated");
 /* DEPRECATED */ }
 /* DEPRECATED */ 
 /* DEPRECATED */ void IOGeneralMemoryDescriptor::mapIntoKernel(unsigned rangeIndex)
 /* DEPRECATED */ {
-/* DEPRECATED */     kern_return_t krtn;
-/* DEPRECATED */     vm_offset_t off;
-/* DEPRECATED */ 
-/* DEPRECATED */     if (_kernPtrAligned)
-/* DEPRECATED */     {
-/* DEPRECATED */         if (_kernPtrAtIndex == rangeIndex)  return;
-/* DEPRECATED */         unmapFromKernel();
-/* DEPRECATED */         assert(_kernPtrAligned == 0);
-/* DEPRECATED */     }
-/* DEPRECATED */  
-/* DEPRECATED */     vm_offset_t srcAlign = trunc_page(_ranges.v[rangeIndex].address);
-/* DEPRECATED */ 
-/* DEPRECATED */     _kernSize = trunc_page(_ranges.v[rangeIndex].address +
-/* DEPRECATED */                            _ranges.v[rangeIndex].length  +
-/* DEPRECATED */                            page_size - 1) - srcAlign;
-/* DEPRECATED */ 
-/* DEPRECATED */     /* Find some memory of the same size in kernel task.  We use vm_allocate() */
-/* DEPRECATED */     /* to do this. vm_allocate inserts the found memory object in the */
-/* DEPRECATED */     /* target task's map as a side effect. */
-/* DEPRECATED */     krtn = vm_allocate( kernel_map,
-/* DEPRECATED */ 	    &_kernPtrAligned,
-/* DEPRECATED */ 	    _kernSize,
-/* DEPRECATED */ 	    VM_FLAGS_ANYWHERE|VM_MAKE_TAG(VM_MEMORY_IOKIT) );  // Find first fit
-/* DEPRECATED */     assert(krtn == KERN_SUCCESS);
-/* DEPRECATED */     if(krtn)  return;
-/* DEPRECATED */ 
-/* DEPRECATED */     /* For each page in the area allocated from the kernel map, */
-/* DEPRECATED */ 	 /* find the physical address of the page. */
-/* DEPRECATED */ 	 /* Enter the page in the target task's pmap, at the */
-/* DEPRECATED */ 	 /* appropriate target task virtual address. */
-/* DEPRECATED */     for ( off = 0; off < _kernSize; off += page_size )
-/* DEPRECATED */     {
-/* DEPRECATED */ 	vm_offset_t kern_phys_addr, phys_addr;
-/* DEPRECATED */ 	if( _task)
-/* DEPRECATED */ 	    phys_addr = pmap_extract( get_task_pmap(_task), srcAlign + off );
-/* DEPRECATED */ 	else
-/* DEPRECATED */ 	    phys_addr = srcAlign + off;
-/* DEPRECATED */         assert(phys_addr);
-/* DEPRECATED */ 	if(phys_addr == 0)  return;
-/* DEPRECATED */ 
-/* DEPRECATED */ 	// Check original state.
-/* DEPRECATED */ 	kern_phys_addr = pmap_extract( kernel_pmap, _kernPtrAligned + off );
-/* DEPRECATED */ 	// Set virtual page to point to the right physical one
-/* DEPRECATED */ 	pmap_enter(
-/* DEPRECATED */ 	    kernel_pmap,
-/* DEPRECATED */ 	    _kernPtrAligned + off,
-/* DEPRECATED */ 	    phys_addr,
-/* DEPRECATED */ 	    VM_PROT_READ|VM_PROT_WRITE,
-/* DEPRECATED */	    VM_WIMG_USE_DEFAULT,
-/* DEPRECATED */ 	    TRUE);
-/* DEPRECATED */     }
-/* DEPRECATED */     _kernPtrAtIndex = rangeIndex;
+                    panic("IOGMD::mapIntoKernel deprecated");
 /* DEPRECATED */ }
 
 /*
@@ -585,8 +697,7 @@ IOByteCount IOMemoryDescriptor::getLength() const
     return _length;
 }
 
-void IOMemoryDescriptor::setTag(
-	IOOptionBits		tag )
+void IOMemoryDescriptor::setTag( IOOptionBits tag )
 {
     _tag = tag;    
 }
@@ -596,6 +707,7 @@ IOOptionBits IOMemoryDescriptor::getTag( void )
     return( _tag);
 }
 
+// @@@ gvdl: who is using this API?  Seems like a wierd thing to implement.
 IOPhysicalAddress IOMemoryDescriptor::getSourceSegment( IOByteCount   offset,
                                                         IOByteCount * length )
 {
@@ -609,263 +721,282 @@ IOPhysicalAddress IOMemoryDescriptor::getSourceSegment( IOByteCount   offset,
     return( physAddr );
 }
 
-IOByteCount IOMemoryDescriptor::readBytes( IOByteCount offset,
-                                                  void *      bytes,
-                                                  IOByteCount withLength )
+IOByteCount IOMemoryDescriptor::readBytes
+                (IOByteCount offset, void *bytes, IOByteCount length)
 {
-    IOByteCount bytesCopied = 0;
+    addr64_t dstAddr = (addr64_t) (UInt32) bytes;
+    IOByteCount remaining;
 
-    assert(offset <= _length);
-    assert(offset <= _length - withLength);
+    // Assert that this entire I/O is withing the available range
+    assert(offset < _length);
+    assert(offset + length <= _length);
+    if (offset >= _length) {
+IOLog("IOGMD(%p): rB = o%lx, l%lx\n", this, offset, length);	// @@@ gvdl
+        return 0;
+    }
 
-    if ( offset < _length )
-    {
-        withLength = min(withLength, _length - offset);
+    remaining = length = min(length, _length - offset);
+    while (remaining) {	// (process another target segment?)
+        addr64_t	srcAddr64;
+        IOByteCount	srcLen;
 
-        while ( withLength ) // (process another source segment?)
-        {
-            IOPhysicalAddress sourceSegment;
-            IOByteCount       sourceSegmentLength;
+        srcAddr64 = getPhysicalSegment64(offset, &srcLen);
+        if (!srcAddr64)
+            break;
 
-            sourceSegment = getPhysicalSegment(offset, &sourceSegmentLength);
-            if ( sourceSegment == 0 )  goto readBytesErr;
+        // Clip segment length to remaining
+        if (srcLen > remaining)
+            srcLen = remaining;
 
-            sourceSegmentLength = min(sourceSegmentLength, withLength);
+        copypv(srcAddr64, dstAddr, srcLen,
+                            cppvPsrc | cppvFsnk | cppvKmap);
 
-            while ( sourceSegmentLength ) // (process another target segment?)
-            {
-                IOPhysicalAddress targetSegment;
-                IOByteCount       targetSegmentLength;
+        dstAddr   += srcLen;
+        offset    += srcLen;
+        remaining -= srcLen;
+    }
 
-                targetSegment = pmap_extract_safe(kernel_task, (vm_offset_t) bytes);
-                if ( targetSegment == 0 )  goto readBytesErr;
+    assert(!remaining);
 
-                targetSegmentLength = min(next_page(targetSegment) - targetSegment, sourceSegmentLength);
+    return length - remaining;
+}
 
-                if ( sourceSegment + targetSegmentLength > next_page(sourceSegment) )
-                {
-                    IOByteCount pageLength;
+IOByteCount IOMemoryDescriptor::writeBytes
+                (IOByteCount offset, const void *bytes, IOByteCount length)
+{
+    addr64_t srcAddr = (addr64_t) (UInt32) bytes;
+    IOByteCount remaining;
 
-                    pageLength = next_page(sourceSegment) - sourceSegment;
+    // Assert that this entire I/O is withing the available range
+    assert(offset < _length);
+    assert(offset + length <= _length);
 
-                    bcopy_phys_safe( /* from */ (char *) sourceSegment, 
-                                     /* to   */ (char *) targetSegment,
-                                     /* size */ (int   ) pageLength );
+    assert( !(kIOMemoryPreparedReadOnly & _flags) );
 
-                    ((UInt8 *) bytes)   += pageLength;
-                    bytesCopied         += pageLength;
-                    offset              += pageLength;
-                    sourceSegment       += pageLength;
-                    sourceSegmentLength -= pageLength;
-                    targetSegment       += pageLength;
-                    targetSegmentLength -= pageLength;
-                    withLength          -= pageLength;
-                }
+    if ( (kIOMemoryPreparedReadOnly & _flags) || offset >= _length) {
+IOLog("IOGMD(%p): wB = o%lx, l%lx\n", this, offset, length);	// @@@ gvdl
+        return 0;
+    }
 
-                bcopy_phys_safe( /* from */ (char *) sourceSegment, 
-                                 /* to   */ (char *) targetSegment,
-                                 /* size */ (int   ) targetSegmentLength );
+    remaining = length = min(length, _length - offset);
+    while (remaining) {	// (process another target segment?)
+        addr64_t    dstAddr64;
+        IOByteCount dstLen;
 
-                ((UInt8 *) bytes)   += targetSegmentLength;
-                bytesCopied         += targetSegmentLength;
-                offset              += targetSegmentLength;
-                sourceSegment       += targetSegmentLength;
-                sourceSegmentLength -= targetSegmentLength;
-                withLength          -= targetSegmentLength;
-            }
-        }
-    }
+        dstAddr64 = getPhysicalSegment64(offset, &dstLen);
+        if (!dstAddr64)
+            break;
 
-readBytesErr:
+        // Clip segment length to remaining
+        if (dstLen > remaining)
+            dstLen = remaining;
 
-    if ( bytesCopied )
-    {
-        // We mark the destination pages as modified, just
-        // in case they are made pageable later on in life.
+        copypv(srcAddr, (addr64_t) dstAddr64, dstLen,
+                            cppvPsnk | cppvFsnk | cppvNoModSnk | cppvKmap);
 
-        pmap_modify_pages( /* pmap  */ kernel_pmap,       
-                           /* start */ trunc_page(((vm_offset_t) bytes) - bytesCopied),
-                           /* end   */ round_page(((vm_offset_t) bytes)) );
+        srcAddr   += dstLen;
+        offset    += dstLen;
+        remaining -= dstLen;
     }
 
-    return bytesCopied;
+    assert(!remaining);
+
+    return length - remaining;
 }
 
-IOByteCount IOMemoryDescriptor::writeBytes( IOByteCount  offset,
-                                                   const void * bytes,
-                                                   IOByteCount  withLength )
-{
-    IOByteCount bytesCopied = 0;
+// osfmk/device/iokit_rpc.c
+extern "C" unsigned int IODefaultCacheBits(addr64_t pa);
 
-    assert(offset <= _length);
-    assert(offset <= _length - withLength);
+/* DEPRECATED */ void IOGeneralMemoryDescriptor::setPosition(IOByteCount position)
+/* DEPRECATED */ {
+                    panic("IOGMD::setPosition deprecated");
+/* DEPRECATED */ }
 
-    if ( offset < _length )
-    {
-        withLength = min(withLength, _length - offset);
+IOPhysicalAddress IOGeneralMemoryDescriptor::getPhysicalSegment
+                        (IOByteCount offset, IOByteCount *lengthOfSegment)
+{
+    IOPhysicalAddress address = 0;
+    IOPhysicalLength  length  = 0;
 
-        while ( withLength ) // (process another target segment?)
-        {
-            IOPhysicalAddress targetSegment;
-            IOByteCount       targetSegmentLength;
+//  assert(offset <= _length);
+    if (offset < _length) // (within bounds?)
+    {
+        if ( (_flags & kIOMemoryTypeMask) == kIOMemoryTypePhysical) {
+            unsigned int ind;
 
-            targetSegment = getPhysicalSegment(offset, &targetSegmentLength);
-            if ( targetSegment == 0 )  goto writeBytesErr;
+            // Physical address based memory descriptor
 
-            targetSegmentLength = min(targetSegmentLength, withLength);
+            // Find offset within descriptor and make it relative
+            // to the current _range.
+            for (ind = 0 ; offset >= _ranges.p[ind].length; ind++ )
+                offset -= _ranges.p[ind].length;
+    
+            IOPhysicalRange cur = _ranges.p[ind];
+            address = cur.address + offset;
+            length  = cur.length  - offset;
+
+            // see how far we can coalesce ranges
+            for (++ind; ind < _rangesCount; ind++) {
+                cur =  _ranges.p[ind];
+        
+                if (address + length != cur.address)
+                    break;
+    
+                length += cur.length;
+            }
 
-            while ( targetSegmentLength ) // (process another source segment?)
+            // @@@ gvdl: should assert(address);
+            // but can't as NVidia GeForce creates a bogus physical mem
             {
-                IOPhysicalAddress sourceSegment;
-                IOByteCount       sourceSegmentLength;
+                assert(address || /*nvidia*/(!_ranges.p[0].address && 1 == _rangesCount));
+            }
+            assert(length);
+        }
+        else do {
+            // We need wiring & we are wired.
+            assert(_wireCount);
 
-                sourceSegment = pmap_extract_safe(kernel_task, (vm_offset_t) bytes);
-                if ( sourceSegment == 0 )  goto writeBytesErr;
+            if (!_wireCount)
+	    {
+		panic("IOGMD: not wired for getPhysicalSegment()");
+                continue;
+	    }
 
-                sourceSegmentLength = min(next_page(sourceSegment) - sourceSegment, targetSegmentLength);
+            assert(_memoryEntries);
 
-                if ( targetSegment + sourceSegmentLength > next_page(targetSegment) )
-                {
-                    IOByteCount pageLength;
+            ioGMDData * dataP = getDataP(_memoryEntries);
+            const ioPLBlock *ioplList = getIOPLList(dataP);
+            UInt ind, numIOPLs = getNumIOPL(dataP, _memoryEntries->getLength());
+            upl_page_info_t *pageList = getPageList(dataP);
 
-                    pageLength = next_page(targetSegment) - targetSegment;
+            assert(numIOPLs > 0);
 
-                    bcopy_phys_safe( /* from */ (char *) sourceSegment, 
-                                     /* to   */ (char *) targetSegment,
-                                     /* size */ (int   ) pageLength );
+            // Scan through iopl info blocks looking for block containing offset
+            for (ind = 1; ind < numIOPLs; ind++) {
+                if (offset < ioplList[ind].fIOMDOffset)
+                    break;
+            }
 
-                    // We flush the data cache in case it is code we've copied,
-                    // such that the instruction cache is in the know about it.
+            // Go back to actual range as search goes past it
+            ioPLBlock ioplInfo = ioplList[ind - 1];
 
-                    flush_dcache(targetSegment, pageLength, true);
+            if (ind < numIOPLs)
+                length = ioplList[ind].fIOMDOffset;
+            else
+                length = _length;
+            length -= offset;			// Remainder within iopl
 
-                    ((UInt8 *) bytes)   += pageLength;
-                    bytesCopied         += pageLength;
-                    offset              += pageLength;
-                    sourceSegment       += pageLength;
-                    sourceSegmentLength -= pageLength;
-                    targetSegment       += pageLength;
-                    targetSegmentLength -= pageLength;
-                    withLength          -= pageLength;
-                }
+            // Subtract offset till this iopl in total list
+            offset -= ioplInfo.fIOMDOffset;
 
-                bcopy_phys_safe( /* from */ (char *) sourceSegment, 
-                                 /* to   */ (char *) targetSegment,
-                                 /* size */ (int   ) sourceSegmentLength );
+            // This is a mapped IOPL so we just need to compute an offset
+            // relative to the mapped base.
+            if (ioplInfo.fMappedBase) {
+                offset += (ioplInfo.fPageOffset & PAGE_MASK);
+                address = ptoa_32(ioplInfo.fMappedBase) + offset;
+                continue;
+            }
 
-                // We flush the data cache in case it is code we've copied,
-                // such that the instruction cache is in the know about it.
+            // Currently the offset is rebased into the current iopl.
+            // Now add the iopl 1st page offset.
+            offset += ioplInfo.fPageOffset;
 
-                flush_dcache(targetSegment, sourceSegmentLength, true);
+            // For external UPLs the fPageInfo field points directly to
+            // the upl's upl_page_info_t array.
+            if (ioplInfo.fFlags & kIOPLExternUPL)
+                pageList = (upl_page_info_t *) ioplInfo.fPageInfo;
+            else
+                pageList = &pageList[ioplInfo.fPageInfo];
 
-                ((UInt8 *) bytes)   += sourceSegmentLength;
-                bytesCopied         += sourceSegmentLength;
-                offset              += sourceSegmentLength;
-                targetSegment       += sourceSegmentLength;
-                targetSegmentLength -= sourceSegmentLength;
-                withLength          -= sourceSegmentLength;
+            // Check for direct device non-paged memory
+            if ( ioplInfo.fFlags & kIOPLOnDevice ) {
+                address = ptoa_32(pageList->phys_addr) + offset;
+                continue;
             }
-        }
-    }
 
-writeBytesErr:
+            // Now we need compute the index into the pageList
+            ind = atop_32(offset);
+            offset &= PAGE_MASK;
+
+            IOPhysicalAddress pageAddr = pageList[ind].phys_addr;
+            address = ptoa_32(pageAddr) + offset;
+
+            // Check for the remaining data in this upl being longer than the
+            // remainder on the current page.  This should be checked for
+            // contiguous pages
+            if (length > PAGE_SIZE - offset) {
+                // See if the next page is contiguous.  Stop looking when we hit
+                // the end of this upl, which is indicated by the
+                // contigLength >= length.
+                IOByteCount contigLength = PAGE_SIZE - offset;
+
+                // Look for contiguous segment
+                while (contigLength < length
+                &&     ++pageAddr == pageList[++ind].phys_addr) {
+                    contigLength += PAGE_SIZE;
+                }
+                if (length > contigLength)
+                    length = contigLength;
+            }
+    
+            assert(address);
+            assert(length);
 
-    return bytesCopied;
-}
+        } while (0);
 
-extern "C" {
-// osfmk/device/iokit_rpc.c
-extern unsigned int  IOTranslateCacheBits(struct phys_entry *pp);
-};
+        if (!address)
+            length = 0;
+    }
 
-/* DEPRECATED */ void IOGeneralMemoryDescriptor::setPosition(IOByteCount position)
-/* DEPRECATED */ {
-/* DEPRECATED */     assert(position <= _length);
-/* DEPRECATED */ 
-/* DEPRECATED */     if (position >= _length)
-/* DEPRECATED */     {
-/* DEPRECATED */         _position         = _length;
-/* DEPRECATED */         _positionAtIndex  = _rangesCount; /* careful: out-of-bounds */
-/* DEPRECATED */         _positionAtOffset = 0;
-/* DEPRECATED */         return;
-/* DEPRECATED */     }
-/* DEPRECATED */ 
-/* DEPRECATED */     if (position < _position)
-/* DEPRECATED */     {
-/* DEPRECATED */ 	_positionAtOffset = position;
-/* DEPRECATED */ 	_positionAtIndex  = 0;
-/* DEPRECATED */     }
-/* DEPRECATED */     else
-/* DEPRECATED */     {
-/* DEPRECATED */ 	_positionAtOffset += (position - _position);
-/* DEPRECATED */     }
-/* DEPRECATED */     _position = position;
-/* DEPRECATED */ 
-/* DEPRECATED */     while (_positionAtOffset >= _ranges.v[_positionAtIndex].length)
-/* DEPRECATED */     {
-/* DEPRECATED */         _positionAtOffset -= _ranges.v[_positionAtIndex].length;
-/* DEPRECATED */         _positionAtIndex++;
-/* DEPRECATED */     }
-/* DEPRECATED */ }
+    if (lengthOfSegment)
+        *lengthOfSegment = length;
 
-IOPhysicalAddress IOGeneralMemoryDescriptor::getPhysicalSegment( IOByteCount   offset,
-                                                                 IOByteCount * lengthOfSegment )
-{
-    IOPhysicalAddress address = 0;
-    IOPhysicalLength  length  = 0;
+    return address;
+}
 
+addr64_t IOMemoryDescriptor::getPhysicalSegment64
+                        (IOByteCount offset, IOByteCount *lengthOfSegment)
+{
+    IOPhysicalAddress phys32;
+    IOByteCount	      length;
+    addr64_t 	      phys64;
 
-//    assert(offset <= _length);
+    phys32 = getPhysicalSegment(offset, lengthOfSegment);
+    if (!phys32)
+	return 0;
 
-    if ( offset < _length ) // (within bounds?)
+    if (gIOSystemMapper)
     {
-        unsigned rangesIndex = 0;
-
-        for ( ; offset >= _ranges.v[rangesIndex].length; rangesIndex++ )
-        {
-            offset -= _ranges.v[rangesIndex].length; // (make offset relative)
-        }
-
-        if ( _task == 0 ) // (physical memory?)
-        {
-            address = _ranges.v[rangesIndex].address + offset;
-            length  = _ranges.v[rangesIndex].length  - offset;
-
-            for ( ++rangesIndex; rangesIndex < _rangesCount; rangesIndex++ )
-            {
-                if ( address + length != _ranges.v[rangesIndex].address )  break;
-
-                length += _ranges.v[rangesIndex].length; // (coalesce ranges)
-            }
-        }
-        else // (virtual memory?)
-        {
-            vm_address_t addressVirtual = _ranges.v[rangesIndex].address + offset;
-
-            assert((0 == (kIOMemoryRequiresWire & _flags)) || _wireCount);
-
-            address = pmap_extract_safe(_task, addressVirtual);
-            length  = next_page(addressVirtual) - addressVirtual;
-            length  = min(_ranges.v[rangesIndex].length - offset, length);
-        }
-
-        assert(address);
-        if ( address == 0 )  length = 0;
+	IOByteCount origLen;
+
+	phys64 = gIOSystemMapper->mapAddr(phys32);
+	origLen = *lengthOfSegment;
+	length = page_size - (phys64 & (page_size - 1));
+	while ((length < origLen)
+	    && ((phys64 + length) == gIOSystemMapper->mapAddr(phys32 + length)))
+	    length += page_size;
+	if (length > origLen)
+	    length = origLen;
+
+	*lengthOfSegment = length;
     }
+    else
+	phys64 = (addr64_t) phys32;
 
-    if ( lengthOfSegment )  *lengthOfSegment = length;
-
-    return address;
+    return phys64;
 }
 
-IOPhysicalAddress IOGeneralMemoryDescriptor::getSourceSegment( IOByteCount   offset,
-                                                               IOByteCount * lengthOfSegment )
+IOPhysicalAddress IOGeneralMemoryDescriptor::getSourceSegment
+                            (IOByteCount offset, IOByteCount *lengthOfSegment)
 {
     IOPhysicalAddress address = 0;
     IOPhysicalLength  length  = 0;
 
     assert(offset <= _length);
 
+    if ( (_flags & kIOMemoryTypeMask) == kIOMemoryTypeUPL)
+	return super::getSourceSegment( offset, lengthOfSegment );
+
     if ( offset < _length ) // (within bounds?)
     {
         unsigned rangesIndex = 0;
@@ -898,193 +1029,197 @@ IOPhysicalAddress IOGeneralMemoryDescriptor::getSourceSegment( IOByteCount   off
 /* DEPRECATED */ void * IOGeneralMemoryDescriptor::getVirtualSegment(IOByteCount offset,
 /* DEPRECATED */ 							IOByteCount * lengthOfSegment)
 /* DEPRECATED */ {
-/* DEPRECATED */     if( offset != _position)
-/* DEPRECATED */ 	setPosition( offset );
-/* DEPRECATED */ 
-/* DEPRECATED */     assert(_position <= _length);
-/* DEPRECATED */ 
-/* DEPRECATED */     /* Fail gracefully if the position is at (or past) the end-of-buffer. */
-/* DEPRECATED */     if (_position >= _length)
-/* DEPRECATED */     {
-/* DEPRECATED */         *lengthOfSegment = 0;
-/* DEPRECATED */         return 0;
-/* DEPRECATED */     }
-/* DEPRECATED */ 
-/* DEPRECATED */     /* Compute the relative length to the end of this virtual segment. */
-/* DEPRECATED */     *lengthOfSegment = _ranges.v[_positionAtIndex].length - _positionAtOffset;
-/* DEPRECATED */ 
-/* DEPRECATED */     /* Compute the relative address of this virtual segment. */
-/* DEPRECATED */     if (_task == kernel_task)
-/* DEPRECATED */         return (void *)(_ranges.v[_positionAtIndex].address + _positionAtOffset);
-/* DEPRECATED */     else
-/* DEPRECATED */     {
-/* DEPRECATED */ 	vm_offset_t off;
-/* DEPRECATED */ 
-/* DEPRECATED */         mapIntoKernel(_positionAtIndex);
-/* DEPRECATED */ 
-/* DEPRECATED */ 	off  = _ranges.v[_kernPtrAtIndex].address;
-/* DEPRECATED */ 	off -= trunc_page(off);
-/* DEPRECATED */ 
-/* DEPRECATED */ 	return (void *) (_kernPtrAligned + off + _positionAtOffset);
-/* DEPRECATED */     }
+                    if (_task == kernel_task)
+                        return (void *) getSourceSegment(offset, lengthOfSegment);
+                    else
+                        panic("IOGMD::getVirtualSegment deprecated");
+
+                    return 0;
 /* DEPRECATED */ }
 /* DEPRECATED */ /* USE INSTEAD: map(), readBytes(), writeBytes() */
 
-/*
- * prepare
- *
- * Prepare the memory for an I/O transfer.  This involves paging in
- * the memory, if necessary, and wiring it down for the duration of
- * the transfer.  The complete() method completes the processing of
- * the memory after the I/O transfer finishes.  This method needn't
- * called for non-pageable memory.
- */
-IOReturn IOGeneralMemoryDescriptor::prepare(
-		IODirection forDirection = kIODirectionNone)
+IOReturn IOGeneralMemoryDescriptor::wireVirtual(IODirection forDirection)
 {
-    UInt rangeIndex = 0;
+    IOReturn error = kIOReturnNoMemory;
+    ioGMDData *dataP;
+    ppnum_t mapBase = 0;
+    IOMapper *mapper;
 
-    if((_wireCount == 0) && (kIOMemoryRequiresWire & _flags)) {
-        kern_return_t rc;
+    assert(!_wireCount);
 
-        if(forDirection == kIODirectionNone)
-            forDirection = _direction;
+    dataP = getDataP(_memoryEntries);
+    mapper = dataP->fMapper;
+    if (mapper && _pages)
+        mapBase = mapper->iovmAlloc(_pages);
 
-        vm_prot_t access;
+    // Note that appendBytes(NULL) zeros the data up to the
+    // desired length.
+    _memoryEntries->appendBytes(0, dataP->fPageCnt * sizeof(upl_page_info_t));
+    dataP = 0;	// May no longer be valid so lets not get tempted.
 
-        switch (forDirection)
-        {
-            case kIODirectionIn:
-                access = VM_PROT_WRITE;
-                break;
-
-            case kIODirectionOut:
-                access = VM_PROT_READ;
-                break;
+    if (forDirection == kIODirectionNone)
+        forDirection = _direction;
 
-            default:
-                access = VM_PROT_READ | VM_PROT_WRITE;
-                break;
-        }
-
-        //
-        // Check user read/write access to the data buffer.
-        //
-
-        for (rangeIndex = 0; rangeIndex < _rangesCount; rangeIndex++)
-        {
-            vm_offset_t checkBase = trunc_page(_ranges.v[rangeIndex].address);
-            vm_size_t   checkSize = round_page(_ranges.v[rangeIndex].length );
+    int uplFlags;    // This Mem Desc's default flags for upl creation
+    switch (forDirection)
+    {
+    case kIODirectionOut:
+        // Pages do not need to be marked as dirty on commit
+        uplFlags = UPL_COPYOUT_FROM;
+        _flags |= kIOMemoryPreparedReadOnly;
+        break;
+
+    case kIODirectionIn:
+    default:
+        uplFlags = 0;	// i.e. ~UPL_COPYOUT_FROM
+        break;
+    }
+    uplFlags |= UPL_SET_IO_WIRE | UPL_SET_LITE;
+
+    //
+    // Check user read/write access to the data buffer.
+    //
+    unsigned int pageIndex = 0;
+    IOByteCount mdOffset = 0;
+    vm_map_t curMap;
+    if (_task == kernel_task && (kIOMemoryBufferPageable & _flags))
+        curMap = 0;
+    else
+        { curMap = get_task_map(_task); }
+
+    for (UInt range = 0; range < _rangesCount; range++) {
+        ioPLBlock iopl;
+        IOVirtualRange curRange = _ranges.v[range];
+        vm_address_t startPage;
+        IOByteCount numBytes;
+
+        startPage = trunc_page_32(curRange.address);
+        iopl.fPageOffset = (short) curRange.address & PAGE_MASK;
+	if (mapper)
+	    iopl.fMappedBase = mapBase + pageIndex;
+	else
+	    iopl.fMappedBase = 0;
+        numBytes = iopl.fPageOffset + curRange.length;
+
+        while (numBytes) {
+            dataP = getDataP(_memoryEntries);
+            vm_map_t theMap =
+                (curMap)? curMap 
+                        : IOPageableMapForAddress(startPage);
+            upl_page_info_array_t pageInfo = getPageList(dataP);
+            int ioplFlags = uplFlags;
+            upl_page_list_ptr_t baseInfo = &pageInfo[pageIndex];
+
+            vm_size_t ioplSize = round_page_32(numBytes);
+            unsigned int numPageInfo = atop_32(ioplSize);
+            error = vm_map_get_upl(theMap, 
+                                   startPage,
+                                   &ioplSize,
+                                   &iopl.fIOPL,
+                                   baseInfo,
+                                   &numPageInfo,
+                                   &ioplFlags,
+                                   false);
+            assert(ioplSize);
+            if (error != KERN_SUCCESS)
+                goto abortExit;
+
+            error = kIOReturnNoMemory;
+
+            if (baseInfo->device) {
+                numPageInfo = 1;
+                iopl.fFlags  = kIOPLOnDevice;
+                // Don't translate device memory at all 
+		if (mapper && mapBase) {
+		    mapper->iovmFree(mapBase, _pages);
+		    mapBase = 0;
+		    iopl.fMappedBase = 0;
+		}
+            }
+            else {
+                iopl.fFlags = 0;
+                if (mapper)
+                    mapper->iovmInsert(mapBase, pageIndex,
+                                       baseInfo, numPageInfo);
+            }
 
-            while (checkSize)
-            {
-                vm_region_basic_info_data_t regionInfo;
-                mach_msg_type_number_t      regionInfoSize = sizeof(regionInfo);
-                vm_size_t                   regionSize;
-
-                if ( (vm_region(
-                          /* map         */ getMapForTask(_task, checkBase),
-                          /* address     */ &checkBase,
-                          /* size        */ &regionSize,
-                          /* flavor      */ VM_REGION_BASIC_INFO,
-                          /* info        */ (vm_region_info_t) &regionInfo,
-                          /* info size   */ &regionInfoSize,
-                          /* object name */ 0 ) != KERN_SUCCESS             ) ||
-                     ( (forDirection & kIODirectionIn ) &&
-                                   !(regionInfo.protection & VM_PROT_WRITE) ) ||
-                     ( (forDirection & kIODirectionOut) && 
-                                   !(regionInfo.protection & VM_PROT_READ ) ) )
-                {
-                    return kIOReturnVMError;
-                }
+            iopl.fIOMDOffset = mdOffset;
+            iopl.fPageInfo = pageIndex;
 
-                assert((regionSize & PAGE_MASK) == 0);
-
-                regionSize = min(regionSize, checkSize);
-                checkSize -= regionSize;
-                checkBase += regionSize;
-            } // (for each vm region)
-        } // (for each io range)
-
-        for (rangeIndex = 0; rangeIndex < _rangesCount; rangeIndex++) {
-
-            vm_offset_t srcAlign = trunc_page(_ranges.v[rangeIndex].address);
-            IOByteCount srcAlignEnd = trunc_page(_ranges.v[rangeIndex].address +
-                                _ranges.v[rangeIndex].length  +
-                                page_size - 1);
-
-	    vm_map_t taskVMMap = getMapForTask(_task, srcAlign);
-
-	    // If this I/O is for a user land task then protect ourselves
-	    // against COW and other vm_shenanigans
-	    if (_task && _task != kernel_task) {
-		// setup a data object to hold the 'named' memory regions
-		// @@@ gvdl: If we fail to allocate an OSData we will just
-		// hope for the best for the time being.  Lets not fail a
-		// prepare at this late stage in product release.
-		if (!_memoryEntries)
-		    _memoryEntries = OSData::withCapacity(16);
-		if (_memoryEntries) {
-		    vm_object_offset_t desiredSize = srcAlignEnd - srcAlign;
-		    vm_object_offset_t entryStart = srcAlign;
-		    ipc_port_t memHandle;
-
-		    do {
-			vm_object_offset_t actualSize = desiredSize;
-
-			rc = mach_make_memory_entry_64
-			    (taskVMMap, &actualSize, entryStart,
-			    forDirection, &memHandle, NULL);
-			if (KERN_SUCCESS != rc) {
-			    IOLog("IOMemoryDescriptor::prepare mach_make_memory_entry_64 failed: %d\n", rc);
-			    goto abortExit;
-			}
-
-			_memoryEntries->
-			    appendBytes(&memHandle, sizeof(memHandle));
-			desiredSize -= actualSize;
-			entryStart += actualSize;
-		    } while (desiredSize);
-		}
+	    if (_flags & kIOMemoryAutoPrepare)
+	    {
+		kernel_upl_commit(iopl.fIOPL, 0, 0);
+		iopl.fIOPL = 0;
 	    }
 
-            rc = vm_map_wire(taskVMMap, srcAlign, srcAlignEnd, access, FALSE);
-	    if (KERN_SUCCESS != rc) {
-		IOLog("IOMemoryDescriptor::prepare vm_map_wire failed: %d\n", rc);
-		goto abortExit;
-	    }
+            if (!_memoryEntries->appendBytes(&iopl, sizeof(iopl))) {
+                // Clean up partial created and unsaved iopl
+		if (iopl.fIOPL)
+		    kernel_upl_abort(iopl.fIOPL, 0);
+                goto abortExit;
+            }
+
+            // Check for a multiple iopl's in one virtual range
+            pageIndex += numPageInfo;
+            mdOffset -= iopl.fPageOffset;
+            if (ioplSize < numBytes) {
+                numBytes -= ioplSize;
+                startPage += ioplSize;
+                mdOffset += ioplSize;
+                iopl.fPageOffset = 0;
+		if (mapper)
+		    iopl.fMappedBase = mapBase + pageIndex;
+            }
+            else {
+                mdOffset += numBytes;
+                break;
+            }
         }
     }
-    _wireCount++;
+
     return kIOReturnSuccess;
 
 abortExit:
-    UInt doneIndex;
-
-
-    for(doneIndex = 0; doneIndex < rangeIndex; doneIndex++) {
-	vm_offset_t srcAlign = trunc_page(_ranges.v[doneIndex].address);
-	IOByteCount srcAlignEnd = trunc_page(_ranges.v[doneIndex].address +
-			    _ranges.v[doneIndex].length  +
-			    page_size - 1);
+    {
+        dataP = getDataP(_memoryEntries);
+        UInt done = getNumIOPL(dataP, _memoryEntries->getLength());
+        ioPLBlock *ioplList = getIOPLList(dataP);
+    
+        for (UInt range = 0; range < done; range++)
+	{
+	    if (ioplList[range].fIOPL)
+		kernel_upl_abort(ioplList[range].fIOPL, 0);
+	}
 
-	vm_map_unwire(getMapForTask(_task, srcAlign), srcAlign,
-			    srcAlignEnd, FALSE);
+        if (mapper && mapBase)
+            mapper->iovmFree(mapBase, _pages);
     }
 
-    if (_memoryEntries) {
-	ipc_port_t *handles, *handlesEnd;
+    return error;
+}
+
+/*
+ * prepare
+ *
+ * Prepare the memory for an I/O transfer.  This involves paging in
+ * the memory, if necessary, and wiring it down for the duration of
+ * the transfer.  The complete() method completes the processing of
+ * the memory after the I/O transfer finishes.  This method needn't
+ * called for non-pageable memory.
+ */
+IOReturn IOGeneralMemoryDescriptor::prepare(IODirection forDirection)
+{
+    IOReturn error = kIOReturnSuccess;
 
-	handles = (ipc_port_t *) _memoryEntries->getBytesNoCopy();
-	handlesEnd = (ipc_port_t *)
-	    ((vm_address_t) handles + _memoryEntries->getLength());
-	while (handles < handlesEnd)
-	    ipc_port_release_send(*handles++);
-	_memoryEntries->release();
-	_memoryEntries = 0;
+    if (!_wireCount && (_flags & kIOMemoryTypeMask) == kIOMemoryTypeVirtual) {
+        error = wireVirtual(forDirection);
+        if (error)
+            return error;
     }
 
-    return kIOReturnVMError;
+    _wireCount++;
+
+    return kIOReturnSuccess;
 }
 
 /*
@@ -1096,50 +1231,36 @@ abortExit:
  * before and after an I/O transfer involving pageable memory.
  */
  
-IOReturn IOGeneralMemoryDescriptor::complete(
-		IODirection forDirection = kIODirectionNone)
+IOReturn IOGeneralMemoryDescriptor::complete(IODirection /* forDirection */)
 {
     assert(_wireCount);
 
-    if(0 == _wireCount)
+    if (!_wireCount)
         return kIOReturnSuccess;
 
     _wireCount--;
-    if((_wireCount == 0) && (kIOMemoryRequiresWire & _flags)) {
-        UInt rangeIndex;
-        kern_return_t rc;
-
-        if(forDirection == kIODirectionNone)
-            forDirection = _direction;
-
-        for(rangeIndex = 0; rangeIndex < _rangesCount; rangeIndex++) {
-
-            vm_offset_t srcAlign = trunc_page(_ranges.v[rangeIndex].address);
-            IOByteCount srcAlignEnd = trunc_page(_ranges.v[rangeIndex].address +
-                                _ranges.v[rangeIndex].length  +
-                                page_size - 1);
-
-            if(forDirection == kIODirectionIn)
-                pmap_modify_pages(get_task_pmap(_task), srcAlign, srcAlignEnd);
-
-            rc = vm_map_unwire(getMapForTask(_task, srcAlign), srcAlign,
-                                  srcAlignEnd, FALSE);
-            if(rc != KERN_SUCCESS)
-                IOLog("IOMemoryDescriptor::complete: vm_map_unwire failed: %d\n", rc);
+    if (!_wireCount) {
+        if ((_flags & kIOMemoryTypeMask) == kIOMemoryTypePhysical) {
+            /* kIOMemoryTypePhysical */
+            // DO NOTHING
         }
+        else {
+            ioGMDData * dataP = getDataP(_memoryEntries);
+            ioPLBlock *ioplList = getIOPLList(dataP);
+	    UInt count = getNumIOPL(dataP, _memoryEntries->getLength());
+
+            if (dataP->fMapper && _pages && ioplList[0].fMappedBase)
+                dataP->fMapper->iovmFree(ioplList[0].fMappedBase, _pages);
+
+            // Only complete iopls that we created which are for TypeVirtual
+            if ( (_flags & kIOMemoryTypeMask) == kIOMemoryTypeVirtual) {
+                for (UInt ind = 0; ind < count; ind++)
+		    if (ioplList[ind].fIOPL)
+			kernel_upl_commit(ioplList[ind].fIOPL, 0, 0);
+            }
 
-	if (_memoryEntries) {
-	    ipc_port_t *handles, *handlesEnd;
-
-	    handles = (ipc_port_t *) _memoryEntries->getBytesNoCopy();
-	    handlesEnd = (ipc_port_t *)
-			((vm_address_t) handles + _memoryEntries->getLength());
-	    while (handles < handlesEnd)
-		ipc_port_release_send(*handles++);
-
-	    _memoryEntries->release();
-	    _memoryEntries = 0;
-	}
+            (void) _memoryEntries->initWithBytes(dataP, sizeof(ioGMDData)); // == setLength()
+        }
     }
     return kIOReturnSuccess;
 }
@@ -1148,8 +1269,8 @@ IOReturn IOGeneralMemoryDescriptor::doMap(
 	vm_map_t		addressMap,
 	IOVirtualAddress *	atAddress,
 	IOOptionBits		options,
-	IOByteCount		sourceOffset = 0,
-	IOByteCount		length = 0 )
+	IOByteCount		sourceOffset,
+	IOByteCount		length )
 {
     kern_return_t kr;
     ipc_port_t sharedMem = (ipc_port_t) _memEntry;
@@ -1164,11 +1285,7 @@ IOReturn IOGeneralMemoryDescriptor::doMap(
 
     if( 0 == sharedMem) {
 
-        vm_size_t size = 0;
-
-        for (unsigned index = 0; index < _rangesCount; index++)
-            size += round_page(_ranges.v[index].address + _ranges.v[index].length)
-                  - trunc_page(_ranges.v[index].address);
+        vm_size_t size = _pages << PAGE_SHIFT;
 
         if( _task) {
 #ifndef i386
@@ -1178,9 +1295,9 @@ IOReturn IOGeneralMemoryDescriptor::doMap(
                         VM_PROT_READ | VM_PROT_WRITE, &sharedMem,
                         NULL );
 
-            if( (KERN_SUCCESS == kr) && (actualSize != round_page(size))) {
+            if( (KERN_SUCCESS == kr) && (actualSize != round_page_32(size))) {
 #if IOASSERT
-                IOLog("mach_make_memory_entry_64 (%08lx) size (%08lx:%08lx)\n",
+                IOLog("mach_make_memory_entry_64 (%08x) size (%08lx:%08x)\n",
                             _ranges.v[0].address, (UInt32)actualSize, size);
 #endif
                 kr = kIOReturnVMError;
@@ -1193,13 +1310,12 @@ IOReturn IOGeneralMemoryDescriptor::doMap(
 
         } else do {
 
-            memory_object_t pager;
-	    unsigned int    flags=0;
-	    struct	phys_entry	*pp;
-    	    IOPhysicalAddress	pa;
+            memory_object_t 	pager;
+	    unsigned int    	flags = 0;
+    	    addr64_t		pa;
     	    IOPhysicalLength	segLen;
 
-	    pa = getPhysicalSegment( sourceOffset, &segLen );
+	    pa = getPhysicalSegment64( sourceOffset, &segLen );
 
             if( !reserved) {
                 reserved = IONew( ExpansionData, 1 );
@@ -1209,41 +1325,35 @@ IOReturn IOGeneralMemoryDescriptor::doMap(
             reserved->pagerContig = (1 == _rangesCount);
 	    reserved->memory = this;
 
-#ifndef i386
-            switch(options & kIOMapCacheMask ) { /*What cache mode do we need*/
+	    /*What cache mode do we need*/
+            switch(options & kIOMapCacheMask ) {
 
 		case kIOMapDefaultCache:
 		default:
-			if((pp = pmap_find_physentry(pa))) {/* Find physical address */
-				/* Use physical attributes as default */
-				flags = IOTranslateCacheBits(pp);
-
-			}
-			else {	/* If no physical, just hard code attributes */
-	    			flags = DEVICE_PAGER_CACHE_INHIB | 
-					DEVICE_PAGER_COHERENT | DEVICE_PAGER_GUARDED;
-			}
-			break;
+		    flags = IODefaultCacheBits(pa);
+		    break;
 	
 		case kIOMapInhibitCache:
-	    		flags = DEVICE_PAGER_CACHE_INHIB | 
-					DEVICE_PAGER_COHERENT | DEVICE_PAGER_GUARDED;
-			break;
+		    flags = DEVICE_PAGER_CACHE_INHIB | 
+				    DEVICE_PAGER_COHERENT | DEVICE_PAGER_GUARDED;
+		    break;
 	
 		case kIOMapWriteThruCache:
-	    		flags = DEVICE_PAGER_WRITE_THROUGH |
-					DEVICE_PAGER_COHERENT | DEVICE_PAGER_GUARDED;
-			break;
+		    flags = DEVICE_PAGER_WRITE_THROUGH |
+				    DEVICE_PAGER_COHERENT | DEVICE_PAGER_GUARDED;
+		    break;
 
 		case kIOMapCopybackCache:
-	    		flags = DEVICE_PAGER_COHERENT;
-			break;
+		    flags = DEVICE_PAGER_COHERENT;
+		    break;
+
+		case kIOMapWriteCombineCache:
+		    flags = DEVICE_PAGER_CACHE_INHIB |
+				    DEVICE_PAGER_COHERENT;
+		    break;
             }
 
 	    flags |= reserved->pagerContig ? DEVICE_PAGER_CONTIGUOUS : 0;
-#else
-	    flags = reserved->pagerContig ? DEVICE_PAGER_CONTIGUOUS : 0;
-#endif
 
             pager = device_pager_setup( (memory_object_t) 0, (int) reserved, 
 								size, flags);
@@ -1289,7 +1399,7 @@ IOReturn IOGeneralMemoryDescriptor::doUnmap(
 	IOByteCount		length )
 {
     // could be much better
-    if( _task && (addressMap == getMapForTask(_task, _ranges.v[0].address)) && (1 == _rangesCount)
+    if( _task && (addressMap == get_task_map(_task)) && (1 == _rangesCount)
 	 && (logical == _ranges.v[0].address)
 	 && (length <= _ranges.v[0].length) )
 	    return( kIOReturnSuccess );
@@ -1481,7 +1591,40 @@ static kern_return_t IOMemoryDescriptorMapAlloc(vm_map_t map, void * _ref)
         if( ref->sharedMem) {
             vm_prot_t prot = VM_PROT_READ
                             | ((ref->options & kIOMapReadOnly) ? 0 : VM_PROT_WRITE);
-    
+
+            // set memory entry cache
+            vm_prot_t memEntryCacheMode = prot | MAP_MEM_ONLY;
+            switch (ref->options & kIOMapCacheMask)
+            {
+		case kIOMapInhibitCache:
+                    SET_MAP_MEM(MAP_MEM_IO, memEntryCacheMode);
+                    break;
+	
+		case kIOMapWriteThruCache:
+                    SET_MAP_MEM(MAP_MEM_WTHRU, memEntryCacheMode);
+                    break;
+
+		case kIOMapWriteCombineCache:
+                    SET_MAP_MEM(MAP_MEM_WCOMB, memEntryCacheMode);
+                    break;
+
+		case kIOMapCopybackCache:
+                    SET_MAP_MEM(MAP_MEM_COPYBACK, memEntryCacheMode);
+                    break;
+
+		case kIOMapDefaultCache:
+		default:
+                    SET_MAP_MEM(MAP_MEM_NOOP, memEntryCacheMode);
+                    break;
+            }
+
+            vm_size_t unused = 0;
+
+            err = mach_make_memory_entry( NULL /*unused*/, &unused, 0 /*unused*/, 
+                                            memEntryCacheMode, NULL, ref->sharedMem );
+            if (KERN_SUCCESS != err)
+                IOLog("MAP_MEM_ONLY failed %d\n", err);
+
             err = vm_map( map,
                             &ref->mapped,
                             ref->size, 0 /* mask */, 
@@ -1524,8 +1667,8 @@ IOReturn IOMemoryDescriptor::doMap(
 	vm_map_t		addressMap,
 	IOVirtualAddress *	atAddress,
 	IOOptionBits		options,
-	IOByteCount		sourceOffset = 0,
-	IOByteCount		length = 0 )
+	IOByteCount		sourceOffset,
+	IOByteCount		length )
 {
     IOReturn		err = kIOReturnSuccess;
     memory_object_t	pager;
@@ -1545,23 +1688,23 @@ IOReturn IOMemoryDescriptor::doMap(
 
         sourceAddr = getSourceSegment( sourceOffset, NULL );
         assert( sourceAddr );
-        pageOffset = sourceAddr - trunc_page( sourceAddr );
+        pageOffset = sourceAddr - trunc_page_32( sourceAddr );
 
-        ref.size = round_page( length + pageOffset );
+        ref.size = round_page_32( length + pageOffset );
 
         logical = *atAddress;
         if( options & kIOMapAnywhere) 
             // vm_map looks for addresses above here, even when VM_FLAGS_ANYWHERE
             ref.mapped = 0;
         else {
-            ref.mapped = trunc_page( logical );
+            ref.mapped = trunc_page_32( logical );
             if( (logical - ref.mapped) != pageOffset) {
                 err = kIOReturnVMError;
                 continue;
             }
         }
 
-        if( ref.sharedMem && (addressMap == kernel_map) && (kIOMemoryRequiresWire & _flags))
+        if( ref.sharedMem && (addressMap == kernel_map) && (kIOMemoryBufferPageable & _flags))
             err = IOIteratePageableMaps( ref.size, &IOMemoryDescriptorMapAlloc, &ref );
         else
             err = IOMemoryDescriptorMapAlloc( addressMap, &ref );
@@ -1608,7 +1751,7 @@ IOReturn IOMemoryDescriptor::handleFault(
     vm_size_t		page;
     IOByteCount		pageOffset;
     IOPhysicalLength	segLen;
-    IOPhysicalAddress	physAddr;
+    addr64_t		physAddr;
 
     if( !addressMap) {
 
@@ -1624,9 +1767,9 @@ IOReturn IOMemoryDescriptor::handleFault(
         return( kIOReturnSuccess );
     }
 
-    physAddr = getPhysicalSegment( sourceOffset, &segLen );
+    physAddr = getPhysicalSegment64( sourceOffset, &segLen );
     assert( physAddr );
-    pageOffset = physAddr - trunc_page( physAddr );
+    pageOffset = physAddr - trunc_page_64( physAddr );
 
     size = length + pageOffset;
     physAddr -= pageOffset;
@@ -1637,14 +1780,14 @@ IOReturn IOMemoryDescriptor::handleFault(
 	// in the middle of the loop only map whole pages
 	if( segLen >= bytes)
 	    segLen = bytes;
-	else if( segLen != trunc_page( segLen))
+	else if( segLen != trunc_page_32( segLen))
 	    err = kIOReturnVMError;
-        if( physAddr != trunc_page( physAddr))
+        if( physAddr != trunc_page_64( physAddr))
 	    err = kIOReturnBadArgument;
 
 #ifdef DEBUG
 	if( kIOLogMapping & gIOKitDebug)
-	    IOLog("_IOMemoryMap::map(%p) %08lx->%08lx:%08lx\n",
+	    IOLog("_IOMemoryMap::map(%p) %08lx->%08qx:%08lx\n",
                 addressMap, address + pageOffset, physAddr + pageOffset,
 		segLen - pageOffset);
 #endif
@@ -1656,7 +1799,7 @@ IOReturn IOMemoryDescriptor::handleFault(
 #ifdef i386  
 	/* i386 doesn't support faulting on device memory yet */
 	if( addressMap && (kIOReturnSuccess == err))
-            err = IOMapPages( addressMap, address, physAddr, segLen, options );
+            err = IOMapPages( addressMap, address, (IOPhysicalAddress) physAddr, segLen, options );
         assert( KERN_SUCCESS == err );
 	if( err)
 	    break;
@@ -1665,19 +1808,19 @@ IOReturn IOMemoryDescriptor::handleFault(
         if( pager) {
             if( reserved && reserved->pagerContig) {
                 IOPhysicalLength	allLen;
-                IOPhysicalAddress	allPhys;
+                addr64_t		allPhys;
 
-                allPhys = getPhysicalSegment( 0, &allLen );
+                allPhys = getPhysicalSegment64( 0, &allLen );
                 assert( allPhys );
-                err = device_pager_populate_object( pager, 0, trunc_page(allPhys), round_page(allLen) );
+                err = device_pager_populate_object( pager, 0, allPhys >> PAGE_SHIFT, round_page_32(allLen) );
 
             } else {
 
                 for( page = 0;
                      (page < segLen) && (KERN_SUCCESS == err);
                      page += page_size) {
-                        err = device_pager_populate_object( pager, sourceOffset + page,
-                                                            physAddr + page, page_size );
+                        err = device_pager_populate_object(pager, sourceOffset + page,
+                        	(ppnum_t)((physAddr + page) >> PAGE_SHIFT), page_size);
                 }
             }
             assert( KERN_SUCCESS == err );
@@ -1715,7 +1858,7 @@ IOReturn IOMemoryDescriptor::handleFault(
 	pageOffset = 0;
 
     } while( bytes
-	&& (physAddr = getPhysicalSegment( sourceOffset, &segLen )));
+	&& (physAddr = getPhysicalSegment64( sourceOffset, &segLen )));
 
     if( bytes)
         err = kIOReturnBadArgument;
@@ -1736,9 +1879,9 @@ IOReturn IOMemoryDescriptor::doUnmap(
                 addressMap, logical, length );
 #endif
 
-    if( (addressMap == kernel_map) || (addressMap == get_task_map(current_task()))) {
+    if( true /* && (addressMap == kernel_map) || (addressMap == get_task_map(current_task()))*/) {
 
-        if( _memEntry && (addressMap == kernel_map) && (kIOMemoryRequiresWire & _flags))
+        if( _memEntry && (addressMap == kernel_map) && (kIOMemoryBufferPageable & _flags))
             addressMap = IOPageableMapForAddress( logical );
 
         err = vm_deallocate( addressMap, logical, length );
@@ -1860,9 +2003,11 @@ void _IOMemoryMap::taskDied( void )
 // of a memory descriptors _mappings set.  This means that we
 // always have 2 references on a mapping.  When either of these mappings
 // are released we need to free ourselves.
-void _IOMemoryMap::taggedRelease(const void *tag = 0) const
+void _IOMemoryMap::taggedRelease(const void *tag) const
 {
+    LOCK;
     super::taggedRelease(tag, 2);
+    UNLOCK;
 }
 
 void _IOMemoryMap::free()
@@ -1991,7 +2136,7 @@ void IOMemoryDescriptor::free( void )
 IOMemoryMap * IOMemoryDescriptor::setMapping(
 	task_t			intoTask,
 	IOVirtualAddress	mapAddress,
-	IOOptionBits		options = 0 )
+	IOOptionBits		options )
 {
     _IOMemoryMap *		map;
 
@@ -2014,7 +2159,7 @@ IOMemoryMap * IOMemoryDescriptor::setMapping(
 }
 
 IOMemoryMap * IOMemoryDescriptor::map( 
-	IOOptionBits		options = 0 )
+	IOOptionBits		options )
 {
 
     return( makeMapping( this, kernel_task, 0,
@@ -2026,8 +2171,8 @@ IOMemoryMap * IOMemoryDescriptor::map(
 	task_t			intoTask,
 	IOVirtualAddress	toAddress,
 	IOOptionBits		options,
-	IOByteCount		offset = 0,
-	IOByteCount		length = 0 )
+	IOByteCount		offset,
+	IOByteCount		length )
 {
     if( 0 == length)
 	length = getLength();
@@ -2120,22 +2265,38 @@ OSDefineMetaClassAndStructors(IOSubMemoryDescriptor, IOMemoryDescriptor)
 
 bool IOSubMemoryDescriptor::initSubRange( IOMemoryDescriptor * parent,
 					IOByteCount offset, IOByteCount length,
-					IODirection withDirection )
+					IODirection direction )
 {
-    if( !super::init())
-	return( false );
-
     if( !parent)
 	return( false);
 
     if( (offset + length) > parent->getLength())
 	return( false);
 
+    /*
+     * We can check the _parent instance variable before having ever set it
+     * to an initial value because I/O Kit guarantees that all our instance
+     * variables are zeroed on an object's allocation.
+     */
+
+    if( !_parent) {
+	if( !super::init())
+	    return( false );
+    } else {
+	/*
+	 * An existing memory descriptor is being retargeted to
+	 * point to somewhere else.  Clean up our present state.
+	 */
+
+	_parent->release();
+	_parent = 0;
+    }
+
     parent->retain();
     _parent	= parent;
     _start	= offset;
     _length	= length;
-    _direction  = withDirection;
+    _direction  = direction;
     _tag	= parent->getTag();
 
     return( true );
@@ -2201,7 +2362,7 @@ void * IOSubMemoryDescriptor::getVirtualSegment(IOByteCount offset,
 }
 
 IOByteCount IOSubMemoryDescriptor::readBytes(IOByteCount offset,
-					void * bytes, IOByteCount withLength)
+					void * bytes, IOByteCount length)
 {
     IOByteCount	byteCount;
 
@@ -2212,14 +2373,14 @@ IOByteCount IOSubMemoryDescriptor::readBytes(IOByteCount offset,
 
     LOCK;
     byteCount = _parent->readBytes( _start + offset, bytes,
-				min(withLength, _length - offset) );
+				min(length, _length - offset) );
     UNLOCK;
 
     return( byteCount );
 }
 
 IOByteCount IOSubMemoryDescriptor::writeBytes(IOByteCount offset,
-				const void* bytes, IOByteCount withLength)
+				const void* bytes, IOByteCount length)
 {
     IOByteCount	byteCount;
 
@@ -2230,14 +2391,14 @@ IOByteCount IOSubMemoryDescriptor::writeBytes(IOByteCount offset,
 
     LOCK;
     byteCount = _parent->writeBytes( _start + offset, bytes,
-				min(withLength, _length - offset) );
+				min(length, _length - offset) );
     UNLOCK;
 
     return( byteCount );
 }
 
 IOReturn IOSubMemoryDescriptor::prepare(
-		IODirection forDirection = kIODirectionNone)
+		IODirection forDirection)
 {
     IOReturn	err;
 
@@ -2249,7 +2410,7 @@ IOReturn IOSubMemoryDescriptor::prepare(
 }
 
 IOReturn IOSubMemoryDescriptor::complete(
-		IODirection forDirection = kIODirectionNone)
+		IODirection forDirection)
 {
     IOReturn	err;
 
@@ -2293,17 +2454,17 @@ IOMemoryMap * IOSubMemoryDescriptor::makeMapping(
 
 bool
 IOSubMemoryDescriptor::initWithAddress(void *      address,
-                                    IOByteCount   withLength,
-                                    IODirection withDirection)
+                                    IOByteCount   length,
+                                    IODirection direction)
 {
     return( false );
 }
 
 bool
 IOSubMemoryDescriptor::initWithAddress(vm_address_t address,
-                                    IOByteCount    withLength,
-                                    IODirection  withDirection,
-                                    task_t       withTask)
+                                    IOByteCount    length,
+                                    IODirection  direction,
+                                    task_t       task)
 {
     return( false );
 }
@@ -2311,8 +2472,8 @@ IOSubMemoryDescriptor::initWithAddress(vm_address_t address,
 bool
 IOSubMemoryDescriptor::initWithPhysicalAddress(
 				 IOPhysicalAddress	address,
-				 IOByteCount		withLength,
-				 IODirection      	withDirection )
+				 IOByteCount		length,
+				 IODirection      	direction )
 {
     return( false );
 }
@@ -2321,9 +2482,9 @@ bool
 IOSubMemoryDescriptor::initWithRanges(
                                    	IOVirtualRange * ranges,
                                    	UInt32           withCount,
-                                   	IODirection      withDirection,
-                                   	task_t           withTask,
-                                  	bool             asReference = false)
+                                   	IODirection      direction,
+                                   	task_t           task,
+                                  	bool             asReference)
 {
     return( false );
 }
@@ -2331,8 +2492,8 @@ IOSubMemoryDescriptor::initWithRanges(
 bool
 IOSubMemoryDescriptor::initWithPhysicalRanges(	IOPhysicalRange * ranges,
                                         	UInt32           withCount,
-                                        	IODirection      withDirection,
-                                        	bool             asReference = false)
+                                        	IODirection      direction,
+                                        	bool             asReference)
 {
     return( false );
 }
@@ -2343,7 +2504,6 @@ bool IOGeneralMemoryDescriptor::serialize(OSSerialize * s) const
 {
     OSSymbol const *keys[2];
     OSObject *values[2];
-    OSDictionary *dict;
     IOVirtualRange *vcopy;
     unsigned int index, nRanges;
     bool result;
@@ -2474,8 +2634,8 @@ bool IOSubMemoryDescriptor::serialize(OSSerialize * s) const
 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
 
 OSMetaClassDefineReservedUsed(IOMemoryDescriptor, 0);
-OSMetaClassDefineReservedUnused(IOMemoryDescriptor, 1);
-OSMetaClassDefineReservedUnused(IOMemoryDescriptor, 2);
+OSMetaClassDefineReservedUsed(IOMemoryDescriptor, 1);
+OSMetaClassDefineReservedUsed(IOMemoryDescriptor, 2);
 OSMetaClassDefineReservedUnused(IOMemoryDescriptor, 3);
 OSMetaClassDefineReservedUnused(IOMemoryDescriptor, 4);
 OSMetaClassDefineReservedUnused(IOMemoryDescriptor, 5);
@@ -2490,6 +2650,6 @@ OSMetaClassDefineReservedUnused(IOMemoryDescriptor, 13);
 OSMetaClassDefineReservedUnused(IOMemoryDescriptor, 14);
 OSMetaClassDefineReservedUnused(IOMemoryDescriptor, 15);
 
-/* inline function implementation */
+/* ex-inline function implementation */
 IOPhysicalAddress IOMemoryDescriptor::getPhysicalAddress()
         { return( getPhysicalSegment( 0, 0 )); }
diff --git a/iokit/Kernel/IOMultiMemoryDescriptor.cpp b/iokit/Kernel/IOMultiMemoryDescriptor.cpp
index 98eb04d82..3e31f16b8 100644
--- a/iokit/Kernel/IOMultiMemoryDescriptor.cpp
+++ b/iokit/Kernel/IOMultiMemoryDescriptor.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Kernel/IONVRAM.cpp b/iokit/Kernel/IONVRAM.cpp
index 738a03cfa..fb6ceb5cd 100644
--- a/iokit/Kernel/IONVRAM.cpp
+++ b/iokit/Kernel/IONVRAM.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -1421,18 +1424,23 @@ IOReturn IODTNVRAM::readNVRAMPropertyType1(IORegistryEntry *entry,
       nvPath = start;
     else if (nvName == 0)
       nvName = start;
-    else if (entry ==
-	     IORegistryEntry::fromPath((const char *) nvPath, gIODTPlane)) {
-      *name = OSSymbol::withCString((const char *) nvName);
-      *value = unescapeBytesToData(start, where - start - 1);
-      if ((*name != 0) && (*value != 0))
-        err = kIOReturnSuccess;
-      else
-        err = kIOReturnNoMemory;
-      break;
-    } else
+    else {
+      IORegistryEntry * compareEntry = IORegistryEntry::fromPath((const char *) nvPath, gIODTPlane);
+      if (entry == compareEntry) {
+        if (compareEntry)
+          compareEntry->release();
+	*name = OSSymbol::withCString((const char *) nvName);
+	*value = unescapeBytesToData(start, where - start - 1);
+	if ((*name != 0) && (*value != 0))
+	  err = kIOReturnSuccess;
+	else
+	  err = kIOReturnNoMemory;
+	break;
+      }
+      if (compareEntry)
+        compareEntry->release();
       nvPath = nvName = 0;
-    
+    }
     start = where;
   }
 
@@ -1475,15 +1483,21 @@ IOReturn IODTNVRAM::writeNVRAMPropertyType1(IORegistryEntry *entry,
         nvPath = start;
       else if (nvName == 0)
         nvName = start;
-      else if (entry ==
-                IORegistryEntry::fromPath((const char *) nvPath, gIODTPlane)) {
-        // delete old property (nvPath -> where)
-        data = OSData::withBytes(propStart, nvPath - propStart);
-        if (data)
-          ok &= data->appendBytes(where, end - where);
-        break;
-      } else
+      else {
+        IORegistryEntry * compareEntry = IORegistryEntry::fromPath((const char *) nvPath, gIODTPlane);
+        if (entry == compareEntry) {
+          if (compareEntry)
+             compareEntry->release();
+           // delete old property (nvPath -> where)
+           data = OSData::withBytes(propStart, nvPath - propStart);
+           if (data)
+             ok &= data->appendBytes(where, end - where);
+	   break;
+        }
+        if (compareEntry)
+          compareEntry->release();
         nvPath = nvName = 0;
+      }
         
       start = where;
     }
diff --git a/iokit/Kernel/IOPMPagingPlexus.cpp b/iokit/Kernel/IOPMPagingPlexus.cpp
index 187e0a1b7..88e197d9c 100644
--- a/iokit/Kernel/IOPMPagingPlexus.cpp
+++ b/iokit/Kernel/IOPMPagingPlexus.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Kernel/IOPMPowerSource.cpp b/iokit/Kernel/IOPMPowerSource.cpp
index c91b1ea3d..b9db0f649 100644
--- a/iokit/Kernel/IOPMPowerSource.cpp
+++ b/iokit/Kernel/IOPMPowerSource.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Kernel/IOPMPowerSourceList.cpp b/iokit/Kernel/IOPMPowerSourceList.cpp
index dc6c949fe..1a968d588 100644
--- a/iokit/Kernel/IOPMPowerSourceList.cpp
+++ b/iokit/Kernel/IOPMPowerSourceList.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Kernel/IOPMchangeNoteList.cpp b/iokit/Kernel/IOPMchangeNoteList.cpp
index 6c529ca80..5d8d94c8b 100644
--- a/iokit/Kernel/IOPMchangeNoteList.cpp
+++ b/iokit/Kernel/IOPMchangeNoteList.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Kernel/IOPMinformee.cpp b/iokit/Kernel/IOPMinformee.cpp
index 8f7452cf7..9f0bcc537 100644
--- a/iokit/Kernel/IOPMinformee.cpp
+++ b/iokit/Kernel/IOPMinformee.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Kernel/IOPMinformeeList.cpp b/iokit/Kernel/IOPMinformeeList.cpp
index 48a870457..a9ea2fbcf 100644
--- a/iokit/Kernel/IOPMinformeeList.cpp
+++ b/iokit/Kernel/IOPMinformeeList.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Kernel/IOPMpmChild.cpp b/iokit/Kernel/IOPMpmChild.cpp
index 0b34a9e45..69bd66323 100644
--- a/iokit/Kernel/IOPMpmChild.cpp
+++ b/iokit/Kernel/IOPMpmChild.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Kernel/IOPlatformExpert.cpp b/iokit/Kernel/IOPlatformExpert.cpp
index e41e3133b..bc3c0e527 100644
--- a/iokit/Kernel/IOPlatformExpert.cpp
+++ b/iokit/Kernel/IOPlatformExpert.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -23,16 +26,19 @@
  * HISTORY
  */
  
-#include <IOKit/system.h>
-#include <IOKit/IOPlatformExpert.h>
 #include <IOKit/IOCPU.h>
 #include <IOKit/IODeviceTreeSupport.h>
-#include <IOKit/IORangeAllocator.h>
-#include <IOKit/IONVRAM.h>
 #include <IOKit/IOKitDebug.h>
+#include <IOKit/IOMapper.h>
+#include <IOKit/IOMessage.h>
+#include <IOKit/IONVRAM.h>
+#include <IOKit/IOPlatformExpert.h>
+#include <IOKit/IORangeAllocator.h>
 #include <IOKit/IOWorkLoop.h>
 #include <IOKit/pwr_mgt/RootDomain.h>
-#include <IOKit/IOMessage.h>
+
+#include <IOKit/system.h>
+
 #include <libkern/c++/OSContainers.h>
 
 
@@ -88,6 +94,23 @@ bool IOPlatformExpert::start( IOService * provider )
     
     if (!super::start(provider))
       return false;
+
+    // Register the presence or lack thereof a system 
+    // PCI address mapper with the IOMapper class
+
+#if 1
+    IORegistryEntry * regEntry = IORegistryEntry::fromPath("/u3/dart", gIODTPlane);
+    if (!regEntry)
+	regEntry = IORegistryEntry::fromPath("/dart", gIODTPlane);
+    if (regEntry) {
+	int debugFlags;
+	if (!PE_parse_boot_arg("dart", &debugFlags) || debugFlags)
+	    setProperty(kIOPlatformMapperPresentKey, kOSBooleanTrue);
+	regEntry->release();
+    }
+#endif
+
+    IOMapper::setMapperRequired(0 != getProperty(kIOPlatformMapperPresentKey));
     
     gIOInterruptControllers = OSDictionary::withCapacity(1);
     gIOInterruptControllersLock = IOLockAlloc();
@@ -152,7 +175,7 @@ IOService * IOPlatformExpert::createNub( OSDictionary * from )
 }
 
 bool IOPlatformExpert::compareNubName( const IOService * nub,
-				OSString * name, OSString ** matched = 0 ) const
+				OSString * name, OSString ** matched) const
 {
     return( nub->IORegistryEntry::compareName( name, matched ));
 }
@@ -1061,7 +1084,7 @@ OSMetaClassDefineReservedUnused(IOPlatformExpertDevice,  3);
 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
 
 bool IOPlatformExpertDevice::compareName( OSString * name,
-                                        OSString ** matched = 0 ) const
+                                        OSString ** matched) const
 {
     return( IODTCompareNubName( this, name, matched ));
 }
@@ -1123,7 +1146,7 @@ OSMetaClassDefineReservedUnused(IOPlatformDevice,  3);
 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
 
 bool IOPlatformDevice::compareName( OSString * name,
-					OSString ** matched = 0 ) const
+					OSString ** matched) const
 {
     return( ((IOPlatformExpert *)getProvider())->
 		compareNubName( this, name, matched ));
diff --git a/iokit/Kernel/IOPowerConnection.cpp b/iokit/Kernel/IOPowerConnection.cpp
index cc3242765..1f4285483 100644
--- a/iokit/Kernel/IOPowerConnection.cpp
+++ b/iokit/Kernel/IOPowerConnection.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Kernel/IORangeAllocator.cpp b/iokit/Kernel/IORangeAllocator.cpp
index 26f6161ac..0dbea067d 100644
--- a/iokit/Kernel/IORangeAllocator.cpp
+++ b/iokit/Kernel/IORangeAllocator.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Kernel/IORegistryEntry.cpp b/iokit/Kernel/IORegistryEntry.cpp
index 5d1e530f1..f95427287 100644
--- a/iokit/Kernel/IORegistryEntry.cpp
+++ b/iokit/Kernel/IORegistryEntry.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Kernel/IOService.cpp b/iokit/Kernel/IOService.cpp
index 919ea16fa..e2fdab2c2 100644
--- a/iokit/Kernel/IOService.cpp
+++ b/iokit/Kernel/IOService.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Kernel/IOServicePM.cpp b/iokit/Kernel/IOServicePM.cpp
index 0f381dbfb..a8542bc7d 100644
--- a/iokit/Kernel/IOServicePM.cpp
+++ b/iokit/Kernel/IOServicePM.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -633,7 +636,7 @@ IOReturn IOService::removePowerChild ( IOPowerConnection * theNub )
             }
         }
     }
-    
+
     theNub->release();
 
     if ( (pm_vars->theControllingDriver == NULL) ||	// if not fully initialized
@@ -642,6 +645,10 @@ IOReturn IOService::removePowerChild ( IOPowerConnection * theNub )
         return IOPMNoErr;				// we can do no more
     }
 
+    // Perhaps the departing child was holding up idle or system sleep - we need to re-evaluate our
+    // childrens' requests. Clear and re-calculate our kIOPMChildClamp and kIOPMChildClamp2 bits.
+    rebuildChildClampBits();
+
     computeDesiredState();				// this may be different now
     changeState();					// change state if we can now tolerate lower power
 
@@ -1082,6 +1089,54 @@ void IOService::setParentInfo ( IOPMPowerFlags newPowerStateFlags, IOPowerConnec
     IOLockUnlock(pm_vars->parentLock);
 }
 
+//*********************************************************************************
+// rebuildChildClampBits
+//
+// The ChildClamp bits (kIOPMChildClamp & kIOPMChildClamp2) in our capabilityFlags
+// indicate that one of our children (or grandchildren or great-grandchildren or ...)
+// doesn't support idle or system sleep in its current state. Since we don't track the
+// origin of each bit, every time any child changes state we have to clear these bits 
+// and rebuild them.
+//*********************************************************************************
+
+void IOService::rebuildChildClampBits(void)
+{
+    unsigned long	i;
+    OSIterator *	iter;
+    OSObject *		next;
+    IOPowerConnection *	connection;
+    
+    
+    // A child's desires has changed.  We need to rebuild the child-clamp bits in our
+    // power state array.  Start by clearing the bits in each power state.
+    
+    for ( i = 0; i < pm_vars->theNumberOfPowerStates; i++ ) {
+        pm_vars->thePowerStates[i].capabilityFlags &= ~(kIOPMChildClamp | kIOPMChildClamp2);
+    }
+
+    // Now loop through the children.  When we encounter the calling child, save
+    // the computed state as this child's desire.  And while we're at it, set the ChildClamp bits
+    // in any of our states that some child has requested with clamp on.
+
+    iter = getChildIterator(gIOPowerPlane);
+
+    if ( iter ) 
+    {
+        while ( (next = iter->getNextObject()) ) 
+        {
+            if ( (connection = OSDynamicCast(IOPowerConnection,next)) ) 
+            {
+                if ( connection->getPreventIdleSleepFlag() )
+                    pm_vars->thePowerStates[connection->getDesiredDomainState()].capabilityFlags |= kIOPMChildClamp;
+                if ( connection->getPreventSystemSleepFlag() )
+                    pm_vars->thePowerStates[connection->getDesiredDomainState()].capabilityFlags |= kIOPMChildClamp2;
+            }
+        }
+        iter->release();
+    }
+
+}
+
 
 //*********************************************************************************
 // requestPowerDomainState
@@ -1166,17 +1221,8 @@ IOReturn IOService::requestPowerDomainState ( IOPMPowerFlags desiredState, IOPow
     
     IOLockLock(pm_vars->childLock);
 
-// A child's desires has changed.  We need to rebuild the child-clamp bits in our
-// power state array.  Start by clearing the bits in each power state.
-    
-    for ( i = 0; i < pm_vars->theNumberOfPowerStates; i++ ) {
-        pm_vars->thePowerStates[i].capabilityFlags &= ~(kIOPMChildClamp | kIOPMChildClamp2);
-    }
-
-// Now loop through the children.  When we encounter the calling child, save
-// the computed state as this child's desire.  And while we're at it, set the ChildClamp bits
-// in any of our states that some child has requested with clamp on.
-
+    // Now loop through the children.  When we encounter the calling child, save
+    // the computed state as this child's desire.
     iter = getChildIterator(gIOPowerPlane);
 
     if ( iter ) {
@@ -1188,16 +1234,14 @@ IOReturn IOService::requestPowerDomainState ( IOPMPowerFlags desiredState, IOPow
                     connection->setPreventSystemSleepFlag(desiredState & kIOPMPreventSystemSleep);
                     connection->setChildHasRequestedPower();
                 }
-                if ( connection->getPreventIdleSleepFlag() ) {
-                    pm_vars->thePowerStates[connection->getDesiredDomainState()].capabilityFlags |= kIOPMChildClamp;
-                }
-                if ( connection->getPreventSystemSleepFlag() ) {
-                    pm_vars->thePowerStates[connection->getDesiredDomainState()].capabilityFlags |= kIOPMChildClamp2;
-                }
             }
         }
         iter->release();
     }
+
+    // Since a child's power requirements may have changed, clear and rebuild 
+    // kIOPMChildClamp and kIOPMChildClamp2 (idle and system sleep clamps)
+    rebuildChildClampBits();
         
     IOLockUnlock(pm_vars->childLock);
     
@@ -3224,8 +3268,11 @@ IOReturn IOService::ask_parent ( unsigned long requestedState )
         ourRequest |= kIOPMPreventSystemSleep;
     }
     
-    if ( priv->previousRequest == ourRequest ) {	// is this a new desire?
-        return IOPMNoErr;				// no, the parent knows already, just return
+    // is this a new desire?
+    if ( priv->previousRequest == ourRequest )
+    {	
+        // no, the parent knows already, just return
+        return IOPMNoErr;				
     }
 
     if (  priv->we_are_root ) {
diff --git a/iokit/Kernel/IOServicePrivate.h b/iokit/Kernel/IOServicePrivate.h
index c74307f6b..d9a341f47 100644
--- a/iokit/Kernel/IOServicePrivate.h
+++ b/iokit/Kernel/IOServicePrivate.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Kernel/IOStartIOKit.cpp b/iokit/Kernel/IOStartIOKit.cpp
index 1121d5ef3..a5ce38079 100644
--- a/iokit/Kernel/IOStartIOKit.cpp
+++ b/iokit/Kernel/IOStartIOKit.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -109,6 +112,8 @@ void IOKitResetTime( void )
     clock_initialize_calendar();
 }
 
+// From <osfmk/kern/debug.c>
+extern int debug_mode;
 
 void StartIOKit( void * p1, void * p2, void * p3, void * p4 )
 {
@@ -126,6 +131,11 @@ void StartIOKit( void * p1, void * p2, void * p3, void * p4 )
 
     if( PE_parse_boot_arg( "io", &debugFlags ))
 	gIOKitDebug = debugFlags;
+
+    // Check for the log synchronous bit set in io
+    if (gIOKitDebug & kIOLogSynchronous)
+        debug_mode = true;
+
     //
     // Have to start IOKit environment before we attempt to start
     // the C++ runtime environment.  At some stage we have to clean up
@@ -138,7 +148,6 @@ void StartIOKit( void * p1, void * p2, void * p3, void * p4 )
 
     IOLog("_cppInit done\n");
 
-
    /*****
     * Declare the fake kmod_info structs for built-in components
     * that must be tracked as independent units for dependencies.
diff --git a/iokit/Kernel/IOStringFuncs.c b/iokit/Kernel/IOStringFuncs.c
index 46e7a246e..1009231d9 100644
--- a/iokit/Kernel/IOStringFuncs.c
+++ b/iokit/Kernel/IOStringFuncs.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Kernel/IOSyncer.cpp b/iokit/Kernel/IOSyncer.cpp
index 92e1d0741..2a9cf5465 100644
--- a/iokit/Kernel/IOSyncer.cpp
+++ b/iokit/Kernel/IOSyncer.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Kernel/IOTimerEventSource.cpp b/iokit/Kernel/IOTimerEventSource.cpp
index 7f42f2471..3c86e6709 100644
--- a/iokit/Kernel/IOTimerEventSource.cpp
+++ b/iokit/Kernel/IOTimerEventSource.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Kernel/IOUserClient.cpp b/iokit/Kernel/IOUserClient.cpp
index 06f700f5b..446932b6a 100644
--- a/iokit/Kernel/IOUserClient.cpp
+++ b/iokit/Kernel/IOUserClient.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -68,6 +71,8 @@ extern ipc_port_t master_device_port;
 extern void iokit_retain_port( ipc_port_t port );
 extern void iokit_release_port( ipc_port_t port );
 
+extern kern_return_t iokit_switch_object_port( ipc_port_t port, io_object_t obj, ipc_kobject_type_t type );
+
 #include <vm/vm_map.h>
 
 } /* extern "C" */
@@ -219,7 +224,36 @@ void IOMachPort::releasePortForObject( OSObject * obj,
 void IOUserClient::destroyUserReferences( OSObject * obj )
 {
     IOMachPort::releasePortForObject( obj, IKOT_IOKIT_OBJECT );
-    IOMachPort::releasePortForObject( obj, IKOT_IOKIT_CONNECT );
+
+    // panther, 3160200
+    // IOMachPort::releasePortForObject( obj, IKOT_IOKIT_CONNECT );
+
+    OSDictionary * dict;
+
+    IOTakeLock( gIOObjectPortLock);
+    obj->retain();
+
+    if( (dict = IOMachPort::dictForType( IKOT_IOKIT_CONNECT )))
+    {
+	IOMachPort * port;
+	port = (IOMachPort *) dict->getObject( (const OSSymbol *) obj );
+	if (port)
+	{
+	    IOUserClient * uc;
+	    if ((uc = OSDynamicCast(IOUserClient, obj)) && uc->mappings)
+	    {
+		dict->setObject((const OSSymbol *) uc->mappings, port);
+		iokit_switch_object_port(port->port, uc->mappings, IKOT_IOKIT_CONNECT);
+
+		uc->mappings->release();
+		uc->mappings = 0;
+	    }
+	    dict->removeObject( (const OSSymbol *) obj );
+	}
+    }
+    obj->release();
+    IOUnlock( gIOObjectPortLock);
+
 }
 
 mach_port_name_t IOMachPort::makeSendRightForTask( task_t task,
@@ -288,8 +322,7 @@ iokit_client_died( io_object_t obj, ipc_port_t /* port */,
     if( (IKOT_IOKIT_CONNECT == type)
      && (client = OSDynamicCast( IOUserClient, obj )))
 	client->clientDied();
-    else if( (IKOT_IOKIT_OBJECT == type)
-     && (map = OSDynamicCast( IOMemoryMap, obj )))
+    if( (map = OSDynamicCast( IOMemoryMap, obj )))
 	map->taskDied();
 
     return( kIOReturnSuccess );
@@ -1642,6 +1675,10 @@ kern_return_t is_io_service_open(
 kern_return_t is_io_service_close(
 	io_object_t connection )
 {
+    OSSet * mappings;
+    if ((mappings = OSDynamicCast(OSSet, connection)))
+	return( kIOReturnSuccess );
+
     CHECK( IOUserClient, connection, client );
 
     client->clientClose();
diff --git a/iokit/Kernel/IOWorkLoop.cpp b/iokit/Kernel/IOWorkLoop.cpp
index 197a09512..a6bfd4673 100644
--- a/iokit/Kernel/IOWorkLoop.cpp
+++ b/iokit/Kernel/IOWorkLoop.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Kernel/PMmisc.cpp b/iokit/Kernel/PMmisc.cpp
index 0ab16cfbe..aa332a73b 100644
--- a/iokit/Kernel/PMmisc.cpp
+++ b/iokit/Kernel/PMmisc.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Kernel/i386/IOAsmSupport.s b/iokit/Kernel/i386/IOAsmSupport.s
index 4483a5d1f..e74e9856c 100644
--- a/iokit/Kernel/i386/IOAsmSupport.s
+++ b/iokit/Kernel/i386/IOAsmSupport.s
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Kernel/i386/IOSharedLock.s b/iokit/Kernel/i386/IOSharedLock.s
index de84a9173..58b50f4de 100644
--- a/iokit/Kernel/i386/IOSharedLock.s
+++ b/iokit/Kernel/i386/IOSharedLock.s
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Kernel/ppc/IOAsmSupport.s b/iokit/Kernel/ppc/IOAsmSupport.s
index 603f7fd73..4d922040c 100644
--- a/iokit/Kernel/ppc/IOAsmSupport.s
+++ b/iokit/Kernel/ppc/IOAsmSupport.s
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Kernel/ppc/IODBDMA.cpp b/iokit/Kernel/ppc/IODBDMA.cpp
index 5a3d9d38e..6e09b2fdd 100644
--- a/iokit/Kernel/ppc/IODBDMA.cpp
+++ b/iokit/Kernel/ppc/IODBDMA.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Kernel/ppc/IOSharedLock.s b/iokit/Kernel/ppc/IOSharedLock.s
index de84a9173..58b50f4de 100644
--- a/iokit/Kernel/ppc/IOSharedLock.s
+++ b/iokit/Kernel/ppc/IOSharedLock.s
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/KernelConfigTables.cpp b/iokit/KernelConfigTables.cpp
index 1eedcc6df..88a6f899d 100644
--- a/iokit/KernelConfigTables.cpp
+++ b/iokit/KernelConfigTables.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -28,16 +31,16 @@
  */
 const char * gIOKernelKmods =
 "{
-    'com.apple.kernel'                         = '6.2';
-    'com.apple.kernel.bsd'                     = '6.2';
-    'com.apple.kernel.iokit'                   = '6.2';
-    'com.apple.kernel.libkern'                 = '6.2';
-    'com.apple.kernel.mach'                    = '6.2';
-    'com.apple.iokit.IOADBFamily'              = '6.2';
-    'com.apple.iokit.IONVRAMFamily'            = '6.2';
-    'com.apple.iokit.IOSystemManagementFamily' = '6.2';
-    'com.apple.iokit.ApplePlatformFamily'      = '6.2';
-    'com.apple.driver.AppleNMI'                = '6.2';
+    'com.apple.kernel'                         = '6.7.5';
+    'com.apple.kernel.bsd'                     = '6.7.5';
+    'com.apple.kernel.iokit'                   = '6.7.5';
+    'com.apple.kernel.libkern'                 = '6.7.5';
+    'com.apple.kernel.mach'                    = '6.7.5';
+    'com.apple.iokit.IOADBFamily'              = '6.7.5';
+    'com.apple.iokit.IONVRAMFamily'            = '6.7.5';
+    'com.apple.iokit.IOSystemManagementFamily' = '6.7.5';
+    'com.apple.iokit.ApplePlatformFamily'      = '6.7.5';
+    'com.apple.driver.AppleNMI'                = '6.7.5';
 }";
 
 
diff --git a/iokit/Tests/TestCollections.cpp b/iokit/Tests/TestCollections.cpp
index ea7f556f0..2a6d22ec0 100644
--- a/iokit/Tests/TestCollections.cpp
+++ b/iokit/Tests/TestCollections.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Tests/TestContainers.cpp b/iokit/Tests/TestContainers.cpp
index 6641fc6a7..6cec00c35 100644
--- a/iokit/Tests/TestContainers.cpp
+++ b/iokit/Tests/TestContainers.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Tests/TestDevice.cpp b/iokit/Tests/TestDevice.cpp
index effbab484..8ae6068b4 100644
--- a/iokit/Tests/TestDevice.cpp
+++ b/iokit/Tests/TestDevice.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Tests/Tests.cpp b/iokit/Tests/Tests.cpp
index 5e570cc27..b136e05ef 100644
--- a/iokit/Tests/Tests.cpp
+++ b/iokit/Tests/Tests.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/Tests/Tests.h b/iokit/Tests/Tests.h
index 99c6033fe..1846f47da 100644
--- a/iokit/Tests/Tests.h
+++ b/iokit/Tests/Tests.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/bsddev/IOKitBSDInit.cpp b/iokit/bsddev/IOKitBSDInit.cpp
index c125eaeae..0900a0985 100644
--- a/iokit/bsddev/IOKitBSDInit.cpp
+++ b/iokit/bsddev/IOKitBSDInit.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -36,6 +39,8 @@ extern "C" {
 // how long to wait for matching root device, secs
 #define ROOTDEVICETIMEOUT	60
 
+extern dev_t mdevadd(int devid, ppnum_t base, unsigned int size, int phys);
+extern dev_t mdevlookup(int devid);
 
 kern_return_t
 IOKitBSDInit( void )
@@ -324,6 +329,8 @@ OSDictionary * IOOFPathMatching( const char * path, char * buf, int maxLen )
 
 }
 
+static int didRam = 0;
+
 kern_return_t IOFindBSDRoot( char * rootName,
 				dev_t * root, u_int32_t * oflags )
 {
@@ -334,6 +341,7 @@ kern_return_t IOFindBSDRoot( char * rootName,
     OSString *		iostr;
     OSNumber *		off;
     OSData *		data = 0;
+    UInt32		*ramdParms = 0;
 
     UInt32		flags = 0;
     int			minor, major;
@@ -346,6 +354,9 @@ kern_return_t IOFindBSDRoot( char * rootName,
     bool		debugInfoPrintedOnce = false;
 
     static int		mountAttempts = 0;
+				
+	int xchar, dchar;
+				
 
     if( mountAttempts++)
 	IOSleep( 5 * 1000 );
@@ -361,17 +372,15 @@ kern_return_t IOFindBSDRoot( char * rootName,
 
     do {
         if( (regEntry = IORegistryEntry::fromPath( "/chosen", gIODTPlane ))) {
-	    data = (OSData *) regEntry->getProperty( "rootpath" );
-	    regEntry->release();
-	    if( data)
-	    continue;
-	}
+			data = (OSData *) regEntry->getProperty( "rootpath" );
+			regEntry->release();
+			if( data) continue;
+		}
         if( (regEntry = IORegistryEntry::fromPath( "/options", gIODTPlane ))) {
-	    data = (OSData *) regEntry->getProperty( "boot-file" );
-	    regEntry->release();
-	    if( data)
-	    continue;
-	}
+			data = (OSData *) regEntry->getProperty( "boot-file" );
+			regEntry->release();
+			if( data) continue;
+		}
     } while( false );
 
     if( data)
@@ -379,14 +388,65 @@ kern_return_t IOFindBSDRoot( char * rootName,
 
     if( rdBootVar[0] == '*') {
         look = rdBootVar + 1;
-	forceNet = false;
+		forceNet = false;
     } else {
         if( (regEntry = IORegistryEntry::fromPath( "/", gIODTPlane ))) {
             forceNet = (0 != regEntry->getProperty( "net-boot" ));
-	    regEntry->release();
-	}
+	    	regEntry->release();
+		}
     }
 
+
+
+//
+//	See if we have a RAMDisk property in /chosen/memory-map.  If so, make it into a device.
+//	It will become /dev/mdx, where x is 0-f. 
+//
+
+	if(!didRam) {												/* Have we already build this ram disk? */
+		didRam = 1;												/* Remember we did this */
+		if((regEntry = IORegistryEntry::fromPath( "/chosen/memory-map", gIODTPlane ))) {	/* Find the map node */
+			data = (OSData *)regEntry->getProperty("RAMDisk");	/* Find the ram disk, if there */
+			if(data) {											/* We found one */
+
+				ramdParms = (UInt32 *)data->getBytesNoCopy();	/* Point to the ram disk base and size */
+				(void)mdevadd(-1, ramdParms[0] >> 12, ramdParms[1] >> 12, 0);	/* Initialize it and pass back the device number */
+			}
+			regEntry->release();								/* Toss the entry */
+		}
+	}
+	
+//
+//	Now check if we are trying to root on a memory device
+//
+
+	if((rdBootVar[0] == 'm') && (rdBootVar[1] == 'd') && (rdBootVar[3] == 0)) {
+		dchar = xchar = rdBootVar[2];							/* Get the actual device */
+		if((xchar >= '0') && (xchar <= '9')) xchar = xchar - '0';	/* If digit, convert */
+		else {
+			xchar = xchar & ~' ';								/* Fold to upper case */
+			if((xchar >= 'A') && (xchar <= 'F')) {				/* Is this a valid digit? */
+				xchar = (xchar & 0xF) + 9;						/* Convert the hex digit */
+				dchar = dchar | ' ';							/* Fold to lower case */
+			}
+			else xchar = -1;									/* Show bogus */
+		}
+		if(xchar >= 0) {										/* Do we have a valid memory device name? */
+			*root = mdevlookup(xchar);							/* Find the device number */
+			if(*root >= 0) {									/* Did we find one? */
+
+				rootName[0] = 'm';								/* Build root name */
+				rootName[1] = 'd';								/* Build root name */
+				rootName[2] = dchar;							/* Build root name */
+				rootName[3] = 0;								/* Build root name */
+				IOLog("BSD root: %s, major %d, minor %d\n", rootName, major(*root), minor(*root));
+				*oflags = 0;									/* Show that this is not network */
+				goto iofrootx;									/* Join common exit... */
+			}
+			panic("IOFindBSDRoot: specified root memory device, %s, has not been configured\n", rdBootVar);	/* Not there */
+		}
+	}
+
     if( look) {
 	// from OpenFirmware path
 	IOLog("From path: \"%s\", ", look);
@@ -397,8 +457,8 @@ kern_return_t IOFindBSDRoot( char * rootName,
             matching = IODiskMatching( look, str, kMaxPathBuf );
         }
     }
-
-    if( (!matching) && rdBootVar[0] ) {
+    
+      if( (!matching) && rdBootVar[0] ) {
 	// by BSD name
 	look = rdBootVar;
 	if( look[0] == '*')
@@ -510,6 +570,7 @@ kern_return_t IOFindBSDRoot( char * rootName,
 
     IOFree( str,  kMaxPathBuf + kMaxBootVar );
 
+iofrootx:
     if( (gIOKitDebug & (kIOLogDTree | kIOLogServiceTree | kIOLogMemory)) && !debugInfoPrintedOnce) {
 
 	IOService::getPlatform()->waitQuiet();
diff --git a/iokit/bsddev/IOKitBSDInit.h b/iokit/bsddev/IOKitBSDInit.h
index 98606f650..89b79b5cc 100644
--- a/iokit/bsddev/IOKitBSDInit.h
+++ b/iokit/bsddev/IOKitBSDInit.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/conf/Makefile.template b/iokit/conf/Makefile.template
index 35daa9e5a..28c5758c4 100644
--- a/iokit/conf/Makefile.template
+++ b/iokit/conf/Makefile.template
@@ -28,9 +28,12 @@ include $(MakeInc_def)
 #
 CFLAGS+= -DKERNEL -DDRIVER_PRIVATE				\
 	-Wall -Wno-four-char-constants -fno-common		\
-	-DIOMATCHDEBUG=1 -DIOALLOCDEBUG=1 -DIOASSERT=0		\
+	-DIOMATCHDEBUG=1 -DIOALLOCDEBUG=1			\
 #-DIOKITDEBUG=-1
 
+CFLAGS_RELEASE += -DIOASSERT=0
+CFLAGS_DEBUG += -DIOASSERT=1
+
 SFLAGS+= -DKERNEL
 
 #
diff --git a/iokit/conf/files b/iokit/conf/files
index bdaf03c11..6c0cf0aed 100644
--- a/iokit/conf/files
+++ b/iokit/conf/files
@@ -37,6 +37,7 @@ iokit/Kernel/IOFilterInterruptEventSource.cpp		optional iokitcpp
 iokit/Kernel/IOTimerEventSource.cpp			optional iokitcpp
 
 iokit/Kernel/IODeviceMemory.cpp				optional iokitcpp
+iokit/Kernel/IOMapper.cpp				optional iokitcpp
 iokit/Kernel/IOMemoryDescriptor.cpp			optional iokitcpp
 iokit/Kernel/IOMemoryCursor.cpp				optional iokitcpp
 iokit/Kernel/IOBufferMemoryDescriptor.cpp		optional iokitcpp
diff --git a/iokit/conf/version.minor b/iokit/conf/version.minor
index 0cfbf0888..7f8f011eb 100644
--- a/iokit/conf/version.minor
+++ b/iokit/conf/version.minor
@@ -1 +1 @@
-2
+7
diff --git a/iokit/conf/version.variant b/iokit/conf/version.variant
index e69de29bb..7ed6ff82d 100644
--- a/iokit/conf/version.variant
+++ b/iokit/conf/version.variant
@@ -0,0 +1 @@
+5
diff --git a/iokit/include/DeviceTree.h b/iokit/include/DeviceTree.h
index ef2a616b8..46700f581 100644
--- a/iokit/include/DeviceTree.h
+++ b/iokit/include/DeviceTree.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/include/architecture/i386/kernBootStruct.h b/iokit/include/architecture/i386/kernBootStruct.h
index 5afc85d65..21940a996 100644
--- a/iokit/include/architecture/i386/kernBootStruct.h
+++ b/iokit/include/architecture/i386/kernBootStruct.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/include/architecture/i386/pio.h b/iokit/include/architecture/i386/pio.h
index 408aac2bc..3897a792a 100644
--- a/iokit/include/architecture/i386/pio.h
+++ b/iokit/include/architecture/i386/pio.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/include/assert.h b/iokit/include/assert.h
index 141036a77..3ed9f2721 100644
--- a/iokit/include/assert.h
+++ b/iokit/include/assert.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/include/bsddev/EventShmemLock.h b/iokit/include/bsddev/EventShmemLock.h
index 4ab305b6c..302b178e3 100644
--- a/iokit/include/bsddev/EventShmemLock.h
+++ b/iokit/include/bsddev/EventShmemLock.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/include/bsddev/ev_keymap.h b/iokit/include/bsddev/ev_keymap.h
index a6f9002a8..12451f34c 100644
--- a/iokit/include/bsddev/ev_keymap.h
+++ b/iokit/include/bsddev/ev_keymap.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/include/bsddev/ev_types.h b/iokit/include/bsddev/ev_types.h
index 91ffc7f01..76ca62d59 100644
--- a/iokit/include/bsddev/ev_types.h
+++ b/iokit/include/bsddev/ev_types.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/include/bsddev/event.h b/iokit/include/bsddev/event.h
index 47520fab5..a94541b1e 100644
--- a/iokit/include/bsddev/event.h
+++ b/iokit/include/bsddev/event.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/include/bsddev/evio.h b/iokit/include/bsddev/evio.h
index e797c040d..22e3fa11e 100644
--- a/iokit/include/bsddev/evio.h
+++ b/iokit/include/bsddev/evio.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/include/bsddev/evsio.h b/iokit/include/bsddev/evsio.h
index e3b799153..4165734a9 100644
--- a/iokit/include/bsddev/evsio.h
+++ b/iokit/include/bsddev/evsio.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/include/bsddev/i386/EventShmemLock.h b/iokit/include/bsddev/i386/EventShmemLock.h
index f8d4c1074..e3982cd83 100644
--- a/iokit/include/bsddev/i386/EventShmemLock.h
+++ b/iokit/include/bsddev/i386/EventShmemLock.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/include/bsddev/i386/event.h b/iokit/include/bsddev/i386/event.h
index 588b60c12..3c6b8febd 100644
--- a/iokit/include/bsddev/i386/event.h
+++ b/iokit/include/bsddev/i386/event.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/include/bsddev/i386/evio.h b/iokit/include/bsddev/i386/evio.h
index d577d8a9f..a50e00718 100644
--- a/iokit/include/bsddev/i386/evio.h
+++ b/iokit/include/bsddev/i386/evio.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/include/bsddev/i386/evsio.h b/iokit/include/bsddev/i386/evsio.h
index e70408425..993c89ed9 100644
--- a/iokit/include/bsddev/i386/evsio.h
+++ b/iokit/include/bsddev/i386/evsio.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/include/bsddev/machine/EventShmemLock.h b/iokit/include/bsddev/machine/EventShmemLock.h
index 3d14ddf25..e0626692a 100644
--- a/iokit/include/bsddev/machine/EventShmemLock.h
+++ b/iokit/include/bsddev/machine/EventShmemLock.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/include/bsddev/machine/event.h b/iokit/include/bsddev/machine/event.h
index 622867427..6b366d70c 100644
--- a/iokit/include/bsddev/machine/event.h
+++ b/iokit/include/bsddev/machine/event.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/include/bsddev/machine/evio.h b/iokit/include/bsddev/machine/evio.h
index 447de6893..fa8e8357f 100644
--- a/iokit/include/bsddev/machine/evio.h
+++ b/iokit/include/bsddev/machine/evio.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/include/bsddev/machine/evsio.h b/iokit/include/bsddev/machine/evsio.h
index 2dfcc948c..6baf3776f 100644
--- a/iokit/include/bsddev/machine/evsio.h
+++ b/iokit/include/bsddev/machine/evsio.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/include/bsddev/ppc/EventShmemLock.h b/iokit/include/bsddev/ppc/EventShmemLock.h
index 71d5658d3..45d004b8d 100644
--- a/iokit/include/bsddev/ppc/EventShmemLock.h
+++ b/iokit/include/bsddev/ppc/EventShmemLock.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/include/bsddev/ppc/event.h b/iokit/include/bsddev/ppc/event.h
index 0abba8c7e..7e2748bf1 100644
--- a/iokit/include/bsddev/ppc/event.h
+++ b/iokit/include/bsddev/ppc/event.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/include/bsddev/ppc/evio.h b/iokit/include/bsddev/ppc/evio.h
index d577d8a9f..a50e00718 100644
--- a/iokit/include/bsddev/ppc/evio.h
+++ b/iokit/include/bsddev/ppc/evio.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/include/bsddev/ppc/evsio.h b/iokit/include/bsddev/ppc/evsio.h
index e70408425..993c89ed9 100644
--- a/iokit/include/bsddev/ppc/evsio.h
+++ b/iokit/include/bsddev/ppc/evsio.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/include/drivers/event_status_driver.h b/iokit/include/drivers/event_status_driver.h
index 1a939be02..bfaa8dffb 100644
--- a/iokit/include/drivers/event_status_driver.h
+++ b/iokit/include/drivers/event_status_driver.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/include/mach/mach.h b/iokit/include/mach/mach.h
index 21fc91eb4..8cab872d6 100644
--- a/iokit/include/mach/mach.h
+++ b/iokit/include/mach/mach.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/iokit/mach-o/mach_header.h b/iokit/mach-o/mach_header.h
index 4d14d1380..d8f3ec944 100644
--- a/iokit/mach-o/mach_header.h
+++ b/iokit/mach-o/mach_header.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libkern/c++/OSArray.cpp b/libkern/c++/OSArray.cpp
index fdc847f10..d76963047 100644
--- a/libkern/c++/OSArray.cpp
+++ b/libkern/c++/OSArray.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -72,7 +75,7 @@ bool OSArray::initWithCapacity(unsigned int inCapacity)
 
 bool OSArray::initWithObjects(const OSObject *objects[],
                               unsigned int theCount,
-                              unsigned int theCapacity = 0)
+                              unsigned int theCapacity)
 {
     unsigned int capacity;
 
@@ -100,7 +103,7 @@ bool OSArray::initWithObjects(const OSObject *objects[],
 }
 
 bool OSArray::initWithArray(const OSArray *anArray,
-                            unsigned int theCapacity = 0)
+                            unsigned int theCapacity)
 {
     if ( !anArray )
         return false;
@@ -114,7 +117,7 @@ OSArray *OSArray::withCapacity(unsigned int capacity)
     OSArray *me = new OSArray;
 
     if (me && !me->initWithCapacity(capacity)) {
-        me->free();
+        me->release();
         return 0;
     }
 
@@ -123,12 +126,12 @@ OSArray *OSArray::withCapacity(unsigned int capacity)
 
 OSArray *OSArray::withObjects(const OSObject *objects[],
                               unsigned int count,
-                              unsigned int capacity = 0)
+                              unsigned int capacity)
 {
     OSArray *me = new OSArray;
 
     if (me && !me->initWithObjects(objects, count, capacity)) {
-        me->free();
+        me->release();
         return 0;
     }
 
@@ -136,12 +139,12 @@ OSArray *OSArray::withObjects(const OSObject *objects[],
 }
 
 OSArray *OSArray::withArray(const OSArray *array,
-                            unsigned int capacity = 0)
+                            unsigned int capacity)
 {
     OSArray *me = new OSArray;
 
     if (me && !me->initWithArray(array, capacity)) {
-        me->free();
+        me->release();
         return 0;
     }
 
diff --git a/libkern/c++/OSBoolean.cpp b/libkern/c++/OSBoolean.cpp
index 42ddc73d2..19c5dd89f 100644
--- a/libkern/c++/OSBoolean.cpp
+++ b/libkern/c++/OSBoolean.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libkern/c++/OSCPPDebug.cpp b/libkern/c++/OSCPPDebug.cpp
index 5cf9649d8..2c39be04e 100644
--- a/libkern/c++/OSCPPDebug.cpp
+++ b/libkern/c++/OSCPPDebug.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libkern/c++/OSCollection.cpp b/libkern/c++/OSCollection.cpp
index 6a958424a..2fe0024b9 100644
--- a/libkern/c++/OSCollection.cpp
+++ b/libkern/c++/OSCollection.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libkern/c++/OSCollectionIterator.cpp b/libkern/c++/OSCollectionIterator.cpp
index e9a77cced..ac9f6223b 100644
--- a/libkern/c++/OSCollectionIterator.cpp
+++ b/libkern/c++/OSCollectionIterator.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -60,7 +63,7 @@ OSCollectionIterator::withCollection(const OSCollection *inColl)
     OSCollectionIterator *me = new OSCollectionIterator;
 
     if (me && !me->initWithCollection(inColl)) {
-        me->free();
+        me->release();
         return 0;
     }
 
diff --git a/libkern/c++/OSData.cpp b/libkern/c++/OSData.cpp
index d4f12fea6..6c5078a1d 100644
--- a/libkern/c++/OSData.cpp
+++ b/libkern/c++/OSData.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -44,9 +47,7 @@ OSMetaClassDefineReservedUnused(OSData, 7);
 #define EXTERNAL ((unsigned int) -1)
 
 #if OSALLOCDEBUG
-extern "C" {
-    extern int debug_container_malloc_size;
-};
+extern int debug_container_malloc_size;
 #define ACCUMSIZE(s) do { debug_container_malloc_size += (s); } while(0)
 #else
 #define ACCUMSIZE(s)
@@ -57,19 +58,26 @@ bool OSData::initWithCapacity(unsigned int inCapacity)
     if (!super::init())
         return false;
 
-    if(inCapacity) {
+    if (data && (!inCapacity || capacity < inCapacity) ) {
+        // clean out old data's storage if it isn't big enough
+        kfree((vm_address_t) data, capacity);
+        data = 0;
+        ACCUMSIZE(-capacity);
+    }
+
+    if (inCapacity && !data) {
         data = (void *) kalloc(inCapacity);
         if (!data)
             return false;
+        capacity = inCapacity;
+        ACCUMSIZE(inCapacity);
     }
 
     length = 0;
-    capacity = inCapacity;
-    capacityIncrement = capacity;
-    if(!capacityIncrement)
+    if (inCapacity < 16)
         capacityIncrement = 16;
-
-    ACCUMSIZE(capacity);
+    else
+        capacityIncrement = inCapacity;
 
     return true;
 }
@@ -79,7 +87,8 @@ bool OSData::initWithBytes(const void *bytes, unsigned int inLength)
     if ((inLength && !bytes) || !initWithCapacity(inLength))
         return false;
 
-    bcopy(bytes, data, inLength);
+    if (bytes != data)
+	bcopy(bytes, data, inLength);
     length = inLength;
 
     return true;
@@ -118,7 +127,7 @@ OSData *OSData::withCapacity(unsigned int inCapacity)
     OSData *me = new OSData;
 
     if (me && !me->initWithCapacity(inCapacity)) {
-        me->free();
+        me->release();
         return 0;
     }
 
@@ -130,7 +139,7 @@ OSData *OSData::withBytes(const void *bytes, unsigned int inLength)
     OSData *me = new OSData;
 
     if (me && !me->initWithBytes(bytes, inLength)) {
-        me->free();
+        me->release();
         return 0;
     }
     return me;
@@ -141,7 +150,7 @@ OSData *OSData::withBytesNoCopy(void *bytes, unsigned int inLength)
     OSData *me = new OSData;
 
     if (me && !me->initWithBytesNoCopy(bytes, inLength)) {
-        me->free();
+        me->release();
         return 0;
     }
 
@@ -153,7 +162,7 @@ OSData *OSData::withData(const OSData *inData)
     OSData *me = new OSData;
 
     if (me && !me->initWithData(inData)) {
-        me->free();
+        me->release();
         return 0;
     }
 
@@ -166,7 +175,7 @@ OSData *OSData::withData(const OSData *inData,
     OSData *me = new OSData;
 
     if (me && !me->initWithData(inData, start, inLength)) {
-        me->free();
+        me->release();
         return 0;
     }
 
@@ -225,7 +234,7 @@ bool OSData::appendBytes(const void *bytes, unsigned int inLength)
 {
     unsigned int newSize;
 
-    if (inLength == 0)
+    if (!inLength)
         return true;
 
     if (capacity == EXTERNAL)
@@ -235,7 +244,11 @@ bool OSData::appendBytes(const void *bytes, unsigned int inLength)
     if ( (newSize > capacity) && newSize > ensureCapacity(newSize) )
         return false;
 
-    bcopy(bytes, &((unsigned char *)data)[length], inLength);
+    if (bytes)
+        bcopy(bytes, &((unsigned char *)data)[length], inLength);
+    else
+        bzero(&((unsigned char *)data)[length], inLength);
+
     length = newSize;
 
     return true;
@@ -245,7 +258,7 @@ bool OSData::appendByte(unsigned char byte, unsigned int inLength)
 {
     unsigned int newSize;
 
-    if (inLength == 0)
+    if (!inLength)
         return true;
 
     if (capacity == EXTERNAL)
@@ -268,7 +281,7 @@ bool OSData::appendBytes(const OSData *other)
 
 const void *OSData::getBytesNoCopy() const
 {
-    if (length == 0)
+    if (!length)
         return 0;
     else
         return data;
@@ -323,7 +336,7 @@ bool OSData::isEqualTo(const OSString *obj) const
     unsigned int checkLen = length;
     unsigned int stringLen;
 
-    if (NULL == obj)
+    if (!obj)
       return false;
 
     stringLen = obj->getLength ();
diff --git a/libkern/c++/OSDictionary.cpp b/libkern/c++/OSDictionary.cpp
index b89306f94..63ccca6dc 100644
--- a/libkern/c++/OSDictionary.cpp
+++ b/libkern/c++/OSDictionary.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -76,7 +79,7 @@ bool OSDictionary::initWithCapacity(unsigned int inCapacity)
 bool OSDictionary::initWithObjects(const OSObject *objects[],
                                    const OSSymbol *keys[],
                                    unsigned int theCount,
-                                   unsigned int theCapacity = 0)
+                                   unsigned int theCapacity)
 {
     unsigned int capacity = theCount;
 
@@ -106,7 +109,7 @@ bool OSDictionary::initWithObjects(const OSObject *objects[],
 bool OSDictionary::initWithObjects(const OSObject *objects[],
                                    const OSString *keys[],
                                    unsigned int theCount,
-                                   unsigned int theCapacity = 0)
+                                   unsigned int theCapacity)
 {
     unsigned int capacity = theCount;
 
@@ -142,7 +145,7 @@ bool OSDictionary::initWithObjects(const OSObject *objects[],
 }
 
 bool OSDictionary::initWithDictionary(const OSDictionary *dict,
-                                      unsigned int theCapacity = 0)
+                                      unsigned int theCapacity)
 {
     unsigned int capacity;
 
@@ -176,7 +179,7 @@ OSDictionary *OSDictionary::withCapacity(unsigned int capacity)
     OSDictionary *me = new OSDictionary;
 
     if (me && !me->initWithCapacity(capacity)) {
-        me->free();
+        me->release();
         return 0;
     }
 
@@ -186,12 +189,12 @@ OSDictionary *OSDictionary::withCapacity(unsigned int capacity)
 OSDictionary *OSDictionary::withObjects(const OSObject *objects[],
                                         const OSSymbol *keys[],
                                         unsigned int count,
-                                        unsigned int capacity = 0)
+                                        unsigned int capacity)
 {
     OSDictionary *me = new OSDictionary;
 
     if (me && !me->initWithObjects(objects, keys, count, capacity)) {
-        me->free();
+        me->release();
         return 0;
     }
 
@@ -201,12 +204,12 @@ OSDictionary *OSDictionary::withObjects(const OSObject *objects[],
 OSDictionary *OSDictionary::withObjects(const OSObject *objects[],
                                         const OSString *keys[],
                                         unsigned int count,
-                                        unsigned int capacity = 0)
+                                        unsigned int capacity)
 {
     OSDictionary *me = new OSDictionary;
 
     if (me && !me->initWithObjects(objects, keys, count, capacity)) {
-        me->free();
+        me->release();
         return 0;
     }
 
@@ -214,12 +217,12 @@ OSDictionary *OSDictionary::withObjects(const OSObject *objects[],
 }
 
 OSDictionary *OSDictionary::withDictionary(const OSDictionary *dict,
-                                           unsigned int capacity = 0)
+                                           unsigned int capacity)
 {
     OSDictionary *me = new OSDictionary;
 
     if (me && !me->initWithDictionary(dict, capacity)) {
-        me->free();
+        me->release();
         return 0;
     }
 
diff --git a/libkern/c++/OSIterator.cpp b/libkern/c++/OSIterator.cpp
index b462c88c6..2f8a70cb1 100644
--- a/libkern/c++/OSIterator.cpp
+++ b/libkern/c++/OSIterator.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libkern/c++/OSMetaClass.cpp b/libkern/c++/OSMetaClass.cpp
index 34b5a2d51..c3019b599 100644
--- a/libkern/c++/OSMetaClass.cpp
+++ b/libkern/c++/OSMetaClass.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libkern/c++/OSNumber.cpp b/libkern/c++/OSNumber.cpp
index 5607d1e7e..e327230f9 100644
--- a/libkern/c++/OSNumber.cpp
+++ b/libkern/c++/OSNumber.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -82,7 +85,7 @@ OSNumber *OSNumber::withNumber(unsigned long long value,
     OSNumber *me = new OSNumber;
 
     if (me && !me->init(value, numberOfBits)) {
-        me->free();
+        me->release();
         return 0;
     }
 
@@ -94,7 +97,7 @@ OSNumber *OSNumber::withNumber(const char *value, unsigned int numberOfBits)
     OSNumber *me = new OSNumber;
 
     if (me && !me->init(value, numberOfBits)) {
-        me->free();
+        me->release();
         return 0;
     }
 
diff --git a/libkern/c++/OSObject.cpp b/libkern/c++/OSObject.cpp
index 4d8122a35..ab5873891 100644
--- a/libkern/c++/OSObject.cpp
+++ b/libkern/c++/OSObject.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libkern/c++/OSOrderedSet.cpp b/libkern/c++/OSOrderedSet.cpp
index 76e1460eb..f90e68322 100644
--- a/libkern/c++/OSOrderedSet.cpp
+++ b/libkern/c++/OSOrderedSet.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -83,7 +86,7 @@ withCapacity(unsigned int capacity,
     OSOrderedSet *me = new OSOrderedSet;
 
     if (me && !me->initWithCapacity(capacity, ordering, orderingRef)) {
-        me->free();
+        me->release();
 	me = 0;
     }
 
diff --git a/libkern/c++/OSRuntime.cpp b/libkern/c++/OSRuntime.cpp
index 7cf2472a0..0c50524c3 100644
--- a/libkern/c++/OSRuntime.cpp
+++ b/libkern/c++/OSRuntime.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libkern/c++/OSSerialize.cpp b/libkern/c++/OSSerialize.cpp
index b84656c48..e3eb5e2e5 100644
--- a/libkern/c++/OSSerialize.cpp
+++ b/libkern/c++/OSSerialize.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -148,7 +151,7 @@ bool OSSerialize::initWithCapacity(unsigned int inCapacity)
 
     tag = 0;
     length = 1;
-    capacity = (inCapacity) ? round_page(inCapacity) : round_page(1);
+    capacity = (inCapacity) ? round_page_32(inCapacity) : round_page_32(1);
     capacityIncrement = capacity;
 
     // allocate from the kernel map so that we can safely map this data
@@ -173,7 +176,7 @@ OSSerialize *OSSerialize::withCapacity(unsigned int inCapacity)
 	OSSerialize *me = new OSSerialize;
 
 	if (me && !me->initWithCapacity(inCapacity)) {
-		me->free();
+		me->release();
 		return 0;
 	}
 
@@ -197,7 +200,7 @@ unsigned int OSSerialize::ensureCapacity(unsigned int newCapacity)
 		return capacity;
 
 	// round up
-	newCapacity = round_page(newCapacity);
+	newCapacity = round_page_32(newCapacity);
 
 	kern_return_t rc = kmem_realloc(kernel_map,
 					(vm_offset_t)data,
@@ -238,7 +241,7 @@ void OSSerialize::free()
 OSDefineMetaClassAndStructors(OSSerializer, OSObject)
 
 OSSerializer * OSSerializer::forTarget( void * target,
-                               OSSerializerCallback callback, void * ref = 0 )
+                               OSSerializerCallback callback, void * ref )
 {
     OSSerializer * thing;
 
diff --git a/libkern/c++/OSSet.cpp b/libkern/c++/OSSet.cpp
index 0b86dd4c1..96c67bccb 100644
--- a/libkern/c++/OSSet.cpp
+++ b/libkern/c++/OSSet.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -51,7 +54,7 @@ bool OSSet::initWithCapacity(unsigned int inCapacity)
 
 bool OSSet::initWithObjects(const OSObject *inObjects[],
                               unsigned int inCount,
-                              unsigned int inCapacity = 0)
+                              unsigned int inCapacity)
 {
     unsigned int capacity = inCount;
 
@@ -76,7 +79,7 @@ bool OSSet::initWithObjects(const OSObject *inObjects[],
 }
 
 bool OSSet::initWithArray(const OSArray *inArray,
-                          unsigned int inCapacity = 0)
+                          unsigned int inCapacity)
 {
     if ( !inArray )
         return false;
@@ -86,7 +89,7 @@ bool OSSet::initWithArray(const OSArray *inArray,
 }
 
 bool OSSet::initWithSet(const OSSet *inSet,
-                        unsigned int inCapacity = 0)
+                        unsigned int inCapacity)
 {
     return initWithArray(inSet->members, inCapacity);
 }
@@ -96,7 +99,7 @@ OSSet *OSSet::withCapacity(unsigned int capacity)
     OSSet *me = new OSSet;
 
     if (me && !me->initWithCapacity(capacity)) {
-        me->free();
+        me->release();
         return 0;
     }
 
@@ -105,12 +108,12 @@ OSSet *OSSet::withCapacity(unsigned int capacity)
 
 OSSet *OSSet::withObjects(const OSObject *objects[],
                           unsigned int count,
-                          unsigned int capacity = 0)
+                          unsigned int capacity)
 {
     OSSet *me = new OSSet;
 
     if (me && !me->initWithObjects(objects, count, capacity)) {
-        me->free();
+        me->release();
         return 0;
     }
 
@@ -118,12 +121,12 @@ OSSet *OSSet::withObjects(const OSObject *objects[],
 }
 
 OSSet *OSSet::withArray(const OSArray *array,
-                        unsigned int capacity = 0)
+                        unsigned int capacity)
 {
     OSSet *me = new OSSet;
 
     if (me && !me->initWithArray(array, capacity)) {
-        me->free();
+        me->release();
         return 0;
     }
 
@@ -131,12 +134,12 @@ OSSet *OSSet::withArray(const OSArray *array,
 }
 
 OSSet *OSSet::withSet(const OSSet *set,
-                      unsigned int capacity = 0)
+                      unsigned int capacity)
 {
     OSSet *me = new OSSet;
 
     if (me && !me->initWithSet(set, capacity)) {
-        me->free();
+        me->release();
         return 0;
     }
 
diff --git a/libkern/c++/OSString.cpp b/libkern/c++/OSString.cpp
index 77d46d78c..fa02c340e 100644
--- a/libkern/c++/OSString.cpp
+++ b/libkern/c++/OSString.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -98,7 +101,7 @@ OSString *OSString::withString(const OSString *aString)
     OSString *me = new OSString;
 
     if (me && !me->initWithString(aString)) {
-        me->free();
+        me->release();
         return 0;
     }
 
@@ -110,7 +113,7 @@ OSString *OSString::withCString(const char *cString)
     OSString *me = new OSString;
 
     if (me && !me->initWithCString(cString)) {
-        me->free();
+        me->release();
         return 0;
     }
 
@@ -122,7 +125,7 @@ OSString *OSString::withCStringNoCopy(const char *cString)
     OSString *me = new OSString;
 
     if (me && !me->initWithCStringNoCopy(cString)) {
-        me->free();
+        me->release();
         return 0;
     }
 
diff --git a/libkern/c++/OSSymbol.cpp b/libkern/c++/OSSymbol.cpp
index daff36bc8..10548e878 100644
--- a/libkern/c++/OSSymbol.cpp
+++ b/libkern/c++/OSSymbol.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libkern/c++/OSUnserialize.cpp b/libkern/c++/OSUnserialize.cpp
index bec931246..a82c4d3fa 100644
--- a/libkern/c++/OSUnserialize.cpp
+++ b/libkern/c++/OSUnserialize.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libkern/c++/OSUnserializeXML.cpp b/libkern/c++/OSUnserializeXML.cpp
index 3a5742ee1..d53cb8d28 100644
--- a/libkern/c++/OSUnserializeXML.cpp
+++ b/libkern/c++/OSUnserializeXML.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libkern/c++/Tests/TestSerialization/test1.kmodproj/test1_main.cpp b/libkern/c++/Tests/TestSerialization/test1.kmodproj/test1_main.cpp
index d9f86d6b2..234fb2912 100644
--- a/libkern/c++/Tests/TestSerialization/test1.kmodproj/test1_main.cpp
+++ b/libkern/c++/Tests/TestSerialization/test1.kmodproj/test1_main.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libkern/c++/Tests/TestSerialization/test1.kmodproj/test1_main.h b/libkern/c++/Tests/TestSerialization/test1.kmodproj/test1_main.h
index 5c8af20b3..ddc518f3d 100644
--- a/libkern/c++/Tests/TestSerialization/test1.kmodproj/test1_main.h
+++ b/libkern/c++/Tests/TestSerialization/test1.kmodproj/test1_main.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libkern/c++/Tests/TestSerialization/test2.kmodproj/test2_main.cpp b/libkern/c++/Tests/TestSerialization/test2.kmodproj/test2_main.cpp
index c4c735719..15c733c0b 100644
--- a/libkern/c++/Tests/TestSerialization/test2.kmodproj/test2_main.cpp
+++ b/libkern/c++/Tests/TestSerialization/test2.kmodproj/test2_main.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libkern/conf/version.minor b/libkern/conf/version.minor
index 0cfbf0888..7f8f011eb 100644
--- a/libkern/conf/version.minor
+++ b/libkern/conf/version.minor
@@ -1 +1 @@
-2
+7
diff --git a/libkern/conf/version.variant b/libkern/conf/version.variant
index e69de29bb..7ed6ff82d 100644
--- a/libkern/conf/version.variant
+++ b/libkern/conf/version.variant
@@ -0,0 +1 @@
+5
diff --git a/libkern/gen/OSAtomicOperations.c b/libkern/gen/OSAtomicOperations.c
index c6e86aaca..222db2a33 100644
--- a/libkern/gen/OSAtomicOperations.c
+++ b/libkern/gen/OSAtomicOperations.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libkern/i386/OSAtomic.c b/libkern/i386/OSAtomic.c
index c5904c3ea..a0af3a184 100644
--- a/libkern/i386/OSAtomic.c
+++ b/libkern/i386/OSAtomic.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libkern/i386/OSAtomic.s b/libkern/i386/OSAtomic.s
index e7f13bf55..83ab5e3d0 100644
--- a/libkern/i386/OSAtomic.s
+++ b/libkern/i386/OSAtomic.s
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libkern/kmod/c_start.c b/libkern/kmod/c_start.c
index ad33f01f4..efb4669ee 100644
--- a/libkern/kmod/c_start.c
+++ b/libkern/kmod/c_start.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libkern/kmod/c_stop.c b/libkern/kmod/c_stop.c
index 3de526ad5..7dd1b7873 100644
--- a/libkern/kmod/c_stop.c
+++ b/libkern/kmod/c_stop.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libkern/kmod/cplus_start.c b/libkern/kmod/cplus_start.c
index 81bc3adc0..555bde420 100644
--- a/libkern/kmod/cplus_start.c
+++ b/libkern/kmod/cplus_start.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libkern/kmod/cplus_stop.c b/libkern/kmod/cplus_stop.c
index 8151fb43f..775a76d59 100644
--- a/libkern/kmod/cplus_stop.c
+++ b/libkern/kmod/cplus_stop.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libkern/libkern/OSAtomic.h b/libkern/libkern/OSAtomic.h
index 300bac7df..98b5388b4 100644
--- a/libkern/libkern/OSAtomic.h
+++ b/libkern/libkern/OSAtomic.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libkern/libkern/OSBase.h b/libkern/libkern/OSBase.h
index 0938bc7bc..b8134e09d 100644
--- a/libkern/libkern/OSBase.h
+++ b/libkern/libkern/OSBase.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libkern/libkern/OSByteOrder.h b/libkern/libkern/OSByteOrder.h
index 7509cf040..b0fd3dabc 100644
--- a/libkern/libkern/OSByteOrder.h
+++ b/libkern/libkern/OSByteOrder.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libkern/libkern/OSReturn.h b/libkern/libkern/OSReturn.h
index 5e925ac03..e1b07fb2d 100644
--- a/libkern/libkern/OSReturn.h
+++ b/libkern/libkern/OSReturn.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libkern/libkern/OSTypes.h b/libkern/libkern/OSTypes.h
index 3328250d0..6a24b78c5 100644
--- a/libkern/libkern/OSTypes.h
+++ b/libkern/libkern/OSTypes.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libkern/libkern/c++/OSArray.h b/libkern/libkern/c++/OSArray.h
index 03630ed7a..9c29e2fe5 100644
--- a/libkern/libkern/c++/OSArray.h
+++ b/libkern/libkern/c++/OSArray.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libkern/libkern/c++/OSBoolean.h b/libkern/libkern/c++/OSBoolean.h
index 3934cfeae..2116f1420 100644
--- a/libkern/libkern/c++/OSBoolean.h
+++ b/libkern/libkern/c++/OSBoolean.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libkern/libkern/c++/OSCPPDebug.h b/libkern/libkern/c++/OSCPPDebug.h
index 8d2eeeb10..b04c5d538 100644
--- a/libkern/libkern/c++/OSCPPDebug.h
+++ b/libkern/libkern/c++/OSCPPDebug.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libkern/libkern/c++/OSCollection.h b/libkern/libkern/c++/OSCollection.h
index 1b3a22600..a76c9c6eb 100644
--- a/libkern/libkern/c++/OSCollection.h
+++ b/libkern/libkern/c++/OSCollection.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libkern/libkern/c++/OSCollectionIterator.h b/libkern/libkern/c++/OSCollectionIterator.h
index 387b6355d..d9e5b2727 100644
--- a/libkern/libkern/c++/OSCollectionIterator.h
+++ b/libkern/libkern/c++/OSCollectionIterator.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libkern/libkern/c++/OSContainers.h b/libkern/libkern/c++/OSContainers.h
index 725a786fb..c21557acd 100644
--- a/libkern/libkern/c++/OSContainers.h
+++ b/libkern/libkern/c++/OSContainers.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libkern/libkern/c++/OSData.h b/libkern/libkern/c++/OSData.h
index 2406be7c0..6f84b50ed 100644
--- a/libkern/libkern/c++/OSData.h
+++ b/libkern/libkern/c++/OSData.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -92,13 +95,12 @@ public:
                                 unsigned int start, unsigned int inLength);
 
     /*!
-        @function initWithBytes
-        @abstract A member function to initialize an instance of OSData with the provided data.
-        @param bytes A pointer to a block of data to be copied.
-        @param inLength The length of the block of data.
+        @function initWithCapacity
+        @abstract A member function to initialize an instance of OSData with a minimum capacity of at least the given size.  If this function is called an an object that has been previously used then the length is set down to 0 and a new block of data is allocated if necessary to ensure the given capacity.
+        @param capacity The length of the allocated block of data.
         @result Returns true if initialization was successful, false otherwise.
     */
-    virtual bool initWithCapacity(unsigned int inCapacity);
+    virtual bool initWithCapacity(unsigned int capacity);
     /*!
         @function initWithBytes
         @abstract A member function to initialize an instance of OSData which references a block of data.
@@ -173,7 +175,7 @@ public:
     /*!
         @function appendBytes
         @abstract A member function which appends a buffer of data onto the end of the object's internal data buffer.
-        @param bytes A pointer to the block of data.
+        @param bytes A pointer to the block of data.  If the value is 0 then append zero-ed memory to the data object.
         @param inLength The length of the data block.
         @result Returns true if the object was able to append the new data, false otherwise.
     */
@@ -249,6 +251,8 @@ public:
     virtual bool appendByte(unsigned char byte, unsigned int inCount);
 
 
+
+private:
     OSMetaClassDeclareReservedUnused(OSData, 0);
     OSMetaClassDeclareReservedUnused(OSData, 1);
     OSMetaClassDeclareReservedUnused(OSData, 2);
diff --git a/libkern/libkern/c++/OSDictionary.h b/libkern/libkern/c++/OSDictionary.h
index f42c4b1d4..091be51a2 100644
--- a/libkern/libkern/c++/OSDictionary.h
+++ b/libkern/libkern/c++/OSDictionary.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libkern/libkern/c++/OSIterator.h b/libkern/libkern/c++/OSIterator.h
index 47fb89213..f774ac32d 100644
--- a/libkern/libkern/c++/OSIterator.h
+++ b/libkern/libkern/c++/OSIterator.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libkern/libkern/c++/OSLib.h b/libkern/libkern/c++/OSLib.h
index d3b597dca..2e1258633 100644
--- a/libkern/libkern/c++/OSLib.h
+++ b/libkern/libkern/c++/OSLib.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libkern/libkern/c++/OSMetaClass.h b/libkern/libkern/c++/OSMetaClass.h
index a4ecef036..4225bc8a5 100644
--- a/libkern/libkern/c++/OSMetaClass.h
+++ b/libkern/libkern/c++/OSMetaClass.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libkern/libkern/c++/OSNumber.h b/libkern/libkern/c++/OSNumber.h
index aa32d0fcb..5eb6fa7ed 100644
--- a/libkern/libkern/c++/OSNumber.h
+++ b/libkern/libkern/c++/OSNumber.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libkern/libkern/c++/OSObject.h b/libkern/libkern/c++/OSObject.h
index d7ed685bc..7f2e7a5db 100644
--- a/libkern/libkern/c++/OSObject.h
+++ b/libkern/libkern/c++/OSObject.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libkern/libkern/c++/OSOrderedSet.h b/libkern/libkern/c++/OSOrderedSet.h
index 4357aee37..87548ee99 100644
--- a/libkern/libkern/c++/OSOrderedSet.h
+++ b/libkern/libkern/c++/OSOrderedSet.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libkern/libkern/c++/OSSerialize.h b/libkern/libkern/c++/OSSerialize.h
index b27811dce..c57c2b08f 100644
--- a/libkern/libkern/c++/OSSerialize.h
+++ b/libkern/libkern/c++/OSSerialize.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libkern/libkern/c++/OSSet.h b/libkern/libkern/c++/OSSet.h
index ee2467122..15bbd47c5 100644
--- a/libkern/libkern/c++/OSSet.h
+++ b/libkern/libkern/c++/OSSet.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libkern/libkern/c++/OSString.h b/libkern/libkern/c++/OSString.h
index 577807a86..49c41c269 100644
--- a/libkern/libkern/c++/OSString.h
+++ b/libkern/libkern/c++/OSString.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libkern/libkern/c++/OSSymbol.h b/libkern/libkern/c++/OSSymbol.h
index 83143678d..d5db609a9 100644
--- a/libkern/libkern/c++/OSSymbol.h
+++ b/libkern/libkern/c++/OSSymbol.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libkern/libkern/c++/OSUnserialize.h b/libkern/libkern/c++/OSUnserialize.h
index 540cf9149..aa5e7e495 100644
--- a/libkern/libkern/c++/OSUnserialize.h
+++ b/libkern/libkern/c++/OSUnserialize.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libkern/libkern/i386/OSByteOrder.h b/libkern/libkern/i386/OSByteOrder.h
index e650d5c1f..0aa2270f1 100644
--- a/libkern/libkern/i386/OSByteOrder.h
+++ b/libkern/libkern/i386/OSByteOrder.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libkern/libkern/machine/OSByteOrder.h b/libkern/libkern/machine/OSByteOrder.h
index 305f265cf..b85d69b9a 100644
--- a/libkern/libkern/machine/OSByteOrder.h
+++ b/libkern/libkern/machine/OSByteOrder.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libkern/libkern/ppc/OSByteOrder.h b/libkern/libkern/ppc/OSByteOrder.h
index e1f90fb8e..28ff91dc2 100644
--- a/libkern/libkern/ppc/OSByteOrder.h
+++ b/libkern/libkern/ppc/OSByteOrder.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libkern/mach-o/loader.h b/libkern/mach-o/loader.h
index 277b2b1e2..f83101ba3 100644
--- a/libkern/mach-o/loader.h
+++ b/libkern/mach-o/loader.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libkern/mach-o/mach_header.h b/libkern/mach-o/mach_header.h
index 4d14d1380..d8f3ec944 100644
--- a/libkern/mach-o/mach_header.h
+++ b/libkern/mach-o/mach_header.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libkern/ppc/OSAtomic.s b/libkern/ppc/OSAtomic.s
index a2aeb032d..4dc31432d 100644
--- a/libkern/ppc/OSAtomic.s
+++ b/libkern/ppc/OSAtomic.s
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -56,17 +59,27 @@ int OSCompareAndSwap( UInt32 oldVal, UInt32 newVal, UInt32 * addr )
 
 	ENTRY	_OSCompareAndSwap
 .L_CASretry:
-	lwarx	r6,	0,r5
-	cmpw	r6,	r3
-	bne-	.L_CASfail
-	stwcx.	r4,	0,r5
-	bne-	.L_CASretry
-	isync
-	li	r3,	1
-	blr
+		lwz		r6,0(r5)		// Get the swap value
+		cmpw	r6,r3			// Is is the same
+		bne--	.L_CASfail2		// No...
+		
+.L_CASretry2:
+		lwarx	r6,0,r5			// Get it atomically now
+		cmpw	r6,r3			// Same?
+		bne--	.L_CASfail		// Nope, go say so and toss reservations...
+		stwcx.	r4,0,r5			// Stash the new value
+		bne--	.L_CASretry2	// Just got collision...
+		isync
+		li	r3,	1
+		blr
+
 .L_CASfail:
-	li	r3,	0
-	blr
+		li		a7,-4			// Point to a spot in the red zone
+		stwcx.	a7,a7,r1		// Kill reservation
+		
+.L_CASfail2:	
+		li	r3,	0
+		blr
 
 
 /*
diff --git a/libkern/ppc/bcmp.s b/libkern/ppc/bcmp.s
index 934ec4dcd..c76ad8c3a 100644
--- a/libkern/ppc/bcmp.s
+++ b/libkern/ppc/bcmp.s
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libkern/ppc/memcmp.s b/libkern/ppc/memcmp.s
index 027af6bae..c47f89a7c 100644
--- a/libkern/ppc/memcmp.s
+++ b/libkern/ppc/memcmp.s
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libkern/ppc/strlen.s b/libkern/ppc/strlen.s
index def6639f3..8f1ca72eb 100644
--- a/libkern/ppc/strlen.s
+++ b/libkern/ppc/strlen.s
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libsa/bootstrap.cpp b/libsa/bootstrap.cpp
index 3b046ab37..8fd9469ed 100644
--- a/libsa/bootstrap.cpp
+++ b/libsa/bootstrap.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -25,13 +28,10 @@
 
 #include <libsa/kmod.h>
 #include <libsa/catalogue.h>
-extern "C" {
 #include <libsa/malloc.h>
-};
 
 #include "kld_patch.h"
 
-extern "C" {
 /*****
  * This function is used by IOCatalogue to load a kernel
  * extension. libsa initially sets it to be a function
@@ -51,7 +51,6 @@ extern void (*remove_startup_extension_function)(const char * name);
  * about loading and matching drivers.
  */
 extern int kernelLinkerPresent;
-};
 
 
 class KLDBootstrap {
@@ -69,6 +68,8 @@ static KLDBootstrap bootstrap_obj;
  */
 KLDBootstrap::KLDBootstrap() {
 
+    malloc_init();
+
     kmod_load_function = &load_kernel_extension;
 
     record_startup_extensions_function = &recordStartupExtensions;
diff --git a/libsa/bsearch.c b/libsa/bsearch.c
index 2a0832467..e885184da 100644
--- a/libsa/bsearch.c
+++ b/libsa/bsearch.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libsa/c++rem3.h b/libsa/c++rem3.h
index 9f37019d6..ef582fef0 100644
--- a/libsa/c++rem3.h
+++ b/libsa/c++rem3.h
@@ -3,21 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * "Portions Copyright (c) 1999 Apple Computer, Inc.  All Rights
- * Reserved.  This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.0 (the 'License').  You may not use this file
- * except in compliance with the License.  Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
  * 
  * The Original Code and all software distributed under the License are
  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License."
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libsa/catalogue.cpp b/libsa/catalogue.cpp
index e9c301939..35c88255f 100644
--- a/libsa/catalogue.cpp
+++ b/libsa/catalogue.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libsa/conf/version.minor b/libsa/conf/version.minor
index 0cfbf0888..7f8f011eb 100644
--- a/libsa/conf/version.minor
+++ b/libsa/conf/version.minor
@@ -1 +1 @@
-2
+7
diff --git a/libsa/conf/version.variant b/libsa/conf/version.variant
index e69de29bb..7ed6ff82d 100644
--- a/libsa/conf/version.variant
+++ b/libsa/conf/version.variant
@@ -0,0 +1 @@
+5
diff --git a/libsa/i386/setjmp.s b/libsa/i386/setjmp.s
index 9bbd90f4a..4e11cd601 100644
--- a/libsa/i386/setjmp.s
+++ b/libsa/i386/setjmp.s
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libsa/kld_patch.c b/libsa/kld_patch.c
index 862be7f96..45d11c0c1 100644
--- a/libsa/kld_patch.c
+++ b/libsa/kld_patch.c
@@ -3,21 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * "Portions Copyright (c) 1999 Apple Computer, Inc.  All Rights
- * Reserved.  This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.0 (the 'License').  You may not use this file
- * except in compliance with the License.  Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
  * 
  * The Original Code and all software distributed under the License are
  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License."
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -1852,13 +1853,13 @@ static Boolean growImage(struct fileRecord *file, vm_size_t delta)
     endMap   = (vm_address_t) file->fMap + file->fMapSize;
 
     // Do we have room in the current mapped image
-    if (endMachO < round_page(endMap)) {
+    if (endMachO < round_page_32(endMap)) {
 	file->fMachOSize += delta;
 	return true;
     }
 
     newsize = endMachO - startMachO;
-    if (newsize < round_page(file->fMapSize)) {
+    if (newsize < round_page_32(file->fMapSize)) {
         DEBUG_LOG(("Growing image %s by moving\n", file->fPath));
 
 	// We have room in the map if we shift the macho image within the
diff --git a/libsa/kld_patch.h b/libsa/kld_patch.h
index b0e6058b3..8b50f49f1 100644
--- a/libsa/kld_patch.h
+++ b/libsa/kld_patch.h
@@ -3,21 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * "Portions Copyright (c) 1999 Apple Computer, Inc.  All Rights
- * Reserved.  This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.0 (the 'License').  You may not use this file
- * except in compliance with the License.  Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
  * 
  * The Original Code and all software distributed under the License are
  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License."
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libsa/kmod.cpp b/libsa/kmod.cpp
index 7e2d50a97..6f43bbea0 100644
--- a/libsa/kmod.cpp
+++ b/libsa/kmod.cpp
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -59,8 +62,8 @@ kmod_start_or_stop(
 extern kern_return_t kmod_retain(kmod_t id);
 extern kern_return_t kmod_release(kmod_t id);
 
-extern void flush_dcache(vm_offset_t addr, unsigned cnt, int phys);
-extern void invalidate_icache(vm_offset_t addr, unsigned cnt, int phys);
+extern void flush_dcache64(addr64_t addr, unsigned cnt, int phys);
+extern void invalidate_icache64(addr64_t addr, unsigned cnt, int phys);
 };
 
 
@@ -522,7 +525,7 @@ unsigned long address_for_loaded_kmod(
         return 0;
     }
 
-    round_headers_size = round_page(headers_size);
+    round_headers_size = round_page_32(headers_size);
     headers_pad = round_headers_size - headers_size;
 
     link_load_address = (unsigned long)g_current_kmod_info->address +
@@ -558,8 +561,8 @@ unsigned long alloc_for_kmod(
     unsigned long round_size;
     unsigned long headers_pad;
 
-    round_headers_size  = round_page(headers_size);
-    round_segments_size = round_page(size - headers_size);
+    round_headers_size  = round_page_32(headers_size);
+    round_segments_size = round_page_32(size - headers_size);
     round_size  = round_headers_size + round_segments_size;
     headers_pad = round_headers_size - headers_size;
 
@@ -993,7 +996,7 @@ kern_return_t load_kmod(OSArray * dependencyList) {
     // bcopy() is (from, to, length)
     bcopy((char *)kmod_header, (char *)link_buffer_address, link_header_size);
     bcopy((char *)kmod_header + link_header_size,
-        (char *)link_buffer_address + round_page(link_header_size),
+        (char *)link_buffer_address + round_page_32(link_header_size),
         link_load_size - link_header_size);
 
 
@@ -1021,13 +1024,13 @@ kern_return_t load_kmod(OSArray * dependencyList) {
     */
     kmod_info->address = link_buffer_address;
     kmod_info->size = link_buffer_size;
-    kmod_info->hdr_size = round_page(link_header_size);
+    kmod_info->hdr_size = round_page_32(link_header_size);
 
    /* We've written data and instructions, so *flush* the data cache
     * and *invalidate* the instruction cache.
     */
-    flush_dcache(link_buffer_address, link_buffer_size, false);
-    invalidate_icache(link_buffer_address, link_buffer_size, false);
+    flush_dcache64((addr64_t)link_buffer_address, link_buffer_size, false);
+    invalidate_icache64((addr64_t)link_buffer_address, link_buffer_size, false);
 
 
    /* Register the new kmod with the kernel proper.
diff --git a/libsa/libsa/i386/setjmp.h b/libsa/libsa/i386/setjmp.h
index 0ab263dbf..c51badfa8 100644
--- a/libsa/libsa/i386/setjmp.h
+++ b/libsa/libsa/i386/setjmp.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libsa/libsa/mach/mach.h b/libsa/libsa/mach/mach.h
index 8c699c2b2..95bd9f4ed 100644
--- a/libsa/libsa/mach/mach.h
+++ b/libsa/libsa/mach/mach.h
@@ -9,4 +9,4 @@ __private_extern__ vm_map_t mach_task_self(void);
 char *mach_error_string(kern_return_t);
 
 
-#endif _LIBSA_MACH_MACH_H_
+#endif /* _LIBSA_MACH_MACH_H_ */
diff --git a/libsa/libsa/malloc.h b/libsa/libsa/malloc.h
index f0a0a4e46..0f70d2a39 100644
--- a/libsa/libsa/malloc.h
+++ b/libsa/libsa/malloc.h
@@ -1,8 +1,10 @@
 #ifndef _LIBSA_MALLOC_H_
 #define _LIBSA_MALLOC_H_
 
+#include <sys/cdefs.h>
 #include "stdlib.h"
 
+__BEGIN_DECLS
 
 /*****
  * These functions are the minimum necessary for use
@@ -12,6 +14,7 @@ void * malloc(size_t size);
 void * realloc(void * address, size_t new_size);
 void   free(void * address);
 
+void   malloc_init(void);
 void   malloc_reset(void); // Destroy all memory regions
 
 
@@ -36,7 +39,9 @@ double malloc_current_efficiency(void);
 void malloc_clear_hiwat(void);
 void malloc_report(void);
 int malloc_sanity_check(void);
-#endif DEBUG
-#endif 0
+#endif /* DEBUG */
+#endif /* 0 */
 
-#endif defined _LIBSA_MALLOC_H_
+__END_DECLS
+
+#endif /* defined _LIBSA_MALLOC_H_ */
diff --git a/libsa/libsa/ppc/setjmp.h b/libsa/libsa/ppc/setjmp.h
index 54d17d51b..df9abf0a6 100644
--- a/libsa/libsa/ppc/setjmp.h
+++ b/libsa/libsa/ppc/setjmp.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libsa/libsa/setjmp.h b/libsa/libsa/setjmp.h
index ed021de4e..7e61235cc 100644
--- a/libsa/libsa/setjmp.h
+++ b/libsa/libsa/setjmp.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libsa/libsa/stdlib.h b/libsa/libsa/stdlib.h
index cecd0a5ff..6b2c48a07 100644
--- a/libsa/libsa/stdlib.h
+++ b/libsa/libsa/stdlib.h
@@ -1,6 +1,7 @@
 #ifndef _LIBSA_STDLIB_H_
 #define _LIBSA_STDLIB_H_
 
+#include <sys/cdefs.h>
 
 #ifndef _BSD_SIZE_T_DEFINED_
 #define _BSD_SIZE_T_DEFINED_
@@ -15,6 +16,9 @@ typedef __SIZE_TYPE__    size_t;
 __private_extern__ char *kld_basefile_name;
 
 
+__BEGIN_DECLS
+
+
 __private_extern__ void * malloc(size_t size);
 __private_extern__ void   free(void * address);
 __private_extern__ void   free_all(void);     // "Free" all memory blocks
@@ -42,4 +46,6 @@ __private_extern__ void * bsearch(
 extern long     strtol(const char *, char **, int);
 extern unsigned long strtoul(const char *, char **, int);
 
-#endif _LIBSA_STDLIB_H_
+__END_DECLS
+
+#endif /* _LIBSA_STDLIB_H_ */
diff --git a/libsa/libsa/unistd.h b/libsa/libsa/unistd.h
index 2dc5efd1c..b85c89a34 100644
--- a/libsa/libsa/unistd.h
+++ b/libsa/libsa/unistd.h
@@ -5,4 +5,4 @@
 #define getpagesize()    PAGE_SIZE
 
 
-#endif _LIBSA_UNISTD_H_
+#endif /* _LIBSA_UNISTD_H_ */
diff --git a/libsa/libsa/vers_rsrc.h b/libsa/libsa/vers_rsrc.h
index fb4901867..dde8efa71 100644
--- a/libsa/libsa/vers_rsrc.h
+++ b/libsa/libsa/vers_rsrc.h
@@ -26,4 +26,4 @@ typedef enum {
 int VERS_parse_string(const char * vers_string, UInt32 * version_num);
 int VERS_string(char * buffer, UInt32 length, UInt32 vers);
 
-#endif _LIBSA_VERS_H_
+#endif /* _LIBSA_VERS_H_ */
diff --git a/libsa/mach.c b/libsa/mach.c
index 1c04135fe..75bcb23fe 100644
--- a/libsa/mach.c
+++ b/libsa/mach.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libsa/mach_loader.h b/libsa/mach_loader.h
index 415f03e93..bea4dda32 100644
--- a/libsa/mach_loader.h
+++ b/libsa/mach_loader.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libsa/malloc.c b/libsa/malloc.c
index d358695ea..ed3a64d2f 100644
--- a/libsa/malloc.c
+++ b/libsa/malloc.c
@@ -3,59 +3,33 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
-#include <vm/vm_kern.h>
-#include <kern/queue.h>
 #include <string.h>
 
-#include <libsa/malloc.h>
-
-#undef CLIENT_DEBUG
-
-
-/*********************************************************************
-* I'm not sure this is really necessary....
-*********************************************************************/
-static inline size_t round_to_long(size_t size) {
-    return (size + sizeof(long int)) & ~(sizeof(long int) - 1);
-}
-
-
-typedef struct queue_entry queue_entry;
-
-/*********************************************************************
-* Structure for an allocation region. Each one is created using
-* kmem_alloc(), and the whole list of these is destroyed by calling
-* malloc_reset(). Client blocks are allocated from a linked list of these
-* regions, on a first-fit basis, and are never freed.
-*********************************************************************/
-typedef struct malloc_region {
-    queue_entry   links;         // Uses queue.h for linked list
-    vm_size_t     region_size;   // total size w/ this bookeeping info
-
-    queue_entry   block_list;    // list of allocated blocks; uses queue.h
-
-    vm_size_t     free_size;     // size of unused area
-    void        * free_address;  // points at the unused area
-
-    char          buffer[0];     // beginning of useable area
-} malloc_region;
+#include <kern/queue.h>
+#include <kern/lock.h>
+#include <kern/assert.h> 
+#include <vm/vm_kern.h>
 
+#include "libsa/malloc.h"
 
 /*********************************************************************
 * Structure for a client memory block. Contains linked-list pointers,
@@ -64,171 +38,49 @@ typedef struct malloc_region {
 * field is guaranteed to lie on a 16-byte boundary.
 *********************************************************************/
 typedef struct malloc_block {
-    queue_entry     links;       // Uses queue.h for linked list
-    malloc_region * region;
-#ifdef CLIENT_DEBUG
-    size_t         request_size;
-#endif CLIENT_DEBUG
-    size_t         block_size;  // total size w/ all bookeeping info
-
-    // the client's memory block
-    char           buffer[0] __attribute__((aligned(16)));
-} malloc_block;
 
+	struct malloc_block	*malFwd;
+	struct malloc_block	*malBwd;
+	unsigned int		malSize;
+	unsigned int		malActl;
+} malloc_block;
 
-/*********************************************************************
-* Private functions.
-*
-* malloc_create_region()
-*   size - The size in bytes of the region. This is rounded up
-*          to a multiple of the VM page size.
-*   Returns a pointer to the new region.
-*
-* malloc_free_region()
-*   region - The region to free.
-*   Returns whatever vm_deallocate() returns.
-*
-* malloc_create_block_in_region()
-*   region - The region to alloate a block from.
-*   size - The total size, including the header, of the block to
-*          allocate.
-*   Returns a pointer to the block, or NULL on failure.
-*
-* malloc_find_block()
-*   address - The address of the client buffer to find a block for.
-*   block (out) - The block header for the address.
-*   region (out) - The region the block was found in, or NULL.
-*********************************************************************/
-static malloc_region * malloc_create_region(vm_size_t size);
-static kern_return_t malloc_free_region(malloc_region * region);
-static malloc_block * malloc_create_block_in_region(
-    malloc_region * region,
-    size_t size);
-static void malloc_find_block(
-    void * address,
-    malloc_block  ** block,
-    malloc_region ** region);
-static void malloc_get_free_block(
-    size_t size,
-    malloc_block  ** block,
-    malloc_region ** region);
-
-
-/*********************************************************************
-* Pointers to the linked list of VM-allocated regions, and a high
-* water mark used in testing/debugging.
-*********************************************************************/
-static queue_entry malloc_region_list = {
-    &malloc_region_list,   // the "next" field
-    &malloc_region_list    // the "prev" field
-};
-
-static queue_entry sorted_free_block_list = {
-    &sorted_free_block_list,
-    &sorted_free_block_list
-};
-
-#ifdef CLIENT_DEBUG
-static size_t   malloc_hiwater_mark   = 0;
-static long int num_regions = 0;
-
-static size_t   current_block_total = 0;
-static double   peak_usage = 0.0;
-static double   min_usage = 100.0;
-#endif CLIENT_DEBUG
+static malloc_block malAnchor = {&malAnchor, &malAnchor, 0, 0};
 
+static int malInited = 0;
+static mutex_t *malloc_lock;
 
-/*********************************************************************
-* malloc()
-*********************************************************************/
 __private_extern__
 void * malloc(size_t size) {
-    size_t need_size;
-    malloc_region * cur_region = NULL;
-    malloc_region * use_region = NULL;
-    malloc_block  * client_block = NULL;
-    void      * client_buffer = NULL;
-
-   /* Add the size of the block header to the request size.
-    */
-    need_size = round_to_long(size + sizeof(malloc_block));
-
-
-   /* See if there's a previously-freed block that we can reuse.
-    */
-    malloc_get_free_block(need_size,
-        &client_block, &use_region);
 
-
-   /* If we found a free block that we can reuse, then reuse it.
-    */
-    if (client_block != NULL) {
-
-       /* Remove the found block from the list of free blocks
-        * and tack it onto the list of allocated blocks.
-        */
-        queue_remove(&sorted_free_block_list, client_block, malloc_block *, links);
-        queue_enter(&use_region->block_list, client_block, malloc_block *, links);
-
-        client_buffer = client_block->buffer;
-        // Don't return here! There's bookkeeping done below.
-
-    } else {
-
-       /* Didn't find a freed block to reuse. */
-
-       /* Look for a region with enough unused space to carve out a new block.
-        */
-        queue_iterate(&malloc_region_list, cur_region, malloc_region *, links) {
-            if (use_region == NULL && cur_region->free_size >= need_size) {
-                use_region = cur_region;
-                break;
-            }
-        }
-
-    
-       /* If we haven't found a region with room, create a new one and
-        * put it at the end of the list of regions.
-        */
-        if (use_region == NULL) {
-            use_region = malloc_create_region(need_size);
-            if (use_region == NULL) {
-                return NULL;
-                // FIXME: panic?
-            }
-        }
-    
-       /* Create a new block in the found/created region.
-        */
-        client_block = malloc_create_block_in_region(use_region, need_size);
-        if (client_block != NULL) {
-            client_buffer = client_block->buffer;
-            // Don't return here! There's bookkeeping done below.
-        }
-    }
-
-#ifdef CLIENT_DEBUG
-    if (client_block != NULL) {
-        size_t region_usage = malloc_region_usage();
-        double current_usage;
-
-        current_block_total += client_block->block_size;
-        if (region_usage > 0) {
-            current_usage = (double)current_block_total / (double)malloc_region_usage();
-            if (current_usage > peak_usage) {
-                peak_usage = current_usage;
-            }
-    
-            if (current_usage < min_usage) {
-                min_usage = current_usage;
-            }
-        }
-
-        client_block->request_size = size;
-    }
-#endif CLIENT_DEBUG
-
-    return client_buffer;
+    unsigned int nsize;
+    unsigned int nmem, rmem;
+    malloc_block *amem;
+ 
+    assert(malInited);
+
+ 	nsize = size + sizeof(malloc_block) + 15;	/* Make sure we get enough to fit */
+
+	nmem = (unsigned int)kalloc(nsize);			/* Get some */
+	if(!nmem) {									/* Got any? */
+		panic("malloc: no memory for a %08X sized request\n", nsize);
+	}
+	
+	rmem = (nmem + 15) & -16;					/* Round to 16 byte boundary */
+	amem = (malloc_block *)rmem;				/* Point to the block */
+	amem->malActl = (unsigned int)nmem;			/* Set the actual address */
+	amem->malSize = nsize;						/* Size */
+	
+	mutex_lock(malloc_lock);
+	
+	amem->malFwd = malAnchor.malFwd;			/* Move anchor to our forward */
+	amem->malBwd = &malAnchor;					/* We point back to anchor */
+	malAnchor.malFwd->malBwd = amem;			/* The old forward's back points to us */
+	malAnchor.malFwd = amem;					/* Now we point the anchor to us */
+	
+	mutex_unlock(malloc_lock);				/* Unlock now */
+	
+	return (void *)(rmem + 16);					/* Return the block */
 
 } /* malloc() */
 
@@ -236,56 +88,45 @@ void * malloc(size_t size) {
 /*********************************************************************
 * free()
 *
-* Moves a block from the allocated list to the free list. Neither
-* list is kept sorted!
 *********************************************************************/
 __private_extern__
 void free(void * address) {
-    malloc_region * found_region = NULL;
-    malloc_block  * found_block = NULL;
-    malloc_block  * cur_block = NULL;
-
-   /* Find the block and region for the given address.
-    */
-    malloc_find_block(address, &found_block, &found_region);
-
-    if (found_block == NULL) {
-        return;
-        // FIXME: panic?
-    }
-
 
-   /* Remove the found block from the list of allocated blocks
-    * and tack it onto the list of free blocks.
-    */
-    queue_remove(&found_region->block_list, found_block, malloc_block *, links);
-
-    found_block->links.next = NULL;
-    queue_iterate(&sorted_free_block_list, cur_block, malloc_block *, links) {
-        if (cur_block->block_size > found_block->block_size) {
-            queue_insert_before(&sorted_free_block_list, found_block, cur_block,
-                malloc_block *, links);
-            break;
-        }
-    }
 
+    malloc_block *amem, *fore, *aft;
+    
+    if(!(unsigned int)address) return;			/* Leave if they try to free nothing */
+    
+    
+    amem = (malloc_block *)((unsigned int)address - sizeof(malloc_block));	/* Point to the header */
 
-   /* If the "next" link is still NULL, then either the list is empty or the
-    * freed block has to go on the end, so just tack it on.
-    */
-    if (found_block->links.next == NULL) {
-        queue_enter(&sorted_free_block_list, found_block, malloc_block *, links);
-    }
+ 	mutex_lock(malloc_lock);
 
+	fore = amem->malFwd;						/* Get the guy in front */
+	aft  = amem->malBwd;						/* And the guy behind */
+	fore->malBwd = aft;							/* The next guy's previous is now my previous */
+	aft->malFwd = fore;							/* The previous guy's forward is now mine */	
 
-#ifdef CLIENT_DEBUG
-    current_block_total -= found_block->block_size;
-#endif CLIENT_DEBUG
+	mutex_unlock(malloc_lock);				/* Unlock now */
+   
+ 	kfree((void *)amem->malActl, amem->malSize);	/* Toss it */
 
-    return;
+	return;	
 
 } /* free() */
 
+/*********************************************************************
+* malloc_reset()
+*
+* Allocate the mutual exclusion lock that protect malloc's data.
+*********************************************************************/
+__private_extern__ void
+malloc_init(void)
+{
+    malloc_lock = mutex_alloc(ETAP_IO_AHA);
+    malInited = 1;
+}
+
 
 /*********************************************************************
 * malloc_reset()
@@ -296,20 +137,27 @@ void free(void * address) {
 *********************************************************************/
 __private_extern__
 void malloc_reset(void) {
-    malloc_region * cur_region;
-
-    while (! queue_empty(&malloc_region_list)) {
-        kern_return_t kern_result;
-        queue_remove_first(&malloc_region_list, cur_region,
-            malloc_region *, links);
-        kern_result = malloc_free_region(cur_region);
-        if (kern_result != KERN_SUCCESS) {
-            // what sort of error checking can we even do here?
-            // printf("malloc_free_region() failed.\n");
-            // panic();
-        }
-    }
-
+ 
+    malloc_block *amem, *bmem;
+
+ 	mutex_lock(malloc_lock);
+	
+	amem = malAnchor.malFwd;					/* Get the first one */
+	
+	while(amem != &malAnchor) {					/* Go until we hit the anchor */
+	
+		bmem = amem->malFwd;					/* Next one */
+ 		kfree((void *)amem->malActl, amem->malSize);	/* Toss it */
+ 		amem = bmem;							/* Skip to it */
+	
+	} 
+
+	malAnchor.malFwd = 0x666;					/* Cause a fault if we try again */
+	malAnchor.malBwd = 0x666;					/* Cause a fault if we try again */
+	
+	mutex_unlock(malloc_lock);				/* Unlock now */
+
+	mutex_free(malloc_lock);
     return;
 
 } /* malloc_reset() */
@@ -324,270 +172,22 @@ void malloc_reset(void) {
 *********************************************************************/
 __private_extern__
 void * realloc(void * address, size_t new_client_size) {
-    malloc_region * found_region = NULL;
-    malloc_block  * found_block = NULL;
     void * new_address;
-    size_t new_block_size;
-    size_t copy_bytecount;
-
-
-    malloc_find_block(address, &found_block, &found_region);
-
-
-   /* If we couldn't find the requested block, 
-    * the caller is in error so return NULL.
-    */
-    if (found_block == NULL) {
-        // printf("realloc() called with invalid block.\n");
-        return NULL;
-        // FIXME: panic?
-    }
-
-
-   /* Figure out how much memory is actually needed.
-    */
-    new_block_size = new_client_size + sizeof(malloc_block);
-
-
-   /* If the new size is <= the current size, don't bother.
-    */
-    if (new_block_size <= found_block->block_size) {
-#ifdef CLIENT_DEBUG
-        if (new_client_size > found_block->request_size) {
-            found_block->request_size = new_client_size;
-        }
-#endif CLIENT_DEBUG
-        return address;
-    }
-
-
-   /* Create a new block of the requested size.
-    */
-    new_address = malloc(new_client_size);
-
-    if (new_address == NULL) {
-        // printf("error in realloc()\n");
-        return NULL;
-        // FIXME: panic?
-    }
-
-
-   /* Copy the data from the old block to the new one.
-    * Make sure to copy only the lesser of the existing and
-    * requested new size. (Note: The code above currently
-    * screens out a realloc to a smaller size, but it might
-    * not always do that.)
-    */
-    copy_bytecount = found_block->block_size - sizeof(malloc_block);
-
-    if (new_client_size < copy_bytecount) {
-        copy_bytecount = new_client_size;
-    }
-
-    memcpy(new_address, address, copy_bytecount);
-
-
-   /* Free the old block.
-    */
-    free(address);
-
-    return (void *)new_address;
+    malloc_block *amem;
+
+	amem = (malloc_block *)((unsigned int)address - sizeof(malloc_block));	/* Point to allocation block */
+	
+	new_address = malloc(new_client_size);		/* get a new one */
+	if(!new_address) {							/* Did we get it? */
+		panic("realloc: can not reallocate one of %08X size\n", new_client_size);
+	}
+	
+    memcpy(new_address, address, amem->malSize - sizeof(malloc_block));	/* Copy the old in */
+    
+    free(address);								/* Toss the old one */
+	
+    return new_address;
 
 } /* realloc() */
 
 
-/*********************************************************************
-**********************************************************************
-*****           PACKAGE-INTERNAL FUNCTIONS BELOW HERE            *****
-**********************************************************************
-*********************************************************************/
-
-
-
-/*********************************************************************
-* malloc_create_region()
-*
-* Package-internal function. VM-allocates a new region and adds it to
-* the given region list.
-*********************************************************************/
-__private_extern__
-malloc_region * malloc_create_region(vm_size_t block_size) {
-
-    malloc_region * new_region;
-    vm_address_t    vm_address;
-    vm_size_t       region_size;
-    kern_return_t   kern_result;
-
-
-   /* Figure out how big the region needs to be and allocate it.
-    */
-    region_size = block_size + sizeof(malloc_region);
-    region_size = round_page(region_size);
-
-    kern_result = kmem_alloc(kernel_map,
-        &vm_address, region_size);
-
-    if (kern_result != KERN_SUCCESS) {
-        // printf("kmem_alloc() failed in malloc_create_region()\n");
-        return NULL;
-        // panic();
-    }
-
-
-   /* Cast the allocated pointer to a region header.
-    */
-    new_region = (malloc_region *)vm_address;
-
-
-   /* Initialize the region header fields and link it onto
-    * the previous region.
-    */
-    new_region->region_size = region_size;
-    queue_init(&new_region->block_list);
-//    queue_init(&new_region->free_list);
-
-    new_region->free_size = region_size - sizeof(malloc_region);
-    new_region->free_address = &new_region->buffer;
-
-    queue_enter(&malloc_region_list, new_region, malloc_region *, links);
-
-   /* If debugging, add the new region's size to the total.
-    */
-#ifdef CLIENT_DEBUG
-    malloc_hiwater_mark += region_size;
-    num_regions++;
-#endif CLIENT_DEBUG
-
-    return new_region;
-
-} /* malloc_create_region() */
-
-
-/*********************************************************************
-* malloc_free_region()
-*
-* Package-internal function. VM-deallocates the given region.
-*********************************************************************/
-__private_extern__
-kern_return_t malloc_free_region(malloc_region * region) {
-
-    kmem_free(kernel_map,
-        (vm_address_t)region,
-        region->region_size);
-
-#ifdef CLIENT_DEBUG
-    num_regions--;
-#endif CLIENT_DEBUG
-    return KERN_SUCCESS;
-
-} /* malloc_free_region() */
-
-
-/*********************************************************************
-* malloc_create_block_in_region()
-*
-* Package-internal function. Allocates a new block out of the given
-* region. The requested size must include the block header. If the
-* size requested is larger than the region's free size, returns NULL.
-*********************************************************************/
-__private_extern__
-malloc_block * malloc_create_block_in_region(
-    malloc_region * region,
-    size_t block_size) {
-
-    malloc_block * new_block = NULL;
-
-
-   /* Sanity checking.
-    */
-    if (block_size > region->free_size) {
-        return NULL;
-        // FIXME: panic?
-    }
-
-
-   /* Carve out a new block.
-    */
-    new_block = (malloc_block *)region->free_address;
-    region->free_address = (char *)region->free_address + block_size;
-    region->free_size -= block_size;
-
-    memset(new_block, 0, sizeof(malloc_block));
-
-    new_block->region = region;
-    new_block->block_size = block_size;
-
-   /* Record the new block as the last one in the region.
-    */
-    queue_enter(&region->block_list, new_block, malloc_block *, links);
-
-    return new_block;
-
-} /* malloc_create_block_in_region() */
-
-
-/*********************************************************************
-* malloc_find_block()
-*
-* Package-internal function. Given a client buffer address, find the
-* malloc_block for it.
-*********************************************************************/
-__private_extern__
-void malloc_find_block(void * address,
-    malloc_block ** block,
-    malloc_region ** region) {
-
-    malloc_region * cur_region;
-
-    *block = NULL;
-    *region = NULL;
-
-    queue_iterate(&malloc_region_list, cur_region, malloc_region *, links) {
-
-        malloc_block  * cur_block;
-
-        queue_iterate(&cur_region->block_list, cur_block, malloc_block *, links) {
-            if (cur_block->buffer == address) {
-                *block = cur_block;
-                *region = cur_region;
-                return;
-            }
-        }
-    }
-
-    return;
-
-} /* malloc_find_block() */
-
-
-/*********************************************************************
-* malloc_get_free_block()
-*********************************************************************/
-__private_extern__
-void malloc_get_free_block(
-    size_t size,
-    malloc_block  ** block,
-    malloc_region ** region) {
-
-    malloc_block * cur_block;
-    size_t fit_threshold = 512;
-
-    *block = NULL;
-    *region = NULL;
-
-    queue_iterate(&sorted_free_block_list, cur_block, malloc_block *, links) {
-
-       /* If we find a block large enough, but not too large to waste memory,
-        * pull it out and return it, along with its region.
-        */
-        if (cur_block->block_size >= size &&
-            cur_block->block_size < (size + fit_threshold)) {
-
-            queue_remove(&sorted_free_block_list, cur_block, malloc_block *, links);
-            *block = cur_block;
-            *region = cur_block->region;
-            return;
-        }
-    }
-    return;
-}
diff --git a/libsa/malloc_debug_stuff b/libsa/malloc_debug_stuff
index 15619526c..91ab21044 100644
--- a/libsa/malloc_debug_stuff
+++ b/libsa/malloc_debug_stuff
@@ -1,7 +1,7 @@
 #ifdef DEBUG
 static void print_region_list(void);
 static int check_block_list(queue_entry * block_list, malloc_block * new_block);
-#endif DEBUG
+#endif /* DEBUG */
 
 
 void print_region_list(void) {
@@ -284,7 +284,7 @@ void malloc_report(void) {
                 cur_block->buffer, cur_block->block_size,
                 cur_block->block_size - sizeof(malloc_block));
         }
-#endif 0
+#endif /* 0 */
     }
 
     printf("High water mark: %ld\n", malloc_hiwater_mark);
diff --git a/libsa/malloc_unused b/libsa/malloc_unused
index cb9fa25af..45e581c56 100644
--- a/libsa/malloc_unused
+++ b/libsa/malloc_unused
@@ -22,7 +22,7 @@ void free_all(void) {
 
 #ifdef CLIENT_DEBUG
     current_block_total = 0;
-#endif CLIENT_DEBUG
+#endif /* CLIENT_DEBUG */
 
     return;
 
diff --git a/libsa/misc.c b/libsa/misc.c
index c5b5a99ab..bee2f5982 100644
--- a/libsa/misc.c
+++ b/libsa/misc.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libsa/mkext.c b/libsa/mkext.c
index 23693233c..020143271 100644
--- a/libsa/mkext.c
+++ b/libsa/mkext.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -26,7 +29,7 @@
 #else
 #include <Kernel/libsa/mkext.h>
 #include <stdlib.h>
-#endif KERNEL
+#endif /* KERNEL */
 
 
 __private_extern__ u_int32_t
diff --git a/libsa/ppc/setjmp.s b/libsa/ppc/setjmp.s
index 8350b13d4..14e95b5d4 100644
--- a/libsa/ppc/setjmp.s
+++ b/libsa/ppc/setjmp.s
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libsa/sort.c b/libsa/sort.c
index 2ed7ab3f0..381524494 100644
--- a/libsa/sort.c
+++ b/libsa/sort.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libsa/strrchr.c b/libsa/strrchr.c
index 8c57859e6..454c30c5b 100644
--- a/libsa/strrchr.c
+++ b/libsa/strrchr.c
@@ -3,21 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * "Portions Copyright (c) 1999 Apple Computer, Inc.  All Rights
- * Reserved.  This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.0 (the 'License').  You may not use this file
- * except in compliance with the License.  Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
  * 
  * The Original Code and all software distributed under the License are
  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License."
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/libsa/strstr.c b/libsa/strstr.c
index b5be864af..b178084d7 100644
--- a/libsa/strstr.c
+++ b/libsa/strstr.c
@@ -3,21 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * "Portions Copyright (c) 1999 Apple Computer, Inc.  All Rights
- * Reserved.  This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.0 (the 'License').  You may not use this file
- * except in compliance with the License.  Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
  * 
  * The Original Code and all software distributed under the License are
  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License."
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/makedefs/MakeInc.def b/makedefs/MakeInc.def
index 83c8b9278..5c9d12e86 100644
--- a/makedefs/MakeInc.def
+++ b/makedefs/MakeInc.def
@@ -129,7 +129,7 @@ export CFLAGS_I386 	= -arch i386 -Di386 -DI386 -D__I386__ -D_BIG_ENDIAN=__LITTLE
 
 export CFLAGS_RELEASEPPC = -O2 -mcpu=750 -mmultiple -fschedule-insns
 export CFLAGS_RELEASE_TRACEPPC = -O2 -mcpu=750 -mmultiple -fschedule-insns
-export CFLAGS_DEBUGPPC = -O1 -mcpu=750 -mmultiple -fschedule-insns
+export CFLAGS_DEBUGPPC = -O2 -mcpu=750 -mmultiple -fschedule-insns
 export CFLAGS_RELEASEI386 = -O2
 export CFLAGS_DEBUGI386 = -O2
 
@@ -201,7 +201,7 @@ export LDFLAGS_KERNEL_RELEASE 	=
 export LDFLAGS_KERNEL_DEBUG 	= 
 export LDFLAGS_KERNEL_PROFILE 	= 
 
-export LDFLAGS_KERNEL_PPC      = -arch ppc -segaddr __VECTORS 0x0 -segaddr __TEXT 0x11000 -e __start -sectalign __DATA __common 0x1000 -sectalign __DATA __bss 0x1000
+export LDFLAGS_KERNEL_PPC      = -arch ppc -segaddr __VECTORS 0x0 -segaddr __TEXT 0x7000 -e __start -sectalign __TEXT __text 0x1000 -sectalign __DATA __common 0x1000 -sectalign __DATA __bss 0x1000
 export LDFLAGS_KERNEL_I386     = -arch i386 -segaddr __TEXT 0x100000 -e _pstart
 
 export LDFLAGS_KERNEL	= $(LDFLAGS_KERNEL_GEN) \
@@ -247,6 +247,8 @@ export VPATH	 	= $(VPATH_GEN)$(VPATH_IMPORT)$(VPATH_EXTERN)$(VPATH_MAKEFILE)
 # install flags for header files
 # 
 INSTALL_FLAGS = -c -m 0444
+FILE_INSTALL_FLAGS = -c -m 0644
+DATA_INSTALL_FLAGS = -c -m 0644
 
 #
 # Header file destinations
diff --git a/makedefs/MakeInc.rule b/makedefs/MakeInc.rule
index 62c7558ff..2f844ffa3 100644
--- a/makedefs/MakeInc.rule
+++ b/makedefs/MakeInc.rule
@@ -524,7 +524,7 @@ $(INSTALL_FILE_FILES): $(DSTROOT)$(INSTALL_FILE_DIR)% : $(TARGET)/% force_file_i
 	@$(MKDIR) $(DSTROOT)$(INSTALL_FILE_DIR);			\
 	if [ "`echo $(INSTALL_ARCHS_LC) | wc -w`" -eq 1 ]; then	\
 		$(RM) $(RMFLAGS) $@;				\
-		install $(INSTALL_FLAGS) $< $(dir $@);		\
+		install $(FILE_INSTALL_FLAGS) $< $(dir $@);		\
 	else							\
 		if [ ! -e $@ ]; then				\
 			echo >empty_file;			\
@@ -555,10 +555,18 @@ $(INSTALL_FILESYS_FILES): $(SYMROOT)$(INSTALL_FILE_DIR)% : $(TARGET)/%.sys force
 		$(LIPO) $@ -replace $(ARCH_CONFIG_LC)  $< -o $@;	\
 	fi
 
+INSTALL_DATA_FILES = $(addprefix $(DSTROOT)$(INSTALL_DATA_DIR), $(INSTALL_DATA_LIST))
+
+$(INSTALL_DATA_FILES): $(DSTROOT)$(INSTALL_DATA_DIR)% : $(SOURCE)/%
+	@echo Installing $< in $@;
+	@$(MKDIR) $(dir $@);		\
+	$(RM) $(RMFLAGS) $@;		\
+	install $(DATA_INSTALL_FLAGS) $< $(dir $@);
+
 setup_build_install:
 	@echo "[ $(SOURCE) ] make setup_build_install $(KERNEL_CONFIG) $(ARCH_CONFIG) $(TARGET)"
 
-do_build_install: $(INSTALL_FILESYS_FILES) $(INSTALL_FILE_FILES)
+do_build_install: $(INSTALL_FILESYS_FILES) $(INSTALL_FILE_FILES) $(INSTALL_DATA_FILES)
 	@echo "[ $(SOURCE) ] make do_build_install $(KERNEL_CONFIG) $(ARCH_CONFIG) $(TARGET)"
 
 INSTALL_MAN_FILES = $(addprefix $(DSTROOT)/$(MANDIR)/$(INSTALL_MAN_DIR)/, $(INSTALL_MAN_LIST))
diff --git a/osfmk/Makefile b/osfmk/Makefile
index 0cf9f4e54..92ea3b008 100644
--- a/osfmk/Makefile
+++ b/osfmk/Makefile
@@ -9,6 +9,7 @@ include $(MakeInc_def)
 
 INSTINC_SUBDIRS = \
 	mach	\
+	machine	\
 	default_pager \
 	device \
 	mach_debug \
@@ -17,10 +18,12 @@ INSTINC_SUBDIRS = \
 
 INSTINC_SUBDIRS_PPC = \
 	mach \
+	ppc	\
 	profiling 
 
 INSTINC_SUBDIRS_I386 = \
 	mach	\
+	i386	\
 	profiling
 
 EXPINC_SUBDIRS = \
diff --git a/osfmk/UserNotification/KUNCUserNotifications.c b/osfmk/UserNotification/KUNCUserNotifications.c
index a4baa980e..8007e03b1 100644
--- a/osfmk/UserNotification/KUNCUserNotifications.c
+++ b/osfmk/UserNotification/KUNCUserNotifications.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/UserNotification/KUNCUserNotifications.h b/osfmk/UserNotification/KUNCUserNotifications.h
index 0351f1d87..c02b2fb11 100644
--- a/osfmk/UserNotification/KUNCUserNotifications.h
+++ b/osfmk/UserNotification/KUNCUserNotifications.h
@@ -2,21 +2,24 @@
  * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
- *
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- *
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * 
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
- *
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ * 
  * @APPLE_LICENSE_HEADER_END@
  */
 
diff --git a/osfmk/UserNotification/UNDReply.defs b/osfmk/UserNotification/UNDReply.defs
index 87bb8b6ac..9ef979642 100644
--- a/osfmk/UserNotification/UNDReply.defs
+++ b/osfmk/UserNotification/UNDReply.defs
@@ -2,21 +2,24 @@
  * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
- *
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- *
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * 
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
- *
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ * 
  * @APPLE_LICENSE_HEADER_END@
  */
 
diff --git a/osfmk/UserNotification/UNDRequest.defs b/osfmk/UserNotification/UNDRequest.defs
index e73bd0391..9740fde2a 100644
--- a/osfmk/UserNotification/UNDRequest.defs
+++ b/osfmk/UserNotification/UNDRequest.defs
@@ -2,21 +2,24 @@
  * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
- *
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- *
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * 
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
- *
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ * 
  * @APPLE_LICENSE_HEADER_END@
  */
 
diff --git a/osfmk/UserNotification/UNDTypes.defs b/osfmk/UserNotification/UNDTypes.defs
index 8ccefc684..46f3a2128 100644
--- a/osfmk/UserNotification/UNDTypes.defs
+++ b/osfmk/UserNotification/UNDTypes.defs
@@ -2,21 +2,24 @@
  * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
- *
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- *
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * 
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
- *
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ * 
  * @APPLE_LICENSE_HEADER_END@
  */
 
diff --git a/osfmk/UserNotification/UNDTypes.h b/osfmk/UserNotification/UNDTypes.h
index 32581eec0..16cb8a582 100644
--- a/osfmk/UserNotification/UNDTypes.h
+++ b/osfmk/UserNotification/UNDTypes.h
@@ -2,21 +2,24 @@
  * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
- *
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- *
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * 
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
- *
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ * 
  * @APPLE_LICENSE_HEADER_END@
  */
 
diff --git a/osfmk/conf/files.i386 b/osfmk/conf/files.i386
index fbdac7ab9..70255775e 100644
--- a/osfmk/conf/files.i386
+++ b/osfmk/conf/files.i386
@@ -64,6 +64,8 @@ osfmk/i386/rtclock.c		standard
 osfmk/i386/trap.c		standard
 osfmk/i386/user_ldt.c		standard
 
+osfmk/i386/commpage/commpage.c	standard
+
 osfmk/i386/AT386/autoconf.c	standard
 osfmk/i386/AT386/bbclock.c	standard
 osfmk/i386/AT386/conf.c		standard
diff --git a/osfmk/conf/files.ppc b/osfmk/conf/files.ppc
index bef664902..7c23352f5 100644
--- a/osfmk/conf/files.ppc
+++ b/osfmk/conf/files.ppc
@@ -13,29 +13,28 @@ OPTIONS/mp			optional mp
 # that the file is placed at the front of the line
 
 
-osfmk/ddb/db_aout.c		optional mach_kdb
-./ppc_disasm.c		optional mach_kdb
-osfmk/ppc/db_disasm.c	optional mach_kdb
-osfmk/ppc/db_asm.s	optional mach_kdb
+osfmk/ddb/db_aout.c			optional mach_kdb
+./ppc_disasm.c				optional mach_kdb
+osfmk/ppc/db_disasm.c		optional mach_kdb
 osfmk/ppc/db_interface.c	optional mach_kdb
 osfmk/ppc/db_trace.c		optional mach_kdb
 osfmk/ppc/db_low_trace.c	optional mach_kdb
+osfmk/ppc/bcopytest.c		optional mach_kdb
 
 osfmk/ppc/lowmem_vectors.s	standard
 osfmk/ppc/start.s			standard
 osfmk/ppc/_setjmp.s			standard
 
-osfmk/ppc/cpu.c 		standard
+osfmk/ppc/cpu.c 			standard
 osfmk/ppc/ppc_init.c		standard
 osfmk/ppc/ppc_vm_init.c		standard
-osfmk/ppc/bat_init.c		standard
 osfmk/ppc/model_dep.c		standard
-osfmk/ppc/mem.c				standard
 osfmk/ppc/pmap.c			standard
 osfmk/ppc/mappings.c		standard
 osfmk/ppc/savearea.c		standard
 osfmk/ppc/savearea_asm.s	standard
 osfmk/ppc/hw_vm.s			standard
+osfmk/ppc/skiplists.s		standard
 osfmk/ppc/hw_lock.s			standard
 osfmk/ppc/misc_asm.s		standard
 osfmk/ppc/status.c			standard
@@ -55,31 +54,41 @@ osfmk/ppc/misc.c			standard
 osfmk/ppc/interrupt.c		standard
 osfmk/ppc/machine_routines.c		standard
 osfmk/ppc/machine_routines_asm.s		standard
-#osfmk/ppc/Performance.s	standard
 osfmk/ppc/Emulate.s			standard
+osfmk/ppc/Emulate64.s		standard
 osfmk/ppc/AltiAssist.s		standard
 osfmk/ppc/conf.c			standard
 osfmk/ppc/rtclock.c			standard
 osfmk/ppc/Diagnostics.c		standard
 osfmk/ppc/PPCcalls.c		standard
 osfmk/ppc/vmachmon.c		standard
-osfmk/ppc/vmachmon_asm.s		standard
+osfmk/ppc/vmachmon_asm.s	standard
 
-#osfmk/ppc/POWERMAC/ser16550.c		standard
-osfmk/ppc/POWERMAC/autoconf.c		optional xxx
-osfmk/ppc/POWERMAC/pci.c		optional xxx
-osfmk/ppc/POWERMAC/pci_probe.c		optional xxx
-osfmk/ppc/POWERMAC/pci_compat.c		optional xxx
+osfmk/ppc/Firmware.s		standard
+osfmk/ppc/FirmwareC.c		standard
 
-osfmk/ppc/Firmware.s			standard
-osfmk/ppc/FirmwareC.c			standard
+osfmk/ppc/aligned_data.s	standard
 
-osfmk/ppc/aligned_data.s		standard
+osfmk/ppc/hw_perfmon.c		standard
+
+osfmk/ppc/commpage/commpage.c	standard
+osfmk/ppc/commpage/commpage_asm.s	standard
+osfmk/ppc/commpage/bcopy_g3.s	standard
+osfmk/ppc/commpage/bcopy_g4.s	standard
+osfmk/ppc/commpage/bcopy_970.s	standard
+osfmk/ppc/commpage/bcopy_64.s	standard
+osfmk/ppc/commpage/bzero_32.s	standard
+osfmk/ppc/commpage/bzero_128.s	standard
+osfmk/ppc/commpage/cacheflush.s	standard
+osfmk/ppc/commpage/gettimeofday.s	standard
+osfmk/ppc/commpage/mach_absolute_time.s	standard
+osfmk/ppc/commpage/pthread.s	standard
+osfmk/ppc/commpage/spinlocks.s	standard
+osfmk/ppc/commpage/bigcopy_970.s	standard
 
 osfmk/kdp/ml/ppc/kdp_machdep.c        optional mach_kdp
 osfmk/kdp/ml/ppc/kdp_vm.c             optional mach_kdp
 osfmk/kdp/ml/ppc/kdp_misc.s           optional mach_kdp
-#osfmk/kdp/pe/POWERMAC/kdp_mace.c      optional mach_kdp
 
 osfmk/ppc/serial_console.c		optional	scc device-driver
 osfmk/ppc/POWERMAC/serial_io.c	optional	scc device-driver
diff --git a/osfmk/conf/kernelversion.minor b/osfmk/conf/kernelversion.minor
index 0cfbf0888..7f8f011eb 100644
--- a/osfmk/conf/kernelversion.minor
+++ b/osfmk/conf/kernelversion.minor
@@ -1 +1 @@
-2
+7
diff --git a/osfmk/conf/kernelversion.variant b/osfmk/conf/kernelversion.variant
index e69de29bb..7ed6ff82d 100644
--- a/osfmk/conf/kernelversion.variant
+++ b/osfmk/conf/kernelversion.variant
@@ -0,0 +1 @@
+5
diff --git a/osfmk/conf/version.minor b/osfmk/conf/version.minor
index 0cfbf0888..7f8f011eb 100644
--- a/osfmk/conf/version.minor
+++ b/osfmk/conf/version.minor
@@ -1 +1 @@
-2
+7
diff --git a/osfmk/conf/version.variant b/osfmk/conf/version.variant
index 8b1378917..7ed6ff82d 100644
--- a/osfmk/conf/version.variant
+++ b/osfmk/conf/version.variant
@@ -1 +1 @@
-
+5
diff --git a/osfmk/ddb/db_access.c b/osfmk/ddb/db_access.c
index 75fe96d4d..d803b7e54 100644
--- a/osfmk/ddb/db_access.c
+++ b/osfmk/ddb/db_access.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -69,33 +72,6 @@
 
 int db_access_level = DB_ACCESS_LEVEL;
 
-/*
- * This table is for sign-extending things.
- * Therefore its entries are signed, and yes
- * they are in fact negative numbers.
- * So don't put Us in it. Or Ls either.
- * Otherwise there is no point having it, n'est pas ?
- */
-static int db_extend[sizeof(long)+1] = { /* table for sign-extending */
-#if defined(__arch64__)
-	0,
-	0xFFFFFFFFFFFFFF80,
-	0xFFFFFFFFFFFF8000,
-	0xFFFFFFFFFF800000,
-	0xFFFFFFFF80000000,
-	0xFFFFFF8000000000,
-	0xFFFF800000000000,
-	0xFF80000000000000,
-	0x8000000000000000,
-#else /* !defined(__arch64__) */
-	0,
-	0xFFFFFF80,
-	0xFFFF8000,
-	0xFF800000,
-	0x80000000
-#endif /* defined(__arch64__) */
-};
-
 db_expr_t
 db_get_task_value(
 	db_addr_t	addr,
@@ -106,6 +82,9 @@ db_get_task_value(
 	char		data[sizeof(db_expr_t)];
 	register db_expr_t value;
 	register int	i;
+	uint64_t signx;
+
+	if(size == 0) return 0;
 
 	db_read_bytes((vm_offset_t)addr, size, data, task);
 
@@ -118,11 +97,13 @@ db_get_task_value(
 	{
 	    value = (value << 8) + (data[i] & 0xFF);
 	}
-	    
-	if (size <= sizeof(int)) {
-	    if (is_signed && (value & db_extend[size]) != 0)
-		value |= db_extend[size];
-	}
+	
+	if(!is_signed) return value;
+	
+	signx = 0xFFFFFFFFFFFFFFFFULL << ((size << 3) - 1);
+	 
+	if(value & signx) value |= signx;	/* Add 1s to front if sign bit is on */
+
 	return (value);
 }
 
diff --git a/osfmk/ddb/db_access.h b/osfmk/ddb/db_access.h
index 89e92c114..11885fa7f 100644
--- a/osfmk/ddb/db_access.h
+++ b/osfmk/ddb/db_access.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ddb/db_aout.c b/osfmk/ddb/db_aout.c
index 05d507670..7c02d170c 100644
--- a/osfmk/ddb/db_aout.c
+++ b/osfmk/ddb/db_aout.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ddb/db_aout.h b/osfmk/ddb/db_aout.h
index 28b9f4255..8b03e052d 100644
--- a/osfmk/ddb/db_aout.h
+++ b/osfmk/ddb/db_aout.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ddb/db_break.c b/osfmk/ddb/db_break.c
index 4f7df3ec1..4eb4c2146 100644
--- a/osfmk/ddb/db_break.c
+++ b/osfmk/ddb/db_break.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -966,7 +969,11 @@ db_breakpoint_cmd(
 	      db_error("Invalid user space address\n");
 	    user_space = TRUE;
 	    db_printf("%#X is in user space\n", addr);
+#ifdef ppc
+	    db_printf("kernel is from %#X to %#x\n", VM_MIN_KERNEL_ADDRESS, vm_last_addr);
+#else
 	    db_printf("kernel is from %#X to %#x\n", VM_MIN_KERNEL_ADDRESS, VM_MAX_KERNEL_ADDRESS);
+#endif
 	}
 	if (db_option(modif, 't') || task_bpt) {
 	    for (n = 0; db_get_next_act(&thr_act, n); n++) {
diff --git a/osfmk/ddb/db_break.h b/osfmk/ddb/db_break.h
index 2882408dd..c2aa6a5e7 100644
--- a/osfmk/ddb/db_break.h
+++ b/osfmk/ddb/db_break.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ddb/db_coff.h b/osfmk/ddb/db_coff.h
index b0cad757e..b49042ef7 100644
--- a/osfmk/ddb/db_coff.h
+++ b/osfmk/ddb/db_coff.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ddb/db_command.c b/osfmk/ddb/db_command.c
index 788cb1eeb..3dc1af941 100644
--- a/osfmk/ddb/db_command.c
+++ b/osfmk/ddb/db_command.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -462,7 +465,6 @@ struct db_command db_show_cmds[] = {
 	{ "simple_lock", db_show_one_simple_lock,	0,	0 },
 	{ "thread_log", (db_func)db_show_thread_log,	0,	0 },
 	{ "shuttle",	db_show_shuttle,		0,	0 },
-	{ "etap_log",	db_show_etap_log,		0,	0 },
 	{ (char *)0, }
 };
 
@@ -516,14 +518,19 @@ struct db_command db_command_table[] = {
 #if defined(__ppc__)
 	{ "lt",		db_low_trace,			CS_MORE|CS_SET_DOT,	0 },
 	{ "dl",		db_display_long,		CS_MORE|CS_SET_DOT,	0 },
+	{ "dc",		db_display_char,		CS_MORE|CS_SET_DOT,	0 },
 	{ "dr",		db_display_real,		CS_MORE|CS_SET_DOT,	0 },
 	{ "dv",		db_display_virtual,		CS_MORE|CS_SET_DOT,	0 },
 	{ "dm",		db_display_mappings,	CS_MORE|CS_SET_DOT,	0 },
+	{ "dh",		db_display_hash,		CS_MORE|CS_SET_DOT,	0 },
 	{ "dp",		db_display_pmap,		CS_MORE,			0 },
+	{ "di",		db_display_iokit,		CS_MORE,			0 },
 	{ "ds",		db_display_save,		CS_MORE|CS_SET_DOT,	0 },
 	{ "dx",		db_display_xregs,		CS_MORE|CS_SET_DOT,	0 },
 	{ "dk",		db_display_kmod,		CS_MORE,			0 },
 	{ "gs",		db_gsnoop,				CS_MORE,			0 },
+	{ "cm",		db_check_mappings,		CS_MORE,			0 },
+	{ "cp",		db_check_pmaps,			CS_MORE,			0 },
 #endif
 	{ (char *)0, }
 };
@@ -616,16 +623,6 @@ db_error(char *s)
 {
 	extern int db_macro_level;
 
-#if defined(__alpha)
-#  if KDEBUG
-	extern boolean_t kdebug_mode;
-	if (kdebug_mode) {
-		if (s) kprintf(DBG_DEBUG, s);
-		return;
-	}
-#  endif /* KDEBUG */
-#endif /* defined(__alpha) */
-
 	db_macro_level = 0;
 	if (db_recover) {
 	    if (s > (char *)1)
@@ -651,10 +648,11 @@ db_fncall(void)
 {
 	db_expr_t	fn_addr;
 #define	MAXARGS		11
-	db_expr_t	args[MAXARGS];
+	uint32_t	args[MAXARGS];
+	db_expr_t argwork;
 	int		nargs = 0;
-	db_expr_t	retval;
-	db_expr_t	(*func)(db_expr_t, ...);
+	uint32_t	retval;
+	uint32_t	(*func)(uint32_t, ...);
 	int		t;
 
 	if (!db_expression(&fn_addr)) {
@@ -662,31 +660,33 @@ db_fncall(void)
 	    db_flush_lex();
 	    return;
 	}
-	func = (db_expr_t (*) (db_expr_t, ...)) fn_addr;
+	func = (uint32_t (*) (uint32_t, ...)) fn_addr;
 
 	t = db_read_token();
 	if (t == tLPAREN) {
-	    if (db_expression(&args[0])) {
-		nargs++;
-		while ((t = db_read_token()) == tCOMMA) {
-		    if (nargs == MAXARGS) {
-			db_printf("Too many arguments\n");
-			db_flush_lex();
-			return;
-		    }
-		    if (!db_expression(&args[nargs])) {
-			db_printf("Argument missing\n");
-			db_flush_lex();
-			return;
-		    }
-		    nargs++;
-		}
-		db_unread_token(t);
+	    if (db_expression(&argwork)) {
+			args[nargs] = (uint32_t)argwork;
+			nargs++;
+			while ((t = db_read_token()) == tCOMMA) {
+				if (nargs == MAXARGS) {
+					db_printf("Too many arguments\n");
+					db_flush_lex();
+					return;
+				}
+				if (!db_expression(&argwork)) {
+					db_printf("Argument missing\n");
+					db_flush_lex();
+					return;
+				}
+				args[nargs] = (uint32_t)argwork;
+				nargs++;
+			}
+			db_unread_token(t);
 	    }
 	    if (db_read_token() != tRPAREN) {
-		db_printf("?\n");
-		db_flush_lex();
-		return;
+			db_printf("?\n");
+			db_flush_lex();
+			return;
 	    }
 	}
 	while (nargs < MAXARGS) {
diff --git a/osfmk/ddb/db_command.h b/osfmk/ddb/db_command.h
index 9626a5091..bb5142bea 100644
--- a/osfmk/ddb/db_command.h
+++ b/osfmk/ddb/db_command.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ddb/db_cond.c b/osfmk/ddb/db_cond.c
index f5aa3af0c..b22b3d76a 100644
--- a/osfmk/ddb/db_cond.c
+++ b/osfmk/ddb/db_cond.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ddb/db_cond.h b/osfmk/ddb/db_cond.h
index cb178648d..2f930448a 100644
--- a/osfmk/ddb/db_cond.h
+++ b/osfmk/ddb/db_cond.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ddb/db_examine.c b/osfmk/ddb/db_examine.c
index 19a46186a..93e4cce67 100644
--- a/osfmk/ddb/db_examine.c
+++ b/osfmk/ddb/db_examine.c
@@ -3,204 +3,28 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
 /*
  * @OSF_COPYRIGHT@
  */
-/*
- * HISTORY
- * 
- * Revision 1.1.1.1  1998/09/22 21:05:47  wsanchez
- * Import of Mac OS X kernel (~semeria)
- *
- * Revision 1.2  1998/04/24 19:34:23  semeria
- * KDP and KDB support
- *
- * Revision 1.1.1.1  1998/03/07 02:26:09  wsanchez
- * Import of OSF Mach kernel (~mburg)
- *
- * Revision 1.2.42.2  1997/09/12  17:15:15  stephen
- * 	make x/x do zero fill right justified hex display
- * 	[1997/09/12  16:31:04  stephen]
- *
- * Revision 1.2.42.1  1997/03/27  18:46:31  barbou
- * 	Add 'p' option to the "examine" command - values in
- * 	memory treated as addresses and rendered as sym+offset
- * 	[1995/12/29  21:32:33  mod]
- * 	ri-osc CR1560: make search command output address of any matching
- * 	data it finds (so user knows it did something).
- * 	[1995/09/20  15:24:55  bolinger]
- * 	[97/02/25            barbou]
- * 
- * Revision 1.2.25.5  1996/01/09  19:15:38  devrcs
- * 	Add db_print_loc() & db_print_inst() functions.
- * 	Make 'l' display 32 bits and new 'q' to display 64 bits.
- * 	Allow 'u' to display unsigned decimal values (same as 'U').
- * 	Changed declarations of 'register foo' to 'register int foo'.
- * 	[1995/12/01  21:42:03  jfraser]
- * 
- * 	Merged '64-bit safe' changes from DEC alpha port.
- * 	[1995/11/21  18:02:58  jfraser]
- * 
- * Revision 1.2.25.4  1995/06/13  18:21:27  sjs
- * 	Merge with flipc_shared.
- * 	[95/05/22            sjs]
- * 
- * Revision 1.2.30.1  1995/04/03  17:35:17  randys
- * 	Minor change; allow a repeat count to work properly when multiple
- * 	modifier flags are given to the ddb 'x' command.  This allows,
- * 	for instance, examination of multiple words in activations other
- * 	than the current one.
- * 	[95/04/03            randys]
- * 
- * Revision 1.2.25.3  1995/01/06  19:10:09  devrcs
- * 	mk6 CR668 - 1.3b26 merge
- * 	* Revision 1.2.6.7  1994/05/06  18:39:09  tmt
- * 	Merged osc1.3dec/shared with osc1.3b19
- * 	Merge Alpha changes into osc1.312b source code.
- * 	64bit cleanup.
- * 	* End1.3merge
- * 	[1994/11/04  08:49:22  dwm]
- * 
- * Revision 1.2.25.2  1994/09/23  01:18:44  ezf
- * 	change marker to not FREE
- * 	[1994/09/22  21:09:44  ezf]
- * 
- * Revision 1.2.25.1  1994/06/11  21:11:43  bolinger
- * 	Merge up to NMK17.2.
- * 	[1994/06/11  20:01:31  bolinger]
- * 
- * Revision 1.2.23.1  1994/02/08  10:57:47  bernadat
- * 	Fixed output of an examine command to have a power of 2
- * 	number of fields.
- * 	[93/09/29            paire]
- * 
- * 	Added dump of hexadecimal address in each line of examine command.
- * 	Fixed beginning of line to be always located at position 0.
- * 	[93/08/11            paire]
- * 	[94/02/07            bernadat]
- * 
- * Revision 1.2.21.4  1994/03/17  22:35:27  dwm
- * 	The infamous name change:  thread_activation + thread_shuttle = thread.
- * 	[1994/03/17  21:25:43  dwm]
- * 
- * Revision 1.2.21.3  1994/01/12  17:50:40  dwm
- * 	Coloc: initial restructuring to follow Utah model.
- * 	[1994/01/12  17:13:08  dwm]
- * 
- * Revision 1.2.21.2  1993/10/12  16:38:58  dwm
- * 	Print '\n' in x/s statements. [rwd]
- * 	[1993/10/12  16:14:41  dwm]
- * 
- * Revision 1.2.6.5  1993/08/11  20:37:37  elliston
- * 	Add ANSI Prototypes.  CR #9523.
- * 	[1993/08/11  03:33:05  elliston]
- * 
- * Revision 1.2.6.4  1993/08/09  19:34:42  dswartz
- * 	Add ANSI prototypes - CR#9523
- * 	[1993/08/06  15:47:32  dswartz]
- * 
- * Revision 1.2.6.3  1993/07/27  18:27:07  elliston
- * 	Add ANSI prototypes.  CR #9523.
- * 	[1993/07/27  18:11:21  elliston]
- * 
- * Revision 1.2.6.2  1993/06/09  02:20:00  gm
- * 	Added to OSF/1 R1.3 from NMK15.0.
- * 	[1993/06/02  20:56:10  jeffc]
- * 
- * Revision 1.2  1993/04/19  16:01:58  devrcs
- * 	Changes from mk78:
- * 	Added void type to functions that needed it.
- * 	Added init to 'size' in db_search_cmd(). Removed unused variables.
- * 	Other cleanup to quiet gcc warnings.
- * 	[92/05/16            jfriedl]
- * 	x/u now examines current user space. x/t still examines user
- * 	space of the the specified thread. x/tu is redundant.
- * 	To examine an value as unsigned decimal, use x/U.
- * 	[92/04/18            danner]
- * 	[93/02/02            bruel]
- * 
- * 	Remember count argument when repeating commands instead of the
- * 	default command, also apply all the formats to current address
- * 	instead of incrementing addresses when switching to next format.
- * 	[barbou@gr.osf.org]
- * 
- * 	Support 'A' format for print 'p' command [barbou@gr.osf.org]
- * 	[92/12/03            bernadat]
- * 
- * Revision 1.1  1992/09/30  02:01:01  robert
- * 	Initial revision
- * 
- * $EndLog$
- */
-/* CMU_HIST */
-/*
- * Revision 2.7  91/10/09  15:59:28  af
- * 	 Revision 2.6.1.1  91/10/05  13:05:49  jeffreyh
- * 	 	Supported non current task space data examination and search.
- * 	 	Added 'm' format and db_xcdump to print with hex and characters.
- * 	 	Added db_examine_{forward, backward}.
- * 	 	Changed db_print_cmd to support variable number of parameters
- * 	 	including string constant.
- * 	 	Included "db_access.h".
- * 	 	[91/08/29            tak]
- * 
- * Revision 2.6.1.1  91/10/05  13:05:49  jeffreyh
- * 	Supported non current task space data examination and search.
- * 	Added 'm' format and db_xcdump to print with hex and characters.
- * 	Added db_examine_{forward, backward}.
- * 	Changed db_print_cmd to support variable number of parameters
- * 	including string constant.
- * 	Included "db_access.h".
- * 	[91/08/29            tak]
- * 
- * Revision 2.6  91/08/28  11:11:01  jsb
- * 	Added 'A' flag to examine: just like 'a' (address), but prints addr
- * 	as a procedure type, thus printing file/line info if available.
- * 	Useful when called as 'x/Ai'.
- * 	[91/08/13  18:14:55  jsb]
- * 
- * Revision 2.5  91/05/14  15:33:31  mrt
- * 	Correcting copyright
- * 
- * Revision 2.4  91/02/05  17:06:20  mrt
- * 	Changed to new Mach copyright
- * 	[91/01/31  16:17:37  mrt]
- * 
- * Revision 2.3  90/11/07  16:49:23  rpd
- * 	Added db_search_cmd, db_search.
- * 	[90/11/06            rpd]
- * 
- * Revision 2.2  90/08/27  21:50:38  dbg
- * 	Add 'r', 'z' to print and examine formats.
- * 	Change calling sequence of db_disasm.
- * 	db_examine sets db_prev and db_next instead of explicitly
- * 	advancing dot.
- * 	[90/08/20            dbg]
- * 	Reflected changes in db_printsym()'s calling seq.
- * 	[90/08/20            af]
- * 	Reduce lint.
- * 	[90/08/07            dbg]
- * 	Created.
- * 	[90/07/25            dbg]
- * 
- */
-/* CMU_ENDHIST */
 /* 
  * Mach Operating System
  * Copyright (c) 1991,1990 Carnegie Mellon University
@@ -445,10 +269,10 @@ db_examine(
 					sizeof(db_expr_t), FALSE, task );
 				    db_find_task_sym_and_offset( value,
 					&symName, &offset, task);
-				    db_printf("\n\t*%8x(%8X) = %s",
+				    db_printf("\n\t*%8llX(%8llX) = %s",
 						next_addr, value, symName );
 				    if( offset )  {
-					db_printf("+%X", offset );
+					db_printf("+%llX", offset );
 				    }
 				    next_addr += size;
 				}
@@ -464,7 +288,7 @@ db_examine(
 				    value = db_get_task_value(next_addr,
 							      sizeof (db_expr_t),
 							      TRUE,task);
-				    db_printf("%-*r", width, value);
+				    db_printf("%-*llr", width, value);
 				    next_addr += sizeof (db_expr_t);
 				}
 				if (sz > 0) {
@@ -474,13 +298,11 @@ db_examine(
 				    }
 				    value = db_get_task_value(next_addr, sz,
 							      TRUE, task);
-				    db_printf("%-*R", width, value);
+				    db_printf("%-*llR", width, value);
 				    next_addr += sz;
 				}
 				break;
-#ifdef APPLE
 			    case 'X':	/* unsigned hex */
-#endif
 			    case 'x':	/* unsigned hex */
 				for (sz = size, next_addr = addr;
 				     sz >= sizeof (db_expr_t);
@@ -492,14 +314,10 @@ db_examine(
 				    value = db_get_task_value(next_addr,
 							      sizeof (db_expr_t),
 							      FALSE,task);
-#ifdef APPLE
 			            if ( c == 'X')
-				      db_printf("%0*X ", 2*size, value);
+				      db_printf("%0*llX ", 2*size, value);
 				    else
-				      db_printf("%-*x", width, value);
-#else
-				    db_printf("%-*x", width, value);
-#endif
+				      db_printf("%-*llx", width, value);
 				    next_addr += sizeof (db_expr_t);
 			        }
 				if (sz > 0) {
@@ -509,14 +327,10 @@ db_examine(
 				    }
 				    value = db_get_task_value(next_addr, sz,
 							      FALSE, task);
-#ifdef APPLE
 			            if ( c == 'X')
-				      db_printf("%0*X ", 2*size, value);
+				      db_printf("%0*llX ", 2*size, value);
 				    else
-				      db_printf("%-*X", width, value);
-#else
-				    db_printf("%-*X", width, value);
-#endif
+				      db_printf("%-*llX", width, value);
 				    next_addr += sz;
 				}
 				break;
@@ -531,7 +345,7 @@ db_examine(
 				    value = db_get_task_value(next_addr,
 							      sizeof (db_expr_t),
 							      TRUE, task);
-				    db_printf("%-*z", width, value);
+				    db_printf("%-*llz", width, value);
 				    next_addr += sizeof (db_expr_t);
 				}
 				if (sz > 0) {
@@ -541,7 +355,7 @@ db_examine(
 				    }
 				    value = db_get_task_value(next_addr,sz,
 							      TRUE,task);
-				    db_printf("%-*Z", width, value);
+				    db_printf("%-*llZ", width, value);
 				    next_addr += sz;
 				}
 				break;
@@ -556,7 +370,7 @@ db_examine(
 				    value = db_get_task_value(next_addr,
 							      sizeof (db_expr_t),
 							      TRUE,task);
-				    db_printf("%-*d", width, value);
+				    db_printf("%-*lld", width, value);
 				    next_addr += sizeof (db_expr_t);
 				}
 				if (sz > 0) {
@@ -566,7 +380,7 @@ db_examine(
 				    }
 				    value = db_get_task_value(next_addr, sz,
 							      TRUE, task);
-				    db_printf("%-*D", width, value);
+				    db_printf("%-*llD", width, value);
 				    next_addr += sz;
 				}
 				break;
@@ -582,7 +396,7 @@ db_examine(
 				    value = db_get_task_value(next_addr,
 							      sizeof (db_expr_t),
 							      FALSE,task);
-				    db_printf("%-*u", width, value);
+				    db_printf("%-*llu", width, value);
 				    next_addr += sizeof (db_expr_t);
 				}
 				if (sz > 0) {
@@ -592,7 +406,7 @@ db_examine(
 				    }
 				    value = db_get_task_value(next_addr, sz,
 							      FALSE, task);
-				    db_printf("%-*U", width, value);
+				    db_printf("%-*llU", width, value);
 				    next_addr += sz;
 				}
 				break;
@@ -607,7 +421,7 @@ db_examine(
 				    value = db_get_task_value(next_addr,
 							      sizeof (db_expr_t),
 							      FALSE,task);
-				    db_printf("%-*o", width, value);
+				    db_printf("%-*llo", width, value);
 				    next_addr += sizeof (db_expr_t);
 				}
 				if (sz > 0) {
@@ -617,7 +431,7 @@ db_examine(
 				    }
 				    value = db_get_task_value(next_addr, sz,
 							      FALSE, task);
-				    db_printf("%-*o", width, value);
+				    db_printf("%-*llo", width, value);
 				    next_addr += sz;
 				}
 				break;
@@ -630,9 +444,9 @@ db_examine(
 				    if ((value >= ' ' && value <= '~') ||
 					value == '\n' ||
 					value == '\t')
-					    db_printf("%c", value);
+					    db_printf("%llc", value);
 				    else
-					    db_printf("\\%03o", value);
+					    db_printf("\\%03llo", value);
 				}
 				break;
 			    case 's':	/* null-terminated string */
@@ -645,9 +459,9 @@ db_examine(
 				    if (value == 0)
 					break;
 				    if (value >= ' ' && value <= '~')
-					db_printf("%c", value);
+					db_printf("%llc", value);
 				    else
-					db_printf("\\%03o", value);
+					db_printf("\\%03llo", value);
 				}
 				break;
 			    case 'i':	/* instruction */
@@ -718,29 +532,32 @@ db_print_cmd(void)
 				 task);
 		break;
 	    case 'r':
-		db_printf("%11r", value);
+		db_printf("%11llr", value);
+		break;
+	    case 'X':
+		db_printf("%016llX", value);
 		break;
 	    case 'x':
-		db_printf("%08x", value);
+		db_printf("%016llx", value);
 		break;
 	    case 'z':
-		db_printf("%8z", value);
+		db_printf("%16llz", value);
 		break;
 	    case 'd':
-		db_printf("%11d", value);
+		db_printf("%11lld", value);
 		break;
 	    case 'u':
-		db_printf("%11u", value);
+		db_printf("%11llu", value);
 		break;
 	    case 'o':
-		db_printf("%16o", value);
+		db_printf("%16llo", value);
 		break;
 	    case 'c':
 		value = value & 0xFF;
 		if (value >= ' ' && value <= '~')
-		    db_printf("%c", value);
+		    db_printf("%llc", value);
 		else
-		    db_printf("\\%03o", value);
+		    db_printf("\\%03llo", value);
 		break;
 	    default:
 		db_printf("Unknown format %c\n", db_print_format);
@@ -903,11 +720,11 @@ db_xcdump(
 		db_printf("%s:\n", name);
 		off = -1;
 	    }
-	    db_printf("%0*X:%s", 2*sizeof(db_addr_t), addr,
+	    db_printf("%0*llX:%s", 2*sizeof(db_addr_t), addr,
 					(size != 1) ? " " : "" );
 	    bcount = ((n > DB_XCDUMP_NC)? DB_XCDUMP_NC: n);
-	    if (trunc_page(addr) != trunc_page(addr+bcount-1)) {
-		db_addr_t next_page_addr = trunc_page(addr+bcount-1);
+	    if (trunc_page_32(addr) != trunc_page_32(addr+bcount-1)) {
+		db_addr_t next_page_addr = trunc_page_32(addr+bcount-1);
 		if (!DB_CHECK_ACCESS(next_page_addr, sizeof(int), task))
 		    bcount = next_page_addr - addr;
 	    }
@@ -916,7 +733,7 @@ db_xcdump(
 		if (i % 4 == 0)
 			db_printf(" ");
 		value = db_get_task_value(addr, size, FALSE, task);
-		db_printf("%0*x ", size*2, value);
+		db_printf("%0*llX ", size*2, value);
 		addr += size;
 		db_find_task_sym_and_offset(addr, &name, &off, task);
 	    }
@@ -927,7 +744,7 @@ db_xcdump(
 	    db_printf("%s*", (size != 1)? " ": "");
 	    for (i = 0; i < bcount; i++) {
 		value = data[i];
-		db_printf("%c", (value >= ' ' && value <= '~')? value: '.');
+		db_printf("%llc", (value >= ' ' && value <= '~')? value: '.');
 	    }
 	    db_printf("*\n");
 	}
diff --git a/osfmk/ddb/db_examine.h b/osfmk/ddb/db_examine.h
index e59698ed6..dda92dc61 100644
--- a/osfmk/ddb/db_examine.h
+++ b/osfmk/ddb/db_examine.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ddb/db_expr.c b/osfmk/ddb/db_expr.c
index d1a27e584..28079f5a3 100644
--- a/osfmk/ddb/db_expr.c
+++ b/osfmk/ddb/db_expr.c
@@ -3,121 +3,28 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
 /*
  * @OSF_COPYRIGHT@
  */
-/*
- * HISTORY
- * 
- * Revision 1.1.1.1  1998/09/22 21:05:48  wsanchez
- * Import of Mac OS X kernel (~semeria)
- *
- * Revision 1.1.1.1  1998/03/07 02:26:09  wsanchez
- * Import of OSF Mach kernel (~mburg)
- *
- * Revision 1.2.19.1  1997/03/27  18:46:35  barbou
- * 	ri-osc CR1561: make operators "logical and", "logical or"
- * 	lex correctly.
- * 	[1995/09/20  15:26:38  bolinger]
- * 	[97/02/25            barbou]
- *
- * Revision 1.2.10.2  1995/01/06  19:10:13  devrcs
- * 	mk6 CR668 - 1.3b26 merge
- * 	* Revision 1.2.3.5  1994/05/06  18:39:16  tmt
- * 	Merged osc1.3dec/shared with osc1.3b19
- * 	Merge Alpha changes into osc1.312b source code.
- * 	64bit cleanup.
- * 	* End1.3merge
- * 	[1994/11/04  08:49:27  dwm]
- * 
- * Revision 1.2.10.1  1994/09/23  01:19:06  ezf
- * 	change marker to not FREE
- * 	[1994/09/22  21:09:53  ezf]
- * 
- * Revision 1.2.3.3  1993/07/27  18:27:15  elliston
- * 	Add ANSI prototypes.  CR #9523.
- * 	[1993/07/27  18:11:36  elliston]
- * 
- * Revision 1.2.3.2  1993/06/09  02:20:06  gm
- * 	Added to OSF/1 R1.3 from NMK15.0.
- * 	[1993/06/02  20:56:16  jeffc]
- * 
- * Revision 1.2  1993/04/19  16:02:09  devrcs
- * 	Allow unprefixed (0x) hexadecimal constants starting by a letter:
- * 	unknown symbols are tentatively interpreted as hexadecimal constants,
- * 	and ambiguities are reported.
- * 	[93/03/24            barbou]
- * 
- * 	Changes from mk78:
- * 	Removed unused variable from db_unary().
- * 	[92/05/16            jfriedl]
- * 	[93/02/02            bruel]
- * 
- * 	Added string format arguments [barbou@gr.osf.org]
- * 	[92/12/03            bernadat]
- * 
- * Revision 1.1  1992/09/30  02:01:04  robert
- * 	Initial revision
- * 
- * $EndLog$
- */
-/* CMU_HIST */
-/*
- * Revision 2.5  91/10/09  15:59:46  af
- * 	 Revision 2.4.3.1  91/10/05  13:06:04  jeffreyh
- * 	 	Added relational expression etc. to support condition expression.
- * 	 	Supported modifier after indirect expression to specify size,
- * 	 	  sign extention and non current task space indirection.
- * 	 	Changed error messages to print more information.
- * 	 	[91/08/29            tak]
- * 
- * Revision 2.4.3.1  91/10/05  13:06:04  jeffreyh
- * 	Added relational expression etc. to support condition expression.
- * 	Supported modifier after indirect expression to specify size,
- * 	  sign extention and non current task space indirection.
- * 	Changed error messages to print more information.
- * 	[91/08/29            tak]
- * 
- * Revision 2.4  91/05/14  15:33:45  mrt
- * 	Correcting copyright
- * 
- * Revision 2.3  91/02/05  17:06:25  mrt
- * 	Changed to new Mach copyright
- * 	[91/01/31  16:17:46  mrt]
- * 
- * Revision 2.2  90/08/27  21:50:57  dbg
- * 	Use '..' instead of '$$' for db_prev.
- * 	Use '+' for db_next.
- * 	[90/08/22            dbg]
- * 
- * 	Allow repeated unary operators.
- * 	[90/08/20            dbg]
- * 
- * 	Reflected back rename of db_symbol_value->db_value_of_name
- * 	[90/08/20            af]
- * 	Reduce lint.
- * 	[90/08/07            dbg]
- * 	Created.
- * 	[90/07/25            dbg]
- * 
- */
-/* CMU_ENDHIST */
 /* 
  * Mach Operating System
  * Copyright (c) 1991,1990 Carnegie Mellon University
@@ -462,7 +369,7 @@ db_shift_expr(db_expr_t *valuep)
 		lhs <<= rhs;
 	    else {
 		/* Shift right is unsigned */
-		lhs = (natural_t) lhs >> rhs;
+		lhs = (uint64_t) lhs >> rhs;
 	    }
 	    t = db_read_token();
 	}
diff --git a/osfmk/ddb/db_expr.h b/osfmk/ddb/db_expr.h
index a57dca83b..616837678 100644
--- a/osfmk/ddb/db_expr.h
+++ b/osfmk/ddb/db_expr.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ddb/db_ext_symtab.c b/osfmk/ddb/db_ext_symtab.c
index d055fbdeb..4549a76e6 100644
--- a/osfmk/ddb/db_ext_symtab.c
+++ b/osfmk/ddb/db_ext_symtab.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -71,6 +74,9 @@
  *	Loads a symbol table for an external file into the kernel debugger.
  *	The symbol table data is an array of characters.  It is assumed that
  *	the caller and the kernel debugger agree on its format.
+ 
+ *	This has never and will never be supported on MacOS X. The only reason I don't remove
+ *	it entirely is that it is an exported symbol.
  */
 kern_return_t
 host_load_symbol_table(
@@ -80,69 +86,5 @@ host_load_symbol_table(
 	pointer_t	symtab,
 	mach_msg_type_number_t	symtab_count)
 {
-#if !MACH_DEBUG || !MACH_KDB
         return KERN_FAILURE;
-#else
-	kern_return_t	result;
-	vm_offset_t	symtab_start;
-	vm_offset_t	symtab_end;
-	vm_map_t	map;
-	vm_map_copy_t	symtab_copy_object;
-
-	if (host_priv == HOST_PRIV_NULL)
-	    return (KERN_INVALID_ARGUMENT);
-
-	/*
-	 * Copy the symbol table array into the kernel.
-	 * We make a copy of the copy object, and clear
-	 * the old one, so that returning error will not
-	 * deallocate the data twice.
-	 */
-	symtab_copy_object = (vm_map_copy_t) symtab;
-	result = vm_map_copyout(
-			kernel_map,
-			&symtab_start,
-			vm_map_copy_copy(symtab_copy_object));
-	if (result != KERN_SUCCESS)
-	    return (result);
-
-	symtab_end = symtab_start + symtab_count;
-
-	/*
-	 * Add the symbol table.
-	 * Do not keep a reference for the task map.	XXX
-	 */
-	if (task == TASK_NULL)
-	    map = VM_MAP_NULL;
-	else
-	    map = task->map;
-	if (!X_db_sym_init((char *)symtab_start,
-			(char *)symtab_end,
-			name,
-			(char *)map))
-	{
-	    /*
-	     * Not enough room for symbol table - failure.
-	     */
-	    (void) vm_deallocate(kernel_map,
-			symtab_start,
-			symtab_count);
-	    return (KERN_FAILURE);
-	}
-
-	/*
-	 * Wire down the symbol table
-	 */
-	(void) vm_map_wire(kernel_map,
-		symtab_start,
-		round_page(symtab_end),
-		VM_PROT_READ|VM_PROT_WRITE, FALSE);
-
-	/*
-	 * Discard the original copy object
-	 */
-	vm_map_copy_discard(symtab_copy_object);
-
-	return (KERN_SUCCESS);
-#endif /* MACH_DEBUG && MACH_KDB */
 }
diff --git a/osfmk/ddb/db_input.c b/osfmk/ddb/db_input.c
index 7283a4519..982c42d28 100644
--- a/osfmk/ddb/db_input.c
+++ b/osfmk/ddb/db_input.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ddb/db_input.h b/osfmk/ddb/db_input.h
index c1a89bffd..1330ddeb3 100644
--- a/osfmk/ddb/db_input.h
+++ b/osfmk/ddb/db_input.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ddb/db_lex.c b/osfmk/ddb/db_lex.c
index efafadfab..6c7343ce8 100644
--- a/osfmk/ddb/db_lex.c
+++ b/osfmk/ddb/db_lex.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ddb/db_lex.h b/osfmk/ddb/db_lex.h
index 6280d3f7b..4e7814bc3 100644
--- a/osfmk/ddb/db_lex.h
+++ b/osfmk/ddb/db_lex.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ddb/db_macro.c b/osfmk/ddb/db_macro.c
index 84e69782c..c82deb92d 100644
--- a/osfmk/ddb/db_macro.c
+++ b/osfmk/ddb/db_macro.c
@@ -3,99 +3,28 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
 /*
  * @OSF_COPYRIGHT@
  */
-/*
- * HISTORY
- * 
- * Revision 1.1.1.1  1998/09/22 21:05:48  wsanchez
- * Import of Mac OS X kernel (~semeria)
- *
- * Revision 1.1.1.1  1998/03/07 02:26:09  wsanchez
- * Import of OSF Mach kernel (~mburg)
- *
- * Revision 1.2.10.4  1996/01/09  19:15:54  devrcs
- * 	Change 'register foo' to 'register int foo'.
- * 	[1995/12/01  21:42:14  jfraser]
- *
- * 	Merged '64-bit safe' changes from DEC alpha port.
- * 	[1995/11/21  18:03:15  jfraser]
- *
- * Revision 1.2.10.3  1995/01/06  19:10:28  devrcs
- * 	mk6 CR668 - 1.3b26 merge
- * 	fix typing
- * 	[1994/11/04  08:49:38  dwm]
- * 
- * Revision 1.2.10.2  1994/09/23  01:20:19  ezf
- * 	change marker to not FREE
- * 	[1994/09/22  21:10:23  ezf]
- * 
- * Revision 1.2.10.1  1994/06/11  21:11:52  bolinger
- * 	Merge up to NMK17.2.
- * 	[1994/06/11  20:01:51  bolinger]
- * 
- * Revision 1.2.8.1  1994/02/08  10:58:03  bernadat
- * 	Fixed reinitialization of db_macro_level to -1.
- * 	Put DB_MACRO_LEVEL and DB_NARGS macros to <ddb/db_variables.h>.
- * 	Changed name of DB_NARGS to DB_MACRO_NARGS.
- * 	Added support of DB_VAR_SHOW.
- * 	[93/08/12            paire]
- * 	[94/02/07            bernadat]
- * 
- * Revision 1.2.2.4  1993/08/11  20:37:58  elliston
- * 	Add ANSI Prototypes.  CR #9523.
- * 	[1993/08/11  03:33:33  elliston]
- * 
- * Revision 1.2.2.3  1993/07/27  18:27:42  elliston
- * 	Add ANSI prototypes.  CR #9523.
- * 	[1993/07/27  18:12:24  elliston]
- * 
- * Revision 1.2.2.2  1993/06/09  02:20:18  gm
- * 	Added to OSF/1 R1.3 from NMK15.0.
- * 	[1993/06/02  20:56:40  jeffc]
- * 
- * Revision 1.2  1993/04/19  16:02:25  devrcs
- * 	Changes from mk78:
- * 	Removed unused variable from db_exec_macro().
- * 	Added include of <ddb/db_command.h>.
- * 	[92/05/16            jfriedl]
- * 	[93/02/02            bruel]
- * 
- * Revision 1.1  1992/09/30  02:01:12  robert
- * 	Initial revision
- * 
- * $EndLog$
- */
-/* CMU_HIST */
-/*
- * Revision 2.2  91/10/09  16:01:09  af
- * 	 Revision 2.1.3.1  91/10/05  13:06:40  jeffreyh
- * 	 	Created for macro support.
- * 	 	[91/08/29            tak]
- * 
- * Revision 2.1.3.1  91/10/05  13:06:40  jeffreyh
- * 	Created for macro support.
- * 	[91/08/29            tak]
- * 
- */
-/* CMU_ENDHIST */
 /* 
  * Mach Operating System
  * Copyright (c) 1991,1990 Carnegie Mellon University
@@ -275,7 +204,7 @@ db_arg_variable(
 
 	if (flag == DB_VAR_SHOW) {
 	    value = db_macro_args[ap->hidden_level][ap->suffix[0]-1];
-	    db_printf("%#n", value);
+	    db_printf("%#lln", value);
 	    db_find_xtrn_task_sym_and_offset(value, &name, &offset, TASK_NULL);
 	    if (name != (char *)0 && offset <= db_maxoff && offset != value) {
 		db_printf("\t%s", name);
diff --git a/osfmk/ddb/db_macro.h b/osfmk/ddb/db_macro.h
index ecd0dbed8..6c6b33f9b 100644
--- a/osfmk/ddb/db_macro.h
+++ b/osfmk/ddb/db_macro.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ddb/db_output.c b/osfmk/ddb/db_output.c
index e98eb0757..972b0e6d8 100644
--- a/osfmk/ddb/db_output.c
+++ b/osfmk/ddb/db_output.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -82,7 +85,7 @@
  */
 
 #ifndef	DB_MAX_LINE
-#define	DB_MAX_LINE		24	/* maximum line */
+#define	DB_MAX_LINE		43	/* maximum line */
 #define DB_MAX_WIDTH		132	/* maximum width */
 #endif	/* DB_MAX_LINE */
 
@@ -144,10 +147,6 @@ db_more(void)
 	register  char *p;
 	boolean_t quit_output = FALSE;
 
-#if defined(__alpha)
-	extern boolean_t kdebug_mode;
-	if (kdebug_mode) return;
-#endif /* defined(__alpha) */
 	for (p = "--db_more--"; *p; p++)
 	    cnputc(*p);
 	switch(cngetc()) {
@@ -289,9 +288,6 @@ db_printf(char *fmt, ...)
 {
 	va_list	listp;
 
-#ifdef	luna88k
-	db_printing();
-#endif
 	va_start(listp, fmt);
 	_doprnt(fmt, &listp, db_putchar, db_radix);
 	va_end(listp);
@@ -340,9 +336,7 @@ void
 db_output_prompt(void)
 {
 	db_printf("db%s", (db_default_act) ? "t": "");
-#if	NCPUS > 1
 	db_printf("{%d}", cpu_number());
-#endif
 	db_printf("> ");
 }
 
diff --git a/osfmk/ddb/db_output.h b/osfmk/ddb/db_output.h
index c1a398935..6d3d0c04c 100644
--- a/osfmk/ddb/db_output.h
+++ b/osfmk/ddb/db_output.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ddb/db_print.c b/osfmk/ddb/db_print.c
index 0dcca6f3a..0cf93a62d 100644
--- a/osfmk/ddb/db_print.c
+++ b/osfmk/ddb/db_print.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -187,7 +190,7 @@ db_show_regs(
 				12-strlen(regp->name)-((i<10)?1:2), "");
 		else
 		    db_printf("%-12s", regp->name);
-		db_printf("%#*N", 2+2*sizeof(vm_offset_t), value);
+		db_printf("%#*llN", 2+2*sizeof(db_expr_t), value);
 		db_find_xtrn_task_sym_and_offset((db_addr_t)value, &name, 
 							&offset, task);
 		if (name != 0 && offset <= db_maxoff && offset != value) {
@@ -719,7 +722,7 @@ db_show_one_act(
 	    thr_act = (thread_act_t) addr;
 
 	if ((act_id = db_lookup_act(thr_act)) < 0) {
-	    db_printf("bad thr_act address %#x\n", addr);
+	    db_printf("bad thr_act address %#llX\n", addr);
 	    db_error(0);
 	    /*NOTREACHED*/
 	}
@@ -771,7 +774,7 @@ db_show_one_task(
 	    task = (task_t) addr;
 
 	if ((task_id = db_lookup_task(task)) < 0) {
-	    db_printf("bad task address 0x%x\n", addr);
+	    db_printf("bad task address 0x%llX\n", addr);
 	    db_error(0);
 	    /*NOTREACHED*/
 	}
@@ -969,7 +972,7 @@ db_show_port_id(
 	} else
 	    thr_act = (thread_act_t) addr;
 	if (db_lookup_act(thr_act) < 0) {
-	    db_printf("Bad thr_act address 0x%x\n", addr);
+	    db_printf("Bad thr_act address 0x%llX\n", addr);
 	    db_error(0);
 	    /*NOTREACHED*/
 	}
diff --git a/osfmk/ddb/db_print.h b/osfmk/ddb/db_print.h
index e3e622889..101c70c3c 100644
--- a/osfmk/ddb/db_print.h
+++ b/osfmk/ddb/db_print.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ddb/db_run.c b/osfmk/ddb/db_run.c
index d0898f80c..e70571169 100644
--- a/osfmk/ddb/db_run.c
+++ b/osfmk/ddb/db_run.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ddb/db_run.h b/osfmk/ddb/db_run.h
index a3544402d..1e048fba4 100644
--- a/osfmk/ddb/db_run.h
+++ b/osfmk/ddb/db_run.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ddb/db_sym.c b/osfmk/ddb/db_sym.c
index 1e8bd1dbc..2578ef347 100644
--- a/osfmk/ddb/db_sym.c
+++ b/osfmk/ddb/db_sym.c
@@ -3,341 +3,28 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
 /*
  * @OSF_COPYRIGHT@
  */
-/*
- * HISTORY
- * 
- * Revision 1.1.1.1  1998/09/22 21:05:48  wsanchez
- * Import of Mac OS X kernel (~semeria)
- *
- * Revision 1.1.1.1  1998/03/07 02:26:09  wsanchez
- * Import of OSF Mach kernel (~mburg)
- *
- * Revision 1.3.22.8  1996/07/31  09:07:24  paire
- * 	Merged with nmk20b7_shared (1.3.47.1)
- * 	[96/07/24            paire]
- *
- * Revision 1.3.47.1  1996/06/13  12:36:08  bernadat
- * 	Do not assume anymore that VM_MIN_KERNEL_ADDRESS
- * 	is greater or equal than VM_MAX_ADDRESS.
- * 	[96/05/23            bernadat]
- * 
- * Revision 1.3.22.7  1996/01/09  19:16:15  devrcs
- * 	Added db_task_getlinenum() function. (steved)
- * 	Make db_maxval & db_minval long int's for Alpha.
- * 	Changed declarations of 'register foo' to 'register int foo'.
- * 	[1995/12/01  21:42:29  jfraser]
- * 
- * 	Merged '64-bit safe' changes from DEC alpha port.
- * 	[1995/11/21  18:03:41  jfraser]
- * 
- * Revision 1.3.22.6  1995/02/28  01:58:46  dwm
- * 	Merged with changes from 1.3.22.5
- * 	[1995/02/28  01:53:47  dwm]
- * 
- * 	mk6 CR1120 - Merge mk6pro_shared into cnmk_shared
- * 	remove a couple local protos, now in .h file (for better or worse)
- * 	[1995/02/28  01:12:51  dwm]
- * 
- * Revision 1.3.22.5  1995/02/23  21:43:43  alanl
- * 	Move TR_INIT to model_dep.c (MACH_TR and MACH_KDB shouldn't
- * 	be bound).
- * 	[95/02/16            travos]
- * 
- * 	Prepend a "db_" to qsort and qsort_limit_search
- * 	(collisions with the real qsort in stdlib.h)
- * 	[95/02/14            travos]
- * 
- * 	Added X_db_init for object independent formats.
- * 	[95/01/24            sjs]
- * 
- * 	Merge with DIPC2_SHARED.
- * 	[1995/01/05  13:32:53  alanl]
- * 
- * Revision 1.3.30.2  1994/12/22  20:36:15  bolinger
- * 	Fix ri-osc CR881:  enable freer use of symbol table of collocated
- * 	tasks.  No point in requiring task to be named for symbols to be
- * 	usable.  Also fixed glitch in use of symtab cloning.
- * 	[1994/12/22  20:34:55  bolinger]
- * 
- * Revision 1.3.30.1  1994/11/04  09:53:14  dwm
- * 	mk6 CR668 - 1.3b26 merge
- * 	add arg to *_db_search_by_addr() from mk6
- * 	* Revision 1.3.4.9  1994/05/13  15:57:14  tmt
- * 	Add hooks for catching calls to uninstalled symbol tables.
- * 	Add XXX_search_by_addr() vectors.
- * 	* Revision 1.3.4.8  1994/05/12  21:59:00  tmt
- * 	Fix numerous db_sym_t/char * mixups.
- * 	Fix and enable db_qualify_ambiguous_names.
- * 	Make dif and newdiff unsigned in symbol searches.
- * 	* Revision 1.3.4.7  1994/05/06  18:39:52  tmt
- * 	Merged osc1.3dec/shared with osc1.3b19
- * 	Fix function prototype declarations.
- * 	Merge Alpha changes into osc1.312b source code.
- * 	String protos.
- * 	Handle multiple, coexisting symbol table types.
- * 	64bit cleanup.
- * 	Revision 1.3.4.5  1993/10/20  18:58:55  gm
- * 	CR9704: Removed symbol load printf.
- * 	* End1.3merge
- * 	[1994/11/04  08:50:02  dwm]
- * 
- * Revision 1.3.22.5  1995/02/23  21:43:43  alanl
- * 	Move TR_INIT to model_dep.c (MACH_TR and MACH_KDB shouldn't
- * 	be bound).
- * 	[95/02/16            travos]
- * 
- * 	Prepend a "db_" to qsort and qsort_limit_search
- * 	(collisions with the real qsort in stdlib.h)
- * 	[95/02/14            travos]
- * 
- * 	Added X_db_init for object independent formats.
- * 	[95/01/24            sjs]
- * 
- * 	Merge with DIPC2_SHARED.
- * 	[1995/01/05  13:32:53  alanl]
- * 
- * Revision 1.3.30.2  1994/12/22  20:36:15  bolinger
- * 	Fix ri-osc CR881:  enable freer use of symbol table of collocated
- * 	tasks.  No point in requiring task to be named for symbols to be
- * 	usable.  Also fixed glitch in use of symtab cloning.
- * 	[1994/12/22  20:34:55  bolinger]
- * 
- * Revision 1.3.30.1  1994/11/04  09:53:14  dwm
- * 	mk6 CR668 - 1.3b26 merge
- * 	add arg to *_db_search_by_addr() from mk6
- * 	* Revision 1.3.4.9  1994/05/13  15:57:14  tmt
- * 	Add hooks for catching calls to uninstalled symbol tables.
- * 	Add XXX_search_by_addr() vectors.
- * 	* Revision 1.3.4.8  1994/05/12  21:59:00  tmt
- * 	Fix numerous db_sym_t/char * mixups.
- * 	Fix and enable db_qualify_ambiguous_names.
- * 	Make dif and newdiff unsigned in symbol searches.
- * 	* Revision 1.3.4.7  1994/05/06  18:39:52  tmt
- * 	Merged osc1.3dec/shared with osc1.3b19
- * 	Fix function prototype declarations.
- * 	Merge Alpha changes into osc1.312b source code.
- * 	String protos.
- * 	Handle multiple, coexisting symbol table types.
- * 	64bit cleanup.
- * 	Revision 1.3.4.5  1993/10/20  18:58:55  gm
- * 	CR9704: Removed symbol load printf.
- * 	* End1.3merge
- * 	[1994/11/04  08:50:02  dwm]
- * 
- * Revision 1.3.22.3  1994/09/23  01:21:37  ezf
- * 	change marker to not FREE
- * 	[1994/09/22  21:10:58  ezf]
- * 
- * Revision 1.3.22.2  1994/06/26  22:58:24  bolinger
- * 	Suppress symbol table range output when table is unsorted, since output
- * 	is meaningless in this case.
- * 	[1994/06/23  20:19:02  bolinger]
- * 
- * Revision 1.3.22.1  1994/06/11  21:12:19  bolinger
- * 	Merge up to NMK17.2.
- * 	[1994/06/11  20:02:31  bolinger]
- * 
- * Revision 1.3.17.1  1994/02/08  10:58:40  bernadat
- * 	Check result of X_db_line_at_pc() before
- * 	invoking db_shorten_filename().
- * 	[93/11/30            bernadat]
- * 
- * 	Installed ddb_init() routine in a symbol-independent file to call
- * 	symbol-dependent and machine-dependent initialization routines.
- * 	[93/08/27            paire]
- * 
- * 	Fixed db_shorten_filename() to gobble the last slash.
- * 	Modified db_search_task_symbol_and_line() interface to return
- * 	the number of a function arguments.
- * 	[93/08/19            paire]
- * 
- * 	Added new arguments to db_sym_print_completion() call.
- * 	[93/08/18            paire]
- * 
- * 	Added db_lookup_incomplete(), db_sym_parse_and_lookup_incomplete(),
- * 	db_sym_print_completion() and db_completion_print() for support of
- * 	symbol completion.
- * 	[93/08/14            paire]
- * 	[94/02/07            bernadat]
- * 
- * Revision 1.3.15.4  1994/06/08  19:11:23  dswartz
- * 	Preemption merge.
- * 	[1994/06/08  19:10:24  dswartz]
- * 
- * Revision 1.3.20.2  1994/06/01  21:34:39  klj
- * 	Initial preemption code base merge
- * 
- * Revision 1.3.15.3  1994/02/10  02:28:15  bolinger
- * 	Fix db_add_symbol_table() to increase db_maxval if highest-addressed
- * 	symbol in new symtab is greater than its current value.
- * 	[1994/02/09  21:42:12  bolinger]
- * 
- * Revision 1.3.15.2  1994/02/03  21:44:23  bolinger
- * 	Update db_maxval when a symbol table is cloned for kernel-loaded
- * 	server.
- * 	[1994/02/03  20:47:22  bolinger]
- * 
- * Revision 1.3.15.1  1994/02/03  02:41:58  dwm
- * 	Add short-term kludge to provide symbolic info on INKServer.
- * 	[1994/02/03  02:31:17  dwm]
- * 
- * Revision 1.3.4.4  1993/08/11  20:38:11  elliston
- * 	Add ANSI Prototypes.  CR #9523.
- * 	[1993/08/11  03:33:59  elliston]
- * 
- * Revision 1.3.4.3  1993/07/27  18:28:09  elliston
- * 	Add ANSI prototypes.  CR #9523.
- * 	[1993/07/27  18:12:57  elliston]
- * 
- * Revision 1.3.4.2  1993/06/09  02:20:50  gm
- * 	CR9176 - ANSI C violations: trailing tokens on CPP
- * 	directives, extra semicolons after decl_ ..., asm keywords
- * 	[1993/06/07  18:57:31  jeffc]
- * 
- * 	Added to OSF/1 R1.3 from NMK15.0.
- * 	[1993/06/02  20:57:10  jeffc]
- * 
- * Revision 1.3  1993/04/19  16:03:09  devrcs
- * 	Protect db_line_at_pc() against null db_last_symtab.
- * 	[1993/02/11  15:37:16  barbou]
- * 
- * 	Changes from MK78:
- * 	Upped MAXNOSYMTABS from 3 to 5. Now there is space for kernel,
- * 	 bootstrap, server, and emulator symbols - plus one for future
- * 	 expansion.
- * 	[92/03/21            danner]
- * 	Changed CHAR arg of db_eqname to UNSIGNED.
- * 	Made arg types proper for db_line_at_pc().
- * 	[92/05/16            jfriedl]
- * 	[92/12/18            bruel]
- * 
- * 	Sort large symbol tables to speedup lookup.
- * 	Improved symbol lookup (use of max_offset, dichotomic search)
- * 	[barbou@gr.osf.org]
- * 
- * 	db_add_symbol_table now takes 3 additional arguments. Machine
- * 	dependant modules must provide them. [barbou@gr.osf.org]
- * 	[92/12/03            bernadat]
- * 
- * Revision 1.2  1992/11/25  01:04:42  robert
- * 	integrate changes below for norma_14
- * 	[1992/11/13  19:22:44  robert]
- * 
- * Revision 1.1  1992/09/30  02:01:25  robert
- * 	Initial revision
- * 
- * $EndLog$
- */
-/* CMU_HIST */
-/*
- * Revision 2.10.4.1  92/02/18  18:38:53  jeffreyh
- * 	Added db_get_sym(). Simple interface to get symbol names
- * 	knowing the offset.
- * 	[91/12/20            bernadat]
- * 
- * 	Do not look for symbol names if address
- * 	is to small or to large, otherwise get
- * 	random names like INCLUDE_VERSION+??
- * 	[91/06/25            bernadat]
- * 
- * Revision 2.10  91/10/09  16:02:30  af
- * 	 Revision 2.9.2.1  91/10/05  13:07:27  jeffreyh
- * 	 	Changed symbol table name qualification syntax from "xxx:yyy"
- * 	 	  to "xxx::yyy" to allow "file:func:line" in "yyy" part.
- * 		       "db_sym_parse_and_lookup" is also added for "yyy" part parsing.
- * 	 	Replaced db_search_symbol with db_search_task_symbol, and moved
- * 	 	  it to "db_sym.h" as a macro.
- * 	 	Added db_task_printsym, and changed db_printsym to call it.
- * 	 	Added include "db_task_thread.h".
- * 	 	Fixed infinite recursion of db_symbol_values.
- * 	 	[91/08/29            tak]
- * 
- * Revision 2.9.2.1  91/10/05  13:07:27  jeffreyh
- * 	Changed symbol table name qualification syntax from "xxx:yyy"
- * 	  to "xxx::yyy" to allow "file:func:line" in "yyy" part.
- * 	       "db_sym_parse_and_lookup" is also added for "yyy" part parsing.
- * 	Replaced db_search_symbol with db_search_task_symbol, and moved
- * 	  it to "db_sym.h" as a macro.
- * 	Added db_task_printsym, and changed db_printsym to call it.
- * 	Added include "db_task_thread.h".
- * 	Fixed infinite recursion of db_symbol_values.
- * 	[91/08/29            tak]
- * 
- * Revision 2.9  91/07/31  17:31:14  dbg
- * 	Add task pointer and space for string storage to symbol table
- * 	descriptor.
- * 	[91/07/31            dbg]
- * 
- * Revision 2.8  91/07/09  23:16:08  danner
- * 	Changed a printf.
- * 	[91/07/08            danner]
- * 
- * Revision 2.7  91/05/14  15:35:54  mrt
- * 	Correcting copyright
- * 
- * Revision 2.6  91/03/16  14:42:40  rpd
- * 	Changed the default db_maxoff to 4K.
- * 	[91/03/10            rpd]
- * 
- * Revision 2.5  91/02/05  17:07:07  mrt
- * 	Changed to new Mach copyright
- * 	[91/01/31  16:19:17  mrt]
- * 
- * Revision 2.4  90/10/25  14:44:05  rwd
- * 	Changed db_printsym to print unsigned.
- * 	[90/10/19            rpd]
- * 
- * Revision 2.3  90/09/09  23:19:56  rpd
- * 	Avoid totally incorrect guesses of symbol names for small values.
- * 	[90/08/30  17:39:48  af]
- * 
- * Revision 2.2  90/08/27  21:52:18  dbg
- * 	Removed nlist.h.  Fixed some type declarations.
- * 	Qualifier character is ':'.
- * 	[90/08/20            dbg]
- * 	Modularized symtab info into a new db_symtab_t type.
- * 	Modified db_add_symbol_table  and others accordingly.
- * 	Defined db_sym_t, a new (opaque) type used to represent
- * 	symbols.  This should support all sort of future symtable
- * 	formats. Functions like db_qualify take a db_sym_t now.
- * 	New db_symbol_values() function to explode the content
- * 	of a db_sym_t.
- * 	db_search_symbol() replaces db_find_sym_and_offset(), which is
- * 	now a macro defined in our (new) header file.  This new
- * 	function accepts more restrictive searches, which are
- * 	entirely delegated to the symtab-specific code.
- * 	Accordingly, db_printsym() accepts a strategy parameter.
- * 	New db_line_at_pc() function.
- * 	Renamed misleading db_eqsym into db_eqname.
- * 	[90/08/20  10:47:06  af]
- * 
- * 	Created.
- * 	[90/07/25            dbg]
- * 
- * Revision 2.1  90/07/26  16:43:52  dbg
- * Created.
- * 
- */
-/* CMU_ENDHIST */
 /* 
  * Mach Operating System
  * Copyright (c) 1991,1990 Carnegie Mellon University
@@ -1632,7 +1319,7 @@ db_clone_symtabXXX(
 	}
 					/* alloc new symbols		*/
 	size = (vm_size_t)(st_src->end - st_src->private);
-	memp = (char *)kalloc( round_page(size) );
+	memp = (char *)kalloc( round_page_32(size) );
 	if (!memp) {
 	    db_printf("db_clone_symtab: no memory for symtab\n");
 	    return;
diff --git a/osfmk/ddb/db_sym.h b/osfmk/ddb/db_sym.h
index e5d19a4d9..672588d86 100644
--- a/osfmk/ddb/db_sym.h
+++ b/osfmk/ddb/db_sym.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ddb/db_task_thread.c b/osfmk/ddb/db_task_thread.c
index cf8f37ea4..e01b03f2f 100644
--- a/osfmk/ddb/db_task_thread.c
+++ b/osfmk/ddb/db_task_thread.c
@@ -3,94 +3,28 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
 /*
  * @OSF_COPYRIGHT@
  */
-/*
- * HISTORY
- * 
- * Revision 1.1.1.1  1998/09/22 21:05:48  wsanchez
- * Import of Mac OS X kernel (~semeria)
- *
- * Revision 1.1.1.1  1998/03/07 02:26:09  wsanchez
- * Import of OSF Mach kernel (~mburg)
- *
- * Revision 1.1.16.3  1996/01/09  19:16:26  devrcs
- * 	Make db_lookup_task_id() globally available (remove static).
- * 	Changed declarations of 'register foo' to 'register int foo'.
- * 	[1995/12/01  21:42:37  jfraser]
- *
- * 	Merged '64-bit safe' changes from DEC alpha port.
- * 	[1995/11/21  18:03:48  jfraser]
- *
- * Revision 1.1.16.2  1994/09/23  01:21:59  ezf
- * 	change marker to not FREE
- * 	[1994/09/22  21:11:09  ezf]
- * 
- * Revision 1.1.16.1  1994/06/11  21:12:29  bolinger
- * 	Merge up to NMK17.2.
- * 	[1994/06/11  20:02:43  bolinger]
- * 
- * Revision 1.1.14.1  1994/02/08  10:59:02  bernadat
- * 	Added support of DB_VAR_SHOW.
- * 	[93/08/12            paire]
- * 	[94/02/08            bernadat]
- * 
- * Revision 1.1.12.3  1994/03/17  22:35:35  dwm
- * 	The infamous name change:  thread_activation + thread_shuttle = thread.
- * 	[1994/03/17  21:25:50  dwm]
- * 
- * Revision 1.1.12.2  1994/01/17  18:08:54  dwm
- * 	Add patchable integer force_act_lookup to force successful
- * 	lookup, to allow stack trace on orphaned act/thread pairs.
- * 	[1994/01/17  16:06:50  dwm]
- * 
- * Revision 1.1.12.1  1994/01/12  17:50:52  dwm
- * 	Coloc: initial restructuring to follow Utah model.
- * 	[1994/01/12  17:13:23  dwm]
- * 
- * Revision 1.1.3.3  1993/07/27  18:28:15  elliston
- * 	Add ANSI prototypes.  CR #9523.
- * 	[1993/07/27  18:13:06  elliston]
- * 
- * Revision 1.1.3.2  1993/06/02  23:12:39  jeffc
- * 	Added to OSF/1 R1.3 from NMK15.0.
- * 	[1993/06/02  20:57:24  jeffc]
- * 
- * Revision 1.1  1992/09/30  02:01:27  robert
- * 	Initial revision
- * 
- * $EndLog$
- */
-/* CMU_HIST */
-/*
- * Revision 2.2  91/10/09  16:03:04  af
- * 	 Revision 2.1.3.1  91/10/05  13:07:50  jeffreyh
- * 	 	Created for task/thread handling.
- * 	 	[91/08/29            tak]
- * 
- * Revision 2.1.3.1  91/10/05  13:07:50  jeffreyh
- * 	Created for task/thread handling.
- * 	[91/08/29            tak]
- * 
- */
-/* CMU_ENDHIST */
 /* 
  * Mach Operating System
  * Copyright (c) 1991,1990 Carnegie Mellon University
diff --git a/osfmk/ddb/db_task_thread.h b/osfmk/ddb/db_task_thread.h
index d558ba543..398e2c270 100644
--- a/osfmk/ddb/db_task_thread.h
+++ b/osfmk/ddb/db_task_thread.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ddb/db_trap.c b/osfmk/ddb/db_trap.c
index 2fcca75ba..128e96616 100644
--- a/osfmk/ddb/db_trap.c
+++ b/osfmk/ddb/db_trap.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ddb/db_trap.h b/osfmk/ddb/db_trap.h
index 60fad74b3..435759a3e 100644
--- a/osfmk/ddb/db_trap.h
+++ b/osfmk/ddb/db_trap.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ddb/db_variables.c b/osfmk/ddb/db_variables.c
index 8e45a4a42..b30a42221 100644
--- a/osfmk/ddb/db_variables.c
+++ b/osfmk/ddb/db_variables.c
@@ -3,151 +3,28 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
 /*
  * @OSF_COPYRIGHT@
  */
-/*
- * HISTORY
- * 
- * Revision 1.1.1.1  1998/09/22 21:05:48  wsanchez
- * Import of Mac OS X kernel (~semeria)
- *
- * Revision 1.1.1.1  1998/03/07 02:26:09  wsanchez
- * Import of OSF Mach kernel (~mburg)
- *
- * Revision 1.2.18.5  1996/01/09  19:16:34  devrcs
- * 	Search the alternate register names if configured
- * 	Changed declarations of 'register foo' to 'register int foo'.
- * 	[1995/12/01  21:42:42  jfraser]
- *
- * 	Merged '64-bit safe' changes from DEC alpha port.
- * 	[1995/11/21  18:03:56  jfraser]
- *
- * Revision 1.2.18.4  1995/02/23  21:43:56  alanl
- * 	Merged with DIPC2_SHARED.
- * 	[1995/01/05  13:35:55  alanl]
- * 
- * Revision 1.2.21.1  1994/11/04  09:53:26  dwm
- * 	mk6 CR668 - 1.3b26 merge
- * 	* Revision 1.2.4.6  1994/05/06  18:40:13  tmt
- * 	Merged osc1.3dec/shared with osc1.3b19
- * 	Merge Alpha changes into osc1.312b source code.
- * 	64bit cleanup.
- * 	* End1.3merge
- * 	[1994/11/04  08:50:12  dwm]
- * 
- * Revision 1.2.18.2  1994/09/23  01:22:35  ezf
- * 	change marker to not FREE
- * 	[1994/09/22  21:11:24  ezf]
- * 
- * Revision 1.2.18.1  1994/06/11  21:12:37  bolinger
- * 	Merge up to NMK17.2.
- * 	[1994/06/11  20:03:04  bolinger]
- * 
- * Revision 1.2.23.1  1994/12/06  19:43:18  alanl
- * 	Intel merge, Oct 94 code drop.
- * 	Added db_find_reg_name (came from db_print.c).
- * 	[94/11/28            mmp]
- * 
- * Revision 1.2.16.1  1994/02/08  10:59:08  bernadat
- * 	Added completion variable.
- * 	[93/08/17            paire]
- * 
- * 	Set up new fields (hidden_xxx) of db_vars[] array that are supposed
- * 	to be helpful to display variables depending on an internal value
- * 	like db_macro_level for macro arguments.
- * 	Added db_auto_wrap as new variable.
- * 	Added "set help" for listing all available variables.
- * 	Added db_show_variable() and db_show_one_variable()
- * 	to print variable values.
- * 	[93/08/12            paire]
- * 	[94/02/08            bernadat]
- * 
- * Revision 1.2.4.4  1993/08/11  20:38:20  elliston
- * 	Add ANSI Prototypes.  CR #9523.
- * 	[1993/08/11  03:34:13  elliston]
- * 
- * Revision 1.2.4.3  1993/07/27  18:28:27  elliston
- * 	Add ANSI prototypes.  CR #9523.
- * 	[1993/07/27  18:13:22  elliston]
- * 
- * Revision 1.2.4.2  1993/06/09  02:21:02  gm
- * 	Added to OSF/1 R1.3 from NMK15.0.
- * 	[1993/06/02  20:57:43  jeffc]
- * 
- * Revision 1.2  1993/04/19  16:03:25  devrcs
- * 	Changes from mk78:
- * 	Added void to db_read_write_variable().
- * 	Removed unused variable 'func' from db_set_cmd().
- * 	[92/05/16            jfriedl]
- * 	[93/02/02            bruel]
- * 
- * 	Print old value when changing register values.
- * 	[barbou@gr.osf.org]
- * 	[92/12/03            bernadat]
- * 
- * Revision 1.1  1992/09/30  02:01:31  robert
- * 	Initial revision
- * 
- * $EndLog$
- */
-/* CMU_HIST */
-/*
- * Revision 2.5  91/10/09  16:03:59  af
- * 	 Revision 2.4.3.1  91/10/05  13:08:27  jeffreyh
- * 	 	Added suffix handling and thread handling of variables.
- * 		Added new variables: lines, task, thread, work and arg.
- * 		Moved db_read_variable and db_write_variable to db_variables.h
- * 	 	  as macros, and added db_read_write_variable instead.
- * 	 	Changed some error messages.
- * 	 	[91/08/29            tak]
- * 
- * Revision 2.4.3.1  91/10/05  13:08:27  jeffreyh
- * 	Added suffix handling and thread handling of variables.
- * 	Added new variables: lines, task, thread, work and arg.
- * 	Moved db_read_variable and db_write_variable to db_variables.h
- * 	  as macros, and added db_read_write_variable instead.
- * 	Changed some error messages.
- * 	[91/08/29            tak]
- * 
- * Revision 2.4  91/05/14  15:36:57  mrt
- * 	Correcting copyright
- * 
- * Revision 2.3  91/02/05  17:07:19  mrt
- * 	Changed to new Mach copyright
- * 	[91/01/31  16:19:46  mrt]
- * 
- * Revision 2.2  90/08/27  21:53:24  dbg
- * 	New db_read/write_variable functions.  Should be used instead
- * 	of dereferencing valuep directly, which might not be a true
- * 	pointer if there is an fcn() access function.
- * 	[90/08/20            af]
- * 
- * 	Fix declarations.
- * 	Check for trailing garbage after last expression on command line.
- * 	[90/08/10  14:34:54  dbg]
- * 
- * 	Created.
- * 	[90/07/25            dbg]
- * 
- */
-/* CMU_ENDHIST */
 /* 
  * Mach Operating System
  * Copyright (c) 1991,1990 Carnegie Mellon University
@@ -387,7 +264,7 @@ db_read_write_variable(
 	} else
 	    (*func)(vp, valuep, rw_flag, ap);
 	if (rw_flag == DB_VAR_SET && vp->precious)
-		db_printf("\t$%s:%s<%#x>\t%#8n\t=\t%#8n\n", vp->name,
+		db_printf("\t$%s:%s<%#x>\t%#8lln\t=\t%#8lln\n", vp->name,
 			  ap->modif, ap->thr_act, old_value, *valuep);
 }
 
@@ -630,7 +507,7 @@ db_show_one_variable(void)
 		aux_param.suffix[0] = i;
 		(*cur->fcn)(cur, (db_expr_t *)0, DB_VAR_SHOW, &aux_param);
 	    } else {
-		db_printf("%#n", *(cur->valuep + i));
+		db_printf("%#lln", *(cur->valuep + i));
 	        db_find_xtrn_task_sym_and_offset(*(cur->valuep + i), &name,
 						 &offset, TASK_NULL);
 		if (name != (char *)0 && offset <= db_maxoff &&
@@ -776,7 +653,7 @@ db_show_variable(void)
 		    aux_param.suffix[0] = i;
 		    (*cur->fcn)(cur, (db_expr_t *)0, DB_VAR_SHOW, &aux_param);
 		} else {
-		    db_printf("%#n", *(cur->valuep + i));
+		    db_printf("%#lln", *(cur->valuep + i));
 		    db_find_xtrn_task_sym_and_offset(*(cur->valuep + i), &name,
 						     &offset, TASK_NULL);
 		    if (name != (char *)0 && offset <= db_maxoff &&
diff --git a/osfmk/ddb/db_variables.h b/osfmk/ddb/db_variables.h
index d4c62d174..71716ee3e 100644
--- a/osfmk/ddb/db_variables.h
+++ b/osfmk/ddb/db_variables.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ddb/db_watch.c b/osfmk/ddb/db_watch.c
index 513ebbb48..f6de79c76 100644
--- a/osfmk/ddb/db_watch.c
+++ b/osfmk/ddb/db_watch.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -394,8 +397,8 @@ db_set_watchpoints(void)
 	    for (watch = db_watchpoint_list; watch != 0; watch = watch->link) {
 		map = (watch->task)? watch->task->map: kernel_map;
 		pmap_protect(map->pmap,
-			     trunc_page(watch->loaddr),
-			     round_page(watch->hiaddr),
+			     trunc_page_32(watch->loaddr),
+			     round_page_32(watch->hiaddr),
 			     VM_PROT_READ);
 	    }
 	    db_watchpoints_inserted = TRUE;
@@ -424,8 +427,8 @@ db_find_watchpoint(
 	    if (watch->task == task_space) {
 		if ((watch->loaddr <= addr) && (addr < watch->hiaddr))
 		    return (TRUE);
-		else if ((trunc_page(watch->loaddr) <= addr) &&
-			 (addr < round_page(watch->hiaddr)))
+		else if ((trunc_page_32(watch->loaddr) <= addr) &&
+			 (addr < round_page_32(watch->hiaddr)))
 		    found = watch;
 	    }
 	}
diff --git a/osfmk/ddb/db_watch.h b/osfmk/ddb/db_watch.h
index 2d37eb46f..613a3e8c6 100644
--- a/osfmk/ddb/db_watch.h
+++ b/osfmk/ddb/db_watch.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ddb/db_write_cmd.c b/osfmk/ddb/db_write_cmd.c
index fdbf14268..bad5b9857 100644
--- a/osfmk/ddb/db_write_cmd.c
+++ b/osfmk/ddb/db_write_cmd.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ddb/db_write_cmd.h b/osfmk/ddb/db_write_cmd.h
index 21fa8ce65..6905f4e81 100644
--- a/osfmk/ddb/db_write_cmd.h
+++ b/osfmk/ddb/db_write_cmd.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ddb/makedis.c b/osfmk/ddb/makedis.c
index b397eb7c4..95a196913 100644
--- a/osfmk/ddb/makedis.c
+++ b/osfmk/ddb/makedis.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ddb/nlist.h b/osfmk/ddb/nlist.h
index 54d868455..8c5103201 100644
--- a/osfmk/ddb/nlist.h
+++ b/osfmk/ddb/nlist.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ddb/orig/db_print.c b/osfmk/ddb/orig/db_print.c
index 59c51daa9..a58514a2c 100644
--- a/osfmk/ddb/orig/db_print.c
+++ b/osfmk/ddb/orig/db_print.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ddb/stab.h b/osfmk/ddb/stab.h
index 328bd6d59..79e89d8e2 100644
--- a/osfmk/ddb/stab.h
+++ b/osfmk/ddb/stab.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ddb/tr.c b/osfmk/ddb/tr.c
index 7edac65d5..b60fd2bc0 100644
--- a/osfmk/ddb/tr.c
+++ b/osfmk/ddb/tr.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ddb/tr.h b/osfmk/ddb/tr.h
index 4288e3de5..65c1c1a82 100644
--- a/osfmk/ddb/tr.h
+++ b/osfmk/ddb/tr.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/default_pager/default_pager.c b/osfmk/default_pager/default_pager.c
index 864b9eabd..897001351 100644
--- a/osfmk/default_pager/default_pager.c
+++ b/osfmk/default_pager/default_pager.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -329,8 +332,8 @@ default_pager_info(
 
 	bs_global_info(&pages_total, &pages_free);
 
-	infop->dpi_total_space = ptoa(pages_total);
-	infop->dpi_free_space = ptoa(pages_free);
+	infop->dpi_total_space = ptoa_32(pages_total);
+	infop->dpi_free_space = ptoa_32(pages_free);
 	infop->dpi_page_size = vm_page_size;
 
 	return KERN_SUCCESS;
diff --git a/osfmk/default_pager/default_pager_alerts.defs b/osfmk/default_pager/default_pager_alerts.defs
index bbf143bd1..a06eebedf 100644
--- a/osfmk/default_pager/default_pager_alerts.defs
+++ b/osfmk/default_pager/default_pager_alerts.defs
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/default_pager/default_pager_internal.h b/osfmk/default_pager/default_pager_internal.h
index f49036b57..170b0a49c 100644
--- a/osfmk/default_pager/default_pager_internal.h
+++ b/osfmk/default_pager/default_pager_internal.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/default_pager/default_pager_object.defs b/osfmk/default_pager/default_pager_object.defs
index 77e4ae75e..cf35688fa 100644
--- a/osfmk/default_pager/default_pager_object.defs
+++ b/osfmk/default_pager/default_pager_object.defs
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/default_pager/default_pager_types.defs b/osfmk/default_pager/default_pager_types.defs
index 1eb3c517f..2ff5f7112 100644
--- a/osfmk/default_pager/default_pager_types.defs
+++ b/osfmk/default_pager/default_pager_types.defs
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/default_pager/default_pager_types.h b/osfmk/default_pager/default_pager_types.h
index 59d395666..ee9fc1060 100644
--- a/osfmk/default_pager/default_pager_types.h
+++ b/osfmk/default_pager/default_pager_types.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/default_pager/diag.h b/osfmk/default_pager/diag.h
index a6e571cfa..9e94e9e85 100644
--- a/osfmk/default_pager/diag.h
+++ b/osfmk/default_pager/diag.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/default_pager/dp_backing_store.c b/osfmk/default_pager/dp_backing_store.c
index 112ced6c6..30d1b6e29 100644
--- a/osfmk/default_pager/dp_backing_store.c
+++ b/osfmk/default_pager/dp_backing_store.c
@@ -1,22 +1,24 @@
-
 /*
  * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -550,7 +552,7 @@ default_pager_backing_store_create(
 		priority = BS_MINPRI;
 	bs->bs_priority = priority;
 
-	bs->bs_clsize = bs_get_global_clsize(atop(clsize));
+	bs->bs_clsize = bs_get_global_clsize(atop_32(clsize));
 
 	BSL_LOCK();
 	queue_enter(&backing_store_list.bsl_queue, bs, backing_store_t,
@@ -614,7 +616,7 @@ default_pager_backing_store_info(
 	basic->bs_pages_out_fail= bs->bs_pages_out_fail;
 
 	basic->bs_priority	= bs->bs_priority;
-	basic->bs_clsize	= ptoa(bs->bs_clsize);	/* in bytes */
+	basic->bs_clsize	= ptoa_32(bs->bs_clsize);	/* in bytes */
 
 	BS_UNLOCK(bs);
 
@@ -1225,7 +1227,7 @@ ps_vstruct_create(
 	vs->vs_errors = 0;
 
 	vs->vs_clshift = local_log2(bs_get_global_clsize(0));
-	vs->vs_size = ((atop(round_page(size)) - 1) >> vs->vs_clshift) + 1;
+	vs->vs_size = ((atop_32(round_page_32(size)) - 1) >> vs->vs_clshift) + 1;
 	vs->vs_async_pending = 0;
 
 	/*
@@ -1771,7 +1773,7 @@ ps_clmap(
 	VS_MAP_LOCK(vs);
 
 	ASSERT(vs->vs_dmap);
-	cluster = atop(offset) >> vs->vs_clshift;
+	cluster = atop_32(offset) >> vs->vs_clshift;
 
 	/*
 	 * Initialize cluster error value
@@ -1887,14 +1889,14 @@ ps_clmap(
 	 * relatively quick.
 	 */
 	ASSERT(trunc_page(offset) == offset);
-	newcl = ptoa(newcl) << vs->vs_clshift;
+	newcl = ptoa_32(newcl) << vs->vs_clshift;
 	newoff = offset & ((1<<(vm_page_shift + vs->vs_clshift)) - 1);
 	if (flag == CL_ALLOC) {
 		/*
 		 * set bits in the allocation bitmap according to which
 		 * pages were requested.  size is in bytes.
 		 */
-		i = atop(newoff);
+		i = atop_32(newoff);
 		while ((size > 0) && (i < VSCLSIZE(vs))) {
 			VSM_SETALLOC(*vsmap, i);
 			i++;
@@ -1907,7 +1909,7 @@ ps_clmap(
 		 * Offset is not cluster aligned, so number of pages
 		 * and bitmaps must be adjusted
 		 */
-		clmap->cl_numpages -= atop(newoff);
+		clmap->cl_numpages -= atop_32(newoff);
 		CLMAP_SHIFT(clmap, vs);
 		CLMAP_SHIFTALLOC(clmap, vs);
 	}
@@ -1936,7 +1938,7 @@ ps_clmap(
 		} else {
 			BS_STAT(clmap->cl_ps->ps_bs,
 				clmap->cl_ps->ps_bs->bs_pages_out_fail +=
-					atop(size));
+					atop_32(size));
 			off = VSM_CLOFF(*vsmap);
 			VSM_SETERR(*vsmap, error);
 		}
@@ -1983,7 +1985,7 @@ ps_clunmap(
 		vm_offset_t 	newoff;
 		int		i;
 
-		cluster = atop(offset) >> vs->vs_clshift;
+		cluster = atop_32(offset) >> vs->vs_clshift;
 		if (vs->vs_indirect)	/* indirect map */
 			vsmap = vs->vs_imap[cluster/CLMAP_ENTRIES];
 		else
@@ -2008,7 +2010,7 @@ ps_clunmap(
 			 * Not cluster aligned.
 			 */
 			ASSERT(trunc_page(newoff) == newoff);
-			i = atop(newoff);
+			i = atop_32(newoff);
 		} else
 			i = 0;
 		while ((i < VSCLSIZE(vs)) && (length > 0)) {
@@ -2079,7 +2081,7 @@ vs_cl_write_complete(
 		dprintf(("write failed error = 0x%x\n", error));
 		/* add upl_abort code here */
 	} else
-		GSTAT(global_stats.gs_pages_out += atop(size));
+		GSTAT(global_stats.gs_pages_out += atop_32(size));
 	/*
 	 * Notify the vstruct mapping code, so it can do its accounting.
 	 */
@@ -2235,7 +2237,7 @@ ps_read_device(
 	default_pager_thread_t *dpt = NULL;
 
 	device = dev_port_lookup(ps->ps_device);
-	clustered_reads[atop(size)]++;
+	clustered_reads[atop_32(size)]++;
 
 	dev_offset = (ps->ps_offset +
 		      (offset >> (vm_page_shift - ps->ps_record_shift)));
@@ -2367,7 +2369,7 @@ ps_write_device(
 
 
 
-	clustered_writes[atop(size)]++;
+	clustered_writes[atop_32(size)]++;
 
 	dev_offset = (ps->ps_offset +
 		      (offset >> (vm_page_shift - ps->ps_record_shift)));
@@ -2404,7 +2406,7 @@ ps_write_device(
 					 "device_write_request returned ",
 					 kr, addr, size, offset));
 			BS_STAT(ps->ps_bs,
-				ps->ps_bs->bs_pages_out_fail += atop(size));
+				ps->ps_bs->bs_pages_out_fail += atop_32(size));
 			/* do the completion notification to free resources */
 			device_write_reply(reply_port, kr, 0);
 			return PAGER_ERROR;
@@ -2430,7 +2432,7 @@ ps_write_device(
 				 "device_write returned ",
 				 kr, addr, size, offset));
 			BS_STAT(ps->ps_bs,
-				ps->ps_bs->bs_pages_out_fail += atop(size));
+				ps->ps_bs->bs_pages_out_fail += atop_32(size));
 			return PAGER_ERROR;
 		}
 		if (bytes_written & ((vm_page_size >> ps->ps_record_shift) - 1))
@@ -2492,7 +2494,7 @@ pvs_object_data_provided(
 	       upl, offset, size));
 
 	ASSERT(size > 0);
-	GSTAT(global_stats.gs_pages_in += atop(size));
+	GSTAT(global_stats.gs_pages_in += atop_32(size));
 
 
 #if	USE_PRECIOUS
@@ -2550,10 +2552,16 @@ pvs_cluster_read(
 	        int     ps_info_valid;
 		int	page_list_count;
 
-	        if (cnt > VM_SUPER_CLUSTER)
+		if((vs_offset & cl_mask) && 
+			(cnt > (VM_SUPER_CLUSTER - 
+				(vs_offset & cl_mask)))) {
+			size = VM_SUPER_CLUSTER;
+			size -= vs_offset & cl_mask;
+	        } else if (cnt > VM_SUPER_CLUSTER) {
 		        size = VM_SUPER_CLUSTER;
-		else
+		} else {
 		        size = cnt;
+		}
 		cnt -= size;
 
 		ps_info_valid = 0;
@@ -2615,7 +2623,7 @@ pvs_cluster_read(
 			        /*
 				 * Let VM system know about holes in clusters.
 				 */
-			        GSTAT(global_stats.gs_pages_unavail += atop(abort_size));
+			        GSTAT(global_stats.gs_pages_unavail += atop_32(abort_size));
 
 				page_list_count = 0;
 				memory_object_super_upl_request(
@@ -2658,9 +2666,11 @@ pvs_cluster_read(
 			 */
 			for (xfer_size = 0; xfer_size < size; ) {
 
-			        while (cl_index < pages_in_cl && xfer_size < size) {
+			        while (cl_index < pages_in_cl 
+						&& xfer_size < size) {
 				        /*
-					 * accumulate allocated pages within a physical segment
+					 * accumulate allocated pages within
+					 * a physical segment
 					 */
 				        if (CLMAP_ISSET(clmap, cl_index)) {
 					        xfer_size  += vm_page_size;
@@ -2672,35 +2682,43 @@ pvs_cluster_read(
 					} else
 					        break;
 				}
-				if (cl_index < pages_in_cl || xfer_size >= size) {
+				if (cl_index < pages_in_cl 
+						|| xfer_size >= size) {
 				        /*
-					 * we've hit an unallocated page or the
-					 * end of this request... go fire the I/O
+					 * we've hit an unallocated page or
+					 * the end of this request... go fire
+					 * the I/O
 					 */
 				        break;
 				}
 				/*
-				 * we've hit the end of the current physical segment
-				 * and there's more to do, so try moving to the next one
+				 * we've hit the end of the current physical
+				 * segment and there's more to do, so try
+				 * moving to the next one
 				 */
 				seg_index++;
 				  
-				ps_offset[seg_index] = ps_clmap(vs, cur_offset & ~cl_mask, &clmap, CL_FIND, 0, 0);
-				psp[seg_index]       = CLMAP_PS(clmap);
+				ps_offset[seg_index] = 
+					ps_clmap(vs,
+						cur_offset & ~cl_mask,
+						&clmap, CL_FIND, 0, 0);
+				psp[seg_index] = CLMAP_PS(clmap);
 				ps_info_valid = 1;
 
 				if ((ps_offset[seg_index - 1] != (ps_offset[seg_index] - cl_size)) || (psp[seg_index - 1] != psp[seg_index])) {
 				        /*
-					 * if the physical segment we're about to step into
-					 * is not contiguous to the one we're currently
-					 * in, or it's in a different paging file, or
+					 * if the physical segment we're about
+					 * to step into is not contiguous to
+					 * the one we're currently in, or it's
+					 * in a different paging file, or
 					 * it hasn't been allocated....
 					 * we stop here and generate the I/O
 					 */
 				        break;
 				}
 				/*
-				 * start with first page of the next physical segment
+				 * start with first page of the next physical
+				 * segment
 				 */
 				cl_index = 0;
 			}
@@ -2711,68 +2729,78 @@ pvs_cluster_read(
 				 */
 				page_list_count = 0;
 			        memory_object_super_upl_request(vs->vs_control,
-						(memory_object_offset_t)vs_offset,
-						xfer_size, xfer_size, 
-						&upl, NULL, &page_list_count,
-						request_flags | UPL_SET_INTERNAL);
+					(memory_object_offset_t)vs_offset,
+					xfer_size, xfer_size, 
+					&upl, NULL, &page_list_count,
+					request_flags | UPL_SET_INTERNAL);
 
-				error = ps_read_file(psp[beg_pseg], upl, (vm_offset_t) 0, 
-						ps_offset[beg_pseg] + (beg_indx * vm_page_size), xfer_size, &residual, 0);
+				error = ps_read_file(psp[beg_pseg],
+					upl, (vm_offset_t) 0, 
+					ps_offset[beg_pseg] +
+						(beg_indx * vm_page_size),
+					xfer_size, &residual, 0);
 			} else
 			        continue;
 
 			failed_size = 0;
 
 			/*
-			 * Adjust counts and send response to VM.  Optimize for the
-			 * common case, i.e. no error and/or partial data.
-			 * If there was an error, then we need to error the entire
-			 * range, even if some data was successfully read.
-			 * If there was a partial read we may supply some
+			 * Adjust counts and send response to VM.  Optimize
+			 * for the common case, i.e. no error and/or partial
+			 * data.  If there was an error, then we need to error
+			 * the entire range, even if some data was successfully
+			 * read.  If there was a partial read we may supply some
 			 * data and may error some as well.  In all cases the
 			 * VM must receive some notification for every page in the
 			 * range.
 			 */
 			if ((error == KERN_SUCCESS) && (residual == 0)) {
 			        /*
-				 * Got everything we asked for, supply the data to
-				 * the VM.  Note that as a side effect of supplying
-				 * the data, the buffer holding the supplied data is
-				 * deallocated from the pager's address space.
+				 * Got everything we asked for, supply the data
+				 * to the VM.  Note that as a side effect of
+				 * supplying * the data, the buffer holding the
+				 * supplied data is * deallocated from the pager's
+				 * address space.
 				 */
-			        pvs_object_data_provided(vs, upl, vs_offset, xfer_size);
+			        pvs_object_data_provided(
+					vs, upl, vs_offset, xfer_size);
 			} else {
 			        failed_size = xfer_size;
 
 				if (error == KERN_SUCCESS) {
 				        if (residual == xfer_size) {
-					        /*
-						 * If a read operation returns no error
-						 * and no data moved, we turn it into
-						 * an error, assuming we're reading at
-						 * or beyong EOF.
-						 * Fall through and error the entire
-						 * range.
-						 */
+				        /*
+					 * If a read operation returns no error
+					 * and no data moved, we turn it into
+					 * an error, assuming we're reading at
+					 * or beyong EOF.
+					 * Fall through and error the entire
+					 * range.
+					 */
 					        error = KERN_FAILURE;
 					} else {
-					        /*
-						 * Otherwise, we have partial read. If
-						 * the part read is a integral number
-						 * of pages supply it. Otherwise round
-						 * it up to a page boundary, zero fill
-						 * the unread part, and supply it.
-						 * Fall through and error the remainder
-						 * of the range, if any.
-						 */
+				        /*
+					 * Otherwise, we have partial read. If
+					 * the part read is a integral number
+					 * of pages supply it. Otherwise round
+					 * it up to a page boundary, zero fill
+					 * the unread part, and supply it.
+					 * Fall through and error the remainder
+					 * of the range, if any.
+					 */
 					        int fill, lsize;
 
-						fill = residual & ~vm_page_size;
-						lsize = (xfer_size - residual) + fill;
-						pvs_object_data_provided(vs, upl, vs_offset, lsize);
+						fill = residual 
+							& ~vm_page_size;
+						lsize = (xfer_size - residual) 
+									 + fill;
+						pvs_object_data_provided(
+							vs, upl,
+							vs_offset, lsize);
 
 						if (lsize < xfer_size) {
-						        failed_size = xfer_size - lsize;
+						        failed_size = 
+							    xfer_size - lsize;
 							error = KERN_FAILURE;
 						}
 					}
@@ -2780,12 +2808,13 @@ pvs_cluster_read(
 			}
 			/*
 			 * If there was an error in any part of the range, tell
-			 * the VM. Note that error is explicitly checked again since
-			 * it can be modified above.
+			 * the VM. Note that error is explicitly checked again
+			 * since it can be modified above.
 			 */
 			if (error != KERN_SUCCESS) {
 				BS_STAT(psp[beg_pseg]->ps_bs,
-					psp[beg_pseg]->ps_bs->bs_pages_in_fail += atop(failed_size));
+					psp[beg_pseg]->ps_bs->bs_pages_in_fail
+						+= atop_32(failed_size));
 			}
 			size       -= xfer_size;
 			vs_offset  += xfer_size;
@@ -2865,16 +2894,18 @@ vs_cluster_write(
 				(memory_object_offset_t)offset,
 				cnt, super_size, 
 				&upl, NULL, &page_list_count,
-				request_flags | UPL_PAGEOUT);
+				request_flags | UPL_FOR_PAGEOUT);
 
 		pl = UPL_GET_INTERNAL_PAGE_LIST(upl);
 
-		for (seg_index = 0, transfer_size = upl->size; transfer_size > 0; ) {
+		for (seg_index = 0, transfer_size = upl->size; 
+						transfer_size > 0; ) {
 
-		        ps_offset[seg_index] = ps_clmap(vs, upl->offset + (seg_index * cl_size),
-						      &clmap, CL_ALLOC, 
-						      transfer_size < cl_size ? 
-						      transfer_size : cl_size, 0);
+		        ps_offset[seg_index] = 
+				ps_clmap(vs, upl->offset + (seg_index * cl_size),
+				       &clmap, CL_ALLOC, 
+				       transfer_size < cl_size ? 
+				       transfer_size : cl_size, 0);
 
 			if (ps_offset[seg_index] == (vm_offset_t) -1) {
 				upl_abort(upl, 0);
@@ -2891,21 +2922,25 @@ vs_cluster_write(
 			} else
 			        transfer_size = 0;
 		}
-		for (page_index = 0, num_of_pages = upl->size / vm_page_size; page_index < num_of_pages; ) {
+		for (page_index = 0,
+				num_of_pages = upl->size / vm_page_size;
+				page_index < num_of_pages; ) {
 			/*
 			 * skip over non-dirty pages
 			 */
 			for ( ; page_index < num_of_pages; page_index++) {
-			        if (UPL_DIRTY_PAGE(pl, page_index) || UPL_PRECIOUS_PAGE(pl, page_index))
+			        if (UPL_DIRTY_PAGE(pl, page_index)
+					|| UPL_PRECIOUS_PAGE(pl, page_index))
 				        /*
 					 * this is a page we need to write
-					 * go see if we can buddy it up with others
-					 * that are contiguous to it
+					 * go see if we can buddy it up with
+					 * others that are contiguous to it
 					 */
 				        break;
 				/*
-				 * if the page is not-dirty, but present we need to commit it...
-				 * this is an unusual case since we only asked for dirty pages
+				 * if the page is not-dirty, but present we 
+				 * need to commit it...  This is an unusual
+				 * case since we only asked for dirty pages
 				 */
 				if (UPL_PAGE_PRESENT(pl, page_index)) {
 					boolean_t empty = FALSE;
@@ -2927,14 +2962,16 @@ vs_cluster_write(
 			        break;
 
 			/*
-			 * gather up contiguous dirty pages... we have at least 1
-			 * otherwise we would have bailed above
+			 * gather up contiguous dirty pages... we have at
+			 * least 1 otherwise we would have bailed above
 			 * make sure that each physical segment that we step
 			 * into is contiguous to the one we're currently in
 			 * if it's not, we have to stop and write what we have
 			 */
-			for (first_dirty = page_index; page_index < num_of_pages; ) {
-			        if ( !UPL_DIRTY_PAGE(pl, page_index) && !UPL_PRECIOUS_PAGE(pl, page_index))
+			for (first_dirty = page_index;
+					page_index < num_of_pages; ) {
+			        if ( !UPL_DIRTY_PAGE(pl, page_index)
+					&& !UPL_PRECIOUS_PAGE(pl, page_index))
 				        break;
 				page_index++;
 				/*
@@ -2946,17 +2983,21 @@ vs_cluster_write(
 				        int cur_seg;
 				        int nxt_seg;
 
-				        cur_seg = (page_index - 1) / pages_in_cl;
+				        cur_seg =
+						(page_index - 1) / pages_in_cl;
 					nxt_seg = page_index / pages_in_cl;
 
 					if (cur_seg != nxt_seg) {
 					        if ((ps_offset[cur_seg] != (ps_offset[nxt_seg] - cl_size)) || (psp[cur_seg] != psp[nxt_seg]))
-						        /*
-							 * if the segment we're about to step into
-							 * is not contiguous to the one we're currently
-							 * in, or it's in a different paging file....
-							 * we stop here and generate the I/O
-							 */
+					        /*
+						 * if the segment we're about
+						 * to step into is not
+						 * contiguous to the one we're
+						 * currently in, or it's in a
+						 * different paging file....
+						 * we stop here and generate
+						 * the I/O
+						 */
 						        break;
 					}
 				}
@@ -2970,22 +3011,29 @@ vs_cluster_write(
 				seg_offset = upl_offset - (seg_index * cl_size);
 				transfer_size = num_dirty * vm_page_size;
 
-				error = ps_write_file(psp[seg_index], upl, upl_offset,
-						      ps_offset[seg_index] + seg_offset, transfer_size, flags);
 
-				if (error == 0) {
-				        while (transfer_size) {
-					        int seg_size;
+				while (transfer_size) {
+				        int seg_size;
 
-						if ((seg_size = cl_size - (upl_offset % cl_size)) > transfer_size)
-						        seg_size = transfer_size;
+					if ((seg_size = cl_size - 
+						(upl_offset % cl_size)) 
+							> transfer_size)
+					        seg_size = transfer_size;
 
-						ps_vs_write_complete(vs, upl->offset + upl_offset, seg_size, error);
+					ps_vs_write_complete(vs, 
+						upl->offset + upl_offset, 
+						seg_size, error);
 
-						transfer_size -= seg_size;
-						upl_offset += seg_size;
-					}
+					transfer_size -= seg_size;
+					upl_offset += seg_size;
 				}
+			        upl_offset = first_dirty * vm_page_size;
+				transfer_size = num_dirty * vm_page_size;
+				error = ps_write_file(psp[seg_index], 
+						upl, upl_offset,
+						ps_offset[seg_index] 
+								+ seg_offset, 
+						transfer_size, flags);
 				must_abort = 0;
 			}
 			if (must_abort) {
@@ -3028,14 +3076,14 @@ vs_cluster_write(
 			/* Assume that the caller has given us contiguous */
 			/* pages */
 	 	   	if(cnt) {
+				ps_vs_write_complete(vs, mobj_target_addr, 
+								cnt, error);
 				error = ps_write_file(ps, internal_upl,
 						0, actual_offset,
 						cnt, flags);
 				if (error)
 				        break;
-				ps_vs_write_complete(vs, mobj_target_addr, 
-								cnt, error);
-		   	   }
+		   	}
 			if (error)
 				break;
 		   	actual_offset += cnt;
@@ -3097,7 +3145,7 @@ ps_vstruct_allocated_size(
 		}
 	}
 
-	return ptoa(num_pages);
+	return ptoa_32(num_pages);
 }
 
 size_t
@@ -3306,7 +3354,7 @@ vs_get_map_entry(
 	struct vs_map	*vsmap;
 	vm_offset_t	cluster;
 
-	cluster = atop(offset) >> vs->vs_clshift;
+	cluster = atop_32(offset) >> vs->vs_clshift;
 	if (vs->vs_indirect) {
 		long	ind_block = cluster/CLMAP_ENTRIES;
 
@@ -3671,7 +3719,7 @@ ps_read_file(
 	int			result;
 
 
-	clustered_reads[atop(size)]++;
+	clustered_reads[atop_32(size)]++;
 
 	f_offset = (vm_object_offset_t)(ps->ps_offset + offset);
 	
@@ -3709,7 +3757,7 @@ ps_write_file(
 
 	int		error = 0;
 
-	clustered_writes[atop(size)]++;
+	clustered_writes[atop_32(size)]++;
 	f_offset = (vm_object_offset_t)(ps->ps_offset + offset);
 
 	if (vnode_pageout(ps->ps_vnode,
diff --git a/osfmk/default_pager/dp_memory_object.c b/osfmk/default_pager/dp_memory_object.c
index 74c1e12da..353b2d9f2 100644
--- a/osfmk/default_pager/dp_memory_object.c
+++ b/osfmk/default_pager/dp_memory_object.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -656,7 +659,7 @@ dp_memory_object_data_initialize(
 	DEBUG(DEBUG_MO_EXTERNAL,
 	      ("mem_obj=0x%x,offset=0x%x,cnt=0x%x\n",
 	       (int)mem_obj, (int)offset, (int)size));
-	GSTAT(global_stats.gs_pages_init += atop(size));
+	GSTAT(global_stats.gs_pages_init += atop_32(size));
 
 	vs_lookup(mem_obj, vs);
 	vs_lock(vs);
@@ -730,7 +733,9 @@ dp_memory_object_data_return(
 		return KERN_SUCCESS;
 	}
 
-	if ((vs->vs_seqno != vs->vs_next_seqno++) || (vs->vs_xfer_pending)) {
+	if ((vs->vs_seqno != vs->vs_next_seqno++)
+			|| (vs->vs_readers)
+			|| (vs->vs_xfer_pending)) {
 		upl_t	upl;
 		int	page_list_count = 0;
 
@@ -895,10 +900,10 @@ default_pager_objects(
 	if (kr != KERN_SUCCESS)
 		return kr;
 
-	osize = round_page(*ocountp * sizeof * objects);
+	osize = round_page_32(*ocountp * sizeof * objects);
 	kr = vm_map_wire(ipc_kernel_map, 
-			trunc_page((vm_offset_t)objects),
-			round_page(((vm_offset_t)objects) + osize), 
+			trunc_page_32((vm_offset_t)objects),
+			round_page_32(((vm_offset_t)objects) + osize), 
 			VM_PROT_READ|VM_PROT_WRITE, FALSE);
 	osize=0;
 
@@ -924,7 +929,7 @@ default_pager_objects(
 		vm_offset_t	newaddr;
 		vm_size_t	newsize;
 
-		newsize = 2 * round_page(actual * sizeof * objects);
+		newsize = 2 * round_page_32(actual * sizeof * objects);
 
 		kr = vm_allocate(kernel_map, &newaddr, newsize, TRUE);
 		if (kr != KERN_SUCCESS)
@@ -940,7 +945,7 @@ default_pager_objects(
 		vm_offset_t	newaddr;
 		vm_size_t	newsize;
 
-		newsize = 2 * round_page(actual * sizeof * pagers);
+		newsize = 2 * round_page_32(actual * sizeof * pagers);
 
 		kr = vm_allocate(kernel_map, &newaddr, newsize, TRUE);
 		if (kr != KERN_SUCCESS)
@@ -1038,7 +1043,7 @@ default_pager_objects(
 	} else {
 		vm_offset_t used;
 
-		used = round_page(actual * sizeof * objects);
+		used = round_page_32(actual * sizeof * objects);
 
 		if (used != osize)
 			(void) vm_deallocate(kernel_map,
@@ -1064,7 +1069,7 @@ default_pager_objects(
 	} else {
 		vm_offset_t used;
 
-		used = round_page(actual * sizeof * pagers);
+		used = round_page_32(actual * sizeof * pagers);
 
 		if (used != psize)
 			(void) vm_deallocate(kernel_map,
@@ -1120,10 +1125,10 @@ default_pager_object_pages(
 	if (kr != KERN_SUCCESS)
 		return kr;
 
-	size = round_page(*countp * sizeof * pages);
+	size = round_page_32(*countp * sizeof * pages);
 	kr = vm_map_wire(ipc_kernel_map, 
-			trunc_page((vm_offset_t)pages),
-			round_page(((vm_offset_t)pages) + size), 
+			trunc_page_32((vm_offset_t)pages),
+			round_page_32(((vm_offset_t)pages) + size), 
 			VM_PROT_READ|VM_PROT_WRITE, FALSE);
 	size=0;
 
@@ -1179,7 +1184,7 @@ default_pager_object_pages(
 
 		if (pages != *pagesp)
 			(void) vm_deallocate(kernel_map, addr, size);
-		size = round_page(actual * sizeof * pages);
+		size = round_page_32(actual * sizeof * pages);
 		kr = vm_allocate(kernel_map, &addr, size, TRUE);
 		if (kr != KERN_SUCCESS)
 			return kr;
@@ -1208,7 +1213,7 @@ default_pager_object_pages(
 	} else {
 		vm_offset_t used;
 
-		used = round_page(actual * sizeof * pages);
+		used = round_page_32(actual * sizeof * pages);
 
 		if (used != size)
 			(void) vm_deallocate(kernel_map,
diff --git a/osfmk/device/device.defs b/osfmk/device/device.defs
index 137cca057..01f3f1dce 100644
--- a/osfmk/device/device.defs
+++ b/osfmk/device/device.defs
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/device/device_init.c b/osfmk/device/device_init.c
index db8fe7a58..ac1823984 100644
--- a/osfmk/device/device_init.c
+++ b/osfmk/device/device_init.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/device/device_port.h b/osfmk/device/device_port.h
index 1f2bbba59..946c83b44 100644
--- a/osfmk/device/device_port.h
+++ b/osfmk/device/device_port.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/device/device_types.defs b/osfmk/device/device_types.defs
index a42ac7c77..e170ac0ce 100644
--- a/osfmk/device/device_types.defs
+++ b/osfmk/device/device_types.defs
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/device/device_types.h b/osfmk/device/device_types.h
index 1e6c2e85f..85528f9eb 100644
--- a/osfmk/device/device_types.h
+++ b/osfmk/device/device_types.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/device/iokit_rpc.c b/osfmk/device/iokit_rpc.c
index a61ad9276..593ea29e8 100644
--- a/osfmk/device/iokit_rpc.c
+++ b/osfmk/device/iokit_rpc.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -61,7 +64,6 @@
 
 #ifdef __ppc__
 #include <ppc/mappings.h>
-#include <ppc/pmap_internals.h>
 #endif
 #include <IOKit/IOTypes.h>
 
@@ -80,7 +82,7 @@ extern ipc_port_t iokit_port_for_object( io_object_t obj,
 			ipc_kobject_type_t type );
 
 extern kern_return_t iokit_client_died( io_object_t obj,
-                        ipc_port_t port, ipc_kobject_type_t type, mach_port_mscount_t mscount );
+                        ipc_port_t port, ipc_kobject_type_t type, mach_port_mscount_t * mscount );
 
 extern kern_return_t
 iokit_client_memory_for_type(
@@ -279,6 +281,14 @@ iokit_destroy_object_port( ipc_port_t port )
     return( KERN_SUCCESS);
 }
 
+EXTERN kern_return_t
+iokit_switch_object_port( ipc_port_t port, io_object_t obj, ipc_kobject_type_t type )
+{
+    ipc_kobject_set( port, (ipc_kobject_t) obj, type);
+
+    return( KERN_SUCCESS);
+}
+
 EXTERN mach_port_name_t
 iokit_make_send_right( task_t task, io_object_t obj, ipc_kobject_type_t type )
 {
@@ -379,67 +389,80 @@ iokit_notify( mach_msg_header_t * msg )
     }
 }
 
-#ifndef i386
-unsigned int IOTranslateCacheBits(struct phys_entry *pp)
+/* need to create a pmap function to generalize */
+unsigned int IODefaultCacheBits(addr64_t pa)
 {
-	unsigned int	flags;
-	unsigned int	memattr;
+    unsigned int	flags;
+#ifndef i386
+    struct phys_entry * pp;
+
+    // Find physical address
+    if ((pp = pmap_find_physentry(pa >> 12))) {
+	// Use physical attributes as default
+	// NOTE: DEVICE_PAGER_FLAGS are made to line up
+	flags = VM_MEM_COHERENT;						/* We only support coherent memory */
+	if(pp->ppLink & ppG) flags |= VM_MEM_GUARDED;	/* Add in guarded if it is */
+	if(pp->ppLink & ppI) flags |= VM_MEM_NOT_CACHEABLE;	/* Add in cache inhibited if so */
+    } else
+	// If no physical, just hard code attributes
+        flags = VM_WIMG_IO;
+#else
+    extern vm_offset_t	avail_end;
 
-	/* need to create a pmap function to generalize */
-	memattr = ((pp->pte1 & 0x00000078) >> 3);
+    if (pa < avail_end)
+	flags = VM_WIMG_COPYBACK;
+    else
+	flags = VM_WIMG_IO;
+#endif
 
-	/* NOTE: DEVICE_PAGER_FLAGS are made to line up */
-	flags = memattr & VM_WIMG_MASK;
-	return flags;
+    return flags;
 }
-#endif
 
 kern_return_t IOMapPages(vm_map_t map, vm_offset_t va, vm_offset_t pa,
 			vm_size_t length, unsigned int options)
 {
     vm_size_t	off;
     vm_prot_t	prot;
-    int			memattr;
-    struct phys_entry *pp;
-    pmap_t 		pmap = map->pmap;
+    unsigned int flags;
+    pmap_t 	 pmap = map->pmap;
 
     prot = (options & kIOMapReadOnly)
 		? VM_PROT_READ : (VM_PROT_READ|VM_PROT_WRITE);
 
+    switch(options & kIOMapCacheMask ) {			/* What cache mode do we need? */
+
+	case kIOMapDefaultCache:
+	default:
+	    flags = IODefaultCacheBits(pa);
+	    break;
+
+	case kIOMapInhibitCache:
+	    flags = VM_WIMG_IO;
+	    break;
+
+	case kIOMapWriteThruCache:
+	    flags = VM_WIMG_WTHRU;
+	    break;
+
+	case kIOWriteCombineCache:
+	    flags = VM_WIMG_WCOMB;
+	    break;
+
+	case kIOMapCopybackCache:
+	    flags = VM_WIMG_COPYBACK;
+	    break;
+    }
 #if __ppc__
 
-	switch(options & kIOMapCacheMask ) {			/* What cache mode do we need? */
-
-		case kIOMapDefaultCache:
-		default:
-			if(pp = pmap_find_physentry(pa)) {		/* Find physical address */
-				memattr = ((pp->pte1 & 0x00000078) >> 3);	/* Use physical attributes as default */
-			}
-			else {									/* If no physical, just hard code attributes */
-				memattr = PTE_WIMG_UNCACHED_COHERENT_GUARDED;
-			}
-			break;
-	
-		case kIOMapInhibitCache:
-			memattr = PTE_WIMG_UNCACHED_COHERENT_GUARDED;
-			break;
-	
-		case kIOMapWriteThruCache:
-			memattr = PTE_WIMG_WT_CACHED_COHERENT_GUARDED;
-			break;
-
-		case kIOMapCopybackCache:
-			memattr = PTE_WIMG_CB_CACHED_COHERENT;
-			break;
-	}
+    // Set up a block mapped area
+    pmap_map_block(pmap, (addr64_t)va, (ppnum_t)(pa >> 12), length, prot, flags, 0);
 
-	pmap_map_block(pmap, va, pa, length, prot, memattr, 0);	/* Set up a block mapped area */
-	
 #else
-// 	enter each page's physical address in the target map
-	for (off = 0; off < length; off += page_size) {		/* Loop for the whole length */
-	 	pmap_enter(pmap, va + off, pa + off, prot, VM_WIMG_USE_DEFAULT, TRUE);	/* Map it in */
-	}
+//  enter each page's physical address in the target map
+
+    for (off = 0; off < length; off += page_size)
+	pmap_enter(pmap, va + off, (pa + off) >> 12, prot, flags, TRUE);
+
 #endif
 
     return( KERN_SUCCESS );
@@ -449,7 +472,7 @@ kern_return_t IOUnmapPages(vm_map_t map, vm_offset_t va, vm_size_t length)
 {
     pmap_t	pmap = map->pmap;
 
-    pmap_remove(pmap, trunc_page(va), round_page(va + length));
+    pmap_remove(pmap, trunc_page_64(va), round_page_64(va + length));
 
     return( KERN_SUCCESS );
 }
diff --git a/osfmk/device/subrs.c b/osfmk/device/subrs.c
index 1282fd398..ccbb9990e 100644
--- a/osfmk/device/subrs.c
+++ b/osfmk/device/subrs.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/AT386/asm_startup.h b/osfmk/i386/AT386/asm_startup.h
index c22b98ac8..4bc3ef027 100644
--- a/osfmk/i386/AT386/asm_startup.h
+++ b/osfmk/i386/AT386/asm_startup.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/AT386/autoconf.c b/osfmk/i386/AT386/autoconf.c
index 7a5d3d7f6..ba1c1cdd8 100644
--- a/osfmk/i386/AT386/autoconf.c
+++ b/osfmk/i386/AT386/autoconf.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/AT386/bbclock.c b/osfmk/i386/AT386/bbclock.c
index ffcad7a77..25564bb58 100644
--- a/osfmk/i386/AT386/bbclock.c
+++ b/osfmk/i386/AT386/bbclock.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/AT386/bbclock_entries.h b/osfmk/i386/AT386/bbclock_entries.h
index 1fd8ca1d7..b9c6bf316 100644
--- a/osfmk/i386/AT386/bbclock_entries.h
+++ b/osfmk/i386/AT386/bbclock_entries.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/AT386/conf.c b/osfmk/i386/AT386/conf.c
index 67632a323..b6eebb8e7 100644
--- a/osfmk/i386/AT386/conf.c
+++ b/osfmk/i386/AT386/conf.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/AT386/config.h b/osfmk/i386/AT386/config.h
index 44fd99948..5098271fb 100644
--- a/osfmk/i386/AT386/config.h
+++ b/osfmk/i386/AT386/config.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/AT386/cram.h b/osfmk/i386/AT386/cram.h
index a56bef22f..4a8a539d4 100644
--- a/osfmk/i386/AT386/cram.h
+++ b/osfmk/i386/AT386/cram.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/AT386/himem.c b/osfmk/i386/AT386/himem.c
index f9abdb912..d9d0fd5f3 100644
--- a/osfmk/i386/AT386/himem.c
+++ b/osfmk/i386/AT386/himem.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/AT386/himem.h b/osfmk/i386/AT386/himem.h
index c0ae26d10..2d0ec0f67 100644
--- a/osfmk/i386/AT386/himem.h
+++ b/osfmk/i386/AT386/himem.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/AT386/iso_scan_font.h b/osfmk/i386/AT386/iso_scan_font.h
index 25ac9734f..26a96c403 100644
--- a/osfmk/i386/AT386/iso_scan_font.h
+++ b/osfmk/i386/AT386/iso_scan_font.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/AT386/kernBootStruct.h b/osfmk/i386/AT386/kernBootStruct.h
index 6ac55d39d..d9cc8bebe 100644
--- a/osfmk/i386/AT386/kernBootStruct.h
+++ b/osfmk/i386/AT386/kernBootStruct.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/AT386/misc_protos.h b/osfmk/i386/AT386/misc_protos.h
index 6b6f6a2d8..ab1001441 100644
--- a/osfmk/i386/AT386/misc_protos.h
+++ b/osfmk/i386/AT386/misc_protos.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/AT386/model_dep.c b/osfmk/i386/AT386/model_dep.c
index c3cb5bc94..b8ac30cd5 100644
--- a/osfmk/i386/AT386/model_dep.c
+++ b/osfmk/i386/AT386/model_dep.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -115,7 +118,8 @@
 
 #include <IOKit/IOPlatformExpert.h>
 
-vm_size_t	mem_size = 0; 
+vm_size_t	mem_size = 0;
+uint64_t	max_mem;
 vm_offset_t	first_addr = 0;	/* set by start.s - keep out of bss */
 vm_offset_t	first_avail = 0;/* first after page tables */
 vm_offset_t	last_addr;
@@ -367,7 +371,7 @@ machine_init(void)
 	 * Display CPU identification
 	 */
 	cpuid_cpu_display("CPU identification", 0);
-	cpuid_cache_display("CPU configuration", 0);
+	cpuid_feature_display("CPU features", 0);
 
 #if	MP_V1_1
 	mp_v1_1_init();
@@ -508,6 +512,7 @@ i386_init(void)
 	first_addr = round_page(first_addr);
 	last_addr = trunc_page(last_addr);
 	mem_size = last_addr - bios_hole_size;
+	max_mem = mem_size;
 
 	avail_start = first_addr;
 	avail_end = last_addr;
diff --git a/osfmk/i386/AT386/mp/boot.h b/osfmk/i386/AT386/mp/boot.h
index e6551c15f..04b61ecff 100644
--- a/osfmk/i386/AT386/mp/boot.h
+++ b/osfmk/i386/AT386/mp/boot.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/AT386/mp/mp.c b/osfmk/i386/AT386/mp/mp.c
index df8f04a51..4ea476827 100644
--- a/osfmk/i386/AT386/mp/mp.c
+++ b/osfmk/i386/AT386/mp/mp.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/AT386/mp/mp.h b/osfmk/i386/AT386/mp/mp.h
index 84339bfcf..a444c5aeb 100644
--- a/osfmk/i386/AT386/mp/mp.h
+++ b/osfmk/i386/AT386/mp/mp.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/AT386/mp/mp_events.h b/osfmk/i386/AT386/mp/mp_events.h
index 2a2e60998..4fa8081c6 100644
--- a/osfmk/i386/AT386/mp/mp_events.h
+++ b/osfmk/i386/AT386/mp/mp_events.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/AT386/mp/mp_v1_1.c b/osfmk/i386/AT386/mp/mp_v1_1.c
index 0f58f2d51..bc5a1c4d9 100644
--- a/osfmk/i386/AT386/mp/mp_v1_1.c
+++ b/osfmk/i386/AT386/mp/mp_v1_1.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/AT386/mp/mp_v1_1.h b/osfmk/i386/AT386/mp/mp_v1_1.h
index de330f41b..86e9d1c00 100644
--- a/osfmk/i386/AT386/mp/mp_v1_1.h
+++ b/osfmk/i386/AT386/mp/mp_v1_1.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/AT386/mp/slave_boot.s b/osfmk/i386/AT386/mp/slave_boot.s
index 4f55d2024..a227728d0 100644
--- a/osfmk/i386/AT386/mp/slave_boot.s
+++ b/osfmk/i386/AT386/mp/slave_boot.s
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/AT386/physmem_entries.h b/osfmk/i386/AT386/physmem_entries.h
index ffb48fa50..4efce6dbe 100644
--- a/osfmk/i386/AT386/physmem_entries.h
+++ b/osfmk/i386/AT386/physmem_entries.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/AT386/rtc.h b/osfmk/i386/AT386/rtc.h
index 9dd18e914..42e112307 100644
--- a/osfmk/i386/AT386/rtc.h
+++ b/osfmk/i386/AT386/rtc.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/AT386/video_console.c b/osfmk/i386/AT386/video_console.c
index 4b610a158..6dc5f0438 100644
--- a/osfmk/i386/AT386/video_console.c
+++ b/osfmk/i386/AT386/video_console.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/AT386/video_console.h b/osfmk/i386/AT386/video_console.h
index ccf059eff..130956005 100644
--- a/osfmk/i386/AT386/video_console.h
+++ b/osfmk/i386/AT386/video_console.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/Makefile b/osfmk/i386/Makefile
index 8e606d055..cb8a18ef7 100644
--- a/osfmk/i386/Makefile
+++ b/osfmk/i386/Makefile
@@ -7,20 +7,18 @@ export MakeInc_dir=${SRCROOT}/makedefs/MakeInc.dir
 include $(MakeInc_cmd)
 include $(MakeInc_def)
 
-DATAFILES = \
-	asm.h eflags.h exec.h machlimits.h \
-	endian.h trap.h soundcard.h
-
-EXPORT_ONLY_FILES = cpu_number.h \
+EXPORT_ONLY_FILES = 	\
+		    cpu_capabilities.h	\
+		    cpu_number.h \
 		    hw_lock_types.h \
 		    io_map_entries.h \
 		    lock.h \
 		    machine_routines.h
 
-INSTALL_MD_LIST = ${DATAFILES}
-
 INSTALL_MD_DIR = i386
 
+INSTALL_MD_LCL_LIST = cpu_capabilities.h
+
 EXPORT_MD_LIST = ${EXPORT_ONLY_FILES}
 
 EXPORT_MD_DIR = i386
diff --git a/osfmk/i386/_setjmp.s b/osfmk/i386/_setjmp.s
index cde520aea..098cd95ca 100644
--- a/osfmk/i386/_setjmp.s
+++ b/osfmk/i386/_setjmp.s
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/apic.h b/osfmk/i386/apic.h
index 2b62c0d06..f18199a24 100644
--- a/osfmk/i386/apic.h
+++ b/osfmk/i386/apic.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/arch_types.h b/osfmk/i386/arch_types.h
index c04037860..7cbebf34e 100644
--- a/osfmk/i386/arch_types.h
+++ b/osfmk/i386/arch_types.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/asm.h b/osfmk/i386/asm.h
index 1bd157fb2..6f2928ccf 100644
--- a/osfmk/i386/asm.h
+++ b/osfmk/i386/asm.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/ast.h b/osfmk/i386/ast.h
index 9f201def5..0b41400c3 100644
--- a/osfmk/i386/ast.h
+++ b/osfmk/i386/ast.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/ast_check.c b/osfmk/i386/ast_check.c
index 15d3cd6bc..267da2ea8 100644
--- a/osfmk/i386/ast_check.c
+++ b/osfmk/i386/ast_check.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/ast_types.h b/osfmk/i386/ast_types.h
index 6ca56f471..56011fc4a 100644
--- a/osfmk/i386/ast_types.h
+++ b/osfmk/i386/ast_types.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/bcopy.s b/osfmk/i386/bcopy.s
index b592689e8..0061c2ed4 100644
--- a/osfmk/i386/bcopy.s
+++ b/osfmk/i386/bcopy.s
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/bsd_i386.c b/osfmk/i386/bsd_i386.c
index 0a96e3cb8..ad24633c2 100644
--- a/osfmk/i386/bsd_i386.c
+++ b/osfmk/i386/bsd_i386.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/bzero.s b/osfmk/i386/bzero.s
index e1d668695..35624b183 100644
--- a/osfmk/i386/bzero.s
+++ b/osfmk/i386/bzero.s
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/commpage/commpage.c b/osfmk/i386/commpage/commpage.c
new file mode 100644
index 000000000..2c41d6662
--- /dev/null
+++ b/osfmk/i386/commpage/commpage.c
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ * 
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ * 
+ * @APPLE_LICENSE_HEADER_END@
+ */
+
+#include <machine/cpu_capabilities.h>
+#include <machine/commpage.h>
+
+int	_cpu_capabilities = 0;				/* define the capability vector */
+
+void	commpage_populate( void ) {
+
+    /* no commpage on Intel yet */
+    
+}
diff --git a/osfmk/i386/commpage/commpage.h b/osfmk/i386/commpage/commpage.h
new file mode 100644
index 000000000..c16d89942
--- /dev/null
+++ b/osfmk/i386/commpage/commpage.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ * 
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ * 
+ * @APPLE_LICENSE_HEADER_END@
+ */
+
+#ifndef _I386_COMMPAGE_H
+#define _I386_COMMPAGE_H
+
+/* we don't have a comm page on Intel, yet */
+
+#endif /* _I386_COMMPAGE_H */
diff --git a/osfmk/i386/cpu.c b/osfmk/i386/cpu.c
index d23ae9e91..dea338a3c 100644
--- a/osfmk/i386/cpu.c
+++ b/osfmk/i386/cpu.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/cpu_capabilities.h b/osfmk/i386/cpu_capabilities.h
new file mode 100644
index 000000000..bd0297633
--- /dev/null
+++ b/osfmk/i386/cpu_capabilities.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ * 
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ * 
+ * @APPLE_LICENSE_HEADER_END@
+ */
+
+#ifndef _I386_CPU_CAPABILITIES_H
+#define _I386_CPU_CAPABILITIES_H
+
+/* Sadly, some clients of this interface misspell __APPLE_API_PRIVATE.
+ * To avoid breaking them, we accept the incorrect _APPLE_API_PRIVATE.
+ */
+#ifdef	_APPLE_API_PRIVATE
+#ifndef __APPLE_API_PRIVATE
+#define	__APPLE_API_PRIVATE
+#endif	/* __APPLE_API_PRIVATE */
+#endif	/* _APPLE_API_PRIVATE */
+
+#ifndef __APPLE_API_PRIVATE
+#error	cpu_capabilities.h is for Apple Internal use only
+#else	/* __APPLE_API_PRIVATE */
+
+/* _cpu_capabilities
+ *
+ * This is the authoritative way to determine from user mode what
+ * implementation-specific processor features are available.
+ * This API only supported for Apple internal use.
+ * 
+ */
+
+#ifndef	__ASSEMBLER__
+ 
+extern int _cpu_capabilities;
+ 
+#endif
+
+/* Bit definitions for _cpu_capabilities: */
+
+#endif /* __APPLE_API_PRIVATE */
+#endif /* _I386_CPU_CAPABILITIES_H */
diff --git a/osfmk/i386/cpu_data.h b/osfmk/i386/cpu_data.h
index a62fc6170..e4ba6fd33 100644
--- a/osfmk/i386/cpu_data.h
+++ b/osfmk/i386/cpu_data.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/cpu_number.h b/osfmk/i386/cpu_number.h
index 255bb119a..b1da54868 100644
--- a/osfmk/i386/cpu_number.h
+++ b/osfmk/i386/cpu_number.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/cpuid.c b/osfmk/i386/cpuid.c
index d66f01d30..395ed4b6f 100644
--- a/osfmk/i386/cpuid.c
+++ b/osfmk/i386/cpuid.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -23,387 +26,431 @@
  * @OSF_COPYRIGHT@
  */
 
-/*
- * Values from http://einstein.et.tudelft.nl/~offerman/chiplist.html
- * (dated 18 Oct 1995)
- */
+#include "cpuid.h"
 
-#include <kern/misc_protos.h>
-#include <i386/cpuid.h>
+#define min(a,b) ((a) < (b) ? (a) : (b))
 
 /*
- * Generic product array (before CPUID)
+ * CPU identification routines.
+ *
+ * Note that this code assumes a processor that supports the
+ * 'cpuid' instruction.
  */
-unsigned int cpuid_i386_freq[] = { 12, 16, 20, 25, 33, 0 };
-unsigned int cpuid_i486_freq[] = { 20, 25, 33, 50, 0 };
-
-struct cpuid_product cpuid_generic[] = {
-    {
-	0,		CPUID_FAMILY_386,	0,
-	80,	cpuid_i386_freq,		"i386"
-    },
-    {
-	0,		CPUID_FAMILY_486,	0,
-	240,	cpuid_i486_freq,		"i486"
-    },
-};
 
-/*
- * INTEL product array
- */
-unsigned int cpuid_i486_dx_freq[] = { 20, 25, 33, 0 };
-unsigned int cpuid_i486_dx_s_freq[] = { 50, 0 };
-unsigned int cpuid_i486_sx_freq[] = { 16, 20, 25, 33, 0 };
-unsigned int cpuid_i486_dx2_freq[] = { 32, 40, 50, 66, 0 };
-unsigned int cpuid_i486_sl_freq[] = { 25, 33, 0 };
-unsigned int cpuid_i486_sx2_freq[] = { 50, 0 };
-unsigned int cpuid_i486_dx2wb_freq[] = { 50, 66, 0 };
-unsigned int cpuid_i486_dx4_freq[] = { 90, 100, 0 };
-
-unsigned int cpuid_i486_dx2wb_od_freq[] = { 32, 40, 50, 66, 0 };
-unsigned int cpuid_i486_dx4_od_freq[] = { 75, 99, 0 };
-
-unsigned int cpuid_p5_freq[] = { 60, 66, 0 };
-unsigned int cpuid_p54_freq[] = { 60, 66, 75, 90, 100, 120, 133, 166, 200, 0 };
-
-unsigned int cpuid_p24t_freq[] = { 25, 33, 0 };
-unsigned int cpuid_p24ct_freq[] = { 63, 83, 0 };
-
-unsigned int cpuid_pii_freq[] = { 300, 0 };
-
-struct cpuid_product cpuid_intel[] = {
-    {
-	CPUID_TYPE_OEM,		CPUID_FAMILY_486,	CPUID_MODEL_I486_DX,
-	240,	cpuid_i486_dx_freq,		"Intel 486DX"
-    },
-    {
-	CPUID_TYPE_OEM,		CPUID_FAMILY_486,	CPUID_MODEL_I486_DX_S,
-	240,	cpuid_i486_dx_s_freq,		"Intel 486DX-S"
-    },
-    {
-	CPUID_TYPE_OEM,		CPUID_FAMILY_486,	CPUID_MODEL_I486_SX,
-	240,	cpuid_i486_sx_freq,		"Intel 486SX"
-    },
-    {
-	CPUID_TYPE_OEM,		CPUID_FAMILY_486,	CPUID_MODEL_I486_DX2,
-	240,	cpuid_i486_dx2_freq,		"Intel 486DX2"
-    },
-    {
-	CPUID_TYPE_OEM,		CPUID_FAMILY_486,	CPUID_MODEL_I486_SL,
-	240,	cpuid_i486_sl_freq,		"Intel 486SL"
-    },
-    {  
-	CPUID_TYPE_OEM,		CPUID_FAMILY_486,	CPUID_MODEL_I486_SX2,
-	240,	cpuid_i486_sx2_freq,		"Intel 486SX2"
-    },
-    {
-	CPUID_TYPE_OEM,		CPUID_FAMILY_486,	CPUID_MODEL_I486_DX2WB,
-	240,	cpuid_i486_dx2wb_freq,		"Intel 486DX2WB"
-    },
-    {
-	CPUID_TYPE_OEM,		CPUID_FAMILY_486,	CPUID_MODEL_I486_DX4,
-	240,	cpuid_i486_dx4_freq,		"Intel 486DX4"
-    },
-    {
-	CPUID_TYPE_OVERDRIVE,	CPUID_FAMILY_486,	CPUID_MODEL_I486_DX2,
-	240,	cpuid_i486_dx2_freq,		"Intel 486DX2 OverDrive"
-    },
-    {
-	CPUID_TYPE_OVERDRIVE,	CPUID_FAMILY_486,	CPUID_MODEL_I486_DX2WB,
-	240,	cpuid_i486_dx2wb_od_freq,	"Intel 486DX2WB OverDrive"
-    },
-    {
-	CPUID_TYPE_OVERDRIVE,	CPUID_FAMILY_486,	CPUID_MODEL_I486_DX4,
-	240,	cpuid_i486_dx4_od_freq,		"Intel 486DX4 OverDrive"
-    },
-    {
-	CPUID_TYPE_OVERDRIVE,	CPUID_FAMILY_P5,	CPUID_MODEL_P24T,
-	208,	cpuid_p24t_freq,		"Intel Pentium P24T OverDrive"
-    },
-    {
-	CPUID_TYPE_OVERDRIVE,	CPUID_FAMILY_P5,	CPUID_MODEL_P54,
-	207,	cpuid_p24ct_freq,		"Intel Pentium P24CT OverDrive"
-    },
-    {
-	CPUID_TYPE_OEM,		CPUID_FAMILY_P5,	CPUID_MODEL_P5A,
-	207,	cpuid_p5_freq,			"Intel Pentium P5 rev A"
-    },
-    {
-	CPUID_TYPE_OEM,		CPUID_FAMILY_P5,	CPUID_MODEL_P5,
-	207,	cpuid_p5_freq,			"Intel Pentium P5"
-    },
-    {
-	CPUID_TYPE_OEM,		CPUID_FAMILY_P5,	CPUID_MODEL_P54,
-	207,	cpuid_p54_freq,			"Intel Pentium P54"
-    },
-    {
-	CPUID_TYPE_OEM,		CPUID_FAMILY_PPRO,	CPUID_MODEL_PII,
-	480,	cpuid_pii_freq,			"Intel Pentium II"
-    }
-};
-unsigned int cpuid_intel_size = sizeof (cpuid_intel) / sizeof (cpuid_intel[0]);
+static unsigned int	cpuid_maxcpuid;
 
-/*
- * AMD product arrays
- */
-unsigned int cpuid_am486_dx_freq[] = { 33, 40, 0 };
-unsigned int cpuid_am486_dx2_freq[] = { 50, 66, 80, 99, 0 };
-unsigned int cpuid_am486_dx4_freq[] = { 99, 120, 133, 0 };
-unsigned int cpuid_am486_dx4wb_freq[] = { 99, 120, 133, 0 };
+static i386_cpu_info_t	cpuid_cpu_info;
 
-/*
- * UMC product array 
- */
-unsigned int cpuid_u5sd_freq[] = { 25, 33, 40, 0 };
-unsigned int cpuid_u5s_freq[] = { 25, 33, 40, 0 };
+uint32_t		cpuid_feature;		/* XXX obsolescent for compat */
 
 /*
- * Vendor ID array
+ * We only identify Intel CPUs here.  Adding support
+ * for others would be straightforward.
  */
-struct cpuid_name cpuid_name[] = {
-    {	CPUID_VID_INTEL,
-	cpuid_intel,	sizeof (cpuid_intel) / sizeof (cpuid_intel[0])
-    },
-    {	CPUID_VID_UMC,
-	(struct cpuid_product *)0,
-    },
-    {	CPUID_VID_AMD,
-	(struct cpuid_product *)0,
-    },
-    {	CPUID_VID_CYRIX,
-	(struct cpuid_product *)0,
-    },
-    {	CPUID_VID_NEXTGEN,
-	(struct cpuid_product *)0
-    },
-    {	"",
-	cpuid_generic,	sizeof (cpuid_generic) / sizeof (cpuid_generic[0])
-    },
-    {	(char *)0,
-    }
+static void	set_cpu_intel(i386_cpu_info_t *);
+static void	set_cpu_unknown(i386_cpu_info_t *);
+
+struct {
+	char	*vendor;
+	void	(* func)(i386_cpu_info_t *);
+} cpu_vendors[] = {
+	{CPUID_VID_INTEL,	set_cpu_intel},
+	{0,			set_cpu_unknown}
 };
 
+void
+cpuid_get_info(i386_cpu_info_t *info_p)
+{
+	uint32_t	cpuid_result[4];
+	int		i;
+
+	bzero((void *)info_p, sizeof(i386_cpu_info_t));
+
+	/* do cpuid 0 to get vendor */
+	do_cpuid(0, cpuid_result);
+	cpuid_maxcpuid = cpuid_result[0];
+	bcopy((char *)&cpuid_result[1], &info_p->cpuid_vendor[0], 4); /* ugh */
+	bcopy((char *)&cpuid_result[2], &info_p->cpuid_vendor[8], 4);
+	bcopy((char *)&cpuid_result[3], &info_p->cpuid_vendor[4], 4);
+	info_p->cpuid_vendor[12] = 0;
+
+	/* look up vendor */
+	for (i = 0; ; i++) {
+		if ((cpu_vendors[i].vendor == 0) ||
+		    (!strcmp(cpu_vendors[i].vendor, info_p->cpuid_vendor))) {
+			cpu_vendors[i].func(info_p);
+			break;
+		}
+	}
+}
+
 /*
- * Feature Flag values
+ * A useful model name string takes some decoding.
  */
-char *cpuid_flag[] = {
-    "FPU",	/* Floating point unit on-chip */
-    "VME",	/* Virtual Mode Extension */
-    "DE",	/* Debugging Extension */
-    "PSE",	/* Page Size Extension */
-    "TSC",	/* Time Stamp Counter */
-    "MSR",	/* Model Specific Registers */
-    "PAE",	/* Physical Address Extension */
-    "MCE",	/* Machine Check Exception */
-    "CX8",	/* CMPXCHG8 Instruction sSupported */
-    "APIC",	/* Local APIC Supported */
-    "(bit 10)",
-    "(bit 11)",
-    "MTRR",	/* Machine Type Range Register */
-    "PGE",	/* Page Global Enable */
-    "MCA",	/* Machine Check Architecture */
-    "CMOV",	/* Conditional Move Instruction Supported */
-    "(bit 16)",
-    "(bit 17)",
-    "(bit 18)",
-    "(bit 19)",
-    "(bit 20)",
-    "(bit 21)",
-    "(bit 22)",
-    "MMX",	/* Supports MMX instructions */
-    "(bit 24)",
-    "(bit 25)",
-    "(bit 26)",
-    "(bit 27)",
-    "(bit 28)",
-    "(bit 29)",
-    "(bit 30)",
-    "(bit 31)",
-};
+char *
+cpuid_intel_get_model_name(
+	uint8_t		brand,
+	uint8_t		family,
+	uint8_t		model,
+	uint32_t	signature)
+{
+	/* check for brand id */
+	switch(brand) {
+	    case 0:
+		/* brand ID not supported; use alternate method. */
+		switch(family) {
+		    case CPUID_FAMILY_486:
+			return "486";
+		    case CPUID_FAMILY_P5:
+			return "Pentium";
+		    case CPUID_FAMILY_PPRO:
+			switch(model) {
+			    case CPUID_MODEL_P6:
+				return "Pentium Pro";
+			    case CPUID_MODEL_PII:
+				return "Pentium II";
+			    case CPUID_MODEL_P65:
+			    case CPUID_MODEL_P66:
+				return "Celeron";
+			    case CPUID_MODEL_P67:
+			    case CPUID_MODEL_P68:
+			    case CPUID_MODEL_P6A:
+			    case CPUID_MODEL_P6B:
+				return "Pentium III";
+			    default:
+				return "Unknown P6 Family";
+			}
+		    case CPUID_FAMILY_PENTIUM4:
+			return "Pentium 4";
+		    default:
+			return "Unknown Family";
+   		}
+	    case 0x01:
+		return "Celeron";
+	    case 0x02:
+	    case 0x04:
+		return "Pentium III";
+	    case 0x03:
+		if (signature == 0x6B1)
+			return "Celeron";
+		else
+			return "Pentium III Xeon";
+	    case 0x06:
+		return "Mobile Pentium III";
+	    case 0x07:
+		return "Mobile Celeron";
+	    case 0x08:
+		if (signature >= 0xF20)
+			return "Genuine Intel";
+		else
+			return "Pentium 4";
+	    case 0x09:
+		return "Pentium 4";
+	    case 0x0b:
+		return "Xeon";
+	    case 0x0e:
+	    case 0x0f:
+		return "Mobile Pentium 4";
+	    default:
+		return "Unknown Pentium";
+	}
+}
 
 /*
- * Cache description array
+ * Cache descriptor table. Each row has the form:
+ *	   (descriptor_value,		cache,	size,		linesize,
+ * 				description)
+ * Note: the CACHE_DESC macro does not expand description text in the kernel.
  */
-struct cpuid_cache_desc cpuid_cache_desc[] = {
-    {	CPUID_CACHE_ITLB_4K,
-	"Instruction TBL, 4K, pages 4-way set associative, 64 entries"
-    },
-    {	CPUID_CACHE_ITLB_4M,
-	"Instruction TBL, 4M, pages 4-way set associative, 4 entries"
-    },
-    {	CPUID_CACHE_DTLB_4K,
-	"Data TBL, 4K pages, 4-way set associative, 64 entries"
-    },
-    {	CPUID_CACHE_DTLB_4M,
-	"Data TBL, 4M pages, 4-way set associative, 4 entries"
-    },
-    {	CPUID_CACHE_ICACHE_8K,
-	"Instruction L1 cache, 8K, 4-way set associative, 32byte line size"
-    },
-    {	CPUID_CACHE_DCACHE_8K,
-	"Data L1 cache, 8K, 2-way set associative, 32byte line size"
-    },
-    {	CPUID_CACHE_UCACHE_128K,
-	"Unified L2 cache, 128K, 4-way set associative, 32byte line size"
-    },
-    {	CPUID_CACHE_UCACHE_256K,
-	"Unified L2 cache, 256K, 4-way set associative, 32byte line size"
-    },
-    {	CPUID_CACHE_UCACHE_512K,
-	"Unified L2 cache, 512K, 4-way set associative, 32byte line size"
-    },
-    {	CPUID_CACHE_NULL,
-	(char *)0
-    }
+static cpuid_cache_desc_t cpuid_cache_desc_tab[] = {
+CACHE_DESC(CPUID_CACHE_ITLB_4K, 	Lnone,	0,		0, \
+	"Instruction TLB, 4K, pages 4-way set associative, 64 entries"),
+CACHE_DESC(CPUID_CACHE_ITLB_4M, 	Lnone,	0,		0, \
+	"Instruction TLB, 4M, pages 4-way set associative, 4 entries"),
+CACHE_DESC(CPUID_CACHE_DTLB_4K, 	Lnone,	0,		0, \
+	"Data TLB, 4K pages, 4-way set associative, 64 entries"),
+CACHE_DESC(CPUID_CACHE_DTLB_4M, 	Lnone,	0,		0, \
+	"Data TLB, 4M pages, 4-way set associative, 4 entries"),
+CACHE_DESC(CPUID_CACHE_ITLB_64, 	Lnone,	0,		0, \
+	"Instruction TLB, 4K and 2M or 4M pages, 64 entries"),
+CACHE_DESC(CPUID_CACHE_ITLB_128, 	Lnone,	0,		0, \
+	"Instruction TLB, 4K and 2M or 4M pages, 128 entries"),
+CACHE_DESC(CPUID_CACHE_ITLB_256, 	Lnone,	0,		0, \
+	"Instruction TLB, 4K and 2M or 4M pages, 256 entries"),
+CACHE_DESC(CPUID_CACHE_DTLB_64,		Lnone,	0,		0, \
+	"Data TLB, 4K and 4M pages, 64 entries"),
+CACHE_DESC(CPUID_CACHE_DTLB_128,	Lnone,	0,		0, \
+	"Data TLB, 4K and 4M pages, 128 entries"),
+CACHE_DESC(CPUID_CACHE_DTLB_256,	Lnone,	0,		0, \
+	"Data TLB, 4K and 4M pages, 256 entries"),
+CACHE_DESC(CPUID_CACHE_ICACHE_8K,	L1I,	8*1024, 	32, \
+	"Instruction L1 cache, 8K, 4-way set associative, 32byte line size"),
+CACHE_DESC(CPUID_CACHE_DCACHE_8K,	L1D,	8*1024, 	32, \
+	"Data L1 cache, 8K, 2-way set associative, 32byte line size"),
+CACHE_DESC(CPUID_CACHE_ICACHE_16K,	L1I,	16*1024,	 32, \
+	"Instruction L1 cache, 16K, 4-way set associative, 32byte line size"),
+CACHE_DESC(CPUID_CACHE_DCACHE_16K,	L1D,	16*1024, 	32, \
+	"Data L1 cache, 16K, 4-way set associative, 32byte line size"),
+CACHE_DESC(CPUID_CACHE_DCACHE_8K_64,	L1D,	8*1024,		64, \
+	"Data L1 cache, 8K, 4-way set associative, 64byte line size"),
+CACHE_DESC(CPUID_CACHE_DCACHE_16K_64,	L1D,	16*1024,	64, \
+	"Data L1 cache, 16K, 4-way set associative, 64byte line size"),
+CACHE_DESC(CPUID_CACHE_DCACHE_32K_64,	L1D,	32*1024,	64, \
+	"Data L1 cache, 32K, 4-way set associative, 64byte line size"),
+CACHE_DESC(CPUID_CACHE_TRACE_12K,	L1I,	12*1024,	64, \
+	"Trace cache, 12K-uop, 8-way set associative"),
+CACHE_DESC(CPUID_CACHE_TRACE_12K,	L1I,	16*1024,	64, \
+	"Trace cache, 16K-uop, 8-way set associative"),
+CACHE_DESC(CPUID_CACHE_TRACE_12K,	L1I,	32*1024,	64, \
+	"Trace cache, 32K-uop, 8-way set associative"),
+CACHE_DESC(CPUID_CACHE_UCACHE_128K,	L2U,	128*1024,	32, \
+	"Unified L2 cache, 128K, 4-way set associative, 32byte line size"),
+CACHE_DESC(CPUID_CACHE_UCACHE_256K,	L2U,	128*1024,	32, \
+	"Unified L2 cache, 256K, 4-way set associative, 32byte line size"),
+CACHE_DESC(CPUID_CACHE_UCACHE_512K,	L2U,	512*1024,	32, \
+	"Unified L2 cache, 512K, 4-way set associative, 32byte line size"),
+CACHE_DESC(CPUID_CACHE_UCACHE_1M,	L2U,	1*1024*1024,	32, \
+	"Unified L2 cache, 1M, 4-way set associative, 32byte line size"),
+CACHE_DESC(CPUID_CACHE_UCACHE_2M,	L2U,	2*1024*1024,	32, \
+	"Unified L2 cache, 2M, 4-way set associative, 32byte line size"),
+CACHE_DESC(CPUID_CACHE_UCACHE_128K_64,	L2U,	128*1024,	64, \
+	"Unified L2 cache, 128K, 8-way set associative, 64byte line size"),
+CACHE_DESC(CPUID_CACHE_UCACHE_256K_64,	L2U,	256*1024,	64, \
+	"Unified L2 cache, 256K, 8-way set associative, 64byte line size"),
+CACHE_DESC(CPUID_CACHE_UCACHE_512K_64,	L2U,	512*1024,	64, \
+	"Unified L2 cache, 512K, 8-way set associative, 64byte line size"),
+CACHE_DESC(CPUID_CACHE_UCACHE_1M_64,	L2U,	1*1024*1024,	64, \
+	"Unified L2 cache, 1M, 8-way set associative, 64byte line size"),
+CACHE_DESC(CPUID_CACHE_UCACHE_256K_32,	L2U,	256*1024,	32, \
+	"Unified L2 cache, 256K, 8-way set associative, 32byte line size"),
+CACHE_DESC(CPUID_CACHE_UCACHE_512K_32,	L2U,	512*1024,	32, \
+	"Unified L2 cache, 512K, 8-way set associative, 32byte line size"),
+CACHE_DESC(CPUID_CACHE_UCACHE_1M_32,	L2U,	1*1024*1024,	32, \
+	"Unified L2 cache, 1M, 8-way set associative, 32byte line size"),
+CACHE_DESC(CPUID_CACHE_UCACHE_2M_32,	L2U,	2*1024*1024,	32, \
+	"Unified L2 cache, 2M, 8-way set associative, 32byte line size"),
+CACHE_DESC(CPUID_CACHE_NULL, Lnone, 0, 0, \
+	(char *)0),
 };
+
+static void
+set_cpu_intel(i386_cpu_info_t *info_p)
+{
+	uint32_t	cpuid_result[4];
+	uint32_t	max_extid;
+        char            str[128], *p;
+	char		*model;
+	int		i;
+	int		j;
+
+	/* get extended cpuid results */
+	do_cpuid(0x80000000, cpuid_result);
+	max_extid = cpuid_result[0];
+
+	/* check to see if we can get brand string */
+	if (max_extid > 0x80000000) {
+		/*
+		 * The brand string 48 bytes (max), guaranteed to
+		 * be NUL terminated.
+		 */
+		do_cpuid(0x80000002, cpuid_result);
+		bcopy((char *)cpuid_result, &str[0], 16);
+		do_cpuid(0x80000003, cpuid_result);
+		bcopy((char *)cpuid_result, &str[16], 16);
+		do_cpuid(0x80000004, cpuid_result);
+		bcopy((char *)cpuid_result, &str[32], 16);
+		for (p = str; *p != '\0'; p++) {
+			if (*p != ' ') break;
+		}
+		strncpy(info_p->cpuid_brand_string,
+			p, sizeof(info_p->cpuid_brand_string)-1);
+		info_p->cpuid_brand_string[sizeof(info_p->cpuid_brand_string)-1] = '\0';
+	}
     
-/*
- * CPU identification
- */
-unsigned int	cpuid_value;
-unsigned char	cpuid_type;
-unsigned char	cpuid_family;
-unsigned char	cpuid_model;
-unsigned char	cpuid_stepping;
-unsigned int	cpuid_feature;
-char		cpuid_vid[CPUID_VID_SIZE + 1];
-unsigned char	cpuid_cache[CPUID_CACHE_SIZE];
+	/* get processor signature and decode */
+	do_cpuid(1, cpuid_result);
+	info_p->cpuid_signature =  cpuid_result[0];
+	info_p->cpuid_stepping  =  cpuid_result[0]        & 0x0f;
+	info_p->cpuid_model     = (cpuid_result[0] >> 4)  & 0x0f;
+	info_p->cpuid_family    = (cpuid_result[0] >> 8)  & 0x0f;
+        info_p->cpuid_type      = (cpuid_result[0] >> 12) & 0x03;
+	info_p->cpuid_extmodel  = (cpuid_result[0] >> 16) & 0x0f;
+	info_p->cpuid_extfamily = (cpuid_result[0] >> 20) & 0xff;
+	info_p->cpuid_brand     =  cpuid_result[1]        & 0xff;
+	info_p->cpuid_features  =  cpuid_result[3];
 
-/*
- * Return correct CPU_TYPE
- */
-/*ARGSUSED*/
-cpu_type_t
-cpuid_cputype(
-    int my_cpu)
+	/* decode family/model/type */
+	switch (info_p->cpuid_type) {
+	    case CPUID_TYPE_OVERDRIVE:
+		strcat(info_p->model_string, "Overdrive ");
+		break;
+	    case CPUID_TYPE_DUAL:
+		strcat(info_p->model_string, "Dual ");
+		break;
+	}
+	strcat(info_p->model_string,
+	       cpuid_intel_get_model_name(info_p->cpuid_brand,
+					  info_p->cpuid_family,
+					  info_p->cpuid_model,
+					  info_p->cpuid_signature));
+	info_p->model_string[sizeof(info_p->model_string)-1] = '\0';
+
+	/* get processor cache descriptor info */
+	do_cpuid(2, cpuid_result);
+	for (j = 0; j < 4; j++) {
+		if ((cpuid_result[j] >> 31) == 1) 	/* bit31 is validity */
+			continue;
+		((uint32_t *) info_p->cache_info)[j] = cpuid_result[j];
+	}
+	/* first byte gives number of cpuid calls to get all descriptors */
+	for (i = 1; i < info_p->cache_info[0]; i++) {
+		if (i*16 > sizeof(info_p->cache_info))
+			break;
+		do_cpuid(2, cpuid_result);
+		for (j = 0; j < 4; j++) {
+			if ((cpuid_result[j] >> 31) == 1) 
+				continue;
+			((uint32_t *) info_p->cache_info)[4*i+j] =
+				cpuid_result[j];
+		}
+	}
+
+	/* decode the descriptors looking for L1/L2/L3 size info */
+	for (i = 1; i < sizeof(info_p->cache_info); i++) {
+		cpuid_cache_desc_t	*descp;
+		uint8_t			desc = info_p->cache_info[i];
+
+		if (desc == CPUID_CACHE_NULL)
+			continue;
+		for (descp = cpuid_cache_desc_tab;
+			descp->value != CPUID_CACHE_NULL; descp++) {
+			if (descp->value != desc)
+				continue;
+			info_p->cache_size[descp->type] = descp->size;
+			if (descp->type == L2U)
+				info_p->cache_linesize = descp->linesize;
+			break;
+		}
+	}
+	/* For P-IIIs, L2 could be 256k or 512k but we can't tell */ 
+	if (info_p->cache_size[L2U] == 0 &&
+	    info_p->cpuid_family == 0x6 && info_p->cpuid_model == 0xb) {
+		info_p->cache_size[L2U] = 256*1024;
+		info_p->cache_linesize = 32;
+	}
+
+	return;
+}
+
+static void
+set_cpu_unknown(i386_cpu_info_t *info_p)
 {
-#ifndef MACH_BSD	/* FIXME  - add more family/chip types */
-    switch (cpuid_family) {
-    case CPUID_FAMILY_PPRO:
-	return (CPU_TYPE_PENTIUMPRO);
-    case CPUID_FAMILY_P5:
-	return (CPU_TYPE_PENTIUM);
-    case CPUID_FAMILY_486:
-	return (CPU_TYPE_I486);
-    default:
-	break;
-    }
-#endif
-    return (CPU_TYPE_I386);
+	strcat(info_p->model_string, "Unknown");
+}
+
+
+static struct {
+	uint32_t	mask;
+	char		*name;
+} feature_names[] = {
+	{CPUID_FEATURE_FPU,   "FPU",},
+	{CPUID_FEATURE_VME,   "VME",},
+	{CPUID_FEATURE_DE,    "DE",},
+	{CPUID_FEATURE_PSE,   "PSE",},
+	{CPUID_FEATURE_TSC,   "TSC",},
+	{CPUID_FEATURE_MSR,   "MSR",},
+	{CPUID_FEATURE_PAE,   "PAE",},
+	{CPUID_FEATURE_MCE,   "MCE",},
+	{CPUID_FEATURE_CX8,   "CX8",},
+	{CPUID_FEATURE_APIC,  "APIC",},
+	{CPUID_FEATURE_SEP,   "SEP",},
+	{CPUID_FEATURE_MTRR,  "MTRR",},
+	{CPUID_FEATURE_PGE,   "PGE",},
+	{CPUID_FEATURE_MCA,   "MCA",},
+	{CPUID_FEATURE_CMOV,  "CMOV",},
+	{CPUID_FEATURE_PAT,   "PAT",},
+	{CPUID_FEATURE_PSE36, "PSE36",},
+	{CPUID_FEATURE_PSN,   "PSN",},
+	{CPUID_FEATURE_CLFSH, "CLFSH",},
+	{CPUID_FEATURE_DS,    "DS",},
+	{CPUID_FEATURE_ACPI,  "ACPI",},
+	{CPUID_FEATURE_MMX,   "MMX",},
+	{CPUID_FEATURE_FXSR,  "FXSR",},
+	{CPUID_FEATURE_SSE,   "SSE",},
+	{CPUID_FEATURE_SSE2,  "SSE2",},
+	{CPUID_FEATURE_SS,    "SS",},
+	{CPUID_FEATURE_HTT,   "HTT",},
+	{CPUID_FEATURE_TM,    "TM",},
+	{0, 0}
+};
+
+char *
+cpuid_get_feature_names(uint32_t feature, char *buf, unsigned buf_len)
+{
+	int	i;
+	int	len;
+	char	*p = buf;
+
+	for (i = 0; feature_names[i].mask != 0; i++) {
+		if ((feature & feature_names[i].mask) == 0)
+			continue;
+		if (i > 0)
+			*p++ = ' ';
+		len = min(strlen(feature_names[i].name), (buf_len-1) - (p-buf));
+		if (len == 0)
+			break;
+		bcopy(feature_names[i].name, p, len);
+		p += len;
+	}
+	*p = '\0';
+	return buf;
+}
+
+void
+cpuid_feature_display(
+	char	*header,
+	int	my_cpu)
+{
+	char	buf[256];
+
+	printf("%s: %s\n", header,
+		  cpuid_get_feature_names(cpuid_features(), buf, sizeof(buf)));
 }
 
-/*
- * Display processor signature
- */
-/*ARGSUSED*/
 void
 cpuid_cpu_display(
-    char *header,
-    int my_cpu)
+	char	*header,
+	int	my_cpu)
 {
-    struct cpuid_name *name;
-    unsigned int i;
-    unsigned int *freq;
-    unsigned int mhz;
-    unsigned int feature;
-    char **flag;
-    extern unsigned int delaycount;
-
-    /*
-     * Identify vendor ID
-     */
-    for (name = cpuid_name; name->name != (char *)0; name++) {
-	char *p = name->name;
-	char *q = cpuid_vid;
-	while (*p == *q && *p != 0) {
-	    p++;
-	    q++;
-	}
-	if (*p == '\0' && *q == '\0')
-	    break;
-    }
-    if (name->name == (char *)0) {
-	printf("Unrecognized processor vendor id = '%s'\n", cpuid_vid);
-	return;
-    }
-
-    /*
-     * Identify Product ID
-     */
-    for (i = 0; i < name->size; i++)
-	if (name->product[i].type == cpuid_type &&
-	    name->product[i].family == cpuid_family &&
-	    name->product[i].model == cpuid_model)
-	    break;
-    if (i == name->size) {
-	printf("%s processor (type = 0x%x, family = 0x%x, model = 0x%x)\n",
-	       "Unrecognized", cpuid_type, cpuid_family, cpuid_model);
-	return;
-    }
-
-    /*
-     * Look for frequency and adjust it to known values
-     */
-    mhz = (1000 * delaycount) / name->product[i].delay;
-    for (freq = name->product[i].frequency; *freq != 0; freq++)
-	if (*freq >= mhz)
-	    break;
-    if (*freq == 0)
-	mhz = *(freq - 1);
-    else if (freq == name->product[i].frequency)
-	mhz = *freq;
-    else if (*freq - mhz > mhz - *(freq - 1))
-	mhz = *(freq - 1);
-    else if (*freq != mhz)
-	mhz = *freq;
-
-    /*
-     * Display product and frequency
-     */
-    printf("%s: %s at %d MHz (signature = %d/%d/%d/%d)\n",
-	   header, name->product[i].name, mhz, cpuid_type,
-	   cpuid_family, cpuid_model, cpuid_stepping);
-
-    /*
-     * Display feature (if any)
-     */
-    if (cpuid_feature) {
-	i = 0;
-	flag = cpuid_flag;
-	for (feature = cpuid_feature; feature != 0; feature >>= 1) {
-	    if (feature & 1)
-		if (i == 0) {
-		    printf("%s: %s", header, *flag);
-		    i = 1;
-		} else 
-		    printf(", %s", *flag);
-	    flag++;
-	}
-	printf("\n");
-    }
+	printf("%s: %s\n", header,
+		(cpuid_cpu_info.cpuid_brand_string[0] != '\0') ?
+			cpuid_cpu_info.cpuid_brand_string :
+			cpuid_cpu_info.model_string);
 }
 
-/*
- * Display processor configuration information
- */
-/*ARGSUSED*/
+unsigned int
+cpuid_family(void)
+{
+	return cpuid_cpu_info.cpuid_family;
+}
+
+unsigned int
+cpuid_features(void)
+{
+	return cpuid_cpu_info.cpuid_features;
+}
+
+i386_cpu_info_t	*
+cpuid_info(void)
+{
+	return &cpuid_cpu_info;
+}
+
+/* XXX for temporary compatibility */
 void
-cpuid_cache_display(
-    char *header,
-    int my_cpu)
+set_cpu_model(void)
 {
-    struct cpuid_cache_desc *desc;
-    unsigned int i;
-
-    if (cpuid_cache[CPUID_CACHE_VALID] == 1)
-	for (i = 0; i < CPUID_CACHE_SIZE; i++) {
-	    if (i != CPUID_CACHE_VALID || cpuid_cache[i] == CPUID_CACHE_NULL)
-		continue;
-	    for (desc = cpuid_cache_desc;
-		 desc->description != (char *)0; desc++)
-		if (desc->value == cpuid_cache[i])
-		    break;
-	    if (desc->description != (char *)0)
-		printf("%s: %s\n", header, desc->description);
-	}
+	cpuid_get_info(&cpuid_cpu_info);
+	cpuid_feature = cpuid_cpu_info.cpuid_features;	/* XXX compat */
 }
+
diff --git a/osfmk/i386/cpuid.h b/osfmk/i386/cpuid.h
index a500c8d02..c8fad3ffb 100644
--- a/osfmk/i386/cpuid.h
+++ b/osfmk/i386/cpuid.h
@@ -1,21 +1,24 @@
 /*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -26,12 +29,15 @@
 /*
  * x86 CPU identification
  *
- * TODO : Add TI/Thomson processors
  */
 
 #ifndef _MACHINE_CPUID_H_
 #define _MACHINE_CPUID_H_
 
+#include <sys/appleapiopts.h>
+
+#ifdef __APPLE_API_PRIVATE
+
 #define	CPUID_VID_SIZE		12
 #define	CPUID_VID_INTEL		"GenuineIntel"
 #define	CPUID_VID_UMC		"UMC UMC UMC "
@@ -41,17 +47,32 @@
 
 #define	CPUID_FEATURE_FPU    0x00000001	/* Floating point unit on-chip */
 #define	CPUID_FEATURE_VME    0x00000002	/* Virtual Mode Extension */
-#define	CPUID_FEATURE_IOB    0x00000004	/* I/O Breakpoints */
+#define	CPUID_FEATURE_DE     0x00000004	/* Debugging Extension */
 #define	CPUID_FEATURE_PSE    0x00000008	/* Page Size Extension */
 #define	CPUID_FEATURE_TSC    0x00000010	/* Time Stamp Counter */
 #define	CPUID_FEATURE_MSR    0x00000020	/* Model Specific Registers */
+#define CPUID_FEATURE_PAE    0x00000040 /* Physical Address Extension */
 #define	CPUID_FEATURE_MCE    0x00000080	/* Machine Check Exception */
 #define	CPUID_FEATURE_CX8    0x00000100	/* CMPXCHG8B */
 #define	CPUID_FEATURE_APIC   0x00000200	/* On-chip APIC */
+#define CPUID_FEATURE_SEP    0x00000800 /* Fast System Call */
 #define	CPUID_FEATURE_MTRR   0x00001000	/* Memory Type Range Register */
 #define	CPUID_FEATURE_PGE    0x00002000	/* Page Global Enable */
 #define	CPUID_FEATURE_MCA    0x00004000	/* Machine Check Architecture */
 #define	CPUID_FEATURE_CMOV   0x00008000	/* Conditional Move Instruction */
+#define CPUID_FEATURE_PAT    0x00010000 /* Page Attribute Table */
+#define CPUID_FEATURE_PSE36  0x00020000 /* 36-bit Page Size Extension */
+#define CPUID_FEATURE_PSN    0x00040000 /* Processor Serial Number */
+#define CPUID_FEATURE_CLFSH  0x00080000 /* CLFLUSH Instruction supported */
+#define CPUID_FEATURE_DS     0x00200000 /* Debug Store */
+#define CPUID_FEATURE_ACPI   0x00400000 /* Thermal Monitor, SW-controlled clock */
+#define CPUID_FEATURE_MMX    0x00800000 /* MMX supported */
+#define CPUID_FEATURE_FXSR   0x01000000 /* Fast floating point save/restore */
+#define CPUID_FEATURE_SSE    0x02000000 /* Streaming SIMD extensions */
+#define CPUID_FEATURE_SSE2   0x04000000 /* Streaming SIMD extensions 2 */
+#define CPUID_FEATURE_SS     0x08000000 /* Self-Snoop */
+#define CPUID_FEATURE_HTT    0x10000000 /* Hyper-Threading Technology */
+#define CPUID_FEATURE_TM     0x20000000 /* Thermal Monitor */
 
 #define	CPUID_TYPE_OEM		    0x0	/* Original processor */
 #define	CPUID_TYPE_OVERDRIVE	    0x1	/* Overdrive processor */
@@ -61,7 +82,8 @@
 #define	CPUID_FAMILY_386	    0x3	/* Intel 386 (not part of CPUID) */
 #define	CPUID_FAMILY_486	    0x4	/* Intel 486 */
 #define	CPUID_FAMILY_P5		    0x5	/* Intel Pentium */
-#define	CPUID_FAMILY_PPRO	    0x6	/* Intel Pentium Pro */
+#define	CPUID_FAMILY_PPRO	    0x6	/* Intel Pentium Pro, II, III */
+#define CPUID_FAMILY_PENTIUM4       0xF /* Intel Pentium 4 */
 
 #define	CPUID_MODEL_I386_DX	    0x0	/* Intel 386 (not part of CPUID) */
 
@@ -97,9 +119,14 @@
 
 #define	CPUID_MODEL_P6		    0x1	/* Intel P6 */
 #define	CPUID_MODEL_PII		    0x3	/* Intel PII */
+#define CPUID_MODEL_P65             0x5 /* Intel PII/Xeon/Celeron model 5 */
+#define CPUID_MODEL_P66             0x6 /* Intel Celeron model 6 */
+#define CPUID_MODEL_P67             0x7 /* Intel PIII/Xeon model 7 */
+#define CPUID_MODEL_P68             0x8 /* Intel PIII/Xeon/Celeron model 8 */
+#define CPUID_MODEL_P6A             0xA /* Intel PIII Xeon model A */
+#define CPUID_MODEL_P6B             0xB /* Intel PIII model B */
 
 #define	CPUID_CACHE_SIZE	16	/* Number of descriptor vales */
-#define	CPUID_CACHE_VALID	 4	/* Index of descriptor validity */
 
 #define	CPUID_CACHE_NULL	   0x00	/* NULL */
 #define	CPUID_CACHE_ITLB_4K	   0x01	/* Instruction TLB, 4K pages */
@@ -107,58 +134,119 @@
 #define	CPUID_CACHE_DTLB_4K	   0x03	/* Data TLB, 4K pages */
 #define	CPUID_CACHE_DTLB_4M	   0x04	/* Data TLB, 4M pages */
 #define	CPUID_CACHE_ICACHE_8K	   0x06	/* Instruction cache, 8K */
+#define	CPUID_CACHE_ICACHE_16K	   0x08	/* Instruction cache, 16K */
 #define	CPUID_CACHE_DCACHE_8K	   0x0A	/* Data cache, 8K */
-#define	CPUID_CACHE_UCACHE_128K	   0x41	/* Unified cache, 128K */
-#define	CPUID_CACHE_UCACHE_256K	   0x42	/* Unified cache, 256K */
-#define	CPUID_CACHE_UCACHE_512K	   0x43	/* Unified cache, 512K */
+#define	CPUID_CACHE_DCACHE_16K	   0x0C	/* Data cache, 16K */
+#define	CPUID_CACHE_UCACHE_128K	   0x41	/* 2nd-level cache, 128K */
+#define	CPUID_CACHE_UCACHE_256K	   0x42	/* 2nd-level cache, 256K */
+#define	CPUID_CACHE_UCACHE_512K	   0x43	/* 2nd-level cache, 512K */
+#define	CPUID_CACHE_UCACHE_1M	   0x44	/* 2nd-level cache, 1M */
+#define	CPUID_CACHE_UCACHE_2M	   0x45	/* 2nd-level cache, 2M */
+#define CPUID_CACHE_ITLB_64        0x50 /* Instruction TLB, 64 entries */
+#define CPUID_CACHE_ITLB_128       0x51 /* Instruction TLB, 128 entries */
+#define CPUID_CACHE_ITLB_256       0x52 /* Instruction TLB, 256 entries */
+#define CPUID_CACHE_DTLB_64        0x5B /* Data TLB, 64 entries */
+#define CPUID_CACHE_DTLB_128       0x5C /* Data TLB, 128 entries */
+#define CPUID_CACHE_DTLB_256       0x5D /* Data TLB, 256 entries */
+#define	CPUID_CACHE_DCACHE_8K_64   0x66	/* Data cache, 8K, 64 byte line size */
+#define	CPUID_CACHE_DCACHE_16K_64  0x67 /* Data cache, 16K, 64 byte line size */
+#define	CPUID_CACHE_DCACHE_32K_64  0x68 /* Data cache, 32K, 64 byte line size */
+#define CPUID_CACHE_TRACE_12K      0x70 /* Trace cache 12K-uop, 8-way */
+#define CPUID_CACHE_TRACE_16K      0x71 /* Trace cache 16K-uop, 8-way */
+#define CPUID_CACHE_TRACE_32K      0x72 /* Trace cache 32K-uop, 8-way */
+#define	CPUID_CACHE_UCACHE_128K_64 0x79 /* 2nd-level, 128K, 8-way, 64 bytes */
+#define	CPUID_CACHE_UCACHE_256K_64 0x7A /* 2nd-level, 256K, 8-way, 64 bytes */
+#define	CPUID_CACHE_UCACHE_512K_64 0x7B /* 2nd-level, 512K, 8-way, 64 bytes */
+#define	CPUID_CACHE_UCACHE_1M_64   0x7C /* 2nd-level, 1M, 8-way, 64 bytes */
+#define CPUID_CACHE_UCACHE_256K_32 0x82 /* 2nd-level, 256K, 8-way, 32 bytes */
+#define CPUID_CACHE_UCACHE_512K_32 0x83 /* 2nd-level, 512K, 8-way, 32 bytes */
+#define CPUID_CACHE_UCACHE_1M_32   0x84 /* 2nd-level, 1M, 8-way, 32 bytes */
+#define CPUID_CACHE_UCACHE_2M_32   0x85 /* 2nd-level, 2M, 8-way, 32 bytes */
 
 #ifndef ASSEMBLER
+#include <stdint.h>
+#include <mach/mach_types.h>
+#include <kern/kern_types.h>
 #include <mach/machine.h>
 
-extern unsigned int	cpuid_value;
-extern unsigned char	cpuid_type;
-extern unsigned char	cpuid_family;
-extern unsigned char	cpuid_model;
-extern unsigned char	cpuid_stepping;
-extern unsigned int	cpuid_feature;
-extern char		cpuid_vid[];
-extern unsigned char	cpuid_cache[];
 
-/*
- * Product ID arrays per vendor
- */
-struct cpuid_product {
-    unsigned char		type;		/* CPU type */
-    unsigned char		family;		/* CPU family */
-    unsigned char		model;		/* CPU model */
-    unsigned int		delay;		/* 1MHz Delay (scale 1000) */
-    unsigned int		*frequency;	/* Frequency array */
-    char			*name;		/* Model name */
-};
+static inline void
+do_cpuid(uint32_t selector, uint32_t *data)
+{
+	asm("cpuid"
+		: "=a" (data[0]),
+		  "=b" (data[1]),
+		  "=c" (data[2]),
+		  "=d" (data[3])
+		: "a"(selector));
+}
 
 /*
- * Vendor ID structure
+ * Cache ID descriptor structure.
+ * Note: description string absent in kernel.
  */
-struct cpuid_name {
-    char			*name;		/* Vendor ID name */
-    struct cpuid_product	*product;	/* product array */
-    unsigned int		size;		/* #elements in product array */
-};
+typedef enum { Lnone, L1I, L1D, L2U, LCACHE_MAX } cache_type_t ; 
+typedef struct {
+	unsigned char	value;          /* Descriptor value */
+	cache_type_t 	type;           /* Cache type */
+	unsigned int 	size;           /* Cache size */
+	unsigned int 	linesize;       /* Cache line size */
+#ifdef KERNEL
+	char         	*description;   /* Cache description */
+#endif /* KERNEL */
+} cpuid_cache_desc_t;  
+
+#ifdef KERNEL
+#define CACHE_DESC(value,type,size,linesize,text) \
+	{ value, type, size, linesize, text }
+#else
+#define CACHE_DESC(value,type,size,linesize,text) \
+	{ value, type, size, linesize }
+#endif /* KERNEL */
+
+/* Physical CPU info */
+typedef struct {
+	char		cpuid_vendor[16];
+	char		cpuid_brand_string[48];
+
+	uint32_t	cpuid_value;
+	cpu_type_t	cpuid_type;
+	uint8_t		cpuid_family;
+	uint8_t		cpuid_model;
+	uint8_t		cpuid_extmodel;
+	uint8_t		cpuid_extfamily;
+	uint8_t		cpuid_stepping;
+	uint32_t	cpuid_features;
+	uint32_t	cpuid_signature;
+	uint8_t   	cpuid_brand; 
+	
+	uint32_t	cache_size[LCACHE_MAX];
+	uint32_t	cache_linesize;
+
+	char            model_string[64];  /* sanitized model string */
+	uint8_t		cache_info[64];    /* list of cache descriptors */
+
+} i386_cpu_info_t;
 
-/*
- * Cache ID description structure
- */
-struct cpuid_cache_desc {
-    unsigned char		value;		/* Descriptor value */
-    char			*description;	/* Cache description */
-};
 
 /*
  * External declarations
  */
 extern cpu_type_t	cpuid_cputype(int);
 extern void		cpuid_cpu_display(char *, int);
-extern void		cpuid_cache_display(char *, int);
+extern void		cpuid_features_display(char *, int);
+extern char *		cpuid_get_feature_names(uint32_t, char *, unsigned);
+
+extern uint32_t		cpuid_features(void);
+extern uint32_t		cpuid_family(void);
+
+extern char *		cpuid_intel_get_model_name(uint8_t, uint8_t,
+						   uint8_t, uint32_t);
 
+extern i386_cpu_info_t	*cpuid_info(void);
+
+extern uint32_t		cpuid_feature;	/* XXX obsolescent */
 #endif /* ASSEMBLER */
+
+#endif /* __APPLE_API_PRIVATE */
 #endif /* _MACHINE_CPUID_H_ */
diff --git a/osfmk/i386/cswitch.s b/osfmk/i386/cswitch.s
index dd8254390..5f7b715a6 100644
--- a/osfmk/i386/cswitch.s
+++ b/osfmk/i386/cswitch.s
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/db_disasm.c b/osfmk/i386/db_disasm.c
index 67e73801f..c99127502 100644
--- a/osfmk/i386/db_disasm.c
+++ b/osfmk/i386/db_disasm.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/db_gcc_aout.c b/osfmk/i386/db_gcc_aout.c
index 15fd0003d..a6744c240 100644
--- a/osfmk/i386/db_gcc_aout.c
+++ b/osfmk/i386/db_gcc_aout.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/db_interface.c b/osfmk/i386/db_interface.c
index bd3a52369..f79971f27 100644
--- a/osfmk/i386/db_interface.c
+++ b/osfmk/i386/db_interface.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/db_machdep.h b/osfmk/i386/db_machdep.h
index 09acd12c9..9a6292451 100644
--- a/osfmk/i386/db_machdep.h
+++ b/osfmk/i386/db_machdep.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/db_trace.c b/osfmk/i386/db_trace.c
index 41349103f..3d21d6f38 100644
--- a/osfmk/i386/db_trace.c
+++ b/osfmk/i386/db_trace.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/eflags.h b/osfmk/i386/eflags.h
index bb5d56d4a..e1496e6c9 100644
--- a/osfmk/i386/eflags.h
+++ b/osfmk/i386/eflags.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/endian.h b/osfmk/i386/endian.h
index 55de05e4d..0f802c36a 100644
--- a/osfmk/i386/endian.h
+++ b/osfmk/i386/endian.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/exec.h b/osfmk/i386/exec.h
index 72526d180..f63add90b 100644
--- a/osfmk/i386/exec.h
+++ b/osfmk/i386/exec.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/flipc_page.h b/osfmk/i386/flipc_page.h
index 542c8a446..aac088fad 100644
--- a/osfmk/i386/flipc_page.h
+++ b/osfmk/i386/flipc_page.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/fpu.c b/osfmk/i386/fpu.c
index 0bce98884..34bf4752a 100644
--- a/osfmk/i386/fpu.c
+++ b/osfmk/i386/fpu.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/fpu.h b/osfmk/i386/fpu.h
index 2b1f9acd7..85ff1b94e 100644
--- a/osfmk/i386/fpu.h
+++ b/osfmk/i386/fpu.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/gcc.s b/osfmk/i386/gcc.s
index 6537364ce..705fb33b3 100644
--- a/osfmk/i386/gcc.s
+++ b/osfmk/i386/gcc.s
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/gdb_defs.h b/osfmk/i386/gdb_defs.h
index c8942d570..0eacdf01b 100644
--- a/osfmk/i386/gdb_defs.h
+++ b/osfmk/i386/gdb_defs.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/gdt.c b/osfmk/i386/gdt.c
index 8d9f57b57..8677ba1e1 100644
--- a/osfmk/i386/gdt.c
+++ b/osfmk/i386/gdt.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/genassym.c b/osfmk/i386/genassym.c
index 302dbe497..f84ee345a 100644
--- a/osfmk/i386/genassym.c
+++ b/osfmk/i386/genassym.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/hardclock.c b/osfmk/i386/hardclock.c
index 31121460f..ebdd3c1ee 100644
--- a/osfmk/i386/hardclock.c
+++ b/osfmk/i386/hardclock.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/hardclock_entries.h b/osfmk/i386/hardclock_entries.h
index 80001989d..ea87802ed 100644
--- a/osfmk/i386/hardclock_entries.h
+++ b/osfmk/i386/hardclock_entries.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/hi_res_clock.h b/osfmk/i386/hi_res_clock.h
index f9c006310..4a1f6f7c6 100644
--- a/osfmk/i386/hi_res_clock.h
+++ b/osfmk/i386/hi_res_clock.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/hi_res_clock_map.c b/osfmk/i386/hi_res_clock_map.c
index 66ca626ff..293c5bb69 100644
--- a/osfmk/i386/hi_res_clock_map.c
+++ b/osfmk/i386/hi_res_clock_map.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/hw_lock_types.h b/osfmk/i386/hw_lock_types.h
index 57ba52cbc..1ec07fb80 100644
--- a/osfmk/i386/hw_lock_types.h
+++ b/osfmk/i386/hw_lock_types.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/i386_lock.s b/osfmk/i386/i386_lock.s
index 5e6acea43..ed2710ccc 100644
--- a/osfmk/i386/i386_lock.s
+++ b/osfmk/i386/i386_lock.s
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/idt.s b/osfmk/i386/idt.s
index e68a8f4fd..03a3535a1 100644
--- a/osfmk/i386/idt.s
+++ b/osfmk/i386/idt.s
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/intel_read_fault.h b/osfmk/i386/intel_read_fault.h
index fbecc7966..d23b32b75 100644
--- a/osfmk/i386/intel_read_fault.h
+++ b/osfmk/i386/intel_read_fault.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/io_emulate.c b/osfmk/i386/io_emulate.c
index 0c955e130..f381088c7 100644
--- a/osfmk/i386/io_emulate.c
+++ b/osfmk/i386/io_emulate.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/io_emulate.h b/osfmk/i386/io_emulate.h
index 239fd081c..4a61a5160 100644
--- a/osfmk/i386/io_emulate.h
+++ b/osfmk/i386/io_emulate.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/io_map.c b/osfmk/i386/io_map.c
index b83e3eb02..9b7c83132 100644
--- a/osfmk/i386/io_map.c
+++ b/osfmk/i386/io_map.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/io_map_entries.h b/osfmk/i386/io_map_entries.h
index 2335e4db3..62673c047 100644
--- a/osfmk/i386/io_map_entries.h
+++ b/osfmk/i386/io_map_entries.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/io_port.h b/osfmk/i386/io_port.h
index 4d0684917..537b12d45 100644
--- a/osfmk/i386/io_port.h
+++ b/osfmk/i386/io_port.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/iopb.c b/osfmk/i386/iopb.c
index ec00e33f2..02e6f0543 100644
--- a/osfmk/i386/iopb.c
+++ b/osfmk/i386/iopb.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/iopb.h b/osfmk/i386/iopb.h
index bd9705115..a202605af 100644
--- a/osfmk/i386/iopb.h
+++ b/osfmk/i386/iopb.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/iopb_entries.h b/osfmk/i386/iopb_entries.h
index 8b50a7eb2..e62cb0eed 100644
--- a/osfmk/i386/iopb_entries.h
+++ b/osfmk/i386/iopb_entries.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/ipl.h b/osfmk/i386/ipl.h
index db59db5d1..532ba8131 100644
--- a/osfmk/i386/ipl.h
+++ b/osfmk/i386/ipl.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/ktss.c b/osfmk/i386/ktss.c
index 23a39df8f..b2236f355 100644
--- a/osfmk/i386/ktss.c
+++ b/osfmk/i386/ktss.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/ldt.c b/osfmk/i386/ldt.c
index 824610f9b..50429cb92 100644
--- a/osfmk/i386/ldt.c
+++ b/osfmk/i386/ldt.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/lock.h b/osfmk/i386/lock.h
index 2f623c68c..3abc1ea93 100644
--- a/osfmk/i386/lock.h
+++ b/osfmk/i386/lock.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/locore.s b/osfmk/i386/locore.s
index 547a233b6..f0a0a08d8 100644
--- a/osfmk/i386/locore.s
+++ b/osfmk/i386/locore.s
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -2773,79 +2776,6 @@ ENTRY(dr_addr)
 	.long	0,0,0,0
 	.text
 
-/*
- * Determine cpu model and set global cpuid_xxx variables
- *
- * Relies on 386 eflags bit 18 (AC) always being zero & 486 preserving it.
- * Relies on 486 eflags bit 21 (ID) always being zero & 586 preserving it.
- * Relies on CPUID instruction for next x86 generations
- * (assumes cpuid-family-homogenous MPs; else convert to per-cpu array)
- */
-
-ENTRY(set_cpu_model)
-	FRAME
-	pushl	%ebx			/* save ebx */
-	andl	$~0x3,%esp		/* Align stack to avoid AC fault */
-	pushfl				/* push EFLAGS */
-	popl	%eax			/* pop into eax */
-	movl	%eax,%ecx		/* Save original EFLAGS */
-	xorl	$(EFL_AC+EFL_ID),%eax	/* toggle ID,AC bits */
-	pushl	%eax			/* push new value */
-	popfl				/* through the EFLAGS register */
-	pushfl				/* and back */
-	popl	%eax			/* into eax */
-	movb	$(CPUID_FAMILY_386),EXT(cpuid_family)
-	pushl	%ecx			/* push original EFLAGS */
-	popfl				/* restore EFLAGS */
-	xorl	%ecx,%eax		/* see what changed */
-	testl	$ EFL_AC,%eax		/* test AC bit */
-	jz	0f			/* if AC toggled (486 or higher) */
-	
-	movb	$(CPUID_FAMILY_486),EXT(cpuid_family)
-	testl	$ EFL_ID,%eax		/* test ID bit */
-	jz	0f			/* if ID toggled use cpuid instruction */
-	
-	xorl	%eax,%eax		/* get vendor identification string */
-	.word	0xA20F			/* cpuid instruction */
-	movl	%eax,EXT(cpuid_value)	/* Store high value */ 
-	movl	%ebx,EXT(cpuid_vid)	/* Store byte 0-3 of Vendor ID */
-	movl	%edx,EXT(cpuid_vid)+4	/* Store byte 4-7 of Vendor ID */
-	movl	%ecx,EXT(cpuid_vid)+8	/* Store byte 8-B of Vendor ID */
-	movl	$1,%eax			/* get processor signature */
-	.word	0xA20F			/* cpuid instruction */
-	movl	%edx,EXT(cpuid_feature)	/* Store feature flags */
-	movl	%eax,%ecx		/* Save original signature */
-	andb	$0xF,%al		/* Get Stepping ID */
-	movb	%al,EXT(cpuid_stepping)	/* Save Stepping ID */
-	movl	%ecx,%eax		/* Get original signature */
-	shrl	$4,%eax			/* Shift Stepping ID */
-	movl	%eax,%ecx		/* Save original signature */
-	andb	$0xF,%al		/* Get Model */
-	movb	%al,EXT(cpuid_model)	/* Save Model */
-	movl	%ecx,%eax		/* Get original signature */
-	shrl	$4,%eax			/* Shift Stepping ID */
-	movl	%eax,%ecx		/* Save original signature */
-	andb	$0xF,%al		/* Get Family */
-	movb	%al,EXT(cpuid_family)	/* Save Family */
-	movl	%ecx,%eax		/* Get original signature */
-	shrl	$4,%eax			/* Shift Stepping ID */
-	andb	$0x3,%al		/* Get Type */
-	movb	%al,EXT(cpuid_type)	/* Save Type */
-
-	movl	EXT(cpuid_value),%eax	/* Get high value */
-	cmpl	$2,%eax			/* Test if processor configuration */
-	jle	0f			/* is present */
-	movl	$2,%eax			/* get processor configuration */
-	.word	0xA20F			/* cpuid instruction */
-	movl	%eax,EXT(cpuid_cache)	/* Store byte 0-3 of configuration */
-	movl	%ebx,EXT(cpuid_cache)+4	/* Store byte 4-7 of configuration */
-	movl	%ecx,EXT(cpuid_cache)+8	/* Store byte 8-B of configuration */
-	movl	%edx,EXT(cpuid_cache)+12 /* Store byte C-F of configuration */
-0:
-	popl	%ebx			/* restore ebx */
-	EMARF
-	ret				/* return */
-
 ENTRY(get_cr0)
 	movl	%cr0, %eax
 	ret
diff --git a/osfmk/i386/loose_ends.c b/osfmk/i386/loose_ends.c
index b0cd27fff..48bbed0e4 100644
--- a/osfmk/i386/loose_ends.c
+++ b/osfmk/i386/loose_ends.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -303,3 +306,40 @@ void machine_callstack(
 }
 
 #endif	/* MACH_ASSERT */
+
+
+
+
+/* FIXMEx86 */
+/* These all need to be implemented somewhere */
+
+void fillPage(ppnum_t pa, unsigned int fill)
+{
+}
+
+uint64_t max_mem;
+uint64_t sane_size;
+
+#include <vm/pmap.h>
+
+ppnum_t pmap_find_phys(pmap_t pmap, addr64_t va)
+{
+  return 0;
+}
+
+kern_return_t copypv(addr64_t source, addr64_t sink, unsigned int size, int which)
+{
+  return KERN_SUCCESS;
+}
+
+void mapping_set_mod(ppnum_t pa)
+{
+}
+
+void flush_dcache64(addr64_t addr, unsigned count, int phys)
+{
+}
+
+void invalidate_icache64(addr64_t addr, unsigned cnt, int phys)
+{
+}
diff --git a/osfmk/i386/mach_param.h b/osfmk/i386/mach_param.h
index 7b2a7e7ce..95cbb59fa 100644
--- a/osfmk/i386/mach_param.h
+++ b/osfmk/i386/mach_param.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/machdep_call.c b/osfmk/i386/machdep_call.c
index b340b6fad..2b141f2d1 100644
--- a/osfmk/i386/machdep_call.c
+++ b/osfmk/i386/machdep_call.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/machdep_call.h b/osfmk/i386/machdep_call.h
index beeb51304..fbc3b4188 100644
--- a/osfmk/i386/machdep_call.h
+++ b/osfmk/i386/machdep_call.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/machine_routines.c b/osfmk/i386/machine_routines.c
index eb2558169..0e358d657 100644
--- a/osfmk/i386/machine_routines.c
+++ b/osfmk/i386/machine_routines.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -133,6 +136,28 @@ machine_signal_idle(
 {
 }
 
+void
+ml_cpu_get_info(ml_cpu_info_t *cpu_info)
+{
+}
+
+void
+ml_init_max_cpus(unsigned long max_cpus)
+{
+}
+
+int
+ml_get_max_cpus(void)
+{
+	return(machine_info.max_cpus);
+}
+
+int
+ml_get_current_cpus(void)
+{
+ 	return machine_info.avail_cpus;
+}
+
 /* Stubs for pc tracing mechanism */
 
 int *pc_trace_buf;
diff --git a/osfmk/i386/machine_routines.h b/osfmk/i386/machine_routines.h
index 4908a08f5..97038c555 100644
--- a/osfmk/i386/machine_routines.h
+++ b/osfmk/i386/machine_routines.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -73,6 +76,70 @@ vm_offset_t
 ml_static_ptovirt(
 	vm_offset_t);
 
+/* PCI config cycle probing */
+boolean_t ml_probe_read(
+	vm_offset_t paddr,
+	unsigned int *val);
+boolean_t ml_probe_read_64(
+	addr64_t paddr,
+	unsigned int *val);
+
+/* Read physical address byte */
+unsigned int ml_phys_read_byte(
+	vm_offset_t paddr);
+unsigned int ml_phys_read_byte_64(
+	addr64_t paddr);
+
+/* Read physical address half word */
+unsigned int ml_phys_read_half(
+	vm_offset_t paddr);
+unsigned int ml_phys_read_half_64(
+	addr64_t paddr);
+
+/* Read physical address word*/
+unsigned int ml_phys_read(
+	vm_offset_t paddr);
+unsigned int ml_phys_read_64(
+	addr64_t paddr);
+unsigned int ml_phys_read_word(
+	vm_offset_t paddr);
+unsigned int ml_phys_read_word_64(
+	addr64_t paddr);
+
+/* Read physical address double word */
+unsigned long long ml_phys_read_double(
+	vm_offset_t paddr);
+unsigned long long ml_phys_read_double_64(
+	addr64_t paddr);
+
+/* Write physical address byte */
+void ml_phys_write_byte(
+	vm_offset_t paddr, unsigned int data);
+void ml_phys_write_byte_64(
+	addr64_t paddr, unsigned int data);
+
+/* Write physical address half word */
+void ml_phys_write_half(
+	vm_offset_t paddr, unsigned int data);
+void ml_phys_write_half_64(
+	addr64_t paddr, unsigned int data);
+
+/* Write physical address word */
+void ml_phys_write(
+	vm_offset_t paddr, unsigned int data);
+void ml_phys_write_64(
+	addr64_t paddr, unsigned int data);
+void ml_phys_write_word(
+	vm_offset_t paddr, unsigned int data);
+void ml_phys_write_word_64(
+	addr64_t paddr, unsigned int data);
+
+/* Write physical address double word */
+void ml_phys_write_double(
+	vm_offset_t paddr, unsigned long long data);
+void ml_phys_write_double_64(
+	addr64_t paddr, unsigned long long data);
+
 void ml_static_mfree(
 	vm_offset_t,
 	vm_size_t);
@@ -81,6 +148,23 @@ void ml_static_mfree(
 vm_offset_t ml_vtophys(
 	vm_offset_t vaddr);
 
+/* Struct for ml_cpu_get_info */
+struct ml_cpu_info {
+	unsigned long		vector_unit;
+	unsigned long		cache_line_size;
+	unsigned long		l1_icache_size;
+	unsigned long		l1_dcache_size;
+	unsigned long		l2_settings;
+	unsigned long		l2_cache_size;
+	unsigned long		l3_settings;
+	unsigned long		l3_cache_size;
+};
+
+typedef struct ml_cpu_info ml_cpu_info_t;
+
+/* Get processor info */
+void ml_cpu_get_info(ml_cpu_info_t *cpu_info);
+
 #endif /* __APPLE_API_UNSTABLE */
 
 #ifdef __APPLE_API_PRIVATE
@@ -99,8 +183,6 @@ vm_offset_t ml_static_malloc(
 #endif /* PEXPERT_KERNEL_PRIVATE || MACH_KERNEL_PRIVATE  */
 
 #ifdef  MACH_KERNEL_PRIVATE 
-/* check pending timers */
-#define machine_clock_assist()
 
 void machine_idle(void);
 
@@ -118,6 +200,18 @@ void ml_thread_policy(
 #define MACHINE_NETWORK_WORKLOOP		0x00000001
 #define MACHINE_NETWORK_NETISR			0x00000002
 
+/* Initialize the maximum number of CPUs */
+void ml_init_max_cpus(
+	unsigned long max_cpus);
+
+/* Return the maximum number of CPUs set by ml_init_max_cpus() */
+int ml_get_max_cpus(
+	void);
+
+/* Return the current number of CPUs */
+int ml_get_current_cpus(
+	void);
+
 #endif /* __APPLE_API_PRIVATE */
 
 #endif /* _I386_MACHINE_ROUTINES_H_ */
diff --git a/osfmk/i386/machine_routines_asm.s b/osfmk/i386/machine_routines_asm.s
index 2c5162fd3..2c7d9bae2 100644
--- a/osfmk/i386/machine_routines_asm.s
+++ b/osfmk/i386/machine_routines_asm.s
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -39,3 +42,254 @@ ENTRY(ml_get_timebase)
         movl    %eax, 4(%ecx)
 
         ret
+
+
+/* PCI config cycle probing
+ *
+ *      boolean_t ml_probe_read(vm_offset_t paddr, unsigned int *val)
+ *
+ *      Read the memory location at physical address paddr.
+ *  This is a part of a device probe, so there is a good chance we will
+ *  have a machine check here. So we have to be able to handle that.
+ *  We assume that machine checks are enabled both in MSR and HIDs
+ */
+ENTRY(ml_probe_read)
+
+        movl S_ARG0, %ecx
+        movl S_ARG1, %eax
+        movl 0(%ecx), %ecx
+        movl %ecx, 0(%eax)
+        movl $1, %eax
+
+        ret
+
+
+/* PCI config cycle probing - 64-bit
+ *
+ *      boolean_t ml_probe_read_64(addr64_t paddr, unsigned int *val)
+ *
+ *      Read the memory location at physical address paddr.
+ *  This is a part of a device probe, so there is a good chance we will
+ *  have a machine check here. So we have to be able to handle that.
+ *  We assume that machine checks are enabled both in MSR and HIDs
+ */
+ENTRY(ml_probe_read_64)
+
+        /* Only use lower 32 bits of address for now */
+        movl S_ARG0, %ecx
+        movl S_ARG2, %eax
+        movl 0(%ecx), %ecx
+        movl %ecx, 0(%eax)
+        movl $1, %eax
+
+        ret
+
+
+/* Read physical address byte
+ *
+ *      unsigned int ml_phys_read_byte(vm_offset_t paddr)
+ *      unsigned int ml_phys_read_byte_64(addr64_t paddr)
+ *
+ *      Read the byte at physical address paddr. Memory should not be cache inhibited.
+ */
+ENTRY(ml_phys_read_byte_64)
+
+        /* Only use lower 32 bits of address for now */
+        movl S_ARG0, %ecx
+        xor %eax, %eax
+        movb 0(%ecx), %eax
+
+	ret
+
+ENTRY(ml_phys_read_byte)
+
+        movl S_ARG0, %ecx
+        xor %eax, %eax
+        movb 0(%ecx), %eax
+
+	ret
+
+
+/* Read physical address half word
+ *
+ *      unsigned int ml_phys_read_half(vm_offset_t paddr)
+ *      unsigned int ml_phys_read_half_64(addr64_t paddr)
+ *
+ *      Read the half word at physical address paddr. Memory should not be cache inhibited.
+ */
+ENTRY(ml_phys_read_half_64)
+
+        /* Only use lower 32 bits of address for now */
+        movl S_ARG0, %ecx
+        xor %eax, %eax
+        movw 0(%ecx), %eax
+
+	ret
+
+ENTRY(ml_phys_read_half)
+
+        movl S_ARG0, %ecx
+        xor %eax, %eax
+        movw 0(%ecx), %eax
+
+	ret
+
+
+/* Read physical address word
+ *
+ *      unsigned int ml_phys_read(vm_offset_t paddr)
+ *      unsigned int ml_phys_read_64(addr64_t paddr)
+ *      unsigned int ml_phys_read_word(vm_offset_t paddr)
+ *      unsigned int ml_phys_read_word_64(addr64_t paddr)
+ *
+ *      Read the word at physical address paddr. Memory should not be cache inhibited.
+ */
+ENTRY(ml_phys_read_64)
+ENTRY(ml_phys_read_word_64)
+
+        /* Only use lower 32 bits of address for now */
+        movl S_ARG0, %ecx
+        movl 0(%ecx), %eax
+
+	ret
+
+ENTRY(ml_phys_read)
+ENTRY(ml_phys_read_word)
+
+        movl S_ARG0, %ecx
+        movl 0(%ecx), %eax
+
+	ret
+
+
+/* Read physical address double
+ *
+ *      unsigned long long ml_phys_read_double(vm_offset_t paddr)
+ *      unsigned long long ml_phys_read_double_64(addr64_t paddr)
+ *
+ *      Read the double word at physical address paddr. Memory should not be cache inhibited.
+ */
+ENTRY(ml_phys_read_double_64)
+
+        /* Only use lower 32 bits of address for now */
+        movl S_ARG0, %ecx
+        movl 0(%ecx), %eax
+        movl 4(%ecx), %edx
+
+	ret
+
+ENTRY(ml_phys_read_double)
+
+        movl S_ARG0, %ecx
+        movl 0(%ecx), %eax
+        movl 4(%ecx), %edx
+
+	ret
+
+
+/* Write physical address byte
+ *
+ *      void ml_phys_write_byte(vm_offset_t paddr, unsigned int data)
+ *      void ml_phys_write_byte_64(addr64_t paddr, unsigned int data)
+ *
+ *      Write the byte at physical address paddr. Memory should not be cache inhibited.
+ */
+ENTRY(ml_phys_write_byte_64)
+
+        /* Only use lower 32 bits of address for now */
+        movl S_ARG0, %ecx
+        movl S_ARG2, %eax
+        movb %eax, 0(%ecx)
+
+	ret
+
+ENTRY(ml_phys_write_byte)
+
+        movl S_ARG0, %ecx
+        movl S_ARG1, %eax
+        movb %eax, 0(%ecx)
+
+	ret
+
+
+/* Write physical address half word
+ *
+ *      void ml_phys_write_half(vm_offset_t paddr, unsigned int data)
+ *      void ml_phys_write_half_64(addr64_t paddr, unsigned int data)
+ *
+ *      Write the byte at physical address paddr. Memory should not be cache inhibited.
+ */
+ENTRY(ml_phys_write_half_64)
+
+        /* Only use lower 32 bits of address for now */
+        movl S_ARG0, %ecx
+        movl S_ARG2, %eax
+        movw %eax, 0(%ecx)
+
+	ret
+
+ENTRY(ml_phys_write_half)
+
+        movl S_ARG0, %ecx
+        movl S_ARG1, %eax
+        movw %eax, 0(%ecx)
+
+	ret
+
+
+/* Write physical address word
+ *
+ *      void ml_phys_write(vm_offset_t paddr, unsigned int data)
+ *      void ml_phys_write_64(addr64_t paddr, unsigned int data)
+ *      void ml_phys_write_word(vm_offset_t paddr, unsigned int data)
+ *      void ml_phys_write_word_64(addr64_t paddr, unsigned int data)
+ *
+ *      Write the word at physical address paddr. Memory should not be cache inhibited.
+ */
+ENTRY(ml_phys_write_64)
+ENTRY(ml_phys_write_word_64)
+
+        /* Only use lower 32 bits of address for now */
+        movl S_ARG0, %ecx
+        movl S_ARG2, %eax
+        movl %eax, 0(%ecx)
+
+	ret
+
+ENTRY(ml_phys_write)
+ENTRY(ml_phys_write_word)
+
+        movl S_ARG0, %ecx
+        movl S_ARG1, %eax
+        movl %eax, 0(%ecx)
+
+	ret
+
+
+/* Write physical address double word
+ *
+ *      void ml_phys_write_double(vm_offset_t paddr, unsigned long long data)
+ *      void ml_phys_write_double_64(addr64_t paddr, unsigned long long data)
+ *
+ *      Write the double word at physical address paddr. Memory should not be cache inhibited.
+ */
+ENTRY(ml_phys_write_double_64)
+
+        /* Only use lower 32 bits of address for now */
+        movl S_ARG0, %ecx
+        movl S_ARG2, %eax
+        movl %eax, 0(%ecx)
+        movl S_ARG3, %eax
+        movl %eax, 4(%ecx)
+
+	ret
+
+ENTRY(ml_phys_write_double)
+
+        movl S_ARG0, %ecx
+        movl S_ARG1, %eax
+        movl %eax, 0(%ecx)
+        movl S_ARG2, %eax
+        movl %eax, 4(%ecx)
+
+	ret
diff --git a/osfmk/i386/machine_rpc.h b/osfmk/i386/machine_rpc.h
index b444de089..5f3bbfe56 100644
--- a/osfmk/i386/machine_rpc.h
+++ b/osfmk/i386/machine_rpc.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/machlimits.h b/osfmk/i386/machlimits.h
index 5aefbace2..140318878 100644
--- a/osfmk/i386/machlimits.h
+++ b/osfmk/i386/machlimits.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/machparam.h b/osfmk/i386/machparam.h
index 34e24e808..d61055f83 100644
--- a/osfmk/i386/machparam.h
+++ b/osfmk/i386/machparam.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/misc_protos.h b/osfmk/i386/misc_protos.h
index d869fc2d6..7b9caa113 100644
--- a/osfmk/i386/misc_protos.h
+++ b/osfmk/i386/misc_protos.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/mp_desc.c b/osfmk/i386/mp_desc.c
index dcab9ae43..29b6aeb26 100644
--- a/osfmk/i386/mp_desc.c
+++ b/osfmk/i386/mp_desc.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/mp_desc.h b/osfmk/i386/mp_desc.h
index 9882f2ae3..29f2f26b9 100644
--- a/osfmk/i386/mp_desc.h
+++ b/osfmk/i386/mp_desc.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/net_filter.c b/osfmk/i386/net_filter.c
index cda06b521..71d7d45a5 100644
--- a/osfmk/i386/net_filter.c
+++ b/osfmk/i386/net_filter.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/ntoh.h b/osfmk/i386/ntoh.h
index 2f9e26ce2..199d22f74 100644
--- a/osfmk/i386/ntoh.h
+++ b/osfmk/i386/ntoh.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/ntoh.s b/osfmk/i386/ntoh.s
index 47868223d..908e1b5be 100644
--- a/osfmk/i386/ntoh.s
+++ b/osfmk/i386/ntoh.s
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/pcb.c b/osfmk/i386/pcb.c
index c261f4214..195018542 100644
--- a/osfmk/i386/pcb.c
+++ b/osfmk/i386/pcb.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/phys.c b/osfmk/i386/phys.c
index f5060f2b9..62ccfe5da 100644
--- a/osfmk/i386/phys.c
+++ b/osfmk/i386/phys.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/pic.h b/osfmk/i386/pic.h
index 1c9311a52..acb3178c2 100644
--- a/osfmk/i386/pic.h
+++ b/osfmk/i386/pic.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/pio.h b/osfmk/i386/pio.h
index 309714aaf..14a4b5506 100644
--- a/osfmk/i386/pio.h
+++ b/osfmk/i386/pio.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/pit.h b/osfmk/i386/pit.h
index ab14da5c1..c82c26f26 100644
--- a/osfmk/i386/pit.h
+++ b/osfmk/i386/pit.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/pmap.c b/osfmk/i386/pmap.c
index a3e6bfa4e..cb6396a9c 100644
--- a/osfmk/i386/pmap.c
+++ b/osfmk/i386/pmap.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -252,6 +255,7 @@ char	*pmap_phys_attributes;
  */
 #define	PHYS_MODIFIED	INTEL_PTE_MOD	/* page modified */
 #define	PHYS_REFERENCED	INTEL_PTE_REF	/* page referenced */
+#define PHYS_NCACHE	INTEL_PTE_NCACHE
 
 /*
  *	Amount of virtual memory mapped by one
@@ -791,6 +795,19 @@ pmap_bootstrap(
 
 	kernel_pmap->pdirbase = kvtophys((vm_offset_t)kernel_pmap->dirbase);
 
+	if (cpuid_features() & CPUID_FEATURE_PAT)
+	{
+		uint64_t pat;
+		uint32_t msr;
+	    
+		msr = 0x277;
+		asm volatile("rdmsr" : "=A" (pat) : "c" (msr));
+	    
+		pat &= ~(0xfULL << 48);
+		pat |= 0x01ULL << 48;
+	    
+		asm volatile("wrmsr" :: "A" (pat), "c" (msr));
+	}
 }
 
 void
@@ -1284,11 +1301,13 @@ pmap_remove_some_phys(
  *	rounded to the hardware page size.
  */
 
+
+/* FIXMEx86 */
 void
 pmap_remove(
 	pmap_t		map,
-	vm_offset_t	s,
-	vm_offset_t	e)
+	addr64_t	s,
+	addr64_t	e)
 {
 	spl_t			spl;
 	register pt_entry_t	*pde;
@@ -1665,8 +1684,15 @@ Retry:
 	    /*
 	     *	May be changing its wired attribute or protection
 	     */
-		
+	
 	    template = pa_to_pte(pa) | INTEL_PTE_VALID;
+
+	    if(flags & VM_MEM_NOT_CACHEABLE) {
+		if(!(flags & VM_MEM_GUARDED))
+			template |= INTEL_PTE_PTA;
+		template |= INTEL_PTE_NCACHE;
+	    }
+
 	    if (pmap != kernel_pmap)
 		template |= INTEL_PTE_USER;
 	    if (prot & VM_PROT_WRITE)
@@ -1985,6 +2011,13 @@ RetryPvList:
 	 *	only the pfn changes.
 	 */
 	template = pa_to_pte(pa) | INTEL_PTE_VALID;
+
+	if(flags & VM_MEM_NOT_CACHEABLE) {
+		if(!(flags & VM_MEM_GUARDED))
+			template |= INTEL_PTE_PTA;
+		template |= INTEL_PTE_NCACHE;
+	}
+
 	if (pmap != kernel_pmap)
 		template |= INTEL_PTE_USER;
 	if (prot & VM_PROT_WRITE)
@@ -2140,7 +2173,7 @@ pmap_expand(
 	 *	Map the page to its physical address so that it
 	 *	can be found later.
 	 */
-	pa = m->phys_addr;
+	pa = m->phys_page;
 	vm_object_lock(pmap_object);
 	vm_page_insert(m, pmap_object, pa);
 	vm_page_lock_queues();
@@ -2212,6 +2245,22 @@ pmap_copy(
 }
 #endif/* 	0 */
 
+/*
+ * pmap_sync_caches_phys(ppnum_t pa)
+ * 
+ * Invalidates all of the instruction cache on a physical page and
+ * pushes any dirty data from the data cache for the same physical page
+ */
+ 
+void pmap_sync_caches_phys(ppnum_t pa)
+{
+	if (!(cpuid_features() & CPUID_FEATURE_SS))
+	{
+		__asm__ volatile("wbinvd");	
+	}
+	return;
+}
+
 int	collect_ref;
 int	collect_unref;
 
diff --git a/osfmk/i386/pmap.h b/osfmk/i386/pmap.h
index 0517c243c..a33be7898 100644
--- a/osfmk/i386/pmap.h
+++ b/osfmk/i386/pmap.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -106,7 +109,14 @@ typedef unsigned int	pt_entry_t;
 #define PTEMASK		0x3ff	/* mask for page table index */
 
 
+#define	VM_WIMG_COPYBACK	VM_MEM_COHERENT
 #define	VM_WIMG_DEFAULT		VM_MEM_COHERENT
+/* ?? intel ?? */
+#define VM_WIMG_IO		(VM_MEM_COHERENT | 	\
+				VM_MEM_NOT_CACHEABLE | VM_MEM_GUARDED)
+#define VM_WIMG_WTHRU		(VM_MEM_WRITE_THROUGH | VM_MEM_COHERENT | VM_MEM_GUARDED)
+/* write combining mode, aka store gather */
+#define VM_WIMG_WCOMB		(VM_MEM_NOT_CACHEABLE | VM_MEM_COHERENT) 
 
 /*
  *	Convert kernel virtual address to linear address
@@ -148,6 +158,7 @@ typedef unsigned int	pt_entry_t;
 #define INTEL_PTE_MOD		0x00000040
 #define INTEL_PTE_WIRED		0x00000200
 #define INTEL_PTE_PFN		0xfffff000
+#define INTEL_PTE_PTA		0x00000080
 
 #define	pa_to_pte(a)		((a) & INTEL_PTE_PFN)
 #define	pte_to_pa(p)		((p) & INTEL_PTE_PFN)
@@ -524,8 +535,6 @@ extern void flush_dcache(vm_offset_t addr, unsigned count, int phys);
 					(KERN_INVALID_ADDRESS)
 #define	pmap_attribute_cache_sync(addr,size,attr,value) \
 					(KERN_INVALID_ADDRESS)
-#define pmap_sync_caches_phys(pa) \
-					(KERN_INVALID_ADDRESS)
 
 #endif	/* ASSEMBLER */
 
diff --git a/osfmk/i386/proc_reg.h b/osfmk/i386/proc_reg.h
index ef752ca61..74d9d50eb 100644
--- a/osfmk/i386/proc_reg.h
+++ b/osfmk/i386/proc_reg.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/read_fault.c b/osfmk/i386/read_fault.c
index 1af4a97f2..17adc5879 100644
--- a/osfmk/i386/read_fault.c
+++ b/osfmk/i386/read_fault.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/rtclock.c b/osfmk/i386/rtclock.c
index 3a995311d..43ab1f3be 100644
--- a/osfmk/i386/rtclock.c
+++ b/osfmk/i386/rtclock.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/rtclock_entries.h b/osfmk/i386/rtclock_entries.h
index 151882afe..04a2cb5a3 100644
--- a/osfmk/i386/rtclock_entries.h
+++ b/osfmk/i386/rtclock_entries.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/sched_param.h b/osfmk/i386/sched_param.h
index 7aecc1b1f..2873b0345 100644
--- a/osfmk/i386/sched_param.h
+++ b/osfmk/i386/sched_param.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/seg.h b/osfmk/i386/seg.h
index 21c63306a..3afe55d5d 100644
--- a/osfmk/i386/seg.h
+++ b/osfmk/i386/seg.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/setjmp.h b/osfmk/i386/setjmp.h
index 0f98cd323..114358680 100644
--- a/osfmk/i386/setjmp.h
+++ b/osfmk/i386/setjmp.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/setjmp.s b/osfmk/i386/setjmp.s
index 5c8af20b3..ddc518f3d 100644
--- a/osfmk/i386/setjmp.s
+++ b/osfmk/i386/setjmp.s
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/stab.h b/osfmk/i386/stab.h
index 897f79e2c..26b4c34d4 100644
--- a/osfmk/i386/stab.h
+++ b/osfmk/i386/stab.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/start.s b/osfmk/i386/start.s
index 41347ee88..7618127ab 100644
--- a/osfmk/i386/start.s
+++ b/osfmk/i386/start.s
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/task.h b/osfmk/i386/task.h
index 931b12a2a..2fc46b452 100644
--- a/osfmk/i386/task.h
+++ b/osfmk/i386/task.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/thread.h b/osfmk/i386/thread.h
index 0aa894348..99bcca4a0 100644
--- a/osfmk/i386/thread.h
+++ b/osfmk/i386/thread.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/thread_act.h b/osfmk/i386/thread_act.h
index ffe762201..20f8b7ed9 100644
--- a/osfmk/i386/thread_act.h
+++ b/osfmk/i386/thread_act.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/timer.h b/osfmk/i386/timer.h
index 713bb946a..63b82cc9a 100644
--- a/osfmk/i386/timer.h
+++ b/osfmk/i386/timer.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/trap.c b/osfmk/i386/trap.c
index 5a6b78c20..29ead88d9 100644
--- a/osfmk/i386/trap.c
+++ b/osfmk/i386/trap.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/trap.h b/osfmk/i386/trap.h
index 1b90618f3..8b2cc1389 100644
--- a/osfmk/i386/trap.h
+++ b/osfmk/i386/trap.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/tss.h b/osfmk/i386/tss.h
index 21604bcd3..92e5de876 100644
--- a/osfmk/i386/tss.h
+++ b/osfmk/i386/tss.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/user_ldt.c b/osfmk/i386/user_ldt.c
index 5e27532e7..5074e296b 100644
--- a/osfmk/i386/user_ldt.c
+++ b/osfmk/i386/user_ldt.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/user_ldt.h b/osfmk/i386/user_ldt.h
index 77768c912..03e6882ac 100644
--- a/osfmk/i386/user_ldt.h
+++ b/osfmk/i386/user_ldt.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/vm_tuning.h b/osfmk/i386/vm_tuning.h
index ba65481ba..33885a5fd 100644
--- a/osfmk/i386/vm_tuning.h
+++ b/osfmk/i386/vm_tuning.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/i386/xpr.h b/osfmk/i386/xpr.h
index 85b2cbd13..0a8071dea 100644
--- a/osfmk/i386/xpr.h
+++ b/osfmk/i386/xpr.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ipc/ipc_entry.c b/osfmk/ipc/ipc_entry.c
index 9d48e93f9..3eab9631c 100644
--- a/osfmk/ipc/ipc_entry.c
+++ b/osfmk/ipc/ipc_entry.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ipc/ipc_entry.h b/osfmk/ipc/ipc_entry.h
index 57e393c6e..daf5ee4fb 100644
--- a/osfmk/ipc/ipc_entry.h
+++ b/osfmk/ipc/ipc_entry.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ipc/ipc_hash.c b/osfmk/ipc/ipc_hash.c
index 844501695..0c45f2441 100644
--- a/osfmk/ipc/ipc_hash.c
+++ b/osfmk/ipc/ipc_hash.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ipc/ipc_hash.h b/osfmk/ipc/ipc_hash.h
index 2b864e5fc..5e88611d8 100644
--- a/osfmk/ipc/ipc_hash.h
+++ b/osfmk/ipc/ipc_hash.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ipc/ipc_init.c b/osfmk/ipc/ipc_init.c
index a32e5c24a..7545baf93 100644
--- a/osfmk/ipc/ipc_init.c
+++ b/osfmk/ipc/ipc_init.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ipc/ipc_init.h b/osfmk/ipc/ipc_init.h
index dbe2831f2..0faf4bcbb 100644
--- a/osfmk/ipc/ipc_init.h
+++ b/osfmk/ipc/ipc_init.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ipc/ipc_kmsg.c b/osfmk/ipc/ipc_kmsg.c
index 58a914593..34ecc07d6 100644
--- a/osfmk/ipc/ipc_kmsg.c
+++ b/osfmk/ipc/ipc_kmsg.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -88,6 +91,12 @@
 
 #include <string.h>
 
+#ifdef ppc
+#include <ppc/Firmware.h>
+#include <ppc/low_trace.h>
+#endif
+
+
 extern vm_map_t		ipc_kernel_copy_map;
 extern vm_size_t	ipc_kmsg_max_vm_space;
 extern vm_size_t	msg_ool_size_small;
@@ -679,7 +688,12 @@ ipc_kmsg_get(
 	trailer->msgh_sender = current_thread()->top_act->task->sec_token;
 	trailer->msgh_trailer_type = MACH_MSG_TRAILER_FORMAT_0;
 	trailer->msgh_trailer_size = MACH_MSG_TRAILER_MINIMUM_SIZE;
-
+	
+#ifdef ppc
+	if(trcWork.traceMask) dbgTrace((unsigned int)kmsg->ikm_header.msgh_id, 
+		(unsigned int)kmsg->ikm_header.msgh_remote_port, 
+		(unsigned int)kmsg->ikm_header.msgh_local_port, 0); 
+#endif
 	*kmsgp = kmsg;
 	return MACH_MSG_SUCCESS;
 }
@@ -1391,7 +1405,7 @@ ipc_kmsg_copyin_body(
 		      	 * Out-of-line memory descriptor, accumulate kernel
 		      	 * memory requirements
 		      	 */
-		    	space_needed += round_page(sstart->out_of_line.size);
+		    	space_needed += round_page_32(sstart->out_of_line.size);
 		    	if (space_needed > ipc_kmsg_max_vm_space) {
 
 			    	/*
@@ -1498,7 +1512,7 @@ ipc_kmsg_copyin_body(
 			 */
 			if (!page_aligned(length)) {
 				(void) memset((void *) (paddr + length), 0,
-					round_page(length) - length);
+					round_page_32(length) - length);
 			}
 			if (vm_map_copyin(ipc_kernel_copy_map, paddr, length,
 					   TRUE, &copy) != KERN_SUCCESS) {
@@ -1507,8 +1521,8 @@ ipc_kmsg_copyin_body(
 			    return MACH_MSG_VM_KERNEL;
 		        }
 			dsc->address = (void *) copy;
-			paddr += round_page(length);
-			space_needed -= round_page(length);
+			paddr += round_page_32(length);
+			space_needed -= round_page_32(length);
 		} else {
 
 			/*
diff --git a/osfmk/ipc/ipc_kmsg.h b/osfmk/ipc/ipc_kmsg.h
index dce03b573..b83857633 100644
--- a/osfmk/ipc/ipc_kmsg.h
+++ b/osfmk/ipc/ipc_kmsg.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ipc/ipc_machdep.h b/osfmk/ipc/ipc_machdep.h
index f528d8913..9cea21fe2 100644
--- a/osfmk/ipc/ipc_machdep.h
+++ b/osfmk/ipc/ipc_machdep.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ipc/ipc_mqueue.c b/osfmk/ipc/ipc_mqueue.c
index 81defb81f..d00ebe34f 100644
--- a/osfmk/ipc/ipc_mqueue.c
+++ b/osfmk/ipc/ipc_mqueue.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ipc/ipc_mqueue.h b/osfmk/ipc/ipc_mqueue.h
index 209414666..93b6fb2fa 100644
--- a/osfmk/ipc/ipc_mqueue.h
+++ b/osfmk/ipc/ipc_mqueue.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ipc/ipc_notify.c b/osfmk/ipc/ipc_notify.c
index 4b311ded0..e00829214 100644
--- a/osfmk/ipc/ipc_notify.c
+++ b/osfmk/ipc/ipc_notify.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ipc/ipc_notify.h b/osfmk/ipc/ipc_notify.h
index 8c0bc9eb1..0d4d0eea5 100644
--- a/osfmk/ipc/ipc_notify.h
+++ b/osfmk/ipc/ipc_notify.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ipc/ipc_object.c b/osfmk/ipc/ipc_object.c
index a20d572b8..df9081bef 100644
--- a/osfmk/ipc/ipc_object.c
+++ b/osfmk/ipc/ipc_object.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ipc/ipc_object.h b/osfmk/ipc/ipc_object.h
index 62a11978a..4b89b4611 100644
--- a/osfmk/ipc/ipc_object.h
+++ b/osfmk/ipc/ipc_object.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ipc/ipc_port.c b/osfmk/ipc/ipc_port.c
index 9bb7ed781..d4d49166e 100644
--- a/osfmk/ipc/ipc_port.c
+++ b/osfmk/ipc/ipc_port.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -1156,7 +1159,7 @@ ipc_port_dealloc_special(
 {
 	ip_lock(port);
 	assert(ip_active(port));
-	assert(port->ip_receiver_name != MACH_PORT_NULL);
+//	assert(port->ip_receiver_name != MACH_PORT_NULL);
 	assert(port->ip_receiver == space);
 
 	/*
diff --git a/osfmk/ipc/ipc_port.h b/osfmk/ipc/ipc_port.h
index 50bc7ed87..2cf4e699c 100644
--- a/osfmk/ipc/ipc_port.h
+++ b/osfmk/ipc/ipc_port.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ipc/ipc_print.h b/osfmk/ipc/ipc_print.h
index f35dff5fb..f0541f8cc 100644
--- a/osfmk/ipc/ipc_print.h
+++ b/osfmk/ipc/ipc_print.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ipc/ipc_pset.c b/osfmk/ipc/ipc_pset.c
index 0befd406c..06f5fd11f 100644
--- a/osfmk/ipc/ipc_pset.c
+++ b/osfmk/ipc/ipc_pset.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ipc/ipc_pset.h b/osfmk/ipc/ipc_pset.h
index e673bd8d8..66846cc77 100644
--- a/osfmk/ipc/ipc_pset.h
+++ b/osfmk/ipc/ipc_pset.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ipc/ipc_right.c b/osfmk/ipc/ipc_right.c
index b2822ebe9..3a06a1c97 100644
--- a/osfmk/ipc/ipc_right.c
+++ b/osfmk/ipc/ipc_right.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ipc/ipc_right.h b/osfmk/ipc/ipc_right.h
index 0623ba61c..06c3956ee 100644
--- a/osfmk/ipc/ipc_right.h
+++ b/osfmk/ipc/ipc_right.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ipc/ipc_space.c b/osfmk/ipc/ipc_space.c
index b51b02999..3429fe5af 100644
--- a/osfmk/ipc/ipc_space.c
+++ b/osfmk/ipc/ipc_space.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ipc/ipc_space.h b/osfmk/ipc/ipc_space.h
index 6ac534951..864edc0b3 100644
--- a/osfmk/ipc/ipc_space.h
+++ b/osfmk/ipc/ipc_space.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ipc/ipc_splay.c b/osfmk/ipc/ipc_splay.c
index ca7817be2..9d02f6ac3 100644
--- a/osfmk/ipc/ipc_splay.c
+++ b/osfmk/ipc/ipc_splay.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ipc/ipc_splay.h b/osfmk/ipc/ipc_splay.h
index a25350d5d..2f223620b 100644
--- a/osfmk/ipc/ipc_splay.h
+++ b/osfmk/ipc/ipc_splay.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ipc/ipc_table.c b/osfmk/ipc/ipc_table.c
index e8de5a125..73da0b40b 100644
--- a/osfmk/ipc/ipc_table.c
+++ b/osfmk/ipc/ipc_table.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ipc/ipc_table.h b/osfmk/ipc/ipc_table.h
index 16a02b303..d099f63cb 100644
--- a/osfmk/ipc/ipc_table.h
+++ b/osfmk/ipc/ipc_table.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -205,21 +208,21 @@ extern void ipc_table_free(
 #define	it_entries_alloc(its)						\
 	((ipc_entry_t)							\
 	ipc_table_alloc(it_entries_reallocable(its) ?			\
-	    round_page((its)->its_size * sizeof(struct ipc_entry)) :	\
+	    round_page_32((its)->its_size * sizeof(struct ipc_entry)) :	\
 	    (its)->its_size * sizeof(struct ipc_entry)			\
 	))
 
 #define	it_entries_realloc(its, table, nits)				\
 	((ipc_entry_t)							\
 	ipc_table_realloc(						\
-	    round_page((its)->its_size * sizeof(struct ipc_entry)),	\
+	    round_page_32((its)->its_size * sizeof(struct ipc_entry)),	\
 	    (vm_offset_t)(table),					\
-	    round_page((nits)->its_size * sizeof(struct ipc_entry))	\
+	    round_page_32((nits)->its_size * sizeof(struct ipc_entry))	\
 	))
 
 #define	it_entries_free(its, table)					\
 	ipc_table_free(it_entries_reallocable(its) ?			\
-	    round_page((its)->its_size * sizeof(struct ipc_entry)) :	\
+	    round_page_32((its)->its_size * sizeof(struct ipc_entry)) :	\
 	    (its)->its_size * sizeof(struct ipc_entry),			\
 	    (vm_offset_t)(table)					\
 	)
diff --git a/osfmk/ipc/ipc_types.h b/osfmk/ipc/ipc_types.h
index 935d44b9e..cdf89ede6 100644
--- a/osfmk/ipc/ipc_types.h
+++ b/osfmk/ipc/ipc_types.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ipc/mach_debug.c b/osfmk/ipc/mach_debug.c
index 7fe99ea81..ead49e1bc 100644
--- a/osfmk/ipc/mach_debug.c
+++ b/osfmk/ipc/mach_debug.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -167,7 +170,7 @@ host_ipc_hash_info(
 		if (info != *infop)
 			kmem_free(ipc_kernel_map, addr, size);
 
-		size = round_page(actual * sizeof *info);
+		size = round_page_32(actual * sizeof *info);
 		kr = kmem_alloc_pageable(ipc_kernel_map, &addr, size);
 		if (kr != KERN_SUCCESS)
 			return KERN_RESOURCE_SHORTAGE;
@@ -188,7 +191,7 @@ host_ipc_hash_info(
 		vm_map_copy_t copy;
 		vm_size_t used;
 
-		used = round_page(actual * sizeof *info);
+		used = round_page_32(actual * sizeof *info);
 
 		if (used != size)
 			kmem_free(ipc_kernel_map, addr + used, size - used);
@@ -282,7 +285,7 @@ mach_port_space_info(
 				kmem_free(ipc_kernel_map,
 					  table_addr, table_size);
 
-			table_size = round_page(table_actual *
+			table_size = round_page_32(table_actual *
 						sizeof *table_info);
 			kr = kmem_alloc(ipc_kernel_map,
 					&table_addr, table_size);
@@ -303,7 +306,7 @@ mach_port_space_info(
 				kmem_free(ipc_kernel_map,
 					  tree_addr, tree_size);
 
-			tree_size = round_page(tree_actual *
+			tree_size = round_page_32(tree_actual *
 					       sizeof *tree_info);
 			kr = kmem_alloc(ipc_kernel_map,
 					&tree_addr, tree_size);
@@ -393,7 +396,7 @@ mach_port_space_info(
 		/* kmem_alloc doesn't zero memory */
 
 		size_used = table_actual * sizeof *table_info;
-		rsize_used = round_page(size_used);
+		rsize_used = round_page_32(size_used);
 
 		if (rsize_used != table_size)
 			kmem_free(ipc_kernel_map,
@@ -431,7 +434,7 @@ mach_port_space_info(
 		/* kmem_alloc doesn't zero memory */
 
 		size_used = tree_actual * sizeof *tree_info;
-		rsize_used = round_page(size_used);
+		rsize_used = round_page_32(size_used);
 
 		if (rsize_used != tree_size)
 			kmem_free(ipc_kernel_map,
diff --git a/osfmk/ipc/mach_msg.c b/osfmk/ipc/mach_msg.c
index 2e3e11493..6036e409d 100644
--- a/osfmk/ipc/mach_msg.c
+++ b/osfmk/ipc/mach_msg.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -1045,9 +1048,9 @@ mach_msg_overwrite_trap(
 
 		assert(ip_active(dest_port));
 		assert(dest_port->ip_receiver != ipc_space_kernel);
-		assert(!imq_full(&dest_port->ip_messages) ||
-		       (MACH_MSGH_BITS_REMOTE(hdr->msgh_bits) ==
-						MACH_MSG_TYPE_PORT_SEND_ONCE));
+//		assert(!imq_full(&dest_port->ip_messages) ||
+//		       (MACH_MSGH_BITS_REMOTE(hdr->msgh_bits) ==
+//						MACH_MSG_TYPE_PORT_SEND_ONCE));
 		assert((hdr->msgh_bits & MACH_MSGH_BITS_CIRCULAR) == 0);
 
 	    {
diff --git a/osfmk/ipc/mach_port.c b/osfmk/ipc/mach_port.c
index e2a75b692..bed9efd82 100644
--- a/osfmk/ipc/mach_port.c
+++ b/osfmk/ipc/mach_port.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -237,7 +240,7 @@ mach_port_names(
 		/* upper bound on number of names in the space */
 
 		bound = space->is_table_size + space->is_tree_total;
-		size_needed = round_page(bound * sizeof(mach_port_name_t));
+		size_needed = round_page_32(bound * sizeof(mach_port_name_t));
 
 		if (size_needed <= size)
 			break;
@@ -329,7 +332,7 @@ mach_port_names(
 		vm_size_t vm_size_used;
 
 		size_used = actual * sizeof(mach_port_name_t);
-		vm_size_used = round_page(size_used);
+		vm_size_used = round_page_32(size_used);
 
 		/*
 		 *	Make used memory pageable and get it into
@@ -1125,7 +1128,7 @@ mach_port_get_set_status(
 		/* didn't have enough memory; allocate more */
 
 		kmem_free(ipc_kernel_map, addr, size);
-		size = round_page(actual * sizeof(mach_port_name_t)) + PAGE_SIZE;
+		size = round_page_32(actual * sizeof(mach_port_name_t)) + PAGE_SIZE;
 	}
 
 	if (actual == 0) {
@@ -1137,7 +1140,7 @@ mach_port_get_set_status(
 		vm_size_t vm_size_used;
 
 		size_used = actual * sizeof(mach_port_name_t);
-		vm_size_used = round_page(size_used);
+		vm_size_used = round_page_32(size_used);
 
 		/*
 		 *	Make used memory pageable and get it into
diff --git a/osfmk/ipc/mig_log.c b/osfmk/ipc/mig_log.c
index 9d9e85e55..981e207f0 100644
--- a/osfmk/ipc/mig_log.c
+++ b/osfmk/ipc/mig_log.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ipc/port.h b/osfmk/ipc/port.h
index 52ffaaf68..544f5bc90 100644
--- a/osfmk/ipc/port.h
+++ b/osfmk/ipc/port.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kdp/kdp.c b/osfmk/kdp/kdp.c
index 2c22fa44c..35e5b6105 100644
--- a/osfmk/kdp/kdp.c
+++ b/osfmk/kdp/kdp.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kdp/kdp.h b/osfmk/kdp/kdp.h
index da4991194..f24d8e67f 100644
--- a/osfmk/kdp/kdp.h
+++ b/osfmk/kdp/kdp.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kdp/kdp_en_debugger.h b/osfmk/kdp/kdp_en_debugger.h
index 6904c399d..5868307d2 100644
--- a/osfmk/kdp/kdp_en_debugger.h
+++ b/osfmk/kdp/kdp_en_debugger.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kdp/kdp_internal.h b/osfmk/kdp/kdp_internal.h
index d3d45b7e7..b9fbc8ca9 100644
--- a/osfmk/kdp/kdp_internal.h
+++ b/osfmk/kdp/kdp_internal.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kdp/kdp_private.h b/osfmk/kdp/kdp_private.h
index e9399002a..d8ea7521a 100644
--- a/osfmk/kdp/kdp_private.h
+++ b/osfmk/kdp/kdp_private.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kdp/kdp_protocol.h b/osfmk/kdp/kdp_protocol.h
index 8768c9c87..b4a0d0a87 100644
--- a/osfmk/kdp/kdp_protocol.h
+++ b/osfmk/kdp/kdp_protocol.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kdp/kdp_udp.c b/osfmk/kdp/kdp_udp.c
index 78b33b16d..5027e333f 100644
--- a/osfmk/kdp/kdp_udp.c
+++ b/osfmk/kdp/kdp_udp.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -30,8 +33,8 @@
 
 #include <mach_kdb.h>
 #include <mach/boolean.h>
-#include <mach/exception_types.h>
 #include <mach/mach_types.h>
+#include <mach/exception_types.h>
 #include <kern/cpu_data.h>
 #include <kern/debug.h>
 
diff --git a/osfmk/kdp/kdp_udp.h b/osfmk/kdp/kdp_udp.h
index ce34cde00..0dda441bd 100644
--- a/osfmk/kdp/kdp_udp.h
+++ b/osfmk/kdp/kdp_udp.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kdp/ml/i386/kdp_machdep.c b/osfmk/kdp/ml/i386/kdp_machdep.c
index b5990a653..408732427 100644
--- a/osfmk/kdp/ml/i386/kdp_machdep.c
+++ b/osfmk/kdp/ml/i386/kdp_machdep.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kdp/ml/i386/kdp_vm.c b/osfmk/kdp/ml/i386/kdp_vm.c
index c5315aea0..53783b91f 100644
--- a/osfmk/kdp/ml/i386/kdp_vm.c
+++ b/osfmk/kdp/ml/i386/kdp_vm.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kdp/ml/ppc/kdp_asm.s b/osfmk/kdp/ml/ppc/kdp_asm.s
index c01b2e5de..3cb2a0a74 100644
--- a/osfmk/kdp/ml/ppc/kdp_asm.s
+++ b/osfmk/kdp/ml/ppc/kdp_asm.s
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -38,11 +41,11 @@
 
 ENTRY(kdp_call_with_ctx, TAG_NO_FRAME_USED)
 	
-	mfmsr	r7					/* Get the MSR */
+	lis		r2,hi16(MASK(MSR_VEC))	; Get the vector enable
+	mfmsr	r7					; Get the MSR
+	ori		r2,r2,lo16(MASK(MSR_EE)|MASK(MSR_FP))	; Get FP and EE
 	mflr	r0
-	rlwinm	r7,r7,0,MSR_EE_BIT+1,MSR_EE_BIT-1	/* Turn off interruptions enable bit */
-	rlwinm	r7,r7,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-	rlwinm	r7,r7,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
+	andc	r7,r7,r2			; Clear FP, VEC, and EE
 	mtmsr	r7
 	isync										; Need this because we may have ditched fp/vec
 	mfsprg	r8,0				/* Get the per_proc block address */
@@ -69,13 +72,13 @@ ENTRY(kdp_call_with_ctx, TAG_NO_FRAME_USED)
 	
 	bl	EXT(kdp_trap)
 
+	lis		r2,hi16(MASK(MSR_VEC))		; Get the vector enable
 	mfmsr	r0					/* Get the MSR */
+	ori		r2,r2,lo16(MASK(MSR_EE)|MASK(MSR_FP))	; Get FP and EE
 	addi	r1,	r1,	FM_SIZE
-	rlwinm	r0,r0,0,MSR_EE_BIT+1,MSR_EE_BIT-1	/* Turn off interruptions enable bit */
-	rlwinm	r0,r0,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-	rlwinm	r0,r0,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
+	andc	r0,r0,r2			; Clear FP, VEC, and EE
 	mtmsr	r0
-	isync										; Need this because we may have ditched fp/vec
+	isync						; Need this because we may have ditched fp/vec
 
 	mfsprg	r8,0				/* Get the per_proc block address */
 	
diff --git a/osfmk/kdp/ml/ppc/kdp_machdep.c b/osfmk/kdp/ml/ppc/kdp_machdep.c
index d315e6a91..d1dce210a 100644
--- a/osfmk/kdp/ml/ppc/kdp_machdep.c
+++ b/osfmk/kdp/ml/ppc/kdp_machdep.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -117,6 +120,57 @@ kdp_getintegerstate(
    
     bzero((char *)state,sizeof (struct ppc_thread_state)) ;
 
+    state->srr0	= (unsigned int)saved_state->save_srr0;
+    state->srr1	= (unsigned int)saved_state->save_srr1;
+    state->r0	= (unsigned int)saved_state->save_r0;
+    state->r1	= (unsigned int)saved_state->save_r1;
+    state->r2	= (unsigned int)saved_state->save_r2;
+    state->r3	= (unsigned int)saved_state->save_r3;
+    state->r4	= (unsigned int)saved_state->save_r4;
+    state->r5	= (unsigned int)saved_state->save_r5;
+    state->r6	= (unsigned int)saved_state->save_r6;
+    state->r7	= (unsigned int)saved_state->save_r7;
+    state->r8	= (unsigned int)saved_state->save_r8;
+    state->r9	= (unsigned int)saved_state->save_r9;
+    state->r10	= (unsigned int)saved_state->save_r10;
+    state->r11	= (unsigned int)saved_state->save_r11;
+    state->r12	= (unsigned int)saved_state->save_r12;
+    state->r13	= (unsigned int)saved_state->save_r13;
+    state->r14	= (unsigned int)saved_state->save_r14;
+    state->r15	= (unsigned int)saved_state->save_r15;
+    state->r16	= (unsigned int)saved_state->save_r16;
+    state->r17	= (unsigned int)saved_state->save_r17;
+    state->r18	= (unsigned int)saved_state->save_r18;
+    state->r19	= (unsigned int)saved_state->save_r19;
+    state->r20	= (unsigned int)saved_state->save_r20;
+    state->r21	= (unsigned int)saved_state->save_r21;
+    state->r22	= (unsigned int)saved_state->save_r22;
+    state->r23	= (unsigned int)saved_state->save_r23;
+    state->r24	= (unsigned int)saved_state->save_r24;
+    state->r25	= (unsigned int)saved_state->save_r25;
+    state->r26	= (unsigned int)saved_state->save_r26;
+    state->r27	= (unsigned int)saved_state->save_r27;
+    state->r28	= (unsigned int)saved_state->save_r28;
+    state->r29	= (unsigned int)saved_state->save_r29;
+    state->r30	= (unsigned int)saved_state->save_r30;
+    state->r31	= (unsigned int)saved_state->save_r31;
+    state->cr	= (unsigned int)saved_state->save_cr;
+    state->xer	= (unsigned int)saved_state->save_xer;
+    state->lr	= (unsigned int)saved_state->save_lr;
+    state->ctr	= (unsigned int)saved_state->save_ctr;
+}
+
+static void
+kdp_getintegerstate64(
+    struct ppc_thread_state64	*state
+)
+{
+    struct savearea	*saved_state;
+   
+    saved_state = kdp.saved_state;
+   
+    bzero((char *)state,sizeof (struct ppc_thread_state64)) ;
+
     state->srr0	= saved_state->save_srr0;
     state->srr1	= saved_state->save_srr1;
     state->r0	= saved_state->save_r0;
@@ -172,13 +226,19 @@ kdp_machine_read_regs(
 		kdp_getintegerstate((struct ppc_thread_state *)data);
 		*size = PPC_THREAD_STATE_COUNT * sizeof(int);
 		return KDPERR_NO_ERROR;
-	
+
+    case PPC_THREAD_STATE64:
+		dprintf(("kdp_readregs THREAD_STATE\n"));
+		kdp_getintegerstate64((struct ppc_thread_state64 *)data);
+		*size = PPC_THREAD_STATE64_COUNT * sizeof(int);
+		return KDPERR_NO_ERROR;
+
     case PPC_FLOAT_STATE:
 		dprintf(("kdp_readregs THREAD_FPSTATE\n"));
 		bzero((char *)data ,sizeof(struct ppc_float_state));	
 		*size = PPC_FLOAT_STATE_COUNT * sizeof(int);
 		return KDPERR_NO_ERROR;
-	
+
     default:
 		dprintf(("kdp_readregs bad flavor %d\n"));
 		return KDPERR_BADFLAVOR;
@@ -234,6 +294,55 @@ kdp_setintegerstate(
     saved_state->save_ctr	= state->ctr;
 }
 
+static void
+kdp_setintegerstate64(
+    struct ppc_thread_state64		*state
+)
+{
+    struct savearea	*saved_state;
+   
+    saved_state = kdp.saved_state;
+
+    saved_state->save_srr0	= state->srr0;
+    saved_state->save_srr1	= state->srr1;
+    saved_state->save_r0	= state->r0;
+    saved_state->save_r1	= state->r1;
+    saved_state->save_r2	= state->r2;
+    saved_state->save_r3	= state->r3;
+    saved_state->save_r4	= state->r4;
+    saved_state->save_r5	= state->r5;
+    saved_state->save_r6	= state->r6;
+    saved_state->save_r7	= state->r7;
+    saved_state->save_r8	= state->r8;
+    saved_state->save_r9	= state->r9;
+    saved_state->save_r10	= state->r10;
+    saved_state->save_r11	= state->r11;
+    saved_state->save_r12	= state->r12;
+    saved_state->save_r13	= state->r13;
+    saved_state->save_r14	= state->r14;
+    saved_state->save_r15	= state->r15;
+    saved_state->save_r16	= state->r16;
+    saved_state->save_r17	= state->r17;
+    saved_state->save_r18	= state->r18;
+    saved_state->save_r19	= state->r19;
+    saved_state->save_r20	= state->r20;
+    saved_state->save_r21	= state->r21;
+    saved_state->save_r22	= state->r22;
+    saved_state->save_r23	= state->r23;
+    saved_state->save_r24	= state->r24;
+    saved_state->save_r25	= state->r25;
+    saved_state->save_r26	= state->r26;
+    saved_state->save_r27	= state->r27;
+    saved_state->save_r28	= state->r28;
+    saved_state->save_r29	= state->r29;
+    saved_state->save_r30	= state->r30;
+    saved_state->save_r31	= state->r31;
+    saved_state->save_cr	= state->cr;
+    saved_state->save_xer	= state->xer;
+    saved_state->save_lr	= state->lr;
+    saved_state->save_ctr	= state->ctr;
+}
+
 kdp_error_t
 kdp_machine_write_regs(
     unsigned int cpu,
@@ -252,11 +361,19 @@ kdp_machine_write_regs(
 		DumpTheSave((struct savearea *)data);		/* (TEST/DEBUG) */
 #endif
 		return KDPERR_NO_ERROR;
-	
+
+    case PPC_THREAD_STATE64:
+		dprintf(("kdp_writeregs THREAD_STATE64\n"));
+		kdp_setintegerstate64((struct ppc_thread_state64 *)data);
+
+#if KDP_TEST_HARNESS
+		DumpTheSave((struct savearea *)data);		/* (TEST/DEBUG) */
+#endif
+		return KDPERR_NO_ERROR;
     case PPC_FLOAT_STATE:
 		dprintf(("kdp_writeregs THREAD_FPSTATE\n"));
 		return KDPERR_NO_ERROR;
-	
+
     default:
 		dprintf(("kdp_writeregs bad flavor %d\n"));
 		return KDPERR_BADFLAVOR;
@@ -418,7 +535,7 @@ kdp_trap(
 )
 {
 	unsigned int *fp;
-	unsigned int register sp;
+	unsigned int sp;
 	struct savearea *state;
 
 	if (kdp_noisy) {
@@ -446,7 +563,7 @@ kdp_trap(
 	if (kdp_noisy)
 		printf("kdp_trap: kdp_raise_exception() ret\n");
 
-	if (*((int *)saved_state->save_srr0) == 0x7c800008)
+	if ((unsigned int)(saved_state->save_srr0) == 0x7c800008)
 		saved_state->save_srr0 += 4;			/* BKPT_SIZE */
 
 	if(saved_state->save_srr1 & (MASK(MSR_SE) | MASK(MSR_BE))) {	/* Are we just stepping or continuing */
diff --git a/osfmk/kdp/ml/ppc/kdp_misc.s b/osfmk/kdp/ml/ppc/kdp_misc.s
index 850b3c232..9eb3f6c6f 100644
--- a/osfmk/kdp/ml/ppc/kdp_misc.s
+++ b/osfmk/kdp/ml/ppc/kdp_misc.s
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -25,59 +28,41 @@
 #include <mach/ppc/vm_param.h>
 #include <assym.s>
 
-.set kLog2CacheLineSize, 5
-.set kCacheLineSize, 32
- 
-ENTRY(kdp_flush_cache, TAG_NO_FRAME_USED)
-	cmpi    cr0,0,r4,0			/* is this zero length? */
-	add     r4,r3,r4			/* calculate last byte + 1 */
-	subi    r4,r4,1				/* calculate last byte */
-
-	srwi    r5,r3,kLog2CacheLineSize	/* calc first cache line index */
-	srwi    r4,r4,kLog2CacheLineSize	/* calc last cache line index */
-	beq     cr0, LdataToCodeDone		/* done if zero length */
-
-	subf    r4,r5,r4			/* calc diff (# lines minus 1) */
-	addi    r4,r4,1				/* # of cache lines to flush */
-	slwi    r5,r5,kLog2CacheLineSize	/* calc addr of first cache line */
-
-	/* flush the data cache lines */
-	mr      r3,r5				/* starting address for loop */
-	mtctr   r4					/* loop count */
-LdataToCodeFlushLoop:
-	dcbf    0, r3						/* flush the data cache line */
-	addi    r3,r3,kCacheLineSize		/* advance to next cache line */
-	bdnz    LdataToCodeFlushLoop		/* loop until count is zero */
-	sync								/* wait until RAM is valid */
-
-	/* invalidate the code cache lines */
-	mr      r3,r5						/* starting address for loop */
-	mtctr   r4							/* loop count */
-LdataToCodeInvalidateLoop:
-	icbi    0, r3						/* invalidate code cache line */
-	addi    r3,r3,kCacheLineSize		/* advance to next cache line */
-	bdnz    LdataToCodeInvalidateLoop	/* loop until count is zero */
-	sync								/* wait until last icbi completes */
-	isync								/* discard prefetched instructions */
-LdataToCodeDone:
-	blr									/* return nothing */
-
 ENTRY(kdp_sync_cache, TAG_NO_FRAME_USED)
 	sync					/* data sync */
 	isync					/* inst sync */
 	blr						/* return nothing */
 
-ENTRY(kdp_xlate_off, TAG_NO_FRAME_USED)
-	mfmsr	r3
-	rlwinm	r3,r3,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-	rlwinm	r3,r3,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-	rlwinm	r4, r3, 0, MSR_DR_BIT+1, MSR_IR_BIT-1
-	mtmsr	r4
-	isync
-	blr
 
-ENTRY(kdp_xlate_restore, TAG_NO_FRAME_USED)
-	mtmsr	r3
-	isync
-	blr
+;
+;		This is a really stupid physical copy. 1 whole byte at a time...
+;		Source and dest are long longs.  We do this with 64-bit on if
+;		supported.
+;
+
+			.align	5
+			.globl	EXT(kdp_copy_phys)
+			
+LEXT(kdp_copy_phys)
 
+			mflr	r12						; Save return
+			
+			bl		EXT(ml_set_physical_disabled)	; No DR and get 64-bit
+			
+			rlwinm	r3,r3,0,1,0				; Dup low to high source
+			rlwinm	r5,r5,0,1,0				; Dup low to high dest
+			rlwimi	r3,r4,0,0,31			; Copy bottom on in source
+			rlwimi	r5,r6,0,0,31			; Copy bottom on in dest
+			
+kcpagain:	addic.	r7,r7,-1				; Drop count
+			blt--	kcpdone					; All done...
+			lbz		r0,0(r3)				; Grab a whole one
+			stb		r0,0(r5)				; Lay it gently down
+			addi	r3,r3,1					; Next source
+			addi	r5,r5,1					; Next destination
+			b		kcpagain				; Once more with feeling...
+		
+kcpdone:	bl		EXT(ml_restore)			; Put trans, etc back
+			mtlr	r12						; Restore return
+			blr								; Come again please...
+		
diff --git a/osfmk/kdp/ml/ppc/kdp_vm.c b/osfmk/kdp/ml/ppc/kdp_vm.c
index 066204a66..ddb002b8c 100644
--- a/osfmk/kdp/ml/ppc/kdp_vm.c
+++ b/osfmk/kdp/ml/ppc/kdp_vm.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -29,73 +32,33 @@
 #include <ppc/machparam.h>
 #include <ppc/mem.h>
 #include <ppc/pmap.h>
-#include <ppc/pmap_internals.h> 
 #include <ppc/mappings.h> 
 
 pmap_t kdp_pmap=0;
 boolean_t kdp_trans_off=0;
+boolean_t kdp_read_io  =0;
 
-unsigned kdp_xlate_off(void);
-void kdp_xlate_restore(unsigned);
-void kdp_flush_cache(vm_offset_t, unsigned);
-vm_offset_t kdp_vtophys(pmap_t pmap, vm_offset_t vaddr);
-void kdp_bcopy( unsigned char *, unsigned char *, unsigned);
-void kdp_pmemcpy( vm_offset_t , vm_offset_t, unsigned);
 unsigned kdp_vm_read( caddr_t, caddr_t, unsigned);
 unsigned kdp_vm_write( caddr_t, caddr_t, unsigned);
 
-extern vm_offset_t kvtophys(vm_offset_t);
-extern vm_offset_t mem_actual;
 
 /*
  *
  */
-vm_offset_t kdp_vtophys(
+addr64_t kdp_vtophys(
 	pmap_t pmap,
-	vm_offset_t va)
+	addr64_t va)
 {
-	register mapping                *mp;
-	register vm_offset_t    pa;
-
-	pa = (vm_offset_t)LRA(pmap->space,(void *)va);
-
-	if (pa != 0)            
-		return(pa);     
-
-	mp = hw_lock_phys_vir(pmap->space, va);
-	if((unsigned int)mp&1) {
-		return 0;
-	}
-
-	if(!mp) {								/* If it was not a normal page */
-		pa = hw_cvp_blk(pmap, va);			/* Try to convert odd-sized page (returns 0 if not found) */
-		return pa;							/* Return physical address */
-	}
-
-	mp = hw_cpv(mp);
-
-	if(!mp->physent) {
-		pa = (vm_offset_t)((mp->PTEr & -PAGE_SIZE) | ((unsigned int)va & (PAGE_SIZE-1)));
-	} else {
-		pa = (vm_offset_t)((mp->physent->pte1 & -PAGE_SIZE) | ((unsigned int)va & (PAGE_SIZE-1)));
-		hw_unlock_bit((unsigned int *)&mp->physent->phys_link, PHYS_LOCK);
-	}
+	addr64_t    pa;
+	ppnum_t pp;
 
+	pp = pmap_find_phys(pmap, va);				/* Get the page number */
+	if(!pp) return 0;							/* Just return if no translation */
+	
+	pa = ((addr64_t)pp << 12) | (va & 0x0000000000000FFFULL);	/* Shove in the page offset */
 	return(pa);
 }
 
-/*
- *
- */
-void kdp_bcopy(
-	unsigned char *src, 
-	unsigned char *dst,
-	unsigned cnt)
-{
-        while (cnt--)
-                *dst++ = *src++;
-}
-
 /*
  *
  */
@@ -104,63 +67,63 @@ unsigned kdp_vm_read(
 	caddr_t dst, 
 	unsigned len)
 {
-	vm_offset_t cur_virt_src, cur_virt_dst;
-	vm_offset_t cur_phys_src;
+	addr64_t cur_virt_src, cur_virt_dst;
+	addr64_t cur_phys_src;
 	unsigned resid, cnt;
-	unsigned msr;
+	unsigned int dummy;
+	pmap_t pmap;
 
 #ifdef KDP_VM_READ_DEBUG
     kprintf("kdp_vm_read1: src %x dst %x len %x - %08X %08X\n", src, dst, len, ((unsigned long *)src)[0], ((unsigned long *)src)[1]);
 #endif
+
+	cur_virt_src = (addr64_t)((unsigned int)src);
+	cur_virt_dst = (addr64_t)((unsigned int)dst);
+	
 	if (kdp_trans_off) {
-		cur_virt_src = (vm_offset_t)src;
-		if((vm_offset_t)src >= mem_actual) return 0;	/* Can't read where there's not any memory */
-		cur_virt_dst = (vm_offset_t)dst;
-		resid = (mem_actual - (vm_offset_t)src) > len ? len : (mem_actual - (vm_offset_t)src);
+		
+		
+		resid = len;								/* Get the length to copy */
 
 		while (resid != 0) {
-			cur_phys_src = cur_virt_src;
-			cnt = ((cur_virt_src + NBPG) & (-NBPG)) - cur_virt_src;	
+
+			if(kdp_read_io == 0)
+				if(!mapping_phys_lookup((ppnum_t)(cur_virt_src >> 12), &dummy)) return 0;	/* Can't read where there's not any memory */
+		
+			cnt = 4096 - (cur_virt_src & 0xFFF);	/* Get length left on page */
+		
 			if (cnt > resid)  cnt = resid;
-			msr = kdp_xlate_off();
-			kdp_bcopy((unsigned char *)cur_phys_src, 
-				(unsigned char *)cur_virt_dst, cnt);
-			kdp_xlate_restore(msr);
-			cur_virt_src +=cnt;
-			cur_virt_dst +=cnt;
+
+			bcopy_phys(cur_virt_src, cur_virt_dst, cnt);		/* Copy stuff over */
+
+			cur_virt_src += cnt;
+			cur_virt_dst += cnt;
 			resid -= cnt;
 		}
+		
 	} else {
-		cur_virt_src = (vm_offset_t)src;
-		cur_virt_dst = (vm_offset_t)dst;
+
 		resid = len;
 
+		if(kdp_pmap) pmap = kdp_pmap;				/* If special pmap, use it */
+		else pmap = kernel_pmap;					/* otherwise, use kernel's */
+
 		while (resid != 0) {   
-			if (kdp_pmap) {
-				if ((cur_phys_src = 
-					kdp_vtophys(kdp_pmap,trunc_page(cur_virt_src))) == 0)
-					goto exit;
-				cur_phys_src += (cur_virt_src & PAGE_MASK);
-			} else {
-				if ((cur_phys_src = kdp_vtophys(kernel_pmap,cur_virt_src)) == 0)
-					goto exit;
-			}
-
-			cnt = ((cur_virt_src + NBPG) & (-NBPG)) - cur_virt_src;
+
+			if((cur_phys_src = kdp_vtophys(pmap, cur_virt_src)) == 0) goto exit;
+			if(kdp_read_io == 0)
+				if(!mapping_phys_lookup((ppnum_t)(cur_phys_src >> 12), &dummy)) goto exit;	/* Can't read where there's not any memory */
+
+			cnt = 4096 - (cur_virt_src & 0xFFF);	/* Get length left on page */
 			if (cnt > resid) cnt = resid;
-				if (kdp_pmap) {
+
 #ifdef KDP_VM_READ_DEBUG
-					kprintf("kdp_vm_read2: pmap %x, virt %x, phys %x\n", 
-							kdp_pmap, cur_virt_src, cur_phys_src);
+				kprintf("kdp_vm_read2: pmap %08X, virt %016LLX, phys %016LLX\n", 
+					pmap, cur_virt_src, cur_phys_src);
 #endif
-				msr = kdp_xlate_off();
-				kdp_bcopy((unsigned char *)cur_phys_src, 
-						(unsigned char *)cur_virt_dst, cnt);
-				kdp_xlate_restore(msr);
-			} else {
-				kdp_bcopy((unsigned char *)cur_virt_src, 
-						(unsigned char *)cur_virt_dst, cnt);
-			}
+
+			bcopy_phys(cur_phys_src, cur_virt_dst, cnt);		/* Copy stuff over */
+			
 			cur_virt_src +=cnt;
 			cur_virt_dst +=cnt;
 			resid -= cnt;
@@ -170,7 +133,7 @@ exit:
 #ifdef KDP_VM_READ_DEBUG
 	kprintf("kdp_vm_read: ret %08X\n", len-resid);
 #endif
-        return (len-resid);
+        return (len - resid);
 }
 
 /*
@@ -181,17 +144,17 @@ unsigned kdp_vm_write(
         caddr_t dst,
         unsigned len)
 {       
-	vm_offset_t cur_virt_src, cur_virt_dst;
-	vm_offset_t cur_phys_src, cur_phys_dst;
-        unsigned resid, cnt, cnt_src, cnt_dst;
-	unsigned msr;
+	addr64_t cur_virt_src, cur_virt_dst;
+	addr64_t cur_phys_src, cur_phys_dst;
+    unsigned resid, cnt, cnt_src, cnt_dst;
 
 #ifdef KDP_VM_WRITE_DEBUG
 	printf("kdp_vm_write: src %x dst %x len %x - %08X %08X\n", src, dst, len, ((unsigned long *)src)[0], ((unsigned long *)src)[1]);
 #endif
 
-	cur_virt_src = (vm_offset_t)src;
-	cur_virt_dst = (vm_offset_t)dst;
+	cur_virt_src = (addr64_t)((unsigned int)src);
+	cur_virt_dst = (addr64_t)((unsigned int)dst);
+
 	resid = len;
 
 	while (resid != 0) {
@@ -210,16 +173,14 @@ unsigned kdp_vm_write(
 		if (cnt > resid) 
 			cnt = resid;
 
-		msr = kdp_xlate_off();
-		kdp_bcopy((unsigned char *)cur_virt_src,  (unsigned char *)cur_phys_dst, cnt);
-		kdp_flush_cache(cur_phys_dst, cnt);
-		kdp_xlate_restore(msr);
+		bcopy_phys(cur_phys_src, cur_phys_dst, cnt);		/* Copy stuff over */
+		sync_cache64(cur_phys_dst, cnt);					/* Sync caches */
 
 		cur_virt_src +=cnt;
 		cur_virt_dst +=cnt;
 		resid -= cnt;
 	}
 exit:
-	return (len-resid);
+	return (len - resid);
 }
 
diff --git a/osfmk/kdp/pe/POWERMAC/kdp_mace.c b/osfmk/kdp/pe/POWERMAC/kdp_mace.c
deleted file mode 100644
index 542f1257f..000000000
--- a/osfmk/kdp/pe/POWERMAC/kdp_mace.c
+++ /dev/null
@@ -1,672 +0,0 @@
-/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
- *
- * @APPLE_LICENSE_HEADER_START@
- * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
- * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
- * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
- * 
- * @APPLE_LICENSE_HEADER_END@
- */
-/*
- * Copyright (c) 1997 Apple Computer, Inc.
- *
- * ethernet driver for mace on-board ethernet
- *
- * HISTORY
- *
- * Dieter Siegmund (dieter@next.com) Thu Feb 27 18:25:33 PST 1997
- * - ripped off code from MK/LINUX, turned it into a polled-mode
- *   driver for the PCI (8500) class machines
- *
- * Dieter Siegmund (dieter@next.com) Fri Mar 21 12:41:29 PST 1997
- * - reworked to support a BSD-style interface, and to support kdb polled
- *   interface and interrupt-driven interface concurrently
- *
- * Justin Walker (justin@apple.com) Tue May 20 10:29:29 PDT 1997
- * - Added multicast support
- *
- * Dieter Siegmund (dieter@next.com) Thu May 29 15:02:29 PDT 1997
- * - fixed problem with sending arp packets for ip address 0.0.0.0
- * - use kdp_register_send_receive() instead of defining 
- *   en_send_pkt/en_recv_pkt routines to avoid name space 
- *   collisions with IOEthernetDebugger and allow these routines to be
- *   overridden by a driverkit-style driver
- *
- * Dieter Siegmund (dieter@apple.com) Tue Jun 24 18:29:15 PDT 1997
- * - don't let the adapter auto-strip 802.3 receive frames, it messes
- *   up the frame size logic
- *
- * Dieter Siegmund (dieter@apple.com) Tue Aug  5 16:24:52 PDT 1997
- * - handle multicast address deletion correctly
- */
-#ifdef MACE_DEBUG
-/*
- * Caveat: MACE_DEBUG delimits some code that is getting kind of
- *         stale. Before blindly turning on MACE_DEBUG for your
- *         testing, take a look at the code enabled by it to check
- *         that it is reasonably sane.
- */
-#endif
-
-#include <mach/boolean.h>
-#include <mach/exception_types.h>
-#include <mach/mach_types.h>
-
-#include <ppc/proc_reg.h>
-#include <ppc/pmap.h>
-#include <pexpert/ppc/powermac.h>
-#include <pexpert/ppc/dbdma.h>
-#include <kdp/kdp_en_debugger.h>
-#include <kdp/kdp_udp.h>
-
-#include "kdp_mace.h"
-
-struct kdp_mace_copy_desc {
-    int *       len;
-    char *      data;
-};
-static mace_t  mace;
- 
-#define MACE_DMA_AREA_SIZE \
-                (ETHER_RX_NUM_DBDMA_BUFS * ETHERNET_BUF_SIZE + PG_SIZE)
-static unsigned long 
-	mace_rx_dma_area[(MACE_DMA_AREA_SIZE + 
-				sizeof(long))/sizeof(long)];                
-static unsigned long 
-	mace_tx_dma_area[(ETHERNET_BUF_SIZE + PG_SIZE + 
-				sizeof(long))/sizeof(long)];
- 
-#ifdef MACE_DEBUG
-static unsigned char testBuffer[PG_SIZE * 4];
-static unsigned char testMsg[] = "mace ethernet interface test";
-#endif
-
-static void polled_send_pkt(char * data, int len);
-static void polled_receive_pkt(char *data, int *len, int timeout_ms);
-
-void kdp_mace_reset(mace_t *);
-void kdp_mace_geteh(unsigned char *);
-void kdp_mace_setup_dbdma(void);
-boolean_t kdp_mace_init(void * baseAddresses[3], unsigned char * netAddr);
-#ifdef MACE_DEBUG
-static void printContiguousEtherPacket(u_char *, int);
-static void send_test_packet(void);
-#endif
-
-typedef int (*funcptr)(char *, int, void *);
-int kdp_mace_recv_pkt(funcptr , void *);
-
-#ifdef MACE_DEBUG
-static int
-macAddrsEqual(unsigned char * one, unsigned char * two)
-{
-    int i;
-
-    for (i = 0; i < NUM_EN_ADDR_BYTES; i++)
-	if (*one++ != *two++)
-	    return 0;
-    return 1;
-}
-
-static __inline__ int
-isprint(unsigned char c)
-{
-    return (c >= 0x20 && c <= 0x7e);
-}
-
-static void
-printEtherHeader(enet_addr_t * dh, enet_addr_t * sh, u_short etype)
-{
-    u_char * dhost = dh->ether_addr_octet; 
-    u_char * shost = sh->ether_addr_octet;
-
-    printf("Dst: %x:%x:%x:%x:%x:%x Src: %x:%x:%x:%x:%x:%x Type: 0x%x\n", 
-	    dhost[0], dhost[1], dhost[2], dhost[3], dhost[4], dhost[5],
-	    shost[0], shost[1], shost[2], shost[3], shost[4], shost[5],
-	    etype);
-}
-
-static void
-printData(u_char * data_p, int n_bytes)
-{
-#define CHARS_PER_LINE 	16
-    char		line_buf[CHARS_PER_LINE + 1];
-    int			line_pos;
-    int			offset;
-
-    for (line_pos = 0, offset = 0; offset < n_bytes; offset++, data_p++) {
-	if (line_pos == 0) {
-	    printf("%04d ", offset);
-	}
-
-	line_buf[line_pos] = isprint(*data_p) ? *data_p : '.';
-	printf(" %02x", *data_p);
-	line_pos++;
-	if (line_pos == CHARS_PER_LINE) {
-	    line_buf[CHARS_PER_LINE] = '\0';
-	    printf("  %s\n", line_buf);
-	    line_pos = 0;
-	}
-    }
-    if (line_pos) { /* need to finish up the line */
-	for (; line_pos < CHARS_PER_LINE; line_pos++) {
-	    printf("   ");
-	    line_buf[line_pos] = ' ';
-	}
-	line_buf[CHARS_PER_LINE] = '\0';
-	printf("  %s\n", line_buf);
-    }
-}
-
-static void
-printEtherPacket(enet_addr_t * dhost, enet_addr_t * shost, u_short type, 
-		 u_char * data_p, int n_bytes)
-{
-    printEtherHeader(dhost, shost, type);
-    printData(data_p, n_bytes);
-}
-
-static void
-printContiguousEtherPacket(u_char * data_p, int n_bytes)
-{
-    printEtherPacket((enet_addr_t *)data_p, 
-		     (enet_addr_t *)(data_p + NUM_EN_ADDR_BYTES), 
-		     *((u_short *)(data_p + (NUM_EN_ADDR_BYTES * 2))),
-		     data_p, n_bytes);
-}
-#endif
-
-
-/*
- * kdp_mace_reset
- *
- * Reset the board..
- */
-void
-kdp_mace_reset(mace_t * m)
-{
-    dbdma_reset(m->rv_dbdma);
-    dbdma_reset(m->tx_dbdma);
-}
-
-
-/*
- * kdp_mace_geteh:
- *
- *	This function gets the ethernet address (array of 6 unsigned
- *	bytes) from the MACE board registers.
- *
- */
-void
-kdp_mace_geteh(unsigned char *ep)
-{
-    int	i;
-    unsigned char ep_temp;
-
-    mace.ereg->iac = IAC_PHYADDR; eieio();
-	
-    for (i = 0; i < ETHER_ADD_SIZE; i++) {
-	ep_temp = mace.ereg->padr; eieio();
-	*ep++ = ep_temp;
-    }
-}
-
-/*
- * mace_seteh:
- *
- *	This function sets the ethernet address (array of 6 unsigned
- *	bytes) on the MACE board. 
- */
-static void
-mace_seteh(unsigned char *ep)
-{
-    int	i;
-    unsigned char	status;
-
-    if (mace.chip_id != MACE_REVISION_A2) {
-	mace.ereg->iac = IAC_ADDRCHG|IAC_PHYADDR; eieio();
-
-	while ((status = mace.ereg->iac)) {
-	    if ((status & IAC_ADDRCHG) == 0) {
-		eieio();
-		break;
-	    }
-	    eieio();
-	}
-    }
-    else {
-	/* start to load the address.. */
-	mace.ereg->iac = IAC_PHYADDR; eieio();
-    }
-
-    for (i = 0; i < NUM_EN_ADDR_BYTES; i++) {
-	mace.ereg->padr = *(ep+i); eieio();
-    }
-    return;
-}
-
-/*
- * kdp_mace_setup_dbdma
- *
- * Setup various dbdma pointers.
- */
-void
-kdp_mace_setup_dbdma()
-{
-    mace_t * 		m = &mace;
-    int			i;
-    dbdma_command_t *	d;
-    vm_offset_t		address;
-    dbdma_regmap_t *	regmap;
-
-#define ALIGN_MASK	0xfffffffcUL
-    if (m->rv_dma_area == 0) {
-	m->rv_dma_area = (unsigned char *)
-	    ((((unsigned long)mace_rx_dma_area) + 3) & ALIGN_MASK);
-	m->rv_dma = dbdma_alloc(ETHER_RX_NUM_DBDMA_BUFS + 2);
-	m->tx_dma = dbdma_alloc(TX_NUM_DBDMA);
-	m->tx_dma_area = (unsigned char *)
-	    ((((unsigned long)mace_tx_dma_area) + 3) & ALIGN_MASK);
-    }
-
-    /* set up a ring of buffers */
-    d = m->rv_dma;
-    for (i = 0; i < ETHER_RX_NUM_DBDMA_BUFS; i++, d++) {
-	address = (vm_offset_t) kvtophys((vm_offset_t)&m->rv_dma_area[i*ETHERNET_BUF_SIZE]);
-	DBDMA_BUILD(d, DBDMA_CMD_IN_LAST, 0, ETHERNET_BUF_SIZE,
-		    address, DBDMA_INT_ALWAYS,
-		    DBDMA_WAIT_NEVER, 
-		    DBDMA_BRANCH_NEVER);
-    }
-
-    /* stop when we hit the end of the list */
-    DBDMA_BUILD(d, DBDMA_CMD_STOP, 0, 0, 0, DBDMA_INT_ALWAYS,
-		DBDMA_WAIT_NEVER, DBDMA_BRANCH_NEVER);
-    d++;
-
-    /* branch to command at "address" ie. element 0 of the "array" */
-    DBDMA_BUILD(d, DBDMA_CMD_NOP, 0, 0, 0, DBDMA_INT_NEVER,
-		DBDMA_WAIT_NEVER, DBDMA_BRANCH_ALWAYS);
-    address = (vm_offset_t) kvtophys((vm_offset_t)m->rv_dma);
-    dbdma_st4_endian(&d->d_cmddep, address);
-
-    m->rv_head = 0;
-    m->rv_tail = ETHER_RX_NUM_DBDMA_BUFS; /* always contains DBDMA_CMD_STOP */
-    regmap = m->rv_dbdma;
-
-    /* stop/init/restart dma channel */
-    dbdma_reset(regmap);
-    dbdma_reset(m->tx_dbdma);
-
-    /* Set the wait value.. */
-    dbdma_st4_endian(&regmap->d_wait, DBDMA_SET_CNTRL(0x00));
-
-    /* Set the tx wait value */
-    regmap = m->tx_dbdma;
-    dbdma_st4_endian(&regmap->d_wait, DBDMA_SET_CNTRL(0x20));
-
-    flush_dcache((vm_offset_t)m->rv_dma, 
-		  sizeof(dbdma_command_t) * (ETHER_RX_NUM_DBDMA_BUFS + 2),
-			FALSE);
-    /* start receiving */
-    dbdma_start(m->rv_dbdma, m->rv_dma);
-}
-
-#ifdef MACE_DEBUG
-static void
-send_test_packet()
-{
-    unsigned char * tp;
-
-    bzero((char *)testBuffer, sizeof(testBuffer));
-
-    tp = testBuffer;
-
-    /* send self-addressed packet */
-    bcopy((char *)&mace.macaddr[0], (char *)tp, NUM_EN_ADDR_BYTES);
-    tp += NUM_EN_ADDR_BYTES;
-    bcopy((char *)&mace.macaddr[0], (char *)tp, NUM_EN_ADDR_BYTES);
-    tp += NUM_EN_ADDR_BYTES;
-    *tp++ = 0;
-    *tp++ = 0;
-    bcopy((char *)testMsg, (char *)tp, sizeof(testMsg));
-    polled_send_pkt((char *)testBuffer, 80);
-    return;
-}
-#endif
-
-/*
- * Function: kdp_mace_init
- *
- * Purpose:
- *   Called early on, initializes the adapter and readies it for
- *   kdb kernel debugging. 
- */
-boolean_t
-kdp_mace_init(void * baseAddresses[3], unsigned char * netAddr)
-{
-    unsigned char	status;
-    mace_t *		m = &mace;
-    struct mace_board * ereg;
-    int 		mpc = 0;
-    int			i;
-
-    bzero((char *)&mace, sizeof(mace));
-
-    /* get the ethernet registers' mapped address */
-    ereg = m->ereg 
-	= (struct mace_board *) baseAddresses[0];
-    m->tx_dbdma = (dbdma_regmap_t *) baseAddresses[1];
-    m->rv_dbdma = (dbdma_regmap_t *) baseAddresses[2];
-
-    for (i = 0; i < NUM_EN_ADDR_BYTES; i++)
-        m->macaddr[i] = netAddr[i];
-
-    /* Reset the board & AMIC.. */
-    kdp_mace_reset(m);
-
-    /* grab the MACE chip rev  */
-    m->chip_id = (ereg->chipid2 << 8 | ereg->chipid1);
-
-    /* don't auto-strip for 802.3 */
-    m->ereg->rcvfc &= ~(RCVFC_ASTRPRCV);
-
-    /* set the ethernet address */
-    mace_seteh(mace.macaddr);
-    {
-	unsigned char macaddr[NUM_EN_ADDR_BYTES];
-	kdp_mace_geteh(macaddr);
-	printf("mace ethernet [%02x:%02x:%02x:%02x:%02x:%02x]\n",
-		macaddr[0], macaddr[1], macaddr[2], 
-		macaddr[3], macaddr[4], macaddr[5]);
-    }
-
-    /* Now clear the Multicast filter */
-    if (m->chip_id != MACE_REVISION_A2) {
-	ereg->iac = IAC_ADDRCHG|IAC_LOGADDR; eieio();
-
-	while ((status = ereg->iac)) {
-	    if ((status & IAC_ADDRCHG) == 0)
-		break;
-	    eieio();
-	}
-	eieio();
-    }
-    else {
-	ereg->iac = IAC_LOGADDR; eieio();
-    }
-    {
-	int i;
-
-	for (i=0; i < 8; i++) 
-	{    ereg->ladrf = 0;
-	     eieio();
-        }
-    }
-
-    /* register interrupt routines */
-    kdp_mace_setup_dbdma();
-
-    /* Start the chip... */
-    m->ereg->maccc = MACCC_ENXMT|MACCC_ENRCV; eieio();
-    {
-	volatile char ch =  mace.ereg->ir; eieio();
-    }
-
-    delay(500); /* paranoia */
-    mace.ereg->imr = 0xfe; eieio();
-
-    /* register our debugger routines */
-    kdp_register_send_receive((kdp_send_t)polled_send_pkt, 
-			      (kdp_receive_t)polled_receive_pkt);
-
-#ifdef MACE_DEBUG
-    printf("Testing 1 2 3\n");
-    send_test_packet();
-    printf("Testing 1 2 3\n");
-    send_test_packet();
-    printf("Testing 1 2 3\n");
-    send_test_packet();
-    do {
-	static unsigned char buf[ETHERNET_BUF_SIZE];
-	int len;
-	int nmpc = mace.ereg->mpc; eieio();
-
-	if (nmpc > mpc) {
-	    mpc = nmpc;
-	    printf("mpc %d\n", mpc);
-	}
-	polled_receive_pkt((char *)buf, &len, 100);
-	if (len > 0) {
-	    printf("rx %d\n", len);
-	    printContiguousEtherPacket(buf, len);
-	}
-    } while(1);
-#endif
-
-    return TRUE;
-}
-
-#ifdef MACE_DEBUG
-static void
-kdp_mace_txstatus(char * msg)
-{
-    dbdma_regmap_t *		dmap = mace.tx_dbdma;
-    volatile unsigned long 	status;
-    volatile unsigned long 	intr;
-    volatile unsigned long 	branch;
-    volatile unsigned long 	wait;
-
-    status = dbdma_ld4_endian(&dmap->d_status); eieio();
-    intr = dbdma_ld4_endian(&dmap->d_intselect); eieio();
-    branch = dbdma_ld4_endian(&dmap->d_branch); eieio();
-    wait = dbdma_ld4_endian(&dmap->d_wait); eieio();
-    printf("(%s s=0x%x i=0x%x b=0x%x w=0x%x)", msg, status, intr, branch,
-	   wait);
-    return;
-}
-#endif
-
-static void
-kdp_mace_tx_dbdma(char * data, int len)
-{
-    unsigned long	count;
-    dbdma_command_t *	d;
-    unsigned long 	page;
-
-    d = mace.tx_dma;
-    page = ((unsigned long) data) & PG_MASK;
-    if ((page + len) <= PG_SIZE) { /* one piece dma */
-	DBDMA_BUILD(d, DBDMA_CMD_OUT_LAST, DBDMA_KEY_STREAM0,
-		    len,
-		    (vm_offset_t) kvtophys((vm_offset_t) data),
-		    DBDMA_INT_NEVER, 
-		    DBDMA_WAIT_IF_FALSE, DBDMA_BRANCH_NEVER);
-    }
-    else { /* two piece dma */
-	count = PG_SIZE - page;
-	DBDMA_BUILD(d, DBDMA_CMD_OUT_MORE, DBDMA_KEY_STREAM0,
-		    count,
-		    (vm_offset_t)kvtophys((vm_offset_t) data),
-		    DBDMA_INT_NEVER, 
-		    DBDMA_WAIT_NEVER, DBDMA_BRANCH_NEVER);
-	d++;
-	DBDMA_BUILD(d, DBDMA_CMD_OUT_LAST, DBDMA_KEY_STREAM0, 
-		    len - count, (vm_offset_t)
-		    kvtophys((vm_offset_t)((unsigned char *)data + count)),
-		    DBDMA_INT_NEVER, 
-		    DBDMA_WAIT_IF_FALSE, DBDMA_BRANCH_NEVER);
-    }
-    d++;
-    DBDMA_BUILD(d, DBDMA_CMD_LOAD_QUAD, DBDMA_KEY_SYSTEM,
-		1, kvtophys((vm_offset_t) &mace.ereg->xmtfs),DBDMA_INT_NEVER, 
-//		1, &mace.ereg->xmtfs,DBDMA_INT_NEVER, 
-		DBDMA_WAIT_NEVER, DBDMA_BRANCH_NEVER);
-    d++;
-    DBDMA_BUILD(d, DBDMA_CMD_LOAD_QUAD, DBDMA_KEY_SYSTEM,
-		1, kvtophys((vm_offset_t) &mace.ereg->ir), DBDMA_INT_ALWAYS,
-//		1, &mace.ereg->ir, DBDMA_INT_ALWAYS,
-		DBDMA_WAIT_NEVER, DBDMA_BRANCH_NEVER);
-    d++;
-    DBDMA_BUILD(d, DBDMA_CMD_STOP, 0, 0, 0, 0, 0, 0);
-
-    flush_dcache((vm_offset_t)mace.tx_dma, 
-		sizeof(dbdma_command_t) * TX_NUM_DBDMA,
-		FALSE);
-    dbdma_start(mace.tx_dbdma, mace.tx_dma);
-    return;
-
-}
-
-static void
-waitForDBDMADone(char * msg)
-{
-    {
-	/* wait for tx dma completion */
-	dbdma_regmap_t *	dmap = mace.tx_dbdma;
-	int 			i;
-	volatile unsigned long 	val;
-
-	i = 0;
-	do {
-	    val = dbdma_ld4_endian(&dmap->d_status); eieio();
-	    delay(50);
-	    i++;
-	} while ((i < 100000) && (val & DBDMA_CNTRL_ACTIVE));
-	if (i == 100000)
-	    printf("mace(%s): kdp_mace_tx_dbdma poll timed out 0x%x", msg, val);
-    }
-}
-
-int
-kdp_mace_recv_pkt(funcptr pktfunc, void * p)
-{
-    vm_offset_t			address;
-    struct mace_board *		board;
-    long			bytes;
-    int				done = 0;
-    int				doContinue = 0;
-    mace_t *			m;
-    unsigned long		resid;
-    unsigned short		status;
-    int				tail;
-
-    m = &mace;
-    board = m->ereg;
-
-    /* remember where the tail was */
-    tail = m->rv_tail;
-    for (done = 0; (done == 0) && (m->rv_head != tail);) {
-	dbdma_command_t *	dmaHead;
-	
-	dmaHead = &m->rv_dma[m->rv_head];
-	resid = dbdma_ld4_endian(&dmaHead->d_status_resid);
-	status = (resid >> 16);
-	bytes  = resid & 0xffff;
-	bytes = ETHERNET_BUF_SIZE - bytes - 8; /* strip off FCS/CRC */
-
-	if ((status & DBDMA_ETHERNET_EOP) == 0)  {
-	    /* no packets are ready yet */
-	    break;
-	}
-	doContinue = 1;
-	/* if the packet is good, pass it up */
-	if (bytes >= (ETHER_MIN_PACKET - 4)) {
-	    char * dmaPacket;
-	    dmaPacket = (char *)&m->rv_dma_area[m->rv_head * ETHERNET_BUF_SIZE];
-	    done = (*pktfunc)(dmaPacket, bytes, p);
-	}
-	/* mark the head as the new tail in the dma channel command list */
-	DBDMA_BUILD(dmaHead, DBDMA_CMD_STOP, 0, 0, 0, DBDMA_INT_ALWAYS,
-		    DBDMA_WAIT_NEVER, DBDMA_BRANCH_NEVER);
-	flush_dcache((vm_offset_t)dmaHead, 
-		sizeof(*dmaHead),
-		FALSE);
-	eieio();
-
-	/* make the tail an available dma'able entry */
-	{
-	    dbdma_command_t *		dmaTail;
-	    dmaTail = &m->rv_dma[m->rv_tail];
-	    address = kvtophys((vm_offset_t) 
-			       &m->rv_dma_area[m->rv_tail*ETHERNET_BUF_SIZE]);
-	    // this command is live so write it carefully
-	    DBDMA_ST4_ENDIAN(&dmaTail->d_address, address);
-	    dmaTail->d_status_resid = 0;
-	    dmaTail->d_cmddep = 0;
-	    eieio();
-	    DBDMA_ST4_ENDIAN(&dmaTail->d_cmd_count,
-			    ((DBDMA_CMD_IN_LAST) << 28) | ((0) << 24) |
-			    ((DBDMA_INT_ALWAYS) << 20) |
-			    ((DBDMA_BRANCH_NEVER) << 18) | ((DBDMA_WAIT_NEVER) << 16) |
-			    (ETHERNET_BUF_SIZE));
-	    eieio();
-	    flush_dcache((vm_offset_t)dmaTail, 
-			sizeof(*dmaTail),
-			FALSE);
-	}
-	/* head becomes the tail */
-	m->rv_tail = m->rv_head;
-
-	/* advance the head */
-	m->rv_head++;
-	if (m->rv_head == (ETHER_RX_NUM_DBDMA_BUFS + 1))
-	    m->rv_head = 0;
-    }
-    if (doContinue) {
-	sync();
-	dbdma_continue(m->rv_dbdma);
-    }
-    return (done);
-}
-
-static int
-kdp_mace_copy(char * pktBuf, int len, void * p)
-{
-    struct kdp_mace_copy_desc * cp = (struct kdp_mace_copy_desc *)p;
-
-    bcopy((char *)pktBuf, (char *)cp->data, len);
-    *cp->len = len;
-    return (1); /* signal that we're done */
-}
-
-/* kdb debugger routines */
-static void
-polled_send_pkt(char * data, int len)
-{
-    waitForDBDMADone("mace: polled_send_pkt start");
-    kdp_mace_tx_dbdma(data, len);
-    waitForDBDMADone("mace: polled_send_pkt end");
-    return;
-}
-
-static void
-polled_receive_pkt(char *data, int *len, int timeout_ms)
-{
-    struct kdp_mace_copy_desc cp;
-
-    cp.len = len;
-    cp.data = data;
-
-    timeout_ms *= 1000;
-    *len = 0;
-    while (kdp_mace_recv_pkt(kdp_mace_copy, (void *)&cp) == 0) {
-	if (timeout_ms <= 0)
-	    break;
-	delay(50);
-	timeout_ms -= 50;
-    }
-    return;
-}
diff --git a/osfmk/kdp/pe/POWERMAC/kdp_mace.h b/osfmk/kdp/pe/POWERMAC/kdp_mace.h
deleted file mode 100644
index f6e978bff..000000000
--- a/osfmk/kdp/pe/POWERMAC/kdp_mace.h
+++ /dev/null
@@ -1,389 +0,0 @@
-/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
- *
- * @APPLE_LICENSE_HEADER_START@
- * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
- * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
- * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
- * 
- * @APPLE_LICENSE_HEADER_END@
- */
-/*
- * Copyright 1996 1995 by Open Software Foundation, Inc. 1997 1996 1995 1994 1993 1992 1991  
- *              All Rights Reserved 
- *  
- * Permission to use, copy, modify, and distribute this software and 
- * its documentation for any purpose and without fee is hereby granted, 
- * provided that the above copyright notice appears in all copies and 
- * that both the copyright notice and this permission notice appear in 
- * supporting documentation. 
- *  
- * OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
- * FOR A PARTICULAR PURPOSE. 
- *  
- * IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR 
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, 
- * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION 
- * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 
- * 
- */
-/*
- * Copyright 1996 1995 by Apple Computer, Inc. 1997 1996 1995 1994 1993 1992 1991  
- *              All Rights Reserved 
- *  
- * Permission to use, copy, modify, and distribute this software and 
- * its documentation for any purpose and without fee is hereby granted, 
- * provided that the above copyright notice appears in all copies and 
- * that both the copyright notice and this permission notice appear in 
- * supporting documentation. 
- *  
- * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
- * FOR A PARTICULAR PURPOSE. 
- *  
- * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR 
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, 
- * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION 
- * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 
- */
-/*
- * MKLINUX-1.0DR2
- */
-/* 
- * PMach Operating System
- * Copyright (c) 1995 Santa Clara University
- * All Rights Reserved.
- */
-/* 
- * Mach Operating System
- * Copyright (c) 1991,1990,1989 Carnegie Mellon University
- * All Rights Reserved.
- * 
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- * 
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- * 
- * Carnegie Mellon requests users of this software to return to
- * 
- *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
- *  School of Computer Science
- *  Carnegie Mellon University
- *  Pittsburgh PA 15213-3890
- * 
- * any improvements or extensions that they make and grant Carnegie Mellon
- * the rights to redistribute these changes.
- */
-/*
- *	File:	if_3c501.h
- *	Author: Philippe Bernadat
- *	Date:	1989
- * 	Copyright (c) 1989 OSF Research Institute 
- *
- * 	3COM Etherlink 3C501 Mach Ethernet drvier
- */
-/*
-  Copyright 1990 by Open Software Foundation,
-Cambridge, MA.
-
-		All Rights Reserved
-
-  Permission to use, copy, modify, and distribute this software and
-its documentation for any purpose and without fee is hereby granted,
-provided that the above copyright notice appears in all copies and
-that both the copyright notice and this permission notice appear in
-supporting documentation, and that the name of OSF or Open Software
-Foundation not be used in advertising or publicity pertaining to
-distribution of the software without specific, written prior
-permission.
-
-  OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
-INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
-IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
-CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
-LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
-NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
-WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-*/
-
-
-
-#define ENETPAD(n)      char n[15] 
-
-/* 0x50f0a000 */
-struct mace_board {
-     volatile unsigned char   rcvfifo;  /* 00  receive fifo */
-     ENETPAD(epad0);
-     volatile unsigned char   xmtfifo;  /* 01  transmit fifo */
-     ENETPAD(epad1);
-     volatile unsigned char   xmtfc;    /* 02  transmit frame control */
-     ENETPAD(epad2);
-     volatile unsigned char   xmtfs;    /* 03  transmit frame status */
-     ENETPAD(epad3);
-     volatile unsigned char   xmtrc;    /* 04  transmit retry count */
-     ENETPAD(epad4);
-     volatile unsigned char   rcvfc;    /* 05  receive frame control -- 4 bytes */
-     ENETPAD(epad5); 
-     volatile unsigned char   rcvfs;    /* 06  receive frame status */
-     ENETPAD(epad6);
-     volatile unsigned char   fifofc;   /* 07  fifo frame count */
-     ENETPAD(epad7);
-     volatile unsigned char   ir;       /* 08  interrupt */
-     ENETPAD(epad8);
-     volatile unsigned char   imr;      /* 09  interrupt mask */
-     ENETPAD(epad9);
-     volatile unsigned char   pr;       /* 10  poll */
-     ENETPAD(epad10);
-     volatile unsigned char   biucc;    /* 11  bus interface unit configuration control */
-     ENETPAD(epad11);
-     volatile unsigned char   fifocc;   /* 12  fifo configuration control */
-     ENETPAD(epad12);
-     volatile unsigned char   maccc;    /* 13  media access control configuration control */
-     ENETPAD(epad13);
-     volatile unsigned char   plscc;    /* 14  physical layer signalling configuration control */
-     ENETPAD(epad14);
-     volatile unsigned char   phycc;    /* 15  physical layer configuration control */
-     ENETPAD(epad15);
-     volatile unsigned char   chipid1;  /* 16  chip identification LSB */
-     ENETPAD(epad16);
-     volatile unsigned char   chipid2;  /* 17  chip identification MSB */
-     ENETPAD(epad17);
-     volatile unsigned char   iac;      /* 18  internal address configuration */
-     ENETPAD(epad18);
-     volatile unsigned char   res1;     /* 19  */
-     ENETPAD(epad19);
-     volatile unsigned char   ladrf;    /* 20  logical address filter -- 8 bytes */
-     ENETPAD(epad20);
-     volatile unsigned char   padr;     /* 21  physical address -- 6 bytes */
-     ENETPAD(epad21);
-     volatile unsigned char   res2;     /* 22  */
-     ENETPAD(epad22);
-     volatile unsigned char   res3;     /* 23  */
-     ENETPAD(epad23);
-     volatile unsigned char   mpc;      /* 24  missed packet count */
-     ENETPAD(epad24);
-     volatile unsigned char   res4;     /* 25  */
-     ENETPAD(epad25);
-     volatile unsigned char   rntpc;    /* 26  runt packet count */
-     ENETPAD(epad26);
-     volatile unsigned char   rcvcc;    /* 27  receive collision count */
-     ENETPAD(epad27);
-     volatile unsigned char   res5;     /* 28  */
-     ENETPAD(epad28);
-     volatile unsigned char   utr;      /* 29  user test */
-     ENETPAD(epad29);
-     volatile unsigned char   res6;     /* 30  */
-     ENETPAD(epad30);
-     volatile unsigned char   res7;     /* 31  */
-     };
-
-/*
- * Chip Revisions..
- */
-
-#define	MACE_REVISION_B0	0x0940
-#define	MACE_REVISION_A2	0x0941
-
-/* xmtfc */
-#define XMTFC_DRTRY       0X80
-#define XMTFC_DXMTFCS     0x08
-#define XMTFC_APADXNT     0x01
-
-/* xmtfs */
-#define XMTFS_XNTSV  	0x80
-#define XMTFS_XMTFS  	0x40
-#define XMTFS_LCOL   	0x20
-#define XMTFS_MORE   	0x10
-#define XMTFS_ONE    	0x08
-#define XMTFS_DEFER  	0x04
-#define XMTFS_LCAR   	0x02
-#define XMTFS_RTRY   	0x01
-
-/* xmtrc */
-#define XMTRC_EXDEF  0x80
-
-/* rcvfc */
-#define RCVFC_LLRCV       0x08
-#define RCVFC_M_R         0x04
-#define RCVFC_ASTRPRCV    0x01
-
-/* rcvfs */
-#define RCVFS_OFLO   	0x80
-#define RCVFS_CLSN   	0x40
-#define RCVFS_FRAM   	0x20
-#define RCVFS_FCS    	0x10
-#define RCVFS_REVCNT 	0x0f
-
-/* fifofc */
-#define	FIFOCC_XFW_8	0x00 
-#define	FIFOCC_XFW_16	0x40 
-#define	FIFOCC_XFW_32	0x80 
-#define	FIFOCC_XFW_XX	0xc0 
-#define	FIFOCC_RFW_16	0x00 
-#define	FIFOCC_RFW_32	0x10 
-#define	FIFOCC_RFW_64	0x20 
-#define	FIFOCC_RFW_XX	0x30 
-#define FIFOCC_XFWU	0x08	
-#define FIFOCC_RFWU	0x04	
-#define FIFOCC_XBRST	0x02	
-#define FIFOCC_RBRST	0x01	
-
-
-/* ir */
-#define IR_JAB    	0x80
-#define IR_BABL   	0x40
-#define IR_CERR   	0x20
-#define IR_RCVCCO 	0x10
-#define IR_RNTPCO 	0x08
-#define IR_MPCO   	0x04
-#define IR_RCVINT 	0x02
-#define IR_XMTINT 	0x01
-
-/* imr */
-#define IMR_MJAB    	0x80
-#define IMR_MBABL   	0x40
-#define IMR_MCERR   	0x20
-#define IMR_MRCVCCO 	0x10
-#define IMR_MRNTPCO 	0x08
-#define IMR_MMPCO   	0x04
-#define IMR_MRCVINT 	0x02
-#define IMR_MXMTINT 	0x01
-
-/* pr */
-#define PR_XMTSV  	0x80
-#define PR_TDTREQ 	0x40
-#define PR_RDTREQ 	0x20
-
-/* biucc */
-#define BIUCC_BSWP        0x40
-#define BIUCC_XMTSP04     0x00
-#define BIUCC_XMTSP16     0x10
-#define BIUCC_XMTSP64     0x20
-#define BIUCC_XMTSP112    0x30
-#define BIUCC_SWRST       0x01
-
-/* fifocc */
-#define FIFOCC_XMTFW08W    0x00
-#define FIFOCC_XMTFW16W    0x40
-#define FIFOCC_XMTFW32W    0x80
-
-#define FIFOCC_RCVFW16     0x00     
-#define FIFOCC_RCVFW32     0x10
-#define FIFOCC_RCVFW64     0x20
-
-#define FIFOCC_XMTFWU      0x08
-#define FIFOCC_RCVFWU      0x04
-#define FIFOCC_XMTBRST     0x02
-#define FIFOCC_RCVBRST     0x01
-
-/* maccc */
-#define MACCC_PROM        0x80
-#define MACCC_DXMT2PD     0x40
-#define MACCC_EMBA        0x20
-#define MACCC_DRCVPA      0x08
-#define MACCC_DRCVBC      0x04
-#define MACCC_ENXMT       0x02
-#define MACCC_ENRCV       0x01
-
-/* plscc */
-#define PLSCC_XMTSEL      0x08
-#define PLSCC_AUI         0x00
-#define PLSCC_TENBASE     0x02
-#define PLSCC_DAI         0x04
-#define PLSCC_GPSI        0x06
-#define PLSCC_ENPLSIO     0x01
-
-/* phycc */
-#define PHYCC_LNKFL       0x80
-#define PHYCC_DLNKTST     0x40
-#define PHYCC_REVPOL      0x20
-#define PHYCC_DAPC        0x10
-#define PHYCC_LRT         0x08
-#define PHYCC_ASEL        0x04
-#define PHYCC_RWAKE       0x02
-#define PHYCC_AWAKE       0x01
-
-/* iac */
-#define IAC_ADDRCHG     0x80
-#define IAC_PHYADDR     0x04
-#define IAC_LOGADDR     0x02
-
-/* utr */
-#define UTR_RTRE        0x80
-#define UTR_RTRD        0x40
-#define UTR_RPA         0x20
-#define UTR_FCOLL       0x10
-#define UTR_RCVFCSE     0x08
-
-#define UTR_NOLOOP      0x00
-#define UTR_EXTLOOP     0x02
-#define UTR_INLOOP      0x04
-#define UTR_INLOOP_M    0x06
-
-#define ENET_PHYADDR_LEN	6
-#define ENET_HEADER         14
-
-#define BFRSIZ		2048
-#define ETHER_ADD_SIZE	6	/* size of a MAC address */
-#define	DSF_LOCK	1
-#define DSF_RUNNING	2
-#define MOD_ENAL 1
-#define MOD_PROM 2
-
-/*
- * MACE Chip revision codes
- */
-#define MACERevA2       0x0941
-#define MACERevB0       0x0940
-
-/*
- * Defines and device state
- * Dieter Siegmund (dieter@next.com) Thu Feb 27 18:25:33 PST 1997
- */
-
-#define PG_SIZE         0x1000UL
-#define PG_MASK         (PG_SIZE - 1UL)
-
-#define ETHERMTU                1500
-#define ETHER_RX_NUM_DBDMA_BUFS 32
-#define ETHERNET_BUF_SIZE       (ETHERMTU + 36)
-#define ETHER_MIN_PACKET        64
-#define TX_NUM_DBDMA            6
-#define NUM_EN_ADDR_BYTES   6
-
-#define DBDMA_ETHERNET_EOP      0x40
-
-typedef struct mace_s {
-    struct mace_board *         ereg;   /* ethernet register set address */
-    dbdma_regmap_t *		tx_dbdma;
-    dbdma_regmap_t *		rv_dbdma;
-    unsigned char               macaddr[NUM_EN_ADDR_BYTES]; /* mac address */
-    int                         chip_id;
-    dbdma_command_t             *rv_dma;
-    dbdma_command_t             *tx_dma;
-    unsigned char               *rv_dma_area;
-    unsigned char               *tx_dma_area;
-    int                         rv_tail;
-    int                         rv_head;
-} mace_t;
-
-
diff --git a/osfmk/kern/assert.h b/osfmk/kern/assert.h
index 42718d5ca..278cd577a 100644
--- a/osfmk/kern/assert.h
+++ b/osfmk/kern/assert.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/ast.c b/osfmk/kern/ast.c
index 848c13caf..0764da904 100644
--- a/osfmk/kern/ast.c
+++ b/osfmk/kern/ast.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/ast.h b/osfmk/kern/ast.h
index 9d2a912c0..3df0a0460 100644
--- a/osfmk/kern/ast.h
+++ b/osfmk/kern/ast.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/bits.c b/osfmk/kern/bits.c
index 085ccd9a6..151888d82 100644
--- a/osfmk/kern/bits.c
+++ b/osfmk/kern/bits.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/bsd_kern.c b/osfmk/kern/bsd_kern.c
index 6b27ea5a9..34afe5ae2 100644
--- a/osfmk/kern/bsd_kern.c
+++ b/osfmk/kern/bsd_kern.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -231,6 +234,17 @@ int  get_task_numacts(task_t t)
 	return(t->thr_act_count);
 }
 
+
+/* does this machine need  64bit register set for signal handler */
+int is_64signalregset(void)
+{
+	task_t t = current_task();
+	if(t->taskFeatures[0] & tf64BitData)
+		return(1);
+	else
+		return(0);
+}
+
 /*
  * Reset the current task's map by taking a reference
  * on the new map.  The old map reference is returned.
diff --git a/osfmk/kern/call_entry.h b/osfmk/kern/call_entry.h
index ad846bf5c..e172384ae 100644
--- a/osfmk/kern/call_entry.h
+++ b/osfmk/kern/call_entry.h
@@ -4,19 +4,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/clock.c b/osfmk/kern/clock.c
index b6a263b70..8f7480979 100644
--- a/osfmk/kern/clock.c
+++ b/osfmk/kern/clock.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/clock.h b/osfmk/kern/clock.h
index 26cefa13c..25dfac50e 100644
--- a/osfmk/kern/clock.h
+++ b/osfmk/kern/clock.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -186,6 +189,10 @@ extern int64_t		clock_set_calendar_adjtime(
 
 extern void			clock_initialize_calendar(void);
 
+extern void			clock_gettimeofday(
+                        uint32_t			*secs,
+                        uint32_t			*microsecs);
+
 #endif	/* __APPLE_API_PRIVATE */
 
 #ifdef	__APPLE_API_UNSTABLE
diff --git a/osfmk/kern/counters.c b/osfmk/kern/counters.c
index 5116219f0..2b1fbf18f 100644
--- a/osfmk/kern/counters.c
+++ b/osfmk/kern/counters.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/counters.h b/osfmk/kern/counters.h
index 7921e0172..b2c44767b 100644
--- a/osfmk/kern/counters.h
+++ b/osfmk/kern/counters.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/cpu_data.c b/osfmk/kern/cpu_data.c
index 10d1afb1f..4c255ec3e 100644
--- a/osfmk/kern/cpu_data.c
+++ b/osfmk/kern/cpu_data.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/cpu_data.h b/osfmk/kern/cpu_data.h
index 1bd1c9e16..9a2ffafc6 100644
--- a/osfmk/kern/cpu_data.h
+++ b/osfmk/kern/cpu_data.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/cpu_number.h b/osfmk/kern/cpu_number.h
index 59d1f50c4..d08d17ea5 100644
--- a/osfmk/kern/cpu_number.h
+++ b/osfmk/kern/cpu_number.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/debug.c b/osfmk/kern/debug.c
index 7793cb8c2..f698c52cf 100644
--- a/osfmk/kern/debug.c
+++ b/osfmk/kern/debug.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/debug.h b/osfmk/kern/debug.h
index 990b10f95..a2d96f047 100644
--- a/osfmk/kern/debug.h
+++ b/osfmk/kern/debug.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/etap.c b/osfmk/kern/etap.c
index d1f5ad913..0a5303767 100644
--- a/osfmk/kern/etap.c
+++ b/osfmk/kern/etap.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/etap_macros.h b/osfmk/kern/etap_macros.h
index 530522648..896c0f4a7 100644
--- a/osfmk/kern/etap_macros.h
+++ b/osfmk/kern/etap_macros.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/etap_map.c b/osfmk/kern/etap_map.c
index 76b125c60..3676080bf 100644
--- a/osfmk/kern/etap_map.c
+++ b/osfmk/kern/etap_map.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/etap_map.h b/osfmk/kern/etap_map.h
index 1e6349d0f..6cbce6947 100644
--- a/osfmk/kern/etap_map.h
+++ b/osfmk/kern/etap_map.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/etap_options.h b/osfmk/kern/etap_options.h
index 4af3a4022..45ee48b20 100644
--- a/osfmk/kern/etap_options.h
+++ b/osfmk/kern/etap_options.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/etap_pool.c b/osfmk/kern/etap_pool.c
index afb69bdd7..24b665596 100644
--- a/osfmk/kern/etap_pool.c
+++ b/osfmk/kern/etap_pool.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/etap_pool.h b/osfmk/kern/etap_pool.h
index 7114cd52b..b4d18b366 100644
--- a/osfmk/kern/etap_pool.h
+++ b/osfmk/kern/etap_pool.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/exception.c b/osfmk/kern/exception.c
index b99139fc2..682ba555d 100644
--- a/osfmk/kern/exception.c
+++ b/osfmk/kern/exception.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -52,6 +55,7 @@
 
 #include <mach_kdb.h>
 
+#include <mach/mach_types.h>
 #include <mach/boolean.h>
 #include <mach/kern_return.h>
 #include <mach/message.h>
diff --git a/osfmk/kern/exception.h b/osfmk/kern/exception.h
index 360da95fc..a75a36c76 100644
--- a/osfmk/kern/exception.h
+++ b/osfmk/kern/exception.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/host.c b/osfmk/kern/host.c
index 2d13930a1..308885c44 100644
--- a/osfmk/kern/host.c
+++ b/osfmk/kern/host.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -511,7 +514,7 @@ host_processor_info(
 		if (machine_slot[i].is_cpu)
 			num++;
 
-	size = (vm_size_t)round_page(num * count * sizeof(natural_t));
+	size = (vm_size_t)round_page_32(num * count * sizeof(natural_t));
 
 	kr = vm_allocate(ipc_kernel_map, &addr, size, TRUE);
 	if (kr != KERN_SUCCESS)
diff --git a/osfmk/kern/host.h b/osfmk/kern/host.h
index 1318ec508..bf3800d50 100644
--- a/osfmk/kern/host.h
+++ b/osfmk/kern/host.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/host_statistics.h b/osfmk/kern/host_statistics.h
index 2d5da2207..d5965452e 100644
--- a/osfmk/kern/host_statistics.h
+++ b/osfmk/kern/host_statistics.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/ipc_clock.c b/osfmk/kern/ipc_clock.c
index a8524dbe5..ac0cfeece 100644
--- a/osfmk/kern/ipc_clock.c
+++ b/osfmk/kern/ipc_clock.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/ipc_host.c b/osfmk/kern/ipc_host.c
index 4c3aa3b45..23d830ffd 100644
--- a/osfmk/kern/ipc_host.c
+++ b/osfmk/kern/ipc_host.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/ipc_host.h b/osfmk/kern/ipc_host.h
index 6b4a0916b..01701d24a 100644
--- a/osfmk/kern/ipc_host.h
+++ b/osfmk/kern/ipc_host.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/ipc_kobject.c b/osfmk/kern/ipc_kobject.c
index 95fbf3885..06898cc5f 100644
--- a/osfmk/kern/ipc_kobject.c
+++ b/osfmk/kern/ipc_kobject.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/ipc_kobject.h b/osfmk/kern/ipc_kobject.h
index 39365d613..a3595a6a2 100644
--- a/osfmk/kern/ipc_kobject.h
+++ b/osfmk/kern/ipc_kobject.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/ipc_mig.c b/osfmk/kern/ipc_mig.c
index 903215823..a880cdea1 100644
--- a/osfmk/kern/ipc_mig.c
+++ b/osfmk/kern/ipc_mig.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/ipc_mig.h b/osfmk/kern/ipc_mig.h
index e962d46f1..637b78fad 100644
--- a/osfmk/kern/ipc_mig.h
+++ b/osfmk/kern/ipc_mig.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/ipc_sync.c b/osfmk/kern/ipc_sync.c
index 34c8ffc00..37ced9071 100644
--- a/osfmk/kern/ipc_sync.c
+++ b/osfmk/kern/ipc_sync.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/ipc_sync.h b/osfmk/kern/ipc_sync.h
index 5d18af44d..e9e7a07c8 100644
--- a/osfmk/kern/ipc_sync.h
+++ b/osfmk/kern/ipc_sync.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/ipc_tt.c b/osfmk/kern/ipc_tt.c
index f387287a5..2cb2d6ef1 100644
--- a/osfmk/kern/ipc_tt.c
+++ b/osfmk/kern/ipc_tt.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -56,6 +59,7 @@
  *	Task and thread related IPC functions.
  */
 
+#include <mach/mach_types.h>
 #include <mach/boolean.h>
 #include <mach_rt.h>
 #include <mach/kern_return.h>
diff --git a/osfmk/kern/ipc_tt.h b/osfmk/kern/ipc_tt.h
index ded87c88c..a14b5eae3 100644
--- a/osfmk/kern/ipc_tt.h
+++ b/osfmk/kern/ipc_tt.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/kalloc.c b/osfmk/kern/kalloc.c
index a67c71d14..7a135a654 100644
--- a/osfmk/kern/kalloc.c
+++ b/osfmk/kern/kalloc.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -435,8 +438,8 @@ krealloc(
 	/* if old block was kmem_alloc'd, then use kmem_realloc if necessary */
 
 	if (old_size >= kalloc_max_prerounded) {
-		old_size = round_page(old_size);
-		new_size = round_page(new_size);
+		old_size = round_page_32(old_size);
+		new_size = round_page_32(new_size);
 		if (new_size > old_size) {
 
 			if (kmem_realloc(kalloc_map, *addrp, old_size, &naddr,
diff --git a/osfmk/kern/kalloc.h b/osfmk/kern/kalloc.h
index 657848b41..2baeb5a72 100644
--- a/osfmk/kern/kalloc.h
+++ b/osfmk/kern/kalloc.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/kern_print.h b/osfmk/kern/kern_print.h
index 2a5b7d062..8d4e54387 100644
--- a/osfmk/kern/kern_print.h
+++ b/osfmk/kern/kern_print.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/kern_types.h b/osfmk/kern/kern_types.h
index 13f58fb74..34d5ed68f 100644
--- a/osfmk/kern/kern_types.h
+++ b/osfmk/kern/kern_types.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/kmod.c b/osfmk/kern/kmod.c
index 0de60c5ce..cb42a9f6a 100644
--- a/osfmk/kern/kmod.c
+++ b/osfmk/kern/kmod.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -788,7 +791,7 @@ kmod_dump(vm_offset_t *addr, unsigned int cnt)
         if (!k->address) {
             continue; // skip fake entries for built-in kernel components
         }
-        if (pmap_extract(kernel_pmap, (vm_offset_t)k) == 0) {
+        if (pmap_find_phys(kernel_pmap, (addr64_t)k) == 0) {
             kdb_printf("         kmod scan stopped due to missing "
                 "kmod page: %08x\n", stop_kmod);
             break;
@@ -808,7 +811,7 @@ kmod_dump(vm_offset_t *addr, unsigned int cnt)
                 for (r = k->reference_list; r; r = r->next) {
                     kmod_info_t * rinfo;
 
-                    if (pmap_extract(kernel_pmap, (vm_offset_t)r) == 0) {
+                    if (pmap_find_phys(kernel_pmap, (addr64_t)r) == 0) {
                         kdb_printf("            kmod dependency scan stopped "
                             "due to missing dependency page: %08x\n", r);
                         break;
@@ -820,7 +823,7 @@ kmod_dump(vm_offset_t *addr, unsigned int cnt)
                         continue; // skip fake entries for built-ins
                     }
 
-                    if (pmap_extract(kernel_pmap, (vm_offset_t)rinfo) == 0) {
+                    if (pmap_find_phys(kernel_pmap, (addr64_t)rinfo) == 0) {
                         kdb_printf("            kmod dependency scan stopped "
                             "due to missing kmod page: %08x\n", rinfo);
                         break;
diff --git a/osfmk/kern/ledger.c b/osfmk/kern/ledger.c
index e7e897c49..d70952ba7 100644
--- a/osfmk/kern/ledger.c
+++ b/osfmk/kern/ledger.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/ledger.h b/osfmk/kern/ledger.h
index afad3b628..e17537298 100644
--- a/osfmk/kern/ledger.h
+++ b/osfmk/kern/ledger.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/lock.c b/osfmk/kern/lock.c
index 0475b12b0..2e2080ab3 100644
--- a/osfmk/kern/lock.c
+++ b/osfmk/kern/lock.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -78,7 +81,6 @@
 
 #ifdef __ppc__
 #include <ppc/Firmware.h>
-#include <ppc/POWERMAC/mp/MPPlugIn.h>
 #endif
 
 #include <sys/kdebug.h>
@@ -213,9 +215,13 @@ usimple_lock_init(
 	usimple_lock_t	l,
 	etap_event_t	event)
 {
+#ifndef	MACHINE_SIMPLE_LOCK
 	USLDBG(usld_lock_init(l, event));
 	ETAPCALL(etap_simplelock_init((l),(event)));
 	hw_lock_init(&l->interlock);
+#else
+	simple_lock_init(l,event);
+#endif
 }
 
 
@@ -230,6 +236,7 @@ void
 usimple_lock(
 	usimple_lock_t	l)
 {
+#ifndef	MACHINE_SIMPLE_LOCK
 	int i;
 	pc_t		pc;
 #if	ETAP_LOCK_TRACE
@@ -251,6 +258,9 @@ usimple_lock(
 
 	ETAPCALL(etap_simplelock_hold(l, pc, start_wait_time));
 	USLDBG(usld_lock_post(l, pc));
+#else
+	simple_lock(l);
+#endif
 }
 
 
@@ -265,6 +275,7 @@ void
 usimple_unlock(
 	usimple_lock_t	l)
 {
+#ifndef	MACHINE_SIMPLE_LOCK
 	pc_t	pc;
 
 //	checkNMI();										/* (TEST/DEBUG) */
@@ -272,7 +283,13 @@ usimple_unlock(
 	OBTAIN_PC(pc, l);
 	USLDBG(usld_unlock(l, pc));
 	ETAPCALL(etap_simplelock_unlock(l));
+#ifdef  __ppc__
+	sync();
+#endif
 	hw_lock_unlock(&l->interlock);
+#else
+	simple_unlock_rwmb(l);
+#endif
 }
 
 
@@ -292,6 +309,7 @@ unsigned int
 usimple_lock_try(
 	usimple_lock_t	l)
 {
+#ifndef	MACHINE_SIMPLE_LOCK
 	pc_t		pc;
 	unsigned int	success;
 	etap_time_t	zero_time;
@@ -304,6 +322,9 @@ usimple_lock_try(
 		ETAPCALL(etap_simplelock_hold(l, pc, zero_time));
 	}
 	return success;
+#else
+	return(simple_lock_try(l));
+#endif
 }
 
 #if ETAP_LOCK_TRACE
diff --git a/osfmk/kern/lock.h b/osfmk/kern/lock.h
index 5119b8959..6ffdea90d 100644
--- a/osfmk/kern/lock.h
+++ b/osfmk/kern/lock.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/lock_mon.c b/osfmk/kern/lock_mon.c
index 05cfb54a3..37ef12ed9 100644
--- a/osfmk/kern/lock_mon.c
+++ b/osfmk/kern/lock_mon.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/mach_clock.c b/osfmk/kern/mach_clock.c
index 1d922cac4..c0b234c63 100644
--- a/osfmk/kern/mach_clock.c
+++ b/osfmk/kern/mach_clock.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/mach_factor.c b/osfmk/kern/mach_factor.c
index 3b86b6970..47a8b3e25 100644
--- a/osfmk/kern/mach_factor.c
+++ b/osfmk/kern/mach_factor.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/mach_param.h b/osfmk/kern/mach_param.h
index db780aca1..6451b3769 100644
--- a/osfmk/kern/mach_param.h
+++ b/osfmk/kern/mach_param.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/machine.c b/osfmk/kern/machine.c
index 0ef1b7e90..bb76bcf96 100644
--- a/osfmk/kern/machine.c
+++ b/osfmk/kern/machine.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -457,17 +460,18 @@ void
 processor_doshutdown(
 	processor_t		processor)
 {
-	register int	cpu = processor->slot_num;
+	register thread_t	old_thread = current_thread();
+	register int		cpu = processor->slot_num;
 
 	timer_call_cancel(&processor->quantum_timer);
-	thread_dispatch(current_thread());
 	timer_switch(&kernel_timer[cpu]);
+	thread_machine_set_current(processor->idle_thread);
+	thread_dispatch(old_thread);
 
 	/*
 	 *	OK, now exit this cpu.
 	 */
 	PMAP_DEACTIVATE_KERNEL(cpu);
-	thread_machine_set_current(processor->idle_thread);
 	cpu_down(cpu);
 	cpu_sleep();
 	panic("zombie processor");
diff --git a/osfmk/kern/machine.h b/osfmk/kern/machine.h
index 5c3f211f4..4ad3e6931 100644
--- a/osfmk/kern/machine.h
+++ b/osfmk/kern/machine.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/macro_help.h b/osfmk/kern/macro_help.h
index eeaf1ae97..b7e838fb9 100644
--- a/osfmk/kern/macro_help.h
+++ b/osfmk/kern/macro_help.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/misc_protos.h b/osfmk/kern/misc_protos.h
index 181bb0fed..0419d720c 100644
--- a/osfmk/kern/misc_protos.h
+++ b/osfmk/kern/misc_protos.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -117,6 +120,8 @@ extern integer_t sprintf(char *buf, const char *fmt, ...);
 
 extern void printf(const char *format, ...);
 
+extern void dbugprintf(const char *format, ...);
+
 extern void kdp_printf(const char *format, ...);
 
 extern void printf_init(void);
diff --git a/osfmk/kern/mk_sp.c b/osfmk/kern/mk_sp.c
index 384d1bf79..f976f5f51 100644
--- a/osfmk/kern/mk_sp.c
+++ b/osfmk/kern/mk_sp.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/mk_sp.h b/osfmk/kern/mk_sp.h
index fe78f7808..2f2381af6 100644
--- a/osfmk/kern/mk_sp.h
+++ b/osfmk/kern/mk_sp.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/mk_timer.c b/osfmk/kern/mk_timer.c
index 668072763..da3c92583 100644
--- a/osfmk/kern/mk_timer.c
+++ b/osfmk/kern/mk_timer.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/mk_timer.h b/osfmk/kern/mk_timer.h
index 3ac2e415c..e630fdbe9 100644
--- a/osfmk/kern/mk_timer.h
+++ b/osfmk/kern/mk_timer.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/norma_protos.h b/osfmk/kern/norma_protos.h
index d00d2901a..ab0eb5a75 100644
--- a/osfmk/kern/norma_protos.h
+++ b/osfmk/kern/norma_protos.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/printf.c b/osfmk/kern/printf.c
index 472ab86c2..ece7a7806 100644
--- a/osfmk/kern/printf.c
+++ b/osfmk/kern/printf.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -150,6 +153,9 @@
  * output bases such as x, X, u, U, o, and O also work.
  */
 
+#include <debug.h>
+#include <mach_kdb.h>
+#include <mach_kdp.h>
 #include <platforms.h>
 #include <mach/boolean.h>
 #include <cpus.h>
@@ -718,6 +724,22 @@ conslog_putc(
 #endif
 }
 
+void
+dbugprintf(const char *fmt, ...)
+{
+
+#if	MACH_KDB
+
+	extern void db_putchar(char c);
+	va_list	listp;
+
+	va_start(listp, fmt);
+	_doprnt(fmt, &listp, db_putchar, 16);
+	va_end(listp);
+#endif
+	return;
+}
+
 void
 printf(const char *fmt, ...)
 {
diff --git a/osfmk/kern/priority.c b/osfmk/kern/priority.c
index 084e8fe2c..23f5e43f0 100644
--- a/osfmk/kern/priority.c
+++ b/osfmk/kern/priority.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/processor.c b/osfmk/kern/processor.c
index 243afa7af..c9251cc75 100644
--- a/osfmk/kern/processor.c
+++ b/osfmk/kern/processor.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/processor.h b/osfmk/kern/processor.h
index be99fc1e7..5ecbbc539 100644
--- a/osfmk/kern/processor.h
+++ b/osfmk/kern/processor.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/profile.c b/osfmk/kern/profile.c
index 599765fc8..1b3bfa0c3 100644
--- a/osfmk/kern/profile.c
+++ b/osfmk/kern/profile.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/profile.h b/osfmk/kern/profile.h
index 5124b2316..31e890bea 100644
--- a/osfmk/kern/profile.h
+++ b/osfmk/kern/profile.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/queue.c b/osfmk/kern/queue.c
index 2ada9236d..b7ca7cf92 100644
--- a/osfmk/kern/queue.c
+++ b/osfmk/kern/queue.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/queue.h b/osfmk/kern/queue.h
index bdb700fb3..ee25fb8ff 100644
--- a/osfmk/kern/queue.h
+++ b/osfmk/kern/queue.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/sched.h b/osfmk/kern/sched.h
index 62c06f5ed..6f5c9d398 100644
--- a/osfmk/kern/sched.h
+++ b/osfmk/kern/sched.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/sched_prim.c b/osfmk/kern/sched_prim.c
index c45c31048..47165b49c 100644
--- a/osfmk/kern/sched_prim.c
+++ b/osfmk/kern/sched_prim.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -1598,8 +1601,6 @@ thread_block_reason(
 
 	check_simple_locks();
 
-	machine_clock_assist();
-
 	s = splsched();
 
 	if ((thread->funnel_state & TH_FN_OWNED) && !(reason & AST_PREEMPT)) {
@@ -1680,8 +1681,6 @@ thread_run(
 
 	assert(old_thread == current_thread());
 
-	machine_clock_assist();
-
 	if (old_thread->funnel_state & TH_FN_OWNED) {
 		old_thread->funnel_state = TH_FN_REFUNNEL;
 		KERNEL_DEBUG(
@@ -2419,8 +2418,6 @@ idle_thread_continue(void)
 #else
 				(void)spllo();
 #endif
-	        machine_clock_assist();
-
 			(void)splsched();
 		}
 
diff --git a/osfmk/kern/sched_prim.h b/osfmk/kern/sched_prim.h
index 758c22e20..47ed03dbc 100644
--- a/osfmk/kern/sched_prim.h
+++ b/osfmk/kern/sched_prim.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/simple_lock.h b/osfmk/kern/simple_lock.h
index 708998e56..44436c742 100644
--- a/osfmk/kern/simple_lock.h
+++ b/osfmk/kern/simple_lock.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/simple_lock_types.h b/osfmk/kern/simple_lock_types.h
index 72b0a2f50..5a5bf702c 100644
--- a/osfmk/kern/simple_lock_types.h
+++ b/osfmk/kern/simple_lock_types.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/spl.c b/osfmk/kern/spl.c
index 15d7cf72e..9eeab1dd9 100644
--- a/osfmk/kern/spl.c
+++ b/osfmk/kern/spl.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/spl.h b/osfmk/kern/spl.h
index e7553a211..bb256b467 100644
--- a/osfmk/kern/spl.h
+++ b/osfmk/kern/spl.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/sscanf.c b/osfmk/kern/sscanf.c
index ade695877..9fca32155 100644
--- a/osfmk/kern/sscanf.c
+++ b/osfmk/kern/sscanf.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/startup.c b/osfmk/kern/startup.c
index 0972af8e1..f5ca35a41 100644
--- a/osfmk/kern/startup.c
+++ b/osfmk/kern/startup.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -83,6 +86,7 @@
 #include <kern/timer_call.h>
 #include <kern/xpr.h>
 #include <kern/zalloc.h>
+#include <vm/vm_shared_memory_server.h>
 #include <vm/vm_kern.h>
 #include <vm/vm_init.h>
 #include <vm/vm_map.h>
@@ -90,6 +94,7 @@
 #include <vm/vm_page.h>
 #include <vm/vm_pageout.h>
 #include <machine/pmap.h>
+#include <machine/commpage.h>
 #include <sys/version.h>
 
 #ifdef __ppc__
@@ -255,20 +260,25 @@ start_kernel_threads(void)
 	 */
 	device_service_create();
 
-	shared_file_boot_time_init();
+	shared_file_boot_time_init(ENV_DEFAULT_SYSTEM, ENV_DEFAULT_ROOT);
 
 #ifdef	IOKIT
 	{
 		PE_init_iokit();
 	}
 #endif
+	
+	(void) spllo();		/* Allow interruptions */
+
+    /*
+     *	Fill in the comm area (mapped into every task address space.)
+     */
+    commpage_populate();
 
 	/*
 	 *	Start the user bootstrap.
 	 */
 	
-	(void) spllo();		/* Allow interruptions */
-	
 #ifdef	MACH_BSD
 	{ 
 		extern void bsd_init(void);
@@ -276,6 +286,10 @@ start_kernel_threads(void)
 	}
 #endif
 
+#if __ppc__
+	serial_keyboard_init();		/* Start serial keyboard if wanted */
+#endif
+
 	thread_bind(current_thread(), PROCESSOR_NULL);
 
 	/*
diff --git a/osfmk/kern/startup.h b/osfmk/kern/startup.h
index bbd76a447..62cb3fa1c 100644
--- a/osfmk/kern/startup.h
+++ b/osfmk/kern/startup.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/sync_lock.c b/osfmk/kern/sync_lock.c
index 9acae3739..d11aa1f89 100644
--- a/osfmk/kern/sync_lock.c
+++ b/osfmk/kern/sync_lock.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/sync_lock.h b/osfmk/kern/sync_lock.h
index 99f2d098c..70a142bd0 100644
--- a/osfmk/kern/sync_lock.h
+++ b/osfmk/kern/sync_lock.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/sync_sema.c b/osfmk/kern/sync_sema.c
index 34618b4b5..6ca013208 100644
--- a/osfmk/kern/sync_sema.c
+++ b/osfmk/kern/sync_sema.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/sync_sema.h b/osfmk/kern/sync_sema.h
index 8d50bcfa7..c25950a93 100644
--- a/osfmk/kern/sync_sema.h
+++ b/osfmk/kern/sync_sema.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/syscall_emulation.c b/osfmk/kern/syscall_emulation.c
index 843dd5a1e..308e3ef7c 100644
--- a/osfmk/kern/syscall_emulation.c
+++ b/osfmk/kern/syscall_emulation.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -374,10 +377,10 @@ task_set_emulation_vector(
 	 *	Can't fault while we hold locks.
 	 */
 	kr = vm_map_wire(ipc_kernel_map,
-			     trunc_page(emul_vector_addr),
-			     round_page(emul_vector_addr +
-					emulation_vector_count *
-					sizeof(eml_dispatch_t)),
+			     trunc_page_32(emul_vector_addr),
+			     round_page_32(emul_vector_addr +
+					   emulation_vector_count *
+					   sizeof(eml_dispatch_t)),
 			     VM_PROT_READ|VM_PROT_WRITE, FALSE);
 	assert(kr == KERN_SUCCESS);
 
@@ -444,7 +447,7 @@ task_get_emulation_vector(
 	     */
 	    vector_size = eml->disp_count * sizeof(vm_offset_t);
 
-	    size_needed = round_page(vector_size);
+	    size_needed = round_page_32(vector_size);
 	    if (size_needed <= size)
 		break;
 
@@ -481,7 +484,7 @@ task_get_emulation_vector(
 	/*
 	 * Free any unused memory beyond the end of the last page used
 	 */
-	size_used = round_page(vector_size);
+	size_used = round_page_32(vector_size);
 	if (size_used != size)
 	    (void) kmem_free(ipc_kernel_map,
 			     addr + size_used,
diff --git a/osfmk/kern/syscall_emulation.h b/osfmk/kern/syscall_emulation.h
index baf87c667..8b7e44771 100644
--- a/osfmk/kern/syscall_emulation.h
+++ b/osfmk/kern/syscall_emulation.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/syscall_subr.c b/osfmk/kern/syscall_subr.c
index 886f49f00..dd4716262 100644
--- a/osfmk/kern/syscall_subr.c
+++ b/osfmk/kern/syscall_subr.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/syscall_subr.h b/osfmk/kern/syscall_subr.h
index 80c86fe82..a147e3d55 100644
--- a/osfmk/kern/syscall_subr.h
+++ b/osfmk/kern/syscall_subr.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/syscall_sw.c b/osfmk/kern/syscall_sw.c
index bd96882de..f44d5cd26 100644
--- a/osfmk/kern/syscall_sw.c
+++ b/osfmk/kern/syscall_sw.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/syscall_sw.h b/osfmk/kern/syscall_sw.h
index c8b3d31bd..1272c1863 100644
--- a/osfmk/kern/syscall_sw.h
+++ b/osfmk/kern/syscall_sw.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/task.c b/osfmk/kern/task.c
index ea12d7b39..aef657a27 100644
--- a/osfmk/kern/task.c
+++ b/osfmk/kern/task.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -112,6 +115,11 @@
 #include <kern/task_swap.h>
 #endif	/* TASK_SWAPPER */
 
+#ifdef __ppc__
+#include <ppc/exception.h>
+#include <ppc/hw_perfmon.h>
+#endif
+
 /*
  * Exported interfaces
  */
@@ -349,8 +357,8 @@ task_create_local(
 		new_task->map = vm_map_fork(parent_task->map);
 	else
 		new_task->map = vm_map_create(pmap_create(0),
-					round_page(VM_MIN_ADDRESS),
-					trunc_page(VM_MAX_ADDRESS), TRUE);
+					round_page_32(VM_MIN_ADDRESS),
+					trunc_page_32(VM_MAX_ADDRESS), TRUE);
 
 	mutex_init(&new_task->lock, ETAP_THREAD_TASK_NEW);
 	queue_init(&new_task->thr_acts);
@@ -371,6 +379,8 @@ task_create_local(
 	new_task->syscalls_mach = 0;
 	new_task->syscalls_unix=0;
 	new_task->csw=0;
+	new_task->taskFeatures[0] = 0;				/* Init task features */
+	new_task->taskFeatures[1] = 0;				/* Init task features */
 	new_task->dynamic_working_set = 0;
 	
 	task_working_set_create(new_task, TWS_SMALL_HASH_LINE_COUNT, 
@@ -380,6 +390,10 @@ task_create_local(
 	new_task->bsd_info = 0;
 #endif /* MACH_BSD */
 
+#ifdef __ppc__
+	if(per_proc_info[0].pf.Available & pf64Bit) new_task->taskFeatures[0] |= tf64BitData;	/* If 64-bit machine, show we have 64-bit registers at least */
+#endif
+
 #if	TASK_SWAPPER
 	new_task->swap_state = TASK_SW_IN;
 	new_task->swap_flags = 0;
@@ -510,6 +524,10 @@ task_deallocate(
 	assert((task->swap_state & TASK_SW_ELIGIBLE) == 0);
 #endif	/* TASK_SWAPPER */
 
+	if(task->dynamic_working_set)
+		tws_hash_destroy((tws_hash_t)task->dynamic_working_set);
+
+
 	eml_task_deallocate(task);
 
 	ipc_task_terminate(task);
@@ -708,8 +726,12 @@ task_terminate_internal(
 
 	shared_region_mapping_dealloc(task->system_shared_region);
 
+	/*
+	 * Flush working set here to avoid I/O in reaper thread
+	 */
 	if(task->dynamic_working_set)
-		tws_hash_destroy((tws_hash_t)task->dynamic_working_set);
+		tws_hash_ws_flush((tws_hash_t)
+				task->dynamic_working_set);
 
 	/*
 	 * We no longer need to guard against being aborted, so restore
@@ -717,6 +739,10 @@ task_terminate_internal(
 	 */
 	thread_interrupt_level(interrupt_save);
 
+#if __ppc__
+    perfmon_release_facility(task); // notify the perfmon facility
+#endif
+
 	/*
 	 * Get rid of the task active reference on itself.
 	 */
diff --git a/osfmk/kern/task.h b/osfmk/kern/task.h
index e59bcbc4a..9b1e4afb6 100644
--- a/osfmk/kern/task.h
+++ b/osfmk/kern/task.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -209,6 +212,9 @@ typedef struct task {
 #endif  
 	vm_offset_t	system_shared_region;
 	vm_offset_t	dynamic_working_set;
+	uint32_t taskFeatures[2];		/* Special feature for this task */
+#define tf64BitAddr	0x80000000		/* Task has 64-bit addressing */
+#define tf64BitData	0x40000000		/* Task has 64-bit data registers */
 } Task;
 
 #define task_lock(task)		mutex_lock(&(task)->lock)
diff --git a/osfmk/kern/task_policy.c b/osfmk/kern/task_policy.c
index a0f9672ae..83aaa43e5 100644
--- a/osfmk/kern/task_policy.c
+++ b/osfmk/kern/task_policy.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/task_swap.c b/osfmk/kern/task_swap.c
index 7d69ca1e4..2e9721870 100644
--- a/osfmk/kern/task_swap.c
+++ b/osfmk/kern/task_swap.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/task_swap.h b/osfmk/kern/task_swap.h
index 279caefe6..9dd342913 100644
--- a/osfmk/kern/task_swap.h
+++ b/osfmk/kern/task_swap.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/thread.c b/osfmk/kern/thread.c
index 98c7a90c1..9c208da92 100644
--- a/osfmk/kern/thread.c
+++ b/osfmk/kern/thread.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -582,7 +585,7 @@ thread_init(void)
 #ifndef MACHINE_STACK
 	simple_lock_init(&stack_lock_data, ETAP_THREAD_STACK);	/* Initialize the stack lock */
 	
-	if (KERNEL_STACK_SIZE < round_page(KERNEL_STACK_SIZE)) {	/* Kernel stacks must be multiples of pages */
+	if (KERNEL_STACK_SIZE < round_page_32(KERNEL_STACK_SIZE)) {	/* Kernel stacks must be multiples of pages */
 		panic("thread_init: kernel stack size (%08X) must be a multiple of page size (%08X)\n", 
 			KERNEL_STACK_SIZE, PAGE_SIZE);
 	}
@@ -1542,7 +1545,7 @@ host_stack_usage(
 
 	*reservedp = 0;
 	*totalp = total;
-	*spacep = *residentp = total * round_page(KERNEL_STACK_SIZE);
+	*spacep = *residentp = total * round_page_32(KERNEL_STACK_SIZE);
 	*maxusagep = maxusage;
 	*maxstackp = 0;
 	return KERN_SUCCESS;
@@ -1670,7 +1673,7 @@ processor_set_stack_usage(
 		kfree(addr, size);
 
 	*totalp = total;
-	*residentp = *spacep = total * round_page(KERNEL_STACK_SIZE);
+	*residentp = *spacep = total * round_page_32(KERNEL_STACK_SIZE);
 	*maxusagep = maxusage;
 	*maxstackp = maxstack;
 	return KERN_SUCCESS;
diff --git a/osfmk/kern/thread.h b/osfmk/kern/thread.h
index 511803644..13c981605 100644
--- a/osfmk/kern/thread.h
+++ b/osfmk/kern/thread.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/thread_act.c b/osfmk/kern/thread_act.c
index f7e5000ec..129f39d9a 100644
--- a/osfmk/kern/thread_act.c
+++ b/osfmk/kern/thread_act.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/thread_act.h b/osfmk/kern/thread_act.h
index 0d7a102da..4e7e1d58c 100644
--- a/osfmk/kern/thread_act.h
+++ b/osfmk/kern/thread_act.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/thread_call.c b/osfmk/kern/thread_call.c
index b69dcdd30..15cd7e8a4 100644
--- a/osfmk/kern/thread_call.c
+++ b/osfmk/kern/thread_call.c
@@ -4,19 +4,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/thread_call.h b/osfmk/kern/thread_call.h
index 952265dd9..5d5576eb6 100644
--- a/osfmk/kern/thread_call.h
+++ b/osfmk/kern/thread_call.h
@@ -4,19 +4,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/thread_policy.c b/osfmk/kern/thread_policy.c
index d7e2c311a..cf5cb1f2e 100644
--- a/osfmk/kern/thread_policy.c
+++ b/osfmk/kern/thread_policy.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/thread_swap.c b/osfmk/kern/thread_swap.c
index 845b98dd4..60655208a 100644
--- a/osfmk/kern/thread_swap.c
+++ b/osfmk/kern/thread_swap.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/thread_swap.h b/osfmk/kern/thread_swap.h
index a6b107e56..1fd9b78d9 100644
--- a/osfmk/kern/thread_swap.h
+++ b/osfmk/kern/thread_swap.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/time_out.h b/osfmk/kern/time_out.h
index f5ec5c019..f1dcc8fd8 100644
--- a/osfmk/kern/time_out.h
+++ b/osfmk/kern/time_out.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/timer.c b/osfmk/kern/timer.c
index 996bc6fe6..3540b1ef7 100644
--- a/osfmk/kern/timer.c
+++ b/osfmk/kern/timer.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/timer.h b/osfmk/kern/timer.h
index c55f093da..776fb5d76 100644
--- a/osfmk/kern/timer.h
+++ b/osfmk/kern/timer.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/timer_call.c b/osfmk/kern/timer_call.c
index b65df6b25..fe421d3e0 100644
--- a/osfmk/kern/timer_call.c
+++ b/osfmk/kern/timer_call.c
@@ -4,19 +4,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/timer_call.h b/osfmk/kern/timer_call.h
index bc5ef3773..5d49861df 100644
--- a/osfmk/kern/timer_call.h
+++ b/osfmk/kern/timer_call.h
@@ -4,19 +4,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/wait_queue.c b/osfmk/kern/wait_queue.c
index d44cd9ec9..d27ca92a1 100644
--- a/osfmk/kern/wait_queue.c
+++ b/osfmk/kern/wait_queue.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -408,12 +411,14 @@ wait_queue_link_noalloc(
 	 */
 	s = splsched();
 	wait_queue_lock(wq);
+	wqs_lock(wq_set);
 	q = &wq->wq_queue;
 	wq_element = (wait_queue_element_t) queue_first(q);
 	while (!queue_end(q, (queue_entry_t)wq_element)) {
 		WAIT_QUEUE_ELEMENT_CHECK(wq, wq_element);
 		if (wq_element->wqe_type == WAIT_QUEUE_LINK &&
 		    ((wait_queue_link_t)wq_element)->wql_setqueue == wq_set) {
+			wqs_unlock(wq_set);
 			wait_queue_unlock(wq);
 			splx(s);
 			return KERN_ALREADY_IN_SET;
@@ -425,7 +430,6 @@ wait_queue_link_noalloc(
 	/*
 	 * Not already a member, so we can add it.
 	 */
-	wqs_lock(wq_set);
 
 	WAIT_QUEUE_SET_CHECK(wq_set);
 
diff --git a/osfmk/kern/wait_queue.h b/osfmk/kern/wait_queue.h
index 960a07b8d..40955cb27 100644
--- a/osfmk/kern/wait_queue.h
+++ b/osfmk/kern/wait_queue.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/xpr.c b/osfmk/kern/xpr.c
index 2a8d85f3f..448da12a1 100644
--- a/osfmk/kern/xpr.c
+++ b/osfmk/kern/xpr.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/xpr.h b/osfmk/kern/xpr.h
index 9c528830a..65e5b4a66 100644
--- a/osfmk/kern/xpr.h
+++ b/osfmk/kern/xpr.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/kern/zalloc.c b/osfmk/kern/zalloc.c
index 66e36c016..6c1b81d27 100644
--- a/osfmk/kern/zalloc.c
+++ b/osfmk/kern/zalloc.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -323,8 +326,8 @@ zinit(
 		((size-1) % sizeof(z->free_elements));
  	if (alloc == 0)
 		alloc = PAGE_SIZE;
-	alloc = round_page(alloc);
-	max   = round_page(max);
+	alloc = round_page_32(alloc);
+	max   = round_page_32(max);
 	/*
 	 * We look for an allocation size with least fragmentation
 	 * in the range of 1 - 5 pages.  This size will be used unless
@@ -431,7 +434,7 @@ zget_space(
 		 *	Add at least one page to allocation area.
 		 */
 
-		space_to_add = round_page(size);
+		space_to_add = round_page_32(size);
 
 		if (new_space == 0) {
 			kern_return_t retval;
@@ -500,7 +503,7 @@ zget_space(
 void
 zone_steal_memory(void)
 {
-	zdata_size = round_page(128*sizeof(struct zone));
+	zdata_size = round_page_32(128*sizeof(struct zone));
 	zdata = pmap_steal_memory(zdata_size);
 }
 
@@ -526,7 +529,7 @@ zfill(
 	if (nelem <= 0)
 		return 0;
 	size = nelem * zone->elem_size;
-	size = round_page(size);
+	size = round_page_32(size);
 	kr = kmem_alloc_wired(kernel_map, &memory, size);
 	if (kr != KERN_SUCCESS)
 		return 0;
@@ -584,17 +587,17 @@ zone_init(
 						FALSE, TRUE, &zone_map);
 	if (retval != KERN_SUCCESS)
 		panic("zone_init: kmem_suballoc failed");
-	zone_max = zone_min + round_page(max_zonemap_size);
+	zone_max = zone_min + round_page_32(max_zonemap_size);
 	/*
 	 * Setup garbage collection information:
 	 */
-	zone_table_size = atop(zone_max - zone_min) * 
+	zone_table_size = atop_32(zone_max - zone_min) * 
 				sizeof(struct zone_page_table_entry);
 	if (kmem_alloc_wired(zone_map, (vm_offset_t *) &zone_page_table,
 			     zone_table_size) != KERN_SUCCESS)
 		panic("zone_init");
-	zone_min = (vm_offset_t)zone_page_table + round_page(zone_table_size);
-	zone_pages = atop(zone_max - zone_min);
+	zone_min = (vm_offset_t)zone_page_table + round_page_32(zone_table_size);
+	zone_pages = atop_32(zone_max - zone_min);
 	zone_map_min_address = zone_min;
 	zone_map_max_address = zone_max;
 	simple_lock_init(&zone_page_table_lock, ETAP_MISC_ZONE_PTABLE);
@@ -665,7 +668,7 @@ zalloc_canblock(
 
 				if (vm_pool_low())
 					alloc_size = 
-					  round_page(zone->elem_size);
+					  round_page_32(zone->elem_size);
 				else
 					alloc_size = zone->alloc_size;
 
@@ -1004,8 +1007,8 @@ zone_page_collectable(
 		panic("zone_page_collectable");
 #endif
 
-	i = atop(addr-zone_map_min_address);
-	j = atop((addr+size-1) - zone_map_min_address);
+	i = atop_32(addr-zone_map_min_address);
+	j = atop_32((addr+size-1) - zone_map_min_address);
 	lock_zone_page_table();
 	for (; i <= j; i++) {
 		if (zone_page_table[i].in_free_list ==
@@ -1030,8 +1033,8 @@ zone_page_keep(
 		panic("zone_page_keep");
 #endif
 
-	i = atop(addr-zone_map_min_address);
-	j = atop((addr+size-1) - zone_map_min_address);
+	i = atop_32(addr-zone_map_min_address);
+	j = atop_32((addr+size-1) - zone_map_min_address);
 	lock_zone_page_table();
 	for (; i <= j; i++) {
 		zone_page_table[i].in_free_list = 0;
@@ -1051,8 +1054,8 @@ zone_page_in_use(
 		panic("zone_page_in_use");
 #endif
 
-	i = atop(addr-zone_map_min_address);
-	j = atop((addr+size-1) - zone_map_min_address);
+	i = atop_32(addr-zone_map_min_address);
+	j = atop_32((addr+size-1) - zone_map_min_address);
 	lock_zone_page_table();
 	for (; i <= j; i++) {
 		if (zone_page_table[i].in_free_list > 0)
@@ -1073,8 +1076,8 @@ zone_page_free(
 		panic("zone_page_free");
 #endif
 
-	i = atop(addr-zone_map_min_address);
-	j = atop((addr+size-1) - zone_map_min_address);
+	i = atop_32(addr-zone_map_min_address);
+	j = atop_32((addr+size-1) - zone_map_min_address);
 	lock_zone_page_table();
 	for (; i <= j; i++) {
 		assert(zone_page_table[i].in_free_list >= 0);
@@ -1096,8 +1099,8 @@ zone_page_init(
 		panic("zone_page_init");
 #endif
 
-	i = atop(addr-zone_map_min_address);
-	j = atop((addr+size-1) - zone_map_min_address);
+	i = atop_32(addr-zone_map_min_address);
+	j = atop_32((addr+size-1) - zone_map_min_address);
 	lock_zone_page_table();
 	for (; i <= j; i++) {
 		zone_page_table[i].alloc_count = value;
@@ -1118,8 +1121,8 @@ zone_page_alloc(
 		panic("zone_page_alloc");
 #endif
 
-	i = atop(addr-zone_map_min_address);
-	j = atop((addr+size-1) - zone_map_min_address);
+	i = atop_32(addr-zone_map_min_address);
+	j = atop_32((addr+size-1) - zone_map_min_address);
 	lock_zone_page_table();
 	for (; i <= j; i++) {
 		/* Set alloc_count to (ZONE_PAGE_USED + 1) if
@@ -1146,8 +1149,8 @@ zone_page_dealloc(
 		panic("zone_page_dealloc");
 #endif
 
-	i = atop(addr-zone_map_min_address);
-	j = atop((addr+size-1) - zone_map_min_address);
+	i = atop_32(addr-zone_map_min_address);
+	j = atop_32((addr+size-1) - zone_map_min_address);
 	lock_zone_page_table();
 	for (; i <= j; i++) {
 		zone_page_table[i].alloc_count--;
@@ -1168,8 +1171,8 @@ zone_add_free_page_list(
 		panic("zone_add_free_page_list");
 #endif
 
-	i = atop(addr-zone_map_min_address);
-	j = atop((addr+size-1) - zone_map_min_address);
+	i = atop_32(addr-zone_map_min_address);
+	j = atop_32((addr+size-1) - zone_map_min_address);
 	lock_zone_page_table();
 	for (; i <= j; i++) {
 		if (zone_page_table[i].alloc_count == 0) {
@@ -1395,7 +1398,7 @@ host_zone_info(
 
 		names = *namesp;
 	} else {
-		names_size = round_page(max_zones * sizeof *names);
+		names_size = round_page_32(max_zones * sizeof *names);
 		kr = kmem_alloc_pageable(ipc_kernel_map,
 					 &names_addr, names_size);
 		if (kr != KERN_SUCCESS)
@@ -1408,7 +1411,7 @@ host_zone_info(
 
 		info = *infop;
 	} else {
-		info_size = round_page(max_zones * sizeof *info);
+		info_size = round_page_32(max_zones * sizeof *info);
 		kr = kmem_alloc_pageable(ipc_kernel_map,
 					 &info_addr, info_size);
 		if (kr != KERN_SUCCESS) {
diff --git a/osfmk/kern/zalloc.h b/osfmk/kern/zalloc.h
index 74aeab881..659efb92e 100644
--- a/osfmk/kern/zalloc.h
+++ b/osfmk/kern/zalloc.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/libsa/ctype.h b/osfmk/libsa/ctype.h
index 152f2ab4c..bff8494b4 100644
--- a/osfmk/libsa/ctype.h
+++ b/osfmk/libsa/ctype.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/libsa/errno.h b/osfmk/libsa/errno.h
index 36b9df2c6..44da56bb3 100644
--- a/osfmk/libsa/errno.h
+++ b/osfmk/libsa/errno.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/libsa/float.h b/osfmk/libsa/float.h
index a1da5a179..c006288d9 100644
--- a/osfmk/libsa/float.h
+++ b/osfmk/libsa/float.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/libsa/i386/float.h b/osfmk/libsa/i386/float.h
index e3d1c1ef1..a10d56dbb 100644
--- a/osfmk/libsa/i386/float.h
+++ b/osfmk/libsa/i386/float.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/libsa/i386/math.h b/osfmk/libsa/i386/math.h
index 21728795a..abed7be9f 100644
--- a/osfmk/libsa/i386/math.h
+++ b/osfmk/libsa/i386/math.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/libsa/i386/stdarg.h b/osfmk/libsa/i386/stdarg.h
index 7a9022fa6..1a303a1bb 100644
--- a/osfmk/libsa/i386/stdarg.h
+++ b/osfmk/libsa/i386/stdarg.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/libsa/i386/types.h b/osfmk/libsa/i386/types.h
index 650acf6a3..2dc28342a 100644
--- a/osfmk/libsa/i386/types.h
+++ b/osfmk/libsa/i386/types.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/libsa/i386/va_list.h b/osfmk/libsa/i386/va_list.h
index aa14743d2..9f8924de7 100644
--- a/osfmk/libsa/i386/va_list.h
+++ b/osfmk/libsa/i386/va_list.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/libsa/ieeefloat.h b/osfmk/libsa/ieeefloat.h
index c42f141c6..26aeee88c 100644
--- a/osfmk/libsa/ieeefloat.h
+++ b/osfmk/libsa/ieeefloat.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/libsa/machine/stdarg.h b/osfmk/libsa/machine/stdarg.h
index 424b40983..bb04b179c 100644
--- a/osfmk/libsa/machine/stdarg.h
+++ b/osfmk/libsa/machine/stdarg.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/libsa/machine/stdarg_apple.h b/osfmk/libsa/machine/stdarg_apple.h
index fde11df56..a32486aff 100644
--- a/osfmk/libsa/machine/stdarg_apple.h
+++ b/osfmk/libsa/machine/stdarg_apple.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/libsa/machine/types.h b/osfmk/libsa/machine/types.h
index 710311b83..c19a0a062 100644
--- a/osfmk/libsa/machine/types.h
+++ b/osfmk/libsa/machine/types.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/libsa/machine/va_list.h b/osfmk/libsa/machine/va_list.h
index 95929edb7..278726760 100644
--- a/osfmk/libsa/machine/va_list.h
+++ b/osfmk/libsa/machine/va_list.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/libsa/math.h b/osfmk/libsa/math.h
index 49cffc7d0..c471818cf 100644
--- a/osfmk/libsa/math.h
+++ b/osfmk/libsa/math.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/libsa/ppc/float.h b/osfmk/libsa/ppc/float.h
index f2608b5ee..a059652e1 100644
--- a/osfmk/libsa/ppc/float.h
+++ b/osfmk/libsa/ppc/float.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/libsa/ppc/math.h b/osfmk/libsa/ppc/math.h
index b094a20cb..a5f3c39bd 100644
--- a/osfmk/libsa/ppc/math.h
+++ b/osfmk/libsa/ppc/math.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/libsa/ppc/stdarg.h b/osfmk/libsa/ppc/stdarg.h
index dcb67693b..43229c2d4 100644
--- a/osfmk/libsa/ppc/stdarg.h
+++ b/osfmk/libsa/ppc/stdarg.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/libsa/ppc/stdarg_apple.h b/osfmk/libsa/ppc/stdarg_apple.h
index c1bcea725..82056e44c 100644
--- a/osfmk/libsa/ppc/stdarg_apple.h
+++ b/osfmk/libsa/ppc/stdarg_apple.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/libsa/ppc/types.h b/osfmk/libsa/ppc/types.h
index 939b82d4f..462a0a7b4 100644
--- a/osfmk/libsa/ppc/types.h
+++ b/osfmk/libsa/ppc/types.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/libsa/ppc/va_list.h b/osfmk/libsa/ppc/va_list.h
index 1c42bff89..f4c4e4bba 100644
--- a/osfmk/libsa/ppc/va_list.h
+++ b/osfmk/libsa/ppc/va_list.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/libsa/stdarg.h b/osfmk/libsa/stdarg.h
index 962196ed7..dfe3776b3 100644
--- a/osfmk/libsa/stdarg.h
+++ b/osfmk/libsa/stdarg.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/libsa/stdio.h b/osfmk/libsa/stdio.h
index 37ecb60a5..8511e9e81 100644
--- a/osfmk/libsa/stdio.h
+++ b/osfmk/libsa/stdio.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/libsa/stdlib.h b/osfmk/libsa/stdlib.h
index 655f8779d..cce6f857e 100644
--- a/osfmk/libsa/stdlib.h
+++ b/osfmk/libsa/stdlib.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/libsa/string.h b/osfmk/libsa/string.h
index 486492e95..e6a0baf63 100644
--- a/osfmk/libsa/string.h
+++ b/osfmk/libsa/string.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/libsa/sys/timers.h b/osfmk/libsa/sys/timers.h
index 645aba560..a67472892 100644
--- a/osfmk/libsa/sys/timers.h
+++ b/osfmk/libsa/sys/timers.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/libsa/types.h b/osfmk/libsa/types.h
index ec12bec91..2d7282616 100644
--- a/osfmk/libsa/types.h
+++ b/osfmk/libsa/types.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/libsa/va_list.h b/osfmk/libsa/va_list.h
index 4034a0ce7..38ccb271f 100644
--- a/osfmk/libsa/va_list.h
+++ b/osfmk/libsa/va_list.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach-o/loader.h b/osfmk/mach-o/loader.h
index 277b2b1e2..f83101ba3 100644
--- a/osfmk/mach-o/loader.h
+++ b/osfmk/mach-o/loader.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach-o/mach_header.c b/osfmk/mach-o/mach_header.c
index 02e88426b..2b2167ce2 100644
--- a/osfmk/mach-o/mach_header.c
+++ b/osfmk/mach-o/mach_header.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach-o/mach_header.h b/osfmk/mach-o/mach_header.h
index 8cf484869..ecc1a9c97 100644
--- a/osfmk/mach-o/mach_header.h
+++ b/osfmk/mach-o/mach_header.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/alert.h b/osfmk/mach/alert.h
index 801aeb6bb..1afa97d98 100644
--- a/osfmk/mach/alert.h
+++ b/osfmk/mach/alert.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/boolean.h b/osfmk/mach/boolean.h
index 4b41b4462..52c843fb3 100644
--- a/osfmk/mach/boolean.h
+++ b/osfmk/mach/boolean.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/boot_info.h b/osfmk/mach/boot_info.h
index 9c9555187..e36bcc26b 100644
--- a/osfmk/mach/boot_info.h
+++ b/osfmk/mach/boot_info.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/bootstrap.h b/osfmk/mach/bootstrap.h
index 045645938..4fa742470 100644
--- a/osfmk/mach/bootstrap.h
+++ b/osfmk/mach/bootstrap.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/clock.defs b/osfmk/mach/clock.defs
index 5c94e007e..cac58b823 100644
--- a/osfmk/mach/clock.defs
+++ b/osfmk/mach/clock.defs
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/clock_priv.defs b/osfmk/mach/clock_priv.defs
index e9be2636f..52bf312f6 100644
--- a/osfmk/mach/clock_priv.defs
+++ b/osfmk/mach/clock_priv.defs
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/clock_reply.defs b/osfmk/mach/clock_reply.defs
index c96663319..067993980 100644
--- a/osfmk/mach/clock_reply.defs
+++ b/osfmk/mach/clock_reply.defs
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/clock_types.defs b/osfmk/mach/clock_types.defs
index 840926dc8..d1a4f531b 100644
--- a/osfmk/mach/clock_types.defs
+++ b/osfmk/mach/clock_types.defs
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/clock_types.h b/osfmk/mach/clock_types.h
index 93687e944..f05a73ec7 100644
--- a/osfmk/mach/clock_types.h
+++ b/osfmk/mach/clock_types.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/error.h b/osfmk/mach/error.h
index 2f6d6c4cb..11a95723b 100644
--- a/osfmk/mach/error.h
+++ b/osfmk/mach/error.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/etap.h b/osfmk/mach/etap.h
index a83d30cff..a774411d1 100644
--- a/osfmk/mach/etap.h
+++ b/osfmk/mach/etap.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/etap_events.h b/osfmk/mach/etap_events.h
index 29dced2f9..29f426aeb 100644
--- a/osfmk/mach/etap_events.h
+++ b/osfmk/mach/etap_events.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/events_info.h b/osfmk/mach/events_info.h
index c6eead64e..c2ce93179 100644
--- a/osfmk/mach/events_info.h
+++ b/osfmk/mach/events_info.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/exc.defs b/osfmk/mach/exc.defs
index 8236168a8..795bc26d4 100644
--- a/osfmk/mach/exc.defs
+++ b/osfmk/mach/exc.defs
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/exception.h b/osfmk/mach/exception.h
index 6796107b2..e2d00bde8 100644
--- a/osfmk/mach/exception.h
+++ b/osfmk/mach/exception.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/exception_types.h b/osfmk/mach/exception_types.h
index 014349674..94253c86f 100644
--- a/osfmk/mach/exception_types.h
+++ b/osfmk/mach/exception_types.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/flipc_cb.h b/osfmk/mach/flipc_cb.h
index 43d811757..2c835d07c 100644
--- a/osfmk/mach/flipc_cb.h
+++ b/osfmk/mach/flipc_cb.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/flipc_debug.h b/osfmk/mach/flipc_debug.h
index 693d695c5..bfcb2e121 100644
--- a/osfmk/mach/flipc_debug.h
+++ b/osfmk/mach/flipc_debug.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/flipc_device.h b/osfmk/mach/flipc_device.h
index 413a1e1cb..dbf34985f 100644
--- a/osfmk/mach/flipc_device.h
+++ b/osfmk/mach/flipc_device.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/flipc_locks.h b/osfmk/mach/flipc_locks.h
index 222bb0b79..3a9755787 100644
--- a/osfmk/mach/flipc_locks.h
+++ b/osfmk/mach/flipc_locks.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/flipc_types.h b/osfmk/mach/flipc_types.h
index 1019cfbbc..3e2c5a130 100644
--- a/osfmk/mach/flipc_types.h
+++ b/osfmk/mach/flipc_types.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/host_info.h b/osfmk/mach/host_info.h
index 28cdb19fe..5729bc3ac 100644
--- a/osfmk/mach/host_info.h
+++ b/osfmk/mach/host_info.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/host_priv.defs b/osfmk/mach/host_priv.defs
index 244c38753..48f5be860 100644
--- a/osfmk/mach/host_priv.defs
+++ b/osfmk/mach/host_priv.defs
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/host_reboot.h b/osfmk/mach/host_reboot.h
index acb4f643f..57e9bbed9 100644
--- a/osfmk/mach/host_reboot.h
+++ b/osfmk/mach/host_reboot.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/host_security.defs b/osfmk/mach/host_security.defs
index ee9a8a470..c15f134c6 100644
--- a/osfmk/mach/host_security.defs
+++ b/osfmk/mach/host_security.defs
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/i386/boolean.h b/osfmk/mach/i386/boolean.h
index 0ec6b1893..92398a34f 100644
--- a/osfmk/mach/i386/boolean.h
+++ b/osfmk/mach/i386/boolean.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/i386/exception.h b/osfmk/mach/i386/exception.h
index aa45d06dd..96ab9058a 100644
--- a/osfmk/mach/i386/exception.h
+++ b/osfmk/mach/i386/exception.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/i386/flipc_dep.h b/osfmk/mach/i386/flipc_dep.h
index 7aa606390..b71afbdaf 100644
--- a/osfmk/mach/i386/flipc_dep.h
+++ b/osfmk/mach/i386/flipc_dep.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/i386/fp_reg.h b/osfmk/mach/i386/fp_reg.h
index 39b6c761c..4357deb73 100644
--- a/osfmk/mach/i386/fp_reg.h
+++ b/osfmk/mach/i386/fp_reg.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/i386/kern_return.h b/osfmk/mach/i386/kern_return.h
index d317340c0..156be66a0 100644
--- a/osfmk/mach/i386/kern_return.h
+++ b/osfmk/mach/i386/kern_return.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/i386/mach_i386.defs b/osfmk/mach/i386/mach_i386.defs
index c29abf0b0..e27468ad5 100644
--- a/osfmk/mach/i386/mach_i386.defs
+++ b/osfmk/mach/i386/mach_i386.defs
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/i386/mach_i386_types.h b/osfmk/mach/i386/mach_i386_types.h
index b2023f05e..414f8ddd8 100644
--- a/osfmk/mach/i386/mach_i386_types.h
+++ b/osfmk/mach/i386/mach_i386_types.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/i386/machine_types.defs b/osfmk/mach/i386/machine_types.defs
index 109f98a21..9ec567bd5 100644
--- a/osfmk/mach/i386/machine_types.defs
+++ b/osfmk/mach/i386/machine_types.defs
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/i386/ndr_def.h b/osfmk/mach/i386/ndr_def.h
index 7a36022f1..f9798cb3d 100644
--- a/osfmk/mach/i386/ndr_def.h
+++ b/osfmk/mach/i386/ndr_def.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/i386/processor_info.h b/osfmk/mach/i386/processor_info.h
index 8709e475a..e362f5fad 100644
--- a/osfmk/mach/i386/processor_info.h
+++ b/osfmk/mach/i386/processor_info.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/i386/rpc.h b/osfmk/mach/i386/rpc.h
index 1f8b879b8..b2e2a50ed 100644
--- a/osfmk/mach/i386/rpc.h
+++ b/osfmk/mach/i386/rpc.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/i386/syscall_sw.h b/osfmk/mach/i386/syscall_sw.h
index 16104a874..1d08cd47f 100644
--- a/osfmk/mach/i386/syscall_sw.h
+++ b/osfmk/mach/i386/syscall_sw.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/i386/thread_state.h b/osfmk/mach/i386/thread_state.h
index 300462b9c..955f69212 100644
--- a/osfmk/mach/i386/thread_state.h
+++ b/osfmk/mach/i386/thread_state.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/i386/thread_status.h b/osfmk/mach/i386/thread_status.h
index e67be918c..eb740972b 100644
--- a/osfmk/mach/i386/thread_status.h
+++ b/osfmk/mach/i386/thread_status.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/i386/vm_param.h b/osfmk/mach/i386/vm_param.h
index 0f18100e6..6f4746d7d 100644
--- a/osfmk/mach/i386/vm_param.h
+++ b/osfmk/mach/i386/vm_param.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -199,7 +202,7 @@
 	pmap_enter(					\
 		(pmap),					\
 		(virtual_address),			\
-		(page)->phys_addr,			\
+		(page)->phys_page,			\
 		__prot__,				\
 		flags,					\
 		(wired)					\
diff --git a/osfmk/mach/i386/vm_types.h b/osfmk/mach/i386/vm_types.h
index 0ad257fcb..1b78956af 100644
--- a/osfmk/mach/i386/vm_types.h
+++ b/osfmk/mach/i386/vm_types.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/kern_return.h b/osfmk/mach/kern_return.h
index c347f1e3d..50278e96b 100644
--- a/osfmk/mach/kern_return.h
+++ b/osfmk/mach/kern_return.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/kmod.h b/osfmk/mach/kmod.h
index 49d0f0103..4c9dd54f8 100644
--- a/osfmk/mach/kmod.h
+++ b/osfmk/mach/kmod.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/ledger.defs b/osfmk/mach/ledger.defs
index ec1b94f76..7f9ea0a58 100644
--- a/osfmk/mach/ledger.defs
+++ b/osfmk/mach/ledger.defs
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/lock_set.defs b/osfmk/mach/lock_set.defs
index da19ca388..fc1d88261 100644
--- a/osfmk/mach/lock_set.defs
+++ b/osfmk/mach/lock_set.defs
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/mach.h b/osfmk/mach/mach.h
index c0e4100ec..d672bc26f 100644
--- a/osfmk/mach/mach.h
+++ b/osfmk/mach/mach.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/mach_host.defs b/osfmk/mach/mach_host.defs
index 0877e01cb..943ba258b 100644
--- a/osfmk/mach/mach_host.defs
+++ b/osfmk/mach/mach_host.defs
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/mach_interface.h b/osfmk/mach/mach_interface.h
index 6b0a54fb7..ecfa07c47 100644
--- a/osfmk/mach/mach_interface.h
+++ b/osfmk/mach/mach_interface.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/mach_norma.defs b/osfmk/mach/mach_norma.defs
index 8e5ff7f09..a7de4ba7d 100644
--- a/osfmk/mach/mach_norma.defs
+++ b/osfmk/mach/mach_norma.defs
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/mach_param.h b/osfmk/mach/mach_param.h
index f82d2b3ff..be886626e 100644
--- a/osfmk/mach/mach_param.h
+++ b/osfmk/mach/mach_param.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/mach_port.defs b/osfmk/mach/mach_port.defs
index 60ee11f1c..bac4fefaa 100644
--- a/osfmk/mach/mach_port.defs
+++ b/osfmk/mach/mach_port.defs
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/mach_syscalls.h b/osfmk/mach/mach_syscalls.h
index 9b9eb91cb..bb4af9470 100644
--- a/osfmk/mach/mach_syscalls.h
+++ b/osfmk/mach/mach_syscalls.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/mach_time.h b/osfmk/mach/mach_time.h
index fe70975e0..253875f0c 100644
--- a/osfmk/mach/mach_time.h
+++ b/osfmk/mach/mach_time.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/mach_traps.h b/osfmk/mach/mach_traps.h
index d87b2869e..4f845279a 100644
--- a/osfmk/mach/mach_traps.h
+++ b/osfmk/mach/mach_traps.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/mach_types.defs b/osfmk/mach/mach_types.defs
index 5a7897eb0..a13f14eac 100644
--- a/osfmk/mach/mach_types.defs
+++ b/osfmk/mach/mach_types.defs
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/mach_types.h b/osfmk/mach/mach_types.h
index 04f9bd114..7bf77076f 100644
--- a/osfmk/mach/mach_types.h
+++ b/osfmk/mach/mach_types.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/machine.h b/osfmk/mach/machine.h
index 40f6ac7dd..17694ea70 100644
--- a/osfmk/mach/machine.h
+++ b/osfmk/mach/machine.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -280,5 +283,6 @@ extern struct machine_slot	machine_slot[];
 #define CPU_SUBTYPE_POWERPC_750		((cpu_subtype_t) 9)
 #define CPU_SUBTYPE_POWERPC_7400	((cpu_subtype_t) 10)
 #define CPU_SUBTYPE_POWERPC_7450	((cpu_subtype_t) 11)
+#define CPU_SUBTYPE_POWERPC_970		((cpu_subtype_t) 100)
 
 #endif	/* _MACH_MACHINE_H_ */
diff --git a/osfmk/mach/machine/asm.h b/osfmk/mach/machine/asm.h
index ed74cc334..5495511c9 100644
--- a/osfmk/mach/machine/asm.h
+++ b/osfmk/mach/machine/asm.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/machine/boolean.h b/osfmk/mach/machine/boolean.h
index d85824189..a2f88cd61 100644
--- a/osfmk/mach/machine/boolean.h
+++ b/osfmk/mach/machine/boolean.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/machine/exception.h b/osfmk/mach/machine/exception.h
index e08c34a15..ca1cf0e85 100644
--- a/osfmk/mach/machine/exception.h
+++ b/osfmk/mach/machine/exception.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/machine/kern_return.h b/osfmk/mach/machine/kern_return.h
index 45ad20b8b..c5261961c 100644
--- a/osfmk/mach/machine/kern_return.h
+++ b/osfmk/mach/machine/kern_return.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/machine/machine_types.defs b/osfmk/mach/machine/machine_types.defs
index 2b9ecc264..2c7494b82 100644
--- a/osfmk/mach/machine/machine_types.defs
+++ b/osfmk/mach/machine/machine_types.defs
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/machine/ndr_def.h b/osfmk/mach/machine/ndr_def.h
index 498d5c984..cac70c7b5 100644
--- a/osfmk/mach/machine/ndr_def.h
+++ b/osfmk/mach/machine/ndr_def.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/machine/processor_info.h b/osfmk/mach/machine/processor_info.h
index fa04db434..130a7237c 100644
--- a/osfmk/mach/machine/processor_info.h
+++ b/osfmk/mach/machine/processor_info.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/machine/rpc.h b/osfmk/mach/machine/rpc.h
index 3d3f19243..3560fb855 100644
--- a/osfmk/mach/machine/rpc.h
+++ b/osfmk/mach/machine/rpc.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/machine/syscall_sw.h b/osfmk/mach/machine/syscall_sw.h
index c140fcdbc..6cdb2fa36 100644
--- a/osfmk/mach/machine/syscall_sw.h
+++ b/osfmk/mach/machine/syscall_sw.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/machine/thread_state.h b/osfmk/mach/machine/thread_state.h
index 286cfc29d..7677db209 100644
--- a/osfmk/mach/machine/thread_state.h
+++ b/osfmk/mach/machine/thread_state.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/machine/thread_status.h b/osfmk/mach/machine/thread_status.h
index 6047637e6..7de6e5bb1 100644
--- a/osfmk/mach/machine/thread_status.h
+++ b/osfmk/mach/machine/thread_status.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/machine/vm_param.h b/osfmk/mach/machine/vm_param.h
index beb5bc185..b3ae8c93d 100644
--- a/osfmk/mach/machine/vm_param.h
+++ b/osfmk/mach/machine/vm_param.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/machine/vm_types.h b/osfmk/mach/machine/vm_types.h
index 7b8770485..403d7e9eb 100644
--- a/osfmk/mach/machine/vm_types.h
+++ b/osfmk/mach/machine/vm_types.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/memory_object.defs b/osfmk/mach/memory_object.defs
index 63c50d18c..23b942e79 100644
--- a/osfmk/mach/memory_object.defs
+++ b/osfmk/mach/memory_object.defs
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/memory_object.h b/osfmk/mach/memory_object.h
index 63675bd21..9c5401ec8 100644
--- a/osfmk/mach/memory_object.h
+++ b/osfmk/mach/memory_object.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/memory_object_control.defs b/osfmk/mach/memory_object_control.defs
index 72f91d927..67bb838c2 100644
--- a/osfmk/mach/memory_object_control.defs
+++ b/osfmk/mach/memory_object_control.defs
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -162,7 +165,7 @@ routine memory_object_page_op(
 		memory_control	: memory_object_control_t;
 	in	offset		: memory_object_offset_t;
 	in	ops		: integer_t;
-	out	phys_entry	: vm_offset_t;
+	out	phys_entry	: uint32_t;
 	out	flags		: integer_t);
 
 routine memory_object_recover_named(
diff --git a/osfmk/mach/memory_object_default.defs b/osfmk/mach/memory_object_default.defs
index 1a15e1bbd..a2db5c1bb 100644
--- a/osfmk/mach/memory_object_default.defs
+++ b/osfmk/mach/memory_object_default.defs
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/memory_object_name.defs b/osfmk/mach/memory_object_name.defs
index 589a998c4..57eb3aa19 100644
--- a/osfmk/mach/memory_object_name.defs
+++ b/osfmk/mach/memory_object_name.defs
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/memory_object_types.h b/osfmk/mach/memory_object_types.h
index 7592100f1..d953a3102 100644
--- a/osfmk/mach/memory_object_types.h
+++ b/osfmk/mach/memory_object_types.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -287,8 +290,28 @@ typedef struct upl_page_info	upl_page_info_t;
 typedef upl_page_info_t		*upl_page_info_array_t;
 typedef upl_page_info_array_t	upl_page_list_ptr_t;
 
+/* named entry processor mapping options */
+/* enumerated */
+#define MAP_MEM_NOOP		0
+#define MAP_MEM_COPYBACK	1
+#define MAP_MEM_IO		2
+#define MAP_MEM_WTHRU		3
+#define MAP_MEM_WCOMB		4	/* Write combining mode */
+					/* aka store gather     */
+
+#define GET_MAP_MEM(flags)	\
+	((((unsigned int)(flags)) >> 24) & 0xFF)
+
+#define SET_MAP_MEM(caching, flags)	\
+	((flags) = ((((unsigned int)(caching)) << 24) \
+			& 0xFF000000) | ((flags) & 0xFFFFFF));
+
+/* leave room for vm_prot bits */
+#define MAP_MEM_ONLY		0x10000	/* change processor caching  */
+#define MAP_MEM_NAMED_CREATE	0x20000 /* create extant object      */
 
 /* upl invocation flags */
+/* top nibble is used by super upl */
 
 #define UPL_FLAGS_NONE		0x0
 #define UPL_COPYOUT_FROM	0x1
@@ -301,6 +324,10 @@ typedef upl_page_info_array_t	upl_page_list_ptr_t;
 #define	UPL_QUERY_OBJECT_TYPE	0x80
 #define UPL_RET_ONLY_ABSENT	0x100  /* used only for COPY_FROM = FALSE */
 #define UPL_FILE_IO             0x200
+#define UPL_SET_LITE		0x400
+#define UPL_SET_INTERRUPTIBLE	0x800
+#define UPL_SET_IO_WIRE		0x1000
+#define UPL_FOR_PAGEOUT		0x2000
 
 /* upl abort error flags */
 #define UPL_ABORT_RESTART	0x1
@@ -380,6 +407,7 @@ typedef upl_page_info_array_t	upl_page_list_ptr_t;
 #define UPL_POP_CLR		0x80000000
 
 
+
 #ifdef KERNEL_PRIVATE
 
 extern void memory_object_reference(memory_object_t object);
@@ -417,6 +445,60 @@ extern void	   	upl_set_dirty(upl_t   upl);
 
 extern void		upl_clear_dirty(upl_t   upl);
 
+
+/* 
+ * The following interface definitions should be generated automatically 
+ * through Mig definitions or whatever follows the MIG tool as part of the
+ * component API.  Until this is up and running however this explicit 
+ * description will do.
+ */
+
+#include <mach/message.h>
+
+/*  supply a map and a range, a upl will be returned. */
+extern int kernel_vm_map_get_upl(
+	vm_map_t		map,
+	vm_address_t		offset,
+	vm_size_t		*upl_size,
+	upl_t			*upl,
+	upl_page_info_array_t	page_list,
+	unsigned int		*count,
+	int			*flags,
+	int             	force_data_sync);
+
+extern int kernel_upl_map(
+	vm_map_t        map,
+	upl_t           upl,
+	vm_offset_t     *dst_addr);
+
+extern int kernel_upl_unmap(
+	vm_map_t        map,
+	upl_t           upl);
+
+extern int     kernel_upl_commit(
+	upl_t                   upl,
+	upl_page_info_t         *pl,
+	mach_msg_type_number_t	 count);
+
+extern int kernel_upl_commit_range(
+	upl_t                   upl,
+	vm_offset_t             offset,
+	vm_size_t		size,
+	int			flags,
+	upl_page_info_array_t	pl,
+	mach_msg_type_number_t	count);
+
+extern int kernel_upl_abort(
+	upl_t                   upl,
+	int                     abort_type);
+
+extern int kernel_upl_abort_range(
+	upl_t                   upl,
+	vm_offset_t             offset,
+	vm_size_t               size,
+	int                     abort_flags);
+
+
 #endif  /* KERNEL_PRIVATE */
 
 #endif  /* __APPLE_API_EVOLVING */
diff --git a/osfmk/mach/message.h b/osfmk/mach/message.h
index a346aa327..75d3531de 100644
--- a/osfmk/mach/message.h
+++ b/osfmk/mach/message.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/mig.h b/osfmk/mach/mig.h
index fa6ac0b03..e274ca543 100644
--- a/osfmk/mach/mig.h
+++ b/osfmk/mach/mig.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/mig_errors.h b/osfmk/mach/mig_errors.h
index 680054f57..e57e77f10 100644
--- a/osfmk/mach/mig_errors.h
+++ b/osfmk/mach/mig_errors.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/mig_log.h b/osfmk/mach/mig_log.h
index c8f1e7190..8551a5394 100644
--- a/osfmk/mach/mig_log.h
+++ b/osfmk/mach/mig_log.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/mk_timer.h b/osfmk/mach/mk_timer.h
index df8a66997..a1744efb1 100644
--- a/osfmk/mach/mk_timer.h
+++ b/osfmk/mach/mk_timer.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/mk_traps.h b/osfmk/mach/mk_traps.h
index c5159b834..dcc2af384 100644
--- a/osfmk/mach/mk_traps.h
+++ b/osfmk/mach/mk_traps.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/msg_type.h b/osfmk/mach/msg_type.h
index 00d56bbb2..415fca4c3 100644
--- a/osfmk/mach/msg_type.h
+++ b/osfmk/mach/msg_type.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/ndr.h b/osfmk/mach/ndr.h
index 56e982d9a..e034eae05 100644
--- a/osfmk/mach/ndr.h
+++ b/osfmk/mach/ndr.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/norma_special_ports.h b/osfmk/mach/norma_special_ports.h
index e0d33258e..708511a18 100644
--- a/osfmk/mach/norma_special_ports.h
+++ b/osfmk/mach/norma_special_ports.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/notify.defs b/osfmk/mach/notify.defs
index 7845a868e..9549738aa 100644
--- a/osfmk/mach/notify.defs
+++ b/osfmk/mach/notify.defs
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/notify.h b/osfmk/mach/notify.h
index 716f3e4fe..0c9dd1246 100644
--- a/osfmk/mach/notify.h
+++ b/osfmk/mach/notify.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/policy.h b/osfmk/mach/policy.h
index 12df6e4f5..0e004fc95 100644
--- a/osfmk/mach/policy.h
+++ b/osfmk/mach/policy.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/port.h b/osfmk/mach/port.h
index df7d75142..670924537 100644
--- a/osfmk/mach/port.h
+++ b/osfmk/mach/port.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/ppc/boolean.h b/osfmk/mach/ppc/boolean.h
index 8e5a91443..6bc37cf03 100644
--- a/osfmk/mach/ppc/boolean.h
+++ b/osfmk/mach/ppc/boolean.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/ppc/exception.h b/osfmk/mach/ppc/exception.h
index 480c56edf..67757395b 100644
--- a/osfmk/mach/ppc/exception.h
+++ b/osfmk/mach/ppc/exception.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -63,6 +66,7 @@
 #define EXC_PPC_PRIVINST	3    /* priviledged instruction */
 #define EXC_PPC_PRIVREG		4    /* priviledged register */
 #define EXC_PPC_TRACE		5    /* trace/single-step */
+#define EXC_PPC_PERFMON     6    /* performance monitor */ 
 
 /*
  *	EXC_BAD_ACCESS
diff --git a/osfmk/mach/ppc/kern_return.h b/osfmk/mach/ppc/kern_return.h
index e14be8d22..18906657e 100644
--- a/osfmk/mach/ppc/kern_return.h
+++ b/osfmk/mach/ppc/kern_return.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/ppc/machine_types.defs b/osfmk/mach/ppc/machine_types.defs
index 022702abd..007b9e455 100644
--- a/osfmk/mach/ppc/machine_types.defs
+++ b/osfmk/mach/ppc/machine_types.defs
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/ppc/ndr_def.h b/osfmk/mach/ppc/ndr_def.h
index 40e82519c..3e8e6145b 100644
--- a/osfmk/mach/ppc/ndr_def.h
+++ b/osfmk/mach/ppc/ndr_def.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/ppc/processor_info.h b/osfmk/mach/ppc/processor_info.h
index 15219f087..2a7fa52d0 100644
--- a/osfmk/mach/ppc/processor_info.h
+++ b/osfmk/mach/ppc/processor_info.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -104,12 +107,6 @@ typedef struct processor_pm_regs *processor_pm_regs_t;
 #define PROCESSOR_PM_REGS_COUNT \
         (sizeof(processor_pm_regs_data_t) / sizeof (unsigned int))
 
-#define PROCESSOR_PM_REGS_COUNT_POWERPC_604 \
-            (PROCESSOR_PM_REGS_COUNT * 1 )
-
-#define PROCESSOR_PM_REGS_COUNT_POWERPC_604e \
-            (PROCESSOR_PM_REGS_COUNT * 2 )
-
 #define PROCESSOR_PM_REGS_COUNT_POWERPC_750 \
             (PROCESSOR_PM_REGS_COUNT * 2 )
 
diff --git a/osfmk/mach/ppc/rpc.h b/osfmk/mach/ppc/rpc.h
index 1ceb410c3..109824983 100644
--- a/osfmk/mach/ppc/rpc.h
+++ b/osfmk/mach/ppc/rpc.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/ppc/syscall_sw.h b/osfmk/mach/ppc/syscall_sw.h
index 1af2369d8..a2d4fd045 100644
--- a/osfmk/mach/ppc/syscall_sw.h
+++ b/osfmk/mach/ppc/syscall_sw.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -71,6 +74,9 @@ ppc_trap(bb_disable_bluebox,0x6006)
 ppc_trap(bb_settaskenv,0x6007)	
 ppc_trap(vmm_stop_vm,0x6008)	
 ppc_trap(CHUDCall,0x6009)	
+ppc_trap(ppcNull,0x600A)	
+ppc_trap(perfmon_control,0x600B)	
+ppc_trap(ppcNullinst,0x600C)	
 #endif /* _MACH_SYSCALL_SW_H_ */
 
 #endif	/* _MACH_PPC_SYSCALL_SW_H_ */
diff --git a/osfmk/mach/ppc/thread_state.h b/osfmk/mach/ppc/thread_state.h
index 515d0d730..ca4ba1cec 100644
--- a/osfmk/mach/ppc/thread_state.h
+++ b/osfmk/mach/ppc/thread_state.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/ppc/thread_status.h b/osfmk/mach/ppc/thread_status.h
index 5f95da004..c19acd8c0 100644
--- a/osfmk/mach/ppc/thread_status.h
+++ b/osfmk/mach/ppc/thread_status.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -41,6 +44,8 @@
 #define PPC_FLOAT_STATE         2
 #define PPC_EXCEPTION_STATE		3
 #define PPC_VECTOR_STATE		4
+#define PPC_THREAD_STATE64		5
+#define PPC_EXCEPTION_STATE64	6
 #define THREAD_STATE_NONE		7
 	       
 /*
@@ -53,8 +58,10 @@
 #define VALID_THREAD_STATE_FLAVOR(x)       \
         ((x == PPC_THREAD_STATE)        || \
          (x == PPC_FLOAT_STATE)         || \
-	 (x == PPC_EXCEPTION_STATE)     || \
+	 (x == PPC_EXCEPTION_STATE)     	|| \
          (x == PPC_VECTOR_STATE)        || \
+         (x == PPC_THREAD_STATE64)      || \
+         (x == PPC_EXCEPTION_STATE64)   || \
          (x == THREAD_STATE_NONE))
 
 typedef struct ppc_thread_state {
@@ -102,6 +109,52 @@ typedef struct ppc_thread_state {
 	unsigned int vrsave;	/* Vector Save Register */
 } ppc_thread_state_t;
 
+#pragma pack(4)							/* Make sure the structure stays as we defined it */
+typedef struct ppc_thread_state64 {
+	unsigned long long srr0;	/* Instruction address register (PC) */
+	unsigned long long srr1;	/* Machine state register (supervisor) */
+	unsigned long long r0;
+	unsigned long long r1;
+	unsigned long long r2;
+	unsigned long long r3;
+	unsigned long long r4;
+	unsigned long long r5;
+	unsigned long long r6;
+	unsigned long long r7;
+	unsigned long long r8;
+	unsigned long long r9;
+	unsigned long long r10;
+	unsigned long long r11;
+	unsigned long long r12;
+	unsigned long long r13;
+	unsigned long long r14;
+	unsigned long long r15;
+	unsigned long long r16;
+	unsigned long long r17;
+	unsigned long long r18;
+	unsigned long long r19;
+	unsigned long long r20;
+	unsigned long long r21;
+	unsigned long long r22;
+	unsigned long long r23;
+	unsigned long long r24;
+	unsigned long long r25;
+	unsigned long long r26;
+	unsigned long long r27;
+	unsigned long long r28;
+	unsigned long long r29;
+	unsigned long long r30;
+	unsigned long long r31;
+
+	unsigned int cr;			/* Condition register */
+	unsigned long long xer;		/* User's integer exception register */
+	unsigned long long lr;		/* Link register */
+	unsigned long long ctr;		/* Count register */
+
+	unsigned int vrsave;		/* Vector Save Register */
+} ppc_thread_state64_t;
+#pragma pack()
+
 /* This structure should be double-word aligned for performance */
 
 typedef struct ppc_float_state {
@@ -146,14 +199,24 @@ typedef struct ppc_thread_state ppc_saved_state_t;
  */
 
 typedef struct ppc_exception_state {
-	unsigned long dar;	/* Fault registers for coredump */
+	unsigned long dar;			/* Fault registers for coredump */
 	unsigned long dsisr;
-	unsigned long exception;/* number of powerpc exception taken */
-	unsigned long pad0;	/* align to 16 bytes */
+	unsigned long exception;	/* number of powerpc exception taken */
+	unsigned long pad0;			/* align to 16 bytes */
 
-	unsigned long pad1[4];	/* space in PCB "just in case" */
+	unsigned long pad1[4];		/* space in PCB "just in case" */
 } ppc_exception_state_t;
 
+#pragma pack(4)					/* Make sure the structure stays as we defined it */
+typedef struct ppc_exception_state64 {
+	unsigned long long dar;		/* Fault registers for coredump */
+	unsigned long dsisr;
+	unsigned long exception;	/* number of powerpc exception taken */
+
+	unsigned long pad1[4];		/* space in PCB "just in case" */
+} ppc_exception_state64_t;
+#pragma pack()
+
 /*
  * Save State Flags
  */
@@ -161,9 +224,15 @@ typedef struct ppc_exception_state {
 #define PPC_THREAD_STATE_COUNT \
    (sizeof(struct ppc_thread_state) / sizeof(int))
 
+#define PPC_THREAD_STATE64_COUNT \
+   (sizeof(struct ppc_thread_state64) / sizeof(int))
+
 #define PPC_EXCEPTION_STATE_COUNT \
    (sizeof(struct ppc_exception_state) / sizeof(int))
 
+#define PPC_EXCEPTION_STATE64_COUNT \
+   (sizeof(struct ppc_exception_state64) / sizeof(int))
+
 #define PPC_FLOAT_STATE_COUNT \
    (sizeof(struct ppc_float_state) / sizeof(int))
 
diff --git a/osfmk/mach/ppc/vm_param.h b/osfmk/mach/ppc/vm_param.h
index 459bbfd24..d14a6e906 100644
--- a/osfmk/mach/ppc/vm_param.h
+++ b/osfmk/mach/ppc/vm_param.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -35,16 +38,10 @@
 
 #define VM_MIN_KERNEL_ADDRESS	((vm_offset_t) 0x00001000)
 
-/* We map the kernel using only SR0,SR1,SR2,SR3 leaving segments alone */
-#define VM_MAX_KERNEL_ADDRESS	((vm_offset_t) 0x3fffffff)
+#define VM_MAX_KERNEL_ADDRESS	((vm_offset_t) 0xDFFFFFFF)
 
 #define USER_STACK_END  ((vm_offset_t) 0xffff0000U)
 
-#define ppc_round_page(x)	((((unsigned)(x)) + PPC_PGBYTES - 1) & \
-					~(PPC_PGBYTES-1))
-#define ppc_trunc_page(x)	(((unsigned)(x)) & ~(PPC_PGBYTES-1))
-
-
 #define KERNEL_STACK_SIZE	(4 * PPC_PGBYTES)
 #define INTSTACK_SIZE		(5 * PPC_PGBYTES)
 
diff --git a/osfmk/mach/ppc/vm_types.h b/osfmk/mach/ppc/vm_types.h
index 157684e16..2f030e070 100644
--- a/osfmk/mach/ppc/vm_types.h
+++ b/osfmk/mach/ppc/vm_types.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -55,7 +58,7 @@
  *	Author:	Avadis Tevanian, Jr.
  *	Date: 1985
  *
- *	Header file for VM data types.  I386 version.
+ *	Header file for VM data types.  PPC version.
  */
 
 #ifndef	_MACH_PPC_VM_TYPES_H_
@@ -63,6 +66,8 @@
 
 #ifndef	ASSEMBLER
 
+#include <stdint.h>
+
 /*
  * A natural_t is the type for the native
  * integer type, e.g. 32 or 64 or.. whatever
@@ -98,11 +103,6 @@ typedef	natural_t	vm_offset_t;
  */
 typedef	natural_t		vm_size_t;
 
-/*
- * space_t is used in the pmap system
- */
-typedef unsigned int	space_t;
-
 #endif	/* ndef ASSEMBLER */
 
 /*
diff --git a/osfmk/mach/processor.defs b/osfmk/mach/processor.defs
index be0f2ae0e..50c7c4698 100644
--- a/osfmk/mach/processor.defs
+++ b/osfmk/mach/processor.defs
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/processor_info.h b/osfmk/mach/processor_info.h
index 17824334b..8ab6322eb 100644
--- a/osfmk/mach/processor_info.h
+++ b/osfmk/mach/processor_info.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/processor_set.defs b/osfmk/mach/processor_set.defs
index 8b01834b5..327755703 100644
--- a/osfmk/mach/processor_set.defs
+++ b/osfmk/mach/processor_set.defs
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/prof.defs b/osfmk/mach/prof.defs
index 9c140a6b8..4a9d93a42 100644
--- a/osfmk/mach/prof.defs
+++ b/osfmk/mach/prof.defs
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/prof_types.h b/osfmk/mach/prof_types.h
index e7096ddc4..3512b6648 100644
--- a/osfmk/mach/prof_types.h
+++ b/osfmk/mach/prof_types.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/rpc.h b/osfmk/mach/rpc.h
index 29d511d22..229ce23fd 100644
--- a/osfmk/mach/rpc.h
+++ b/osfmk/mach/rpc.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/semaphore.defs b/osfmk/mach/semaphore.defs
index 468b8c94f..d906e7da0 100644
--- a/osfmk/mach/semaphore.defs
+++ b/osfmk/mach/semaphore.defs
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/semaphore.h b/osfmk/mach/semaphore.h
index 55a4a39ab..8ac6f1963 100644
--- a/osfmk/mach/semaphore.h
+++ b/osfmk/mach/semaphore.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/shared_memory_server.h b/osfmk/mach/shared_memory_server.h
index 4f44265d9..03195e2c5 100644
--- a/osfmk/mach/shared_memory_server.h
+++ b/osfmk/mach/shared_memory_server.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/std_types.defs b/osfmk/mach/std_types.defs
index 23b1d49f5..7b1cf5301 100644
--- a/osfmk/mach/std_types.defs
+++ b/osfmk/mach/std_types.defs
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/std_types.h b/osfmk/mach/std_types.h
index c002d05fe..8a46240ba 100644
--- a/osfmk/mach/std_types.h
+++ b/osfmk/mach/std_types.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/sync.defs b/osfmk/mach/sync.defs
index fb011c404..dadf4d80d 100644
--- a/osfmk/mach/sync.defs
+++ b/osfmk/mach/sync.defs
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/sync_policy.h b/osfmk/mach/sync_policy.h
index bca61a6d8..4e4028454 100644
--- a/osfmk/mach/sync_policy.h
+++ b/osfmk/mach/sync_policy.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/syscall_sw.h b/osfmk/mach/syscall_sw.h
index c939b8050..1bbf2c75d 100644
--- a/osfmk/mach/syscall_sw.h
+++ b/osfmk/mach/syscall_sw.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/task.defs b/osfmk/mach/task.defs
index 45e9519e2..b3d410599 100644
--- a/osfmk/mach/task.defs
+++ b/osfmk/mach/task.defs
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/task_info.h b/osfmk/mach/task_info.h
index d9750ddd8..f6dc3b1a1 100644
--- a/osfmk/mach/task_info.h
+++ b/osfmk/mach/task_info.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/task_ledger.h b/osfmk/mach/task_ledger.h
index cf68eded1..a5c535172 100644
--- a/osfmk/mach/task_ledger.h
+++ b/osfmk/mach/task_ledger.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/task_policy.h b/osfmk/mach/task_policy.h
index cbf35f467..780eb181e 100644
--- a/osfmk/mach/task_policy.h
+++ b/osfmk/mach/task_policy.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/task_special_ports.h b/osfmk/mach/task_special_ports.h
index b3384f50e..2c98197be 100644
--- a/osfmk/mach/task_special_ports.h
+++ b/osfmk/mach/task_special_ports.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/thread_act.defs b/osfmk/mach/thread_act.defs
index 2637408a4..530dd2263 100644
--- a/osfmk/mach/thread_act.defs
+++ b/osfmk/mach/thread_act.defs
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/thread_info.h b/osfmk/mach/thread_info.h
index 7b99b9f59..6282d506e 100644
--- a/osfmk/mach/thread_info.h
+++ b/osfmk/mach/thread_info.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/thread_policy.h b/osfmk/mach/thread_policy.h
index 143081614..ef8c3bf77 100644
--- a/osfmk/mach/thread_policy.h
+++ b/osfmk/mach/thread_policy.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/thread_special_ports.h b/osfmk/mach/thread_special_ports.h
index a7e7a3193..c2419daac 100644
--- a/osfmk/mach/thread_special_ports.h
+++ b/osfmk/mach/thread_special_ports.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/thread_status.h b/osfmk/mach/thread_status.h
index 49903043b..dc01b6ae3 100644
--- a/osfmk/mach/thread_status.h
+++ b/osfmk/mach/thread_status.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/thread_switch.h b/osfmk/mach/thread_switch.h
index e03383287..eb675e284 100644
--- a/osfmk/mach/thread_switch.h
+++ b/osfmk/mach/thread_switch.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/time_value.h b/osfmk/mach/time_value.h
index afaff9eee..3bc09a77b 100644
--- a/osfmk/mach/time_value.h
+++ b/osfmk/mach/time_value.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/upl.defs b/osfmk/mach/upl.defs
index 89fc94389..b10e5a2a1 100644
--- a/osfmk/mach/upl.defs
+++ b/osfmk/mach/upl.defs
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/vm_attributes.h b/osfmk/mach/vm_attributes.h
index 595c8b926..73fa44766 100644
--- a/osfmk/mach/vm_attributes.h
+++ b/osfmk/mach/vm_attributes.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/vm_behavior.h b/osfmk/mach/vm_behavior.h
index 6b2eee6d6..31431769b 100644
--- a/osfmk/mach/vm_behavior.h
+++ b/osfmk/mach/vm_behavior.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/vm_inherit.h b/osfmk/mach/vm_inherit.h
index d6efd9b57..0fff91768 100644
--- a/osfmk/mach/vm_inherit.h
+++ b/osfmk/mach/vm_inherit.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/vm_map.defs b/osfmk/mach/vm_map.defs
index e0f88b10a..aeb2fe50a 100644
--- a/osfmk/mach/vm_map.defs
+++ b/osfmk/mach/vm_map.defs
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/vm_param.h b/osfmk/mach/vm_param.h
index aba1ed3ef..c7a034389 100644
--- a/osfmk/mach/vm_param.h
+++ b/osfmk/mach/vm_param.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -79,7 +82,10 @@
 #endif	/* KERNEL_PRIVATE */
 
 #include <mach/machine/vm_param.h>
-#include <mach/machine/vm_types.h>
+
+#ifndef	ASSEMBLER
+#include <mach/vm_types.h>
+#endif	/* ASSEMBLER */
 
 /*
  *	The machine independent pages are refered to as PAGES.  A page
@@ -98,11 +104,19 @@
  *	virtual memory system implementation.
  */
 
-#ifndef	PAGE_SIZE_FIXED
+#ifdef	PAGE_SIZE_FIXED
+#define PAGE_SIZE	4096
+#define PAGE_SHIFT	12
+#define	PAGE_MASK	(PAGE_SIZE-1)
+#endif	/* PAGE_SIZE_FIXED */
+
+#ifndef	ASSEMBLER
+
 extern vm_size_t	page_size;
 extern vm_size_t	page_mask;
 extern int		page_shift;
 
+#ifndef	PAGE_SIZE_FIXED
 #define PAGE_SIZE	page_size 	/* pagesize in addr units */
 #define PAGE_SHIFT	page_shift	/* number of bits to shift for pages */
 #define PAGE_MASK	page_mask	/* mask for off in page */
@@ -110,33 +124,123 @@ extern int		page_shift;
 #define PAGE_SIZE_64 (unsigned long long)page_size /* pagesize in addr units */
 #define PAGE_MASK_64 (unsigned long long)page_mask /* mask for off in page */
 #else	/* PAGE_SIZE_FIXED */
-#define PAGE_SIZE	4096
-#define PAGE_SHIFT	12
-#define	PAGE_MASK	(PAGE_SIZE-1)
+
 #define PAGE_SIZE_64	(unsigned long long)4096
 #define PAGE_MASK_64	(PAGE_SIZE_64-1)
 #endif	/* PAGE_SIZE_FIXED */
 
-#ifndef	ASSEMBLER
 /*
- *	Convert addresses to pages and vice versa.
- *	No rounding is used.
+ *	Convert addresses to pages and vice versa.  No rounding is used.
+ *      The atop_32 and ptoa_32 macros should not be use on 64 bit types.
+ *      The round_page_64 and trunc_page_64 macros should be used instead.
  */
 
-#define atop(x)		(((natural_t)(x)) >> PAGE_SHIFT)
-#define ptoa(x)		((vm_offset_t)((x) << PAGE_SHIFT))
+#define atop_32(x) ((uint32_t)(x) >> PAGE_SHIFT)
+#define ptoa_32(x) ((uint32_t)(x) << PAGE_SHIFT)
+#define atop_64(x) ((uint64_t)(x) >> PAGE_SHIFT)
+#define ptoa_64(x) ((uint64_t)(x) << PAGE_SHIFT)
+
+/*
+ *      While the following block is enabled, the legacy atop and ptoa
+ *      macros will behave correctly.  If not, they will generate
+ *      invalid lvalue errors.
+ */
+
+#if 1
+#define atop(x)	((uint32_t)(x) >> PAGE_SHIFT)
+#define ptoa(x)	((uint32_t)(x) << PAGE_SHIFT)
+#else
+#define atop(x) (0UL = 0)
+#define ptoa(x) (0UL = 0)
+#endif
+
 
 /*
  *	Round off or truncate to the nearest page.  These will work
  *	for either addresses or counts.  (i.e. 1 byte rounds to 1 page
- *	bytes.
+ *	bytes.  The round_page_32 and trunc_page_32 macros should not be
+ *      use on 64 bit types.  The round_page_64 and trunc_page_64 macros
+ *      should be used instead.
+ */
+
+#define round_page_32(x) (((uint32_t)(x) + PAGE_MASK) & ~((signed)PAGE_MASK))
+#define trunc_page_32(x) ((uint32_t)(x) & ~((signed)PAGE_MASK))
+#define round_page_64(x) (((uint64_t)(x) + PAGE_MASK) & ~((signed)PAGE_MASK))
+#define trunc_page_64(x) ((uint64_t)(x) & ~((signed)PAGE_MASK))
+
+
+/*
+ *      While the following block is enabled, the legacy round_page
+ *      and trunc_page macros will behave correctly.  If not, they will
+ *      generate invalid lvalue errors.
+ */
+
+#if 1
+#define round_page(x) (((uint32_t)(x) + PAGE_MASK) & ~((signed)PAGE_MASK))
+#define trunc_page(x) ((uint32_t)(x) & ~((signed)PAGE_MASK))
+#else
+#define round_page(x) (0UL = 0)
+#define trunc_page(x) (0UL = 0)
+#endif
+
+/*
+ *      Enable the following block to find uses of xxx_32 macros that should
+ *      be xxx_64.  These macros only work in C code, not C++.  The resulting
+ *      binaries are not functional.  Look for invalid lvalue errors in
+ *      the compiler output.
+ *
+ *      Enabling the following block will also find use of the xxx_64 macros
+ *      that have been passed pointers.  The parameters should be case to an
+ *      unsigned long type first.  Look for invalid operands to binary + error
+ *      in the compiler output.
  */
 
-#define round_page(x)	((vm_offset_t)((((vm_offset_t)(x)) + PAGE_MASK) & ~PAGE_MASK))
-#define trunc_page(x)	((vm_offset_t)(((vm_offset_t)(x)) & ~PAGE_MASK))
+#if 0
+#undef atop_32
+#undef ptoa_32
+#undef round_page_32
+#undef trunc_page_32
+#undef atop_64
+#undef ptoa_64
+#undef round_page_64
+#undef trunc_page_64
+
+#ifndef __cplusplus
+
+#define atop_32(x) \
+    (__builtin_choose_expr (sizeof(x) != sizeof(uint64_t), \
+        (*(long *)0), \
+        (0UL)) = 0)
+
+#define ptoa_32(x) \
+    (__builtin_choose_expr (sizeof(x) != sizeof(uint64_t), \
+        (*(long *)0), \
+        (0UL)) = 0)
+
+#define round_page_32(x) \
+    (__builtin_choose_expr (sizeof(x) != sizeof(uint64_t), \
+        (*(long *)0), \
+        (0UL)) = 0)
+
+#define trunc_page_32(x) \
+    (__builtin_choose_expr (sizeof(x) != sizeof(uint64_t), \
+        (*(long *)0), \
+        (0UL)) = 0)
+#else
+
+#define atop_32(x) (0)
+#define ptoa_32(x) (0)
+#define round_page_32(x) (0)
+#define trunc_page_32(x) (0)
+
+#endif /* ! __cplusplus */
+
+#define atop_64(x) ((uint64_t)((x) + (uint8_t *)0))
+#define ptoa_64(x) ((uint64_t)((x) + (uint8_t *)0))
+#define round_page_64(x) ((uint64_t)((x) + (uint8_t *)0))
+#define trunc_page_64(x) ((uint64_t)((x) + (uint8_t *)0))
 
-#define round_page_64(x)	((unsigned long long)((((unsigned long long)(x)) + PAGE_MASK_64) & ~PAGE_MASK_64))
-#define trunc_page_64(x)	((unsigned long long)(((unsigned long long)(x)) & ~PAGE_MASK_64))
+#endif
 
 /*
  *	Determine whether an address is page-aligned, or a count is
@@ -145,7 +249,11 @@ extern int		page_shift;
 
 #define	page_aligned(x)	((((vm_object_offset_t) (x)) & PAGE_MASK) == 0)
 
-extern vm_size_t	mem_size;	/* size of physical memory (bytes) */
+extern vm_size_t	mem_size;		/* 32-bit size of memory - limited by maxmem - deprecated */
+extern uint64_t	max_mem;			/* 64-bit size of memory - limited by maxmem */
+extern uint64_t	mem_actual;			/* 64-bit size of memory - not limited by maxmem */
+extern uint64_t	sane_size;			/* Memory size to use for defaults calculations */
+extern addr64_t 	vm_last_addr;	/* Highest kernel virtual address known to the VM system */
 
 #endif	/* ASSEMBLER */
 #endif	/* _MACH_VM_PARAM_H_ */
diff --git a/osfmk/mach/vm_prot.h b/osfmk/mach/vm_prot.h
index 9980336e4..4f29436d4 100644
--- a/osfmk/mach/vm_prot.h
+++ b/osfmk/mach/vm_prot.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/vm_region.h b/osfmk/mach/vm_region.h
index 1fd3e2492..f77c731da 100644
--- a/osfmk/mach/vm_region.h
+++ b/osfmk/mach/vm_region.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/vm_statistics.h b/osfmk/mach/vm_statistics.h
index f2667b9c5..754aec336 100644
--- a/osfmk/mach/vm_statistics.h
+++ b/osfmk/mach/vm_statistics.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/vm_sync.h b/osfmk/mach/vm_sync.h
index af5562372..827b22d5a 100644
--- a/osfmk/mach/vm_sync.h
+++ b/osfmk/mach/vm_sync.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach/vm_types.h b/osfmk/mach/vm_types.h
index 0e7470124..cdfa02cd3 100644
--- a/osfmk/mach/vm_types.h
+++ b/osfmk/mach/vm_types.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -36,6 +39,34 @@ typedef vm_offset_t     	pointer_t;
 typedef vm_offset_t     	vm_address_t;
 typedef uint64_t		vm_object_offset_t;
 
+/*
+ * We use addr64_t for 64-bit addresses that are used on both
+ * 32 and 64-bit machines.  On PPC, they are passed and returned as
+ * two adjacent 32-bit GPRs.  We use addr64_t in places where
+ * common code must be useable both on 32 and 64-bit machines.
+ */
+typedef uint64_t addr64_t;		/* Basic effective address */
+
+/*
+ * We use reg64_t for addresses that are 32 bits on a 32-bit
+ * machine, and 64 bits on a 64-bit machine, but are always
+ * passed and returned in a single GPR on PPC.  This type
+ * cannot be used in generic 32-bit c, since on a 64-bit
+ * machine the upper half of the register will be ignored
+ * by the c compiler in 32-bit mode.  In c, we can only use the
+ * type in prototypes of functions that are written in and called
+ * from assembly language.  This type is basically a comment.
+ */
+typedef	uint32_t	reg64_t;
+
+/*
+ * To minimize the use of 64-bit fields, we keep some physical
+ * addresses (that are page aligned) as 32-bit page numbers. 
+ * This limits the physical address space to 16TB of RAM.
+ */
+typedef uint32_t ppnum_t;		/* Physical page number */
+
+
 #ifdef KERNEL_PRIVATE
 
 #if !defined(__APPLE_API_PRIVATE) || !defined(MACH_KERNEL_PRIVATE)
diff --git a/osfmk/mach_debug/hash_info.h b/osfmk/mach_debug/hash_info.h
index bb8b5e3a2..bb99a4585 100644
--- a/osfmk/mach_debug/hash_info.h
+++ b/osfmk/mach_debug/hash_info.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach_debug/ipc_info.h b/osfmk/mach_debug/ipc_info.h
index f3ec4fac8..70cb31577 100644
--- a/osfmk/mach_debug/ipc_info.h
+++ b/osfmk/mach_debug/ipc_info.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach_debug/mach_debug.h b/osfmk/mach_debug/mach_debug.h
index 8f1a6f095..5779704aa 100644
--- a/osfmk/mach_debug/mach_debug.h
+++ b/osfmk/mach_debug/mach_debug.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach_debug/mach_debug_types.defs b/osfmk/mach_debug/mach_debug_types.defs
index ce06a74d0..2188fb46c 100644
--- a/osfmk/mach_debug/mach_debug_types.defs
+++ b/osfmk/mach_debug/mach_debug_types.defs
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach_debug/mach_debug_types.h b/osfmk/mach_debug/mach_debug_types.h
index 27e2684cc..2cb575b85 100644
--- a/osfmk/mach_debug/mach_debug_types.h
+++ b/osfmk/mach_debug/mach_debug_types.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach_debug/page_info.h b/osfmk/mach_debug/page_info.h
index 3f05d26a8..d98d7dcb2 100644
--- a/osfmk/mach_debug/page_info.h
+++ b/osfmk/mach_debug/page_info.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach_debug/vm_info.h b/osfmk/mach_debug/vm_info.h
index 38aa6e6b1..7807016c8 100644
--- a/osfmk/mach_debug/vm_info.h
+++ b/osfmk/mach_debug/vm_info.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/mach_debug/zone_info.h b/osfmk/mach_debug/zone_info.h
index 60b56d694..e6d533dd1 100644
--- a/osfmk/mach_debug/zone_info.h
+++ b/osfmk/mach_debug/zone_info.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/machine/Makefile b/osfmk/machine/Makefile
index ae517d9e9..141fa285b 100644
--- a/osfmk/machine/Makefile
+++ b/osfmk/machine/Makefile
@@ -12,6 +12,8 @@ DATAFILES = \
 	machlimits.h 	\
 	ast.h	\
 	ast_types.h	\
+	commpage.h	\
+	cpu_capabilities.h	\
 	cpu_number.h	\
 	db_machdep.h	\
 	endian.h	\
@@ -36,6 +38,9 @@ DATAFILES = \
 	xpr.h		\
 	hw_lock_types.h
 
+INSTALL_MI_LCL_LIST = cpu_capabilities.h
+
+INSTALL_MI_DIR = machine
 
 EXPORT_MI_LIST = ${DATAFILES}
 
diff --git a/osfmk/machine/asm.h b/osfmk/machine/asm.h
index b0ace5272..df298a6b8 100644
--- a/osfmk/machine/asm.h
+++ b/osfmk/machine/asm.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/machine/ast.h b/osfmk/machine/ast.h
index 5ec6ba6eb..db97c7293 100644
--- a/osfmk/machine/ast.h
+++ b/osfmk/machine/ast.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/machine/ast_types.h b/osfmk/machine/ast_types.h
index b04ed6317..de7ca848d 100644
--- a/osfmk/machine/ast_types.h
+++ b/osfmk/machine/ast_types.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/machine/commpage.h b/osfmk/machine/commpage.h
new file mode 100644
index 000000000..cac45f519
--- /dev/null
+++ b/osfmk/machine/commpage.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ * 
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ * 
+ * @APPLE_LICENSE_HEADER_END@
+ */
+
+#ifndef _MACHINE_COMMPAGE_H
+#define _MACHINE_COMMPAGE_H
+
+#if defined (__ppc__)
+#include "ppc/commpage/commpage.h"
+#elif defined (__i386__)
+#include "i386/commpage/commpage.h"
+#else
+#error architecture not supported
+#endif
+
+#ifndef	__ASSEMBLER__
+
+extern	void	commpage_populate( void ); 	/* called once during startup */
+
+#endif	/* __ASSEMBLER__ */
+
+#endif	/* _MACHINE_COMMPAGE_H */
diff --git a/osfmk/machine/cpu_capabilities.h b/osfmk/machine/cpu_capabilities.h
new file mode 100644
index 000000000..52ec0f320
--- /dev/null
+++ b/osfmk/machine/cpu_capabilities.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ * 
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ * 
+ * @APPLE_LICENSE_HEADER_END@
+ */
+
+#ifndef _MACHINE_CPU_CAPABILITIES_H
+#define _MACHINE_CPU_CAPABILITIES_H
+
+#ifdef __APPLE_API_PRIVATE
+
+#if defined (__ppc__)
+#include "ppc/cpu_capabilities.h"
+#elif defined (__i386__)
+#include "i386/cpu_capabilities.h"
+#else
+#error architecture not supported
+#endif
+
+#endif /* __APPLE_API_PRIVATE */
+#endif /* _MACHINE_CPU_CAPABILITIES_H */
diff --git a/osfmk/machine/cpu_data.h b/osfmk/machine/cpu_data.h
index b10bac948..17e30b0ff 100644
--- a/osfmk/machine/cpu_data.h
+++ b/osfmk/machine/cpu_data.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/machine/cpu_number.h b/osfmk/machine/cpu_number.h
index 075c108eb..cda615448 100644
--- a/osfmk/machine/cpu_number.h
+++ b/osfmk/machine/cpu_number.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/machine/db_machdep.h b/osfmk/machine/db_machdep.h
index bec9b4715..5b74664d4 100644
--- a/osfmk/machine/db_machdep.h
+++ b/osfmk/machine/db_machdep.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/machine/disk.h b/osfmk/machine/disk.h
index 03174e58d..3ff990564 100644
--- a/osfmk/machine/disk.h
+++ b/osfmk/machine/disk.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/machine/endian.h b/osfmk/machine/endian.h
index f0c8b29d3..14eb8c515 100644
--- a/osfmk/machine/endian.h
+++ b/osfmk/machine/endian.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/machine/gdb_defs.h b/osfmk/machine/gdb_defs.h
index 821448666..5fba823bb 100644
--- a/osfmk/machine/gdb_defs.h
+++ b/osfmk/machine/gdb_defs.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/machine/hw_lock_types.h b/osfmk/machine/hw_lock_types.h
index 0335f3601..d15ba7790 100644
--- a/osfmk/machine/hw_lock_types.h
+++ b/osfmk/machine/hw_lock_types.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/machine/io_map_entries.h b/osfmk/machine/io_map_entries.h
index 49a6b83ab..8257fca0b 100644
--- a/osfmk/machine/io_map_entries.h
+++ b/osfmk/machine/io_map_entries.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/machine/iobus.h b/osfmk/machine/iobus.h
index b6e758edd..2ea845c13 100644
--- a/osfmk/machine/iobus.h
+++ b/osfmk/machine/iobus.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/machine/kgdb_defs.h b/osfmk/machine/kgdb_defs.h
index c4178dcd1..f9a0a8d8e 100644
--- a/osfmk/machine/kgdb_defs.h
+++ b/osfmk/machine/kgdb_defs.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/machine/kgdb_setjmp.h b/osfmk/machine/kgdb_setjmp.h
index 256830d27..8d8458bec 100644
--- a/osfmk/machine/kgdb_setjmp.h
+++ b/osfmk/machine/kgdb_setjmp.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/machine/lock.h b/osfmk/machine/lock.h
index a65444044..17b0b62e9 100644
--- a/osfmk/machine/lock.h
+++ b/osfmk/machine/lock.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/machine/mach_param.h b/osfmk/machine/mach_param.h
index f143d6aff..d473a3406 100644
--- a/osfmk/machine/mach_param.h
+++ b/osfmk/machine/mach_param.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/machine/machine_routines.h b/osfmk/machine/machine_routines.h
index 57481db5a..4d01bb68c 100644
--- a/osfmk/machine/machine_routines.h
+++ b/osfmk/machine/machine_routines.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/machine/machine_rpc.h b/osfmk/machine/machine_rpc.h
index bb1891453..6f1379eb5 100644
--- a/osfmk/machine/machine_rpc.h
+++ b/osfmk/machine/machine_rpc.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/machine/machlimits.h b/osfmk/machine/machlimits.h
index 2add98192..9f9de5e3a 100644
--- a/osfmk/machine/machlimits.h
+++ b/osfmk/machine/machlimits.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/machine/machparam.h b/osfmk/machine/machparam.h
index f29685ffc..c2d1eea78 100644
--- a/osfmk/machine/machparam.h
+++ b/osfmk/machine/machparam.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/machine/pmap.h b/osfmk/machine/pmap.h
index 198bdd167..a35c0206c 100644
--- a/osfmk/machine/pmap.h
+++ b/osfmk/machine/pmap.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/machine/sched_param.h b/osfmk/machine/sched_param.h
index c32ea5f61..c419f7105 100644
--- a/osfmk/machine/sched_param.h
+++ b/osfmk/machine/sched_param.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/machine/setjmp.h b/osfmk/machine/setjmp.h
index 1f4e5ef2c..2678b53cb 100644
--- a/osfmk/machine/setjmp.h
+++ b/osfmk/machine/setjmp.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/machine/spl.h b/osfmk/machine/spl.h
index f343dbb3e..aa82e03d9 100644
--- a/osfmk/machine/spl.h
+++ b/osfmk/machine/spl.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/machine/task.h b/osfmk/machine/task.h
index 56f48ae72..dd32100ec 100644
--- a/osfmk/machine/task.h
+++ b/osfmk/machine/task.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/machine/thread.h b/osfmk/machine/thread.h
index 11ace465a..823c46327 100644
--- a/osfmk/machine/thread.h
+++ b/osfmk/machine/thread.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/machine/thread_act.h b/osfmk/machine/thread_act.h
index e40989981..658f50db7 100644
--- a/osfmk/machine/thread_act.h
+++ b/osfmk/machine/thread_act.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/machine/timer.h b/osfmk/machine/timer.h
index eafb03fb9..6d9f8520f 100644
--- a/osfmk/machine/timer.h
+++ b/osfmk/machine/timer.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/machine/trap.h b/osfmk/machine/trap.h
index ef021722c..ba26e5ca7 100644
--- a/osfmk/machine/trap.h
+++ b/osfmk/machine/trap.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/machine/vm_tuning.h b/osfmk/machine/vm_tuning.h
index d74da3049..a8f2bac10 100644
--- a/osfmk/machine/vm_tuning.h
+++ b/osfmk/machine/vm_tuning.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/machine/xpr.h b/osfmk/machine/xpr.h
index 9507298b8..c8be0442f 100644
--- a/osfmk/machine/xpr.h
+++ b/osfmk/machine/xpr.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ppc/AltiAssist.s b/osfmk/ppc/AltiAssist.s
index 5d194389b..540a232b9 100644
--- a/osfmk/ppc/AltiAssist.s
+++ b/osfmk/ppc/AltiAssist.s
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -36,8 +39,6 @@
 #include <mach/machine/vm_param.h>
 #include <assym.s>
 
-#define kernAccess 31
-
 ;
 ;
 ;			General stuff what happens here:
@@ -68,11 +69,7 @@
 
 LEXT(AltivecAssist)
 
-			mfmsr		r20							; Get the current MSR
 			li			r10,emvr0					; Point to the vector savearea
-			oris		r20,r20,hi16(MASK(MSR_VEC))	; Turn on vector
-			mtmsr		r20							; Turn on vector
-			isync
 			
 			li			r11,emvr1					; Another savearea
 			stvxl		v0,r10,r2					; Save V0
diff --git a/osfmk/ppc/Diagnostics.c b/osfmk/ppc/Diagnostics.c
index ffa7e0f64..a24486c8d 100644
--- a/osfmk/ppc/Diagnostics.c
+++ b/osfmk/ppc/Diagnostics.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -54,7 +57,6 @@
 #include <ppc/mappings.h>
 #include <ppc/pmap.h>
 #include <ppc/mem.h>
-#include <ppc/pmap_internals.h>
 #include <ppc/savearea.h>
 #include <ppc/Diagnostics.h>
 #include <ppc/machine_cpu.h>
@@ -75,8 +77,11 @@ int diagCall(struct savearea *save) {
 	} ttt, adj;
 	natural_t tbu, tbu2, tbl;
 	struct per_proc_info *per_proc;					/* Area for my per_proc address */
-	int cpu;
+	int cpu, ret;
 	unsigned int tstrt, tend, temp, temp2;
+	addr64_t src, snk;
+	uint64_t scom, hid1, hid4, srrwrk, stat;
+	scomcomm sarea;
 
 	if(!(dgWork.dgFlags & enaDiagSCs)) return 0;	/* If not enabled, cause an exception */
 
@@ -116,7 +121,7 @@ int diagCall(struct savearea *save) {
  */
 		case dgLRA:
 		
-			save->save_r3 = pmap_extract(current_act()->map->pmap, save->save_r4);	/* Get read address */
+			save->save_r3 = pmap_find_phys(current_act()->map->pmap, save->save_r4);	/* Get read address */
 			
 			return -1;								/* Return no AST checking... */
 			
@@ -125,11 +130,58 @@ int diagCall(struct savearea *save) {
  */
 		case dgpcpy:
 		
-#if 0
-			save->save_r3 = copyp2v(save->save_r4, save->save_r5, save->save_r6);	/* Copy the physical page */
+		
+#if 1
+			src = (save->save_r4 << 32) | (0x00000000FFFFFFFFULL & save->save_r5);	/* Merge into 64-bit */
+			snk = (save->save_r6 << 32) | (0x00000000FFFFFFFFULL & save->save_r7);	/* Merge into 64-bit */
+			save->save_r3 = copypv(src, snk, save->save_r8, save->save_r9);	/* Copy the physical page */
 #endif			
 			return 1;								/* Return and check for ASTs... */
 			
+/*
+ *		Read/Write physical memory
+ */
+		case dgprw:
+		
+			src = (save->save_r5 << 32) | (0x00000000FFFFFFFFULL & save->save_r6);	/* Merge into 64-bit */
+			
+			switch(save->save_r4) {					/* Select the actual function */
+
+				case 0:
+					save->save_r3 = (uint64_t)ml_phys_read_byte((unsigned int)src);
+					break;
+			
+				case 1:
+					save->save_r3 = (uint64_t)ml_phys_read_byte_64(src);
+					break;
+				
+				case 2:
+					save->save_r3 = (uint64_t)ml_phys_read((unsigned int)src);
+					break;
+				
+				case 3:
+					save->save_r3 = (uint64_t)ml_phys_read_64(src);
+					break;
+
+				case 4:
+					ml_phys_write_byte((unsigned int)src, (unsigned int)save->save_r7);
+					break;
+			
+				case 5:
+					ml_phys_write_byte_64(src, (unsigned int)save->save_r7);
+					break;
+				
+				case 6:
+					ml_phys_write((unsigned int)src, (unsigned int)save->save_r7);
+					break;
+				
+				case 7:
+					ml_phys_write_64(src, (unsigned int)save->save_r7);
+					break;
+			}
+
+			return 1;								/* Return and check for ASTs... */
+			
 			
 /*
  *		Soft reset processor
@@ -159,16 +211,7 @@ int diagCall(struct savearea *save) {
  */
 		case dgFlush:
 		
-#if 1
 			cacheInit();							/* Blow cache */
-#else
-			asm volatile("	mftb %0" : "=r" (tstrt));
-			tend = tstrt;			
-			while((tend - tstrt) < 0x000A2837) {
-				asm volatile("	mftb %0" : "=r" (tend));
-			}
-
-#endif
 			return 1;								/* Return and check for ASTs... */
 
 /*
@@ -189,9 +232,9 @@ int diagCall(struct savearea *save) {
  *		parms - vaddr, paddr, size, prot, attributes
  */
 		case dgBMphys:
-		
-			pmap_map_block(current_act()->map->pmap, save->save_r4, save->save_r5, save->save_r6,	/* Map in the block */
-				save->save_r7, save->save_r8, 0);
+					
+			pmap_map_block(current_act()->map->pmap, (addr64_t)save->save_r4,	/* Map in the block */ 
+				save->save_r5, save->save_r6, save->save_r7, save->save_r8, 0);
 
 			return 1;								/* Return and check for ASTs... */
 		
@@ -210,28 +253,16 @@ int diagCall(struct savearea *save) {
 /*
  *		Allows direct control of alignment handling.
  *
- *		The bottom two bits of the parameter are used to set the two control bits:
- *		0b00 - !trapUnalignbit - !notifyUnalignbit - default - instruction is emulated
- *		0b01 - !trapUnalignbit -  notifyUnalignbit - emulation is done, but traps afterwards
- *		0b10 -  trapUnalignbit - !notifyUnalignbit - no emulation - causes exception
- *		0b11 -  trapUnalignbit -  notifyUnalignbit - no emulation - causes exception
+ *		The bottom bit of the parameter is used to set the control bit, enaNotifyEM.
  */
 		case dgAlign:
 		
-			temp = current_act()->mact.specFlags;	/* Save the old values */
-			
-			temp = ((current_act()->mact.specFlags >> (31 - trapUnalignbit - 1)) 	/* Reformat them to pass back */
-				| (current_act()->mact.specFlags >> (31 - notifyUnalignbit))) & 3;
-				
-			temp2 = ((save->save_r4 << (31 - trapUnalignbit - 1)) & trapUnalign)	/* Move parms into flag format */
-				| ((save->save_r4 << (31 - notifyUnalignbit)) & notifyUnalign);
-
-			current_act()->mact.specFlags &= ~(trapUnalign | notifyUnalign);		/* Clean the old ones */
-			current_act()->mact.specFlags |= temp2;									/* Set the new ones */
-			
-			per_proc_info[cpu_number()].spcFlags = current_act()->mact.specFlags;
+			temp = dgWork.dgFlags;				/* Save the old values */
 			
-			save->save_r3 = temp;
+			temp2 = (save->save_r4 & 1) << (31 - enaNotifyEMb);	/* Move parms into flag format */
+			dgWork.dgFlags = (temp & ~enaNotifyEM) | temp2;	/* Set the flag */
+		
+			save->save_r3 = (temp >> (31 - enaNotifyEMb)) & 1;	/* Return the original */
 			
 			return 1;								/* Return and check for ASTs... */
 			
@@ -240,14 +271,102 @@ int diagCall(struct savearea *save) {
  */
 		case dgBootScreen:
 			
-#if 0
 			ml_set_interrupts_enabled(1);
 			(void)copyout((char *)&vinfo, (char *)save->save_r4, sizeof(struct vc_info));	/* Copy out the video info */
 			ml_set_interrupts_enabled(0);
-#endif
 			return 1;								/* Return and check for ASTs... */
 			
+/*
+ *		Don't return info for boot screen
+ */
+		case dgCPNull:
+			
+			ml_set_interrupts_enabled(1);
+			(void)copyout((char *)&vinfo, (char *)save->save_r4, 0);	/* Copy out nothing */
+			ml_set_interrupts_enabled(0);
+			return 1;								/* Return and check for ASTs... */
+			
+/*
+ *		Test machine check handler - only on 64-bit machines
+ */
+		case dgmck:
+			if(!(per_proc_info[0].pf.Available & pf64Bit)) return 0;	/* Leave if not correct machine */
+
+			fwEmMck(save->save_r4, save->save_r5, save->save_r6, save->save_r7, save->save_r8, save->save_r9);	/* Start injecting */ 
+
+			return -1;								/* Return and don't check for ASTs... */
+
+/*
+ *		Set 64-bit on or off - only on 64-bit machines
+ */
+		case dg64:
+			if(!(per_proc_info[0].pf.Available & pf64Bit)) return 0;	/* Leave if not correct machine */
+
+			srrwrk = save->save_srr1 >> 63;			/* Save the old 64-bit bit */
+			
+			save->save_srr1 = (save->save_srr1 & 0x7FFFFFFFFFFFFFFFULL) | (save->save_r4 << 63);	/* Set the requested mode */
+			save->save_r3 = srrwrk;					/* Return the old value */
+
+			return -1;								/* Return and don't check for ASTs... */
+		
+/*
+ *		Test the probe read function
+ */
+
+		case dgProbeRead:
+		
+			src = (save->save_r4 << 32) | (0x00000000FFFFFFFFULL & save->save_r5);	/* Merge into 64-bit */
+			save->save_r3 = ml_probe_read_64(src, &temp);	/* Try the address */
+			save->save_r4 = temp;					/* Return the data */
+			return -1;								/* Regurn and don't check for ASTs */
+		
+/*
+ *		Do perf monitor stuff
+ */
+
+		case dgPerfMon:
 		
+			setPmon(save->save_r4, save->save_r5);	/* Go load up MMCR0 and MMCR1 */
+			return -1;								/* Regurn and don't check for ASTs */
+
+/*
+ *		Map a page
+ *		Don't bother to check for any errors.
+ *		parms - vaddr, paddr, prot, attributes
+ */
+		case dgMapPage:
+					
+			(void)mapping_map(current_act()->map->pmap, /* Map in the page */ 
+				(addr64_t)(((save->save_r5 & 0xFFFFFFFF) << 32) | (save->save_r5 & 0xFFFFFFFF)), save->save_r6, 0, 1, VM_PROT_READ|VM_PROT_WRITE);
+
+			return -1;								/* Return and check for ASTs... */
+		
+/*
+ *		SCOM interface
+ *		parms - pointer to scomcomm
+ */
+		case dgScom:
+					
+			ret = copyin((unsigned int)(save->save_r4), &sarea, sizeof(scomcomm));	/* Get the data */
+			if(ret) return 0;						/* Copyin failed - return an exception */
+			
+			sarea.scomstat = 0xFFFFFFFFFFFFFFFFULL;	/* Clear status */
+			cpu = cpu_number();						/* Get us */
+			
+			if((sarea.scomcpu < NCPUS) && machine_slot[sarea.scomcpu].running) {
+				if(sarea.scomcpu == cpu) fwSCOM(&sarea);	/* Do it if it is us */
+				else {									/* Otherwise, tell the other processor */
+					(void)cpu_signal(sarea.scomcpu, SIGPcpureq, CPRQscom ,(unsigned int)&sarea);	/* Ask him to do this */
+					(void)hw_cpu_sync((unsigned long)&sarea.scomstat, LockTimeOut);	/* Wait for the other processor to get its temperature */
+				}
+			}
+
+			ret = copyout(&sarea, (unsigned int)(save->save_r4), sizeof(scomcomm));	/* Get the data */
+			if(ret) return 0;						/* Copyin failed - return an exception */
+	
+			return -1;								/* Return and check for ASTs... */
+		
+
 		default:									/* Handle invalid ones */
 			return 0;								/* Return an exception */
 		
diff --git a/osfmk/ppc/Diagnostics.h b/osfmk/ppc/Diagnostics.h
index 6837f338f..979c256ef 100644
--- a/osfmk/ppc/Diagnostics.h
+++ b/osfmk/ppc/Diagnostics.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -52,6 +55,14 @@ int diagCall(struct savearea *save);
 #define dgBootScreen 7
 #define dgFlush 8
 #define dgAlign 9
+#define dgprw 10
+#define dgmck 11
+#define dg64 12
+#define dgProbeRead 13
+#define dgCPNull 14
+#define dgPerfMon 15
+#define dgMapPage 16
+#define dgScom 17
 
 
 typedef struct diagWork {			/* Diagnostic work area */
@@ -70,6 +81,10 @@ typedef struct diagWork {			/* Diagnostic work area */
 #define enaDiagSDMb  27
 #define enaDiagEM  0x00000020
 #define enaDiagEMb  26
+#define enaDiagTrap  0x00000040
+#define enaDiagTrapb  25
+#define enaNotifyEM  0x00000080
+#define enaNotifyEMb  24
 /* Suppress lock checks */
 #define disLkType 0x80000000
 #define disLktypeb 0
@@ -89,7 +104,16 @@ typedef struct diagWork {			/* Diagnostic work area */
 
 } diagWork;
 
+typedef struct scomcomm {
+	uint16_t	scomcpu;	/* CPU number */
+	uint16_t	scomfunc;	/* 0 = read; 1 = write */
+	uint32_t	scomreg;	/* SCOM register */
+	uint64_t	scomstat;	/* returned status */
+	uint64_t	scomdata;	/* input for write,  output for read */
+} scomcomm;
+
 extern diagWork dgWork;
+extern int diagTrap(struct savearea *, unsigned int);
 
 
 #endif /* _DIAGNOSTICS_H_ */
diff --git a/osfmk/ppc/Emulate.s b/osfmk/ppc/Emulate.s
index 419b24747..f7037e6af 100644
--- a/osfmk/ppc/Emulate.s
+++ b/osfmk/ppc/Emulate.s
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -36,7 +39,6 @@
 #include <mach/machine/vm_param.h>
 #include <assym.s>
 
-#define kernAccess 31
 #define traceInst 30
 #define dssAllDone 29
 
@@ -64,13 +66,13 @@
 
 LEXT(Emulate)
 
+			bf--	pf64Bitb,emn64					; Skip if not 64-bit
+			b		EXT(Emulate64)					; Jump to the 64-bit code...
 			
-			mfsprg	r31,0							; Get the per_proc
-			lis		r30,hi16(EXT(dgWork))			; Get the high half of diagnostic work area
-			lwz		r12,savesrr1(r13)				; Get the exception info
-			ori		r30,r30,lo16(EXT(dgWork))		; And the low half
+emn64:		mfsprg	r31,0							; Get the per_proc
+			lwz		r12,savesrr1+4(r13)				; Get the exception info
 			rlwinm.	r0,r12,0,SRR1_PRG_ILL_INS_BIT,SRR1_PRG_ILL_INS_BIT	; Emulation candidate?
-			lwz		r30,dgFlags(r30)				; Get the flags
+			lwz		r30,dgFlags(0)					; Get the flags
 			beq+	eExit							; Nope, do not try to emulate...
 
 			rlwinm.	r0,r30,0,enaDiagEMb,enaDiagEMb	; Do we want to try to emulate something?
@@ -111,9 +113,9 @@ eNoVect:	bl		eIFetch							; Get the instruction image
 			cror	cr1_eq,cr1_eq,cr0_eq			; Remember
 			bne		cr1_eq,eNotIndex				; Go check non-index forms...
 
-			rlwinm.	r21,r10,18,25,29				; Extract index to rA to build EA
-			rlwinm	r22,r10,23,25,29				; Extract index to rB
-			addi	r24,r13,saver0					; Point to the start of registers
+			rlwinm.	r21,r10,19,24,28				; Extract index to rA to build EA
+			rlwinm	r22,r10,24,24,28				; Extract index to rB
+			addi	r24,r13,saver0+4				; Point to the start of registers
 			li		r19,0							; Assume 0 base
 			beq		eZeroBase						; Yes...
 			lwzx	r19,r24,r21						; Get the base register value
@@ -128,15 +130,15 @@ eNotIndex:	cmplwi	r0,725							; stswi?
 			cror	cr1_eq,cr1_eq,cr0_eq			; Remember
 			bne		cr1,eExit						; Not one we handle...
 	
-			rlwinm.	r21,r10,18,25,29				; Extract index to rA to build EA
-			addi	r24,r13,saver0					; Point to the start of registers
+			rlwinm.	r21,r10,19,24,28				; Extract index to rA to build EA
+			addi	r24,r13,saver0+4				; Point to the start of registers
 			li		r22,0							; Assume 0 base
 			beq		eFinishUp						; Yes, it is...
 			lwzx	r22,r24,r21						; Get the base register value
 			
 eFinishUp:	stw		r20,savedsisr(r13)				; Set the DSISR
 			li		r11,T_ALIGNMENT					; Get the exception code
-			stw		r22,savedar(r13)				; Save the DAR
+			stw		r22,savedar+4(r13)				; Save the DAR
 			stw		r11,saveexception(r13)			; Set the exception code
 			b		EXT(AlignAssist)				; Go emulate the handler...
 
@@ -153,20 +155,15 @@ eExit:		b		EXT(EmulExit)					; Just return for now...
 
 			.align	5
 
-eIFetch:	lwz		r23,savesrr1(r13)				; Get old MSR
+eIFetch:	lwz		r23,savesrr1+4(r13)				; Get old MSR
 			mflr	r28								; Save return
 
 			rlwinm.	r22,r23,0,MSR_PR_BIT,MSR_PR_BIT	; Within kernel?
 
 			mfmsr	r30								; Save the MSR for now
-			lwz		r23,savesrr0(r13)				; Get instruction address
-			crmove	kernAccess,cr0_eq				; Remember if fault was in kernel
-			li		r25,4							; Set access length
-			or		r22,r22,r30						; Add PR to access MSR
+			lwz		r23,savesrr0+4(r13)				; Get instruction address
 			
-			bfl+	kernAccess,aaSetSegs			; Go set SRs if we are in user and need to
-
-			ori		r22,r22,lo16(MASK(MSR_DR)|MASK(MSR_RI))		; Set RI onto access MSR
+			ori		r22,r30,lo16(MASK(MSR_DR)|MASK(MSR_RI))		; Set RI and DR onto access MSR
 
 			crset	cr0_eq							; Set this to see if we failed
 			mtmsr	r22								; Flip DR, RI, and maybe PR on
@@ -174,15 +171,10 @@ eIFetch:	lwz		r23,savesrr1(r13)				; Get old MSR
 			
 			lwz		r10,0(r23)						; Fetch the instruction
 			
-			crmove	28,cr0_eq						; Remember if we failed
-			li		r0,loadMSR						; Set the magic "get back to supervisor" SC
-			mr		r3,r30							; Get MSR to load
-			sc										; Get back to supervisor state
-			
-			bfl+	kernAccess,aaUnSetSegs			; Go set SRs if we are in user and need to
+			mtmsr	r30								; Trans and RI off
+			isync
 			
 			mtlr	r28								; Restore the LR
-			crmove	cr0_eq,28						; Set CR0_EQ if the fetch succeeded
 			blr										; Return with instruction image in R10
 
 
@@ -191,14 +183,14 @@ eIFetch:	lwz		r23,savesrr1(r13)				; Get old MSR
 ;
 
 eRedriveAsISI:
-			lwz		r6,savesrr1(r13)				; Get the srr1 value
+			lwz		r6,savesrr1+4(r13)				; Get the srr1 value
 			lwz		r4,SAVflags(r13)				; Pick up the flags
 			li		r11,T_INSTRUCTION_ACCESS		; Set failing instruction fetch code
 			rlwimi	r6,r1,0,0,4						; Move the DSISR bits to the SRR1
 			oris	r4,r4,hi16(SAVredrive)			; Set the redrive bit
 			stw		r11,saveexception(r13)			; Set the replacement code
 			stw		r4,SAVflags(r13)				; Set redrive request
-			stw		r6,savesrr1(r13)				; Set the srr1 value
+			stw		r6,savesrr1+4(r13)				; Set the srr1 value
 			b		EXT(EmulExit)					; Bail out to handle ISI...
 
 
@@ -225,55 +217,40 @@ eRedriveAsISI:
 			.globl	EXT(AlignAssist)
 
 LEXT(AlignAssist)
-
-#if 0
-			b		EXT(EmulExit)					; Just return for now...
-#endif
-
-
+			bf--	pf64Bitb,aan64					; Skip if not 64-bit
+			b		EXT(AlignAssist64)				; Jump to the 64-bit code...
+			
+aan64:		lwz		r20,savedsisr(r13)				; Get the DSISR
 			mfsprg	r31,0							; Get the per_proc
-			lwz		r20,savedsisr(r13)				; Get the DSISR
+			mtcrf	0x10,r20						; Put instruction ID in CR for later
 			lwz		r21,spcFlags(r31)				; Grab the special flags
-			mtcrf	0x1C,r20						; Put instruction ID in CR for later
+			mtcrf	0x08,r20						; Put instruction ID in CR for later
 			rlwinm.	r0,r21,0,runningVMbit,runningVMbit	; Are we running a VM?
-			lwz		r22,savesrr1(r13)				; Get the SRR1
+			mtcrf	0x04,r20						; Put instruction ID in CR for later
+			lwz		r22,savesrr1+4(r13)				; Get the SRR1
 			bne-	aaPassAlong						; We are in a VM, no emulation for alignment exceptions...
-			rlwinm.	r0,r21,0,trapUnalignbit,trapUnalignbit	; Should we trap alignment exceptions?
+			lwz		r19,dgFlags(0)					; Get the diagnostics flags
 			crxor	iFloat,iOptype1,iOptype2		; Set this to 0 if both bits are either 0 or 1
 			mr		r26,r20							; Save the DSISR
-			bne-	aaPassAlong						; No alignment exceptions allowed...
 			rlwinm.	r0,r22,0,MSR_SE_BIT,MSR_SE_BIT	; Were we single stepping?
-			lwz		r23,savedar(r13)				; Pick up the address that we want to access
+			lwz		r23,savedar+4(r13)				; Pick up the address that we want to access
 			crnot	traceInst,cr0_eq				; Remember if trace is on
-			rlwinm.	r0,r21,0,notifyUnalignbit,notifyUnalignbit	; Should we notify that an alignment exception happened?
-			mfsprg	r28,2							; Get the processor features
-			crnot	iNotify,cr0_eq					; Remember to tell someone we did this				
-			rlwinm.	r22,r22,0,MSR_PR_BIT,MSR_PR_BIT	; Did we take the exception in the kernel and isolate PR?
+			
+			rlwinm.	r0,r19,0,enaNotifyEMb,enaNotifyEMb	; Should we notify that an alignment exception happened?
 			mfmsr	r30								; Save the MSR for now
+			crnot	iNotify,cr0_eq					; Remember to tell someone we did this				
 			li		r29,emfp0						; Point to work area
 			crxor	iFloat,iFloat,iOptype3			; Set true if we have a floating point instruction
-			or		r22,r22,r30						; Add PR to access MSR
 			dcbz	r29,r31							; Clear and allocate a cache line for us to work in
-			rlwinm	r24,r20,2,25,29					; Get displacement to register to update if update form
+			rlwinm	r24,r20,3,24,28					; Get displacement to register to update if update form
 			rlwimi	r20,r20,24,28,28				; Move load/store indication to the bottom of index
-			ori		r22,r22,lo16(MASK(MSR_DR)|MASK(MSR_RI))		; Set RI onto access MSR
-			crmove	kernAccess,cr0_eq				; Remember if fault was in kernel
-			rlwinm.	r28,r28,0,pfAltivecb,pfAltivecb	; Do we have Altivec on this machine?
+			ori		r22,r30,lo16(MASK(MSR_DR)|MASK(MSR_RI))		; Set RI onto access MSR
 			rlwimi	r20,r20,26,27,27				; Move single/double indication to just above the bottom
-			beq		aaNoVect						; Nope, no Altivec...
-			
-			dssall									; We need to kill streams because we are going to flip to problem state
-			sync
-			
-aaNoVect:	lis		r29,hi16(aaFPopTable)			; High part of FP branch table
+			lis		r29,hi16(EXT(aaFPopTable))		; High part of FP branch table
 			bf-		iFloat,aaNotFloat				; This is not a floating point instruction...
-			li		r25,8							; Assume 8-byte access for now
-			ori		r29,r29,lo16(aaFPopTable)		; Low part of FP branch table
-			bt		iDouble,aaFPis8					; So far, we think we are a double...
-			li		r25,4							; Set word access
+			ori		r29,r29,lo16(EXT(aaFPopTable))	; Low part of FP branch table
 			
-aaFPis8:	rlwimi	r29,r20,0,22,28					; Index into table based upon register||iDouble||iStore
-			ori		r0,r30,lo16(MASK(MSR_FP))		; Turn on floating point
+			rlwimi	r29,r20,0,22,28					; Index into table based upon register||iDouble||iStore
 			mtctr	r29								; Get set to call the function	
 			bt		iStore,aaFPstore				; This is an FP store...
 		
@@ -281,11 +258,8 @@ aaFPis8:	rlwimi	r29,r20,0,22,28					; Index into table based upon register||iDou
 ;			Here we handle floating point loads
 ;			
 
-aaFPload:	bfl+	kernAccess,aaSetSegs			; Go set SRs if we are in user and need to
-
-			crset	cr0_eq							; Set this to see if we failed
-			ori		r3,r30,lo16(MASK(MSR_FP))		; We will need FP on in a bit, so turn on when we ditch problem state
-			mtmsr	r22								; Flip DR, RI, and maybe PR on
+aaFPload:	crset	cr0_eq							; Set this to see if we failed
+			mtmsr	r22								; Flip DR, RI
 			isync
 			
 			lwz		r10,0(r23)						; Get the first word
@@ -294,8 +268,9 @@ aaFPload:	bfl+	kernAccess,aaSetSegs			; Go set SRs if we are in user and need to
 			lwz		r11,4(r23)						; Get the second half
 			
 aaLdNotDbl:	mr		r4,r0							; Save the DAR if we failed the access
-			li		r0,loadMSR						; Set the magic "get back to supervisor" SC
-			sc										; Get back to supervisor state and turn on FP
+			
+			mtmsr	r30								; Turn off translation again
+			isync
 			
 			bf-		cr0_eq,aaRedriveAsDSI			; Go redrive this as a DSI...	
 			
@@ -312,24 +287,17 @@ aaLdNotDbl:	mr		r4,r0							; Save the DAR if we failed the access
 
 			.align	5
 
-aaFPstore:	mtmsr	r0								; We need floating point on for the first phase
-			isync	
-			
-			bctrl									; Go save the source FP register
+aaFPstore:	bctrl									; Go save the source FP register
 			
 			lwz		r10,emfp0(r31)					; Get first word
 			crandc	iDouble,iDouble,iOptype4		; Change to 4-byte access if stfiwx
 			lwz		r11,emfp0+4(r31)				; and the second
 			bf+		iOptype4,aaNotstfiwx			; This is not a stfiwx...
-			li		r25,4							; Set this is a word
 			mr		r10,r11							; The stfiwx wants to store the second half
 
 aaNotstfiwx:
-			bfl+	kernAccess,aaSetSegs			; Go set SRs if we are in user and need to
-			
 			crset	cr0_eq							; Set this to see if we failed
-			mr		r3,r30							; Set the normal MSR
-			mtmsr	r22								; Flip DR, RI, and maybe PR on
+			mtmsr	r22								; Flip DR, RI
 			isync
 			
 			stw		r10,0(r23)						; Save the first word
@@ -338,31 +306,26 @@ aaNotstfiwx:
 			stw		r11,4(r23)						; Save the second half
 			
 aaStNotDbl:	mr		r4,r0							; Save the DAR if we failed the access
-			li		r0,loadMSR						; Set the magic "get back to supervisor" SC
-			sc										; Get back to supervisor state
-			
+			mtmsr	r30								; Turn off
+			isync
 			
 			bf-		cr0_eq,aaRedriveAsDSI			; Go redrive this as a DSI...
-			
-			
 
 ;
 ;			Common exit routines
 ;
 
-aaComExit:	lwz		r10,savesrr0(r13)				; Get the failing instruction address
+aaComExit:	lwz		r10,savesrr0+4(r13)				; Get the failing instruction address
 			add		r24,r24,r13						; Offset to update register
 			li		r11,T_IN_VAIN					; Assume we are all done
 			addi	r10,r10,4						; Step to the next instruction
 			bf		iUpdate,aaComExNU				; Skip if not an update form...
-			stw		r23,saver0(r24)					; Update the target
+			stw		r23,saver0+4(r24)				; Update the target
 			
 aaComExNU:	lwz		r9,SAVflags(r13)				; Get the flags
-			stw		r10,savesrr0(r13)				; Set new PC
+			stw		r10,savesrr0+4(r13)				; Set new PC
 			bt-		traceInst,aaComExitrd			; We are tracing, go emulate trace...
 			bf+		iNotify,aaComExGo				; Nothing special here, go...
-
-			bfl+	kernAccess,aaUnSetSegs			; Go set SRs if we are in user and need to
 	
 			li		r11,T_ALIGNMENT					; Set the we just did an alignment exception....
 			
@@ -393,7 +356,7 @@ aaNotFloat:
 			ori		r19,r19,lo16(aaEmTable)			; Low part of table address
 			blt-	aaPassAlong						; We do not handle any of these (lwarx, stwcx., eciwx, ecowx)...
 			add		r19,r19,r3						; Point to emulation routine
-			rlwinm	r18,r26,29,25,29				; Get the target/source register displacement
+			rlwinm	r18,r26,30,24,28				; Get the target/source register displacement
 
 			mtctr	r19								; Set the routine address
 			
@@ -435,14 +398,12 @@ aaEmTable:
 			.align	5
 						
 aaLmwStmw:
-			subfic	r25,r18,32*4					; Calculate the length of the transfer
+			rlwinm	r17,r18,31,1,29					; Convert doublword based index to words
 			li		r28,0							; Set no extra bytes to move (used for string instructions)
-			mr		r17,r25							; Save the word transfer length here
+			subfic	r17,r17,32*4					; Calculate the length of the transfer
 
-aaLSComm:	addi	r19,r13,saver0					; Offset to registers in savearea
+aaLSComm:	addi	r19,r13,saver0+4				; Offset to registers in savearea
 			mr		r16,r23							; Make a hunk pointer
-
-			bfl+	kernAccess,aaSetSegs			; Go set SRs if we are in user and need to
 			
 			bt		iUpdate,aaStmw					; This is the stmw...
 			
@@ -455,7 +416,7 @@ aaLmwNxt:	cmplwi	cr1,r17,8*4						; Is there enough to move 8?
 			subi	r17,r17,8*4						; Back off for another hunk
 			
 			crset	cr0_eq							; Set this to see if we failed
-			mtmsr	r22								; Flip DR, RI, and maybe PR on
+			mtmsr	r22								; Flip DR, RI
 			isync
 		
 			lwz		r2,0(r16)						; Load word 0
@@ -475,38 +436,37 @@ aaLmwNxt:	cmplwi	cr1,r17,8*4						; Is there enough to move 8?
 			lwz		r9,28(r16)						; Load word 7
 		
 aaLmwB1:	mr		r4,r0							; Remember DAR, jus in case we failed the access
-			mr		r3,r30							; Set the normal MSR
-			li		r0,loadMSR						; Set the magic "get back to supervisor" SC
-			sc										; Get back to supervisor state
+			mtmsr	r30								; Turn off DR, RI
+			isync
 
 			bf-		cr0_eq,aaRedriveAsDSI			; We failed, go redrive this as a DSI...
 
 			addi	r16,r16,8*4						; Point up to next input aread
 		
 			stwx	r2,r19,r18						; Store register
-			addi	r18,r18,4						; Next register
-			rlwinm	r18,r18,0,25,29					; Wrap back to 0 if needed
+			addi	r18,r18,8						; Next register
+			rlwinm	r18,r18,0,24,28					; Wrap back to 0 if needed
 			stwx	r15,r19,r18						; Store register
-			addi	r18,r18,4						; Next register
-			rlwinm	r18,r18,0,25,29					; Wrap back to 0 if needed
+			addi	r18,r18,8						; Next register
+			rlwinm	r18,r18,0,24,28					; Wrap back to 0 if needed
 			stwx	r14,r19,r18						; Store register
-			addi	r18,r18,4						; Next register
-			rlwinm	r18,r18,0,25,29					; Wrap back to 0 if needed
+			addi	r18,r18,8						; Next register
+			rlwinm	r18,r18,0,24,28					; Wrap back to 0 if needed
 			stwx	r5,r19,r18						; Store register
-			addi	r18,r18,4						; Next register
-			rlwinm	r18,r18,0,25,29					; Wrap back to 0 if needed
+			addi	r18,r18,8						; Next register
+			rlwinm	r18,r18,0,24,28					; Wrap back to 0 if needed
 			stwx	r6,r19,r18						; Store register
-			addi	r18,r18,4						; Next register
-			rlwinm	r18,r18,0,25,29					; Wrap back to 0 if needed
+			addi	r18,r18,8						; Next register
+			rlwinm	r18,r18,0,24,28					; Wrap back to 0 if needed
 			stwx	r7,r19,r18						; Store register
-			addi	r18,r18,4						; Next register
-			rlwinm	r18,r18,0,25,29					; Wrap back to 0 if needed
+			addi	r18,r18,8						; Next register
+			rlwinm	r18,r18,0,24,28					; Wrap back to 0 if needed
 			stwx	r8,r19,r18						; Store register
-			addi	r18,r18,4						; Next register
-			rlwinm	r18,r18,0,25,29					; Wrap back to 0 if needed
+			addi	r18,r18,8						; Next register
+			rlwinm	r18,r18,0,24,28					; Wrap back to 0 if needed
 			stwx	r9,r19,r18						; Store register
-			addi	r18,r18,4						; Next register
-			rlwinm	r18,r18,0,25,29					; Wrap back to 0 if needed
+			addi	r18,r18,8						; Next register
+			rlwinm	r18,r18,0,24,28					; Wrap back to 0 if needed
 
 			b		aaLmwNxt						; Do the next hunk...
 
@@ -530,26 +490,25 @@ aaLmwNxtH:	cmplwi	cr1,r17,4*4						; Do we have 4 left?
 			lwz		r5,12(r16)						; Load word 3
 		
 aaLmwB2:	mr		r4,r0							; Remember DAR, jus in case we failed the access
-			mr		r3,r30							; Set the normal MSR
-			li		r0,loadMSR						; Set the magic "get back to supervisor" SC
-			sc										; Get back to supervisor state
+			mtmsr	r30								; Turn off DR, RI
+			isync
 
 			bf-		cr0_eq,aaRedriveAsDSI			; We failed, go redrive this as a DSI...
 		
 			addi	r16,r16,4*4						; Point up to next input aread
 			
 			stwx	r2,r19,r18						; Store register
-			addi	r18,r18,4						; Next register
-			rlwinm	r18,r18,0,25,29					; Wrap back to 0 if needed
+			addi	r18,r18,8						; Next register
+			rlwinm	r18,r18,0,24,28					; Wrap back to 0 if needed
 			stwx	r15,r19,r18						; Store register
-			addi	r18,r18,4						; Next register
-			rlwinm	r18,r18,0,25,29					; Wrap back to 0 if needed
+			addi	r18,r18,8						; Next register
+			rlwinm	r18,r18,0,24,28					; Wrap back to 0 if needed
 			stwx	r14,r19,r18						; Store register
-			addi	r18,r18,4						; Next register
-			rlwinm	r18,r18,0,25,29					; Wrap back to 0 if needed
+			addi	r18,r18,8						; Next register
+			rlwinm	r18,r18,0,24,28					; Wrap back to 0 if needed
 			stwx	r5,r19,r18						; Store register
-			addi	r18,r18,4						; Next register
-			rlwinm	r18,r18,0,25,29					; Wrap back to 0 if needed
+			addi	r18,r18,8						; Next register
+			rlwinm	r18,r18,0,24,28					; Wrap back to 0 if needed
 
 aaLmwL4:	or.		r5,r17,r28						; Do we have anything left?
 			cmplwi	cr1,r17,(2*4)					; Do we have one, two, or three full words left?
@@ -599,26 +558,27 @@ aaLmwDn:	rlwinm	r5,r5,24,0,7					; Move first byte to top
 			cmplwi	cr1,r17,(2*4)					; Do we have one, two, or three full words left?
 			mr		r3,r30							; Set the normal MSR
 			rlwimi	r5,r9,8,8,23					; Move bytes 1 and 2 after 0
-			li		r0,loadMSR						; Set the magic "get back to supervisor" SC
-			sc										; Get back to supervisor state
+
+			mtmsr	r30								; Turn off DR, RI
+			isync
 
 			bf-		cr0_eq,aaRedriveAsDSI			; We failed, go redrive this as a DSI...
 
 			beq-	cr2,aaLmwCb						; No full words, copy bytes...
 
 			stwx	r2,r19,r18						; Store register
-			addi	r18,r18,4						; Next register
-			rlwinm	r18,r18,0,25,29					; Wrap back to 0 if needed
+			addi	r18,r18,8						; Next register
+			rlwinm	r18,r18,0,24,28					; Wrap back to 0 if needed
 			blt		cr1,aaLmwCb						; We only had one, we are done...
 			
 			stwx	r15,r19,r18						; Store register
-			addi	r18,r18,4						; Next register
-			rlwinm	r18,r18,0,25,29					; Wrap back to 0 if needed
+			addi	r18,r18,8						; Next register
+			rlwinm	r18,r18,0,24,28					; Wrap back to 0 if needed
 			beq		cr1,aaLmwCb						; We had two, we are done...
 
 			stwx	r14,r19,r18						; Store register
-			addi	r18,r18,4						; Next register
-			rlwinm	r18,r18,0,25,29					; Wrap back to 0 if needed
+			addi	r18,r18,8						; Next register
+			rlwinm	r18,r18,0,24,28					; Wrap back to 0 if needed
 
 aaLmwCb:	mr.		r28,r28							; Any trailing bytes to do?
 			beq+	aaComExit						; Nope, leave...
@@ -641,29 +601,29 @@ aaStmwNxt:	cmplwi	cr1,r17,8*4						; Is there enough to move 8?
 			subi	r17,r17,8*4						; Back off for another hunk
 		
 			lwzx	r2,r19,r18						; Store register
-			addi	r18,r18,4						; Next register
-			rlwinm	r18,r18,0,25,29					; Wrap back to 0 if needed
+			addi	r18,r18,8						; Next register
+			rlwinm	r18,r18,0,24,28					; Wrap back to 0 if needed
 			lwzx	r15,r19,r18						; Store register
-			addi	r18,r18,4						; Next register
-			rlwinm	r18,r18,0,25,29					; Wrap back to 0 if needed
+			addi	r18,r18,8						; Next register
+			rlwinm	r18,r18,0,24,28					; Wrap back to 0 if needed
 			lwzx	r14,r19,r18						; Store register
-			addi	r18,r18,4						; Next register
-			rlwinm	r18,r18,0,25,29					; Wrap back to 0 if needed
+			addi	r18,r18,8						; Next register
+			rlwinm	r18,r18,0,24,28					; Wrap back to 0 if needed
 			lwzx	r5,r19,r18						; Store register
-			addi	r18,r18,4						; Next register
-			rlwinm	r18,r18,0,25,29					; Wrap back to 0 if needed
+			addi	r18,r18,8						; Next register
+			rlwinm	r18,r18,0,24,28					; Wrap back to 0 if needed
 			lwzx	r6,r19,r18						; Store register
-			addi	r18,r18,4						; Next register
-			rlwinm	r18,r18,0,25,29					; Wrap back to 0 if needed
+			addi	r18,r18,8						; Next register
+			rlwinm	r18,r18,0,24,28					; Wrap back to 0 if needed
 			lwzx	r7,r19,r18						; Store register
-			addi	r18,r18,4						; Next register
-			rlwinm	r18,r18,0,25,29					; Wrap back to 0 if needed
+			addi	r18,r18,8						; Next register
+			rlwinm	r18,r18,0,24,28					; Wrap back to 0 if needed
 			lwzx	r8,r19,r18						; Store register
-			addi	r18,r18,4						; Next register
-			rlwinm	r18,r18,0,25,29					; Wrap back to 0 if needed
+			addi	r18,r18,8						; Next register
+			rlwinm	r18,r18,0,24,28					; Wrap back to 0 if needed
 			lwzx	r9,r19,r18						; Store register
-			addi	r18,r18,4						; Next register
-			rlwinm	r18,r18,0,25,29					; Wrap back to 0 if needed
+			addi	r18,r18,8						; Next register
+			rlwinm	r18,r18,0,24,28					; Wrap back to 0 if needed
 			
 			crset	cr0_eq							; Set this to see if we failed
 			mtmsr	r22								; Flip DR, RI, and maybe PR on
@@ -689,9 +649,8 @@ aaStmwNxt:	cmplwi	cr1,r17,8*4						; Is there enough to move 8?
 		
 		
 aaStmwB1:	mr		r4,r0							; Remember DAR, jus in case we failed the access
-			mr		r3,r30							; Set the normal MSR
-			li		r0,loadMSR						; Set the magic "get back to supervisor" SC
-			sc										; Get back to supervisor state
+			mtmsr	r30								; Normal MSR
+			isync
 
 			bt-		cr0_eq,aaStmwNxt				; We have more to do and no failed access...
 			b		aaRedriveAsDSI					; We failed, go redrive this as a DSI...
@@ -703,20 +662,20 @@ aaStmwNxtH:	cmplwi	cr1,r17,(4*4)					; Do we have at least 4 left?
 			subi	r17,r17,4*4						; Set count properly
 
 			lwzx	r2,r19,r18						; Store register
-			addi	r18,r18,4						; Next register
-			rlwinm	r18,r18,0,25,29					; Wrap back to 0 if needed
+			addi	r18,r18,8						; Next register
+			rlwinm	r18,r18,0,24,28					; Wrap back to 0 if needed
 			lwzx	r15,r19,r18						; Store register
-			addi	r18,r18,4						; Next register
-			rlwinm	r18,r18,0,25,29					; Wrap back to 0 if needed
+			addi	r18,r18,8						; Next register
+			rlwinm	r18,r18,0,24,28					; Wrap back to 0 if needed
 			lwzx	r14,r19,r18						; Store register
-			addi	r18,r18,4						; Next register
-			rlwinm	r18,r18,0,25,29					; Wrap back to 0 if needed
+			addi	r18,r18,8						; Next register
+			rlwinm	r18,r18,0,24,28					; Wrap back to 0 if needed
 			lwzx	r5,r19,r18						; Store register
-			addi	r18,r18,4						; Next register
-			rlwinm	r18,r18,0,25,29					; Wrap back to 0 if needed
+			addi	r18,r18,8						; Next register
+			rlwinm	r18,r18,0,24,28					; Wrap back to 0 if needed
 			
 			crset	cr0_eq							; Set this to see if we failed
-			mtmsr	r22								; Flip DR, RI, and maybe PR on
+			mtmsr	r22								; Flip DR, RI
 			isync
 		
 			stw		r2,0(r16)						; Store word 0
@@ -730,9 +689,8 @@ aaStmwNxtH:	cmplwi	cr1,r17,(4*4)					; Do we have at least 4 left?
 			addi	r16,r16,4*4						; Point up to next input aread
 		
 aaStmwB2:	mr		r4,r0							; Remember DAR, jus in case we failed the access
-			mr		r3,r30							; Set the normal MSR
-			li		r0,loadMSR						; Set the magic "get back to supervisor" SC
-			sc										; Get back to supervisor state
+			mtmsr	r30								; Normal MSR
+			isync
 
 			bf-		cr0_eq,aaRedriveAsDSI			; We failed, go redrive this as a DSI...
 
@@ -744,18 +702,18 @@ aaStmwL4:	or.		r5,r17,r28						; Do we have anything left to do?
 			beq-	cr2,aaStmwBy1					; No full words, check out bytes
 
 			lwzx	r2,r19,r18						; Store register
-			addi	r18,r18,4						; Next register
-			rlwinm	r18,r18,0,25,29					; Wrap back to 0 if needed
+			addi	r18,r18,8						; Next register
+			rlwinm	r18,r18,0,24,28					; Wrap back to 0 if needed
 			blt		cr1,aaStmwBy1					; We only had one, go save it...
 			
 			lwzx	r15,r19,r18						; Store register
-			addi	r18,r18,4						; Next register
-			rlwinm	r18,r18,0,25,29					; Wrap back to 0 if needed
+			addi	r18,r18,8						; Next register
+			rlwinm	r18,r18,0,24,28					; Wrap back to 0 if needed
 			beq		cr1,aaStmwBy1					; We had two, go save it...
 			
 			lwzx	r14,r19,r18						; Store register
-			addi	r18,r18,4						; Next register
-			rlwinm	r18,r18,0,25,29					; Wrap back to 0 if needed
+			addi	r18,r18,8						; Next register
+			rlwinm	r18,r18,0,24,28					; Wrap back to 0 if needed
 			
 aaStmwBy1:	mr.		r28,r28							; Do we have any trailing bytes?
 			beq+	aaStmwSt						; Nope...
@@ -763,22 +721,23 @@ aaStmwBy1:	mr.		r28,r28							; Do we have any trailing bytes?
 			lwzx	r5,r19,r18						; Yes, pick up one extra register
 			
 aaStmwSt:	crset	cr0_eq							; Set this to see if we failed
-			mtmsr	r22								; Flip DR, RI, and maybe PR on
+			mtmsr	r22								; Flip DR, RI
 			isync
 
 			beq-	cr2,aaStmwBy2					; No words, check trailing bytes...					
 
 			stw		r2,0(r16)						; Save first word
-			bf-		cr0_eq,aaStmwDn					; Read failed, escape...
+			bf-		cr0_eq,aaStmwDn					; Store failed, escape...
 			addi	r16,r16,4						; Bump sink
 			blt		cr1,aaStmwBy2					; We only had one, we are done...
 
 			stw		r15,0(r16)						; Save second word
-			bf-		cr0_eq,aaStmwDn					; Read failed, escape...
+			bf-		cr0_eq,aaStmwDn					; Store failed, escape...
 			addi	r16,r16,4						; Bump sink
 			beq		cr1,aaStmwBy2					; We had two, we are done...
 
 			stw		r14,0(r16)						; Save third word
+			bf-		cr0_eq,aaStmwDn					; Store failed, escape...
 			addi	r16,r16,4						; Bump sink
 				
 aaStmwBy2:	rlwinm	r2,r5,8,24,31					; Get byte 0
@@ -801,9 +760,8 @@ aaStmwBy2:	rlwinm	r2,r5,8,24,31					; Get byte 0
 			stb		r14,2(r16)						; Save third byte
 
 aaStmwDn:	mr		r4,r0							; Remember DAR, jus in case we failed the access
-			mr		r3,r30							; Set the normal MSR
-			li		r0,loadMSR						; Set the magic "get back to supervisor" SC
-			sc										; Get back to supervisor state
+			mtmsr	r30								; Normal MSR
+			isync
 
 			bf-		cr0_eq,aaRedriveAsDSI			; We failed, go redrive this as a DSI...
 
@@ -816,7 +774,7 @@ aaStmwDn:	mr		r4,r0							; Remember DAR, jus in case we failed the access
 
 			.align	5
 			
-aaLswx:		lwz		r17,savexer(r13)				; Pick up the XER
+aaLswx:		lwz		r17,savexer+4(r13)				; Pick up the XER
 			crclr	iUpdate							; Make sure we think this the load form
 			rlwinm.	r25,r17,0,25,31					; Get the number of bytes to load
 			rlwinm	r28,r17,0,30,31					; Get the number of bytes past an even word
@@ -850,7 +808,7 @@ aaLswi:		mr		r9,r23							; Save the DAR
 
 			.align	5
 
-aaStswx:	lwz		r17,savexer(r13)				; Pick up the XER
+aaStswx:	lwz		r17,savexer+4(r13)				; Pick up the XER
 			crclr	iUpdate							; Make sure this is clear in case we have 0 length
 			rlwinm.	r25,r17,0,25,31					; Get the number of bytes to load
 			rlwinm	r28,r17,0,30,31					; Get the number of bytes past an even word
@@ -888,28 +846,24 @@ aaStswi:	mr		r9,r23							; Save the DAR
 
 aaLwbrx:
 			add		r18,r18,r13						; Index to source register
-			li		r25,4							; Set the length
-
-			bfl+	kernAccess,aaSetSegs			; Go set SRs if we are in user and need to
 
 			crset	cr0_eq							; Set this to see if we failed
-			mr		r3,r30							; Set the normal MSR
 			mtmsr	r22								; Flip DR, RI, and maybe PR on
 			isync
 		
 			lwz		r11,0(r23)						; Load the word
 		
 			mr		r4,r0							; Save the DAR if we failed the access
-			li		r0,loadMSR						; Set the magic "get back to supervisor" SC
-			sc										; Get back to supervisor state
-
+			mtmsr	r30								; Restore normal MSR
+			isync
+			
 			bf-		cr0_eq,aaRedriveAsDSI			; We failed, go redrive this as a DSI...
 			
 			rlwinm	r10,r11,8,0,31					; Get byte 0 to 3 and byte 2 to 1
 			rlwimi	r10,r11,24,16,23				; Move byte 1 to byte 2
 			rlwimi	r10,r11,24,0,7					; Move byte 3 to byte 0
 		
-			stw		r10,saver0(r18)					; Set the register
+			stw		r10,saver0+4(r18)				; Set the register
 
 			b		aaComExit						; All done, go exit...
 
@@ -923,26 +877,22 @@ aaLwbrx:
 
 aaStwbrx:
 			add		r18,r18,r13						; Index to source register
-			li		r25,4							; Set the length
-			lwz		r11,saver0(r18)					; Get the register to store
+			lwz		r11,saver0+4(r18)				; Get the register to store
 
 			rlwinm	r10,r11,8,0,31					; Get byte 0 to 3 and byte 2 to 1
 			rlwimi	r10,r11,24,16,23				; Move byte 1 to byte 2
 			rlwimi	r10,r11,24,0,7					; Move byte 3 to byte 0
 			
-			bfl+	kernAccess,aaSetSegs			; Go set SRs if we are in user and need to
-			
 			crset	cr0_eq							; Set this to see if we failed
-			mr		r3,r30							; Set the normal MSR
 			mtmsr	r22								; Flip DR, RI, and maybe PR on
 			isync
 		
 			stw		r10,0(r23)						; Store the reversed halfword
 		
 			mr		r4,r0							; Save the DAR if we failed the access
-			li		r0,loadMSR						; Set the magic "get back to supervisor" SC
-			sc										; Get back to supervisor state
-
+			mtmsr	r30								; Restore normal MSR
+			isync
+			
 			bt+		cr0_eq,aaComExit				; All done, go exit...
 			b		aaRedriveAsDSI					; We failed, go redrive this as a DSI...	
 
@@ -956,27 +906,23 @@ aaStwbrx:
 
 aaLhbrx:
 			add		r18,r18,r13						; Index to source register
-			li		r25,2							; Set the length
-
-			bfl+	kernAccess,aaSetSegs			; Go set SRs if we are in user and need to
 
 			crset	cr0_eq							; Set this to see if we failed
-			mr		r3,r30							; Set the normal MSR
 			mtmsr	r22								; Flip DR, RI, and maybe PR on
 			isync
 		
 			lhz		r11,0(r23)						; Load the halfword
 		
 			mr		r4,r0							; Save the DAR if we failed the access
-			li		r0,loadMSR						; Set the magic "get back to supervisor" SC
-			sc										; Get back to supervisor state
+			mtmsr	r30								; Restore normal MSR
+			isync
 
 			bf-		cr0_eq,aaRedriveAsDSI			; We failed, go redrive this as a DSI...
 			
 			rlwinm	r10,r11,8,16,23					; Rotate bottom byte up one and clear everything else
 			rlwimi	r10,r11,24,24,31				; Put old second from bottom into bottom
 		
-			stw		r10,saver0(r18)					; Set the register
+			stw		r10,saver0+4(r18)				; Set the register
 
 			b		aaComExit						; All done, go exit...
 
@@ -989,23 +935,19 @@ aaLhbrx:
 
 aaSthbrx:
 			add		r18,r18,r13						; Index to source register
-			li		r25,2							; Set the length
-			lwz		r10,saver0(r18)					; Get the register to store
+			lwz		r10,saver0+4(r18)				; Get the register to store
 			rlwinm	r10,r10,8,0,31					; Rotate bottom byte up one
 			rlwimi	r10,r10,16,24,31				; Put old second from bottom into bottom
 			
-			bfl+	kernAccess,aaSetSegs			; Go set SRs if we are in user and need to
-			
 			crset	cr0_eq							; Set this to see if we failed
-			mr		r3,r30							; Set the normal MSR
 			mtmsr	r22								; Flip DR, RI, and maybe PR on
 			isync
 		
 			sth		r10,0(r23)						; Store the reversed halfword
 		
 			mr		r4,r0							; Save the DAR if we failed the access
-			li		r0,loadMSR						; Set the magic "get back to supervisor" SC
-			sc										; Get back to supervisor state
+			mtmsr	r30								; Restore normal MSR
+			isync
 
 			bt+		cr0_eq,aaComExit				; All done, go exit...
 			b		aaRedriveAsDSI					; We failed, go redrive this as a DSI...	
@@ -1017,13 +959,9 @@ aaSthbrx:
 			.align	5
 
 aaDcbz:
-			li		r25,32							; Set the length
 			rlwinm	r23,r23,0,0,26					; Round back to a 32-byte boundary
 			
-			bfl+	kernAccess,aaSetSegs			; Go set SRs if we are in user and need to
-			
 			crset	cr0_eq							; Set this to see if we failed
-			mr		r3,r30							; Set the normal MSR
 			li		r0,0							; Clear this out
 			mtmsr	r22								; Flip DR, RI, and maybe PR on
 			isync
@@ -1045,8 +983,8 @@ aaDcbz:
 			stw		r0,28(r23)						; Clear word		
 			
 aaDcbzXit:	mr		r4,r0							; Save the DAR if we failed the access
-			li		r0,loadMSR						; Set the magic "get back to supervisor" SC
-			sc										; Get back to supervisor state
+			mtmsr	r30								; Restore normal MSR
+			isync
 
 			crclr	iUpdate							; Make sure we do not think this is an update form
 			
@@ -1058,10 +996,6 @@ aaDcbzXit:	mr		r4,r0							; Save the DAR if we failed the access
 ;			Unhandled alignment exception, pass it along
 ;
 
-aaPassAlongUnMap:
-			bfl+	kernAccess,aaUnSetSegs			; Go set SRs if we are in user and need to
-
-
 aaPassAlong:
 			b		EXT(EmulExit)					
 
@@ -1075,7 +1009,6 @@ aaPassAlong:
 			.align	5
 			
 aaComExitrd:
-			bfl+	kernAccess,aaUnSetSegs			; Go set SRs back if we need to because we are not going back to user yet
 			oris	r9,r9,hi16(SAVredrive)			; Set the redrive bit
 			li		r11,T_TRACE						; Set trace interrupt
 			rlwinm	r12,r12,0,16,31					; Clear top half of SRR1
@@ -1091,92 +1024,15 @@ aaComExitrd:
 aaRedriveAsDSI:
 			mr		r20,r1							; Save the DSISR
 			mr		r21,r4
-			bfl+	kernAccess,aaUnSetSegs			; Go set SRs back if we need to because we are not going back to user yet
 			lwz		r4,SAVflags(r13)				; Pick up the flags
 			li		r11,T_DATA_ACCESS				; Set failing data access code
 			oris	r4,r4,hi16(SAVredrive)			; Set the redrive bit
 			stw		r20,savedsisr(r13)				; Set the DSISR of failed access
-			stw		r21,savedar(r13)				; Set the address of the failed access
+			stw		r21,savedar+4(r13)				; Set the address of the failed access
 			stw		r11,saveexception(r13)			; Set the replacement code
 			stw		r4,SAVflags(r13)				; Set redrive request
 			b		EXT(EmulExit)					; Bail out to handle ISI...
 
-;
-;			Set segment registers for user access.  Do not call this if we are trying to get
-;			supervisor state memory.  We do not need this.
-;
-;			Performance-wise, we will usually be setting one SR here. Most memory will be
-;			allocated before the 1GB mark.  Since the kernel maps the first GB, the exception
-;			handler always sets the SRs before we get here.  Therefore, we will usually 
-;			have to remap it.
-;
-;			Also, we need to un-do these mapping ONLY if we take a non-standard 
-;			exit, e.g., emulate DSI, emulate trace exception, etc.  This is because
-;			translation will never be turned on until we return and at that point,
-;			normal exception exit code will restore the first 4 SRs if needed.
-;
-	
-			.align	5
-
-			.globl	EXT(aaSetSegsX)
-
-LEXT(aaSetSegsX)
-			
-aaSetSegs:	addi	r3,r25,-1						; Point at last accessed offset in range
-			lwz		r7,PP_USERPMAP(r31)				; Get the current user pmap
-			lis		r0,0x4000						; This is the address of the first segment outside of the kernel
-			rlwinm	r5,r23,6,26,29					; Get index into pmap table
-			add		r4,r23,r3						; Point to the last byte accessed
-			addi	r5,r5,PMAP_SEGS					; Point to the segment slot
-			cmplw	r23,r0							; See if first segment register needs to be reloaded
-			cmplw	cr2,r4,r0						; Do we need to set the second (if any) SR?
-			xor		r0,r4,r23						; See if we are in the same segment as first
-			bge		aaSetS1ok						; Nope, we are in a pure user range
-			
-			lwzx	r6,r5,r7						; Get the user address space SR value
-			mtsrin	r6,r23							; Load the corresponding SR register
-			
-aaSetS1ok:	rlwinm.	r0,r0,0,0,3						; Any change in segment?
-			bgelr-	cr2								; We are in user only space, we do not need to mess with SR
-			rlwinm	r5,r4,6,26,29					; Get index into pmap table
-			beqlr+									; No change in segment, we are done...
-
-			lwzx	r6,r5,r7						; Get the user address space SR value
-			mtsrin	r6,r4							; Load the corresponding SR register
-			blr										; Leave...
-
-;
-;			Unset segment registers for user access. Do not call unless we had a user access. 
-;
-	
-			.align	5
-			
-			.globl	EXT(aaUnSetSegsX)
-			
-LEXT(aaUnSetSegsX)
-			
-aaUnSetSegs:	
-			addi	r3,r25,-1						; Point at last accessed offset in range
-			lis		r0,0x4000						; This is the address of the first segment outside of the kernel
-			lis		r5,hi16(KERNEL_SEG_REG0_VALUE)	; Get the high half of the kernel SR0 value 
-			add		r4,r23,r3						; Point to the last byte accessed
-			cmplw	r23,r0							; See if first segment register needs to be reloaded
-			rlwimi	r5,r23,24,8,11					; Make the correct kernel segment
-			cmplw	cr2,r4,r0						; Do we need to set the second (if any) SR?
-			xor		r0,r4,r23						; See if we are in the same segment as first
-			bge		aaUnSetS1ok						; Nope, we are in a pure user range
-			
-			mtsrin	r5,r23							; Load the corresponding SR register
-			
-aaUnSetS1ok:	
-			rlwinm.	r0,r0,0,0,3						; Any change in segment?
-			bgelr	cr2								; We are in user only space, we do not need to mess with SR
-			rlwimi	r5,r4,24,8,11					; Make the correct kernel segment
-			beqlr+									; No change in segment, we are done...
-
-			mtsrin	r5,r4							; Load the corresponding SR register
-			blr										; Leave...
-
 
 
 ;
@@ -1189,8 +1045,9 @@ aaUnSetS1ok:
 ;
 
 			.align	10								; Make sure we are on a 1k boundary
+			.globl	EXT(aaFPopTable)
 			
-aaFPopTable:
+LEXT(aaFPopTable)
 			lfs		f0,emfp0(r31)					; Load single variant
 			blr
 
diff --git a/osfmk/ppc/Emulate64.s b/osfmk/ppc/Emulate64.s
new file mode 100644
index 000000000..fff72fefb
--- /dev/null
+++ b/osfmk/ppc/Emulate64.s
@@ -0,0 +1,945 @@
+/*
+ * Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ * 
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ * 
+ * @APPLE_LICENSE_HEADER_END@
+ */ 																							
+
+/* Emulate64.s
+ *
+ * Software emulation of instructions not handled in hw, on 64-bit machines.
+ */
+ 
+#include <sys/appleapiopts.h>
+#include <cpus.h>
+#include <ppc/asm.h>
+#include <ppc/proc_reg.h>
+#include <ppc/exception.h>
+#include <mach/machine/vm_param.h>
+#include <ppc/cpu_capabilities.h>
+#include <assym.s>
+
+// CR bit set if the instruction is an "update" form (LFDU, STWU, etc):
+#define	kUpdate	25
+
+// CR bit set if interrupt occured in trace mode (ie, MSR_SE_BIT):
+#define kTrace	8
+
+// CR bit set if notification on alignment interrupts is requested (notifyUnalignbit in spcFlags):
+#define	kNotify	9
+
+// CR bit distinguishes between alignment and program exceptions:
+#define	kAlignment	10
+
+
+
+// *************************************
+// * P R O G R A M   I N T E R R U P T *
+// *************************************
+//
+// These are floating pt exceptions, illegal instructions, privileged mode violations,
+// and traps.  All we're interested in at this low level is illegal instructions.
+// The ones we "emulate" are:
+//		DCBA,  which is not implemented in the IBM 970.  The emulation is to ignore it,
+//			   as it is just a hint.
+//		MCRXR, which is not implemented on the IBM 970, but is in the PPC ISA.
+//
+// Additionally, to facilitate debugging the alignment handler, we recognize a special
+// diagnostic mode that is used to simulate alignment exceptions.  When in this mode,
+// if the instruction has opcode==0 and the extended opcode is one of the X-form
+// instructions that can take an alignment interrupt, then we change the opcode to
+// 31 and pretend it got an alignment interrupt.  This exercises paths that
+// are hard to drive or perhaps never driven on this particular CPU.
+
+        .text
+        .globl	EXT(Emulate64)
+        .align	5
+LEXT(Emulate64)
+        crclr	kAlignment						// not an alignment exception
+        b		a64AlignAssistJoin				// join alignment handler
+        
+        
+// Return from alignment handler with all the regs loaded for opcode emulation.
+        
+a64HandleProgramInt:
+        rlwinm.	r0,r29,0,SRR1_PRG_ILL_INS_BIT,SRR1_PRG_ILL_INS_BIT	// illegal opcode?
+        beq		a64PassAlong					// No, must have been trap or priv violation etc
+        rlwinm	r3,r20,6,26,31					// right justify opcode field (bits 0-5)
+        rlwinm	r4,r20,31,22,31					// right justify extended opcode field (bits 21-30)
+        cmpwi	cr0,r3,31						// X-form?
+        cmpwi	cr1,r4,758						// DCBA?
+        cmpwi	cr4,r4,512						// MCRXR?
+        crand	cr1_eq,cr0_eq,cr1_eq			// merge the two tests for DCBA
+        crand	cr4_eq,cr0_eq,cr4_eq			// and for MCRXR
+        beq++	cr1_eq,a64ExitEm				// was DCBA, so ignore
+        bne--	cr4_eq,a64NotEmulated			// skip if not MCRXR
+        
+// Was MCRXR, so emulate.
+
+        ld		r3,savexer(r13)					// get the XER
+        lwz		r4,savecr(r13)					// and the CR
+        rlwinm	r5,r20,11,27,29					// get (CR# * 4) from instruction
+        rlwinm	r6,r3,0,4,31					// zero XER[32-35] (also XER[0-31])
+        sld		r4,r4,r5						// move target CR field to bits 32-35
+        rlwimi	r4,r3,0,0,3						// move XER[32-35] into CR field
+        stw		r6,savexer+4(r13)				// update XER
+        srd		r4,r4,r5						// re-position CR
+        stw		r4,savecr(r13)					// update CR
+        b		a64ExitEm						// done
+
+// Not an opcode we normally emulate.  If in special diagnostic mode and opcode=0,
+// emulate as an alignment exception.  This special case is for test software.
+
+a64NotEmulated:
+        lwz		r30,dgFlags(0)					// Get the flags
+        rlwinm.	r0,r30,0,enaDiagEMb,enaDiagEMb	// Do we want to try to emulate something?
+        beq++	a64PassAlong					// No emulation allowed
+        cmpwi	r3,0							// opcode==0 ?
+        bne		a64PassAlong					// not the special case
+        oris	r20,r20,0x7C00					// change opcode to 31
+        crset	kAlignment						// say we took alignment exception
+        rlwinm	r5,r4,0,26+1,26-1				// mask Update bit (32) out of extended opcode
+        rlwinm	r5,r5,0,0,31					// Clean out leftover junk from rlwinm
+
+        cmpwi	r4,1014							// dcbz/dcbz128 ?
+        crmove	cr1_eq,cr0_eq
+        cmpwi	r5,21							// ldx/ldux ?
+        cror	cr1_eq,cr0_eq,cr1_eq
+        cmpwi	r5,599							// lfdx/lfdux ?
+        cror	cr1_eq,cr0_eq,cr1_eq
+        cmpwi	r5,535							// lfsx/lfsux ?
+        cror	cr1_eq,cr0_eq,cr1_eq
+        cmpwi	r5,343							// lhax/lhaux ?
+        cror	cr1_eq,cr0_eq,cr1_eq
+        cmpwi	r4,790							// lhbrx ?
+        cror	cr1_eq,cr0_eq,cr1_eq
+        cmpwi	r5,279							// lhzx/lhzux ?
+        cror	cr1_eq,cr0_eq,cr1_eq
+        cmpwi	r4,597							// lswi ?
+        cror	cr1_eq,cr0_eq,cr1_eq
+        cmpwi	r4,533							// lswx ?
+        cror	cr1_eq,cr0_eq,cr1_eq
+        cmpwi	r5,341							// lwax/lwaux ?
+        cror	cr1_eq,cr0_eq,cr1_eq
+        cmpwi	r4,534							// lwbrx ?
+        cror	cr1_eq,cr0_eq,cr1_eq
+        cmpwi	r5,23							// lwz/lwzx ?
+        cror	cr1_eq,cr0_eq,cr1_eq
+        cmpwi	r5,149							// stdx/stdux ?
+        cror	cr1_eq,cr0_eq,cr1_eq
+        cmpwi	r5,727							// stfdx/stfdux ?
+        cror	cr1_eq,cr0_eq,cr1_eq
+        cmpwi	r4,983							// stfiwx ?
+        cror	cr1_eq,cr0_eq,cr1_eq
+        cmpwi	r5,663							// stfsx/stfsux ?
+        cror	cr1_eq,cr0_eq,cr1_eq
+        cmpwi	r4,918							// sthbrx ?
+        cror	cr1_eq,cr0_eq,cr1_eq
+        cmpwi	r5,407							// sthx/sthux ?
+        cror	cr1_eq,cr0_eq,cr1_eq
+        cmpwi	r4,725							// stswi ?
+        cror	cr1_eq,cr0_eq,cr1_eq
+        cmpwi	r4,661							// stswx ?
+        cror	cr1_eq,cr0_eq,cr1_eq
+        cmpwi	r4,662							// stwbrx ?
+        cror	cr1_eq,cr0_eq,cr1_eq
+        cmpwi	r5,151							// stwx/stwux ?
+        cror	cr1_eq,cr0_eq,cr1_eq
+        
+        beq++	cr1,a64GotInstruction			// it was one of the X-forms we handle
+        crclr	kAlignment						// revert to program interrupt
+        b		a64PassAlong					// not recognized extended opcode
+        
+
+// *****************************************
+// * A L I G N M E N T   I N T E R R U P T *
+// *****************************************
+//
+// We get here in exception context, ie with interrupts disabled, translation off, and
+// in 64-bit mode, with:
+//		r13 = save-area pointer, with general context already saved in it
+//		cr6 = feature flags
+// We preserve r13 and cr6.  Other GPRs and CRs, the LR and CTR are used.
+//
+// Current 64-bit processors (GPUL) handle almost all misaligned operations in hardware,
+// so this routine usually isn't called very often.  Only floating pt ops that cross a page
+// boundary and are not word aligned, and LMW/STMW can take exceptions to cacheable memory.
+// However, in contrast to G3 and G4, any misaligned load/store will get an alignment
+// interrupt on uncached memory.
+//
+// We always emulate scalar ops with a series of byte load/stores.  Doing so is no slower
+// than LWZ/STW in cases where a scalar op gets an alignment exception.
+//
+// This routine supports all legal permutations of alignment interrupts occuring in user or
+// supervisor mode, 32 or 64-bit addressing, and translation on or off.  We do not emulate
+// instructions that go past the end of an address space, such as "LHZ -1(0)"; we just pass
+// along the alignment exception rather than wrap around to byte 0.  (Treatment of address
+// space wrap is a moot point in Mac OS X, since we do not map either the last page or
+// page 0.)
+//
+// First, check for a few special cases such as virtual machines, etc.
+
+        .globl	EXT(AlignAssist64)
+        .align	5
+LEXT(AlignAssist64)
+        crset	kAlignment								// mark as alignment interrupt
+
+a64AlignAssistJoin:										// join here from program interrupt handler
+        mfsprg	r31,0									// get the per_proc data ptr
+        mcrf	cr3,cr6									// save feature flags here...
+        lwz		r21,spcFlags(r31)						// grab the special flags
+        ld		r29,savesrr1(r13)						// get the MSR etc at the fault
+        ld		r28,savesrr0(r13)						// get the EA of faulting instruction
+        mfmsr	r26										// save MSR at entry
+        rlwinm.	r0,r21,0,runningVMbit,runningVMbit		// Are we running a VM?
+        lwz		r19,dgFlags(0)							// Get the diagnostics flags
+        bne--	a64PassAlong							// yes, let the virtual machine monitor handle
+
+
+// Set up the MSR shadow regs.  We turn on FP in this routine, and usually set DR and RI
+// when accessing user space (the SLB is still set up with all the user space translations.)
+// However, if the interrupt occured in the kernel with DR off, we keep it off while
+// accessing the "target" address space.  If we set DR to access the target space, we also
+// set RI.  The RI bit tells the exception handlers to clear cr0 beq and return if we get an
+// exception accessing the user address space.  We are careful to test cr0 beq after every such
+// access.  We keep the following "shadows" of the MSR in global regs across this code:
+//		r25 = MSR at entry, plus FP and probably DR and RI (used to access target space)
+//		r26 = MSR at entry
+//		r27 = free
+//		r29 = SRR1 (ie, MSR at interrupt)
+// Note that EE and IR are always off, and SF is always on in this code.
+
+		rlwinm	r3,r29,0,MSR_DR_BIT,MSR_DR_BIT			// was translation on at fault?
+        rlwimi	r3,r3,32-MSR_RI_BIT+MSR_DR_BIT,MSR_RI_BIT,MSR_RI_BIT	// if DR was set, set RI too
+        or		r25,r26,r3								// assemble MSR to use accessing target space
+        
+
+// Because the DSISR and DAR are either not set or are not to be trusted on some 64-bit
+// processors on an alignment interrupt, we must fetch the faulting instruction ourselves,
+// then decode/hash the opcode and reconstruct the EA manually.
+
+        mtmsr	r25					// turn on FP and (if it was on at fault) DR and RI
+        isync						// wait for it to happen
+		cmpw	r0,r0				// turn on beq so we can check for DSIs
+        lwz		r20,0(r28)			// fetch faulting instruction, probably with DR on
+        bne--	a64RedriveAsISI		// got a DSI trying to fetch it, pretend it was an ISI
+        mtmsr	r26					// turn DR back off
+        isync						// wait for it to happen
+
+
+// Set a few flags while we wait for the faulting instruction to arrive from cache.
+
+        rlwinm.	r0,r29,0,MSR_SE_BIT,MSR_SE_BIT				// Were we single stepping?
+		stw		r20,savemisc2(r13)	// Save the instruction image in case we notify
+        crnot	kTrace,cr0_eq
+        rlwinm.	r0,r19,0,enaNotifyEMb,enaNotifyEMb			// Should we notify?
+        crnot	kNotify,cr0_eq        
+
+
+// Hash the intruction into a 5-bit value "AAAAB" used to index the branch table, and a
+// 1-bit kUpdate flag, as follows:
+//  ¥ for X-form instructions (with primary opcode 31):
+//       the "AAAA" bits are bits 21-24 of the instruction
+//       the "B" bit is the XOR of bits 29 and 30
+//       the update bit is instruction bit 25
+//	¥ for D and DS-form instructions (actually, any primary opcode except 31):
+//       the "AAAA" bits are bits 1-4 of the instruction
+//       the "B" bit is 0
+//       the update bit is instruction bit 5
+//
+// Just for fun (and perhaps a little speed on deep-pipe machines), we compute the hash,
+// update flag, and EA without branches and with ipc >= 2.
+//
+// When we "bctr" to the opcode-specific reoutine, the following are all set up:
+//		MSR = EE and IR off, SF and FP on
+//		r13 = save-area pointer (physical)
+//		r14 = ptr to saver0 in save-area (ie, to base of GPRs)
+//		r15 = 0x00000000FFFFFFFF if 32-bit mode fault, 0xFFFFFFFFFFFFFFFF if 64
+//		r16 = RA * 8 (ie, reg# not reg value)
+//		r17 = EA
+//		r18 = (RA|0) (reg value)
+//		r19 = -1 if X-form, 0 if D-form
+//		r20 = faulting instruction
+//		r21 = RT * 8 (ie, reg# not reg value)
+//		r22 = addr(aaFPopTable)+(RT*32), ie ptr to floating pt table for target register
+//		r25 = MSR at entrance, probably with DR and RI set (for access to target space)
+//		r26 = MSR at entrance
+//		r27 = free
+//		r28 = SRR0 (ie, EA of faulting instruction)
+//		r29 = SRR1 (ie, MSR at fault)
+//		r30 = scratch, usually user data
+//		r31 = per-proc pointer
+//		cr2 = kTrace, kNotify, and kAlignment flags
+//      cr3 = saved copy of feature flags used in lowmem vector code
+//		cr6 = bits 24-27 of CR are bits 24-27 of opcode if X-form, or bits 4-5 and 00 if D-form
+//			  bit 25 is the kUpdate flag, set for update form instructions
+//		cr7 = bits 28-31 of CR are bits 28-31 of opcode if X-form, or 0 if D-form
+
+a64GotInstruction:					// here from program interrupt with instruction in r20
+        rlwinm	r21,r20,6+6,20,25	// move the primary opcode (bits 0-6) to bits 20-25
+        la		r14,saver0(r13)		// r14 <- base address of GPR registers
+        xori	r19,r21,0x07C0		// iff primary opcode is 31, set r19 to 0
+        rlwinm	r16,r20,16+3,24,28	// r16 <- RA*8
+        subi	r19,r19,1			// set bit 0 iff X-form (ie, if primary opcode is 31)
+        rlwinm	r17,r20,21+3,24,28	// r17 <- RB*8 (if X-form)
+        sradi	r19,r19,63			// r19 <- -1 if X-form, 0 if D-form
+        extsh	r22,r20				// r22 <- displacement (if D-form)
+
+        ldx		r23,r14,r17			// get (RB), if any
+        and		r15,r20,r19			// instruction if X, 0 if D
+        andc	r17,r21,r19			// primary opcode in bits 20-25 if D, 0 if X
+        ldx		r18,r14,r16			// get (RA)
+        subi	r24,r16,1			// set bit 0 iff RA==0
+        or		r21,r15,r17			// r21 <- instruction if X, or bits 0-5 in bits 20-25 if D
+        sradi	r24,r24,63			// r24 <- -1 if RA==0, 0 otherwise
+        rlwinm	r17,r21,32-4,25,28	// shift opcode bits 21-24 to 25-28 (hash "AAAA" bits)
+        lis		r10,ha16(a64BranchTable)	// start to build up branch table address
+        rlwimi	r17,r21,0,29,29		// move opcode bit 29 into hash as start of "B" bit
+        rlwinm	r30,r21,1,29,29		// position opcode bit 30 in position 29
+        and		r12,r23,r19			// RB if X-form, 0 if D-form
+        andc	r11,r22,r19			// 0 if X-form, sign extended displacement if D-form
+        xor		r17,r17,r30			// bit 29 ("B") of hash is xor(bit29,bit30)
+        addi	r10,r10,lo16(a64BranchTable)
+        or		r12,r12,r11			// r12 <- (RB) or displacement, as appropriate
+        lwzx	r30,r10,r17			// get address from branch table
+        mtcrf	0x01,r21			// move opcode bits 28-31 to CR7
+        sradi	r15,r29,32			// propogate SF bit from SRR1 (MSR_SF, which is bit 0)
+        andc	r18,r18,r24			// r18 <- (RA|0)
+        mtcrf	0x02,r21			// move opcode bits 24-27 to CR6 (kUpdate is bit 25)
+        add		r17,r18,r12			// r17 <- EA, which might need to be clamped to 32 bits
+        mtctr	r30					// set up branch address
+        
+        oris	r15,r15,0xFFFF		// start to fill low word of r15 with 1s
+        rlwinm	r21,r20,11+3,24,28	// r21 <- RT * 8
+        lis		r22,ha16(EXT(aaFPopTable))	// start to compute address of floating pt table
+        ori		r15,r15,0xFFFF		// now bits 32-63 of r15 are 1s
+        addi	r22,r22,lo16(EXT(aaFPopTable))
+        and		r17,r17,r15			// clamp EA to 32 bits if necessary
+        rlwimi	r22,r21,2,22,26		// move RT into aaFPopTable address (which is 1KB aligned)
+        
+        bf--	kAlignment,a64HandleProgramInt	// return to Program Interrupt handler
+        bctr						// if alignment interrupt, jump to opcode-specific routine
+        
+        
+// Floating-pt load single (lfs[u], lfsx[u])
+
+a64LfsLfsx:
+        bl		a64Load4Bytes		// get data in r30
+        mtctr	r22					// set up address of "lfs fRT,emfp0(r31)"
+        stw		r30,emfp0(r31)		// put word here for aaFPopTable routine
+        bctrl						// do the lfs
+        b		a64UpdateCheck		// update RA if necessary and exit
+        
+        
+// Floating-pt store single (stfs[u], stfsx[u])
+
+a64StfsStfsx:
+        ori		r22,r22,8			// set dir==1 (ie, single store) in aaFPopTable
+        mtctr	r22					// set up address of "stfs fRT,emfp0(r31)"
+        bctrl						// execute the store into emfp0
+        lwz		r30,emfp0(r31)		// get the word
+        bl		a64Store4Bytes		// store r30 into user space
+        b		a64UpdateCheck		// update RA if necessary and exit
+        
+
+// Floating-pt store as integer word (stfiwx)
+
+a64Stfiwx:
+        ori		r22,r22,16+8		// set size=1, dir==1 (ie, double store) in aaFPopTable
+        mtctr	r22					// set up FP register table address
+        bctrl						// double precision store into emfp0
+        lwz		r30,emfp0+4(r31)	// get the low-order word
+        bl		a64Store4Bytes		// store r30 into user space
+        b		a64Exit				// successfully emulated
+        
+
+// Floating-pt load double (lfd[u], lfdx[u])
+
+a64LfdLfdx:
+        ori		r22,r22,16			// set Double bit in aaFPopTable address
+        bl		a64Load8Bytes		// get data in r30
+        mtctr	r22					// set up address of "lfd fRT,emfp0(r31)"
+        std		r30,emfp0(r31)		// put doubleword here for aaFPopTable routine
+        bctrl						// execute the load
+        b		a64UpdateCheck		// update RA if necessary and exit
+
+
+// Floating-pt store double (stfd[u], stfdx[u])
+
+a64StfdStfdx:
+        ori		r22,r22,16+8		// set size=1, dir==1 (ie, double store) in aaFPopTable address
+        mtctr	r22					// address of routine to stfd RT
+        bctrl						// store into emfp0
+        ld		r30,emfp0(r31)		// get the doubleword
+        bl		a64Store8Bytes		// store r30 into user space
+        b		a64UpdateCheck		// update RA if necessary and exit
+
+
+// Load halfword w 0-fill (lhz[u], lhzx[u])
+
+a64LhzLhzx:
+        bl		a64Load2Bytes		// load into r30 from user space (w 0-fill)
+        stdx	r30,r14,r21			// store into RT slot in register file
+        b		a64UpdateCheck		// update RA if necessary and exit
+
+
+// Load halfword w sign fill (lha[u], lhax[u])
+
+a64LhaLhax:
+        bl		a64Load2Bytes		// load into r30 from user space (w 0-fill)
+        extsh	r30,r30				// sign-extend
+        stdx	r30,r14,r21			// store into RT slot in register file
+        b		a64UpdateCheck		// update RA if necessary and exit
+
+
+// Load halfword byte reversed (lhbrx)
+
+a64Lhbrx:
+        bl		a64Load2Bytes		// load into r30 from user space (w 0-fill)
+        rlwinm	r3,r30,8,16,23		// reverse bytes into r3
+        rlwimi	r3,r30,24,24,31
+        stdx	r3,r14,r21			// store into RT slot in register file
+        b		a64Exit				// successfully emulated
+
+
+// Store halfword (sth[u], sthx[u])
+
+a64SthSthx:
+        ldx		r30,r14,r21			// get RT
+        bl		a64Store2Bytes		// store r30 into user space
+        b		a64UpdateCheck		// update RA if necessary and exit
+
+
+// Store halfword byte reversed (sthbrx)
+
+a64Sthbrx:
+        addi	r21,r21,6			// point to low two bytes of RT
+        lhbrx	r30,r14,r21			// load and reverse
+        bl		a64Store2Bytes		// store r30 into user space
+        b		a64Exit				// successfully emulated
+
+
+// Load word w 0-fill (lwz[u], lwzx[u]), also lwarx.
+
+a64LwzLwzxLwarx:
+        andc	r3,r19,r20			// light bit 30 of r3 iff lwarx
+        andi.	r0,r3,2				// is it lwarx?
+        bne--	a64PassAlong		// yes, never try to emulate a lwarx
+        bl		a64Load4Bytes		// load 4 bytes from user space into r30 (0-filled)
+        stdx	r30,r14,r21			// update register file
+        b		a64UpdateCheck		// update RA if necessary and exit
+        
+        
+// Load word w sign fill (lwa, lwax[u])
+
+a64Lwa:
+        crclr	kUpdate				// no update form of lwa (its a reserved encoding)
+a64Lwax:
+        bl		a64Load4Bytes		// load 4 bytes from user space into r30 (0-filled)
+        extsw	r30,r30				// sign extend
+        stdx	r30,r14,r21			// update register file
+        b		a64UpdateCheck		// update RA if necessary and exit
+
+
+// Load word byte reversed (lwbrx)
+
+a64Lwbrx:
+        bl		a64Load4Bytes		// load 4 bytes from user space into r30 (0-filled)
+        rlwinm	r3,r30,24,0,31		// flip bytes 1234 to 4123
+        rlwimi	r3,r30,8,8,15		// r3 is now 4323
+        rlwimi	r3,r30,8,24,31		// r3 is now 4321
+        stdx	r3,r14,r21			// update register file
+        b		a64Exit				// successfully emulated
+
+        
+// Store word (stw[u], stwx[u])
+
+a64StwStwx:
+        ldx		r30,r14,r21			// get RT
+        bl		a64Store4Bytes		// store r30 into user space
+        b		a64UpdateCheck		// update RA if necessary and exit
+
+
+// Store word byte reversed (stwbrx)
+
+a64Stwbrx:
+        addi	r21,r21,4			// point to low word of RT
+        lwbrx	r30,r14,r21			// load and reverse
+        bl		a64Store4Bytes		// store r30 into user space
+        b		a64Exit				// successfully emulated
+
+
+// Load doubleword (ld[u], ldx[u]), also lwa.
+
+a64LdLwa:							// these are DS form: ld=0, ldu=1, and lwa=2
+        andi.	r0,r20,2			// ld[u] or lwa? (test bit 30 of DS field)
+        rlwinm	r3,r20,0,30,31		// must adjust EA by subtracting DS field
+        sub		r17,r17,r3
+        and		r17,r17,r15			// re-clamp to 32 bits if necessary
+        bne		a64Lwa				// handle lwa
+a64Ldx:
+        bl		a64Load8Bytes		// load 8 bytes from user space into r30
+        stdx	r30,r14,r21			// update register file
+        b		a64UpdateCheck		// update RA if necessary and exit
+
+
+// Store doubleword (stdx[u], std[u])
+
+a64StdxStwcx:
+        bf--	30,a64PassAlong		// stwcx, so pass along alignment exception
+        b		a64Stdx				// was stdx
+a64StdStfiwx:
+        bt		30,a64Stfiwx		// handle stfiwx
+        rlwinm.	r3,r20,0,30,31		// must adjust EA by subtracting DS field
+        sub		r17,r17,r3
+        and		r17,r17,r15			// re-clamp to 32 bits if necessary
+a64Stdx:
+        ldx		r30,r14,r21			// get RT
+        bl		a64Store8Bytes		// store RT into user space
+        b		a64UpdateCheck		// update RA if necessary and exit
+
+
+// Dcbz and Dcbz128 (bit 10 distinguishes the two forms)
+
+a64DcbzDcbz128:
+        andis.	r0,r20,0x0020		// bit 10 set?
+        li		r3,0				// get a 0 to store
+        li		r0,4				// assume 32-bit version, store 8 bytes 4x
+        li		r4,_COMM_PAGE_BASE_ADDRESS
+        rldicr	r17,r17,0,63-5		// 32-byte align EA
+        beq		a64DcbzSetup		// it was the 32-byte version
+        rldicr	r17,r17,0,63-7		// zero low 7 bits of EA
+        li		r0,16				// store 8 bytes 16x
+a64DcbzSetup:
+        xor		r4,r4,r28			// was dcbz in the commpage(s)?
+        and		r4,r4,r15			// mask off high-order bits if 32-bit mode
+        srdi.	r4,r4,12			// check SRR0
+        bne		a64NotCommpage		// not in commpage
+        rlwinm.	r4,r29,0,MSR_PR_BIT,MSR_PR_BIT	// did fault occur in user mode?
+        beq--	a64NotCommpage		// do not zero cr7 if kernel got alignment exception
+        lwz		r4,savecr(r13)		// if we take a dcbz{128} in the commpage...
+        rlwinm	r4,r4,0,0,27		// ...clear user's cr7...
+        stw		r4,savecr(r13)		// ...as a flag for _COMM_PAGE_BIGCOPY
+a64NotCommpage:
+        mtctr	r0
+        cmpw	r0,r0				// turn cr0 beq on so we can check for DSIs
+        mtmsr	r25					// turn on DR and RI so we can address user space
+        isync						// wait for it to happen
+a64DcbzLoop:
+        std		r3,0(r17)			// store into user space
+        bne--	a64RedriveAsDSI
+        addi	r17,r17,8
+        bdnz	a64DcbzLoop
+        
+        mtmsr	r26					// restore MSR
+        isync						// wait for it to happen
+        b		a64Exit
+
+
+// Load and store multiple (lmw, stmw), distinguished by bit 25
+
+a64LmwStmw:
+        subfic	r22,r21,32*8		// how many regs to load or store?
+        srwi	r22,r22,1			// get bytes to load/store
+        bf		25,a64LoadMultiple	// handle lmw
+        b		a64StoreMultiple	// it was stmw
+        
+        
+// Load string word immediate (lswi)
+
+a64Lswi:
+        rlwinm	r22,r20,21,27,31	// get #bytes in r22
+        and		r17,r18,r15			// recompute EA as (RA|0), and clamp
+        subi	r3,r22,1			// r22==0?
+        rlwimi	r22,r3,6,26,26		// map count of 0 to 32
+        b		a64LoadMultiple
+        
+        
+// Store string word immediate (stswi)
+
+a64Stswi:
+        rlwinm	r22,r20,21,27,31	// get #bytes in r22
+        and		r17,r18,r15			// recompute EA as (RA|0), and clamp
+        subi	r3,r22,1			// r22==0?
+        rlwimi	r22,r3,6,26,26		// map count of 0 to 32
+        b		a64StoreMultiple
+        
+        
+// Load string word indexed (lswx), also lwbrx
+
+a64LswxLwbrx:
+        bf		30,a64Lwbrx			// was lwbrx
+        ld		r22,savexer(r13)	// get the xer
+        rlwinm	r22,r22,0,25,31		// isolate the byte count
+        b		a64LoadMultiple		// join common code
+        
+        
+// Store string word indexed (stswx), also stwbrx
+
+a64StswxStwbrx:
+        bf		30,a64Stwbrx		// was stwbrx
+        ld		r22,savexer(r13)	// get the xer
+        rlwinm	r22,r22,0,25,31		// isolate the byte count
+        b		a64StoreMultiple	// join common code
+
+
+// Load multiple words.  This handles lmw, lswi, and lswx.
+
+a64LoadMultiple:					// r22 = byte count, may be 0
+        subic.	r3,r22,1			// get (#bytes-1)
+        blt		a64Exit				// done if 0
+        add		r4,r17,r3			// get EA of last operand byte
+        and		r4,r4,r15			// clamp
+        cmpld	r4,r17				// address space wrap?
+        blt--	a64PassAlong		// pass along exception if so
+        srwi.	r4,r22,2			// get # full words to load
+        rlwinm	r22,r22,0,30,31		// r22 <- leftover byte count
+        cmpwi	cr1,r22,0			// leftover bytes?
+        beq		a64Lm3				// no words
+        mtctr	r4					// set up word count
+        cmpw	r0,r0				// set beq for DSI test
+a64Lm2:
+        mtmsr	r25					// turn on DR and RI
+        isync						// wait for it to happen
+        lbz		r3,0(r17)
+        bne--	a64RedriveAsDSI		// got a DSI
+        lbz		r4,1(r17)
+        bne--	a64RedriveAsDSI		// got a DSI
+        lbz		r5,2(r17)
+        bne--	a64RedriveAsDSI		// got a DSI
+        lbz		r6,3(r17)
+        bne--	a64RedriveAsDSI		// got a DSI
+        rlwinm	r30,r3,24,0,7		// pack bytes into r30
+        rldimi	r30,r4,16,40
+        rldimi	r30,r5,8,48
+        rldimi	r30,r6,0,56
+        mtmsr	r26					// turn DR back off so we can store into register file
+        isync
+        addi	r17,r17,4			// bump EA
+        stdx	r30,r14,r21			// pack into register file
+        addi	r21,r21,8			// bump register file offset
+        rlwinm	r21,r21,0,24,28		// wrap around to 0
+        bdnz	a64Lm2
+a64Lm3:								// cr1/r22 = leftover bytes (0-3), cr0 beq set
+        beq		cr1,a64Exit			// no leftover bytes
+        mtctr	r22
+        mtmsr	r25					// turn on DR so we can access user space
+        isync
+        lbz		r3,0(r17)			// get 1st leftover byte
+        bne--	a64RedriveAsDSI		// got a DSI
+        rlwinm	r30,r3,24,0,7		// position in byte 4 of r30 (and clear rest of r30)
+        bdz		a64Lm4				// only 1 byte leftover
+        lbz		r3,1(r17)			// get 2nd byte
+        bne--	a64RedriveAsDSI		// got a DSI
+        rldimi	r30,r3,16,40		// insert into byte 5 of r30
+        bdz		a64Lm4				// only 2 bytes leftover
+        lbz		r3,2(r17)			// get 3rd byte
+        bne--	a64RedriveAsDSI		// got a DSI
+        rldimi	r30,r3,8,48			// insert into byte 6
+a64Lm4:
+        mtmsr	r26					// turn DR back off so we can store into register file
+        isync
+        stdx	r30,r14,r21			// pack partially-filled word into register file
+        b		a64Exit
+
+
+// Store multiple words.  This handles stmw, stswi, and stswx.
+
+a64StoreMultiple:					// r22 = byte count, may be 0
+        subic.	r3,r22,1			// get (#bytes-1)
+        blt		a64Exit				// done if 0
+        add		r4,r17,r3			// get EA of last operand byte
+        and		r4,r4,r15			// clamp
+        cmpld	r4,r17				// address space wrap?
+        blt--	a64PassAlong		// pass along exception if so
+        srwi.	r4,r22,2			// get # full words to load
+        rlwinm	r22,r22,0,30,31		// r22 <- leftover byte count
+        cmpwi	cr1,r22,0			// leftover bytes?
+        beq		a64Sm3				// no words
+        mtctr	r4					// set up word count
+        cmpw	r0,r0				// turn on beq so we can check for DSIs
+a64Sm2:
+        ldx		r30,r14,r21			// get next register
+        addi	r21,r21,8			// bump register file offset
+        rlwinm	r21,r21,0,24,28		// wrap around to 0
+        srwi	r3,r30,24			// shift the four bytes into position
+        srwi	r4,r30,16
+        srwi	r5,r30,8
+        mtmsr	r25					// turn on DR so we can access user space
+        isync						// wait for it to happen
+        stb		r3,0(r17)
+        bne--	a64RedriveAsDSI		// got a DSI
+        stb		r4,1(r17)
+        bne--	a64RedriveAsDSI		// got a DSI
+        stb		r5,2(r17)
+        bne--	a64RedriveAsDSI		// got a DSI
+        stb		r30,3(r17)
+        bne--	a64RedriveAsDSI		// got a DSI
+        mtmsr	r26					// turn DR back off
+        isync
+        addi	r17,r17,4			// bump EA
+        bdnz	a64Sm2
+a64Sm3:								// r22 = 0-3, cr1 set on r22, cr0 beq set
+        beq		cr1,a64Exit			// no leftover bytes
+        ldx		r30,r14,r21			// get last register
+        mtctr	r22
+        mtmsr	r25					// turn on DR so we can access user space
+        isync						// wait for it to happen
+a64Sm4:
+        rlwinm	r30,r30,8,0,31		// position next byte
+        stb		r30,0(r17)			// pack into user space
+        addi	r17,r17,1			// bump user space ptr
+        bne--	a64RedriveAsDSI		// got a DSI
+        bdnz	a64Sm4
+        mtmsr	r26					// turn DR back off
+        isync
+        b		a64Exit
+
+
+// Subroutines to load bytes from user space.
+
+a64Load2Bytes:						// load 2 bytes right-justified into r30
+        addi	r7,r17,1			// get EA of last byte
+        and		r7,r7,r15			// clamp
+        cmpld	r7,r17				// address wrap?
+        blt--	a64PassAlong		// yes
+        mtmsr	r25					// turn on DR so we can access user space
+        isync						// wait for it to happen
+        sub.	r30,r30,r30			// 0-fill dest and set beq
+        b		a64Load2			// jump into routine
+a64Load4Bytes:						// load 4 bytes right-justified into r30 (ie, low order word)
+        addi	r7,r17,3			// get EA of last byte
+        and		r7,r7,r15			// clamp
+        cmpld	r7,r17				// address wrap?
+        blt--	a64PassAlong		// yes
+        mtmsr	r25					// turn on DR so we can access user space
+        isync						// wait for it to happen
+        sub.	r30,r30,r30			// 0-fill dest and set beq
+        b		a64Load4			// jump into routine
+a64Load8Bytes:						// load 8 bytes into r30
+        addi	r7,r17,7			// get EA of last byte
+        and		r7,r7,r15			// clamp
+        cmpld	r7,r17				// address wrap?
+        blt--	a64PassAlong		// yes
+        mtmsr	r25					// turn on DR so we can access user space
+        isync						// wait for it to happen
+        sub.	r30,r30,r30			// 0-fill dest and set beq
+        lbz		r3,-7(r7)			// get byte 0
+        bne--	a64RedriveAsDSI		// got a DSI
+        lbz		r4,-6(r7)			// and byte 1, etc
+        bne--	a64RedriveAsDSI		// got a DSI
+        lbz		r5,-5(r7)
+        bne--	a64RedriveAsDSI		// got a DSI
+        lbz		r6,-4(r7)
+        bne--	a64RedriveAsDSI		// got a DSI
+        rldimi	r30,r3,56,0			// position bytes in upper word
+        rldimi	r30,r4,48,8
+        rldimi	r30,r5,40,16
+        rldimi	r30,r6,32,24
+a64Load4:
+        lbz		r3,-3(r7)
+        bne--	a64RedriveAsDSI		// got a DSI
+        lbz		r4,-2(r7)
+        bne--	a64RedriveAsDSI		// got a DSI
+        rldimi	r30,r3,24,32		// insert bytes 4 and 5 into r30
+        rldimi	r30,r4,16,40
+a64Load2:
+        lbz		r3,-1(r7)
+        bne--	a64RedriveAsDSI		// got a DSI
+        lbz		r4,0(r7)
+        bne--	a64RedriveAsDSI		// got a DSI
+        mtmsr	r26					// turn DR back off
+        isync
+        rldimi	r30,r3,8,48			// insert bytes 6 and 7 into r30
+        rldimi	r30,r4,0,56
+        blr
+        
+        
+// Subroutines to store bytes into user space.
+
+a64Store2Bytes:						// store bytes 6 and 7 of r30
+        addi	r7,r17,1			// get EA of last byte
+        and		r7,r7,r15			// clamp
+        cmpld	r7,r17				// address wrap?
+        blt--	a64PassAlong		// yes
+        mtmsr	r25					// turn on DR so we can access user space
+        isync						// wait for it to happen
+        cmpw	r0,r0				// set beq so we can check for DSI
+        b		a64Store2			// jump into routine
+a64Store4Bytes:						// store bytes 4-7 of r30 (ie, low order word)
+        addi	r7,r17,3			// get EA of last byte
+        and		r7,r7,r15			// clamp
+        cmpld	r7,r17				// address wrap?
+        blt--	a64PassAlong		// yes
+        mtmsr	r25					// turn on DR so we can access user space
+        isync						// wait for it to happen
+        cmpw	r0,r0				// set beq so we can check for DSI
+        b		a64Store4			// jump into routine
+a64Store8Bytes:						// r30 = bytes
+        addi	r7,r17,7			// get EA of last byte
+        and		r7,r7,r15			// clamp
+        cmpld	r7,r17				// address wrap?
+        blt--	a64PassAlong		// yes
+        mtmsr	r25					// turn on DR so we can access user space
+        isync						// wait for it to happen
+        cmpw	r0,r0				// set beq so we can check for DSI
+        rotldi	r3,r30,8			// shift byte 0 into position
+        rotldi	r4,r30,16			// and byte 1
+        rotldi	r5,r30,24			// and byte 2
+        rotldi	r6,r30,32			// and byte 3
+        stb		r3,-7(r7)			// store byte 0
+        bne--	a64RedriveAsDSI		// got a DSI
+        stb		r4,-6(r7)			// and byte 1 etc...
+        bne--	a64RedriveAsDSI		// got a DSI
+        stb		r5,-5(r7)
+        bne--	a64RedriveAsDSI		// got a DSI
+        stb		r6,-4(r7)
+        bne--	a64RedriveAsDSI		// got a DSI
+a64Store4:
+        rotldi	r3,r30,40			// shift byte 4 into position
+        rotldi	r4,r30,48			// and byte 5
+        stb		r3,-3(r7)
+        bne--	a64RedriveAsDSI		// got a DSI
+        stb		r4,-2(r7)
+        bne--	a64RedriveAsDSI		// got a DSI
+a64Store2:
+        rotldi	r3,r30,56			// shift byte 6 into position
+        stb		r3,-1(r7)			// store byte 6
+        bne--	a64RedriveAsDSI		// got a DSI
+        stb		r30,0(r7)			// store byte 7, which is already positioned
+        bne--	a64RedriveAsDSI		// got a DSI
+        mtmsr	r26					// turn off DR
+        isync
+        blr
+        
+                
+// Exit routines.
+
+a64ExitEm:
+		li		r30,T_EMULATE			// Change exception code to emulate
+		stw		r30,saveexception(r13)	// Save it
+		b		a64Exit					// Join standard exit routine...
+
+a64PassAlong:							// unhandled exception, just pass it along
+        crset	kNotify					// return T_ALIGNMENT or T_PROGRAM
+        crclr	kTrace					// not a trace interrupt
+        b		a64Exit1
+a64UpdateCheck:							// successfully emulated, may be update form
+        bf		kUpdate,a64Exit			// update?
+        stdx	r17,r14,r16				// yes, store EA into RA
+a64Exit:								// instruction successfully emulated
+        addi	r28,r28,4				// bump SRR0 past the emulated instruction
+        li		r30,T_IN_VAIN			// eat the interrupt since we emulated it
+        and		r28,r28,r15				// clamp to address space size (32 vs 64)
+        std		r28,savesrr0(r13)		// save, so we return to next instruction
+a64Exit1:
+        bt--	kTrace,a64Trace			// were we in single-step at fault?
+        bt--	kNotify,a64Notify		// should we say T_ALIGNMENT anyway?
+a64Exit2:
+        mcrf	cr6,cr3					// restore feature flags
+        mr		r11,r30					// pass back exception code (T_IN_VAIN etc) in r11
+        b		EXT(EmulExit)			// return to exception processing
+
+
+// Notification requested: pass exception upstairs even though it might have been emulated.
+
+a64Notify:
+        li		r30,T_ALIGNMENT			// somebody wants to know about it (but don't redrive)
+        bt		kAlignment,a64Exit2		// was an alignment exception
+        li		r30,T_PROGRAM			// was an emulated instruction
+        b		a64Exit2
+
+
+// Emulate a trace interrupt after handling alignment interrupt.
+
+a64Trace:
+        lwz		r9,SAVflags(r13)		// get the save-area flags
+        li		r30,T_TRACE
+        oris	r9,r9,hi16(SAVredrive)	// Set the redrive bit
+        stw		r30,saveexception(r13)	// Set the exception code
+        stw		r9,SAVflags(r13)		// Set the flags
+        b		a64Exit2				// Exit and do trace interrupt...
+
+
+// Got a DSI accessing user space.  Redrive.  One way this can happen is if another
+// processor removes a mapping while we are emulating.
+
+a64RedriveAsISI:						// this DSI happened fetching the opcode (r1==DSISR  r4==DAR)
+        mtmsr	r26						// turn DR back off
+        isync							// wait for it to happen
+        li		r30,T_INSTRUCTION_ACCESS
+        rlwimi	r29,r1,0,0,4			// insert the fault type from DSI's DSISR
+        std		r29,savesrr1(r13)		// update SRR1 to look like an ISI
+        b		a64Redrive
+
+a64RedriveAsDSI:						// r0==DAR  r1==DSISR
+        mtmsr	r26						// turn DR back off
+        isync							// wait for it to happen
+        stw		r1,savedsisr(r13)		// Set the DSISR of failed access
+        std		r0,savedar(r13)			// Set the address of the failed access
+        li		r30,T_DATA_ACCESS		// Set failing data access code
+a64Redrive:
+        lwz		r9,SAVflags(r13)		// Pick up the flags
+        stw		r30,saveexception(r13)	// Set the replacement code
+        oris	r9,r9,hi16(SAVredrive)	// Set the redrive bit
+        stw		r9,SAVflags(r13)		// Set redrive request
+        crclr	kTrace					// don't take a trace interrupt
+        crclr	kNotify					// don't pass alignment exception
+        b		a64Exit2				// done
+        
+
+// This is the branch table, indexed by the "AAAAB" opcode hash.
+
+a64BranchTable:
+        .long	a64LwzLwzxLwarx		// 00000  lwz[u], lwzx[u], lwarx
+        .long	a64Ldx				// 00001  ldx[u]
+        .long	a64PassAlong		// 00010  ldarx 	(never emulate these)
+        .long	a64PassAlong		// 00011
+        .long	a64StwStwx			// 00100  stw[u], stwx[u]
+        .long	a64StdxStwcx		// 00101  stdx[u], stwcx
+        .long	a64PassAlong		// 00110
+        .long	a64PassAlong		// 00111  stdcx		(never emulate these)
+        .long	a64LhzLhzx			// 01000  lhz[u], lhzx[u]
+        .long	a64PassAlong		// 01001
+        .long	a64LhaLhax			// 01010  lha[u], lhax[u]
+        .long	a64Lwax				// 01011  lwax[u]
+        .long	a64SthSthx			// 01100  sth[u], sthx[u]
+        .long	a64PassAlong		// 01101
+        .long	a64LmwStmw			// 01110  lmw, stmw
+        .long	a64PassAlong		// 01111
+        .long	a64LfsLfsx			// 10000  lfs[u], lfsx[u]
+        .long	a64LswxLwbrx		// 10001  lswx, lwbrx
+        .long	a64LfdLfdx			// 10010  lfd[u], lfdx[u]
+        .long	a64Lswi				// 10011  lswi
+        .long	a64StfsStfsx		// 10100  stfs[u], stfsx[u]
+        .long	a64StswxStwbrx		// 10101  stswx, stwbrx
+        .long	a64StfdStfdx		// 10110  stfd[u], stfdx[u]
+        .long	a64Stswi			// 10111  stswi
+        .long	a64PassAlong		// 11000
+        .long	a64Lhbrx			// 11001  lhbrx
+        .long	a64LdLwa			// 11010  ld[u], lwa
+        .long	a64PassAlong		// 11011
+        .long	a64PassAlong		// 11100
+        .long	a64Sthbrx			// 11101  sthbrx
+        .long	a64StdStfiwx		// 11110  std[u], stfiwx
+        .long	a64DcbzDcbz128		// 11111  dcbz, dcbz128
+
+
diff --git a/osfmk/ppc/Firmware.h b/osfmk/ppc/Firmware.h
index 23b25171f..a3b93c6c7 100644
--- a/osfmk/ppc/Firmware.h
+++ b/osfmk/ppc/Firmware.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -38,6 +41,9 @@
 #error This file is only useful on PowerPC.
 #endif
 
+#include <mach/vm_types.h>
+#include <ppc/Diagnostics.h>
+
 /*
  *	This routine is used to write debug output to either the modem or printer port.
  *	parm 1 is printer (0) or modem (1); parm 2 is ID (printed directly); parm 3 converted to hex
@@ -48,14 +54,18 @@ void dbgLog(unsigned int d0, unsigned int d1, unsigned int d2, unsigned int d3);
 void dbgLog2(unsigned int type, unsigned int p1, unsigned int p2);
 void dbgDispLL(unsigned int port, unsigned int id, unsigned int data);
 void fwSCCinit(unsigned int port);
+void fwEmMck(unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int);	/* Start injecting */ 
+void fwSCOM(scomcomm *);	/* Read/Write SCOM */ 
+void setPmon(unsigned int, unsigned int);	/* Set perf mon stuff */ 
 
-extern void dbgTrace(unsigned int item1, unsigned int item2, unsigned int item3);
+extern void dbgTrace(unsigned int item1, unsigned int item2, unsigned int item3, unsigned int item4);
 #if 0		/* (TEST/DEBUG) - eliminate inline */
-extern __inline__ void dbgTrace(unsigned int item1, unsigned int item2, unsigned int item3) {
+extern __inline__ void dbgTrace(unsigned int item1, unsigned int item2, unsigned int item3, unsigned int item4) {
  
  		__asm__ volatile("mr   r3,%0" : : "r" (item1) : "r3");
  		__asm__ volatile("mr   r4,%0" : : "r" (item2) : "r4");
  		__asm__ volatile("mr   r5,%0" : : "r" (item3) : "r5");
+ 		__asm__ volatile("mr   r6,%0" : : "r" (item3) : "r6");
         __asm__ volatile("lis  r0,hi16(CutTrace)" : : : "r0");
         __asm__ volatile("ori  r0,r0,lo16(CutTrace)" : : : "r0");
         __asm__ volatile("sc");
@@ -107,7 +117,7 @@ extern __inline__ void ChokeSys(unsigned int ercd) {
 typedef struct Boot_Video bootBumbleC;
 
 extern void StoreReal(unsigned int val, unsigned int addr);
-extern void ReadReal(unsigned int raddr, unsigned int *vaddr);
+extern void ReadReal(addr64_t raddr, unsigned int *vaddr);
 extern void ClearReal(unsigned int addr, unsigned int lgn);
 extern void LoadDBATs(unsigned int *bat);
 extern void LoadIBATs(unsigned int *bat);
@@ -119,6 +129,7 @@ extern void GratefulDebInit(bootBumbleC *boot_video_info);
 extern void GratefulDebDisp(unsigned int coord, unsigned int data);
 extern void checkNMI(void);
 
+#pragma pack(1)							/* Make sure the structure stays as we defined it */
 typedef struct GDWorkArea {			/* Grateful Deb work area one per processor */
 
 /*	Note that a lot of info is duplicated for each processor */
@@ -144,6 +155,7 @@ typedef struct GDWorkArea {			/* Grateful Deb work area one per processor */
 	unsigned int GDrowbuf2[128];	/* Buffer to an 8 character row */
 
 } GDWorkArea;
+#pragma pack()
 #define GDfontsize 16
 #define GDdispcols 2
 
diff --git a/osfmk/ppc/Firmware.s b/osfmk/ppc/Firmware.s
index 3c16dd1df..21743295a 100644
--- a/osfmk/ppc/Firmware.s
+++ b/osfmk/ppc/Firmware.s
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -40,7 +43,6 @@
 #include <ppc/asm.h>
 #include <ppc/proc_reg.h>
 #include <ppc/spec_reg.h>
-#include <ppc/POWERMAC/mp/MPPlugIn.h>
 #include <ppc/exception.h>
 #include <mach/machine/vm_param.h>
 #include <assym.s>
@@ -80,54 +82,57 @@ EXT(FWtable):
  *			R3 is as passed in by the user.  All others must be gotten from the save area
  */
 
-ENTRY(FirmwareCall, TAG_NO_FRAME_USED)
+
+			.align	5
+			.globl	EXT(FirmwareCall)
+
+LEXT(FirmwareCall)
 		
 			rlwinm	r1,r0,2,1,29					/* Clear out bit 0 and multiply by 4 */
 			lis		r12,HIGH_ADDR(EXT(FWtable))		/* Get the high part of the firmware call table */
 			cmplwi	r1,EXT(FirmwareCnt)*4			/* Is it a valid firmware call number */
-			mflr	r11								/* Save the return */
 			ori		r12,r12,LOW_ADDR(EXT(FWtable))	/* Now the low part */
 			ble+	goodCall						/* Yeah, it is... */
 			
 			li		r3,T_SYSTEM_CALL				/* Tell the vector handler that we know nothing */
-			blr										/* Return for errors... */
+			b		EXT(FCReturn)					; Bye dudes...
 			
 goodCall:	mfsprg	r10,0							/* Make sure about the per_proc block */
 			lwzx	r1,r1,r12						/* Pick up the address of the routine */
-			lwz		r4,saver4(r13)					/* Pass in caller's R4 */
-			lwz		r5,saver5(r13)					/* Pass in caller's R5 */
+			lwz		r4,saver4+4(r13)				/* Pass in caller's R4 */
+			lwz		r5,saver5+4(r13)				/* Pass in caller's R5 */
 			rlwinm.	r1,r1,0,0,29					/* Make sure the flag bits are clear */
-			stw		r11,PP_TEMPWORK1(r10)			/* Save our return point */
 
 			mtlr	r1								/* Put it in the LR */
 			beq-	callUnimp						/* This one was unimplimented... */
 
 			blrl									/* Call the routine... */
 
-			mfsprg	r10,0							/* Make sure about the per_proc again */
-			stw		r3,saver3(r13)					/* Pass back the return code to caller */
-			lwz		r11,PP_TEMPWORK1(r10)			/* Get our return point */
+			stw		r3,saver3+4(r13)				/* Pass back the return code to caller */
 			li		r3,T_IN_VAIN					/* Tell the vector handler that we took care of it */
-			mtlr	r11								/* Set the return */
-			blr										/* Bye, dudes... */
+			b		EXT(FCReturn)					; Bye dudes...
 	
-callUnimp:	lwz		r11,PP_TEMPWORK1(r10)			/* Restore the return address */
-			li		r3,T_SYSTEM_CALL				/* Tell the vector handler that we know nothing */
-			mtlr	r11								/* Restore the LR */
-			blr										/* Return for errors... */
+callUnimp:	li		r3,T_SYSTEM_CALL				/* Tell the vector handler that we know nothing */
+			b		EXT(FCReturn)					; Bye dudes...
 
 /*
  *			This routine is used to store using a real address. It stores parmeter1 at parameter2.
  */
 
-ENTRY(StoreReal, TAG_NO_FRAME_USED)
+			.align	5
+			.globl	EXT(StoreReal)
+
+LEXT(StoreReal)
 
 			lis		r0,HIGH_ADDR(StoreRealCall)		/* Get the top part of the SC number */
 			ori		r0,r0,LOW_ADDR(StoreRealCall)	/* and the bottom part */
 			sc										/* Do it to it */
 			blr										/* Bye bye, Birdie... */
 			
-ENTRY(StoreRealLL, TAG_NO_FRAME_USED)
+			.align	5
+			.globl	EXT(StoreRealLL)
+
+LEXT(StoreRealLL)
 
 			stw		r3,0(r4)						/* Store the word */
 			blr										/* Leave... */
@@ -135,15 +140,22 @@ ENTRY(StoreRealLL, TAG_NO_FRAME_USED)
 /*
  *			This routine is used to clear a range of physical pages.
  */
+			
+			.align	5
+			.globl	EXT(ClearReal)
 
-ENTRY(ClearReal, TAG_NO_FRAME_USED)
+LEXT(ClearReal)
 
 			lis		r0,HIGH_ADDR(ClearRealCall)		/* Get the top part of the SC number */
 			ori		r0,r0,LOW_ADDR(ClearRealCall)	/* and the bottom part */
 			sc										/* Do it to it */
 			blr										/* Bye bye, Birdie... */
 			
-ENTRY(ClearRealLL, TAG_NO_FRAME_USED)
+			
+			.align	5
+			.globl	EXT(ClearRealLL)
+
+LEXT(ClearRealLL)
 
 /*
  *			We take the first parameter as a physical address.  The second is the length in bytes.
@@ -172,30 +184,56 @@ clrloop:	subi	r4,r4,32						/* Back off a cache line */
 /*
  *			This routine will read in 32 byte of real storage.
  */
- 
-ENTRY(ReadReal, TAG_NO_FRAME_USED)
-
-			mfmsr	r0								/* Get the MSR */
-			rlwinm	r5,r0,0,28,26					/* Clear DR bit */
-			rlwinm	r5,r5,0,17,15					/* Clear EE bit */
-			mtmsr	r5								/* Disable EE and DR */
+ 			
+			.align	5
+			.globl	EXT(ReadReal)
+
+LEXT(ReadReal)
+
+			mfsprg	r9,2							; Get the features
+			mfmsr	r0								; Get the MSR 
+			li		r8,lo16(MASK(MSR_DR))			; Get the DR bit
+			rlwinm.	r9,r9,0,pf64Bitb,pf64Bitb		; Are we 64-bit?
+			ori		r8,r8,lo16(MASK(MSR_EE))		; Add in the EE bit
+			li		r7,1							; Get set for it
+			andc	r8,r0,r8						; Turn off EE and DR
+			bt--	cr0_eq,rr32a					; Yes, we are...
+			
+			rldimi	r8,r7,63,MSR_SF_BIT				; Set SF bit (bit 0)
+			sldi	r3,r3,32						; Slide on over for true 64-bit address
+			mtmsrd	r8
+			isync
+			or		r3,r3,r4						; Join top and bottom of address
+			mr		r4,r5							; Set destination address
+			b		rrJoina							; Join on up...
+			
+rr32a:		mr		r3,r4							; Position bottom of long long
+			mr		r4,r5							; Set destination address
+			mtmsr	r8								/* Disable EE and DR */
 			isync									/* Just make sure about it */
 			
-			lwz		r5,0(r3)						/* Get word 0 */
+rrJoina:	lwz		r5,0(r3)						/* Get word 0 */
 			lwz		r6,4(r3)						/* Get word 1 */
 			lwz		r7,8(r3)						/* Get word 2 */
 			lwz		r8,12(r3)						/* Get word 3 */
-			rlwinm	r0,r0,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
+			lis		r2,hi16(MASK(MSR_VEC))			; Get the vector enable 
 			lwz		r9,16(r3)						/* Get word 4 */
+			ori		r2,r2,lo16(MASK(MSR_FP))		; Get the FP enable 
 			lwz		r10,20(r3)						/* Get word 5 */
-			rlwinm	r0,r0,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
+			andc	r0,r0,r2						; Clear VEC and FP enables
 			lwz		r11,24(r3)						/* Get word 6 */
 			lwz		r12,28(r3)						/* Get word 7 */
 			
-			mtmsr	r0								/* Restore original machine state */
+			bt--	cr0_eq,rr32b					; We are not 64-bit...
+
+			mtmsrd	r0
+			isync
+			b		rrJoinb							; Join on up...
+
+rr32b:		mtmsr	r0								/* Restore original machine state */
 			isync									/* Insure goodness */
 			
-			stw		r5,0(r4)						/* Set word 0 */
+rrJoinb:	stw		r5,0(r4)						/* Set word 0 */
 			stw		r6,4(r4)						/* Set word 1 */
 			stw		r7,8(r4)						/* Set word 2 */
 			stw		r8,12(r4)						/* Set word 3 */
@@ -210,8 +248,12 @@ ENTRY(ReadReal, TAG_NO_FRAME_USED)
 /*
  *			This routine is used to load all 4 DBATs.
  */
+ 			
+			.align	5
+			.globl	EXT(LoadDBATs)
+
+LEXT(LoadDBATs)
 
-ENTRY(LoadDBATs, TAG_NO_FRAME_USED)
 
 			lis		r0,HIGH_ADDR(LoadDBATsCall)		/* Top half of LoadDBATsCall firmware call number */
 			ori		r0,r0,LOW_ADDR(LoadDBATsCall)	/* Bottom half */
@@ -219,7 +261,11 @@ ENTRY(LoadDBATs, TAG_NO_FRAME_USED)
 
 			blr										/* Bye bye, Birdie... */
 			
-ENTRY(xLoadDBATsLL, TAG_NO_FRAME_USED)
+ 			
+			.align	5
+			.globl	EXT(xLoadDBATsLL)
+
+LEXT(xLoadDBATsLL)
 
 			lwz		r4,0(r3)						/* Get DBAT 0 high */
 			lwz		r5,4(r3)						/* Get DBAT 0 low */
@@ -248,14 +294,21 @@ ENTRY(xLoadDBATsLL, TAG_NO_FRAME_USED)
  *			This routine is used to load all 4 IBATs.
  */
 
-ENTRY(LoadIBATs, TAG_NO_FRAME_USED)
+			.align	5
+			.globl	EXT(LoadIBATs)
+
+LEXT(LoadIBATs)
+
 
 			lis		r0,HIGH_ADDR(LoadIBATsCall)		/* Top half of LoadIBATsCall firmware call number */
 			ori		r0,r0,LOW_ADDR(LoadIBATsCall)	/* Bottom half */
 			sc										/* Do it to it */
 			blr										/* Bye bye, Birdie... */
 			
-ENTRY(xLoadIBATsLL, TAG_NO_FRAME_USED)
+			.align	5
+			.globl	EXT(xLoadIBATsLL)
+
+LEXT(xLoadIBATsLL)
 
 			lwz		r4,0(r3)						/* Get IBAT 0 high */
 			lwz		r5,4(r3)						/* Get IBAT 0 low */
@@ -284,8 +337,11 @@ ENTRY(xLoadIBATsLL, TAG_NO_FRAME_USED)
 /*
  *			This is the glue to call the CutTrace firmware call
  */
- 
-ENTRY(dbgTrace, TAG_NO_FRAME_USED)
+ 			
+			.align	5
+			.globl	EXT(dbgTrace)
+
+LEXT(dbgTrace)
 			
 			lis		r0,HIGH_ADDR(CutTrace)			/* Top half of CreateFakeIO firmware call number */
 			ori		r0,r0,LOW_ADDR(CutTrace)		/* Bottom half */
@@ -295,8 +351,11 @@ ENTRY(dbgTrace, TAG_NO_FRAME_USED)
 /*
  *			This is the glue to create a fake I/O interruption
  */
- 
-ENTRY(CreateFakeIO, TAG_NO_FRAME_USED)
+  			
+			.align	5
+			.globl	EXT(CreateFakeIO)
+
+LEXT(CreateFakeIO)
 			
 			lis		r0,HIGH_ADDR(CreateFakeIOCall)	/* Top half of CreateFakeIO firmware call number */
 			ori		r0,r0,LOW_ADDR(CreateFakeIOCall)	/* Bottom half */
@@ -306,14 +365,18 @@ ENTRY(CreateFakeIO, TAG_NO_FRAME_USED)
 /*
  *			This is the glue to create a fake Dec interruption
  */
- 
-ENTRY(CreateFakeDEC, TAG_NO_FRAME_USED)
+   			
+			.align	5
+			.globl	EXT(CreateFakeDEC)
+
+LEXT(CreateFakeDEC)
 			
 #if 0
 			mflr	r4								; (TEST/DEBUG)
 			bl		EXT(ml_sense_nmi)				; (TEST/DEBUG)
 			mtlr	r4								; (TEST/DEBUG)
-#endif
+#endif			
+			
 			lis		r0,HIGH_ADDR(CreateFakeDECCall)	/* Top half of CreateFakeDEC firmware call number */
 			ori		r0,r0,LOW_ADDR(CreateFakeDECCall)	/* Bottom half */
 			sc										/* Do it to it */
@@ -324,7 +387,10 @@ ENTRY(CreateFakeDEC, TAG_NO_FRAME_USED)
  *			This is the glue to create a shutdown context
  */
  
-ENTRY(CreateShutdownCTX, TAG_NO_FRAME_USED)
+			.align	5
+			.globl	EXT(CreateShutdownCTX)
+
+LEXT(CreateShutdownCTX)
 			
 			lis		r0,HIGH_ADDR(CreateShutdownCTXCall)	/* Top half of CreateFakeIO firmware call number */
 			ori		r0,r0,LOW_ADDR(CreateShutdownCTXCall)	/* Bottom half */
@@ -334,8 +400,11 @@ ENTRY(CreateShutdownCTX, TAG_NO_FRAME_USED)
 /*
  *			This is the glue to choke system
  */
- 
-ENTRY(ChokeSys, TAG_NO_FRAME_USED)
+  
+			.align	5
+			.globl	EXT(ChokeSys)
+
+LEXT(ChokeSys)
 			
 			lis		r0,HIGH_ADDR(Choke)				/* Top half of Choke firmware call number */
 			ori		r0,r0,LOW_ADDR(Choke)			/* Bottom half */
@@ -346,8 +415,11 @@ ENTRY(ChokeSys, TAG_NO_FRAME_USED)
  *			Used to initialize the SCC for debugging output
  */
 
+  
+			.align	5
+			.globl	EXT(fwSCCinit)
 
-ENTRY(fwSCCinit, TAG_NO_FRAME_USED)
+LEXT(fwSCCinit)
 		
 			mfmsr	r8										/* Save the MSR */
 			mr.		r3,r3									/* See if printer or modem */
@@ -632,8 +704,11 @@ wSCCrdy:	eieio											/* Barricade it */
  *			This routine is used to write debug output to either the modem or printer port.
  *			parm 1 is printer (0) or modem (1); parm 2 is ID (printed directly); parm 3 converted to hex
  */
+  
+			.align	5
+			.globl	EXT(dbgDisp)
 
-ENTRY(dbgDisp, TAG_NO_FRAME_USED)
+LEXT(dbgDisp)
 
 			mr		r12,r0									/* Keep R0 pristene */
 			lis		r0,HIGH_ADDR(dbgDispCall)				/* Top half of dbgDispCall firmware call number */
@@ -646,7 +721,10 @@ ENTRY(dbgDisp, TAG_NO_FRAME_USED)
 			
 /*			Here's the low-level part of dbgDisp			*/
 
-ENTRY(dbgDispLL, TAG_NO_FRAME_USED)
+			.align	5
+			.globl	EXT(dbgDispLL)
+
+LEXT(dbgDispLL)
 
 dbgDispInt:	mfmsr	r8										/* Save the MSR */
 
@@ -1029,21 +1107,22 @@ hexTab:		STRINGD	"0123456789ABCDEF"						/* Convert hex numbers to printable hex
  */
  
 
-ENTRY(dbgRegsLL, TAG_NO_FRAME_USED)
+			.align	5
+			.globl	EXT(dbgRegsLL)
+
+LEXT(dbgRegsLL)
 
+			b		EXT(FCReturn)					; Bye dudes...
+#if 0
 			li		r3,0									/* ? */
 			bl		dbgRegsCm								/* Join on up... */
-
-/*
- *			Note that we bypass the normal return 'cause we don't wanna mess up R3
- */
-			mfsprg	r11,0									/* Get the per_proc */
-			lwz		r11,PP_TEMPWORK1(r11)					/* Get our return point */
-			li		r3,T_IN_VAIN							/* Tell the vector handler that we took care of it */
-			mtlr	r11										/* Set the return */
-			blr												/* Bye, dudes... */
+			b		EXT(FCReturn)					; Bye dudes...
+			
 			
-ENTRY(dbgRegs, TAG_NO_FRAME_USED)
+			.align	5
+			.globl	EXT(dbgRegs)
+
+LEXT(dbgRegs)
 
 dbgRegsCm:	mfmsr	r8										/* Save the MSR */
 			mr.		r3,r3									/* ? */
@@ -1428,14 +1507,17 @@ ddwait1:	lwarx	r5,0,r3									/* Get the lock */
 			mtmsr	r8										/* Restore the MSR */
 			isync											/* Wait for it */
 			blr												/* Leave... */
-			
+#endif			
 			
 /*
  *			Used for debugging to leave stuff in 0x380-0x3FF (128 bytes).
  *			Mapping is V=R.  Stores and loads are real.
  */
+			
+			.align	5
+			.globl	EXT(dbgCkpt)
 
-ENTRY(dbgCkpt, TAG_NO_FRAME_USED)
+LEXT(dbgCkpt)
 
 			mr		r12,r0									/* Keep R0 pristene */
 			lis		r0,HIGH_ADDR(dbgCkptCall)				/* Top half of dbgCkptCall firmware call number */
@@ -1448,7 +1530,11 @@ ENTRY(dbgCkpt, TAG_NO_FRAME_USED)
 			
 /*			Here's the low-level part of dbgCkpt			*/
 
-ENTRY(dbgCkptLL, TAG_NO_FRAME_USED)
+			.align	5
+			.globl	EXT(dbgCkptLL)
+
+LEXT(dbgCkptLL)
+
 
 			li		r12,0x380								/* Point to output area */
 			li		r1,32									/* Get line size */
@@ -1553,14 +1639,14 @@ ENTRY(dbgCkptLL, TAG_NO_FRAME_USED)
  *			Do Preemption.  Forces a T_PREEMPT trap to allow a preemption to occur.
  */
 
-ENTRY(DoPreemptLL, TAG_NO_FRAME_USED)
+			.align	5
+			.globl	EXT(DoPreemptLL)
+
+LEXT(DoPreemptLL)
 
-			mfsprg	r11,0							/* Get the per_proc address */
-			lwz		r11,PP_TEMPWORK1(r11)			/* Restore the return address */
 			li		r3,T_PREEMPT					/* Set preemption interrupt value */
-			mtlr	r11								/* Restore the LR */
 			stw		r3,saveexception(r13)			/* Modify the exception type to preemption */
-			blr										/* Return to interrupt handler */
+			b		EXT(FCReturn)					; Bye dudes...
 
 			
 /*
@@ -1570,14 +1656,14 @@ ENTRY(DoPreemptLL, TAG_NO_FRAME_USED)
  *			Forces a T_CSWITCH
  */
 
-ENTRY(SwitchContextLL, TAG_NO_FRAME_USED)
+			.align	5
+			.globl	EXT(SwitchContextLL)
+
+LEXT(SwitchContextLL)
 
-			mfsprg	r11,0							/* Get the per_proc address */
-			lwz		r11,PP_TEMPWORK1(r11)			/* Restore the return address */
 			li		r3,T_CSWITCH					/* Set context switch value */
-			mtlr	r11								/* Restore the LR */
 			stw		r3,saveexception(r13)			/* Modify the exception type to switch context */
-			blr										/* Return to interrupt handler */
+			b		EXT(FCReturn)					; Bye dudes...
 
 			
 /*
@@ -1585,92 +1671,106 @@ ENTRY(SwitchContextLL, TAG_NO_FRAME_USED)
  *			Forces a T_INTERRUPT trap to pretend that an actual I/O interrupt occurred.
  */
 
-ENTRY(CreateFakeIOLL, TAG_NO_FRAME_USED)
+			.align	5
+			.globl	EXT(CreateFakeIOLL)
+
+LEXT(CreateFakeIOLL)
 
-			mfsprg	r11,0							/* Get the per_proc address */
-			lwz		r11,PP_TEMPWORK1(r11)			/* Restore the return address */
 			li		r3,T_INTERRUPT					/* Set external interrupt value */
-			mtlr	r11								/* Restore the LR */
 			stw		r3,saveexception(r13)			/* Modify the exception type to external */
-			blr										/* Return to interrupt handler */
+			b		EXT(FCReturn)					; Bye dudes...
 			
 /*
  *			Create a shutdown context
  *			Forces a T_SHUTDOWN trap.
  */
 
-ENTRY(CreateShutdownCTXLL, TAG_NO_FRAME_USED)
+			.align	5
+			.globl	EXT(CreateShutdownCTXLL)
+
+LEXT(CreateShutdownCTXLL)
 
-			mfsprg	r11,0							/* Get the per_proc address */
-			lwz		r11,PP_TEMPWORK1(r11)			/* Restore the return address */
 			li		r3,T_SHUTDOWN					/* Set external interrupt value */
-			mtlr	r11								/* Restore the LR */
 			stw		r3,saveexception(r13)			/* Modify the exception type to external */
-			blr										/* Return to interrupt handler */
+			b		EXT(FCReturn)					; Bye dudes...
 			
 /*
  *			Create a fake decrementer 'rupt.  
  *			Forces a T_DECREMENTER trap to pretend that an actual decrementer interrupt occurred.
  */
 
-ENTRY(CreateFakeDECLL, TAG_NO_FRAME_USED)
+			.align	5
+			.globl	EXT(CreateFakeDECLL)
+
+LEXT(CreateFakeDECLL)
 
-			mfsprg	r11,0							/* Get the per_proc address */
-			lwz		r11,PP_TEMPWORK1(r11)			/* Restore the return address */
 			li		r3,T_DECREMENTER				/* Set decrementer interrupt value */
-			mtlr	r11								/* Restore the LR */
 			stw		r3,saveexception(r13)			/* Modify the exception type to external */
-			blr										/* Return to interrupt handler */
+			b		EXT(FCReturn)					; Bye dudes...
 
 /*
  *			Choke the system.  
  */
 
-ENTRY(DoChokeLL, TAG_NO_FRAME_USED)
+			.align	5
+			.globl	EXT(DoChokeLL)
+
+LEXT(DoChokeLL)
 
-			mfsprg	r11,0							; Get the per_proc address 
-			lwz		r11,PP_TEMPWORK1(r11)			; Restore the return address 
 			li		r3,T_CHOKE						; Set external interrupt value
-			mtlr	r11								; Restore the LR 
 			stw		r3,saveexception(r13)			; Modify the exception type to external
-			blr										; Return to interrupt handler 
-			
+			b		EXT(FCReturn)					; Bye dudes...
+
 /*
- *			Set the low level trace flags 
+ *			Null firmware call 
  */
- 
-ENTRY(LLTraceSet, TAG_NO_FRAME_USED)
 
-			mfsprg	r6,2							; Get feature flags 
-			mfmsr	r12								/* Get the MSR */
-			mr		r4,r3							/* Save the new value */
-			andi.	r3,r12,0x01C0					/* Clear interrupts and translation */
-			mtcrf	0x04,r6							; Set the features			
-			bt		pfNoMSRirb,ltsNoMSR				; Use MSR...
+			.align	5
+			.globl	EXT(NullLL)
 
-			mtmsr	r3								; Translation and all off
-			isync									; Toss prefetch
-			b		ltsNoMSRx
-			
-ltsNoMSR:	li		r0,loadMSR						; Get the MSR setter SC
-			sc										; Set it
+LEXT(NullLL)
 
-ltsNoMSRx:
-			
-			lis		r5,hi16(EXT(trcWork))			; Get trace area
-			rlwinm	r12,r12,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-			ori		r5,r5,lo16(EXT(trcWork))		; again
-			
-			lwz		r3,traceMask(r5)				/* Get the old trace flags to pass back */
-			rlwinm	r12,r12,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-			stw		r4,traceMask(r5)				/* Replace with the new ones */
+			li		r3,T_IN_VAIN					; Set to just ignore this one
+			b		EXT(FCReturn)					; Bye dudes...
+
+;
+;			Null firmware call 
+;
+
+			.align	5
+			.globl	EXT(iNullLL)
+
+LEXT(iNullLL)
+
+			mfspr	r4,pmc1							; Get stamp
+			stw		r4,0x6100+(9*16)+0x0(0)			; Save it
+#if 1
+			mfspr	r4,pmc2							; Get stamp
+			stw		r4,0x6100+(9*16)+0x4(0)			; Save it
+			mfspr	r4,pmc3							; Get stamp
+			stw		r4,0x6100+(9*16)+0x8(0)			; Save it
+			mfspr	r4,pmc4							; Get stamp
+			stw		r4,0x6100+(9*16)+0xC(0)			; Save it
+#endif
+			li		r3,T_IN_VAIN					; Set to just ignore this one
+			b		EXT(FCReturn)					; Bye dudes...
 			
-			mtmsr	r12								/* Restore the MSR */
-			isync
+;
+;			Set the low level trace flags 
+;
+ 
+			.align	5
+			.globl	EXT(LLTraceSet)
+
+LEXT(LLTraceSet)
+
+			mr		r4,r3							; Save the new value 
 			
-			blr										/* Leave... */
+			lwz		r3,traceMask(0)					; Get the old trace flags to pass back 
+			stw		r4,traceMask(0)					; Replace with the new ones
+			blr										; Leave... 
 
-#if 1
+#if 0
 	
 /*
 ; ***************************************************************************
@@ -1695,7 +1795,11 @@ ltsNoMSRx:
 #define GDfromright 20
 #define GDfontsize 16
 
-ENTRY(GratefulDeb,TAG_NO_FRAME_USED)
+			.align	5
+			.globl	EXT(GratefulDeb)
+
+LEXT(GratefulDeb)
+
 			mfspr	r6,pir							/* Get the PIR */
 			lis		r5,HIGH_ADDR(EXT(GratefulDebWork))	/* Point to our work area */
 			rlwinm	r6,r6,8,23,23					/* Get part of the offset to our processors area */
@@ -1825,7 +1929,10 @@ GDbailout:	mr		r1,r31							/* Move the workarea base */
  */
 
 
-ENTRY(GratefulDebDisp,TAG_NO_FRAME_USED)
+			.align	5
+			.globl	EXT(GratefulDebDisp)
+
+LEXT(GratefulDebDisp)
 
 			mfmsr	r9								/* Save the current MSR */
 			mflr	r7								/* Save the return */
@@ -1846,22 +1953,26 @@ ENTRY(GratefulDebDisp,TAG_NO_FRAME_USED)
  */
 
 
-ENTRY(checkNMI,TAG_NO_FRAME_USED)
+			.align	5
+			.globl	EXT(checkNMI)
+
+LEXT(checkNMI)
 		
 			mfmsr	r9								/* Save it */
 			andi.	r8,r9,0x7FCF					/* Clear it */
 			mtmsr	r8								/* Disable it */
 			isync									/* Fence it */
 			lis		r7,0xF300						/* Find it */
+			lis		r2,hi16(MASK(MSR_VEC))			; Get the vector enable 
 			ori		r7,r7,0x0020					/* Find it */
+			ori		r2,r2,lo16(MASK(MSR_FP))		; Get the FP enable 
 			dcbi	0,r7							/* Toss it */
 			sync									/* Sync it */
-			rlwinm	r9,r9,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
+			andc	r9,r9,r2						; Clear VEC and FP enables
 			eieio									/* Get it */
 			lwz		r6,0x000C(r7)					/* Check it */
 			eieio									/* Fence it */
 			dcbi	0,r7							/* Toss it */
-			rlwinm	r9,r9,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
 			rlwinm.	r4,r6,0,19,19					/* Check it */
 			rlwinm	r6,r6,0,20,18					/* Clear it */
 			sync									/* Sync it */
@@ -1884,193 +1995,6 @@ xnonmi:												/* Label it */
 			isync									/* Hold it */
 			blr										/* Return from it */
 
-
-/*
- *			Early debug code
- */
- 
-dumpr7:		lis		r9,HIGH_ADDR(hexTab)	/* (TEST/DEBUG) */
-			li		r5,8					/* (TEST/DEBUG) */
-			ori		r9,r9,LOW_ADDR(hexTab)	/* (TEST/DEBUG) */
-
-dumpr7n:	rlwinm	r7,r7,4,0,31		/* (TEST/DEBUG) */
-			mr		r6,r7				/* (TEST/DEBUG) */
-			andi.	r6,r6,15			/* (TEST/DEBUG) */
-			lbzx	r6,r9,r6			/* (TEST/DEBUG) */
-			lis		r10,0xF301			/* (TEST/DEBUG) */
-			ori		r10,r10,0x2000		/* (TEST/DEBUG) */
-
-#if 0
-xqrw2:		eieio						/* (TEST/DEBUG) */
-			lbz		r7,0(r10)			/* (TEST/DEBUG) */
-			dcbi	0,r10				/* (TEST/DEBUG) */
-			sync						/* (TEST/DEBUG) */
-			andi.	r7,r7,0x04			/* (TEST/DEBUG) */
-			beq		xqrw2				/* (TEST/DEBUG) */
-#endif
-			
-			dcbf	0,r10				/* (TEST/DEBUG) */
-			sync						/* (TEST/DEBUG) */
-			dcbi	0,r10				/* (TEST/DEBUG) */
-			eieio						/* (TEST/DEBUG) */
-			stb		r6,4(r10)			/* (TEST/DEBUG) */
-			
-			lis		r6,10				/* (TEST/DEBUG) */
-dumpr7d:	addi	r6,r6,-1			/* (TEST/DEBUG) */
-			mr.		r6,r6				/* (TEST/DEBUG) */
-			bne-	dumpr7d				/* (TEST/DEBUG) */
-			dcbf	0,r10				/* (TEST/DEBUG) */
-			sync						/* (TEST/DEBUG) */
-			dcbi	0,r10				/* (TEST/DEBUG) */
-			eieio						/* (TEST/DEBUG) */
-		
-			addic.	r5,r5,-1			/* (TEST/DEBUG) */
-			bne+	dumpr7n				/* (TEST/DEBUG) */
-
-			blr							/* (TEST/DEBUG) */
-
-;			
-;			Log a special entry in physical memory.
-;			This assumes that memory size has been significantly lowered using
-;			the maxmem boot option. The buffer starts just after the end of mem_size.
-;
-;			This is absolutely for special tracing cases. Do not ever leave in...
-;
-
-ENTRY(dbgLog,TAG_NO_FRAME_USED)
-
-			li		r11,0				; Clear callers callers callers return
-			li		r10,0				; Clear callers callers callers callers return
-			li		r9,0				; Clear callers callers callers callers callers return
-			lwz		r2,0(r1)			; Get callers callers stack frame
-			lis		r0,0x4000			; First invalid address
-			lwz		r12,8(r2)			; Get our callers return
-			lwz		r2,0(r2)			; Back chain
-
-			mr.		r2,r2				; End of chain?
-			cmplw	cr1,r2,r0			; Valid kernel address?
-			beq-	nosavehere			; Yes, end of chain...
-			bge-	cr1,nosavehere		; No...
-			lwz		r11,8(r2)			; Get our callers return
-			lwz		r2,0(r2)			; Back chain
-
-			mr.		r2,r2				; End of chain?
-			cmplw	cr1,r2,r0			; Valid kernel address?
-			beq-	nosavehere			; Yes, end of chain...
-			bge-	cr1,nosavehere		; No...
-			lwz		r10,8(r2)			; Get our callers return
-			lwz		r2,0(r2)			; Back chain
-
-			mr.		r2,r2				; End of chain?
-			cmplw	cr1,r2,r0			; Valid kernel address?
-			beq-	nosavehere			; Yes, end of chain...
-			bge-	cr1,nosavehere		; No...
-			lwz		r9,8(r2)			; Get our callers return
-
-nosavehere:	mfmsr	r8					; Get the MSR	
-			lis		r2,hi16(EXT(DebugWork))	; High part of area
-			lis		r7,hi16(EXT(mem_actual))	; High part of actual
-			andi.	r0,r8,0x7FCF		; Interrupts and translation off
-			ori		r2,r2,lo16(EXT(DebugWork))	; Get the entry
-			mtmsr	r0					; Turn stuff off
-			ori		r7,r7,lo16(EXT(mem_actual))	; Get the actual
-			isync
-		
-			lwz		r0,4(r2)			; Get the flag
-			mr.		r0,r0				; Should we log?
-			lwz		r0,0(r7)			; Get the end of memory
-			lwz		r7,0(r2)			; Get the position
-			bne-	waytoofar			; No logging...
-			mr.		r7,r7				; Is this the first? 
-			bne+	gotspot				; Nope...
-			
-			lis		r7,hi16(EXT(mem_size))	; High part of defined memory
-			ori		r7,r7,lo16(EXT(mem_size))	; Low part of defined memory
-			lwz		r7,0(r7)			; Make it end of defined
-			
-gotspot:	cmplw	r7,r0				; Do we fit in memory
-			addi	r0,r7,0x0020		; Next slot
-			bge-	waytoofar			; No fit...
-			
-			stw		r0,0(r2)			; Set next time slot
-			dcbz	0,r7				; Zap it
-			
-			stw		r3,0(r7)			; First data
-			li		r3,32				; Disp to next line
-			stw		r4,4(r7)			; Second data
-			dcbz	r3,r7				; Zap it
-			stw		r5,8(r7)			; Third data
-			stw		r6,12(r7)			; Fourth data
-			
-			stw		r12,16(r7)			; Callers callers
-			stw		r11,20(r7)			; Callers callers caller
-			stw		r10,24(r7)			; Callers callers callers caller
-			stw		r9,28(r7)			; Callers callers callers callers caller
-
-waytoofar:	mtmsr	r8					; Back to normal
-			isync
-			blr
-
-;
-;			Same as the other, but no traceback and 16 byte entry
-;			Trashes R0, R2, R10, R12
-;
-
-			.align	5
-			.globl	EXT(dbgLog2)
-
-LEXT(dbgLog2)
-
-
-			mfmsr	r10					; Get the MSR	
-			lis		r2,hi16(EXT(DebugWork))	; High part of area
-			lis		r12,hi16(EXT(mem_actual))	; High part of actual
-			andi.	r0,r10,0x7FCF		; Interrupts and translation off
-			ori		r2,r2,lo16(EXT(DebugWork))	; Get the entry
-			mtmsr	r0					; Turn stuff off
-			ori		r12,r12,lo16(EXT(mem_actual))	; Get the actual
-			isync
-		
-			lwz		r0,4(r2)			; Get the flag
-			mr.		r0,r0				; Should we log?
-			lwz		r0,0(r12)			; Get the end of memory
-			lwz		r12,0(r2)			; Get the position
-			bne-	waytoofar2			; No logging...
-			mr.		r12,r12				; Is this the first? 
-			bne+	gotspot2			; Nope...
-			
-			lis		r12,hi16(EXT(mem_size))	; High part of defined memory
-			ori		r12,r12,lo16(EXT(mem_size))	; Low part of defined memory
-			lwz		r12,0(r12)			; Make it end of defined
-			
-gotspot2:	cmplw	cr1,r12,r0			; Do we fit in memory
-			rlwinm.	r0,r12,0,27,27		; Are we on a new line?
-			bge-	cr1,waytoofar2		; No fit...
-			addi	r0,r12,0x0010		; Next slot
-			
-			bne+	nonewline			; Not on a new line...
-			dcbz	br0,r12				; Clear it so we do not fetch it
-			
-nonewline:	cmplwi	r3,68				; Special place for time stamp?
-			
-			stw		r0,0(r2)			; Set next time slot
-			bne+	nospcts				; Nope...
-
-			lwz		r0,0x17C(br0)		; Get special saved time stamp
-			b		nospctt				; Skip...
-			
-nospcts:	mftb	r0					; Get the current time
-						
-nospctt:	stw		r3,4(r12)			; First data
-			stw		r4,8(r12)			; Second data
-			stw		r5,12(r12)			; Third data
-			stw		r0,0(r12)			; Time stamp
-
-waytoofar2:	mtmsr	r10					; Back to normal
-			isync
-			blr
-
-
 ;
 ;			Saves floating point registers
 ;
@@ -2080,13 +2004,19 @@ waytoofar2:	mtmsr	r10					; Back to normal
 
 LEXT(stFloat)
 
-			mfmsr	r0					; Save the MSR
-			rlwinm	r0,r0,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-			rlwinm	r0,r0,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-			rlwinm	r4,r0,0,MSR_EE_BIT,MSR_EE_BIT	; Turn off interruptions
-			ori		r4,r4,lo16(MASK(MSR_FP))	; Enable floating point
+			lis		r2,hi16(MASK(MSR_VEC))			; Get the vector enable 
+			li		r4,0
+			ori		r2,r2,lo16(MASK(MSR_FP))		; Get the FP enable 
+			ori		r4,r4,lo16(MASK(MSR_EE))		; Get the EE bit
+
+			mfmsr	r0								; Save the MSR
+
+			andc	r4,r0,r4						; Clear EE
+			ori		r4,r4,lo16(MASK(MSR_FP))		; Enable floating point
 			mtmsr	r4
 			isync
+
+			andc	r0,r0,r2						; Clear VEC and FP enables
 			
 			stfd	f0,0x00(r3)
 			stfd	f1,0x08(r3)
@@ -2137,6 +2067,10 @@ LEXT(stFloat)
 
 LEXT(stVectors)
 
+			lis		r2,hi16(MASK(MSR_VEC))			; Get the vector enable 
+			li		r4,0
+			ori		r2,r2,lo16(MASK(MSR_FP))		; Get the FP enable 
+			ori		r4,r4,lo16(MASK(MSR_EE))		; Get the EE bit
 			
 			mfsprg	r6,2				; Get features
 			mr		r5,r3				; Save area address
@@ -2145,13 +2079,15 @@ LEXT(stVectors)
 			beqlr-						; No...
 			
 			mfmsr	r0					; Save the MSR
-			rlwinm	r0,r0,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-			rlwinm	r0,r0,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-			rlwinm	r4,r0,0,MSR_EE_BIT,MSR_EE_BIT	; Turn off interruptions
+	
+			andc	r4,r0,r4			; Clear EE
+
 			oris	r4,r4,hi16(MASK(MSR_VEC))	; Enable vectors
 			mtmsr	r4
 			isync
 			
+			andc	r0,r0,r2			; Clear FP and VEC
+			
 			stvxl	v0,0,r5
 			addi	r5,r5,16
 			stvxl	v1,0,r5
@@ -2235,10 +2171,16 @@ LEXT(stVectors)
 
 LEXT(stSpecrs)
 
+
+			lis		r2,hi16(MASK(MSR_VEC))			; Get the vector enable 
+			li		r4,0
+			ori		r2,r2,lo16(MASK(MSR_FP))		; Get the FP enable 
+			ori		r4,r4,lo16(MASK(MSR_EE))		; Get the EE bit
+
+
 			mfmsr	r0					; Save the MSR
-			rlwinm	r0,r0,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-			rlwinm	r0,r0,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-			rlwinm	r4,r0,0,MSR_EE_BIT,MSR_EE_BIT	; Turn off interruptions
+			andc	r0,r0,r2			; Turn of VEC and FP
+			andc	r4,r0,r4			; And EE
 			mtmsr	r4
 			isync
 			
@@ -2302,9 +2244,6 @@ stSnsr:		mfsrin	r6,r5
 			addi	r4,r4,4
 			bne+	stSnsr
 
-			cmplwi	cr1,r12,PROCESSOR_VERSION_604e		
-			cmplwi	cr5,r12,PROCESSOR_VERSION_604ev
-			cror	cr1_eq,cr1_eq,cr5_eq			; Set if 604 type
 			cmplwi	r12,PROCESSOR_VERSION_750
 			mfspr	r4,hid0
 			stw		r4,(39*4)(r3)
@@ -2313,15 +2252,13 @@ stSnsr:		mfsrin	r6,r5
 			li		r5,0
 			li		r6,0
 			li		r7,0
-			beq-	cr1,before750
-			blt-	before750
 			
 			mfspr	r4,hid1
 			mfspr	r5,l2cr
 			mfspr	r6,msscr0
 			mfspr	r7,msscr1
 
-before750:	stw		r4,(40*4)(r3)
+			stw		r4,(40*4)(r3)
 			stw		r6,(42*4)(r3)
 			stw		r5,(41*4)(r3)
 			stw		r7,(43*4)(r3)
@@ -2336,7 +2273,6 @@ isis750:	stw		r4,0(r3)
 			li		r5,0
 			li		r6,0
 			li		r7,0
-			beq-	cr1,b4750
 			blt-	b4750
 			
 			mfspr	r4,thrm1
@@ -2350,9 +2286,11 @@ b4750:		stw		r4,(44*4)(r3)
 			stw		r7,(47*4)(r3)
 			
 			li		r4,0
+			li		r6,0
 			cmplwi	r12,PROCESSOR_VERSION_7400
 			bne		nnmax
 			
+			mfspr	r6,dabr
 			mfpvr	r5
 			rlwinm	r5,r5,0,16,31
 			cmplwi	r5,0x1101
@@ -2363,8 +2301,167 @@ b4750:		stw		r4,(44*4)(r3)
 gnmax:		mfspr	r4,1016
 
 nnmax:		stw		r4,(48*4)(r3)
+			stw		r6,(49*4)(r3)
 			
 			mtmsr	r0
 			isync
 
 			blr
+
+
+;
+;			fwEmMck - this forces the hardware to emulate machine checks
+;			Only valid on 64-bit machines
+;			Note: we want interruptions disabled here
+;
+
+			.globl	EXT(fwEmMck)
+			
+			.align	5
+
+LEXT(fwEmMck)
+
+
+			rlwinm	r3,r3,0,1,0						; Copy low of high high - scomd
+			rlwinm	r5,r5,0,1,0						; Copy low of high high - hid1
+			rlwinm	r7,r7,0,1,0						; Copy low of high high - hid4
+			rlwimi	r3,r4,0,0,31					; Copy low of low low
+			rlwimi	r5,r6,0,0,31					; Copy low of low low
+			rlwimi	r7,r8,0,0,31					; Copy low of low low
+
+			lis		r9,3							; Start forming hid1 error inject mask
+			lis		r10,hi16(0x01084083)			; Start formaing hid4 error inject mask
+			ori		r9,r9,0xC000					; Next bit
+			ori		r10,r10,lo16(0x01084083)		; Next part
+			sldi	r9,r9,32						; Shift up high
+			sldi	r10,r10,8						; Shift into position
+			
+			mfspr	r0,hid1							; Get hid1
+			mfspr	r2,hid4							; and hid4
+			
+			and		r5,r5,r9						; Keep only error inject controls - hid1
+			and		r7,r7,r10						; Keep only error inject controls - hid4
+			
+			andc	r0,r0,r9						; Clear error inject controls hid1
+			andc	r2,r2,r10						; Clear error inject controls hid4
+			
+			or		r0,r0,r5						; Add in the new controls hid1
+			or		r2,r2,r7						; Add in the new controls hid4
+			
+/* ? */
+#if 0
+			lis		r12,CoreErrI					; Get the error inject controls
+			sync
+
+			mtspr	scomd,r3						; Set the error inject controls
+			mtspr	scomc,r12						; Request error inject
+			mfspr	r11,scomc						; Get back the status (we just ignore it)
+#endif
+			sync
+			isync							
+			
+			mtspr	hid1,r0							; Move in hid1 controls
+			mtspr	hid1,r0							; We need to do it twice
+			isync
+			
+			sync
+			mtspr	hid4,r2							; Move in hid4 controls
+			isync
+			
+			blr										; Leave...
+
+;
+;			fwSCOMrd - read/write SCOM
+;
+			.align	5
+			.globl	EXT(fwSCOM)
+
+LEXT(fwSCOM)
+
+			lhz		r12,scomfunc(r3)				; Get the function
+			lwz		r4,scomreg(r3)					; Get the register
+			rldicr	r4,r4,8,47						; Position for SCOM
+
+			mr.		r12,r12							; See if read or write
+			bne		fwSCwrite						; Go do a write
+
+			mfsprg	r0,2							; Get the feature flags
+			ori		r4,r4,0x8000					; Set to read data
+			rlwinm.	r0,r0,pfSCOMFixUpb+1,31,31		; Set shift if we need a fix me up
+			sync
+
+			mtspr	scomc,r4						; Request the register
+			mfspr	r11,scomd						; Get the register contents
+			mfspr	r10,scomc						; Get back the status
+			sync
+			isync							
+
+			sld		r11,r11,r0						; Fix up if needed
+			
+			std		r11,scomdata(r3)				; Save result
+			eieio
+			std		r10,scomstat(r3)				; Save status
+
+			blr
+
+fwSCwrite:	ld		r5,scomdata(r3)					; Get the data
+			
+			sync
+
+			mtspr	scomd,r5						; Set the data
+			mtspr	scomc,r4						; Set it
+			mfspr	r10,scomc						; Get back the status
+			sync
+			isync							
+
+			std		r10,scomstat(r3)				; Save status
+			
+			blr
+
+;
+;			diagTrap - this is used to trigger checks from user space
+;			any "twi 31,r31,0xFFFx" will come here (x = 0 to F).
+;			On entry R3 points to savearea.
+;			R4 is the "x" from instruction;
+;			Pass back 1 to no-op twi and return to user
+;			Pass back 0 to treat as normal twi.
+;
+
+			.globl	EXT(diagTrap)
+			
+			.align	5
+
+LEXT(diagTrap)
+
+			li		r3,0							; Ignore TWI
+			blr										; Leave...
+
+
+
+
+;
+;			setPmon - this is used to manipulate MMCR0 and MMCR1
+
+			.globl	EXT(setPmon)
+			
+			.align	5
+
+LEXT(setPmon)
+
+			li		r0,0
+			isync
+			mtspr	mmcr0,r0						; Clear MMCR0
+			mtspr	mmcr1,r0						; Clear MMCR1
+			mtspr	pmc1,r0
+			mtspr	pmc2,r0
+			mtspr	pmc3,r0
+			mtspr	pmc4,r0
+
+			isync
+
+			mtspr	mmcr0,r3						; Set MMCR0
+			mtspr	mmcr1,r4						; Set MMCR1
+			isync
+			blr										; Leave...
+
+
diff --git a/osfmk/ppc/FirmwareC.c b/osfmk/ppc/FirmwareC.c
index a8b7355e0..a2e9bd5f3 100644
--- a/osfmk/ppc/FirmwareC.c
+++ b/osfmk/ppc/FirmwareC.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -39,11 +42,9 @@
 #include <ppc/proc_reg.h>
 #include <ppc/mem.h>
 #include <ppc/pmap.h>
-#include <ppc/pmap_internals.h>
 #include <ppc/new_screen.h>
 #include <ppc/Firmware.h>
 #include <ppc/mappings.h>
-//#include <pexpert/ppc/powermac.h>
 #include <pexpert/pexpert.h>
 #include <ddb/db_output.h>
 
@@ -265,11 +266,11 @@ void GratefulDebInit(bootBumbleC *boot_video_info) {	/* Initialize the video deb
 		GratefulDebWork[i].GDdepth = boot_video_info->v_depth;
 		GratefulDebWork[i].GDcollgn = nrmlgn;
 	
-//		RuptCtrs[(48*i)+47].timed = gPEClockFrequencyInfo.bus_clock_rate_hz >> 6;	/* (Update every 16th of a second (16 fps) */
-		RuptCtrs[(48*i)+47].timed = gPEClockFrequencyInfo.bus_clock_rate_hz >> 5;	/* (Update every 8th of a second (8 fps) */
-//		RuptCtrs[(48*i)+47].timed = gPEClockFrequencyInfo.bus_clock_rate_hz >> 4;	/* (Update every 4th of a second (4 fps) */
-//		RuptCtrs[(48*i)+47].timed = gPEClockFrequencyInfo.bus_clock_rate_hz >> 3;	/* (Update every 2th of a second (2 fps) */
-//		RuptCtrs[(48*i)+47].timed = gPEClockFrequencyInfo.bus_clock_rate_hz >> 2;	/* (Update every 1 second (1 fps) */
+//		RuptCtrs[(48*i)+47].timed = gPEClockFrequencyInfo.timebase_frequency_hz >> 4;	/* (Update every 16th of a second (16 fps) */
+		RuptCtrs[(48*i)+47].timed = gPEClockFrequencyInfo.timebase_frequency_hz >> 3;	/* (Update every 8th of a second (8 fps) */
+//		RuptCtrs[(48*i)+47].timed = gPEClockFrequencyInfo.timebase_frequency_hz >> 2;	/* (Update every 4th of a second (4 fps) */
+//		RuptCtrs[(48*i)+47].timed = gPEClockFrequencyInfo.timebase_frequency_hz >> 1;	/* (Update every 2th of a second (2 fps) */
+//		RuptCtrs[(48*i)+47].timed = gPEClockFrequencyInfo.timebase_frequency_hz >> 0;	/* (Update every 1 second (1 fps) */
 		
 		sync();
 		
@@ -278,4 +279,7 @@ void GratefulDebInit(bootBumbleC *boot_video_info) {	/* Initialize the video deb
 
 }
 
-
+void debugNoop(void);
+void debugNoop(void) {								/* This does absolutely nothing */
+	return;
+}
diff --git a/osfmk/ppc/FirmwareCalls.h b/osfmk/ppc/FirmwareCalls.h
index 61fdb6b52..e404ade79 100644
--- a/osfmk/ppc/FirmwareCalls.h
+++ b/osfmk/ppc/FirmwareCalls.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -60,9 +63,8 @@
 			fwCallEnt(dbgRegsCall, dbgRegsLL)				/* Dumps all registers */
 			fwCallEnt(CreateFakeDECCall, CreateFakeDECLL)	/* Make a fake decrementer interruption */
 			fwCallEnt(CreateShutdownCTXCall, CreateShutdownCTXLL)	/* create a shutdown context */
-#if PERF_HIST
-			fwCallEnt(PerfCtlCall, PerfCtlLL)				/* Control performance monitor */
-#endif
+			fwCallEnt(NullCall, NullLL)						/* Null Firmware call */
+			fwCallEnt(iNullCall, iNullLL)					/* Instrumented null Firmware call */
 
 #endif	/* _FIRMWARECALLS_H_ */
 
diff --git a/osfmk/ppc/MPinterfaces.s b/osfmk/ppc/MPinterfaces.s
index 56bc2b510..b428d1129 100644
--- a/osfmk/ppc/MPinterfaces.s
+++ b/osfmk/ppc/MPinterfaces.s
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ppc/Makefile b/osfmk/ppc/Makefile
index e9bdc4758..fbef39c9c 100644
--- a/osfmk/ppc/Makefile
+++ b/osfmk/ppc/Makefile
@@ -8,25 +8,23 @@ include $(MakeInc_cmd)
 include $(MakeInc_def)
 
 
-DATAFILES = \
-	asm.h machlimits.h 
-
 EXPORT_ONLY_FILES = 		\
 	asm.h 			\
+	cpu_capabilities.h	\
 	cpu_number.h		\
 	lock.h			\
 	hw_lock_types.h		\
 	io_map_entries.h	\
 	proc_reg.h		\
-	machine_routines.h		\
+	machine_routines.h	\
 	Diagnostics.h		\
 	savearea.h		\
 	mappings.h
 
-INSTALL_MD_LIST = ${DATAFILES}
-
 INSTALL_MD_DIR = ppc
 
+INSTALL_MD_LCL_LIST = cpu_capabilities.h
+
 EXPORT_MD_LIST = ${EXPORT_ONLY_FILES}
 
 EXPORT_MD_DIR = ppc
diff --git a/osfmk/ppc/POWERMAC/dbdma.c b/osfmk/ppc/POWERMAC/dbdma.c
index 224fe15fc..8d7101b2c 100644
--- a/osfmk/ppc/POWERMAC/dbdma.c
+++ b/osfmk/ppc/POWERMAC/dbdma.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ppc/POWERMAC/dbdma.h b/osfmk/ppc/POWERMAC/dbdma.h
index 7cf4d8358..b1d88470a 100644
--- a/osfmk/ppc/POWERMAC/dbdma.h
+++ b/osfmk/ppc/POWERMAC/dbdma.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ppc/POWERMAC/mp/MPPlugIn.h b/osfmk/ppc/POWERMAC/mp/MPPlugIn.h
deleted file mode 100644
index 07cf468b6..000000000
--- a/osfmk/ppc/POWERMAC/mp/MPPlugIn.h
+++ /dev/null
@@ -1,346 +0,0 @@
-/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
- *
- * @APPLE_LICENSE_HEADER_START@
- * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
- * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
- * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
- * 
- * @APPLE_LICENSE_HEADER_END@
- */
-/*
- * @OSF_FREE_COPYRIGHT@
- */
-/*
- * @APPLE_FREE_COPYRIGHT@
- */
-
-/*
-	MPPlugIn.h
-
-	Herein we find all the global MP plugin stuff
-
-	Lovingly crafted by Bill Angell using traditional methods
-
-*/
-
-
-/*
- *	External hook completion codes
- *
- *	The MP plugin's external interrupt hook returns one of these codes
- */
-
-#define kMPVainInterrupt 0							/* Interruption in vain -- ignore it */
-#define kMPIOInterruptPending 1						/* This is an I/O interruption -- handle it */
-#define kMPSignalPending 2							/* This is a pending signal -- handle it */
-
-
-/* ***********************************************************************
- * Entry point jump table entry numbers
- * *********************************************************************** */
-
-#define kCountProcessors 		0
-#define kStartProcessor 		1					/* ->cpu address, ->start address, ->pass-thru parm */
-#define kResumeProcessor 		2					/* ->cpu address */
-#define kStopProcessor 			3					/* ->cpu address */
-#define kResetProcessor 		4					/* ->cpu address */
-#define kSignalProcessor 		5					/* ->cpu address */
-#define kStoreProcessorStatus 	6					/* ->cpu address, ->status area address */
-#define kSynchClock 			7					/* ->cpu address */
-#define kExternalHook 			8					/* no parms */
-#define kProcessorState 		9					/* ->cpu address */
-#define kRunSIGPRun 			10					/* no parms */
-#define kPhoneyFirmware			11					/* Dummy kernel for alternate processors */
-	
-#define kMPPlugInMaxCall 		11					/* set MPPlugInMaxCall to the highest-numbered call */
-
-
-/* ***********************************************************************
- *	MP Plug-In specification
- *
- *	The address of this area is passed to the MP plugin by the initialization code. If the
- *	version ID and the installed hardware match the MP plugin, it returns its memory
- *	requirements and a table of offsets to its entry points.
- * *********************************************************************** */
-
-#define kMPPlugInVersionID		1
-
-#define kSIGPUninitializedState	0
-#define kSIGPResetState			1
-#define kSIGPStoppedState		2
-#define kSIGPOperatingState		3
-#define kSIGPErrorState			4
-
-#define kSIGPnoErr				0
-#define kSIGPInvalidStateErr	-3999
-#define kSIGPInterfaceBusyErr	-3998
-#define kSIGPPrivilegeErr		-3997
-#define kSIGPNoPlugInErr		-3996
-#define kTimeBaseSynchronizationErr		-3995
-#define kSIGPTargetAddrErr		-3994
-#define kSIGPInvalidStatusErr	-3993
-
-#define kMPPlugInInstallFailed	-4999
-#define kMPPlugInInternalError	-4998
-
-/* 
- * ***********************************************************************
- *	Signal processor request codes
- * ***********************************************************************
- */
-
-#define SIGPast					0					/* Requests an ast on target processor */
-#define SIGPptlb				1					/* Requests a total purge of the TLB */
-#define SIGPkdb					2					/* Requests a KDB entry */
-
-/* 
- * ***********************************************************************
- *	Temporary debugging error codes (well, at least as temporary as the income tax)
- * ***********************************************************************
- */
-#define kMPPHairyPalms			-10002
-#define kMPPOffline				-10003
-#define kMPPBadState			-10004
-#define kMPPInvalCPU			-10005
-#define kMPPCantLock			-10006
-#define kMPPNotReady			-10007
-#define kMPPNotStopped			-10008
-#define kMPPBadCPU				-10009
-#define kMPPOnly1CPU			-10010
-#define kMPPBadVers				-10011
-#define kMPPNotRunning			-10012
-#define kMPPTimeOut				-10013
-#define kMPPInitTO1				-10014
-#define kMPPInitTO2				-10015
-#define kMPPInitTO3				-10016
-
-
-/* 
- * ***********************************************************************
- *	Let's define some hardware stuff
- * ***********************************************************************
- */
- 
-#define Bandit1			0xF2000000
-#define PCI1AdrReg		0xF2800000
-#define GrandCentral	0xF3000000
-#define EtherNetROM		0xF3019000
-#define HammerHead		0xF8000000
-#define ArbConfig		0x0090
-#define TwoCPU			0x02
-#define WhoAmI			0x00B0
-#define PriCPU			0x10
-#define SecCPU			0x08
-#define IntReg			0x00C0
-#define SecInt			0x80
-
-
-/* 
- * ***********************************************************************
- *	Let's define the flags for MPPInterface
- * ***********************************************************************
- */
-
-#define SpinTimeOut		30000000
-
-#define MPPICmsgp		0xc0000000					/* Message pending (busy + pass) */
-#define MPPICBusy		0x80000000					/* Processor area busy, i.e., locked */
-#define MPPICPass		0x40000000					/* Busy lock passed to receiving processor */
-#define MPPICOnline		0x20000000					/* Processor is online */
-#define MPPICReady		0x10000000					/* Processor is ready, i.e., started, not reset */
-#define MPPICStop		0x08000000					/* Processor is stopped */
-#define MPPICBset		0x000000FF					/* Processor that owns busy, i.e., the ID of */
-													/*   whomever set busy. When a busy is passed, */
-													/*   this is the requestor of the function. */
-#define MPPICfunc		0x0000FF00					/* Current function */
-#define MPPICfIdle		0x00						/* No function pending */
-#define MPPICfStrt		0x01						/* Start the processor, physical address in  */
-													/*   MPPIParm0 */
-#define MPPICfResm		0x02						/* Resume a stopped processor */
-#define MPPICfStop		0x03						/* Stop a processor */
-#define MPPICfSigp		0x04						/* Signal a processor */
-#define MPPICfStat		0x05						/* Store the processor machine state -  */
-													/*   physical address of response in MPPIParm0 */
-#define MPPICfTBsy		0x06						/* Synchronize timebase - */
-													/*   TB image in MPPIParm0 and MPPIParm1 */
-#define MPPICfReset		0x07						/* Reset the processor */
-#define MPPICfTBsy1		0x81						/* TB sync, phase 1 */
-#define MPPICfTBsy2		0x82						/* TB sync, phase 2 */
-#define MPPICSigp		0x80000000					/* Processor has signal pending (keep signal status when stopped) */
-#define MPPICXRun		0x40000000					/* Explicit SIGP run call */
-
-
-                       
-#ifndef __ASSEMBLER__
-
-typedef unsigned char	CPUState;
-typedef unsigned int	CPUNotification;
-
-struct MPPlugInSpec {								/* This is MPSxxxx for assembler */
-		unsigned int 		versionID;				/* Version ID, must match */
-		unsigned int		*areaAddr;				/* Virtual address of area to be */
-													/*  relocated to physical memory */
-		unsigned int 		areaSize;				/* Size of area to be relocated */
-		unsigned int 		*offsetTableAddr;		/* Virtual address of table of entry offsets */
-		unsigned int		*baseAddr;				/* Common base area - used for debugging */
-		unsigned int		*dataArea;				/* Pointer to the MP workarea - used for debugging */
-		unsigned int		*CPUArea;				/* Pointer to the CPU workarea - used for debugging */
-		unsigned int		*SIGPhandler;			/* Physical address of signal interrupt filter */
-};
-
-typedef struct MPPlugInSpec MPPlugInSpec;
-typedef MPPlugInSpec *MPPlugInSpecPtr;
-
-struct MPEntryPts {	
-		unsigned int		EntAddr[kMPPlugInMaxCall+1];	/* Real addresses of all plugin entry points */
-};
-
-typedef struct MPEntryPts MPEntryPts;
-
-struct SystemRegister {
-		unsigned int		regno;
-		unsigned int		contents;
-};
-
-typedef struct SystemRegister SystemRegister;
-
-typedef struct FPRegs {
-		unsigned int		lo;
-		unsigned int		hi;
-} FPRegs;
-
-struct BATregs {
-		unsigned int		upper;
-		unsigned int		lower;
-};
-
-typedef struct BATregs BATregs;
-
-
-#define kSysRegCount 16
-		
-struct CPUStatusArea {								/*  0000 This is CSAxxxxx for assembler */
-
-/*
- *		Note that this guy always has to be in one-to-one mapped area contiguously
- */
- 
-		CPUState			state;					/*  0000 */
-		unsigned char		regsAreValid;			/*  0001 */
-		unsigned char		filler[2];				/*  0002 */
-		unsigned int		gpr[32];				/*  0004 */
-		FPRegs				fpr[32];				/*  0084 */
-		unsigned int		cr;						/*  0184 */
-		unsigned int		fpscr;					/*  0188 */
-		unsigned int		xer;					/*  018C */
-		unsigned int		lr;						/*  0190 */
-		unsigned int		ctr;					/*  0194 */
-		unsigned int		tbu;					/*  0198 This is rtcu on 601. */
-		unsigned int		tbl;					/*  019C This is rtcl on 601. */
-		unsigned int		pvr;					/*  01A0 */
-		BATregs				ibat[4];				/*  01A4 */
-		BATregs				dbat[4];				/*  01E4 */
-		unsigned int		sdr1;					/*  0224 */
-		unsigned int		sr[16];					/*  0228 */
-		unsigned int		dar;					/*  0268 */
-		unsigned int		dsisr;					/*  026C */
-		unsigned int		sprg[4];				/*  0270 */
-		unsigned int		srr0;					/*  0280 */
-		unsigned int		srr1;					/*  0284 */
-		unsigned int		dec;					/*  0288 */
-		unsigned int		dabr;					/*  028C */
-		unsigned int		iabr;					/*  0290 */
-		unsigned int		ear;					/*  0294 */
-		unsigned int		hid[16];				/*  0298 */
-		unsigned int		mmcr[2];				/*  02D8 */
-		unsigned int		pmc[4];					/*  02E0 */
-		unsigned int		pir;					/*  02F0 */
-		unsigned int		sda;					/*  02F4 */
-		unsigned int		sia;					/*  02F8 */
-		unsigned int		mq;						/*  02FC */
-		
-		unsigned int		msr;					/*  0300 */
-		unsigned int		pc;						/*  0304 */
-		
-		SystemRegister		sysregs[kSysRegCount];	/*  0308 */
-		
-		unsigned int		filler2[6];				/*  0388  Always pad up to 32-byte boundary */
-													/*  03A0 */
-};
-
-typedef struct CPUStatusArea CPUStatusArea;
-typedef CPUStatusArea *CPUStatusAreaPtr;
-
-extern CPUStatusArea CSA[NCPUS];
-
-struct SenseInfo {
-	CPUNotification		notification;
-	CPUState			state;
-};
-
-typedef struct SenseInfo SenseInfo;
-typedef SenseInfo *SenseInfoPtr;
-
-
-struct MPPInterface {
-
-	unsigned int			MPPICStat;						/* Processor status (interlocked update for this one) */
-	unsigned int			MPPICParm0;			/* SIGP parm 0 */
-	unsigned int			MPPICParm1;			/* SIGP parm 1 */
-	unsigned int			MPPICParm2;			/* SIGP parm 2 */
-	unsigned int			MPPICspare0;		/* unused */
-	unsigned int			MPPICspare1;		/* unused */
-	unsigned int			MPPICParm0BU;		/* Parm 0 backed up here at 'rupt time for safe keeping */
-	unsigned int			MPPICPriv;			/* Processor status (interlocked update for this one) */
-};
-
-typedef struct MPPInterface MPPInterface;
-typedef MPPInterface *MPPInterfacePtr;
-
-extern MPPInterface MPPICPUs[];
-
-
-/* ***********************************************************************
- *	Function prototypes and data areas
- * *********************************************************************** */
-
-extern unsigned int	MPgetProcCount	(void);
-extern unsigned int	MPstart			(unsigned int cpu, unsigned int sadr, unsigned int parm);
-extern unsigned int	MPexternalHook	(void);
-extern unsigned int	MPsignal		(unsigned int cpu, unsigned int	SIGPparm);
-extern unsigned int	MPstop			(unsigned int cpu);
-#if 0
-extern unsigned int	MPCPUAddress	(void);
-extern unsigned int	MPresume		(unsigned int cpu);
-extern unsigned int	MPreset			(unsigned int cpu);
-extern unsigned int	MPSense			(unsigned int cpu, unsigned int	*info);
-extern unsigned int	MPstoreStatus	(unsigned int cpu, unsigned int	*statusArea);
-extern unsigned int	MPSetStatus		(unsigned int cpu, unsigned int	*statusArea);
-extern unsigned int	MPgetSignal		(void);
-extern unsigned int	MPsyncTB		(void);
-extern unsigned int	MPcheckPending	(void);
-#endif
-extern int MPinstall		(unsigned int physAddr, unsigned int band1, unsigned int hammerh, unsigned int grandc,
-								unsigned int pci1ar, unsigned int enetr);
-extern unsigned int MPprobe	(MPPlugInSpecPtr spec, unsigned int hammerh);
-
-extern void start_secondary	(void);
-extern void mp_intr	(void);
-
-
-extern MPPlugInSpec	MPspec;							/* An area for the MP interfaces */
-extern MPEntryPts	MPEntries;						/* Real addresses of plugin routines */
-
-#endif /* ndef __ASSEMBLER */
diff --git a/osfmk/ppc/POWERMAC/mp/MP_2p.s b/osfmk/ppc/POWERMAC/mp/MP_2p.s
deleted file mode 100644
index 73c54e0fd..000000000
--- a/osfmk/ppc/POWERMAC/mp/MP_2p.s
+++ /dev/null
@@ -1,2409 +0,0 @@
-/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
- *
- * @APPLE_LICENSE_HEADER_START@
- * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
- * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
- * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
- * 
- * @APPLE_LICENSE_HEADER_END@
- */
-/*
- * @OSF_COPYRIGHT_INTERNAL_USE_ONLY@
- */
-
-/* 																							
- 	MP_2p.s 
-
-	MP low-level signaling, configuration, et all.  This is for a and Apple/Daystar 2p board
-
-	Lovingly crafted by Bill Angell using traditional methods
-
-*/
-
-#include <ppc/asm.h>
-#include <ppc/proc_reg.h>
-#include <ppc/POWERMAC/mp/MPPlugIn.h>
-#include <assym.s>
-#include <mach/machine/vm_param.h>
-
-
-
-			.set	MPPlugInVersion,0						/* Current version code */
-
-/* */
-/*			Interfaces to hardware */
-/* */
-
-			.set	PCI1ARdisp,		0x00800000				/* Displacement from Bandit to PCI1 address configuiration register */
-			.set	GrandCdisp,		0x01000000				/* Displacement from Bandit to Grand Central */
-			.set	EventsReg,		0x20					/* Interruption events register (latched) */
-			.set	LevelsReg,		0x2C					/* Interruption levels register (unlatched) */
-			.set	MaskReg,		0x24					/* Interruption mask register */
-			.set	ClearReg,		0x28					/* Interruption clear register */
-			.set	TicksPerMic,	11						/* We'll use 11 ticks per µS - 120MHz is really 10, 180MHz is 11.24 */
-			.set	EtherNRdisp,	0x01019000				/* Displacement into bandit of EtherNet ROM */
-
-#ifdef	__ELF__
-			.section ".data"
-#else
-			.data
-#endif
-
-			.align	5									/* Get us out to the end */
-
-			.globl MPPIwork
-#ifdef __ELF__
-			.type  MPPIwork,@function
-#endif
-
-MPPIwork:
-MPPIstatus:	.byte	0									/* Global MP board status */
-			.set	MPPIinit,	0x80					/* Global initialization complete */
-			.set	MPPI2Pv2,	0x40					/* Second rev of 2P board (no watchdog and different state machine) */
-			.byte	0									/* Reserved */
-MPPIinst:	.byte	0									/* Mask of CPUs installed */
-MPPIonline:	.byte	0									/* Mask of CPUs online (i.e., initialized) */
-MPPIlogCPU:	.long	0									/* Used to configure CPU addresses */
-MPPITBsync:	.long	0									/* Used to sync time bases */
-			.long	0
-MPPIHammer:	.long	0									/* Address of HammerHead */
-MPPIGrandC:	.long	0									/* Address of GrandCentral */
-MPPIPCI1Adr: .long	0									/* Address of PCI1's config reg addr */
-MPPIEther:	.long	0									/* Address of EtherNet ROM */
-			
-			.align	5
-MPPISncFght: .fill	4,4,0								/* Space for 9 passes of a TB sync fight + 1 guard pass */
-			.fill	4,4,0
-			.fill	4,4,0
-			.fill	4,4,0
-			.fill	4,4,0
-			.fill	4,4,0
-			.fill	4,4,0
-			.fill	4,4,0
-			.fill	4,4,0
-			.fill	4,4,0
- 			.align	7									/* Point to the start of the CPU status */
-
-			.globl EXT(MPPICPUs)
-#ifdef __ELF__
-			.type  EXT(MPPICPUs),@function
-#endif
-EXT(MPPICPUs):												/* Start of Processor specific areas */
-/*			There are 8 of these indexed by processor number */
-
-
-MPPICPU0:	.fill	8,4,0									/* First processor */
-MPPICPU1:	.fill	8,4,0									/* Second processor */
-MPPICPU2:	.fill	8,4,0									/* Third processor */
-MPPICPU3:	.fill	8,4,0									/* Fourth processor */
-			.set	MPPIMaxCPU, (.-EXT(MPPICPUs)-32)/32			/* Get the maximum CPU address */
-
-
-			.text
-
-/******************************************************************************************************** */
-/******************************************************************************************************** */
-/* */
-/*			Here starteth ye stuff */
-/* */
-/******************************************************************************************************** */
-/******************************************************************************************************** */
-
-/******************************************************************************************************** */
-/* */
-/*			Validate that the hardware matches with our code.  At this point, we cannot check */
-/*			for anything other than the possibility of this working.  There's no version code */
-/*			or nothin'.  So, if we have a second processor and are a 604 or 604e, we'll say */
-/*			we're capable.  Also we'll check version codes for our code. */
-/* */
-/*			When we get here, DDAT and IDAT are both on, 'rupts are disabled. */
-/*  */
-/*			We're called like this:  */
-/*				OSStatus MP_probe(MPPlugInSpecPtr spec, UInt32 HammerheadAddr); */
-/* */
-/******************************************************************************************************** */
-
-ENTRY(MPprobe, TAG_NO_FRAME_USED)
-
-			
-MPPIbase:	mfpvr	r7									/* Get the processor version */
-			rlwinm	r7,r7,16,16,31						/* Isolate the processor type */
-
-			lbz		r5,ArbConfig(r4)					/* See if there is another processor */
-			
-			andi.	r5,r5,TwoCPU						/* Are we a real live two processor? */
-			beq		OneWay								/* Nope, we be gone... */
-			
-			cmplwi	cr0,r7,4							/* Are we a 604? */
-			beq		SeemsOK								/* Yeah, we're cool... */
-			cmplwi	cr0,r7,9							/* Are we a 604E? */
-			beq		SeemsOK								/* Yeah, go finish up... */
-			
-OneWay:		li		r3,0								/* Say we can't find the proper CPU */
-			blr											/* Leave... */
-			
-SeemsOK:	mr		r10,r3								/* Save the parameter list */
-			
-			lwz		r4,MPSversionID(r10)				/* Get the version ID */
-			cmplwi	cr0,r4,kMPPlugInVersionID			/* Correct version? */
-			beq		IsOK								/* Yeah, we think we're ok... */
-			
-			li		r3,0								/* Set bad version' */
-			blr											/* Leave... */
-			
-IsOK:		mflr	r11									/* Save the LR */
-			lis		r9,HIGH_ADDR(MPPIwork)				/* Get the top half of the data area */
-			bl		SetBase1							/* Jump to the next instruction */
-SetBase1:	mflr	r12									/* Get the base register */
-			ori		r9,r9,LOW_ADDR(MPPIwork)			/* Get the bottom half of the data area */
-			addi	r12,r12,LOW_ADDR(MPPIbase-SetBase1)	/* Adjust to the start of all our code */
-			
-			stw		r12,MPSbaseAddr(r10)				/* Save off the common base for all functions */
-			
-			la		r5,LOW_ADDR(MPPIFunctions-MPPIbase)(r12)	/* Point to the base of all functions */
-			stw		r5,MPSareaAddr(r10)					/* Pass back the code address */
-			
-			la		r5,LOW_ADDR(MPPIFuncOffs-MPPIbase)(r12)	/* Point to the function offset table */
-			stw		r5,MPSoffsetTableAddr(r10)			/* Pass back the pointer to the offset table */
-			
-			li		r5,LOW_ADDR(MPPISize-MPPIFunctions)	/* Get our size without data area */
-			stw		r5,MPSareaSize(r10)					/* Save it */
-			
-			stw		r9,MPSdataArea(r10)					/* Save it */
-			
-			la		r5,LOW_ADDR(EXT(MPPICPUs)-MPPIwork)(r9)	/* Point to the CPU area base */
-			stw		r5,MPSCPUArea(r10)					/* Save it */
-			
-			mtlr	r11									/* Restore that return address */
-			li		r3,1								/* Set no error */
-			blr											/* Leave, we're all done... */
-
-/******************************************************************************************************** */
-/******************************************************************************************************** */
-/* */
-/*			Here starteth ye code that starteth up ye second prothether. */
-/*			Yea, though ye prothether executeth asynchronously, it appears unto men */
-/*			in ye shape of a synchronous process.  By ye instruction of He who gave it */
-/*			form and being, it stopeth to worship and praise its Lord, to joyously  */
-/*			receive His blessings and teachings, to guide its way along the path to */
-/*			righteous execution. */
-/* */
-/******************************************************************************************************** */
-/******************************************************************************************************** */
-
-
-/******************************************************************************************************** */
-/* */
-/*			Initialize the MP hardware.  This will bring the other processor online. */
-/* */
-/*			First we will tick the board to its 5th state the "TBEN off" state. */
-/* */
-/*			Just for giggles, here's the states: */
-/* */
-/*			1) 1st ROM			- This state exists after motherboard reset */
-/*			2) Open Firmware	- Transitions here when the SecInt line is first asserted */
-/*								  Open Firmware attempts to execute some code on the secondary */
-/*								  processor to obtain the PVR register.  It's got some problems */
-/*								  and hangs the secondary disabled. */
-/*			3) Reset (my name)	- Entered when the SecInt line is deasserted. A timer starts and */
-/*								  468µS later the reset line is pulled.  I may have this wrong here, */
-/*								  it may be that the reset line is held for 468µS.  Either way, */
-/*								  this state is invisible to us. */
-/*			4) 2nd ROM			- This state exists when the secondary processor begins executing */
-/*								  after the reset. */
-/*			5) TBEN off			- We transition here when SecInt is asserted in the 2nd ROM state. */
-/*								  In this state, the TBEN pin is set to disable the timebase from  */
-/*								  running on all processors, thus freezing time. (Performace analysis */
-/*								  note: here would be the best time to run stats, all tests would */
-/*								  run in 0 time giving us infinite speed.) Also the "primary arbitration" */
-/*								  mode is set.  This mode causes the CPU board to arbitrate both processors */
-/*								  using a single bus master.  This gets us around the L2 cache dumbness. */
-/*								  We should also note that because of this, there is now no way to  */
-/*								  tell if we are on the secondary processor, the WhoAmI register will */
-/*								  always indicate the primary processor.  We need to have sewn */
-/*								  name tags into our underwear before now. */
-/*								  Finally, this state is the only way we can tell if we are executing */
-/*								  on the older version of the 2-way board.  When it is in this state */
-/*								  "primary arbitration" has not been enabled yet.  The WhoAmI register */
-/*								  will indicate if we are on the secondary processor on not.  We should */
-/*								  check this because we need to do signals differently. */
-/*			6) TBEN on			- The next assertion of SecInt brings us to our final destination.  For */
-/*								  those of you who will be deplaning, please remember that timebases */
-/*								  are running and primary arbitration is enabled.  Always remember: */
-/*								  buckle up for safety and if you're tired pull over for a rest. */
-/* */
-/******************************************************************************************************** */
-
-ENTRY(MPinstall, TAG_NO_FRAME_USED)
-
-/*			int MP_install(unsigned int *physAddr, unsigned int band1, unsigned int hammerh, unsigned int grandc,
- *			unsigned int pci1ar, unsigned int enetr);
- */
-	
-			lis		r11,HIGH_ADDR(MPPIwork)				/* Get the top half of the data area */
-			mflr	r0									/* Save the LR */
-			ori		r11,r11,LOW_ADDR(MPPIwork)			/* Get the bottom half of the data area */
-			
-			stw		r5,MPPIHammer-MPPIwork(r11)			/* Save the HammerHead address for later */
-			stw		r6,MPPIGrandC-MPPIwork(r11)			/* Save address of Grand Central */
-			stw		r7,MPPIPCI1Adr-MPPIwork(r11)		/* Save the PCI1 address register address */
-			stw		r8,MPPIEther-MPPIwork(r11)			/* Save Ethernet ROM address */
-
-			li		r4,LOW_ADDR(0xC080)					/* Set CPU 0&1 installed, CPU 0 online */
-			lis		r10,(MPPICOnline+MPPICReady)>>16	/* Set CPU 0 online and ready */
-			
-			mfspr	r6,pir								/* Get the PIR contents */
-			
-			sth		r4,MPPIinst-MPPIwork(r11)			/* Set 'em for later */
-			rlwinm	r6,r6,0,0,27						/* Clear to use processor 0 */
-			stw		r10,EXT(MPPICPUs)-MPPIwork(r11)		/* Preset CPU 0 online and ready */
-
-			mtspr	pir,r6								/* Set our PIR */
-
-/* */
-/*			Ok, ok, enough of this.  Let's really start 'em up. */
-/* */
-
-			lis		r9,HIGH_ADDR(CPUInit)				/* Top of init code */
-			li		r6,1								/* Get the other guy's CPU address		 */
-			ori		r9,r9,LOW_ADDR(CPUInit)				/* Get physical address of init code */
-		
-			mfmsr	r8									/* Get the MSR */
-
-			stw		r6,MPPIlogCPU-MPPIwork(r11)			/* Set the logical CPU address to assign */
-						
-			rlwinm	r6,r8,0,17,15						/* Turn off interruptions */
-			sync										/* Make sure the work area is updated */
-			mtmsr	r6									/* Flip the EE bit off */
-			isync										/* Chill a bit */
-			
-			stw		r9,0(r7)							/* Pass the initialization code address to our friend */
-			sync										/* Fence off the pig */
-			
-			li		r6,0								/* Clear this out */
-			stb		r6,IntReg(r5)						/* Kick the other processor */
-			eieio										/* Pig in the sty */
-
-/*			At this point we should be in the "TBEN off" state.  The second processor should be starting */
-/*			to come up. */
-
-/*			Note that we are assuming that the secondary processor will reset the interrupt request. */
-/*			If we are on one of the old boards, we will die in about 256µS if it is not reset, 'cause */
-/*			of that silly watchchihuahua timer.  We can't use the TB or decrimenter here to set a  */
-/*			timeout because when we are in "TBEN off" state these guys don't run. */
-
-			lis		r4,HIGH_ADDR(SpinTimeOut)			/* Get about 1 second at 200MHz */
-														/* At 120 MHz this is 1.66 seconds, at 400MHz it is .5 */
-														/* All these are more than enough time for this handshake */
-			ori		r4,r4,LOW_ADDR(SpinTimeOut)			/* Get the bottom part */
-
-WaitReady:	lwz		r9,0(r7)							/* Get this back */
-			mr.		r9,r9								/* The other processor will set to 0 */
-														/*    when it is ready for the work area address */
-			beq		CodeUp								/* The code is up on the other side */
-			subi	r4,r4,1								/* Count the try */
-			mr.		r4,r4								/* Did we timeout? */
-			bne+	WaitReady							/* Nope... */
-			
-			li		r3,kMPPInitTO1						/* Set that we timed out with initial code bringup */
-			mtmsr	r8									/* Restore the interrupt state */
-			mtlr	r0									/* Restore the return addess */
-			blr											/* Return a failure... */
-
-CodeUp:		isync										/* Make sure we don't prefetch past here */
-			
-/*			Timebase is stopped here, no need for the funky "get time base right" loop */
-
-			mftbu	r4									/* Get upper timebase half */
-			mftb	r9									/* Get bottom  */
-			stw		r4,MPPITBsync-MPPIwork(r11)			/* Save the top */
-			stw		r9,MPPITBsync+4-MPPIwork(r11)		/* Save the second half */
-			sync										/* Be very sure it's there */
-			
-			stw		r11,0(r7)							/* Set the PCI1 adr reg non-zero - this releases the spin */
-														/*	loop and allows the timebase to be set. */
-			eieio
-
-			lis		r9,HIGH_ADDR(SpinTimeOut)			/* Get the spin time */
-			ori		r9,r9,LOW_ADDR(SpinTimeOut)			/* Get the bottom part */
-			
-WaitTBset:	lwz		r4,0(r7)							/* Get this back */
-			mr.		r4,r4								/* When zero, the other guy's TB is set up */
-			beq-	TBSetUp								/* She's'a all done... */
-			subi	r9,r9,1								/* Count the try */
-			mr.		r9,r9								/* Did we timeout? */
-			bne+	WaitTBset							/* Nope... */
-			
-			li		r3,kMPPInitTO3						/* Set that we timed out setting clock */
-			mtmsr	r8									/* Restore the interrupt state */
-			isync
-			mtlr	r0									/* Restore the return addess */
-			blr											/* Return a failure... */
-
-TBSetUp:	stb		r6,IntReg(r5)						/* Kick the other processor again */
-														/* This will tick us to the next state */
-			eieio
-						
-SpinDelay:	addi	r6,r6,1								/* Bump spin count (we finally are trashing R6) */
-			cmplwi	cr0,r6,4096							/* Spun enough? */
-			ble+	SpinDelay							/* Nope... */
-			
-			li		r6,SecInt							/* Set the interrupt bit */
-			stb		r6,IntReg(r5)						/* Deassert the external signal */
-/* */
-/*			Ok, the other processor should be online in a spin waiting for a start signal from */
-/*			us.  It should be in the reset state with no external interruptions pending.  There may */
-/*			be a decrimenter pop waiting in the wings though. */
-/* */
-			
-			lwz		r7,MPPIGrandC-MPPIwork(r11)			/* Point to GrandCentral */
-			lwz		r4,MaskReg(r7)						/* Get the grand central mask register (note that this */
-														/* is a little-endian area, but I'm too lazy to access it that way */
-														/* so I'll document what it really should be, but, probably, it would */
-														/* have been much, much easier just to code up the lwbrx and be done */
-														/* with it rather than producing this monograph describing my alternate */
-														/* access method that I really don't explain anyway. */
-			ori		r4,r4,0x0040						/* Flip on bit 30 (hah, figure that one out).  This enables the */
-														/* Ext10 interrupt which is connected to the MACE ethernet chip's */
-														/* chip-select pin. */
-			stw		r4,MaskReg(r7)						/* Stick it on back */
-			eieio
-			
-			mtlr	r0									/* Get back the original LR */
-			sync										/* Make sure all storage ops are done */
-			mtmsr	r8									/* Restore the MSR */
-			isync
-			li		r3,kSIGPnoErr						/* Set that we worked jest fine and dandy */
-			blr											/* Bye now... */
-
-			.align	5
-/******************************************************************************************************** */
-/******************************************************************************************************** */
-/* */
-/*			This is where the individual SIGP function calls reside.  */
-/*			Also, it is where we cram the second processor's initialization code wo'w we */
-/*			can use physical addressing. */
-/* */
-/******************************************************************************************************** */
-/******************************************************************************************************** */
-
-MPPIFunctions:											/* Start of all externally called functions and interrupt handling code */
-
-
-/******************************************************************************************************** */
-/* */
-/*			Count the number of processors.  This hardwires to 2 (or 1 if no secondary) */
-/* */
-/******************************************************************************************************** */
-
-CountProcessors:
-			lis		r12,HIGH_ADDR(MPPIwork)				/* Get the top half of the data area */
-			mfmsr	r9									/* Get the MSR */
-			ori		r12,r12,LOW_ADDR(MPPIwork)			/* Get the bottom half of the data area */
-			
-			ori		r10,r9,0x0010						/* Turn on DDAT */
-			
-			lwz		r8,MPPIHammer-MPPIwork(r12)			/* Point to the HammerHead controller */
-			
-			mtmsr	r10									/* Turn on DDAT */
-			isync										/* Kill speculation */
-
-			li		r3,2								/* Assume we have them all */
-			lbz		r5,ArbConfig(r8)					/* Check if we've seen a second processor */
-			andi.	r5,r5,TwoCPU						/* Are we a real live two processor? */
-			mtmsr	r9									/* Put back the DDAT */
-			isync
-			
-			bnelr+										/* Yeah... */
-			li		r3,1								/* Nope, set a count of 1 */
-			blr											/* Leave, we're inadequate... */
-
-/******************************************************************************************************** */
-/* */
-/*			Start up the selected processor (R3=processor; R4=physical start address; R5=pass-thru parm) */
-/* */
-/******************************************************************************************************** */
-			
-StartProcessor:
-
-			mr		r7,r5								/* Copy pass-thru parameter */
-			mfspr	r10,pir								/* Get our processor number */
-			rlwinm	r9,r3,5,23,26						/* Get index into CPU array */
-			cmplw	cr0,r3,r10							/* Trying to start ourselves? */
-			lis		r12,HIGH_ADDR(MPPIwork)				/* Get the top half of the data area */
-			cmplwi	cr1,r3,MPPIMaxCPU					/* See if we are bigger than max */
-			li		r3,kMPPHairyPalms					/* Set trying to do it to ourselves */
-			beqlr-										/* Self abuse... */
-			li		r3,kSIGPTargetAddrErr				/* CPU number is too big */
-			bgtlr-	cr1									/* Sure are... (Get our address also) */
-			ori		r12,r12,LOW_ADDR(MPPIwork)			/* Get the bottom half of the data area */
-			la		r9,EXT(MPPICPUs)-MPPIwork(r9)			/* Point into the proccessor control area */
-			mflr	r11									/* Save the return address */
-			add		r9,r9,r12							/* Point right at the entry */
-			
-SPretry:	lwarx	r5,0,r9								/* Pick up the status flags (MPPICStat) and reserve it */
-			li		r3,kSIGPInterfaceBusyErr			/* Fill dead space and get busy return code */
-			rlwinm.	r0,r5,0,0,0							/* Are we marked as busy? */
-			lis		r6,MPPICOnline>>16					/* Get the online flag */
-			bne-	ErrorReturn							/* Yeah, go leave, don't bother me now... */
-			and.	r0,r5,r6							/* Are we online */
-			li		r3,kMPPOffline						/* Set offline */
-			beq-	ErrorReturn							/* Ain't online, ain't ready, buzz off... */
-			li		r3,kMPPBadState						/* Set bad state */
-			oris	r5,r5,(MPPICBusy>>16)&0x0000FFFF	/* Turn on the busy bit */
-			
-			stwcx.	r5,0,r9								/* Try to set busy */
-			bne-	SPretry								
-			
-			ori		r6,r10,MPPICfStrt<<8				/* Put the Start function in front of the processor ID */
-			rlwimi	r5,r6,0,16,31						/* Put these behind the status flags */
-			stw		r4,MPPICParm0(r9)					/* Set the starting physical address parameter */
-			stw		r7,MPPICParm2(r9)					/* Set pass-thru parameter */
-			
-			sync										/* Make sure it's all out there */
-			b		KickAndGo							/* We're done now... */
-
-/******************************************************************************************************** */
-/* */
-/*			Reset the selected processor (R3=processor).  You can't reset yourself or the primary. */
-/*			We're gonna try, try real hard...  This is not for the faint-of-heart. */
-/*			If there's ever any way to yank a reset line, we'll do it here. */
-/* */
-/******************************************************************************************************** */
-			
-ResetProcessor:
-			mfspr	r10,pir								/* Get our processor number */
-			rlwinm	r9,r3,5,23,26						/* Get index into CPU array */
-			rlwinm	r10,r10,0,28,31						/* Clean up the PIR */
-			cmplw	cr0,r3,r10							/* Trying to start ourselves? */
-			cmplwi	cr1,r3,MPPIMaxCPU					/* See if we are bigger than max */
-			li		r3,kMPPHairyPalms					/* Set trying to do it to ourselves */
-			beqlr-										/* Self abuse... */
-			mr.		r9,r9								/* Trying to reset the primary?!?  Dude, that's insubordination!!!! */
-			lis		r12,HIGH_ADDR(MPPIwork)				/* Get the top half of the data area */
-			li		r3,kMPPInvalCPU						/* Say that that's a major offense */
-			beqlr-										/* Bye now... */
-			li		r3,kSIGPTargetAddrErr				/* CPU number is too big */
-			bgtlr-	cr1									/* Sure are... (Get our address also) */
-			ori		r12,r12,LOW_ADDR(MPPIwork)			/* Get the bottom half of the data area */
-			
-			la		r9,EXT(MPPICPUs)-MPPIwork(r9)		/* Point into the proccessor control area		 */
-			mflr	r11									/* Save the return address */
-			add		r9,r9,r12							/* Point right at the entry */
-			
-			li		r4,16								/* Try for 16 times to get the busy lock */
-
-RSlockS:	mftb	r6									/* Time stamp start */
-
-RSlock:		lwarx	r5,0,r9								/* Pick up the status flags (MPPICStat) and reserve it */
-			rlwinm.	r0,r5,0,2,2							/* Are we online */
-			li		r3,kMPPOffline						/* Set offline */
-			cmplwi	cr1,r5,0							/* Check for busy */
-			beq-	ErrorReturn							/* Ain't online, ain't ready, buzz off... */
-			bge+	cr1,RSnotBusy						/* Not busy, make it so... */
-			
-			mftb	r7									/* Stamp the time */
-			sub		r7,r7,r6							/* Get elapsed time */
-			rlwinm.	r7,r7,16,16,31						/* Divide ticks by microseconds (this is pretty darn "kinda-in-the-ballpark") */
-			cmplwi	cr0,r7,TicksPerMic					/* See if we hit 65536µS yet */
-			blt+	RSlock								/* Not yet... */
-			
-RSatmtCnt:	subi	r4,r4,1								/* Count the retries */
-			mr.		r4,r4								/* Are we done yet? */
-			bgt+	RSlockS								/* Start the lock attempt again... */
-			
-			li		r3,kMPPCantLock						/* Say we can't get the lock */
-			b		ErrorReturn							/* Bye, dude... */
-			
-RSnotBusy:	rlwinm	r5,r5,0,0,15						/* Clear out the function and requestor */
-			oris	r5,r5,(MPPICBusy>>16)&0x0000FFFF	/* Set busy */
-			or		r5,r10,r5							/* Add in our processor */
-			ori		r5,r5,MPPICfReset<<8				/* Set the reset function */
-			stwcx.	r5,0,r9								/* Cram it back */
-			bne-	RSatmtCnt							/* We lost the reservation... */
-			b		KickAndGo							/* Try to send it across... */
-			
-
-/******************************************************************************************************** */
-/* */
-/*			Here we will try to resume execution of a stopped processor (R3=processor). */
-/* */
-/******************************************************************************************************** */
-			
-ResumeProcessor:
-			mfspr	r10,pir								/* Get our processor number */
-			rlwinm	r9,r3,5,23,26						/* Get index into CPU array */
-			cmplw	cr0,r3,r10							/* Trying to resume ourselves? */
-			cmplwi	cr1,r3,MPPIMaxCPU					/* See if we are bigger than max */
-			li		r3,kMPPHairyPalms					/* Set trying to do it to ourselves */
-			beqlr-										/* Self abuse... */
-			li		r3,kSIGPTargetAddrErr				/* CPU number is too big */
-			bgtlr-	cr1									/* Sure are... (Get our address also) */
-			lis		r12,HIGH_ADDR(MPPIwork)				/* Get the top half of the data area */
-			la		r9,EXT(MPPICPUs)-MPPIwork(r9)			/* Point into the proccessor control area */
-			ori		r12,r12,LOW_ADDR(MPPIwork)			/* Get the bottom half of the data area */
-			mflr	r11									/* Save the link register */
-			add		r9,r9,r12							/* Point right at the entry */
-			
-RPretry:	lwarx	r5,0,r9								/* Pick up the status flags (MPPICStat) and reserve it */
-			li		r3,kSIGPInterfaceBusyErr			/* Fill dead space and get busy return code */
-			rlwinm.	r0,r5,0,0,0							/* Are we marked as busy? */
-			lis		r6,MPPICOnline>>16					/* Get the online flag */
-			bne-	ErrorReturn							/* Yeah, go leave, don't bother me now... */
-			and.	r0,r5,r6							/* Are we online */
-			li		r3,kMPPOffline						/* Set offline */
-			lis		r6,MPPICReady>>16					/* Get the ready bit */
-			beq-	ErrorReturn							/* Ain't online, ain't ready, buzz off... */
-			and.	r0,r5,r6							/* Are we ready? */
-			li		r3,kMPPNotReady						/* Set not ready */
-			lis		r6,MPPICStop>>16					/* Get the stopped bit */
-			beq-	ErrorReturn							/* Ain't ready, buzz off... */
-			and.	r0,r5,r6							/* Are we stopped? */
-			li		r3,kMPPNotStopped					/* Set not stopped */
-			oris	r5,r5,(MPPICBusy>>16)&0x0000FFFF	/* Turn on the busy bit */
-			beq-	ErrorReturn							/* Nope, not stopped, so how do we resume? */
-			
-			stwcx.	r5,0,r9								/* Try to set busy */
-			bne-	RPretry
-			
-			ori		r6,r10,MPPICfResm<<8				/* Put the resume function in front of the processor ID */
-			rlwimi	r5,r6,0,16,31						/* Put these behind the status flags */
-			b		KickAndGo							/* We're done now... */
-
-
-
-/******************************************************************************************************** */
-/* */
-/*			Here we will try to stop execution of a running processor (R3=processor). */
-/* */
-/******************************************************************************************************** */
-			
-StopProcessor:
-			mfspr	r10,pir								/* Get our processor number */
-			rlwinm	r9,r3,5,23,26						/* Get index into CPU array */
-			cmplw	cr0,r3,r10							/* Are we doing ourselves? */
-			cmplwi	cr1,r3,MPPIMaxCPU					/* See if we are bigger than max */
-			li		r3,kMPPHairyPalms					/* Set trying to do it to ourselves */
-			beqlr-										/* Self abuse... */
-			li		r3,kSIGPTargetAddrErr				/* CPU number is too big */
-			bgtlr-	cr1									/* Sure are... (Get our address also) */
-			lis		r12,HIGH_ADDR(MPPIwork)				/* Get the top half of the data area */
-			la		r9,EXT(MPPICPUs)-MPPIwork(r9)			/* Point into the proccessor control area */
-			ori		r12,r12,LOW_ADDR(MPPIwork)			/* Get the bottom half of the data area */
-			mflr	r11									/* Save the link register */
-			add		r9,r9,r12							/* Point right at the entry */
-			
-PPretry:	lwarx	r5,0,r9								/* Pick up the status flags (MPPICStat) and reserve it */
-			li		r3,kSIGPInterfaceBusyErr			/* Fill dead space and get busy return code */
-			rlwinm.	r0,r5,0,0,0							/* Are we marked as busy? */
-			lis		r6,MPPICOnline>>16					/* Get the online flag */
-			bne-	ErrorReturn							/* Yeah, go leave, don't bother me now... */
-			and.	r0,r5,r6							/* Are we online */
-			li		r3,kMPPOffline						/* Set offline */
-			lis		r6,MPPICReady>>16					/* Get the ready bit */
-			beq-	ErrorReturn							/* Ain't online, ain't ready, buzz off... */
-			and.	r0,r5,r6							/* Are we ready? */
-			li		r3,kMPPNotReady						/* Set not ready */
-			lis		r6,MPPICStop>>16					/* Get the stopped bit */
-			beq-	ErrorReturn							/* Ain't ready, buzz off... */
-			and.	r0,r5,r6							/* Are we stopped? */
-			li		r3,kMPPNotRunning					/* Set not running */
-			oris	r5,r5,(MPPICBusy>>16)&0x0000FFFF	/* Turn on the busy bit */
-			bne-	ErrorReturn							/* Nope, already stopped, so how do we stop? */
-			
-			stwcx.	r5,0,r9								/* Try to set busy */
-			ori		r10,r10,MPPICfStop<<8				/* Put the stop function in front of the processor ID */
-			bne-	PPretry
-			
-			rlwimi	r5,r10,0,16,31						/* Put these behind the status flags */
-			b		KickAndGo							/* We're done now... */
-
-
-/******************************************************************************************************** */
-/* */
-/*			Here we will try to signal a running processor (R3=processor). */
-/*			Note that this should have good performace.  Well, actually, seeing as how slow we really are, it */
-/*			probably is moot anyhow. */
-/*			Another note: this function (and all most others as well) will return a timeout when the  */
-/*			second processor tries to do itself on the old version of the board.  This happens because */
-/*			In order to keep the watchchihuahua from popping (just imagine the scene: that little runt-dog just so */
-/*			excited that its veins and eyes bulge and then explode) signaling to the secondary  */
-/*			is done syncronously and disabled.  If the secondary signals the secondary, it will never enable so */
-/*			it will never see the 'rupt, so it will never clear it, so it will time out, so there... */
-/* */
-/******************************************************************************************************** */
-			
-SignalProcessor:
-			mfspr	r10,pir								/* Get our processor number */
-			rlwinm	r9,r3,5,23,26						/* Get index into CPU array */
-			lis		r12,HIGH_ADDR(MPPIwork)				/* Get the top half of the data area */
-			cmplwi	cr1,r3,MPPIMaxCPU					/* See if we are bigger than max */
-			li		r3,kSIGPTargetAddrErr				/* CPU number is too big */
-			bgtlr-	cr1									/* Sure are... (Get our address also) */
-			la		r9,EXT(MPPICPUs)-MPPIwork(r9)			/* Point into the proccessor control area */
-			ori		r12,r12,LOW_ADDR(MPPIwork)			/* Get the bottom half of the data area */
-			mflr	r11									/* Save the link register */
-			add		r9,r9,r12							/* Point right at the entry */
-			
-SiPretry:	lwarx	r5,0,r9								/* Pick up the status flags (MPPICStat) and reserve it */
-			li		r3,kSIGPInterfaceBusyErr			/* Fill dead space and get busy return code */
-			rlwinm.	r0,r5,0,0,0							/* Are we marked as busy? */
-			lis		r6,MPPICOnline>>16					/* Get the online flag */
-			bne-	ErrorReturn							/* Yeah, go leave, don't bother me now... */
-			and.	r0,r5,r6							/* Are we online */
-			li		r3,kMPPOffline						/* Set offline */
-			lis		r6,MPPICReady>>16					/* Get the ready bit */
-			beq-	ErrorReturn							/* Ain't online, ain't ready, buzz off... */
-			and.	r0,r5,r6							/* Are we ready? */
-			li		r3,kMPPNotReady						/* Set not ready */
-			oris	r5,r5,(MPPICBusy>>16)&0x0000FFFF	/* Turn on the busy bit */
-			beq-	ErrorReturn							/* Ain't ready, buzz off... */
-			
-			stwcx.	r5,0,r9								/* Try to set busy */
-			ori		r10,r10,MPPICfSigp<<8				/* Put the SIGP function in front of the processor ID */
-			bne-	SiPretry
-			
-			stw		r4,MPPICParm0(r9)					/* Pass along the SIGP parameter */
-			
-			rlwimi	r5,r10,0,16,31						/* Put these behind the status flags */
-			b		KickAndGo							/* We're done now... */
-
-
-/******************************************************************************************************** */
-/* */
-/*			Here we will store the state of a processor (R3=processor; R4=status area). */
-/*			Self abuse will store the state as is, is not asynchronous, and grows hair on your palms. */
-/* */
-/******************************************************************************************************** */
-			
-StoreProcessorStatus:
-			mfspr	r10,pir								/* Get our processor number */
-			rlwinm	r9,r3,5,23,26						/* Get index into CPU array */
-			cmplw	cr0,r3,r10							/* Saving our own state???  Abusing oneself??? */
-			cmplwi	cr1,r3,MPPIMaxCPU					/* See if we are bigger than max */
-			li		r3,kSIGPTargetAddrErr				/* CPU number is too big */
-			mflr	r11									/* Save the link register */
-			beq		Flagellant							/* Oh baby, oh baby... */
-			bgtlr-	cr1									/* Sure are... (Get our address also) */
-			lis		r12,HIGH_ADDR(MPPIwork)				/* Get the top half of the data area */
-			la		r9,EXT(MPPICPUs)-MPPIwork(r9)			/* Point into the proccessor control area */
-			ori		r12,r12,LOW_ADDR(MPPIwork)			/* Get the bottom half of the data area */
-			add		r9,r9,r12							/* Point right at the entry */
-			
-SSretry:	lwarx	r5,0,r9								/* Pick up the status flags (MPPICStat) and reserve it */
-			li		r3,kSIGPInterfaceBusyErr			/* Fill dead space and get busy return code */
-			rlwinm.	r0,r5,0,0,0							/* Are we marked as busy? */
-			lis		r6,MPPICOnline>>16					/* Get the online flag */
-			bne-	ErrorReturn							/* Yeah, go leave, don't bother me now... */
-			and.	r0,r5,r6							/* Are we online */
-			li		r3,kMPPOffline						/* Set offline */
-			beq-	ErrorReturn							/* Ain't online, buzz off... */
-			oris	r5,r5,(MPPICBusy>>16)&0x0000FFFF	/* Turn on the busy bit */
-			
-			stwcx.	r5,0,r9								/* Try to set busy */
-			ori		r10,r10,MPPICfStat<<8				/* Put the store status function in front of the processor ID */
-			bne-	SSretry								/* Lost reservation, return busy... */
-			
-			li		r0,0								/* Get false */
-			stb		r0,CSAregsAreValid(r4)				/* Set that the registers ain't valid */
-			stw		r4,MPPICParm0(r9)					/* Set the status area physical address parameter */
-			
-			rlwimi	r5,r10,0,16,31						/* Put these behind the status flags */
-			b		KickAndGo							/* We're done now... */
-			
-/*			Spill one's seed upon the soil */
-
-Flagellant:	bl		StoreStatus							/* Go store off all the registers 'n' stuff */
-			mtlr	r11									/* Restore the return address */
-			li		r3,kSIGPnoErr						/* Return no error */
-			blr											/* Leave... */
-
-
-/******************************************************************************************************** */
-/* */
-/*			Here we will attempt to syncronize clocks (R3=processor). */
-/*			Self abuse will just return with an all-ok code. */
-/* */
-/******************************************************************************************************** */
-			
-SynchClock:
-			mfspr	r10,pir								/* Get our processor number */
-			rlwinm	r9,r3,5,23,26						/* Get index into CPU array */
-			cmplw	cr0,r3,r10							/* Cleaning our own clock?? */
-			cmplwi	cr1,r3,MPPIMaxCPU					/* See if we are bigger than max */
-			lis		r12,HIGH_ADDR(MPPIwork)				/* Get the top half of the data area */
-			li		r3,kSIGPnoErr						/* Assume self-cleaning clock */
-			beqlr										/* Oh baby, oh baby... */
-			li		r3,kSIGPTargetAddrErr				/* CPU number is too big */
-			bgtlr-	cr1									/* Sure are... (Get our address also) */
-			ori		r12,r12,LOW_ADDR(MPPIwork)			/* Get the bottom half of the data area */
-			la		r9,EXT(MPPICPUs)-MPPIwork(r9)			/* Point into the proccessor control area */
-			mflr	r11									/* Save the link register */
-			add		r9,r9,r12							/* Point right at the entry */
-			
-SyCretry:	lwarx	r5,0,r9								/* Pick up the status flags (MPPICStat) and reserve it */
-			li		r3,kSIGPInterfaceBusyErr			/* Fill dead space and get busy return code */
-			rlwinm.	r0,r5,0,0,0							/* Are we marked as busy? */
-			lis		r6,MPPICOnline>>16					/* Get the online flag */
-			bne-	ErrorReturn							/* Yeah, go leave, don't bother me now... */
-			and.	r0,r5,r6							/* Are we online */
-			li		r3,kMPPOffline						/* Set offline */
-			beq-	ErrorReturn							/* Ain't online, ain't ready, buzz off... */
-			oris	r5,r5,(MPPICBusy>>16)&0x0000FFFF	/* Turn on the busy bit */
-			li		r0,0								/* Clear this */
-			
-			stwcx.	r5,0,r9								/* Try to set busy */
-			ori		r10,r10,MPPICfTBsy<<8				/* Put the timebase sync function in front of the processor ID */
-			bne-	SyCretry							/* Lost reservation, return busy... */
-
-			stw		r0,MPPITBsync+4-MPPIwork(r12)		/* Make sure the parm area is 0 */
-			mr		r0,r11								/* Save the LR */
-			bl		SyCbase								/* Get a base register */
-SyCbase:	rlwimi	r5,r10,0,16,31						/* Put these behind the status flags */
-			mflr	r11									/* Get the base */
-			la		r11,(4*4)(r11)						/* DON'T MESS WITH THESE INSTRUCTIONS Make up the return point */
-			b		KickAndGo							/* Go signal the other side */
-
-SyCKrtrn:	mr		r11,r0								/* Restore the return */
-
-/* */
-/*			Start sync'ing 'er up */
-/* */
-		
-			mftb	r4									/* Take a timeout stamp (don't need top half, we have at least 13 hours) */
-
-SyCInP0:	lwz		r5,0(r9)							/* Get the CPU status word */
-			rlwinm	r5,r5,24,24,31						/* Isolate the command byte */
-			cmplwi	cr0,r5,MPPICfTBsy1					/* Have we reached time base sync phase 1 yet? */
-			beq		SyCInP1								/* Yeah, we're in phase 1... */
-			mftb	r5									/* Get the bottom half of the timer again */
-			sub		r5,r5,r4							/* How long we been messin' around? */
-			cmplwi	cr0,r5,1000*TicksPerMic				/* Don't try more'n' a 1000µS */
-			blt+	SyCInP0								/* We haven't, so wait some more... */
-			li		r3,kMPPTimeOut						/* Signal timeout */
-			b		ErrorReturn							/* By dude... */
-			
-/* */
-/*			Here we make sure there is enough time to sync the clocks before the lower part of the TB ticks */
-/*			up into the high part.  This eliminates the need for any funky  */
-/*			"get-the-top-then-get-the-bottom-then-get-the-top-again-to-see-if-it-changed" stuff.  That would */
-/*			only make the sync harder to do. */
-/*			 */
-/*			Also, because we use the lower TB value for the signal, we also need to make sure we do not have */
-/*			a value of 0, we would be ever-so-sorry if it was. */
-/* */
-
-SyCInP1:	li		r4,lo16(0xC000)						/* Get the minimum time left on clock before tick ('bout 1 1/4 ms) */
-			li		r8,0								/* Get a 0 constant */
-			
-SyCdelay:	mftb	r5									/* Get the time left */
-			cmplw	cr0,r5,r4							/* See if there is sufficient time before carry into high clock */
-			bgt-	SyCdelay							/* Nope, hang until it is... */
-			mr.		r5,r5								/* Did we just tick, however? */
-			beq-	SyCdelay							/* Yeah, wait until it is at least 1... */
-			
-			mftbu	r4									/* Get the upper */
-			stw		r4,MPPITBsync-MPPIwork(r12)			/* Make sure the top half is set */
-			sync										/* Wait until it is done */
-			
-			mftb	r5									/* Get the lower timebase now */
-			stw		r5,MPPITBsync+4-MPPIwork(r12)		/* Shove it out for the other processor */
-
-			la		r6,MPPISncFght-MPPIwork(r12)		/* Point to the courtroom area */
-			li		r5,0								/* Point to the first line */
-
-SyCclear:	dcbz	r5,r6								/* Clear the court */
-			addi	r5,r5,32							/* Point to the next line */
-			cmplwi	cr0,r5,10*2*32						/* Enough for 9 iterations, 2 chunks at a time */
-			blt+	SyCclear							/* Clear the whole smear... */
-			sync										/* Make sure everyone's out */
-
-			mftb	r5									/* Get the lower timebase now */
-		
-SyCWait:	lwz		r7,MPPITBsync+4-MPPIwork(r12)		/* Get it back */
-			mftb	r6									/* Get the bottom half again */
-			mr.		r7,r7								/* Have they set their clock yet? */
-			sub		r0,r6,r5							/* See if we're hung up */
-			beq-	SyCdonesync							/* Clock is set */
-			cmplwi	cr0,r0,1000*TicksPerMic				/* Timeout if we spend more than 1000µS doing this */
-			blt+	SyCWait								/* No timeout, wait some more... */
-			li		r3,kMPPTimeOut						/* Set timeout */
-			b		ErrorReturn							/* Leave... */
-			
-/* */
-/*			Ok, so now we have set a preliminary TB value on the second processor.  It's close, but only */
-/*			within handgranade range.   */
-/* */
-/*			What we will do now is to let the processors (starting with the other guy) argue about the time for */
-/*			a while (10 passes-we use the middle 8).  We'll look at the results and try to adjust the other processor's */
-/*			time such that the timing windows are overlapping evenly. This should put the TBs close enough together */
-/*			(0-2 ticks) that the difference is undetectable. */
-/* */
-
-
-			
-SyCdonesync:
-			li		r4,0								/* Clear this */
-			la		r5,MPPISncFght-MPPIwork(r12)		/* Point to the squared circle */
-
-SyCWtArg:	
-			dcbf	0,r5								/* Make sure of it */
-			sync										/* Doubly shure */
-			lwz		r6,0(r5)							/* Listen for the defence argument */
-
-			mr.		r6,r6								/* See if they are done */
-			beq+	SyCWtArg							/* Nope, still going... */
-
-			mftb	r7									/* They're done, time for rebuttal */
-			stw		r7,32(r5)							/* Make rebuttle */
-	
-			addi	r4,r4,1								/* Count rounds */
-
-			cmplwi	cr0,r4,10							/* See if we've gone 8 rounds plus an extra one */
-			addi	r5,r5,64							/* Point to the next round areas */
-
-			blt+	SyCWtArg							/* Not yet, come out of your corners fighting... */
-			
-			mftb	r5									/* Stamp the wait */
-			
-SyCWadj:	lwz		r7,MPPITBsync+4-MPPIwork(r12)		/* Get adjustment flag */
-			mftb	r6									/* Get timebase again */
-			
-			mr.		r7,r7								/* Have they set their timebase with adjusted time yet? */
-			sub		r6,r6,r5							/* Get elapsed time */
-			bne+	SyCdone								/* They say it, sync done... */
-			cmplwi	cr0,r6,1000*TicksPerMic				/* Timeout if we spend more than 1000µS doing this */
-			blt+	SyCWadj								/* Still time, wait until adjustment is done... */
-			
-			li		r3,kMPPTimeOut						/* Set timeout */
-			b		ErrorReturn							/* Pass it back... */
-			
-SyCdone:	li		r3,kSIGPnoErr						/* No errors */
-			mtlr	r11									/* Restore LR */
-			blr											/* Leave... */
-
-
-/******************************************************************************************************** */
-/* */
-/*			Here we will get the physical address of the interrupt handler. */
-/* */
-/******************************************************************************************************** */
-			
-GetExtHandlerAddress:
-			mflr	r11									/* Save our return */
-			bl		GEXbase								/* Make a base address */
-GEXbase:	mflr	r3									/* Get address into our base */
-			addi	r3,r3,LOW_ADDR(GotSignal-GEXbase)	/* Get the logical address of the 'rupt handler */
-
-			mtlr	r11									/* Restore LR */
-			blr
-
-
-/******************************************************************************************************** */
-/* */
-/*			Here we will get a snapshot of the processor's current signaling state (R3=processor). */
-/* */
-/******************************************************************************************************** */
-			
-ProcessorState:
-			lis		r12,HIGH_ADDR(MPPIwork)				/* Get the top half of the data area */
-			rlwinm	r9,r3,5,23,26						/* Get index into CPU array */
-			cmplwi	cr1,r3,MPPIMaxCPU					/* See if we are bigger than max */
-			li		r3,kSIGPTargetAddrErr				/* CPU number is too big */
-			bgtlr-	cr1									/* Sure are... (Get our address also) */
-			la		r9,EXT(MPPICPUs)-MPPIwork(r9)			/* Point into the proccessor control area */
-			ori		r12,r12,LOW_ADDR(MPPIwork)			/* Get the bottom half of the data area */
-			add		r9,r9,r12							/* Point right at the entry */
-			lwz		r4,MPPICStat(r9)					/* Get the status word */
-			li		r3,kSIGPnoErr						/* Set no errors */
-			rlwinm.	r4,r4,0,0,0							/* Test for busy status */
-			beqlr										/* Return kSIGPnoErr if not busy */
-			li		r3,kSIGPInterfaceBusyErr			/* Otherwise, return busy */
-			blr											/* Return it */
-
-/******************************************************************************************************** */
-/* */
-/*			Here we will try to handle any pending messages (just as if an interruption occurred). */
-/*			The purpose of this function is to assure the message passing system runs even */
-/*			though external interrupts are disabled. Lacking a separate physical signalling */
-/*			class, we have to share the external interrupt signal. Unfortunately, there are */
-/*			times when disabled loops occur (in spin locks, in the debugger, etc.), and when they */
-/*			happen, a low level message sent to a processor will not get processed, hence this */
-/*			function exists to be called from those disabled loops. Since the calls are often */
-/*			from disabled code, all that can be done is to process any pending *message*. Any */
-/*			pending notification interruption (referred to throughtout this code as a SIGP */
-/*			interruption) must remain pending. */
-/* */
-/******************************************************************************************************** */
-			
-RunSIGPRun:
-			lis		r12,HIGH_ADDR(MPPIwork)				/* Get the top half of the data area */
-			mfspr	r3,pir								/* Get our CPU address */
-			rlwinm	r9,r3,5,23,26						/* Get index into CPU array */
-			ori		r12,r12,LOW_ADDR(MPPIwork)			/* Get the bottom half of the data area */
-			la		r9,EXT(MPPICPUs)-MPPIwork(r9)			/* Point into the proccessor control area */
-			mflr	r11									/* Save the link register */
-			add		r9,r9,r12							/* Point right at our entry */
-			lwz		r3,MPPICPriv(r9)					/* Get our privates */
-			cmplw	cr1,r11,r11							/* Make sure IdleWait doesn't try to clear 'rupt request */
-			oris	r3,r3,MPPICXRun>>16					/* Diddle with them and show we entered here */
-			stw		r3,MPPICPriv(r9)					/* Put away our privates */
-			b		IdleWait							/* Go pretend there was an interrupt... */
-
-/******************************************************************************************************** */
-/* */
-/*			Error return.  We only need this when we leave with a reservation.  We really SHOULD clear it... */
-/* */
-/******************************************************************************************************** */
-
-ErrorReturn:
-			mtlr	r11									/* Restore LR */
-			blr											
-
-/******************************************************************************************************** */
-/* */
-/*			Kick the target processor.  Note that we won't set the passing bit until we are ready to exit. */
-/*			The reason for this is that we have the silly, old watchchihuahua board to deal with.  Because  */
-/*			we can't just set the interrupt and leave, we gotta wait for it to be seen on the other side. */
-/*			This means that there could be a timeout and if so, we need to back off the function request else */
-/*			we'd see busy when they tried to redrive it.  We'll have to deal with a tad of spin on the secondary side. */
-/*			note that this just applies to a primary to secondary function on the old board. */
-/* */
-/******************************************************************************************************** */
-	
-KickAndGo:
-			la		r8,MPPICPU0-MPPIwork(r12)			/* Get the primary work area address */
-			mtlr	r11									/* Restore the link register */
-			cmplw	cr0,r8,r9							/* Which is target?  primary or secondary? */
-			mfmsr	r11									/* Save off the MSR */
-			oris	r5,r5,MPPICPass>>16					/* Set the passing bit on */
-			stw		r5,MPPICStat(r9)					/* Store the pass and let the other processor go on */
-			
-			beq		KickPrimary							/* The target is the primary... */
-			
-			ori		r3,r11,0x0010						/* Turn on DDAT bit */
-			lbz		r4,MPPIstatus-MPPIwork(r12)			/* Load up the global status byte */
-			lwz		r8,MPPIHammer-MPPIwork(r12)			/* Point to the Hammerhead area */
-	
-			mtmsr	r3									/* Turn on DDAT */
-			isync
-			
-			andi.	r4,r4,MPPI2Pv2						/* Are we on the new or old board? */
-			li		r3,0								/* Set the bit for an interrupt request */
-			beq		KickOld								/* Ok, it's the old board... */
-			
-			sync										/* Make sure this is out there */
-			stb		r3,IntReg(r8)						/* Set the interruption signal */
-			eieio
-	
-			mtmsr	r11									/* Set DDAT back to what it was */
-			isync
-			li		r3,kSIGPnoErr						/* Set no errors */
-			blr											/* Leave... */
-			
-KickOld:	li		r4,8								/* Set the number of tries */
-
-KickAgain:	mftb	r6									/* Stamp the bottom half of time base */
-			stb		r3,IntReg(r8)						/* Stick the interrupt */
-			eieio										/* Fence me in */
-			
-CheckKick:	lbz		r10,IntReg(r8)						/* Get the interrupt request back again */
-			mr.		r10,r10								/* Yes? Got it? */
-			bne		FinalDelay							/* Yeah, do the final delay and then go away... */
-			
-			mftb	r7									/* Get the time again */
-			sub		r7,r7,r6							/* Get time-so-far */
-			cmplwi	cr0,r7,75*TicksPerMic				/* Hold it for 75µS (average disable is supposed to be 100µS or so) */
-			blt+	CheckKick							/* Keep waiting the whole time... */
-			
-			li		r10,SecInt							/* Set the deassert bit */
-			mftb	r6									/* Stamp start of deassert time */
-			stb		r10,IntReg(r8)						/* Deassert the interrupt request */
-			eieio
-			
-DeassertWT:	mftb	r7									/* Stamp out the time */
-			sub		r7,r7,r6							/* Get elapsed */
-			cmplwi	cr0,r7,16*TicksPerMic				/* Hold off 16µS (minimum is 12µS) */
-			blt+	DeassertWT							/* Keep spinning... */
-			
-			subi	r4,r4,1								/* See if we have another retry we can do */
-			mr.		r4,r4								/* Are we there yet? */
-			blt+	KickAgain							/* Retry one more time... */
-			
-			rlwinm	r5,r5,0,2,31						/* Clear busy and passing bits */
-			rlwinm	r5,r5,0,24,15						/* Clear the function request to idle */
-			
-			mtmsr	r11									/* Restore DDAT stuff */
-			isync
-
-			stw		r5,MPPICStat(r9)					/* Rescind the request */
-			li		r3,kMPPTimeOut						/* Set timeout */
-			blr											/* Leave... */
-			
-FinalDelay:	mftb	r6									/* Stamp the start of the final delay */
-
-FinalDelayW:
-			mftb	r7									/* Stamp out the time */
-			sub		r7,r7,r6							/* Get elapsed */
-			cmplwi	cr0,r7,16*TicksPerMic				/* Hold off 16µS (minimum is 12µS) */
-			blt+	FinalDelayW							/* Keep spinning... */
-
-			mtmsr	r11									/* Restore DDAT stuff */
-			isync
-			li		r3,kSIGPnoErr						/* Set no errors */
-			blr											/* Leave... */
-			
-KickPrimary:
-			ori		r3,r11,0x0010						/* Turn on the DDAT bit */
-			lwz		r8,MPPIEther-MPPIwork(r12)			/* Get the address of the ethernet ROM */
-			
-			mtmsr	r3									/* Turn on DDAT */
-			isync
-
-			li		r4,4								/* Get flip count */
-			
-			sync										/* Make sure the status word is out there */
-
-FlipOff:	lbz		r3,0(r8)							/* Reference ethernet ROM to get chip select twiddled */
-			eieio										/* Make sure of this (Hmm, this is chip select, not memory-mapped */
-														/* storage.  Do we even need the eieio?) */
-														
-			addic.	r4,r4,-1							/* Have we flipped them off enough? */
-			bgt+	FlipOff								/* Not yet, they deserve more... */
-			
-			mtmsr	r11									/* Restore DDAT stuff */
-			isync
-			li		r3,kSIGPnoErr						/* Set no errors */
-			blr											/* Return... */
-
-/******************************************************************************************************** */
-/* */
-/*			This is the code for the secondary processor */
-/* */
-/******************************************************************************************************** */
-
-/*			Note that none of this code needs locks because there's kind of a synchronization */
-/*			shuffle going on. */
-
-/* */
-/*			First, we need to do a bit of initialization of the processor. */
-/* */
-
-
-CPUInit:	
-			li		r27,0x3040							/* Set floating point and machine checks on, IP to 0xFFF0xxxx */
-			mtmsr	r27									/* Load 'em on in */
-			isync
-			
-			lis		r28,-32768							/* Turn on machine checks */
-														/* should be 0x8000 */
-			ori		r28,r28,0xCC84						/* Enable caches, clear them,  */
-														/* disable serial execution and turn BHT on */
-			sync
-			mtspr	HID0,r28							/* Start the cache clear */
-			sync
-
-/* */
-/*			Clear out the TLB.  They be garbage after hard reset. */
-/* */
-
-			li		r0,512								/* Get number of TLB entries (FIX THIS) */
-			li		r3,0								/* Start at 0 */
-			mtctr	r0									/* Set the CTR */
-			
-purgeTLB:	tlbie	r3									/* Purge this entry */
-			addi	r3,r3,4096							/* Next page */
-			bdnz	purgeTLB							/* Do 'em all... */
-					
-			sync										/* Make sure all TLB purges are done */
-			tlbsync										/* Make sure on other processors also */
-			sync										/* Make sure the TLBSYNC is done */
-
-/* */
-/*			Clear out the BATs.  They are garbage after hard reset. */
-/* */
-
-			li		r3,0								/* Clear a register */
-			
-			mtspr	DBAT0L,r3							/* Clear BAT */
-			mtspr	DBAT0U,r3							/* Clear BAT */
-			mtspr	DBAT1L,r3							/* Clear BAT */
-			mtspr	DBAT1U,r3							/* Clear BAT */
-			mtspr	DBAT2L,r3							/* Clear BAT */
-			mtspr	DBAT2U,r3							/* Clear BAT */
-			mtspr	DBAT3L,r3							/* Clear BAT */
-			mtspr	DBAT3U,r3							/* Clear BAT */
-			
-			mtspr	IBAT0L,r3							/* Clear BAT */
-			mtspr	IBAT0U,r3							/* Clear BAT */
-			mtspr	IBAT1L,r3							/* Clear BAT */
-			mtspr	IBAT1U,r3							/* Clear BAT */
-			mtspr	IBAT2L,r3							/* Clear BAT */
-			mtspr	IBAT2U,r3							/* Clear BAT */
-			mtspr	IBAT3L,r3							/* Clear BAT */
-			mtspr	IBAT3U,r3							/* Clear BAT */
-
-/* */
-/*			Map 0xF0000000 to 0xFFFFFFFF for I/O; make it R/W non-cacheable */
-/*			Map	0x00000000 to 0x0FFFFFFF for mainstore; make it R/W cachable */
-/* */
-
-			lis		r6,0xF000							/* Set RPN to last segment */
-			ori		r6,r6,0x1FFF						/* Set up upper BAT for 256M, access both */
-			
-			lis		r7,0xF000							/* Set RPN to last segment */
-			ori		r7,r7,0x0032						/* Set up lower BAT for 256M, access both, non-cachable */
-		
-			mtspr	DBAT0L,r7							/* Setup ROM and I/O mapped areas */
-			mtspr	DBAT0U,r6							/* Now do the upper DBAT */
-			sync
-	
-			li		r6,0x1FFF							/* Set up upper BAT for 256M, access both */
-			li		r7,0x0012							/* Set up lower BAT for r/w access */
-			
-			mtspr	DBAT1L,r7							/* Set up an initial view of mainstore */
-			mtspr	DBAT1U,r6							/* Now do the upper DBAT */
-			sync
-
-/* */
-/*			Clean up SDR and segment registers */
-/* */
-
-			li		r3,0								/* Clear a register */
-			mtspr	SDR1,r3								/* Clear SDR1 */
-			
-			li		r4,0								/* Clear index for segment registers */
-			lis		r5,0x1000							/* Set the segment indexer */
-			
-clearSR:	mtsrin	r3,r4								/* Zero out the SR */
-			add.	r4,r4,r5							/* Point to the next segment */
-			bne-	clearSR								/* Keep going until we wrap back to 0 */
-			
-			lis		r5,HIGH_ADDR(EXT(FloatInit))		/* Get top of floating point init value */
-			ori		r5,r5,LOW_ADDR(EXT(FloatInit))		/* Slam bottom */
-			lfd		f0,0(r5)							/* Initialize FP0 */
-			fmr		f1,f0								/* Ours in not */					
-			fmr		f2,f0								/* to wonder why, */
-			fmr		f3,f0								/* ours is but to */
-			fmr		f4,f0								/* do or die! */
-			fmr		f5,f0						
-			fmr		f6,f0						
-			fmr		f7,f0						
-			fmr		f8,f0						
-			fmr		f9,f0						
-			fmr		f10,f0						
-			fmr		f11,f0						
-			fmr		f12,f0						
-			fmr		f13,f0						
-			fmr		f14,f0						
-			fmr		f15,f0						
-			fmr		f16,f0						
-			fmr		f17,f0						
-			fmr		f18,f0						
-			fmr		f19,f0						
-			fmr		f20,f0						
-			fmr		f21,f0						
-			fmr		f22,f0						
-			fmr		f23,f0						
-			fmr		f24,f0						
-			fmr		f25,f0						
-			fmr		f26,f0						
-			fmr		f27,f0						
-			fmr		f28,f0						
-			fmr		f29,f0						
-			fmr		f30,f0						
-			fmr		f31,f0						
-			
-/* */
-/*			Whew, that was like, work, man!  What a cleaning job, I should be neater */
-/*			when I reset. */
-/* */
-/*			Finally we can get some data DAT turned on and we can reset the interrupt */
-/*			(which may have been done before we get here) and get into the bring up */
-/*			handshakes. */
-/*		 */
-/*			Note that here we need to use the actual V=R addresses for HammerHead */
-/*			and PCI1 adr.  There are no virtual mappings set up on this processor. */
-/*			We need to switch once the firmware is initialized.  Also, we don't know */
-/*			where our control block is yet. */
-/* */
-		
-			lis		r12,HIGH_ADDR(MPPIwork)				/* Get the top half of the data area */
-			ori		r12,r12,LOW_ADDR(MPPIwork)			/* Get the bottom half of the data area */
-
-			mfmsr	r3									/* Get the MSR */
-			ori		r3,r3,0x0010						/* Turn data DAT on */
-			mtmsr	r3									/* DAT is on (well, almost) */
-			isync										/* Now it is for sure */
-		
-			lis		r8,HammerHead>>16					/* Point to the HammerHead controller */
-			li		r7,SecInt							/* Get value to reset */
-			stb		r7,IntReg(r8)						/* Reset the interrupt */
-			eieio										/* Fence it off */
-		
-/* */
-/*			Now we can plant and harvest some bits. */
-/* */
-		
-			lwz		r6,MPPIlogCPU-MPPIwork(r12)			/* Get the logical CPU address to assign */
-			mfspr	r7,pir								/* Get the old PIR */
-			rlwimi	r7,r6,0,27,31						/* Copy all of the reserved parts */
-			mtspr	pir,r7								/* Set it */
-			
-/* */
-/*			This little piece of code here determines if we are on the first or second version */
-/*			of the two processor board.  The old one shouldn't ever be shipped (well, maybe by  */
-/*			DayStar) but there are some around here. */
-/* */
-/*			The newer version of the 2P board has a different state machine than the older one. */
-/*			When we are in the board state we're in now, primary arbitration is turned on while */
-/*			it is not until the next state in the old board.  By checking the our bus address */
-/*			(WhoAmI) we can tell. */
-/* */
-
-			lbz		r7,WhoAmI(r8)						/* Get the current bus master ID */
-			andi.	r7,r7,PriCPU						/* Do we think we're the primary? */
-			beq		On2Pv1								/* No, that means we're on the old 2P board */
-			
-			lbz		r7,MPPIstatus-MPPIwork(r12)			/* Get the status byte */
-			ori		r7,r7,MPPI2Pv2						/* Show we're on the new board */
-			stb		r7,MPPIstatus-MPPIwork(r12)			/* Set the board version */
-			
-On2Pv1:		rlwinm	r9,r6,5,23,26						/* Get index into the CPU specific area */
-				
-			la		r9,EXT(MPPICPUs)-MPPIwork(r9)			/* Index to processor */
-			add		r9,r9,r12							/* Get a base for our CPU specific area */
-			
-			oris	r6,r6,((MPPICBusy+MPPICOnline+MPPICStop)>>16)&0x0000FFFF	/* Set CPU busy, online, stopped,  */
-																				/*   and busy set by himself */
-			stw		r6,MPPICStat(r9)					/* Save the whole status word */
-			
-			li		r4,0x80								/* Get beginnings of a CPU address mask */
-			lhz		r11,MPPIinst-MPPIwork(r12)			/* Get the installed and online status flags */
-			srw		r4,r4,r6							/* Make a mask */
-			rlwimi	r4,r4,8,16,23						/* Double up the mask for both flags */
-			or		r11,r11,r4							/* Set that we are installed and online */
-			sync										/* Make sure the main processor sees the rest of the stuff */
-			
-			sth		r11,MPPIinst-MPPIwork(r12)			/* We're almost done, just need to set the TB */
-			
-			lis		r5,PCI1AdrReg>>16					/* Point to the PCI1 address register		 */
-			li		r4,0								/* Clear this out */
-			stw		r4,0(r5)							/* Set PCI register to 0 to show we're ready for TB sync */
-			eieio										/* Fence it off */
-
-Wait4TB:	lwz		r7,0(r5)							/* Get the PCI1 reg to see if time to set time */
-			mr.		r7,r7								/* Is it ready yet? */
-			beq		Wait4TB								/* Nope, wait for it... */
-			isync										/* No peeking... */
-			
-			lwz		r3,MPPITBsync-MPPIwork(r12)			/* Get the high word of TB */
-			lwz		r4,MPPITBsync+4-MPPIwork(r12)		/* Get the low word */
-			
-/*			Note that we need no TB magic here 'cause they ain't running */
-
-			mttbu	r3									/* Set the high part */
-			mttbl	r4									/* Set the low part */
-			
-			rlwinm	r6,r6,0,2,31						/* Clear the busy bit and passed */
-			stw		r6,MPPICStat(r9)					/* Store the status word */
-			
-			sync										/* Make sure all is right with the world */
-			
-			li		r3,0								/* Set the init done signal */
-			stw		r3,0(r5)							/* Feed the dog and let him out */
-			sync										/* Make sure this is pushed on out */
-
-			li		r27,0x3040							/* Make MSR the way we likes it */
-			mtmsr	r27									/* Load 'em on in */
-			isync
-
-/* */
-/*			Jump on to the idle wait loop.  We're online and ready, but we're */
-/*			still in the reset state.  We need to wait until we see a start signal. */
-/* */
-/*			Note that the idle loop expects R9 to be our CPU-specific work area; */
-/*			R12 is the base of the code and global work area  */
-/* */
-
-			cmplw	cr1,r11,r12							/* Make sure IdleWait knows to clear 'rupt request */
-			b		IdleWait
-
-
-/******************************************************************************************************** */
-/******************************************************************************************************** */
-/* */
-/*			Here is the interruption handler. */
-/* */
-/*			What we'll do here is to get our registers into a standard state and figure out which */
-/*			which processor we are on.  The processors have pretty much the same code.  The primary */
-/*			will reset the the secondary to primary interruption bit and the secondary will reset the SecInt */
-/*			flags. */
-/* */
-/*			The primary to secondary interrupt is an exception interruption contolled by a bit in the  */
-/*			Hammerhead IntReg.  The only bit in here is SecInt which is active low.  Writing a 0 into the */
-/*			bit (bit 0) yanks on the external pin on the secondary.  Note that it is the only external */
-/*			connected on the secondary.  SecInt must be set to 1 to clear the interruption.  On the old */
-/*			2P board, asserting the external interrupt causes a watchdog timer to start which expires unless */
-/*			the interrupt request is withdrawn. On a 180Mhz system the time to expire is about 256µS,  */
-/*			not very long.  So, what we need to do is to time the assertion and if it has not been reset */
-/*			reset, do it ourself.  Unfortunatelty we need to keep it deasserted for at least 12µS or the  */
-/*			watchdog will not stop.  This leads to another problem: even if the secondary processor sees */
-/*			the interrupt and deasserts the request itself,  we cannot reassert before the 12µS limit, */
-/*			else havoc will be wrought.  We just gotta make sure. */
-/* */
-/*			So, the secondary to primary interrupt is megafunky.  The mother board is wired with the  */
-/*			MACE ethernet chip's chip-select pin wired to Grand Centeral's external interrrupt #10 pin. */
-/*			This causes a transient interrupt whenever MACE is diddled. GC latches the interrupt into the */
-/*			events register where we can see it and clear it. */
-/* */
-/******************************************************************************************************** */
-/******************************************************************************************************** */
-
-GotSignal:	mfspr	r9,pir								/* Get our processor ID */
-			lis		r12,HIGH_ADDR(MPPIwork)				/* Get the top half of the data area */
-			rlwinm	r9,r9,5,23,26						/* Clean this up */
-			ori		r12,r12,LOW_ADDR(MPPIwork)			/* Get the bottom half of the data area */
-			la		r9,EXT(MPPICPUs)-MPPIwork(r9)			/* Point into the proccessor control area */
-			mflr	r11									/* Save our return */
-			add		r9,r9,r12							/* Point right at the entry */
-
-/*			We'll come in here if we're stopped and found the 'rupt via polling */
-/*			or we were kicked off by the PollSIGP call.  We  need */
-/*			to wipe out the interrupt request no matter how we got here. */
-
-SimRupt:	mfmsr	r4									/* Get the MSR */
-
-			la		r8,MPPICPU0-MPPIwork(r12)			/* Get address of main processor's work area */
-			ori		r5,r4,0x0010						/* Turn on the DDAT bit */
-			cmplw	cr0,r8,r9							/* Are we on the main? */
-			cmplw	cr1,r4,r4							/* Set CR1 to indicate we've cleared any 'rupts */
-			bne		SecondarySig						/* Go if we are not on main processor... */
-
-/* */
-/*			Handle the secondary to primary signal */
-/* */
-
-PrimarySig:
-
-			lwz		r8,MPPIGrandC-MPPIwork(r12)			/* Get the address of the Grand Central area base */
-			mtmsr	r5									/* Turn on DDAT */
-			isync										/* Now don't be usin' dem speculative executions */
-			li		r7,EventsReg						/* Get address of the interrupt events register */
-			lwbrx	r6,r7,r8							/* Grab the interruption events */
-
-			lis		r5,0x4000							/* Get the mask for the Ext10 pin */
-			and.	r0,r6,r5							/* See if our bit is on */
-			li		r7,ClearReg							/* Point to the interruption clear register */
-		
-			beq+	SkpClr								/* Skip the clear 'cause it's supposed to be soooo slow... */
-			
-			stwbrx	r5,r7,r8							/* Reset the interrupt latch */
-			eieio										/* Fence off the last 'rupt */
-
-SkpClr:		mtmsr	r4									/* Set MSR to entry state */
-			isync										/* Make sure we ain't gunked up no future storage references */
-		
-			bne+	IdleWait							/* Go join up and decode the function... */
-			
-			mtlr	r11									/* Restore return address */
-			andc.	r0,r6,r5							/* Any other bits on? */
-			li		r3,kMPVainInterrupt					/* Assume we got nothing */
-			beqlr										/* We got nothing, tell 'em to eat 'rupt... */
-			li		r3,kMPIOInterruptPending			/* Tell them to process an I/O 'rupt */
-			blr											/* Ignore the interrupt... */
-
-/* */
-/*			Handle the primary to secondary signal */
-/* */
-
-SecondarySig:
-			lwz		r3,MPPICStat(r9)					/* Pick up our status word */
-			lis		r8,HammerHead>>16					/* Get the address of the hammerhead (used during INIT on non-main processor) */
-			rlwinm.	r3,r3,0,3,3							/* Check if we are already "in-the-know" (all started up) */
-			beq-	UseAltAddr							/* Nope, use hardcoded Hammerhead address */
-			lwz		r8,MPPIHammer-MPPIwork(r12)			/* Get the kernel's HammerHead area */
-
-UseAltAddr:	mtmsr	r5									/* Turn on DDAT */
-			isync										/* Now don't be usin' dem speculative executions */
-			li		r0,SecInt							/* Get the Secondary interrupt bit */
-			stb		r0,IntReg(r8)						/* Reset the interrupt request */
-			mtmsr	r4									/* Set MSR to entry state */
-			eieio										/* Fence me in */
-			isync										/* Make sure we ain't gunked up no future storage references */
-			
-			b		IdleWait							/* Go decode this request... */
-			
-/******************************************************************************************************** */
-/******************************************************************************************************** */
-/* */
-/*			This is the idle wait.   */
-/* */
-/*			We're stuck in here so long as we are stopped or reset. */
-/*			All functions except for "start" pass back through here.  Start is weird because */
-/*			it is an initial thing, i.e., we can't have gotten here via any kind of exception, */
-/*			so there is no state to restore.  The "started" code is expected to require no know */
-/*			state and will take care of all initialization/fixup required. */
-/* */
-/******************************************************************************************************** */
-/******************************************************************************************************** */
-
-BadRuptState:											/* We don't do anything special yet for a bad state, just eat request */
-KillBusy:	rlwinm	r3, r3, 0, 2, 31					/* Remove the message pending flags. */
-			rlwinm	r3, r3, 0, 24, 16					/* Set the function to idle. */
-			stw		r3,MPPICStat(r9)					/* Update/unlock the status word. */
-
-ReenterWait: cmplwi	cr1,r9,0							/* Turn off the 'rupt cleared flag */
-
-IdleWait:	lis		r4,MPPICBusy>>16					/* Get busy status */
-
-SpinIdle:				
-			lwz		r3,MPPICStat(r9)					/* Pick up our status word */
-		
-			and.	r5,r3,r4							/* Isolate the busy bit */
-			lis		r6,MPPICPass>>16					/* Get the passed busy flag */
-			bne		TooBusy								/* Work, work, work, that's all we do is work... */
-			
-			rlwinm.	r5,r3,0,4,4							/* See if we are stopped */
-			lwz		r8,MPPICPriv(r9)					/* Pick up our private flags */
-			bne-	SpinIdle							/* Yeah, keep spinning... */
-			
-			
-/* */
-/*			Restore the state and get outta here.  Now, we shouldn't be in a reset state and not be stopped, */
-/*			so we can go ahead and safely return up a level because it exists.  If we are reset, no state exists */
-/*			and we should always be stopped. */
-/* */
-			
-			rlwinm	r4, r8, 1, 0, 0 					/* Get the explicit run bit, shifted left one. */
-			rlwinm.	r5, r8, 0, 0, 0						/* See if there is a SIGP signal pending */
-			and		r4, r8, r4							/* Turn off the SIGP pending bit if this was not an explicit run */
-														/* Also the explicit run bit is cleared */
-			mtlr	r11									/* Restore the return point */
-			li		r3,kMPVainInterrupt					/* Tell the interrupt handler to ignore the interrupt */
-			stw		r4,MPPICPriv(r9)					/* Set that flag back for later */
-			beqlr										/* Time to leave if we ate the 'rupt... */
-
-			li		r3,kMPSignalPending					/* Set that there is a SIGP interruption pending */
-			
-			blr											/* Go away, let our caller handle this thing... QED!!!!!!!!! */
-
-/* */
-/*           QQQQQ       EEEEEEEEEE    DDDDDDDDD */
-/*         QQQQQQQQQ     EEEEEEEEEE    DDDDDDDDDDD */
-/*        QQQQ   QQQQ    EEEE          DDD     DDD */
-/*       QQQQ     QQQQ   EEEEEEEEEE    DDD     DDD */
-/*       QQQQ   Q QQQQ   EEEEEEEEEE    DDD     DDD */
-/*        QQQQ  QQQQQ    EEEE          DDD     DDD */
-/*         QQQQQQQQQQQ   EEEEEEEEEE    DDDDDDDDDDD */
-/*           QQQQQ QQQ   EEEEEEEEEE    DDDDDDDDD */
-/* */
-/*			(I finished here) */
-/* */
-
-			
-/* */
-/*			This is where we decode the function and do what's right. */
-/*			First we need to check if it's really time to do something. */
-/* */
-
-TooBusy:	and.	r5,r3,r6							/* See if the passed flag is on */
-			beq		SpinIdle							/* No, not yet, try the whole smear again... */
-			
-			beq+	cr1,KeepRupt						/* Don't clear 'rupt if we already did (or entered via RunSIGRun) */
-
-			lwz		r5,MPPICPriv(r9)					/* Get the private flags */
-			rlwinm.	r5, r5, 0, 1, 1						/* Did we enter via RunSIGPRun? */
-			beq		SimRupt								/* Nope, 's'ok, go clear physical 'rupt... */
-			
-KeepRupt:
-			bl		GetOurBase							/* Get our address */
-GetOurBase:	rlwinm	r4,r3,26,22,29						/* Get the opcode index * 4 */
-			mflr	r12									/* Get the base address */
-			la		r7,LOW_ADDR(IFuncTable-GetOurBase)(r12)		/* Point to the function table */
-			
-			cmplwi	cr0,r4,7*4							/* See if they sent us some bogus junk */
-														/* Change 7 if we add more functions */
-			add		r7,r7,r4							/* Point right at the entry */
-			bgt-	KillBusy							/* Bad request code, reset busy and eat it... */
-			
-			mtlr	r7									/* Set up the LR */
-			
-			blr											/* Go execute the function... */
-	
-IFuncTable:
-			b		KillBusy							/* This handles the signal in vain... */
-			b		IStart								/* This handles the start function */
-			b		IResume								/* This handles the resume function */
-			b		IStop								/* This handles the stop function */
-			b		ISIGP								/* This handles the SIGP function */
-			b		IStatus								/* This handles the store status function */
-			b		ITBsync								/* This handles the synchronize timer base function */
-			b		IReset								/* This handles the reset function */
-
-/******************************************************************************************************** */
-/******************************************************************************************************** */
-/* */
-/*			Here are the functions handled at interrupt time */
-/* */
-/******************************************************************************************************** */
-/******************************************************************************************************** */
-
-/******************************************************************************************************** */
-/* */
-/*			The Start function.  This guy requires that the processor be in the reset and online state. */
-/* */
-/******************************************************************************************************** */
-
-IStart:		lis		r4,MPPICOnline>>16					/* Get bits required to be on */
-			isync										/* Make sure we haven't gone past here */
-			and		r6,r3,r4							/* See if they are on */
-			cmplw	cr1,r6,r4							/* Are they all on? */
-			lwz		r4,MPPICParm0(r9)					/* Get the physical address of the code to go to */
-			bne-	cr1,BadRuptState					/* Some required state bits are off */
-			rlwinm	r3,r3,0,2,31						/* Kill the busy bits */
-			rlwinm	r3,r3,0,24,15						/* Set the function to idle */
-			oris	r3,r3,MPPICReady>>16				/* Set ready state */
-			rlwinm	r3,r3,0,5,3							/* Clear out the stop bit */
-			mtlr	r4									/* Set the LR */
-			stw		r3,MPPICStat(r9)					/* Clear out the status flags */
-			lwz		r3,MPPICParm2(r9)					/* Get pass-thru parameter */
-			blrl										/* Start up the code... */
-/* */
-/*			The rules for coming back here via BLR are just opposite the normal way:  you can trash R0-R3 and */
-/*			R13-R31, all the CRs; don't touch SPRG1 or SPRG3, the MSR, the SRs or BATs 0 and 1. */
-/*			Follow these simple rules and you allowed back; don't follow them and die. */
-/*			We only come back here if there is some kind of startup failure so's we can try again later */
-/* */
-
-			lwz		r3,MPPICStat(r9)					/* Get back the status word */
-			cmplw	cr1,r4,r4							/* Show that we have already taken care of the 'rupt */
-			rlwinm	r3,r3,0,4,2							/* Reset the ready bit */
-			b		KillBusy							/* Back into the fold... */
-
-/******************************************************************************************************** */
-/* */
-/*			The Resume function.  This guy requires that the processor be online and ready. */
-/* */
-/******************************************************************************************************** */
-
-IResume:	lis		r4,(MPPICOnline+MPPICReady)>>16		/* Get states required to be set */
-			and		r6,r3,r4							/* See if they are on */
-			cmplw	cr0,r6,r4							/* Are they all on? */
-			bne-	BadRuptState						/* Some required off state bits are on */
-			rlwinm	r3,r3,0,5,3							/* Clear out the stop bit */
-			b		KillBusy							/* Get going... */
-
-/******************************************************************************************************** */
-/* */
-/*			The Stop function.  All we care about here is that the guy is online. */
-/* */
-/******************************************************************************************************** */
-
-IStop:		lis		r4,MPPICOnline>>16					/* All we care about is if we are online or not */
-			and.	r6,r3,r4							/* See if we are online */
-			beq-	BadRuptState						/* Some required off state bits are on */
-			oris	r3,r3,MPPICStop>>16					/* Set the stop bit */
-			b		KillBusy							/* Get stopped... */
-
-
-/******************************************************************************************************** */
-/* */
-/*			The SIGP function.  All we care about here is that the guy is online. */
-/* */
-/******************************************************************************************************** */
-
-ISIGP:		lis		r4,(MPPICOnline+MPPICReady)>>16		/* Get states required to be set */
-			and		r6,r3,r4							/* See if they are on */
-			lwz		r7,MPPICPriv(r9)					/* Get the private flags */
-			cmplw	cr0,r6,r4							/* Are they all on? */
-			oris	r6,r7,(MPPICSigp>>16)&0x0000FFFF	/* Set the SIGP pending bit */
-			bne-	BadRuptState						/* Some required off state bits are on */
-			lwz		r4,MPPICParm0(r9)					/* Get the SIGP parameter */
-			stw		r6,MPPICPriv(r9)					/* Stick the pending bit back */
-			stw		r4,MPPICParm0BU(r9)					/* Back up parm 0 so it is safe once we unlock */
-			b		KillBusy							/* Get stopped... */
-
-/******************************************************************************************************** */
-/* */
-/*			The store status function.  This guy requires that the processor be in the stopped state. */
-/* */
-/******************************************************************************************************** */
-
-IStatus:	lis		r4,MPPICOnline>>16					/* All we care about is if we are online or not */
-			and.	r6,r3,r4							/* See if we are online */
-			isync										/* Make sure we havn't gone past here */
-			beq-	BadRuptState						/* Some required off state bits are on */
-			lwz		r4,MPPICParm0(r9)					/* Get the status area physical address */
-			rlwinm.	r6,r3,0,3,3							/* Test processor ready */
-			
-			beq		INotReady							/* Not ready, don't assume valid exception save area */
-			bl		StoreStatus							/* Go store off all the registers 'n' stuff */
-			b		KillBusy							/* All done... */
-			
-INotReady:
-			lis		r7,0xDEAD							/* Get 0xDEAD + 1 */
-			ori		r7,r7,0xF1D0						/* Get 0xDEADF1D0 */
-			stw		r7,CSAgpr+(0*4)(r4)					/* Store invalid R0 */
-			stw		r7,CSAgpr+(1*4)(r4)					/* Store invalid R1 */
-			stw		r7,CSAgpr+(2*4)(r4)					/* Store invalid R2 */
-			stw		r7,CSAgpr+(3*4)(r4)					/* Store invalid R3 */
-			stw		r7,CSAgpr+(4*4)(r4)					/* Store invalid R4 */
-			stw		r7,CSAgpr+(5*4)(r4)					/* Store invalid R5 */
-			stw		r7,CSAgpr+(6*4)(r4)					/* Store invalid R6 */
-			stw		r7,CSAgpr+(7*4)(r4)					/* Store invalid R7 */
-			stw		r7,CSAgpr+(8*4)(r4)					/* Store invalid R8 */
-			stw		r7,CSAgpr+(9*4)(r4)					/* Store invalid R9 */
-			stw		r7,CSAgpr+(10*4)(r4)				/* Store invalid R10 */
-			stw		r7,CSAgpr+(11*4)(r4)				/* Store invalid R11 */
-			stw		r7,CSAgpr+(12*4)(r4)				/* Store invalid R12 */
-			stw		r13,CSAgpr+(13*4)(r4)				/* Save general registers */
-			stw		r14,CSAgpr+(14*4)(r4)				/* Save general registers */
-			stw		r15,CSAgpr+(15*4)(r4)				/* Save general registers */
-			stw		r16,CSAgpr+(16*4)(r4)				/* Save general registers */
-			stw		r17,CSAgpr+(17*4)(r4)				/* Save general registers */
-			stw		r18,CSAgpr+(18*4)(r4)				/* Save general registers */
-			stw		r19,CSAgpr+(19*4)(r4)				/* Save general registers */
-			stw		r20,CSAgpr+(20*4)(r4)				/* Save general registers */
-			stw		r21,CSAgpr+(21*4)(r4)				/* Save general registers */
-			stw		r22,CSAgpr+(22*4)(r4)				/* Save general registers */
-			stw		r23,CSAgpr+(23*4)(r4)				/* Save general registers */
-			stw		r24,CSAgpr+(24*4)(r4)				/* Save general registers */
-			stw		r25,CSAgpr+(25*4)(r4)				/* Save general registers */
-			stw		r26,CSAgpr+(26*4)(r4)				/* Save general registers */
-			stw		r27,CSAgpr+(27*4)(r4)				/* Save general registers */
-			stw		r28,CSAgpr+(28*4)(r4)				/* Save general registers */
-			stw		r29,CSAgpr+(29*4)(r4)				/* Save general registers */
-			stw		r30,CSAgpr+(30*4)(r4)				/* Save general registers */
-			stw		r31,CSAgpr+(31*4)(r4)				/* Save general registers */
-			bl		StoreLiveStatus
-			b		KillBusy
-
-/* */
-/*			Save the whole status.  Lot's of busy work. */
-/*			Anything marked unclean is of the devil and should be shunned.  Actually, it depends upon  */
-/*			knowledge of firmware control areas and is no good for a plug in.  But, we've sacrificed the */
-/*			white ram and are standing within a circle made of his skin, so we can dance with the devil */
-/*			safely. */
-/* */
-
-StoreStatus:
-			mfspr	r10,sprg0							/* Get the pointer to the exception save area (unclean) */
-			
-			lwz		r5,saver0(r13)						/* Get R0 (unclean) */
-			lwz		r6,saver1(r13)						/* Get R1 (unclean) */
-			lwz		r7,saver2(r13)						/* Get R2 (unclean) */
-			stw		r5,CSAgpr+(0*4)(r4)					/* Save R0 */
-			stw		r6,CSAgpr+(1*4)(r4)					/* Save R1 */
-			stw		r7,CSAgpr+(2*4)(r4)					/* Save R2 */
-			lwz		r5,saver3(r13)						/* Get R3 (unclean) */
-			lwz		r6,saver4(r13)						/* Get R4 (unclean) */
-			lwz		r7,saver5(r13)						/* Get R5 (unclean) */
-			stw		r5,CSAgpr+(3*4)(r4)					/* Save R3 */
-			stw		r6,CSAgpr+(4*4)(r4)					/* Save R4 */
-			stw		r7,CSAgpr+(5*4)(r4)					/* Save R5 */
-			lwz		r5,saver6(r13)						/* Get R6 (unclean) */
-			lwz		r6,saver7(r13)						/* Get R7 (unclean) */
-			lwz		r7,saver8(r13)						/* Get R8 (unclean) */
-			stw		r5,CSAgpr+(6*4)(r4)					/* Save R6 */
-			stw		r6,CSAgpr+(7*4)(r4)					/* Save R7 */
-			stw		r7,CSAgpr+(8*4)(r4)					/* Save R8 */
-			lwz		r5,saver9(r13)						/* Get R9 (unclean) */
-			lwz		r6,saver10(r13)						/* Get R10 (unclean) */
-			lwz		r7,saver11(r13)						/* Get R11 (unclean) */
-			stw		r5,CSAgpr+(9*4)(r4)					/* Save R9 */
-			stw		r6,CSAgpr+(10*4)(r4)				/* Save R10 */
-			lwz		r5,saver12(r13)						/* Get R12 (unclean) */
-			stw		r7,CSAgpr+(11*4)(r4)				/* Save R11 */
-			stw		r5,CSAgpr+(12*4)(r4)				/* Save R12 */
-			
-			lwz		r5,saver13(r13)						/* Get R13 (unclean) */
-			lwz		r6,saver14(r13)						/* Get R14 (unclean) */
-			lwz		r7,saver15(r13)						/* Get R15 (unclean) */
-			stw		r5,CSAgpr+(13*4)(r4)				/* Save R13 */
-			stw		r6,CSAgpr+(14*4)(r4)				/* Save R14 */
-			stw		r7,CSAgpr+(15*4)(r4)				/* Save R15 */
-			lwz		r5,saver16(r13)						/* Get R16 (unclean) */
-			lwz		r6,saver17(r13)						/* Get R17 (unclean) */
-			lwz		r7,saver18(r13)						/* Get R18 (unclean) */
-			stw		r5,CSAgpr+(16*4)(r4)				/* Save R16 */
-			stw		r6,CSAgpr+(17*4)(r4)				/* Save R17 */
-			stw		r7,CSAgpr+(18*4)(r4)				/* Save R18 */
-			lwz		r5,saver19(r13)						/* Get R19 (unclean) */
-			lwz		r6,saver20(r13)						/* Get R20 (unclean) */
-			lwz		r7,saver21(r13)						/* Get R21 (unclean) */
-			stw		r5,CSAgpr+(19*4)(r4)				/* Save R19 */
-			stw		r6,CSAgpr+(20*4)(r4)				/* Save R20 */
-			stw		r7,CSAgpr+(21*4)(r4)				/* Save R21 */
-			lwz		r5,saver22(r13)						/* Get R22 (unclean) */
-			lwz		r6,saver23(r13)						/* Get R23 (unclean) */
-			lwz		r7,saver24(r13)						/* Get R24 (unclean) */
-			stw		r5,CSAgpr+(22*4)(r4)				/* Save R22 */
-			stw		r6,CSAgpr+(23*4)(r4)				/* Save R23*/
-			stw		r7,CSAgpr+(24*4)(r4)				/* Save R24 */
-			lwz		r5,saver25(r13)						/* Get R25 (unclean) */
-			lwz		r6,saver26(r13)						/* Get R26 (unclean) */
-			lwz		r7,saver27(r13)						/* Get R27 (unclean) */
-			stw		r5,CSAgpr+(25*4)(r4)				/* Save R25 */
-			stw		r6,CSAgpr+(26*4)(r4)				/* Save R26 */
-			stw		r7,CSAgpr+(27*4)(r4)				/* Save R27 */
-
-			lwz		r5,saver28(r13)						/* Get R28 (unclean) */
-			lwz		r6,saver29(r13)						/* Get R29 (unclean) */
-			lwz		r7,saver30(r13)						/* Get R30 (unclean) */
-			stw		r5,CSAgpr+(28*4)(r4)				/* Save R28 */
-			lwz		r5,saver31(r13)						/* Get R31(unclean) */
-			stw		r6,CSAgpr+(29*4)(r4)				/* Save R29 */
-			stw		r7,CSAgpr+(30*4)(r4)				/* Save R30 */
-			stw		r5,CSAgpr+(31*4)(r4)				/* Save R31 */
-
-StoreLiveStatus:
-			mfmsr	r5									/* Get the current MSR */
-			ori		r6,r5,0x2000						/* Turn on floating point instructions */
-			mtmsr	r6									/* Turn them on */
-			isync										/* Make sure they're on */
-			
-			stfd 	f0,CSAfpr+(0*8)(r4)					/* Save floating point registers */
-			stfd	f1,CSAfpr+(1*8)(r4)					/* Save floating point registers */
-			stfd	f2,CSAfpr+(2*8)(r4)					/* Save floating point registers */
-			stfd	f3,CSAfpr+(3*8)(r4)					/* Save floating point registers */
-			stfd	f4,CSAfpr+(4*8)(r4)					/* Save floating point registers */
-			stfd	f5,CSAfpr+(5*8)(r4)					/* Save floating point registers */
-			stfd	f6,CSAfpr+(6*8)(r4)					/* Save floating point registers */
-			stfd	f7,CSAfpr+(7*8)(r4)					/* Save floating point registers */
-			stfd	f8,CSAfpr+(8*8)(r4)					/* Save floating point registers */
-			stfd	f9,CSAfpr+(9*8)(r4)					/* Save floating point registers */
-			stfd	f10,CSAfpr+(10*8)(r4)				/* Save floating point registers */
-			stfd	f11,CSAfpr+(11*8)(r4)				/* Save floating point registers */
-			stfd	f12,CSAfpr+(12*8)(r4)				/* Save floating point registers */
-			stfd	f13,CSAfpr+(13*8)(r4)				/* Save floating point registers */
-			stfd	f14,CSAfpr+(14*8)(r4)				/* Save floating point registers */
-			stfd	f15,CSAfpr+(15*8)(r4)				/* Save floating point registers */
-			stfd	f16,CSAfpr+(16*8)(r4)				/* Save floating point registers */
-			stfd	f17,CSAfpr+(17*8)(r4)				/* Save floating point registers */
-			stfd	f18,CSAfpr+(18*8)(r4)				/* Save floating point registers */
-			stfd	f19,CSAfpr+(19*8)(r4)				/* Save floating point registers */
-			stfd	f20,CSAfpr+(20*8)(r4)				/* Save floating point registers */
-			stfd	f21,CSAfpr+(21*8)(r4)				/* Save floating point registers */
-			stfd	f22,CSAfpr+(22*8)(r4)				/* Save floating point registers */
-			stfd	f23,CSAfpr+(23*8)(r4)				/* Save floating point registers */
-			stfd	f24,CSAfpr+(24*8)(r4)				/* Save floating point registers */
-			stfd	f25,CSAfpr+(25*8)(r4)				/* Save floating point registers */
-			stfd	f26,CSAfpr+(26*8)(r4)				/* Save floating point registers */
-			stfd	f27,CSAfpr+(27*8)(r4)				/* Save floating point registers */
-			stfd	f28,CSAfpr+(28*8)(r4)				/* Save floating point registers */
-			stfd	f29,CSAfpr+(29*8)(r4)				/* Save floating point registers */
-			stfd	f30,CSAfpr+(30*8)(r4)				/* Save floating point registers */
-			stfd	f31,CSAfpr+(31*8)(r4)				/* Save floating point registers */
-			
-			mffs	f1									/* Get the FPSCR */
-			stfd	f1,CSAfpscr-4(r4)					/* Save the whole thing (we'll overlay the first half with CR later) */
-			
-			lfd		f1,CSAfpr+(1*4)(r4)					/* Restore F1 */
-			
-			mtmsr	r5									/* Put the floating point back to what it was before */
-			isync										/* Wait for it */
-			
-			lwz		r6,savecr(r13)						/* Get the old CR (unclean) */
-			stw		r6,CSAcr(r4)						/* Save the CR */
-			
-			mfxer	r6									/* Get the XER */
-			stw		r6,CSAxer(r4)						/* Save the XER */
-			
-			lwz		r6,savelr(r13)						/* Get the old LR (unclean) */
-			stw		r6,CSAlr(r4)						/* Save the LR */
-			
-			mfctr	r6									/* Get the CTR */
-			stw		r6,CSActr(r4)						/* Save the CTR */
-			
-STtbase:	mftbu	r5									/* Get the upper timebase */
-			mftb	r6									/* Get the lower */
-			mftbu	r7									/* Get the top again */
-			cmplw	cr0,r5,r7							/* Did it tick? */
-			bne-	STtbase								/* Yeah, do it again... */
-			
-			mfdec	r7									/* Get the decrimenter (make it at about the same time as the TB) */
-			stw		r7,CSAdec(r4)						/* Save the decrimenter */
-			
-			
-			stw		r5,CSAtbu(r4)						/* Stash the top part */
-			stw		r6,CSAtbl(r4)						/* Stash the lower part */
-			
-			lwz		r5,savesrr1(r13)					/* SRR1 at exception is as close as we get to the MSR (unclean) */
-			lwz		r6,savesrr0(r13)					/* Get SRR0 also */
-			stw		r5,CSAmsr(r4)						/* Save the MSR */
-			stw		r6,CSApc(r4)						/* Save the PC */
-			stw		r5,CSAsrr1(r4)						/* Set SRR1 also */
-			stw		r6,CSAsrr0(r4)						/* Save SRR0 */
-			
-			mfpvr	r5									/* Get the PVR */
-			stw		r5,CSApvr(r4)						/* Save the PVR */
-			
-			mfspr	r5,pir								/* Get the PIR */
-			stw		r5,CSApir(r4)						/* Save the PIR */
-			
-			mfspr	r5,ibat0u							/* Get the upper IBAT0 */
-			mfspr	r6,ibat0l							/* Get the lower IBAT0 */
-			stw		r5,CSAibat+(0*8+0)(r4)				/* Save the upper IBAT0 */
-			stw		r6,CSAibat+(0*8+4)(r4)				/* Save the upper IBAT0 */
-
-			mfspr	r5,ibat1u							/* Get the upper IBAT1 */
-			mfspr	r6,ibat1l							/* Get the lower IBAT1 */
-			stw		r5,CSAibat+(1*8+0)(r4)				/* Save the upper IBAT1 */
-			stw		r6,CSAibat+(1*8+4)(r4)				/* Save the upper IBAT1 */
-
-			mfspr	r5,ibat2u							/* Get the upper IBAT2 */
-			mfspr	r6,ibat2l							/* Get the lower IBAT2 */
-			stw		r5,CSAibat+(2*8+0)(r4)				/* Save the upper IBAT2 */
-			stw		r6,CSAibat+(2*8+4)(r4)				/* Save the upper IBAT2 */
-
-			mfspr	r5,ibat3u							/* Get the upper IBAT3 */
-			mfspr	r6,ibat3l							/* Get the lower IBAT3 */
-			stw		r5,CSAibat+(3*8+0)(r4)				/* Save the upper IBAT3 */
-			stw		r6,CSAibat+(3*8+4)(r4)				/* Save the upper IBAT3 */
-
-			mfspr	r5,dbat0u							/* Get the upper DBAT0 */
-			mfspr	r6,dbat0l							/* Get the lower DBAT0 */
-			stw		r5,CSAdbat+(0*8+0)(r4)				/* Save the upper DBAT0 */
-			stw		r6,CSAdbat+(0*8+4)(r4)				/* Save the upper DBAT0 */
-
-			mfspr	r5,dbat1u							/* Get the upper DBAT1 */
-			mfspr	r6,dbat1l							/* Get the lower DBAT1 */
-			stw		r5,CSAdbat+(1*8+0)(r4)				/* Save the upper DBAT1 */
-			stw		r6,CSAdbat+(1*8+4)(r4)				/* Save the upper DBAT1 */
-
-			mfspr	r5,dbat2u							/* Get the upper DBAT2 */
-			mfspr	r6,dbat2l							/* Get the lower DBAT2 */
-			stw		r5,CSAdbat+(2*8+0)(r4)				/* Save the upper DBAT2 */
-			stw		r6,CSAdbat+(2*8+4)(r4)				/* Save the upper DBAT2 */
-
-			mfspr	r5,dbat3u							/* Get the upper DBAT3 */
-			mfspr	r6,dbat3l							/* Get the lower DBAT3 */
-			stw		r5,CSAdbat+(3*8+0)(r4)				/* Save the upper DBAT3 */
-			stw		r6,CSAdbat+(3*8+4)(r4)				/* Save the upper DBAT3 */
-			
-			mfsdr1	r5									/* Get the SDR1 */
-			stw		r5,CSAsdr1(r4)						/* Save the SDR1 */
-			
-			mfsr	r5,sr0								/* Get SR 0 */
-			mfsr	r6,sr1								/* Get SR 1 */
-			mfsr	r7,sr2								/* Get SR 2 */
-			stw		r5,CSAsr+(0*4)(r4)					/* Save SR 0 */
-			stw		r6,CSAsr+(1*4)(r4)					/* Save SR 1 */
-			mfsr	r5,sr3								/* Get SR 3 */
-			mfsr	r6,sr4								/* Get SR 4 */
-			stw		r7,CSAsr+(2*4)(r4)					/* Save SR 2 */
-			mfsr	r7,sr5								/* Get SR 5 */
-			stw		r5,CSAsr+(3*4)(r4)					/* Save SR 3 */
-			stw		r6,CSAsr+(4*4)(r4)					/* Save SR 4 */
-			mfsr	r5,sr6								/* Get SR 6 */
-			mfsr	r6,sr7								/* Get SR 7 */
-			stw		r7,CSAsr+(5*4)(r4)					/* Save SR 5 */
-			mfsr	r7,sr8								/* Get SR 8 */
-			stw		r5,CSAsr+(6*4)(r4)					/* Save SR 6 */
-			stw		r6,CSAsr+(7*4)(r4)					/* Save SR 7 */
-			mfsr	r5,sr9								/* Get SR 9 */
-			mfsr	r6,sr10								/* Get SR 11 */
-			stw		r7,CSAsr+(8*4)(r4)					/* Save SR 8 */
-			mfsr	r7,sr11								/* Get SR 11 */
-			stw		r5,CSAsr+(9*4)(r4)					/* Save SR 9 */
-			stw		r6,CSAsr+(10*4)(r4)					/* Save SR 10 */
-			mfsr	r5,sr12								/* Get SR 12 */
-			mfsr	r6,sr13								/* Get SR 13 */
-			stw		r7,CSAsr+(11*4)(r4)					/* Save SR 11 */
-			mfsr	r7,sr14								/* Get SR 14 */
-			stw		r5,CSAsr+(12*4)(r4)					/* Save SR 12 */
-			stw		r6,CSAsr+(13*4)(r4)					/* Save SR 13 */
-			mfsr	r5,sr15								/* Get SR 15 */
-			stw		r7,CSAsr+(14*4)(r4)					/* Save SR 14 */
-			stw		r5,CSAsr+(15*4)(r4)					/* Save SR 15 */
-			
-			mfdar	r6									/* Get the DAR */
-			stw		r6,CSAdar(r4)						/* Save it */
-			
-			mfdsisr	r5									/* Get the DSISR */
-			stw		r5,CSAdsisr(r4)						/* Save it */
-			
-			stw		r10,CSAsprg+(1*4)(r4)				/* Save SPRG1 */
-			mfspr	r7,sprg0							/* Get SPRG0 */
-			mfspr	r6,sprg2							/* Get SPRG2 */
-			stw		r7,CSAsprg+(0*4)(r4)				/* Save SPRG0 */
-			mfspr	r5,sprg3							/* Get SPRG3 */
-			stw		r6,CSAsprg+(2*4)(r4)				/* Save SPRG2 */
-			stw		r5,CSAsprg+(3*4)(r4)				/* Save SPRG4 */
-			
-			mfspr	r6,1013								/* Get the DABR */
-			mfspr	r7,1010								/* Get the IABR */
-			stw		r6,CSAdabr(r4)						/* Save the DABR */
-			stw		r7,CSAiabr(r4)						/* Save the IABR */
-			
-			mfspr	r5,282								/* Get the EAR */
-			stw		r5,CSAear(r4)						/* Save the EAR */
-			
-			lis		r7,0xDEAD							/* Get 0xDEAD */
-			ori		r7,r7,0xF1D0						/* Get 0xDEADF1D0 */
-			
-			mfpvr	r5									/* Get the processor type */
-			rlwinm	r5,r5,16,16,31						/* Isolate the processor */
-			cmplwi	cr1,r5,4							/* Set CR1_EQ if this is a plain 604, something else if it's a 604E */
-			
-			mfspr	r6,hid0								/* Get HID0 */
-			mr		r5,r7								/* Assume 604 */
-			beq		cr1,NoHID1							/* It is... */
-			mfspr	r5,hid1								/* Get the HID1 */
-
-NoHID1:		stw		r6,CSAhid+(0*4)(r4)					/* Save HID0 */
-			stw		r5,CSAhid+(1*4)(r4)					/* Save HID1 */
-			stw		r7,CSAhid+(2*4)(r4)					/* Save HID2 */
-			stw		r7,CSAhid+(3*4)(r4)					/* Save HID3 */
-			stw		r7,CSAhid+(4*4)(r4)					/* Save HID4 */
-			stw		r7,CSAhid+(5*4)(r4)					/* Save HID5 */
-			stw		r7,CSAhid+(6*4)(r4)					/* Save HID6 */
-			stw		r7,CSAhid+(7*4)(r4)					/* Save HID7 */
-			stw		r7,CSAhid+(8*4)(r4)					/* Save HID8 */
-			stw		r7,CSAhid+(9*4)(r4)					/* Save HID9 */
-			stw		r7,CSAhid+(10*4)(r4)				/* Save HID10 */
-			stw		r7,CSAhid+(11*4)(r4)				/* Save HID11 */
-			stw		r7,CSAhid+(12*4)(r4)				/* Save HID12 */
-			stw		r7,CSAhid+(13*4)(r4)				/* Save HID13 */
-			stw		r7,CSAhid+(14*4)(r4)				/* Save HID14 */
-			stw		r7,CSAhid+(15*4)(r4)				/* Save HID15 */
-			
-			mfspr	r6,952								/* Get MMCR0 */
-			mr		r5,r7								/* Assume 604 */
-			beq		NoMMCR1								/* It is... */
-			mfspr	r5,956								/* Get the MMCR1 */
-
-NoMMCR1:	stw		r6,CSAmmcr+(0*4)(r4)				/* Save MMCR0 */
-			stw		r5,CSAmmcr+(1*4)(r4)				/* Save MMCR1 */
-			
-			mfspr	r6,953								/* Get PMC1 */
-			mfspr	r5,954								/* Get PMC2 */
-			stw		r6,CSApmc+(0*4)(r4)					/* Save PMC1 */
-			stw		r5,CSApmc+(1*4)(r4)					/* Save PMC2 */
-			
-			mr		r6,r7								/* Assume 604 */
-			mr		r5,r7								/* Assume 604 */
-			beq		NoPMC3								/* Yeah... */
-			mfspr	r6,957								/* Get the PMC3 for a 604E */
-			mfspr	r5,958								/* Get the PMC4 for a 604E */
-			
-NoPMC3:		stw		r6,CSApmc+(2*4)(r4)					/* Save PMC3 */
-			stw		r5,CSApmc+(3*4)(r4)					/* Save PMC4 */
-
-			mfspr	r6,955								/* Get SIA */
-			mfspr	r5,959								/* Get SDA */
-			stw		r6,CSAsia(r4)						/* Save the SIA */
-			stw		r5,CSAsda(r4)						/* Save the SDA */
-			
-			stw		r7,CSAmq(r4)						/* There is no MQ on either the 604 or 604E */
-			
-			
-			lwz		r6,MPPICStat(r9)					/* Get the status of this processor */
-			lis		r10,MPPICReady>>16					/* Get the flag for reset or not */
-			li		r5,kSIGPResetState					/* Assume we're operating */
-			and.	r0,r6,r10							/* See if the ready bit is set */
-			lis		r10,MPPICStop>>16					/* Get the flag for stopped or not */
-			beq		SetStateInf							/* Go set that we are reset... */
-			and.	r0,r6,r10							/* Are we stopped? */
-			li		r5,kSIGPStoppedState				/* Assume we area */
-			bne		SetStateInf							/* We are, go set it... */
-			li		r5,kSIGPOperatingState				/* Not stopped, so we're going */
-			
-SetStateInf: stb		r5,CSAstate(r4)					/* Set the state byte */
-			
-			li		r0,1								/* Set the truth */
-			sync										/* Make sure it's stored */
-			
-			stb		r0,CSAregsAreValid(r4)				/* Set that the status is valid */
-
-			blr											/* We're done here... */
-			
-
-/******************************************************************************************************** */
-/* */
-/*			The synchronize time base function.  No state requirements for this one. */
-/* */
-/******************************************************************************************************** */
-
-ITBsync:												/* This handles the synchronize time base function */
-			lis		r12,HIGH_ADDR(MPPIwork)				/* Get the top of work area */
-			li		r0,MPPICfTBsy1						/* Get the flag for TB sync state 1 */
-			li		r7,0								/* Get a 0 */
-			ori		r12,r12,LOW_ADDR(MPPIwork)			/* Get low part of work area */
-			mttbl	r7									/* Clear the bottom of the TB so's there's noupper ticks */
-			mttbu	r7									/* Clear the top part, just 'cause I wanna */
-			
-			sync										/* Make sure all is saved */
-			stb		r0,MPPICStat+2(r9)					/* Tell the main dude to tell us the time */
-			isync										/* Make sure we don't go nowhere's */
-
-/* */
-/*			Remember that the sync'ing processor insures that the TB won't tick the high part for at least */
-/*			16k ticks.  That should be way longer than we need for the whole process here */
-/* */
-
-WaitTBLower: lwz	r5,MPPITBsync+4-MPPIwork(r12)		/* Get the lower part of the TB */
-			mttbl	r5									/* Put it in just in case it's set now */
-			mr.		r5,r5								/* Was it actually? */
-			beq+	WaitTBLower							/* Nope, go check again... */
-			lwz		r4,MPPITBsync-MPPIwork(r12)			/* Get the high order part */
-			mttbu	r4									/* Set the top half also */
-
-			stw		r7,MPPITBsync+4-MPPIwork(r12)		/* Tell 'em we've got it */
-			
-			sync
-			
-			li		r4,0								/* Clear this */
-			la		r5,MPPISncFght-32-MPPIwork(r12)		/* Point to the squared circle (our corner) */
-
-			b		TB1stPnch							/* Go take the first punch... */
-
-TBSargue:	
-			dcbf	0,r5								/* *** Fix cache coherency (data integrity) HW bug *** */
-			sync										/* *** Fix cache coherency (data integrity) HW bug *** */
-			lwz		r6,0(r5)							/* Listen for the procecution's argument */
-			mr.		r6,r6								/* See if they are done */
-			beq+	TBSargue							/* Nope, still going... */
-			
-TB1stPnch:	mftb	r7									/* They're done, time for rebuttal */
-			stw		r7,32(r5)							/* Make rebuttle */
-	
-			addi	r4,r4,1								/* Count rounds */
-
-			cmplwi	cr0,r4,10							/* See if we've gone 9 more rounds */
-			addi	r5,r5,64							/* Point to the next round areas */
-		
-			blt+	TBSargue							/* Not yet, come out of your corners fighting... */
-			
-/* */
-/*			We'll set the latest-up-to-datest from the other processor now */
-/* */
-TBSetTB:		
-			dcbf	0,r5								/* *** Fix cache coherency (data integrity) HW bug *** */
-			sync										/* *** Fix cache coherency (data integrity) HW bug *** */
-			lwz		r6,0(r5)							/* Listen for the procecution's argument */
-			mttbl	r6									/* Set it just in case it's ok */
-			mr.		r6,r6								/* See if they are done */
-			beq+	TBSetTB								/* Nope, still going... */
-
-/* */
-/*			Get average duration for each processor.  We skip the first pass on the asumption */
-/*			that the caches were not warmed up and it would take longer.  In proctice this */
-/*			is what was seen. */
-/* */
-
-			mr		r0,r11								/* Move return address to a safe register */
-
-			li		r4,0								/* Clear a counter */
-			li		r3,0								/* Clear accumulator for duration */
-			li		r10,0								/* Clear start time accumulator top half */
-			li		r11,0								/* Clear start time accumulator bottom half */
-			li		r1,0								/* Clear start time accumulator top half */
-			li		r2,0								/* Clear start time accumulator bottom half */
-			li		r10,0								/* Clear accumulator for durations */
-			la		r5,MPPISncFght+64-MPPIwork(r12)		/* Get second round start time address */
-		
-TBSaccumU:	lwz		r6,0(r5)							/* Get start time */
-			lwz		r11,32(r5)							/* Get the other processor's start time */
-			lwz		r7,64(r5)							/* Get end time */
-			lwz		r8,96(r5)							/* Other proc's end time */
-			sub		r7,r7,r6							/* Get duration */
-			sub		r8,r8,r11							/* Get other side's duration */
-			addi	r4,r4,1								/* Count arguments */
-			add		r3,r3,r7							/* Accumulate durations */
-			add		r2,r2,r7							/* Accumulate other side's durations */
-			cmplwi	cr0,r4,8							/* Have we gotten them all yet? */
-			addi	r5,r5,64							/* Step to the next argument */
-			blt+	TBSaccumU							/* We're not done yet... */
-
-			add		r7,r2,r3							/* Sum the two differences */
-			addi	r7,r7,0x10							/* Round up */
-			rlwinm	r7,r7,27,5,31						/* Get the average difference divided in half */
-
-			mftb	r8									/* Get the time now */
-			add		r8,r8,r7							/* Slide the window */
-			mttbl	r8									/* Set the time */
-			
-			stw		r12,MPPITBsync+4-MPPIwork(r12)		/* Show that we are done */
-			
-			lwz		r3,MPPICStat(r9)					/* Get back our status */
-			mr		r11,r0								/* Restore the return register */
-			b		KillBusy							/* We're all done now, done for it, c'est la vie... */
-			
-
-/******************************************************************************************************** */
-/* */
-/*			The reset function.  No state requirements for this one. */
-/*			This suicides the processor. Our caller is never returned to (good english).  The only way out of  */
-/*			this is a start function subsequently.  So, we give a flying f**k about the registers 'n' sutff. */
-/* */
-/******************************************************************************************************** */
-
-IReset:		lis		r28,0x8000							/* Turn on machine checks */
-			
-			ori		r28,r28,0xCC84						/* Enable caches, clear them,  */
-														/* disable serial execution and turn BHT on */
-			sync
-			mtspr	HID0,r28							/* Start the cache clear */
-			sync
-
-/* */
-/*			Clear out the TLB.  They be garbage after hard reset. */
-/* */
-
-			li		r0,512								/* Get number of TLB entries (FIX THIS) */
-			li		r3,0								/* Start at 0 */
-			mtctr	r0									/* Set the CTR */
-			
-IRpurgeTLB:	tlbie	r3									/* Purge this entry */
-			addi	r3,r3,4096							/* Next page */
-			bdnz	IRpurgeTLB							/* Do 'em all... */
-			
-			sync										/* Make sure all TLB purges are done */
-			tlbsync										/* Make sure on other processors also */
-			sync										/* Make sure the TLBSYNC is done */
-
-/* */
-/*			Clear out the BATs. */
-/* */
-
-			li		r3,0								/* Clear a register */
-			
-			mtspr	DBAT0L,r3							/* Clear BAT */
-			mtspr	DBAT0U,r3							/* Clear BAT */
-			mtspr	DBAT1L,r3							/* Clear BAT */
-			mtspr	DBAT1U,r3							/* Clear BAT */
-			mtspr	DBAT2L,r3							/* Clear BAT */
-			mtspr	DBAT2U,r3							/* Clear BAT */
-			mtspr	DBAT3L,r3							/* Clear BAT */
-			mtspr	DBAT3U,r3							/* Clear BAT */
-			
-			mtspr	IBAT0L,r3							/* Clear BAT */
-			mtspr	IBAT0U,r3							/* Clear BAT */
-			mtspr	IBAT1L,r3							/* Clear BAT */
-			mtspr	IBAT1U,r3							/* Clear BAT */
-			mtspr	IBAT2L,r3							/* Clear BAT */
-			mtspr	IBAT2U,r3							/* Clear BAT */
-			mtspr	IBAT3L,r3							/* Clear BAT */
-			mtspr	IBAT3U,r3							/* Clear BAT */
-
-/* */
-/*			Map 0xF0000000 to 0xFFFFFFFF for I/O; make it R/W non-cacheable */
-/*			Map	0x00000000 to 0x0FFFFFFF for mainstore; make it R/W cachable */
-/* */
-
-			lis		r6,0xF000							/* Set RPN to last segment */
-			ori		r6,r6,0x1FFF						/* Set up upper BAT for 256M, access both */
-			
-			lis		r7,0xF000							/* Set RPN to last segment */
-			ori		r7,r7,0x0032						/* Set up lower BAT for 256M, access both, non-cachable */
-		
-			mtspr	DBAT0L,r7							/* Setup ROM and I/O mapped areas */
-			mtspr	DBAT0U,r6							/* Now do the upper DBAT */
-			sync
-	
-			li		r6,0x1FFF							/* Set up upper BAT for 256M, access both */
-			li		r7,0x0012							/* Set up lower BAT for r/w access */
-			
-			mtspr	DBAT1L,r7							/* Set up an initial view of mainstore */
-			mtspr	DBAT1U,r6							/* Now do the upper DBAT */
-			sync
-
-/* */
-/*			Clean up SDR and segment registers */
-/* */
-
-			li		r3,0								/* Clear a register */
-			mtspr	SDR1,r3								/* Clear SDR1 */
-			
-			li		r4,0								/* Clear index for segment registers */
-			lis		r5,0x1000							/* Set the segment indexer */
-			
-IRclearSR:	mtsrin	r3,r4								/* Zero out the SR */
-			add.	r4,r4,r5							/* Point to the next segment */
-			bne-	IRclearSR							/* Keep going until we wrap back to 0 */
-			
-			lis		r3,(MPPICOnline+MPPICStop)>>16		/* Set the reset/online state flags */
-			b		KillBusy							/* Go wipe out the busy flags... */
-
-/*	(TEST/DEBUG) (TEST/DEBUG) (TEST/DEBUG) (TEST/DEBUG) (TEST/DEBUG) (TEST/DEBUG) (TEST/DEBUG) (TEST/DEBUG) (TEST/DEBUG)  */
-/* */
-/*			Here lies the Phoney Firmware used to test SIGPs.  Take this out later. */
-/* */
-/*	(TEST/DEBUG) (TEST/DEBUG) (TEST/DEBUG) (TEST/DEBUG) (TEST/DEBUG) (TEST/DEBUG) (TEST/DEBUG) (TEST/DEBUG) (TEST/DEBUG)  */
-
-mp_PhoneyFirmware:
-
-			li		r27,0x3040							/* Set floating point and machine checks on, IP to 0xFFF0xxxx */
-			mtmsr	r27									/* Load 'em on in */
-			isync
-			
-			bl		PhoneyBase							/* Make a base register */
-PhoneyBase:	mflr	r26									/* Get it */
-			addi	r26,r26,LOW_ADDR(MPPIbase-PhoneyBase)	/* Adjust it back */
-
-			la		r20,LOW_ADDR(rupttab-MPPIbase)(r26)		/* Get the address of the interrupt table */
-			la		r21,LOW_ADDR(rupttabend-MPPIbase)(r26)	/* Get the end of the table */
-			
-relocate:	lwz		r22,0(r20)							/* Get the displacement to routine */
-			add		r22,r22,r12							/* Relocate to the physical address */
-			stw		r22,0(r20)							/* Stick it back */
-			addi	r20,r20,4							/* Point to the next one */
-			cmplw	cr0,r20,r21							/* Still in table? */
-			ble+	cr0,relocate						/* Yeah... */
-			
-			la		r20,LOW_ADDR(rupttab-MPPIbase)(r26)	/* Get the interrupt table back again */
-			mtsprg	3,r20								/* Activate the phoney Rupt table */
-			
-			lis		r24,hi16(HammerHead)				/* Get the actual hammerhead address */
-			ori		r24,r24,0x0032						/* Make R/W non-cachable */
-			lwz		r23,MPPIHammer-MPPIwork(r12)		/* Get the address mapped on the main processor */
-			ori		r23,r23,0x0003						/* Set both super and user valid for 128KB */
-			
-			mtspr	DBAT0L,r24							/* Setup hammerhead's real address */
-			mtspr	DBAT0U,r23							/* Map hammerhead to the same virtual address as on the main processor */
-			sync										/* Make sure it is done */
-
-			la		r25,MPPICPU2-MPPIwork(r12)			/* Point to a phoney register save area */
-			mtsprg	1,r25								/* Phoney up initialized processor state */
-
-			lis		r24,0xFEED							/* Get 0xFEED */
-			ori		r24,r24,0xF1D0						/* Get 0xFEEDF1D0 */
-			
-			stw		r24,CSAgpr+(0*4)(r25)				/* Store invalid R0 */
-			stw		r24,CSAgpr+(1*4)(r25)				/* Store invalid R1 */
-			stw		r24,CSAgpr+(2*4)(r25)				/* Store invalid R2 */
-			stw		r24,CSAgpr+(3*4)(r25)				/* Store invalid R3 */
-			stw		r24,CSAgpr+(4*4)(r25)				/* Store invalid r4 */
-			stw		r24,CSAgpr+(5*4)(r25)				/* Store invalid R5 */
-			stw		r24,CSAgpr+(6*4)(r25)				/* Store invalid R6 */
-			stw		r24,CSAgpr+(7*4)(r25)				/* Store invalid r7 */
-			stw		r24,CSAgpr+(8*4)(r25)				/* Store invalid R8 */
-			stw		r24,CSAgpr+(9*4)(r25)				/* Store invalid R9 */
-			stw		r24,CSAgpr+(10*4)(r25)				/* Store invalid R10 */
-			stw		r24,CSAgpr+(11*4)(r25)				/* Store invalid R11 */
-			stw		r24,CSAgpr+(12*4)(r25)				/* Store invalid R12 */
-			
-waititout:	lwz		r25,0x30(br0)						/* Get wait count */
-			mfmsr	r24									/* Get the MSR */
-			addi	r25,r25,1							/* Bounce it up */
-			ori		r24,r24,0x8000						/* Turn on external interruptions */
-			stw		r25,0x30(br0)						/* Save back the count */
-			mtmsr	r24									/* Set it */
-			isync										/* Stop until we're here */
-			b		waititout							/* Loop forever... */
-			
-/* */
-/*			Phoney interrupt handlers */
-/* */
-
-pexternal:	mflr	r29									/* Get the LR value */
-			lwz		r29,0(r29)							/* Get the rupt code */
-			stw		r29,0x0B0(br0)						/* Save the code */
-			bl		GotSignal							/* Call the signal handler */
-			oris	r3,r3,0x8000						/* Turn on high bit so we see a code 0 */
-			stw		r3,0xA8(br0)						/* Save return code in debug area */
-			
-ignorerupt:	mflr	r29									/* Get the LR value */
-			lwz		r29,0(r29)							/* Get the rupt code */
-			stw		r29,0x0B0(br0)						/* Save the code */
-			rfi											/* Bail to from whence we commest... */
-			.long	0			
-			.long	0			
-			.long	0			
-			.long	0			
-			.long	0			
-			.long	0			
-			.long	0			
-
-rupttab:	.long	ignorerupt
-			.long	ignorerupt
-			.long	ignorerupt
-			.long	ignorerupt
-			.long	ignorerupt
-			.long	pexternal							/* Phoney external handler */
-			.long	ignorerupt
-			.long	ignorerupt
-			.long	ignorerupt
-			.long	ignorerupt
-			.long	ignorerupt
-			.long	ignorerupt
-			.long	ignorerupt
-			.long	ignorerupt
-			.long	ignorerupt
-			.long	ignorerupt
-			.long	ignorerupt
-			.long	ignorerupt
-			.long	ignorerupt
-			.long	ignorerupt
-			.long	ignorerupt
-			.long	ignorerupt
-			.long	ignorerupt
-			.long	ignorerupt
-			.long	ignorerupt
-			.long	ignorerupt
-			.long	ignorerupt
-			.long	ignorerupt
-			.long	ignorerupt
-			.long	ignorerupt
-			.long	ignorerupt
-			.long	ignorerupt
-			.long	ignorerupt
-			.long	ignorerupt
-			.long	ignorerupt
-			.long	ignorerupt
-			.long	ignorerupt
-			.long	ignorerupt
-			.long	ignorerupt
-			.long	ignorerupt
-			.long	ignorerupt
-			.long	ignorerupt
-			.long	ignorerupt
-			.long	ignorerupt
-			.long	ignorerupt
-			.long	ignorerupt
-			.long	ignorerupt
-rupttabend:	.long	ignorerupt
-
-/*	(TEST/DEBUG) (TEST/DEBUG) (TEST/DEBUG) (TEST/DEBUG) (TEST/DEBUG) (TEST/DEBUG) (TEST/DEBUG) (TEST/DEBUG) (TEST/DEBUG)  */
-/* */
-/*			Here lies the end of the Phoney Firmware used to test SIGPs.  Take this out later. */
-/* */
-/*	(TEST/DEBUG) (TEST/DEBUG) (TEST/DEBUG) (TEST/DEBUG) (TEST/DEBUG) (TEST/DEBUG) (TEST/DEBUG) (TEST/DEBUG) (TEST/DEBUG)  */
-
-
-/* */
-/*			Table of function offsets */
-/* */
-
-MPPIFuncOffs:
-
-			.long	CountProcessors-MPPIFunctions					/* Offset to routine */
-			.long	StartProcessor-MPPIFunctions					/* Offset to routine */
-			.long	ResumeProcessor-MPPIFunctions					/* Offset to routine */
-			.long	StopProcessor-MPPIFunctions						/* Offset to routine */
-			.long	ResetProcessor-MPPIFunctions					/* Offset to routine */
-			.long	SignalProcessor-MPPIFunctions					/* Offset to routine */
-			.long	StoreProcessorStatus-MPPIFunctions				/* Offset to routine */
-			.long	SynchClock-MPPIFunctions						/* Offset to routine */
-			.long	GetExtHandlerAddress-MPPIFunctions				/* Offset to routine */
-			.long	GotSignal-MPPIFunctions							/* Offset to routine */
-			.long	ProcessorState-MPPIFunctions					/* Offset to routine */
-			.long	RunSIGPRun-MPPIFunctions						/* Offset to routine */
-			.long	mp_PhoneyFirmware-MPPIFunctions					/* (TEST/DEBUG) */
-
-MPPISize:
-	
diff --git a/osfmk/ppc/POWERMAC/mp/mp.c b/osfmk/ppc/POWERMAC/mp/mp.c
deleted file mode 100644
index b75296d6e..000000000
--- a/osfmk/ppc/POWERMAC/mp/mp.c
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
- *
- * @APPLE_LICENSE_HEADER_START@
- * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
- * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
- * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
- * 
- * @APPLE_LICENSE_HEADER_END@
- */
-/*
- * @OSF_FREE_COPYRIGHT@
- */
-/*
- * @APPLE_FREE_COPYRIGHT@
- */
-#include <cpus.h>
-#include <ppc/POWERMAC/mp/MPPlugIn.h>
-
-MPPlugInSpec	MPspec;		/* An area for the MP interfaces */
-MPEntryPts	MPEntries;	/* Real addresses of plugin routines */
diff --git a/osfmk/ppc/POWERMAC/mp/mp.h b/osfmk/ppc/POWERMAC/mp/mp.h
deleted file mode 100644
index 9dd6ec62f..000000000
--- a/osfmk/ppc/POWERMAC/mp/mp.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
- *
- * @APPLE_LICENSE_HEADER_START@
- * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
- * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
- * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
- * 
- * @APPLE_LICENSE_HEADER_END@
- */
-/*
- * @OSF_COPYRIGHT@
- */
-
-#ifndef	_PPC_POWERMAC_MP_MP_H_
-#define _PPC_POWERMAC_MP_MP_H_
-
-#include <cpus.h>
-
-#if	NCPUS > 1
-
-#ifndef	ASSEMBLER
-#include <kern/lock.h>
-extern int real_ncpus;				/* real number of cpus */
-extern int wncpu;				/* wanted number of cpus */
-decl_simple_lock_data(extern, debugger_lock)	/* debugger lock */
-
-extern int debugger_cpu;				/* current cpu running debugger */
-extern int debugger_debug;
-extern int debugger_is_slave[];
-extern int debugger_active[];
-#endif	/* ASSEMBLER */
-
-#endif	/* NCPUS > 1 */
-
-#endif	/* _PPC_POWERMAC_MP_MP_H_ */
diff --git a/osfmk/ppc/POWERMAC/scc_8530.h b/osfmk/ppc/POWERMAC/scc_8530.h
index 868e649df..709fd8bda 100644
--- a/osfmk/ppc/POWERMAC/scc_8530.h
+++ b/osfmk/ppc/POWERMAC/scc_8530.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ppc/POWERMAC/serial_io.c b/osfmk/ppc/POWERMAC/serial_io.c
index f3f9eb742..fbc152f40 100644
--- a/osfmk/ppc/POWERMAC/serial_io.c
+++ b/osfmk/ppc/POWERMAC/serial_io.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -96,8 +99,12 @@ struct scc_tty scc_tty[NSCC_LINE];
 #define scc_dev_no(chan) ((chan)^0x01)
 #define scc_chan(dev_no) ((dev_no)^0x01)
 
+extern unsigned int disableSerialOuput;
+
 int	serial_initted = 0;
-unsigned int scc_parm_done = 0;				/* (TEST/DEBUG) */
+unsigned int scc_parm_done = 0;
+
+extern unsigned int serialmode;
 
 static struct scc_byte {
 	unsigned char	reg;
@@ -138,46 +145,19 @@ enum scc_error {SCC_ERR_NONE, SCC_ERR_PARITY, SCC_ERR_BREAK, SCC_ERR_OVERRUN};
  *	BRGconstant = 	---------------------------  -  2
  *			      BaudRate
  */
-
 #define SERIAL_CLOCK_FREQUENCY (115200*2) /* Power Mac value */
 #define	convert_baud_rate(rate)	((((SERIAL_CLOCK_FREQUENCY) + (rate)) / (2 * (rate))) - 2)
 
 #define DEFAULT_SPEED 57600
+#define DEFAULT_PORT0_SPEED 1200
 #define DEFAULT_FLAGS (TF_LITOUT|TF_ECHO)
 
 int	scc_param(struct scc_tty *tp);
 
-
 struct scc_softc	scc_softc[NSCC];
 caddr_t	scc_std[NSCC] = { (caddr_t) 0};
 
-
-#define SCC_RR1_ERRS (SCC_RR1_FRAME_ERR|SCC_RR1_RX_OVERRUN|SCC_RR1_PARITY_ERR)
-#define SCC_RR3_ALL (SCC_RR3_RX_IP_A|SCC_RR3_TX_IP_A|SCC_RR3_EXT_IP_A|\
-                     SCC_RR3_RX_IP_B|SCC_RR3_TX_IP_B|SCC_RR3_EXT_IP_B)
-
-#define DEBUG_SCC
-#undef  DEBUG_SCC
-
-#ifdef DEBUG_SCC
-static int total_chars, total_ints, total_overruns, total_errors, num_ints, max_chars;
-static int chars_received[8];
-static int __SCC_STATS = 0;
-static int max_in_q = 0;
-static int max_out_q = 0;
-#endif
-
-DECL_FUNNEL(, scc_funnel)	/* funnel to serialize the SCC driver */
-boolean_t scc_funnel_initted = FALSE;
-#define SCC_FUNNEL		scc_funnel
-#define SCC_FUNNEL_INITTED	scc_funnel_initted
-
-
-/*
- * Adapt/Probe/Attach functions
- */
-boolean_t	scc_uses_modem_control = FALSE;/* patch this with adb */
-decl_simple_lock_data(,scc_stomp)			/* (TEST/DEBUG) */
+decl_simple_lock_data(,scc_stomp)
 
 /* This is called VERY early on in the init and therefore has to have
  * hardcoded addresses of the serial hardware control registers. The
@@ -190,22 +170,13 @@ initialize_serial( caddr_t scc_phys_base )
 {
 	int i, chan, bits;
 	scc_regmap_t	regs;
-	DECL_FUNNEL_VARS
 
 	assert( scc_phys_base );
 
-	if (!SCC_FUNNEL_INITTED) {
-		FUNNEL_INIT(&SCC_FUNNEL, master_processor);
-		SCC_FUNNEL_INITTED = TRUE;
-	}
-	FUNNEL_ENTER(&SCC_FUNNEL);
-
-	if (serial_initted) {
-		FUNNEL_EXIT(&SCC_FUNNEL);
+	if (serial_initted)
 		return;
-	}
 
-	simple_lock_init(&scc_stomp, FALSE);				/* (TEST/DEBUG) */
+	simple_lock_init(&scc_stomp, FALSE);
 	
 	scc_softc[0].full_modem = TRUE;
 
@@ -234,12 +205,10 @@ initialize_serial( caddr_t scc_phys_base )
 
 			scc_read_reg_zero(regs, 0, bits);/* Clear the status */
 		}
-                scc_parm_done = 1;			/* (TEST/DEBUG) */
+                scc_parm_done = 1;
 	}
 
 	serial_initted = TRUE;
-
-	FUNNEL_EXIT(&SCC_FUNNEL);
 	return;
 }
 
@@ -250,26 +219,11 @@ scc_probe(void)
 	register int	val, i;
 	register scc_regmap_t	regs;
 	spl_t	s;
-	DECL_FUNNEL_VARS
-
-	if (!SCC_FUNNEL_INITTED) {
-		FUNNEL_INIT(&SCC_FUNNEL, master_processor);
-		SCC_FUNNEL_INITTED = TRUE;
-	}
-	FUNNEL_ENTER(&SCC_FUNNEL);
-
-	/* Readjust the I/O address to handling 
-	 * new memory mappings.
-	 */
-
-//	scc_std[0] = POWERMAC_IO(scc_std[0]);
 
 	regs = (scc_regmap_t)scc_std[0];
 
-	if (regs == (scc_regmap_t) 0) {
-		FUNNEL_EXIT(&SCC_FUNNEL);
+	if (regs == (scc_regmap_t) 0)
 		return 0;
-	}
 
 	scc = &scc_softc[0];
 	scc->regs = regs;
@@ -284,8 +238,13 @@ scc_probe(void)
 		   open but are needed if the port will be used
 		   independently of the Mach interfaces, e.g., for
 		   gdb or for a serial console.  */
-		tp->t_ispeed = DEFAULT_SPEED;
-		tp->t_ospeed = DEFAULT_SPEED;
+		if (i == 0) {
+		  tp->t_ispeed = DEFAULT_PORT0_SPEED;
+		  tp->t_ospeed = DEFAULT_PORT0_SPEED;
+		} else {
+		  tp->t_ispeed = DEFAULT_SPEED;
+		  tp->t_ospeed = DEFAULT_SPEED;
+		}
 		tp->t_flags = DEFAULT_FLAGS;
 		scc->softr[i].speed = -1;
 
@@ -296,8 +255,6 @@ scc_probe(void)
 	}
 
 	splx(s);
-
-	FUNNEL_EXIT(&SCC_FUNNEL);
 	return 1;
 }
 
@@ -314,16 +271,12 @@ scc_getc(int unit, int line, boolean_t wait, boolean_t raw)
 	unsigned char   c, value;
 	int             rcvalue, from_line;
 	spl_t		s = splhigh();
-	DECL_FUNNEL_VARS
-
-	FUNNEL_ENTER(&SCC_FUNNEL);
 
-	simple_lock(&scc_stomp);					/* (TEST/DEBUG) */
+	simple_lock(&scc_stomp);
 	regs = scc_softc[0].regs;
 
 	/*
 	 * wait till something available
-	 *
 	 */
 again:
 	rcvalue = 0;
@@ -334,9 +287,8 @@ again:
 			break;
 
 		if (!wait) {
-			simple_unlock(&scc_stomp);			/* (TEST/DEBUG) */
+			simple_unlock(&scc_stomp);
 			splx(s);
-			FUNNEL_EXIT(&SCC_FUNNEL);
 			return -1;
 		}
 	}
@@ -352,16 +304,16 @@ again:
 	if (console_is_serial() &&
 	    c == ('_' & 0x1f)) {
 		/* Drop into the debugger */
-		simple_unlock(&scc_stomp);				/* (TEST/DEBUG) */
+		simple_unlock(&scc_stomp);
 		Debugger("Serial Line Request");
-		simple_lock(&scc_stomp);				/* (TEST/DEBUG) */
+		simple_lock(&scc_stomp);
 		scc_write_reg(regs, line, SCC_RR0, SCC_RESET_HIGHEST_IUS);
 		if (wait) {
 			goto again;
 		}
-		simple_unlock(&scc_stomp);				/* (TEST/DEBUG) */
+		sync();
+		simple_unlock(&scc_stomp);
 		splx(s);
-		FUNNEL_EXIT(&SCC_FUNNEL);
 		return -1;
 	}
 #endif	/* MACH_KDB */
@@ -377,13 +329,11 @@ again:
 			goto again;
 		}
 	}
-
 	scc_write_reg(regs, line, SCC_RR0, SCC_RESET_HIGHEST_IUS);
 
-	simple_unlock(&scc_stomp);					/* (TEST/DEBUG) */
+	sync();
+	simple_unlock(&scc_stomp);
 	splx(s);
-
-	FUNNEL_EXIT(&SCC_FUNNEL);
 	return c;
 }
 
@@ -396,12 +346,14 @@ int
 scc_putc(int unit, int line, int c)
 {
 	scc_regmap_t	regs;
-	spl_t            s = splhigh();
+	spl_t            s;
 	unsigned char	 value;
-	DECL_FUNNEL_VARS
 
-	FUNNEL_ENTER(&SCC_FUNNEL);
-	simple_lock(&scc_stomp);				/* (TEST/DEBUG) */
+	if (disableSerialOuput)
+		return 0;
+
+	s = splhigh();
+	simple_lock(&scc_stomp);
 
 	regs = scc_softc[0].regs;
 
@@ -421,11 +373,10 @@ scc_putc(int unit, int line, int c)
 			break;
 	} while (1);
 	scc_write_reg(regs, line, SCC_RR0, SCC_RESET_HIGHEST_IUS);
-	simple_unlock(&scc_stomp);				/* (TEST/DEBUG) */
 
+	sync();
+	simple_unlock(&scc_stomp);
 	splx(s);
-
-	FUNNEL_EXIT(&SCC_FUNNEL);
 	return 0;
 }
 
@@ -435,12 +386,8 @@ powermac_scc_set_datum(scc_regmap_t regs, unsigned int offset, unsigned char val
 {
 	volatile unsigned char *address = (unsigned char *) regs + offset;
   
-	assert(FUNNEL_IN_USE(&SCC_FUNNEL));
-
 	*address = value;
 	eieio();
-
-	assert(FUNNEL_IN_USE(&SCC_FUNNEL));
 }
   
 unsigned char
@@ -449,12 +396,9 @@ powermac_scc_get_datum(scc_regmap_t regs, unsigned int offset)
 	volatile unsigned char *address = (unsigned char *) regs + offset;
 	unsigned char	value;
   
-	assert(FUNNEL_IN_USE(&SCC_FUNNEL));
-
-	value = *address; eieio();
+	value = *address; 
+	eieio();
 	return value;
-
-	assert(FUNNEL_IN_USE(&SCC_FUNNEL));
 }
 
 int
@@ -468,10 +412,8 @@ scc_param(struct scc_tty *tp)
 	struct scc_softreg	*sr;
 	scc_softc_t	scc;
 
-	assert(FUNNEL_IN_USE(&SCC_FUNNEL));
-	
 	s = splhigh();
-	simple_lock(&scc_stomp);				/* (TEST/DEBUG) */
+	simple_lock(&scc_stomp);
 
 	chan = scc_chan(tp->t_dev);
 	scc = &scc_softc[0];
@@ -482,30 +424,30 @@ scc_param(struct scc_tty *tp)
 	/* Do a quick check to see if the hardware needs to change */
 	if ((sr->flags & (TF_ODDP|TF_EVENP)) == (tp->t_flags & (TF_ODDP|TF_EVENP))
 	    && sr->speed == tp->t_ispeed) {
-		assert(FUNNEL_IN_USE(&SCC_FUNNEL));
-		simple_unlock(&scc_stomp);					/* (TEST/DEBUG) */
-		splx(s);											/* (TEST/DEBUG) */
-		return 0;											/* (TEST/DEBUG) */
+		simple_unlock(&scc_stomp);
+		splx(s);
+		return 0;
 	}
 
 	if(scc_parm_done) 	{								
 		
-		scc_write_reg(regs,  chan,  3, SCC_WR3_RX_8_BITS|SCC_WR3_RX_ENABLE);	/* (TEST/DEBUG) */
-		sr->wr1 = SCC_WR1_RXI_FIRST_CHAR | SCC_WR1_EXT_IE;	/* (TEST/DEBUG) */
-		scc_write_reg(regs,  chan,  1, sr->wr1);			/* (TEST/DEBUG) */
-       	scc_write_reg(regs,  chan, 15, SCC_WR15_ENABLE_ESCC);	/* (TEST/DEBUG) */
-		scc_write_reg(regs,  chan,  7, SCC_WR7P_RX_FIFO);	/* (TEST/DEBUG) */
-		scc_write_reg(regs,  chan,  0, SCC_IE_NEXT_CHAR);	/* (TEST/DEBUG) */
-		scc_write_reg(regs,  chan,  0, SCC_RESET_EXT_IP);	/* (TEST/DEBUG) */
-		scc_write_reg(regs,  chan,  0, SCC_RESET_EXT_IP);	/* (TEST/DEBUG) */
-		scc_write_reg(regs,  chan,  9, SCC_WR9_MASTER_IE|SCC_WR9_NV);	/* (TEST/DEBUG) */
-		scc_read_reg_zero(regs, 0, bits);					/* (TEST/DEBUG) */
-		sr->wr1 = SCC_WR1_RXI_FIRST_CHAR | SCC_WR1_EXT_IE;	/* (TEST/DEBUG) */
-		scc_write_reg(regs,  chan,  1, sr->wr1);			/* (TEST/DEBUG) */
-		scc_write_reg(regs,  chan,  0, SCC_IE_NEXT_CHAR);	/* (TEST/DEBUG) */
-		simple_unlock(&scc_stomp);							/* (TEST/DEBUG) */
-		splx(s);											/* (TEST/DEBUG) */
-		return 0;											/* (TEST/DEBUG) */
+		scc_write_reg(regs,  chan,  3, SCC_WR3_RX_8_BITS|SCC_WR3_RX_ENABLE);
+		sr->wr1 = SCC_WR1_RXI_FIRST_CHAR | SCC_WR1_EXT_IE;
+		scc_write_reg(regs,  chan,  1, sr->wr1);
+		scc_write_reg(regs,  chan, 15, SCC_WR15_ENABLE_ESCC);
+		scc_write_reg(regs,  chan,  7, SCC_WR7P_RX_FIFO);
+		scc_write_reg(regs,  chan,  0, SCC_IE_NEXT_CHAR);
+		scc_write_reg(regs,  chan,  0, SCC_RESET_EXT_IP);
+		scc_write_reg(regs,  chan,  0, SCC_RESET_EXT_IP);
+		scc_write_reg(regs,  chan,  9, SCC_WR9_MASTER_IE|SCC_WR9_NV);
+		scc_read_reg_zero(regs, 0, bits);
+		sr->wr1 = SCC_WR1_RXI_FIRST_CHAR | SCC_WR1_EXT_IE;
+		scc_write_reg(regs,  chan,  1, sr->wr1);
+		scc_write_reg(regs,  chan,  0, SCC_IE_NEXT_CHAR);
+		sync();
+		simple_unlock(&scc_stomp);
+		splx(s);
+		return 0;
 	}
 	
 	sr->flags = tp->t_flags;
@@ -515,10 +457,9 @@ scc_param(struct scc_tty *tp)
 	if (tp->t_ispeed == 0) {
 		sr->wr5 &= ~SCC_WR5_DTR;
 		scc_write_reg(regs,  chan, 5, sr->wr5);
-		simple_unlock(&scc_stomp);							/* (TEST/DEBUG) */
+		sync();
+		simple_unlock(&scc_stomp);
 		splx(s);
-
-		assert(FUNNEL_IN_USE(&SCC_FUNNEL));
 		return 0;
 	}
 	
@@ -621,12 +562,59 @@ scc_param(struct scc_tty *tp)
 	sr->wr5 |= SCC_WR5_TX_ENABLE;
 	scc_write_reg(regs,  chan,  5, sr->wr5);
 
-	simple_unlock(&scc_stomp);			/* (TEST/DEBUG) */
+	sync();
+	simple_unlock(&scc_stomp);
 	splx(s);
-
-	assert(FUNNEL_IN_USE(&SCC_FUNNEL));
 	return 0;
 
 }
 
+/*
+ *  This routine will start a thread that polls the serial port, listening for
+ *  characters that have been typed.
+ */
+
+void
+serial_keyboard_init(void)
+{
+
+	if(!(serialmode & 2)) return;		/* Leave if we do not want a serial console */
+
+	kprintf("Serial keyboard started\n");
+	kernel_thread_with_priority(kernel_task, MAXPRI_STANDARD, serial_keyboard_start, TRUE, TRUE);
+	return;
+}
+
+void
+serial_keyboard_start(void)
+{
+	thread_t cthread;
+
+	cthread = current_thread();		/* Just who the heck are we anyway? */
+	stack_privilege(cthread);		/* Make sure we don't lose our stack */
+	serial_keyboard_poll();			/* Go see if there are any characters pending now */
+	panic("serial_keyboard_start: we can't get back here\n");
+}
+
+void
+serial_keyboard_poll(void)
+{
+	int chr;
+	uint64_t next;
+	extern void cons_cinput(char ch);	/* The BSD routine that gets characters */
+
+	while(1) {				/* Do this for a while */
+		chr = scc_getc(0, 1, 0, 1);	/* Get a character if there is one */
+		if(chr < 0) break;		/* The serial buffer is empty */
+		cons_cinput((char)chr);		/* Buffer up the character */
+	}
+
+	clock_interval_to_deadline(16, 1000000, &next);	/* Get time of pop */
+
+	assert_wait((event_t)serial_keyboard_poll, THREAD_INTERRUPTIBLE);	/* Show we are "waiting" */
+	thread_set_timer_deadline(next);	/* Set the next time to check */
+	thread_block(serial_keyboard_poll);	/* Wait for it */
+	panic("serial_keyboard_poll: Shouldn't never ever get here...\n");
+}
+
 #endif	/* NSCC > 0 */
diff --git a/osfmk/ppc/POWERMAC/serial_io.h b/osfmk/ppc/POWERMAC/serial_io.h
index a1f9979d9..c48c5750c 100644
--- a/osfmk/ppc/POWERMAC/serial_io.h
+++ b/osfmk/ppc/POWERMAC/serial_io.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -124,19 +127,10 @@ extern int		switch_to_video_console(
 extern void		switch_to_old_console(
 				int			old_console);
 
+void serial_keyboard_init(void);
+void serial_keyboard_start(void);
+void serial_keyboard_poll(void);
 
-/*
- * JMM - We are not really going to support this driver in SMP (barely
- * support it now - so just pick up the stubbed out versions.
- */
-#define DECL_FUNNEL(class,f)
-#define DECL_FUNNEL_VARS
-#define FUNNEL_INIT(f,p)
-#define FUNNEL_ENTER(f)
-#define FUNNEL_EXIT(f)
-#define FUNNEL_ESCAPE(f)		(1)
-#define FUNNEL_REENTER(f,count)
-#define FUNNEL_IN_USE(f)		(TRUE)
 
 /*
  * Flags
diff --git a/osfmk/ppc/POWERMAC/video_console.c b/osfmk/ppc/POWERMAC/video_console.c
index 61a510e97..4c5f52989 100644
--- a/osfmk/ppc/POWERMAC/video_console.c
+++ b/osfmk/ppc/POWERMAC/video_console.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -111,6 +114,11 @@
 #include <kern/time_out.h>
 #include <kern/lock.h>
 #include <kern/debug.h>
+#include <mach/vm_param.h>
+#include <vm/vm_kern.h>
+#include <vm/vm_map.h>
+#include <vm/vm_page.h>
+#include <ppc/pmap.h>
 
 #include <kdp/kdp_udp.h>
 
@@ -2833,23 +2841,82 @@ static void vc_clear_screen( void )
     reversecursor();
 };
 
+
+unsigned int lastVideoPhys = 0;
+unsigned int lastVideoVirt = 0;
+unsigned int lastVideoSize = 0;
+
 void
 initialize_screen(Boot_Video * boot_vinfo, unsigned int op)
 {
+	
+	unsigned int fbsize;
+	unsigned int newVideoVirt;
+	ppnum_t fbppage;
+
 	if( boot_vinfo) {
             bcopy( (const void *) boot_vinfo,
                     (void *) &boot_video_info,
                     sizeof( boot_video_info));
+/* 
+ *			First, check if we are changing the size and/or location of the framebuffer
+ */
+
 
             vinfo.v_name[0] = 0;
             vinfo.v_width = boot_vinfo->v_width;
             vinfo.v_height = boot_vinfo->v_height;
             vinfo.v_depth = boot_vinfo->v_depth;
             vinfo.v_rowbytes = boot_vinfo->v_rowBytes;
-            vinfo.v_physaddr = boot_vinfo->v_baseAddr;
-            vinfo.v_baseaddr = vinfo.v_physaddr;
+            vinfo.v_physaddr = boot_vinfo->v_baseAddr;		/* Get the physical address */
+ 			
+ 			kprintf("initialize_screen: b=%08X, w=%08X, h=%08X, r=%08X\n",				/* (BRINGUP) */
+				vinfo.v_physaddr, vinfo.v_width,  vinfo.v_height,  vinfo.v_rowbytes);	/* (BRINGUP) */
+
+			if(!vinfo.v_physaddr) {							/* Check to see if we have a framebuffer */
+				kprintf("initialize_screen: No video - forcing serial mode\n");		/* (BRINGUP) */
+				(void)switch_to_serial_console();			/* Switch into serial mode */
+				vc_graphics_mode = FALSE;					/* Say we are not in graphics mode */
+				disableConsoleOutput = FALSE;				/* Allow printfs to happen */
+				vc_acquired = TRUE;
+				return;										/* Nothing more to do here */
+			}
+
+
+/*			Note that for the first time only, boot_vinfo->v_baseAddr is physical */
+
+			if(kernel_map != VM_MAP_NULL) {					/* If VM is up, we are given a virtual address */
+				fbppage = pmap_find_phys(kernel_pmap, boot_vinfo->v_baseAddr);	/* Get the physical address of frame buffer */
+				if(!fbppage) {								/* Did we find it? */
+					panic("initialize_screen: Strange framebuffer - addr = %08X\n", boot_vinfo->v_baseAddr);
+				}
+				vinfo.v_physaddr = fbppage << 12;			/* Get the physical address */
+			}
+			
             vinfo.v_type = 0;
 
+			fbsize = round_page_32(vinfo.v_height * vinfo.v_rowbytes);	/* Remember size */
+
+			if((lastVideoPhys != vinfo.v_physaddr) || (fbsize > lastVideoSize)) {	/* Did framebuffer change location or get bigger? */
+
+				newVideoVirt = io_map_spec((vm_offset_t)vinfo.v_physaddr, fbsize);	/* Allocate address space for framebuffer */
+
+				if(lastVideoVirt) {							/* Was the framebuffer mapped before? */
+					if(lastVideoVirt > vm_last_addr) {		/* Was this a special pre-VM mapping? */
+						pmap_remove(kernel_pmap, (addr64_t)lastVideoVirt, (addr64_t)(lastVideoVirt + lastVideoSize));	/* Toss mappings */
+					}
+					else {									/* This was not special boot-time allocation */
+						kmem_free(kernel_map, lastVideoVirt, lastVideoSize);	/* Toss kernel addresses */
+					}
+				}
+				
+				lastVideoPhys = vinfo.v_physaddr;			/* Remember the framebuffer address */
+				lastVideoSize = fbsize;						/* Remember the size */
+				lastVideoVirt = newVideoVirt;				/* Remember the virtual framebuffer address */
+			}
+           
+            vinfo.v_baseaddr = lastVideoVirt;				/* Set the new framebuffer address */
+
             vc_initialize();
 #if 0
             GratefulDebInit((bootBumbleC *)boot_vinfo);	/* Re-initialize GratefulDeb */
@@ -2859,58 +2926,58 @@ initialize_screen(Boot_Video * boot_vinfo, unsigned int op)
 	switch( op ) {
 
 	    case kPEGraphicsMode:
-		vc_graphics_mode = TRUE;
-		disableConsoleOutput = TRUE;
-		vc_acquired = TRUE;
-		break;
+			vc_graphics_mode = TRUE;
+			disableConsoleOutput = TRUE;
+			vc_acquired = TRUE;
+			break;
 
 	    case kPETextMode:
-		vc_graphics_mode = FALSE;
-		disableConsoleOutput = FALSE;
-		vc_acquired = TRUE;
-		vc_clear_screen();
-		break;
+			vc_graphics_mode = FALSE;
+			disableConsoleOutput = FALSE;
+			vc_acquired = TRUE;
+			vc_clear_screen();
+			break;
 
 	    case kPETextScreen:
-		vc_progress_set( FALSE, 0 );
-		disableConsoleOutput = FALSE;
-		if( vc_need_clear) {
-		    vc_need_clear = FALSE;
-                    vc_clear_screen();
-		}
-		break;
+			vc_progress_set( FALSE, 0 );
+			disableConsoleOutput = FALSE;
+			if( vc_need_clear) {
+				vc_need_clear = FALSE;
+				vc_clear_screen();
+			}
+			break;
 
-            case kPEEnableScreen:
-		if( vc_acquired) {
-                    if( vc_graphics_mode)
-                        vc_progress_set( TRUE, vc_progress_tick );
-                    else
-                        vc_clear_screen();
-		}
-		break;
+		case kPEEnableScreen:
+			if( vc_acquired) {
+				if( vc_graphics_mode)
+				vc_progress_set( TRUE, vc_progress_tick );
+				else
+				vc_clear_screen();
+			}
+			break;
 
-            case kPEDisableScreen:
-		vc_progress_set( FALSE, 0 );
-		break;
+		case kPEDisableScreen:
+			vc_progress_set( FALSE, 0 );
+			break;
 
 	    case kPEAcquireScreen:
-		vc_need_clear = (FALSE == vc_acquired);
-		vc_acquired = TRUE;
-		vc_progress_set( vc_graphics_mode, vc_need_clear ? 2 * hz : 0 );
-		disableConsoleOutput = vc_graphics_mode;
-		if( vc_need_clear && !vc_graphics_mode) {
-		    vc_need_clear = FALSE;
-                    vc_clear_screen();
-		}
-		break;
+			vc_need_clear = (FALSE == vc_acquired);
+			vc_acquired = TRUE;
+			vc_progress_set( vc_graphics_mode, vc_need_clear ? 2 * hz : 0 );
+			disableConsoleOutput = vc_graphics_mode;
+			if( vc_need_clear && !vc_graphics_mode) {
+				vc_need_clear = FALSE;
+				vc_clear_screen();
+			}
+			break;
 
 	    case kPEReleaseScreen:
-		vc_acquired = FALSE;
-		vc_progress_set( FALSE, 0 );
-                vc_clut8 = NULL;
-		disableConsoleOutput = TRUE;
+			vc_acquired = FALSE;
+			vc_progress_set( FALSE, 0 );
+			vc_clut8 = NULL;
+			disableConsoleOutput = TRUE;
 #if 0
-		GratefulDebInit(0);						/* Stop grateful debugger */
+			GratefulDebInit(0);						/* Stop grateful debugger */
 #endif
 		break;
 	}
diff --git a/osfmk/ppc/POWERMAC/video_console.h b/osfmk/ppc/POWERMAC/video_console.h
index 083712b08..54b3591f2 100644
--- a/osfmk/ppc/POWERMAC/video_console.h
+++ b/osfmk/ppc/POWERMAC/video_console.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ppc/POWERMAC/video_console_entries.h b/osfmk/ppc/POWERMAC/video_console_entries.h
index 088358905..afdf214cc 100644
--- a/osfmk/ppc/POWERMAC/video_console_entries.h
+++ b/osfmk/ppc/POWERMAC/video_console_entries.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ppc/POWERMAC/video_scroll.s b/osfmk/ppc/POWERMAC/video_scroll.s
index c7931c150..1a9095e18 100644
--- a/osfmk/ppc/POWERMAC/video_scroll.s
+++ b/osfmk/ppc/POWERMAC/video_scroll.s
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -40,20 +43,23 @@
 
 ENTRY(video_scroll_up, TAG_NO_FRAME_USED)
 
-			mfmsr	r0									/* Get the MSR */
-			rlwinm	r0,r0,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-			rlwinm	r0,r0,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-			mflr	r6									/* Get the LR */
-			ori		r7,r0,1<<(31-MSR_FP_BIT)			/* Turn on floating point */
-			stwu	r1,-(FM_SIZE+16)(r1)				/* Get space for a couple of registers on stack */
-			rlwinm	r7,r7,0,MSR_EE_BIT+1,MSR_EE_BIT-1	/* Turn off interrupts */
-			stw		r6,(FM_SIZE+16+FM_LR_SAVE)(r1)		/* Save the return */
+
+			lis		r8,hi16(MASK(MSR_VEC))			; Get the vector flag
+			mfmsr	r0								; Get the MSR 
+			ori		r8,r8,lo16(MASK(MSR_FP))		; Add the FP flag
+			mflr	r6								; Get the LR
+			andc	r0,r0,r8						; Clear VEC and FP
+			ori		r7,r8,lo16(MASK(MSR_EE))		; Drop EE and DR
+			andc	r7,r0,r7						; Clear VEC, FP, and EE
+			ori		r7,r7,MASK(MSR_FP)				; Turn floating point back on
+			stwu	r1,-(FM_SIZE+16)(r1)			; Get space for a couple of registers on stack
+			stw		r6,(FM_SIZE+16+FM_LR_SAVE)(r1)	; Save the return
 			
-			mtmsr	r7									/* Turn on FPU */
-			isync										/* Wait for it */
+			mtmsr	r7								; Turn on FPU
+			isync									; Wait for it 
 			
-vsufpuon1:	stfd	f0,(FM_SIZE+0)(r1)					/* Save one register */
-			stfd	f1,(FM_SIZE+8)(r1)					/* and the second */
+vsufpuon1:	stfd	f0,(FM_SIZE+0)(r1)				; Save one register
+			stfd	f1,(FM_SIZE+8)(r1)				; and the second
 
 /* ok, now we can use the FPU registers to do some fast copying
  */
@@ -95,20 +101,23 @@ ENTRY(video_scroll_down, TAG_NO_FRAME_USED)
 	 */
 	
 
-			mfmsr	r0									/* Get the MSR */
-			rlwinm	r0,r0,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-			rlwinm	r0,r0,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-			mflr	r6									/* Get the LR */
-			ori		r7,r0,1<<(31-MSR_FP_BIT)			/* Turn on floating point */
-			stwu	r1,-(FM_SIZE+16)(r1)				/* Get space for a couple of registers on stack */
-			rlwinm	r7,r7,0,MSR_EE_BIT+1,MSR_EE_BIT-1	/* Turn off interrupts */
-			stw		r6,(FM_SIZE+16+FM_LR_SAVE)(r1)		/* Save the return */
+			lis		r8,hi16(MASK(MSR_VEC))			; Get the vector flag
+			mfmsr	r0								; Get the MSR 
+			ori		r8,r8,lo16(MASK(MSR_FP))		; Add the FP flag
+			mflr	r6								; Get the LR
+			andc	r0,r0,r8						; Clear VEC and FP
+			ori		r7,r8,lo16(MASK(MSR_EE))		; Drop EE and DR
+			andc	r7,r0,r7						; Clear VEC, FP, DR, and EE
+			ori		r7,r7,MASK(MSR_FP)				; Turn on floating point 
+			stwu	r1,-(FM_SIZE+16)(r1)			; Get space for a couple of registers on stack
+			stw		r6,(FM_SIZE+16+FM_LR_SAVE)(r1)	; Save the return
 			
-			mtmsr	r7									/* Turn on FPU */
-			isync										/* Wait for it */
+			mtmsr	r7								; Turn on FPU
+			isync									; Wait for it 
 			
-vsdfpuon1:	stfd	f0,(FM_SIZE+0)(r1)					/* Save one register */
-			stfd	f1,(FM_SIZE+8)(r1)					/* and the second */
+vsdfpuon1:	stfd	f0,(FM_SIZE+0)(r1)				; Save one register
+			stfd	f1,(FM_SIZE+8)(r1)				; and the second
+
 
 /* ok, now we can use the FPU registers to do some fast copying	 */
 
diff --git a/osfmk/ppc/PPCcalls.c b/osfmk/ppc/PPCcalls.c
index 1460c10be..27ed40e7e 100644
--- a/osfmk/ppc/PPCcalls.c
+++ b/osfmk/ppc/PPCcalls.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -29,6 +32,8 @@
 #include <ppc/Diagnostics.h>
 #include <ppc/vmachmon.h>
 #include <ppc/PseudoKernel.h>
+#include <ppc/misc_protos.h>
+#include <ppc/hw_perfmon.h>
 
 /*
  *	To add a new entry:
diff --git a/osfmk/ppc/PPCcalls.h b/osfmk/ppc/PPCcalls.h
index bab0f34f2..bc03373e3 100644
--- a/osfmk/ppc/PPCcalls.h
+++ b/osfmk/ppc/PPCcalls.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -51,12 +54,28 @@ PPCcallEnt	PPCcalls[] = {
 
 	PPCcall(dis),					/* 0x6009 CHUD Interface hook */
 	
-	PPCcall(dis),					/* 0x600A disabled */
-	PPCcall(dis),					/* 0x600B disabled */
-	PPCcall(dis),					/* 0x600C disabled */
+	PPCcall(ppcNull),				/* 0x600A Null PPC syscall */
+	PPCcall(perfmon_control),		/* 0x600B performance monitor */
+	PPCcall(ppcNullinst),			/* 0x600C Instrumented Null PPC syscall */
 	PPCcall(dis),					/* 0x600D disabled */
 	PPCcall(dis),					/* 0x600E disabled */
 	PPCcall(dis),					/* 0x600F disabled */
+	PPCcall(dis),					/* 0x6010 disabled */
+	PPCcall(dis),					/* 0x6011 disabled */
+	PPCcall(dis),					/* 0x6012 disabled */
+	PPCcall(dis),					/* 0x6013 disabled */
+	PPCcall(dis),					/* 0x6014 disabled */
+	PPCcall(dis),					/* 0x6015 disabled */
+	PPCcall(dis),					/* 0x6016 disabled */
+	PPCcall(dis),					/* 0x6017 disabled */
+	PPCcall(dis),					/* 0x6018 disabled */
+	PPCcall(dis),					/* 0x6019 disabled */
+	PPCcall(dis),					/* 0x601A disabled */
+	PPCcall(dis),					/* 0x601B disabled */
+	PPCcall(dis),					/* 0x601C disabled */
+	PPCcall(dis),					/* 0x601D disabled */
+	PPCcall(dis),					/* 0x601E disabled */
+	PPCcall(dis),					/* 0x601F disabled */
 };
 
 #undef dis
diff --git a/osfmk/ppc/Performance.h b/osfmk/ppc/Performance.h
index b06f1f018..0b94b34f3 100644
--- a/osfmk/ppc/Performance.h
+++ b/osfmk/ppc/Performance.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ppc/Performance.s b/osfmk/ppc/Performance.s
index d3c11e922..39cdbf1cc 100644
--- a/osfmk/ppc/Performance.s
+++ b/osfmk/ppc/Performance.s
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -35,7 +38,6 @@
 
 #include <ppc/asm.h>
 #include <ppc/proc_reg.h>
-#include <ppc/POWERMAC/mp/MPPlugIn.h>
 #include <ppc/exception.h>
 #include <ppc/Performance.h>
 #include <mach/machine/vm_param.h>
diff --git a/osfmk/ppc/PseudoKernel.c b/osfmk/ppc/PseudoKernel.c
index ce31867cf..b41b1352c 100644
--- a/osfmk/ppc/PseudoKernel.c
+++ b/osfmk/ppc/PseudoKernel.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -167,11 +170,11 @@ void bbSetRupt(ReturnHandler *rh, thread_act_t act) {
 			bttd->InterruptControlWord = (bttd->InterruptControlWord & ~kInterruptStateMask) | 
 				(kInPseudoKernel << kInterruptStateShift);
 				
-			bttd->exceptionInfo.srr0 = sv->save_srr0;		/* Save the current PC */
-			sv->save_srr0 = bttd->InterruptVector;			/* Set the new PC */
-			bttd->exceptionInfo.sprg1 = sv->save_r1;		/* Save the original R1 */
-			sv->save_r1 = bttd->exceptionInfo.sprg0;		/* Set the new R1 */
-			bttd->exceptionInfo.srr1 = sv->save_srr1;		/* Save the original MSR */
+			bttd->exceptionInfo.srr0 = (unsigned int)sv->save_srr0;		/* Save the current PC */
+			sv->save_srr0 = (uint64_t)bttd->InterruptVector;	/* Set the new PC */
+			bttd->exceptionInfo.sprg1 = (unsigned int)sv->save_r1;		/* Save the original R1 */
+			sv->save_r1 = (uint64_t)bttd->exceptionInfo.sprg0;	/* Set the new R1 */
+			bttd->exceptionInfo.srr1 = (unsigned int)sv->save_srr1;		/* Save the original MSR */
 			sv->save_srr1 &= ~(MASK(MSR_BE)|MASK(MSR_SE));	/* Clear SE|BE bits in MSR */
 			act->mact.specFlags &= ~bbNoMachSC;				/* reactivate Mach SCs */ 
 			disable_preemption();							/* Don't move us around */
@@ -212,8 +215,9 @@ kern_return_t enable_bluebox(
 	 ) {
 	
 	thread_t 		th;
-	vm_offset_t		kerndescaddr, physdescaddr, origdescoffset;
+	vm_offset_t		kerndescaddr, origdescoffset;
 	kern_return_t 	ret;
+	ppnum_t			physdescpage;
 	
 	th = current_thread();									/* Get our thread */					
 
@@ -239,8 +243,8 @@ kern_return_t enable_bluebox(
 		return KERN_FAILURE;	
 	}
 		
-	physdescaddr = 											/* Get the physical address of the page */
-		pmap_extract(th->top_act->map->pmap, (vm_offset_t) Desc_TableStart);
+	physdescpage = 											/* Get the physical page number of the page */
+		pmap_find_phys(th->top_act->map->pmap, (addr64_t)Desc_TableStart);
 
 	ret =  kmem_alloc_pageable(kernel_map, &kerndescaddr, PAGE_SIZE);	/* Find a virtual address to use */
 	if(ret != KERN_SUCCESS) {								/* Could we get an address? */
@@ -252,7 +256,7 @@ kern_return_t enable_bluebox(
 	}
 	
 	(void) pmap_enter(kernel_pmap, 							/* Map this into the kernel */
-		kerndescaddr, physdescaddr, VM_PROT_READ|VM_PROT_WRITE, 
+		kerndescaddr, physdescpage, VM_PROT_READ|VM_PROT_WRITE, 
 		VM_WIMG_USE_DEFAULT, TRUE);
 	
 	th->top_act->mact.bbDescAddr = (unsigned int)kerndescaddr+origdescoffset;	/* Set kernel address of the table */
@@ -392,7 +396,7 @@ int bb_settaskenv( struct savearea *save )
 	act->mact.bbTaskEnv = save->save_r4;
 	if(act == current_act()) {						/* Are we setting our own? */
 		disable_preemption();						/* Don't move us around */
-		per_proc_info[cpu_number()].spcFlags = act->mact.specFlags;	/* Copy the flags */
+		per_proc_info[cpu_number()].ppbbTaskEnv = act->mact.bbTaskEnv;	/* Remember the environment */
 		enable_preemption();						/* Ok to move us around */
 	}
 
diff --git a/osfmk/ppc/PseudoKernel.h b/osfmk/ppc/PseudoKernel.h
index ca3722b2c..ccbbc2425 100644
--- a/osfmk/ppc/PseudoKernel.h
+++ b/osfmk/ppc/PseudoKernel.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ppc/_setjmp.s b/osfmk/ppc/_setjmp.s
index c8a40b93d..9cf5fe7d3 100644
--- a/osfmk/ppc/_setjmp.s
+++ b/osfmk/ppc/_setjmp.s
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ppc/aligned_data.s b/osfmk/ppc/aligned_data.s
index be7a239ef..a1c091cd9 100644
--- a/osfmk/ppc/aligned_data.s
+++ b/osfmk/ppc/aligned_data.s
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -46,6 +49,8 @@
 #include <cpus.h>
 #include <ppc/asm.h>
 #include <ppc/proc_reg.h>
+#include <ppc/spec_reg.h>
+#include <mach/ppc/vm_param.h>
 #include <assym.s>
 
 ;
@@ -56,19 +61,19 @@
 
 			.data
 
-/*		1024-byte aligned areas */
+/*		4096-byte aligned areas */
 
 		.globl	EXT(per_proc_info)
-		.align	10
+		.align	12
 EXT(per_proc_info):									; Per processor data area
-		.fill	(ppSize*NCPUS)/4,4,0				; (filled with 0s)
+		.space	(ppSize*NCPUS),0				; (filled with 0s)
 
 /*		512-byte aligned areas */
 
 		.globl	EXT(kernel_pmap_store)				; This is the kernel_pmap
 		.align	8
 EXT(kernel_pmap_store):
-		.set	.,.+PMAP_SIZE
+		.set	.,.+pmapSize
 
 
 /*		256-byte aligned areas */
@@ -83,11 +88,6 @@ EXT(GratefulDebWork):								; Enough for 2 rows of 8 chars of 16-pixel wide 32-
 debstash:
 		.set	.,.+256
 
-		.globl	EXT(hw_counts)						; Counter banks per processor
-		.align	8
-EXT(hw_counts):
-		.set	.,.+(NCPUS*256)
-
 #if PREEMPTSTACK
 
 ;
@@ -103,37 +103,11 @@ EXT(DBGpreempt):
 
 /*		128-byte aligned areas */
 
-		.globl	EXT(saveanchor)
-		.align	7
-EXT(saveanchor):
-		.set	.,.+SVsize
-
 		.globl	EXT(mapCtl)
 		.align	7
 EXT(mapCtl):
 		.set	.,.+mapcsize
 
-		.globl	EXT(trcWork)
-		.align	7
-EXT(trcWork):
-		.long	EXT(traceTableBeg)					; The next trace entry to use
-#if DEBUG
-/*		.long	0x02000000 	*/						/* Only alignment exceptions enabled */
-		.long	0xFFFFFFFF 							/* All enabled */
-/*		.long	0xFBBFFFFF	*/						/* EXT and DEC disabled */
-/*		.long	0xFFBFFFFF	*/						/* DEC disabled */
-#else
-		.long	0x00000000							; All disabled on non-debug systems
-#endif
-		.long	EXT(traceTableBeg)					; Start of the trace table
-		.long	EXT(traceTableEnd)					; End (wrap point) of the trace
-		.long	0									; Saved mask while in debugger
-
-		.long	0
-		.long	0
-		.long	0
-		
-		
 		.globl	fwdisplock
 		.align	7
 fwdisplock:
@@ -194,19 +168,6 @@ EXT(QNaNbarbarian):
 		.long	0x7FFFDEAD							/* This is a quiet not-a-number which is a "known" debug value */
 		.long	0x7FFFDEAD							/* This is a quiet not-a-number which is a "known" debug value */
 
-		.globl	EXT(dgWork)
-		.align	5
-EXT(dgWork):
-		.long	0
-		.long	0
-		.long	0
-		.long	0
-		.long	0
-		.long	0
-		.long	0
-		.long	0
-
-
 /*		8-byte aligned areas */
 
     	.globl  EXT(FloatInit)
@@ -236,3 +197,41 @@ EXT(dbfloats):
 		.align	3
 EXT(dbspecrs):
 		.set	.,.+(80*4)
+
+/*
+ *		Interrupt and debug stacks go here
+ */
+ 	
+		.align  PPC_PGSHIFT
+     	.globl  EXT(FixedStackStart)
+EXT(FixedStackStart):
+     
+	 	.globl  EXT(intstack)
+EXT(intstack):
+		.set	.,.+INTSTACK_SIZE*NCPUS
+	
+/* Debugger stack - used by the debugger if present */
+/* NOTE!!! Keep the debugger stack right after the interrupt stack */
+
+    	.globl  EXT(debstack)
+EXT(debstack):
+		.set	., .+KERNEL_STACK_SIZE*NCPUS
+     
+		 .globl  EXT(FixedStackEnd)
+EXT(FixedStackEnd):
+
+		.align	ALIGN
+   		.globl  EXT(intstack_top_ss)
+EXT(intstack_top_ss):
+		.long	EXT(intstack)+INTSTACK_SIZE-FM_SIZE			/* intstack_top_ss points to the top of interrupt stack */
+
+		.align	ALIGN
+   	 	.globl  EXT(debstack_top_ss)	
+EXT(debstack_top_ss):
+
+		.long	EXT(debstack)+KERNEL_STACK_SIZE-FM_SIZE		/* debstack_top_ss points to the top of debug stack */
+
+    	.globl  EXT(debstackptr)
+EXT(debstackptr):	
+		.long	EXT(debstack)+KERNEL_STACK_SIZE-FM_SIZE
+
diff --git a/osfmk/ppc/asm.h b/osfmk/ppc/asm.h
index e12d9bfe1..23e865444 100644
--- a/osfmk/ppc/asm.h
+++ b/osfmk/ppc/asm.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -65,6 +68,8 @@
 #define sprg1	273
 #define sprg2	274
 #define sprg3	275
+#define scomc	276
+#define scomd	277
 #define pvr		287
 
 #define IBAT0U	528
@@ -102,6 +107,8 @@
 #define dbat3l	543
 
 #define ummcr2	928		/* Performance monitor control */
+#define upmc5   929     /* Performance monitor counter */
+#define upmc6   930     /* Performance monitor counter */
 #define ubamr	935		/* Performance monitor mask */
 #define ummcr0	936		/* Performance monitor control */
 #define upmc1	937		/* Performance monitor counter */
@@ -112,6 +119,8 @@
 #define upmc4	942		/* Performance monitor counter */
 #define usda	943		/* User sampled data address */
 #define mmcr2	944		/* Performance monitor control */
+#define pmc5    945     /* Performance monitor counter */
+#define pmc6    946     /* Performance monitor counter */
 #define bamr	951		/* Performance monitor mask */
 #define mmcr0	952
 #define pmc1	953
@@ -122,8 +131,11 @@
 #define	pmc4	958
 #define	sda		959		/* Sampled data address */
 #define dmiss	976		/* ea that missed */
+#define trig0	976		
 #define dcmp	977		/* compare value for the va that missed */
+#define trig1	977		
 #define hash1	978		/* pointer to first hash pteg */
+#define trig2	978		
 #define	hash2	979		/* pointer to second hash pteg */
 #define imiss	980		/* ea that missed */
 #define tlbmiss	980		/* ea that missed */
@@ -137,11 +149,15 @@
 #define hid0	1008	/* Checkstop and misc enables */
 #define HID1	1009	/* Clock configuration */
 #define hid1	1009	/* Clock configuration */
+#define HID2	1016	/* Other processor controls */
+#define hid2	1016	/* Other processor controls */
 #define iabr	1010	/* Instruction address breakpoint register */
 #define ictrl	1011	/* Instruction Cache Control */
 #define ldstdb	1012	/* Load/Store Debug */
+#define hid4	1012	/* Misc stuff */
 #define dabr	1013	/* Data address breakpoint register */
 #define msscr0	1014	/* Memory subsystem control */
+#define hid5	1014	/* Misc stuff */
 #define msscr1	1015	/* Memory subsystem debug */
 #define msssr0	1015	/* Memory Subsystem Status */
 #define ldstcr	1016	/* Load/Store Status/Control */
@@ -154,6 +170,59 @@
 #define thrm3	1022	/* Thermal management 3 */
 #define pir		1023	/* Processor ID Register */
 
+
+/* SPR registers (64-bit, PPC970 specific) */
+
+#define scomc_gp	276
+#define scomd_gp	277
+
+#define hsprg0		304
+#define hsprg1		305
+#define hdec		310
+#define hior		311
+#define rmor		312
+#define hrmor		313
+#define hsrr0		314
+#define hsrr1		315
+#define lpcr		318
+#define lpidr		319
+
+#define ummcra_gp	770
+#define upmc1_gp	771
+#define upmc2_gp	772
+#define upmc3_gp	773
+#define upmc4_gp	774
+#define upmc5_gp	775
+#define upmc6_gp	776
+#define upmc7_gp	777
+#define upmc8_gp	778
+#define ummcr0_gp	779
+#define usiar_gp	780
+#define usdar_gp	781
+#define ummcr1_gp	782
+#define uimc_gp		783
+
+#define mmcra_gp	786
+#define pmc1_gp		787
+#define pmc2_gp		788
+#define pmc3_gp		789
+#define pmc4_gp		790
+#define pmc5_gp		791
+#define pmc6_gp		792
+#define pmc7_gp		793
+#define pmc8_gp		794
+#define mmcr0_gp	795
+#define siar_gp		796
+#define sdar_gp		797
+#define mmcr1_gp	798
+#define imc_gp		799
+
+#define trig0_gp	976		
+#define trig1_gp	977		
+#define trig2_gp	978		
+
+#define dabrx		1015
+
 ;	hid0 bits
 #define emcp	0
 #define emcpm	0x80000000
@@ -195,6 +264,7 @@
 #define ilockm	0x00002000
 #define dlock	19
 #define dlockm	0x00001000
+#define exttben	19
 #define icfi	20
 #define icfim	0x00000800
 #define dcfi	21
@@ -225,13 +295,21 @@
 #define hid1prem	0x06000000
 #define hid1pi0		14
 #define hid1pi0m	0x00020000
+#define hid1FCPErr	14
 #define hid1ps		15
+#define hid1FCD0PErr	15
 #define hid1psm		0x00010000
 #define hid1pc0		0x0000F800
 #define hid1pr0		0x00000600
 #define hid1pc1		0x000000F8
 #define hid1pc0		0x0000F800
 #define hid1pr1		0x00000006
+#define hid1FCD1PErr	16
+#define hid1FIERATErr	17
+
+;	hid2 bits
+#define hid2vmin	18
+#define hid2vminm	0x00002000
 
 ;	msscr0 bits
 #define shden	0
@@ -312,6 +390,80 @@
 #define apmck	15
 #define apmckm	0x00010000
 
+#define mckIFUE	42
+#define mckLDST	43
+#define mckXCs	44
+#define mckXCe	45
+#define mckNoErr	0
+#define mckIFSLBPE	1
+#define mckIFTLBPE	2
+#define mckIFTLBUE	3
+
+;	dsisr bits
+#define mckUEdfr	16
+#define mckUETwDfr	17
+#define mckL1DCPE	18
+#define	mckL1DTPE	19
+#define	mckDEPE		20
+#define mckTLBPE	21
+#define mckSLBPE	23
+
+;	Async MCK source
+#define AsyMCKSrc 0x0226
+#define AsyMCKRSrc 0x0227
+#define AsyMCKext 0
+#define AsyMCKfir 1
+#define AsyMCKhri 2
+#define AsyMCKdbg 3
+#define AsyMCKncstp 4
+
+;	Core FIR
+#define cFIR 0x0300
+#define cFIRrst 0x0310
+#define cFIRICachePE 0
+#define cFIRITagPE0 1
+#define cFIRITagPE1 2
+#define cFIRIEratPE 3
+#define cFIRIFUL2UE 4
+#define cFIRIFUCS 5
+#define cFIRDCachePE 6
+#define cFIRDTagPE 7
+#define cFIRDEratPE 8
+#define cFIRTLBPE 9
+#define cFIRSLBPE 10
+#define cFIRSL2UE 11
+
+;	Core Error Inject
+#define CoreErrI 0x0350
+#define CoreIFU 0
+#define CoreLSU 1
+#define CoreRate0 2
+#define CoreRate1 3
+#define CoreOnce 0
+#define CoreSolid 2
+#define CorePulse 3
+
+;	GUS Mode Register
+#define GUSModeReg 0x0430
+#define GUSMdmapen 0x00008000
+#define GUSMstgtdis 0x00000080
+#define GUSMstgttim 0x00000038
+#define GUSMstgttoff 0x00000004
+
+;	HID4
+#define hid4RMCI 23
+#define hid4FAlgn 24
+#define hid4DisPF 25
+#define hid4ResPF 26
+#define hid4EnSPTW 27
+#define hid4L1DCFI 28
+#define hid4DisDERpg 31
+#define hid4DisDCTpg 36
+#define hid4DisDCpg 41
+#define hid4DisTLBpg 48
+#define hid4DisSLBpg 54
+#define hid4MckEIEna 55
+
 ;	L2 cache control
 #define l2e		0
 #define l2em	0x80000000
@@ -476,6 +628,13 @@
 #define cr7_so	31
 #define cr7_un	31
 
+#define slbESID	36
+#define slbKey	52
+#define slbIndex 52
+#define slbV	36
+#define slbVm	0x08000000
+#define slbCnt	64
+
 /*
  * Macros to access high and low word values of an address
  */
diff --git a/osfmk/ppc/ast.h b/osfmk/ppc/ast.h
index fe64a1f94..3310e203c 100644
--- a/osfmk/ppc/ast.h
+++ b/osfmk/ppc/ast.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ppc/ast_types.h b/osfmk/ppc/ast_types.h
index 4db875d69..0f867cb58 100644
--- a/osfmk/ppc/ast_types.h
+++ b/osfmk/ppc/ast_types.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ppc/atomic_switch.h b/osfmk/ppc/atomic_switch.h
index 7b2eed2ff..dda677031 100644
--- a/osfmk/ppc/atomic_switch.h
+++ b/osfmk/ppc/atomic_switch.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ppc/atomic_switch.s b/osfmk/ppc/atomic_switch.s
index 607bc04a4..c66791ba5 100644
--- a/osfmk/ppc/atomic_switch.s
+++ b/osfmk/ppc/atomic_switch.s
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -75,6 +78,10 @@ ENTRY(atomic_switch_trap, TAG_NO_FRAME_USED)
 
 			li		r5, BTTD_TRAP_VECTOR
 
+			cmplwi	r24,0x3C							; (BRINGUP)
+			bne		.L_CallPseudoKernel					; (BRINGUP)
+			nop											; (BRINGUP)
+
 /******************************************************************************
  * void CallPseudoKernel ( int vector, thread_act_t * act, BEDA_t * beda, savearea *sv )
  *
@@ -134,20 +141,20 @@ ENTRY(atomic_switch_trap, TAG_NO_FRAME_USED)
 
 .L_CallFromPreemptiveThread:
 
-			lwz		r1,savesrr0(r4)						; Get current PC
-			lwz		r2,saver1(r4)						; Get current R1
-			lwz		r3,savesrr1(r4)						; Get current MSR
+			lwz		r1,savesrr0+4(r4)					; Get current PC
+			lwz		r2,saver1+4(r4)						; Get current R1
+			lwz		r3,savesrr1+4(r4)					; Get current MSR
 			stw		r1,BEDA_SRR0(r26)					; Save current PC
 			rlwinm	r3,r3,0,MSR_BE_BIT+1,MSR_SE_BIT-1				
 														; Clear SE|BE bits in MSR
 			stw		r2,BEDA_SPRG1(r26)					; Save current R1 
-			stw		r3,savesrr1(r4)						; Load new MSR
+			stw		r3,savesrr1+4(r4)					; Load new MSR
 
 			lwz		r1,BEDA_SPRG0(r26)					; Get replacement R1
 			lwzx	r2,r5,r6							; Load vector address
 			stw		r3,BEDA_SRR1(r26)					; Update saved MSR
-			stw		r1,saver1(r4)						; Load up new R1
-			stw		r2,savesrr0(r4)						; Save vector as PC
+			stw		r1,saver1+4(r4)						; Load up new R1
+			stw		r2,savesrr0+4(r4)					; Save vector as PC
 
 			b		EXT(fastexit)						; Go back and take the fast path exit...
 
@@ -183,7 +190,7 @@ ENTRY(atomic_switch_trap, TAG_NO_FRAME_USED)
 			ori		r7,r7,(0x8000 >> (bbNoMachSCbit - 16))	; Disable Mach SCs for Blue Box
 
 			cmpwi	r2,0								; Is this a preemptive thread
-			stw		r1,savectr(r4)						; Update CTR
+			stw		r1,savectr+4(r4)						; Update CTR
 			beq		.L_ExitFromPreemptiveThread
 
 			lwz		r8,BTTD_INTCONTROLWORD(r6)			; Get ICW
@@ -199,10 +206,10 @@ ENTRY(atomic_switch_trap, TAG_NO_FRAME_USED)
 			beq		cr1,.L_ExitToSystemContext			; We are in system context
 			beq		.L_ExitUpdateRuptControlWord		; We do not have a pending interrupt
 
-			lwz		r2,saver1(r4)						; Get current R1
+			lwz		r2,saver1+4(r4)						; Get current R1
 			lwz		r1,BEDA_SPRG0(r26)					; Get replacement R1
 			stw		r2,BEDA_SPRG1(r26)					; Save current R1
-			stw		r1,saver1(r4)						; Load up new R1
+			stw		r1,saver1+4(r4)						; Load up new R1
 			lwz		r3,BTTD_PENDINGINT_VECTOR(r6)		; Get pending interrupt PC
 			b		.L_ExitAbortExit					; Abort and Exit
 
@@ -215,17 +222,17 @@ ENTRY(atomic_switch_trap, TAG_NO_FRAME_USED)
 
 .L_ExitFromPreemptiveThread:
 			mfsprg	r3,0								; Get the per_proc
-			lwz		r2,savesrr1(r4)						; Get current MSR	
+			lwz		r2,savesrr1+4(r4)					; Get current MSR	
 			lwz		r1,BEDA_SRR1(r26)					; Get new MSR
 			stw		r7,ACT_MACT_SPF(r13)				; Update special flags
 			stw		r7,spcFlags(r3)						; Update per_proc version
 			rlwimi	r2,r1,0,MSR_FE0_BIT,MSR_FE1_BIT
 														; Insert FE0,FE1,SE,BE bits
 			lwz		r3,BEDA_SRR0(r26)					; Get new PC
-			stw		r2,savesrr1(r4)						; Update MSR
+			stw		r2,savesrr1+4(r4)						; Update MSR
 
 .L_ExitAbortExit:
-			stw		r3,savesrr0(r4)						; Update PC
+			stw		r3,savesrr0+4(r4)						; Update PC
 
 			b		EXT(fastexit)						; Go back and take the fast path exit...
 
diff --git a/osfmk/ppc/bat_init.c b/osfmk/ppc/bat_init.c
index 5d36e6fa4..9ea600f3b 100644
--- a/osfmk/ppc/bat_init.c
+++ b/osfmk/ppc/bat_init.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ppc/bcopy.s b/osfmk/ppc/bcopy.s
index 1a18bf37a..389fe4b2f 100644
--- a/osfmk/ppc/bcopy.s
+++ b/osfmk/ppc/bcopy.s
@@ -1,21 +1,24 @@
 /*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -27,13 +30,22 @@
 ;
 #include <ppc/asm.h>
 #include <ppc/proc_reg.h>
+#include <assym.s>
 
 ;		Use CR5_lt to indicate non-cached
 #define noncache 20
+
 ;		Use CR5_gt to indicate that we need to turn data translation back on
 #define fixxlate 21
-;		Use CR5_eq to indicate that we need to invalidate bats
-#define killbats 22
+
+;		Use CR5_eq to indicate that we need to invalidate bats (if 32-bit) or turn off
+;		64-bit mode (if 64-bit) before returning to our caller.  We overload the
+;		bit to reduce the number of conditional branches at bcopy exit.
+#define restorex 22
+
+;		Use CR5_so to indicate that we need to restore real-mode cachability
+;		Only needed on 64-bit machines
+#define flipcache 23
 
 ;
 ; bcopy_nc(from, to, nbytes)
@@ -53,19 +65,24 @@ LEXT(bcopy_nc)
 ;	
 ; void bcopy_physvir(from, to, nbytes)
 ; Attempt to copy physically addressed memory with translation on if conditions are met.
-; Otherwise do a normal bcopy_phys.
+; Otherwise do a normal bcopy_phys.  This routine is used because some 32-bit processors 
+; are very slow doing real-mode (translation off) copies, so we set up temporary BATs
+; for the passed phys addrs and do the copy with translation on.  
 ;
 ; Rules are: neither source nor destination can cross a page. 
-; No accesses above the 2GB line (I/O or ROM).
 ;
-; Interrupts must be disabled throughout the copy when this is called
-
+; Interrupts must be disabled throughout the copy when this is called.
 ; To do this, we build a
 ; 128 DBAT for both the source and sink.  If both are the same, only one is
 ; loaded.  We do not touch the IBATs, so there is no issue if either physical page
 ; address is the same as the virtual address of the instructions we are executing.
 ;
-; At the end, we invalidate the used DBATs and reenable interrupts.
+; At the end, we invalidate the used DBATs.
+;
+; Note that the address parameters are long longs.  We will transform these to 64-bit
+; values.  Note that on 32-bit architectures that this will ignore the high half of the
+; passed in value.  This should be ok since we can not have any bigger than 32 bit addresses
+; there anyhow.
 ;
 ; Note, this one will not work in user state
 ; 
@@ -75,22 +92,32 @@ LEXT(bcopy_nc)
 
 LEXT(bcopy_physvir)
 
-			addic.	r0,r5,-1					; Get length - 1
+			crclr	flipcache					; (HACK) No cache flip needed
+            mfsprg	r8,2						; get processor feature flags
+            rlwinm	r3,r3,0,1,0					; Duplicate high half of long long paddr into top of reg
+			addic.	r0,r7,-1					; Get length - 1
+			rlwimi	r3,r4,0,0,31				; Combine bottom of long long to full 64-bits
 			add		r11,r3,r0					; Point to last byte of sink
-			cmplw	cr1,r3,r4					; Does source == sink?			
+			rlwinm	r4,r5,0,1,0					; Duplicate high half of long long paddr into top of reg
+            mtcrf	0x02,r8						; move pf64Bit to cr6 so we can test
+            rlwimi	r4,r6,0,0,31				; Combine bottom of long long to full 64-bits
+			mr		r5,r7						; Get the length into the right register
+			cmplw	cr1,r3,r4					; Does source == sink?	
+            bt++	pf64Bitb,bcopy_phys1		; if 64-bit processor, use standard routine (no BATs)
 			add		r12,r4,r0					; Point to last byte of source
 			bltlr-								; Bail if length is 0 or way too big
 			xor		r7,r11,r3					; See if we went to next page
 			xor		r8,r12,r4					; See if we went to next page
 			or		r0,r7,r8					; Combine wrap
 			
-			li		r9,((PTE_WIMG_CB_CACHED_COHERENT<<3)|2)	; Set default attributes
+//			li		r9,((PTE_WIMG_CB_CACHED_COHERENT<<3)|2)	; Set default attributes
+			li		r9,((2<<3)|2)				; Set default attributes
 			rlwinm.	r0,r0,0,0,19				; Did we overflow a page?
 			li		r7,2						; Set validity flags
 			li		r8,2						; Set validity flags
-			bne-	EXT(bcopy_phys)				; Overflowed page, do normal physical copy...
+			bne-	bcopy_phys1					; Overflowed page, do normal physical copy...
 
-			crset	killbats					; Remember to trash BATs on the way out
+			crset	restorex					; Remember to trash BATs on the way out
 			rlwimi	r11,r9,0,15,31				; Set sink lower DBAT value
 			rlwimi	r12,r9,0,15,31				; Set source lower DBAT value
 			rlwimi	r7,r11,0,0,14				; Set sink upper DBAT value
@@ -109,41 +136,123 @@ LEXT(bcopy_physvir)
 
 bcpvsame:	mr		r6,r3						; Set source
 			crclr	noncache					; Set cached
+			crclr	fixxlate					; Set translation already ok
 			
-			b		copyit						; Go copy it...
-
+			b		copyit32					; Go copy it...
 
 ;	
 ; void bcopy_phys(from, to, nbytes)
 ; Turns off data translation before the copy.  Note, this one will
-; not work in user state
+; not work in user state.  This routine is used on 32 and 64-bit
+; machines.
+;
+; Note that the address parameters are long longs.  We will transform these to 64-bit
+; values.  Note that on 32-bit architectures that this will ignore the high half of the
+; passed in value.  This should be ok since we can not have any bigger than 32 bit addresses
+; there anyhow.
+;
+; Also note that you probably will not be happy if either the sink or source spans across the
+; boundary between RAM and I/O space.  Good chance of hanging the machine and this code 
+; will not check, so be careful.
 ;
 
 			.align	5
 			.globl	EXT(bcopy_phys)
 
 LEXT(bcopy_phys)
-
+			crclr	flipcache					; (HACK) No cache flip needed
+            rlwinm	r3,r3,0,1,0					; Duplicate high half of long long paddr into top of reg
+            mfsprg	r8,2						; get processor feature flags
+			rlwimi	r3,r4,0,0,31				; Combine bottom of long long to full 64-bits
+			rlwinm	r4,r5,0,1,0					; Duplicate high half of long long paddr into top of reg
+			mtcrf	0x02,r8						; move pf64Bit to cr6 so we can test
+			rlwimi	r4,r6,0,0,31				; Combine bottom of long long to full 64-bits
+			mr		r5,r7						; Get the length into the right register
+            
+bcopy_phys1:									; enter from bcopy_physvir with pf64Bit already in cr6
 			mfmsr	r9							; Get the MSR
-
 			crclr	noncache					; Set cached
-			rlwinm.	r8,r9,0,MSR_DR_BIT,MSR_DR_BIT	; Is data translation on?
-
-			cmplw	cr1,r4,r3					; Compare "to" and "from"
+            bt++	pf64Bitb,bcopy_phys64		; skip if 64-bit (only they take hint)
+
+; 32-bit CPUs
+            
+            sub.	r0,r3,r4					; to==from?
+			rlwinm	r8,r9,0,MSR_DR_BIT,MSR_DR_BIT	; was translation on?
+            cmpwi	cr1,r8,0					; set cr1 beq if translation was off
+			oris	r8,r8,hi16(MASK(MSR_VEC))	; Get vector enable
 			cmplwi	cr7,r5,0					; Check if we have a 0 length
+            beqlr-								; bail if to==from
+			ori		r8,r8,lo16(MASK(MSR_FP))	; Get FP
 			mr		r6,r3						; Set source
-			beqlr-	cr1							; Bail if "to" and "from" are the same	
-			xor		r9,r9,r8					; Turn off translation if it is on (should be)
+			andc	r9,r9,r8					; Turn off translation if it is on (should be) and FP, VEC
 			beqlr-	cr7							; Bail if length is 0
 			
-			rlwinm	r9,r9,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-			crclr	killbats					; Make sure we do not trash BATs on the way out
-			rlwinm	r9,r9,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
+			crclr	restorex					; Make sure we do not trash BATs on the way out
 			mtmsr	r9							; Set DR translation off
 			isync								; Wait for it
 			
-			crnot	fixxlate,cr0_eq				; Remember to turn on translation if it was
-			b		copyit						; Go copy it...
+			crnot	fixxlate,cr1_eq				; Remember to turn on translation if it was
+			b		copyit32					; Go copy it...
+            
+; 64-bit: turn DR off and SF on, remember if we need to restore on way out.
+
+bcopy_phys64:									; r9 = MSR
+
+			srdi	r2,r3,31					; (HACK) Get a 1 if source is in I/O memory
+            srdi.	r0,r9,63-MSR_SF_BIT			; set cr0 beq on if SF was off when we were called
+            rlwinm	r8,r9,MSR_DR_BIT+1,31,31	; r8 <- DR bit right justified
+            cmpld	cr1,r3,r4					; to==from?
+            li		r0,1						; Note - we use this in a couple places below
+			lis		r6,hi16(MASK(MSR_VEC))		; Get vector enable
+            cmpwi	cr7,r5,0					; length==0 ?
+            ori		r6,r6,lo16(MASK(MSR_FP)|MASK(MSR_DR))	; Add in FP and DR
+            beqlr--	cr1							; bail if to==from
+			srdi	r10,r4,31					; (HACK) Get a 1 if sink is in I/O memory
+            rldimi	r9,r0,63,MSR_SF_BIT			; set SF on
+            beqlr--	cr7							; bail if length==0
+            andc	r9,r9,r6					; turn DR, VEC, FP off
+            cmpwi	cr1,r8,0					; was DR on?
+            crmove	restorex,cr0_eq				; if SF was off, remember to turn back off before we return
+            mtmsrd	r9							; turn 64-bit addressing on, data translation off
+			cmpldi	cr0,r2,1					; (HACK) Is source in I/O memory?
+            isync								; wait for it to happen
+			mr		r6,r3						; Set source
+			cmpldi	cr7,r10,1					; (HACK) Is sink in I/O memory?
+            crnot	fixxlate,cr1_eq				; if DR was on, remember to turn back on before we return
+
+			cror	flipcache,cr0_eq,cr7_eq		; (HACK) See if either source or sink is in I/O area
+
+			rlwinm	r10,r9,MSR_EE_BIT+1,31,31	; (HACK GLORIOUS HACK) Isolate the EE bit
+			sldi	r11,r0,31-MSR_EE_BIT		; (HACK GLORIOUS HACK)) Get a mask for the EE bit
+			sldi	r0,r0,32+8					; (HACK) Get the right bit to turn off caching
+			bf++	flipcache,copyit64			; (HACK) No need to mess with caching...
+			
+;
+;			HACK GLORIOUS HACK - when we force of caching, we need to also force off
+;			interruptions.  We are out of CR bits, so we need to stash the entry EE
+;			somewheres.  It is in the XER....  We NEED to change this!!!!
+;
+
+			mtxer	r10							; (HACK GLORIOUS HACK) Remember EE
+			andc	r9,r9,r11					; (HACK GLORIOUS HACK) Turn off EE bit
+			mfspr	r2,hid4						; (HACK) Get HID4
+			crset	noncache					; (HACK) Set non-cached
+			mtmsrd	r9							; (HACK GLORIOUS HACK) Force off EE
+			or		r2,r2,r0					; (HACK) Set bit to make real accesses cache-inhibited
+			sync								; (HACK) Sync up
+			li		r0,1
+			mtspr	hid4,r2						; (HACK) Make real accesses cache-inhibited
+			isync								; (HACK) Toss prefetches
+
+			lis		r12,0xE000					; (HACK) Get the unlikeliest ESID possible
+			srdi	r12,r12,1					; (HACK) Make 0x7FFFFFFFF0000000
+			slbie	r12							; (HACK) Make sure the ERAT is cleared 
+			
+			sync								; (HACK)
+			isync								; (HACK)
+			
+            b		copyit64
+            
 
 ;	
 ; void bcopy(from, to, nbytes)
@@ -156,14 +265,19 @@ LEXT(bcopy)
 
 			crclr	noncache					; Set cached
 
-bcpswap:	cmplw	cr1,r4,r3					; Compare "to" and "from"
-			mr.		r5,r5						; Check if we have a 0 length
+bcpswap:	
+			crclr	flipcache					; (HACK) No cache flip needed
+            mfsprg	r8,2						; get processor feature flags
+            sub.	r0,r4,r3					; test for to==from in mode-independent way
+            mtcrf	0x02,r8						; move pf64Bit to cr6 so we can test
+			cmpwi	cr1,r5,0					; Check if we have a 0 length
+			crclr	restorex					; Make sure we do not trash BATs on the way out
 			mr		r6,r3						; Set source
-			crclr	killbats					; Make sure we do not trash BATs on the way out
-			beqlr-	cr1							; Bail if "to" and "from" are the same	
-			beqlr-								; Bail if length is 0
 			crclr	fixxlate					; Set translation already ok
-			b		copyit						; Go copy it...
+			beqlr-								; Bail if "to" and "from" are the same	
+			beqlr-	cr1							; Bail if length is 0
+            bt++	pf64Bitb,copyit64			; handle 64-bit processor
+			b		copyit32					; Go copy it...
 
 ;
 ;			When we move the memory, forward overlays must be handled.  We
@@ -171,19 +285,32 @@ bcpswap:	cmplw	cr1,r4,r3					; Compare "to" and "from"
 ;			We need to preserve R3 because it needs to be returned for memcpy.
 ;			We can be interrupted and lose control here.
 ;
-;			There is no stack, so in order to used floating point, we would
-;			need to take the FP exception. Any potential gains by using FP 
+;			There is no stack, so in order to use vectors, we would
+;			need to take the vector exception. Any potential gains by using vectors 
 ;			would be more than eaten up by this.
 ;
-;			Later, we should used Altivec for large moves.
+;			NOTE: this code is called in three "modes":
+;				- on 32-bit processors (32-byte cache line)
+;				- on 64-bit processors running in 32-bit mode (128-byte cache line)
+;				- on 64-bit processors running in 64-bit mode (128-byte cache line)
+;
+;			ALSO NOTE: bcopy is called from copyin and copyout etc
+;			with the "thread_recover" ptr set.  This means bcopy must not set up a
+;			stack frame or touch non-volatile registers, and also means that it
+;			cannot rely on turning off interrupts, because we expect to get DSIs
+;			and have execution aborted by a "longjmp" to the thread_recover
+;			routine.
 ;
 	
 			.align	5
 			.globl	EXT(memcpy)
-
+            ; NB: memcpy is only called in 32-bit mode, albeit on both 32- and 64-bit
+            ; processors...
 LEXT(memcpy)
-
+			crclr	flipcache					; (HACK) No cache flip needed
+            mfsprg	r8,2						; get processor feature flags
 			cmplw	cr1,r3,r4					; "to" and "from" the same?
+            mtcrf	0x02,r8						; move pf64Bit to cr6 so we can test
 			mr		r6,r4						; Set the "from"
 			mr.		r5,r5						; Length zero?
 			crclr	noncache					; Set cached
@@ -191,9 +318,10 @@ LEXT(memcpy)
 			crclr	fixxlate					; Set translation already ok
 			beqlr-	cr1							; "to" and "from" are the same
 			beqlr-								; Length is 0
-			crclr	killbats					; Make sure we do not trash BATs on the way out
+			crclr	restorex					; Make sure we do not trash BATs on the way out
+            bt++	pf64Bitb,copyit64			; handle 64-bit processors
 			
-copyit:		sub		r12,r4,r6					; Get potential overlap (negative if backward move)
+copyit32:	sub		r12,r4,r6					; Get potential overlap (negative if backward move)
 			lis		r8,0x7FFF					; Start up a mask
 			srawi	r11,r12,31					; Propagate the sign bit
 			dcbt	br0,r6						; Touch in the first source line
@@ -206,7 +334,7 @@ copyit:		sub		r12,r4,r6					; Get potential overlap (negative if backward move)
 			cmplwi	cr7,r9,32					; See if at least a line between  source and sink
 			dcbtst	br0,r4						; Touch in the first sink line
 			cmplwi	cr1,r5,32					; Are we moving more than a line?
-			cror	noncache,noncache,28		; Set to not DCBZ output line if not enough space
+			cror	noncache,noncache,cr7_lt	; Set to not DCBZ output line if not enough space
 			blt-	fwdovrlap					; This is a forward overlapping area, handle it...
 
 ;
@@ -222,6 +350,7 @@ copyit:		sub		r12,r4,r6					; Get potential overlap (negative if backward move)
 ;			We can not do this if noncache is set because we will take an 
 ;			alignment exception.
 
+G4word:											; enter from 64-bit case with word aligned uncached operands
 			neg		r0,r4						; Get the number of bytes to move to align to a line boundary
 			rlwinm.	r0,r0,0,27,31				; Clean it up and test it
 			and		r0,r0,r8					; limit to the maximum front end move
@@ -358,17 +487,45 @@ nohalf:		bf		31,bcpydone					; Leave cuz we are all done...
 			lbz		r7,0(r6)					; Get the byte
 			stb		r7,0(r4)					; Save the single
 
-bcpydone:	bt-		killbats,bcclrbat			; Jump if we need to clear bats...
-			bflr	fixxlate					; Leave now if we do not need to fix translation...
+bcpydone:	
 			mfmsr	r9							; Get the MSR
+			bf++	flipcache,bcpydone0			; (HACK) No need to mess with caching...
+
+			li		r0,1						; (HACK) Get a 1
+			mfxer	r10							; (HACK GLORIOUS HACK) Get the entry EE
+			sldi	r0,r0,32+8					; (HACK) Get the right bit to turn off caching
+			mfspr	r2,hid4						; (HACK) Get HID4
+			rlwinm	r10,r10,31-MSR_EE_BIT,MSR_EE_BIT,MSR_EE_BIT	; (HACK GLORIOUS HACK) Set the EE bit
+			andc	r2,r2,r0					; (HACK) Clear bit to make real accesses cache-inhibited
+			or		r9,r9,r10					; (HACK GLORIOUS HACK) Set the EE in MSR
+			sync								; (HACK) Sync up
+			mtspr	hid4,r2						; (HACK) Make real accesses not cache-inhibited
+			isync								; (HACK) Toss prefetches
+	
+			lis		r12,0xE000					; (HACK) Get the unlikeliest ESID possible
+			srdi	r12,r12,1					; (HACK) Make 0x7FFFFFFFF0000000
+			slbie	r12							; (HACK) Make sure the ERAT is cleared 
+
+			mtmsr	r9							; (HACK GLORIOUS HACK) Set EE properly
+
+bcpydone0:
+			lis		r0,hi16(MASK(MSR_VEC))		; Get the vector bit
+			ori		r0,r0,lo16(MASK(MSR_FP))	; Get the float bit
+			bf++	fixxlate,bcpydone1			; skip if we do not need to fix translation...
 			ori		r9,r9,lo16(MASK(MSR_DR))	; Turn data translation on
-			rlwinm	r9,r9,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-			rlwinm	r9,r9,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
+			andc	r9,r9,r0					; Make sure that FP and VEC are off
 			mtmsr	r9							; Just do it
 			isync								; Hang in there
-			blr									; Leave cuz we are all done...			
-
-bcclrbat:	li		r0,0						; Get set to invalidate upper half
+            
+bcpydone1:
+            bflr++	restorex					; done if we do not have to fix up addressing
+            mfsprg	r8,2						; get the feature flags again
+            mtcrf	0x02,r8						; put pf64Bit where we can test it
+            bt++	pf64Bitb,bcpydone2			; skip if 64-bit processor
+            
+            ; 32-bit processor, so clear out the BATs we set up for bcopy_physvir
+            
+            li		r0,0						; Get set to invalidate upper half
 			sync								; Make sure all is well
 			mtdbatu	0,r0						; Clear sink upper DBAT
 			mtdbatu	1,r0						; Clear source upper DBAT
@@ -376,6 +533,16 @@ bcclrbat:	li		r0,0						; Get set to invalidate upper half
 			isync			
 			blr
 
+            ; 64-bit processor, so turn off 64-bit mode we turned on to do bcopy_phys
+            
+bcpydone2:
+            mfmsr	r9							; get MSR again
+			andc	r9,r9,r0					; Make sure that FP and VEC are off
+            rldicl	r9,r9,0,MSR_SF_BIT+1		; clear SF
+            mtmsrd	r9
+            isync
+            blr
+
 
 ;
 ;			0123456789ABCDEF0123456789ABCDEF
@@ -396,7 +563,8 @@ bcclrbat:	li		r0,0						; Get set to invalidate upper half
 ;			and on in order.  That means that when we are at the second to last DW we
 ;			have to wait until the whole line is in cache before we can proceed.
 ;
-	
+
+G4reverseWord:									; here from 64-bit code with word aligned uncached operands
 fwdovrlap:	add		r4,r5,r4					; Point past the last sink byte
 			add		r6,r5,r6					; Point past the last source byte 
 			and		r0,r4,r8					; Apply movement limit
@@ -543,3 +711,306 @@ bnohalf:	bflr	31							; Leave cuz we are all done...
 			stb		r7,-1(r4)					; Save the single
 			
 			b		bcpydone					; Go exit cuz we are all done...
+
+
+// Here on 64-bit processors, which have a 128-byte cache line.  This can be
+// called either in 32 or 64-bit mode, which makes the test for reverse moves
+// a little tricky.  We've already filtered out the (sou==dest) and (len==0)
+// special cases.
+//
+// When entered:
+//		r4 = destination (32 or 64-bit ptr)
+//		r5 = length (always 32 bits)
+//		r6 = source (32 or 64-bit ptr)
+//		cr5 = noncache, fixxlate, flipcache, and restorex flags set
+
+        .align	5
+copyit64:
+        lis		r2,0x4000			// r2 = 0x00000000 40000000
+        neg		r12,r4				// start to compute #bytes to align dest
+		bt--	noncache,noncache1	// (HACK) Do not even try anything cached...
+        dcbt	0,r6				// touch in 1st block of source
+noncache1:     
+        add.	r2,r2,r2			// if 0x00000000 80000000 < 0, we are in 32-bit mode
+        cntlzw	r9,r5				// get highest power-of-2 in length
+        rlwinm	r7,r12,0,25,31		// r7 <- bytes to 128-byte align dest
+		bt--	noncache,noncache2	// (HACK) Do not even try anything cached...
+        dcbtst	0,r4				// touch in 1st destination cache block
+noncache2:
+        sraw	r2,r2,r9			// get mask with 1s for leading 0s in length, plus 1 more 1-bit
+        bge		copyit64a			// skip if we are running in 64-bit mode
+        rlwinm	r4,r4,0,0,31		// running in 32-bit mode, so truncate ptrs and lengths to 32 bits
+        rlwinm	r5,r5,0,0,31
+        rlwinm	r6,r6,0,0,31
+copyit64a:							// now we can use 64-bit compares even if running in 32-bit mode
+        sub		r8,r4,r6			// get (dest-source)
+        andc	r7,r7,r2			// limit bytes to align by operand length
+        cmpld	cr1,r8,r5			// if (dest-source)<length, must move reverse
+        bt--	noncache,c64uncached	// skip if uncached
+        blt--	cr1,c64rdouble		// handle cached reverse moves        
+        
+        
+// Forward, cached or doubleword aligned uncached.  This is the common case.
+//   r4-r6 = dest, length, source (as above)
+//		r7 = #bytes 128-byte align dest (limited by copy length)
+//     cr5 = flags, as above
+
+c64double:
+        andi.	r8,r7,7				// r8 <- #bytes to doubleword align
+        srwi	r9,r7,3				// r9 <- #doublewords to 128-byte align
+        sub		r5,r5,r7			// adjust length remaining
+        cmpwi	cr1,r9,0			// any doublewords to move to cache align?
+        srwi	r10,r5,7			// r10 <- 128-byte chunks to xfer after aligning dest
+        cmpwi	cr7,r10,0			// set cr7 on chunk count
+        beq		c64double2			// dest already doubleword aligned
+        mtctr	r8
+        b		c64double1
+        
+        .align	5					// align inner loops
+c64double1:							// copy bytes until dest is doubleword aligned
+        lbz		r0,0(r6)
+        addi	r6,r6,1
+        stb		r0,0(r4)
+        addi	r4,r4,1
+        bdnz	c64double1
+
+c64double2:							// r9/cr1=doublewords, r10=128-byte chunks, cr7=blt if r5==0
+        beq		cr1,c64double4		// no doublewords to xfer in order to cache align
+        mtctr	r9
+        b		c64double3
+
+        .align	5					// align inner loops
+c64double3:							// copy doublewords until dest is 128-byte aligned
+        ld		r7,0(r6)
+        addi	r6,r6,8
+        std		r7,0(r4)
+        addi	r4,r4,8
+        bdnz	c64double3
+        
+// Here to xfer 128-byte chunks, if any.  Because the IBM 970 cannot issue two stores/cycle,
+// we pipeline the inner loop so we can pair loads and stores.  Since we only have 8 GPRs for
+// data (64 bytes), we load/store each twice per 128-byte chunk.
+
+c64double4:							// r10/cr7=128-byte chunks
+        rlwinm	r0,r5,29,28,31		// r0 <- count of leftover doublewords, after moving chunks
+        cmpwi	cr1,r0,0			// set cr1 on leftover doublewords
+        beq		cr7,c64double7		// no 128-byte chunks
+        sub		r8,r6,r4			// r8 <- (source - dest)
+        li		r9,128				// start at next cache line (we've already touched in 1st line)
+        cmpldi	cr7,r8,128			// if (source-dest)<128, cannot use dcbz128 beacause of overlap
+        cror	noncache,cr7_lt,noncache	// turn on "noncache" flag if (source-dest)<128
+		bt--	noncache,noncache3	// (HACK) Skip cache touch if noncachable
+        dcbt128	r9,r6,1				// start forward stream
+noncache3:
+        mtctr	r10
+        
+        ld		r0,0(r6)			// start pipe: load 1st half-line
+        ld		r2,8(r6)
+        ld		r7,16(r6)
+        ld		r8,24(r6)
+        ld		r9,32(r6)
+        ld		r10,40(r6)
+        ld		r11,48(r6)
+        ld		r12,56(r6)
+		b		c64InnerLoopEntryPt
+        
+        .align	5					// align inner loop
+c64InnerLoop:						// loop copying 128-byte cache lines to 128-aligned destination
+        std		r0,64(r4)			// store 2nd half of chunk n
+        ld		r0,0(r6)			// load 1st half of chunk n+1
+        std		r2,72(r4)
+        ld		r2,8(r6)
+        std		r7,80(r4)
+        ld		r7,16(r6)
+        std		r8,88(r4)
+        ld		r8,24(r6)
+        std		r9,96(r4)
+        ld		r9,32(r6)
+        std		r10,104(r4)
+        ld		r10,40(r6)
+        std		r11,112(r4)
+        ld		r11,48(r6)
+        std		r12,120(r4)
+        ld		r12,56(r6)
+        addi	r4,r4,128			// advance to next dest chunk
+c64InnerLoopEntryPt:				// initial entry into loop, with 1st halfline loaded        
+        bt		noncache,c64InnerLoop1	// skip if uncached or overlap
+        dcbz128	0,r4				// avoid prefetch of next cache line
+c64InnerLoop1:
+        std		r0,0(r4)			// store 1st half of chunk n
+        ld		r0,64(r6)			// load 2nd half of chunk n
+        std		r2,8(r4)
+        ld		r2,72(r6)
+        std		r7,16(r4)
+        ld		r7,80(r6)
+        std		r8,24(r4)
+        ld		r8,88(r6)
+        std		r9,32(r4)
+        ld		r9,96(r6)
+        std		r10,40(r4)
+        ld		r10,104(r6)
+        std		r11,48(r4)
+        ld		r11,112(r6)
+        std		r12,56(r4)
+        ld		r12,120(r6)
+        addi	r6,r6,128			// advance to next source chunk if any
+        bdnz	c64InnerLoop		// loop if more chunks
+        
+        std		r0,64(r4)			// store 2nd half of last chunk
+        std		r2,72(r4)
+        std		r7,80(r4)
+        std		r8,88(r4)
+        std		r9,96(r4)
+        std		r10,104(r4)
+        std		r11,112(r4)
+        std		r12,120(r4)
+        addi	r4,r4,128			// advance to next dest chunk
+
+c64double7:         	            // r5 <- leftover bytes, cr1 set on doubleword count
+        rlwinm	r0,r5,29,28,31		// r0 <- count of leftover doublewords (0-15)
+        andi.	r5,r5,7				// r5/cr0 <- count of leftover bytes (0-7)
+        beq		cr1,c64byte			// no leftover doublewords
+        mtctr	r0
+        b		c64double8
+        
+        .align	5					// align inner loop
+c64double8:							// loop copying leftover doublewords
+        ld		r0,0(r6)
+        addi	r6,r6,8
+        std		r0,0(r4)
+        addi	r4,r4,8
+        bdnz	c64double8
+
+
+// Forward byte loop.
+
+c64byte:							// r5/cr0 <- byte count (can be big if unaligned uncached)
+		beq		bcpydone			// done if no leftover bytes
+        mtctr	r5
+        b		c64byte1
+        
+        .align	5					// align inner loop
+c64byte1:
+        lbz		r0,0(r6)
+        addi	r6,r6,1
+        stb		r0,0(r4)
+        addi	r4,r4,1
+        bdnz	c64byte1
+
+        b		bcpydone
+
+
+// Uncached copies.  We must avoid unaligned accesses, since they always take alignment
+// exceptions on uncached memory on 64-bit processors.  This may mean we copy long operands
+// a byte at a time, but that is still much faster than alignment exceptions.
+//   r4-r6 = dest, length, source (as above)
+//		r2 = mask of 1s for leading 0s in length, plus 1 extra 1
+//		r7 = #bytes to copy to 128-byte align dest (limited by operand length)
+//	   cr1 = blt if reverse move required
+
+c64uncached:
+        xor		r0,r6,r4			// get relative alignment
+        rlwinm	r10,r0,0,29,31		// relatively doubleword aligned?
+        rlwinm	r11,r0,0,30,31		// relatively word aligned?
+        not		r8,r2				// get mask to limit initial length of copy for G4word
+        blt		cr1,c64reverseUncached
+        
+        cmpwi	cr0,r10,0			// set cr0 beq if doubleword aligned
+        cmpwi	cr1,r11,0			// set cr1 beq if word aligned
+        beq		cr0,c64double		// doubleword aligned
+        beq		cr1,G4word			// word aligned, use G3/G4 code
+        cmpwi	r5,0				// set cr0 on byte count
+        b		c64byte				// unaligned operands
+
+c64reverseUncached:
+        cmpwi	cr0,r10,0			// set cr0 beq if doubleword aligned
+        cmpwi	cr1,r11,0			// set cr1 beq if word aligned
+        beq		cr0,c64rdouble		// doubleword aligned so can use LD/STD
+        beq		cr1,G4reverseWord	// word aligned, use G3/G4 code
+        add		r6,r6,r5			// point to (end+1) of source and dest
+        add		r4,r4,r5
+        cmpwi	r5,0				// set cr0 on length
+        b		c64rbyte			// copy a byte at a time
+        
+        
+
+// Reverse doubleword copies.  This is used for all cached copies, and doubleword
+// aligned uncached copies.
+//		r4 = destination (32 or 64-bit ptr)
+//		r5 = length (always 32 bits)
+//		r6 = source (32 or 64-bit ptr)
+//		cr5 = noncache, fixxlate, and restorex flags set
+
+c64rdouble:
+        add		r6,r6,r5			// point to (end+1) of source and dest
+        add		r4,r4,r5
+        rlwinm.	r7,r4,0,29,31		// r7 <- #bytes to doubleword align dest
+        cmplw	cr1,r7,r5			// operand long enough to doubleword align?
+        blt		cr1,c64rd0			// yes
+        mr		r7,r5				// no
+c64rd0:
+        sub		r5,r5,r7			// adjust length
+        srwi	r8,r5,6				// r8 <- 64-byte chunks to xfer
+        cmpwi	cr1,r8,0			// any chunks?
+        beq		c64rd2				// source already doubleword aligned
+        mtctr	r7
+
+c64rd1:								// copy bytes until source doublword aligned
+        lbzu	r0,-1(r6)
+        stbu	r0,-1(r4)
+        bdnz	c64rd1
+        
+c64rd2:								// r8/cr1 <- count of 64-byte chunks
+        rlwinm	r0,r5,29,29,31		// r0 <- count of leftover doublewords
+        andi.	r5,r5,7				// r5/cr0 <- count of leftover bytes
+        cmpwi	cr7,r0,0			// leftover doublewords?
+        beq		cr1,c64rd4			// no chunks to xfer
+        li		r9,-128				// start at next cache line
+        mtctr	r8
+        bt		noncache,c64rd3		// (HACK) Do not start a stream if noncachable...
+        dcbt128	r9,r6,3				// start reverse stream
+        b		c64rd3
+        
+        .align	5					// align inner loop
+c64rd3:								// loop copying 64-byte chunks
+        ld		r7,-8(r6)
+        ld		r8,-16(r6)
+        ld		r9,-24(r6)
+        ld		r10,-32(r6)
+        ld		r11,-40(r6)
+        ld		r12,-48(r6)
+        std		r7,-8(r4)
+        std		r8,-16(r4)
+        ld		r7,-56(r6)
+        ldu		r8,-64(r6)
+        std		r9,-24(r4)
+        std		r10,-32(r4)
+        std		r11,-40(r4)
+        std		r12,-48(r4)
+        std		r7,-56(r4)
+        stdu	r8,-64(r4)
+        bdnz	c64rd3
+
+c64rd4:								// r0/cr7 = leftover doublewords  r5/cr0 = leftover bytes
+        beq		cr7,c64rbyte		// no leftover doublewords
+        mtctr	r0
+        
+c64rd5:								// loop copying leftover doublewords
+        ldu		r0,-8(r6)
+        stdu	r0,-8(r4)
+        bdnz	c64rd5
+
+
+// Reverse byte loop.
+
+c64rbyte:							// r5/cr0 <- byte count (can be big if unaligned uncached)
+        beq		bcpydone			// done if no leftover bytes
+        mtctr	r5
+        
+c64rbyte1:
+        lbzu	r0,-1(r6)
+        stbu	r0,-1(r4)
+        bdnz	c64rbyte1
+
+        b		bcpydone
+
diff --git a/osfmk/ppc/bcopytest.c b/osfmk/ppc/bcopytest.c
new file mode 100644
index 000000000..e27d13eeb
--- /dev/null
+++ b/osfmk/ppc/bcopytest.c
@@ -0,0 +1,626 @@
+#include <cpus.h>
+#include <debug.h>
+#include <mach_kgdb.h>
+#include <mach_vm_debug.h>
+#include <db_machine_commands.h>
+
+#include <kern/thread.h>
+#include <kern/thread_act.h>
+#include <mach/vm_attributes.h>
+#include <mach/vm_param.h>
+#include <vm/vm_kern.h>
+#include <vm/vm_map.h>
+#include <vm/vm_page.h>
+#include <kern/spl.h>
+
+#include <kern/misc_protos.h>
+#include <ppc/exception.h>
+#include <ppc/misc_protos.h>
+#include <ppc/proc_reg.h>
+
+#include <vm/pmap.h>
+#include <ppc/pmap.h>
+#include <ppc/mem.h>
+
+#include <ppc/new_screen.h>
+#include <ppc/Firmware.h>
+#include <ppc/mappings.h>
+#include <ddb/db_output.h>
+
+#include <ppc/POWERMAC/video_console.h>		/* (TEST/DEBUG) */
+
+#define patper 253
+
+
+int main(void);
+void clrarea(unsigned int *source, unsigned int *sink);
+int tstcopy(void *src, void *snk, unsigned int lgn);
+void clrarea2(unsigned int *source, unsigned int *sink);
+int tstcopy2(void *src, void *snk, unsigned int lgn);
+int tstcopy3(void *src, void *snk, unsigned int lgn);
+int tstcopy4(void *src, void *snk, unsigned int lgn);
+int tstcopy5(void *src, void *snk, unsigned int lgn);
+int dumbcopy(void *src, void *snk, unsigned int lgn);
+
+
+unsigned int gtick(void);
+
+
+void bcopytest(void);
+void bcopytest(void) {
+
+	void *srcptr, *snkptr, *asrc, *asnk;
+	int bsrc, bsnk, size, iterations, i, ret, n; 
+	unsigned int makerand, timein, timeout, ticks;
+	volatile int dbg = 0;
+	unsigned int *sink, *source;
+	
+	long long tottime, totbytes;
+	long long tottime2, totbytes2;
+	
+	kern_return_t retr;
+	
+	db_printf("bcopy test\n");	
+	
+	retr = kmem_alloc_wired(kernel_map, (vm_offset_t *)&sink, (1024*1024)+4096);	/* Get sink area */
+	if(retr != KERN_SUCCESS) {	/* Did we find any memory at all? */
+		panic("bcopytest: Whoops...  no memory for sink\n");
+	}
+	
+	retr = kmem_alloc_wired(kernel_map, (vm_offset_t *)&source, (1024*1024)+4096);	/* Get source area */
+	if(retr != KERN_SUCCESS) {	/* Did we find any memory at all? */
+		panic("bcopytest: Whoops...  no memory for source\n");
+	}
+
+	db_printf("Source at %08X; Sink at %08X\n", source, sink);
+	
+	srcptr = (void *)&source[0];
+	snkptr = (void *)&sink[0];
+	
+#if 1
+	db_printf("Testing non-overlap case; source bndry = 0 to 7F; sink bndry = 0 - 7F; lgn = 1 to 256\n");
+	for(bsrc = 0; bsrc < 128; bsrc++) {			/* Step the source by 1 */
+		for(bsnk = 0; bsnk < 128; bsnk++) {		/* Step the sink by 1 */
+			for(size = 1; size <= 256; size++) {	/* Step the size by 1 */
+			
+				clrarea(source, sink);						/* Reset source and clear sink */
+				if(size == 255) {
+					dbg = 99;
+				}
+				if(tstcopy((void *)((unsigned int)srcptr + bsrc), (void *)((unsigned int)snkptr + bsnk), size)) {	
+					db_printf("Test failed; source = %02X; sink = %02X; length = %d\n", bsrc, bsnk, size);
+					db_printf("failed\n");
+				}
+			}
+		}
+	}
+	db_printf("Non-overlap test complete\n");
+#endif
+
+
+#if 1	
+	db_printf("Testing overlap\n");
+	for(bsrc = 1; bsrc < 128; bsrc++) {			/* Step the source by 1 */
+		for(bsnk = 0; bsnk < 128; bsnk++) {		/* Step the sink by 1 */
+			for(size = 1; size <= 256; size++) {	/* Step the size by 1 */
+			
+				clrarea2(source, sink);						/* Reset source and clear sink */
+				if(bsrc < bsnk) {
+					dbg = 88;
+				}
+				else {
+					dbg = 99;
+				}
+				if(tstcopy2((void *)((unsigned int)srcptr + bsrc), (void *)((unsigned int)srcptr + bsnk), size)) {	
+					db_printf("Test failed; source = %02X; sink = %02X; length = %d\n", bsrc, bsnk, size);
+					db_printf("failed\n");
+				}
+			}
+		}
+	}
+	db_printf("Overlap test complete\n");
+#endif
+
+#if 1
+	db_printf("Starting exhaustive tests\n");
+	for(i = 0; i < 262144 * 4; i++) {		/* Set all 1MB of source and dest to known pattern */
+		((unsigned char *)srcptr)[i] = i % patper;	/* Make a non-power-of-two length pattern */
+		((unsigned char *)snkptr)[i] = i % patper;	/* Make a non-power-of-two length pattern */
+	}
+
+	db_printf("No overlap; source < sink, length = 0 to 1023\nSource =");
+
+#if 1
+	for(bsrc = 0; bsrc < 128; bsrc++) {				/* Step source by 1 */
+		db_printf(" %3d", bsrc);					/* Show where we're at */
+		for(bsnk = 0; bsnk < 128; bsnk++) {			/* Step sink by 1 */
+			for(size = 0; size < 1025; size++) {	/* Step size from 0 to 1023 */				
+				asrc = (void *)((unsigned int)srcptr + bsrc); 			/* Start byte address */
+				asnk = (void *)((unsigned int)srcptr + bsnk + 2048);	/* End byte address */
+				ret = tstcopy5(asrc, asnk, size);	/* Copy and validate */
+				if(ret) {	
+					db_printf("\nTest failed - source = %3d, sink = %3d size = %d\n", bsrc, bsnk, size);
+					db_printf("failed\n");
+				}
+			}
+		}
+	}
+#endif
+				
+	db_printf("\n");
+	db_printf("No overlap; source > sink, length = 0 to 1023\nSource =");
+
+#if 1
+	for(bsrc = 0; bsrc < 128; bsrc++) {				/* Step source by 1 */
+		db_printf(" %3d", bsrc);					/* Show where we're at */
+		for(bsnk = 0; bsnk < 128; bsnk++) {			/* Step sink by 1 */
+			for(size = 0; size < 1025; size++) {	/* Step size from 0 to 1023 */				
+				asrc = (void *)((unsigned int)srcptr + bsrc + 2048);	/* Start byte address */
+				asnk = (void *)((unsigned int)srcptr + bsnk);			/* End byte address */
+				ret = tstcopy5(asrc, asnk, size);	/* Copy and validate */
+				if(ret) {	
+					db_printf("\nTest failed - source = %3d, sink = %3d size = %d\n", bsrc, bsnk, size);
+					db_printf("failed\n");
+				}
+			}
+		}
+	}
+#endif
+				
+	db_printf("\n");
+	db_printf("Overlap; source = sink + N (N = 0 to 127), length = 0 to 1023\nN =");
+
+#if 1
+	for(n = 0; n < 128; n++) {						/* Step n by 1 */
+		db_printf(" %3d", n);					/* Show where we're at */
+		for(bsnk = 0; bsnk < 128; bsnk++) {			/* Step sink by 1 */
+			for(size = 0; size < 1025; size++) {	/* Step size from 0 to 1023 */				
+				asrc = (void *)((unsigned int)srcptr + bsnk + n);	/* Start byte address */
+				asnk = (void *)((unsigned int)srcptr + bsnk);		/* End byte address */
+				ret = tstcopy5(asrc, asnk, size);	/* Copy and validate */
+				if(ret) {	
+					db_printf("\nTest failed - source = %3d, sink = %3d size = %d\n", bsrc, bsnk, size);
+					db_printf("failed\n");
+				}
+			}
+		}
+	}
+#endif
+				
+	db_printf("\n");
+	db_printf("Overlap; source + N = sink (N = 0 to 127), length = 0 to 1023\nSource =");
+
+#if 1
+	for(bsrc = 0; bsrc < 128; bsrc++) {				/* Step source by 1 */
+		db_printf(" %3d", bsrc);					/* Show where we're at */
+		for(n = 0; n < 128; n++) {					/* Step N by 1 */
+			for(size = 0; size < 1025; size++) {	/* Step size from 0 to 1023 */				
+				asrc = (void *)((unsigned int)srcptr + bsnk);	/* Start byte address */
+				asnk = (void *)((unsigned int)srcptr + bsnk + n);	/* End byte address */
+				ret = tstcopy5(asrc, asnk, size);	/* Copy and validate */
+				if(ret) {	
+					db_printf("\nTest failed - source = %3d, n = %3d size = %d\n", bsrc, n, size);
+					db_printf("failed\n");
+				}
+			}
+		}
+	}
+#endif
+				
+				
+	db_printf("\n");
+	db_printf("Overlap; source = sink + N + 128 (N = 0 to 127), length = 0 to 1023\nN =");
+
+#if 1
+	for(n = 0; n < 128; n++) {						/* Step n by 1 */
+		db_printf(" %3d", n);					/* Show where we're at */
+		for(bsnk = 0; bsnk < 128; bsnk++) {			/* Step sink by 1 */
+			for(size = 0; size < 1025; size++) {	/* Step size from 0 to 1023 */				
+				asrc = (void *)((unsigned int)srcptr + bsnk + n + 128);	/* Start byte address */
+				asnk = (void *)((unsigned int)srcptr + bsnk);		/* End byte address */
+				ret = tstcopy5(asrc, asnk, size);	/* Copy and validate */
+				if(ret) {	
+					db_printf("\nTest failed - source = %3d, sink = %3d size = %d\n", bsrc, bsnk, size);
+					db_printf("failed\n");
+				}
+			}
+		}
+	}
+#endif
+				
+	db_printf("\n");
+	db_printf("Overlap; source + N + 128 = sink (N = 0 to 127), length = 0 to 1023\nSource =");
+
+#if 1
+	for(bsrc = 0; bsrc < 128; bsrc++) {				/* Step source by 1 */
+		db_printf(" %3d", bsrc);					/* Show where we're at */
+		for(n = 0; n < 128; n++) {					/* Step N by 1 */
+			for(size = 0; size < 1025; size++) {	/* Step size from 0 to 1023 */				
+				asrc = (void *)((unsigned int)srcptr + bsnk);	/* Start byte address */
+				asnk = (void *)((unsigned int)srcptr + bsnk + n + 128);	/* End byte address */
+				ret = tstcopy5(asrc, asnk, size);	/* Copy and validate */
+				if(ret) {	
+					db_printf("\nTest failed - source = %3d, n = %3d size = %d\n", bsrc, n, size);
+					db_printf("failed\n");
+				}
+			}
+		}
+	}
+#endif
+				
+	db_printf("\n");
+	db_printf("Overlap; source = sink + N + 256 (N = 0 to 127), length = 0 to 1023\nSource =");
+
+#if 1
+	for(n = 0; n < 128; n++) {						/* Step n by 1 */
+		db_printf(" %3d", n);					/* Show where we're at */
+		for(bsnk = 0; bsnk < 128; bsnk++) {			/* Step sink by 1 */
+			for(size = 0; size < 1025; size++) {	/* Step size from 0 to 1023 */				
+				asrc = (void *)((unsigned int)srcptr + bsnk + n + 256);	/* Start byte address */
+				asnk = (void *)((unsigned int)srcptr + bsnk);		/* End byte address */
+				ret = tstcopy5(asrc, asnk, size);	/* Copy and validate */
+				if(ret) {	
+					db_printf("\nTest failed - source = %3d, sink = %3d size = %d\n", bsrc, bsnk, size);
+					db_printf("failed\n");
+				}
+			}
+		}
+	}
+#endif
+				
+	db_printf("\n");
+	db_printf("Overlap; source + N + 256 = sink (N = 0 to 127), length = 0 to 1023\nSource =");
+#if 1
+	for(bsrc = 0; bsrc < 128; bsrc++) {				/* Step source by 1 */
+		db_printf(" %3d", bsrc);					/* Show where we're at */
+		for(n = 0; n < 128; n++) {					/* Step N by 1 */
+			for(size = 0; size < 1025; size++) {	/* Step size from 0 to 1023 */				
+				asrc = (void *)((unsigned int)srcptr + bsnk);	/* Start byte address */
+				asnk = (void *)((unsigned int)srcptr + bsnk + n + 256);	/* End byte address */
+				ret = tstcopy5(asrc, asnk, size);	/* Copy and validate */
+				if(ret) {	
+					db_printf("\nTest failed - source = %3d, n = %3d size = %d\n", bsrc, n, size);
+					db_printf("failed\n");
+				}
+			}
+		}
+	}
+#endif
+				
+
+
+
+
+
+#endif
+	
+#if 0
+	iterations = 1000;
+	tottime = 0;
+	totbytes = 0;
+	
+	db_printf("Random test starting; iterations = %d\n", iterations);
+	for(i = 0; i < 262144 * 4; i++) {		/* Clear all 2MB of source (and dest for this test) */
+		((unsigned char *)srcptr)[i] = i & 255;
+	}
+	
+	for(i = 0; i < iterations; i++) {			/* Test until we are done */
+		makerand = rand() << 16 | (rand() & 0x0000FFFF);
+		bsrc = makerand & 0x0007FFFF;			/* Generate source */
+		makerand = rand() << 16 | (rand() & 0x0000FFFF);
+		bsnk = makerand & 0x0007FFFF;			/* Generate sink */
+		makerand = rand() << 16 | (rand() & 0x0000FFFF);
+		size = makerand & 0x0007FFFF;			/* Generate length */
+#if 1
+		db_printf("rt %7d: src = %08X; sink = %08X; length = %7d\n", i, ((unsigned int)srcptr + bsrc),
+			((unsigned int)srcptr + bsnk), size);
+#endif
+
+		asrc = (void *)((unsigned int)srcptr + bsrc); 
+		asnk = (void *)((unsigned int)srcptr + bsnk); 
+		timein = gtick();
+		ret = tstcopy3(asrc, asnk, size);
+		timeout = gtick();
+		if(ret) {	
+			db_printf("Test failed; source = %02X; sink = %02X; length = %d\n", bsrc, bsnk, size);
+			db_printf("failed\n");
+	
+		}
+		ticks = timeout - timein;				/* Get time in ticks for copy */
+		tottime += ticks;
+		totbytes += size;
+		
+		rate = (double) totbytes / (double)tottime;	/* Get bytes per tick */ 
+//		rate = rate * (double)11250000.0;				/* Bytes per second */
+//		rate = rate * (double)16500000.0;				/* Bytes per second */
+		rate = rate * (double)tbfreq;					/* Bytes per second */
+		rate = rate / (double)1000000.0;				/* Get number of MBs */
+		
+		db_printf("Total bytes = %lld; total time = %lld; rate = %f10\n", totbytes, tottime, rate);
+		
+	}
+#endif
+
+
+	
+#if 0
+	iterations = 100;
+	tottime = 0;
+	totbytes = 0;
+	
+	db_printf("Random test starting; iterations = %d\n", iterations);
+	for(i = 0; i < 262144 * 4; i++) {		/* Clear all 2MB of source (and dest for this test) */
+		((unsigned char *)srcptr)[i] = i & 255;
+	}
+	
+	for(i = 0; i < iterations; i++) {			/* Test until we are done */
+		makerand = rand() << 16 | (rand() & 0x0000FFFF);
+		bsrc = makerand & 0x0007FFFF;			/* Generate source */
+		makerand = rand() << 16 | (rand() & 0x0000FFFF);
+		bsnk = makerand & 0x0007FFFF;			/* Generate sink */
+		makerand = rand() << 16 | (rand() & 0x0000FFFF);
+		size = makerand & 0x0007FFFF;			/* Generate length */
+#if 1
+		db_printf("rt %7d: src = %08X; sink = %08X; length = %7d\n", i, ((unsigned int)srcptr + bsrc),
+			((unsigned int)srcptr + bsnk), size);
+#endif
+
+		asrc = (void *)((unsigned int)srcptr + bsrc); 
+		asnk = (void *)((unsigned int)srcptr + bsnk); 
+		timein = gtick();
+		ret = tstcopy4(asrc, asnk, size);
+		timeout = gtick();
+		if(ret) {	
+			db_printf("Test failed; source = %02X; sink = %02X; length = %d\n", bsrc, bsnk, size);
+			db_printf("failed\n");
+	
+		}
+		ticks = timeout - timein;				/* Get time in ticks for copy */
+		tottime += ticks;
+		totbytes += size;
+		
+		rate = (double) totbytes / (double)tottime;	/* Get bytes per tick */ 
+//		rate = rate * (double)11250000.0;				/* Bytes per second */
+//		rate = rate * (double)16500000.0;				/* Bytes per second */
+		rate = rate * (double)tbfreq;					/* Bytes per second */
+		rate = rate / (double)1000000.0;				/* Get number of MBs */
+		
+		db_printf("Total bytes = %lld; total time = %lld; rate = %f10\n", totbytes, tottime, rate);
+		
+	}
+#endif
+	
+#if 0
+	iterations = 100;
+	tottime = 0;
+	totbytes = 0;
+	
+	db_printf("Random test starting; iterations = %d\n", iterations);
+	for(i = 0; i < 262144 * 4; i++) {		/* Clear all 2MB of source (and dest for this test) */
+		((unsigned char *)srcptr)[i] = i & 255;
+	}
+	
+	for(i = 0; i < iterations; i++) {			/* Test until we are done */
+		makerand = rand() << 16 | (rand() & 0x0000FFFF);
+		bsrc = makerand & 0x0007FFFF;			/* Generate source */
+		makerand = rand() << 16 | (rand() & 0x0000FFFF);
+		bsnk = makerand & 0x0007FFFF;			/* Generate sink */
+		makerand = rand() << 16 | (rand() & 0x0000FFFF);
+		size = makerand & 0x0007FFFF;			/* Generate length */
+#if 1
+		db_printf("rt %7d: src = %08X; sink = %08X; length = %7d\n", i, ((unsigned int)srcptr + bsrc),
+			((unsigned int)srcptr + bsnk), size);
+#endif
+
+		asrc = (void *)((unsigned int)srcptr + bsrc); 
+		asnk = (void *)((unsigned int)srcptr + bsnk); 
+		timein = gtick();
+		ret = dumbcopy(asrc, asnk, size);
+		timeout = gtick();
+		if(ret) {	
+			db_printf("Test failed; source = %02X; sink = %02X; length = %d\n", bsrc, bsnk, size);
+			db_printf("failed\n");
+	
+		}
+		ticks = timeout - timein;				/* Get time in ticks for copy */
+		tottime += ticks;
+		totbytes += size;
+		
+		rate = (double) totbytes / (double)tottime;	/* Get bytes per tick */ 
+		rate = rate * (double)tbfreq;				/* Bytes per second */
+		rate = rate / (double)1000000.0;			/* Get number of MBs */
+		
+		db_printf("Total bytes = %lld; total time = %lld; rate = %f10\n", totbytes, tottime, rate);
+		
+	}
+#endif
+	
+	kmem_free(kernel_map, (vm_offset_t) sink, (1024*1024)+4096);	/* Release this mapping block */
+	kmem_free(kernel_map, (vm_offset_t) source, (1024*1024)+4096);	/* Release this mapping block */
+	
+	if(dbg == 22) db_printf("Gabbagoogoo\n");
+	return;
+}
+
+void clrarea(unsigned int *source, unsigned int *sink) {
+
+	unsigned int i;
+	
+	for(i=0; i < 1024; i++) {		/* Init source & sink */
+		source[i]	= 0x55555555;	/* Known pattern */
+		sink[i] 	= 0xAAAAAAAA;	/* Known pattern */
+	}
+	return;
+}
+
+void clrarea2(unsigned int *source, unsigned int *sink) {
+
+	unsigned int i;
+	unsigned char *ss;
+	
+	ss = (unsigned char *)&source[0];
+	
+	for(i=0; i < 1024 * 4; i++) {	/* Init source/sink */
+		ss[i] = i & 0xFF;			/* Known pattern */
+	}
+	return;
+}
+
+int tstcopy(void *src, void *snk, unsigned int lgn) {
+
+	unsigned int i, crap;
+	
+	bcopy(src, snk, lgn);
+	
+	for(i = 0; i < lgn; i++) {
+		if(((unsigned char *)snk)[i] != 0x55) {
+			crap = (unsigned int)&((unsigned char *)snk)[i];
+			db_printf("bad copy at sink[%d] (%08X) it is %02X\n", i,crap, ((unsigned char *)snk)[i]);
+			return 1;
+		}
+	}
+	if(((unsigned char *)snk)[lgn] != 0xAA) {	/* Is it right? */
+		crap = (unsigned int)&((unsigned char *)snk)[i];
+		db_printf("Copied too far at sink[%d] (%08X) it is %02X\n", i, crap, ((unsigned char *)snk)[lgn]);
+		return 1;
+	}
+	return 0;
+
+}
+
+int tstcopy2(void *src, void *snk, unsigned int lgn) {
+
+	unsigned int i, crap;
+	unsigned char ic, ec;
+	
+	ic = ((unsigned char *)src)[0];
+	ec = ((unsigned char *)snk)[lgn];
+	
+	bcopy(src, snk, lgn);
+	
+	for(i = 0; i < lgn; i++) {
+		if(((unsigned char *)snk)[i] != ic) {
+			crap = (unsigned int)&((unsigned char *)snk)[i];
+			db_printf("bad copy at sink[%d] (%08X) it is %02X\n", i,crap, ((unsigned char *)snk)[i]);
+			return 1;
+		}
+		ic = (ic + 1) & 0xFF;
+	}
+	
+	if(((unsigned char *)snk)[lgn] != ec) {	/* Is it right? */
+		crap = (unsigned int)&((unsigned char *)snk)[i];
+		db_printf("Copied too far at sink[%d] (%08X) it is %02X\n", i, crap, ((unsigned char *)snk)[lgn]);
+		return 1;
+	}
+	return 0;
+
+}
+
+int tstcopy3(void *src, void *snk, unsigned int lgn) {
+
+	unsigned int i, crap;
+	unsigned char ic, ec, oic;
+	
+	oic = ((unsigned char *)snk)[0];
+	ic = ((unsigned char *)src)[0];
+	ec = ((unsigned char *)snk)[lgn];
+	
+	bcopy(src, snk, lgn);
+	
+	for(i = 0; i < lgn; i++) {
+		if(((unsigned char *)snk)[i] != ic) {
+			crap = (unsigned int)&((unsigned char *)snk)[i];
+			db_printf("bad copy at sink[%d] (%08X) it is %02X\n", i ,crap, ((unsigned char *)snk)[i]);
+			return 1;
+		}
+		ic = (ic + 1) & 0xFF;
+	}
+	
+	if(((unsigned char *)snk)[lgn] != ec) {	/* Is it right? */
+		crap = (unsigned int)&((unsigned char *)snk)[i];
+		db_printf("Copied too far at sink[%d] (%08X) it is %02X\n", i, crap, ((unsigned char *)snk)[lgn]);
+		return 1;
+	}
+
+	for(i=0; i < lgn; i++) {	/* Restore pattern */
+		((unsigned char *)snk)[i] = oic;		
+		oic = (oic + 1) & 0xFF;
+	}
+
+	return 0;
+
+}
+
+int tstcopy4(void *src, void *snk, unsigned int lgn) {
+	
+	bcopy(src, snk, lgn);
+	return 0;
+
+}
+
+int tstcopy5(void *src, void *snk, unsigned int lgn) {
+
+	unsigned int i, crap;
+	unsigned char ic, ec, oic, pc;
+	
+	oic = ((unsigned char *)snk)[0];				/* Original first sink character */
+	ic = ((unsigned char *)src)[0];					/* Original first source character */
+	ec = ((unsigned char *)snk)[lgn];				/* Original character just after last sink character */
+	pc = ((unsigned char *)snk)[-1];				/* Original character just before sink */
+	
+	bcopy(src, snk, lgn);
+	
+	if(((unsigned char *)snk)[lgn] != ec) {			/* Did we copy too far forward? */
+		crap = (unsigned int)&((unsigned char *)snk)[i];
+		db_printf("Copied too far at sink[%d] (%08X) it is %02X\n", i, crap, ((unsigned char *)snk)[lgn]);
+		return 1;
+	}
+
+	if(((unsigned char *)snk)[-1] != pc) {			/* Did we copy too far backward? */
+		crap = (unsigned int)&((unsigned char *)snk)[i];
+		db_printf("Copied too far at sink[%d] (%08X) it is %02X\n", i, crap, ((unsigned char *)snk)[lgn]);
+		return 1;
+	}
+
+	for(i = 0; i < lgn; i++) {						/* Check sink byte sequence */
+		if(((unsigned char *)snk)[i] != ic) {
+			crap = (unsigned int)&((unsigned char *)snk)[i];
+			db_printf("bad copy at sink[%d] (%08X) it is %02X\n", i ,crap, ((unsigned char *)snk)[i]);
+			return 1;
+		}
+		ic = (ic + 1) % patper;
+	}
+
+	for(i=0; i < lgn; i++) {	/* Restore pattern */
+		((unsigned char *)snk)[i] = oic;		
+		oic = (oic + 1) % patper;
+	}
+
+	return 0;
+
+}
+
+int dumbcopy(void *src, void *snk, unsigned int lgn) {
+	int i;
+	char *p = (char *)snk;
+	char *q = (char *)src;
+	
+	for(i = 0; i < lgn; i++) {
+		*p++ = *q++;
+	}
+	return 0;
+
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/osfmk/ppc/bits.s b/osfmk/ppc/bits.s
index a01cf81fe..f7e586e85 100644
--- a/osfmk/ppc/bits.s
+++ b/osfmk/ppc/bits.s
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ppc/boot.h b/osfmk/ppc/boot.h
index e37a7d660..b6f2edac9 100644
--- a/osfmk/ppc/boot.h
+++ b/osfmk/ppc/boot.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ppc/bsd_asm.s b/osfmk/ppc/bsd_asm.s
deleted file mode 100644
index c1af2dafc..000000000
--- a/osfmk/ppc/bsd_asm.s
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
- *
- * @APPLE_LICENSE_HEADER_START@
- * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
- * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
- * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
- * 
- * @APPLE_LICENSE_HEADER_END@
- */
-#include <debug.h>           
-#include <mach_assert.h>
-#include <mach/exception_types.h>
-#include <mach/ppc/vm_param.h> 
-        
-#include <assym.s>
- 
-#include <ppc/asm.h> 
-#include <ppc/proc_reg.h>
-#include <ppc/trap.h>
-#include <ppc/exception.h>
- 
-/*
- * void cthread_set_self(cproc_t p)
- *
- * set's thread state "user_value"
- *
- * This op is invoked as follows:
- *	li r0, CthreadSetSelfNumber	// load the fast-trap number
- *	sc				// invoke fast-trap
- *	blr
- *
- * Entry:	VM switched ON
- *		Interrupts  OFF
- *              original r1-3 saved in sprg1-3
- *              original srr0 and srr1 saved in per_proc_info structure
- *              original cr            saved in per_proc_info structure
- *              exception type         saved in per_proc_info structure
- *              r1 = scratch
- *              r2 = virt addr of per_proc_info
- *		r3 = exception type (one of EXC_...)
- *
- */
- 	.text
-	.align	5
-ENTRY(CthreadSetSelfNumber, TAG_NO_FRAME_USED)
-	lwz	r1,	PP_CPU_DATA(r2)
-	lwz	r1,	CPU_ACTIVE_THREAD(r1)
-	lwz	r1,	THREAD_TOP_ACT(r1)  
-	lwz	r1,	ACT_MACT_PCB(r1)
-
-	mfsprg	r3,	3
-	stw	r3,	CTHREAD_SELF(r1)
-
-	/* Prepare to rfi to the exception exit routine, which is
-	 * in physical address space */
-	addis	r3,	0,	HIGH_CADDR(EXT(exception_exit))
-	addi	r3,	r3,	LOW_ADDR(EXT(exception_exit))
-
-	lwz	r3,	0(r3)
-	mtsrr0	r3
-	li	r3,	MSR_VM_OFF
-	mtsrr1	r3
-
-	lwz	r3,	PP_SAVE_SRR1(r2)	/* load the last register... */
-	lwz	r2,	PP_SAVE_SRR0(r2)	/* For trampoline */
-	lwz	r1,	PCB_SR0(r1)		/* For trampoline... */
-
-	rfi
-
-
-/*
- * ur_cthread_t ur_cthread_self(void)
- *
- * return thread state "user_value"
- *
- * This op is invoked as follows:
- *	li r0, UrCthreadSelfNumber	// load the fast-trap number
- *	sc				// invoke fast-trap
- *	blr
- *
- * Entry:	VM switched ON
- *		Interrupts  OFF
- *              original r1-3 saved in sprg1-3
- *              original srr0 and srr1 saved in per_proc_info structure
- *              original cr            saved in per_proc_info structure
- *              exception type         saved in per_proc_info structure
- *              r1 = scratch
- *              r2 = virt addr of per_proc_info
- *		r3 = exception type (one of EXC_...)
- *
- */
- 	.text
-	.align	5
-ENTRY(UrCthreadSelfNumber, TAG_NO_FRAME_USED)
-	lwz	r1,	PP_CPU_DATA(r2)
-	lwz	r1,	CPU_ACTIVE_THREAD(r1)
-	lwz	r1,	THREAD_TOP_ACT(r1)  
-	lwz	r1,	ACT_MACT_PCB(r1)
-
-	lwz	r3,	CTHREAD_SELF(r1)
-	mtsprg	3,	r3
-
-
-	/* Prepare to rfi to the exception exit routine, which is
-	 * in physical address space */
-	addis	r3,	0,	HIGH_CADDR(EXT(exception_exit))
-	addi	r3,	r3,	LOW_ADDR(EXT(exception_exit))
-	lwz	r3,	0(r3)
-	mtsrr0	r3
-	li	r3,	MSR_VM_OFF
-	mtsrr1	r3
-
-	lwz	r3,	PP_SAVE_SRR1(r2)	/* load the last register... */
-	lwz	r2,	PP_SAVE_SRR0(r2)	/* For trampoline */
-	lwz	r1,	PCB_SR0(r1)		/* For trampoline... */
-
-	rfi
diff --git a/osfmk/ppc/bsd_ppc.c b/osfmk/ppc/bsd_ppc.c
deleted file mode 100644
index d3afa89dc..000000000
--- a/osfmk/ppc/bsd_ppc.c
+++ /dev/null
@@ -1,280 +0,0 @@
-/*
- * Copyright (c) 2000-2001 Apple Computer, Inc. All rights reserved.
- *
- * @APPLE_LICENSE_HEADER_START@
- * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
- * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
- * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
- * 
- * @APPLE_LICENSE_HEADER_END@
- */
-#include <mach/mach_types.h>
-#include <mach/exception_types.h>
-#include <mach/error.h>
-#include <kern/counters.h>
-#include <kern/syscall_sw.h>
-#include <kern/task.h>
-#include <kern/thread.h>
-#include <ppc/thread.h>
-#include <kern/thread_act.h>
-#include <ppc/thread_act.h>
-#include <ppc/asm.h>
-#include <ppc/proc_reg.h>
-#include <ppc/trap.h>
-#include <ppc/exception.h>
-#include <kern/assert.h>
-
-#include <sys/syscall.h>
-#include <sys/ktrace.h>
-#include <sys/kdebug.h>
-struct proc;
-
-#define	ERESTART	-1		/* restart syscall */
-#define	EJUSTRETURN	-2		/* don't modify regs, just return */
-
-struct unix_syscallargs {
-	int flavor;
-	int r3;
-	int arg1, arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9;
-};
-struct sysent {		/* system call table */
-	unsigned short		sy_narg;		/* number of args */
-	char			sy_parallel;	/* can execute in parallel */
-	char			sy_funnel;	/* funnel type */
-	unsigned long		(*sy_call)(void *, void *, int *);	/* implementing function */
-};
-
-#define KERNEL_FUNNEL 1
-#define NETWORK_FUNNEL 2
-
-extern funnel_t * kernel_flock;
-extern funnel_t * network_flock;
-
-extern struct sysent sysent[];
-
-void  *get_bsdtask_info(
-	task_t);
-
-int set_bsduthreadargs (
-	thread_act_t, struct pcb *, 
-	struct unix_syscallargs  *);
-
-void * get_bsduthreadarg(
-	thread_act_t);
-
-void
-unix_syscall(
-	struct pcb * pcb,
-    int, int, int, int, int, int, int );
-
-/*
- * Function:	unix_syscall
- *
- * Inputs:	pcb	- pointer to Process Control Block
- *		arg1	- arguments to mach system calls
- *		arg2
- *		arg3
- *		arg4
- *		arg5
- *		arg6
- *		arg7
- *
- * Outputs:	none
- */
-void
-unix_syscall(
-    struct pcb * pcb,
-    int arg1,
-    int arg2,
-    int arg3,
-    int arg4,
-    int arg5,
-    int arg6,
-    int arg7 
-    )
-{
-	struct ppc_saved_state	*regs;
-	thread_act_t		thread;
-	struct sysent		*callp;
-	int				nargs, error;
-	unsigned short		code;
-	struct proc *p;
-	void *vt;
-	int * vtint;
-	int *rval;
-	int funnel_type;
-	struct proc *current_proc();
-
-	struct unix_syscallargs sarg;
-	extern int nsysent;
-
-	regs = &pcb->ss;
-	code = regs->r0;
-
-	thread = current_act();
-	p = current_proc();
-	rval = (int *)get_bsduthreadrval(thread);
-
-	/*
-	 * Set up call pointer
-	 */
-	callp = (code >= nsysent) ? &sysent[63] : &sysent[code];
-
-	sarg. flavor = (callp == sysent)? 1: 0;
-	if (sarg.flavor) {
-		code = regs->r3;
-		callp = (code >= nsysent) ? &sysent[63] : &sysent[code];
-	} else 
-		sarg. r3 = regs->r3;
-
-	if (code != 180) {
-		if (sarg.flavor)
-			KERNEL_DEBUG_CONSTANT(BSDDBG_CODE(DBG_BSD_EXCP_SC, code) | DBG_FUNC_START,
-				arg1, arg2, arg3, arg4, 0);
-		else
-			KERNEL_DEBUG_CONSTANT(BSDDBG_CODE(DBG_BSD_EXCP_SC, code) | DBG_FUNC_START,
-				sarg.r3, arg1, arg2, arg3, 0);
-	}
-	sarg.arg1 = arg1;
-	sarg.arg2 = arg2;
-	sarg.arg3 = arg3;
-	sarg.arg4 = arg4;
-	sarg.arg5 = arg5;
-	sarg.arg6 = arg6;
-	sarg.arg7 = arg7;
-
-	if(callp->sy_funnel == NETWORK_FUNNEL) {
-		(void) thread_funnel_set(network_flock, TRUE);
-	} else {
-		(void) thread_funnel_set(kernel_flock, TRUE);
-	}
-
-	set_bsduthreadargs(thread,pcb,&sarg);
-
-	if (callp->sy_narg > 8)
-		panic("unix_syscall: max arg count exceeded");
-
-	rval[0] = 0;
-
-	/*
-	 * r4 is volatile, if we set it to regs->r4 here the child
-	 * will have parents r4 after execve
-	 */
-	rval[1] = 0;
-
-	error = 0; /* Start with a good value */
-
-	/*
-	** the PPC runtime calls cerror after every unix system call, so
-	** assume no error and adjust the "pc" to skip this call.
-	** It will be set back to the cerror call if an error is detected.
-	*/
-	regs->srr0 += 4;
-	vt = get_bsduthreadarg(thread);
-	counter_always(c_syscalls_unix++);
-	current_task()->syscalls_unix++;
-
-	ktrsyscall(p, code, callp->sy_narg, vt);
-
-	error = (*(callp->sy_call))(p, (void *)vt, rval);
-
-	regs = find_user_regs(thread);
-	if (regs == (struct ppc_saved_state  *)0)
-		panic("No user savearea while returning from system call");
-
-	if (error == ERESTART) {
-		regs->srr0 -= 8;
-	} else if (error != EJUSTRETURN) {
-		if (error) {
-			regs->r3 = error;
-			/* set the "pc" to execute cerror routine */
-			regs->srr0 -= 4;
-		} else { /* (not error) */
-			regs->r3 = rval[0];
-			regs->r4 = rval[1];
-		} 
-	}
-	/* else  (error == EJUSTRETURN) { nothing } */
-
-	ktrsysret(p, code, error, rval[0]);
-
-	(void) thread_funnel_set(current_thread()->funnel_lock, FALSE);
-
-	if (code != 180) {
-		KERNEL_DEBUG_CONSTANT(BSDDBG_CODE(DBG_BSD_EXCP_SC, code) | DBG_FUNC_END,
-			error, rval[0], rval[1], 0, 0);
-	}
-
-	thread_exception_return();
-	/* NOTREACHED */
-}
-
-unix_syscall_return(error)
-{
-	struct ppc_saved_state	*regs;
-	thread_act_t		thread;
-	struct sysent		*callp;
-	int				nargs;
-	unsigned short		code;
-	int *rval;
-	struct proc *p;
-	void *vt;
-	int * vtint;
-	struct pcb *pcb;
-	struct proc *current_proc();
-
-	struct unix_syscallargs sarg;
-	extern int nsysent;
-
-	thread = current_act();
-	p = current_proc();
-	rval = (int *)get_bsduthreadrval(thread);
-	pcb = thread->mact.pcb;
-	regs = &pcb->ss;
-
-	if (thread_funnel_get() == THR_FUNNEL_NULL)
-		panic("Unix syscall return without funnel held");
-
-	/*
-	 * Get index into sysent table
-	 */   
-	code = regs->r0;
-
-	if (error == ERESTART) {
-		regs->srr0 -= 8;
-	} else if (error != EJUSTRETURN) {
-		if (error) {
-			regs->r3 = error;
-			/* set the "pc" to execute cerror routine */
-			regs->srr0 -= 4;
-		} else { /* (not error) */
-			regs->r3 = rval[0];
-			regs->r4 = rval[1];
-		} 
-	}
-	/* else  (error == EJUSTRETURN) { nothing } */
-
-	ktrsysret(p, code, error, rval[0]);
-
-	(void) thread_funnel_set(current_thread()->funnel_lock, FALSE);
-
-	if (code != 180) {
-		KERNEL_DEBUG_CONSTANT(BSDDBG_CODE(DBG_BSD_EXCP_SC, code) | DBG_FUNC_END,
-			error, rval[0], rval[1], 0, 0);
-	}
-
-	thread_exception_return();
-	/* NOTREACHED */
-}
-
diff --git a/osfmk/ppc/bzero.s b/osfmk/ppc/bzero.s
index 2faf894a0..82e83de1c 100644
--- a/osfmk/ppc/bzero.s
+++ b/osfmk/ppc/bzero.s
@@ -1,287 +1,307 @@
 /*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
- /*
- * @OSF_FREE_COPYRIGHT@
- */
 
 #include <ppc/asm.h>
-#include <ppc/proc_reg.h>	/* For CACHE_LINE_SIZE */
-
-/*
- *	 void	bzero(char *addr, unsigned int length)
- *
- * bzero implementation for PowerPC
- *   - assumes cacheable memory (i.e. uses DCBZ)
- *   - assumes non-pic code
- *
- * returns start address in r3, as per memset (called by memset)
- */	
-	
-ENTRY(bzero, TAG_NO_FRAME_USED)
-
-	cmpwi	cr0,	r4,	0 /* no bytes to zero? */
-	mr	r7,	r3
-	mr	r8,	r3	/* use r8 as counter to where we are */
-	beqlr-
-	cmpwi	cr0,	r4,	CACHE_LINE_SIZE /* clear less than a block? */
-	li	r0,	0	 /* use r0 as source of zeros */
-	blt	.L_bzeroEndWord
-
-/* first, clear bytes up to the next word boundary */
-	addis	r6,	0,	HIGH_CADDR(.L_bzeroBeginWord)
-	addi	r6,	r6,	LOW_ADDR(.L_bzeroBeginWord)
-		 /* extract byte offset as word offset */
-	rlwinm. r5,	r8,	2,	28,	29
-	addi	r8,	r8,	-1 /* adjust for update */
-	beq	.L_bzeroBeginWord /* no bytes to zero */
-	subfic	r5,	r5,	16 /* compute the number of instructions */
-	sub	r6,	r6,	r5 /* back from word clear to execute */
-	mtctr	r6
-	bctr
-
-	stbu	r0,	1(r8)
-	stbu	r0,	1(r8)
-	stbu	r0,	1(r8)
-
-/* clear words up to the next block boundary */
-.L_bzeroBeginWord:
-	addis	r6,	0,	HIGH_CADDR(.L_bzeroBlock)
-	addi	r6,	r6,	LOW_ADDR(.L_bzeroBlock)
-	addi	r8,	r8,	1
-	rlwinm. r5,	r8,	0,	27,	29 /* extract word offset */
-	addi	r8,	r8,	-4		/* adjust for update */
-	beq	.L_bzeroBlock			/* no words to zero */
-		/* compute the number of instructions */
-	subfic	r5,	r5,	CACHE_LINE_SIZE
-	sub	r6,	r6,	r5 /* back from word clear to execute */
-	mtctr	r6
-	bctr
-
-	stwu	r0,	4(r8)
-	stwu	r0,	4(r8)
-	stwu	r0,	4(r8)
-	stwu	r0,	4(r8)
-	stwu	r0,	4(r8)
-	stwu	r0,	4(r8)
-	stwu	r0,	4(r8)
-
- /* clear cache blocks */
-.L_bzeroBlock:
-	addi	r8,	r8,	4 /* remove update adjust */
-	sub	r5,	r8,	r7 /* bytes zeroed */
-	sub	r4,	r4,	r5
-	srwi.	r5,	r4,	CACHE_LINE_POW2 /* blocks to zero */
-	beq	.L_bzeroEndWord
-	mtctr	r5
-
-.L_bzeroBlock1:
-	dcbz	0,	r8
-	addi	r8,	r8,	CACHE_LINE_SIZE
-	bdnz	.L_bzeroBlock1
-
- /* clear remaining words */
-.L_bzeroEndWord:
-	addis	r6,	0,	HIGH_CADDR(.L_bzeroEndByte)
-	addi	r6,	r6,	LOW_ADDR(.L_bzeroEndByte)
-	rlwinm. r5,	r4,	0,	27,	29 /* extract word offset */
-	addi	r8,	r8,	-4		   /* adjust for update */
-	beq	.L_bzeroEndByte			   /* no words to zero */
-	sub	r6,	r6,	r5 /* back from word clear to execute */
-	mtctr	r6
-	bctr
-
-	stwu	r0,	4(r8)
-	stwu	r0,	4(r8)
-	stwu	r0,	4(r8)
-	stwu	r0,	4(r8)
-	stwu	r0,	4(r8)
-	stwu	r0,	4(r8)
-	stwu	r0,	4(r8)
-
- /* clear remaining bytes */
-.L_bzeroEndByte:
-	addis	r6,	0,	HIGH_CADDR(.L_bzeroEnd)
-	addi	r6,	r6,	LOW_ADDR(.L_bzeroEnd)
-		/* extract byte offset as word offset */
-	rlwinm. r5,	r4,	2,	28,	29
-	addi	r8,	r8,	3 /* adjust for update */
-	beqlr
-	sub	r6,	r6,	r5 /* back from word clear to execute */
-	mtctr	r6
-	bctr
-
-	stbu	r0,	1(r8)
-	stbu	r0,	1(r8)
-	stbu	r0,	1(r8)
-
-.L_bzeroEnd:
-	blr
-
-/*
- * void *memset(void *from, int c, vm_size_t nbytes)
- *
- * almost everywhere in the kernel 
- * this appears to be called with argument c==0. We optimise for those 
- * cases and call bzero if we can.
- *
- */
-
-ENTRY(memset, TAG_NO_FRAME_USED)
-
-	mr.	ARG3,	ARG1
-	mr	ARG1,	ARG2
-	/* optimised case - do a bzero */
-	beq+	EXT(bzero)
-
-	/* If count is zero, return straight away */
-	cmpi	cr0,	ARG1,	0
-	beqlr-	
-	
-	/* Now, ARG0 = addr, ARG1=len, ARG3=value */
-
-	subi	ARG2,	ARG0,	1	/* use ARG2 as our counter */
-	
-0:
-	subi	ARG1,	ARG1,	1
-	cmpi	cr0,	ARG1,	0
-	stbu	ARG3,	1(ARG2)
-	bne+	0b
-
-	/* Return original address in ARG0 */
-	
-	blr
-
-/*
- *	 void	bzero_nc(char *addr, unsigned int length)
- *
- * bzero implementation for PowerPC
- *   - assumes non-pic code
- *
- * returns start address in r3, as per memset (called by memset)
- */	
-	
-ENTRY(bzero_nc, TAG_NO_FRAME_USED)
-
-	cmpwi	cr0,	r4,	0 /* no bytes to zero? */
-	mr	r7,	r3
-	mr	r8,	r3	/* use r8 as counter to where we are */
-	beqlr-
-	cmpwi	cr0,	r4,	CACHE_LINE_SIZE /* clear less than a block? */
-	li	r0,	0	 /* use r0 as source of zeros */
-	blt	.L_bzeroNCEndWord
-
-/* first, clear bytes up to the next word boundary */
-	addis	r6,	0,	HIGH_CADDR(.L_bzeroNCBeginWord)
-	addi	r6,	r6,	LOW_ADDR(.L_bzeroNCBeginWord)
-		 /* extract byte offset as word offset */
-	rlwinm. r5,	r8,	2,	28,	29
-	addi	r8,	r8,	-1 /* adjust for update */
-	beq	.L_bzeroNCBeginWord /* no bytes to zero */
-	subfic	r5,	r5,	16 /* compute the number of instructions */
-	sub	r6,	r6,	r5 /* back from word clear to execute */
-	mtctr	r6
-	bctr
-
-	stbu	r0,	1(r8)
-	stbu	r0,	1(r8)
-	stbu	r0,	1(r8)
-
-/* clear words up to the next block boundary */
-.L_bzeroNCBeginWord:
-	addis	r6,	0,	HIGH_CADDR(.L_bzeroNCBlock)
-	addi	r6,	r6,	LOW_ADDR(.L_bzeroNCBlock)
-	addi	r8,	r8,	1
-	rlwinm. r5,	r8,	0,	27,	29 /* extract word offset */
-	addi	r8,	r8,	-4		/* adjust for update */
-	beq	.L_bzeroNCBlock			/* no words to zero */
-		/* compute the number of instructions */
-	subfic	r5,	r5,	CACHE_LINE_SIZE
-	sub	r6,	r6,	r5 /* back from word clear to execute */
-	mtctr	r6
-	bctr
-
-	stwu	r0,	4(r8)
-	stwu	r0,	4(r8)
-	stwu	r0,	4(r8)
-	stwu	r0,	4(r8)
-	stwu	r0,	4(r8)
-	stwu	r0,	4(r8)
-	stwu	r0,	4(r8)
-
- /* clear cache blocks */
-.L_bzeroNCBlock:
-	addi	r8,	r8,	4 /* remove update adjust */
-	sub	r5,	r8,	r7 /* bytes zeroed */
-	sub	r4,	r4,	r5
-	srwi.	r5,	r4,	CACHE_LINE_POW2 /* blocks to zero */
-	beq	.L_bzeroNCEndWord
-	mtctr	r5
-
-.L_bzeroNCBlock1:
-	stw	r0,	0(r8)
-	stw	r0,	4(r8)
-	stw	r0,	8(r8)
-	stw	r0,	12(r8)
-	stw	r0,	16(r8)
-	stw	r0,	20(r8)
-	stw	r0,	24(r8)
-	stw	r0,	28(r8)
-	addi	r8,	r8,	CACHE_LINE_SIZE
-	bdnz	.L_bzeroNCBlock1
-
- /* clear remaining words */
-.L_bzeroNCEndWord:
-	addis	r6,	0,	HIGH_CADDR(.L_bzeroNCEndByte)
-	addi	r6,	r6,	LOW_ADDR(.L_bzeroNCEndByte)
-	rlwinm. r5,	r4,	0,	27,	29 /* extract word offset */
-	addi	r8,	r8,	-4		   /* adjust for update */
-	beq	.L_bzeroNCEndByte			   /* no words to zero */
-	sub	r6,	r6,	r5 /* back from word clear to execute */
-	mtctr	r6
-	bctr
-
-	stwu	r0,	4(r8)
-	stwu	r0,	4(r8)
-	stwu	r0,	4(r8)
-	stwu	r0,	4(r8)
-	stwu	r0,	4(r8)
-	stwu	r0,	4(r8)
-	stwu	r0,	4(r8)
-
- /* clear remaining bytes */
-.L_bzeroNCEndByte:
-	addis	r6,	0,	HIGH_CADDR(.L_bzeroNCEnd)
-	addi	r6,	r6,	LOW_ADDR(.L_bzeroNCEnd)
-		/* extract byte offset as word offset */
-	rlwinm. r5,	r4,	2,	28,	29
-	addi	r8,	r8,	3 /* adjust for update */
-	beqlr
-	sub	r6,	r6,	r5 /* back from word clear to execute */
-	mtctr	r6
-	bctr
-
-	stbu	r0,	1(r8)
-	stbu	r0,	1(r8)
-	stbu	r0,	1(r8)
+#include <ppc/exception.h>
+#include <assym.s>
+
+        .text
+        .align	2
+        .globl	_memset
+        .globl	_bzero
+        .globl	_bzero_nc
+        .globl	_bzero_phys
+
+
+// ***********************
+// * B Z E R O _ P H Y S *
+// ***********************
+//
+// void bzero_phys(addr64_t phys_addr, uint32_t length);
+//
+// Takes a phys addr in (r3,r4), and length in r5.  We leave cache on.
+
+        .align	5
+LEXT(bzero_phys)
+        mflr	r12				// save return address
+        rlwinm	r3,r3,0,1,0		// coallesce long-long in (r3,r4) into reg64_t in r3
+        rlwimi	r3,r4,0,0,31
+        mr		r4,r5			// put length where bzero() expects it
+        bl		EXT(ml_set_physical_get_ffs)	// turn DR off, SF on, features in cr6, old MSR in r11
+        bl		EXT(bzero)		// use normal bzero() routine
+        mtlr	r12				// restore return
+        b		EXT(ml_restore)		// restore MSR, turning DR on and SF off
+        
+
+// *******************
+// * B Z E R O _ N C *
+// *******************
+//
+//	void bzero_nc(char	*addr, unsigned int length);
+//
+// For use with uncached memory.  Doesn't seem to be used at all, so probably not
+// performance critical.  NB: we must avoid unaligned stores, because some
+// machines (eg, 970) take alignment exceptions on _any_ unaligned op to uncached
+// memory.  Of course, we must also avoid dcbz.
+
+LEXT(bzero_nc)
+        cmplwi	cr1,r4,20		// too short to bother with 16-byte loops?
+        cmplwi	cr7,r4,0		// check for (len==0)
+        li		r6,0			// get a 0
+        bge		cr1,bznc1		// skip if length >=20
+        mtctr	r4				// set up byte loop
+        beqlr--	cr7				// done if len=0
+        
+// Short operands, loop over bytes.
+
+bznc0:
+        stb		r6,0(r3)
+        addi	r3,r3,1
+        bdnz	bznc0
+        blr
+        
+// Handle operands long enough to do doubleword stores; we must doubleword
+// align, to avoid alignment exceptions.
+
+bznc1:
+        neg		r7,r3			// start to compute #bytes to align
+        mfsprg	r10,2			// get feature flags
+        andi.	r0,r7,7			// get #bytes to doubleword align
+        mr		r5,r3			// make copy of operand ptr as bcopy expects
+        mtcrf	0x02,r10		// put pf64Bitb etc in cr6
+        beq		bzero_tail		// already doubleword aligned
+        sub		r4,r4,r0		// adjust count
+        mtctr	r0				// set up loop
+bznc2:							// zero bytes until doubleword aligned
+        stb		r6,0(r5)
+        addi	r5,r5,1
+        bdnz	bznc2
+        b		bzero_tail		// join bzero, now that r5 is aligned
+        
+
+// *************     ***************
+// * B Z E R O * and * M E M S E T *
+// *************     ***************
+//
+// void *   memset(void *b, int c, size_t len);
+// void		bzero(void *b, size_t len);
+//
+// These routines support G3, G4, and the 970, and run in both 32 and
+// 64-bit mode.  Lengths (size_t) are always 32 bits.
+//
+// Register use:
+//    r0 = temp
+//    r2 = temp
+//    r3 = original ptr, not changed since memset returns it
+//    r4 = count of bytes to set
+//    r5 = working operand ptr ("rp")
+//    r6 = value to store (usually 0)
+// r7-r9 = temps
+//   r10 = feature flags
+//   r11 = old MSR (if bzero_phys)
+//   r12 = return address (if bzero_phys)
+//   cr6 = feature flags (pf64Bit, pf128Byte, and pf32Byte)
+
+        .align	5
+LEXT(memset)					// void *   memset(void *b, int c, size_t len);
+        andi.	r6,r4,0xFF		// copy value to working register, test for 0
+        mr		r4,r5			// move length to working register
+        bne--	memset1			// skip if nonzero
+LEXT(bzero)						// void	bzero(void *b, size_t len);
+        dcbtst	0,r3			// touch in 1st cache block
+        mfsprg	r10,2			// get features
+        li		r6,0			// get a 0
+        neg		r7,r3			// start to compute #bytes to align
+        andi.	r0,r10,pf128Byte+pf32Byte // get cache line size
+        mtcrf	0x02,r10		// put pf128Byte etc in cr6
+        cmplw	r4,r0			// operand length >= cache line size?
+        mr		r5,r3			// make copy of operand ptr (can't change r3)
+        blt		bzero_tail		// too short for dcbz (or dcbz128)
+        rlwinm	r0,r7,0,0x1F	// get #bytes to  32-byte align
+        rlwinm	r9,r7,0,0x7F	// get #bytes to 128-byte align
+        bt++	pf128Byteb,bzero_128 // skip if 128-byte processor
+
+// Operand length >=32 and cache line size is 32.
+//		r0 = #bytes to 32-byte align
+//		r4 = length
+//		r5 = ptr to operand
+//		r6 = 0
+
+        sub		r2,r4,r0		// adjust length
+        cmpwi	cr1,r0,0		// already 32-byte aligned?
+        srwi.	r8,r2,5			// get #32-byte chunks
+        beq		bzero_tail		// not long enough to dcbz
+        mtctr	r8				// set up loop count
+        rlwinm	r4,r2,0,27,31	// mask down to leftover byte count
+        beq		cr1,bz_dcbz32 	// skip if already 32-byte aligned
+        
+// 32-byte align.  We just store 32 0s, rather than test and use conditional
+// branches.  This is usually faster, because there are no mispredicts.
+
+        stw		r6,0(r5)		// zero next 32 bytes
+        stw		r6,4(r5)
+        stw		r6,8(r5)
+        stw		r6,12(r5)
+        stw		r6,16(r5)
+        stw		r6,20(r5)
+        stw		r6,24(r5)
+        stw		r6,28(r5)
+        add		r5,r5,r0		// now r5 is 32-byte aligned
+        b		bz_dcbz32
+
+// Loop doing 32-byte version of DCBZ instruction.
+
+        .align	4				// align the inner loop
+bz_dcbz32:
+        dcbz	0,r5			// zero another 32 bytes
+        addi	r5,r5,32
+        bdnz	bz_dcbz32
+
+// Store trailing bytes.  This routine is used both by bzero and memset.
+//		r4 = #bytes to store (may be large if memset)
+//		r5 = address
+//		r6 = value to store (in all 8 bytes)
+//     cr6 = pf64Bit etc flags
+
+bzero_tail:
+        srwi.	r0,r4,4			// get #(16-byte-chunks)
+        mtcrf	0x01,r4			// remaining byte count to cr7
+        beq		bzt3			// no 16-byte chunks
+        mtctr	r0				// set up loop count
+        bt++	pf64Bitb,bzt2	// skip if 64-bit processor
+        b		bzt1
+        .align	5
+bzt1:							// loop over 16-byte chunks on 32-bit processor
+        stw		r6,0(r5)
+        stw		r6,4(r5)
+        stw		r6,8(r5)
+        stw		r6,12(r5)
+        addi	r5,r5,16
+        bdnz	bzt1
+        b		bzt3
+        .align	5
+bzt2:							// loop over 16-byte chunks on 64-bit processor
+        std		r6,0(r5)
+        std		r6,8(r5)
+        addi	r5,r5,16
+        bdnz	bzt2
+        bf		28,bzt4			// 8-byte chunk?
+        std		r6,0(r5)
+        addi	r5,r5,8
+        b		bzt4
+bzt3:
+        bf		28,bzt4			// 8-byte chunk?
+        stw		r6,0(r5)
+        stw		r6,4(r5)
+        addi	r5,r5,8
+bzt4:
+        bf		29,bzt5			// word?
+        stw		r6,0(r5)
+        addi	r5,r5,4
+bzt5:
+        bf		30,bzt6			// halfword?
+        sth		r6,0(r5)
+        addi	r5,r5,2
+bzt6:
+        bflr	31				// byte?
+        stb		r6,0(r5)
+        blr
+        
+// Operand length is >=128 and cache line size is 128. We assume that
+// because the linesize is 128 bytes, this is a 64-bit processor.
+//		r4 = length
+//		r5 = ptr to operand
+//		r6 = 0
+//		r7 = neg(r5)
+//		r9 = #bytes to 128-byte align
+
+        .align	5
+bzero_128:
+        sub		r2,r4,r9		// r2 <- length remaining after cache-line aligning
+        rlwinm	r0,r7,0,0xF		// r0 <- #bytes to 16-byte align
+        srwi.	r8,r2,7			// r8 <- number of cache lines to 0
+        std		r6,0(r5)		// always store 16 bytes to 16-byte align...
+        std		r6,8(r5)		// ...even if too short for dcbz128
+        add		r5,r5,r0		// 16-byte align ptr
+        sub		r4,r4,r0		// adjust count
+        beq		bzero_tail		// r8==0, not long enough to dcbz128
+        sub.	r7,r9,r0		// get #bytes remaining to 128-byte align
+        rlwinm	r4,r2,0,0x7F	// r4 <- length remaining after dcbz128'ing
+        mtctr	r8				// set up dcbz128 loop
+        beq		bz_dcbz128		// already 128-byte aligned
+        b		bz_align		// enter loop over 16-byte chunks
+
+// 128-byte align by looping over 16-byte chunks.
+        
+        .align	5
+bz_align:						// loop over 16-byte chunks
+        subic.	r7,r7,16		// more to go?
+        std		r6,0(r5)
+        std		r6,8(r5)
+        addi	r5,r5,16
+        bgt		bz_align
+        
+        b		bz_dcbz128		// enter dcbz128 loop
+        
+// Loop over 128-byte cache lines.
+//		r4 = length remaining after cache lines (0..127)
+//		r5 = ptr (128-byte aligned)
+//		r6 = 0
+//		ctr = count of cache lines to 0
+
+        .align	5
+bz_dcbz128:
+        dcbz128	0,r5			// zero a 128-byte cache line
+        addi	r5,r5,128
+        bdnz	bz_dcbz128
+        
+        b		bzero_tail		// handle leftovers
+
+
+// Handle memset() for nonzero values.  This case is relatively infrequent;
+// the large majority of memset() calls are for 0.
+//		r3 = ptr
+//		r4 = count
+//		r6 = value in lower byte (nonzero)
+
+memset1:
+        cmplwi	r4,16			// too short to bother aligning?
+        rlwimi	r6,r6,8,16,23	// replicate value to low 2 bytes
+        mr		r5,r3			// make working copy of operand ptr
+        rlwimi	r6,r6,16,0,15	// value now in all 4 bytes
+        blt		bzero_tail		// length<16, we won't be using "std"
+        mfsprg	r10,2			// get feature flags
+        neg		r7,r5			// start to compute #bytes to align
+        rlwinm	r6,r6,0,1,0		// value now in all 8 bytes (if 64-bit)
+        andi.	r0,r7,7			// r6 <- #bytes to doubleword align
+        stw		r6,0(r5)		// store 8 bytes to avoid a loop
+        stw		r6,4(r5)
+        mtcrf	0x02,r10		// get pf64Bit flag etc in cr6
+        sub		r4,r4,r0		// adjust count
+        add		r5,r5,r0		// doubleword align ptr
+        b		bzero_tail
+        
+        
 
-.L_bzeroNCEnd:
-	blr
diff --git a/osfmk/ppc/cache.s b/osfmk/ppc/cache.s
index 0f3157714..94d9fe0ca 100644
--- a/osfmk/ppc/cache.s
+++ b/osfmk/ppc/cache.s
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -23,82 +26,27 @@
  * @OSF_COPYRIGHT@
  */
 
-#include <cpus.h>
-
 #include <ppc/asm.h>
 #include <ppc/proc_reg.h>
-#include <cpus.h>
+#include <ppc/exception.h>
 #include <assym.s>
-#include <mach_debug.h>
-#include <mach/ppc/vm_param.h>
 
-/*
- * extern void sync_cache(vm_offset_t pa, unsigned count);
- *
- * sync_cache takes a physical address and count to sync, thus
- * must not be called for multiple virtual pages.
- *
- * it writes out the data cache and invalidates the instruction
- * cache for the address range in question
+/* These routines run in 32 or 64-bit addressing, and handle
+ * 32 and 128 byte caches.  They do not use compare instructions
+ * on addresses, since compares are 32/64-bit-mode-specific.
  */
 
-ENTRY(sync_cache, TAG_NO_FRAME_USED)
-
-	/* Switch off data translations */
-	mfmsr	r6
-	rlwinm	r6,r6,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-	rlwinm	r6,r6,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-	rlwinm	r7,	r6,	0,	MSR_DR_BIT+1,	MSR_DR_BIT-1
-	mtmsr	r7
-	isync
-
-	/* Check to see if the address is aligned. */
-	add	r8, r3,r4
-	andi.	r8,r8,(CACHE_LINE_SIZE-1)
-	beq-	.L_sync_check
-	addi	r4,r4,CACHE_LINE_SIZE
-	li	r7,(CACHE_LINE_SIZE-1)	/* Align buffer & count - avoid overflow problems */
-	andc	r4,r4,r7
-	andc	r3,r3,r7
-
-.L_sync_check:
-	cmpwi	r4,	CACHE_LINE_SIZE
-	ble	.L_sync_one_line
-	
-	/* Make ctr hold count of how many times we should loop */
-	addi	r8,	r4,	(CACHE_LINE_SIZE-1)
-	srwi	r8,	r8,	CACHE_LINE_POW2
-	mtctr	r8
+#define	kDcbf			0x1
+#define	kDcbfb			31
+#define	kDcbi			0x2
+#define	kDcbib			30
+#define	kIcbi			0x4
+#define	kIcbib			29
 
-	/* loop to flush the data cache */
-.L_sync_data_loop:
-	subic	r4,	r4,	CACHE_LINE_SIZE
-	dcbf	r3,	r4
-	bdnz	.L_sync_data_loop
-	
-	sync
-	mtctr	r8
-
-	/* loop to invalidate the instruction cache */
-.L_sync_inval_loop:
-	icbi	r3,	r4
-	addic	r4,	r4,	CACHE_LINE_SIZE
-	bdnz	.L_sync_inval_loop
-
-.L_sync_cache_done:
-	sync			/* Finish physical writes */
-	mtmsr	r6		/* Restore original translations */
-	isync			/* Ensure data translations are on */
-	blr
-
-.L_sync_one_line:
-	dcbf	0,r3
-	sync
-	icbi	0,r3
-	b	.L_sync_cache_done
 
 /*
  * extern void flush_dcache(vm_offset_t addr, unsigned count, boolean phys);
+ * extern void flush_dcache64(addr64_t addr, unsigned count, boolean phys);
  *
  * flush_dcache takes a virtual or physical address and count to flush
  * and (can be called for multiple virtual pages).
@@ -109,172 +57,222 @@ ENTRY(sync_cache, TAG_NO_FRAME_USED)
  * if 'phys' is non-zero then physical addresses will be used
  */
 
-ENTRY(flush_dcache, TAG_NO_FRAME_USED)
-
-	/* optionally switch off data translations */
-
-	cmpwi	r5,	0
-	mfmsr	r6
-	beq+	0f
-	rlwinm	r6,r6,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-	rlwinm	r6,r6,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-	rlwinm	r7,	r6,	0,	MSR_DR_BIT+1,	MSR_DR_BIT-1
-	mtmsr	r7
-	isync
-0:	
-
-	/* Check to see if the address is aligned. */
-	add	r8, r3,r4
-	andi.	r8,r8,(CACHE_LINE_SIZE-1)
-	beq-	.L_flush_dcache_check
-	addi	r4,r4,CACHE_LINE_SIZE
-	li	r7,(CACHE_LINE_SIZE-1)	/* Align buffer & count - avoid overflow problems */
-	andc	r4,r4,r7
-	andc	r3,r3,r7
 
-.L_flush_dcache_check:
-	cmpwi	r4,	CACHE_LINE_SIZE
-	ble	.L_flush_dcache_one_line
-	
-	/* Make ctr hold count of how many times we should loop */
-	addi	r8,	r4,	(CACHE_LINE_SIZE-1)
-	srwi	r8,	r8,	CACHE_LINE_POW2
-	mtctr	r8
+ 
+        .text
+        .align	5
+        .globl	_flush_dcache
+_flush_dcache:
+        li		r0,kDcbf					// use DCBF instruction
+        rlwinm	r3,r3,0,0,31				// truncate address in case this is a 64-bit machine
+        b		cache_op_join				// join common code
 
-.L_flush_dcache_flush_loop:
-	subic	r4,	r4,	CACHE_LINE_SIZE
-	dcbf	r3,	r4
-	bdnz	.L_flush_dcache_flush_loop
-
-.L_flush_dcache_done:
-	/* Sync restore msr if it was modified */
-	cmpwi	r5,	0
-	sync			/* make sure invalidates have completed */
-	beq+	0f
-	mtmsr	r6		/* Restore original translations */
-	isync			/* Ensure data translations are on */
-0:
-	blr
-
-.L_flush_dcache_one_line:
-	xor	r4,r4,r4
-	dcbf	0,r3
-	b	.L_flush_dcache_done
+        .align	5
+        .globl	_flush_dcache64
+_flush_dcache64:
+		rlwinm	r3,r3,0,1,0					; Duplicate high half of long long paddr into top of reg
+		li		r0,kDcbf					// use DCBF instruction
+		rlwimi	r3,r4,0,0,31				; Combine bottom of long long to full 64-bits
+		mr		r4,r5						; Move count
+		mr		r5,r6						; Move physical flag
+        b		cache_op_join				// join common code
 
 
 /*
  * extern void invalidate_dcache(vm_offset_t va, unsigned count, boolean phys);
+ * extern void invalidate_dcache64(addr64_t va, unsigned count, boolean phys);
  *
  * invalidate_dcache takes a virtual or physical address and count to
  * invalidate and (can be called for multiple virtual pages).
  *
  * it invalidates the data cache for the address range in question
  */
-
-ENTRY(invalidate_dcache, TAG_NO_FRAME_USED)
-
-	/* optionally switch off data translations */
-
-	cmpwi	r5,	0
-	mfmsr	r6
-	beq+	0f
-	rlwinm	r6,r6,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-	rlwinm	r6,r6,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-	rlwinm	r7,	r6,	0,	MSR_DR_BIT+1,	MSR_DR_BIT-1
-	mtmsr	r7
-	isync
-0:	
-
-	/* Check to see if the address is aligned. */
-	add	r8, r3,r4
-	andi.	r8,r8,(CACHE_LINE_SIZE-1)
-	beq-	.L_invalidate_dcache_check
-	addi	r4,r4,CACHE_LINE_SIZE
-	li	r7,(CACHE_LINE_SIZE-1)	/* Align buffer & count - avoid overflow problems */
-	andc	r4,r4,r7
-	andc	r3,r3,r7
-
-.L_invalidate_dcache_check:
-	cmpwi	r4,	CACHE_LINE_SIZE
-	ble	.L_invalidate_dcache_one_line
-	
-	/* Make ctr hold count of how many times we should loop */
-	addi	r8,	r4,	(CACHE_LINE_SIZE-1)
-	srwi	r8,	r8,	CACHE_LINE_POW2
-	mtctr	r8
-
-.L_invalidate_dcache_invalidate_loop:
-	subic	r4,	r4,	CACHE_LINE_SIZE
-	dcbi	r3,	r4
-	bdnz	.L_invalidate_dcache_invalidate_loop
-
-.L_invalidate_dcache_done:
-	/* Sync restore msr if it was modified */
-	cmpwi	r5,	0
-	sync			/* make sure invalidates have completed */
-	beq+	0f
-	mtmsr	r6		/* Restore original translations */
-	isync			/* Ensure data translations are on */
-0:
-	blr
-
-.L_invalidate_dcache_one_line:
-	xor	r4,r4,r4
-	dcbi	0,r3
-	b	.L_invalidate_dcache_done
+ 
+        .globl	_invalidate_dcache
+_invalidate_dcache:
+        li		r0,kDcbi					// use DCBI instruction
+        rlwinm	r3,r3,0,0,31				// truncate address in case this is a 64-bit machine
+        b		cache_op_join				// join common code
+
+
+        .align	5
+        .globl	_invalidate_dcache64
+_invalidate_dcache64:
+		rlwinm	r3,r3,0,1,0					; Duplicate high half of long long paddr into top of reg
+        li		r0,kDcbi					// use DCBI instruction
+		rlwimi	r3,r4,0,0,31				; Combine bottom of long long to full 64-bits
+		mr		r4,r5						; Move count
+		mr		r5,r6						; Move physical flag
+        b		cache_op_join				// join common code
 
 /*
  * extern void invalidate_icache(vm_offset_t addr, unsigned cnt, boolean phys);
+ * extern void invalidate_icache64(addr64_t addr, unsigned cnt, boolean phys);
  *
  * invalidate_icache takes a virtual or physical address and
  * count to invalidate, (can be called for multiple virtual pages).
  *
  * it invalidates the instruction cache for the address range in question.
+ */
+ 
+        .globl	_invalidate_icache
+_invalidate_icache:
+        li		r0,kIcbi					// use ICBI instruction
+        rlwinm	r3,r3,0,0,31				// truncate address in case this is a 64-bit machine
+        b		cache_op_join				// join common code
+        
+
+        .align	5
+        .globl	_invalidate_icache64
+_invalidate_icache64:
+		rlwinm	r3,r3,0,1,0					; Duplicate high half of long long paddr into top of reg
+        li		r0,kIcbi					// use ICBI instruction
+		rlwimi	r3,r4,0,0,31				; Combine bottom of long long to full 64-bits
+		mr		r4,r5						; Move count
+		mr		r5,r6						; Move physical flag
+        b		cache_op_join				// join common code
+                        
+/*
+ * extern void sync_ppage(ppnum_t pa);
+ *
+ * sync_ppage takes a physical page number
+ *
+ * it writes out the data cache and invalidates the instruction
+ * cache for the address range in question
  */
 
-ENTRY(invalidate_icache, TAG_NO_FRAME_USED)
-
-	/* optionally switch off data translations */
-	cmpwi	r5,	0
-	mfmsr	r6
-	beq+	0f
-	rlwinm	r6,r6,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-	rlwinm	r6,r6,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-	rlwinm	r7,	r6,	0,	MSR_DR_BIT+1,	MSR_DR_BIT-1
-	mtmsr	r7
-	isync
-0:	
-
-	/* Check to see if the address is aligned. */
-	add	r8, r3,r4
-	andi.	r8,r8,(CACHE_LINE_SIZE-1)
-	beq-	.L_invalidate_icache_check
-	addi	r4,r4,CACHE_LINE_SIZE
-	li	r7,(CACHE_LINE_SIZE-1)	/* Align buffer & count - avoid overflow problems */
-	andc	r4,r4,r7
-	andc	r3,r3,r7
+        .globl	_sync_ppage
+        .align	5
+_sync_ppage:								// Should be the most commonly called routine, by far 
+		mfsprg	r2,2
+        li		r0,kDcbf+kIcbi				// we need to dcbf and then icbi
+		mtcrf	0x02,r2						; Move pf64Bit to cr6
+        li		r5,1						// set flag for physical addresses
+		li		r4,4096						; Set page size
+		bt++	pf64Bitb,spp64				; Skip if 64-bit (only they take the hint)
+        rlwinm	r3,r3,12,0,19				; Convert to physical address - 32-bit
+        b		cache_op_join				; Join up....
+        
+spp64:	sldi	r3,r3,12					; Convert to physical address - 64-bit        
+        b		cache_op_join				; Join up....
+                        
 
-.L_invalidate_icache_check:
-	cmpwi	r4,	CACHE_LINE_SIZE
-	ble	.L_invalidate_icache_one_line
-	
-	/* Make ctr hold count of how many times we should loop */
-	addi	r8,	r4,	(CACHE_LINE_SIZE-1)
-	srwi	r8,	r8,	CACHE_LINE_POW2
-	mtctr	r8
 
-.L_invalidate_icache_invalidate_loop:
-	subic	r4,	r4,	CACHE_LINE_SIZE
-	icbi	r3,	r4
-	bdnz	.L_invalidate_icache_invalidate_loop
+/*
+ * extern void sync_cache_virtual(vm_offset_t addr, unsigned count);
+ *
+ * Like "sync_cache", except it takes a virtual address and byte count.
+ * It flushes the data cache, invalidates the I cache, and sync's.
+ */
+ 
+        .globl	_sync_cache_virtual
+        .align	5
+_sync_cache_virtual:
+        li		r0,kDcbf+kIcbi				// we need to dcbf and then icbi
+        li		r5,0						// set flag for virtual addresses
+        b		cache_op_join				// join common code
+        
+                        
+/*
+ * extern void sync_cache(vm_offset_t pa, unsigned count);
+ * extern void sync_cache64(addr64_t pa, unsigned count);
+ *
+ * sync_cache takes a physical address and count to sync, thus
+ * must not be called for multiple virtual pages.
+ *
+ * it writes out the data cache and invalidates the instruction
+ * cache for the address range in question
+ */
 
-.L_invalidate_icache_done:
-	sync			/* make sure invalidates have completed */
-	mtmsr	r6		/* Restore original translations */
-	isync			/* Ensure data translations are on */
-	blr
+        .globl	_sync_cache
+        .align	5
+_sync_cache:
+        li		r0,kDcbf+kIcbi				// we need to dcbf and then icbi
+        li		r5,1						// set flag for physical addresses
+        rlwinm	r3,r3,0,0,31				// truncate address in case this is a 64-bit machine
+        b		cache_op_join				// join common code
+
+        .globl	_sync_cache64
+        .align	5
+_sync_cache64: 
+		rlwinm	r3,r3,0,1,0					; Duplicate high half of long long paddr into top of reg
+        li		r0,kDcbf+kIcbi				// we need to dcbf and then icbi
+		rlwimi	r3,r4,0,0,31				; Combine bottom of long long to full 64-bits
+       	mr		r4,r5						; Copy over the length
+        li		r5,1						// set flag for physical addresses
+
+        
+        // Common code to handle the cache operations.
+
+cache_op_join:								// here with r3=addr, r4=count, r5=phys flag, r0=bits
+        mfsprg	r10,2						// r10 <- processor feature flags
+        cmpwi	cr5,r5,0					// using physical addresses?
+        mtcrf	0x01,r0						// move kDcbf, kDcbi, and kIcbi bits to CR7
+        andi.	r9,r10,pf32Byte+pf128Byte	// r9 <- cache line size
+        mtcrf	0x02,r10					// move pf64Bit bit to CR6
+        subi	r8,r9,1						// r8 <- (linesize-1)
+        beq--	cr5,cache_op_2				// skip if using virtual addresses
+        
+        bf--	pf64Bitb,cache_op_not64		// This is not a 64-bit machine
+       
+        srdi	r12,r3,31					// Slide bit 32 to bit 63
+        cmpldi	r12,1						// Are we in the I/O mapped area?
+        beqlr--								// No cache ops allowed here...
+        
+cache_op_not64:
+        mflr	r12							// save return address
+        bl		EXT(ml_set_physical)		// turn on physical addressing
+        mtlr	r12							// restore return address
+
+        // get r3=first cache line, r4=first line not in set, r6=byte count
+        
+cache_op_2:        
+        add		r7,r3,r4					// point to 1st byte not to operate on
+        andc	r3,r3,r8					// r3 <- 1st line to operate on
+        add		r4,r7,r8					// round up
+        andc	r4,r4,r8					// r4 <- 1st line not to operate on
+        sub.	r6,r4,r3					// r6 <- byte count to operate on
+        beq--	cache_op_exit				// nothing to do
+        bf--	kDcbfb,cache_op_6			// no need to dcbf
+        
+        
+        // DCBF loop
+        
+cache_op_5:
+        sub.	r6,r6,r9					// more to go?
+        dcbf	r6,r3						// flush next line to RAM
+        bne		cache_op_5					// loop if more to go
+        sync								// make sure the data reaches RAM
+        sub		r6,r4,r3					// reset count
+
+
+        // ICBI loop
+        
+cache_op_6:
+        bf--	kIcbib,cache_op_8			// no need to icbi
+cache_op_7:
+        sub.	r6,r6,r9					// more to go?
+        icbi	r6,r3						// invalidate next line
+        bne		cache_op_7
+        sub		r6,r4,r3					// reset count
+        isync
+        sync
+        
+        
+        // DCBI loop
+        
+cache_op_8:
+        bf++	kDcbib,cache_op_exit		// no need to dcbi
+cache_op_9:
+        sub.	r6,r6,r9					// more to go?
+        dcbi	r6,r3						// invalidate next line
+        bne		cache_op_9
+        sync
+        
+        
+        // restore MSR iff necessary and done
+        
+cache_op_exit:
+        beqlr--	cr5							// if using virtual addresses, no need to restore MSR
+        b		EXT(ml_restore)				// restore MSR and return
 
-.L_invalidate_icache_one_line:
-	xor	r4,r4,r4
-	icbi	0,r3
-	b	.L_invalidate_icache_done
diff --git a/osfmk/ppc/clock.h b/osfmk/ppc/clock.h
index e4c912349..077f87bf1 100644
--- a/osfmk/ppc/clock.h
+++ b/osfmk/ppc/clock.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ppc/commpage/bcopy_64.s b/osfmk/ppc/commpage/bcopy_64.s
new file mode 100644
index 000000000..60df800ec
--- /dev/null
+++ b/osfmk/ppc/commpage/bcopy_64.s
@@ -0,0 +1,301 @@
+/*
+ * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ * 
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ * 
+ * @APPLE_LICENSE_HEADER_END@
+ */
+/* =======================================
+ * BCOPY, MEMCPY, and MEMMOVE for Mac OS X
+ * =======================================
+ *
+ * Version of 2/20/2003, for a hypothetic 64-bit processor without Altivec.
+ * This version might be used bringing up new processors, with known
+ * Altivec bugs that need to be worked around.  It is not particularly well
+ * optimized.
+ *
+ * Register usage.  Note we use R2, so this code will not run in a PEF/CFM
+ * environment.
+ *   r0  = "w7" or temp
+ *   r2  = "w8"
+ *   r3  = not used, as memcpy and memmove return 1st parameter as a value
+ *   r4  = source ptr ("rs")
+ *   r5  = count of bytes to move ("rc")
+ *   r6  = "w1"
+ *   r7  = "w2"
+ *   r8  = "w3"
+ *   r9  = "w4"
+ *   r10 = "w5"
+ *   r11 = "w6"
+ *   r12 = destination ptr ("rd")
+ */
+#define rs	r4
+#define rd	r12
+#define rc	r5
+#define	rv	r2
+
+#define w1	r6
+#define w2	r7
+#define w3	r8
+#define	w4	r9
+#define	w5	r10
+#define	w6	r11
+#define	w7	r0
+#define	w8	r2
+
+#define	ASSEMBLER
+#include <sys/appleapiopts.h>
+#include <ppc/asm.h>
+#include <machine/cpu_capabilities.h>
+#include <machine/commpage.h>
+
+        .text
+        .globl 	EXT(bcopy_64)
+
+#define	kLong		64				// too long for inline loopless code
+
+
+// Main entry points.
+
+        .align 	5
+bcopy_64:							// void bcopy(const void *src, void *dst, size_t len)
+        cmplwi	rc,kLong			// short or long?
+        sub		w1,r4,r3			// must move in reverse if (rd-rs)<rc
+        cmplw	cr1,w1,rc			// set cr1 blt iff we must move reverse
+        mr		rd,r4				// start to move registers to canonic spot
+        mr		rs,r3
+        blt		LShort				// handle short operands
+        dcbt	0,r3				// touch in destination
+        b		LLong				// join medium/long operand code
+
+// NB: memmove() must be 8 words past bcopy(), to agree with comm page addresses.
+        
+        .align	5
+Lmemcpy_g4:							// void* memcpy(void *dst, void *src, size_t len)
+Lmemmove_g4:						// void* memmove(void *dst, const void *src, size_t len)
+        cmplwi	rc,kLong			// short or long?
+        sub		w1,r3,r4			// must move in reverse if (rd-rs)<rc
+        dcbt	0,r4				// touch in the first line of source
+        cmplw	cr1,w1,rc			// set cr1 blt iff we must move reverse
+        mr		rd,r3				// must leave r3 alone, it is return value for memcpy etc
+        bge		LLong				// handle medium or long operands
+
+// Handle short operands.
+        
+LShort:
+        mtcrf	0x02,rc				// put length bits 26-27 in cr6 (faster one cr at a time)
+        mtcrf	0x01,rc				// put length bits 28-31 in cr7
+        blt		cr1,LShortReverse
+        
+// Forward short operands.  This is the most frequent case, so it is inline.
+
+LShort64:							// enter to xfer last 64 bytes
+        bf		26,0f				// 64-byte chunk to xfer?
+        ld		w1,0(rs)
+        ld		w2,8(rs)
+        ld		w3,16(rs)
+        ld		w4,24(rs)
+        addi	rs,rs,32
+        std		w1,0(rd)
+        std		w2,8(rd)
+        std		w3,16(rd)
+        std		w4,24(rd)
+        addi	rd,rd,32
+0:
+        bf		27,1f				// quadword to move?
+        ld		w1,0(rs)
+        ld		w2,8(rs)
+        addi	rs,rs,16
+        std		w1,0(rd)
+        std		w2,8(rd)
+        addi	rd,rd,16
+1:
+        bf		28,2f				// doubleword?
+        ld		w1,0(rs)
+        addi	rs,rs,8
+        std		w1,0(rd)
+        addi	rd,rd,8
+2:
+        bf		29,3f				// word?
+        lwz		w1,0(rs)
+        addi	rs,rs,4
+        stw		w1,0(rd)
+        addi	rd,rd,4
+3:
+        bf		30,4f				// halfword to move?
+        lhz		w1,0(rs)
+        addi	rs,rs,2
+        sth		w1,0(rd)
+        addi	rd,rd,2
+4:
+        bflr	31					// skip if no odd byte
+        lbz		w1,0(rs)
+        stb		w1,0(rd)
+        blr
+        
+        
+// Handle short reverse operands.
+//		cr6 = bits 26-27 of length
+//		cr7 = bits 28-31 of length      
+
+LShortReverse:
+        add		rs,rs,rc			// adjust ptrs for reverse move
+        add		rd,rd,rc
+LShortReverse64:					// enter to xfer last 64 bytes
+        bf		26,0f				// 64-byte chunk to xfer?
+        ld		w1,-8(rs)
+        ld		w2,-16(rs)
+        ld		w3,-24(rs)
+        ldu		w4,-32(rs)
+        std		w1,-8(rd)
+        std		w2,-16(rd)
+        std		w3,-24(rd)
+        stdu	w4,-32(rd)
+0:
+        bf		27,1f				// quadword to move?
+        ld		w1,-8(rs)
+        ldu		w2,-16(rs)
+        std		w1,-8(rd)
+        stdu	w2,-16(rd)
+1:
+        bf		28,2f				// doubleword?
+        ldu		w1,-8(rs)
+        stdu	w1,-8(rd)
+2:
+        bf		29,3f				// word?
+        lwzu	w1,-4(rs)
+        stwu	w1,-4(rd)
+3:
+        bf		30,4f				// halfword to move?
+        lhzu	w1,-2(rs)
+        sthu	w1,-2(rd)
+4:
+        bflr	31					// done if no odd byte
+        lbz 	w1,-1(rs)			// no update
+        stb 	w1,-1(rd)
+        blr
+        
+
+// Long operands.
+//     cr1 = blt iff we must move reverse
+
+        .align	4
+LLong:
+        dcbtst	0,rd				// touch in destination
+        neg		w3,rd				// start to compute #bytes to align destination
+        andi.	w6,w3,7				// w6 <- #bytes to 8-byte align destination
+        blt		cr1,LLongReverse	// handle reverse moves
+        mtctr	w6					// set up for loop to align destination
+        sub		rc,rc,w6			// adjust count
+        beq		LAligned			// destination already 8-byte aligned
+1:
+        lbz		w1,0(rs)
+        addi	rs,rs,1
+        stb		w1,0(rd)
+        addi	rd,rd,1
+        bdnz	1b
+        
+// Destination is 8-byte aligned.
+
+LAligned:
+        srwi.	w2,rc,6				// w2 <- count of 64-byte chunks
+        mtcrf	0x02,rc				// leftover byte count to cr (faster one cr at a time)
+        mtcrf	0x01,rc				// put length bits 28-31 in cr7
+        beq		LShort64			// no 64-byte chunks
+        mtctr	w2
+        b		1f
+        
+// Loop moving 64-byte chunks.
+
+        .align	5
+1:
+        ld		w1,0(rs)
+        ld		w2,8(rs)
+        ld		w3,16(rs)
+        ld		w4,24(rs)
+        ld		w5,32(rs)
+        ld		w6,40(rs)
+        ld		w7,48(rs)
+        ld		w8,56(rs)
+        addi	rs,rs,64
+        std		w1,0(rd)
+        std		w2,8(rd)
+        std		w3,16(rd)
+        std		w4,24(rd)
+        std		w5,32(rd)
+        std		w6,40(rd)
+        std		w7,48(rd)
+        std		w8,56(rd)
+        addi	rd,rd,64
+        bdnz	1b
+        
+        b		LShort64
+
+        
+// Handle reverse moves.
+
+LLongReverse:
+        add		rd,rd,rc				// point to end of operands
+        add		rs,rs,rc
+        andi.	r0,rd,7					// is destination 8-byte aligned?
+        sub		rc,rc,r0				// adjust count
+        mtctr	r0						// set up for byte loop
+        beq		LRevAligned				// already aligned
+        
+1:
+        lbzu	w1,-1(rs)
+        stbu	w1,-1(rd)
+        bdnz	1b
+
+// Destination is 8-byte aligned.
+
+LRevAligned:
+        srwi.	w2,rc,6				// w2 <- count of 64-byte chunks
+        mtcrf	0x02,rc				// leftover byte count to cr (faster one cr at a time)
+        mtcrf	0x01,rc				// put length bits 28-31 in cr7
+        beq		LShortReverse64		// no 64-byte chunks
+        mtctr	w2
+        b		1f
+
+// Loop over 64-byte chunks (reverse).
+
+        .align	5
+1:
+        ld		w1,-8(rs)
+        ld		w2,-16(rs)
+        ld		w3,-24(rs)
+        ld		w4,-32(rs)
+        ld		w5,-40(rs)
+        ld		w6,-48(rs)
+        ld		w7,-56(rs)
+        ldu		w8,-64(rs)
+        std		w1,-8(rd)
+        std		w2,-16(rd)
+        std		w3,-24(rd)
+        std		w4,-32(rd)
+        std		w5,-40(rd)
+        std		w6,-48(rd)
+        std		w7,-56(rd)
+        stdu	w8,-64(rd)
+        bdnz	1b
+        
+        b		LShortReverse64
+
+        COMMPAGE_DESCRIPTOR(bcopy_64,_COMM_PAGE_BCOPY,k64Bit,kHasAltivec,0)
diff --git a/osfmk/ppc/commpage/bcopy_970.s b/osfmk/ppc/commpage/bcopy_970.s
new file mode 100644
index 000000000..d21d0bc44
--- /dev/null
+++ b/osfmk/ppc/commpage/bcopy_970.s
@@ -0,0 +1,592 @@
+/*
+ * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ * 
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ * 
+ * @APPLE_LICENSE_HEADER_END@
+ */
+/* =======================================
+ * BCOPY, MEMCPY, and MEMMOVE for Mac OS X
+ * =======================================
+ *
+ * Version of 6/11/2003, tuned for the IBM 970.
+ *
+ *
+ * Register usage.  Note the rather delicate way we assign multiple uses
+ * to the same register.  Beware.
+ *   r0  = temp (NB: cannot use r0 for any constant such as "c16")
+ *   r3  = not used, as memcpy and memmove return 1st parameter as a value
+ *   r4  = source ptr ("rs")
+ *   r5  = count of bytes to move ("rc")
+ *   r6  = "w1", "c16", or "cm17"
+ *   r7  = "w2", "c32", or "cm33"
+ *   r8  = "w3", "c48", or "cm49"
+ *   r9  = "w4",        or "cm1"
+ *   r10 = vrsave ("rv")
+ *   r11 = unused
+ *   r12 = destination ptr ("rd")
+ *   v0  = permute vector ("vp") 
+ * v1-v8 = qw's loaded from source
+ *v9-v12 = permuted qw's ("vw", "vx", "vy", and "vz")
+ */
+#define rs	r4
+#define rd	r12
+#define rc	r5
+#define	rv	r10
+
+#define w1	r6
+#define w2	r7
+#define w3	r8
+#define	w4	r9
+
+#define c16		r6
+#define cm17	r6
+#define c32		r7
+#define cm33	r7
+#define c48		r8
+#define cm49	r8
+#define cm1		r9
+
+#define	vp	v0
+#define	vw	v9
+#define	vx	v10
+#define	vy	v11
+#define	vz	v12
+
+#define	ASSEMBLER
+#include <sys/appleapiopts.h>
+#include <ppc/asm.h>
+#include <machine/cpu_capabilities.h>
+#include <machine/commpage.h>
+
+        .text
+        .globl	EXT(bcopy_970)
+
+
+#define	kShort		64
+#define	kVeryLong	(128*1024)
+
+
+// Main entry points.
+
+        .align 	5
+bcopy_970:							// void bcopy(const void *src, void *dst, size_t len)
+        cmplwi	rc,kShort			// short or long?
+        sub		w1,r4,r3			// must move in reverse if (rd-rs)<rc
+        mr		rd,r4				// move registers to canonic spot
+        mr		rs,r3
+        blt		LShort				// handle short operands
+        dcbt	0,rs				// touch in the first line of source
+        dcbtst	0,rd				// touch in destination
+        b		LLong1				// join long operand code
+
+// NB: memmove() must be 8 words past bcopy(), to agree with comm page addresses.
+
+        .align	5
+Lmemcpy_970:						// void* memcpy(void *dst, void *src, size_t len)
+Lmemmove_970:						// void* memmove(void *dst, const void *src, size_t len)
+        cmplwi	rc,kShort			// short or long?
+        sub		w1,r3,r4			// must move in reverse if (rd-rs)<rc
+        mr		rd,r3				// must leave r3 alone, it is return value for memcpy etc
+        bge		LLong0				// handle long operands
+
+// Handle short operands.
+//		rs = source
+//		rd = destination
+//		rc = count
+//		w1 = (rd-rs), must move reverse if (rd-rs)<rc
+        
+LShort:
+        cmplw	cr1,w1,rc			// set cr1 blt if we must move reverse
+        mtcrf	0x02,rc				// move length to cr6 and cr7 one at a time
+        mtcrf	0x01,rc
+        blt--	cr1,LShortReverse
+        
+// Forward short operands.  This is the most frequent case, so it is inline.
+
+        bf		26,0f				// 32-byte chunk to move?
+        ld		w1,0(rs)
+        ld		w2,8(rs)
+        ld		w3,16(rs)
+        ld		w4,24(rs)
+        addi	rs,rs,32
+        std		w1,0(rd)
+        std		w2,8(rd)
+        std		w3,16(rd)
+        std		w4,24(rd)
+        addi	rd,rd,32
+0:
+LShort32:
+        bf		27,1f				// quadword to move?
+        ld		w1,0(rs)
+        ld		w3,8(rs)
+        addi	rs,rs,16
+        std		w1,0(rd)
+        std		w3,8(rd)
+        addi	rd,rd,16
+1:
+LShort16:							// join here to xfer 0-15 bytes
+        bf		28,2f				// doubleword?
+        ld		w1,0(rs)
+        addi	rs,rs,8
+        std		w1,0(rd)
+        addi	rd,rd,8
+2:
+        bf		29,3f				// word?
+        lwz		w1,0(rs)
+        addi	rs,rs,4
+        stw		w1,0(rd)
+        addi	rd,rd,4
+3:
+        bf		30,4f				// halfword to move?
+        lhz		w1,0(rs)
+        addi	rs,rs,2
+        sth		w1,0(rd)
+        addi	rd,rd,2
+4:
+        bflr	31					// skip if no odd byte
+        lbz		w1,0(rs)
+        stb		w1,0(rd)
+        blr
+        
+        
+// Handle short reverse operands.
+//		cr = length in bits 26-31       
+
+LShortReverse:
+        add		rs,rs,rc			// adjust ptrs for reverse move
+        add		rd,rd,rc
+        bf		26,0f				// 32 bytes to move?
+        ld		w1,-8(rs)
+        ld		w2,-16(rs)
+        ld		w3,-24(rs)
+        ldu		w4,-32(rs)
+        std		w1,-8(rd)
+        std		w2,-16(rd)
+        std		w3,-24(rd)
+        stdu	w4,-32(rd)
+0:
+        bf		27,1f				// quadword to move?
+        ld		w1,-8(rs)
+        ldu		w2,-16(rs)
+        std		w1,-8(rd)
+        stdu	w2,-16(rd)
+1:
+LShortReverse16:					// join here to xfer 0-15 bytes and return
+        bf		28,2f				// doubleword?
+        ldu		w1,-8(rs)
+        stdu	w1,-8(rd)
+2:
+        bf		29,3f				// word?
+        lwzu	w1,-4(rs)
+        stwu	w1,-4(rd)
+3:
+        bf		30,4f				// halfword to move?
+        lhzu	w1,-2(rs)
+        sthu	w1,-2(rd)
+4:
+        bflr	31					// done if no odd byte
+        lbz 	w1,-1(rs)			// no update
+        stb 	w1,-1(rd)
+        blr
+        
+
+// Long operands, use Altivec in most cases.
+//		rs = source
+//		rd = destination
+//		rc = count
+//		w1 = (rd-rs), must move reverse if (rd-rs)<rc
+
+LLong0:								// entry from memmove()
+        dcbt	0,rs				// touch in source
+        dcbtst	0,rd				// touch in destination
+LLong1:								// entry from bcopy() with operands already touched in
+        cmplw	cr1,w1,rc			// set cr1 blt iff we must move reverse
+        neg		w3,rd				// start to compute #bytes to align destination
+        rlwinm	w2,w1,0,0xF			// 16-byte aligned?  (w2==0 if so)
+        andi.	w4,w3,0xF			// w4 <- #bytes to 16-byte align destination
+        cmpwi	cr5,w2,0			// set cr5 beq if relatively 16-byte aligned
+        blt--	cr1,LLongReverse	// handle reverse moves
+        sub		rc,rc,w4			// adjust length for aligning destination
+        srwi	r0,rc,7				// get #cache lines to copy (may be 0)
+        cmpwi	cr1,r0,0			// set cr1 on #chunks
+        beq		LFwdAligned			// dest is already aligned
+        
+// 16-byte align destination.
+
+        mtcrf	0x01,w4				// cr7 <- #bytes to align dest (nonzero)
+        bf		31,1f				// byte to move?
+        lbz		w1,0(rs)
+        addi	rs,rs,1
+        stb		w1,0(rd)
+        addi	rd,rd,1
+1:
+        bf		30,2f				// halfword?
+        lhz		w1,0(rs)
+        addi	rs,rs,2
+        sth		w1,0(rd)
+        addi	rd,rd,2
+2:
+        bf		29,3f				// word?
+        lwz		w1,0(rs)
+        addi	rs,rs,4
+        stw		w1,0(rd)
+        addi	rd,rd,4
+3:
+        bf		28,LFwdAligned		// doubleword?
+        ld		w1,0(rs)
+        addi	rs,rs,8
+        std		w1,0(rd)
+        addi	rd,rd,8
+
+
+// Forward, destination is 16-byte aligned.  There are five cases:
+//  1. If the length>=kVeryLong (ie, several pages), then use the
+//     "bigcopy" path that pulls all the punches.  This is the fastest
+//	   case for cold-cache operands, as any this long will likely be.
+//	2. If length>=128 and source is 16-byte aligned, then use the
+//	   lvx/stvx loop over 128-byte chunks.  This is the fastest
+//     case for hot-cache operands, 2nd fastest for cold.
+//	3. If length>=128 and source is not 16-byte aligned, then use the
+//	   lvx/vperm/stvx loop over 128-byte chunks.
+//	4. If length<128 and source is 8-byte aligned, then use the
+//	   ld/std loop over 32-byte chunks.
+//	5. If length<128 and source is not 8-byte aligned, then use the
+//	   lvx/vperm/stvx loop over 32-byte chunks.  This is the slowest case.
+// Registers at this point:
+//		r0/cr1 = count of cache lines ("chunks") that we'll cover (may be 0)
+//			rs = alignment unknown
+//		    rd = 16-byte aligned
+//			rc = bytes remaining
+//			w2 = low 4 bits of (rd-rs), used to check alignment
+//		   cr5 = beq if source is also 16-byte aligned
+
+LFwdAligned:
+        andi.	w3,w2,7				// is source at least 8-byte aligned?
+        mtcrf	0x01,rc				// move leftover count to cr7 for LShort16
+        bne		cr1,LFwdLongVectors	// at least one 128-byte chunk, so use vectors
+        srwi	w1,rc,5				// get 32-byte chunk count
+        mtcrf	0x02,rc				// move bit 27 of length to cr6 for LShort32
+        mtctr	w1					// set up 32-byte loop (w1!=0)
+        beq		LFwdMedAligned		// source is 8-byte aligned, so use ld/std loop
+        mfspr	rv,vrsave			// get bitmap of live vector registers
+        oris	w4,rv,0xFFF8		// we use v0-v12
+        li		c16,16				// get constants used in lvx
+        li		c32,32
+        mtspr	vrsave,w4			// update mask
+        lvx		v1,0,rs				// prefetch 1st source quadword
+        lvsl	vp,0,rs				// get permute vector to shift left
+        
+        
+// Fewer than 128 bytes but not doubleword aligned: use lvx/vperm/stvx.
+
+1:									// loop over 32-byte chunks
+        lvx		v2,c16,rs
+        lvx		v3,c32,rs
+        addi	rs,rs,32
+        vperm	vx,v1,v2,vp
+        vperm	vy,v2,v3,vp
+        vor		v1,v3,v3			// v1 <- v3
+        stvx	vx,0,rd
+        stvx	vy,c16,rd
+        addi	rd,rd,32
+        bdnz	1b
+        
+        mtspr	vrsave,rv			// restore bitmap of live vr's
+        b		LShort32
+
+        
+// Fewer than 128 bytes and doubleword aligned: use ld/std.
+
+        .align	5
+LFwdMedAligned:									// loop over 32-byte chunks
+        ld		w1,0(rs)
+        ld		w2,8(rs)
+        ld		w3,16(rs)
+        ld		w4,24(rs)
+        addi	rs,rs,32
+        std		w1,0(rd)
+        std		w2,8(rd)
+        std		w3,16(rd)
+        std		w4,24(rd)
+        addi	rd,rd,32
+        bdnz	LFwdMedAligned
+        
+        b		LShort32
+
+        
+// Forward, 128 bytes or more: use vectors.  When entered:
+//	    r0 = 128-byte chunks to move (>0)
+//		rd = 16-byte aligned
+//	   cr5 = beq if source is 16-byte aligned
+//	   cr7 = low 4 bits of rc (ie, leftover byte count 0-15)
+// We set up many registers:
+//	   ctr = number of 128-byte chunks to move
+//	r0/cr0 = leftover QWs to move
+//	   cr7 = low 4 bits of rc (ie, leftover byte count 0-15)
+//	   cr6 = beq if leftover byte count is 0
+//		rv = original value of VRSave
+// c16,c32,c48 = loaded
+
+LFwdLongVectors:
+        mfspr	rv,vrsave			// get bitmap of live vector registers
+        lis		w3,kVeryLong>>16	// cutoff for very-long-operand special case path
+        cmplw	cr1,rc,w3			// very long operand?
+        rlwinm	w3,rc,0,28,31		// move last 0-15 byte count to w3
+        bgea--	cr1,_COMM_PAGE_BIGCOPY	// handle big copies separately
+        mtctr	r0					// set up loop count
+        cmpwi	cr6,w3,0			// set cr6 on leftover byte count
+        oris	w4,rv,0xFFF8		// we use v0-v12
+        rlwinm.	r0,rc,28,29,31		// get number of quadword leftovers (0-7) and set cr0
+        li		c16,16				// get constants used in ldvx/stvx
+        mtspr	vrsave,w4			// update mask
+        li		c32,32
+        li		c48,48
+        beq		cr5,LFwdLongAligned	// source is also 16-byte aligned, no need for vperm
+        lvsl	vp,0,rs				// get permute vector to shift left
+        lvx		v1,0,rs				// prefetch 1st source quadword
+        b		LFwdLongUnaligned
+
+
+// Forward, long, unaligned vector loop.
+
+        .align	5					// align inner loops
+LFwdLongUnaligned:					// loop over 128-byte chunks
+        addi	w4,rs,64
+        lvx		v2,c16,rs
+        lvx		v3,c32,rs
+        lvx		v4,c48,rs
+        lvx		v5,0,w4
+        lvx		v6,c16,w4
+        vperm	vw,v1,v2,vp
+        lvx		v7,c32,w4
+        lvx		v8,c48,w4
+        addi	rs,rs,128
+        vperm	vx,v2,v3,vp
+        addi	w4,rd,64
+        lvx		v1,0,rs
+        stvx	vw,0,rd
+        vperm	vy,v3,v4,vp
+        stvx	vx,c16,rd
+        vperm	vz,v4,v5,vp
+        stvx	vy,c32,rd
+        vperm	vw,v5,v6,vp
+        stvx	vz,c48,rd
+        vperm	vx,v6,v7,vp
+        addi	rd,rd,128
+        stvx	vw,0,w4
+        vperm	vy,v7,v8,vp
+        stvx	vx,c16,w4
+        vperm	vz,v8,v1,vp
+        stvx	vy,c32,w4
+        stvx	vz,c48,w4
+        bdnz	LFwdLongUnaligned
+
+        beq		4f					// no leftover quadwords
+        mtctr	r0
+3:									// loop over remaining quadwords
+        lvx		v2,c16,rs
+        addi	rs,rs,16
+        vperm	vx,v1,v2,vp
+        vor		v1,v2,v2			// v1 <- v2
+        stvx	vx,0,rd
+        addi	rd,rd,16
+        bdnz	3b
+4:
+        mtspr	vrsave,rv			// restore bitmap of live vr's
+        bne		cr6,LShort16		// handle last 0-15 bytes if any
+        blr
+
+
+// Forward, long, 16-byte aligned vector loop.
+
+        .align	5
+LFwdLongAligned:        			// loop over 128-byte chunks
+        addi	w4,rs,64
+        lvx		v1,0,rs
+        lvx		v2,c16,rs
+        lvx		v3,c32,rs
+        lvx		v4,c48,rs
+        lvx		v5,0,w4
+        lvx		v6,c16,w4
+        lvx		v7,c32,w4
+        lvx		v8,c48,w4
+        addi	rs,rs,128
+        addi	w4,rd,64
+        stvx	v1,0,rd 
+        stvx	v2,c16,rd
+        stvx	v3,c32,rd
+        stvx	v4,c48,rd
+        stvx	v5,0,w4
+        stvx	v6,c16,w4
+        stvx	v7,c32,w4
+        stvx	v8,c48,w4
+        addi	rd,rd,128
+        bdnz	LFwdLongAligned
+                
+        beq		4f					// no leftover quadwords
+        mtctr	r0
+3:									// loop over remaining quadwords (1-7)
+        lvx		v1,0,rs
+        addi	rs,rs,16
+        stvx	v1,0,rd
+        addi	rd,rd,16
+        bdnz	3b
+4:
+        mtspr	vrsave,rv			// restore bitmap of live vr's
+        bne		cr6,LShort16		// handle last 0-15 bytes if any
+        blr
+        
+
+// Long, reverse moves.
+//		rs = source
+//		rd = destination
+//		rc = count
+//	   cr5 = beq if relatively 16-byte aligned
+
+LLongReverse:
+        add		rd,rd,rc			// point to end of operands
+        add		rs,rs,rc
+        andi.	r0,rd,0xF			// #bytes to 16-byte align destination
+        beq		2f					// already aligned
+        
+// 16-byte align destination.
+
+        mtctr	r0					// set up for loop
+        sub		rc,rc,r0
+1:
+        lbzu	w1,-1(rs)
+        stbu	w1,-1(rd)
+        bdnz	1b
+
+// Prepare for reverse vector loop.  When entered:
+//		rd = 16-byte aligned
+//		cr5 = beq if source also 16-byte aligned
+// We set up many registers:
+//		ctr/cr1 = number of 64-byte chunks to move (may be 0)
+//		r0/cr0 = leftover QWs to move
+//		cr7 = low 4 bits of rc (ie, leftover byte count 0-15)
+//		cr6 = beq if leftover byte count is 0
+//		cm1 = -1
+//		rv = original value of vrsave
+
+2:
+        mfspr	rv,vrsave			// get bitmap of live vector registers
+        srwi	r0,rc,6				// get count of 64-byte chunks to move (may be 0)
+        oris	w1,rv,0xFFF8		// we use v0-v12
+        mtcrf	0x01,rc				// prepare for moving last 0-15 bytes in LShortReverse16
+        rlwinm	w3,rc,0,28,31		// move last 0-15 byte count to w3 too
+        cmpwi	cr1,r0,0			// set cr1 on chunk count
+        mtspr	vrsave,w1			// update mask
+        mtctr	r0					// set up loop count
+        cmpwi	cr6,w3,0			// set cr6 on leftover byte count
+        rlwinm.	r0,rc,28,30,31		// get number of quadword leftovers (0-3) and set cr0
+        li		cm1,-1				// get constants used in ldvx/stvx
+        
+        bne		cr5,LReverseVecUnal	// handle unaligned operands
+        beq		cr1,2f				// no chunks (if no chunks, must be leftover QWs)
+        li		cm17,-17
+        li		cm33,-33
+        li		cm49,-49
+        b		1f
+
+// Long, reverse 16-byte-aligned vector loop.
+      
+        .align	5					// align inner loops
+1:        							// loop over 64-byte chunks
+        lvx		v1,cm1,rs
+        lvx		v2,cm17,rs
+        lvx		v3,cm33,rs
+        lvx		v4,cm49,rs
+        subi	rs,rs,64
+        stvx	v1,cm1,rd
+        stvx	v2,cm17,rd
+        stvx	v3,cm33,rd
+        stvx	v4,cm49,rd
+        subi	rd,rd,64
+        bdnz	1b
+        
+        beq		4f					// no leftover quadwords
+2:									// r0=#QWs, rv=vrsave, cr7=(rc & F), cr6 set on cr7
+        mtctr	r0
+3:									// loop over remaining quadwords (1-7)
+        lvx		v1,cm1,rs
+        subi	rs,rs,16
+        stvx	v1,cm1,rd
+        subi	rd,rd,16
+        bdnz	3b
+4:
+        mtspr	vrsave,rv			// restore bitmap of live vr's
+        bne		cr6,LShortReverse16	// handle last 0-15 bytes if any
+        blr
+
+
+// Long, reverse, unaligned vector loop.
+//		ctr/cr1 = number of 64-byte chunks to move (may be 0)
+//		r0/cr0 = leftover QWs to move
+//		cr7 = low 4 bits of rc (ie, leftover byte count 0-15)
+//		cr6 = beq if leftover byte count is 0
+//		rv = original value of vrsave
+//		cm1 = -1
+
+LReverseVecUnal:
+        lvsl	vp,0,rs				// get permute vector to shift left
+        lvx		v1,cm1,rs			// v1 always looks ahead
+        li		cm17,-17
+        beq		cr1,2f				// no chunks (if no chunks, must be leftover QWs)
+        li		cm33,-33
+        li		cm49,-49
+        b		1f
+        
+        .align	5					// align the inner loops
+1:									// loop over 64-byte chunks
+        lvx		v2,cm17,rs
+        lvx		v3,cm33,rs
+        lvx		v4,cm49,rs
+        subi	rs,rs,64
+        vperm	vx,v2,v1,vp
+        lvx		v1,cm1,rs
+        vperm	vy,v3,v2,vp
+        stvx	vx,cm1,rd
+        vperm	vz,v4,v3,vp
+        stvx	vy,cm17,rd
+        vperm	vx,v1,v4,vp
+        stvx	vz,cm33,rd
+        stvx	vx,cm49,rd
+        subi	rd,rd,64
+        bdnz	1b
+
+        beq		4f					// no leftover quadwords
+2:									// r0=#QWs, rv=vrsave, v1=next QW, cr7=(rc & F), cr6 set on cr7
+        mtctr	r0
+3:									// loop over 1-3 quadwords
+        lvx		v2,cm17,rs
+        subi	rs,rs,16
+        vperm	vx,v2,v1,vp
+        vor		v1,v2,v2			// v1 <- v2
+        stvx	vx,cm1,rd
+        subi	rd,rd,16
+        bdnz	3b
+4:
+        mtspr	vrsave,rv			// restore bitmap of live vr's
+        bne		cr6,LShortReverse16	// handle last 0-15 bytes iff any
+        blr
+
+        COMMPAGE_DESCRIPTOR(bcopy_970,_COMM_PAGE_BCOPY,k64Bit+kHasAltivec,0,kCommPageMTCRF)
diff --git a/osfmk/ppc/commpage/bcopy_g3.s b/osfmk/ppc/commpage/bcopy_g3.s
new file mode 100644
index 000000000..cfa8eddcc
--- /dev/null
+++ b/osfmk/ppc/commpage/bcopy_g3.s
@@ -0,0 +1,274 @@
+/*
+ * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ * 
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ * 
+ * @APPLE_LICENSE_HEADER_END@
+ */
+/* =======================================
+ * BCOPY, MEMCPY, and MEMMOVE for Mac OS X
+ * =======================================
+ *
+ * Version of 2/20/2003, tuned for G3.
+ *
+ * Register usage.  Note we use R2, so this code will not run in a PEF/CFM
+ * environment.
+ *
+ *   r0  = "w7" or temp
+ *   r2  = "w8"
+ *   r3  = not used, as memcpy and memmove return 1st parameter as a value
+ *   r4  = source ptr ("rs")
+ *   r5  = count of bytes to move ("rc")
+ *   r6  = "w1"
+ *   r7  = "w2"
+ *   r8  = "w3"
+ *   r9  = "w4"
+ *   r10 = "w5"
+ *   r11 = "w6"
+ *   r12 = destination ptr ("rd")
+ * f0-f3 = used for moving 8-byte aligned data
+ */
+#define rs	r4		// NB: we depend on rs==r4 in "lswx" instructions
+#define rd	r12
+#define rc	r5
+
+#define w1	r6
+#define w2	r7
+#define w3	r8
+#define	w4	r9
+#define	w5	r10
+#define	w6	r11
+#define	w7	r0
+#define	w8	r2
+
+#define	ASSEMBLER
+#include <sys/appleapiopts.h>
+#include <ppc/asm.h>
+#include <machine/cpu_capabilities.h>
+#include <machine/commpage.h>
+
+        .text
+        .globl 	EXT(bcopy_g3)
+
+
+#define	kLong	33					// too long for string ops
+
+
+// Main entry points.
+
+        .align 	5
+bcopy_g3:							// void bcopy(const void *src, void *dst, size_t len)
+        cmplwi	rc,kLong			// length > 32 bytes?
+        sub		w1,r4,r3			// must move in reverse if (rd-rs)<rc
+        mr		rd,r4				// start to move source & dest to canonic spot
+        bge		LLong0				// skip if long operand
+        mtxer	rc					// set length for string ops
+        lswx	r5,0,r3				// load bytes into r5-r12
+        stswx	r5,0,r4				// store them
+        blr
+
+// NB: memcpy() and memmove() must follow bcopy() by 32 bytes, for comm page.
+
+        .align	5
+Lmemcpy_g3:							// void* memcpy(void *dst, void *src, size_t len)
+Lmemmove_g3:						// void* memmove(void *dst, const void *src, size_t len)
+        cmplwi	rc,kLong			// length > 32 bytes?
+        sub		w1,r3,rs			// must move in reverse if (rd-rs)<rc
+        mr		rd,r3				// must leave r3 alone, it is return value for memcpy etc
+        bge		LLong1				// longer than 32 bytes
+        mtxer	rc					// set length for string ops
+        lswx	r5,0,r4				// load bytes into r5-r12
+        stswx	r5,0,r3				// store them
+        blr
+
+// Long operands (more than 32 bytes.)
+//		w1  = (rd-rs), used to check for alignment
+
+LLong0:								// enter from bcopy()
+        mr		rs,r3				// must leave r3 alone (it is return value for memcpy)
+LLong1:								// enter from memcpy() and memmove()
+        cmplw	cr1,w1,rc			// set cr1 blt iff we must move reverse
+        rlwinm	r0,w1,0,0x3			// are operands relatively word-aligned?
+        neg		w2,rd				// prepare to align destination
+        cmpwi	cr5,r0,0			// set cr5 beq if relatively word aligned
+        blt		cr1,LLongReverse	// handle reverse move
+        andi.	w4,w2,3				// w4 <- #bytes to word align destination
+        beq		cr5,LLongFloat		// relatively aligned so use FPRs
+        sub		rc,rc,w4			// adjust count for alignment
+        srwi	r0,rc,5				// get #chunks to xfer (>=1)
+        rlwinm	rc,rc,0,0x1F		// mask down to leftover bytes
+        mtctr	r0					// set up loop count
+        beq		1f					// dest already word aligned
+    
+// Word align the destination.
+        
+        mtxer	w4					// byte count to xer
+        cmpwi	r0,0				// any chunks to xfer?
+        lswx	w1,0,rs				// move w4 bytes to align dest
+        add		rs,rs,w4
+        stswx	w1,0,rd
+        add		rd,rd,w4
+        beq-	2f					// pathologic case, no chunks to xfer
+
+// Forward, unaligned loop.
+
+1:
+        lwz		w1,0(rs)
+        lwz		w2,4(rs)
+        lwz		w3,8(rs)
+        lwz		w4,12(rs)
+        lwz		w5,16(rs)
+        lwz		w6,20(rs)
+        lwz		w7,24(rs)
+        lwz		w8,28(rs)
+        addi	rs,rs,32
+        stw		w1,0(rd)
+        stw		w2,4(rd)
+        stw		w3,8(rd)
+        stw		w4,12(rd)
+        stw		w5,16(rd)
+        stw		w6,20(rd)
+        stw		w7,24(rd)
+        stw		w8,28(rd)
+        addi	rd,rd,32
+        bdnz	1b
+2:									// rc = remaining bytes (0-31)
+        mtxer	rc					// set up count for string ops
+        mr		r0,rd				// move dest ptr out of the way
+        lswx	r5,0,rs				// load xer bytes into r5-r12 (rs==r4)
+        stswx	r5,0,r0				// store them
+        blr
+        
+
+
+// Forward, aligned loop.  We use FPRs.
+
+LLongFloat:
+        andi.	w4,w2,7				// W4 <- #bytes to doubleword-align destination
+        sub		rc,rc,w4			// adjust count for alignment
+        srwi	r0,rc,5				// number of 32-byte chunks to xfer
+        rlwinm	rc,rc,0,0x1F		// mask down to leftover bytes
+        mtctr	r0					// set up loop count
+        beq		1f					// dest already doubleword aligned
+    
+// Doubleword align the destination.
+        
+        mtxer	w4					// byte count to xer
+        cmpwi	r0,0				// any chunks to xfer?
+        lswx	w1,0,rs				// move w4 bytes to align dest
+        add		rs,rs,w4
+        stswx	w1,0,rd
+        add		rd,rd,w4
+        beq-	2f					// pathologic case, no chunks to xfer
+1:									// loop over 32-byte chunks
+        lfd		f0,0(rs)
+        lfd		f1,8(rs)
+        lfd		f2,16(rs)
+        lfd		f3,24(rs)
+        addi	rs,rs,32
+        stfd	f0,0(rd)
+        stfd	f1,8(rd)
+        stfd	f2,16(rd)
+        stfd	f3,24(rd)
+        addi	rd,rd,32
+        bdnz	1b
+2:									// rc = remaining bytes (0-31)
+        mtxer	rc					// set up count for string ops
+        mr		r0,rd				// move dest ptr out of the way
+        lswx	r5,0,rs				// load xer bytes into r5-r12 (rs==r4)
+        stswx	r5,0,r0				// store them
+        blr
+
+        
+// Long, reverse moves.
+//		cr5 = beq if relatively word aligned
+
+LLongReverse:
+        add		rd,rd,rc			// point to end of operands + 1
+        add		rs,rs,rc
+        beq		cr5,LReverseFloat	// aligned operands so can use FPRs
+        srwi	r0,rc,5				// get chunk count
+        rlwinm	rc,rc,0,0x1F		// mask down to leftover bytes
+        mtctr	r0					// set up loop count
+        mtxer	rc					// set up for trailing bytes
+1:
+        lwz		w1,-4(rs)
+        lwz		w2,-8(rs)
+        lwz		w3,-12(rs)
+        lwz		w4,-16(rs)
+        stw		w1,-4(rd)
+        lwz		w5,-20(rs)
+        stw		w2,-8(rd)
+        lwz		w6,-24(rs)
+        stw		w3,-12(rd)
+        lwz		w7,-28(rs)
+        stw		w4,-16(rd)
+        lwzu	w8,-32(rs)
+        stw		w5,-20(rd)
+        stw		w6,-24(rd)
+        stw		w7,-28(rd)
+        stwu	w8,-32(rd)
+        bdnz	1b
+
+        sub		r4,rs,rc			// point to 1st (leftmost) leftover byte (0..31)
+        sub		r0,rd,rc			// move dest ptr out of way
+        lswx	r5,0,r4				// load xer bytes into r5-r12
+        stswx	r5,0,r0				// store them
+        blr
+
+
+// Long, reverse aligned moves.  We use FPRs.
+
+LReverseFloat:
+        andi.	w4,rd,7				// W3 <- #bytes to doubleword-align destination
+        sub		rc,rc,w4			// adjust count for alignment
+        srwi	r0,rc,5				// number of 32-byte chunks to xfer
+        rlwinm	rc,rc,0,0x1F		// mask down to leftover bytes
+        mtctr	r0					// set up loop count
+        beq		1f					// dest already doubleword aligned
+    
+// Doubleword align the destination.
+        
+        mtxer	w4					// byte count to xer
+        cmpwi	r0,0				// any chunks to xfer?
+        sub		rs,rs,w4			// point to 1st bytes to xfer
+        sub		rd,rd,w4
+        lswx	w1,0,rs				// move w3 bytes to align dest
+        stswx	w1,0,rd
+        beq-	2f					// pathologic case, no chunks to xfer
+1:
+        lfd		f0,-8(rs)
+        lfd		f1,-16(rs)
+        lfd		f2,-24(rs)
+        lfdu	f3,-32(rs)
+        stfd	f0,-8(rd)
+        stfd	f1,-16(rd)
+        stfd	f2,-24(rd)
+        stfdu	f3,-32(rd)
+        bdnz	1b
+2:									// rc = remaining bytes (0-31)
+        mtxer	rc					// set up count for string ops
+        sub		r4,rs,rc			// point to 1st (leftmost) leftover byte (0..31)
+        sub		r0,rd,rc			// move dest ptr out of way
+        lswx	r5,0,r4				// load xer bytes into r5-r12
+        stswx	r5,0,r0				// store them
+        blr
+
+        COMMPAGE_DESCRIPTOR(bcopy_g3,_COMM_PAGE_BCOPY,0,k64Bit+kHasAltivec,0)
diff --git a/osfmk/ppc/commpage/bcopy_g4.s b/osfmk/ppc/commpage/bcopy_g4.s
new file mode 100644
index 000000000..4750ae42e
--- /dev/null
+++ b/osfmk/ppc/commpage/bcopy_g4.s
@@ -0,0 +1,621 @@
+/*
+ * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ * 
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ * 
+ * @APPLE_LICENSE_HEADER_END@
+ */
+/* =======================================
+ * BCOPY, MEMCPY, and MEMMOVE for Mac OS X
+ * =======================================
+ *
+ * Version of 2/20/2003, tuned for G4.  The inner loops use DCBA to avoid
+ * reading destination cache lines.  Only the 7450 actually benefits from
+ * this, and then only in the cold-cache case.  On 7400s and 7455s, we
+ * patch the DCBAs into NOPs.
+ *
+ * Register usage.  Note we use R2, so this code will not run in a PEF/CFM
+ * environment.  Note also the rather delicate way we assign multiple uses
+ * to the same register.  Beware.
+ *
+ *   r0  = "w7" or temp (NB: cannot use r0 for any constant such as "c16")
+ *   r2  = "w8" or vrsave ("rv")
+ *   r3  = not used, as memcpy and memmove return 1st parameter as a value
+ *   r4  = source ptr ("rs")
+ *   r5  = count of bytes to move ("rc")
+ *   r6  = "w1", "c16", or "cm17"
+ *   r7  = "w2", "c32", or "cm33"
+ *   r8  = "w3", "c48", or "cm49"
+ *   r9  = "w4", or "cm1"
+ *   r10 = "w5", "c96", or "cm97"
+ *   r11 = "w6", "c128", or "cm129"
+ *   r12 = destination ptr ("rd")
+ *   v0  = permute vector ("vp") 
+ * v1-v4 = qw's loaded from source
+ * v5-v7 = permuted qw's ("vw", "vx", "vy")
+ */
+#define rs	r4
+#define rd	r12
+#define rc	r5
+#define	rv	r2
+
+#define w1	r6
+#define w2	r7
+#define w3	r8
+#define	w4	r9
+#define	w5	r10
+#define	w6	r11
+#define	w7	r0
+#define	w8	r2
+
+#define c16		r6
+#define cm17	r6
+#define c32		r7
+#define cm33	r7
+#define c48		r8
+#define cm49	r8
+#define cm1		r9
+#define c96		r10
+#define cm97	r10
+#define c128	r11
+#define cm129	r11
+
+#define	vp	v0
+#define	vw	v5
+#define	vx	v6
+#define	vy	v7
+
+#define	ASSEMBLER
+#include <sys/appleapiopts.h>
+#include <ppc/asm.h>
+#include <machine/cpu_capabilities.h>
+#include <machine/commpage.h>
+
+        .text
+        .globl 	EXT(bcopy_g4)
+
+#define	kMedium		32				// too long for inline loopless code
+#define	kLong		96				// long enough to justify use of Altivec
+
+
+// Main entry points.
+
+        .align 	5
+bcopy_g4:							// void bcopy(const void *src, void *dst, size_t len)
+        cmplwi	rc,kMedium			// short or long?
+        sub		w1,r4,r3			// must move in reverse if (rd-rs)<rc
+        cmplw	cr1,w1,rc			// set cr1 blt iff we must move reverse
+        mr		rd,r4				// start to move registers to canonic spot
+        mr		rs,r3
+        blt+	LShort				// handle short operands
+        dcbt	0,r3				// touch in destination
+        b		LMedium				// join medium/long operand code
+
+// NB: memmove() must be 8 words past bcopy(), to agree with comm page addresses.
+        
+        .align	5
+Lmemcpy_g4:							// void* memcpy(void *dst, void *src, size_t len)
+Lmemmove_g4:						// void* memmove(void *dst, const void *src, size_t len)
+        cmplwi	rc,kMedium			// short or long?
+        sub		w1,r3,r4			// must move in reverse if (rd-rs)<rc
+        dcbt	0,r4				// touch in the first line of source
+        cmplw	cr1,w1,rc			// set cr1 blt iff we must move reverse
+        mr		rd,r3				// must leave r3 alone, it is return value for memcpy etc
+        bge-	LMedium				// handle medium or long operands
+
+// Handle short operands.
+        
+LShort:
+        andi.	r0,rc,0x10			// test bit 27 separately (faster on G4)
+        mtcrf	0x01,rc				// put length bits 28-31 in cr7
+        blt-	cr1,LShortReverse
+        
+// Forward short operands.  This is the most frequent case, so it is inline.
+
+        beq		LShort16			// quadword to move?
+        lwz		w1,0(rs)
+        lwz		w2,4(rs)
+        lwz		w3,8(rs)
+        lwz		w4,12(rs)
+        addi	rs,rs,16
+        stw		w1,0(rd)
+        stw		w2,4(rd)
+        stw		w3,8(rd)
+        stw		w4,12(rd)
+        addi	rd,rd,16
+LShort16:							// join here to xfer 0-15 bytes
+        bf		28,2f				// doubleword?
+        lwz		w1,0(rs)
+        lwz		w2,4(rs)
+        addi	rs,rs,8
+        stw		w1,0(rd)
+        stw		w2,4(rd)
+        addi	rd,rd,8
+2:
+        bf		29,3f				// word?
+        lwz		w1,0(rs)
+        addi	rs,rs,4
+        stw		w1,0(rd)
+        addi	rd,rd,4
+3:
+        bf		30,4f				// halfword to move?
+        lhz		w1,0(rs)
+        addi	rs,rs,2
+        sth		w1,0(rd)
+        addi	rd,rd,2
+4:
+        bflr	31					// skip if no odd byte
+        lbz		w1,0(rs)
+        stb		w1,0(rd)
+        blr
+        
+        
+// Handle short reverse operands.
+//		cr0 = bne if bit 27 of length is set
+//		cr7 = bits 28-31 of length      
+
+LShortReverse:
+        add		rs,rs,rc			// adjust ptrs for reverse move
+        add		rd,rd,rc
+        beq		LShortReverse16		// quadword to move?
+        lwz		w1,-4(rs)
+        lwz		w2,-8(rs)
+        lwz		w3,-12(rs)
+        lwzu	w4,-16(rs)
+        stw		w1,-4(rd)
+        stw		w2,-8(rd)
+        stw		w3,-12(rd)
+        stwu	w4,-16(rd)
+LShortReverse16:					// join here to xfer 0-15 bytes and return
+        bf		28,2f				// doubleword?
+        lwz		w1,-4(rs)
+        lwzu	w2,-8(rs)
+        stw		w1,-4(rd)
+        stwu	w2,-8(rd)
+2:
+        bf		29,3f				// word?
+        lwzu	w1,-4(rs)
+        stwu	w1,-4(rd)
+3:
+        bf		30,4f				// halfword to move?
+        lhzu	w1,-2(rs)
+        sthu	w1,-2(rd)
+4:
+        bflr	31					// done if no odd byte
+        lbz 	w1,-1(rs)			// no update
+        stb 	w1,-1(rd)
+        blr
+        
+
+// Medium and long operands.  Use Altivec if long enough, else scalar loops.
+//		w1 = (rd-rs), used to check for alignment
+//     cr1 = blt iff we must move reverse
+
+        .align	4
+LMedium:
+        dcbtst	0,rd				// touch in destination
+        cmplwi	cr7,rc,kLong		// long enough for vectors?
+        neg		w3,rd				// start to compute #bytes to align destination
+        rlwinm	r0,w1,0,0x7			// check relative 8-byte alignment
+        andi.	w6,w3,7				// w6 <- #bytes to 8-byte align destination
+        blt		cr1,LMediumReverse	// handle reverse moves
+        rlwinm	w4,w3,0,0x1F		// w4 <- #bytes to 32-byte align destination
+        cmpwi	cr6,r0,0			// set cr6 beq if relatively aligned
+        bge		cr7,LFwdLong		// long enough for vectors
+
+// Medium length: use scalar loops.
+//	w6/cr0 = #bytes to 8-byte align destination
+//	   cr6 = beq if relatively doubleword aligned
+
+        sub		rc,rc,w6			// decrement length remaining
+        beq		1f					// skip if dest already doubleword aligned
+        mtxer	w6					// set up count for move
+        lswx	w1,0,rs				// move w6 bytes to align destination
+        stswx	w1,0,rd
+        add		rs,rs,w6			// bump ptrs past
+        add		rd,rd,w6
+1:        
+        srwi	r0,rc,4				// get # 16-byte chunks (>=1)
+        mtcrf	0x01,rc				// save remaining byte count here for LShort16
+        mtctr	r0					// set up 16-byte loop
+        bne		cr6,3f				// source not 4-byte aligned
+        b		2f
+        
+        .align	4
+2:									// loop over 16-byte  aligned chunks
+        lfd		f0,0(rs)
+        lfd		f1,8(rs)
+        addi	rs,rs,16
+        stfd	f0,0(rd)
+        stfd	f1,8(rd)
+        addi	rd,rd,16
+        bdnz	2b
+        
+        b		LShort16
+        
+        .align	4
+3:									// loop over 16-byte unaligned chunks
+        lwz		w1,0(rs)
+        lwz		w2,4(rs)
+        lwz		w3,8(rs)
+        lwz		w4,12(rs)
+        addi	rs,rs,16
+        stw		w1,0(rd)
+        stw		w2,4(rd)
+        stw		w3,8(rd)
+        stw		w4,12(rd)
+        addi	rd,rd,16
+        bdnz	3b
+        
+        b		LShort16
+
+
+// Vector loops.  First, we must 32-byte align the destination.
+//		w1 = (rd-rs), used to check for reverse and alignment
+//		w4 = #bytes to 32-byte align destination
+//		rc = long enough for at least one vector loop
+
+LFwdLong:
+        cmpwi	w4,0				// dest already aligned?
+        sub		rc,rc,w4			// adjust length
+        mtcrf	0x01,w4				// cr7 <- #bytes to align dest
+        rlwinm	w2,w1,0,0xF			// relatively 16-byte aligned?
+        mtcrf	0x02,w4				// finish moving #bytes to align to cr6 and cr7
+        srwi	r0,rc,6				// get # 64-byte chunks to xfer (>=1)
+        cmpwi	cr5,w2,0			// set cr5 beq if relatively 16-byte aligned
+        beq		LFwdAligned			// dest is already aligned
+        
+// 32-byte align destination.
+
+        bf		31,1f				// byte to move?
+        lbz		w1,0(rs)
+        addi	rs,rs,1
+        stb		w1,0(rd)
+        addi	rd,rd,1
+1:
+        bf		30,2f				// halfword?
+        lhz		w1,0(rs)
+        addi	rs,rs,2
+        sth		w1,0(rd)
+        addi	rd,rd,2
+2:
+        bf		29,3f				// word?
+        lwz		w1,0(rs)
+        addi	rs,rs,4
+        stw		w1,0(rd)
+        addi	rd,rd,4
+3:
+        bf		28,4f				// doubleword?
+        lwz		w1,0(rs)
+        lwz		w2,4(rs)
+        addi	rs,rs,8
+        stw		w1,0(rd)
+        stw		w2,4(rd)
+        addi	rd,rd,8
+4:	
+        bf		27,LFwdAligned		// quadword?
+        lwz		w1,0(rs)
+        lwz		w2,4(rs)
+        lwz		w3,8(rs)
+        lwz		w4,12(rs)
+        addi	rs,rs,16
+        stw		w1,0(rd)
+        stw		w2,4(rd)
+        stw		w3,8(rd)
+        stw		w4,12(rd)
+        addi	rd,rd,16
+
+
+// Destination is 32-byte aligned.
+//		r0 = count of 64-byte chunks to move (not 0)
+//		rd = 32-byte aligned
+//		rc = bytes remaining
+//	   cr5 = beq if source is 16-byte aligned
+// We set up many registers:
+//	   ctr = number of 64-byte chunks to move
+//	r0/cr0 = leftover QWs to move
+//	   cr7 = low 4 bits of rc (ie, leftover byte count 0-15)
+//	   cr6 = beq if leftover byte count is 0
+//		rv = original value of vrsave
+// c16 etc = loaded
+
+LFwdAligned:
+        mfspr	rv,vrsave			// get bitmap of live vector registers
+        mtcrf	0x01,rc				// move leftover count to cr7 for LShort16
+        rlwinm	w3,rc,0,28,31		// move last 0-15 byte count to w3
+        mtctr	r0					// set up loop count
+        cmpwi	cr6,w3,0			// set cr6 on leftover byte count
+        oris	w1,rv,0xFF00		// we use v0-v7
+        rlwinm.	r0,rc,28,30,31		// get number of quadword leftovers (0-3) and set cr0
+        mtspr	vrsave,w1			// update mask
+        li		c16,16				// get constants used in ldvx/stvx
+        li		c32,32
+        li		c48,48
+        li		c96,96
+        li		c128,128
+        bne		cr5,LForwardVecUnal	// handle unaligned operands
+        b		1f
+
+        .align	4
+1:        							// loop over 64-byte chunks
+        dcbt	c96,rs
+        dcbt	c128,rs
+        lvx		v1,0,rs
+        lvx		v2,c16,rs
+        lvx		v3,c32,rs
+        lvx		v4,c48,rs
+        addi	rs,rs,64
+        dcba	0,rd				// patched to NOP on some machines
+        stvx	v1,0,rd
+        stvx	v2,c16,rd
+        dcba	c32,rd				// patched to NOP on some machines
+        stvx	v3,c32,rd
+        stvx	v4,c48,rd
+        addi	rd,rd,64
+        bdnz	1b
+                
+        beq		4f					// no leftover quadwords
+        mtctr	r0
+3:									// loop over remaining quadwords (1-3)
+        lvx		v1,0,rs
+        addi	rs,rs,16
+        stvx	v1,0,rd
+        addi	rd,rd,16
+        bdnz	3b
+4:
+        mtspr	vrsave,rv			// restore bitmap of live vr's
+        bne		cr6,LShort16		// handle last 0-15 bytes if any
+        blr
+        
+
+// Long, forward, unaligned vector loop.
+
+LForwardVecUnal:
+        lvsl	vp,0,rs				// get permute vector to shift left
+        lvx		v1,0,rs				// prefetch 1st source quadword
+        b		1f
+
+        .align	4					// align inner loops
+1:									// loop over 64-byte chunks
+        lvx		v2,c16,rs
+        dcbt	c96,rs
+        lvx		v3,c32,rs
+        dcbt	c128,rs
+        lvx		v4,c48,rs
+        addi	rs,rs,64
+        vperm	vw,v1,v2,vp
+        lvx		v1,0,rs
+        vperm	vx,v2,v3,vp
+        dcba	0,rd				// patched to NOP on some machines
+        stvx	vw,0,rd
+        vperm	vy,v3,v4,vp
+        stvx	vx,c16,rd
+        vperm	vw,v4,v1,vp
+        dcba	c32,rd				// patched to NOP on some machines
+        stvx	vy,c32,rd
+        stvx	vw,c48,rd
+        addi	rd,rd,64
+        bdnz	1b
+
+        beq-	4f					// no leftover quadwords
+        mtctr	r0
+3:									// loop over remaining quadwords
+        lvx		v2,c16,rs
+        addi	rs,rs,16
+        vperm	vx,v1,v2,vp
+        vor		v1,v2,v2			// v1 <- v2
+        stvx	vx,0,rd
+        addi	rd,rd,16
+        bdnz	3b
+4:
+        mtspr	vrsave,rv			// restore bitmap of live vr's
+        bne		cr6,LShort16		// handle last 0-15 bytes if any
+        blr
+        
+
+// Medium and long, reverse moves.  We use altivec if the operands are long enough,
+// else a lwz/stx loop.
+//		w1 = (rd-rs), used to check for reverse and alignment
+//	   cr7 = bge if long
+
+LMediumReverse:
+        add		rd,rd,rc			// point to end of operands
+        add		rs,rs,rc
+        andi.	w4,rd,0x1F			// w4 <- #bytes to 32-byte align destination
+        rlwinm	w6,rd,0,0x3			// w6 <- #bytes to 4-byte align destination
+        bge		cr7,LLongReverse	// long enough for vectors
+
+// Scalar loop.
+//	    w6 = #bytes to 4-byte align destination
+
+        sub		rc,rc,w6			// decrement length remaining
+        mtxer	w6					// set up count for move
+        sub		rs,rs,w6			// back up ptrs
+        sub		rd,rd,w6
+        srwi	r0,rc,4				// get # 16-byte chunks (>=1)
+        mtcrf	0x01,rc				// set remaining byte count here for LShortReverse16
+        lswx	w1,0,rs				// move w6 bytes to align destination
+        stswx	w1,0,rd
+        mtctr	r0					// set up 16-byte loop
+        b		1f
+        
+        .align	4
+1:									// loop over 16-byte  aligned chunks
+        lwz		w1,-4(rs)
+        lwz		w2,-8(rs)
+        lwz		w3,-12(rs)
+        lwzu	w4,-16(rs)
+        stw		w1,-4(rd)
+        stw		w2,-8(rd)
+        stw		w3,-12(rd)
+        stwu	w4,-16(rd)
+        bdnz	1b
+        
+        b		LShortReverse16
+        
+
+// Reverse vector loops.  First, we must 32-byte align the destination.
+//		w1 = (rd-rs), used to check for reverse and alignment
+//	w4/cr0 = #bytes to 32-byte align destination
+//		rc = long enough for at least one vector loop
+
+LLongReverse:
+        sub		rc,rc,w4			// adjust length
+        mtcrf	0x01,w4				// cr7 <- #bytes to align dest
+        rlwinm	w2,w1,0,0xF			// relatively 16-byte aligned?
+        mtcrf	0x02,w4				// finish moving #bytes to align to cr6 and cr7
+        srwi	r0,rc,6				// get # 64-byte chunks to xfer (>=1)
+        cmpwi	cr5,w2,0			// set cr5 beq if relatively 16-byte aligned
+        beq		LReverseAligned		// dest is already aligned
+        
+// 32-byte align destination.
+
+        bf		31,1f				// byte to move?
+        lbzu 	w1,-1(rs)
+        stbu 	w1,-1(rd)
+1:
+        bf		30,2f				// halfword?
+        lhzu 	w1,-2(rs)
+        sthu 	w1,-2(rd)
+2:
+        bf		29,3f				// word?
+        lwzu 	w1,-4(rs)
+        stwu 	w1,-4(rd)
+3:
+        bf		28,4f				// doubleword?
+        lwz		w1,-4(rs)
+        lwzu	w2,-8(rs)
+        stw		w1,-4(rd)
+        stwu	w2,-8(rd)
+4:	
+        bf		27,LReverseAligned	// quadword?
+        lwz		w1,-4(rs)
+        lwz		w2,-8(rs)
+        lwz		w3,-12(rs)
+        lwzu	w4,-16(rs)
+        stw		w1,-4(rd)
+        stw		w2,-8(rd)
+        stw		w3,-12(rd)
+        stwu	w4,-16(rd)
+
+// Destination is 32-byte aligned.
+//		r0 = count of 64-byte chunks to move (not 0)
+//		rd = 32-byte aligned
+//		rc = bytes remaining
+//	   cr5 = beq if source is 16-byte aligned
+// We set up many registers:
+//	   ctr = number of 64-byte chunks to move
+//	r0/cr0 = leftover QWs to move
+//	   cr7 = low 4 bits of rc (ie, leftover byte count 0-15)
+//	   cr6 = beq if leftover byte count is 0
+//		rv = original value of vrsave
+// cm1 etc = loaded
+        
+LReverseAligned:
+        mfspr	rv,vrsave			// get bitmap of live vector registers
+        mtcrf	0x01,rc				// move leftover count to cr7 for LShort16
+        rlwinm	w3,rc,0,28,31		// move last 0-15 byte count to w3
+        mtctr	r0					// set up loop count
+        cmpwi	cr6,w3,0			// set cr6 on leftover byte count
+        oris	w1,rv,0xFF00		// we use v0-v7
+        rlwinm.	r0,rc,28,30,31		// get number of quadword leftovers (0-3) and set cr0
+        mtspr	vrsave,w1			// update mask
+        li		cm1,-1				// get constants used in ldvx/stvx
+        li		cm17,-17
+        li		cm33,-33
+        li		cm49,-49
+        li		cm97,-97
+        li		cm129,-129        
+        bne		cr5,LReverseVecUnal	// handle unaligned operands
+        b		1f
+      
+        .align	4					// align inner loops
+1:        							// loop over 64-byte chunks
+        dcbt	cm97,rs
+        dcbt	cm129,rs
+        lvx		v1,cm1,rs
+        lvx		v2,cm17,rs
+        lvx		v3,cm33,rs
+        lvx		v4,cm49,rs
+        subi	rs,rs,64
+        stvx	v1,cm1,rd
+        stvx	v2,cm17,rd
+        stvx	v3,cm33,rd
+        stvx	v4,cm49,rd
+        subi	rd,rd,64
+        bdnz	1b
+
+        beq		4f					// no leftover quadwords
+        mtctr	r0
+3:									// loop over remaining quadwords (1-7)
+        lvx		v1,cm1,rs
+        subi	rs,rs,16
+        stvx	v1,cm1,rd
+        subi	rd,rd,16
+        bdnz	3b
+4:
+        mtspr	vrsave,rv			// restore bitmap of live vr's
+        bne		cr6,LShortReverse16	// handle last 0-15 bytes if any
+        blr
+
+
+// Long, reverse, unaligned vector loop.
+
+LReverseVecUnal:
+        lvsl	vp,0,rs				// get permute vector to shift left
+        lvx		v1,cm1,rs			// v1 always looks ahead
+        b		1f
+        
+        .align	4					// align the inner loops
+1:									// loop over 64-byte chunks
+        lvx		v2,cm17,rs
+        dcbt	cm97,rs
+        lvx		v3,cm33,rs
+        dcbt	cm129,rs
+        lvx		v4,cm49,rs
+        subi	rs,rs,64
+        vperm	vw,v2,v1,vp
+        lvx		v1,cm1,rs
+        vperm	vx,v3,v2,vp
+        stvx	vw,cm1,rd
+        vperm	vy,v4,v3,vp
+        stvx	vx,cm17,rd
+        vperm	vw,v1,v4,vp
+        stvx	vy,cm33,rd
+        stvx	vw,cm49,rd
+        subi	rd,rd,64
+        bdnz	1b
+        
+        beq		3f					// no leftover quadwords
+        mtctr	r0
+2:									// loop over 1-3 quadwords
+        lvx		v2,cm17,rs
+        subi	rs,rs,16
+        vperm	vx,v2,v1,vp
+        vor		v1,v2,v2			// v1 <- v2
+        stvx	vx,cm1,rd
+        subi	rd,rd,16
+        bdnz	2b
+3:
+        mtspr	vrsave,rv			// restore bitmap of live vr's
+        bne		cr6,LShortReverse16	// handle last 0-15 bytes iff any
+        blr
+
+        COMMPAGE_DESCRIPTOR(bcopy_g4,_COMM_PAGE_BCOPY,kHasAltivec,k64Bit,kCommPageDCBA)
diff --git a/osfmk/ppc/commpage/bigcopy_970.s b/osfmk/ppc/commpage/bigcopy_970.s
new file mode 100644
index 000000000..fa9e1245a
--- /dev/null
+++ b/osfmk/ppc/commpage/bigcopy_970.s
@@ -0,0 +1,499 @@
+/*
+ * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ * 
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ * 
+ * @APPLE_LICENSE_HEADER_END@
+ */
+/* ====================================
+ * Very Long Operand BCOPY for Mac OS X
+ * ====================================
+ *
+ * Version of 6/11/2003, tuned for the IBM 970.  This is for operands at
+ * least several pages long.  It is called from bcopy()/memcpy()/memmove().
+ *
+ * We use the following additional strategies not used by the shorter
+ * operand paths.  Mostly, we try to optimize for memory bandwidth:
+ *	1. Use DCBZ128 to avoid reading destination lines.  Because this code
+ *     resides on the commmpage, it can use a private interface with the
+ *     kernel to minimize alignment exceptions if the destination is
+ *     uncached.  The kernel will clear cr7 whenever it emulates a DCBZ or
+ *     DCBZ128 on the commpage.  Thus we take at most one exception per call,
+ *     which is amortized across the very long operand.
+ *	2. Copy larger chunks per iteration to minimize R/W bus turnaround
+ *     and maximize DRAM page locality (opening a new page is expensive.)
+ *  3. Touch in one source chunk ahead with DCBT.  This is probably the
+ *     least important change, and probably only helps restart the
+ *     hardware stream at the start of each source page.
+ *
+ * Register usage.  Note the rather delicate way we assign multiple uses
+ * to the same register.  Beware.
+ *   r0  = temp (NB: cannot use r0 for any constant such as "c16")
+ *   r3  = not used, as memcpy and memmove return 1st parameter as a value
+ *   r4  = source ptr ("rs")
+ *   r5  = count of bytes to move ("rc")
+ *   r6  = constant 16 ("c16")
+ *   r7  = constant 32 (""c32")
+ *   r8  = constant 48 (""c48")
+ *   r9  = constant 128 (""c128")
+ *   r10 = vrsave ("rv")
+ *   r11 = constant 256 (""c256")
+ *   r12 = destination ptr ("rd")
+ *	 r13 = constant 384 (""c384")
+ *	 r14 = temp ("rx")
+ *	 r15 = temp ("rt")
+ */
+#define rs	r4
+#define rd	r12
+#define rc	r5
+#define	rv	r10
+#define	rx	r14
+#define	rt	r15
+
+#define c16	r6
+#define c32	r7
+#define c48	r8
+#define	c128	r9
+#define	c256	r11
+#define	c384	r13
+
+// Offsets within the "red zone" (which is 224 bytes long):
+
+#define rzR13	-8
+#define rzR14	-12
+#define rzR15	-16
+#define rzV20	-32
+#define rzV21	-48
+#define rzV22	-64
+#define rzV23	-80
+#define rzV24	-96
+#define rzV25	-112
+#define rzV26	-128
+#define rzV27	-144
+#define rzV28	-160
+#define rzV29	-176
+#define rzV30	-192
+#define rzV31	-208
+
+
+#include <sys/appleapiopts.h>
+#include <ppc/asm.h>
+#include <machine/cpu_capabilities.h>
+#include <machine/commpage.h>
+
+        .text
+        .globl	EXT(bigcopy_970)
+
+
+// Entry point.  This is a subroutine of bcopy().  When called:
+//	r4 = source ptr (aka "rs")
+// r12 = dest ptr (aka "rd")
+//	r5 = length (>= 16K bytes) (aka "rc")
+// 
+// We only do "forward" moves, ie non-overlapping or toward 0.
+//
+// We return with non-volatiles and r3 preserved.
+
+        .align 	5
+bigcopy_970:
+        stw		r13,rzR13(r1)		// spill non-volatile regs we use to redzone
+        stw		r14,rzR14(r1)
+        stw		r15,rzR15(r1)
+        li		r0,rzV20
+        neg		rt,rd				// start to cache-line-align destination
+        stvx	v20,r1,r0			// we use all 32 VRs
+        li		r0,rzV21
+        stvx	v21,r1,r0
+        li		r0,rzV22
+        stvx	v22,r1,r0
+        li		r0,rzV23
+        stvx	v23,r1,r0
+        li		r0,rzV24
+        andi.	rt,rt,127			// get #bytes to 128-byte align
+        stvx	v24,r1,r0
+        li		r0,rzV25
+        stvx	v25,r1,r0
+        li		r0,rzV26
+        sub		rc,rc,rt			// adjust length by #bytes to align destination
+        stvx	v26,r1,r0
+        li		r0,rzV27
+        stvx	v27,r1,r0
+        li		r0,rzV28
+        mtctr	rt					// #bytes to align destination
+        stvx	v28,r1,r0
+        li		r0,rzV29
+        stvx	v29,r1,r0
+        li		r0,rzV30
+        stvx	v30,r1,r0
+        li		r0,rzV31
+        stvx	v31,r1,r0
+        beq		2f					// dest already 128-byte aligned
+        b		1f
+
+
+// Cache-line-align destination.
+
+        .align	5
+1:
+        lbz		r0,0(rs)
+        addi	rs,rs,1
+        stb		r0,0(rd)
+        addi	rd,rd,1
+        bdnz	1b
+
+
+// Is source 16-byte aligned?  Load constant offsets.
+
+2:
+        andi.	r0,rs,15			// check source alignment
+        mfspr	rv,vrsave			// save caller's bitmask
+        li		r0,-1				// we use all 32 VRs
+        li		c16,16				// load the constant offsets for x-form ops
+        li		c32,32
+        li		c48,48
+        li		c128,128
+        li		c256,256
+        li		c384,384
+        mtspr	vrsave,r0
+
+// NB: the kernel clears cr7 if it emulates a dcbz128 on the commpage,
+// and we dcbz only if cr7 beq is set.  We check to be sure the dcbz's
+// won't zero source bytes before we load them, since we zero before
+// loading as this is faster than zeroing after loading and before storing.
+
+        cmpw	cr7,r0,r0			// initialize cr7 beq to use dcbz128
+        sub		rt,rs,rd			// get (rs-rd)
+        cmplwi	cr1,rt,512			// are we moving down less than 512 bytes?
+        
+// Start fetching in source cache lines.
+
+        dcbt	c128,rs				// first line already touched in
+        dcbt	c256,rs
+        dcbt	c384,rs
+        
+        bge++	cr1,3f				// skip if not moving down less than 512 bytes
+        cmpw	cr7,c16,c32			// cannot dcbz since it would zero source bytes
+3:
+        beq		LalignedLoop		// handle aligned sources
+        lvsl	v0,0,rs				// get permute vector for left shift
+        lvxl	v1,0,rs				// prime the loop
+        b		LunalignedLoop		// enter unaligned loop
+
+
+// Main loop for unaligned operands.  We loop over 384-byte chunks (3 cache lines)
+// since we need a few VRs for permuted destination QWs and the permute vector.
+
+        .align	5
+LunalignedLoop:
+        subi	rc,rc,384			// decrement byte count
+        addi	rx,rs,384			// get address of next chunk
+        lvxl	v2,c16,rs
+        lvxl	v3,c32,rs
+        bne--	cr7,1f				// skip dcbz's if cr7 beq has been turned off by kernel
+        dcbz128	0,rd				// (also skip if moving down less than 512 bytes)
+        bne--	cr7,1f				// catch it first time through
+        dcbz128	c128,rd
+        dcbz128	c256,rd
+1:
+        addi	rt,rs,64
+        dcbt	0,rx				// touch in next chunk
+        dcbt	c128,rx
+        dcbt	c256,rx
+        lvxl	v4,c48,rs
+        addi	rs,rs,128
+        lvxl	v5,0,rt
+        cmplwi	rc,384				// another chunk to go?
+        lvxl	v6,c16,rt
+        lvxl	v7,c32,rt
+        lvxl	v8,c48,rt
+        addi	rt,rs,64
+        vperm	v25,v1,v2,v0
+        lvxl	v9,0,rs
+        lvxl	v10,c16,rs
+        vperm	v26,v2,v3,v0
+        lvxl	v11,c32,rs
+        lvxl	v12,c48,rs
+        vperm	v27,v3,v4,v0
+        addi	rs,rs,128
+        lvxl	v13,0,rt
+        lvxl	v14,c16,rt
+        vperm	v28,v4,v5,v0
+        lvxl	v15,c32,rt
+        lvxl	v16,c48,rt
+        vperm	v29,v5,v6,v0
+        addi	rt,rs,64
+        lvxl	v17,0,rs
+        lvxl	v18,c16,rs
+        vperm	v30,v6,v7,v0
+        lvxl	v19,c32,rs
+        lvxl	v20,c48,rs
+        vperm	v31,v7,v8,v0
+        addi	rs,rs,128
+        lvxl	v21,0,rt
+        lvxl	v22,c16,rt
+        vperm	v2,v8,v9,v0
+        lvxl	v23,c32,rt
+        lvxl	v24,c48,rt
+        vperm	v3,v9,v10,v0
+        lvx		v1,0,rs				// get 1st qw of next chunk
+        vperm	v4,v10,v11,v0
+        
+        addi	rt,rd,64
+        stvxl	v25,0,rd
+        stvxl	v26,c16,rd
+        vperm	v5,v11,v12,v0
+        stvxl	v27,c32,rd
+        stvxl	v28,c48,rd
+        vperm	v6,v12,v13,v0
+        addi	rd,rd,128
+        stvxl	v29,0,rt
+        stvxl	v30,c16,rt
+        vperm	v7,v13,v14,v0
+        stvxl	v31,c32,rt
+        stvxl	v2,c48,rt
+        vperm	v8,v14,v15,v0
+        addi	rt,rd,64
+        stvxl	v3,0,rd
+        stvxl	v4,c16,rd
+        vperm	v9,v15,v16,v0
+        stvxl	v5,c32,rd
+        stvxl	v6,c48,rd
+        vperm	v10,v16,v17,v0
+        addi	rd,rd,128
+        stvxl	v7,0,rt
+        vperm	v11,v17,v18,v0
+        stvxl	v8,c16,rt
+        stvxl	v9,c32,rt
+        vperm	v12,v18,v19,v0
+        stvxl	v10,c48,rt
+        addi	rt,rd,64
+        vperm	v13,v19,v20,v0
+        stvxl	v11,0,rd
+        stvxl	v12,c16,rd
+        vperm	v14,v20,v21,v0
+        stvxl	v13,c32,rd
+        vperm	v15,v21,v22,v0
+        stvxl	v14,c48,rd
+        vperm	v16,v22,v23,v0
+        addi	rd,rd,128
+        stvxl	v15,0,rt
+        vperm	v17,v23,v24,v0
+        stvxl	v16,c16,rt
+        vperm	v18,v24,v1,v0
+        stvxl	v17,c32,rt
+        stvxl	v18,c48,rt
+        bge++	LunalignedLoop		// loop if another 384 bytes to go
+
+// End of unaligned main loop.  Handle up to 384 leftover bytes.
+
+        srwi.	r0,rc,5				// get count of 32-byte chunks remaining
+        beq		Ldone				// none
+        rlwinm	rc,rc,0,0x1F		// mask count down to 0..31 leftover bytes
+        mtctr	r0
+1:									// loop over 32-byte chunks
+        lvx		v2,c16,rs
+        lvx		v3,c32,rs
+        addi	rs,rs,32
+        vperm	v8,v1,v2,v0
+        vperm	v9,v2,v3,v0
+        vor		v1,v3,v3			// v1 <- v3
+        stvx	v8,0,rd
+        stvx	v9,c16,rd
+        addi	rd,rd,32
+        bdnz	1b
+        
+        b		Ldone
+        
+        
+// Aligned loop.  Destination is 128-byte aligned, and source is 16-byte
+// aligned.  Loop over 512-byte chunks (4 cache lines.)
+
+        .align	5
+LalignedLoop:
+        subi	rc,rc,512			// decrement count
+        addi	rx,rs,512			// address of next chunk
+        lvxl	v1,0,rs
+        lvxl	v2,c16,rs
+        bne--	cr7,1f				// skip dcbz's if cr7 beq has been turned off by kernel
+        dcbz128	0,rd				// (also skip if moving down less than 512 bytes)
+        bne--	cr7,1f				// catch it first time through
+        dcbz128	c128,rd
+        dcbz128	c256,rd
+        dcbz128	c384,rd
+1:
+        addi	rt,rs,64
+        dcbt	0,rx				// touch in next chunk
+        dcbt	c128,rx
+        dcbt	c256,rx
+        dcbt	c384,rx
+        lvxl	v3,c32,rs
+        lvxl	v4,c48,rs
+        addi	rs,rs,128
+        lvxl	v5,0,rt
+        cmplwi	rc,512				// another chunk to go?
+        lvxl	v6,c16,rt
+        lvxl	v7,c32,rt
+        lvxl	v8,c48,rt
+        addi	rt,rs,64
+        lvxl	v9,0,rs
+        lvxl	v10,c16,rs
+        lvxl	v11,c32,rs
+        lvxl	v12,c48,rs
+        addi	rs,rs,128
+        lvxl	v13,0,rt
+        lvxl	v14,c16,rt
+        lvxl	v15,c32,rt
+        lvxl	v16,c48,rt
+        addi	rt,rs,64
+        lvxl	v17,0,rs
+        lvxl	v18,c16,rs
+        lvxl	v19,c32,rs
+        lvxl	v20,c48,rs
+        addi	rs,rs,128
+        lvxl	v21,0,rt
+        lvxl	v22,c16,rt
+        lvxl	v23,c32,rt
+        lvxl	v24,c48,rt
+        addi	rt,rs,64
+        lvxl	v25,0,rs
+        lvxl	v26,c16,rs
+        lvxl	v27,c32,rs
+        lvxl	v28,c48,rs
+        addi	rs,rs,128
+        lvxl	v29,0,rt
+        lvxl	v30,c16,rt
+        lvxl	v31,c32,rt
+        lvxl	v0,c48,rt
+
+        addi	rt,rd,64
+        stvxl	v1,0,rd
+        stvxl	v2,c16,rd
+        stvxl	v3,c32,rd
+        stvxl	v4,c48,rd
+        addi	rd,rd,128
+        stvxl	v5,0,rt
+        stvxl	v6,c16,rt
+        stvxl	v7,c32,rt
+        stvxl	v8,c48,rt
+        addi	rt,rd,64
+        stvxl	v9,0,rd
+        stvxl	v10,c16,rd
+        stvxl	v11,c32,rd
+        stvxl	v12,c48,rd
+        addi	rd,rd,128
+        stvxl	v13,0,rt
+        stvxl	v14,c16,rt
+        stvxl	v15,c32,rt
+        stvxl	v16,c48,rt
+        addi	rt,rd,64
+        stvxl	v17,0,rd
+        stvxl	v18,c16,rd
+        stvxl	v19,c32,rd
+        stvxl	v20,c48,rd
+        addi	rd,rd,128
+        stvxl	v21,0,rt
+        stvxl	v22,c16,rt
+        stvxl	v23,c32,rt
+        stvxl	v24,c48,rt
+        addi	rt,rd,64
+        stvxl	v25,0,rd
+        stvxl	v26,c16,rd
+        stvxl	v27,c32,rd
+        stvxl	v28,c48,rd
+        addi	rd,rd,128
+        stvxl	v29,0,rt
+        stvxl	v30,c16,rt
+        stvxl	v31,c32,rt
+        stvxl	v0,c48,rt
+        bge++	LalignedLoop		// loop if another 512 bytes to go
+
+// End of aligned main loop.  Handle up to 511 leftover bytes.
+
+        srwi.	r0,rc,5				// get count of 32-byte chunks remaining
+        beq		Ldone				// none
+        rlwinm	rc,rc,0,0x1F		// mask count down to 0..31 leftover bytes
+        mtctr	r0
+1:									// loop over 32-byte chunks
+        lvx		v1,0,rs
+        lvx		v2,c16,rs
+        addi	rs,rs,32
+        stvx	v1,0,rd
+        stvx	v2,c16,rd
+        addi	rd,rd,32
+        bdnz	1b
+
+
+// Done, except for 0..31 leftovers at end.  Restore non-volatiles.
+//	rs = source ptr
+//	rd = dest ptr
+//	rc = count (0..31)
+//	rv = caller's vrsave
+
+Ldone:
+        cmpwi	rc,0				// any leftover bytes?
+        lwz		r13,rzR13(r1)		// restore non-volatiles from redzone
+        lwz		r14,rzR14(r1)
+        lwz		r15,rzR15(r1)
+        li		r0,rzV20
+        lvx		v20,r1,r0
+        li		r0,rzV21
+        lvx		v21,r1,r0
+        li		r0,rzV22
+        lvx		v22,r1,r0
+        li		r0,rzV23
+        lvx		v23,r1,r0
+        li		r0,rzV24
+        lvx		v24,r1,r0
+        li		r0,rzV25
+        lvx		v25,r1,r0
+        li		r0,rzV26
+        lvx		v26,r1,r0
+        li		r0,rzV27
+        lvx		v27,r1,r0
+        li		r0,rzV28
+        lvx		v28,r1,r0
+        li		r0,rzV29
+        lvx		v29,r1,r0
+        li		r0,rzV30
+        lvx		v30,r1,r0
+        li		r0,rzV31
+        lvx		v31,r1,r0
+        mtspr	vrsave,rv			// restore caller's bitmask
+        beqlr						// done if no leftover bytes
+        
+
+// Handle 1..31 leftover bytes at end.
+
+        mtctr	rc					// set up loop count
+        b		1f
+        
+        .align	5
+1:
+        lbz		r0,0(rs)
+        addi	rs,rs,1
+        stb		r0,0(rd)
+        addi	rd,rd,1
+        bdnz	1b
+        
+        blr
+
+
+        COMMPAGE_DESCRIPTOR(bigcopy_970,_COMM_PAGE_BIGCOPY,0,0,0) // load on all machines for now
+
diff --git a/osfmk/ppc/commpage/bzero_128.s b/osfmk/ppc/commpage/bzero_128.s
new file mode 100644
index 000000000..f97db603d
--- /dev/null
+++ b/osfmk/ppc/commpage/bzero_128.s
@@ -0,0 +1,156 @@
+/*
+ * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ * 
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ * 
+ * @APPLE_LICENSE_HEADER_END@
+ */
+
+#define	ASSEMBLER
+#include <sys/appleapiopts.h>
+#include <ppc/asm.h>
+#include <machine/cpu_capabilities.h>
+#include <machine/commpage.h>
+
+        .text
+        .align	2
+        .globl	EXT(bzero_128)
+        
+
+// *********************
+// * B Z E R O _ 1 2 8 *
+// *********************
+//
+// For 64-bit processors with a 128-byte cache line.
+//
+// Register use:
+//		r0 = zero
+//		r3 = original ptr, not changed since memset returns it
+//		r4 = count of bytes to set
+//		r9 = working operand ptr
+// We do not touch r2 and r10-r12, which some callers depend on.
+
+        .align	5
+bzero_128:						// void	bzero(void *b, size_t len);
+        cmplwi	cr7,r4,128		// too short for DCBZ128?
+        li		r0,0			// get a 0
+        neg		r5,r3			// start to compute #bytes to align
+        mr		r9,r3			// make copy of operand ptr (can't change r3)
+        blt		cr7,Ltail		// length < 128, too short for DCBZ
+
+// At least 128 bytes long, so compute alignment and #cache blocks.
+
+        andi.	r5,r5,0x7F		// r5 <-  #bytes to 128-byte align
+        sub		r4,r4,r5		// adjust length
+        srwi	r8,r4,7			// r8 <- 128-byte chunks
+        rlwinm	r4,r4,0,0x7F	// mask length down to remaining bytes
+        mtctr	r8				// set up loop count
+        beq		Ldcbz			// skip if already aligned (r8!=0)
+        
+// 128-byte align
+
+        mtcrf	0x01,r5			// start to move #bytes to align to cr6 and cr7
+        cmpwi	cr1,r8,0		// any 128-byte cache lines to 0?
+        mtcrf	0x02,r5
+        
+        bf		31,1f			// byte?
+        stb		r0,0(r9)
+        addi	r9,r9,1
+1:
+        bf		30,2f			// halfword?
+        sth		r0,0(r9)
+        addi	r9,r9,2
+2:
+        bf		29,3f			// word?
+        stw		r0,0(r9)
+        addi	r9,r9,4
+3:
+        bf		28,4f			// doubleword?
+        std		r0,0(r9)
+        addi	r9,r9,8
+4:
+        bf		27,5f			// quadword?
+        std		r0,0(r9)
+        std		r0,8(r9)
+        addi	r9,r9,16
+5:
+        bf		26,6f			// 32-byte chunk?
+        std		r0,0(r9)
+        std		r0,8(r9)
+        std		r0,16(r9)
+        std		r0,24(r9)
+        addi	r9,r9,32
+6:
+        bf		25,7f			// 64-byte chunk?
+        std		r0,0(r9)
+        std		r0,8(r9)
+        std		r0,16(r9)
+        std		r0,24(r9)
+        std		r0,32(r9)
+        std		r0,40(r9)
+        std		r0,48(r9)
+        std		r0,56(r9)
+        addi	r9,r9,64
+7:
+        beq		cr1,Ltail		// no chunks to dcbz128
+
+// Loop doing 128-byte version of DCBZ instruction.
+// NB: if the memory is cache-inhibited, the kernel will clear cr7
+// when it emulates the alignment exception.  Eventually, we may want
+// to check for this case.
+
+Ldcbz:
+        dcbz128	0,r9			// zero another 32 bytes
+        addi	r9,r9,128
+        bdnz	Ldcbz
+
+// Store trailing bytes.
+//		r0 = 0
+//		r4 = count
+//		r9 = ptr
+
+Ltail:
+        srwi.	r5,r4,4			// r5 <- 16-byte chunks to 0
+        mtcrf	0x01,r4			// remaining byte count to cr7
+        mtctr	r5
+        beq		2f				// skip if no 16-byte chunks
+1:								// loop over 16-byte chunks
+        std		r0,0(r9)
+        std		r0,8(r9)
+        addi	r9,r9,16
+        bdnz	1b
+2:
+        bf		28,4f			// 8-byte chunk?
+        std		r0,0(r9)
+        addi	r9,r9,8
+4:
+        bf		29,5f			// word?
+        stw		r0,0(r9)
+        addi	r9,r9,4
+5:
+        bf		30,6f			// halfword?
+        sth		r0,0(r9)
+        addi	r9,r9,2
+6:
+        bflr	31				// byte?
+        stb		r0,0(r9)
+        blr
+
+        COMMPAGE_DESCRIPTOR(bzero_128,_COMM_PAGE_BZERO,kCache128+k64Bit,0,kCommPageMTCRF)
diff --git a/osfmk/ppc/commpage/bzero_32.s b/osfmk/ppc/commpage/bzero_32.s
new file mode 100644
index 000000000..820120061
--- /dev/null
+++ b/osfmk/ppc/commpage/bzero_32.s
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ * 
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ * 
+ * @APPLE_LICENSE_HEADER_END@
+ */
+
+#define	ASSEMBLER
+#include <sys/appleapiopts.h>
+#include <ppc/asm.h>
+#include <machine/cpu_capabilities.h>
+#include <machine/commpage.h>
+
+        .text
+        .align	2
+        .globl	EXT(bzero_32)
+        
+
+// *******************
+// * B Z E R O _ 3 2 *
+// *******************
+//
+// For 32-bit processors with a 32-byte cache line.
+//
+// Register use:
+//		r0 = zero
+//		r3 = original ptr, not changed since memset returns it
+//		r4 = count of bytes to set
+//		r9 = working operand ptr
+// We do not touch r2 and r10-r12, which some callers depend on.
+
+        .align	5
+bzero_32:						// void	bzero(void *b, size_t len);
+        cmplwi	cr7,r4,32		// too short for DCBZ?
+        li		r0,0			// get a 0
+        neg		r5,r3			// start to compute #bytes to align
+        mr		r9,r3			// make copy of operand ptr (can't change r3)
+        blt		cr7,Ltail		// length < 32, too short for DCBZ
+
+// At least 32 bytes long, so compute alignment and #cache blocks.
+
+        andi.	r5,r5,0x1F		// r5 <-  #bytes to 32-byte align
+        sub		r4,r4,r5		// adjust length
+        srwi	r8,r4,5			// r8 <- #32-byte chunks
+        cmpwi	cr1,r8,0		// any chunks?
+        mtctr	r8				// set up loop count
+        beq		1f				// skip if already 32-byte aligned (r8!=0)
+        
+// 32-byte align.  We just store 32 0s, rather than test and use conditional
+// branches.  We've already stored the first few bytes above.
+
+        stw		r0,0(r9)
+        stw		r0,4(r9)
+        stw		r0,8(r9)
+        stw		r0,12(r9)
+        stw		r0,16(r9)
+        stw		r0,20(r9)
+        stw		r0,24(r9)
+        stw		r0,28(r9)
+        add		r9,r9,r5		// now rp is 32-byte aligned
+        beq		cr1,Ltail		// skip if no 32-byte chunks
+
+// Loop doing 32-byte version of DCBZ instruction.
+// NB: we take alignment exceptions on cache-inhibited memory.
+// The kernel could be changed to zero cr7 when emulating a
+// dcbz (as it does on 64-bit processors), so we could avoid all
+// but the first.
+
+1:
+        andi.	r5,r4,0x1F		// will there be trailing bytes?
+        b		2f
+        .align	4
+2:
+        dcbz	0,r9			// zero another 32 bytes
+        addi	r9,r9,32
+        bdnz	2b
+        
+        beqlr					// no trailing bytes
+
+// Store trailing bytes.
+
+Ltail:
+        andi.	r5,r4,0x10		// test bit 27 separately
+        mtcrf	0x01,r4			// remaining byte count to cr7
+        
+        beq		2f				// no 16-byte chunks
+        stw		r0,0(r9)
+        stw		r0,4(r9)
+        stw		r0,8(r9)
+        stw		r0,12(r9)
+        addi	r9,r9,16
+2:
+        bf		28,4f			// 8-byte chunk?
+        stw		r0,0(r9)
+        stw		r0,4(r9)
+        addi	r9,r9,8
+4:
+        bf		29,5f			// word?
+        stw		r0,0(r9)
+        addi	r9,r9,4
+5:
+        bf		30,6f			// halfword?
+        sth		r0,0(r9)
+        addi	r9,r9,2
+6:
+        bflr	31				// byte?
+        stb		r0,0(r9)
+        blr
+
+        COMMPAGE_DESCRIPTOR(bzero_32,_COMM_PAGE_BZERO,kCache32,0,0)
diff --git a/osfmk/ppc/commpage/cacheflush.s b/osfmk/ppc/commpage/cacheflush.s
new file mode 100644
index 000000000..a556ad6c2
--- /dev/null
+++ b/osfmk/ppc/commpage/cacheflush.s
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ * 
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ * 
+ * @APPLE_LICENSE_HEADER_END@
+ */
+
+#define	ASSEMBLER
+#include <sys/appleapiopts.h>
+#include <ppc/asm.h>					// EXT, LEXT
+#include <machine/cpu_capabilities.h>
+#include <machine/commpage.h>
+
+        .text
+        .align	2
+        .globl	EXT(commpage_flush_dcache)
+        .globl	EXT(commpage_flush_icache)
+
+
+// *********************************************
+// * C O M M P A G E _ F L U S H _ D C A C H E *
+// *********************************************
+//
+//	r3 = ptr to 1st byte to flush
+//	r4 = length to flush (may be 0)
+
+commpage_flush_dcache:
+        cmpwi	r4,0			// length 0?
+        lhz		r5,_COMM_PAGE_CACHE_LINESIZE(0)
+        subi	r9,r5,1			// get (linesize-1)
+        and		r0,r3,r9		// get offset within line of 1st byte
+        add		r4,r4,r0		// adjust length so we flush them all
+        add		r4,r4,r9		// round length up...
+        andc	r4,r4,r9		// ...to multiple of cache lines
+        beqlr--					// length was 0, so exit
+1:
+        sub.	r4,r4,r5		// more to go?
+        dcbf	0,r3			// flush another line
+        add		r3,r3,r5
+        bne		1b
+        sync					// make sure lines are flushed before we return
+        blr
+        
+        COMMPAGE_DESCRIPTOR(commpage_flush_dcache,_COMM_PAGE_FLUSH_DCACHE,0,0,0)	// matches all CPUs
+        
+        
+// *********************************************
+// * C O M M P A G E _ F L U S H _ I C A C H E *
+// *********************************************
+//
+//	r3 = ptr to 1st byte to flush
+//	r4 = length to flush (may be 0)
+
+commpage_flush_icache:
+        cmpwi	r4,0			// length 0?
+        lhz		r5,_COMM_PAGE_CACHE_LINESIZE(0)
+        subi	r9,r5,1			// get (linesize-1)
+        and		r0,r3,r9		// get offset within line of 1st byte
+        add		r4,r4,r0		// adjust length so we flush them all
+        mr		r7,r3			// copy ptr
+        add		r4,r4,r9		// round length up...
+        andc	r4,r4,r9		// ...to multiple of cache lines
+        mr		r6,r4			// copy length
+        beqlr--					// length was 0, so exit
+1:
+        sub.	r4,r4,r5		// more to go?
+        dcbf	0,r3			// flush another line
+        add		r3,r3,r5
+        bne		1b
+        sync					// make sure lines are flushed
+2:
+        sub.	r6,r6,r5		// more to go?
+        icbi	0,r7
+        add		r7,r7,r5
+        bne		2b
+        isync					// make sure we haven't prefetched old instructions
+        
+        blr
+
+        COMMPAGE_DESCRIPTOR(commpage_flush_icache,_COMM_PAGE_FLUSH_ICACHE,0,0,0)	// matches all CPUs
+
+        
diff --git a/osfmk/ppc/commpage/commpage.c b/osfmk/ppc/commpage/commpage.c
new file mode 100644
index 000000000..1c67e50fe
--- /dev/null
+++ b/osfmk/ppc/commpage/commpage.c
@@ -0,0 +1,492 @@
+/*
+ * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ * 
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ * 
+ * @APPLE_LICENSE_HEADER_END@
+ */
+
+/*
+ *	Here's what to do if you want to add a new routine to the comm page:
+ *
+ *		1. Add a definition for it's address in osfmk/ppc/cpu_capabilities.h,
+ *		   being careful to reserve room for future expansion.
+ *
+ *		2. Write one or more versions of the routine, each with it's own
+ *		   commpage_descriptor.  The tricky part is getting the "special",
+ *		   "musthave", and "canthave" fields right, so that exactly one
+ *		   version of the routine is selected for every machine.
+ *		   The source files should be in osfmk/ppc/commpage/.
+ *
+ *		3. Add a ptr to your new commpage_descriptor(s) in the "routines"
+ *		   array in commpage_populate().  Of course, you'll also have to
+ *		   declare them "extern" in commpage_populate().
+ *
+ *		4. Write the code in Libc to use the new routine.
+ */
+
+#include <mach/mach_types.h>
+#include <mach/machine.h>
+#include <ppc/exception.h>
+#include <ppc/machine_routines.h>
+#include <machine/cpu_capabilities.h>
+#include <machine/commpage.h>
+#include <machine/pmap.h>
+#include <vm/vm_kern.h>
+#include <mach/vm_map.h>
+
+static	char	*next = NULL;			// next available byte in comm page
+static	int		cur_routine = 0;		// comm page address of "current" routine
+static	int		matched;				// true if we've found a match for "current" routine
+
+int		_cpu_capabilities = 0;			// define the capability vector
+
+char	*commPagePtr = NULL;			// virtual address of comm page in kernel map
+
+
+/* Allocate the commpages and add to the shared submap created by vm:
+ * 	1. allocate pages in the kernel map (RW)
+ *	2. wire them down
+ *	3. make a memory entry out of them
+ *	4. map that entry into the shared comm region map (R-only)
+ */
+static	void*
+commpage_allocate( void )
+{
+    extern	vm_map_t	com_region_map;				// the shared submap, set up in vm init
+    vm_offset_t			kernel_addr;				// address of commpage in kernel map
+    vm_offset_t			zero = 0;
+    vm_size_t			size = _COMM_PAGE_AREA_USED;	// size actually populated
+    ipc_port_t			handle;
+    
+    if (com_region_map == NULL)
+        panic("commpage map is null");
+    
+    if (vm_allocate(kernel_map,&kernel_addr,_COMM_PAGE_AREA_USED,VM_FLAGS_ANYWHERE))
+        panic("cannot allocate commpage");
+        
+    if (vm_map_wire(kernel_map,kernel_addr,kernel_addr+_COMM_PAGE_AREA_USED,VM_PROT_DEFAULT,FALSE))
+        panic("cannot wire commpage");
+    
+    if (mach_make_memory_entry(	kernel_map,			// target map
+                                &size,				// size
+                                kernel_addr,		// offset (address in kernel map)
+                                VM_PROT_DEFAULT,	// map it RW
+                                &handle,			// this is the object handle we get
+                                NULL ))				// parent_entry
+        panic("cannot make entry for commpage");
+    
+    if (vm_map_64(	com_region_map,					// target map (shared submap)
+                    &zero,							// address (map into 1st page in submap)
+                    _COMM_PAGE_AREA_USED,			// size
+                    0,								// mask
+                    VM_FLAGS_FIXED,					// flags (it must be 1st page in submap)
+                    handle,							// port is the memory entry we just made
+                    0,								// offset (map 1st page in memory entry)
+                    FALSE,							// copy
+                    VM_PROT_READ,					// cur_protection (R-only in user map)
+                    VM_PROT_READ,					// max_protection
+                    VM_INHERIT_SHARE ))				// inheritance
+        panic("cannot map commpage");
+        
+    ipc_port_release(handle);
+        
+    return (void*) kernel_addr;						// return address in kernel map
+}
+
+
+/* Get address (in kernel map) of a commpage field. */
+
+static	void*
+commpage_addr_of(
+    int 	addr_at_runtime	)
+{
+    return	(void*) (commPagePtr + addr_at_runtime - _COMM_PAGE_BASE_ADDRESS);
+}
+
+
+/* Determine number of CPUs on this system.  We cannot rely on
+ * machine_info.max_cpus this early in the boot.
+ */
+static int
+commpage_cpus( void )
+{
+    int		cpus;
+    
+    cpus = ml_get_max_cpus();			// NB: this call can block
+    
+    if (cpus == 0)
+        panic("commpage cpus==0");
+    if (cpus > 0xFF)
+        cpus = 0xFF;
+    
+    return	cpus;
+}
+
+
+/* Initialize kernel version of _cpu_capabilities vector (used by KEXTs.) */
+
+static void
+commpage_init_cpu_capabilities( void )
+{
+    struct per_proc_info *pp;
+    procFeatures	*pfp;
+    int	cpus;
+    int	available;
+
+    pp = per_proc_info;					// use CPU 0's per-proc
+    pfp = &pp->pf;						// point to features in per-proc
+    available = pfp->Available;
+
+    // If AltiVec is disabled make sure it is not reported as available.
+    if ((available & pfAltivec) == 0) {
+        _cpu_capabilities &= ~kHasAltivec;
+    }
+
+    if (_cpu_capabilities & kDcbaAvailable) { 		// if this processor has DCBA, time it...
+        _cpu_capabilities |= commpage_time_dcba();	// ...and set kDcbaRecomended if it helps.
+    }
+
+    cpus = commpage_cpus();				// how many CPUs do we have
+    if (cpus == 1) _cpu_capabilities |= kUP;
+    _cpu_capabilities |= (cpus << kNumCPUsShift);
+}
+
+
+/* Copy data into commpage. */
+
+ void
+commpage_stuff(
+    int 	address,
+    void 	*source,
+    int 	length	)
+{    
+    char	*dest = commpage_addr_of(address);
+    
+    if (dest < next)
+        panic("commpage overlap: %08 - %08X", dest, next);
+    
+    bcopy((char*)source,dest,length);
+    
+    next = (dest + length);
+}
+
+
+/* Modify commpage code in-place for this specific platform. */
+
+static void
+commpage_change(
+    uint32_t 	*ptr,
+    int 		bytes,
+    uint32_t 	search_mask, 
+    uint32_t 	search_pattern,
+    uint32_t 	new_mask,
+    uint32_t 	new_pattern,
+    int			(*check)(uint32_t instruction)	)
+{
+    int			words = bytes >> 2;
+    uint32_t	word;
+    int			found_one = 0;
+
+    while( (--words) >= 0 ) {
+        word = *ptr;
+        if ((word & search_mask)==search_pattern) {
+            if ((check==NULL) || (check(word))) {	// check instruction if necessary
+                found_one = 1;
+                word &= ~new_mask;
+                word |= new_pattern;
+                *ptr = word;
+            }
+        }
+        ptr++;
+    }
+    
+    if (!found_one)
+        panic("commpage opcode not found");
+}
+
+
+/* Check to see if exactly one bit is set in a MTCRF instruction's FXM field.
+ */
+static int
+commpage_onebit(
+    uint32_t	mtcrf )
+{
+    int x = (mtcrf >> 12) & 0xFF;		// isolate the FXM field of the MTCRF
+    
+    if (x==0)
+        panic("commpage bad mtcrf");
+        
+    return	(x & (x-1))==0 ? 1 : 0;		// return 1 iff exactly 1 bit set in FXM field
+}
+
+
+/* Handle kCommPageDCBA bit: this routine uses DCBA.  If the machine we're
+ * running on doesn't benefit from use of that instruction, map them to NOPs
+ * in the commpage.
+ */
+static void
+commpage_handle_dcbas(
+    int 	address,
+    int 	length	)
+{
+    uint32_t	*ptr, search_mask, search, replace_mask, replace;
+    
+    if ((_cpu_capabilities & kDcbaAvailable) == 0) {
+        ptr = commpage_addr_of(address);
+        
+        search_mask =	0xFC0007FE;		// search x-form opcode bits
+        search =		0x7C0005EC;		// for a DCBA
+        replace_mask = 	0xFFFFFFFF;		// replace all bits...
+        replace =		0x60000000;		// ...with a NOP
+    
+        commpage_change(ptr,length,search_mask,search,replace_mask,replace,NULL);
+    }
+}
+
+
+/* Handle kCommPageSYNC bit: this routine uses SYNC or LWSYNC.  If we're
+ * running on a UP machine, map them to NOPs.
+ */
+static void
+commpage_handle_syncs(
+    int 	address, 
+    int 	length	)
+{
+    uint32_t	*ptr, search_mask, search, replace_mask, replace;
+    
+    if (_NumCPUs() == 1) {
+        ptr = commpage_addr_of(address);
+        
+        search_mask =	0xFC0007FE;		// search x-form opcode bits
+        search =		0x7C0004AC;		// for a SYNC or LWSYNC
+        replace_mask = 	0xFFFFFFFF;		// replace all bits...
+        replace =		0x60000000;		// ...with a NOP
+    
+        commpage_change(ptr,length,search_mask,search,replace_mask,replace,NULL);
+    }
+}
+
+
+/* Handle kCommPageMTCRF bit.  When this was written (3/03), the assembler did not
+ * recognize the special form of MTCRF instructions, in which exactly one bit is set
+ * in the 8-bit mask field.  Bit 11 of the instruction should be set in this case,
+ * since the 970 and probably other 64-bit processors optimize it.  Once the assembler
+ * has been updated this code can be removed, though it need not be.
+ */
+static void
+commpage_handle_mtcrfs(
+    int 	address, 
+    int 	length	)
+{
+    uint32_t	*ptr, search_mask, search, replace_mask, replace;
+    
+    if (_cpu_capabilities & k64Bit) {
+        ptr = commpage_addr_of(address);
+        
+        search_mask =	0xFC0007FE;		// search x-form opcode bits
+        search =		0x7C000120;		// for a MTCRF
+        replace_mask = 	0x00100000;		// replace bit 11...
+        replace =		0x00100000;		// ...with a 1-bit
+    
+        commpage_change(ptr,length,search_mask,search,replace_mask,replace,commpage_onebit);
+    }
+}
+
+
+/* Copy a routine into comm page if it matches running machine.
+ */
+static void
+commpage_stuff_routine(
+    commpage_descriptor	*rd	)
+{
+    char	*routine_code;
+    int		must,cant;
+    
+    if (rd->commpage_address != cur_routine) {
+        if ((cur_routine!=0) && (matched==0))
+            panic("commpage no match");
+        cur_routine = rd->commpage_address;
+        matched = 0;
+    }
+    
+    must = _cpu_capabilities & rd->musthave;
+    cant = _cpu_capabilities & rd->canthave;
+    
+    if ((must == rd->musthave) && (cant == 0)) {
+        if (matched)
+            panic("commpage duplicate matches");
+        matched = 1;
+        routine_code = ((char*)rd) + rd->code_offset;
+        
+        commpage_stuff(rd->commpage_address,routine_code,rd->code_length);
+        
+        if (rd->special & kCommPageDCBA)
+            commpage_handle_dcbas(rd->commpage_address,rd->code_length);
+            
+        if (rd->special & kCommPageSYNC)
+            commpage_handle_syncs(rd->commpage_address,rd->code_length);
+            
+        if (rd->special & kCommPageMTCRF)
+            commpage_handle_mtcrfs(rd->commpage_address,rd->code_length);
+    }
+}
+
+
+/* Fill in commpage: called once, during kernel initialization, from the
+ * startup thread before user-mode code is running.
+ * See the top of this file for a list of what you have to do to add
+ * a new routine to the commpage.
+ */  
+void
+commpage_populate( void )
+{
+    char	c1;
+    short	c2;
+    addr64_t c8;
+    static double	two52 = 1048576.0 * 1048576.0 * 4096.0;	// 2**52
+    static double	ten6 = 1000000.0;						// 10**6
+    commpage_descriptor	**rd;
+    short	version = _COMM_PAGE_THIS_VERSION;
+    
+    
+    commPagePtr = (char*) commpage_allocate();
+    
+    commpage_init_cpu_capabilities();
+
+
+    /* Stuff in the constants.  We move things into the comm page in strictly
+     * ascending order, so we can check for overlap and panic if so.
+     */
+     
+    commpage_stuff(_COMM_PAGE_VERSION,&version,2);
+
+    commpage_stuff(_COMM_PAGE_CPU_CAPABILITIES,&_cpu_capabilities,sizeof(int));
+    
+    c1 = (_cpu_capabilities & kHasAltivec) ? -1 : 0;
+    commpage_stuff(_COMM_PAGE_ALTIVEC,&c1,1);
+    
+    c1 = (_cpu_capabilities & k64Bit) ? -1 : 0;
+    commpage_stuff(_COMM_PAGE_64_BIT,&c1,1);
+    
+    if (_cpu_capabilities & kCache32)
+        c2 = 32;
+    else if (_cpu_capabilities & kCache64)
+        c2 = 64;
+    else if (_cpu_capabilities & kCache128)
+        c2 = 128;
+    commpage_stuff(_COMM_PAGE_CACHE_LINESIZE,&c2,2);
+    
+    commpage_stuff(_COMM_PAGE_2_TO_52,&two52,8);
+    
+    commpage_stuff(_COMM_PAGE_10_TO_6,&ten6,8);
+    
+    c8 = 0;													// 0 timestamp means "disabled"
+    commpage_stuff(_COMM_PAGE_TIMEBASE,&c8,8);
+    commpage_stuff(_COMM_PAGE_TIMESTAMP,&c8,8);
+    commpage_stuff(_COMM_PAGE_SEC_PER_TICK,&c8,8);
+
+
+    /* Now the routines.  We try each potential routine in turn,
+     * and copy in any that "match" the platform we are running on.
+     * We require that exactly one routine match for each slot in the
+     * comm page, and panic if not.
+     *
+     * The check for overlap assumes that these routines are
+     * in strictly ascending order, sorted by address in the
+     * comm page.
+     */
+
+    extern	commpage_descriptor	mach_absolute_time_32;
+    extern	commpage_descriptor	mach_absolute_time_64;
+    extern	commpage_descriptor	spinlock_32_try_mp;
+    extern	commpage_descriptor	spinlock_32_try_up;
+    extern	commpage_descriptor	spinlock_64_try_mp;
+    extern	commpage_descriptor	spinlock_64_try_up;
+    extern	commpage_descriptor	spinlock_32_lock_mp;
+    extern	commpage_descriptor	spinlock_32_lock_up;
+    extern	commpage_descriptor	spinlock_64_lock_mp;
+    extern	commpage_descriptor	spinlock_64_lock_up;
+    extern	commpage_descriptor	spinlock_32_unlock_mp;
+    extern	commpage_descriptor	spinlock_32_unlock_up;
+    extern	commpage_descriptor	spinlock_64_unlock_mp;
+    extern	commpage_descriptor	spinlock_64_unlock_up;
+    extern	commpage_descriptor	pthread_getspecific_sprg3;
+    extern	commpage_descriptor	pthread_getspecific_uftrap;
+    extern	commpage_descriptor	gettimeofday_32;
+    extern	commpage_descriptor	gettimeofday_64;
+    extern	commpage_descriptor	commpage_flush_dcache;
+    extern	commpage_descriptor	commpage_flush_icache;
+    extern	commpage_descriptor	pthread_self_sprg3;
+    extern	commpage_descriptor	pthread_self_uftrap;
+    extern	commpage_descriptor	spinlock_relinquish;
+    extern	commpage_descriptor	bzero_32;
+    extern	commpage_descriptor	bzero_128;
+    extern	commpage_descriptor	bcopy_g3;
+    extern	commpage_descriptor	bcopy_g4;
+    extern	commpage_descriptor	bcopy_970;
+    extern	commpage_descriptor	bcopy_64;
+    extern	commpage_descriptor	bigcopy_970;
+    
+    static	commpage_descriptor	*routines[] = {
+        &mach_absolute_time_32,
+        &mach_absolute_time_64,
+        &spinlock_32_try_mp,
+        &spinlock_32_try_up,
+        &spinlock_64_try_mp,
+        &spinlock_64_try_up,
+        &spinlock_32_lock_mp,
+        &spinlock_32_lock_up,
+        &spinlock_64_lock_mp,
+        &spinlock_64_lock_up,
+        &spinlock_32_unlock_mp,
+        &spinlock_32_unlock_up,
+        &spinlock_64_unlock_mp,
+        &spinlock_64_unlock_up,
+        &pthread_getspecific_sprg3,
+        &pthread_getspecific_uftrap,
+        &gettimeofday_32,
+        &gettimeofday_64,
+        &commpage_flush_dcache,
+        &commpage_flush_icache,
+        &pthread_self_sprg3,
+        &pthread_self_uftrap,
+        &spinlock_relinquish,
+        &bzero_32,
+        &bzero_128,
+        &bcopy_g3,
+        &bcopy_g4,
+        &bcopy_970,
+        &bcopy_64,
+        &bigcopy_970,
+        NULL };
+        
+    for( rd = routines; *rd != NULL ; rd++ ) 
+        commpage_stuff_routine(*rd);
+        
+    if (!matched)
+        panic("commpage no match on last routine");
+    
+    if (next > (commPagePtr + _COMM_PAGE_AREA_USED))
+        panic("commpage overflow");
+        
+    sync_cache_virtual((vm_offset_t) commPagePtr,_COMM_PAGE_AREA_USED);	// make all that new code executable
+
+}
diff --git a/osfmk/ppc/commpage/commpage.h b/osfmk/ppc/commpage/commpage.h
new file mode 100644
index 000000000..7b48fda34
--- /dev/null
+++ b/osfmk/ppc/commpage/commpage.h
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ * 
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ * 
+ * @APPLE_LICENSE_HEADER_END@
+ */
+
+#ifndef _PPC_COMMPAGE_H
+#define _PPC_COMMPAGE_H
+
+#ifndef	__ASSEMBLER__
+#include <stdint.h>
+#endif /* __ASSEMBLER__ */
+
+
+/* Special check bits for the compage_descriptor "special" field. */
+ 
+#define	kCommPageDCBA		0x0001			// this routine uses DCBA, map to NOP if not appropriate
+#define	kCommPageSYNC		0x0002			// this routine uses SYNC, map to NOP if UP
+#define	kCommPageMTCRF		0x0004			// set bit 11 in MTCRF if only 1 cr specified
+
+
+#ifdef	__ASSEMBLER__
+
+#define	COMMPAGE_DESCRIPTOR(label,address,must,cant,special)	\
+LEXT(label)	@\
+    .short	label-.	@\
+    .short	.-label-2	@\
+    .short	address	@\
+    .short	special	@\
+    .long	must	@\
+    .long	cant
+    
+
+#else /* __ASSEMBLER__ */
+
+/* Each potential commpage routine is described by one of these.
+ * Note that the COMMPAGE_DESCRIPTOR macro (above), used in
+ * assembly language, must agree with this.
+ */
+ 
+typedef	struct	commpage_descriptor	{
+    short	code_offset;					// offset to code from this descriptor
+    short	code_length;					// length in bytes
+    short	commpage_address;				// put at this address (_COMM_PAGE_BCOPY etc)
+    short	special;						// special handling bits for DCBA and SYNC etc
+    long	musthave;						// _cpu_capability bits we must have
+    long	canthave;						// _cpu_capability bits we can't have
+} commpage_descriptor;
+
+
+extern	char	*commPagePtr;				// virt address of commpage in kernel map
+
+
+extern	void	commpage_set_timestamp(uint64_t tbr,uint32_t secs,uint32_t usecs,uint32_t ticks_per_sec);
+extern	int		commpage_time_dcba( void );
+
+#endif	/* __ASSEMBLER__ */
+
+#endif /* _PPC_COMMPAGE_H */
diff --git a/osfmk/ppc/commpage/commpage_asm.s b/osfmk/ppc/commpage/commpage_asm.s
new file mode 100644
index 000000000..3c30b32a5
--- /dev/null
+++ b/osfmk/ppc/commpage/commpage_asm.s
@@ -0,0 +1,256 @@
+/*
+ * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ * 
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ * 
+ * @APPLE_LICENSE_HEADER_END@
+ */
+
+#include <sys/appleapiopts.h>
+#include <ppc/asm.h>
+#include <ppc/proc_reg.h>
+#include <machine/cpu_capabilities.h>
+#include <machine/commpage.h>
+
+
+// commpage_time_dcba() uses a stack frame as follows:
+
+#define	kBufSiz		1024				// Size of the buffer we use to do DCBA timing on G4
+#define	kSFSize		(kBufSiz+128+16)	// Stack frame size, which contains the 128-byte-aligned buffer
+#define	kLoopCnt	5					// Iterations of the timing loop
+#define	kDCBA		22					// Bit in cr5 used as a flag in timing loop
+
+
+// commpage_set_timestamp() uses the red zone for temporary storage:
+
+#define	rzSaveF1			-8		// caller's FPR1
+#define	rzSaveF2			-16		// caller's FPR2
+#define	rzSaveF3			-24		// caller's FPR3
+#define	rzSaveF4			-32		// caller's FPR4
+#define	rzSaveF5			-40		// caller's FPR5
+#define	rzNewTimeBase		-48		// used to load 64-bit TBR into a FPR
+
+
+// commpage_set_timestamp() uses the following data.  kkTicksPerSec remembers
+// the number used to compute _COMM_PAGE_SEC_PER_TICK.  Since this constant
+// rarely changes, we use it to avoid needless recomputation.  It is a double
+// value, pre-initialize with an exponent of 2**52.
+
+#define	kkBinary0		0					// offset in data to long long 0 (a constant)
+#define	kkDouble1		8					// offset in data to double 1.0 (a constant)
+#define	kkTicksPerSec	16					// offset in data to double(ticks_per_sec)
+
+        .data
+        .align	3							// three doubleword fields
+Ldata:
+        .long	0							// kkBinary0
+        .long	0
+        .double	1.0e0						// kkDouble1        
+        .long	0x43300000					// kkTicksPerSec (plus 2**52)
+        .long	0							// this is where we store ticks_per_sec, to float
+
+        .text
+        .align	2
+        .globl	EXT(commpage_time_dcba)
+        .globl	EXT(commpage_set_timestamp)
+
+
+/*	***********************************************
+ *	* C O M M P A G E _ S E T _ T I M E S T A M P *
+ *	***********************************************
+ *
+ *	Update the gettimeofday() shared data on the commpage, as follows:
+ *		_COMM_PAGE_TIMESTAMP = a BSD-style pair of uint_32's for secs and usecs
+ *		_COMM_PAGE_TIMEBASE = the timebase at which the timestamp was valid
+ *		_COMM_PAGE_SEC_PER_TICK = multiply timebase ticks by this to get seconds (double)
+ *	The convention is that if the timebase is 0, the data is invalid.  Because other
+ *	CPUs are reading the three values asynchronously and must get a consistent set, 
+ *	it is critical that we update them with the following protocol:
+ *		1. set timebase to 0 (atomically), to invalidate all three values
+ *		2. eieio (to create a barrier in stores to cacheable memory)
+ *		3. change timestamp and "secs per tick"
+ *		4. eieio
+ *		5. set timebase nonzero (atomically)
+ *	This works because readers read the timebase, then the timestamp and divisor, sync
+ *	if MP, then read the timebase a second time and check to be sure it is equal to the first.
+ *
+ *	We could save a few cycles on 64-bit machines by special casing them, but it probably
+ *	isn't necessary because this routine shouldn't be called very often.
+ *
+ *	When called:
+ *		r3 = upper half of timebase (timebase is disabled if 0)
+ *		r4 = lower half of timebase
+ *		r5 = seconds part of timestamp
+ *		r6 = useconds part of timestamp
+ *		r7 = divisor (ie, timebase ticks per sec)
+ *	We set up:
+ *		r8 = ptr to our static data (kkBinary0, kkDouble1, kkTicksPerSec)
+ *		r9 = ptr to comm page in kernel map
+ *
+ *	--> Interrupts must be disabled and rtclock locked when called.  <--
+ */
+ 
+        .align	5
+LEXT(commpage_set_timestamp)				// void commpage_set_timestamp(tbr,secs,usecs,divisor)
+        mfmsr	r11							// get MSR
+        ori		r2,r11,MASK(MSR_FP)			// turn FP on
+        mtmsr	r2
+        isync								// wait until MSR changes take effect
+        
+        or.		r0,r3,r4					// is timebase 0? (thus disabled)
+        lis		r8,hi16(Ldata)				// point to our data
+        lis		r9,ha16(EXT(commPagePtr))	// get ptr to address of commpage in kernel map
+        stfd	f1,rzSaveF1(r1)				// save a FPR in the red zone
+        ori		r8,r8,lo16(Ldata)
+        lwz		r9,lo16(EXT(commPagePtr))(r9)	// r9 <- commPagePtr
+        lfd		f1,kkBinary0(r8)			// get fixed 0s
+        li		r0,_COMM_PAGE_BASE_ADDRESS	// get va in user space of commpage
+        cmpwi	cr1,r9,0					// is commpage allocated yet?
+        sub		r9,r9,r0					// r9 <- commpage address, biased by user va
+        beq--	cr1,3f						// skip if not allocated
+        stfd	f1,_COMM_PAGE_TIMEBASE(r9)	// turn off the timestamp (atomically)
+        eieio								// make sure all CPUs see it is off
+        beq		3f							// all we had to do is turn off timestamp
+        
+        lwz		r0,kkTicksPerSec+4(r8)		// get last ticks_per_sec (or 0 if first)
+        stw		r3,rzNewTimeBase(r1)		// store new timebase so we can lfd
+        stw		r4,rzNewTimeBase+4(r1)
+        cmpw	r0,r7						// do we need to recompute _COMM_PAGE_SEC_PER_TICK?
+        stw		r5,_COMM_PAGE_TIMESTAMP(r9)	// store the new timestamp
+        stw		r6,_COMM_PAGE_TIMESTAMP+4(r9)
+        lfd		f1,rzNewTimeBase(r1)		// get timebase in a FPR so we can store atomically
+        beq++	2f							// same ticks_per_sec, no need to recompute
+        
+        stw		r7,kkTicksPerSec+4(r8)		// must recompute SEC_PER_TICK
+        stfd	f2,rzSaveF2(r1)				// we'll need a few more temp FPRs
+        stfd	f3,rzSaveF3(r1)
+        stfd	f4,rzSaveF4(r1)
+        stfd	f5,rzSaveF5(r1)
+        lfd		f2,_COMM_PAGE_2_TO_52(r9)	// f2 <- double(2**52)
+        lfd		f3,kkTicksPerSec(r8)		// float new ticks_per_sec + 2**52
+        lfd		f4,kkDouble1(r8)			// f4 <- double(1.0)
+        mffs	f5							// save caller's FPSCR
+        mtfsfi	7,0							// clear Inexeact Exception bit, set round-to-nearest
+        fsub	f3,f3,f2					// get ticks_per_sec
+        fdiv	f3,f4,f3					// divide 1 by ticks_per_sec to get SEC_PER_TICK
+        stfd	f3,_COMM_PAGE_SEC_PER_TICK(r9)
+        mtfsf	0xFF,f5						// restore FPSCR
+        lfd		f2,rzSaveF2(r1)				// restore FPRs
+        lfd		f3,rzSaveF3(r1)
+        lfd		f4,rzSaveF4(r1)
+        lfd		f5,rzSaveF5(r1)
+2:											// f1 == new timestamp
+        eieio								// wait until the stores take
+        stfd	f1,_COMM_PAGE_TIMEBASE(r9)	// then turn the timestamp back on (atomically)
+3:											// here once all fields updated
+        lfd		f1,rzSaveF1(r1)				// restore last FPR
+        mtmsr	r11							// turn FP back off
+        isync
+        blr
+
+
+/*	***************************************
+ *	* C O M M P A G E _ T I M E _ D C B A *
+ *	***************************************
+ *
+ *	Not all processors that support the DCBA opcode actually benefit from it.
+ *	Some store-gather and read-cancel well enough that there is no need to use
+ *	DCBA to avoid fetching cache lines that will be completely overwritten, while
+ *	others have this feature disabled (to work around errata etc), and so benefit
+ *	from DCBA.  Since it is hard to tell the one group from the other, we just
+ *	time loops with and without DCBA, and pick the fastest.  Thus we avoid
+ *	delicate dependence on processor and/or platform revisions.
+ *
+ *	We return either kDcbaRecommended or zero.
+ *
+ *		int commpage_time_dcba( void );
+ */
+ 
+LEXT(commpage_time_dcba)
+        mflr	r12					// get return
+        stw		r12,8(r1)			// save
+        stwu	r1,-kSFSize(r1)		// carve our temp buffer from the stack
+        addi	r11,r1,127+16		// get base address...
+        rlwinm	r11,r11,0,0,24		// ...of our buffer, 128-byte aligned
+        crset	kDCBA				// first, use DCBA
+        bl		LTest				// time it with DCBA
+        srwi	r0,r3,3				// bias 12 pct in favor of not using DCBA...
+        add		r10,r3,r0			// ...because DCBA is always slower with warm cache
+        crclr	kDCBA
+        bl		LTest				// time without DCBA
+        cmplw	r10,r3				// which is better?
+        mtlr	r12					// restore return
+        lwz		r1,0(r1)			// pop off our stack frame
+        li		r3,kDcbaRecommended		// assume using DCBA is faster
+        bltlr
+        li		r3,0			// no DCBA is faster
+        blr
+                
+        
+// Subroutine to time a loop with or without DCBA.
+//		kDCBA = set if we should use DCBA
+//		r11 = base of buffer to use for test (kBufSiz bytes)
+//
+//		We return TBR ticks in r3.
+//		We use r0,r3-r9.
+
+LTest:
+        li		r4,kLoopCnt			// number of times to loop
+        li		r3,-1				// initialize fastest time
+1:
+        mr		r6,r11				// initialize buffer ptr
+        li		r0,kBufSiz/32		// r0 <- cache blocks to test
+        mtctr	r0
+2:
+        dcbf	0,r6				// first, force the blocks out of the cache
+        addi	r6,r6,32
+        bdnz	2b
+        sync						// make sure all the flushes take
+        mr		r6,r11				// re-initialize buffer ptr
+        mtctr	r0					// reset cache-block count
+        mftbu	r7					// remember upper half so we can check for carry
+        mftb	r8					// start the timer
+3:									// loop over cache blocks
+        bf		kDCBA,4f			// should we DCBA?
+        dcba	0,r6
+4:
+        stw		r0,0(r6)			// store the entire cache block
+        stw		r0,4(r6)
+        stw		r0,8(r6)
+        stw		r0,12(r6)
+        stw		r0,16(r6)
+        stw		r0,20(r6)
+        stw		r0,24(r6)
+        stw		r0,28(r6)
+        addi	r6,r6,32
+        bdnz	3b
+        mftb	r9
+        mftbu	r0
+        cmpw	r0,r7				// did timebase carry?
+        bne		1b					// yes, retest rather than fuss
+        sub		r9,r9,r8			// r9 <- time for this loop
+        cmplw	r9,r3				// faster than current best?
+        bge		5f					// no
+        mr		r3,r9				// remember fastest time through loop
+5:
+        subi	r4,r4,1				// decrement outer loop count
+        cmpwi	r4,0				// more to go?
+        bne		1b					// loop if so
+        blr							// return fastest time in r3
diff --git a/osfmk/ppc/commpage/gettimeofday.s b/osfmk/ppc/commpage/gettimeofday.s
new file mode 100644
index 000000000..f16855913
--- /dev/null
+++ b/osfmk/ppc/commpage/gettimeofday.s
@@ -0,0 +1,212 @@
+/*
+ * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ * 
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ * 
+ * @APPLE_LICENSE_HEADER_END@
+ */
+
+#define	ASSEMBLER
+#include <sys/appleapiopts.h>
+#include <ppc/asm.h>					// EXT, LEXT
+#include <machine/cpu_capabilities.h>
+#include <machine/commpage.h>
+
+#define	USEC_PER_SEC	1000000
+
+
+/* The red zone is used to move data between GPRs and FPRs: */
+
+#define	rzTicks			-8			// elapsed ticks since timestamp (double)
+#define	rzSeconds		-16			// seconds since timestamp (double)
+#define	rzUSeconds		-24			// useconds since timestamp (double)
+
+
+        .text
+        .align	2
+        .globl	EXT(gettimeofday_32)
+        .globl	EXT(gettimeofday_64)
+
+
+// *********************************
+// * G E T T I M E O F D A Y _ 3 2 *
+// *********************************
+//
+// This is a subroutine of gettimeofday.c that gets the seconds and microseconds
+// in user mode, usually without having to make a system call.  We do not deal with
+// the timezone.  The kernel maintains the following values in the comm page:
+//
+//	_COMM_PAGE_TIMESTAMP = a BSD-style pair of uint_32's for seconds and microseconds
+//
+//	_COMM_PAGE_TIMEBASE = the timebase at which the timestamp was valid
+//
+//	_COMM_PAGE_SEC_PER_TICK = multiply timebase ticks by this to get seconds (double)
+//
+//	_COMM_PAGE_2_TO_52 = double precision constant 2**52
+//
+//	_COMM_PAGE_10_TO_6 = double precision constant 10**6
+//
+// We have to be careful to read these values atomically.  The kernel updates them 
+// asynchronously to account for drift or time changes (eg, ntp.)  We adopt the
+// convention that (timebase==0) means the timestamp is invalid, in which case we
+// return a bad status so our caller can make the system call.
+//
+//		r3 = ptr to user's timeval structure (should not be null)
+
+gettimeofday_32:								// int gettimeofday_32(timeval *tp);
+0:
+        lwz		r5,_COMM_PAGE_TIMEBASE+0(0)		// r5,r6 = TBR at timestamp
+        lwz		r6,_COMM_PAGE_TIMEBASE+4(0)
+        lwz		r7,_COMM_PAGE_TIMESTAMP+0(0)	// r7 = timestamp seconds
+        lwz		r8,_COMM_PAGE_TIMESTAMP+4(0)	// r8 = timestamp microseconds
+        lfd		f1,_COMM_PAGE_SEC_PER_TICK(0)
+1:        
+        mftbu	r10								// r10,r11 = current timebase
+        mftb	r11
+        mftbu	r12
+        cmplw	r10,r12
+        bne-	1b
+        or.		r0,r5,r6						// timebase 0? (ie, is timestamp invalid?)
+        
+        sync									// create a barrier (patched to NOP if UP)
+        
+        lwz		r0,_COMM_PAGE_TIMEBASE+0(0)		// then load data a 2nd time
+        lwz		r12,_COMM_PAGE_TIMEBASE+4(0)
+        lwz		r2,_COMM_PAGE_TIMESTAMP+0(0)
+        lwz		r9,_COMM_PAGE_TIMESTAMP+4(0)
+        cmplw	cr6,r5,r0			// did we read a consistent set?
+        cmplw	cr7,r6,r12
+        beq-	3f					// timestamp is disabled so return bad status
+        cmplw	cr1,r2,r7
+        cmplw	cr5,r9,r8
+        crand	cr0_eq,cr6_eq,cr7_eq
+        crand	cr1_eq,cr1_eq,cr5_eq
+        crand	cr0_eq,cr0_eq,cr1_eq
+        bne-	0b					// loop until we have a consistent set of data
+        
+        subfc	r11,r6,r11			// compute ticks since timestamp
+        lwz		r9,_COMM_PAGE_2_TO_52(0)	// get exponent for (2**52)
+        subfe	r10,r5,r10			// complete 64-bit subtract
+        lfd		f2,_COMM_PAGE_2_TO_52(0)	// f3 <- (2**52)
+        srwi.	r0,r10,2			// if more than 2**34 ticks have elapsed...
+        stw		r11,rzTicks+4(r1)	// store elapsed ticks into red zone
+        or		r10,r10,r9			// convert long-long in (r10,r11) into double
+        bne-	3f					// ...call kernel to reprime timestamp
+
+        stw		r10,rzTicks(r1)		// complete double
+        lis		r12,hi16(USEC_PER_SEC)
+        ori		r12,r12,lo16(USEC_PER_SEC)
+        
+        lfd		f3,rzTicks(r1)		// get elapsed ticks since timestamp + 2**52
+        fsub	f4,f3,f2			// subtract 2**52 and normalize
+        fmul	f5,f4,f1			// f5 <- elapsed seconds since timestamp
+        lfd		f3,_COMM_PAGE_10_TO_6(0)	// get 10**6
+        fctiwz	f6,f5				// convert to integer
+        stfd	f6,rzSeconds(r1)	// store integer seconds into red zone
+        stw		r9,rzSeconds(r1)	// prepare to reload as floating pt
+        lfd		f6,rzSeconds(r1)	// get seconds + 2**52
+        fsub	f6,f6,f2			// f6 <- integral seconds
+        fsub	f6,f5,f6			// f6 <- fractional part of elapsed seconds
+        fmul	f6,f6,f3			// f6 <- fractional elapsed useconds
+        fctiwz	f6,f6				// convert useconds to integer
+        stfd	f6,rzUSeconds(r1)	// store useconds into red zone
+        
+        lwz		r5,rzSeconds+4(r1)	// r5 <- seconds since timestamp
+        lwz		r6,rzUSeconds+4(r1)	// r6 <- useconds since timestamp
+        add		r7,r7,r5			// add elapsed seconds to timestamp seconds
+        add		r8,r8,r6			// ditto useconds
+        
+        cmplw	r8,r12				// r8 >= USEC_PER_SEC ?
+        blt		2f					// no
+        addi	r7,r7,1				// add 1 to secs
+        sub		r8,r8,r12			// subtract USEC_PER_SEC from usecs
+2:
+        stw		r7,0(r3)			// store secs//usecs into user's timeval
+        stw		r8,4(r3)
+        li		r3,0				// return success
+        blr
+3:									// too long since last timestamp or this code is disabled
+        li		r3,1				// return bad status so our caller will make syscall
+        blr
+        
+        COMMPAGE_DESCRIPTOR(gettimeofday_32,_COMM_PAGE_GETTIMEOFDAY,0,k64Bit,kCommPageSYNC)
+        
+        
+// *********************************
+// * G E T T I M E O F D A Y _ 6 4 *
+// *********************************
+
+gettimeofday_64:							// int gettimeofday_64(timeval *tp);
+0:
+        ld		r6,_COMM_PAGE_TIMEBASE(0)	// r6 = TBR at timestamp
+        ld		r8,_COMM_PAGE_TIMESTAMP(0)	// r8 = timestamp (seconds,useconds)
+        lfd		f1,_COMM_PAGE_SEC_PER_TICK(0)
+        mftb	r10							// r10 = get current timebase
+        lwsync								// create a barrier if MP (patched to NOP if UP)
+        ld		r11,_COMM_PAGE_TIMEBASE(0)	// then get data a 2nd time
+        ld		r12,_COMM_PAGE_TIMESTAMP(0)
+        cmpdi	cr1,r6,0			// is the timestamp disabled?
+        cmpld	cr6,r6,r11			// did we read a consistent set?
+        cmpld	cr7,r8,r12
+        beq--	cr1,3f				// exit if timestamp disabled
+        crand	cr6_eq,cr7_eq,cr6_eq
+        sub		r11,r10,r6			// compute elapsed ticks from timestamp
+        bne--	cr6,0b				// loop until we have a consistent set of data
+                
+        srdi.	r0,r11,35			// has it been more than 2**35 ticks since last timestamp?
+        std		r11,rzTicks(r1)		// put ticks in redzone where we can "lfd" it
+        bne--	3f					// timestamp too old, so reprime
+
+        lfd		f3,rzTicks(r1)		// get elapsed ticks since timestamp (fixed pt)
+        fcfid	f4,f3				// float the tick count
+        fmul	f5,f4,f1			// f5 <- elapsed seconds since timestamp
+        lfd		f3,_COMM_PAGE_10_TO_6(0)	// get 10**6
+        fctidz	f6,f5				// convert integer seconds to fixed pt
+        stfd	f6,rzSeconds(r1)	// save fixed pt integer seconds in red zone
+        fcfid	f6,f6				// float the integer seconds
+        fsub	f6,f5,f6			// f6 <- fractional part of elapsed seconds
+        fmul	f6,f6,f3			// f6 <- fractional elapsed useconds
+        fctidz	f6,f6				// convert useconds to fixed pt integer
+        stfd	f6,rzUSeconds(r1)	// store useconds into red zone
+        
+        lis		r12,hi16(USEC_PER_SEC)	// r12 <- 10**6
+        srdi	r7,r8,32			// extract seconds from doubleword timestamp
+        lwz		r5,rzSeconds+4(r1)	// r5 <- seconds since timestamp
+        ori		r12,r12,lo16(USEC_PER_SEC)
+        lwz		r6,rzUSeconds+4(r1)	// r6 <- useconds since timestamp
+        add		r7,r7,r5			// add elapsed seconds to timestamp seconds
+        add		r8,r8,r6			// ditto useconds
+        
+        cmplw	r8,r12				// r8 >= USEC_PER_SEC ?
+        blt		2f					// no
+        addi	r7,r7,1				// add 1 to secs
+        sub		r8,r8,r12			// subtract USEC_PER_SEC from usecs
+2:
+        stw		r7,0(r3)			// store secs//usecs into user's timeval
+        stw		r8,4(r3)
+        li		r3,0				// return success
+        blr
+3:									// too long since last timestamp or this code is disabled
+        li		r3,1				// return bad status so our caller will make syscall
+        blr
+
+        COMMPAGE_DESCRIPTOR(gettimeofday_64,_COMM_PAGE_GETTIMEOFDAY,k64Bit,0,kCommPageSYNC)
+
+        
diff --git a/osfmk/ppc/commpage/mach_absolute_time.s b/osfmk/ppc/commpage/mach_absolute_time.s
new file mode 100644
index 000000000..865f91e9c
--- /dev/null
+++ b/osfmk/ppc/commpage/mach_absolute_time.s
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ * 
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ * 
+ * @APPLE_LICENSE_HEADER_END@
+ */
+
+#define	ASSEMBLER
+#include <sys/appleapiopts.h>
+#include <ppc/asm.h>					// EXT, LEXT
+#include <machine/cpu_capabilities.h>
+#include <machine/commpage.h>
+
+        .text
+        .align	2
+        .globl	EXT(mach_absolute_time_32)
+        .globl	EXT(mach_absolute_time_64)
+
+
+// *********************************************
+// * M A C H _ A B S O L U T E _ T I M E _ 3 2 *
+// *********************************************
+
+mach_absolute_time_32:
+1:        
+        mftbu	r3
+        mftb	r4
+        mftbu	r5
+        cmplw	r3,r5
+        beqlr+
+        b		1b
+        
+        COMMPAGE_DESCRIPTOR(mach_absolute_time_32,_COMM_PAGE_ABSOLUTE_TIME,0,k64Bit,0)
+        
+        
+// *********************************************
+// * M A C H _ A B S O L U T E _ T I M E _ 6 4 *
+// *********************************************
+//
+// Why bother to special case for 64-bit?  Because the "mftb" variants
+// are 10 cycles each, and they are serialized. 
+
+mach_absolute_time_64:
+        mftb	r4
+        srdi	r3,r4,32
+        blr
+
+        COMMPAGE_DESCRIPTOR(mach_absolute_time_64,_COMM_PAGE_ABSOLUTE_TIME,k64Bit,0,0)
+
+        
diff --git a/osfmk/ppc/commpage/pthread.s b/osfmk/ppc/commpage/pthread.s
new file mode 100644
index 000000000..a53c7ef3d
--- /dev/null
+++ b/osfmk/ppc/commpage/pthread.s
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ * 
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ * 
+ * @APPLE_LICENSE_HEADER_END@
+ */
+
+#include <sys/appleapiopts.h>
+#include <ppc/asm.h>					// EXT, LEXT
+#include <machine/cpu_capabilities.h>
+#include <machine/commpage.h>
+
+        .text
+        .align	2
+        .globl	EXT(pthread_getspecific_sprg3)
+        .globl	EXT(pthread_getspecific_uftrap)
+        .globl	EXT(pthread_self_sprg3)
+        .globl	EXT(pthread_self_uftrap)
+
+#define	USER_SPRG3	259		// user-mode-readable encoding for SPRG3
+
+
+// *****************************************************
+// * P T H R E A D _ G E T S P E C I F I C _ S P R G 3 *
+// *****************************************************
+//
+// For processors with user-readable SPRG3.   Called with:
+//		r3 = word number
+//		r4 = offset to thread specific data (_PTHREAD_TSD_OFFSET)
+
+pthread_getspecific_sprg3:
+        slwi	r5,r3,2				// convert word# to byte offset
+        mfspr	r3,USER_SPRG3		// get per-thread cookie
+        add		r5,r5,r4			// add in offset to first word
+        lwzx	r3,r3,r5			// get the thread-specific word
+        blr
+        
+    COMMPAGE_DESCRIPTOR(pthread_getspecific_sprg3,_COMM_PAGE_PTHREAD_GETSPECIFIC,k64Bit,0,0)
+    
+    
+// ***************************************
+// * P T H R E A D _ S E L F _ S P R G 3 *
+// ***************************************
+//
+// For processors with user-readable SPRG3.
+
+pthread_self_sprg3:
+        mfspr	r3,USER_SPRG3		// get per-thread cookie
+        blr
+        
+    COMMPAGE_DESCRIPTOR(pthread_self_sprg3,_COMM_PAGE_PTHREAD_SELF,k64Bit,0,0)
+    
+        
+// *******************************************************
+// * P T H R E A D _ G E T S P E C I F I C _ U F T R A P *
+// *******************************************************
+//
+// For processors that use the Ultra-Fast-Trap to get the thread-specific ptr.
+// Called with:
+//		r3 = word number
+//		r4 = offset to thread specific data (_PTHREAD_TSD_OFFSET)
+
+pthread_getspecific_uftrap:
+        slwi	r5,r3,2				// convert word# to byte offset
+        li 		r0,0x7FF2			// magic "pthread_self" ultra-fast trap code
+        sc
+        add		r5,r5,r4			// add in offset to first word
+        lwzx	r3,r3,r5			// get the thread-specific word
+        blr
+
+    COMMPAGE_DESCRIPTOR(pthread_getspecific_uftrap,_COMM_PAGE_PTHREAD_GETSPECIFIC,0,k64Bit,0)
+    
+        
+// *****************************************
+// * P T H R E A D _ S E L F _ U F T R A P *
+// *****************************************
+//
+// For processors that use the Ultra-Fast-Trap to get the thread-specific ptr.
+
+pthread_self_uftrap:
+        li 		r0,0x7FF2			// magic "pthread_self" ultra-fast trap code
+        sc							// get r3==TLDP
+        blr
+
+    COMMPAGE_DESCRIPTOR(pthread_self_uftrap,_COMM_PAGE_PTHREAD_SELF,0,k64Bit,0)
diff --git a/osfmk/ppc/commpage/spinlocks.s b/osfmk/ppc/commpage/spinlocks.s
new file mode 100644
index 000000000..d619a6e8e
--- /dev/null
+++ b/osfmk/ppc/commpage/spinlocks.s
@@ -0,0 +1,238 @@
+/*
+ * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ * 
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ * 
+ * @APPLE_LICENSE_HEADER_END@
+ */
+
+#include <sys/appleapiopts.h>
+#include <ppc/asm.h>					// EXT, LEXT
+#include <machine/cpu_capabilities.h>
+#include <machine/commpage.h>
+
+        .text
+        .align	2
+        .globl	EXT(spinlock_32_try_mp)
+        .globl	EXT(spinlock_32_try_up)
+        .globl	EXT(spinlock_32_lock_mp)
+        .globl	EXT(spinlock_32_lock_up)
+        .globl	EXT(spinlock_32_unlock_mp)
+        .globl	EXT(spinlock_32_unlock_up)
+        
+        .globl	EXT(spinlock_64_try_mp)
+        .globl	EXT(spinlock_64_try_up)
+        .globl	EXT(spinlock_64_lock_mp)
+        .globl	EXT(spinlock_64_lock_up)
+        .globl	EXT(spinlock_64_unlock_mp)
+        .globl	EXT(spinlock_64_unlock_up)
+        
+        .globl	EXT(spinlock_relinquish)
+
+#define	MP_SPIN_TRIES   1000
+
+
+// The user mode spinlock library.  There are many versions,
+// in order to take advantage of a few special cases:
+//	- no barrier instructions (SYNC,ISYNC) are needed if UP
+//	- 64-bit processors can use LWSYNC instead of SYNC (if MP)
+//	- branch hints appropriate to the processor (+ vs ++ etc)
+//	- potentially custom relinquish strategies (not used at present)
+//	- fixes for errata as necessary
+
+
+spinlock_32_try_mp:
+1:
+        lwarx	r4,0,r3
+        cmpwi	r4,0
+        bne-	2f
+        stwcx.	r3,0,r3
+        isync				// cancel speculative execution
+        beqlr+
+        b		1b
+2:
+        li		r3,0
+        blr
+
+    COMMPAGE_DESCRIPTOR(spinlock_32_try_mp,_COMM_PAGE_SPINLOCK_TRY,0,k64Bit+kUP,0)
+        
+
+spinlock_32_try_up:
+1:
+        lwarx	r4,0,r3
+        cmpwi	r4,0
+        bne-	2f
+        stwcx.	r3,0,r3
+        beqlr+
+        b		1b
+2:
+        li		r3,0
+        blr
+
+    COMMPAGE_DESCRIPTOR(spinlock_32_try_up,_COMM_PAGE_SPINLOCK_TRY,kUP,k64Bit,0)
+
+
+spinlock_32_lock_mp:
+        li		r5,MP_SPIN_TRIES
+1:
+        lwarx	r4,0,r3
+        cmpwi	r4,0
+        bne-	2f
+        stwcx.	r3,0,r3
+        isync				// cancel speculative execution
+        beqlr+				// we return void
+        b		1b
+2:
+        subic.	r5,r5,1		// try again before relinquish?
+        bne		1b
+        ba		_COMM_PAGE_RELINQUISH
+
+    COMMPAGE_DESCRIPTOR(spinlock_32_lock_mp,_COMM_PAGE_SPINLOCK_LOCK,0,k64Bit+kUP,0)
+
+
+spinlock_32_lock_up:
+1:
+        lwarx	r4,0,r3
+        cmpwi	r4,0
+        bnea-	_COMM_PAGE_RELINQUISH	// always depress on UP (let lock owner run)
+        stwcx.	r3,0,r3
+        beqlr+				// we return void
+        b		1b
+
+    COMMPAGE_DESCRIPTOR(spinlock_32_lock_up,_COMM_PAGE_SPINLOCK_LOCK,kUP,k64Bit,0)
+
+
+spinlock_32_unlock_mp:
+        li		r4,0
+        sync				// complete prior stores before unlock
+        stw		r4,0(r3)
+        blr
+
+    COMMPAGE_DESCRIPTOR(spinlock_32_unlock_mp,_COMM_PAGE_SPINLOCK_UNLOCK,0,k64Bit+kUP,0)
+
+
+spinlock_32_unlock_up:
+        li		r4,0
+        stw		r4,0(r3)
+        blr
+
+    COMMPAGE_DESCRIPTOR(spinlock_32_unlock_up,_COMM_PAGE_SPINLOCK_UNLOCK,kUP,k64Bit,0)
+
+
+spinlock_64_try_mp:
+1:
+        lwarx	r4,0,r3
+        cmpwi	r4,0
+        bne--	2f
+        stwcx.	r3,0,r3
+        isync				// cancel speculative execution
+        beqlr++
+        b		1b
+2:
+        li		r6,-4
+        stwcx.	r3,r6,r1	// clear the pending reservation (using red zone)
+        li		r3,0		// Pass failure
+        blr
+
+    COMMPAGE_DESCRIPTOR(spinlock_64_try_mp,_COMM_PAGE_SPINLOCK_TRY,k64Bit,kUP,0)
+
+
+spinlock_64_try_up:
+1:
+        lwarx	r4,0,r3
+        cmpwi	r4,0
+        bne--	2f
+        stwcx.	r3,0,r3
+        beqlr++
+        b		1b
+2:
+        li		r6,-4
+        stwcx.	r3,r6,r1	// clear the pending reservation (using red zone)
+        li		r3,0
+        blr
+
+    COMMPAGE_DESCRIPTOR(spinlock_64_try_up,_COMM_PAGE_SPINLOCK_TRY,k64Bit+kUP,0,0)
+
+
+spinlock_64_lock_mp:
+        li		r5,MP_SPIN_TRIES
+1:
+        lwarx	r4,0,r3
+        cmpwi	r4,0
+        bne--	2f
+        stwcx.	r3,0,r3
+        isync				// cancel speculative execution
+        beqlr++				// we return void
+        b		1b
+2:
+        li		r6,-4
+        stwcx.	r3,r6,r1	// clear the pending reservation (using red zone)
+        subic.	r5,r5,1		// try again before relinquish?
+        bne--	1b			// mispredict this one (a cheap back-off)
+        ba		_COMM_PAGE_RELINQUISH
+
+    COMMPAGE_DESCRIPTOR(spinlock_64_lock_mp,_COMM_PAGE_SPINLOCK_LOCK,k64Bit,kUP,0)
+
+
+spinlock_64_lock_up:
+1:
+        lwarx	r4,0,r3
+        cmpwi	r4,0
+        bne--	2f
+        stwcx.	r3,0,r3
+        beqlr++				// we return void
+        b		1b
+2:							// always relinquish on UP (let lock owner run)
+        li		r6,-4
+        stwcx.	r3,r6,r1	// clear the pending reservation (using red zone)
+		ba		_COMM_PAGE_RELINQUISH
+
+    COMMPAGE_DESCRIPTOR(spinlock_64_lock_up,_COMM_PAGE_SPINLOCK_LOCK,k64Bit+kUP,0,0)
+
+
+spinlock_64_unlock_mp:
+        li		r4,0
+        lwsync				// complete prior stores before unlock
+        stw		r4,0(r3)
+        blr
+
+    COMMPAGE_DESCRIPTOR(spinlock_64_unlock_mp,_COMM_PAGE_SPINLOCK_UNLOCK,k64Bit,kUP,0)
+
+
+spinlock_64_unlock_up:
+        li		r4,0
+        stw		r4,0(r3)
+        blr
+
+    COMMPAGE_DESCRIPTOR(spinlock_64_unlock_up,_COMM_PAGE_SPINLOCK_UNLOCK,k64Bit+kUP,0,0)
+    
+
+spinlock_relinquish:
+        mr		r12,r3		// preserve lockword ptr across relinquish
+        li		r3,0		// THREAD_NULL
+        li		r4,1		// SWITCH_OPTION_DEPRESS
+        li		r5,1		// timeout (ms)
+        li		r0,-61		// SYSCALL_THREAD_SWITCH
+        sc					// relinquish
+        mr		r3,r12
+        ba		_COMM_PAGE_SPINLOCK_LOCK
+        
+    COMMPAGE_DESCRIPTOR(spinlock_relinquish,_COMM_PAGE_RELINQUISH,0,0,0)
+
diff --git a/osfmk/ppc/conf.c b/osfmk/ppc/conf.c
index 585ef5b73..a1575fdca 100644
--- a/osfmk/ppc/conf.c
+++ b/osfmk/ppc/conf.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ppc/console_feed.c b/osfmk/ppc/console_feed.c
index be442911a..4c80ebf2d 100644
--- a/osfmk/ppc/console_feed.c
+++ b/osfmk/ppc/console_feed.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ppc/console_feed_entries.h b/osfmk/ppc/console_feed_entries.h
index 312734a44..1ea0de1ef 100644
--- a/osfmk/ppc/console_feed_entries.h
+++ b/osfmk/ppc/console_feed_entries.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ppc/cpu.c b/osfmk/ppc/cpu.c
index cbfab1860..97a56d260 100644
--- a/osfmk/ppc/cpu.c
+++ b/osfmk/ppc/cpu.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -38,8 +41,11 @@
 #include <ppc/machine_cpu.h>
 #include <ppc/exception.h>
 #include <ppc/asm.h>
+#include <ppc/hw_perfmon.h>
 #include <pexpert/pexpert.h>
 #include <kern/cpu_data.h>
+#include <ppc/mappings.h>
+#include <ppc/Diagnostics.h>
 
 /* TODO: BOGUS TO BE REMOVED */
 int real_ncpus = 1;
@@ -92,20 +98,15 @@ cpu_control(
 	     cpu_subtype != cmd->cmd_cpu_subtype)
 	  return(KERN_FAILURE);
 
+	if (perfmon_acquire_facility(current_task()) != KERN_SUCCESS) {
+		return(KERN_RESOURCE_SHORTAGE); /* cpu performance facility in use by another task */
+	}
+
 	switch (cmd->cmd_op)
 	  {
 	  case PROCESSOR_PM_CLR_PMC:       /* Clear Performance Monitor Counters */
 	    switch (cpu_subtype)
 	      {
-	      case CPU_SUBTYPE_POWERPC_604:
-		{
-		  oldlevel = ml_set_interrupts_enabled(FALSE);    /* disable interrupts */
-		  mtpmc1(0x0);
-		  mtpmc2(0x0);
-		  ml_set_interrupts_enabled(oldlevel);     /* enable interrupts */
-		  return(KERN_SUCCESS);
-		}
-	      case CPU_SUBTYPE_POWERPC_604e:
 	      case CPU_SUBTYPE_POWERPC_750:
 	      case CPU_SUBTYPE_POWERPC_7400:
 	      case CPU_SUBTYPE_POWERPC_7450:
@@ -124,21 +125,6 @@ cpu_control(
 	  case PROCESSOR_PM_SET_REGS:      /* Set Performance Monitor Registors */
 	    switch (cpu_subtype)
 	      {
-	      case CPU_SUBTYPE_POWERPC_604:
-		if (count <  (PROCESSOR_CONTROL_CMD_COUNT 
-			       + PROCESSOR_PM_REGS_COUNT_POWERPC_604))
-		  return(KERN_FAILURE);
-		else
-		  {
-		    perf_regs = (processor_pm_regs_t)cmd->cmd_pm_regs;
-		    oldlevel = ml_set_interrupts_enabled(FALSE);    /* disable interrupts */
-		    mtmmcr0(PERFMON_MMCR0(perf_regs) & MMCR0_SUPPORT_MASK);
-		    mtpmc1(PERFMON_PMC1(perf_regs));
-		    mtpmc2(PERFMON_PMC2(perf_regs));
-		    ml_set_interrupts_enabled(oldlevel);     /* enable interrupts */
-		    return(KERN_SUCCESS);
-		  }
-	      case CPU_SUBTYPE_POWERPC_604e:
 	      case CPU_SUBTYPE_POWERPC_750:
 		if (count <  (PROCESSOR_CONTROL_CMD_COUNT +
 		       PROCESSOR_PM_REGS_COUNT_POWERPC_750))
@@ -181,17 +167,6 @@ cpu_control(
 	  case PROCESSOR_PM_SET_MMCR:
 	    switch (cpu_subtype)
 	      {
-	      case CPU_SUBTYPE_POWERPC_604:
-		if (count < (PROCESSOR_CONTROL_CMD_COUNT +
-		       PROCESSOR_PM_REGS_COUNT_POWERPC_604))
-		  return(KERN_FAILURE);
-		else
-		  {
-		    perf_regs = (processor_pm_regs_t)cmd->cmd_pm_regs;
-		    mtmmcr0(PERFMON_MMCR0(perf_regs) & MMCR0_SUPPORT_MASK);
-		    return(KERN_SUCCESS);
-		  }
-	      case CPU_SUBTYPE_POWERPC_604e:
 	      case CPU_SUBTYPE_POWERPC_750:
 		if (count < (PROCESSOR_CONTROL_CMD_COUNT +
 		      PROCESSOR_PM_REGS_COUNT_POWERPC_750))
@@ -242,11 +217,6 @@ cpu_info_count(
 	switch (flavor) {
 		case PROCESSOR_PM_REGS_INFO:
 			switch (cpu_subtype) {
-				case CPU_SUBTYPE_POWERPC_604:
-					*count = PROCESSOR_PM_REGS_COUNT_POWERPC_604;
-					return(KERN_SUCCESS);
-
-				case CPU_SUBTYPE_POWERPC_604e:
 				case CPU_SUBTYPE_POWERPC_750:
 		
 					*count = PROCESSOR_PM_REGS_COUNT_POWERPC_750;
@@ -294,21 +264,6 @@ cpu_info(
 			perf_regs = (processor_pm_regs_t) info;
 
 			switch (cpu_subtype) {
-				case CPU_SUBTYPE_POWERPC_604:
-
-					if (*count < PROCESSOR_PM_REGS_COUNT_POWERPC_604)
-					  return(KERN_FAILURE);
-				  
-					oldlevel = ml_set_interrupts_enabled(FALSE);    /* disable interrupts */
-					PERFMON_MMCR0(perf_regs) = mfmmcr0();
-					PERFMON_PMC1(perf_regs)  = mfpmc1();
-					PERFMON_PMC2(perf_regs)  = mfpmc2();
-					ml_set_interrupts_enabled(oldlevel);     /* enable interrupts */
-		
-					*count = PROCESSOR_PM_REGS_COUNT_POWERPC_604;
-					return(KERN_SUCCESS);
-
-				case CPU_SUBTYPE_POWERPC_604e:
 				case CPU_SUBTYPE_POWERPC_750:
 
 					if (*count < PROCESSOR_PM_REGS_COUNT_POWERPC_750)
@@ -445,8 +400,8 @@ cpu_start(
 {
 	struct per_proc_info	*proc_info;
 	kern_return_t		ret;
+	mapping *mp;
 
-	extern void (*exception_handlers[])(void);
 	extern vm_offset_t	intstack;
 	extern vm_offset_t	debstack;
 
@@ -475,15 +430,17 @@ cpu_start(
 		proc_info->need_ast = (unsigned int)&need_ast[cpu];
 		proc_info->FPU_owner = 0;
 		proc_info->VMX_owner = 0;
-
+		mp = (mapping *)(&proc_info->ppCIOmp);
+		mp->mpFlags = 0x01000000 | mpSpecial | 1;
+		mp->mpSpace = invalSpace;
 
 		if (proc_info->start_paddr == EXCEPTION_VECTOR(T_RESET)) {
 
 			/* TODO: get mutex lock reset_handler_lock */
 
 			resethandler_target.type = RESET_HANDLER_START;
-			resethandler_target.call_paddr = kvtophys((vm_offset_t)_start_cpu); 
-			resethandler_target.arg__paddr = kvtophys((vm_offset_t)proc_info);
+			resethandler_target.call_paddr = (vm_offset_t)_start_cpu; 	/* Note: these routines are always V=R */
+			resethandler_target.arg__paddr = (vm_offset_t)proc_info; 	/* Note: these routines are always V=R */
 			
 			ml_phys_write((vm_offset_t)&ResetHandler + 0,
 				      resethandler_target.type);
@@ -539,10 +496,10 @@ cpu_signal_handler(
 	pproc = &per_proc_info[cpu];					/* Point to our block */
 
 /*
- *	Since we've been signaled, wait just under 1ms for the signal lock to pass
+ *	Since we've been signaled, wait about 31 ms for the signal lock to pass
  */
 	if(!hw_lock_mbits(&pproc->MPsigpStat, (MPsigpMsgp | MPsigpAck), (MPsigpBusy | MPsigpPass),
-	  (MPsigpBusy | MPsigpPass | MPsigpAck), (gPEClockFrequencyInfo.bus_clock_rate_hz >> 7))) {
+	  (MPsigpBusy | MPsigpPass | MPsigpAck), (gPEClockFrequencyInfo.timebase_frequency_hz >> 5))) {
 		panic("cpu_signal_handler: Lock pass timed out\n");
 	}
 	
@@ -565,7 +522,7 @@ cpu_signal_handler(
 			switch (holdParm0) {					/* Decode SIGP message order */
 
 				case SIGPast:						/* Should we do an AST? */
-					pproc->numSIGPast++;			/* Count this one */
+					pproc->hwCtr.numSIGPast++;		/* Count this one */
 #if 0
 					kprintf("cpu_signal_handler: AST check on cpu %x\n", cpu_number());
 #endif
@@ -574,7 +531,7 @@ cpu_signal_handler(
 					
 				case SIGPcpureq:					/* CPU specific function? */
 				
-					pproc->numSIGPcpureq++;			/* Count this one */
+					pproc->hwCtr.numSIGPcpureq++;	/* Count this one */
 					switch (holdParm1) {			/* Select specific function */
 					
 						case CPRQtemp:				/* Get the temperature */
@@ -614,6 +571,10 @@ cpu_signal_handler(
 							timebaseAddr->done = TRUE;
 
 							return;
+						
+						case CPRQscom:
+							fwSCOM((scomcomm *)holdParm2);	/* Do the function */
+							return;
 
 						default:
 							panic("cpu_signal_handler: unknown CPU request - %08X\n", holdParm1);
@@ -623,14 +584,14 @@ cpu_signal_handler(
 	
 				case SIGPdebug:						/* Enter the debugger? */		
 
-					pproc->numSIGPdebug++;			/* Count this one */
+					pproc->hwCtr.numSIGPdebug++;	/* Count this one */
 					debugger_is_slave[cpu]++;		/* Bump up the count to show we're here */
 					hw_atomic_sub(&debugger_sync, 1);	/* Show we've received the 'rupt */
 					__asm__ volatile("tw 4,r3,r3");	/* Enter the debugger */
 					return;							/* All done now... */
 					
 				case SIGPwake:						/* Wake up CPU */
-					pproc->numSIGPwake++;			/* Count this one */
+					pproc->hwCtr.numSIGPwake++;		/* Count this one */
 					return;							/* No need to do anything, the interrupt does it all... */
 					
 				default:
@@ -690,12 +651,12 @@ cpu_signal(
 	if((tpproc->MPsigpStat & MPsigpMsgp) == MPsigpMsgp) {	/* Is there an unreceived message already pending? */
 
 		if(signal == SIGPwake) {					/* SIGPwake can merge into all others... */
-			mpproc->numSIGPmwake++;					/* Account for merged wakes */
+			mpproc->hwCtr.numSIGPmwake++;			/* Account for merged wakes */
 			return KERN_SUCCESS;
 		}
 
 		if((signal == SIGPast) && (tpproc->MPsigpParm0 == SIGPast)) {	/* We can merge ASTs */
-			mpproc->numSIGPmast++;					/* Account for merged ASTs */
+			mpproc->hwCtr.numSIGPmast++;			/* Account for merged ASTs */
 			return KERN_SUCCESS;					/* Don't bother to send this one... */
 		}
 
@@ -703,15 +664,15 @@ cpu_signal(
 			if (hw_lock_mbits(&tpproc->MPsigpStat, (MPsigpMsgp | MPsigpAck), 
 			                  (MPsigpBusy | MPsigpPass ), MPsigpBusy, 0)) {
 				busybitset = 1;
-				mpproc->numSIGPmwake++;	
+				mpproc->hwCtr.numSIGPmwake++;	
 			}
 		}
 	}	
 	
 	if((busybitset == 0) && 
 	   (!hw_lock_mbits(&tpproc->MPsigpStat, MPsigpMsgp, 0, MPsigpBusy, 
-	   (gPEClockFrequencyInfo.bus_clock_rate_hz >> 13)))) {	/* Try to lock the message block with a .5ms timeout */
-		mpproc->numSIGPtimo++;						/* Account for timeouts */
+	   (gPEClockFrequencyInfo.timebase_frequency_hz >> 11)))) {	/* Try to lock the message block with a .5ms timeout */
+		mpproc->hwCtr.numSIGPtimo++;				/* Account for timeouts */
 		return KERN_FAILURE;						/* Timed out, take your ball and go home... */
 	}
 
@@ -735,6 +696,7 @@ void
 cpu_doshutdown(
 	void)
 {
+	enable_preemption();
 	processor_doshutdown(current_processor());
 }
 
@@ -745,15 +707,11 @@ cpu_sleep(
 	struct per_proc_info	*proc_info;
 	unsigned int	cpu;
 	facility_context *fowner;
-	extern void (*exception_handlers[])(void);
 	extern vm_offset_t	intstack;
 	extern vm_offset_t	debstack;
 	extern void _restart_cpu(void);
 
 	cpu = cpu_number();
-#if 0
-	kprintf("******* About to sleep cpu %d\n", cpu);
-#endif
 
 	proc_info = &per_proc_info[cpu];
 
@@ -779,8 +737,8 @@ cpu_sleep(
 			extern void _start_cpu(void);
 	
 			resethandler_target.type = RESET_HANDLER_START;
-			resethandler_target.call_paddr = kvtophys((vm_offset_t)_start_cpu); 
-			resethandler_target.arg__paddr = kvtophys((vm_offset_t)proc_info);
+			resethandler_target.call_paddr = (vm_offset_t)_start_cpu; 	/* Note: these routines are always V=R */
+			resethandler_target.arg__paddr = (vm_offset_t)proc_info; 	/* Note: these routines are always V=R */
 	
 			ml_phys_write((vm_offset_t)&ResetHandler + 0,
 					  resethandler_target.type);
diff --git a/osfmk/ppc/cpu_capabilities.h b/osfmk/ppc/cpu_capabilities.h
new file mode 100644
index 000000000..ae54cc1b3
--- /dev/null
+++ b/osfmk/ppc/cpu_capabilities.h
@@ -0,0 +1,160 @@
+/*
+ * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ * 
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ * 
+ * @APPLE_LICENSE_HEADER_END@
+ */
+
+#ifndef _PPC_CPU_CAPABILITIES_H
+#define _PPC_CPU_CAPABILITIES_H
+
+/* Sadly, some clients of this interface misspell __APPLE_API_PRIVATE.
+ * To avoid breaking them, we accept the incorrect _APPLE_API_PRIVATE.
+ */
+#ifdef	_APPLE_API_PRIVATE
+#ifndef __APPLE_API_PRIVATE
+#define	__APPLE_API_PRIVATE
+#endif	/* __APPLE_API_PRIVATE */
+#endif	/* _APPLE_API_PRIVATE */
+ 
+#ifndef __APPLE_API_PRIVATE
+#error	cpu_capabilities.h is for Apple Internal use only
+#else	/* __APPLE_API_PRIVATE */
+
+/* _cpu_capabilities
+ *
+ * This is the authoritative way to determine from user mode what
+ * implementation-specific processor features are available.
+ * This API only supported for Apple internal use.
+ * 
+ */
+
+#ifndef	__ASSEMBLER__
+ 
+extern int _cpu_capabilities;
+ 
+#endif /* __ASSEMBLER__ */
+
+/* Bit definitions for _cpu_capabilities: */
+
+#define	kHasAltivec				0x00000001
+#define	k64Bit					0x00000002	// 64-bit GPRs
+#define	kCache32				0x00000004	// cache line size is 32 bytes
+#define	kCache64				0x00000008
+#define	kCache128				0x00000010
+#define	kDcbaRecommended		0x00000020	// PPC: dcba is available and recommended
+#define	kDcbaAvailable			0x00000040	// PPC: dcba is available but is not recommended
+#define	kDataStreamsRecommended	0x00000080	// PPC: dst, dstt, dstst, dss, and dssall instructions available and recommended
+#define	kDataStreamsAvailable	0x00000100	// PPC: dst, dstt, dstst, dss, and dssall instructions available but not recommended
+#define	kDcbtStreamsRecommended	0x00000200	// PPC: enhanced dcbt instruction available and recommended
+#define	kDcbtStreamsAvailable	0x00000400	// PPC: enhanced dcbt instruction available and recommended
+
+#define	kUP						0x00008000	// set if (kNumCPUs == 1)
+#define	kNumCPUs				0x00FF0000	// number of CPUs (see _NumCPUs() below)
+
+#define	kNumCPUsShift			16			// see _NumCPUs() below
+
+#define	kHasGraphicsOps			0x08000000	// PPC: has fres, frsqrte, and fsel instructions
+#define	kHasStfiwx				0x10000000	// PPC: has stfiwx instruction
+#define	kHasFsqrt				0x20000000	// PPC: has fsqrt and fsqrts instructions
+
+#ifndef	__ASSEMBLER__
+ 
+static __inline__ int _NumCPUs( void ) { return (_cpu_capabilities & kNumCPUs) >> kNumCPUsShift; }
+
+#endif /* __ASSEMBLER__ */
+
+
+/*
+ * The shared kernel/user "comm page(s)":
+ *
+ * The last eight pages of every address space are reserved for the kernel/user
+ * "comm area".  Because they can be addressed via a sign-extended 16-bit field,
+ * it is particularly efficient to access code or data in the comm area with
+ * absolute branches (ba, bla, bca) or absolute load/stores ("lwz r0,-4096(0)").
+ * Because the comm area can be reached from anywhere, dyld is not needed.
+ * Although eight pages are reserved, presently only two are populated and mapped.
+ *
+ * Routines on the comm page(s) can be thought of as the firmware for extended processor
+ * instructions, whose opcodes are special forms of "bla".  Ie, they are cpu
+ * capabilities.  During system initialization, the kernel populates the comm page with
+ * code customized for the particular processor and platform.
+ *
+ * Because Mach VM cannot map the last page of an address space, the max length of
+ * the comm area is seven pages.
+ */
+ 
+#define _COMM_PAGE_BASE_ADDRESS			(-8*4096)						// start at page -8, ie 0xFFFF8000
+#define	_COMM_PAGE_AREA_LENGTH			( 7*4096)						// reserved length of entire comm area
+#define	_COMM_PAGE_AREA_USED			( 2*4096)						// we use two pages so far
+ 
+/* data in the comm page */
+ 
+#define _COMM_PAGE_SIGNATURE			(_COMM_PAGE_BASE_ADDRESS+0x000)	// first few bytes are a signature
+#define _COMM_PAGE_VERSION				(_COMM_PAGE_BASE_ADDRESS+0x01E)	// 16-bit version#
+#define	_COMM_PAGE_THIS_VERSION			1								// this is version 1 of the commarea format
+  
+#define _COMM_PAGE_CPU_CAPABILITIES		(_COMM_PAGE_BASE_ADDRESS+0x020)	// mirror of extern int _cpu_capabilities
+#define _COMM_PAGE_NCPUS				(_COMM_PAGE_BASE_ADDRESS+0x021)	// number of configured CPUs
+#define _COMM_PAGE_ALTIVEC				(_COMM_PAGE_BASE_ADDRESS+0x024)	// nonzero if Altivec available
+#define _COMM_PAGE_64_BIT				(_COMM_PAGE_BASE_ADDRESS+0x025)	// nonzero if 64-bit processor
+#define _COMM_PAGE_CACHE_LINESIZE		(_COMM_PAGE_BASE_ADDRESS+0x026)	// cache line size (16-bit field)
+ 
+#define _COMM_PAGE_UNUSED1				(_COMM_PAGE_BASE_ADDRESS+0x030)	// 16 unused bytes
+ 
+#define _COMM_PAGE_2_TO_52				(_COMM_PAGE_BASE_ADDRESS+0x040)	// double float constant 2**52
+#define _COMM_PAGE_10_TO_6				(_COMM_PAGE_BASE_ADDRESS+0x048)	// double float constant 10**6
+ 
+#define _COMM_PAGE_UNUSED2				(_COMM_PAGE_BASE_ADDRESS+0x050)	// 16 unused bytes
+ 
+#define _COMM_PAGE_TIMEBASE				(_COMM_PAGE_BASE_ADDRESS+0x060)	// used by gettimeofday()
+#define _COMM_PAGE_TIMESTAMP			(_COMM_PAGE_BASE_ADDRESS+0x068)	// used by gettimeofday()
+#define _COMM_PAGE_SEC_PER_TICK			(_COMM_PAGE_BASE_ADDRESS+0x070)	// used by gettimeofday()
+ 
+#define _COMM_PAGE_UNUSED3				(_COMM_PAGE_BASE_ADDRESS+0x080)	// 384 unused bytes
+ 
+ /* jump table (bla to this address, which may be a branch to the actual code somewhere else) */
+ 
+#define _COMM_PAGE_ABSOLUTE_TIME		(_COMM_PAGE_BASE_ADDRESS+0x200)	// mach_absolute_time()
+#define _COMM_PAGE_SPINLOCK_TRY			(_COMM_PAGE_BASE_ADDRESS+0x220)	// spinlock_try()
+#define _COMM_PAGE_SPINLOCK_LOCK		(_COMM_PAGE_BASE_ADDRESS+0x260)	// spinlock_lock()
+#define _COMM_PAGE_SPINLOCK_UNLOCK		(_COMM_PAGE_BASE_ADDRESS+0x2a0)	// spinlock_unlock()
+#define _COMM_PAGE_PTHREAD_GETSPECIFIC	(_COMM_PAGE_BASE_ADDRESS+0x2c0)	// pthread_getspecific()
+#define _COMM_PAGE_GETTIMEOFDAY			(_COMM_PAGE_BASE_ADDRESS+0x2e0)	// used by gettimeofday()
+#define _COMM_PAGE_FLUSH_DCACHE			(_COMM_PAGE_BASE_ADDRESS+0x4e0)	// sys_dcache_flush()
+#define _COMM_PAGE_FLUSH_ICACHE			(_COMM_PAGE_BASE_ADDRESS+0x520)	// sys_icache_invalidate()
+#define _COMM_PAGE_PTHREAD_SELF			(_COMM_PAGE_BASE_ADDRESS+0x580)	// pthread_self()
+#define	_COMM_PAGE_UNUSED4				(_COMM_PAGE_BASE_ADDRESS+0x5a0)	// 32 unused bytes
+#define	_COMM_PAGE_RELINQUISH			(_COMM_PAGE_BASE_ADDRESS+0x5c0)	// used by spinlocks
+ 
+#define _COMM_PAGE_UNUSED5				(_COMM_PAGE_BASE_ADDRESS+0x5e0)	// 32 unused bytes
+ 
+#define _COMM_PAGE_BZERO				(_COMM_PAGE_BASE_ADDRESS+0x600)	// bzero()
+#define _COMM_PAGE_BCOPY				(_COMM_PAGE_BASE_ADDRESS+0x780)	// bcopy()
+#define	_COMM_PAGE_MEMCPY				(_COMM_PAGE_BASE_ADDRESS+0x7a0)	// memcpy()
+#define	_COMM_PAGE_MEMMOVE				(_COMM_PAGE_BASE_ADDRESS+0x7a0)	// memmove()
+
+#define	_COMM_PAGE_UNUSED6				(_COMM_PAGE_BASE_ADDRESS+0xF80)	// 128 unused bytes
+
+#define	_COMM_PAGE_BIGCOPY				(_COMM_PAGE_BASE_ADDRESS+0x1000)// very-long-operand copies
+
+#endif /* __APPLE_API_PRIVATE */
+#endif /* _PPC_CPU_CAPABILITIES_H */
diff --git a/osfmk/ppc/cpu_data.h b/osfmk/ppc/cpu_data.h
index e97ccb865..6c5da111a 100644
--- a/osfmk/ppc/cpu_data.h
+++ b/osfmk/ppc/cpu_data.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -42,7 +45,17 @@ extern __inline__ thread_act_t current_act(void)
 	thread_act_t act;
 	__asm__ volatile("mfsprg %0,1" : "=r" (act));  
 	return act;
-}
+};
+
+/*
+ *	Note that the following function is ONLY guaranteed when preemption or interrupts are disabled
+ */
+extern __inline__ struct per_proc_info *getPerProc(void) 
+{
+	struct per_proc_info *perproc;
+	__asm__ volatile("mfsprg %0,0" : "=r" (perproc));  
+	return perproc;
+};
 
 #define	current_thread()	current_act()->thread
 
diff --git a/osfmk/ppc/cpu_number.h b/osfmk/ppc/cpu_number.h
index 1c3626e58..30a43fbc8 100644
--- a/osfmk/ppc/cpu_number.h
+++ b/osfmk/ppc/cpu_number.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ppc/cswtch.s b/osfmk/ppc/cswtch.s
index 148730393..28e69c4a6 100644
--- a/osfmk/ppc/cswtch.s
+++ b/osfmk/ppc/cswtch.s
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -59,7 +62,7 @@ LEXT(Load_context)
 /*
  * Since this is the first thread, we came in on the interrupt
  * stack. The first thread never returns, so there is no need to
- e worry about saving its frame, hence we can reset the istackptr
+ * worry about saving its frame, hence we can reset the istackptr
  * back to the saved_state structure at it's top
  */
 			
@@ -79,19 +82,16 @@ LEXT(Load_context)
 			lwz		r12,PP_ACTIVE_STACKS(r6)
 			lwz		r1,THREAD_KERNEL_STACK(r3)
 			lwz		r9,THREAD_TOP_ACT(r3)			/* Point to the active activation */
-			mtsprg		1,r9
+			mtsprg	1,r9
 			stw		r1,0(r12)
 			li		r0,0							/* Clear a register */
-			lwz		r8,ACT_MACT_PCB(r9)				/* Get the savearea used */
-			rlwinm	r7,r8,0,0,19					/* Switch to savearea base */
-			lwz		r11,SAVprev(r8)					/* Get the previous savearea */
+			lwz		r3,ACT_MACT_PCB(r9)				/* Get the savearea used */
 			mfmsr	r5								/* Since we are passing control, get our MSR values */
-			lwz		r1,saver1(r8)					/* Load new stack pointer */
-			stw		r0,saver3(r8)					/* Make sure we pass in a 0 for the continuation */
-			lwz		r7,SACvrswap(r7)				/* Get the translation from virtual to real */
+			lwz		r11,SAVprev+4(r3)				/* Get the previous savearea */
+			lwz		r1,saver1+4(r3)					/* Load new stack pointer */
+			stw		r0,saver3+4(r3)					/* Make sure we pass in a 0 for the continuation */
 			stw		r0,FM_BACKPTR(r1)				/* zero backptr */
-			stw		r5,savesrr1(r8)					/* Pass our MSR to the new guy */
-			xor		r3,r7,r8						/* Get the physical address of the new context save area */
+			stw		r5,savesrr1+4(r3)				/* Pass our MSR to the new guy */
 			stw		r11,ACT_MACT_PCB(r9)			/* Unstack our savearea */
 			b		EXT(exception_exit)				/* Go end it all... */
 	
@@ -119,19 +119,18 @@ LEXT(Call_continuation)
 /*
  * Get the old kernel stack, and store into the thread structure.
  * See if a continuation is supplied, and skip state save if so.
- * NB. Continuations are no longer used, so this test is omitted,
- * as should the second argument, but it is in generic code.
- * We always save state. This does not hurt even if continuations
- * are put back in.
+ *
+ * Note that interrupts must be disabled before we get here (i.e., splsched)
  */
 
 /* 			Context switches are double jumps.  We pass the following to the
  *			context switch firmware call:
  *
- *			R3  = switchee's savearea
+ *			R3  = switchee's savearea, virtual if continuation, low order physical for full switch
  *			R4  = old thread
  *			R5  = new SRR0
  *			R6  = new SRR1
+ *			R7  = high order physical address of savearea for full switch
  *
  *			savesrr0 is set to go to switch_in
  *			savesrr1 is set to uninterruptible with translation on
@@ -143,169 +142,169 @@ LEXT(Call_continuation)
 
 LEXT(Switch_context)
 
+			lwz		r11,THREAD_KERNEL_STACK(r5)		; Get the new stack pointer
 			mfsprg	r12,0							; Get the per_proc block
 			lwz		r10,PP_ACTIVE_STACKS(r12)		; Get the pointer to the current stack
 #if DEBUG
-			lwz		r11,PP_ISTACKPTR(r12)			; (DEBUG/TRACE) make sure we are not
-			mr.		r11,r11							; (DEBUG/TRACE) on the interrupt
-			bne+	notonintstack					; (DEBUG/TRACE) stack
+			lwz		r0,PP_ISTACKPTR(r12)			; (DEBUG/TRACE) make sure we are not
+			mr.		r0,r0							; (DEBUG/TRACE) on the interrupt
+			bne++	notonintstack					; (DEBUG/TRACE) stack
 			BREAKPOINT_TRAP
 notonintstack:
 #endif	
- 			stw		r4,THREAD_CONTINUATION(r3)		; Set continuation into the thread
-			cmpwi	cr1,r4,0						; used waaaay down below 
+		
+#if 0
+			lwz		r8,lgPPStart(0)					; (TEST/DEBUG) Get the start of per_procs
+			sub		r7,r12,r8						; (TEST/DEBUG) Find offset to our per_proc
+			xori	r7,r7,0x1000					; (TEST/DEBUG) Switch to other proc
+			add		r8,r8,r7						; (TEST/DEBUG) Switch to it
+			lwz		r8,PP_ACTIVE_THREAD(r8)			; (TEST/DEBUG) Get the other active thread
+			cmplw	r8,r5							; (TEST/DEBUG) Trying to switch to an active thread?
+			bne++	snively							; (TEST/DEBUG) Nope...
+			BREAKPOINT_TRAP							; (TEST/DEBUG) Get to debugger...
+
+snively:											; (TEST/DEBUG)
+#endif
+
+			stw		r5,PP_ACTIVE_THREAD(r12)		; Make the new thread current
+ 			lwz		r5,THREAD_TOP_ACT(r5)			; Get the new activation
+			stw		r4,THREAD_CONTINUATION(r3)		; Set continuation into the thread
 			lwz		r7,0(r10)						; Get the current stack
-/*
- * Make the new thread the current thread.
- */
-	
+			cmpwi	cr1,r4,0						; Remeber if there is a continuation - used waaaay down below 
+			stw		r11,0(r10)						; Save the new kernel stack address
+
+			lwz		r8,ACT_MACT_PCB(r5)				; Get the PCB for the new guy
+			lwz		r9,cioSpace(r5)					; Get copyin/out address space
 			stw		r7,THREAD_KERNEL_STACK(r3)		; Remember the current stack in the thread (do not need???)
-			stw		r5,	PP_ACTIVE_THREAD(r12)		; Make the new thread current
-			
-			lwz		r11,THREAD_KERNEL_STACK(r5)		; Get the new stack pointer
-		
-			lwz		r5,THREAD_TOP_ACT(r5)			; Get the new activation
-			mtsprg		1,r5
+			mtsprg	1,r5							; Set the current activation pointer
 			lwz		r7,CTHREAD_SELF(r5)				; Pick up the user assist word
-			lwz		r8,ACT_MACT_PCB(r5)				; Get the PCB for the new guy
-			
-#if 0
-			lwz		r0,SAVflags(r8)					; (TEST/DEBUG)
-			rlwinm	r0,r0,24,24,31					; (TEST/DEBUG)
-			cmplwi	r0,SAVempty						; (TEST/DEBUG)
-			bne+	nnnn							; (TEST/DEBUG)
-			b		.								; (TEST/DEBUG)
-nnnn:												; (TEST/DEBUG)
-#endif			
+			lwz		r11,ACT_MACT_BTE(r5)			; Get BlueBox Task Environment
+			lwz		r6,cioRelo(r5)					; Get copyin/out relocation top
+			lwz		r2,cioRelo+4(r5)				; Get copyin/out relocation bottom
 			
-			stw		r11,0(r10)						; Save the new kernel stack address
 			stw		r7,UAW(r12)						; Save the assist word for the "ultra fast path"
-			
-			lwz		r11,ACT_MACT_BTE(r5)			; Get BlueBox Task Environment
-		
+
 			lwz		r7,ACT_MACT_SPF(r5)				; Get the special flags
 			
-			lwz		r10,ACT_KLOADED(r5)
+			lwz		r0,ACT_KLOADED(r5)
+			sth		r9,ppCIOmp+mpSpace(r12)			; Save the space
+			stw		r6,ppCIOmp+mpNestReloc(r12)		; Save top part of physical address
+			stw		r2,ppCIOmp+mpNestReloc+4(r12)	; Save bottom part of physical address
+			lwz		r10,PP_ACTIVE_KLOADED(r12)		; Get kernel loaded flag address
+			subfic	r0,r0,0							; Get bit 0 to 0 if not kloaded, 1 otherwise
+			lwz		r2,traceMask(0)					; Get the enabled traces
 			stw		r11,ppbbTaskEnv(r12)			; Save the bb task env
-			li		r0,0
-			cmpwi	cr0,r10,0
-			lwz		r10,PP_ACTIVE_KLOADED(r12)
+			srawi	r0,r0,31						; Get 0 if not kloaded, ffffffff otherwise
 			stw		r7,spcFlags(r12)				; Set per_proc copy of the special flags
-			beq		cr0,.L_sw_ctx_not_kld
+			and		r0,r5,r0						; Get 0 if not kloaded, activation otherwise
 		
-			stw		r5,0(r10)
-			b		.L_sw_ctx_cont
-
-.L_sw_ctx_not_kld:	
-			stw		r0,0(r10)						/* act_kloaded = 0 */
-
-.L_sw_ctx_cont:	
-			lis		r10,hi16(EXT(trcWork))			; Get top of trace mask
-			rlwinm	r7,r8,0,0,19					/* Switch to savearea base */
-			ori		r10,r10,lo16(EXT(trcWork))		; Get bottom of mask
-			lwz		r11,SAVprev(r8)					/* Get the previous of the switchee's savearea */
-			lwz		r10,traceMask(r10)				; Get the enabled traces
+			mr.		r2,r2							; Any tracing going on?
+			stw		r0,0(r10)						; Set the kloaded stuff
 			lis		r0,hi16(CutTrace)				; Trace FW call
-			mr.		r10,r10							; Any tracing going on?
+			lwz		r11,SAVprev+4(r8)				; Get the previous of the switchee savearea 
 			ori		r0,r0,lo16(CutTrace)			; Trace FW call
-			beq+	cswNoTrc						; No trace today, dude...
 			mr		r10,r3							; Save across trace
+			beq++	cswNoTrc						; No trace today, dude...
 			lwz		r2,THREAD_TOP_ACT(r3)			; Trace old activation
 			mr		r3,r11							; Trace prev savearea
 			sc										; Cut trace entry of context switch
 			mr		r3,r10							; Restore
 			
-cswNoTrc:	mfmsr	r6								/* Get the MSR because the switched to thread should inherit it */
-			lwz		r7,SACvrswap(r7)				/* Get the translation from virtual to real */
-			stw		r11,ACT_MACT_PCB(r5)			/* Dequeue the savearea we're switching to */
-
-			rlwinm	r6,r6,0,MSR_FP_BIT+1,MSR_FP_BIT-1	/* Turn off the FP */
-			lwz		r2,curctx(r5)					; Grab our current context pointer
-			rlwinm	r6,r6,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	/* Turn off the vector */
-			mr		r4,r3							/* Save our old thread to pass back */
-			
-			lhz		r0,PP_CPU_NUMBER(r12)			; Get our CPU number
+cswNoTrc:	lwz		r2,curctx(r5)					; Grab our current context pointer
 			lwz		r10,FPUowner(r12)				; Grab the owner of the FPU			
 			lwz		r9,VMXowner(r12)				; Grab the owner of the vector
+			lhz		r0,PP_CPU_NUMBER(r12)			; Get our CPU number
+			mfmsr	r6								; Get the MSR because the switched to thread should inherit it 
+			stw		r11,ACT_MACT_PCB(r5)			; Dequeue the savearea we are switching to
+			li		r0,1							; Get set to hold off quickfret
+
+			rlwinm	r6,r6,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Turn off the FP
 			cmplw	r10,r2							; Do we have the live float context?
 			lwz		r10,FPUlevel(r2)				; Get the live level
+			mr		r4,r3							; Save our old thread to pass back 
 			cmplw	cr5,r9,r2						; Do we have the live vector context?		
-			bne+	cswnofloat						; Float is not ours...
+			rlwinm	r6,r6,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Turn off the vector
+			stw		r0,holdQFret(r12)				; Make sure we hold off releasing quickfret
+			bne++	cswnofloat						; Float is not ours...
 			
 			cmplw	r10,r11							; Is the level the same?
 			lwz		r5,FPUcpu(r2)					; Get the owning cpu
-			bne+	cswnofloat						; Level not the same, this is not live...
+			bne++	cswnofloat						; Level not the same, this is not live...
 			
 			cmplw	r5,r0							; Still owned by this cpu?
 			lwz		r10,FPUsave(r2)					; Get the level
-			bne+	cswnofloat						; CPU claimed by someone else...
+			bne++	cswnofloat						; CPU claimed by someone else...
 			
 			mr.		r10,r10							; Is there a savearea here?
 			ori		r6,r6,lo16(MASK(MSR_FP))		; Enable floating point
 			
-			beq-	cswnofloat						; No savearea to check...
+			beq--	cswnofloat						; No savearea to check...
 			
 			lwz		r3,SAVlevel(r10)				; Get the level
-			lwz		r5,SAVprev(r10)					; Get the previous of this savearea
+			lwz		r5,SAVprev+4(r10)				; Get the previous of this savearea
 			cmplw	r3,r11							; Is it for the current level?
 			
-			bne+	cswnofloat						; Nope...
+			bne++	cswnofloat						; Nope...
 			
 			stw		r5,FPUsave(r2)					; Pop off this savearea
-			rlwinm	r5,r10,0,0,19					; Move back to start of page
-			lwz		r5,SACvrswap(r5)				; Get the virtual to real conversion
-			la		r9,quickfret(r12)				; Point to the quickfret chain header					
-			xor		r5,r10,r5						; Convert savearea address to real
+
+			rlwinm	r3,r10,0,0,19					; Move back to start of page
+
+			lwz		r5,quickfret(r12)				; Get the first in quickfret list (top)					
+			lwz		r9,quickfret+4(r12)				; Get the first in quickfret list (bottom)					
+			lwz		r7,SACvrswap(r3)				; Get the virtual to real conversion (top)
+			lwz		r3,SACvrswap+4(r3)				; Get the virtual to real conversion (bottom)
+			stw		r5,SAVprev(r10)					; Link the old in (top)					
+			stw		r9,SAVprev+4(r10)				; Link the old in (bottom)					
+			xor		r3,r10,r3						; Convert to physical
+			stw		r7,quickfret(r12)				; Set the first in quickfret list (top)					
+			stw		r3,quickfret+4(r12)				; Set the first in quickfret list (bottom)					
 
 #if FPVECDBG
 			lis		r0,hi16(CutTrace)				; (TEST/DEBUG)
+			mr		r7,r2							; (TEST/DEBUG)
 			li		r2,0x4401						; (TEST/DEBUG)
 			oris	r0,r0,lo16(CutTrace)			; (TEST/DEBUG)
 			sc										; (TEST/DEBUG)
 			lhz		r0,PP_CPU_NUMBER(r12)			; (TEST/DEBUG)
+			mr		r2,r7							; (TEST/DEBUG) 
 #endif	
 
-;
-;			Note: we need to do the atomic operation here because, even though
-;			it is impossible with the current implementation, that we may take a
-;			PTE miss between the load of the quickfret anchor and the subsequent
-;			store.  The interrupt handler will dequeue everything on the list and
-;			we could end up using stale data.  I do not like doing this...
-;
-
-cswfpudq:	lwarx	r3,0,r9							; Pick up the old chain head
-			stw		r3,SAVprev(r10)					; Move it to the current guy
-			stwcx.	r5,0,r9							; Save it
-			bne-	cswfpudq						; Someone chaged the list...
-
-cswnofloat:	bne+	cr5,cswnovect					; Vector is not ours...
+cswnofloat:	bne++	cr5,cswnovect					; Vector is not ours...
 
 			lwz		r10,VMXlevel(r2)				; Get the live level
 			
 			cmplw	r10,r11							; Is the level the same?
 			lwz		r5,VMXcpu(r2)					; Get the owning cpu
-			bne+	cswnovect						; Level not the same, this is not live...
+			bne++	cswnovect						; Level not the same, this is not live...
 			
 			cmplw	r5,r0							; Still owned by this cpu?
 			lwz		r10,VMXsave(r2)					; Get the level
-			bne+	cswnovect						; CPU claimed by someone else...
+			bne++	cswnovect						; CPU claimed by someone else...
 			
 			mr.		r10,r10							; Is there a savearea here?
 			oris	r6,r6,hi16(MASK(MSR_VEC))		; Enable vector
 			
-			beq-	cswnovect						; No savearea to check...
+			beq--	cswnovect						; No savearea to check...
 			
 			lwz		r3,SAVlevel(r10)				; Get the level
-			lwz		r5,SAVprev(r10)					; Get the previous of this savearea
+			lwz		r5,SAVprev+4(r10)				; Get the previous of this savearea
 			cmplw	r3,r11							; Is it for the current level?
 			
-			bne+	cswnovect						; Nope...
+			bne++	cswnovect						; Nope...
 			
 			stw		r5,VMXsave(r2)					; Pop off this savearea
-			rlwinm	r5,r10,0,0,19					; Move back to start of page
-			lwz		r5,SACvrswap(r5)				; Get the virtual to real conversion
-			la		r9,quickfret(r12)				; Point to the quickfret chain header					
-			xor		r5,r10,r5						; Convert savearea address to real
+			rlwinm	r3,r10,0,0,19					; Move back to start of page
+
+			lwz		r5,quickfret(r12)				; Get the first in quickfret list (top)					
+			lwz		r9,quickfret+4(r12)				; Get the first in quickfret list (bottom)					
+			lwz		r2,SACvrswap(r3)				; Get the virtual to real conversion (top)
+			lwz		r3,SACvrswap+4(r3)				; Get the virtual to real conversion (bottom)
+			stw		r5,SAVprev(r10)					; Link the old in (top)					
+			stw		r9,SAVprev+4(r10)				; Link the old in (bottom)					
+			xor		r3,r10,r3						; Convert to physical
+			stw		r2,quickfret(r12)				; Set the first in quickfret list (top)					
+			stw		r3,quickfret+4(r12)				; Set the first in quickfret list (bottom)					
 
 #if FPVECDBG
 			lis		r0,hi16(CutTrace)				; (TEST/DEBUG)
@@ -314,31 +313,23 @@ cswnofloat:	bne+	cr5,cswnovect					; Vector is not ours...
 			sc										; (TEST/DEBUG)
 #endif	
 
-;
-;			Note: we need to do the atomic operation here because, even though
-;			it is impossible with the current implementation, that we may take a
-;			PTE miss between the load of the quickfret anchor and the subsequent
-;			store.  The interrupt handler will dequeue everything on the list and
-;			we could end up using stale data.  I do not like doing this...
-;
-
-cswvecdq:	lwarx	r3,0,r9							; Pick up the old chain head
-			stw		r3,SAVprev(r10)					; Move it to the current guy
-			stwcx.	r5,0,r9							; Save it
-			bne-	cswvecdq						; Someone chaged the list...
+cswnovect:	li		r0,0							; Get set to release quickfret holdoff	
+			rlwinm	r11,r8,0,0,19					; Switch to savearea base
+			lis		r9,hi16(EXT(switch_in))			; Get top of switch in routine 
+			lwz		r5,savesrr0+4(r8)				; Set up the new SRR0
+			lwz		r7,SACvrswap(r11)				; Get the high order V to R translation
+			lwz		r11,SACvrswap+4(r11)			; Get the low order V to R translation
+			ori		r9,r9,lo16(EXT(switch_in))		; Bottom half of switch in 
+			stw		r0,holdQFret(r12)				; Make sure we release quickfret holdoff
+			stw		r9,savesrr0+4(r8)				; Make us jump to the switch in routine 
 
-cswnovect:	lis		r9,hi16(EXT(switch_in))			/* Get top of switch in routine */
-			lwz		r5,savesrr0(r8)					/* Set up the new SRR0 */
-			ori		r9,r9,lo16(EXT(switch_in))		/* Bottom half of switch in */
+			lwz		r9,SAVflags(r8)					/* Get the flags */
 			lis		r0,hi16(SwitchContextCall)		/* Top part of switch context */
-			stw		r9,savesrr0(r8)					/* Make us jump to the switch in routine */
-			
 			li		r10,MSR_SUPERVISOR_INT_OFF		/* Get the switcher's MSR */
-			lwz		r9,SAVflags(r8)					/* Get the flags */
-			stw		r10,savesrr1(r8)				/* Set up for switch in */
-			rlwinm	r9,r9,0,15,13					/* Reset the syscall flag */
 			ori		r0,r0,lo16(SwitchContextCall)	/* Bottom part of switch context */
-			xor		r3,r7,r8						/* Get the physical address of the new context save area */
+			stw		r10,savesrr1+4(r8)				/* Set up for switch in */
+			rlwinm	r9,r9,0,15,13					/* Reset the syscall flag */
+			xor		r3,r11,r8						/* Get the physical address of the new context save area */
 			stw		r9,SAVflags(r8)					/* Set the flags */
 
 			bne		cr1,swtchtocont					; Switch to the continuation
@@ -360,9 +351,11 @@ cswnovect:	lis		r9,hi16(EXT(switch_in))			/* Get top of switch in routine */
 
 		
 swtchtocont:
-			stw		r5,savesrr0(r8)					; Set the pc
-			stw		r6,savesrr1(r8)					; Set the next MSR to use
-			stw		r4,saver3(r8)					; Make sure we pass back the old thread
+
+			stw		r5,savesrr0+4(r8)				; Set the pc
+			stw		r6,savesrr1+4(r8)				; Set the next MSR to use
+			stw		r4,saver3+4(r8)					; Make sure we pass back the old thread
+			mr		r3,r8							; Pass in the virtual address of savearea
 			
 			b		EXT(exception_exit)				; Blocking on continuation, toss old context...
 
@@ -375,7 +368,7 @@ swtchtocont:
  *			with translation on.  If we could, this should be done in lowmem_vectors
  *			before translation is turned on.  But we can't, dang it!
  *
- *			R3  = switcher's savearea
+ *			R3  = switcher's savearea (32-bit virtual)
  *			saver4  = old thread in switcher's save
  *			saver5  = new SRR0 in switcher's save
  *			saver6  = new SRR1 in switcher's save
@@ -388,31 +381,30 @@ swtchtocont:
 			.globl	EXT(switch_in)
 
 LEXT(switch_in)
-			
-			lwz		r4,saver4(r3)					/* Get the old thread */
-			lwz		r9,THREAD_TOP_ACT(r4)			/* Get the switched from ACT */
-			lwz		r5,saver5(r3)					/* Get the srr0 value */
-			lwz		r10,ACT_MACT_PCB(r9)			/* Get the top PCB on the old thread */
-			lwz		r6,saver6(r3)					/* Get the srr1 value */
 
-			stw		r3,ACT_MACT_PCB(r9)				/* Put the new one on top */
-			stw		r10,SAVprev(r3)					/* Chain on the old one */
+			lwz		r4,saver4+4(r3)					; Get the old thread 
+			lwz		r5,saver5+4(r3)					; Get the srr0 value 
+			
+	 		mfsprg	r0,2							; Get feature flags 
+			lwz		r9,THREAD_TOP_ACT(r4)			; Get the switched from ACT
+			lwz		r6,saver6+4(r3)					; Get the srr1 value 
+			rlwinm.	r0,r0,0,pf64Bitb,pf64Bitb		; Check for 64-bit
+			lwz		r10,ACT_MACT_PCB(r9)			; Get the top PCB on the old thread 
 
-			mr		r3,r4							/* Pass back the old thread */
+			stw		r3,ACT_MACT_PCB(r9)				; Put the new one on top
+			stw		r10,SAVprev+4(r3)				; Chain on the old one
 
-			mtsrr0	r5								/* Set return point */
-			mtsrr1	r6								/* Set return MSR */
-			rfi										/* Jam... */
-			.long	0
-			.long	0
-			.long	0
-			.long	0
-			.long	0
-			.long	0
-			.long	0
-			.long	0
+			mr		r3,r4							; Pass back the old thread 
 
+			mtsrr0	r5								; Set return point
+			mtsrr1	r6								; Set return MSR
+			
+			bne++	siSixtyFour						; Go do 64-bit...
 
+			rfi										; Jam...
+			
+siSixtyFour:
+			rfid									; Jam...
 			
 /*
  * void fpu_save(facility_context ctx)
@@ -428,12 +420,14 @@ LEXT(switch_in)
 
 LEXT(fpu_save)
 			
+			lis		r2,hi16(MASK(MSR_VEC))			; Get the vector enable
+			li		r12,lo16(MASK(MSR_EE))			; Get the EE bit
+			ori		r2,r2,lo16(MASK(MSR_FP))		; Get FP
 
 			mfmsr	r0								; Get the MSR
-			rlwinm	r0,r0,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-			rlwinm	r2,r0,0,MSR_EE_BIT+1,MSR_EE_BIT-1	; But do interrupts only for now
+			andc	r0,r0,r2						; Clear FP, VEC
+			andc	r2,r0,r12						; Clear EE
 			ori		r2,r2,MASK(MSR_FP)				; Enable the floating point feature for now also
-			rlwinm	r0,r0,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
 			mtmsr	r2								; Set the MSR
 			isync
 
@@ -448,7 +442,7 @@ LEXT(fpu_save)
 			mr.		r3,r12							; (TEST/DEBUG)
 			li		r2,0x6F00						; (TEST/DEBUG)
 			li		r5,0							; (TEST/DEBUG)
-			beq-	noowneryet						; (TEST/DEBUG)
+			beq--	noowneryet						; (TEST/DEBUG)
 			lwz		r4,FPUlevel(r12)				; (TEST/DEBUG)
 			lwz		r5,FPUsave(r12)					; (TEST/DEBUG)
 
@@ -461,17 +455,17 @@ noowneryet:	oris	r0,r0,lo16(CutTrace)			; (TEST/DEBUG)
 
 fsretry:	mr.		r12,r12							; Anyone own the FPU?
 			lhz		r11,PP_CPU_NUMBER(r6)			; Get our CPU number
-			beq-	fsret							; Nobody owns the FPU, no save required...
+			beq--	fsret							; Nobody owns the FPU, no save required...
 			
 			cmplw	cr1,r3,r12						; Is the specified context live?
 			
 			isync									; Force owner check first
 			
 			lwz		r9,FPUcpu(r12)					; Get the cpu that context was last on		
-			bne-	cr1,fsret						; No, it is not...
+			bne--	cr1,fsret						; No, it is not...
 			
 			cmplw	cr1,r9,r11						; Was the context for this processor? 
-			beq-	cr1,fsgoodcpu					; Facility last used on this processor...
+			beq--	cr1,fsgoodcpu					; Facility last used on this processor...
 
 			b		fsret							; Someone else claimed it...
 			
@@ -485,7 +479,7 @@ fsgoodcpu:	lwz		r3,FPUsave(r12)					; Get the current FPU savearea for the threa
 			
 			lwz		r8,SAVlevel(r3)					; Get the level this savearea is for
 			cmplw	cr1,r9,r8						; Correct level?
-			beq-	cr1,fsret						; The current level is already saved, bail out...
+			beq--	cr1,fsret						; The current level is already saved, bail out...
 
 fsneedone:	bl		EXT(save_get)					; Get a savearea for the context
 
@@ -494,78 +488,26 @@ fsneedone:	bl		EXT(save_get)					; Get a savearea for the context
 			lwz		r12,FPUowner(r6)				; Get back our thread
 			stb		r4,SAVflags+2(r3)				; Mark this savearea as a float
 			mr.		r12,r12							; See if we were disowned while away. Very, very small chance of it...
-			beq-	fsbackout						; If disowned, just toss savearea...
+			beq--	fsbackout						; If disowned, just toss savearea...
 			lwz		r4,facAct(r12)					; Get the activation associated with live context
-			mtlr	r2								; Restore return
 			lwz		r8,FPUsave(r12)					; Get the current top floating point savearea
 			stw		r4,SAVact(r3)					; Indicate the right activation for this context
 			lwz		r9,FPUlevel(r12)				; Get our current level indicator again		
 			stw		r3,FPUsave(r12)					; Set this as the most current floating point context
-			stw		r8,SAVprev(r3)					; And then chain this in front
+			stw		r8,SAVprev+4(r3)				; And then chain this in front
 
 			stw		r9,SAVlevel(r3)					; Show level in savearea
 
-;
-; 			Save the current FPU state into the PCB of the thread that owns it.
-; 
-
-			la		r11,savefp0(r3)					; Point to the 1st line
-			dcbz	0,r11							; Allocate the first savearea line 
-			
-			la		r11,savefp4(r3)					; Point to the 2nd line 
-			stfd    f0,savefp0(r3)
-			dcbz	0,r11							; Allocate it
-			stfd    f1,savefp1(r3)
-			stfd    f2,savefp2(r3)
-			la		r11,savefp8(r3)					; Point to the 3rd line 
-			stfd    f3,savefp3(r3)
-			dcbz	0,r11							; Allocate it 
-			stfd    f4,savefp4(r3)
-			stfd    f5,savefp5(r3)
-			stfd    f6,savefp6(r3)
-			la		r11,savefp12(r3)				; Point to the 4th line 
-			stfd    f7,savefp7(r3)
-			dcbz	0,r11							; Allocate it 
-			stfd    f8,savefp8(r3)
-			stfd    f9,savefp9(r3)
-			stfd    f10,savefp10(r3)
-			la		r11,savefp16(r3)				; Point to the 5th line 
-			stfd    f11,savefp11(r3)
-			dcbz	0,r11							; Allocate it 
-			stfd    f12,savefp12(r3)
-			stfd    f13,savefp13(r3)
-			stfd    f14,savefp14(r3)
-			la		r11,savefp20(r3)				; Point to the 6th line 
-			stfd    f15,savefp15(r3)
-			stfd    f16,savefp16(r3)
-			stfd    f17,savefp17(r3)
-			stfd    f18,savefp18(r3)
-			la		r11,savefp24(r3)				; Point to the 7th line 
-			stfd    f19,savefp19(r3)
-			dcbz	0,r11							; Allocate it 
-			stfd    f20,savefp20(r3)
-			stfd    f21,savefp21(r3)
-			stfd    f22,savefp22(r3)
-			la		r11,savefp28(r3)				; Point to the 8th line 
-			stfd    f23,savefp23(r3)
-			dcbz	0,r11							; Allocate it 
-			stfd    f24,savefp24(r3)
-			stfd    f25,savefp25(r3)
-			stfd    f26,savefp26(r3)
-			stfd    f27,savefp27(r3)
-			stfd    f28,savefp28(r3)
-
-			stfd    f29,savefp29(r3)
-			stfd    f30,savefp30(r3)
-			stfd    f31,savefp31(r3)
-
+            bl		fp_store						; save all 32 FPRs in the save area at r3
+			mtlr	r2								; Restore return
+            
 fsret:		mtmsr	r0								; Put interrupts on if they were and floating point off
 			isync
 
 			blr
 
-fsbackout:	mr		r12,r0							; Save the original MSR
-			b		EXT(save_ret_join)				; Toss savearea and return from there...
+fsbackout:	mr		r4,r0							; restore the original MSR
+			b		EXT(save_ret_wMSR)				; Toss savearea and return from there...
 
 /*
  * fpu_switch()
@@ -667,6 +609,7 @@ fswretry:	mr.		r22,r22							; See if there is any live FP status
 			mr		r5,r31							; (TEST/DEBUG)
 			oris	r0,r0,lo16(CutTrace)			; (TEST/DEBUG)
 			sc										; (TEST/DEBUG)
+			li		r3,0							; (TEST/DEBUG)
 #endif	
 
 			beq+	fsnosave						; Same level, so already saved...
@@ -676,16 +619,54 @@ fsmstsave:	stw		r3,FPUowner(r26)				; Kill the context now
 			eieio									; Make sure everyone sees it
 			bl		EXT(save_get)					; Go get a savearea
 
-			la		r11,savefp0(r3)					; Point to the 1st line in new savearea
-			lwz		r12,facAct(r22)					; Get the activation associated with the context
-			dcbz	0,r11							; Allocate cache
-			stw		r3,FPUsave(r22)					; Set this as the latest context savearea for the thread
+			mr.		r31,r31							; Are we saving the user state?
+			la		r15,FPUsync(r22)				; Point to the sync word
+			beq++	fswusave						; Yeah, no need for lock...
+;
+;			Here we make sure that the live context is not tossed while we are
+;			trying to push it.  This can happen only for kernel context and
+;			then only by a race with act_machine_sv_free.
+;
+;			We only need to hold this for a very short time, so no sniffing needed.
+;			If we find any change to the level, we just abandon.
+;
+fswsync:	lwarx	r19,0,r15						; Get the sync word
+			li		r0,1							; Get the lock
+			cmplwi	cr1,r19,0						; Is it unlocked?
+			stwcx.	r0,0,r15						; Store lock and test reservation
+			cror	cr0_eq,cr1_eq,cr0_eq			; Combine lost reservation and previously locked
+			bne--	fswsync							; Try again if lost reservation or locked...
 
-			stw		r30,SAVprev(r3)					; Point us to the old context
+			isync									; Toss speculation
+			
+			lwz		r0,FPUlevel(r22)				; Pick up the level again
+			li		r7,0							; Get unlock value
+			cmplw	r0,r31							; Same level?
+			beq++	fswusave						; Yeah, we expect it to be...
+			
+			stw		r7,FPUsync(r22)					; Unlock lock. No need to sync here
+			
+			bl		EXT(save_ret)					; Toss save area because we are abandoning save				
+			b		fsnosave						; Skip the save...
+
+			.align	5
+
+fswusave:	lwz		r12,facAct(r22)					; Get the activation associated with the context
+			stw		r3,FPUsave(r22)					; Set this as the latest context savearea for the thread
+			mr.		r31,r31							; Check again if we were user level
+			stw		r30,SAVprev+4(r3)				; Point us to the old context
 			stw		r31,SAVlevel(r3)				; Tag our level
 			li		r7,SAVfloat						; Get the floating point ID
 			stw		r12,SAVact(r3)					; Make sure we point to the right guy
 			stb		r7,SAVflags+2(r3)				; Set that we have a floating point save area
+			
+			li		r7,0							; Get the unlock value
+
+			beq--	fswnulock						; Skip unlock if user (we did not lock it)...
+			eieio									; Make sure that these updates make it out
+			stw		r7,FPUsync(r22)					; Unlock it.
+			
+fswnulock:		
 
 #if FPVECDBG
 			lis		r0,hi16(CutTrace)				; (TEST/DEBUG)
@@ -694,58 +675,7 @@ fsmstsave:	stw		r3,FPUowner(r26)				; Kill the context now
 			sc										; (TEST/DEBUG)
 #endif	
 
-;
-;			Now we will actually save the old context
-;
-			
-			la		r11,savefp4(r3)					; Point to the 2nd line
-			stfd    f0,savefp0(r3)
-			dcbz	0,r11							; Allocate cache
-			stfd    f1,savefp1(r3)
-			stfd    f2,savefp2(r3)
-			la		r11,savefp8(r3)					; Point to the 3rd line
-			stfd    f3,savefp3(r3)
-			dcbz	0,r11							; Allocate cache
-			stfd    f4,savefp4(r3)
-			stfd    f5,savefp5(r3)
-			stfd    f6,savefp6(r3)
-			la		r11,savefp12(r3)				; Point to the 4th line
-			stfd    f7,savefp7(r3)
-			dcbz	0,r11							; Allocate cache
-			stfd    f8,savefp8(r3)
-			stfd    f9,savefp9(r3)
-			stfd    f10,savefp10(r3)
-			la		r11,savefp16(r3)				; Point to the 5th line
-			stfd    f11,savefp11(r3)
-			dcbz	0,r11							; Allocate cache
-			stfd    f12,savefp12(r3)
-			stfd    f13,savefp13(r3)
-			stfd    f14,savefp14(r3)
-			la		r11,savefp20(r3)				; Point to the 6th line 
-			stfd    f15,savefp15(r3)
-			dcbz	0,r11							; Allocate cache
-			stfd    f16,savefp16(r3)
-			stfd    f17,savefp17(r3)
-			stfd    f18,savefp18(r3)
-			la		r11,savefp24(r3)				; Point to the 7th line
-			stfd    f19,savefp19(r3)
-			dcbz	0,r11							; Allocate cache
-			stfd    f20,savefp20(r3)
-
-			stfd    f21,savefp21(r3)
-			stfd    f22,savefp22(r3)
-			la		r11,savefp28(r3)				; Point to the 8th line
-			stfd    f23,savefp23(r3)
-			dcbz	0,r11							; allocate it
-			stfd    f24,savefp24(r3)
-			stfd    f25,savefp25(r3)
-			stfd    f26,savefp26(r3)
-			stfd    f27,savefp27(r3)
-			dcbz	0,r11							; allocate it
-			stfd    f28,savefp28(r3)
-			stfd    f29,savefp29(r3)
-			stfd    f30,savefp30(r3)
-			stfd    f31,savefp31(r3)
+            bl		fp_store						; store all 32 FPRs
 
 ;
 ;			The context is all saved now and the facility is free.
@@ -780,28 +710,30 @@ fsnosave:	lwz		r15,ACT_MACT_PCB(r17)			; Get the current level of the "new" one
 			ori		r18,r18,lo16(EXT(per_proc_info))	; Set base per_proc
 			li		r16,FPUowner					; Displacement to float owner
 			add		r19,r18,r19						; Point to the owner per_proc	
-			li		r0,0
 			
 fsinvothr:	lwarx	r18,r16,r19						; Get the owner
-			cmplw	r18,r29							; Does he still have this context?
-			bne		fsinvoths						; Nope...		
-			stwcx.	r0,r16,r19						; Try to invalidate it
-			bne-	fsinvothr						; Try again if there was a collision...
+			sub		r0,r18,r29						; Subtract one from the other
+			sub		r11,r29,r18						; Subtract the other from the one
+			or		r11,r11,r0						; Combine them
+			srawi	r11,r11,31						; Get a 0 if equal or -1 of not
+			and		r18,r18,r11						; Make 0 if same, unchanged if not
+			stwcx.	r18,r16,r19						; Try to invalidate it
+			bne--	fsinvothr						; Try again if there was a collision...
 		
-fsinvoths:	cmplwi	cr1,r14,0						; Do we possibly have some context to load?
+			cmplwi	cr1,r14,0						; Do we possibly have some context to load?
 			la		r11,savefp0(r14)				; Point to first line to bring in
 			stw		r15,FPUlevel(r29)				; Set the "new" active level
 			eieio
 			stw		r29,FPUowner(r26)				; Mark us as having the live context
 			
-			beq+	cr1,MakeSureThatNoTerroristsCanHurtUsByGod	; No "new" context to load...
+			beq++	cr1,MakeSureThatNoTerroristsCanHurtUsByGod	; No "new" context to load...
 			
 			dcbt	0,r11							; Touch line in
 
-			lwz		r3,SAVprev(r14)					; Get the previous context
+			lwz		r3,SAVprev+4(r14)				; Get the previous context
 			lwz		r0,SAVlevel(r14)				; Get the level of first facility savearea
 			cmplw	r0,r15							; Top level correct to load?
-			bne-	MakeSureThatNoTerroristsCanHurtUsByGod	; No, go initialize...
+			bne--	MakeSureThatNoTerroristsCanHurtUsByGod	; No, go initialize...
 
 			stw		r3,FPUsave(r29)					; Pop the context (we will toss the savearea later)
 			
@@ -812,6 +744,9 @@ fsinvoths:	cmplwi	cr1,r14,0						; Do we possibly have some context to load?
 			sc										; (TEST/DEBUG)
 #endif	
 
+// Note this code is used both by 32- and 128-byte processors.  This means six extra DCBTs
+// are executed on a 128-byte machine, but that is better than a mispredicted branch.
+
 			la		r11,savefp4(r14)				; Point to next line
 			dcbt	0,r11							; Touch line in
 			lfd     f0, savefp0(r14)
@@ -862,18 +797,18 @@ fsinvoths:	cmplwi	cr1,r14,0						; Do we possibly have some context to load?
 			mr		r3,r14							; Get the old savearea (we popped it before)
 			bl		EXT(save_ret)					; Toss it
 			
-fsenable:	lwz		r8,savesrr1(r25)				; Get the msr of the interrupted guy
-			rlwinm	r5,r25,0,0,19					; Get the page address of the savearea 
+fsenable:	lwz		r8,savesrr1+4(r25)				; Get the msr of the interrupted guy
 			ori		r8,r8,MASK(MSR_FP)				; Enable the floating point feature
-			lwz		r10,ACT_MACT_SPF(r17)			; Get the special flags
-			lwz		r5,SACvrswap(r5)				; Get Virtual to Real translation 
+			lwz		r10,ACT_MACT_SPF(r17)			; Get the act special flags
+			lwz		r11,spcFlags(r26)				; Get per_proc spec flags cause not in sync with act
 			oris	r10,r10,hi16(floatUsed|floatCng)	; Set that we used floating point
+			oris	r11,r11,hi16(floatUsed|floatCng)	; Set that we used floating point
 			rlwinm.	r0,r8,0,MSR_PR_BIT,MSR_PR_BIT	; See if we are doing this for user state
-			stw		r8,savesrr1(r25)				; Set the msr of the interrupted guy
-			xor		r3,r25,r5						; Get the real address of the savearea
+			stw		r8,savesrr1+4(r25)				; Set the msr of the interrupted guy
+			mr		r3,r25							; Pass the virtual addres of savearea
 			beq-	fsnuser							; We are not user state...
 			stw		r10,ACT_MACT_SPF(r17)			; Set the activation copy
-			stw		r10,spcFlags(r26)				; Set per_proc copy
+			stw		r11,spcFlags(r26)				; Set per_proc copy
 
 fsnuser:
 #if FPVECDBG
@@ -954,13 +889,14 @@ fsthesame:
 			beq-	cr1,fsenable					; Not saved yet, nothing to pop, go enable and exit...
 			
 			lwz		r11,SAVlevel(r30)				; Get the level of top saved context
-			lwz		r14,SAVprev(r30)				; Get the previous savearea
+			lwz		r14,SAVprev+4(r30)				; Get the previous savearea
 			
 			cmplw	r11,r31							; Are live and saved the same?
 
 			bne+	fsenable						; Level not the same, nothing to pop, go enable and exit...
 			
 			mr		r3,r30							; Get the old savearea (we popped it before)
+			stw		r14,FPUsave(r22)				; Pop the savearea from the stack
 			bl		EXT(save_ret)					; Toss it
 			b		fsenable						; Go enable and exit...
 
@@ -975,12 +911,13 @@ fsthesame:
 
 LEXT(toss_live_fpu)
 			
-			
+			lis		r0,hi16(MASK(MSR_VEC))			; Get VEC
 			mfmsr	r9								; Get the MSR
-			rlwinm	r0,r9,0,MSR_EE_BIT+1,MSR_EE_BIT-1	; Clear interuptions
+			ori		r0,r0,lo16(MASK(MSR_FP))		; Add in FP
 			rlwinm.	r8,r9,0,MSR_FP_BIT,MSR_FP_BIT	; Are floats on right now?
-			rlwinm	r9,r9,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Make sure vectors are turned off
-			rlwinm	r9,r9,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Make sure floats are turned off
+			andc	r9,r9,r0						; Force off VEC and FP
+			ori		r0,r0,lo16(MASK(MSR_EE))		; Turn off EE
+			andc	r0,r9,r0						; Turn off EE now
 			mtmsr	r0								; No interruptions
 			isync
 			beq+	tlfnotours						; Floats off, can not be live here...
@@ -995,9 +932,9 @@ LEXT(toss_live_fpu)
 			lwz		r6,FPUowner(r8)					; Get the thread that owns the floats
 			li		r0,0							; Clear this just in case we need it
 			cmplw	r6,r3							; Are we tossing our own context?
-			bne-	tlfnotours						; Nope...
+			bne--	tlfnotours						; Nope...
 			
-			fsub	f1,f1,f1						; Make a 0			
+			lfd		f1,Zero(0)						; Make a 0			
 			mtfsf	0xFF,f1							; Clear it
 
 tlfnotours:	lwz		r11,FPUcpu(r3)					; Get the cpu on which we last loaded context
@@ -1006,15 +943,18 @@ tlfnotours:	lwz		r11,FPUcpu(r3)					; Get the cpu on which we last loaded contex
 			ori		r12,r12,lo16(EXT(per_proc_info))	; Set base per_proc
 			li		r10,FPUowner					; Displacement to float owner
 			add		r11,r12,r11						; Point to the owner per_proc	
-			li		r0,0							; Set a 0 to invalidate context
 			
 tlfinvothr:	lwarx	r12,r10,r11						; Get the owner
-			cmplw	r12,r3							; Does he still have this context?
-			bne+	tlfexit							; Nope, leave...		
-			stwcx.	r0,r10,r11						; Try to invalidate it
-			bne-	tlfinvothr						; Try again if there was a collision...
 
-tlfexit:	mtmsr	r9								; Restore interruptions
+			sub		r0,r12,r3						; Subtract one from the other
+			sub		r8,r3,r12						; Subtract the other from the one
+			or		r8,r8,r0						; Combine them
+			srawi	r8,r8,31						; Get a 0 if equal or -1 of not
+			and		r12,r12,r8						; Make 0 if same, unchanged if not
+			stwcx.	r12,r10,r11						; Try to invalidate it
+			bne--	tlfinvothr						; Try again if there was a collision...
+
+			mtmsr	r9								; Restore interruptions
 			isync									; Could be turning off floats here
 			blr										; Leave...
 
@@ -1047,11 +987,14 @@ tlfexit:	mtmsr	r9								; Restore interruptions
 
 LEXT(vec_save)
 
+
+			lis		r2,hi16(MASK(MSR_VEC))			; Get VEC
 			mfmsr	r0								; Get the MSR
-			rlwinm	r0,r0,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Make sure vectors are turned off when we leave
-			rlwinm	r2,r0,0,MSR_EE_BIT+1,MSR_EE_BIT-1	; But do interrupts only for now
+			ori		r2,r2,lo16(MASK(MSR_FP))		; Add in FP
+			andc	r0,r0,r2						; Force off VEC and FP
+			ori		r2,r2,lo16(MASK(MSR_EE))		; Clear EE
+			andc	r2,r0,r2						; Clear EE for now
 			oris	r2,r2,hi16(MASK(MSR_VEC))		; Enable the vector facility for now also
-			rlwinm	r0,r0,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force off fp
 			mtmsr	r2								; Set the MSR
 			isync
 		
@@ -1110,17 +1053,17 @@ vsgoodcpu:	lwz		r3,VMXsave(r12)					; Get the current vector savearea for the th
 			
 			bne+	vsret							; VRsave is non-zero so we need to keep what is saved...
 						
-			lwz		r4,SAVprev(r3)					; Pick up the previous area
+			lwz		r4,SAVprev+4(r3)				; Pick up the previous area
 			lwz		r5,SAVlevel(r4)					; Get the level associated with save
 			stw		r4,VMXsave(r12)					; Dequeue this savearea
+			li		r4,0							; Clear
 			stw		r5,VMXlevel(r12)				; Save the level
 	
-			li		r3,0							; Clear
-			stw		r3,VMXowner(r12)				; Show no live context here
+			stw		r4,VMXowner(r12)				; Show no live context here
 			eieio
 
-vsbackout:	mr		r12,r0							; Set the saved MSR			
-			b		EXT(save_ret_join)				; Toss the savearea and return from there...
+vsbackout:	mr		r4,r0							; restore the saved MSR			
+			b		EXT(save_ret_wMSR)				; Toss the savearea and return from there...
 
 			.align	5
 
@@ -1136,286 +1079,22 @@ vsneedone:	mr.		r10,r10							; Is VRsave set to 0?
 			mr.		r12,r12							; See if we were disowned while away. Very, very small chance of it...
 			beq-	vsbackout						; If disowned, just toss savearea...
 			lwz		r4,facAct(r12)					; Get the activation associated with live context
-			mtlr	r2								; Restore return
 			lwz		r8,VMXsave(r12)					; Get the current top vector savearea
 			stw		r4,SAVact(r3)					; Indicate the right activation for this context
 			lwz		r9,VMXlevel(r12)				; Get our current level indicator again		
 			stw		r3,VMXsave(r12)					; Set this as the most current floating point context
-			stw		r8,SAVprev(r3)					; And then chain this in front
+			stw		r8,SAVprev+4(r3)				; And then chain this in front
 
 			stw		r9,SAVlevel(r3)					; Set level in savearea
+            mfcr	r12								; save CRs across call to vr_store
+			lwz		r10,liveVRS(r6)					; Get the right VRSave register
+            
+            bl		vr_store						; store live VRs into savearea as required (uses r4-r11)
 
-			mfcr	r2						; Save non-volatile CRs
-			lwz		r10,liveVRS(r6)			; Get the right VRSave register
-			lis		r9,0x5555				; Mask with odd bits set		
-			rlwinm	r11,r10,1,0,31			; Shift over 1
-			ori		r9,r9,0x5555			; Finish mask
-			or		r4,r10,r11				; After this, even bits show which lines to zap
-			
-			andc	r11,r4,r9				; Clear out odd bits
-			
-			la		r6,savevr0(r3)			; Point to line 0
-			rlwinm	r4,r11,15,0,15			; Move line 8-15 flags to high order odd bits
-			or		r4,r11,r4				; Set the odd bits
-											; (bit 0 is line 0, bit 1 is line 8,
-											; bit 2 is line 1, bit 3 is line 9, etc.
-			rlwimi	r4,r10,16,16,31			; Put vrsave 0 - 15 into positions 16 - 31
-			la		r7,savevr2(r3)			; Point to line 1
-			mtcrf	255,r4					; Load up the CRs
-			stw		r10,savevrvalid(r3)		; Save the validity information
-			mr		r8,r6					; Start registers off
-;	
-;			Save the current vector state
-;
-						
-			bf		0,snol0					; No line 0 to do...
-			dcba	br0,r6					; Allocate cache line 0
-			
-snol0:		
-			la		r6,savevr4(r3)			; Point to line 2
-			bf		2,snol1					; No line 1 to do...
-			dcba	br0,r7					; Allocate cache line 1
-			
-snol1:		
-			la		r7,savevr6(r3)			; Point to line 3
-			bf		4,snol2					; No line 2 to do...
-			dcba	br0,r6					; Allocate cache line 2
-			
-snol2:		
-			li		r11,16					; Get offset for odd registers
-			bf		16,snovr0				; Do not save VR0...
-			stvxl	v0,br0,r8				; Save VR0
-			
-snovr0:		
-			la		r9,savevr2(r3)			; Point to V2/V3 pair
-			bf		17,snovr1				; Do not save VR1...
-			stvxl	v1,r11,r8				; Save VR1
-			
-snovr1:
-			la		r6,savevr8(r3)			; Point to line 4
-			bf		6,snol3					; No line 3 to do...
-			dcba	br0,r7					; Allocate cache line 3
-			
-snol3:		
-			la		r8,savevr4(r3)			; Point to V4/V5 pair
-			bf		18,snovr2				; Do not save VR2...
-			stvxl	v2,br0,r9				; Save VR2
-			
-snovr2:
-			bf		19,snovr3				; Do not save VR3...
-			stvxl	v3,r11,r9				; Save VR3
-			
-snovr3:
-;
-;			Note: CR4 is now free
-;
-			la		r7,savevr10(r3)			; Point to line 5
-			bf		8,snol4					; No line 4 to do...
-			dcba	br0,r6					; Allocate cache line 4
-			
-snol4:		
-			la		r9,savevr6(r3)			; Point to R6/R7 pair
-			bf		20,snovr4				; Do not save VR4...
-			stvxl	v4,br0,r8				; Save VR4
-			
-snovr4:
-			bf		21,snovr5				; Do not save VR5...
-			stvxl	v5,r11,r8				; Save VR5
-			
-snovr5:
-			mtcrf	0x08,r10				; Set CRs for registers 16-19
-			la		r6,savevr12(r3)			; Point to line 6
-			bf		10,snol5				; No line 5 to do...
-			dcba	br0,r7					; Allocate cache line 5
-			
-snol5:		
-			la		r8,savevr8(r3)			; Point to V8/V9 pair
-			bf		22,snovr6				; Do not save VR6...
-			stvxl	v6,br0,r9				; Save VR6
-			
-snovr6:
-			bf		23,snovr7				; Do not save VR7...
-			stvxl	v7,r11,r9				; Save VR7
-			
-snovr7:
-;
-;			Note: CR5 is now free
-;
-			la		r7,savevr14(r3)			; Point to line 7
-			bf		12,snol6				; No line 6 to do...
-			dcba	br0,r6					; Allocate cache line 6
-			
-snol6:		
-			la		r9,savevr10(r3)			; Point to V10/V11 pair
-			bf		24,snovr8				; Do not save VR8...
-			stvxl	v8,br0,r8				; Save VR8
-			
-snovr8:
-			bf		25,snovr9				; Do not save VR9...
-			stvxl	v9,r11,r8				; Save VR9
-			
-snovr9:
-			mtcrf	0x04,r10				; Set CRs for registers 20-23
-			la		r6,savevr16(r3)			; Point to line 8
-			bf		14,snol7				; No line 7 to do...
-			dcba	br0,r7					; Allocate cache line 7
-			
-snol7:		
-			la		r8,savevr12(r3)			; Point to V12/V13 pair
-			bf		26,snovr10				; Do not save VR10...
-			stvxl	v10,br0,r9				; Save VR10
-			
-snovr10:
-			bf		27,snovr11				; Do not save VR11...
-			stvxl	v11,r11,r9				; Save VR11
-			
-snovr11:
-
-;
-;			Note: CR6 is now free
-;
-			la		r7,savevr18(r3)			; Point to line 9
-			bf		1,snol8					; No line 8 to do...
-			dcba	br0,r6					; Allocate cache line 8
-			
-snol8:		
-			la		r9,savevr14(r3)			; Point to V14/V15 pair
-			bf		28,snovr12				; Do not save VR12...
-			stvxl	v12,br0,r8				; Save VR12
-			
-snovr12:
-			bf		29,snovr13				; Do not save VR13...
-			stvxl	v13,r11,r8				; Save VR13
-			
-snovr13:
-			mtcrf	0x02,r10				; Set CRs for registers 24-27
-			la		r6,savevr20(r3)			; Point to line 10
-			bf		3,snol9					; No line 9 to do...
-			dcba	br0,r7					; Allocate cache line 9
-			
-snol9:		
-			la		r8,savevr16(r3)			; Point to V16/V17 pair
-			bf		30,snovr14				; Do not save VR14...
-			stvxl	v14,br0,r9				; Save VR14
-			
-snovr14:
-			bf		31,snovr15				; Do not save VR15...
-			stvxl	v15,r11,r9				; Save VR15
-			
-snovr15:
-;
-;			Note: CR7 is now free
-;
-			la		r7,savevr22(r3)			; Point to line 11
-			bf		5,snol10				; No line 10 to do...
-			dcba	br0,r6					; Allocate cache line 10
-			
-snol10:		
-			la		r9,savevr18(r3)			; Point to V18/V19 pair
-			bf		16,snovr16				; Do not save VR16...
-			stvxl	v16,br0,r8				; Save VR16
-			
-snovr16:
-			bf		17,snovr17				; Do not save VR17...
-			stvxl	v17,r11,r8				; Save VR17
-			
-snovr17:
-			mtcrf	0x01,r10				; Set CRs for registers 28-31
-;
-;			Note: All registers have been or are accounted for in CRs
-;
-			la		r6,savevr24(r3)			; Point to line 12
-			bf		7,snol11				; No line 11 to do...
-			dcba	br0,r7					; Allocate cache line 11
-			
-snol11:		
-			la		r8,savevr20(r3)			; Point to V20/V21 pair
-			bf		18,snovr18				; Do not save VR18...
-			stvxl	v18,br0,r9				; Save VR18
-			
-snovr18:
-			bf		19,snovr19				; Do not save VR19...
-			stvxl	v19,r11,r9				; Save VR19
-			
-snovr19:
-			la		r7,savevr26(r3)			; Point to line 13
-			bf		9,snol12				; No line 12 to do...
-			dcba	br0,r6					; Allocate cache line 12
-			
-snol12:		
-			la		r9,savevr22(r3)			; Point to V22/V23 pair
-			bf		20,snovr20				; Do not save VR20...
-			stvxl	v20,br0,r8				; Save VR20
-			
-snovr20:
-			bf		21,snovr21				; Do not save VR21...
-			stvxl	v21,r11,r8				; Save VR21
-			
-snovr21:
-			la		r6,savevr28(r3)			; Point to line 14
-			bf		11,snol13				; No line 13 to do...
-			dcba	br0,r7					; Allocate cache line 13
-			
-snol13:		
-			la		r8,savevr24(r3)			; Point to V24/V25 pair
-			bf		22,snovr22				; Do not save VR22...
-			stvxl	v22,br0,r9				; Save VR22
-			
-snovr22:
-			bf		23,snovr23				; Do not save VR23...
-			stvxl	v23,r11,r9				; Save VR23
-			
-snovr23:
-			la		r7,savevr30(r3)			; Point to line 15
-			bf		13,snol14				; No line 14 to do...
-			dcba	br0,r6					; Allocate cache line 14
-			
-snol14:		
-			la		r9,savevr26(r3)			; Point to V26/V27 pair
-			bf		24,snovr24				; Do not save VR24...
-			stvxl	v24,br0,r8				; Save VR24
-			
-snovr24:
-			bf		25,snovr25				; Do not save VR25...
-			stvxl	v25,r11,r8				; Save VR25
-			
-snovr25:
-			bf		15,snol15				; No line 15 to do...
-			dcba	br0,r7					; Allocate cache line 15
-			
-snol15:		
-;
-;			Note: All cache lines allocated now
-;
-			la		r8,savevr28(r3)			; Point to V28/V29 pair
-			bf		26,snovr26				; Do not save VR26...
-			stvxl	v26,br0,r9				; Save VR26
-
-snovr26:
-			bf		27,snovr27				; Do not save VR27...
-			stvxl	v27,r11,r9				; Save VR27
-			
-snovr27:
-			la		r7,savevr30(r3)			; Point to V30/V31 pair
-			bf		28,snovr28				; Do not save VR28...
-			stvxl	v28,br0,r8				; Save VR28
-			
-snovr28:		
-			bf		29,snovr29				; Do not save VR29...
-			stvxl	v29,r11,r8				; Save VR29
-			
-snovr29:		
-			bf		30,snovr30				; Do not save VR30...
-			stvxl	v30,br0,r7				; Save VR30
-			
-snovr30:
-			bf		31,snovr31				; Do not save VR31...
-			stvxl	v31,r11,r7				; Save VR31
-			
-snovr31:
-			mtcrf	255,r2					; Restore all cr
-
-vsret:		mtmsr	r0						; Put interrupts on if they were and vector off
+			mtcrf	255,r12							; Restore the non-volatile CRs
+            mtlr	r2								; restore return address
+		
+vsret:		mtmsr	r0								; Put interrupts on if they were and vector off
 			isync
 
 			blr
@@ -1529,7 +1208,7 @@ vsvretry:	mr.		r22,r22							; See if there is any live vector status
 
 			bne-	cr2,vsnosave					; Live context saved and VRSave not 0, no save and keep context...
 			
-			lwz		r4,SAVprev(r30)					; Pick up the previous area
+			lwz		r4,SAVprev+4(r30)				; Pick up the previous area
 			li		r5,0							; Assume this is the only one (which should be the ususal case)
 			mr.		r4,r4							; Was this the only one?
 			stw		r4,VMXsave(r22)					; Dequeue this savearea
@@ -1552,14 +1231,54 @@ vsmstsave:	stw		r8,VMXowner(r26)				; Clear owner
 
 			bl		EXT(save_get)					; Go get a savearea
 
-			lwz		r12,facAct(r22)					; Get the activation associated with the context
-			stw		r3,VMXsave(r22)					; Set this as the latest context savearea for the thread
+			mr.		r31,r31							; Are we saving the user state?
+			la		r15,VMXsync(r22)				; Point to the sync word
+			beq++	vswusave						; Yeah, no need for lock...
+;
+;			Here we make sure that the live context is not tossed while we are
+;			trying to push it.  This can happen only for kernel context and
+;			then only by a race with act_machine_sv_free.
+;
+;			We only need to hold this for a very short time, so no sniffing needed.
+;			If we find any change to the level, we just abandon.
+;
+vswsync:	lwarx	r19,0,r15						; Get the sync word
+			li		r0,1							; Get the lock
+			cmplwi	cr1,r19,0						; Is it unlocked?
+			stwcx.	r0,0,r15						; Store lock and test reservation
+			cror	cr0_eq,cr1_eq,cr0_eq			; Combine lost reservation and previously locked
+			bne--	vswsync							; Try again if lost reservation or locked...
+
+			isync									; Toss speculation
+			
+			lwz		r0,VMXlevel(r22)				; Pick up the level again
+			li		r7,0							; Get unlock value
+			cmplw	r0,r31							; Same level?
+			beq++	fswusave						; Yeah, we expect it to be...
+			
+			stw		r7,VMXsync(r22)					; Unlock lock. No need to sync here
+			
+			bl		EXT(save_ret)					; Toss save area because we are abandoning save				
+			b		fsnosave						; Skip the save...
 
-			stw		r30,SAVprev(r3)					; Point us to the old context
+			.align	5
+
+vswusave:	lwz		r12,facAct(r22)					; Get the activation associated with the context
+			stw		r3,VMXsave(r22)					; Set this as the latest context savearea for the thread
+			mr.		r31,r31							; Check again if we were user level
+			stw		r30,SAVprev+4(r3)				; Point us to the old context
 			stw		r31,SAVlevel(r3)				; Tag our level
 			li		r7,SAVvector					; Get the vector ID
 			stw		r12,SAVact(r3)					; Make sure we point to the right guy
 			stb		r7,SAVflags+2(r3)				; Set that we have a vector save area
+		
+			li		r7,0							; Get the unlock value
+
+			beq--	vswnulock						; Skip unlock if user (we did not lock it)...
+			eieio									; Make sure that these updates make it out
+			stw		r7,VMXsync(r22)					; Unlock it.
+			
+vswnulock:		
 
 #if FPVECDBG
 			lis		r0,hi16(CutTrace)				; (TEST/DEBUG)
@@ -1569,273 +1288,7 @@ vsmstsave:	stw		r8,VMXowner(r26)				; Clear owner
 #endif	
 
 			lwz		r10,liveVRS(r26)				; Get the right VRSave register
-			lis		r9,0x5555						; Mask with odd bits set		
-			rlwinm	r11,r10,1,0,31					; Shift over 1
-			ori		r9,r9,0x5555					; Finish mask
-			or		r21,r10,r11						; After this, even bits show which lines to zap
-			
-			andc	r13,r21,r9						; Clear out odd bits
-			
-			la		r11,savevr0(r3)					; Point to line 0
-			rlwinm	r24,r13,15,0,15					; Move line 8-15 flags to high order odd bits
-			or		r24,r13,r24						; Set the odd bits
-													; (bit 0 is line 0, bit 1 is line 8,
-													; bit 2 is line 1, bit 3 is line 9, etc.
-			rlwimi	r24,r10,16,16,31				; Put vrsave 0 - 15 into positions 16 - 31
-			la		r21,savevr2(r3)					; Point to line 1
-			mtcrf	255,r24							; Load up the CRs
-			stw		r10,savevrvalid(r3)				; Save the validity information
-			mr		r12,r11							; Start registers off
-;	
-;			Save the current vector state
-;
-						
-			bf		0,nol0							; No line 0 to do...
-			dcba	br0,r11							; Allocate cache line 0
-			
-nol0:		
-			la		r11,savevr4(r3)					; Point to line 2
-			bf		2,nol1							; No line 1 to do...
-			dcba	br0,r21							; Allocate cache line 1
-			
-nol1:		
-			la		r21,savevr6(r3)					; Point to line 3
-			bf		4,nol2							; No line 2 to do...
-			dcba	br0,r11							; Allocate cache line 2
-			
-nol2:		
-			li		r14,16							; Get offset for odd registers
-			bf		16,novr0						; Do not save VR0...
-			stvxl	v0,br0,r12						; Save VR0
-			
-novr0:		
-			la		r13,savevr2(r3)					; Point to V2/V3 pair
-			bf		17,novr1						; Do not save VR1...
-			stvxl	v1,r14,r12						; Save VR1
-			
-novr1:
-			la		r11,savevr8(r3)					; Point to line 4
-			bf		6,nol3							; No line 3 to do...
-			dcba	br0,r21							; Allocate cache line 3
-			
-nol3:		
-			la		r12,savevr4(r3)					; Point to V4/V5 pair
-			bf		18,novr2						; Do not save VR2...
-			stvxl	v2,br0,r13						; Save VR2
-			
-novr2:
-			bf		19,novr3						; Do not save VR3...
-			stvxl	v3,r14,r13						; Save VR3
-			
-novr3:
-;
-;			Note: CR4 is now free
-;
-			la		r21,savevr10(r3)				; Point to line 5
-			bf		8,nol4							; No line 4 to do...
-			dcba	br0,r11							; Allocate cache line 4
-			
-nol4:		
-			la		r13,savevr6(r3)					; Point to R6/R7 pair
-			bf		20,novr4						; Do not save VR4...
-			stvxl	v4,br0,r12						; Save VR4
-			
-novr4:
-			bf		21,novr5						; Do not save VR5...
-			stvxl	v5,r14,r12						; Save VR5
-			
-novr5:
-			mtcrf	0x08,r10						; Set CRs for registers 16-19
-			la		r11,savevr12(r3)				; Point to line 6
-			bf		10,nol5							; No line 5 to do...
-			dcba	br0,r21							; Allocate cache line 5
-			
-nol5:		
-			la		r12,savevr8(r3)					; Point to V8/V9 pair
-			bf		22,novr6						; Do not save VR6...
-			stvxl	v6,br0,r13						; Save VR6
-			
-novr6:
-			bf		23,novr7						; Do not save VR7...
-			stvxl	v7,r14,r13						; Save VR7
-			
-novr7:
-;
-;			Note: CR5 is now free
-;
-			la		r21,savevr14(r3)				; Point to line 7
-			bf		12,nol6							; No line 6 to do...
-			dcba	br0,r11							; Allocate cache line 6
-			
-nol6:		
-			la		r13,savevr10(r3)				; Point to V10/V11 pair
-			bf		24,novr8						; Do not save VR8...
-			stvxl	v8,br0,r12						; Save VR8
-			
-novr8:
-			bf		25,novr9						; Do not save VR9...
-			stvxl	v9,r14,r12						; Save VR9
-			
-novr9:
-			mtcrf	0x04,r10						; Set CRs for registers 20-23
-			la		r11,savevr16(r3)				; Point to line 8
-			bf		14,nol7							; No line 7 to do...
-			dcba	br0,r21							; Allocate cache line 7
-			
-nol7:		
-			la		r12,savevr12(r3)				; Point to V12/V13 pair
-			bf		26,novr10						; Do not save VR10...
-			stvxl	v10,br0,r13						; Save VR10
-			
-novr10:
-			bf		27,novr11						; Do not save VR11...
-			stvxl	v11,r14,r13						; Save VR11
-			
-novr11:
-
-;
-;			Note: CR6 is now free
-;
-			la		r21,savevr18(r3)				; Point to line 9
-			bf		1,nol8							; No line 8 to do...
-			dcba	br0,r11							; Allocate cache line 8
-			
-nol8:		
-			la		r13,savevr14(r3)				; Point to V14/V15 pair
-			bf		28,novr12						; Do not save VR12...
-			stvxl	v12,br0,r12						; Save VR12
-			
-novr12:
-			bf		29,novr13						; Do not save VR13...
-			stvxl	v13,r14,r12						; Save VR13
-			
-novr13:
-			mtcrf	0x02,r10						; Set CRs for registers 24-27
-			la		r11,savevr20(r3)				; Point to line 10
-			bf		3,nol9							; No line 9 to do...
-			dcba	br0,r21							; Allocate cache line 9
-			
-nol9:		
-			la		r12,savevr16(r3)				; Point to V16/V17 pair
-			bf		30,novr14						; Do not save VR14...
-			stvxl	v14,br0,r13						; Save VR14
-			
-novr14:
-			bf		31,novr15						; Do not save VR15...
-			stvxl	v15,r14,r13						; Save VR15
-			
-novr15:
-;
-;			Note: CR7 is now free
-;
-			la		r21,savevr22(r3)				; Point to line 11
-			bf		5,nol10							; No line 10 to do...
-			dcba	br0,r11							; Allocate cache line 10
-			
-nol10:		
-			la		r13,savevr18(r3)				; Point to V18/V19 pair
-			bf		16,novr16						; Do not save VR16...
-			stvxl	v16,br0,r12						; Save VR16
-			
-novr16:
-			bf		17,novr17						; Do not save VR17...
-			stvxl	v17,r14,r12						; Save VR17
-			
-novr17:
-			mtcrf	0x01,r10						; Set CRs for registers 28-31
-;
-;			Note: All registers have been or are accounted for in CRs
-;
-			la		r11,savevr24(r3)				; Point to line 12
-			bf		7,nol11							; No line 11 to do...
-			dcba	br0,r21							; Allocate cache line 11
-			
-nol11:		
-			la		r12,savevr20(r3)				; Point to V20/V21 pair
-			bf		18,novr18						; Do not save VR18...
-			stvxl	v18,br0,r13						; Save VR18
-			
-novr18:
-			bf		19,novr19						; Do not save VR19...
-			stvxl	v19,r14,r13						; Save VR19
-			
-novr19:
-			la		r21,savevr26(r3)				; Point to line 13
-			bf		9,nol12							; No line 12 to do...
-			dcba	br0,r11							; Allocate cache line 12
-			
-nol12:		
-			la		r13,savevr22(r3)				; Point to V22/V23 pair
-			bf		20,novr20						; Do not save VR20...
-			stvxl	v20,br0,r12						; Save VR20
-			
-novr20:
-			bf		21,novr21						; Do not save VR21...
-			stvxl	v21,r14,r12						; Save VR21
-			
-novr21:
-			la		r11,savevr28(r3)				; Point to line 14
-			bf		11,nol13						; No line 13 to do...
-			dcba	br0,r21							; Allocate cache line 13
-			
-nol13:		
-			la		r12,savevr24(r3)				; Point to V24/V25 pair
-			bf		22,novr22						; Do not save VR22...
-			stvxl	v22,br0,r13						; Save VR22
-			
-novr22:
-			bf		23,novr23						; Do not save VR23...
-			stvxl	v23,r14,r13						; Save VR23
-			
-novr23:
-			la		r21,savevr30(r3)				; Point to line 15
-			bf		13,nol14						; No line 14 to do...
-			dcba	br0,r11							; Allocate cache line 14
-			
-nol14:		
-			la		r13,savevr26(r3)				; Point to V26/V27 pair
-			bf		24,novr24						; Do not save VR24...
-			stvxl	v24,br0,r12						; Save VR24
-			
-novr24:
-			bf		25,novr25						; Do not save VR25...
-			stvxl	v25,r14,r12						; Save VR25
-			
-novr25:
-			bf		15,nol15						; No line 15 to do...
-			dcba	br0,r21							; Allocate cache line 15
-			
-nol15:		
-;
-;			Note: All cache lines allocated now
-;
-			la		r12,savevr28(r3)				; Point to V28/V29 pair
-			bf		26,novr26						; Do not save VR26...
-			stvxl	v26,br0,r13						; Save VR26
-			
-novr26:
-			bf		27,novr27						; Do not save VR27...
-			stvxl	v27,r14,r13						; Save VR27
-			
-novr27:
-			la		r13,savevr30(r3)				; Point to V30/V31 pair
-			bf		28,novr28						; Do not save VR28...
-			stvxl	v28,br0,r12						; Save VR28
-			
-novr28:		
-			bf		29,novr29						; Do not save VR29...
-			stvxl	v29,r14,r12						; Save VR29
-			
-novr29:		
-			bf		30,novr30						; Do not save VR30...
-			stvxl	v30,br0,r13						; Save VR30
-			
-novr30:
-			bf		31,novr31						; Do not save VR31...
-			stvxl	v31,r14,r13						; Save VR31
-			
-novr31:
-
+            bl		vr_store						; store VRs into savearea according to vrsave (uses r4-r11)
 			
 
 ;
@@ -1884,27 +1337,29 @@ vsnosave:	vspltisb v31,-10						; Get 0xF6F6F6F6
 			li		r16,VMXowner					; Displacement to vector owner
 			add		r19,r18,r19						; Point to the owner per_proc	
 			vrlb	v31,v31,v29						; Get 0xDEADDEAD	
-			li		r0,0
 			
 vsinvothr:	lwarx	r18,r16,r19						; Get the owner
-			cmplw	r18,r29							; Does he still have this context?
-			bne		vsinvoths						; Nope...		
-			stwcx.	r0,r16,r19						; Try to invalidate it
-			bne-	vsinvothr						; Try again if there was a collision...
-		
+
+			sub		r0,r18,r29						; Subtract one from the other
+			sub		r11,r29,r18						; Subtract the other from the one
+			or		r11,r11,r0						; Combine them
+			srawi	r11,r11,31						; Get a 0 if equal or -1 of not
+			and		r18,r18,r11						; Make 0 if same, unchanged if not
+			stwcx.	r18,r16,r19						; Try to invalidate it
+			bne--	vsinvothr						; Try again if there was a collision...		
 	
-vsinvoths:	cmplwi	cr1,r14,0						; Do we possibly have some context to load?
+			cmplwi	cr1,r14,0						; Do we possibly have some context to load?
 			vmrghh	v31,v30,v31						; Get 0x7FFFDEAD.  V31 keeps this value until the bitter end
 			stw		r15,VMXlevel(r29)				; Set the "new" active level
 			eieio
 			stw		r29,VMXowner(r26)				; Mark us as having the live context
 
-			beq-	cr1,ProtectTheAmericanWay		; Nothing to restore, first time use...
+			beq--	cr1,ProtectTheAmericanWay		; Nothing to restore, first time use...
 		
-			lwz		r3,SAVprev(r14)					; Get the previous context
+			lwz		r3,SAVprev+4(r14)				; Get the previous context
 			lwz		r0,SAVlevel(r14)				; Get the level of first facility savearea
 			cmplw	r0,r15							; Top level correct to load?
-			bne-	ProtectTheAmericanWay			; No, go initialize...
+			bne--	ProtectTheAmericanWay			; No, go initialize...
 			
 			stw		r3,VMXsave(r29)					; Pop the context (we will toss the savearea later)
 
@@ -1915,391 +1370,26 @@ vsinvoths:	cmplwi	cr1,r14,0						; Do we possibly have some context to load?
 			sc										; (TEST/DEBUG)
 #endif	
 
-			lwz		r22,savevrsave(r25)				; Get the most current VRSAVE
 			lwz		r10,savevrvalid(r14)			; Get the valid VRs in the savearea
-			lis		r9,0x5555						; Mask with odd bits set
+			lwz		r22,savevrsave(r25)				; Get the most current VRSAVE
 			and		r10,r10,r22						; Figure out just what registers need to be loaded
-			ori		r9,r9,0x5555					; Finish mask
-			rlwinm	r11,r10,1,0,31					; Shift over 1
-			or		r12,r10,r11						; After this, even bits show which lines to touch
-			andc	r13,r12,r9						; Clear out odd bits
-			
-			la		r20,savevr0(r14)				; Point to line 0
-			rlwinm	r3,r13,15,0,15					; Move line 8-15 flags to high order odd bits
-			la		r21,savevr2(r3)					; Point to line 1
-			or		r3,r13,r3						; Set the odd bits
-													; (bit 0 is line 0, bit 1 is line 8,
-													; bit 2 is line 1, bit 3 is line 9, etc.
-			rlwimi	r3,r10,16,16,31					; Put vrsave 0 - 15 into positions 16 - 31
-			mtcrf	255,r3							; Load up the CRs
-			mr		r22,r20							; Start registers off
-;	
-;			Load the new vector state
-;
-						
-			bf		0,lnol0							; No line 0 to do...
-			dcbt	br0,r20							; Touch cache line 0
-			
-lnol0:		
-			la		r20,savevr4(r14)				; Point to line 2
-			bf		2,lnol1							; No line 1 to do...
-			dcbt	br0,r21							; Touch cache line 1
-			
-lnol1:		
-			la		r21,savevr6(r14)				; Point to line 3
-			bf		4,lnol2							; No line 2 to do...
-			dcbt	br0,r20							; Touch cache line 2
-			
-lnol2:		
-			li		r30,16							; Get offset for odd registers
-			bf		16,lnovr0						; Do not restore VR0...
-			lvxl	v0,br0,r22						; Restore VR0
-			
-lnovr0:		
-			la		r23,savevr2(r14)				; Point to V2/V3 pair
-			bf		17,lnovr1						; Do not restore VR1...
-			lvxl	v1,r30,r22						; Restore VR1
-			
-lnovr1:
-			la		r20,savevr8(r14)				; Point to line 4
-			bf		6,lnol3							; No line 3 to do...
-			dcbt	br0,r21							; Touch cache line 3
-			
-lnol3:		
-			la		r22,savevr4(r14)				; Point to V4/V5 pair
-			bf		18,lnovr2						; Do not restore VR2...
-			lvxl	v2,br0,r23						; Restore VR2
-			
-lnovr2:
-			bf		19,lnovr3						; Do not restore VR3...
-			lvxl	v3,r30,r23						; Restore VR3
-			
-lnovr3:
-;
-;			Note: CR4 is now free
-;
-			la		r21,savevr10(r14)				; Point to line 5
-			bf		8,lnol4							; No line 4 to do...
-			dcbt	br0,r20							; Touch cache line 4
-			
-lnol4:		
-			la		r23,savevr6(r14)				; Point to R6/R7 pair
-			bf		20,lnovr4						; Do not restore VR4...
-			lvxl	v4,br0,r22						; Restore VR4
-			
-lnovr4:
-			bf		21,lnovr5						; Do not restore VR5...
-			lvxl	v5,r30,r22						; Restore VR5
-			
-lnovr5:
-			mtcrf	0x08,r10						; Set CRs for registers 16-19
-			la		r20,savevr12(r14)				; Point to line 6
-			bf		10,lnol5						; No line 5 to do...
-			dcbt	br0,r21							; Touch cache line 5
-			
-lnol5:		
-			la		r22,savevr8(r14)				; Point to V8/V9 pair
-			bf		22,lnovr6						; Do not restore VR6...
-			lvxl	v6,br0,r23						; Restore VR6
-			
-lnovr6:
-			bf		23,lnovr7						; Do not restore VR7...
-			lvxl	v7,r30,r23						; Restore VR7
-			
-lnovr7:
-;
-;			Note: CR5 is now free
-;
-			la		r21,savevr14(r14)				; Point to line 7
-			bf		12,lnol6						; No line 6 to do...
-			dcbt	br0,r20							; Touch cache line 6
-			
-lnol6:		
-			la		r23,savevr10(r14)				; Point to V10/V11 pair
-			bf		24,lnovr8						; Do not restore VR8...
-			lvxl	v8,br0,r22						; Restore VR8
-			
-lnovr8:
-			bf		25,lnovr9						; Do not save VR9...
-			lvxl	v9,r30,r22						; Restore VR9
-			
-lnovr9:
-			mtcrf	0x04,r10						; Set CRs for registers 20-23
-			la		r20,savevr16(r14)				; Point to line 8
-			bf		14,lnol7						; No line 7 to do...
-			dcbt	br0,r21							; Touch cache line 7
-			
-lnol7:		
-			la		r22,savevr12(r14)				; Point to V12/V13 pair
-			bf		26,lnovr10						; Do not restore VR10...
-			lvxl	v10,br0,r23						; Restore VR10
-			
-lnovr10:
-			bf		27,lnovr11						; Do not restore VR11...
-			lvxl	v11,r30,r23						; Restore VR11
-			
-lnovr11:
-
-;
-;			Note: CR6 is now free
-;
-			la		r21,savevr18(r14)				; Point to line 9
-			bf		1,lnol8							; No line 8 to do...
-			dcbt	br0,r20							; Touch cache line 8
-			
-lnol8:		
-			la		r23,savevr14(r14)				; Point to V14/V15 pair
-			bf		28,lnovr12						; Do not restore VR12...
-			lvxl	v12,br0,r22						; Restore VR12
-			
-lnovr12:
-			bf		29,lnovr13						; Do not restore VR13...
-			lvxl	v13,r30,r22						; Restore VR13
-			
-lnovr13:
-			mtcrf	0x02,r10						; Set CRs for registers 24-27
-			la		r20,savevr20(r14)				; Point to line 10
-			bf		3,lnol9							; No line 9 to do...
-			dcbt	br0,r21							; Touch cache line 9
-			
-lnol9:		
-			la		r22,savevr16(r14)				; Point to V16/V17 pair
-			bf		30,lnovr14						; Do not restore VR14...
-			lvxl	v14,br0,r23						; Restore VR14
-			
-lnovr14:
-			bf		31,lnovr15						; Do not restore VR15...
-			lvxl	v15,r30,r23						; Restore VR15
-			
-lnovr15:
-;
-;			Note: CR7 is now free
-;
-			la		r21,savevr22(r14)				; Point to line 11
-			bf		5,lnol10						; No line 10 to do...
-			dcbt	br0,r20							; Touch cache line 10
-			
-lnol10:		
-			la		r23,savevr18(r14)				; Point to V18/V19 pair
-			bf		16,lnovr16						; Do not restore VR16...
-			lvxl	v16,br0,r22						; Restore VR16
-			
-lnovr16:
-			bf		17,lnovr17						; Do not restore VR17...
-			lvxl	v17,r30,r22						; Restore VR17
-			
-lnovr17:
-			mtcrf	0x01,r10						; Set CRs for registers 28-31
-;
-;			Note: All registers have been or are accounted for in CRs
-;
-			la		r20,savevr24(r14)				; Point to line 12
-			bf		7,lnol11						; No line 11 to do...
-			dcbt	br0,r21							; Touch cache line 11
-			
-lnol11:		
-			la		r22,savevr20(r14)				; Point to V20/V21 pair
-			bf		18,lnovr18						; Do not restore VR18...
-			lvxl	v18,br0,r23						; Restore VR18
-			
-lnovr18:
-			bf		19,lnovr19						; Do not restore VR19...
-			lvxl	v19,r30,r23						; Restore VR19
-			
-lnovr19:
-			la		r21,savevr26(r14)				; Point to line 13
-			bf		9,lnol12						; No line 12 to do...
-			dcbt	br0,r20							; Touch cache line 12
-			
-lnol12:		
-			la		r23,savevr22(r14)				; Point to V22/V23 pair
-			bf		20,lnovr20						; Do not restore VR20...
-			lvxl	v20,br0,r22						; Restore VR20
-			
-lnovr20:
-			bf		21,lnovr21						; Do not restore VR21...
-			lvxl	v21,r30,r22						; Restore VR21
-			
-lnovr21:
-			la		r20,savevr28(r14)				; Point to line 14
-			bf		11,lnol13						; No line 13 to do...
-			dcbt	br0,r21							; Touch cache line 13
-			
-lnol13:		
-			la		r22,savevr24(r14)				; Point to V24/V25 pair
-			bf		22,lnovr22						; Do not restore VR22...
-			lvxl	v22,br0,r23						; Restore VR22
-			
-lnovr22:
-			bf		23,lnovr23						; Do not restore VR23...
-			lvxl	v23,r30,r23						; Restore VR23
-			
-lnovr23:
-			la		r21,savevr30(r14)				; Point to line 15
-			bf		13,lnol14						; No line 14 to do...
-			dcbt	br0,r20							; Touch cache line 14
-			
-lnol14:		
-			la		r23,savevr26(r14)				; Point to V26/V27 pair
-			bf		24,lnovr24						; Do not restore VR24...
-			lvxl	v24,br0,r22						; Restore VR24
-			
-lnovr24:
-			bf		25,lnovr25						; Do not restore VR25...
-			lvxl	v25,r30,r22						; Restore VR25
-			
-lnovr25:
-			bf		15,lnol15						; No line 15 to do...
-			dcbt	br0,r21							; Touch cache line 15
-			
-lnol15:		
-;
-;			Note: All needed cache lines have been touched now
-;
-			la		r22,savevr28(r14)				; Point to V28/V29 pair
-			bf		26,lnovr26						; Do not restore VR26...
-			lvxl	v26,br0,r23						; Restore VR26
-			
-lnovr26:
-			bf		27,lnovr27						; Do not restore VR27...
-			lvxl	v27,r30,r23						; Restore VR27
-			
-lnovr27:
-			la		r23,savevr30(r14)				; Point to V30/V31 pair
-			bf		28,lnovr28						; Do not restore VR28...
-			lvxl	v28,br0,r22						; Restore VR28
-			
-lnovr28:		
-			bf		29,lnovr29						; Do not restore VR29...
-			lvxl	v29,r30,r22						; Restore VR29
-			
-lnovr29:		
-			bf		30,lnovr30						; Do not restore VR30...
-			lvxl	v30,br0,r23						; Restore VR30
-			
-lnovr30:
-;
-;			Everything is restored now except for VR31.  We need it to get
-;			the QNaNBarbarian value to put into idle vector registers. 
-;			Note: V31 was set above to QNaNbarbarian
-;
-			
-			cmpwi	r10,-1							; Handle the quick case of all registers in use
-			beq-	mstlvr31						; Not likely, but all are in use...
-			mtcrf	255,r10							; Get mask of valid registers
-
-			bt		0,ni0							; Register is ok already...
-			vor		v0,v31,v31						; Copy into the next register
-ni0:
-			bt		1,ni1							; Register is ok already...
-			vor		v1,v31,v31						; Copy into the next register
-ni1:
-			bt		2,ni2							; Register is ok already...
-			vor		v2,v31,v31						; Copy into the next register
-ni2:
-			bt		3,ni3							; Register is ok already...
-			vor		v3,v31,v31						; Copy into the next register
-ni3:
-			bt		4,ni4							; Register is ok already...
-			vor		v4,v31,v31						; Copy into the next register
-ni4:
-			bt		5,ni5							; Register is ok already...
-			vor		v5,v31,v31						; Copy into the next register
-ni5:
-			bt		6,ni6							; Register is ok already...
-			vor		v6,v31,v31						; Copy into the next register
-ni6:
-			bt		7,ni7							; Register is ok already...
-			vor		v7,v31,v31						; Copy into the next register
-ni7:
-			bt		8,ni8							; Register is ok already...
-			vor		v8,v31,v31						; Copy into the next register
-ni8:
-			bt		9,ni9							; Register is ok already...
-			vor		v9,v31,v31						; Copy into the next register
-ni9:
-			bt		10,ni10							; Register is ok already...
-			vor		v10,v31,v31						; Copy into the next register
-ni10:
-			bt		11,ni11							; Register is ok already...
-			vor		v11,v31,v31						; Copy into the next register
-ni11:
-			bt		12,ni12							; Register is ok already...
-			vor		v12,v31,v31						; Copy into the next register
-ni12:
-			bt		13,ni13							; Register is ok already...
-			vor		v13,v31,v31						; Copy into the next register
-ni13:
-			bt		14,ni14							; Register is ok already...
-			vor		v14,v31,v31						; Copy into the next register
-ni14:
-			bt		15,ni15							; Register is ok already...
-			vor		v15,v31,v31						; Copy into the next register
-ni15:
-			bt		16,ni16							; Register is ok already...
-			vor		v16,v31,v31						; Copy into the next register
-ni16:
-			bt		17,ni17							; Register is ok already...
-			vor		v17,v31,v31						; Copy into the next register
-ni17:
-			bt		18,ni18							; Register is ok already...
-			vor		v18,v31,v31						; Copy into the next register
-ni18:
-			bt		19,ni19							; Register is ok already...
-			vor		v19,v31,v31						; Copy into the next register
-ni19:
-			bt		20,ni20							; Register is ok already...
-			vor		v20,v31,v31						; Copy into the next register
-ni20:
-			bt		21,ni21							; Register is ok already...
-			vor		v21,v31,v31						; Copy into the next register
-ni21:
-			bt		22,ni22							; Register is ok already...
-			vor		v22,v31,v31						; Copy into the next register
-ni22:
-			bt		23,ni23							; Register is ok already...
-			vor		v23,v31,v31						; Copy into the next register
-ni23:
-			bt		24,ni24							; Register is ok already...
-			vor		v24,v31,v31						; Copy into the next register
-ni24:
-			bt		25,ni25							; Register is ok already...
-			vor		v25,v31,v31						; Copy into the next register
-ni25:
-			bt		26,ni26							; Register is ok already...
-			vor		v26,v31,v31						; Copy into the next register
-ni26:
-			bt		27,ni27							; Register is ok already...
-			vor		v27,v31,v31						; Copy into the next register
-ni27:
-			bt		28,ni28							; Register is ok already...
-			vor		v28,v31,v31						; Copy into the next register
-ni28:
-			bt		29,ni29							; Register is ok already...
-			vor		v29,v31,v31						; Copy into the next register
-ni29:
-			bt		30,ni30							; Register is ok already...
-			vor		v30,v31,v31						; Copy into the next register
-ni30:
-			bf		31,lnovr31						; V31 is empty, no need to restore...
-
-mstlvr31:	lvxl	v31,r30,r23						; Restore VR31
+            mr		r3,r14							; r3 <- ptr to savearea with VRs
+            bl		vr_load							; load VRs from save area based on vrsave in r10
+            			
+			bl		EXT(save_ret)					; Toss the save area after loading VRs
 			
-lnovr31:	mr		r3,r14							; Get the old savearea (we popped it before)
-			bl		EXT(save_ret)					; Toss it
-			
-vrenable:	lwz		r8,savesrr1(r25)				; Get the msr of the interrupted guy
-			rlwinm	r5,r25,0,0,19					; Get the page address of the savearea 
+vrenable:	lwz		r8,savesrr1+4(r25)				; Get the msr of the interrupted guy
 			oris	r8,r8,hi16(MASK(MSR_VEC))		; Enable the vector facility
-			lwz		r10,ACT_MACT_SPF(r17)			; Get the special flags
-			lwz		r5,SACvrswap(r5)				; Get Virtual to Real translation 
+			lwz		r10,ACT_MACT_SPF(r17)			; Get the act special flags
+			lwz		r11,spcFlags(r26)				; Get per_proc spec flags cause not in sync with act
 			oris	r10,r10,hi16(vectorUsed|vectorCng)	; Set that we used vectors
+			oris	r11,r11,hi16(vectorUsed|vectorCng)	; Set that we used vectors
 			rlwinm.	r0,r8,0,MSR_PR_BIT,MSR_PR_BIT	; See if we are doing this for user state
-			stw		r8,savesrr1(r25)				; Set the msr of the interrupted guy
-			xor		r3,r25,r5						; Get the real address of the savearea
+			stw		r8,savesrr1+4(r25)				; Set the msr of the interrupted guy
+			mr		r3,r25							; Pass virtual address of the savearea
 			beq-	vrnuser							; We are not user state...
 			stw		r10,ACT_MACT_SPF(r17)			; Set the activation copy
-			stw		r10,spcFlags(r26)				; Set per_proc copy
+			stw		r11,spcFlags(r26)				; Set per_proc copy
 
 vrnuser:
 #if FPVECDBG
@@ -2378,13 +1468,14 @@ vsthesame:
 			beq-	cr1,vrenable					; Not saved yet, nothing to pop, go enable and exit...
 			
 			lwz		r11,SAVlevel(r30)				; Get the level of top saved context
-			lwz		r14,SAVprev(r30)				; Get the previous savearea
+			lwz		r14,SAVprev+4(r30)				; Get the previous savearea
 			
 			cmplw	r11,r31							; Are live and saved the same?
 
 			bne+	vrenable						; Level not the same, nothing to pop, go enable and exit...
 			
 			mr		r3,r30							; Get the old savearea (we popped it before)
+			stw		r11,VMXsave(r22)				; Pop the vector stack
 			bl		EXT(save_ret)					; Toss it
 			b		vrenable						; Go enable and exit...
 
@@ -2399,11 +1490,13 @@ vsthesame:
 
 LEXT(toss_live_vec)
 			
+			lis		r0,hi16(MASK(MSR_VEC))			; Get VEC
 			mfmsr	r9								; Get the MSR
-			rlwinm	r0,r9,0,MSR_EE_BIT+1,MSR_EE_BIT-1	; Clear interuptions
-			rlwinm.	r8,r9,0,MSR_VEC_BIT,MSR_VEC_BIT	; Is vector on right now?
-			rlwinm	r9,r9,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Make sure vector is turned off
-			rlwinm	r9,r9,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Make sure fpu is turned off
+			ori		r0,r0,lo16(MASK(MSR_FP))		; Add in FP
+			rlwinm.	r8,r9,0,MSR_VEC_BIT,MSR_VEC_BIT	; Are vectors on right now?
+			andc	r9,r9,r0						; Force off VEC and FP
+			ori		r0,r0,lo16(MASK(MSR_EE))		; Turn off EE
+			andc	r0,r9,r0						; Turn off EE now
 			mtmsr	r0								; No interruptions
 			isync
 			beq+	tlvnotours						; Vector off, can not be live here...
@@ -2435,12 +1528,16 @@ tlvnotours:	lwz		r11,VMXcpu(r3)					; Get the cpu on which we last loaded contex
 			li		r0,0							; Set a 0 to invalidate context
 			
 tlvinvothr:	lwarx	r12,r10,r11						; Get the owner
-			cmplw	r12,r3							; Does he still have this context?
-			bne+	tlvexit							; Nope, leave...		
-			stwcx.	r0,r10,r11						; Try to invalidate it
-			bne-	tlvinvothr						; Try again if there was a collision...
 
-tlvexit:	mtmsr	r9								; Restore interruptions
+			sub		r0,r12,r3						; Subtract one from the other
+			sub		r8,r3,r12						; Subtract the other from the one
+			or		r8,r8,r0						; Combine them
+			srawi	r8,r8,31						; Get a 0 if equal or -1 of not
+			and		r12,r12,r8						; Make 0 if same, unchanged if not
+			stwcx.	r12,r10,r11						; Try to invalidate it
+			bne--	tlvinvothr						; Try again if there was a collision...		
+
+			mtmsr	r9								; Restore interruptions
 			isync									; Could be turning off vectors here
 			blr										; Leave....
 
@@ -2470,22 +1567,26 @@ LEXT(vec_trash)
 			ori		r12,r12,lo16(EXT(per_proc_info))	; Set base per_proc
 			li		r10,VMXowner					; Displacement to vector owner
 			add		r11,r12,r11						; Point to the owner per_proc	
-			li		r0,0							; Set a 0 to invalidate context
 			
 vtinvothr:	lwarx	r12,r10,r11						; Get the owner
-			cmplw	r12,r3							; Does he still have this context?
-			bne		vtnotlive						; Nope, not live anywhere...	
-			stwcx.	r0,r10,r11						; Try to invalidate it
-			bne-	vtinvothr						; Try again if there was a collision...
 
-vtnotlive:	beqlr+	cr1								; Leave if there is no savearea
+			sub		r0,r12,r3						; Subtract one from the other
+			sub		r8,r3,r12						; Subtract the other from the one
+			or		r8,r8,r0						; Combine them
+			srawi	r8,r8,31						; Get a 0 if equal or -1 of not
+			and		r12,r12,r8						; Make 0 if same, unchanged if not
+			stwcx.	r12,r10,r11						; Try to invalidate it
+			bne--	vtinvothr						; Try again if there was a collision...		
+
+
+			beqlr++	cr1								; Leave if there is no savearea
 			lwz		r8,SAVlevel(r9)					; Get the level of the savearea
 			cmplw	r8,r11							; Savearea for the current level?
-			bnelr+									; No, nothing to release...
+			bnelr++									; No, nothing to release...
 			
-			lwz		r8,SAVprev(r9)					; Pick up the previous area
+			lwz		r8,SAVprev+4(r9)				; Pick up the previous area
 			mr.		r8,r8							; Is there a previous?
-			beq-	vtnoprev						; Nope...
+			beq--	vtnoprev						; Nope...
 			lwz		r7,SAVlevel(r8)					; Get the level associated with save
 
 vtnoprev:	stw		r8,VMXsave(r3)					; Dequeue this savearea
@@ -2517,3 +1618,660 @@ LEXT(fctx_test)
 			mtspr	vrsave,r5						; Set VRSave
 			vor		v0,v0,v0						; Use vectors
 			blr
+
+
+// *******************
+// * f p _ s t o r e *
+// *******************
+//
+// Store FPRs into a save area.   Called by fpu_save and fpu_switch.
+//
+// When called:
+//		floating pt is enabled
+//		r3 = ptr to save area
+//
+// We destroy:
+//		r11.
+
+fp_store:
+            mfsprg	r11,2					; get feature flags
+            mtcrf	0x02,r11				; put cache line size bits in cr6
+            la		r11,savefp0(r3)			; point to 1st line
+            dcbz128	0,r11					; establish 1st line no matter what linesize is
+            bt--	pf32Byteb,fp_st32		; skip if a 32-byte machine
+            
+// Store the FPRs on a 128-byte machine.
+			
+			stfd    f0,savefp0(r3)
+			stfd    f1,savefp1(r3)
+			la		r11,savefp16(r3)		; Point to the 2nd cache line
+			stfd    f2,savefp2(r3)
+			stfd    f3,savefp3(r3)
+			dcbz128	0,r11					; establish 2nd line
+			stfd    f4,savefp4(r3)
+			stfd    f5,savefp5(r3)
+			stfd    f6,savefp6(r3)
+			stfd    f7,savefp7(r3)
+			stfd    f8,savefp8(r3)
+			stfd    f9,savefp9(r3)
+			stfd    f10,savefp10(r3)
+			stfd    f11,savefp11(r3)
+			stfd    f12,savefp12(r3)
+			stfd    f13,savefp13(r3)
+			stfd    f14,savefp14(r3)
+			stfd    f15,savefp15(r3)
+			stfd    f16,savefp16(r3)
+			stfd    f17,savefp17(r3)
+			stfd    f18,savefp18(r3)
+			stfd    f19,savefp19(r3)
+			stfd    f20,savefp20(r3)
+			stfd    f21,savefp21(r3)
+			stfd    f22,savefp22(r3)
+			stfd    f23,savefp23(r3)
+			stfd    f24,savefp24(r3)
+			stfd    f25,savefp25(r3)
+			stfd    f26,savefp26(r3)
+			stfd    f27,savefp27(r3)
+			stfd    f28,savefp28(r3)
+			stfd    f29,savefp29(r3)
+			stfd    f30,savefp30(r3)
+			stfd    f31,savefp31(r3)
+            blr
+            
+// Store FPRs on a 32-byte machine.
+
+fp_st32:
+			la		r11,savefp4(r3)				; Point to the 2nd line
+			stfd    f0,savefp0(r3)
+			dcbz	0,r11						; Allocate cache
+			stfd    f1,savefp1(r3)
+			stfd    f2,savefp2(r3)
+			la		r11,savefp8(r3)				; Point to the 3rd line
+			stfd    f3,savefp3(r3)
+			dcbz	0,r11						; Allocate cache
+			stfd    f4,savefp4(r3)
+			stfd    f5,savefp5(r3)
+			stfd    f6,savefp6(r3)
+			la		r11,savefp12(r3)			; Point to the 4th line
+			stfd    f7,savefp7(r3)
+			dcbz	0,r11						; Allocate cache
+			stfd    f8,savefp8(r3)
+			stfd    f9,savefp9(r3)
+			stfd    f10,savefp10(r3)
+			la		r11,savefp16(r3)			; Point to the 5th line
+			stfd    f11,savefp11(r3)
+			dcbz	0,r11						; Allocate cache
+			stfd    f12,savefp12(r3)
+			stfd    f13,savefp13(r3)
+			stfd    f14,savefp14(r3)
+			la		r11,savefp20(r3)			; Point to the 6th line 
+			stfd    f15,savefp15(r3)
+			dcbz	0,r11						; Allocate cache
+			stfd    f16,savefp16(r3)
+			stfd    f17,savefp17(r3)
+			stfd    f18,savefp18(r3)
+			la		r11,savefp24(r3)			; Point to the 7th line
+			stfd    f19,savefp19(r3)
+			dcbz	0,r11						; Allocate cache
+			stfd    f20,savefp20(r3)
+
+			stfd    f21,savefp21(r3)
+			stfd    f22,savefp22(r3)
+			la		r11,savefp28(r3)			; Point to the 8th line
+			stfd    f23,savefp23(r3)
+			dcbz	0,r11						; allocate it
+			stfd    f24,savefp24(r3)
+			stfd    f25,savefp25(r3)
+			stfd    f26,savefp26(r3)
+			stfd    f27,savefp27(r3)
+
+			stfd    f28,savefp28(r3)
+			stfd    f29,savefp29(r3)
+			stfd    f30,savefp30(r3)
+			stfd    f31,savefp31(r3)
+            blr
+
+
+// *******************
+// * v r _ s t o r e *
+// *******************
+//
+// Store VRs into savearea, according to bits set in passed vrsave bitfield.  This routine is used
+// both by vec_save and vec_switch.  In order to minimize conditional branches and touching in
+// unnecessary cache blocks, we either save all or none of the VRs in a block.  We have separate paths
+// for each cache block size.
+//
+// When called:
+//		interrupts are off, vectors are enabled
+//		r3 = ptr to save area
+//		r10 = vrsave (not 0)
+//
+// We destroy:
+//		r4 - r11, all CRs.
+
+vr_store:
+            mfsprg	r9,2					; get feature flags
+			stw		r10,savevrvalid(r3)		; Save the validity information in savearea
+			slwi	r8,r10,1				; Shift over 1
+            mtcrf	0x02,r9					; put cache line size bits in cr6 where we can test
+			or		r8,r10,r8				; r8 <- even bits show which pairs are in use
+            bt--	pf32Byteb,vr_st32		; skip if 32-byte cacheline processor
+
+            
+; Save vectors on a 128-byte linesize processor.  We save all or none of the 8 registers in each of
+; the four cache lines.  This minimizes mispredicted branches yet handles cache lines optimally.
+
+            slwi	r7,r8,2					; shift groups-of-2 over by 2
+            li		r4,16					; load offsets for X-form stores
+            or		r8,r7,r8				; show if any in group of 4 are in use
+            li		r5,32
+            slwi	r7,r8,4					; shift groups-of-4 over by 4
+            li		r6,48
+            or		r11,r7,r8				; show if any in group of 8 are in use
+            li		r7,64
+            mtcrf	0x80,r11				; set CRs one at a time (faster)
+            li		r8,80
+            mtcrf	0x20,r11
+            li		r9,96
+            mtcrf	0x08,r11
+            li		r10,112
+            mtcrf	0x02,r11
+            
+            bf		0,vr_st64b				; skip if none of vr0-vr7 are in use
+            la		r11,savevr0(r3)			; get address of this group of registers in save area
+            dcbz128	0,r11					; zero the line
+            stvxl	v0,0,r11				; save 8 VRs in the line
+            stvxl	v1,r4,r11
+            stvxl	v2,r5,r11
+            stvxl	v3,r6,r11
+            stvxl	v4,r7,r11
+            stvxl	v5,r8,r11
+            stvxl	v6,r9,r11
+            stvxl	v7,r10,r11
+            
+vr_st64b:
+            bf		8,vr_st64c				; skip if none of vr8-vr15 are in use
+            la		r11,savevr8(r3)			; get address of this group of registers in save area
+            dcbz128	0,r11					; zero the line
+            stvxl	v8,0,r11				; save 8 VRs in the line
+            stvxl	v9,r4,r11
+            stvxl	v10,r5,r11
+            stvxl	v11,r6,r11
+            stvxl	v12,r7,r11
+            stvxl	v13,r8,r11
+            stvxl	v14,r9,r11
+            stvxl	v15,r10,r11
+
+vr_st64c:
+            bf		16,vr_st64d				; skip if none of vr16-vr23 are in use
+            la		r11,savevr16(r3)		; get address of this group of registers in save area
+            dcbz128	0,r11					; zero the line
+            stvxl	v16,0,r11				; save 8 VRs in the line
+            stvxl	v17,r4,r11
+            stvxl	v18,r5,r11
+            stvxl	v19,r6,r11
+            stvxl	v20,r7,r11
+            stvxl	v21,r8,r11
+            stvxl	v22,r9,r11
+            stvxl	v23,r10,r11
+
+vr_st64d:
+            bflr	24						; done if none of vr24-vr31 are in use
+            la		r11,savevr24(r3)		; get address of this group of registers in save area
+            dcbz128	0,r11					; zero the line
+            stvxl	v24,0,r11				; save 8 VRs in the line
+            stvxl	v25,r4,r11
+            stvxl	v26,r5,r11
+            stvxl	v27,r6,r11
+            stvxl	v28,r7,r11
+            stvxl	v29,r8,r11
+            stvxl	v30,r9,r11
+            stvxl	v31,r10,r11
+            blr            
+            
+; Save vectors on a 32-byte linesize processor.  We save in 16 groups of 2: we either save both
+; or neither in each group.  This cuts down on conditional branches.
+;			 r8 = bitmask with bit n set (for even n) if either of that pair of VRs is in use
+;		     r3 = savearea
+
+vr_st32:
+            mtcrf	0xFF,r8					; set CR bits so we can branch on them
+            li		r4,16					; load offset for X-form stores
+
+            bf		0,vr_st32b				; skip if neither VR in this pair is in use
+            la		r11,savevr0(r3)			; get address of this group of registers in save area
+            dcba	0,r11					; establish the line wo reading it
+            stvxl	v0,0,r11				; save the two VRs in the line
+            stvxl	v1,r4,r11
+
+vr_st32b:
+            bf		2,vr_st32c				; skip if neither VR in this pair is in use
+            la		r11,savevr2(r3)			; get address of this group of registers in save area
+            dcba	0,r11					; establish the line wo reading it
+            stvxl	v2,0,r11				; save the two VRs in the line
+            stvxl	v3,r4,r11
+
+vr_st32c:
+            bf		4,vr_st32d				; skip if neither VR in this pair is in use
+            la		r11,savevr4(r3)			; get address of this group of registers in save area
+            dcba	0,r11					; establish the line wo reading it
+            stvxl	v4,0,r11				; save the two VRs in the line
+            stvxl	v5,r4,r11
+
+vr_st32d:
+            bf		6,vr_st32e				; skip if neither VR in this pair is in use
+            la		r11,savevr6(r3)			; get address of this group of registers in save area
+            dcba	0,r11					; establish the line wo reading it
+            stvxl	v6,0,r11				; save the two VRs in the line
+            stvxl	v7,r4,r11
+
+vr_st32e:
+            bf		8,vr_st32f				; skip if neither VR in this pair is in use
+            la		r11,savevr8(r3)			; get address of this group of registers in save area
+            dcba	0,r11					; establish the line wo reading it
+            stvxl	v8,0,r11				; save the two VRs in the line
+            stvxl	v9,r4,r11
+
+vr_st32f:
+            bf		10,vr_st32g				; skip if neither VR in this pair is in use
+            la		r11,savevr10(r3)		; get address of this group of registers in save area
+            dcba	0,r11					; establish the line wo reading it
+            stvxl	v10,0,r11				; save the two VRs in the line
+            stvxl	v11,r4,r11
+
+vr_st32g:
+            bf		12,vr_st32h				; skip if neither VR in this pair is in use
+            la		r11,savevr12(r3)		; get address of this group of registers in save area
+            dcba	0,r11					; establish the line wo reading it
+            stvxl	v12,0,r11				; save the two VRs in the line
+            stvxl	v13,r4,r11
+
+vr_st32h:
+            bf		14,vr_st32i				; skip if neither VR in this pair is in use
+            la		r11,savevr14(r3)		; get address of this group of registers in save area
+            dcba	0,r11					; establish the line wo reading it
+            stvxl	v14,0,r11				; save the two VRs in the line
+            stvxl	v15,r4,r11
+
+vr_st32i:
+            bf		16,vr_st32j				; skip if neither VR in this pair is in use
+            la		r11,savevr16(r3)		; get address of this group of registers in save area
+            dcba	0,r11					; establish the line wo reading it
+            stvxl	v16,0,r11				; save the two VRs in the line
+            stvxl	v17,r4,r11
+
+vr_st32j:
+            bf		18,vr_st32k				; skip if neither VR in this pair is in use
+            la		r11,savevr18(r3)		; get address of this group of registers in save area
+            dcba	0,r11					; establish the line wo reading it
+            stvxl	v18,0,r11				; save the two VRs in the line
+            stvxl	v19,r4,r11
+
+vr_st32k:
+            bf		20,vr_st32l				; skip if neither VR in this pair is in use
+            la		r11,savevr20(r3)		; get address of this group of registers in save area
+            dcba	0,r11					; establish the line wo reading it
+            stvxl	v20,0,r11				; save the two VRs in the line
+            stvxl	v21,r4,r11
+
+vr_st32l:
+            bf		22,vr_st32m				; skip if neither VR in this pair is in use
+            la		r11,savevr22(r3)		; get address of this group of registers in save area
+            dcba	0,r11					; establish the line wo reading it
+            stvxl	v22,0,r11				; save the two VRs in the line
+            stvxl	v23,r4,r11
+
+vr_st32m:
+            bf		24,vr_st32n				; skip if neither VR in this pair is in use
+            la		r11,savevr24(r3)		; get address of this group of registers in save area
+            dcba	0,r11					; establish the line wo reading it
+            stvxl	v24,0,r11				; save the two VRs in the line
+            stvxl	v25,r4,r11
+
+vr_st32n:
+            bf		26,vr_st32o				; skip if neither VR in this pair is in use
+            la		r11,savevr26(r3)		; get address of this group of registers in save area
+            dcba	0,r11					; establish the line wo reading it
+            stvxl	v26,0,r11				; save the two VRs in the line
+            stvxl	v27,r4,r11
+
+vr_st32o:
+            bf		28,vr_st32p				; skip if neither VR in this pair is in use
+            la		r11,savevr28(r3)		; get address of this group of registers in save area
+            dcba	0,r11					; establish the line wo reading it
+            stvxl	v28,0,r11				; save the two VRs in the line
+            stvxl	v29,r4,r11
+
+vr_st32p:
+            bflr	30						; done if neither VR in this pair is in use
+            la		r11,savevr30(r3)		; get address of this group of registers in save area
+            dcba	0,r11					; establish the line wo reading it
+            stvxl	v30,0,r11				; save the two VRs in the line
+            stvxl	v31,r4,r11
+            blr
+
+
+// *****************
+// * v r _ l o a d *
+// *****************
+//
+// Load live VRs from a savearea, according to bits set in a passed vector.  This is the reverse
+// of "vr_store".  Like it, we avoid touching unnecessary cache blocks and minimize conditional
+// branches by loading all VRs from a cache line, if we have to load any.  If we don't load the VRs
+// in a cache line, we bug them.  Note that this behavior is slightly different from earlier kernels,
+// which would bug all VRs that aren't live.
+//
+// When called:
+//		interrupts are off, vectors are enabled
+//		r3 = ptr to save area
+//		r10 = vector of live regs to load (ie, savevrsave & savevrvalid, may be 0)
+//		v31 = bugbug constant (0x7FFFDEAD7FFFDEAD7FFFDEAD7FFFDEAD)
+//
+// We destroy:
+//		r4 - r11, all CRs.
+
+vr_load:
+            mfsprg	r9,2					; get feature flags
+            li		r6,1					; assuming 32-byte, get (#VRs)-1 in a cacheline
+            mtcrf	0x02,r9					; set cache line size bits in cr6
+            lis		r7,0xC000				; assuming 32-byte, set bits 0-1
+            bt--	pf32Byteb,vr_ld0		; skip if 32-bit processor
+            li		r6,7					; 128-byte machines have 8 VRs in a cacheline
+            lis		r7,0xFF00				; so set bits 0-7
+            
+// Loop touching in cache blocks we will load from.
+//		r3 = savearea ptr
+//		r5 = we light bits for the VRs we will be loading
+//		r6 = 1 if 32-byte, 7 if 128-byte
+//		r7 = 0xC0000000 if 32-byte, 0xFF000000 if 128-byte
+//		r10 = live VR bits
+//		v31 = bugbug constant
+
+vr_ld0:
+            li		r5,0					; initialize set of VRs to load
+            la		r11,savevr0(r3)			; get address of register file
+            b		vr_ld2					; enter loop in middle
+            
+            .align	5
+vr_ld1:										; loop over each cache line we will load
+            dcbt	r4,r11					; start prefetch of the line
+            andc	r10,r10,r9				; turn off the bits in this line
+            or		r5,r5,r9				; we will load all these
+vr_ld2:										; initial entry pt
+            cntlzw	r4,r10					; get offset to next live VR
+            andc	r4,r4,r6				; cacheline align it
+            srw.	r9,r7,r4				; position bits for VRs in that cache line
+            slwi	r4,r4,4					; get byte offset within register file to that line
+            bne		vr_ld1					; loop if more bits in r10
+            
+            bf--	pf128Byteb,vr_ld32		; skip if not 128-byte lines
+
+// Handle a processor with 128-byte cache lines.  Four groups of 8 VRs.
+//		r3 = savearea ptr
+//		r5 = 1st bit in each cacheline is 1 iff any reg in that line must be loaded
+//		r11 = addr(savevr0)
+//		v31 = bugbug constant
+
+            mtcrf	0x80,r5					; set up bits for conditional branches
+            li		r4,16					; load offsets for X-form stores
+            li		r6,48
+            mtcrf	0x20,r5					; load CRs ona at a time, which is faster
+            li		r7,64
+            li		r8,80
+            mtcrf	0x08,r5
+            li		r9,96
+            li		r10,112
+            mtcrf	0x02,r5
+            li		r5,32
+            
+            bt		0,vr_ld128a				; skip if this line must be loaded
+            vor		v0,v31,v31				; no VR must be loaded, so bug them all
+            vor		v1,v31,v31
+            vor		v2,v31,v31
+            vor		v3,v31,v31
+            vor		v4,v31,v31
+            vor		v5,v31,v31
+            vor		v6,v31,v31
+            vor		v7,v31,v31
+            b		vr_ld128b
+vr_ld128a:									; must load from this line
+            lvxl	v0,0,r11
+            lvxl	v1,r4,r11
+            lvxl	v2,r5,r11
+            lvxl	v3,r6,r11
+            lvxl	v4,r7,r11
+            lvxl	v5,r8,r11
+            lvxl	v6,r9,r11
+            lvxl	v7,r10,r11
+            
+vr_ld128b:   								; here to handle next cache line         
+            la		r11,savevr8(r3)			; load offset to it
+            bt		8,vr_ld128c				; skip if this line must be loaded
+            vor		v8,v31,v31				; no VR must be loaded, so bug them all
+            vor		v9,v31,v31
+            vor		v10,v31,v31
+            vor		v11,v31,v31
+            vor		v12,v31,v31
+            vor		v13,v31,v31
+            vor		v14,v31,v31
+            vor		v15,v31,v31
+            b		vr_ld128d
+vr_ld128c:									; must load from this line
+            lvxl	v8,0,r11
+            lvxl	v9,r4,r11
+            lvxl	v10,r5,r11
+            lvxl	v11,r6,r11
+            lvxl	v12,r7,r11
+            lvxl	v13,r8,r11
+            lvxl	v14,r9,r11
+            lvxl	v15,r10,r11
+            
+vr_ld128d:   								; here to handle next cache line         
+            la		r11,savevr16(r3)		; load offset to it
+            bt		16,vr_ld128e			; skip if this line must be loaded
+            vor		v16,v31,v31				; no VR must be loaded, so bug them all
+            vor		v17,v31,v31
+            vor		v18,v31,v31
+            vor		v19,v31,v31
+            vor		v20,v31,v31
+            vor		v21,v31,v31
+            vor		v22,v31,v31
+            vor		v23,v31,v31
+            b		vr_ld128f
+vr_ld128e:									; must load from this line
+            lvxl	v16,0,r11
+            lvxl	v17,r4,r11
+            lvxl	v18,r5,r11
+            lvxl	v19,r6,r11
+            lvxl	v20,r7,r11
+            lvxl	v21,r8,r11
+            lvxl	v22,r9,r11
+            lvxl	v23,r10,r11
+            
+vr_ld128f:   								; here to handle next cache line         
+            la		r11,savevr24(r3)		; load offset to it
+            bt		24,vr_ld128g			; skip if this line must be loaded
+            vor		v24,v31,v31				; no VR must be loaded, so bug them all
+            vor		v25,v31,v31
+            vor		v26,v31,v31
+            vor		v27,v31,v31
+            vor		v28,v31,v31
+            vor		v29,v31,v31
+            vor		v30,v31,v31
+            blr
+vr_ld128g:									; must load from this line
+            lvxl	v24,0,r11
+            lvxl	v25,r4,r11
+            lvxl	v26,r5,r11
+            lvxl	v27,r6,r11
+            lvxl	v28,r7,r11
+            lvxl	v29,r8,r11
+            lvxl	v30,r9,r11
+            lvxl	v31,r10,r11
+            blr
+            
+// Handle a processor with 32-byte cache lines.  Sixteen groups of two VRs.
+//		r5 = 1st bit in each cacheline is 1 iff any reg in that line must be loaded
+//		r11 = addr(savevr0)
+
+vr_ld32:
+            mtcrf	0xFF,r5					; set up bits for conditional branches
+            li		r4,16					; load offset for X-form stores
+            
+            bt		0,vr_ld32load0			; skip if we must load this line
+            vor		v0,v31,v31				; neither VR is live, so bug them both
+            vor		v1,v31,v31
+            b		vr_ld32test2
+vr_ld32load0:								; must load VRs in this line
+            lvxl	v0,0,r11
+            lvxl	v1,r4,r11
+            
+vr_ld32test2:								; here to handle next cache line
+            la		r11,savevr2(r3)			; get offset to next cache line
+            bt		2,vr_ld32load2			; skip if we must load this line
+            vor		v2,v31,v31				; neither VR is live, so bug them both
+            vor		v3,v31,v31
+            b		vr_ld32test4
+vr_ld32load2:								; must load VRs in this line
+            lvxl	v2,0,r11
+            lvxl	v3,r4,r11
+            
+vr_ld32test4:								; here to handle next cache line
+            la		r11,savevr4(r3)			; get offset to next cache line
+            bt		4,vr_ld32load4			; skip if we must load this line
+            vor		v4,v31,v31				; neither VR is live, so bug them both
+            vor		v5,v31,v31
+            b		vr_ld32test6
+vr_ld32load4:								; must load VRs in this line
+            lvxl	v4,0,r11
+            lvxl	v5,r4,r11
+            
+vr_ld32test6:								; here to handle next cache line
+            la		r11,savevr6(r3)			; get offset to next cache line
+            bt		6,vr_ld32load6			; skip if we must load this line
+            vor		v6,v31,v31				; neither VR is live, so bug them both
+            vor		v7,v31,v31
+            b		vr_ld32test8
+vr_ld32load6:								; must load VRs in this line
+            lvxl	v6,0,r11
+            lvxl	v7,r4,r11
+            
+vr_ld32test8:								; here to handle next cache line
+            la		r11,savevr8(r3)			; get offset to next cache line
+            bt		8,vr_ld32load8			; skip if we must load this line
+            vor		v8,v31,v31				; neither VR is live, so bug them both
+            vor		v9,v31,v31
+            b		vr_ld32test10
+vr_ld32load8:								; must load VRs in this line
+            lvxl	v8,0,r11
+            lvxl	v9,r4,r11
+            
+vr_ld32test10:								; here to handle next cache line
+            la		r11,savevr10(r3)		; get offset to next cache line
+            bt		10,vr_ld32load10		; skip if we must load this line
+            vor		v10,v31,v31				; neither VR is live, so bug them both
+            vor		v11,v31,v31
+            b		vr_ld32test12
+vr_ld32load10:								; must load VRs in this line
+            lvxl	v10,0,r11
+            lvxl	v11,r4,r11
+            
+vr_ld32test12:								; here to handle next cache line
+            la		r11,savevr12(r3)		; get offset to next cache line
+            bt		12,vr_ld32load12		; skip if we must load this line
+            vor		v12,v31,v31				; neither VR is live, so bug them both
+            vor		v13,v31,v31
+            b		vr_ld32test14
+vr_ld32load12:								; must load VRs in this line
+            lvxl	v12,0,r11
+            lvxl	v13,r4,r11
+            
+vr_ld32test14:								; here to handle next cache line
+            la		r11,savevr14(r3)		; get offset to next cache line
+            bt		14,vr_ld32load14		; skip if we must load this line
+            vor		v14,v31,v31				; neither VR is live, so bug them both
+            vor		v15,v31,v31
+            b		vr_ld32test16
+vr_ld32load14:								; must load VRs in this line
+            lvxl	v14,0,r11
+            lvxl	v15,r4,r11
+            
+vr_ld32test16:								; here to handle next cache line
+            la		r11,savevr16(r3)		; get offset to next cache line
+            bt		16,vr_ld32load16		; skip if we must load this line
+            vor		v16,v31,v31				; neither VR is live, so bug them both
+            vor		v17,v31,v31
+            b		vr_ld32test18
+vr_ld32load16:								; must load VRs in this line
+            lvxl	v16,0,r11
+            lvxl	v17,r4,r11
+            
+vr_ld32test18:								; here to handle next cache line
+            la		r11,savevr18(r3)		; get offset to next cache line
+            bt		18,vr_ld32load18		; skip if we must load this line
+            vor		v18,v31,v31				; neither VR is live, so bug them both
+            vor		v19,v31,v31
+            b		vr_ld32test20
+vr_ld32load18:								; must load VRs in this line
+            lvxl	v18,0,r11
+            lvxl	v19,r4,r11
+            
+vr_ld32test20:								; here to handle next cache line
+            la		r11,savevr20(r3)		; get offset to next cache line
+            bt		20,vr_ld32load20		; skip if we must load this line
+            vor		v20,v31,v31				; neither VR is live, so bug them both
+            vor		v21,v31,v31
+            b		vr_ld32test22
+vr_ld32load20:								; must load VRs in this line
+            lvxl	v20,0,r11
+            lvxl	v21,r4,r11
+            
+vr_ld32test22:								; here to handle next cache line
+            la		r11,savevr22(r3)		; get offset to next cache line
+            bt		22,vr_ld32load22		; skip if we must load this line
+            vor		v22,v31,v31				; neither VR is live, so bug them both
+            vor		v23,v31,v31
+            b		vr_ld32test24
+vr_ld32load22:								; must load VRs in this line
+            lvxl	v22,0,r11
+            lvxl	v23,r4,r11
+            
+vr_ld32test24:								; here to handle next cache line
+            la		r11,savevr24(r3)		; get offset to next cache line
+            bt		24,vr_ld32load24		; skip if we must load this line
+            vor		v24,v31,v31				; neither VR is live, so bug them both
+            vor		v25,v31,v31
+            b		vr_ld32test26
+vr_ld32load24:								; must load VRs in this line
+            lvxl	v24,0,r11
+            lvxl	v25,r4,r11
+            
+vr_ld32test26:								; here to handle next cache line
+            la		r11,savevr26(r3)		; get offset to next cache line
+            bt		26,vr_ld32load26		; skip if we must load this line
+            vor		v26,v31,v31				; neither VR is live, so bug them both
+            vor		v27,v31,v31
+            b		vr_ld32test28
+vr_ld32load26:								; must load VRs in this line
+            lvxl	v26,0,r11
+            lvxl	v27,r4,r11
+            
+vr_ld32test28:								; here to handle next cache line
+            la		r11,savevr28(r3)		; get offset to next cache line
+            bt		28,vr_ld32load28		; skip if we must load this line
+            vor		v28,v31,v31				; neither VR is live, so bug them both
+            vor		v29,v31,v31
+            b		vr_ld32test30
+vr_ld32load28:								; must load VRs in this line
+            lvxl	v28,0,r11
+            lvxl	v29,r4,r11
+            
+vr_ld32test30:								; here to handle next cache line
+            la		r11,savevr30(r3)		; get offset to next cache line
+            bt		30,vr_ld32load30		; skip if we must load this line
+            vor		v30,v31,v31				; neither VR is live, so bug them both
+            blr
+vr_ld32load30:								; must load VRs in this line
+            lvxl	v30,0,r11
+            lvxl	v31,r4,r11
+            blr
diff --git a/osfmk/ppc/db_asm.s b/osfmk/ppc/db_asm.s
index 37c800684..7eeeb4e4b 100644
--- a/osfmk/ppc/db_asm.s
+++ b/osfmk/ppc/db_asm.s
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -29,60 +32,6 @@
 #include <mach/ppc/vm_param.h>
 #include <assym.s>
 
-/* void
- * db_phys_copy(src, dst, bytecount)
- *      vm_offset_t     src;
- *      vm_offset_t     dst;
- *      int             bytecount
- *
- * This routine will copy bytecount bytes from physical address src to physical
- * address dst. 
- */
-ENTRY(db_phys_copy, TAG_NO_FRAME_USED)
-
-	/* Switch off data translations */
-	mfmsr	r6
-	rlwinm	r6,r6,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-	rlwinm	r6,r6,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-	rlwinm	r7,	r6,	0,	MSR_DR_BIT+1,	MSR_DR_BIT-1
-	mtmsr	r7
-	isync			/* Ensure data translations are off */
-
-	subi	r3,	r3,	4
-	subi	r4,	r4,	4
-
-	cmpwi	r5,	3
-	ble-	.L_db_phys_copy_bytes
-.L_db_phys_copy_loop:
-	lwz	r0,	4(r3)
-	addi	r3,	r3,	4
-	subi	r5,	r5,	4
-	stw	r0,	4(r4)
-	addi	r4,	r4,	4
-	cmpwi	r5,	3
-	bgt+	.L_db_phys_copy_loop
-
-	/* If no leftover bytes, we're done now */
-	cmpwi	r5,	0
-	beq+	.L_db_phys_copy_done
-	
-.L_db_phys_copy_bytes:
-	addi	r3,	r3,	3
-	addi	r4,	r4,	3
-.L_db_phys_copy_byte_loop:	
-	lbz	r0,	1(r3)
-	addi	r3,	r3,	1
-	subi	r5,	r5,	1
-	stb	r0,	1(r4)
-	addi	r4,	r4,	1
-	cmpwi	r5,	0
-	bne+	.L_db_phys_copy_loop
-
-.L_db_phys_copy_done:
-	mtmsr	r6		/* Restore original translations */
-	isync			/* Ensure data translations are off */
-
-	blr
 
 /* void
  * db_phys_cmp(src_a, src_b, bytecount)
@@ -94,11 +43,15 @@ ENTRY(db_phys_copy, TAG_NO_FRAME_USED)
  * address src_b. 
  */
 
+#warning THIS IS BROKEN FOR 64-BIT
+
 	/* Switch off data translations */
+	lis		r7,hi16(MASK(MSR_VEC))
+	ori		r7,r7,lo16(MASK(MSR_FP))
 	mfmsr	r6
-	rlwinm	r6,r6,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-	rlwinm	r6,r6,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-	rlwinm	r7,	r6,	0,	MSR_DR_BIT+1,	MSR_DR_BIT-1
+	andc	r6,r6,r7			; Force FP and vec off
+	ori		r7,r7,lo16(MASK(MSR_DR))	; Set the DR bit
+	andc	r7,r6,r7			; Force DR off
 	mtmsr	r7
 	isync			/* Ensure data translations are off */
 
diff --git a/osfmk/ppc/db_disasm.c b/osfmk/ppc/db_disasm.c
index 984124ba0..810aeb110 100644
--- a/osfmk/ppc/db_disasm.c
+++ b/osfmk/ppc/db_disasm.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -66,6 +69,7 @@ db_disasm(
 		db_task_printsym(db_disasm_symaddr, DB_STGY_ANY, task);
 		db_printf(">");
 	}
+	db_printf("\n");		/* Make sure we have a new line for multiline displays */
 	dis_done();
 	return (loc+4);
 }
diff --git a/osfmk/ppc/db_interface.c b/osfmk/ppc/db_interface.c
index 229f4f5ac..ccce9c5b6 100644
--- a/osfmk/ppc/db_interface.c
+++ b/osfmk/ppc/db_interface.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -115,11 +118,6 @@ extern void	kdbprinttrap(
 			int			code,
 			int			*pc,
 			int			sp);
-extern int	db_user_to_kernel_address(
-			task_t			task,
-			vm_offset_t		addr,
-			unsigned		*kaddr,
-			int			flag);
 extern void	db_write_bytes_user_space(
 			vm_offset_t		addr,
 			int			size,
@@ -250,68 +248,22 @@ kdbprinttrap(
 /*
  *
  */
-vm_offset_t db_vtophys(
+addr64_t db_vtophys(
 	pmap_t pmap,
 	vm_offset_t va)
 {
-	register mapping	*mp;
-	register vm_offset_t	pa;
-
-	pa = (vm_offset_t)LRA(pmap->space,(void *)va);
+	ppnum_t pp;
+	addr64_t pa;
 
-	if (pa != 0)
-		return(pa);
+	pp = pmap_find_phys(pmap, (addr64_t)va);
 
-	mp = hw_lock_phys_vir(pmap->space, va);
-	if((unsigned int)mp&1) {
-		return 0;
-	}
-
-	if(!mp) {								/* If it was not a normal page */
-		pa = hw_cvp_blk(pmap, va);			/* Try to convert odd-sized page (returns 0 if not found) */
-		return pa;							/* Return physical address */
-	}
-
-	mp = hw_cpv(mp);						/* Convert to virtual address */
-
-	if(!mp->physent) {
-		pa = (vm_offset_t)((mp->PTEr & -PAGE_SIZE) | ((unsigned int)va & (PAGE_SIZE-1)));
-	} else {
-		pa = (vm_offset_t)((mp->physent->pte1 & -PAGE_SIZE) | ((unsigned int)va & (PAGE_SIZE-1)));
-		hw_unlock_bit((unsigned int *)&mp->physent->phys_link, PHYS_LOCK);
-	}
+	if (pp == 0) return(0);					/* Couldn't find it */
+	
+	pa = ((addr64_t)pp << 12) | (addr64_t)(va & 0xFFF);	/* Get physical address */
 
 	return(pa);
 }
 
-int
-db_user_to_kernel_address(
-	task_t		task,
-	vm_offset_t	addr,
-	unsigned	*kaddr,
-	int		flag)
-{
-	unsigned int	sr_val, raddr;
-
-	raddr = (unsigned int)db_vtophys(task->map->pmap, trunc_page(addr));	/* Get the real address */
-
-	if (!raddr) {
-	    if (flag) {
-		db_printf("\nno memory is assigned to address %08x\n", addr);
-		db_error(0);
-		/* NOTREACHED */
-	    }
-	    return -1;
-	}
-	sr_val = SEG_REG_PROT | task->map->pmap->space
-		 | ((addr >> 8) & 0x00F00000);
-		
-	mtsr(SR_COPYIN_NUM, sr_val);
-	sync();
-	*kaddr = (addr & 0x0fffffff) | (SR_COPYIN_NUM << 28);
-	return(0);
-}
-	
 /*
  * Read bytes from task address space for debugger.
  */
@@ -323,8 +275,8 @@ db_read_bytes(
 	task_t		task)
 {
 	int		n,max;
-	unsigned	phys_dst;
-	unsigned 	phys_src;
+	addr64_t	phys_dst;
+	addr64_t 	phys_src;
 	pmap_t	pmap;
 	
 	while (size > 0) {
@@ -333,16 +285,15 @@ db_read_bytes(
 		else
 			pmap = kernel_pmap;
 
-		phys_src = (unsigned int)db_vtophys(pmap, trunc_page(addr));  
+		phys_src = db_vtophys(pmap, (vm_offset_t)addr);  
 		if (phys_src == 0) {
 			db_printf("\nno memory is assigned to src address %08x\n",
 				  addr);
 			db_error(0);
 			/* NOTREACHED */
 		}
-		phys_src = phys_src| (addr & page_mask);
 
-		phys_dst = (unsigned int)db_vtophys(kernel_pmap, trunc_page(data)); 
+		phys_dst = db_vtophys(kernel_pmap, (vm_offset_t)data); 
 		if (phys_dst == 0) {
 			db_printf("\nno memory is assigned to dst address %08x\n",
 				  data);
@@ -350,22 +301,20 @@ db_read_bytes(
 			/* NOTREACHED */
 		}
 		
-		phys_dst = phys_dst | (((vm_offset_t) data) & page_mask);
-
 		/* don't over-run any page boundaries - check src range */
-		max = ppc_round_page(phys_src) - phys_src;
+		max = round_page_64(phys_src + 1) - phys_src;
 		if (max > size)
 			max = size;
 		/* Check destination won't run over boundary either */
-		n = ppc_round_page(phys_dst) - phys_dst;
-		if (n < max)
-			max = n;
+		n = round_page_64(phys_dst + 1) - phys_dst;
+		
+		if (n < max) max = n;
 		size -= max;
 		addr += max;
 		phys_copy(phys_src, phys_dst, max);
 
 		/* resync I+D caches */
-		sync_cache(phys_dst, max);
+		sync_cache64(phys_dst, max);
 
 		phys_src += max;
 		phys_dst += max;
@@ -383,13 +332,13 @@ db_write_bytes(
 	task_t		task)
 {
 	int		n,max;
-	unsigned	phys_dst;
-	unsigned 	phys_src;
+	addr64_t	phys_dst;
+	addr64_t 	phys_src;
 	pmap_t	pmap;
 	
 	while (size > 0) {
 
-		phys_src = (unsigned int)db_vtophys(kernel_pmap, trunc_page(data)); 
+		phys_src = db_vtophys(kernel_pmap, (vm_offset_t)data); 
 		if (phys_src == 0) {
 			db_printf("\nno memory is assigned to src address %08x\n",
 				  data);
@@ -397,27 +346,24 @@ db_write_bytes(
 			/* NOTREACHED */
 		}
 		
-		phys_src = phys_src | (((vm_offset_t) data) & page_mask);
-
 		/* space stays as kernel space unless in another task */
 		if (task == NULL) pmap = kernel_pmap;
 		else pmap = task->map->pmap;
 
-		phys_dst = (unsigned int)db_vtophys(pmap, trunc_page(addr));  
+		phys_dst = db_vtophys(pmap, (vm_offset_t)addr);  
 		if (phys_dst == 0) {
 			db_printf("\nno memory is assigned to dst address %08x\n",
 				  addr);
 			db_error(0);
 			/* NOTREACHED */
 		}
-		phys_dst = phys_dst| (addr & page_mask);
 
 		/* don't over-run any page boundaries - check src range */
-		max = ppc_round_page(phys_src) - phys_src;
+		max = round_page_64(phys_src + 1) - phys_src;
 		if (max > size)
 			max = size;
 		/* Check destination won't run over boundary either */
-		n = ppc_round_page(phys_dst) - phys_dst;
+		n = round_page_64(phys_dst + 1) - phys_dst;
 		if (n < max)
 			max = n;
 		size -= max;
@@ -425,7 +371,7 @@ db_write_bytes(
 		phys_copy(phys_src, phys_dst, max);
 
 		/* resync I+D caches */
-		sync_cache(phys_dst, max);
+		sync_cache64(phys_dst, max);
 
 		phys_src += max;
 		phys_dst += max;
@@ -442,18 +388,16 @@ db_check_access(
 	unsigned int	kern_addr;
 
 	if (task == kernel_task || task == TASK_NULL) {
-	    if (kernel_task == TASK_NULL)
-	        return(TRUE);
+	    if (kernel_task == TASK_NULL)  return(TRUE);
 	    task = kernel_task;
 	} else if (task == TASK_NULL) {
-	    if (current_act() == THR_ACT_NULL)
-		return(FALSE);
+	    if (current_act() == THR_ACT_NULL) return(FALSE);
 	    task = current_act()->task;
 	}
+
 	while (size > 0) {
-	    if (db_user_to_kernel_address(task, addr, &kern_addr, 0) < 0)
-		return(FALSE);
-	    n = ppc_trunc_page(addr+PPC_PGBYTES) - addr;
+		if(!pmap_find_phys(task->map->pmap, (addr64_t)addr)) return (FALSE);	/* Fail if page not mapped */
+	    n = trunc_page_32(addr+PPC_PGBYTES) - addr;
 	    if (n > size)
 		n = size;
 	    size -= n;
@@ -469,7 +413,7 @@ db_phys_eq(
 	task_t		task2,
 	vm_offset_t	addr2)
 {
-	vm_offset_t	physa, physb;
+	addr64_t	physa, physb;
 
 	if ((addr1 & (PPC_PGBYTES-1)) != (addr2 & (PPC_PGBYTES-1)))	/* Is byte displacement the same? */
 		return FALSE;
@@ -480,8 +424,8 @@ db_phys_eq(
 		task1 = current_act()->task;				/* If so, use that one */
 	}
 	
-	if(!(physa = db_vtophys(task1->map->pmap, trunc_page(addr1)))) return FALSE;	/* Get real address of the first */
-	if(!(physb = db_vtophys(task2->map->pmap, trunc_page(addr2)))) return FALSE;	/* Get real address of the second */
+	if(!(physa = db_vtophys(task1->map->pmap, (vm_offset_t)trunc_page_32(addr1)))) return FALSE;	/* Get real address of the first */
+	if(!(physb = db_vtophys(task2->map->pmap, (vm_offset_t)trunc_page_32(addr2)))) return FALSE;	/* Get real address of the second */
 	
 	return (physa == physb);						/* Check if they are equal, then return... */
 }
@@ -489,6 +433,16 @@ db_phys_eq(
 #define DB_USER_STACK_ADDR		(0xc0000000)
 #define DB_NAME_SEARCH_LIMIT		(DB_USER_STACK_ADDR-(PPC_PGBYTES*3))
 
+boolean_t	db_phys_cmp(
+				vm_offset_t a1, 
+				vm_offset_t a2, 
+				vm_size_t s1) {
+
+	db_printf("db_phys_cmp: not implemented\n");
+	return 0;
+}
+
+
 int
 db_search_null(
 	task_t		task,
@@ -500,65 +454,37 @@ db_search_null(
 	register unsigned vaddr;
 	register unsigned *kaddr;
 
-	kaddr = (unsigned *)*skaddr;
-	for (vaddr = *svaddr; vaddr > evaddr; ) {
-	    if (vaddr % PPC_PGBYTES == 0) {
-		vaddr -= sizeof(unsigned);
-		if (db_user_to_kernel_address(task, vaddr, skaddr, 0) < 0)
-		    return(-1);
-		kaddr = (unsigned *)*skaddr;
-	    } else {
-		vaddr -= sizeof(unsigned);
-		kaddr--;
-	    }
-	    if ((*kaddr == 0) ^ (flag  == 0)) {
-		*svaddr = vaddr;
-		*skaddr = (unsigned)kaddr;
-		return(0);
-	    }
-	}
+	db_printf("db_search_null: not implemented\n");
+
 	return(-1);
 }
 
+unsigned char *getProcName(struct proc *proc);
+
 void
 db_task_name(
 	task_t		task)
 {
-	register char *p;
+	register unsigned char *p;
 	register int n;
 	unsigned int vaddr, kaddr;
+	unsigned char tname[33];
+	int i;
 
-	vaddr = DB_USER_STACK_ADDR;
-	kaddr = 0;
-
-	/*
-	 * skip nulls at the end
-	 */
-	if (db_search_null(task, &vaddr, DB_NAME_SEARCH_LIMIT, &kaddr, 0) < 0) {
-	    db_printf(DB_NULL_TASK_NAME);
-	    return;
-	}
-	/*
-	 * search start of args
-	 */
-	if (db_search_null(task, &vaddr, DB_NAME_SEARCH_LIMIT, &kaddr, 1) < 0) {
-	    db_printf(DB_NULL_TASK_NAME);
-	    return;
-	}
-
-	n = DB_TASK_NAME_LEN-1;
-	p = (char *)kaddr + sizeof(unsigned);
-	for (vaddr += sizeof(int); vaddr < DB_USER_STACK_ADDR && n > 0; 
-							vaddr++, p++, n--) {
-	    if (vaddr % PPC_PGBYTES == 0) {
-		if (db_user_to_kernel_address(task, vaddr, &kaddr, 0) <0)
-			return;
-		p = (char*)kaddr;
-	    }
-	    db_printf("%c", (*p < ' ' || *p > '~')? ' ': *p);
+	p = 0;
+	tname[0] = 0;
+	
+	if(task->bsd_info) p = getProcName((struct proc *)(task->bsd_info));	/* Point to task name */
+	
+	if(p) {
+		for(i = 0; i < 32; i++) {			/* Move no more than 32 bytes */
+			tname[i] = p[i];
+			if(p[i] == 0) break;
+		}
+		tname[i] = 0;
+		db_printf("%s", tname);
 	}
-	while (n-- >= 0)	/* compare with >= 0 for one more space */
-	    db_printf(" ");
+	else db_printf("no name");
 }
 
 void
diff --git a/osfmk/ppc/db_low_trace.c b/osfmk/ppc/db_low_trace.c
index 2bc5ce0c4..1fa7e586b 100644
--- a/osfmk/ppc/db_low_trace.c
+++ b/osfmk/ppc/db_low_trace.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -58,14 +61,11 @@
 #include <ppc/mappings.h>
 #include <ppc/pmap.h>
 #include <ppc/mem.h>
-#include <ppc/pmap_internals.h>
 #include <ppc/savearea.h>
 #include <ppc/vmachmon.h>
 
-void db_dumpphys(struct phys_entry *pp); 					/* Dump from physent */
-void db_dumppca(struct mapping *mp); 						/* PCA */
+void db_dumppca(unsigned int ptegindex); 	
 void db_dumpmapping(struct mapping *mp); 					/* Dump out a mapping */
-void db_dumppmap(pmap_t pmap);								/* Dump out a pmap */
 extern kmod_info_t *kmod;									/* Find the kmods */
 
 db_addr_t	db_low_trace_prev = 0;
@@ -84,11 +84,11 @@ void db_low_trace(db_expr_t addr, int have_addr, db_expr_t count, char * modif)
 
 	int		c, i;
 	unsigned int tempx, cnt;
-	unsigned int xbuf[8];
-	unsigned int xTraceCurr, xTraceStart, xTraceEnd, cxltr, xxltr;
+	unsigned int xTraceCurr, xTraceStart, xTraceEnd, cxltr;
 	db_addr_t	next_addr;
 	LowTraceRecord xltr;
 	unsigned char cmark;
+	addr64_t xxltr;
 	
 	cnt = 16;													/* Default to 16 entries */
 	
@@ -108,29 +108,36 @@ void db_low_trace(db_expr_t addr, int have_addr, db_expr_t count, char * modif)
 		return;													/* Leave... */
 	}
 
-	if((unsigned int)addr&0x0000003F) {							/* Proper alignment? */
-		db_printf("address not aligned on trace entry boundary (0x40)\n");	/* Tell 'em */
+	if((unsigned int)addr&0x0000007F) {							/* Proper alignment? */
+		db_printf("address not aligned on trace entry boundary (0x80)\n");	/* Tell 'em */
 		return;													/* Leave... */
 	}
 	
-	xxltr=(unsigned int)addr;									/* Set the start */
-	cxltr=((xTraceCurr==xTraceStart ? xTraceEnd : xTraceCurr)-sizeof(LowTraceRecord));	/* Get address of newest entry */
+	xxltr = addr;												/* Set the start */
+	cxltr = ((xTraceCurr == xTraceStart ? xTraceEnd : xTraceCurr) - sizeof(LowTraceRecord));	/* Get address of newest entry */
 
 	db_low_trace_prev = addr;									/* Starting point */
 
 	for(i=0; i < cnt; i++) {									/* Dump the 16 (or all) entries */
 	
-		ReadReal(xxltr, (unsigned int *)&xltr);					/* Get the first half */
-		ReadReal(xxltr+32, &(((unsigned int *)&xltr)[8]));		/* Get the second half */
+		ReadReal((addr64_t)xxltr, (unsigned int *)&xltr);					/* Get the first half */
+		ReadReal((addr64_t)xxltr + 32, &(((unsigned int *)&xltr)[8]));		/* Get the second half */
+		ReadReal((addr64_t)xxltr + 64, &(((unsigned int *)&xltr)[16]));		/* Get the second half */
+		ReadReal((addr64_t)xxltr + 96, &(((unsigned int *)&xltr)[24]));		/* Get the second half */
 		
-		db_printf("\n%s%08X  %1X  %08X %08X - %04X\n", (xxltr!=cxltr ? " " : "*"), 
+		db_printf("\n%s%08llX  %1X  %08X %08X - %04X\n", (xxltr != cxltr ? " " : "*"), 
 			xxltr,
 			xltr.LTR_cpu, xltr.LTR_timeHi, xltr.LTR_timeLo, 
-			(xltr.LTR_excpt&0x8000 ? 0xFFFF : xltr.LTR_excpt*64));	/* Print the first line */
-		db_printf("              %08X %08X %08X %08X %08X %08X %08X\n",
-			xltr.LTR_cr, xltr.LTR_srr0, xltr.LTR_srr1, xltr.LTR_dar, xltr.LTR_save, xltr.LTR_lr, xltr.LTR_ctr);
-		db_printf("              %08X %08X %08X %08X %08X %08X\n",
-			xltr.LTR_r0, xltr.LTR_r1, xltr.LTR_r2, xltr.LTR_r3, xltr.LTR_r4, xltr.LTR_r5);
+			(xltr.LTR_excpt & 0x8000 ? 0xFFFF : xltr.LTR_excpt * 64));	/* Print the first line */
+			
+		db_printf("              DAR/DSR/CR: %016llX %08X %08X\n", xltr.LTR_dar, xltr.LTR_dsisr, xltr.LTR_cr);
+		
+		db_printf("                SRR0/SRR1 %016llX %016llX\n",  xltr.LTR_srr0, xltr.LTR_srr1);
+		db_printf("                LR/CTR    %016llX %016llX\n",  xltr.LTR_lr, xltr.LTR_ctr);
+
+		db_printf("                R0/R1/R2  %016llX %016llX %016llX\n", xltr.LTR_r0, xltr.LTR_r1, xltr.LTR_r2);
+		db_printf("                R3/R4/R5  %016llX %016llX %016llX\n", xltr.LTR_r3, xltr.LTR_r4, xltr.LTR_r5);
+		db_printf("              R6/sv/rsv   %016llX %016llX %08X\n", xltr.LTR_r6, xltr.LTR_save, xltr.LTR_rsvd0);
 	
 		if((cnt != 16) && (xxltr == xTraceCurr)) break;			/* If whole table dump, exit when we hit start again... */
 
@@ -155,14 +162,69 @@ void db_display_long(db_expr_t addr, int have_addr, db_expr_t count, char * modi
 	int				i;
 
 	for(i=0; i<8; i++) {									/* Print 256 bytes */
-		db_printf("%08X   %08X %08X %08X %08X  %08X %08X %08X %08X\n", addr,	/* Print a line */
+		db_printf("%016llX   %08X %08X %08X %08X  %08X %08X %08X %08X\n", addr,	/* Print a line */
 			((unsigned long *)addr)[0], ((unsigned long *)addr)[1], ((unsigned long *)addr)[2], ((unsigned long *)addr)[3], 
 			((unsigned long *)addr)[4], ((unsigned long *)addr)[5], ((unsigned long *)addr)[6], ((unsigned long *)addr)[7]);
-		addr=(db_expr_t)((unsigned int)addr+0x00000020);	/* Point to next address */
+		addr=(db_expr_t)(addr+0x00000020);					/* Point to next address */
 	}
 	db_next = addr;
 
 
+}
+
+unsigned char xtran[256] = {
+/*  x0   x1   x2   x3   x4   x5   x6   x7   x8   x9   xA   xB   xC   xD   xE   xF   	   */
+	'.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.',  /* 0x */
+	'.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.',  /* 1x */
+	' ', '!', '"', '#', '$', '%', '&',0x27, '(', ')', '*', '+', ',', '-', '.', '/',  /* 2x */
+	'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?',  /* 3x */
+	'@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',  /* 4x */
+	'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[',0x5C, ']', '^', '_',  /* 5x */
+	'`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',  /* 6x */
+	'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~', '.',  /* 7x */
+	'.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.',  /* 8x */
+	'.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.',  /* 9x */
+	'.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.',  /* Ax */
+	'.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.',  /* Bx */
+	'.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.',  /* Cx */
+	'.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.',  /* Dx */
+	'.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.',  /* Ex */
+	'.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.',  /* Fx */
+};
+
+/*
+ *		Print out 256 bytes in characters
+ *
+ *		
+ *		dc [entaddr]
+ */
+void db_display_char(db_expr_t addr, int have_addr, db_expr_t count, char * modif) {
+
+	int				i, j, k;
+	unsigned char xlt[256], *xaddr;
+	
+	xaddr = (unsigned char *)addr;
+	
+
+	for(i = 0; i < 8; i++) {								/* Print 256 bytes */
+		j = 0;
+		for(k = 0; k < 32; k++) {
+			xlt[j] = xtran[*xaddr];
+			xaddr++;
+			j++;
+			if((k & 3) == 3) {
+				xlt[j] = ' ';
+				j++;
+			}
+		}
+		xlt[j] = 0;
+		
+		db_printf("%016llX   %s\n", (addr64_t)(xaddr - 32), xlt);	/* Print a line */
+	}
+
+	db_next = (db_expr_t)xaddr;
+
+
 }
 
 /*
@@ -178,15 +240,13 @@ void db_display_real(db_expr_t addr, int have_addr, db_expr_t count, char * modi
 	unsigned int xbuf[8];
 
 	for(i=0; i<8; i++) {									/* Print 256 bytes */
-		ReadReal((unsigned int)addr, &xbuf[0]);				/* Get the real storage data */
-		db_printf("%08X   %08X %08X %08X %08X  %08X %08X %08X %08X\n", addr,	/* Print a line */
+		ReadReal(addr, &xbuf[0]);							/* Get the real storage data */
+		db_printf("%016llX   %08X %08X %08X %08X  %08X %08X %08X %08X\n", addr,	/* Print a line */
 			xbuf[0], xbuf[1], xbuf[2], xbuf[3], 
 			xbuf[4], xbuf[5], xbuf[6], xbuf[7]);
-		addr=(db_expr_t)((unsigned int)addr+0x00000020);	/* Point to next address */
+		addr = addr + 0x00000020;							/* Point to next address */
 	}
 	db_next = addr;
-
-
 }
 
 unsigned int	dvspace = 0;
@@ -199,30 +259,92 @@ unsigned int	dvspace = 0;
  */
 void db_display_mappings(db_expr_t addr, int have_addr, db_expr_t count, char * modif) {
 
-	int				i;
-	unsigned int	xspace;
+	db_expr_t	xspace;
+	pmap_t			pmap;
+	addr64_t		lnextva;
 
-	mapping		*mp, *mpv;
-	vm_offset_t	pa;
+	mapping		*mp;
+	
+	if (db_expression(&xspace)) {							/* Get the address space requested */
+		if(xspace >= maxAdrSp) {
+			db_printf("requested address space (%llX) larger than max (%X)\n", xspace, maxAdrSp - 1);
+			return;
+		}
+		dvspace = xspace;									/* Get the space or set default */
+	}
 	
-	if (db_expression(&xspace)) dvspace = xspace;			/* Get the space or set default */
+	db_printf("mapping information for %016llX in space %8X:\n", addr, dvspace);
+
+	pmap = pmapTrans[dvspace].pmapVAddr;					/* Find the pmap address */
+	if(!pmap) {												/* The pmap is not in use */
+		db_printf("The space %X is not assigned to a pmap\n", dvspace);	/* Say we are wrong */
+		return;
+	}
+
+	mp = hw_find_map(pmap, (addr64_t)addr, &lnextva);		/* Try to find the mapping for this address */
+	if((unsigned int)mp == mapRtBadLk) {					/* Did we lock up ok? */
+		db_printf("Timeout locking physical entry for virtual address %016ll8X\n", addr);	
+		return;
+	}
 	
-	db_printf("mapping information for %08X in space %08X:\n", addr, dvspace);
-	mp = hw_lock_phys_vir(dvspace, addr);					/* Lock the physical entry for this mapping */
 	if(!mp) {												/* Did we find one? */
 		db_printf("Not mapped\n");	
 		return;												/* Didn't find any, return FALSE... */
 	}
-	if((unsigned int)mp&1) {								/* Did we timeout? */
-		db_printf("Timeout locking physical entry for virtual address (%08X)\n", addr);	/* Yeah, scream about it! */
-		return;												/* Bad hair day, return FALSE... */
+	
+	mapping_drop_busy(mp);									/* The mapping shouldn't be changing */
+
+	db_dumpmapping(mp);										/* Dump it all out */
+
+	return;													/* Tell them we did it */
+
+
+}
+
+/*
+ *		Print out hash table data
+ *
+ *		
+ *		dh vaddr [space] (defaults to last entered) 
+ */
+void db_display_hash(db_expr_t addr, int have_addr, db_expr_t count, char * modif) {
+
+	db_expr_t		xspace;
+	unsigned int	seg, vsid, ptegindex, htsize;
+	pmap_t			pmap;
+	addr64_t		lnextva, llva, vpn, esid;
+	uint64_t		hash;
+	int 			s4bit;
+
+	llva = (addr64_t)((unsigned int)addr);					/* Make sure we are 64-bit now */
+	
+	s4bit = !((per_proc_info[0].pf.Available & pf64Bit) == 0);	/* Are we a big guy? */
+	if (db_expression(&xspace)) {							/* Get the address space requested */
+		if(xspace >= maxAdrSp) {
+			db_printf("requested address space (%llX) larger than max (%X)\n", xspace, maxAdrSp - 1);
+			return;
+		}
+		dvspace = xspace;									/* Get the space or set default */
 	}
-	printf("dumpaddr: space=%08X; vaddr=%08X\n", dvspace, addr);	/* Say what address were dumping */
-	mpv = hw_cpv(mp);										/* Get virtual address of mapping */
-	dumpmapping(mpv);
-	if(mpv->physent) {
-		hw_unlock_bit((unsigned int *)&mpv->physent->phys_link, PHYS_LOCK);	/* Unlock physical entry associated with mapping */
+	
+	pmap = pmapTrans[dvspace].pmapVAddr;					/* Find the pmap address */
+	if(!pmap) {												/* The pmap is not in use */
+		db_printf("The space %X is not assigned to a pmap\n", dvspace);	/* Say we are wrong */
+		return;
 	}
+
+	hash = (uint64_t)pmap->space | ((uint64_t)pmap->space << maxAdrSpb) | ((uint64_t)pmap->space << (2 * maxAdrSpb));	/* Get hash value */
+	hash = hash & 0x0000001FFFFFFFFF;						/* Make sure we stay within supported ranges */
+	
+	esid = ((llva >> 14) & -maxAdrSp) ^ hash;				/* Get ESID */
+	llva = ((llva >> 12) & 0xFFFF) ^ esid;					/* Get index into hash table */
+
+	if(s4bit) htsize = hash_table_size >> 7;				/* Get number of entries in hash table for 64-bit */
+	else htsize = hash_table_size >> 6;						/* get number of entries in hash table for 32-bit */
+	
+	ptegindex = llva & (htsize - 1);						/* Get the index to the pteg and pca */
+	db_dumppca(ptegindex);									/* dump the info */
+	
 	return;													/* Tell them we did it */
 
 
@@ -236,133 +358,193 @@ void db_display_mappings(db_expr_t addr, int have_addr, db_expr_t count, char *
 void db_display_pmap(db_expr_t addr, int have_addr, db_expr_t count, char * modif) {
 
 	pmap_t			pmap;
+	int i;
+	unsigned int v0, v1, st0, st1;
 	
-	pmap = kernel_pmap;										/* Start at the beginning */
+	pmap = (pmap_t)addr;
+	if(!have_addr) pmap = kernel_pmap;						/* Start at the beginning */
 	
-	db_printf("PMAP     (real)    Next     Prev     VRMask   Space    Bmaps    Flags    Ref      spaceNum Resident Wired\n"); 
-//	           xxxxxxxx rrrrrrrr  xxxxxxxx pppppppp vvvvvvvv ssssssss bbbbbbbb cccccccc vvvvvvvv nnnnnnnn rrrrrrrr wwwwwwwww
+	db_printf("PMAP     (real)            Next     Prev     Space    Flags    Ref      spaceNum Resident Wired\n"); 
+//	           xxxxxxxx rrrrrrrrrrrrrrrr  xxxxxxxx pppppppp ssssssss cccccccc vvvvvvvv nnnnnnnn rrrrrrrr wwwwwwwww
 	while(1) {												/* Do them all */
-		db_printf("%08X %08X  %08X %08X %08X %08X %08X %08X %08X %08X %08X %08X\n",
-			pmap, (unsigned int)pmap ^ pmap->pmapvr,
-			pmap->pmap_link.next,  pmap->pmap_link.prev, pmap->pmapvr,
-			pmap->space, pmap->bmaps, pmap->vflags, pmap->ref_count, pmap->spaceNum,
+		db_printf("%08X %016llX  %08X %08X %08X %08X %08X %08X %08X %08X\n",
+			pmap, (addr64_t)pmap ^ pmap->pmapvr,
+			pmap->pmap_link.next,  pmap->pmap_link.prev,
+			pmap->space, pmap->pmapFlags, pmap->ref_count, pmap->spaceNum,
 			pmap->stats.resident_count,
 			pmap->stats.wired_count);
 
+		db_printf("lists = %d, rand = %08X, visits = %016llX, searches = %08X\n",
+			pmap->pmapCurLists, pmap->pmapRandNum,
+			pmap->pmapSearchVisits, pmap->pmapSearchCnt); 
 
-//	               xxxxxxxx rrrrrrrr  xxxxxxxx pppppppp vvvvvvvv ssssssss bbbbbbbb cccccccc vvvvvvvv nnnnnnnn rrrrrrrr wwwwwwwww
-		db_printf("             SRs:  %08X %08X %08X %08X %08X %08X %08X %08X\n", pmap->pmapSegs[0], pmap->pmapSegs[1], pmap->pmapSegs[2], pmap->pmapSegs[3],
-			pmap->pmapSegs[4], pmap->pmapSegs[5], pmap->pmapSegs[6], pmap->pmapSegs[7]);
-		db_printf("                   %08X %08X %08X %08X %08X %08X %08X %08X\n", pmap->pmapSegs[8], pmap->pmapSegs[9], pmap->pmapSegs[10], pmap->pmapSegs[11],
-			pmap->pmapSegs[12], pmap->pmapSegs[13], pmap->pmapSegs[14], pmap->pmapSegs[15]);
-	
-		db_printf("          spmaps:  %08X %08X %08X %08X %08X %08X %08X %08X\n", pmap->pmapPmaps[0], pmap->pmapPmaps[1], pmap->pmapPmaps[2], pmap->pmapPmaps[3],
-			pmap->pmapPmaps[4], pmap->pmapPmaps[5], pmap->pmapPmaps[6], pmap->pmapPmaps[7]);
-		db_printf("                   %08X %08X %08X %08X %08X %08X %08X %08X\n", pmap->pmapPmaps[8], pmap->pmapPmaps[9], pmap->pmapPmaps[10], pmap->pmapPmaps[11],
-			pmap->pmapPmaps[12], pmap->pmapPmaps[13], pmap->pmapPmaps[14], pmap->pmapPmaps[15]);
+		db_printf("cctl = %08X, SCSubTag = %016llX\n",
+			pmap->pmapCCtl, pmap->pmapSCSubTag); 
+		
+		for(i = 0; i < 16; i +=2) {
+			v0 = (pmap->pmapCCtl >> (31 - i) & 1);			/* Get high order bit */
+			v1 = (pmap->pmapCCtl >> (30 - i) & 1);			/* Get high order bit */
+			st0 = (pmap->pmapSCSubTag >> (60 - (4 * i))) & 0xF;	/* Get the sub-tag */
+			st1 = (pmap->pmapSCSubTag >> (56 - (4 * i))) & 0xF;	/* Get the sub-tag */
+			
+			db_printf("         %01X %01X %016llX/%016llX  %01X %01X %016llX/%016llX\n", 
+				v0, st0, pmap->pmapSegCache[i].sgcESID, pmap->pmapSegCache[i].sgcVSID,
+				v1, st1, pmap->pmapSegCache[i+1].sgcESID, pmap->pmapSegCache[i+1].sgcVSID);
+		}
 
-		pmap = (pmap_t)pmap->pmap_link.next;				/* Skip to the next */
 		db_printf("\n");
+		if(have_addr) break;								/* Do only one if address supplied */
+		pmap = (pmap_t)pmap->pmap_link.next;				/* Skip to the next */
 		if(pmap == kernel_pmap) break;						/* We've wrapped, we're done */
 	}
 	return;
 }
 
-/* 
- *	print information about the passed in pmap block 
- */
 
-void db_dumppmap(pmap_t pmap) {
-
-	db_printf("Dump of pmap block: %08X\n", pmap);
-	db_printf("         pmap_link: %08X %08X\n", pmap->pmap_link.next,  pmap->pmap_link.prev);
-	db_printf("            pmapvr: %08X\n", pmap->pmapvr);
-	db_printf("             space: %08X\n", pmap->space);
-	db_printf("             bmaps: %08X\n", pmap->bmaps);
-	db_printf("         ref_count: %08X\n", pmap->ref_count);
-	db_printf("          spaceNum: %08X\n", pmap->spaceNum);
-	db_printf("    resident_count: %08X\n", pmap->stats.resident_count);
-	db_printf("       wired_count: %08X\n", pmap->stats.wired_count);
-	db_printf("\n");
+/*
+ *		Checks the pmap skip lists
+ *
+ *		
+ *		cp pmap
+ */
+void db_check_pmaps(db_expr_t addr, int have_addr, db_expr_t count, char * modif) {
 
+	int				i;
+	unsigned int ret;
+	uint64_t dumpa[32];
+	pmap_t pmap;
+	
+	pmap = (pmap_t)addr;
+	if(!have_addr) pmap = kernel_pmap;						/* If no map supplied, start with kernel */
+	
+	while(1) {												/* Do them all */
+		ret = mapSkipListVerifyC(pmap, &dumpa);							/* Check out the map */
+		if(!ret) db_printf("Skiplists verified ok, pmap = %08X\n", pmap);
+		else { 
+			db_printf("Verification failure at %08X, pmap = %08X\n", ret, pmap);
+			for(i = 0; i < 32; i += 4) {
+				db_printf("R%02d  %016llX  %016llX  %016llX  %016llX\n", i,
+					dumpa[i], dumpa[i + 1], dumpa[i + 2], dumpa[i + 3]);
+			}
+		}
+		if(have_addr) break;								/* Do only one if address supplied */
+		pmap = (pmap_t)pmap->pmap_link.next;				/* Skip to the next */
+		if(pmap == kernel_pmap) break;						/* We've wrapped, we're done */
+	}
+	
 	return;
 
 }
 
+
 /*
- *		Prints out a mapping control block
+ *		Displays iokit junk
  *
+  *		dp
  */
- 
-void db_dumpmapping(struct mapping *mp) { 					/* Dump out a mapping */
 
-	db_printf("Dump of mapping block: %08X\n", mp);			/* Header */
-	db_printf("                 next: %08X\n", mp->next);                 
-	db_printf("             hashnext: %08X\n", mp->hashnext);                 
-	db_printf("              PTEhash: %08X\n", mp->PTEhash);                 
-	db_printf("               PTEent: %08X\n", mp->PTEent);                 
-	db_printf("              physent: %08X\n", mp->physent);                 
-	db_printf("                 PTEv: %08X\n", mp->PTEv);                 
-	db_printf("                 PTEr: %08X\n", mp->PTEr);                 
-	db_printf("                 pmap: %08X\n", mp->pmap);
-	
-	if(mp->physent) {									/* Print physent if it exists */
-		db_printf("Associated physical entry: %08X %08X\n", mp->physent->phys_link, mp->physent->pte1);
-	}
-	else {
-		db_printf("Associated physical entry: none\n");
-	}
-	
-	db_dumppca(mp);										/* Dump out the PCA information */
-	
+void db_piokjunk(void);
+
+void db_display_iokit(db_expr_t addr, int have_addr, db_expr_t count, char * modif) {
+
+	db_piokjunk();
+
 	return;
 }
 
 /*
- *		Prints out a PTEG control area
+ *		Prints out a mapping control block
  *
  */
  
-void db_dumppca(struct mapping *mp) { 						/* PCA */
-
-	PCA				*pca;
-	unsigned int	*pteg, sdr;
-	
-	pca = (PCA *)((unsigned int)mp->PTEhash&-64);		/* Back up to the start of the PCA */
-	__asm__ volatile("mfsdr1 %0" : "=r" (sdr));
-	db_printf("        SDR1: %08X\n", sdr);
-	pteg=(unsigned int *)((unsigned int)pca-(((sdr&0x0000FFFF)+1)<<16));
-	db_printf(" Dump of PCA: %08X\n", pca);		/* Header */
-	db_printf("     PCAlock: %08X\n", pca->PCAlock);                 
-	db_printf("     PCAallo: %08X\n", pca->flgs.PCAallo);                 
-	db_printf("     PCAhash: %08X %08X %08X %08X\n", pca->PCAhash[0], pca->PCAhash[1], pca->PCAhash[2], pca->PCAhash[3]);                 
-	db_printf("              %08X %08X %08X %08X\n", pca->PCAhash[4], pca->PCAhash[5], pca->PCAhash[6], pca->PCAhash[7]);                 
-	db_printf("Dump of PTEG: %08X\n", pteg);		/* Header */
-	db_printf("              %08X %08X %08X %08X\n", pteg[0], pteg[1], pteg[2], pteg[3]);                 
-	db_printf("              %08X %08X %08X %08X\n", pteg[4], pteg[5], pteg[6], pteg[7]);                 
-	db_printf("              %08X %08X %08X %08X\n", pteg[8], pteg[9], pteg[10], pteg[11]);                 
-	db_printf("              %08X %08X %08X %08X\n", pteg[12], pteg[13], pteg[14], pteg[15]);                 
+void db_dumpmapping(struct mapping *mp) { 					/* Dump out a mapping */
+
+	pmap_t pmap;
+	int i;
+
+	db_printf("Dump of mapping block: %08X,  pmap: %08X (%016llX)\n", mp, pmapTrans[mp->mpSpace].pmapVAddr, 
+		pmapTrans[mp->mpSpace].pmapPAddr);			/* Header */
+	db_printf("              mpFlags: %08X\n", mp->mpFlags);                 
+	db_printf("              mpSpace: %04X\n", mp->mpSpace);                 
+	db_printf("              mpBSize: %04X\n", mp->mpBSize);                 
+	db_printf("                mpPte: %08X\n", mp->mpPte);                 
+	db_printf("              mpPAddr: %08X\n", mp->mpPAddr);                 
+	db_printf("              mpVAddr: %016llX\n", mp->mpVAddr);                 
+	db_printf("              mpAlias: %016llX\n", mp->mpAlias);                 
+	db_printf("             mpList00: %016llX\n", mp->mpList0);                 
+	
+	for(i = 1; i < (mp->mpFlags & mpLists); i++) {			/* Dump out secondary physical skip lists */
+		db_printf("             mpList%02d: %016llX\n", i, mp->mpList[i - 1]);     
+	}
+	            
 	return;
 }
 
 /*
- *		Dumps starting with a physical entry
+ *		Prints out a PTEG and PCA
+ *
  */
  
-void db_dumpphys(struct phys_entry *pp) { 						/* Dump from physent */
+void db_dumppca(unsigned int ptegindex) { 	
 
-	mapping			*mp;
-	PCA				*pca;
-	unsigned int	*pteg;
+	addr64_t pteg, pca, llva;	
+	unsigned int xpteg[32], xpca[8], space, hash, pva, seg, api, va;
+	int i, s4bit;
+	unsigned long long llslot, llseg, llhash;
 
-	db_printf("Dump from physical entry %08X: %08X %08X\n", pp, pp->phys_link, pp->pte1);
-	mp = hw_cpv(pp->phys_link);
-	while(mp) {
-		db_dumpmapping(mp);
-		db_dumppca(mp);
-		mp = hw_cpv(mp->next);
-	}
+	s4bit = !((per_proc_info[0].pf.Available & pf64Bit) == 0);	/* Are we a big guy? */
+
+	pteg = hash_table_base + (ptegindex << 6);				/* Point to the PTEG */
+	if(s4bit) pteg = hash_table_base + (ptegindex << 7);	/* Point to the PTEG */
+	pca  = hash_table_base - ((ptegindex + 1) * 4);			/* Point to the PCA */
+	db_printf("PTEG = %016llX, PCA = %016llX (index = %08X)\n", pteg, pca, ptegindex);
 	
+	ReadReal(pteg, &xpteg[0]);								/* Get first half of the pteg */
+	ReadReal(pteg + 0x20, &xpteg[8]);						/* Get second half of the pteg */
+	ReadReal(pca, &xpca[0]);								/* Get pca */
+
+	db_printf("PCA: free = %02X, steal = %02X, auto = %02X, misc = %02X\n", 
+		((xpca[0] >> 24) & 255), ((xpca[0] >> 16) & 255), ((xpca[0] >> 8) & 255), xpca[0] & 255);
+		
+	if(!s4bit) {											/* Little guy? */
+
+		for(i = 0; i < 16; i += 2) {						/* Step through pteg */
+			db_printf("%08X %08X - ", xpteg[i], xpteg[i + 1]);	/* Dump the pteg slot */
+			
+			if(xpteg[i] & 0x80000000) db_printf("  valid - ");	/* Is it valid? */
+			else db_printf("invalid - ");					/* Nope, invalid */
+		
+			space = (xpteg[i] >> 7) & (maxAdrSp - 1);		/* Extract the space */
+			hash = space | (space << maxAdrSpb) | (space << (2 * maxAdrSpb));	/* Get the hash */
+			pva =  ptegindex ^ hash;						/* Get part of the vaddr */
+			seg = (xpteg[i] >> 7) ^ hash;					/* Get the segment number */
+			api = (xpteg[i] & 0x3F);						/* Get the API */
+			va = ((seg << (28 - maxAdrSpb)) & 0xF0000000) | (api << 22) | ((pva << 12) & 0x003FF000);	/* Get the vaddr */
+			db_printf("va = %08X\n", va);
+		}
+	}
+	else {
+		ReadReal(pteg + 0x40, &xpteg[16]);					/* Get third half of the pteg */
+		ReadReal(pteg + 0x60, &xpteg[24]);					/* Get fourth half of the pteg */
+
+		for(i = 0; i < 32; i += 4) {						/* Step through pteg */
+			db_printf("%08X%08X %08X%08X - ", xpteg[i], xpteg[i + 1], xpteg[i + 2], xpteg[i + 3]);	/* Dump the pteg slot */
+			
+			if(xpteg[i + 1] & 1) db_printf("  valid - ");	/* Is it valid? */
+			else db_printf("invalid - ");					/* Nope, invalid */
+
+			llslot = ((long long)xpteg[i] << 32) | (long long)xpteg[i + 1];	/* Make a long long version of this */ 
+			space = (llslot >> 12) & (maxAdrSp - 1);		/* Extract the space */
+			llhash = (unsigned long long)space | ((unsigned long long)space << maxAdrSpb) | ((unsigned long long)space << (2 * maxAdrSpb));	/* Get the hash */
+			llhash = llhash & 0x0000001FFFFFFFFF;			/* Make sure we stay within supported ranges */
+			pva =  (unsigned long long)ptegindex ^ llhash;	/* Get part of the vaddr */
+			llseg = (llslot >> 12) ^ llhash;				/* Get the segment number */
+			api = (llslot >> 7) & 0x1F;						/* Get the API */
+			llva = ((llseg << (28 - maxAdrSpb)) & 0xFFFFFFFFF0000000ULL) | (api << 23) | ((pva << 12) & 0x007FF000);	/* Get the vaddr */
+			db_printf("va = %016llX\n", llva);
+		}
+	}
+
 	return;
 }
 
@@ -376,16 +558,30 @@ void db_dumpphys(struct phys_entry *pp) { 						/* Dump from physent */
  */
 void db_display_virtual(db_expr_t addr, int have_addr, db_expr_t count, char * modif) {
 
-	int				i, size, lines, rlines;
+	int			i, size, lines, rlines;
 	unsigned int 	xbuf[8];
-	unsigned int	xspace;
+	db_expr_t	xspace;
+	pmap_t		pmap;
 
 	mapping		*mp, *mpv;
-	vm_offset_t	pa;
+	addr64_t	pa;
+	ppnum_t		pnum;
+
+	if (db_expression(&xspace)) {							/* Parse the space ID */
+		if(xspace >= (1 << maxAdrSpb)) {					/* Check if they gave us a sane space number */
+			db_printf("Invalid space ID: %llX - max is %X\n", xspace, (1 << maxAdrSpb) - 1);
+			return;
+		}
+		dvspace = xspace;									/* Get the space or set default */
+	}
 	
-	if (db_expression(&xspace)) dvspace = xspace;			/* Get the space or set default */
+	pmap = (pmap_t)pmapTrans[dvspace].pmapVAddr;			/* Find the pmap address */
+	if((unsigned int)pmap == 0) {							/* Is there actually a pmap here? */
+		db_printf("Address space not found: %X\n", dvspace);	/* Complain */
+		return;
+	}
 	
-	addr&=-32;
+	addr &= -32;
 	
 	size = 4096 - (addr & 0x00000FFF);						/* Bytes left on page */
 	lines = size / 32;										/* Number of lines in first or only part */
@@ -393,63 +589,47 @@ void db_display_virtual(db_expr_t addr, int have_addr, db_expr_t count, char * m
 	rlines = 8 - lines;
 	if(rlines < 0) lines = 0;
 	
-	db_printf("Dumping %08X (space=%08X); ", addr, dvspace);
-	mp = hw_lock_phys_vir(dvspace, addr);					/* Lock the physical entry for this mapping */
-	if(!mp) {												/* Did we find one? */
+	db_printf("Dumping %016llX (pmap = %08X, space = %X); ", addr, pmap, dvspace);
+
+	pnum = pmap_find_phys(pmap, (addr64_t)addr);			/* Phynd the Physical */
+	if(!pnum) {												/* Did we find one? */
 		db_printf("Not mapped\n");	
 		return;												/* Didn't find any, return FALSE... */
 	}
-	if((unsigned int)mp&1) {								/* Did we timeout? */
-		db_printf("Timeout locking physical entry for virtual address (%08X)\n", addr);	/* Yeah, scream about it! */
-		return;												/* Bad hair day, return FALSE... */
-	}
-	mpv = hw_cpv(mp);										/* Get virtual address of mapping */
-	if(!mpv->physent) {										/* Was there a physical entry? */
-		pa = (vm_offset_t)((mpv->PTEr & -PAGE_SIZE) | ((unsigned int)addr & (PAGE_SIZE-1)));	/* Get physical address from physent */
-	}
-	else {
-		pa = (vm_offset_t)((mpv->physent->pte1 & -PAGE_SIZE) | ((unsigned int)addr & (PAGE_SIZE-1)));	/* Get physical address from physent */
-		hw_unlock_bit((unsigned int *)&mpv->physent->phys_link, PHYS_LOCK);		/* Unlock the physical entry */
-	}
-	db_printf("phys=%08X\n", pa);
+
+	pa = (addr64_t)(pnum << 12) | (addr64_t)(addr & 0xFFF);	/* Get the physical address */
+	db_printf("phys = %016llX\n", pa);
+
 	for(i=0; i<lines; i++) {								/* Print n bytes */
-		ReadReal((unsigned int)pa, &xbuf[0]);				/* Get the real storage data */
-		db_printf("%08X   %08X %08X %08X %08X  %08X %08X %08X %08X\n", addr,	/* Print a line */
+		ReadReal(pa, &xbuf[0]);								/* Get the real storage data */
+		db_printf("%016llX   %08X %08X %08X %08X  %08X %08X %08X %08X\n", addr,	/* Print a line */
 			xbuf[0], xbuf[1], xbuf[2], xbuf[3], 
 			xbuf[4], xbuf[5], xbuf[6], xbuf[7]);
-		addr=(db_expr_t)((unsigned int)addr+0x00000020);	/* Point to next address */
-		pa=(unsigned int)pa+0x00000020;						/* Point to next address */
+		addr = (db_expr_t)((unsigned int)addr + 0x00000020);	/* Point to next address */
+		pa = pa + 0x00000020;								/* Point to next address */
 	}
 	db_next = addr;
 	
 	if(!rlines) return;
 	
-	db_printf("Dumping %08X (space=%08X); ", addr, dvspace);
-	mp = hw_lock_phys_vir(dvspace, addr);					/* Lock the physical entry for this mapping */
-	if(!mp) {												/* Did we find one? */
+	db_printf("Dumping %016llX (pmap = %08X, space = %X); ", addr, pmap, dvspace);
+
+	pnum = pmap_find_phys(pmap, (addr64_t)((unsigned int)addr));	/* Phynd the Physical */
+	if(!pnum) {												/* Did we find one? */
 		db_printf("Not mapped\n");	
 		return;												/* Didn't find any, return FALSE... */
 	}
-	if((unsigned int)mp&1) {								/* Did we timeout? */
-		db_printf("Timeout locking physical entry for virtual address (%08X)\n", addr);	/* Yeah, scream about it! */
-		return;												/* Bad hair day, return FALSE... */
-	}
-	mpv = hw_cpv(mp);										/* Get virtual address of mapping */
-	if(!mpv->physent) {										/* Was there a physical entry? */
-		pa = (vm_offset_t)((mpv->PTEr & -PAGE_SIZE) | ((unsigned int)addr & (PAGE_SIZE-1)));	/* Get physical address from physent */
-	}
-	else {
-		pa = (vm_offset_t)((mpv->physent->pte1 & -PAGE_SIZE) | ((unsigned int)addr & (PAGE_SIZE-1)));	/* Get physical address from physent */
-		hw_unlock_bit((unsigned int *)&mp->physent->phys_link, PHYS_LOCK);	/* Unlock the physical entry */
-	}
-	db_printf("phys=%08X\n", pa);
+
+	pa = (addr64_t)(pnum << 12) | (addr64_t)((unsigned int)addr & 0xFFF);	/* Get the physical address */
+	db_printf("phys = %016llX\n", pa);
+
 	for(i=0; i<rlines; i++) {								/* Print n bytes */
-		ReadReal((unsigned int)pa, &xbuf[0]);				/* Get the real storage data */
-		db_printf("%08X   %08X %08X %08X %08X  %08X %08X %08X %08X\n", addr,	/* Print a line */
+		ReadReal(pa, &xbuf[0]);								/* Get the real storage data */
+		db_printf("%016llX   %08X %08X %08X %08X  %08X %08X %08X %08X\n", addr,	/* Print a line */
 			xbuf[0], xbuf[1], xbuf[2], xbuf[3], 
 			xbuf[4], xbuf[5], xbuf[6], xbuf[7]);
-		addr=(db_expr_t)((unsigned int)addr+0x00000020);	/* Point to next address */
-		pa=(unsigned int)pa+0x00000020;						/* Point to next address */
+		addr = (db_expr_t)(addr + 0x00000020);				/* Point to next address */
+		pa = pa + 0x00000020;								/* Point to next address */
 	}
 	db_next = addr;
 
@@ -494,8 +674,8 @@ void db_display_save(db_expr_t addr, int have_addr, db_expr_t count, char * modi
 			
 			while(save) {							/* Do them all */
 				totsaves++;							/* Count savearea */
-				db_printf("         Norm %08X: %08X %08X - tot = %d\n", save, save->save_srr0, save->save_srr1, totsaves);
-				save = save->save_hdr.save_prev;	/* Next one */
+				db_printf("         Norm %08X: %016llX %016llX - tot = %d\n", save, save->save_srr0, save->save_srr1, totsaves);
+				save = (savearea *)save->save_hdr.save_prev;	/* Next one */
 				if(chainsize++ > chainmax) {		/* See if we might be in a loop */
 					db_printf("         Chain terminated by count (%d) before %08X\n", chainmax, save);
 					break;
@@ -507,7 +687,7 @@ void db_display_save(db_expr_t addr, int have_addr, db_expr_t count, char * modi
 			while(save) {							/* Do them all */
 				totsaves++;							/* Count savearea */
 				db_printf("         FPU  %08X: %08X - tot = %d\n", save, save->save_hdr.save_level, totsaves);
-				save = save->save_hdr.save_prev;	/* Next one */
+				save = (savearea *)save->save_hdr.save_prev;	/* Next one */
 				if(chainsize++ > chainmax) {		/* See if we might be in a loop */
 					db_printf("         Chain terminated by count (%d) before %08X\n", chainmax, save);
 					break;
@@ -519,7 +699,7 @@ void db_display_save(db_expr_t addr, int have_addr, db_expr_t count, char * modi
 			while(save) {							/* Do them all */
 				totsaves++;							/* Count savearea */
 				db_printf("         Vec  %08X: %08X - tot = %d\n", save, save->save_hdr.save_level, totsaves);
-				save = save->save_hdr.save_prev;	/* Next one */
+				save = (savearea *)save->save_hdr.save_prev;	/* Next one */
 				if(chainsize++ > chainmax) {		/* See if we might be in a loop */
 					db_printf("         Chain terminated by count (%d) before %08X\n", chainmax, save);
 					break;
@@ -528,7 +708,7 @@ void db_display_save(db_expr_t addr, int have_addr, db_expr_t count, char * modi
 			
 			if(CTable = act->mact.vmmControl) {		/* Are there virtual machines? */
 				
-				for(vmid = 0; vmid < kVmmMaxContextsPerThread; vmid++) {
+				for(vmid = 0; vmid < kVmmMaxContexts; vmid++) {
 					
 					if(!(CTable->vmmc[vmid].vmmFlags & vmmInUse)) continue;	/* Skip if vm is not in use */
 					
@@ -544,7 +724,7 @@ void db_display_save(db_expr_t addr, int have_addr, db_expr_t count, char * modi
 					while(save) {						/* Do them all */
 						totsaves++;						/* Count savearea */
 						db_printf("         FPU  %08X: %08X - tot = %d\n", save, save->save_hdr.save_level, totsaves);
-						save = save->save_hdr.save_prev;	/* Next one */
+						save = (savearea *)save->save_hdr.save_prev;	/* Next one */
 						if(chainsize++ > chainmax) {	/* See if we might be in a loop */
 							db_printf("         Chain terminated by count (%d) before %08X\n", chainmax, save);
 							break;
@@ -556,7 +736,7 @@ void db_display_save(db_expr_t addr, int have_addr, db_expr_t count, char * modi
 					while(save) {						/* Do them all */
 						totsaves++;						/* Count savearea */
 						db_printf("         Vec  %08X: %08X - tot = %d\n", save, save->save_hdr.save_level, totsaves);
-						save = save->save_hdr.save_prev;	/* Next one */
+						save = (savearea *)save->save_hdr.save_prev;	/* Next one */
 						if(chainsize++ > chainmax) {	/* See if we might be in a loop */
 							db_printf("         Chain terminated by count (%d) before %08X\n", chainmax, save);
 							break;
@@ -601,6 +781,8 @@ void db_display_xregs(db_expr_t addr, int have_addr, db_expr_t count, char * mod
 	db_printf("THRM2:  %08X\n", dbspecrs[45]);
 	db_printf("THRM3:  %08X\n", dbspecrs[46]);
 	db_printf("ICTC:   %08X\n", dbspecrs[47]);
+	db_printf("L2CR2:  %08X\n", dbspecrs[48]);
+	db_printf("DABR:   %08X\n", dbspecrs[49]);
 	db_printf("\n");
 
 	db_printf("DBAT: %08X %08X %08X %08X\n", dbspecrs[2], dbspecrs[3], dbspecrs[4], dbspecrs[5]);
@@ -641,6 +823,192 @@ void db_display_xregs(db_expr_t addr, int have_addr, db_expr_t count, char * mod
 
 }
 
+/*
+ *		Check check mappings and hash table for consistency
+ *
+  *		cm
+ */
+void db_check_mappings(db_expr_t addr, int have_addr, db_expr_t count, char * modif) {
+
+	addr64_t  pteg, pca, llva, lnextva;	
+	unsigned int xpteg[32], xpca[8], space, hash, pva, seg, api, va, free, free2, xauto, PTEGcnt, wimgkk, wimgxx, slotoff;
+	int i, j, fnderr, slot, slot2, k, s4bit;
+	pmap_t pmap;
+	mapping	 *mp;
+	ppnum_t ppn, pa, aoff;
+	unsigned long long llslot, llseg, llhash;
+	
+	s4bit = 0;												/* Assume dinky? */
+	if(per_proc_info[0].pf.Available & pf64Bit) s4bit = 1;	/* Are we a big guy? */
+	
+	PTEGcnt = hash_table_size / 64;							/* Get the number of PTEGS */
+	if(s4bit) PTEGcnt = PTEGcnt / 2;						/* PTEGs are twice as big */	
+
+	pteg = hash_table_base;									/* Start of hash table */
+	pca = hash_table_base - 4;								/* Start of PCA */
+	
+	for(i = 0; i < PTEGcnt; i++) {							/* Step through them all */
+
+		fnderr = 0;
+	
+		ReadReal(pteg, &xpteg[0]);							/* Get first half of the pteg */
+		ReadReal(pteg + 0x20, &xpteg[8]);					/* Get second half of the pteg */
+		if(s4bit) {											/* See if we need the other half */
+			ReadReal(pteg + 0x40, &xpteg[16]);				/* Get third half of the pteg */
+			ReadReal(pteg + 0x60, &xpteg[24]);				/* Get fourth half of the pteg */
+		}
+		ReadReal(pca, &xpca[0]);							/* Get pca */
+	
+		if(xpca[0] & 0x00000001) {							/* Is PCA locked? */
+			db_printf("Unexpected locked PCA\n");			/* Yeah, this may be bad */
+			fnderr = 1;										/* Remember to print the pca/pteg pair later */
+		}
+
+		free = 0x80000000;
+		
+		for(j = 0; j < 7; j++) {							/* Search for duplicates */
+			slot = j * 2;									/* Point to the slot */
+			if(s4bit) slot = slot * 2;						/* Adjust for bigger slots */
+			if(!(xpca[0] & free)) {							/* Check more if slot is allocated */
+				for(k = j + 1; k < 8; k++) {				/* Search remaining slots */
+					slot2 = k * 2;							/* Point to the slot */
+					if(s4bit) slot2 = slot2 * 2;			/* Adjust for bigger slots */
+					if((xpteg[slot] == xpteg[slot2]) 
+					   && (!s4bit || (xpteg[slot + 1] == xpteg[slot2 + 1]))) {		/* Do we have duplicates? */
+						db_printf("Duplicate tags in pteg, slot %d and slot %d\n", j, k);
+						fnderr = 1;
+					}
+				}
+			}
+			free = free >> 1;								/* Move slot over */
+		}
+		
+		free = 0x80000000;
+		xauto = 0x00008000;
+
+		for(j = 0; j < 8; j++) {							/* Step through the slots */
+		
+			slot = j * 2;									/* Point to the slot */
+			if(s4bit) slot = slot * 2;						/* Hagfish? */
+			if(xpca[0] & free) {							/* Check if marked free */
+				if((!s4bit && (xpteg[slot] & 0x80000000))	/* Is a supposedly free slot valid? */
+				   || (s4bit && (xpteg[slot + 1] & 1))) {	
+					db_printf("Free slot still valid - %d\n", j);	
+					fnderr = 1;
+				}	
+			}
+			else {											/* We have an in use slot here */
+								
+				if(!(!s4bit && (xpteg[slot] & 0x80000000))	/* Is a supposedly in use slot valid? */
+				   && !(s4bit && (xpteg[slot + 1] & 1))) {	
+					db_printf("Inuse slot not valid - %d\n", j);	
+					fnderr = 1;
+				}	
+				else {										/* Slot is valid, check mapping */
+					if(!s4bit) {							/* Not Hagfish? */
+						space = (xpteg[slot] >> 7) & (maxAdrSp - 1);	/* Extract the space */
+						hash = space | (space << maxAdrSpb) | (space << (2 * maxAdrSpb));	/* Get the hash */
+						pva =  i ^ hash;					/* Get part of the vaddr */
+						seg = (xpteg[slot] >> 7) ^ hash;	/* Get the segment number */
+						api = (xpteg[slot] & 0x3F);			/* Get the API */
+						va = ((seg << (28 - maxAdrSpb)) & 0xF0000000) | (api << 22) | ((pva << 12) & 0x003FF000);	/* Get the vaddr */
+						llva = (addr64_t)va;				/* Make this a long long */
+						wimgxx = xpteg[slot + 1] & 0x7F;	/* Get the wimg and pp */
+						ppn = xpteg[slot + 1] >> 12;		/* Get physical page number */
+						slotoff = (i * 64) + (j * 8) | 1;	/* Get offset to slot and valid bit */
+					}
+					else {									/* Yes, Hagfish */
+						llslot = ((long long)xpteg[slot] << 32) | (long long)xpteg[slot + 1];	/* Make a long long version of this */ 
+						space = (llslot >> 12) & (maxAdrSp - 1);	/* Extract the space */
+						llhash = (unsigned long long)space | ((unsigned long long)space << maxAdrSpb) | ((unsigned long long)space << (2 * maxAdrSpb));	/* Get the hash */
+						llhash = llhash & 0x0000001FFFFFFFFF;	/* Make sure we stay within supported ranges */
+						pva =  i ^ llhash;					/* Get part of the vaddr */
+						llseg = ((llslot >> 12) ^ llhash);	/* Get the segment number */
+						api = (llslot >> 7) & 0x1F;			/* Get the API */
+						llva = ((llseg << (28 - maxAdrSpb)) & 0xFFFFFFFFF0000000ULL) | (api << 23) | ((pva << 12) & 0x007FF000);	/* Get the vaddr */
+						wimgxx = xpteg[slot + 3] & 0x7F;	/* Get the wimg and pp */
+						ppn =  (xpteg[slot + 2] << 20) | (xpteg[slot + 3] >> 12);	/* Get physical page number */
+						slotoff = (i * 128) + (j * 16) | 1;		/* Get offset to slot and valid bit */
+					}
+					
+					pmap = pmapTrans[space].pmapVAddr;	/* Find the pmap address */
+					if(!pmap) {								/* The pmap is not in use */
+						db_printf("The space %08X is not assigned to a pmap, slot = %d\n", space, slot);	/* Say we are wrong */
+						fnderr = 1;
+						goto dcmout;
+					}
+				
+					mp = hw_find_map(pmap, llva, &lnextva);		/* Try to find the mapping for this address */
+//					db_printf("%08X - %017llX\n", mp, llva);
+					if((unsigned int)mp == mapRtBadLk) {	/* Did we lock up ok? */
+						db_printf("Timeout locking mapping for for virtual address %016ll8X, slot = %d\n", llva, j);	
+						return;
+					}
+					
+					if(!mp) {								/* Did we find one? */
+						db_printf("Not mapped, slot = %d, va = %08X\n", j, (unsigned int)llva);	
+						fnderr = 1;
+						goto dcmout;
+					}
+					
+					if((mp->mpFlags & 0xFF000000) > 0x01000000) {	/* Is busy count too high? */
+						db_printf("Busy count too high, slot = %d\n", j);
+						fnderr = 1;
+					}
+					
+					if(mp->mpFlags & mpBlock) {				/* Is this a block map? */
+						if(!(xpca[0] & xauto)) {				/* Is it marked as such? */
+							db_printf("mapping marked as block, PCA is not, slot = %d\n", j);
+							fnderr = 1;
+						}
+					}
+					else {									/* Is a block */
+						if(xpca[0] & xauto) {				/* Is it marked as such? */
+							db_printf("mapping not marked as block, PCA is, slot = %d\n", j);
+							fnderr = 1;
+						}
+						if(mp->mpPte != slotoff) {			/* See if mapping PTEG offset is us */
+							db_printf("mapping does not point to PTE, slot = %d\n", j);
+							fnderr = 1;
+						}
+					}
+				
+					wimgkk = (unsigned int)mp->mpVAddr;		/* Get last half of vaddr where keys, etc are */
+					wimgkk = (wimgkk ^ wimgxx) & 0x7F;		/* XOR to find differences from PTE */
+					if(wimgkk) {							/* See if key in PTE is what we want */
+						db_printf("key or WIMG does not match, slot = %d\n", j);
+						fnderr = 1;
+					}
+					
+					aoff = (ppnum_t)((llva >> 12) - (mp->mpVAddr >> 12));	/* Get the offset from vaddr */
+					pa = aoff + mp->mpPAddr;				/* Get the physical page number we expect */
+					if(pa != ppn) {							/* Is physical address expected? */
+						db_printf("Physical address does not match, slot = %d\n", j);
+						fnderr = 1;
+					}
+	
+					mapping_drop_busy(mp);					/* We're done with the mapping */
+				}
+				
+			}
+dcmout:
+			free = free >> 1;
+			xauto = xauto >> 1;
+		}
+
+
+		if(fnderr)db_dumppca(i);							/* Print if error */
+
+		pteg = pteg + 64;									/* Go to the next one */
+		if(s4bit) pteg = pteg + 64;							/* Hagfish? */
+		pca = pca - 4;										/* Go to the next one */
+
+
+	}
+
+	return;
+}
+
 /*
  *		Displays all of the kmods in the system.
  *
diff --git a/osfmk/ppc/db_low_trace.h b/osfmk/ppc/db_low_trace.h
index 7b243f6ff..4de489146 100644
--- a/osfmk/ppc/db_low_trace.h
+++ b/osfmk/ppc/db_low_trace.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -56,6 +59,13 @@ void db_display_long(
 	char 		*modif
 );
 
+void db_display_char(
+	db_expr_t	addr,
+	int			have_addr,
+	db_expr_t	count,
+	char 		*modif
+);
+
 void db_display_real(
 	db_expr_t	addr,
 	int			have_addr,
@@ -65,10 +75,14 @@ void db_display_real(
 
 void db_display_virtual(db_expr_t addr, int have_addr, db_expr_t count, char * modif);
 void db_display_mappings(db_expr_t addr, int have_addr, db_expr_t count, char * modif);
+void db_display_hash(db_expr_t addr, int have_addr, db_expr_t count, char * modif);
 void db_display_pmap(db_expr_t addr, int have_addr, db_expr_t count, char * modif);
+void db_display_iokit(db_expr_t addr, int have_addr, db_expr_t count, char * modif);
 void db_display_save(db_expr_t addr, int have_addr, db_expr_t count, char * modif);
 void db_display_xregs(db_expr_t addr, int have_addr, db_expr_t count, char * modif);
 void db_display_kmod(db_expr_t addr, int have_addr, db_expr_t count, char * modif);
 void db_gsnoop(db_expr_t addr, int have_addr, db_expr_t count, char * modif);
+void db_check_mappings(db_expr_t addr, int have_addr, db_expr_t count, char * modif);
+void db_check_pmaps(db_expr_t addr, int have_addr, db_expr_t count, char * modif);
 
 #endif	/* !_DDB_DB_LTR_H_ */
diff --git a/osfmk/ppc/db_machdep.h b/osfmk/ppc/db_machdep.h
index fb95f0608..cde656d26 100644
--- a/osfmk/ppc/db_machdep.h
+++ b/osfmk/ppc/db_machdep.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -65,8 +68,8 @@
 #include <ppc/proc_reg.h>
 #include <ppc/savearea.h>
 
-typedef	vm_offset_t	db_addr_t;	/* address - unsigned */
-typedef	int		db_expr_t;	/* expression - signed */
+typedef	addr64_t db_addr_t;	/* address - unsigned */
+typedef	uint64_t db_expr_t;	/* expression - signed???  try unsigned */
 
 typedef struct savearea db_regs_t;
 db_regs_t	ddb_regs;	/* register state */
@@ -101,7 +104,7 @@ int db_inst_store(unsigned long);
 	db_phys_eq(task1,addr1,task2,addr2)
 #define DB_VALID_KERN_ADDR(addr)				\
 	((addr) >= VM_MIN_KERNEL_ADDRESS && 			\
-	 (addr) < VM_MAX_KERNEL_ADDRESS)
+	 (addr) < vm_last_addr)
 #define DB_VALID_ADDRESS(addr,user)				\
 	((!(user) && DB_VALID_KERN_ADDR(addr)) ||		\
 	 ((user) && (addr) < VM_MAX_ADDRESS))
@@ -127,10 +130,6 @@ extern db_addr_t	db_disasm(
 				db_addr_t	loc,
 				boolean_t	altfmt,
 				task_t		task);
-extern vm_offset_t	db_kvtophys( 
-				space_t space,
-				vm_offset_t va);
-
 extern void		db_read_bytes(
 				vm_offset_t	addr,
 				int		size,
@@ -183,11 +182,6 @@ extern void		kdb_on(
 				int			cpu);
 extern void		cnpollc(
 				boolean_t		on);
-				
-extern void		db_phys_copy(
-				vm_offset_t, 
-				vm_offset_t, 
-				vm_size_t);
 
 extern boolean_t	db_phys_cmp(
 				vm_offset_t, 
diff --git a/osfmk/ppc/db_trace.c b/osfmk/ppc/db_trace.c
index f7129ff9f..2f6931a63 100644
--- a/osfmk/ppc/db_trace.c
+++ b/osfmk/ppc/db_trace.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -58,30 +61,17 @@ extern  char FixedStackStart[], FixedStackEnd[];
 	((((vm_offset_t)(va)) >= (vm_offset_t)&FixedStackStart) &&	\
 	(((vm_offset_t)(va)) < ((vm_offset_t)&FixedStackEnd)))
 
-#if 0
-
-#define	INKERNELSTACK(va, th)					\
-	(th == THR_ACT_NULL ||				\
-	 (((vm_offset_t)(va)) >= th->thread->kernel_stack &&	\
-	  (((vm_offset_t)(va)) < th->thread->kernel_stack +	\
-	                         KERNEL_STACK_SIZE)) ||		\
-         INFIXEDSTACK(va))
-#else
 #define INKERNELSTACK(va, th) 1
 
-#endif
-
-#ifdef __MACHO__
 struct db_ppc_frame {
 	struct db_ppc_frame	*f_frame;
 	int			pad1;
-	db_addr_t		f_retaddr;
+	uint32_t	f_retaddr;
 	int			pad3;
 	int			pad4;
 	int			pad5;
-	db_addr_t		f_arg[DB_NUMARGS_MAX];
+	uint32_t	f_arg[DB_NUMARGS_MAX];
 };
-#endif
 
 #define	TRAP		1
 #define	INTERRUPT	2
@@ -124,45 +114,45 @@ extern int	_setjmp(
  */
 struct db_variable db_regs[] = {
 	/* XXX "pc" is an alias to "srr0"... */
-  { "pc",	(int *)&ddb_regs.save_srr0,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "srr0",	(int *)&ddb_regs.save_srr0,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "srr1",	(int *)&ddb_regs.save_srr1,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r0",	(int *)&ddb_regs.save_r0,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r1",	(int *)&ddb_regs.save_r1,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r2",	(int *)&ddb_regs.save_r2,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r3",	(int *)&ddb_regs.save_r3,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r4",	(int *)&ddb_regs.save_r4,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r5",	(int *)&ddb_regs.save_r5,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r6",	(int *)&ddb_regs.save_r6,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r7",	(int *)&ddb_regs.save_r7,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r8",	(int *)&ddb_regs.save_r8,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r9",	(int *)&ddb_regs.save_r9,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r10",	(int *)&ddb_regs.save_r10,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r11",	(int *)&ddb_regs.save_r11,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r12",	(int *)&ddb_regs.save_r12,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r13",	(int *)&ddb_regs.save_r13,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r14",	(int *)&ddb_regs.save_r14,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r15",	(int *)&ddb_regs.save_r15,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r16",	(int *)&ddb_regs.save_r16,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r17",	(int *)&ddb_regs.save_r17,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r18",	(int *)&ddb_regs.save_r18,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r19",	(int *)&ddb_regs.save_r19,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r20",	(int *)&ddb_regs.save_r20,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r21",	(int *)&ddb_regs.save_r21,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r22",	(int *)&ddb_regs.save_r22,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r23",	(int *)&ddb_regs.save_r23,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r24",	(int *)&ddb_regs.save_r24,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r25",	(int *)&ddb_regs.save_r25,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r26",	(int *)&ddb_regs.save_r26,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r27",	(int *)&ddb_regs.save_r27,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r28",	(int *)&ddb_regs.save_r28,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r29",	(int *)&ddb_regs.save_r29,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r30",	(int *)&ddb_regs.save_r30,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "r31",	(int *)&ddb_regs.save_r31,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "cr",	(int *)&ddb_regs.save_cr,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "xer",	(int *)&ddb_regs.save_xer,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "lr",	(int *)&ddb_regs.save_lr,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
-  { "ctr",	(int *)&ddb_regs.save_ctr,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "pc",	&ddb_regs.save_srr0,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "srr0",	&ddb_regs.save_srr0,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "srr1",	&ddb_regs.save_srr1,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r0",	&ddb_regs.save_r0,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r1",	&ddb_regs.save_r1,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r2",	&ddb_regs.save_r2,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r3",	&ddb_regs.save_r3,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r4",	&ddb_regs.save_r4,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r5",	&ddb_regs.save_r5,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r6",	&ddb_regs.save_r6,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r7",	&ddb_regs.save_r7,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r8",	&ddb_regs.save_r8,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r9",	&ddb_regs.save_r9,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r10",	&ddb_regs.save_r10,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r11",	&ddb_regs.save_r11,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r12",	&ddb_regs.save_r12,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r13",	&ddb_regs.save_r13,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r14",	&ddb_regs.save_r14,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r15",	&ddb_regs.save_r15,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r16",	&ddb_regs.save_r16,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r17",	&ddb_regs.save_r17,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r18",	&ddb_regs.save_r18,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r19",	&ddb_regs.save_r19,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r20",	&ddb_regs.save_r20,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r21",	&ddb_regs.save_r21,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r22",	&ddb_regs.save_r22,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r23",	&ddb_regs.save_r23,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r24",	&ddb_regs.save_r24,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r25",	&ddb_regs.save_r25,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r26",	&ddb_regs.save_r26,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r27",	&ddb_regs.save_r27,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r28",	&ddb_regs.save_r28,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r29",	&ddb_regs.save_r29,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r30",	&ddb_regs.save_r30,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "r31",	&ddb_regs.save_r31,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "cr",	&ddb_regs.save_cr,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "xer",	&ddb_regs.save_xer,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "lr",	&ddb_regs.save_lr,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
+  { "ctr",	&ddb_regs.save_ctr,	db_ppc_reg_value, 0, 0, 0, 0, TRUE },
 };
 struct db_variable *db_eregs = db_regs + sizeof(db_regs)/sizeof(db_regs[0]);
 
@@ -173,8 +163,10 @@ db_ppc_reg_value(
 	int			flag,
 	db_var_aux_param_t	ap)
 {
-	int			*dp = 0;
-	db_expr_t		null_reg = 0;
+	db_expr_t *dp = 0;
+	db_expr_t null_reg = 0;
+	uint32_t *dp32;
+	
 	register thread_act_t	thr_act = ap->thr_act;
 	int			cpu;
 
@@ -184,71 +176,78 @@ db_ppc_reg_value(
 		    db_error("no user registers\n");
 	    }
 	    if (thr_act == current_act()) {
-		if (IS_USER_TRAP((&ddb_regs)))
-		    dp = vp->valuep;
-		else if (INFIXEDSTACK(ddb_regs.save_r1))
-		    db_error("cannot get/set user registers in nested interrupt\n");
+			if (IS_USER_TRAP((&ddb_regs))) dp = vp->valuep;
+			else if (INFIXEDSTACK(ddb_regs.save_r1))
+				db_error("cannot get/set user registers in nested interrupt\n");
 	    }
-	} else {
-	    if (thr_act == THR_ACT_NULL || thr_act == current_act()) {
-		dp = vp->valuep;
-	    } else {
-	      if (thr_act->thread &&
-		  !(thr_act->thread->state & TH_STACK_HANDOFF) && 
-			thr_act->thread->kernel_stack) {
-		int cpu;
-
-		for (cpu = 0; cpu < NCPUS; cpu++) {
-		    if (cpu_to_processor(cpu)->state == PROCESSOR_RUNNING &&
-			cpu_to_processor(cpu)->cpu_data->active_thread == thr_act->thread && saved_state[cpu]) {
-			dp = (int *) (((int)saved_state[cpu]) +
-				      (((int) vp->valuep) -
-				       (int) &ddb_regs));
-			break;
-		    }
-		}
+	} 
+	else {
+		if (thr_act == THR_ACT_NULL || thr_act == current_act()) {
+			dp = vp->valuep;
+		} 
+		else {
+			if (thr_act->thread &&
+				!(thr_act->thread->state & TH_STACK_HANDOFF) && 
+				thr_act->thread->kernel_stack) {
+				
+				int cpu;
 
-		if (dp == 0)
-		    dp = &null_reg;
-	      } else if (thr_act->thread &&
-			 (thr_act->thread->state&TH_STACK_HANDOFF)){
-		/* only PC is valid */
-		if (vp->valuep == (int *) &ddb_regs.save_srr0) {
-		    dp = (int *)(&thr_act->thread->continuation);
-		} else {
-		    dp = &null_reg;
-		}
-	      }
+				for (cpu = 0; cpu < NCPUS; cpu++) {
+					if (cpu_to_processor(cpu)->state == PROCESSOR_RUNNING &&
+						cpu_to_processor(cpu)->cpu_data->active_thread == thr_act->thread && saved_state[cpu]) {
+						
+						dp = (db_expr_t)(((uint32_t)saved_state[cpu]) +
+								  (((uint32_t) vp->valuep) -
+								   (uint32_t) &ddb_regs));
+						break;
+					}
+				}
+
+				if (dp == 0) dp = &null_reg;
+			} 
+			else if (thr_act->thread && (thr_act->thread->state & TH_STACK_HANDOFF)){
+				/* only PC is valid */
+				if (vp->valuep == (int *) &ddb_regs.save_srr0) {
+					dp = (int *)(&thr_act->thread->continuation);
+				} 
+				else {
+					dp = &null_reg;
+				}
+			}
 	    }
 	}
 	if (dp == 0) {
-	    int cpu;
 
 	    if (!db_option(ap->modif, 'u')) {
-		for (cpu = 0; cpu < NCPUS; cpu++) {
-		    if (cpu_to_processor(cpu)->state == PROCESSOR_RUNNING &&
-		    	cpu_to_processor(cpu)->cpu_data->active_thread == thr_act->thread && saved_state[cpu]) {
-		    	    dp = (int *) (((int)saved_state[cpu]) +
-					  (((int) vp->valuep) -
-					   (int) &ddb_regs));
-			    break;
-		    }
-		}
+			for (cpu = 0; cpu < NCPUS; cpu++) {
+				if (cpu_to_processor(cpu)->state == PROCESSOR_RUNNING &&
+					cpu_to_processor(cpu)->cpu_data->active_thread == thr_act->thread && saved_state[cpu]) {
+						dp = (int *) (((int)saved_state[cpu]) +
+						  (((int) vp->valuep) - (int) &ddb_regs));
+					break;
+				}
+			}
 	    }
 	    if (dp == 0) {
-		if (!thr_act || thr_act->mact.pcb == 0)
-		    db_error("no pcb\n");
-		dp = (int *)((int)thr_act->mact.pcb + 
-			     ((int)vp->valuep - (int)&ddb_regs));
+			if (!thr_act || thr_act->mact.pcb == 0) db_error("no pcb\n");
+			dp = (int *)((int)thr_act->mact.pcb + ((int)vp->valuep - (int)&ddb_regs));
 	    }
 	}
-	if (flag == DB_VAR_SET)
-	    *dp = *valuep;
-	else
-	    *valuep = *dp;
+
+	if(vp->valuep == (int *) &ddb_regs.save_cr) {	/* Is this the CR we are doing? */
+		dp32 = (uint32_t *)dp;						/* Make this easier */
+		if (flag == DB_VAR_SET) *dp32 = *valuep;
+		else *valuep = *dp32;
+	}
+	else {											/* Normal 64-bit registers */
+		if (flag == DB_VAR_SET) *dp = *valuep;
+		else *valuep = *(unsigned long long *)dp;
+	}
+	
 	return(0);
 }
 
+
 void
 db_find_trace_symbols(void)
 {
@@ -374,6 +373,13 @@ db_nextframe(
 	    /* falling down for unknown case */
 	default:
 	miss_frame:
+		
+		if(!pmap_find_phys(kernel_pmap, (addr64_t)*fp)) {	/* Check if this is valid */
+			db_printf("Frame not mapped %08X\n",*fp);		/* Say not found */
+			*fp = 0;										/* Show not found */
+			break;											/* Out of here */
+		}
+		
 		if ((*fp)->f_frame)
 		    *ip = (db_addr_t)
 			    db_get_task_value((int)&(*fp)->f_frame->f_retaddr,
diff --git a/osfmk/ppc/endian.h b/osfmk/ppc/endian.h
index 5ff26263e..15f706bb5 100644
--- a/osfmk/ppc/endian.h
+++ b/osfmk/ppc/endian.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ppc/exception.h b/osfmk/ppc/exception.h
index e268b0d2d..8598062d0 100644
--- a/osfmk/ppc/exception.h
+++ b/osfmk/ppc/exception.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -46,8 +49,9 @@
 #include <ppc/machine_routines.h>
 
 /*	Per processor CPU features */
+#pragma pack(4)							/* Make sure the structure stays as we defined it */
 struct procFeatures {
-	unsigned int	Available;
+	unsigned int	Available;			/* 0x000 */
 #define pfFloat		0x80000000
 #define pfFloatb	0
 #define pfAltivec	0x40000000
@@ -66,12 +70,24 @@ struct procFeatures {
 #define pfThermalb	7
 #define pfThermInt	0x00800000
 #define pfThermIntb	8
-#define pfNoL2PFNap	0x00008000
-#define pfNoL2PFNapb	16
-#define pfSlowNap	0x00004000
-#define pfSlowNapb	17
-#define pfNoMuMMCK	0x00002000
-#define pfNoMuMMCKb	18
+#define pfSlowNap	0x00400000
+#define pfSlowNapb	9
+#define pfNoMuMMCK	0x00200000
+#define pfNoMuMMCKb	10
+#define pfNoL2PFNap	0x00100000
+#define pfNoL2PFNapb	11
+#define pfSCOMFixUp	0x00080000
+#define pfSCOMFixUpb	12
+#define	pfHasDcba	0x00040000
+#define	pfHasDcbab	13
+#define	pfL1fa		0x00010000
+#define	pfL1fab		15
+#define pfL2		0x00008000
+#define pfL2b		16
+#define pfL2fa		0x00004000
+#define pfL2fab		17
+#define pfL2i		0x00002000
+#define pfL2ib		18
 #define pfLClck		0x00001000
 #define pfLClckb	19
 #define pfWillNap	0x00000800
@@ -80,49 +96,50 @@ struct procFeatures {
 #define pfNoMSRirb	21
 #define pfL3pdet	0x00000200
 #define pfL3pdetb	22
-#define pfL1i		0x00000100
-#define pfL1ib		23
-#define pfL1d		0x00000080
-#define pfL1db		24
-#define pfL1fa		0x00000040
-#define pfL1fab		25
-#define pfL2		0x00000020
-#define pfL2b		26
-#define pfL2fa		0x00000010
-#define pfL2fab		27
-#define pfL2i		0x00000008
-#define pfL2ib		28
+#define	pf128Byte	0x00000080
+#define	pf128Byteb	24
+#define	pf32Byte	0x00000020
+#define	pf32Byteb	26
+#define	pf64Bit		0x00000010
+#define	pf64Bitb	27
 #define pfL3		0x00000004
 #define pfL3b		29
 #define pfL3fa		0x00000002
 #define pfL3fab		30
 #define pfValid		0x00000001
 #define pfValidb	31
-	unsigned short	rptdProc;
-	unsigned short	lineSize;
-	unsigned int	l1iSize;
-	unsigned int	l1dSize;
-	unsigned int	l2cr;
-	unsigned int	l2Size;
-	unsigned int	l3cr;
-	unsigned int	l3Size;
-	unsigned int	pfHID0;
-	unsigned int	pfHID1;
-	unsigned int	pfHID2;
-	unsigned int	pfHID3;
-	unsigned int	pfMSSCR0;
-	unsigned int	pfMSSCR1;
-	unsigned int	pfICTRL;
-	unsigned int	pfLDSTCR;
-	unsigned int	pfLDSTDB;
-	unsigned int	l2crOriginal;
-	unsigned int	l3crOriginal;
-	unsigned int	pfBootConfig;
-	unsigned int	reserved[4];
+	unsigned short	rptdProc;			/* 0x004 */
+	unsigned short	lineSize;			/* 0x006 */
+	unsigned int	l1iSize;			/* 0x008 */
+	unsigned int	l1dSize;			/* 0x00C */
+	unsigned int	l2cr;				/* 0x010 */
+	unsigned int	l2Size;				/* 0x014 */
+	unsigned int	l3cr;				/* 0x018 */
+	unsigned int	l3Size;				/* 0x01C */
+	unsigned int	pfMSSCR0;			/* 0x020 */
+	unsigned int	pfMSSCR1;			/* 0x024 */
+	unsigned int	pfICTRL;			/* 0x028 */
+	unsigned int	pfLDSTCR;			/* 0x02C */
+	unsigned int	pfLDSTDB;			/* 0x030 */
+	unsigned int	pfMaxVAddr;			/* 0x034 */
+	unsigned int	pfMaxPAddr;			/* 0x038 */
+	unsigned int	pfPTEG;				/* 0x03C */
+	uint64_t		pfHID0;				/* 0x040 */
+	uint64_t		pfHID1;				/* 0x048 */
+	uint64_t		pfHID2;				/* 0x050 */
+	uint64_t		pfHID3;				/* 0x058 */
+	uint64_t		pfHID4;				/* 0x060 */
+	uint64_t		pfHID5;				/* 0x068 */
+	unsigned int	l2crOriginal;		/* 0x070 */
+	unsigned int	l3crOriginal;		/* 0x074 */
+	unsigned int	pfBootConfig;		/* 0x07C */
+	unsigned int	reserved[1];		/* 0x80 */
 };
+#pragma pack()
 
 typedef struct procFeatures procFeatures;
 
+#pragma pack(4)							/* Make sure the structure stays as we defined it */
 struct thrmControl {
 	unsigned int	maxTemp;			/* Maximum temprature before damage */
 	unsigned int	throttleTemp;		/* Temprature at which to throttle down */
@@ -131,11 +148,130 @@ struct thrmControl {
 	unsigned int	thrm3val;			/* Value for thrm3 register */
 	unsigned int	rsvd[3];			/* Pad to cache line */
 };
+#pragma pack()
 
 typedef struct thrmControl thrmControl;
 
+/*
+ *
+ *		Various performance counters
+ */
+#pragma pack(4)							/* Make sure the structure stays as we defined it */
+struct hwCtrs {	
+
+	unsigned int	hwInVains; 				/* In vain */
+	unsigned int	hwResets;				/* Reset */
+	unsigned int	hwMachineChecks;		/* Machine check */
+	unsigned int	hwDSIs; 				/* DSIs */
+	unsigned int	hwISIs; 				/* ISIs */
+	unsigned int	hwExternals; 			/* Externals */
+	unsigned int	hwAlignments; 			/* Alignment */
+	unsigned int	hwPrograms; 			/* Program */
+	unsigned int	hwFloatPointUnavailable;	/* Floating point */
+	unsigned int	hwDecrementers; 		/* Decrementer */
+	unsigned int	hwIOErrors; 			/* I/O error */
+	unsigned int	hwrsvd0; 				/* Reserved */
+	unsigned int	hwSystemCalls; 			/* System call */
+	unsigned int	hwTraces; 				/* Trace */
+	unsigned int	hwFloatingPointAssists; /* Floating point assist */
+	unsigned int	hwPerformanceMonitors; 	/* Performance monitor */
+	unsigned int	hwAltivecs; 			/* VMX */
+	unsigned int	hwrsvd1; 				/* Reserved */
+	unsigned int	hwrsvd2; 				/* Reserved */
+	unsigned int	hwrsvd3; 				/* Reserved */
+	unsigned int	hwInstBreakpoints; 		/* Instruction breakpoint */
+	unsigned int	hwSystemManagements; 	/* System management */
+	unsigned int	hwAltivecAssists; 		/* Altivec Assist */
+	unsigned int	hwThermal;				/* Thermals */
+	unsigned int	hwrsvd5; 				/* Reserved */
+	unsigned int	hwrsvd6; 				/* Reserved */
+	unsigned int	hwrsvd7; 				/* Reserved */
+	unsigned int	hwrsvd8;				/* Reserved */
+	unsigned int	hwrsvd9; 				/* Reserved */
+	unsigned int	hwrsvd10; 				/* Reserved */
+	unsigned int	hwrsvd11; 				/* Reserved */
+	unsigned int	hwrsvd12; 				/* Reserved */
+	unsigned int	hwrsvd13; 				/* Reserved */
+	unsigned int	hwTrace601;				/* Trace */
+	unsigned int	hwSIGPs; 				/* SIGP */
+	unsigned int	hwPreemptions; 			/* Preemption */
+	unsigned int	hwContextSwitchs;		/* Context switch */
+	unsigned int	hwShutdowns;			/* Shutdowns */
+	unsigned int	hwChokes;				/* System ABENDs */
+	unsigned int	hwDataSegments;			/* Data Segment Interruptions */
+	unsigned int	hwInstructionSegments;	/* Instruction Segment Interruptions */
+	unsigned int	hwSoftPatches;			/* Soft Patch interruptions */
+	unsigned int	hwMaintenances;			/* Maintenance interruptions */
+	unsigned int	hwInstrumentations;		/* Instrumentation interruptions */
+	unsigned int	hwrsvd14;				/* Reswerved */
+/*											0x0B4 */
+
+	unsigned int	hwspare0[17];			/* Reserved */
+	unsigned int	hwRedrives;				/* Number of redriven interrupts */
+	unsigned int	hwSteals;				/* PTE Steals */
+/*											0x100 */
+
+	unsigned int 	hwMckHang;				/* ? */
+	unsigned int 	hwMckSLBPE;				/* ? */
+	unsigned int 	hwMckTLBPE;				/* ? */
+	unsigned int 	hwMckERCPE;				/* ? */
+	unsigned int	hwMckL1DPE;				/* ? */
+	unsigned int	hwMckL1TPE;				/* ? */
+	unsigned int 	hwMckUE;				/* ? */
+	unsigned int 	hwMckIUE;				/* ? */
+	unsigned int 	hwMckIUEr;				/* ? */
+	unsigned int 	hwMckDUE;				/* ? */
+	unsigned int 	hwMckDTW;				/* ? */
+	unsigned int 	hwMckUnk;				/* ? */
+	unsigned int 	hwMckExt;				/* ? */
+	unsigned int 	hwMckICachePE;			/* ? */
+	unsigned int 	hwMckITagPE;			/* ? */
+	unsigned int 	hwMckIEratPE;			/* ? */
+	unsigned int 	hwMckDEratPE;			/* ? */
+	unsigned int	hwspare2[15];			/* Pad to next 128 bndry */
+/*											0x180 */
+
+	unsigned int	napStamp[2];			/* Time base when we napped */
+	unsigned int	napTotal[2];			/* Total nap time in ticks */
+	unsigned int	numSIGPast;				/* Number of SIGP asts recieved */
+	unsigned int	numSIGPcpureq;			/* Number of SIGP cpu requests recieved */
+	unsigned int	numSIGPdebug;			/* Number of SIGP debugs recieved */
+	unsigned int	numSIGPwake;			/* Number of SIGP wakes recieved */
+	unsigned int	numSIGPtimo;			/* Number of SIGP send timeouts */
+	unsigned int	numSIGPmast;			/* Number of SIGPast messages merged */
+	unsigned int	numSIGPmwake;			/* Number of SIGPwake messages merged */
+	
+	unsigned int	hwspare3[21];			/* Pad to 512 */
+	
+};
+#pragma pack()
+
+typedef struct hwCtrs hwCtrs;
+
+struct patch_entry {
+	unsigned int	*addr;
+	unsigned int	data;
+	unsigned int	type;
+	unsigned int	value;
+};
+
+typedef struct patch_entry patch_entry_t;
+
+#define	PATCH_INVALID		0
+#define	PATCH_PROCESSOR		1
+#define	PATCH_FEATURE		2
+
+#define PATCH_TABLE_SIZE	12
+
+#define PatchExt32		0x80000000
+#define PatchExt32b		0
+#define PatchLwsync		0x40000000
+#define PatchLwsyncb	1
+
 /* When an exception is taken, this info is accessed via sprg0 */
 /* We should always have this one on a cache line boundary */
+
+#pragma pack(4)							/* Make sure the structure stays as we defined it */
 struct per_proc_info {
 	unsigned short	cpu_number;
 	unsigned short	cpu_flags;			/* Various low-level flags */
@@ -145,8 +281,8 @@ struct per_proc_info {
 	vm_offset_t  	debstackptr;
 	vm_offset_t  	debstack_top_ss;
 
-	unsigned int	tempwork1;			/* Temp work area - monitor use carefully */
-	unsigned int	save_exception_type;
+	unsigned int 	spcFlags;			/* Special thread flags */
+	unsigned int 	Uassist;			/* User Assist Word */
 	unsigned int	old_thread;
 
 	/* PPC cache line boundary here - 020 */
@@ -158,31 +294,28 @@ struct per_proc_info {
  *	Note: the following two pairs of words need to stay in order and each pair must
  *	be in the same reservation (line) granule 
  */
-	struct facility_context	*FPU_owner;		/* Owner of the FPU on this cpu */
-	unsigned int	pprsv1;
-	struct facility_context	*VMX_owner;		/* Owner of the VMX on this cpu */
-	unsigned int 	pprsv2;
-	unsigned int	next_savearea;			/* pointer to the next savearea */
+	struct facility_context	*FPU_owner;	/* Owner of the FPU on this cpu */
+	unsigned int 	liveVRSave;			/* VRSave assiciated with live vector registers */
+	struct facility_context	*VMX_owner;	/* Owner of the VMX on this cpu */
+	unsigned int 	holdQFret;			/* Hold off releasing quickfret list */
+	unsigned int	rsrvd03C[1];
 
 	/* PPC cache line boundary here - 040 */
-	unsigned int 	quickfret;			/* List of saveareas to release */
-	unsigned int 	lclfree;			/* Pointer to local savearea list */
+	addr64_t		quickfret;			/* List of saveareas to release */
+	addr64_t		lclfree;			/* Pointer to local savearea list */
 	unsigned int	lclfreecnt;			/* Entries in local savearea list */
-	unsigned int 	Lastpmap;			/* Last user pmap loaded  */
-	unsigned int	userspace;			/* Last loaded user memory space ID  */
-	unsigned int	userpmap;			/* User pmap - real address */
-	unsigned int 	liveVRSave;			/* VRSave assiciated with live vector registers */
-	unsigned int 	spcFlags;			/* Special thread flags */
+	unsigned int	spcTRc;				/* Special trace count */
+	unsigned int	spcTRp;				/* Special trace buffer pointer */
+	unsigned int	ppbbTaskEnv;		/* BlueBox Task Environment */
 
 	/* PPC cache line boundary here - 060 */
 	boolean_t		interrupts_enabled;
-	unsigned int	ppbbTaskEnv;		/* BlueBox Task Environment */
 	IOInterruptHandler	interrupt_handler;
 	void *			interrupt_nub;
 	unsigned int	interrupt_source;
 	void *			interrupt_target;
 	void *			interrupt_refCon;
-	time_base_enable_t	time_base_enable;
+	uint64_t		next_savearea;			/* pointer to the next savearea */
 
 	/* PPC cache line boundary here - 080 */
 	unsigned int	MPsigpStat;			/* Signal Processor status (interlocked update for this one) */
@@ -201,7 +334,8 @@ struct per_proc_info {
 #define SIGPdebug	2					/* Requests a debugger entry */
 #define SIGPwake	3					/* Wake up a sleeping processor */
 #define CPRQtemp	0					/* Get temprature of processor */
-#define CPRQtimebase	1					/* Get timebase of processor */
+#define CPRQtimebase	1				/* Get timebase of processor */
+#define CPRQscom	2					/* SCOM */
 	unsigned int	MPsigpParm0;		/* SIGP parm 0 */
 	unsigned int	MPsigpParm1;		/* SIGP parm 1 */
 	unsigned int	MPsigpParm2;		/* SIGP parm 2 */
@@ -212,40 +346,79 @@ struct per_proc_info {
 	/* PPC cache line boundary here - 0A0 */
 	procFeatures 	pf;					/* Processor features */
 	
-	/* PPC cache line boundary here - 100 */
-	thrmControl		thrm;				/* Thermal controls */
-	
 	/* PPC cache line boundary here - 120 */
-	unsigned int	napStamp[2];		/* Time base when we napped */
-	unsigned int	napTotal[2];		/* Total nap time in ticks */
-	unsigned int	numSIGPast;			/* Number of SIGP asts recieved */
-	unsigned int	numSIGPcpureq;		/* Number of SIGP cpu requests recieved */
-	unsigned int	numSIGPdebug;		/* Number of SIGP debugs recieved */
-	unsigned int	numSIGPwake;		/* Number of SIGP wakes recieved */
+	thrmControl		thrm;				/* Thermal controls */
 	
 	/* PPC cache line boundary here - 140 */
-	unsigned int	numSIGPtimo;		/* Number of SIGP send timeouts */
-	unsigned int	numSIGPmast;		/* Number of SIGPast messages merged */
-	unsigned int	numSIGPmwake;		/* Number of SIGPwake messages merged */
-	unsigned int	spcTRc;				/* Special trace count */
-	unsigned int	spcTRp;				/* Special trace buffer pointer */
-	unsigned int 	Uassist;			/* User Assist Word */
-	unsigned int	rsrvd158[2];		/* Reserved slots */
+	unsigned int	ppRsvd140[8];		/* Reserved */
 	
 	/* PPC cache line boundary here - 160 */
+	time_base_enable_t	time_base_enable;
+	unsigned int	ppRsvd164[3];		/* Reserved */
 	cpu_data_t		pp_cpu_data;		/* cpu data info */
-	unsigned int	rsrvd170[4];		/* Reserved slots */
 	
 	/* PPC cache line boundary here - 180 */
-	unsigned int	rsrvd180[8];		/* Reserved slots */
+	unsigned int	ppRsvd180[2];		/* Reserved */
+	uint64_t		validSegs;			/* Valid SR/STB slots */
+	addr64_t		ppUserPmap;			/* Current user state pmap (physical address) */
+	unsigned int	ppUserPmapVirt;		/* Current user state pmap (virtual address) */
+	unsigned int	ppMapFlags;			/* Mapping flags */
 	
 	/* PPC cache line boundary here - 1A0 */
-	unsigned int	rsrvd1A0[8];		/* Reserved slots */
+	unsigned short	ppInvSeg;			/* Forces complete invalidate of SRs/SLB (this must stay with ppInvSeg) */
+	unsigned short	ppCurSeg;			/* Set to 1 if user segments, 0 if kernel (this must stay with ppInvSeg) */
+	unsigned int	ppSegSteal;			/* Count of segment slot steals */
+	ppnum_t			VMMareaPhys;		/* vmm state page physical addr */
+	unsigned int	VMMXAFlgs;			/* vmm extended flags */
+	unsigned int	FAMintercept;		/* vmm FAM Exceptions to intercept */
+	unsigned int	rsrvd1B4[3];		/* Reserved slots */
 	
 	/* PPC cache line boundary here - 1C0 */
-	unsigned int	rsrvd1C0[8];		/* Reserved slots */
+	unsigned int	ppCIOmp[16];		/* Linkage mapping for copyin/out - 64 bytes */
+	
+	/* PPC cache line boundary here - 200 */
+	uint64_t		tempr0;				/* temporary savearea */
+	uint64_t		tempr1;			
+	uint64_t		tempr2;
+	uint64_t		tempr3;
+
+	uint64_t		tempr4;				
+	uint64_t		tempr5;
+	uint64_t		tempr6;
+	uint64_t		tempr7;
+
+	uint64_t		tempr8;
+	uint64_t		tempr9;
+	uint64_t		tempr10;
+	uint64_t		tempr11;
+	
+	uint64_t		tempr12;
+	uint64_t		tempr13;
+	uint64_t		tempr14;
+	uint64_t		tempr15;
 	
-	/* PPC cache line boundary here - 1E0 */
+	uint64_t		tempr16;
+	uint64_t		tempr17;
+	uint64_t		tempr18;
+	uint64_t		tempr19;
+
+	uint64_t		tempr20;
+	uint64_t		tempr21;
+	uint64_t		tempr22;
+	uint64_t		tempr23;
+	
+	uint64_t		tempr24;
+	uint64_t		tempr25;
+	uint64_t		tempr26;
+	uint64_t		tempr27;
+	
+	uint64_t		tempr28;
+	uint64_t		tempr29;
+	uint64_t		tempr30;
+	uint64_t		tempr31;
+
+
+	/* PPC cache line boundary here - 300 */
 	double			emfp0;				/* Copies of floating point registers */
 	double			emfp1;				/* Used for emulation purposes */
 	double			emfp2;
@@ -286,12 +459,12 @@ struct per_proc_info {
 	double			emfp30;
 	double			emfp31;
 
-/*								   - 2E0 */
+/*								   - 400 */
 	unsigned int 	emfpscr_pad;
 	unsigned int 	emfpscr;
 	unsigned int	empadfp[6];
 	
-/*								   - 300 */
+/*								   - 420 */
 	unsigned int	emvr0[4];			/* Copies of vector registers used both */
 	unsigned int	emvr1[4];			/* for full vector emulation or */
 	unsigned int	emvr2[4];			/* as saveareas while assisting denorms */
@@ -326,10 +499,21 @@ struct per_proc_info {
 	unsigned int	emvr31[4];
 	unsigned int	emvscr[4];			
 	unsigned int	empadvr[4];			
-/*								   - 520 */
+/*								   - 640 */
+/* note implicit dependence on kSkipListMaxLists, which must be <= 28 */
+    addr64_t		skipListPrev[28];	/* prev ptrs saved as side effect of calling mapSearchFull() */
+    
+/*								   - 720 */
 
 	unsigned int	patcharea[56];
-/*								   - 600 */
+/*								   - 800 */
+
+	hwCtrs			hwCtr;					/* Hardware exception counters */
+/*								   - A00 */
+
+	unsigned int	pppadpage[384];			/* Pad to end of page */
+/*								   - 1000 */
+
 
 };
 
@@ -338,13 +522,15 @@ struct per_proc_info {
 #define	pp_simple_lock_count	pp_cpu_data.simple_lock_count
 #define	pp_interrupt_level	pp_cpu_data.interrupt_level
 
+#pragma pack()
+
 
 extern struct per_proc_info per_proc_info[NCPUS];
 
+
 extern char *trap_type[];
 
-#endif /* ndef ASSEMBLER */
-/* with this savearea should be redriven */
+#endif /* ndef ASSEMBLER */											/* with this savearea should be redriven */
 
 /* cpu_flags defs */
 #define SIGPactive	0x8000
@@ -392,7 +578,7 @@ extern char *trap_type[];
 #define T_INVALID_EXCP10		(0x1D * T_VECTOR_SIZE)
 #define T_INVALID_EXCP11		(0x1E * T_VECTOR_SIZE)
 #define T_INVALID_EXCP12		(0x1F * T_VECTOR_SIZE)
-#define T_INVALID_EXCP13		(0x20 * T_VECTOR_SIZE)
+#define T_EMULATE				(0x20 * T_VECTOR_SIZE)
 
 #define T_RUNMODE_TRACE			(0x21 * T_VECTOR_SIZE) /* 601 only */
 
@@ -402,10 +588,20 @@ extern char *trap_type[];
 #define T_SHUTDOWN				(0x25 * T_VECTOR_SIZE)
 #define T_CHOKE					(0x26 * T_VECTOR_SIZE)
 
+#define T_DATA_SEGMENT			(0x27 * T_VECTOR_SIZE)
+#define T_INSTRUCTION_SEGMENT	(0x28 * T_VECTOR_SIZE)
+
+#define T_SOFT_PATCH			(0x29 * T_VECTOR_SIZE)
+#define T_MAINTENANCE			(0x2A * T_VECTOR_SIZE)
+#define T_INSTRUMENTATION		(0x2B * T_VECTOR_SIZE)
+#define T_ARCHDEP0				(0x2C * T_VECTOR_SIZE)
+
 #define T_AST					(0x100 * T_VECTOR_SIZE) 
 #define T_MAX					T_CHOKE		 /* Maximum exception no */
 
-#define	EXCEPTION_VECTOR(exception)	(exception * 0x100 /T_VECTOR_SIZE )
+#define	T_FAM					0x00004000
+
+#define	EXCEPTION_VECTOR(exception)	(exception * 0x100 / T_VECTOR_SIZE )
 
 /*
  *		System choke (failure) codes 
@@ -418,17 +614,21 @@ extern char *trap_type[];
 #define failNoSavearea 4
 #define failSaveareaCorr 5
 #define failBadLiveContext 6
+#define	failSkipLists 7
+#define	failUnalignedStk 8
 
 /* Always must be last - update failNames table in model_dep.c as well */
-#define failUnknown 7
+#define failUnknown 9
 
 #ifndef ASSEMBLER
 
+#pragma pack(4)							/* Make sure the structure stays as we defined it */
 typedef struct resethandler {
 	unsigned int	type;
 	vm_offset_t	call_paddr;
 	vm_offset_t	arg__paddr;
 } resethandler_t;
+#pragma pack()
 
 extern resethandler_t ResetHandler;
 
@@ -436,5 +636,7 @@ extern resethandler_t ResetHandler;
 
 #define	RESET_HANDLER_NULL	0x0
 #define	RESET_HANDLER_START	0x1
+#define	RESET_HANDLER_BUPOR	0x2
+#define	RESET_HANDLER_IGNORE	0x3
 
 #endif /* _PPC_EXCEPTION_H_ */
diff --git a/osfmk/ppc/fpu_protos.h b/osfmk/ppc/fpu_protos.h
index 6781cc8ce..7a64366c6 100644
--- a/osfmk/ppc/fpu_protos.h
+++ b/osfmk/ppc/fpu_protos.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ppc/genassym.c b/osfmk/ppc/genassym.c
index 54397dd3e..430eb0542 100644
--- a/osfmk/ppc/genassym.c
+++ b/osfmk/ppc/genassym.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -60,14 +63,15 @@
 #include <vm/vm_map.h>
 #include <vm/pmap.h>
 #include <ppc/pmap.h>
-#include <ppc/pmap_internals.h>
 #include <ppc/Diagnostics.h>
-#include <ppc/POWERMAC/mp/MPPlugIn.h>
 #include <pexpert/pexpert.h>
 #include <mach/machine.h>
 #include <ppc/vmachmon.h>
+#include <ppc/hw_perfmon.h>
 #include <ppc/PPCcalls.h>
 #include <ppc/mem.h>
+#include <ppc/boot.h>
+#include <ppc/lowglobals.h>
 
 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE)0)->MEMBER)
 
@@ -83,7 +87,12 @@ int main(int argc, char *argv[])
 	DECLARE("ACT_MACT_BTS",	offsetof(struct thread_activation *, mact.bbTableStart));
 	DECLARE("ACT_MACT_BTE",	offsetof(struct thread_activation *, mact.bbTaskEnv));
 	DECLARE("ACT_MACT_SPF",	offsetof(struct thread_activation *, mact.specFlags));
+	DECLARE("ACT_PREEMPT_CNT",	offsetof(struct thread_activation *, mact.preemption_count));
 	DECLARE("qactTimer",	offsetof(struct thread_activation *, mact.qactTimer));
+	DECLARE("cioSpace",		offsetof(struct thread_activation *, mact.cioSpace));
+	DECLARE("cioRelo",		offsetof(struct thread_activation *, mact.cioRelo));
+	DECLARE("cioSwitchAway",	cioSwitchAway);
+	DECLARE("cioSwitchAwayb",	cioSwitchAwayb);
 	
 	DECLARE("floatUsed",	floatUsed);
 	DECLARE("vectorUsed",	vectorUsed);
@@ -95,19 +104,22 @@ int main(int argc, char *argv[])
 	DECLARE("vectorCngbit",	vectorCngbit);
 	DECLARE("userProtKey",	userProtKey);
 	DECLARE("userProtKeybit",	userProtKeybit);
-	DECLARE("trapUnalign",	trapUnalign);
-	DECLARE("trapUnalignbit",	trapUnalignbit);
-	DECLARE("notifyUnalign",	notifyUnalign);
-	DECLARE("notifyUnalignbit",	notifyUnalignbit);
 
 	DECLARE("bbThread",		bbThread);
 	DECLARE("bbThreadbit",	bbThreadbit);
+	DECLARE("bbNoMachSC",	bbNoMachSC);
 	DECLARE("bbNoMachSCbit",bbNoMachSCbit);
 	DECLARE("bbPreemptive",	bbPreemptive);
 	DECLARE("bbPreemptivebit",	bbPreemptivebit);
 
 	DECLARE("fvChkb",		fvChkb);
 	DECLARE("fvChk",		fvChk);
+	DECLARE("FamVMena",		FamVMena);
+	DECLARE("FamVMenabit",		FamVMenabit);
+	DECLARE("FamVMmode",		FamVMmode);
+	DECLARE("FamVMmodebit",		FamVMmodebit);
+	DECLARE("perfMonitor",		perfMonitor);
+	DECLARE("perfMonitorbit",	perfMonitorbit);
 
 	/* Per Proc info structure */
 	DECLARE("PP_CPU_NUMBER",		offsetof(struct per_proc_info *, cpu_number));
@@ -116,14 +128,10 @@ int main(int argc, char *argv[])
 	DECLARE("PP_INTSTACK_TOP_SS",	offsetof(struct per_proc_info *, intstack_top_ss));
 	DECLARE("PP_DEBSTACKPTR",		offsetof(struct per_proc_info *, debstackptr));
 	DECLARE("PP_DEBSTACK_TOP_SS",	offsetof(struct per_proc_info *, debstack_top_ss));
-	DECLARE("PP_TEMPWORK1",			offsetof(struct per_proc_info *, tempwork1));
-	DECLARE("PP_USERSPACE",			offsetof(struct per_proc_info *, userspace));
-	DECLARE("PP_USERPMAP",			offsetof(struct per_proc_info *, userpmap));
-	DECLARE("PP_LASTPMAP",			offsetof(struct per_proc_info *, Lastpmap));
 	DECLARE("FPUowner",				offsetof(struct per_proc_info *, FPU_owner));
 	DECLARE("VMXowner",				offsetof(struct per_proc_info *, VMX_owner));
+	DECLARE("holdQFret",			offsetof(struct per_proc_info *, holdQFret));
 
-	DECLARE("PP_SAVE_EXCEPTION_TYPE", offsetof(struct per_proc_info *, save_exception_type));
 	DECLARE("PP_ACTIVE_KLOADED", 	offsetof(struct per_proc_info *, active_kloaded));
 	DECLARE("PP_ACTIVE_STACKS", 	offsetof(struct per_proc_info *, active_stacks));
 	DECLARE("PP_NEED_AST", 			offsetof(struct per_proc_info *, need_ast));
@@ -132,9 +140,8 @@ int main(int argc, char *argv[])
 	DECLARE("lclfreecnt",			offsetof(struct per_proc_info *, lclfreecnt));
 	DECLARE("PP_INTS_ENABLED", 		offsetof(struct per_proc_info *, interrupts_enabled));
 	DECLARE("UAW", 					offsetof(struct per_proc_info *, Uassist));
-	DECLARE("next_savearea", 			offsetof(struct per_proc_info *, next_savearea));
+	DECLARE("next_savearea", 		offsetof(struct per_proc_info *, next_savearea));
 	DECLARE("PP_ACTIVE_THREAD", 	offsetof(struct per_proc_info *, pp_active_thread));
-	DECLARE("PP_PREEMPT_CNT", 		offsetof(struct per_proc_info *, pp_preemption_count));
 	DECLARE("PP_SIMPLE_LOCK_CNT",	offsetof(struct per_proc_info *, pp_simple_lock_count));
 	DECLARE("PP_INTERRUPT_LVL",		offsetof(struct per_proc_info *, pp_interrupt_level));
 	DECLARE("ppbbTaskEnv", 			offsetof(struct per_proc_info *, ppbbTaskEnv));
@@ -158,30 +165,20 @@ int main(int argc, char *argv[])
 	DECLARE("pfCanNapb",			pfCanNapb);
 	DECLARE("pfCanDoze",			pfCanDoze);
 	DECLARE("pfCanDozeb",			pfCanDozeb);
-	DECLARE("pfCanDoze",			pfCanDoze);
-	DECLARE("pfCanDozeb",			pfCanDozeb);
 	DECLARE("pfThermal",			pfThermal);
 	DECLARE("pfThermalb",			pfThermalb);
 	DECLARE("pfThermInt",			pfThermInt);
 	DECLARE("pfThermIntb",			pfThermIntb);
-	DECLARE("pfWillNap",			pfWillNap);
-	DECLARE("pfWillNapb",			pfWillNapb);
-	DECLARE("pfNoMSRir",			pfNoMSRir);
-	DECLARE("pfNoMSRirb",			pfNoMSRirb);
-	DECLARE("pfNoL2PFNap",				pfNoL2PFNap);
-	DECLARE("pfNoL2PFNapb",				pfNoL2PFNapb);
 	DECLARE("pfSlowNap",				pfSlowNap);
 	DECLARE("pfSlowNapb",				pfSlowNapb);
 	DECLARE("pfNoMuMMCK",				pfNoMuMMCK);
 	DECLARE("pfNoMuMMCKb",				pfNoMuMMCKb);
-	DECLARE("pfLClck",				pfLClck);
-	DECLARE("pfLClckb",				pfLClckb);
-	DECLARE("pfL3pdet",				pfL3pdet);
-	DECLARE("pfL3pdetb",			pfL3pdetb);
-	DECLARE("pfL1i",				pfL1i);
-	DECLARE("pfL1ib",				pfL1ib);
-	DECLARE("pfL1d",				pfL1d);
-	DECLARE("pfL1db",				pfL1db);
+	DECLARE("pfNoL2PFNap",				pfNoL2PFNap);
+	DECLARE("pfNoL2PFNapb",				pfNoL2PFNapb);
+	DECLARE("pfSCOMFixUp",				pfSCOMFixUp);
+	DECLARE("pfSCOMFixUpb",				pfSCOMFixUpb);
+    DECLARE("pfHasDcba",			pfHasDcba);
+	DECLARE("pfHasDcbab",			pfHasDcbab);
 	DECLARE("pfL1fa",				pfL1fa);
 	DECLARE("pfL1fab",				pfL1fab);
 	DECLARE("pfL2",					pfL2);
@@ -190,6 +187,20 @@ int main(int argc, char *argv[])
 	DECLARE("pfL2fab",				pfL2fab);
 	DECLARE("pfL2i",				pfL2i);
 	DECLARE("pfL2ib",				pfL2ib);
+	DECLARE("pfLClck",				pfLClck);
+	DECLARE("pfLClckb",				pfLClckb);
+	DECLARE("pfWillNap",			pfWillNap);
+	DECLARE("pfWillNapb",			pfWillNapb);
+	DECLARE("pfNoMSRir",			pfNoMSRir);
+	DECLARE("pfNoMSRirb",			pfNoMSRirb);
+	DECLARE("pfL3pdet",				pfL3pdet);
+	DECLARE("pfL3pdetb",			pfL3pdetb);
+    DECLARE("pf128Byte",			pf128Byte);
+    DECLARE("pf128Byteb",			pf128Byteb);
+    DECLARE("pf32Byte",				pf32Byte);
+    DECLARE("pf32Byteb",			pf32Byteb);
+    DECLARE("pf64Bit",				pf64Bit);
+    DECLARE("pf64Bitb",				pf64Bitb);
 	DECLARE("pfL3",					pfL3);
 	DECLARE("pfL3b",				pfL3b);
 	DECLARE("pfL3fa",				pfL3fa);
@@ -208,6 +219,8 @@ int main(int argc, char *argv[])
 	DECLARE("pfHID1", 				offsetof(struct per_proc_info *, pf.pfHID1));
 	DECLARE("pfHID2", 				offsetof(struct per_proc_info *, pf.pfHID2));
 	DECLARE("pfHID3", 				offsetof(struct per_proc_info *, pf.pfHID3));
+	DECLARE("pfHID4", 				offsetof(struct per_proc_info *, pf.pfHID4));
+	DECLARE("pfHID5", 				offsetof(struct per_proc_info *, pf.pfHID5));
 	DECLARE("pfMSSCR0", 			offsetof(struct per_proc_info *, pf.pfMSSCR0));
 	DECLARE("pfMSSCR1", 			offsetof(struct per_proc_info *, pf.pfMSSCR1));
 	DECLARE("pfICTRL", 				offsetof(struct per_proc_info *, pf.pfICTRL));
@@ -216,6 +229,9 @@ int main(int argc, char *argv[])
 	DECLARE("pfl2crOriginal", 		offsetof(struct per_proc_info *, pf.l2crOriginal));
 	DECLARE("pfl3crOriginal", 		offsetof(struct per_proc_info *, pf.l3crOriginal));
 	DECLARE("pfBootConfig",			offsetof(struct per_proc_info *, pf.pfBootConfig));
+	DECLARE("pfPTEG", 				offsetof(struct per_proc_info *, pf.pfPTEG));
+	DECLARE("pfMaxVAddr", 			offsetof(struct per_proc_info *, pf.pfMaxVAddr));
+	DECLARE("pfMaxPAddr", 			offsetof(struct per_proc_info *, pf.pfMaxPAddr));
 	DECLARE("pfSize", 				sizeof(procFeatures));
 	
 	DECLARE("thrmmaxTemp", 			offsetof(struct per_proc_info *, thrm.maxTemp));
@@ -225,8 +241,52 @@ int main(int argc, char *argv[])
 	DECLARE("thrm3val", 			offsetof(struct per_proc_info *, thrm.thrm3val));
 	DECLARE("thrmSize", 			sizeof(thrmControl));
 
-	DECLARE("napStamp", 			offsetof(struct per_proc_info *, napStamp));
-	DECLARE("napTotal", 			offsetof(struct per_proc_info *, napTotal));
+	DECLARE("validSegs", 			offsetof(struct per_proc_info *, validSegs));
+	DECLARE("ppUserPmapVirt", 		offsetof(struct per_proc_info *, ppUserPmapVirt));
+	DECLARE("ppUserPmap", 			offsetof(struct per_proc_info *, ppUserPmap));
+	DECLARE("ppMapFlags", 			offsetof(struct per_proc_info *, ppMapFlags));
+	DECLARE("ppInvSeg", 			offsetof(struct per_proc_info *, ppInvSeg));
+	DECLARE("ppCurSeg", 			offsetof(struct per_proc_info *, ppCurSeg));
+	DECLARE("ppSegSteal", 			offsetof(struct per_proc_info *, ppSegSteal));
+
+	DECLARE("VMMareaPhys", 			offsetof(struct per_proc_info *, VMMareaPhys));
+	DECLARE("VMMXAFlgs", 			offsetof(struct per_proc_info *, VMMXAFlgs));
+	DECLARE("FAMintercept", 		offsetof(struct per_proc_info *, FAMintercept));
+
+	DECLARE("ppCIOmp", 				offsetof(struct per_proc_info *, ppCIOmp));
+
+	DECLARE("tempr0", 				offsetof(struct per_proc_info *, tempr0));
+	DECLARE("tempr1", 				offsetof(struct per_proc_info *, tempr1));
+	DECLARE("tempr2", 				offsetof(struct per_proc_info *, tempr2));
+	DECLARE("tempr3", 				offsetof(struct per_proc_info *, tempr3));
+	DECLARE("tempr4", 				offsetof(struct per_proc_info *, tempr4));
+	DECLARE("tempr5", 				offsetof(struct per_proc_info *, tempr5));
+	DECLARE("tempr6", 				offsetof(struct per_proc_info *, tempr6));
+	DECLARE("tempr7", 				offsetof(struct per_proc_info *, tempr7));
+	DECLARE("tempr8", 				offsetof(struct per_proc_info *, tempr8));
+	DECLARE("tempr9", 				offsetof(struct per_proc_info *, tempr9));
+	DECLARE("tempr10", 				offsetof(struct per_proc_info *, tempr10));
+	DECLARE("tempr11", 				offsetof(struct per_proc_info *, tempr11));
+	DECLARE("tempr12", 				offsetof(struct per_proc_info *, tempr12));
+	DECLARE("tempr13", 				offsetof(struct per_proc_info *, tempr13));
+	DECLARE("tempr14", 				offsetof(struct per_proc_info *, tempr14));
+	DECLARE("tempr15", 				offsetof(struct per_proc_info *, tempr15));
+	DECLARE("tempr16", 				offsetof(struct per_proc_info *, tempr16));
+	DECLARE("tempr17", 				offsetof(struct per_proc_info *, tempr17));
+	DECLARE("tempr18", 				offsetof(struct per_proc_info *, tempr18));
+	DECLARE("tempr19", 				offsetof(struct per_proc_info *, tempr19));
+	DECLARE("tempr20", 				offsetof(struct per_proc_info *, tempr20));
+	DECLARE("tempr21", 				offsetof(struct per_proc_info *, tempr21));
+	DECLARE("tempr22", 				offsetof(struct per_proc_info *, tempr22));
+	DECLARE("tempr23", 				offsetof(struct per_proc_info *, tempr23));
+	DECLARE("tempr24", 				offsetof(struct per_proc_info *, tempr24));
+	DECLARE("tempr25", 				offsetof(struct per_proc_info *, tempr25));
+	DECLARE("tempr26", 				offsetof(struct per_proc_info *, tempr26));
+	DECLARE("tempr27", 				offsetof(struct per_proc_info *, tempr27));
+	DECLARE("tempr28", 				offsetof(struct per_proc_info *, tempr28));
+	DECLARE("tempr29", 				offsetof(struct per_proc_info *, tempr29));
+	DECLARE("tempr30", 				offsetof(struct per_proc_info *, tempr30));
+	DECLARE("tempr31", 				offsetof(struct per_proc_info *, tempr31));
 
 	DECLARE("emfp0", 				offsetof(struct per_proc_info *, emfp0));
 	DECLARE("emfp1", 				offsetof(struct per_proc_info *, emfp1));
@@ -296,9 +356,92 @@ int main(int argc, char *argv[])
 	DECLARE("emvr30", 				offsetof(struct per_proc_info *, emvr30));
 	DECLARE("emvr31", 				offsetof(struct per_proc_info *, emvr31));
 	DECLARE("empadvr", 				offsetof(struct per_proc_info *, empadvr));
+	DECLARE("skipListPrev", 		offsetof(struct per_proc_info *, skipListPrev));
 	DECLARE("ppSize",				sizeof(struct per_proc_info));
 	DECLARE("patcharea", 			offsetof(struct per_proc_info *, patcharea));
 
+	DECLARE("hwCounts",				offsetof(struct per_proc_info *, hwCtr));
+	DECLARE("hwInVains",			offsetof(struct per_proc_info *, hwCtr.hwInVains));
+	DECLARE("hwResets",				offsetof(struct per_proc_info *, hwCtr.hwResets));
+	DECLARE("hwMachineChecks",		offsetof(struct per_proc_info *, hwCtr.hwMachineChecks));
+	DECLARE("hwDSIs",				offsetof(struct per_proc_info *, hwCtr.hwDSIs));
+	DECLARE("hwISIs",				offsetof(struct per_proc_info *, hwCtr.hwISIs));
+	DECLARE("hwExternals",			offsetof(struct per_proc_info *, hwCtr.hwExternals));
+	DECLARE("hwAlignments",			offsetof(struct per_proc_info *, hwCtr.hwAlignments));
+	DECLARE("hwPrograms",			offsetof(struct per_proc_info *, hwCtr.hwPrograms));
+	DECLARE("hwFloatPointUnavailable",	offsetof(struct per_proc_info *, hwCtr.hwFloatPointUnavailable));
+	DECLARE("hwDecrementers",		offsetof(struct per_proc_info *, hwCtr.hwDecrementers));
+	DECLARE("hwIOErrors",			offsetof(struct per_proc_info *, hwCtr.hwIOErrors));
+	DECLARE("hwrsvd0",				offsetof(struct per_proc_info *, hwCtr.hwrsvd0));
+	DECLARE("hwSystemCalls",		offsetof(struct per_proc_info *, hwCtr.hwSystemCalls));
+	DECLARE("hwTraces",				offsetof(struct per_proc_info *, hwCtr.hwTraces));
+	DECLARE("hwFloatingPointAssists",	offsetof(struct per_proc_info *, hwCtr.hwFloatingPointAssists));
+	DECLARE("hwPerformanceMonitors",	offsetof(struct per_proc_info *, hwCtr.hwPerformanceMonitors));
+	DECLARE("hwAltivecs",			offsetof(struct per_proc_info *, hwCtr.hwAltivecs));
+	DECLARE("hwrsvd1",				offsetof(struct per_proc_info *, hwCtr.hwrsvd1));
+	DECLARE("hwrsvd2",				offsetof(struct per_proc_info *, hwCtr.hwrsvd2));
+	DECLARE("hwrsvd3",				offsetof(struct per_proc_info *, hwCtr.hwrsvd3));
+	DECLARE("hwInstBreakpoints",	offsetof(struct per_proc_info *, hwCtr.hwInstBreakpoints));
+	DECLARE("hwSystemManagements",	offsetof(struct per_proc_info *, hwCtr.hwSystemManagements));
+	DECLARE("hwAltivecAssists",		offsetof(struct per_proc_info *, hwCtr.hwAltivecAssists));
+	DECLARE("hwThermal",			offsetof(struct per_proc_info *, hwCtr.hwThermal));
+	DECLARE("hwrsvd5",				offsetof(struct per_proc_info *, hwCtr.hwrsvd5));
+	DECLARE("hwrsvd6",				offsetof(struct per_proc_info *, hwCtr.hwrsvd6));
+	DECLARE("hwrsvd7",				offsetof(struct per_proc_info *, hwCtr.hwrsvd7));
+	DECLARE("hwrsvd8",				offsetof(struct per_proc_info *, hwCtr.hwrsvd8));
+	DECLARE("hwrsvd9",				offsetof(struct per_proc_info *, hwCtr.hwrsvd9));
+	DECLARE("hwrsvd10",				offsetof(struct per_proc_info *, hwCtr.hwrsvd10));
+	DECLARE("hwrsvd11",				offsetof(struct per_proc_info *, hwCtr.hwrsvd11));
+	DECLARE("hwrsvd12",				offsetof(struct per_proc_info *, hwCtr.hwrsvd12));
+	DECLARE("hwrsvd13",				offsetof(struct per_proc_info *, hwCtr.hwrsvd13));
+	DECLARE("hwTrace601",			offsetof(struct per_proc_info *, hwCtr.hwTrace601));
+	DECLARE("hwSIGPs",				offsetof(struct per_proc_info *, hwCtr.hwSIGPs));
+	DECLARE("hwPreemptions",		offsetof(struct per_proc_info *, hwCtr.hwPreemptions));
+	DECLARE("hwContextSwitchs",		offsetof(struct per_proc_info *, hwCtr.hwContextSwitchs));
+	DECLARE("hwShutdowns",			offsetof(struct per_proc_info *, hwCtr.hwShutdowns));
+	DECLARE("hwChokes",				offsetof(struct per_proc_info *, hwCtr.hwChokes));
+	DECLARE("hwDataSegments",		offsetof(struct per_proc_info *, hwCtr.hwDataSegments));
+	DECLARE("hwInstructionSegments",	offsetof(struct per_proc_info *, hwCtr.hwInstructionSegments));
+	DECLARE("hwSoftPatches",		offsetof(struct per_proc_info *, hwCtr.hwSoftPatches));
+	DECLARE("hwMaintenances",		offsetof(struct per_proc_info *, hwCtr.hwMaintenances));
+	DECLARE("hwInstrumentations",	offsetof(struct per_proc_info *, hwCtr.hwInstrumentations));
+	DECLARE("hwRedrives",			offsetof(struct per_proc_info *, hwCtr.hwRedrives));
+	DECLARE("hwSteals",				offsetof(struct per_proc_info *, hwCtr.hwSteals));
+
+	DECLARE("hwMckHang",			offsetof(struct per_proc_info *, hwCtr.hwMckHang));
+	DECLARE("hwMckSLBPE",			offsetof(struct per_proc_info *, hwCtr.hwMckSLBPE));
+	DECLARE("hwMckTLBPE",			offsetof(struct per_proc_info *, hwCtr.hwMckTLBPE));
+	DECLARE("hwMckERCPE",			offsetof(struct per_proc_info *, hwCtr.hwMckERCPE));
+	DECLARE("hwMckL1DPE",			offsetof(struct per_proc_info *, hwCtr.hwMckL1DPE));
+	DECLARE("hwMckL1TPE",			offsetof(struct per_proc_info *, hwCtr.hwMckL1TPE));
+	DECLARE("hwMckUE",				offsetof(struct per_proc_info *, hwCtr.hwMckUE));
+	DECLARE("hwMckIUE",				offsetof(struct per_proc_info *, hwCtr.hwMckIUE));
+	DECLARE("hwMckIUEr",			offsetof(struct per_proc_info *, hwCtr.hwMckIUEr));
+	DECLARE("hwMckDUE",				offsetof(struct per_proc_info *, hwCtr.hwMckDUE));
+	DECLARE("hwMckDTW",				offsetof(struct per_proc_info *, hwCtr.hwMckDTW));
+	DECLARE("hwMckUnk",				offsetof(struct per_proc_info *, hwCtr.hwMckUnk));
+	DECLARE("hwMckExt",				offsetof(struct per_proc_info *, hwCtr.hwMckExt));
+	DECLARE("hwMckICachePE",		offsetof(struct per_proc_info *, hwCtr.hwMckICachePE));
+	DECLARE("hwMckITagPE",			offsetof(struct per_proc_info *, hwCtr.hwMckITagPE));
+	DECLARE("hwMckIEratPE",			offsetof(struct per_proc_info *, hwCtr.hwMckIEratPE));
+	DECLARE("hwMckDEratPE",			offsetof(struct per_proc_info *, hwCtr.hwMckDEratPE));
+
+	DECLARE("napStamp", 			offsetof(struct per_proc_info *, hwCtr.napStamp));
+	DECLARE("napTotal", 			offsetof(struct per_proc_info *, hwCtr.napTotal));
+
+	DECLARE("patchAddr",			offsetof(struct patch_entry *, addr));
+	DECLARE("patchData",			offsetof(struct patch_entry *, data));
+	DECLARE("patchType",			offsetof(struct patch_entry *, type));
+	DECLARE("patchValue",			offsetof(struct patch_entry *, value));
+	DECLARE("peSize", 				sizeof(patch_entry_t));
+	DECLARE("PATCH_PROCESSOR",		PATCH_PROCESSOR);
+	DECLARE("PATCH_FEATURE",		PATCH_FEATURE);
+	DECLARE("PATCH_TABLE_SIZE",		PATCH_TABLE_SIZE);
+	DECLARE("PatchExt32",			PatchExt32);
+	DECLARE("PatchExt32b",			PatchExt32b);
+	DECLARE("PatchLwsync",			PatchLwsync);
+	DECLARE("PatchLwsyncb",			PatchLwsyncb);
+
 	DECLARE("RESETHANDLER_TYPE", 	offsetof(struct resethandler *, type));
 	DECLARE("RESETHANDLER_CALL", 	offsetof(struct resethandler *, call_paddr));
 	DECLARE("RESETHANDLER_ARG", 	offsetof(struct resethandler *, arg__paddr));
@@ -347,9 +490,11 @@ int main(int argc, char *argv[])
 	DECLARE("FPUsave",				offsetof(struct facility_context *,FPUsave));
 	DECLARE("FPUlevel",				offsetof(struct facility_context *,FPUlevel));
 	DECLARE("FPUcpu",				offsetof(struct facility_context *,FPUcpu));
+	DECLARE("FPUsync",				offsetof(struct facility_context *,FPUsync));
 	DECLARE("VMXsave",				offsetof(struct facility_context *,VMXsave));
 	DECLARE("VMXlevel",				offsetof(struct facility_context *,VMXlevel));
 	DECLARE("VMXcpu",				offsetof(struct facility_context *,VMXcpu));
+	DECLARE("VMXsync",				offsetof(struct facility_context *,VMXsync));
 	DECLARE("facAct",				offsetof(struct facility_context *,facAct));
 
 	/* Values from vmachmon.h */
@@ -367,8 +512,25 @@ int main(int argc, char *argv[])
 	DECLARE("kVmmGetFloatState",	kVmmGetFloatState);
 	DECLARE("kVmmGetVectorState",	kVmmGetVectorState);
 	DECLARE("kVmmSetTimer", 		kVmmSetTimer);
+	DECLARE("kVmmGetTimer", 		kVmmGetTimer);
 	DECLARE("kVmmExecuteVM", 		kVmmExecuteVM);
 	DECLARE("kVmmProtectPage", 		kVmmProtectPage);
+	DECLARE("kVmmMapList", 			kVmmMapList);
+	DECLARE("kVmmUnmapList", 		kVmmUnmapList);
+	DECLARE("kVmmSetXA", 			kVmmSetXA);
+	DECLARE("kVmmGetXA", 			kVmmGetXA);
+	DECLARE("kVmmMapPage64", 		kVmmMapPage64);
+	DECLARE("kVmmGetPageMapping64",	kVmmGetPageMapping64);
+	DECLARE("kVmmUnmapPage64", 		kVmmUnmapPage64);
+	DECLARE("kVmmGetPageDirtyFlag64", 	kVmmGetPageDirtyFlag64);
+	DECLARE("kVmmMapExecute64", 	kVmmMapExecute64);
+	DECLARE("kVmmProtectExecute64", kVmmProtectExecute64);
+	DECLARE("kVmmMapList64", 		kVmmMapList64);
+	DECLARE("kVmmUnmapList64", 		kVmmUnmapList64);
+	DECLARE("kvmmExitToHost",		kvmmExitToHost);
+	DECLARE("kvmmResumeGuest",		kvmmResumeGuest);
+	DECLARE("kvmmGetGuestRegister",	kvmmGetGuestRegister);
+	DECLARE("kvmmSetGuestRegister",	kvmmSetGuestRegister);
 
 	DECLARE("kVmmReturnNull",		kVmmReturnNull);
 	DECLARE("kVmmStopped",			kVmmStopped);
@@ -379,6 +541,7 @@ int main(int argc, char *argv[])
 	DECLARE("kVmmReturnProgramException",	kVmmReturnProgramException);
 	DECLARE("kVmmReturnSystemCall",		kVmmReturnSystemCall);
 	DECLARE("kVmmReturnTraceException",	kVmmReturnTraceException);
+	DECLARE("kVmmInvalidAdSpace",	kVmmInvalidAdSpace);
 
 	DECLARE("kVmmProtXtnd",			kVmmProtXtnd);
 	DECLARE("kVmmProtNARW",			kVmmProtNARW);
@@ -387,88 +550,176 @@ int main(int argc, char *argv[])
 	DECLARE("kVmmProtRORO",			kVmmProtRORO);
 	
 	DECLARE("vmmFlags",				offsetof(struct vmmCntrlEntry *, vmmFlags));
+	DECLARE("vmmXAFlgs",			offsetof(struct vmmCntrlEntry *, vmmXAFlgs));
+	DECLARE("vmmPmap",				offsetof(struct vmmCntrlEntry *, vmmPmap));
 	DECLARE("vmmInUseb",			vmmInUseb);
 	DECLARE("vmmInUse",				vmmInUse);
-	DECLARE("vmmPmap",				offsetof(struct vmmCntrlEntry *, vmmPmap));
 	DECLARE("vmmContextKern",		offsetof(struct vmmCntrlEntry *, vmmContextKern));
+	DECLARE("vmmContextPhys",		offsetof(struct vmmCntrlEntry *, vmmContextPhys));
 	DECLARE("vmmContextUser",		offsetof(struct vmmCntrlEntry *, vmmContextUser));
 	DECLARE("vmmFacCtx",			offsetof(struct vmmCntrlEntry *, vmmFacCtx));
-	DECLARE("vmmLastMap",			offsetof(struct vmmCntrlEntry *, vmmLastMap));
+	DECLARE("vmmLastMap",			offsetof(struct vmmCntrlTable *, vmmLastMap));
+	DECLARE("vmmGFlags",			offsetof(struct vmmCntrlTable *, vmmGFlags));
+	DECLARE("vmmc",					offsetof(struct vmmCntrlTable *, vmmc));
+	DECLARE("vmmAdsp",				offsetof(struct vmmCntrlTable *, vmmAdsp));
+	DECLARE("vmmLastAdSp",			vmmLastAdSp);
+	DECLARE("vmmFAMintercept",		offsetof(struct vmmCntrlEntry *, vmmFAMintercept));
 	DECLARE("vmmCEntrySize",		sizeof(struct vmmCntrlEntry));
-	DECLARE("kVmmMaxContextsPerThread",		kVmmMaxContextsPerThread);
+	DECLARE("kVmmMaxContexts",		kVmmMaxContexts);
 	
 	DECLARE("interface_version",	offsetof(struct vmm_state_page_t *, interface_version));
 	DECLARE("thread_index",			offsetof(struct vmm_state_page_t *, thread_index));
 	DECLARE("vmmStat",				offsetof(struct vmm_state_page_t *, vmmStat));
 	DECLARE("vmmCntrl",				offsetof(struct vmm_state_page_t *, vmmCntrl));
+	DECLARE("vmm_proc_state",		offsetof(struct vmm_state_page_t *, vmm_proc_state));
+
 	DECLARE("return_code",			offsetof(struct vmm_state_page_t *, return_code));
+
+	DECLARE("return_params",		offsetof(struct vmm_state_page_t *, vmmRet.vmmrp32.return_params));
+	DECLARE("return_paramsX",		offsetof(struct vmm_state_page_t *, vmmRet.vmmrp64.return_params));
+
+#if 0
 	DECLARE("return_params",		offsetof(struct vmm_state_page_t *, return_params));
 	DECLARE("vmm_proc_state",		offsetof(struct vmm_state_page_t *, vmm_proc_state));
-	DECLARE("return_params",		offsetof(struct vmm_state_page_t *, return_params));
+#endif
 	DECLARE("vmmppcVRs",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcVRs));
 	DECLARE("vmmppcVSCR",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcVSCR));
-	DECLARE("vmmppcVSCRshadow",		offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcVSCRshadow));
 	DECLARE("vmmppcFPRs",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcFPRs));
 	DECLARE("vmmppcFPSCR",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcFPSCR));
-	DECLARE("vmmppcFPSCRshadow",	offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcFPSCRshadow));
-
-	DECLARE("vmmppcpc",				offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcPC));
-	DECLARE("vmmppcmsr",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcMSR));
-	DECLARE("vmmppcr0",				offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcGPRs+0x00));
-	DECLARE("vmmppcr1",				offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcGPRs+0x04));
-	DECLARE("vmmppcr2",				offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcGPRs+0x08));
-	DECLARE("vmmppcr3",				offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcGPRs+0x0C));
-	DECLARE("vmmppcr4",				offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcGPRs+0x10));
-	DECLARE("vmmppcr5",				offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcGPRs+0x14));
-
-	DECLARE("vmmppcr6",				offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcGPRs+0x18));
-	DECLARE("vmmppcr7",				offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcGPRs+0x1C));
-	DECLARE("vmmppcr8",				offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcGPRs+0x20));
-	DECLARE("vmmppcr9",				offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcGPRs+0x24));
-	DECLARE("vmmppcr10",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcGPRs+0x28));
-	DECLARE("vmmppcr11",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcGPRs+0x2C));
-	DECLARE("vmmppcr12",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcGPRs+0x30));
-	DECLARE("vmmppcr13",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcGPRs+0x34));
-
-	DECLARE("vmmppcr14",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcGPRs+0x38));
-	DECLARE("vmmppcr15",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcGPRs+0x3C));
-	DECLARE("vmmppcr16",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcGPRs+0x40));
-	DECLARE("vmmppcr17",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcGPRs+0x44));
-	DECLARE("vmmppcr18",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcGPRs+0x48));
-	DECLARE("vmmppcr19",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcGPRs+0x4C));
-	DECLARE("vmmppcr20",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcGPRs+0x50));
-	DECLARE("vmmppcr21",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcGPRs+0x54));
-
-	DECLARE("vmmppcr22",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcGPRs+0x58));
-	DECLARE("vmmppcr23",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcGPRs+0x5C));
-	DECLARE("vmmppcr24",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcGPRs+0x60));
-	DECLARE("vmmppcr25",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcGPRs+0x64));
-	DECLARE("vmmppcr26",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcGPRs+0x68));
-	DECLARE("vmmppcr27",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcGPRs+0x6C));
-	DECLARE("vmmppcr28",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcGPRs+0x70));
-	DECLARE("vmmppcr29",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcGPRs+0x74));
-
-	DECLARE("vmmppcr30",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcGPRs+0x78));
-	DECLARE("vmmppcr31",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcGPRs+0x7C));
-	DECLARE("vmmppccr",				offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcCR));
-	DECLARE("vmmppcxer",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcXER));
-	DECLARE("vmmppclr",				offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcLR));
-	DECLARE("vmmppcctr",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcCTR));
-	DECLARE("vmmppcmq",				offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcMQ));
-	DECLARE("vmmppcvrsave",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcVRSave));	
+
+	DECLARE("vmmppcpc",				offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs32.ppcPC));
+	DECLARE("vmmppcmsr",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs32.ppcMSR));
+	DECLARE("vmmppcr0",				offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs32.ppcGPRs+0x00));
+	DECLARE("vmmppcr1",				offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs32.ppcGPRs+0x04));
+	DECLARE("vmmppcr2",				offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs32.ppcGPRs+0x08));
+	DECLARE("vmmppcr3",				offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs32.ppcGPRs+0x0C));
+	DECLARE("vmmppcr4",				offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs32.ppcGPRs+0x10));
+	DECLARE("vmmppcr5",				offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs32.ppcGPRs+0x14));
+
+	DECLARE("vmmppcr6",				offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs32.ppcGPRs+0x18));
+	DECLARE("vmmppcr7",				offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs32.ppcGPRs+0x1C));
+	DECLARE("vmmppcr8",				offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs32.ppcGPRs+0x20));
+	DECLARE("vmmppcr9",				offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs32.ppcGPRs+0x24));
+	DECLARE("vmmppcr10",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs32.ppcGPRs+0x28));
+	DECLARE("vmmppcr11",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs32.ppcGPRs+0x2C));
+	DECLARE("vmmppcr12",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs32.ppcGPRs+0x30));
+	DECLARE("vmmppcr13",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs32.ppcGPRs+0x34));
+
+	DECLARE("vmmppcr14",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs32.ppcGPRs+0x38));
+	DECLARE("vmmppcr15",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs32.ppcGPRs+0x3C));
+	DECLARE("vmmppcr16",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs32.ppcGPRs+0x40));
+	DECLARE("vmmppcr17",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs32.ppcGPRs+0x44));
+	DECLARE("vmmppcr18",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs32.ppcGPRs+0x48));
+	DECLARE("vmmppcr19",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs32.ppcGPRs+0x4C));
+	DECLARE("vmmppcr20",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs32.ppcGPRs+0x50));
+	DECLARE("vmmppcr21",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs32.ppcGPRs+0x54));
+
+	DECLARE("vmmppcr22",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs32.ppcGPRs+0x58));
+	DECLARE("vmmppcr23",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs32.ppcGPRs+0x5C));
+	DECLARE("vmmppcr24",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs32.ppcGPRs+0x60));
+	DECLARE("vmmppcr25",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs32.ppcGPRs+0x64));
+	DECLARE("vmmppcr26",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs32.ppcGPRs+0x68));
+	DECLARE("vmmppcr27",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs32.ppcGPRs+0x6C));
+	DECLARE("vmmppcr28",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs32.ppcGPRs+0x70));
+	DECLARE("vmmppcr29",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs32.ppcGPRs+0x74));
+
+	DECLARE("vmmppcr30",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs32.ppcGPRs+0x78));
+	DECLARE("vmmppcr31",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs32.ppcGPRs+0x7C));
+	DECLARE("vmmppccr",				offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs32.ppcCR));
+	DECLARE("vmmppcxer",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs32.ppcXER));
+	DECLARE("vmmppclr",				offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs32.ppcLR));
+	DECLARE("vmmppcctr",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs32.ppcCTR));
+	DECLARE("vmmppcmq",				offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs32.ppcMQ));
+	DECLARE("vmmppcvrsave",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs32.ppcVRSave));	
+
+	DECLARE("vmmppcXpc",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs64.ppcPC));
+	DECLARE("vmmppcXmsr",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs64.ppcMSR));
+	DECLARE("vmmppcXr0",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs64.ppcGPRs+0x00));
+	DECLARE("vmmppcXr1",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs64.ppcGPRs+0x08));
+	DECLARE("vmmppcXr2",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs64.ppcGPRs+0x10));
+	DECLARE("vmmppcXr3",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs64.ppcGPRs+0x18));
+	DECLARE("vmmppcXr4",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs64.ppcGPRs+0x20));
+	DECLARE("vmmppcXr5",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs64.ppcGPRs+0x28));
+
+	DECLARE("vmmppcXr6",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs64.ppcGPRs+0x30));
+	DECLARE("vmmppcXr7",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs64.ppcGPRs+0x38));
+	DECLARE("vmmppcXr8",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs64.ppcGPRs+0x40));
+	DECLARE("vmmppcXr9",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs64.ppcGPRs+0x48));
+	DECLARE("vmmppcXr10",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs64.ppcGPRs+0x50));
+	DECLARE("vmmppcXr11",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs64.ppcGPRs+0x58));
+	DECLARE("vmmppcXr12",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs64.ppcGPRs+0x60));
+	DECLARE("vmmppcXr13",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs64.ppcGPRs+0x68));
+
+	DECLARE("vmmppcXr14",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs64.ppcGPRs+0x70));
+	DECLARE("vmmppcXr15",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs64.ppcGPRs+0x78));
+	DECLARE("vmmppcXr16",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs64.ppcGPRs+0x80));
+	DECLARE("vmmppcXr17",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs64.ppcGPRs+0x88));
+	DECLARE("vmmppcXr18",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs64.ppcGPRs+0x90));
+	DECLARE("vmmppcXr19",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs64.ppcGPRs+0x98));
+	DECLARE("vmmppcXr20",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs64.ppcGPRs+0xA0));
+	DECLARE("vmmppcXr21",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs64.ppcGPRs+0xA8));
+
+	DECLARE("vmmppcXr22",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs64.ppcGPRs+0xB0));
+	DECLARE("vmmppcXr23",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs64.ppcGPRs+0xB8));
+	DECLARE("vmmppcXr24",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs64.ppcGPRs+0xC0));
+	DECLARE("vmmppcXr25",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs64.ppcGPRs+0xC8));
+	DECLARE("vmmppcXr26",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs64.ppcGPRs+0xD0));
+	DECLARE("vmmppcXr27",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs64.ppcGPRs+0xD8));
+	DECLARE("vmmppcXr28",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs64.ppcGPRs+0xE0));
+	DECLARE("vmmppcXr29",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs64.ppcGPRs+0xE8));
+
+	DECLARE("vmmppcXr30",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs64.ppcGPRs+0xF0));
+	DECLARE("vmmppcXr31",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs64.ppcGPRs+0xF8));
+	DECLARE("vmmppcXcr",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs64.ppcCR));
+	DECLARE("vmmppcXxer",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs64.ppcXER));
+	DECLARE("vmmppcXlr",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs64.ppcLR));
+	DECLARE("vmmppcXctr",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs64.ppcCTR));
+	DECLARE("vmmppcXvrsave",		offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcRegs.ppcRegs64.ppcVRSave));	
 
 	DECLARE("vmmppcvscr",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcVSCR+0x00));	
 	DECLARE("vmmppcfpscrpad",		offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcFPSCR));
 	DECLARE("vmmppcfpscr",			offsetof(struct vmm_state_page_t *, vmm_proc_state.ppcFPSCR+4));
 
+	DECLARE("famguestr0",			offsetof(struct vmm_state_page_t *, vmm_fastassist_state.vmmfs32.guest_register));
+	DECLARE("famguestr1",			offsetof(struct vmm_state_page_t *, vmm_fastassist_state.vmmfs32.guest_register+0x4));
+	DECLARE("famguestr2",			offsetof(struct vmm_state_page_t *, vmm_fastassist_state.vmmfs32.guest_register+0x8));
+	DECLARE("famguestr3",			offsetof(struct vmm_state_page_t *, vmm_fastassist_state.vmmfs32.guest_register+0xC));
+	DECLARE("famguestr4",			offsetof(struct vmm_state_page_t *, vmm_fastassist_state.vmmfs32.guest_register+0x10));
+	DECLARE("famguestr5",			offsetof(struct vmm_state_page_t *, vmm_fastassist_state.vmmfs32.guest_register+0x14));
+	DECLARE("famguestr6",			offsetof(struct vmm_state_page_t *, vmm_fastassist_state.vmmfs32.guest_register+0x18));
+	DECLARE("famguestr7",			offsetof(struct vmm_state_page_t *, vmm_fastassist_state.vmmfs32.guest_register+0x1C));
+	DECLARE("famguestpc",			offsetof(struct vmm_state_page_t *, vmm_fastassist_state.vmmfs32.guest_pc));
+	DECLARE("famguestmsr",			offsetof(struct vmm_state_page_t *, vmm_fastassist_state.vmmfs32.guest_msr));
+	DECLARE("famdispcode",			offsetof(struct vmm_state_page_t *, vmm_fastassist_state.vmmfs32.fastassist_dispatch_code));
+	DECLARE("famrefcon",			offsetof(struct vmm_state_page_t *, vmm_fastassist_state.vmmfs32.fastassist_refcon));
+	DECLARE("famparam",				offsetof(struct vmm_state_page_t *, vmm_fastassist_state.vmmfs32.fastassist_parameter));
+	DECLARE("famhandler",			offsetof(struct vmm_state_page_t *, vmm_fastassist_state.vmmfs32.fastassist_dispatch));
+	DECLARE("famintercepts",		offsetof(struct vmm_state_page_t *, vmm_fastassist_state.vmmfs32.fastassist_intercepts));
+
+	DECLARE("famguestXr0",			offsetof(struct vmm_state_page_t *, vmm_fastassist_state.vmmfs64.guest_register));
+	DECLARE("famguestXr1",			offsetof(struct vmm_state_page_t *, vmm_fastassist_state.vmmfs64.guest_register+0x8));
+	DECLARE("famguestXr2",			offsetof(struct vmm_state_page_t *, vmm_fastassist_state.vmmfs64.guest_register+0x10));
+	DECLARE("famguestXr3",			offsetof(struct vmm_state_page_t *, vmm_fastassist_state.vmmfs64.guest_register+0x18));
+	DECLARE("famguestXr4",			offsetof(struct vmm_state_page_t *, vmm_fastassist_state.vmmfs64.guest_register+0x20));
+	DECLARE("famguestXr5",			offsetof(struct vmm_state_page_t *, vmm_fastassist_state.vmmfs64.guest_register+0x28));
+	DECLARE("famguestXr6",			offsetof(struct vmm_state_page_t *, vmm_fastassist_state.vmmfs64.guest_register+0x30));
+	DECLARE("famguestXr7",			offsetof(struct vmm_state_page_t *, vmm_fastassist_state.vmmfs64.guest_register+0x38));
+	DECLARE("famguestXpc",			offsetof(struct vmm_state_page_t *, vmm_fastassist_state.vmmfs64.guest_pc));
+	DECLARE("famguestXmsr",			offsetof(struct vmm_state_page_t *, vmm_fastassist_state.vmmfs64.guest_msr));
+	DECLARE("famdispcodeX",			offsetof(struct vmm_state_page_t *, vmm_fastassist_state.vmmfs64.fastassist_dispatch_code));
+	DECLARE("famrefconX",			offsetof(struct vmm_state_page_t *, vmm_fastassist_state.vmmfs64.fastassist_refcon));
+	DECLARE("famparamX",				offsetof(struct vmm_state_page_t *, vmm_fastassist_state.vmmfs64.fastassist_parameter));
+	DECLARE("famhandlerX",			offsetof(struct vmm_state_page_t *, vmm_fastassist_state.vmmfs64.fastassist_dispatch));
+	DECLARE("faminterceptsX",		offsetof(struct vmm_state_page_t *, vmm_fastassist_state.vmmfs64.fastassist_intercepts));
+
 	DECLARE("vmmFloatCngd",			vmmFloatCngd);
 	DECLARE("vmmFloatCngdb",		vmmFloatCngdb);
 	DECLARE("vmmVectCngd",			vmmVectCngd);
 	DECLARE("vmmVectCngdb",			vmmVectCngdb);
 	DECLARE("vmmTimerPop",			vmmTimerPop);
 	DECLARE("vmmTimerPopb",			vmmTimerPopb);
-	DECLARE("vmmMapDone",			vmmMapDone);
-	DECLARE("vmmMapDoneb",			vmmMapDoneb);
+	DECLARE("vmmFAMmode",			vmmFAMmode);
+	DECLARE("vmmFAMmodeb",			vmmFAMmodeb);
 	DECLARE("vmmSpfSave",			vmmSpfSave);
 	DECLARE("vmmSpfSaveb",			vmmSpfSaveb);
 	DECLARE("vmmFloatLoad",			vmmFloatLoad);
@@ -485,6 +736,11 @@ int main(int argc, char *argv[])
 	DECLARE("vmmXStopb",			vmmXStopb);
 	DECLARE("vmmKey",				vmmKey);
 	DECLARE("vmmKeyb",				vmmKeyb);
+	DECLARE("vmmFamSet",			vmmFamSet);
+	DECLARE("vmmFamSetb",			vmmFamSetb);
+	DECLARE("vmmFamEna",			vmmFamEna);
+	DECLARE("vmmFamEnab",			vmmFamEnab);
+	DECLARE("vmm64Bit",				vmm64Bit);
 
 	/* values from kern/task.h */
 	DECLARE("TASK_SYSCALLS_MACH",
@@ -496,13 +752,50 @@ int main(int argc, char *argv[])
 	DECLARE("VMMAP_PMAP",	offsetof(struct vm_map *, pmap));
 
 	/* values from machine/pmap.h */
-	DECLARE("PMAP_SPACE",	offsetof(struct pmap *, space));
-	DECLARE("PMAP_BMAPS",	offsetof(struct pmap *, bmaps));
-	DECLARE("PMAP_PMAPVR",	offsetof(struct pmap *, pmapvr));
-	DECLARE("PMAP_VFLAGS",	offsetof(struct pmap *, vflags));
-	DECLARE("PMAP_USAGE",	offsetof(struct pmap *, pmapUsage));
-	DECLARE("PMAP_SEGS",	offsetof(struct pmap *, pmapSegs));
-	DECLARE("PMAP_SIZE",	pmapSize);
+	DECLARE("pmapSpace",			offsetof(struct pmap *, space));
+	DECLARE("spaceNum",				offsetof(struct pmap *, spaceNum));
+	DECLARE("pmapSXlk",				offsetof(struct pmap *, pmapSXlk));
+	DECLARE("pmapCCtl",				offsetof(struct pmap *, pmapCCtl));
+    DECLARE("pmapCCtlVal",			pmapCCtlVal);
+    DECLARE("pmapCCtlLck",			pmapCCtlLck);
+    DECLARE("pmapCCtlLckb",			pmapCCtlLckb);
+    DECLARE("pmapCCtlGen",			pmapCCtlGen);
+    DECLARE("pmapSegCacheCnt",		pmapSegCacheCnt);
+    DECLARE("pmapSegCacheUse",		pmapSegCacheUse);
+	DECLARE("pmapvr",				offsetof(struct pmap *, pmapvr));
+	DECLARE("pmapFlags",			offsetof(struct pmap *, pmapFlags));
+    DECLARE("pmapKeys",				pmapKeys);
+    DECLARE("pmapKeyDef",			pmapKeyDef);
+	DECLARE("pmapSCSubTag",			offsetof(struct pmap *, pmapSCSubTag));
+	DECLARE("pmapSegCache",			offsetof(struct pmap *, pmapSegCache));
+	DECLARE("pmapCurLists",			offsetof(struct pmap *, pmapCurLists));
+	DECLARE("pmapRandNum",			offsetof(struct pmap *, pmapRandNum));
+	DECLARE("pmapSkipLists",		offsetof(struct pmap *, pmapSkipLists));
+	DECLARE("pmapSearchVisits",		offsetof(struct pmap *, pmapSearchVisits));
+	DECLARE("pmapSearchCnt",		offsetof(struct pmap *, pmapSearchCnt));
+	DECLARE("pmapSize",				pmapSize);
+    DECLARE("kSkipListFanoutShift",	kSkipListFanoutShift);
+    DECLARE("kSkipListMaxLists",	kSkipListMaxLists);
+    DECLARE("invalSpace",			invalSpace);
+
+	DECLARE("sgcESID",				offsetof(struct sgc *, sgcESID));
+	DECLARE("sgcESmsk",				sgcESmsk);
+	DECLARE("sgcVSID",				offsetof(struct sgc *, sgcVSID));
+	DECLARE("sgcVSmsk",				sgcVSmsk);
+	DECLARE("sgcVSKeys",			sgcVSKeys);
+	DECLARE("sgcVSKeyUsr",			sgcVSKeyUsr);
+	DECLARE("sgcVSNoEx",			sgcVSNoEx);
+	DECLARE("pmapPAddr",			offsetof(struct pmapTransTab *, pmapPAddr));
+	DECLARE("pmapVAddr",			offsetof(struct pmapTransTab *, pmapVAddr));
+	DECLARE("pmapTransSize",		sizeof(pmapTransTab));
+	DECLARE("pmapResidentCnt",		offsetof(struct pmap *, stats.resident_count));
+
+	DECLARE("maxAdrSp",				maxAdrSp);
+	DECLARE("maxAdrSpb",			maxAdrSpb);
+
+	/* values from kern/processor.h */
+	DECLARE("psthreads",			offsetof(struct processor_set *, threads));
+	DECLARE("psthreadcnt",			offsetof(struct processor_set *, thread_count));
 
 	/* values from kern/processor.h */
 	DECLARE("psthreads",	offsetof(struct processor_set *, threads));
@@ -524,13 +817,6 @@ int main(int argc, char *argv[])
 	
 	DECLARE("PPCcallmax", sizeof(PPCcalls));
 
-	/* values from cpu_data.h */
-	DECLARE("CPU_ACTIVE_THREAD", offsetof(cpu_data_t *, active_thread));
-	DECLARE("CPU_PREEMPTION_LEVEL", offsetof(cpu_data_t *, preemption_level));
-	DECLARE("CPU_SIMPLE_LOCK_COUNT",
-		offsetof(cpu_data_t *, simple_lock_count));
-	DECLARE("CPU_INTERRUPT_LEVEL",offsetof(cpu_data_t *, interrupt_level));
-
 	/* Misc values used by assembler */
 	DECLARE("AST_ALL", AST_ALL);
 	DECLARE("AST_URGENT", AST_URGENT);
@@ -566,6 +852,8 @@ int main(int argc, char *argv[])
 	DECLARE("LTR_srr0",	offsetof(struct LowTraceRecord *, LTR_srr0));
 	DECLARE("LTR_srr1",	offsetof(struct LowTraceRecord *, LTR_srr1));
 	DECLARE("LTR_dar",	offsetof(struct LowTraceRecord *, LTR_dar));
+	DECLARE("LTR_dsisr",	offsetof(struct LowTraceRecord *, LTR_dsisr));
+	DECLARE("LTR_rsvd0",	offsetof(struct LowTraceRecord *, LTR_rsvd0));
 	DECLARE("LTR_save",	offsetof(struct LowTraceRecord *, LTR_save));
 	DECLARE("LTR_lr",	offsetof(struct LowTraceRecord *, LTR_lr));
 	DECLARE("LTR_ctr",	offsetof(struct LowTraceRecord *, LTR_ctr));
@@ -575,6 +863,7 @@ int main(int argc, char *argv[])
 	DECLARE("LTR_r3",	offsetof(struct LowTraceRecord *, LTR_r3));
 	DECLARE("LTR_r4",	offsetof(struct LowTraceRecord *, LTR_r4));
 	DECLARE("LTR_r5",	offsetof(struct LowTraceRecord *, LTR_r5));
+	DECLARE("LTR_r6",	offsetof(struct LowTraceRecord *, LTR_r6));
 	DECLARE("LTR_size",	sizeof(struct LowTraceRecord));
 
 /*	Values from pexpert.h */
@@ -582,58 +871,117 @@ int main(int argc, char *argv[])
 	DECLARE("PECFIbusrate",	offsetof(struct clock_frequency_info_t *, bus_clock_rate_hz));
 
 /*	Values from pmap_internals.h and mappings.h */
-	DECLARE("mmnext",		offsetof(struct mapping *, next));
-	DECLARE("mmhashnext",	offsetof(struct mapping *, hashnext));
-	DECLARE("mmPTEhash",	offsetof(struct mapping *, PTEhash));
-	DECLARE("mmPTEent",		offsetof(struct mapping *, PTEent));
-	DECLARE("mmPTEv",		offsetof(struct mapping *, PTEv));
-	DECLARE("mmPTEr",		offsetof(struct mapping *, PTEr));
-	DECLARE("mmphysent",	offsetof(struct mapping *, physent));
-	DECLARE("mmpmap",		offsetof(struct mapping *, pmap));
-	
-	DECLARE("bmnext",		offsetof(struct blokmap *, next));
-	DECLARE("bmstart",		offsetof(struct blokmap *, start));
-	DECLARE("bmend",		offsetof(struct blokmap *, end));
-	DECLARE("bmcurrent",		offsetof(struct blokmap *, current));
-	DECLARE("bmPTEr",		offsetof(struct blokmap *, PTEr));
-	DECLARE("bmspace",		offsetof(struct blokmap *, space));
-	DECLARE("blkFlags",		offsetof(struct blokmap *, blkFlags));
-	DECLARE("blkPerm",		blkPerm);
-	DECLARE("blkRem",		blkRem);
-	DECLARE("blkPermbit",	blkPermbit);
-	DECLARE("blkRembit",	blkRembit);
-	DECLARE("BLKREMMAX",	BLKREMMAX);
-	
+
+	DECLARE("mpFlags",		offsetof(struct mapping *, mpFlags));
+	DECLARE("mpBusy",		mpBusy);
+	DECLARE("mpPIndex",		mpPIndex);
+	DECLARE("mpSpecial",	mpSpecial);
+	DECLARE("mpSpecialb",	mpSpecialb);
+	DECLARE("mpFIP",		mpFIP);
+	DECLARE("mpFIPb",		mpFIPb);
+	DECLARE("mpRemovable",	mpRemovable);
+	DECLARE("mpRemovableb",	mpRemovableb);
+	DECLARE("mpNest",		mpNest);
+	DECLARE("mpNestb",		mpNestb);
+	DECLARE("mpPerm",		mpPerm);
+	DECLARE("mpPermb",		mpPermb);
+	DECLARE("mpBlock",		mpBlock);
+	DECLARE("mpBlockb",		mpBlockb);
+	DECLARE("mpRIP",		mpRIP);
+	DECLARE("mpRIPb",		mpRIPb);
+	DECLARE("mpRSVD1",		mpRSVD1);
+	DECLARE("mpLists",		mpLists);
+	DECLARE("mpListsb",		mpListsb);
+
+	DECLARE("mpSpace",		offsetof(struct mapping *, mpSpace));
+	DECLARE("mpBSize",		offsetof(struct mapping *, mpBSize));
+	DECLARE("mpPte",		offsetof(struct mapping *, mpPte));
+	DECLARE("mpHValid",		mpHValid);
+	DECLARE("mpHValidb",	mpHValidb);
+
+	DECLARE("mpPAddr",		offsetof(struct mapping *, mpPAddr));
+	DECLARE("mpVAddr",		offsetof(struct mapping *, mpVAddr));
+	DECLARE("mpHWFlags",	mpHWFlags);
+	DECLARE("mpPP",			mpPP);
+	DECLARE("mpPPb",		mpPPb);
+	DECLARE("mpKKN",		mpKKN);
+	DECLARE("mpKKNb",		mpKKNb);
+	DECLARE("mpWIMG",		mpWIMG);
+	DECLARE("mpWIMGb",		mpWIMGb);
+	DECLARE("mpW",			mpW);
+	DECLARE("mpWb",			mpWb);
+	DECLARE("mpI",			mpI);
+	DECLARE("mpIb",			mpIb);
+	DECLARE("mpM",			mpM);
+	DECLARE("mpMb",			mpMb);
+	DECLARE("mpG",			mpG);
+	DECLARE("mpGb",			mpGb);
+	DECLARE("mpWIMGe",		mpWIMGe);
+	DECLARE("mpC",			mpC);
+	DECLARE("mpCb",			mpCb);
+	DECLARE("mpR",			mpR);
+	DECLARE("mpRb",			mpRb);
+	DECLARE("mpAlias",		offsetof(struct mapping *, mpAlias));
+	DECLARE("mpNestReloc",	offsetof(struct mapping *, mpNestReloc));	
+	DECLARE("mpBlkRemCur",	offsetof(struct mapping *, mpBlkRemCur));	
+	DECLARE("mpList0",		offsetof(struct mapping *, mpList0));
+	DECLARE("mpList	",		offsetof(struct mapping *, mpList));
+	DECLARE("mpBasicSize",	mpBasicSize);
+	DECLARE("mpBasicLists",	mpBasicLists);
+
 	DECLARE("mbvrswap",		offsetof(struct mappingblok *, mapblokvrswap));
 	DECLARE("mbfree",		offsetof(struct mappingblok *, mapblokfree));
 	DECLARE("mapcsize",		sizeof(struct mappingctl));
 
-	DECLARE("pephyslink",	offsetof(struct phys_entry *, phys_link));
-	DECLARE("pepte1",		offsetof(struct phys_entry *, pte1));
+	DECLARE("ppLink",		offsetof(struct phys_entry *, ppLink));
+	DECLARE("ppLock",		ppLock);
+	DECLARE("ppN",			ppN);
+	DECLARE("ppFlags",		ppFlags);
+	DECLARE("ppI",			ppI);
+	DECLARE("ppIb",			ppIb);
+	DECLARE("ppG",			ppG);
+	DECLARE("ppGb",			ppGb);
+	DECLARE("ppR",			ppR);
+	DECLARE("ppRb",			ppRb);
+	DECLARE("ppC",			ppC);
+	DECLARE("ppCb",			ppCb);
+	DECLARE("ppPP",			ppPP);
+	DECLARE("ppPPb",		ppPPb);
+	DECLARE("ppPPe",		ppPPe);
 
-	DECLARE("PCAlock",		offsetof(struct PCA *, PCAlock));
 	DECLARE("PCAallo",		offsetof(struct PCA *, flgs.PCAallo));
 	DECLARE("PCAfree",		offsetof(struct PCA *, flgs.PCAalflgs.PCAfree));
 	DECLARE("PCAauto",		offsetof(struct PCA *, flgs.PCAalflgs.PCAauto));
-	DECLARE("PCAslck",		offsetof(struct PCA *, flgs.PCAalflgs.PCAslck));
+	DECLARE("PCAmisc",		offsetof(struct PCA *, flgs.PCAalflgs.PCAmisc));
+	DECLARE("PCAlock",		PCAlock);
+	DECLARE("PCAlockb",		PCAlockb);
 	DECLARE("PCAsteal",		offsetof(struct PCA *, flgs.PCAalflgs.PCAsteal));
-	DECLARE("PCAgas",		offsetof(struct PCA *, PCAgas));
-	DECLARE("PCAhash",		offsetof(struct PCA *, PCAhash));
 
+	DECLARE("mrPhysTab",	offsetof(struct mem_region *, mrPhysTab));
+	DECLARE("mrStart",		offsetof(struct mem_region *, mrStart));
+	DECLARE("mrEnd",		offsetof(struct mem_region *, mrEnd));
+	DECLARE("mrAStart",		offsetof(struct mem_region *, mrAStart));
+	DECLARE("mrAEnd",		offsetof(struct mem_region *, mrAEnd));
+	DECLARE("mrSize",		sizeof(struct mem_region));
+
+	DECLARE("mapRemChunk",	mapRemChunk);
+
+	DECLARE("mapRetCode",	mapRetCode);
+	DECLARE("mapRtOK",		mapRtOK);
+	DECLARE("mapRtBadLk",	mapRtBadLk);
+	DECLARE("mapRtPerm",	mapRtPerm);
+	DECLARE("mapRtNotFnd",	mapRtNotFnd);
+	DECLARE("mapRtBlock",	mapRtBlock);
+	DECLARE("mapRtNest",	mapRtNest);
+	DECLARE("mapRtRemove",	mapRtRemove);
+	DECLARE("mapRtMapDup",	mapRtMapDup);
+
+#if 0
 	DECLARE("MFpcaptr",		offsetof(struct mappingflush *, pcaptr));
 	DECLARE("MFmappingcnt",		offsetof(struct mappingflush *, mappingcnt));
 	DECLARE("MFmapping",		offsetof(struct mappingflush *, mapping));
 	DECLARE("MFmappingSize", 	sizeof(struct mfmapping));
-
-	DECLARE("SVlock",		offsetof(struct Saveanchor *, savelock));
-	DECLARE("SVpoolfwd",	offsetof(struct Saveanchor *, savepoolfwd));
-	DECLARE("SVpoolbwd",	offsetof(struct Saveanchor *, savepoolbwd));
-	DECLARE("SVfree",		offsetof(struct Saveanchor *, savefree));
-	DECLARE("SVfreecnt",	offsetof(struct Saveanchor *, savefreecnt));
-	DECLARE("SVadjust",		offsetof(struct Saveanchor *, saveadjust));
-	DECLARE("SVinuse",		offsetof(struct Saveanchor *, saveinuse));
-	DECLARE("SVtarget",		offsetof(struct Saveanchor *, savetarget));
-	DECLARE("SVsize",		sizeof(struct Saveanchor));
+#endif
 
 #if 1
 	DECLARE("GDsave",		offsetof(struct GDWorkArea *, GDsave));
@@ -653,9 +1001,6 @@ int main(int argc, char *argv[])
 	DECLARE("GDrowbuf2",	offsetof(struct GDWorkArea *, GDrowbuf2));
 #endif
 
-	DECLARE("dgLock",		offsetof(struct diagWork *, dgLock));
-	DECLARE("dgFlags",		offsetof(struct diagWork *, dgFlags));
-	DECLARE("dgMisc0",		offsetof(struct diagWork *, dgMisc0));
 	DECLARE("enaExpTrace",	enaExpTrace);
 	DECLARE("enaExpTraceb",	enaExpTraceb);
 	DECLARE("enaUsrFCall",	enaUsrFCall);
@@ -666,6 +1011,8 @@ int main(int argc, char *argv[])
 	DECLARE("enaDiagSCsb",	enaDiagSCsb);
 	DECLARE("enaDiagEM",	enaDiagEM);
 	DECLARE("enaDiagEMb",	enaDiagEMb);
+	DECLARE("enaNotifyEM",	enaNotifyEM);
+	DECLARE("enaNotifyEMb",	enaNotifyEMb);
 	DECLARE("disLkType",	disLkType);
 	DECLARE("disLktypeb",	disLktypeb);
 	DECLARE("disLkThread",	disLkThread);
@@ -680,12 +1027,6 @@ int main(int argc, char *argv[])
 	DECLARE("dgMisc4",		offsetof(struct diagWork *, dgMisc4));
 	DECLARE("dgMisc5",		offsetof(struct diagWork *, dgMisc5));
 
-	DECLARE("traceMask",	offsetof(struct traceWork *, traceMask));
-	DECLARE("traceCurr",	offsetof(struct traceWork *, traceCurr));
-	DECLARE("traceStart",	offsetof(struct traceWork *, traceStart));
-	DECLARE("traceEnd",		offsetof(struct traceWork *, traceEnd));
-	DECLARE("traceMsnd",	offsetof(struct traceWork *, traceMsnd));
-
 	DECLARE("SACnext",		offsetof(struct savearea_comm *, sac_next));
 	DECLARE("SACprev",		offsetof(struct savearea_comm *, sac_prev));
 	DECLARE("SACvrswap",	offsetof(struct savearea_comm *, sac_vrswap));
@@ -711,11 +1052,16 @@ int main(int argc, char *argv[])
 	DECLARE("SAVflags",		offsetof(struct savearea_comm *, save_flags));
 	DECLARE("SAVlevel",		offsetof(struct savearea_comm *, save_level));
 	DECLARE("SAVtime",		offsetof(struct savearea_comm *, save_time));
+	DECLARE("savemisc0",	offsetof(struct savearea_comm *, save_misc0));
+	DECLARE("savemisc1",	offsetof(struct savearea_comm *, save_misc1));
+	DECLARE("savemisc2",	offsetof(struct savearea_comm *, save_misc2));
+	DECLARE("savemisc3",	offsetof(struct savearea_comm *, save_misc3));
+
 	DECLARE("SAVsize",		sizeof(struct savearea));
 	DECLARE("SAVsizefpu",	sizeof(struct savearea_vec));
 	DECLARE("SAVsizevec",	sizeof(struct savearea_fpu));
 	DECLARE("SAVcommsize",	sizeof(struct savearea_comm));
-
+	
 	DECLARE("savesrr0",		offsetof(struct savearea *, save_srr0));
 	DECLARE("savesrr1",		offsetof(struct savearea *, save_srr1));
 	DECLARE("savecr",		offsetof(struct savearea *, save_cr));
@@ -730,6 +1076,13 @@ int main(int argc, char *argv[])
 	DECLARE("savevrsave",	offsetof(struct savearea *, save_vrsave));	
 	DECLARE("savevscr",		offsetof(struct savearea *, save_vscr));	
 
+	DECLARE("savemmcr0",	offsetof(struct savearea *, save_mmcr0));
+	DECLARE("savemmcr1",	offsetof(struct savearea *, save_mmcr1));
+	DECLARE("savemmcr2",	offsetof(struct savearea *, save_mmcr2));
+	DECLARE("savepmc",		offsetof(struct savearea *, save_pmc));
+	
+	DECLARE("saveinstr",	offsetof(struct savearea *, save_instr));
+
 	DECLARE("saver0",		offsetof(struct savearea *, save_r0));
 	DECLARE("saver1",		offsetof(struct savearea *, save_r1));
 	DECLARE("saver2",		offsetof(struct savearea *, save_r2));
@@ -763,23 +1116,6 @@ int main(int argc, char *argv[])
 	DECLARE("saver30",		offsetof(struct savearea *, save_r30));
 	DECLARE("saver31",		offsetof(struct savearea *, save_r31));
 
-	DECLARE("savesr0",		offsetof(struct savearea *, save_sr0));
-	DECLARE("savesr1",		offsetof(struct savearea *, save_sr1));
-	DECLARE("savesr2",		offsetof(struct savearea *, save_sr2));
-	DECLARE("savesr3",		offsetof(struct savearea *, save_sr3));
-	DECLARE("savesr4",		offsetof(struct savearea *, save_sr4));
-	DECLARE("savesr5",		offsetof(struct savearea *, save_sr5));
-	DECLARE("savesr6",		offsetof(struct savearea *, save_sr6));
-	DECLARE("savesr7",		offsetof(struct savearea *, save_sr7));
-	DECLARE("savesr8",		offsetof(struct savearea *, save_sr8));
-	DECLARE("savesr9",		offsetof(struct savearea *, save_sr9));
-	DECLARE("savesr10",		offsetof(struct savearea *, save_sr10));
-	DECLARE("savesr11",		offsetof(struct savearea *, save_sr11));
-	DECLARE("savesr12",		offsetof(struct savearea *, save_sr12));
-	DECLARE("savesr13",		offsetof(struct savearea *, save_sr13));
-	DECLARE("savesr14",		offsetof(struct savearea *, save_sr14));
-	DECLARE("savesr15",		offsetof(struct savearea *, save_sr15));
-
 	DECLARE("savefp0",		offsetof(struct savearea_fpu *, save_fp0));
 	DECLARE("savefp1",		offsetof(struct savearea_fpu *, save_fp1));
 	DECLARE("savefp2",		offsetof(struct savearea_fpu *, save_fp2));
@@ -886,25 +1222,51 @@ int main(int argc, char *argv[])
 	DECLARE("procState",		offsetof(struct processor *, state));
 	
 	DECLARE("CPU_SUBTYPE_POWERPC_ALL",		CPU_SUBTYPE_POWERPC_ALL);
-	DECLARE("CPU_SUBTYPE_POWERPC_601",		CPU_SUBTYPE_POWERPC_601);
-	DECLARE("CPU_SUBTYPE_POWERPC_602",		CPU_SUBTYPE_POWERPC_602);
-	DECLARE("CPU_SUBTYPE_POWERPC_603",		CPU_SUBTYPE_POWERPC_603);
-	DECLARE("CPU_SUBTYPE_POWERPC_603e",		CPU_SUBTYPE_POWERPC_603e);
-	DECLARE("CPU_SUBTYPE_POWERPC_603ev",	CPU_SUBTYPE_POWERPC_603ev);
-	DECLARE("CPU_SUBTYPE_POWERPC_604",		CPU_SUBTYPE_POWERPC_604);
-	DECLARE("CPU_SUBTYPE_POWERPC_604e",		CPU_SUBTYPE_POWERPC_604e);
-	DECLARE("CPU_SUBTYPE_POWERPC_620",		CPU_SUBTYPE_POWERPC_620);
 	DECLARE("CPU_SUBTYPE_POWERPC_750",		CPU_SUBTYPE_POWERPC_750);
 	DECLARE("CPU_SUBTYPE_POWERPC_7400",		CPU_SUBTYPE_POWERPC_7400);
 	DECLARE("CPU_SUBTYPE_POWERPC_7450",		CPU_SUBTYPE_POWERPC_7450);
+	DECLARE("CPU_SUBTYPE_POWERPC_970",		CPU_SUBTYPE_POWERPC_970);
 
 	DECLARE("shdIBAT",	offsetof(struct shadowBAT *, IBATs));	
 	DECLARE("shdDBAT",	offsetof(struct shadowBAT *, DBATs));	
 	
-
+	/* Low Memory Globals */
+
+	DECLARE("lgVerCode", 			offsetof(struct lowglo *, lgVerCode));
+	DECLARE("lgPPStart", 			offsetof(struct lowglo *, lgPPStart));
+	DECLARE("trcWork", 				offsetof(struct lowglo *, lgTrcWork));
+	DECLARE("traceMask",			offsetof(struct lowglo *, lgTrcWork.traceMask));
+	DECLARE("traceCurr",			offsetof(struct lowglo *, lgTrcWork.traceCurr));
+	DECLARE("traceStart",			offsetof(struct lowglo *, lgTrcWork.traceStart));
+	DECLARE("traceEnd",				offsetof(struct lowglo *, lgTrcWork.traceEnd));
+	DECLARE("traceMsnd",			offsetof(struct lowglo *, lgTrcWork.traceMsnd));
+
+	DECLARE("Zero", 				offsetof(struct lowglo *, lgZero));
+	DECLARE("saveanchor", 			offsetof(struct lowglo *, lgSaveanchor));
+
+	DECLARE("SVlock",				offsetof(struct lowglo *, lgSaveanchor.savelock));
+	DECLARE("SVpoolfwd",			offsetof(struct lowglo *, lgSaveanchor.savepoolfwd));
+	DECLARE("SVpoolbwd",			offsetof(struct lowglo *, lgSaveanchor.savepoolbwd));
+	DECLARE("SVfree",				offsetof(struct lowglo *, lgSaveanchor.savefree));
+	DECLARE("SVfreecnt",			offsetof(struct lowglo *, lgSaveanchor.savefreecnt));
+	DECLARE("SVadjust",				offsetof(struct lowglo *, lgSaveanchor.saveadjust));
+	DECLARE("SVinuse",				offsetof(struct lowglo *, lgSaveanchor.saveinuse));
+	DECLARE("SVtarget",				offsetof(struct lowglo *, lgSaveanchor.savetarget));
+	DECLARE("SVsize",				sizeof(struct Saveanchor));
+
+	DECLARE("tlbieLock", 			offsetof(struct lowglo *, lgTlbieLck));
+
+	DECLARE("dgFlags",				offsetof(struct lowglo *, lgdgWork.dgFlags));
+	DECLARE("dgLock",				offsetof(struct lowglo *, lgdgWork.dgLock));
+	DECLARE("dgMisc0",				offsetof(struct lowglo *, lgdgWork.dgMisc0));
 	
-	return(0);  /* For ANSI C :-) */
-
-
+	DECLARE("lgKillResv",			offsetof(struct lowglo *, lgKillResv));
+	
+	DECLARE("scomcpu",				offsetof(struct scomcomm *, scomcpu));
+	DECLARE("scomfunc",				offsetof(struct scomcomm *, scomfunc));
+	DECLARE("scomreg",				offsetof(struct scomcomm *, scomreg));
+	DECLARE("scomstat",				offsetof(struct scomcomm *, scomstat));
+	DECLARE("scomdata",				offsetof(struct scomcomm *, scomdata));
 
+	return(0);  /* For ANSI C :-) */
 }
diff --git a/osfmk/ppc/hardclock_entries.h b/osfmk/ppc/hardclock_entries.h
index ab499201d..e0906e06d 100644
--- a/osfmk/ppc/hardclock_entries.h
+++ b/osfmk/ppc/hardclock_entries.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ppc/hexfont.h b/osfmk/ppc/hexfont.h
index 91b3caf3e..e501c2ab3 100644
--- a/osfmk/ppc/hexfont.h
+++ b/osfmk/ppc/hexfont.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ppc/hw_counters.h b/osfmk/ppc/hw_counters.h
deleted file mode 100644
index 8a7a5d321..000000000
--- a/osfmk/ppc/hw_counters.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
- *
- * @APPLE_LICENSE_HEADER_START@
- * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
- * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
- * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
- * 
- * @APPLE_LICENSE_HEADER_END@
- */
-/*
- *
- *		Hardware specific performance counters
- */
-#ifndef _HW_COUNTERS_H_
-#define _HW_COUNTERS_H_
-
-#ifndef __ppc__
-#error This file is only useful on PowerPC.
-#endif
-
-
-typedef struct hw_counters {	
-
-	unsigned int hw_InVains; 				/* In vain */
-	unsigned int hw_Resets;					/* Reset */
-	unsigned int hw_MachineChecks;			/* Machine check */
-	unsigned int hw_DSIs; 					/* DSIs */
-	unsigned int hw_ISIs; 					/* ISIs */
-	unsigned int hw_Externals; 				/* Externals */
-	unsigned int hw_Alignments; 			/* Alignment */
-	unsigned int hw_Programs; 				/* Program */
-	unsigned int hw_FloatPointUnavailable; 	/* Floating point */
-	unsigned int hw_Decrementers; 			/* Decrementer */
-	unsigned int hw_IOErrors; 				/* I/O error */
-	unsigned int hw_rsvd0; 					/* Reserved */
-	unsigned int hw_SystemCalls; 			/* System call */
-	unsigned int hw_Traces; 				/* Trace */
-	unsigned int hw_FloatingPointAssists; 	/* Floating point assist */
-	unsigned int hw_PerformanceMonitors; 	/* Performance monitor */
-	unsigned int hw_Altivecs; 				/* VMX */
-	unsigned int hw_rsvd1; 					/* Reserved */
-	unsigned int hw_rsvd2; 					/* Reserved */
-	unsigned int hw_rsvd3; 					/* Reserved */
-	unsigned int hw_InstBreakpoints; 		/* Instruction breakpoint */
-	unsigned int hw_SystemManagements; 		/* System management */
-	unsigned int hw_rsvd4; 					/* Reserved */
-	unsigned int hw_AltivecAssists;			/* Altivec Assist */
-	unsigned int hw_rsvd6; 					/* Reserved */
-	unsigned int hw_rsvd7; 					/* Reserved */
-	unsigned int hw_rsvd8;					/* Reserved */
-	unsigned int hw_rsvd9; 					/* Reserved */
-	unsigned int hw_rsvd10; 				/* Reserved */
-	unsigned int hw_rsvd11; 				/* Reserved */
-	unsigned int hw_rsvd12; 				/* Reserved */
-	unsigned int hw_rsvd13; 				/* Reserved */
-	unsigned int hw_rsvd14; 				/* Reserved */
-	unsigned int hw_Trace601;				/* Trace */
-	unsigned int hw_SIGPs; 					/* SIGP */
-	unsigned int hw_Preemptions; 			/* Preemption */
-	unsigned int hw_ContextSwitchs;			/* Context switch */
-	
-	unsigned int hw_spare[27];				/* Pad to 256 bytes */
-
-} hw_counters;
-
-extern hw_counters hw_counts(NCPUS);
-
-#endif /* _HW_COUNTERS_H_ */
diff --git a/osfmk/ppc/hw_exception.s b/osfmk/ppc/hw_exception.s
index f0296682b..5b3775d84 100644
--- a/osfmk/ppc/hw_exception.s
+++ b/osfmk/ppc/hw_exception.s
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -50,7 +53,8 @@
 
 #define VERIFYSAVE 0
 #define FPVECDBG 0
-	
+#define INSTRUMENT 0
+
 /*
  * thandler(type)
  *
@@ -104,7 +108,7 @@ LEXT(thandler)										; Trap handler
 			lwz		r1,ACT_MACT_KSP(r13)			; Get the top of kernel stack
 			bnel-	checkassist						; See if we should assist this
 			stw		r4,ACT_MACT_PCB(r13)			; Point to our savearea
-			stw		r8,SAVprev(r4)					; Queue the new save area in the front 
+			stw		r8,SAVprev+4(r4)				; Queue the new save area in the front 
 			
 #if VERIFYSAVE
 			bl		versave							; (TEST/DEBUG)
@@ -113,16 +117,17 @@ LEXT(thandler)										; Trap handler
 			lwz		r9,THREAD_KERNEL_STACK(r6)		; Get our kernel stack start
 			cmpwi	cr1,r1,0						; Are we already on kernel stack?
 			stw		r13,SAVact(r4)					; Mark the savearea as belonging to this activation
-			lwz		r26,saver1(r4)					; Get the stack at interrupt time
+			lwz		r26,saver1+4(r4)				; Get the stack at interrupt time
 
 			bne+	cr1,.L_kstackfree				; We are not on kernel stack yet...		
 
 			subi	r1,r26,FM_REDZONE				; Make a red zone on interrupt time kernel stack
 
 .L_kstackfree:
-			lwz		r7,savesrr1(r4)					; Pick up the entry MSR 
+			lwz		r7,savesrr1+4(r4)				; Pick up the entry MSR 
 			sub		r9,r1,r9						; Get displacment into the kernel stack
 			li		r0,0							; Make this 0
+			rlwinm.	r0,r9,0,28,31					; Verify that we have a 16-byte aligned stack (and get a 0)
 			cmplwi	cr2,r9,KERNEL_STACK_SIZE		; Do we still have room on the stack?
 			beq		cr1,.L_state_on_kstack			; using above test for pcb/stack
 
@@ -130,12 +135,13 @@ LEXT(thandler)										; Trap handler
 
 .L_state_on_kstack:	
 			lwz		r9,savevrsave(r4)				; Get the VRSAVE register
+			bne--	kernelStackUnaligned			; Stack is unaligned...
 			rlwinm.	r6,r7,0,MSR_VEC_BIT,MSR_VEC_BIT	; Was vector on?
 			subi	r1,r1,FM_SIZE					; Push a header onto the current stack 
-			bgt-	cr2,kernelStackBad				; Kernel stack is bogus...
+			bgt--	cr2,kernelStackBad				; Kernel stack is bogus...
 
 kernelStackNotBad:									; Vector was off
-			beq+	tvecoff							; Vector off, do not save vrsave...
+			beq++	tvecoff							; Vector off, do not save vrsave...
 			stw		r9,liveVRS(r25)					; Set the live value
 
 tvecoff:	stw		r26,FM_BACKPTR(r1)				; Link back to the previous frame
@@ -145,7 +151,7 @@ tvecoff:	stw		r26,FM_BACKPTR(r1)				; Link back to the previous frame
  * which links back to the trapped routine. The second is
  * that which the C routine below will need
  */
-			lwz		r3,savesrr0(r4)					; Get the point of interruption
+			lwz		r3,savesrr0+4(r4)				; Get the point of interruption
 			stw		r3,FM_LR_SAVE(r1)				; save old instr ptr as LR value 
 			stwu	r1,	-FM_SIZE(r1)				; and make new frame 
 #endif /* DEBUG */
@@ -175,9 +181,10 @@ tvecoff:	stw		r26,FM_BACKPTR(r1)				; Link back to the previous frame
 			
 			crandc	cr0_eq,cr7_eq,cr0_eq			; Do not intercept if we are in the kernel (cr0_eq == 1 if yes)
 			
-			lwz		r6,savedar(r4)					; Get the DAR 
+			lwz		r6,savedar(r4)					; Get the DAR (top)
+			lwz		r7,savedar+4(r4)				; Get the DAR (bottom)
 	
-			beq-	cr2, .L_call_trap				; Do not turn on interrupts for T_PREEMPT
+			beq-	cr2,.L_call_trap				; Do not turn on interrupts for T_PREEMPT
 			beq-	exitFromVM						; Any true trap but T_MACHINE_CHECK exits us from the VM...
 
 /* syscall exception might warp here if there's nothing left
@@ -188,10 +195,10 @@ tvecoff:	stw		r26,FM_BACKPTR(r1)				; Link back to the previous frame
 
 			bl	EXT(trap)
 
+			lis		r10,hi16(MASK(MSR_VEC))			; Get the vector enable
 			mfmsr	r7								; Get the MSR
-			rlwinm	r7,r7,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-			rlwinm	r7,r7,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-			rlwinm	r7,r7,0,MSR_EE_BIT+1,MSR_EE_BIT-1	; Clear the interrupt enable mask
+			ori		r10,r10,lo16(MASK(MSR_FP)|MASK(MSR_EE))	; Add in FP and EE
+			andc	r7,r7,r10						; Turn off VEC, FP, and EE
 			mtmsr	r7								; Disable for interrupts
 			mfsprg	r10,0							; Restore the per_proc info
 /*
@@ -201,21 +208,21 @@ tvecoff:	stw		r26,FM_BACKPTR(r1)				; Link back to the previous frame
  */
 
 thread_return:
-			lwz		r4,SAVprev(r3)					; Pick up the previous savearea 
 			lwz		r11,SAVflags(r3)				; Get the flags of the current savearea
-			lwz		r8,savesrr1(r3)					; Get the MSR we are going to
-			rlwinm	r11,r11,0,15,13					; Clear the syscall flag
-			lwz		r1,PP_ACTIVE_THREAD(r10)		; Get the active thread 
-			rlwinm.	r8,r8,0,MSR_PR_BIT,MSR_PR_BIT	; Are we going to the user?
+			lwz		r0,savesrr1+4(r3)				; Get the MSR we are going to
+			lwz		r4,SAVprev+4(r3)				; Pick up the previous savearea 
 			mfsprg	r8,1							; Get the current activation
+			lwz		r1,PP_ACTIVE_THREAD(r10)		; Get the active thread 
+			rlwinm	r11,r11,0,15,13					; Clear the syscall flag
+			rlwinm.	r0,r0,0,MSR_PR_BIT,MSR_PR_BIT	; Are we going to the user?
 			stw		r11,SAVflags(r3)				; Save back the flags (with reset stack cleared) 
 
+			lwz		r5,THREAD_KERNEL_STACK(r1)		; Get the base pointer to the stack 
 			stw		r4,ACT_MACT_PCB(r8)				; Point to the previous savearea (or 0 if none)
+			addi	r5,r5,KERNEL_STACK_SIZE-FM_SIZE	; Reset to empty 
 
-			beq-	chkfac							; We are not leaving the kernel yet...
+			beq--	chkfac							; We are not leaving the kernel yet...
 
-			lwz		r5,THREAD_KERNEL_STACK(r1)		; Get the base pointer to the stack 
-			addi	r5,r5,KERNEL_STACK_SIZE-FM_SIZE	; Reset to empty 
 			stw		r5,ACT_MACT_KSP(r8)				; Save the empty stack pointer 
 			b		chkfac							; Go end it all...
 
@@ -238,6 +245,12 @@ kernelStackBad:
 			li		r3,failStack					; Bad stack code
 			sc										; System ABEND
 
+kernelStackUnaligned:
+			lis		r0,hi16(Choke)					; Choke code
+			ori		r0,r0,lo16(Choke)				; and the rest
+			li		r3,failUnalignedStk				; Unaligned stack code
+			sc										; System ABEND
+
 
 /*
  * shandler(type)
@@ -273,34 +286,44 @@ kernelStackBad:
 			.globl EXT(shandler)
 LEXT(shandler)										; System call handler
 
+			lwz		r7,savesrr1+4(r4)				; Get the SRR1 value
 			mfsprg	r25,0							; Get the per proc area 
-			lwz		r0,saver0(r4)					; Get the original syscall number
+			lwz		r0,saver0+4(r4)					; Get the original syscall number
 			lwz		r17,PP_ISTACKPTR(r25)			; Get interrupt stack pointer
 			rlwinm	r15,r0,0,0,19					; Clear the bottom of call number for fast check
 			mr.		r17,r17							; Are we on interrupt stack?
-			lwz		r7,savesrr1(r4)					; Get the SRR1 value
-			beq-	EXT(ihandler)					; On interrupt stack, not allowed...
 			lwz		r9,savevrsave(r4)				; Get the VRsave register
+			beq--	EXT(ihandler)					; On interrupt stack, not allowed...
 			rlwinm.	r6,r7,0,MSR_VEC_BIT,MSR_VEC_BIT	; Was vector on?
 			lwz		r16,PP_ACTIVE_THREAD(r25)		; Get the thread pointer 
 			mfsprg	r13,1							; Pick up the active thread 
 
-			beq+	svecoff							; Vector off, do not save vrsave...
+			beq++	svecoff							; Vector off, do not save vrsave...
 			stw		r9,liveVRS(r25)					; Set the live value
 ;
 ; 			Check if SCs are being redirected for the BlueBox or to VMM
 ;
 
 svecoff:	lwz		r6,ACT_MACT_SPF(r13)			; Pick up activation special flags
-			mtcrf	0x41,r6							; Check special flags
+			mtcrf	0x40,r6							; Check special flags
+			mtcrf	0x01,r6							; Check special flags
 			crmove	cr6_eq,runningVMbit				; Remember if we are in VMM
-			bf+		bbNoMachSCbit,noassist			; Take branch if SCs are not redirected
+			bne++	cr6,sVMchecked					; Not running VM
+			lwz		r18,spcFlags(r25)				; Load per_proc special flags
+			rlwinm. r18,r18,0,FamVMmodebit,FamVMmodebit	; Is FamVMmodebit set?
+			beq		sVMchecked						; Not in FAM
+			cmpwi	r0,0x6004						; Is it vmm_dispatch syscall:
+			bne		sVMchecked
+			lwz		r26,saver3+4(r4)				; Get the original syscall number
+			cmpwi	cr6,r26,kvmmExitToHost			; vmm_exit_to_host request
+sVMchecked:
+			bf++	bbNoMachSCbit,noassist			; Take branch if SCs are not redirected
 			lwz		r26,ACT_MACT_BEDA(r13)			; Pick up the pointer to the blue box exception area
 			b		EXT(atomic_switch_syscall)		; Go to the assist...
 
 noassist:	cmplwi	r15,0x7000						; Do we have a fast path trap? 
 			lwz		r14,ACT_MACT_PCB(r13)			; Now point to the PCB 
-			beql+	fastpath						; We think it is a fastpath... 
+			beql	fastpath						; We think it is a fastpath... 
 
 			lwz		r1,ACT_MACT_KSP(r13)			; Get the kernel stack pointer 
 #if DEBUG
@@ -311,15 +334,15 @@ noassist:	cmplwi	r15,0x7000						; Do we have a fast path trap?
 
 			stw		r4,ACT_MACT_PCB(r13)			; Point to our savearea
 			li		r0,0							; Clear this out 
-			stw		r14,SAVprev(r4)					; Queue the new save area in the front 
+			stw		r14,SAVprev+4(r4)				; Queue the new save area in the front 
 			stw		r13,SAVact(r4)					; Point the savearea at its activation
 			
 #if VERIFYSAVE
 			bl		versave							; (TEST/DEBUG)
 #endif			
 			
+			lwz		r15,saver1+4(r4)				; Grab interrupt time stack 
 			mr		r30,r4							; Save pointer to the new context savearea
-			lwz		r15,saver1(r4)					; Grab interrupt time stack 
 			stw		r0,ACT_MACT_KSP(r13)			; Mark stack as busy with 0 val 
 			stw		r15,FM_BACKPTR(r1)				; Link stack frame backwards
 		
@@ -328,32 +351,31 @@ noassist:	cmplwi	r15,0x7000						; Do we have a fast path trap?
  * which links back to the trapped routine. The second is
  * that which the C routine below will need
  */
-			lwz		r8,savesrr0(r30)				; Get the point of interruption
+			lwz		r8,savesrr0+4(r30)				; Get the point of interruption
 			stw		r8,FM_LR_SAVE(r1)				; Save old instr ptr as LR value
 			stwu	r1,	-FM_SIZE(r1)				; and make new frame
 #endif /* DEBUG */
 
-			mfmsr	r11								; Get the MSR
 			lwz		r15,SAVflags(r30)				; Get the savearea flags
+			lwz		r0,saver0+4(r30)				; Get R0 back
+			mfmsr	r11								; Get the MSR
+			stwu	r1,-(FM_SIZE+ARG_SIZE)(r1)		; Make a stack frame
 			ori		r11,r11,lo16(MASK(MSR_EE))		; Turn on interruption enabled bit
-			lwz		r0,saver0(r30)					; Get R0 back
-			oris	r15,r15,SAVsyscall >> 16 		; Mark that it this is a syscall
 			rlwinm	r10,r0,0,0,19					; Keep only the top part 
-			stwu	r1,-(FM_SIZE+ARG_SIZE)(r1)		; Make a stack frame
+			oris	r15,r15,SAVsyscall >> 16 		; Mark that it this is a syscall
 			cmplwi	r10,0x6000						; Is it the special ppc-only guy?
 			stw		r15,SAVflags(r30)				; Save syscall marker
-			beq-	cr6,exitFromVM					; It is time to exit from alternate context...
+			beq--	cr6,exitFromVM					; It is time to exit from alternate context...
 			
 			beq-	ppcscall						; Call the ppc-only system call handler...
 
+			mr.		r0,r0							; What kind is it?
 			mtmsr	r11								; Enable interruptions
 
-			lwz		r0,saver0(r30)					; Get the system call selector
-			mr.		r0,r0							; What kind is it?
-			blt-	.L_kernel_syscall				; System call number if negative, this is a mach call...
+			blt--	.L_kernel_syscall				; System call number if negative, this is a mach call...
 											
 			cmpwi	cr0,r0,0x7FFA					; Special blue box call?
-			beq-	.L_notify_interrupt_syscall		; Yeah, call it...
+			beq--	.L_notify_interrupt_syscall		; Yeah, call it...
 			
 			lwz     r8,ACT_TASK(r13)				; Get our task
 			lis     r10,hi16(EXT(c_syscalls_unix))	; Get top half of counter address 
@@ -377,7 +399,7 @@ noassist:	cmplwi	r15,0x7000						; Do we have a fast path trap?
 			b		EXT(doexception)				; Go away, never to return...
 
 .L_notify_interrupt_syscall:
-			lwz		r3,saver3(r30)					; Get the new PC address to pass in
+			lwz		r3,saver3+4(r30)				; Get the new PC address to pass in
 			bl		EXT(syscall_notify_interrupt)
 			b		.L_syscall_return
 	
@@ -423,9 +445,19 @@ ppcscall:	rlwinm	r11,r0,2,18,29					; Make an index into the table
 			mr		r3,r30							; Pass the savearea
 			mr		r4,r13							; Pass the activation
 			mr.		r11,r11							; See if there is a function here
-			mtlr	r11								; Set the function address
+			mtctr	r11								; Set the function address
 			beq-	.L_call_server_syscall_exception	; Disabled call...
-			blrl									; Call it
+#if INSTRUMENT
+			mfspr	r4,pmc1							; Get stamp
+			stw		r4,0x6100+(9*16)+0x0(0)			; Save it
+			mfspr	r4,pmc2							; Get stamp
+			stw		r4,0x6100+(9*16)+0x4(0)			; Save it
+			mfspr	r4,pmc3							; Get stamp
+			stw		r4,0x6100+(9*16)+0x8(0)			; Save it
+			mfspr	r4,pmc4							; Get stamp
+			stw		r4,0x6100+(9*16)+0xC(0)			; Save it
+#endif
+			bctrl									; Call it
 	
 			.globl	EXT(ppcscret)
 
@@ -435,7 +467,7 @@ LEXT(ppcscret)
 			bgt+	.L_thread_syscall_ret_check_ast	; Take normal AST checking return....
 			mfsprg	r10,0							; Get the per_proc
 			blt+	.L_thread_syscall_return		; Return, but no ASTs....
-			lwz		r0,saver0(r30)					; Restore the system call number
+			lwz		r0,saver0+4(r30)				; Restore the system call number
 			b		.L_call_server_syscall_exception	; Go to common exit...
 
 
@@ -454,155 +486,68 @@ LEXT(ppcscret)
 ; Call a function that can print out our syscall info 
 ; Note that we don t care about any volatiles yet
 ;
-			mr		r4,r30 
+			lis		r8,hi16(EXT(kdebug_enable))	; Get top of kdebug_enable 
+			ori		r8,r8,lo16(EXT(kdebug_enable))	; Get bottom of kdebug_enable 
+			lwz		r0,saver0+4(r30)
+			lwz		r8,0(r8)					; Get kdebug_enable 
+			lis		r29,hi16(EXT(mach_trap_count))	; Get address of count
+			neg		r31,r0						; Make this positive
+			ori		r29,r29,lo16(EXT(mach_trap_count))	; Get address of count
+			lis		r28,hi16(EXT(mach_trap_table))	; Get address of table
+			cmplwi	r8,0						; Is kdebug_enable false?
+			lwz		r29,0(r29)					; Pick up the actual count of system calls
+			slwi	r27,r31,MACH_TRAP_OFFSET_POW2	; Convert index to offset
+			ori		r28,r28,lo16(EXT(mach_trap_table))	; Get address of table
+			beq++	ksysnotrc					; No tracing...
+			mr		r4,r30						; Pass in saved state
 			bl      EXT(syscall_trace)
-			lwz		r0,saver0(r30)					; Get the system call selector */
-			neg		r31,r0							; Make system call number positive and put in r31
-			lis		r29,hi16(EXT(mach_trap_count))	; High part of valid trap number
-			ori		r29,r29,lo16(EXT(mach_trap_count))	; Low part of valid trap number
-			lis		r28,hi16(EXT(mach_trap_table))	; High part of trap table
-			lwz		r29,0(r29)						; Get the first invalid system call number
-			ori		r28,r28,lo16(EXT(mach_trap_table))	; Low part of trap table
-
-			cmplw	r31,r29							; See if we have a valid system call number
-			slwi	r31,r31,MACH_TRAP_OFFSET_POW2	; Get offset into table
-		
-			bge-	.L_call_server_syscall_exception	; System call number of bogus
-
-			add		r31,r31,r28						; Point to the system call entry
-			lis		r28,hi16(EXT(kern_invalid))		; Get the high invalid routine address
-			lwz		r0,MACH_TRAP_FUNCTION(r31)		; Grab the system call routine address
-			ori		r28,r28,lo16(EXT(kern_invalid))	; Get the low part of the invalid routine address
-			lwz		r29,MACH_TRAP_ARGC(r31)			; Get the number of arguments in the call
-			cmplw	r0,r28							; Is this an invalid entry?
-			beq-	.L_call_server_syscall_exception	; Yes, it is invalid...
-		
-/* get arg count. If argc > 8 then not all args were in regs,
- * so we must perform copyin.
- */
-			cmpwi	cr0,r29,8						; Do we have more than 8 arguments?
-			ble+	.L_syscall_got_args				; Nope, no copy in needed...
-
-/* argc > 8  - perform a copyin */
-/* if the syscall came from kernel space, we can just copy */
-
-			lwz		r0,savesrr1(r30)				; Pick up exception time MSR
-			andi.	r0,r0,MASK(MSR_PR)				; Check the priv bit
-			bne+	.L_syscall_arg_copyin			; We are not priviliged...
-
-/* we came from a privilaged task, just do a copy */
-/* get user's stack pointer */
-
-			lwz		r28,saver1(r30)					; Get the stack pointer
-
-			subi	r29,r29,8						; Get the number of arguments to copy 
-
-			addi	r28,r28,COPYIN_ARG0_OFFSET-4	; Point to source - 4 
-			addi	r27,r1,FM_ARG0-4			; Point to sink - 4
-
-.L_syscall_copy_word_loop:
-			addic.	r29,r29,-1						; Count down the number of arguments left
-			lwz		r0,4(r28)						; Pick up the argument from the stack 
-			addi	r28,r28,4						; Point to the next source 
-			stw		r0,4(r27)						; Store the argument 
-			addi	r27,r27,4						; Point to the next sink 
-			bne+	.L_syscall_copy_word_loop		; Move all arguments... 
-			b		.L_syscall_got_args				; Go call it now... 
-
-
-/* we came from a user task, pay the price of a real copyin */	
-/* set recovery point */
-
-			.align	5
-
-.L_syscall_arg_copyin:
-			lwz		r8,ACT_VMMAP(r13)				; Get the vm_map for this activation
-			lis		r28,hi16(.L_syscall_copyin_recover)
-			lwz		r8,VMMAP_PMAP(r8)				; Get the pmap
-			ori		r28,r28,lo16(.L_syscall_copyin_recover)
-			addi	r8,r8,PMAP_SEGS					; Point to the pmap SR slots
-			stw		r28,THREAD_RECOVER(r16) 		; R16 still holds thread ptr 
-
-/* We can manipulate the COPYIN segment register quite easily
- * here, but we've also got to make sure we don't go over a
- * segment boundary - hence some mess.
- * Registers from 12-29 are free for our use.
- */
-	
-
-			lwz		r28,saver1(r30)					; Get the stack pointer 
-			subi	r29,r29,8						; Get the number of arguments to copy
-			addi	r28,r28,COPYIN_ARG0_OFFSET		; Set source in user land 
-
-/* set up SR_COPYIN to allow us to copy, we may need to loop
- * around if we change segments. We know that this previously
- * pointed to user space, so the sid doesn't need setting.
- */
-
-			rlwinm	r7,r28,6,26,29					; Get index to the segment slot
-
-.L_syscall_copyin_seg_loop:			
-			lwzx	r10,r8,r7						; Get the source SR value
-			rlwinm	r26,r28,0,4,31					; Clear the segment number from source address
-			mtsr	SR_COPYIN,r10					; Set the copyin SR
-			isync
+			
+ksysnotrc:	cmplw	r31,r29						; Is this syscall in the table?	
+			add		r31,r27,r28					; Point right to the syscall table entry
 
-			oris	r26,r26,(SR_COPYIN_NUM << (28-16))	; Insert the copyin segment number into source address
+			bge-	.L_call_server_syscall_exception	; The syscall number is invalid
 	
-			addi	r27,r1,FM_ARG0-4				; Point to area - 4 where we will store the arguments
-	
-.L_syscall_copyin_word_loop:			
-			lwz		r0,0(r26)						; MAY CAUSE PAGE FAULT!
-			subi	r29,r29,1						; Decrement count
-			addi	r26,r26,4						; Bump input
-			stw		r0,4(r27)						; Save the copied in word
-			mr.		r29,r29							; Are they all moved?
-			addi	r27,r27,4						; Bump output
-			beq+	.L_syscall_copyin_done			; Escape if we are done...
-	
-			rlwinm.	r0,r26,0,4,29					; Did we just step into a new segment?		
-			addi	r28,r28,4						; Bump up user state address also
-			bne+	.L_syscall_copyin_word_loop		; We are still on the same segment...
-
-			addi	r7,r7,4							; Bump to next slot
-			b		.L_syscall_copyin_seg_loop		; On new segment! remap 
-
-/* Don't bother restoring SR_COPYIN, we can leave it trashed */
-/* clear thread recovery as we're done touching user data */
-
-			.align	5
-
-.L_syscall_copyin_done:	
-			li		r0,0
-			stw		r0,THREAD_RECOVER(r16) 			; R16 still holds thread ptr 
-
-.L_syscall_got_args:
-			lwz		r0,MACH_TRAP_FUNCTION(r31)		; Get function address
-			lwz		r8,ACT_TASK(r13)				; Get our task 
-			lis		r10,hi16(EXT(c_syscalls_mach))	; Get top half of counter address
-			lwz		r7,TASK_SYSCALLS_MACH(r8)		; Get the current count
-			lwz		r3,saver3(r30)  				; Restore r3
-			addi	r7,r7,1							; Bump it
-			ori		r10,r10,lo16(EXT(c_syscalls_mach)) ; Get low half of counter address 
-			stw		r7,TASK_SYSCALLS_MACH(r8)		; Save it
-			lwz		r4,saver4(r30)  				; Restore r4 
-			lwz		r9,0(r10)						; Get counter	
-			mtctr	r0								; Set function address
-			lwz		r5,saver5(r30)  				; Restore r5 
-			lwz		r6,saver6(r30)  				; Restore r6
-			addi	r9,r9,1							; Add 1 
-			lwz		r7,saver7(r30)  				; Restore r7 
-			lwz		r8,saver8(r30)  				; Restore r8 
-			stw		r9,0(r10)						; Save it back	
-			lwz		r9,saver9(r30)  				; Restore r9 
-			lwz		r10,saver10(r30)  				; Restore r10
-
+			lwz		r0,MACH_TRAP_FUNCTION(r31)	; Pick up the function address
 
 ;
-;			Note that all arguments from the system call are passed into the function
+;	NOTE: We do not support more than 8 parameters for PPC.  The only 
+;	system call to use more than 8 is mach_msg_overwrite_trap and it
+;	uses 9.  We pass a 0 in as number 9.
 ;
-
-			bctrl									; Perform the actual syscall
+			lwz		r8,ACT_TASK(r13)			; Get our task 
+			lis		r29,hi16(EXT(kern_invalid))	; Get high half of invalid syscall function
+			ori		r29,r29,lo16(EXT(kern_invalid))	; Get low half of invalid syscall function
+			lwz		r7,TASK_SYSCALLS_MACH(r8)		; Get the current count
+			lis		r10,hi16(EXT(c_syscalls_mach))	; Get top half of counter address 
+			lwz		r3,saver3+4(r30)  			; Restore r3 
+			addi	r7,r7,1						; Bump it
+			cmp		cr0,r0,r29					; Check if this is an invalid system call
+			ori		r10,r10,lo16(EXT(c_syscalls_mach))	; Get low half of counter address 
+			beq-	.L_call_server_syscall_exception	; We have a bad one...
+			stw		r7,TASK_SYSCALLS_MACH(r8)	; Save count
+			lwz		r4,saver4+4(r30)  			; Restore r4 
+			lwz		r9,0(r10)					; Get counter 	
+			mtctr	r0							; Set the function call address
+			lwz		r5,saver5+4(r30)  			; Restore r5 
+			lwz		r6,saver6+4(r30)  			; Restore r6
+			addi	r9,r9,1						; Add 1 
+			lwz		r7,saver7+4(r30)  			; Restore r7
+			li		r0,0						; Clear this out
+			lwz		r8,saver8+4(r30)  			; Restore r8 
+			stw		r9,0(r10)					; Save it back
+			lwz		r9,saver9+4(r30)  			; Restore r9 
+			lwz		r10,saver10+4(r30)  		; Restore r10
+			stw		r0,FM_ARG0(r1)				; Clear that 9th parameter just in case some fool uses it
+			bctrl								; perform the actual syscall
+	
+			lis		r10,hi16(EXT(kdebug_enable))	; Get top of kdebug_enable 
+			ori		r10,r10,lo16(EXT(kdebug_enable))	; Get bottom of kdebug_enable 
+			lwz		r10,0(r10)					; Get kdebug_enable 
+			cmplwi	r10,0						; Is kdebug_enable false?
+	
+			beq++	.L_syscall_return			; No tracing...
+			mr		r4,r30						; Pass in the savearea
+			bl		EXT(syscall_trace_end)		; Trace the exit of the system call	
 
 /* 'standard' syscall returns here - INTERRUPTS ARE STILL ON */
 
@@ -634,16 +579,13 @@ LEXT(ppcscret)
 
 .L_syscall_return:	
 			mr		r31,r16							; Move the current thread pointer
-			stw		r3,saver3(r30)					; Stash the return code
-	
-			mr		r4,r30							; Pass in the savearea
-			bl		EXT(syscall_trace_end)			; Trace the exit of the system call	
+			stw		r3,saver3+4(r30)				; Stash the return code
 	
 .L_thread_syscall_ret_check_ast:	
+			lis		r10,hi16(MASK(MSR_VEC))			; Get the vector enable
 			mfmsr	r12								; Get the current MSR 
-			rlwinm	r12,r12,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-			rlwinm	r12,r12,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-			rlwinm	r12,r12,0,MSR_EE_BIT+1,MSR_EE_BIT-1	; Turn off interruptions enable bit
+			ori		r10,r10,lo16(MASK(MSR_FP)|MASK(MSR_EE))	; Add in FP and EE
+			andc	r12,r12,r10						; Turn off VEC, FP, and EE
 			mtmsr	r12								; Turn interruptions off
 			
 			mfsprg	r10,0							; Get the per_processor block
@@ -653,7 +595,7 @@ LEXT(ppcscret)
 			lwz		r4,PP_NEED_AST(r10)				; Get the pointer to the ast requests
 			lwz		r4,0(r4)						; Get the flags
 			cmpi	cr0,r4,	0						; Any pending asts?
-			beq+	cr0,.L_syscall_no_ast			; Nope...
+			beq++	cr0,.L_syscall_no_ast			; Nope...
 
 /* Yes there is, call ast_taken 
  * pretending that the user thread took an AST exception here,
@@ -662,9 +604,9 @@ LEXT(ppcscret)
 
 #if	DEBUG
 /* debug assert - make sure that we're not returning to kernel */
-			lwz		r3,savesrr1(r30)
+			lwz		r3,savesrr1+4(r30)
 			andi.	r3,r3,MASK(MSR_PR)
-			bne+	scrnotkern						; returning to user level, check 
+			bne++	scrnotkern						; returning to user level, check 
 			
 			lis		r0,hi16(Choke)					; Choke code
 			ori		r0,r0,lo16(Choke)				; and the rest
@@ -694,40 +636,17 @@ scrnotkern:
 .L_thread_syscall_return:
 
 			mr		r3,r30							; Get savearea to the correct register for common exit
-			mfsprg	r8,1				 			; Now find the current activation 
-
-			lwz		r11,SAVflags(r30)				; Get the flags 
 			lwz		r5,THREAD_KERNEL_STACK(r31)		; Get the base pointer to the stack 
-			rlwinm	r11,r11,0,15,13					; Clear the syscall flag
-			lwz		r4,SAVprev(r30)					; Get the previous save area
-			stw		r11,SAVflags(r30)				; Stick back the flags
+			lwz		r11,SAVflags(r30)				; Get the flags 
+			lwz		r4,SAVprev+4(r30)				; Get the previous save area
+			mfsprg	r8,1				 			; Now find the current activation 
 			addi	r5,r5,KERNEL_STACK_SIZE-FM_SIZE	; Reset to empty
 			stw		r4,ACT_MACT_PCB(r8)				; Save previous save area
+			rlwinm	r11,r11,0,15,13					; Clear the syscall flag
 			stw		r5,ACT_MACT_KSP(r8)				; Save the empty stack pointer
+			stw		r11,SAVflags(r30)				; Stick back the flags
 			b		chkfac							; Go end it all...
 
-			.align	5
-
-.L_syscall_copyin_recover:
-
-/* This is the catcher for any data faults in the copyin
- * of arguments from the user's stack.
- * r30 still holds a pointer to the PCB
- *
- * call syscall_error(EXC_BAD_ACCESS, EXC_PPC_VM_PROT_READ, sp, ssp),
- *
- * we already had a frame so we can do this
- */	
-	
-			li		r3,EXC_BAD_ACCESS				; Set bad access code
-			li		r4,EXC_PPC_VM_PROT_READ			; Set protection exception
-			lwz		r5,saver1(r30)					; Point to the stack
-			mr		r6,r30							; Pass savearea
-		
-			bl		EXT(syscall_error)				; Generate error...
-			b		.L_syscall_return				; Continue out...
-
-		
 /*
  * thread_exception_return()
  *
@@ -742,10 +661,10 @@ LEXT(thread_bootstrap_return)						; NOTE: THIS IS GOING AWAY IN A FEW DAYS....
 LEXT(thread_exception_return)						; Directly return to user mode
 
 .L_thread_exc_ret_check_ast:	
+			lis		r10,hi16(MASK(MSR_VEC))			; Get the vector enable
 			mfmsr	r3								; Get the MSR 
-			rlwinm	r3,r3,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-			rlwinm	r3,r3,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-			rlwinm	r3,r3,0,MSR_EE_BIT+1,MSR_EE_BIT-1	; Clear EE 
+			ori		r10,r10,lo16(MASK(MSR_FP)|MASK(MSR_EE))	; Add in FP and EE
+			andc	r3,r3,r10						; Turn off VEC, FP, and EE
 			mtmsr	r3								; Disable interrupts
 
 /* Check to see if there's an outstanding AST */
@@ -756,17 +675,16 @@ LEXT(thread_exception_return)						; Directly return to user mode
 		
 			mfsprg	r10,0							; Get the per_processor block 
 			lwz		r4,PP_NEED_AST(r10)
+			li		r3,AST_ALL
 			lwz		r4,0(r4)
 			cmpi	cr0,r4,	0
-			beq		cr0,.L_exc_ret_no_ast
+			li		r4,1
+			beq+		cr0,.L_exc_ret_no_ast
 		
 /* Yes there is, call ast_taken 
  * pretending that the user thread took an AST exception here,
  * ast_taken will save all state and bring us back here
  */
-	
-			li		r3,AST_ALL
-			li		r4,1
 			
 			bl		EXT(ast_taken)
 			b		.L_thread_exc_ret_check_ast		; check for a second AST (rare)
@@ -788,7 +706,7 @@ LEXT(thread_exception_return)						; Directly return to user mode
  * get the active thread's PCB pointer and thus pointer to user state
  */
 		
-			lwz		r3,savesrr1(r30)
+			lwz		r3,savesrr1+4(r30)
 			andi.	r3,r3,MASK(MSR_PR)
 			bne+	ret_user2						; We are ok...
 
@@ -805,9 +723,9 @@ ret_user2:
  * which takes PCB pointer in R3, not in r30!
  */
 			lwz		r0,SAVflags(r30)				; Grab the savearea flags
-			mr		r3,r30							; Copy pcb pointer into r3 in case we need it
 			andis.	r0,r0,SAVsyscall>>16			; Are we returning from a syscall?
-			beq-	cr0,thread_return				; Nope, must be a thread return...
+			mr		r3,r30							; Copy pcb pointer into r3 in case we need it
+			beq--	cr0,thread_return				; Nope, must be a thread return...
 			b		.L_thread_syscall_return		; Join up with the system call return...
 
 ;
@@ -823,7 +741,7 @@ makeDummyCtx:
 			li		r4,SAVgeneral					; Get the general context type
 			li		r0,0							; Get a 0
 			stb		r4,SAVflags+2(r3)				; Set type
-			addi	r2,r3,savevscr					; Point past what we are clearing
+			addi	r2,r3,savefpscr+4				; Point past what we are clearing
 			mr		r4,r3							; Save the start
 			
 cleardummy:	stw		r0,0(r4)						; Clear stuff
@@ -833,7 +751,7 @@ cleardummy:	stw		r0,0(r4)						; Clear stuff
 			
 			lis		r2,hi16(MSR_EXPORT_MASK_SET)	; Set the high part of the user MSR
 			ori		r2,r2,lo16(MSR_EXPORT_MASK_SET)	; And the low part
-			stw		r2,savesrr1(r3)					; Set the default user MSR
+			stw		r2,savesrr1+4(r3)				; Set the default user MSR
 	
 			b		thread_return					; Go let em try to execute, hah!
 	
@@ -857,7 +775,7 @@ LEXT(ihandler)										; Interrupt handler */
  * interrupt stack.
  */
 
-			lwz		r10,savesrr1(r4)				; Get SRR1 
+			lwz		r10,savesrr1+4(r4)				; Get SRR1 
 			lwz		r7,savevrsave(r4)				; Get the VRSAVE register
 			mfsprg	r25,0							; Get the per_proc block
 			li		r14,0							; Zero this for now
@@ -869,16 +787,15 @@ LEXT(ihandler)										; Interrupt handler */
 			beq+	ivecoff							; Vector off, do not save vrsave...
 			stw		r7,liveVRS(r25)					; Set the live value
 
-ivecoff:	li		r0,0							; Get a constant 0
-			cmplwi	cr1,r16,0						; Are we still booting? 
+ivecoff:	cmplwi	cr1,r16,0						; Are we still booting? 
 
 ifpoff:		mr.		r1,r1							; Is it active?
 			beq-	cr1,ihboot1						; We are still coming up...
 			lwz		r13,THREAD_TOP_ACT(r16)			; Pick up the active thread
 			lwz		r14,ACT_MACT_PCB(r13)			; Now point to the PCB 
 
-ihboot1:	lwz		r9,saver1(r4)					; Pick up the rupt time stack
-			stw		r14,SAVprev(r4)					; Queue the new save area in the front
+ihboot1:	lwz		r9,saver1+4(r4)					; Pick up the rupt time stack
+			stw		r14,SAVprev+4(r4)				; Queue the new save area in the front
 			stw		r13,SAVact(r4)					; Point the savearea at its activation
 			beq-	cr1,ihboot4						; We are still coming up...
 			stw		r4,ACT_MACT_PCB(r13)			; Point to our savearea 
@@ -900,19 +817,27 @@ ihboot4:	bne		.L_istackfree					; Nope...
 			subi	r5,r5,KERNEL_STACK_SIZE-FM_SIZE	; Adjust to start of stack
 			sub		r5,r1,r5						; Get displacement into debug stack
 			cmplwi	cr2,r5,KERNEL_STACK_SIZE-FM_SIZE	; Check if we are on debug stack
-			blt+	ihsetback						; Yeah, that is ok too...
+			blt+	cr2,ihsetback					; Yeah, that is ok too...
 
 			lis		r0,hi16(Choke)					; Choke code
 			ori		r0,r0,lo16(Choke)				; and the rest
 			li		r3,failStack					; Bad stack code
 			sc										; System ABEND
 
+intUnalignedStk:
+			lis		r0,hi16(Choke)					; Choke code
+			ori		r0,r0,lo16(Choke)				; and the rest
+			li		r3,failUnalignedStk				; Unaligned stack code
+			sc										; System ABEND
+
 			.align	5
 			
 .L_istackfree:
-			lwz		r10,SAVflags(r4)			
+			rlwinm.	r0,r1,0,28,31					; Check if stack is aligned (and get 0)
+			lwz		r10,SAVflags(r4)				; Get savearea flags
+			bne--	intUnalignedStk					; Stack is unaligned...
 			stw		r0,PP_ISTACKPTR(r25)			; Mark the stack in use 
-			oris	r10,r10,HIGH_ADDR(SAVrststk)	; Indicate we reset stack when we return from this one 
+			oris	r10,r10,hi16(SAVrststk)			; Indicate we reset stack when we return from this one 
 			stw		r10,SAVflags(r4)				; Stick it back		
 	
 /*
@@ -937,13 +862,13 @@ ihbootnover:										; (TEST/DEBUG)
  * which links back to the trapped routine. The second is
  * that which the C routine below will need
  */
-			lwz		r5,savesrr0(r4)					; Get interrupt address 
+			lwz		r5,savesrr0+4(r4)				; Get interrupt address 
 			stw		r5,FM_LR_SAVE(r1)				; save old instr ptr as LR value 
 			stwu	r1,-FM_SIZE(r1)					; Make another new frame for C routine
 #endif /* DEBUG */
 
 			lwz		r5,savedsisr(r4)				; Get the DSISR
-			lwz		r6,savedar(r4)					; Get the DAR 
+			lwz		r6,savedar+4(r4)				; Get the DAR 
 			
 			bl	EXT(interrupt)
 
@@ -956,26 +881,22 @@ ihbootnover:										; (TEST/DEBUG)
 
 LEXT(ihandler_ret)									; Marks our return point from debugger entry
 
+			lis		r10,hi16(MASK(MSR_VEC))			; Get the vector enable
 			mfmsr	r0								; Get our MSR
-			rlwinm	r0,r0,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-			rlwinm	r0,r0,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-			rlwinm	r0,r0,0,MSR_EE_BIT+1,MSR_EE_BIT-1	; Flip off the interrupt enabled bit
+			ori		r10,r10,lo16(MASK(MSR_FP)|MASK(MSR_EE))	; Add in FP and EE
+			andc	r0,r0,r10						; Turn off VEC, FP, and EE
 			mtmsr	r0								; Make sure interrupts are disabled
 			mfsprg	r10,0							; Get the per_proc block
 		
 			lwz		r7,SAVflags(r3)					; Pick up the flags
 			lwz		r8,PP_ACTIVE_THREAD(r10)		; and the active thread 
-			lwz		r9,SAVprev(r3)					; Get previous save area
+			lwz		r9,SAVprev+4(r3)					; Get previous save area
 			cmplwi	cr1,r8,0						; Are we still initializing?
-			lwz		r12,savesrr1(r3)				; Get the MSR we will load on return 
-			beq-	cr1,ihboot2						; Skip if we are still in init... 
+			lwz		r12,savesrr1+4(r3)				; Get the MSR we will load on return 
 			lwz		r8,THREAD_TOP_ACT(r8)			; Pick up the active thread 
-
-ihboot2:	andis.	r11,r7,hi16(SAVrststk)			; Is this the first on the stack?
-			beq-	cr1,ihboot3						; Skip if we are still in init... 
+			andis.	r11,r7,hi16(SAVrststk)			; Is this the first on the stack?
 			stw		r9,ACT_MACT_PCB(r8)				; Point to previous context savearea 
-
-ihboot3:	mr		r4,r3							; Move the savearea pointer
+			mr		r4,r3							; Move the savearea pointer
 			beq		.L_no_int_ast2					; Get going if not the top-o-stack...
 
 
@@ -988,7 +909,7 @@ ihboot3:	mr		r4,r3							; Move the savearea pointer
 			lwz		r9,PP_INTSTACK_TOP_SS(r10)		; Get the empty stack value 
 			andc	r7,r7,r11						; Remove the stack reset bit in case we pass this one
 			stw		r9,PP_ISTACKPTR(r10)			; Save that saved state ptr 
-			lwz		r3,PP_PREEMPT_CNT(r10)		; Get preemption level 
+			lwz		r3,ACT_PREEMPT_CNT(r8)			; Get preemption level 
 			stw		r7,SAVflags(r4)					; Save the flags
 			cmplwi	r3, 0							; Check for preemption
 			bne		.L_no_int_ast					; Do not preempt if level is not zero
@@ -1025,7 +946,7 @@ ihboot3:	mr		r4,r3							; Move the savearea pointer
 			rlwinm	r7,r7,0,15,13					; Clear the syscall flag
 			li		r4,0							; Assume for a moment that we are in init
 			stw		r7,SAVflags(r3)					; Set the flags with cleared syscall flag
-			beq-	cr1,chkfac						; Jump away if we are in init...
+			beq--	cr1,chkfac						; Jump away if we are in init...
 
 			lwz		r4,ACT_MACT_PCB(r8)				; Get the new level marker
 
@@ -1051,31 +972,27 @@ ihboot3:	mr		r4,r3							; Move the savearea pointer
 ;			are going to user state.  CR2_eq will be set to indicate deferred.
 ;
 
-chkfac:		mr		r31,r10							; Move per_proc address
-			mr		r30,r4							; Preserve new level
-			lwz		r29,savesrr1(r3)				; Get the current MSR
+chkfac:		lwz		r29,savesrr1+4(r3)				; Get the current MSR
 			mr.		r28,r8							; Are we still in boot?
+			mr		r31,r10							; Move per_proc address
+			mr		r30,r4							; Preserve new level
 			mr		r27,r3							; Save the old level
-			beq-	chkenax							; Yeah, skip it all...
+			beq--	chkenax							; Yeah, skip it all...
 			
 			rlwinm.	r0,r29,0,MSR_PR_BIT,MSR_PR_BIT	; Are we going into user state?
 
-#if 0
-			beq+	lllll							; (TEST/DEBUG)
-			BREAKPOINT_TRAP							; (TEST/DEBUG)
-lllll:
-#endif
-			
 			lwz		r20,curctx(r28)					; Get our current context
 			lwz		r26,deferctx(r28)				; Get any deferred context switch
+			li		r0,1							; Get set to hold off quickfret
 			rlwinm	r29,r29,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Turn off floating point for now
 			lwz		r21,FPUlevel(r20)				; Get the facility level
 			cmplwi	cr2,r26,0						; Are we going into a deferred context later?
 			rlwinm	r29,r29,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Turn off vector for now
 			crnor	cr2_eq,cr0_eq,cr2_eq			; Set cr2_eq if going to user state and there is deferred
-			cmplw	r27,r21							; Are we returning from the active level?
 			lhz		r19,PP_CPU_NUMBER(r31)			; Get our CPU number
-			bne+	fpuchkena						; Nope...
+			cmplw	r27,r21							; Are we returning from the active level?
+			stw		r0,holdQFret(r31)				; Make sure we hold off releasing quickfret
+			bne++	fpuchkena						; Nope...
 
 ;
 ;			First clean up any live context we are returning from
@@ -1086,21 +1003,28 @@ lllll:
 			stw		r19,FPUcpu(r20)					; Claim context for us
 			
 			eieio									; Make sure this gets out before owner clear
+
+#if ppSize != 4096
+#error per_proc_info is not 4k in size
+#endif
 			
 			lis		r23,hi16(EXT(per_proc_info))	; Set base per_proc
-			mulli	r22,r22,ppSize					; Find offset to the owner per_proc			
+			slwi	r22,r22,12						; FInd offset to the owner per_proc
 			ori		r23,r23,lo16(EXT(per_proc_info))	; Set base per_proc
 			li		r24,FPUowner					; Displacement to FPU owner
 			add		r22,r23,r22						; Point to the owner per_proc	
-			li		r0,0							; We need this in a bit
 			
 fpuinvothr:	lwarx	r23,r24,r22						; Get the owner
-			cmplw	r23,r20							; Does he still have this context?
-			bne		fpuinvoths						; Nope...		
-			stwcx.	r0,r24,r22						; Try to invalidate it
-			bne-	fpuinvothr						; Try again if there was a collision...
-			
-fpuinvoths:	isync
+
+			sub		r0,r23,r20						; Subtract one from the other
+			sub		r21,r20,r23						; Subtract the other from the one
+			or		r21,r21,r0						; Combine them
+			srawi	r21,r21,31						; Get a 0 if equal or -1 of not
+			and		r23,r23,r21						; Make 0 if same, unchanged if not
+			stwcx.	r23,r24,r22						; Try to invalidate it
+			bne--	fpuinvothr						; Try again if there was a collision...
+
+			isync
 
 ;
 ;			Now if there is a savearea associated with the popped context, release it.
@@ -1110,24 +1034,31 @@ fpuinvoths:	isync
 			lwz		r22,FPUsave(r20)				; Get pointer to the first savearea
 			li		r21,0							; Assume we popped all the way out
 			mr.		r22,r22							; Is there anything there?
-			beq+	fpusetlvl						; No, see if we need to enable...
+			beq++	fpusetlvl						; No, see if we need to enable...
 			
 			lwz		r21,SAVlevel(r22)				; Get the level of that savearea
 			cmplw	r21,r27							; Is this the saved copy of the live stuff?
 			bne		fpusetlvl						; No, leave as is...
 			
-			lwz		r24,SAVprev(r22)				; Pick up the previous area
+			lwz		r24,SAVprev+4(r22)				; Pick up the previous area
 			li		r21,0							; Assume we popped all the way out
 			mr.		r24,r24							; Any more context stacked?
-			beq-	fpuonlyone						; Nope...
+			beq--	fpuonlyone						; Nope...
 			lwz		r21,SAVlevel(r24)				; Get the level associated with save
 
 fpuonlyone:	stw		r24,FPUsave(r20)				; Dequeue this savearea
 
 			rlwinm	r3,r22,0,0,19					; Find main savearea header
-			lwz		r3,SACvrswap(r3)				; Get the virtual to real conversion
-			la		r9,quickfret(r31)				; Point to the quickfret chain header					
+
+			lwz		r8,quickfret(r31)				; Get the first in quickfret list (top)					
+			lwz		r9,quickfret+4(r31)				; Get the first in quickfret list (bottom)					
+			lwz		r2,SACvrswap(r3)				; Get the virtual to real conversion (top)
+			lwz		r3,SACvrswap+4(r3)				; Get the virtual to real conversion (bottom)
+			stw		r8,SAVprev(r22)					; Link the old in (top)					
+			stw		r9,SAVprev+4(r22)				; Link the old in (bottom)					
 			xor		r3,r22,r3						; Convert to physical
+			stw		r2,quickfret(r31)				; Set the first in quickfret list (top)					
+			stw		r3,quickfret+4(r31)				; Set the first in quickfret list (bottom)					
 			
 #if FPVECDBG
 			lis		r0,HIGH_ADDR(CutTrace)			; (TEST/DEBUG)
@@ -1136,11 +1067,6 @@ fpuonlyone:	stw		r24,FPUsave(r20)				; Dequeue this savearea
 			sc										; (TEST/DEBUG)
 #endif				
 
-fpufpucdq:	lwarx	r0,0,r9							; Pick up the old chain head
-			stw		r0,SAVprev(r22)					; Move it to the current guy
-			stwcx.	r3,0,r9							; Save it
-			bne-	fpufpucdq						; Someone chaged the list...
-
 fpusetlvl:	stw		r21,FPUlevel(r20)				; Save the level
 		
 ;
@@ -1150,33 +1076,65 @@ fpusetlvl:	stw		r21,FPUlevel(r20)				; Save the level
 ;			going into user state.
 ;
 			
-fpuchkena:	bt-		cr2_eq,fpuhasdfrd				; Skip if deferred, R26 already set up...
+fpuchkena:	bt--	cr2_eq,fpuhasdfrd				; Skip if deferred, R26 already set up...
 			mr		r26,r20							; Use the non-deferred value
 			
-fpuhasdfrd:	lwz		r21,FPUowner(r31)				; Get the ID of the live context
+fpuhasdfrd:	
+#if 0
+			rlwinm.	r0,r29,0,MSR_PR_BIT,MSR_PR_BIT	; (TEST/DEBUG) Going into user state?
+			beq		fpunusrstt						; (TEST/DEBUG) Nope...	
+			lwz		r23,FPUlevel(r26)				; (TEST/DEBUG) Get the level ID
+			lwz		r24,FPUsave(r26)				; (TEST/DEBUG) Get the first savearea
+			mr.		r23,r23							; (TEST/DEBUG) Should be level 0
+			beq++	fpulvl0							; (TEST/DEBUG) Yes...
+			BREAKPOINT_TRAP							; (TEST/DEBUG)
+			
+fpulvl0:	mr.		r24,r24							; (TEST/DEBUG) Any context?
+			beq		fpunusrstt						; (TEST/DEBUG) No...
+			lwz		r23,SAVlevel(r24)				; (TEST/DEBUG) Get level of context
+			lwz		r21,SAVprev+4(r24)				; (TEST/DEBUG) Get previous pointer
+			mr.		r23,r23							; (TEST/DEBUG) Is this our user context?
+			beq++	fpulvl0b						; (TEST/DEBUG) Yes...
+			BREAKPOINT_TRAP							; (TEST/DEBUG)
+			
+fpulvl0b:	mr.		r21,r21							; (TEST/DEBUG) Is there a forward chain?
+			beq++	fpunusrstt						; (TEST/DEBUG) Nope...
+			BREAKPOINT_TRAP							; (TEST/DEBUG)
+						
+fpunusrstt:											; (TEST/DEBUG)
+#endif				
+			
+			lwz		r21,FPUowner(r31)				; Get the ID of the live context
 			lwz		r23,FPUlevel(r26)				; Get the level ID
-			cmplw	cr3,r26,r21						; Do we have the live context?
 			lwz		r24,FPUcpu(r26)					; Get the CPU that the context was last dispatched on
-			bne-	cr3,chkvec						; No, can not possibly enable...
+			cmplw	cr3,r26,r21						; Do we have the live context?
 			cmplw	r30,r23							; Are we about to launch the live level?
+			bne--	cr3,chkvec						; No, can not possibly enable...
 			cmplw	cr1,r19,r24						; Was facility used on this processor last?
-			bne-	chkvec							; No, not live...
-			bne-	cr1,chkvec						; No, wrong cpu, have to enable later....
+			bne--	chkvec							; No, not live...
+			bne--	cr1,chkvec						; No, wrong cpu, have to enable later....
 			
 			lwz		r24,FPUsave(r26)				; Get the first savearea
 			mr.		r24,r24							; Any savearea?
-			beq+	fpuena							; Nope...
+			beq++	fpuena							; Nope...
 			lwz		r25,SAVlevel(r24)				; Get the level of savearea
-			lwz		r0,SAVprev(r24)					; Get the previous
+			lwz		r0,SAVprev+4(r24)				; Get the previous
 			cmplw	r30,r25							; Is savearea for the level we are launching?
-			bne+	fpuena							; No, just go enable...
+			bne++	fpuena							; No, just go enable...
 			
 			stw		r0,FPUsave(r26)					; Pop the chain
 
 			rlwinm	r3,r24,0,0,19					; Find main savearea header
-			lwz		r3,SACvrswap(r3)				; Get the virtual to real conversion
-			la		r9,quickfret(r31)				; Point to the quickfret chain header					
+
+			lwz		r8,quickfret(r31)				; Get the first in quickfret list (top)					
+			lwz		r9,quickfret+4(r31)				; Get the first in quickfret list (bottom)					
+			lwz		r2,SACvrswap(r3)				; Get the virtual to real conversion (top)
+			lwz		r3,SACvrswap+4(r3)				; Get the virtual to real conversion (bottom)
+			stw		r8,SAVprev(r24)					; Link the old in (top)					
+			stw		r9,SAVprev+4(r24)				; Link the old in (bottom)					
 			xor		r3,r24,r3						; Convert to physical
+			stw		r2,quickfret(r31)				; Set the first in quickfret list (top)					
+			stw		r3,quickfret+4(r31)				; Set the first in quickfret list (bottom)					
 
 #if FPVECDBG
 			lis		r0,HIGH_ADDR(CutTrace)			; (TEST/DEBUG)
@@ -1184,34 +1142,11 @@ fpuhasdfrd:	lwz		r21,FPUowner(r31)				; Get the ID of the live context
 			oris	r0,r0,LOW_ADDR(CutTrace)		; (TEST/DEBUG)
 			sc										; (TEST/DEBUG)
 #endif				
-			
-fpuhascdq:	lwarx	r0,0,r9							; Pick up the old chain head
-			stw		r0,SAVprev(r24)					; Move it to the current guy
-			stwcx.	r3,0,r9							; Save it
-			bne-	fpuhascdq						; Someone chaged the list...
 
 fpuena:		ori		r29,r29,lo16(MASK(MSR_FP))		; Enable facility			
 			
 chkvec:		
 
-#if 0
-			rlwinm.	r21,r29,0,MSR_PR_BIT,MSR_PR_BIT	; (TEST/DEBUG)
-			beq+	ppppp							; (TEST/DEBUG)
-			lwz		r21,FPUlevel(r26)				; (TEST/DEBUG)
-			mr.		r21,r21							; (TEST/DEBUG)
-			bne-	qqqqq							; (TEST/DEBUG)
-			lwz		r21,FPUsave(r26)				; (TEST/DEBUG)
-			mr.		r21,r21							; (TEST/DEBUG)
-			beq+	ppppp							; (TEST/DEBUG)
-			lwz		r22,SAVlevel(r21)				; (TEST/DEBUG)
-			mr.		r22,r22							; (TEST/DEBUG)
-			beq+	ppppp							; (TEST/DEBUG)
-qqqqq:
-			BREAKPOINT_TRAP							; (TEST/DEBUG)
-
-ppppp:												; (TEST/DEBUG)
-#endif
-			
 			lwz		r21,VMXlevel(r20)				; Get the facility level
 		
 			cmplw	r27,r21							; Are we returning from the active level?
@@ -1229,19 +1164,22 @@ ppppp:												; (TEST/DEBUG)
 			eieio									; Make sure this gets out before owner clear
 			
 			lis		r23,hi16(EXT(per_proc_info))	; Set base per_proc
-			mulli	r22,r22,ppSize					; Find offset to the owner per_proc			
+			slwi	r22,r22,12						; Find offset to the owner per_proc			
 			ori		r23,r23,lo16(EXT(per_proc_info))	; Set base per_proc
 			li		r24,VMXowner					; Displacement to VMX owner
 			add		r22,r23,r22						; Point to the owner per_proc	
-			li		r0,0							; We need this in a bit
 			
 vmxinvothr:	lwarx	r23,r24,r22						; Get the owner
-			cmplw	r23,r20							; Does he still have this context?
-			bne		vmxinvoths						; Nope...		
-			stwcx.	r0,r24,r22						; Try to invalidate it
-			bne-	vmxinvothr						; Try again if there was a collision...
-			
-vmxinvoths:	isync
+
+			sub		r0,r23,r20						; Subtract one from the other
+			sub		r21,r20,r23						; Subtract the other from the one
+			or		r21,r21,r0						; Combine them
+			srawi	r21,r21,31						; Get a 0 if equal or -1 of not
+			and		r23,r23,r21						; Make 0 if same, unchanged if not
+			stwcx.	r23,r24,r22						; Try to invalidate it
+			bne--	vmxinvothr						; Try again if there was a collision...
+
+			isync
 
 ;
 ;			Now if there is a savearea associated with the popped context, release it.
@@ -1251,24 +1189,31 @@ vmxinvoths:	isync
 			lwz		r22,VMXsave(r20)				; Get pointer to the first savearea
 			li		r21,0							; Assume we popped all the way out
 			mr.		r22,r22							; Is there anything there?
-			beq+	vmxsetlvl						; No, see if we need to enable...
+			beq++	vmxsetlvl						; No, see if we need to enable...
 			
 			lwz		r21,SAVlevel(r22)				; Get the level of that savearea
 			cmplw	r21,r27							; Is this the saved copy of the live stuff?
 			bne		vmxsetlvl						; No, leave as is...
 			
-			lwz		r24,SAVprev(r22)				; Pick up the previous area
+			lwz		r24,SAVprev+4(r22)				; Pick up the previous area
 			li		r21,0							; Assume we popped all the way out
 			mr.		r24,r24							; Any more context?
-			beq-	vmxonlyone						; Nope...
+			beq--	vmxonlyone						; Nope...
 			lwz		r21,SAVlevel(r24)				; Get the level associated with save
 
 vmxonlyone:	stw		r24,VMXsave(r20)				; Dequeue this savearea
 			
 			rlwinm	r3,r22,0,0,19					; Find main savearea header
-			lwz		r3,SACvrswap(r3)				; Get the virtual to real conversion
-			la		r9,quickfret(r31)				; Point to the quickfret chain header					
-			xor		r3,r22,r3						; Convert to physical
+
+			lwz		r8,quickfret(r31)				; Get the first in quickfret list (top)					
+			lwz		r9,quickfret+4(r31)				; Get the first in quickfret list (bottom)					
+			lwz		r2,SACvrswap(r3)				; Get the virtual to real conversion (top)
+			lwz		r3,SACvrswap+4(r3)				; Get the virtual to real conversion (bottom)
+			stw		r8,SAVprev(r22)					; Link the old in (top)					
+			stw		r9,SAVprev+4(r22)				; Link the old in (bottom)					
+			xor		r3,r24,r3						; Convert to physical
+			stw		r2,quickfret(r31)				; Set the first in quickfret list (top)					
+			stw		r3,quickfret+4(r31)				; Set the first in quickfret list (bottom)					
 
 #if FPVECDBG
 			lis		r0,HIGH_ADDR(CutTrace)			; (TEST/DEBUG)
@@ -1276,11 +1221,6 @@ vmxonlyone:	stw		r24,VMXsave(r20)				; Dequeue this savearea
 			oris	r0,r0,LOW_ADDR(CutTrace)		; (TEST/DEBUG)
 			sc										; (TEST/DEBUG)
 #endif				
-			
-vmxhscdq:	lwarx	r0,0,r9							; Pick up the old chain head
-			stw		r0,SAVprev(r22)					; Move it to the current guy
-			stwcx.	r3,0,r9							; Save it
-			bne-	vmxhscdq						; Someone chaged the list...
 
 vmxsetlvl:	stw		r21,VMXlevel(r20)				; Save the level
 		
@@ -1292,26 +1232,33 @@ vmxchkena:	lwz		r21,VMXowner(r31)				; Get the ID of the live context
 			lwz		r23,VMXlevel(r26)				; Get the level ID
 			cmplw	r26,r21							; Do we have the live context?
 			lwz		r24,VMXcpu(r26)					; Get the CPU that the context was last dispatched on
-			bne-	setena							; No, can not possibly enable...
+			bne--	setena							; No, can not possibly enable...
 			cmplw	r30,r23							; Are we about to launch the live level?
 			cmplw	cr1,r19,r24						; Was facility used on this processor last?
-			bne-	setena							; No, not live...
-			bne-	cr1,setena						; No, wrong cpu, have to enable later....
+			bne--	setena							; No, not live...
+			bne--	cr1,setena						; No, wrong cpu, have to enable later....
 			
 			lwz		r24,VMXsave(r26)				; Get the first savearea
 			mr.		r24,r24							; Any savearea?
-			beq+	vmxena							; Nope...
+			beq++	vmxena							; Nope...
 			lwz		r25,SAVlevel(r24)				; Get the level of savearea
-			lwz		r0,SAVprev(r24)					; Get the previous
+			lwz		r0,SAVprev+4(r24)				; Get the previous
 			cmplw	r30,r25							; Is savearea for the level we are launching?
-			bne+	vmxena							; No, just go enable...
+			bne++	vmxena							; No, just go enable...
 
 			stw		r0,VMXsave(r26)					; Pop the chain
 			
 			rlwinm	r3,r24,0,0,19					; Find main savearea header
-			lwz		r3,SACvrswap(r3)				; Get the virtual to real conversion
-			la		r9,quickfret(r31)				; Point to the quickfret chain header					
+
+			lwz		r8,quickfret(r31)				; Get the first in quickfret list (top)					
+			lwz		r9,quickfret+4(r31)				; Get the first in quickfret list (bottom)					
+			lwz		r2,SACvrswap(r3)				; Get the virtual to real conversion (top)
+			lwz		r3,SACvrswap+4(r3)				; Get the virtual to real conversion (bottom)
+			stw		r8,SAVprev(r24)					; Link the old in (top)					
+			stw		r9,SAVprev+4(r24)				; Link the old in (bottom)					
 			xor		r3,r24,r3						; Convert to physical
+			stw		r2,quickfret(r31)				; Set the first in quickfret list (top)					
+			stw		r3,quickfret+4(r31)				; Set the first in quickfret list (bottom)					
 
 #if FPVECDBG
 			lis		r0,HIGH_ADDR(CutTrace)			; (TEST/DEBUG)
@@ -1320,20 +1267,19 @@ vmxchkena:	lwz		r21,VMXowner(r31)				; Get the ID of the live context
 			sc										; (TEST/DEBUG)
 #endif				
 			
-vmxckcdq:	lwarx	r0,0,r9							; Pick up the old chain head
-			stw		r0,SAVprev(r24)					; Move it to the current guy
-			stwcx.	r3,0,r9							; Save it
-			bne-	vmxckcdq						; Someone chaged the list...
-			
 vmxena:		oris	r29,r29,hi16(MASK(MSR_VEC))		; Enable facility
 
-
-setena:		rlwinm.	r0,r29,0,MSR_PR_BIT,MSR_PR_BIT	; Are we about to launch user state?
-			rlwinm	r20,r29,(((31-vectorCngbit)+(MSR_VEC_BIT+1))&31),vectorCngbit,vectorCngbit	; Set flag if we enabled vector
-			stw		r29,savesrr1(r27)				; Turn facility on or off
+setena:		lwz		r18,cioSpace(r28)				; Get the space ID in case we are launching user
+			rlwinm.	r0,r29,0,MSR_PR_BIT,MSR_PR_BIT	; Are we about to launch user state?
+			li		r0,0							; Get set to release quickfret holdoff
 			crmove	cr7_eq,cr0_eq					; Remember if we are going to user state
-			lwz		r19,deferctx(r28)				; Get any deferred facility context switch
 			rlwimi.	r20,r29,(((31-floatCngbit)+(MSR_FP_BIT+1))&31),floatCngbit,floatCngbit	; Set flag if we enabled floats
+			lwz		r19,deferctx(r28)				; Get any deferred facility context switch
+			rlwinm	r20,r29,(((31-vectorCngbit)+(MSR_VEC_BIT+1))&31),vectorCngbit,vectorCngbit	; Set flag if we enabled vector
+			stw		r29,savesrr1+4(r27)				; Turn facility on or off
+			stw		r0,holdQFret(r31)				; Release quickfret
+			oris	r18,r18,hi16(cioSwitchAway)		; Set the switch-away bit in case we go to user
+
 			beq		setenaa							; Neither float nor vector turned on....
 			
 			lwz		r5,ACT_MACT_SPF(r28)			; Get activation copy
@@ -1353,15 +1299,15 @@ setenaa:	mfdec	r24								; Get decrementer
 nodefer:	lwz		r22,qactTimer(r28)				; Get high order quick activation timer
 			mr.		r24,r24							; See if it has popped already...
 			lwz		r23,qactTimer+4(r28)			; Get low order qact timer
-			ble-	chkenax							; We have popped or are just about to...
+			ble-	chkifuser						; We have popped or are just about to...
 			
 segtb:		mftbu	r20								; Get the upper time base
 			mftb	r21								; Get the low
 			mftbu	r19								; Get upper again
 			or.		r0,r22,r23						; Any time set?
 			cmplw	cr1,r20,r19						; Did they change?
-			beq+	chkenax							; No time set....
-			bne-	cr1,segtb						; Timebase ticked, get them again...
+			beq++	chkifuser						; No time set....
+			bne--	cr1,segtb						; Timebase ticked, get them again...
 			
 			subfc	r6,r21,r23						; Subtract current from qact time
 			li		r0,0							; Make a 0
@@ -1369,12 +1315,15 @@ segtb:		mftbu	r20								; Get the upper time base
 			subfze	r0,r0							; Get a 0 if qact was bigger than current, -1 otherwise
 			andc.	r12,r5,r0						; Set 0 if qact has passed
 			andc	r13,r6,r0						; Set 0 if qact has passed
-			bne		chkenax							; If high order is non-zero, this is too big for a decrementer
+			bne		chkifuser						; If high order is non-zero, this is too big for a decrementer
 			cmplw	r13,r24							; Is this earlier than the decrementer? (logical compare takes care of high bit on)
-			bge+	chkenax							; No, do not reset decrementer...
+			bge++	chkifuser						; No, do not reset decrementer...
 			
 			mtdec	r13								; Set our value
 
+chkifuser:	beq--	cr7,chkenax						; Skip this if we are going to kernel...
+			stw		r18,cioSpace(r28)				; Half-invalidate to force MapUserAddressSpace to reload SRs
+
 chkenax:	
 
 	
@@ -1396,13 +1345,40 @@ chkenax:
 yeswereok:
 #endif
 	
-			rlwinm	r5,r27,0,0,19					; Round savearea down to page bndry
-			lwz		r5,SACvrswap(r5)				; Get the conversion from virtual to real
-			xor		r3,r27,r5						; Flip to physical address
+			mr		r3,r27							; Pass savearea back
 			b		EXT(exception_exit)				; We are all done now...
 
 
 
+;
+;			Null PPC call - performance testing, does absolutely nothing
+;
+
+			.align	5
+			
+			.globl	EXT(ppcNull)
+			
+LEXT(ppcNull)
+
+			li		r3,-1							; Make sure we test no asts
+			blr
+
+
+;
+;			Instrumented null PPC call - performance testing, does absolutely nothing
+;			Forces various timestamps to be returned.
+;
+
+			.align	5
+			
+			.globl	EXT(ppcNullinst)
+			
+LEXT(ppcNullinst)
+
+			li		r3,-1							; Make sure we test no asts
+			blr
+
+
 /*
  *			Here's where we handle the fastpath stuff
  *			We'll do what we can here because registers are already
@@ -1421,8 +1397,10 @@ yeswereok:
 
 			.align	5
 
-fastpath:	cmplwi	cr3,r0,0x7FF1				; Is it CthreadSetSelfNumber? 	
-			bnelr-	cr3							; Not a fast path...
+fastpath:	cmplwi	cr3,r0,0x7FF5				; Is this a null fastpath?
+			beq--	cr3,fastexutl				; Yes, bail fast...
+			cmplwi	cr3,r0,0x7FF1				; Is it CthreadSetSelfNumber? 	
+			bnelr--	cr3							; Not a fast path...
 
 /*
  * void cthread_set_self(cproc_t p)
@@ -1438,17 +1416,15 @@ fastpath:	cmplwi	cr3,r0,0x7FF1				; Is it CthreadSetSelfNumber?
 
 CthreadSetSelfNumber:
 
-			lwz		r5,saver3(r4)				/* Retrieve the self number */
+			lwz		r5,saver3+4(r4)				/* Retrieve the self number */
 			stw		r5,CTHREAD_SELF(r13)		/* Remember it */
 			stw		r5,UAW(r25)					/* Prime the per_proc_info with it */
 
 
 			.globl	EXT(fastexit)
 EXT(fastexit):
-			rlwinm	r9,r4,0,0,19				/* Round down to the base savearea block */
-			lwz		r9,SACvrswap(r9)			/* Get the conversion from virtual to real */
-			xor		r3,r4,r9					/* Switch savearea to physical addressing */
-			b		EXT(exception_exit)			/* Go back to the caller... */
+fastexutl:	mr		r3,r4						; Pass back savearea
+			b		EXT(exception_exit)			; Go back to the caller...
 
 
 /*
@@ -1462,12 +1438,12 @@ EXT(fastexit):
 			
 checkassist:
 			lwz		r0,saveexception(r4)		; Get the exception code
-			lwz		r23,savesrr1(r4)			; Get the interrupted MSR 
+			lwz		r23,savesrr1+4(r4)			; Get the interrupted MSR 
 			lwz		r26,ACT_MACT_BEDA(r13)		; Get Blue Box Descriptor Area
 			mtcrf	0x18,r23					; Check what SRR1 says
 			lwz		r24,ACT_MACT_BTS(r13)		; Get the table start 
 			cmplwi	r0,T_AST					; Check for T_AST trap 
-			lwz		r27,savesrr0(r4)			; Get trapped address 
+			lwz		r27,savesrr0+4(r4)			; Get trapped address 
 			crnand	cr1_eq,SRR1_PRG_TRAP_BIT,MSR_PR_BIT	; We need both trap and user state
 			sub		r24,r27,r24					; See how far into it we are 
 			cror	cr0_eq,cr0_eq,cr1_eq		; Need to bail if AST or not trap or not user state
@@ -1497,7 +1473,7 @@ exitFromVM:	mr		r30,r4						; Get the savearea
 LEXT(retFromVM)
 			mfsprg	r10,0						; Restore the per_proc info
 			mr		r8,r3						; Get the activation
-			lwz		r4,SAVprev(r30)				; Pick up the previous savearea
+			lwz		r4,SAVprev+4(r30)			; Pick up the previous savearea
 			mr		r3,r30						; Put savearea in proper register for common code
 			lwz		r11,SAVflags(r30)			; Get the flags of the current savearea
 			rlwinm	r11,r11,0,15,13				; Clear the syscall flag 
@@ -1531,15 +1507,13 @@ LEXT(retFromVM)
 
 			.align	5
 			.globl EXT(chandler)
-LEXT(chandler)									/* Choke handler */
+LEXT(chandler)									; Choke handler
 
-			lis		r25,hi16(EXT(trcWork))		; (TEST/DEBUG)
-			li		r31,0						; (TEST/DEBUG)
-			ori		r25,r25,lo16(EXT(trcWork))	; (TEST/DEBUG)
-			stw		r31,traceMask(r25)			; (TEST/DEBUG)
+			li		r31,0						; Get a 0
+			mfsprg	r25,0						; Get the per_proc 
+			stw		r31,traceMask(0)			; Force tracing off right now
 		
 		
-			mfsprg	r25,0						; Get the per_proc 
 		
 			lwz		r1,PP_DEBSTACKPTR(r25)		; Get debug stack pointer
 			cmpwi	r1,-1						; Are we already choking?
@@ -1555,7 +1529,7 @@ chokespin:	addi	r31,r31,1					; Spin and hope for an analyzer connection...
 			
 chokefirst:	li		r0,-1						; Set choke value
 			mr.		r1,r1						; See if we are on debug stack yet
-			lwz		r10,saver1(r4)				; 
+			lwz		r10,saver1+4(r4)			; 
 			stw		r0,PP_DEBSTACKPTR(r25)		; Show we are choking
 			bne		chokestart					; We are not on the debug stack yet...
 			
@@ -1580,7 +1554,22 @@ chokestart:	li		r0,0						; Get a zero
 ;
 		
 versave:	
-#if 1
+#if 0
+			lis		r22,hi16(EXT(DebugWork))		; (TEST/DEBUG)
+			ori		r22,r22,lo16(EXT(DebugWork))	; (TEST/DEBUG)
+			lwz		r23,0(r22)						; (TEST/DEBUG)
+			mr.		r23,r23							; (TEST/DEBUG)
+			beqlr-									; (TEST/DEBUG)
+			mfsprg	r20,0							; (TEST/DEBUG)
+			lwz		r21,pfAvailable(r20)			; (TEST/DEBUG)
+			mr.		r21,r21							; (TEST/DEBUG)
+			bnelr+									; (TEST/DEBUG)
+			
+			stw		r22,0(r22)						; (TEST/DEBUG) Lock out more checks
+			BREAKPOINT_TRAP							; (TEST/DEBUG) Get into debugger
+#endif
+
+#if 0
 ;
 ;			Make sure that all savearea chains have the right type on them
 ;
@@ -1659,190 +1648,9 @@ versavetype:
 			stw		r22,0(r22)						; (TEST/DEBUG) Lock out more checks
 			BREAKPOINT_TRAP							; (TEST/DEBUG) Get into debugger
 			
-versvok:	lwz		r20,SAVprev(r20)				; (TEST/DEBUG) Get the previous one
+versvok:	lwz		r20,SAVprev+4(r20)				; (TEST/DEBUG) Get the previous one
 			b		versavetype						; (TEST/DEBUG) Go check its type...
 #endif
 
-#if 0
-;
-;			Make sure there are no circular links in the float chain
-;			And that FP is marked busy in it.
-;			And the only the top is marked invalid.
-;			And that the owning PCB is correct.
-;
 
-			lis		r28,hi16(EXT(default_pset))		; (TEST/DEBUG)
-			lis		r27,hi16(EXT(DebugWork))		; (TEST/DEBUG)
-			ori		r28,r28,lo16(EXT(default_pset))	; (TEST/DEBUG)
-			ori		r27,r27,lo16(EXT(DebugWork))	; (TEST/DEBUG)
-			li		r20,0							; (TEST/DEBUG)
-			lwz		r26,0(r27)						; (TEST/DEBUG)
-			lwz		r27,psthreadcnt(r28)			; (TEST/DEBUG)
-			mr.		r26,r26							; (TEST/DEBUG)
-			lwz		r28,psthreads(r28)				; (TEST/DEBUG)
-			bnelr-									; (TEST/DEBUG)
-			
-fcknxtth:	mr.		r27,r27							; (TEST/DEBUG)
-			beqlr-									; (TEST/DEBUG)
-			
-			lwz		r26,THREAD_TOP_ACT(r28)			; (TEST/DEBUG)
-
-fckact:		mr.		r26,r26							; (TEST/DEBUG)
-			bne+	fckact2							; (TEST/DEBUG)
-			
-			lwz		r28,THREAD_PSTHRN(r28)			; (TEST/DEBUG) Next in line
-			subi	r27,r27,1						; (TEST/DEBUG)
-			b		fcknxtth						; (TEST/DEBUG) 
-	
-fckact2:	lwz		r20,ACT_MACT_FPU(r26)			; (TEST/DEBUG) Get FPU chain
-			li		r29,1							; (TEST/DEBUG)
-			li		r22,0							; (TEST/DEBUG)
-
-fckact3:	mr.		r20,r20							; (TEST/DEBUG) Are there any?
-			beq+	fckact5							; (TEST/DEBUG) No...
-			
-			addi	r22,r22,1						; (TEST/DEBUG) Count chain depth
-			
-			lwz		r21,SAVflags(r20)				; (TEST/DEBUG) Get the flags
-			rlwinm.	r21,r21,0,1,1					; (TEST/DEBUG) FP busy?
-			bne+	fckact3a						; (TEST/DEBUG) Yeah...
-			lis		r27,hi16(EXT(DebugWork))		; (TEST/DEBUG)
-			ori		r27,r27,lo16(EXT(DebugWork))	; (TEST/DEBUG)
-			stw		r27,0(r27)						; (TEST/DEBUG)
-			BREAKPOINT_TRAP							; (TEST/DEBUG) Die
-			
-fckact3a:	cmplwi	r22,1							; (TEST/DEBUG) At first SA?
-			beq+	fckact3b						; (TEST/DEBUG) Yeah, invalid is ok...
-			lwz		r21,SAVlvlfp(r20)				; (TEST/DEBUG) Get level
-			cmplwi	r21,1							; (TEST/DEBUG) Is it invalid?
-			bne+	fckact3b						; (TEST/DEBUG) Nope, it is ok...
-			lis		r27,hi16(EXT(DebugWork))		; (TEST/DEBUG)
-			ori		r27,r27,lo16(EXT(DebugWork))	; (TEST/DEBUG)
-			stw		r27,0(r27)						; (TEST/DEBUG)
-			BREAKPOINT_TRAP							; (TEST/DEBUG) Die
-			
-fckact3b:	lwz		r21,SAVact(r20)					; (TEST/DEBUG) Get the owner
-			cmplw	r21,r26							; (TEST/DEBUG) Correct activation?
-			beq+	fckact3c						; (TEST/DEBUG) Yup...
-			lis		r27,hi16(EXT(DebugWork))		; (TEST/DEBUG)
-			ori		r27,r27,lo16(EXT(DebugWork))	; (TEST/DEBUG)
-			stw		r27,0(r27)						; (TEST/DEBUG)
-			BREAKPOINT_TRAP							; (TEST/DEBUG) Die
-
-fckact3c:											; (TEST/DEBUG)
-			lbz		r21,SAVflags+3(r20)				; (TEST/DEBUG) Pick up the test byte
-			mr.		r21,r21							; (TEST/DEBUG) marked?
-			beq+	fckact4							; (TEST/DEBUG) No, good...
-			
-			lis		r27,hi16(EXT(DebugWork))		; (TEST/DEBUG)
-			ori		r27,r27,lo16(EXT(DebugWork))	; (TEST/DEBUG)
-			stw		r27,0(r27)						; (TEST/DEBUG)
-			BREAKPOINT_TRAP							; (TEST/DEBUG)
-			
-fckact4:	stb		r29,SAVflags+3(r20)				; (TEST/DEBUG) Set the test byte
-			lwz		r20,SAVprefp(r20)				; (TEST/DEBUG) Next in list
-			b		fckact3							; (TEST/DEBUG) Try it...
-
-fckact5:	lwz		r20,ACT_MACT_FPU(r26)			; (TEST/DEBUG) Get FPU chain
-			li		r29,0							; (TEST/DEBUG)
-
-fckact6:	mr.		r20,r20							; (TEST/DEBUG) Are there any?
-			beq+	fcknact							; (TEST/DEBUG) No...
-			
-			stb		r29,SAVflags+3(r20)				; (TEST/DEBUG) Clear the test byte
-			lwz		r20,SAVprefp(r20)				; (TEST/DEBUG) Next in list
-			b		fckact6							; (TEST/DEBUG) Try it...
-			
-fcknact:	lwz		r26,ACT_LOWER(r26)				; (TEST/DEBUG) Next activation
-			b		fckact							; (TEST/DEBUG)
-#endif
-
-
-#if 0
-;
-;			Make sure in use count matches found savearea.  This is
-;			not always accurate.  There is a variable "fuzz" factor in count.
-
-			lis		r28,hi16(EXT(default_pset))		; (TEST/DEBUG)
-			lis		r27,hi16(EXT(DebugWork))		; (TEST/DEBUG)
-			ori		r28,r28,lo16(EXT(default_pset))	; (TEST/DEBUG)
-			ori		r27,r27,lo16(EXT(DebugWork))	; (TEST/DEBUG)
-			li		r20,0							; (TEST/DEBUG)
-			lwz		r26,0(r27)						; (TEST/DEBUG)
-			lwz		r27,psthreadcnt(r28)			; (TEST/DEBUG)
-			mr.		r26,r26							; (TEST/DEBUG)
-			lwz		r28,psthreads(r28)				; (TEST/DEBUG)
-			bnelr-									; (TEST/DEBUG)
-			
-cknxtth:	mr.		r27,r27							; (TEST/DEBUG)
-			beq-	cktotal							; (TEST/DEBUG)
-			
-			lwz		r26,THREAD_TOP_ACT(r28)			; (TEST/DEBUG)
-
-ckact:		mr.		r26,r26							; (TEST/DEBUG)
-			bne+	ckact2							; (TEST/DEBUG)
-			
-			lwz		r28,THREAD_PSTHRN(r28)			; (TEST/DEBUG) Next in line
-			subi	r27,r27,1						; (TEST/DEBUG)
-			b		cknxtth							; (TEST/DEBUG) 
-			
-ckact2:		lwz		r29,ACT_MACT_PCB(r26)			; (TEST/DEBUG)
-			
-cknorm:		mr.		r29,r29							; (TEST/DEBUG)
-			beq-	cknormd							; (TEST/DEBUG)
-			
-			addi	r20,r20,1						; (TEST/DEBUG) Count normal savearea
-			
-			lwz		r29,SAVprev(r29)				; (TEST/DEBUG)
-			b		cknorm							; (TEST/DEBUG)
-			
-cknormd:	lwz		r29,ACT_MACT_FPU(r26)			; (TEST/DEBUG)
-
-ckfpu:		mr.		r29,r29							; (TEST/DEBUG)
-			beq-	ckfpud							; (TEST/DEBUG)
-			
-			lwz		r21,SAVflags(r29)				; (TEST/DEBUG)
-			rlwinm.	r21,r21,0,0,0					; (TEST/DEBUG) See if already counted
-			bne-	cknfpu							; (TEST/DEBUG)
-			
-			addi	r20,r20,1						; (TEST/DEBUG) Count fpu savearea
-			
-cknfpu:		lwz		r29,SAVprefp(r29)				; (TEST/DEBUG)
-			b		ckfpu							; (TEST/DEBUG)
-			
-ckfpud:		lwz		r29,ACT_MACT_VMX(r26)			; (TEST/DEBUG)
-
-ckvmx:		mr.		r29,r29							; (TEST/DEBUG)
-			beq-	ckvmxd							; (TEST/DEBUG)
-			
-			lwz		r21,SAVflags(r29)				; (TEST/DEBUG)
-			rlwinm.	r21,r21,0,0,1					; (TEST/DEBUG) See if already counted
-			bne-	cknvmx							; (TEST/DEBUG)
-			
-			addi	r20,r20,1						; (TEST/DEBUG) Count vector savearea
-			
-cknvmx:		lwz		r29,SAVprevec(r29)				; (TEST/DEBUG)
-			b		ckvmx							; (TEST/DEBUG)
-			
-ckvmxd:		lwz		r26,ACT_LOWER(r26)				; (TEST/DEBUG) Next activation
-			b		ckact							; (TEST/DEBUG)
-
-cktotal:	lis		r28,hi16(EXT(saveanchor))		; (TEST/DEBUG)
-			lis		r27,hi16(EXT(real_ncpus))		; (TEST/DEBUG)
-			ori		r28,r28,lo16(EXT(saveanchor))	; (TEST/DEBUG)
-			ori		r27,r27,lo16(EXT(real_ncpus))	; (TEST/DEBUG)
-
-			lwz		r21,SVinuse(r28)				; (TEST/DEBUG)
-			lwz		r27,0(r27)						; (TEST/DEBUG) Get the number of CPUs
-			sub.	r29,r21,r20						; (TEST/DEBUG) Get number accounted for
-			blt-	badsave							; (TEST/DEBUG) Have too many in use...
-			sub		r26,r29,r27						; (TEST/DEBUG) Should be 1 unaccounted for for each processor
-			cmpwi	r26,10							; (TEST/DEBUG) Allow a 10 area slop factor
-			bltlr+									; (TEST/DEBUG)
-			
-badsave:	lis		r27,hi16(EXT(DebugWork))		; (TEST/DEBUG)
-			ori		r27,r27,lo16(EXT(DebugWork))	; (TEST/DEBUG)
-			stw		r27,0(r27)						; (TEST/DEBUG)
-			BREAKPOINT_TRAP							; (TEST/DEBUG)
-#endif
 #endif	
diff --git a/osfmk/ppc/hw_lock.s b/osfmk/ppc/hw_lock.s
index ec68b45a8..08605f5f7 100644
--- a/osfmk/ppc/hw_lock.s
+++ b/osfmk/ppc/hw_lock.s
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -24,9 +27,6 @@
 #include <mach_assert.h>
 #include <mach_ldebug.h>
 #include <mach_rt.h>
-
-#include <kern/etap_options.h>
-	
 #include <ppc/asm.h>
 #include <ppc/proc_reg.h>
 #include <assym.s>
@@ -39,45 +39,34 @@
 
 #define	ILK_LOCKED		0x01
 #define	WAIT_FLAG		0x02
-#define	SLOCK_FAST		0x02
 #define TH_FN_OWNED		0x01
 
-;
-;		NOTE: make sure that PREEMPTSTACK in aligned_data is
-;		set the same as it is here.  This is the number of
-;		traceback entries we can handle per processor
-;
-;		A value of 0 disables the stack.
-;
-#define PREEMPTSTACK 0
 #define CHECKNMI 0
 #define CHECKLOCKS 1
 
-#include <ppc/POWERMAC/mp/mp.h>
-
-#define PROLOG(space)							  \
-			stwu	r1,-(FM_ALIGN(space)+FM_SIZE)(r1)	__ASMNL__ \
-			mflr	r0							__ASMNL__ \
-			stw		r3,FM_ARG0(r1)				__ASMNL__ \
+#define PROLOG(space)											\
+			stwu	r1,-(FM_ALIGN(space)+FM_SIZE)(r1)	__ASMNL__	\
+			mflr	r0								__ASMNL__	\
+			stw		r3,FM_ARG0(r1)					__ASMNL__	\
 			stw		r0,(FM_ALIGN(space)+FM_SIZE+FM_LR_SAVE)(r1)	__ASMNL__
 	
-#define EPILOG									  \
-			lwz		r1,0(r1)					__ASMNL__ \
-			lwz		r0,FM_LR_SAVE(r1)			__ASMNL__ \
-			mtlr	r0							__ASMNL__					
+#define EPILOG												 	\
+			lwz		r1,0(r1)						__ASMNL__	\
+			lwz		r0,FM_LR_SAVE(r1)				__ASMNL__	\
+			mtlr	r0								__ASMNL__
 
 #if	MACH_LDEBUG && CHECKLOCKS
 /*
  * Routines for general lock debugging.
  */
 
-/* Gets lock check flags in CR6: CR bits 24-27 */
+/* 
+ * Gets lock check flags in CR6: CR bits 24-27
+ */
 
-#define CHECK_SETUP(rg)									\
-			lis		rg,hi16(EXT(dgWork))	__ASMNL__ 	\
-			ori		rg,rg,lo16(EXT(dgWork))	__ASMNL__ 	\
-			lbz		rg,dgFlags(rg)			__ASMNL__ 	\
-			mtcrf	2,rg					__ASMNL__ 
+#define CHECK_SETUP(rg)											\
+			lbz		rg,dgFlags(0)					__ASMNL__ 	\
+			mtcrf	2,rg							__ASMNL__ 
 
 
 /*
@@ -85,15 +74,15 @@
  * mismatch.  Detects calls to Mutex functions with
  * type simplelock and vice versa.
  */
-#define	CHECK_MUTEX_TYPE()							\
-			bt		24+disLktypeb,1f			__ASMNL__ 	\
-			lwz		r10,MUTEX_TYPE(r3)			__ASMNL__ 	\
-			cmpwi	r10,MUTEX_TAG				__ASMNL__	\
-			beq+	1f							__ASMNL__	\
-			lis		r3,hi16(not_a_mutex)		__ASMNL__	\
-			ori		r3,r3,lo16(not_a_mutex)		__ASMNL__	\
-			bl		EXT(panic)					__ASMNL__	\
-			lwz		r3,FM_ARG0(r1)				__ASMNL__	\
+#define	CHECK_MUTEX_TYPE()										\
+			bt		24+disLktypeb,1f				__ASMNL__ 	\
+			lwz		r10,MUTEX_TYPE(r3)				__ASMNL__ 	\
+			cmpwi	r10,MUTEX_TAG					__ASMNL__	\
+			beq+	1f								__ASMNL__	\
+			lis		r3,hi16(not_a_mutex)			__ASMNL__	\
+			ori		r3,r3,lo16(not_a_mutex)			__ASMNL__	\
+			bl		EXT(panic)						__ASMNL__	\
+			lwz		r3,FM_ARG0(r1)					__ASMNL__	\
 1:
 	
 	.data
@@ -101,15 +90,15 @@ not_a_mutex:
 			STRINGD	"not a mutex!\n\000"
 			.text
 
-#define CHECK_SIMPLE_LOCK_TYPE()					\
-			bt		24+disLktypeb,1f			__ASMNL__ 	\
-			lwz		r10,SLOCK_TYPE(r3)			__ASMNL__ 	\
-			cmpwi	r10,USLOCK_TAG				__ASMNL__ 	\
-			beq+	1f							__ASMNL__ 	\
-			lis		r3,hi16(not_a_slock)		__ASMNL__ 	\
-			ori		r3,r3,lo16(not_a_slock) 	__ASMNL__ 	\
-			bl		EXT(panic)					__ASMNL__ 	\
-			lwz		r3,FM_ARG0(r1)				__ASMNL__ 	\
+#define CHECK_SIMPLE_LOCK_TYPE()								\
+			bt		24+disLktypeb,1f				__ASMNL__ 	\
+			lhz		r10,SLOCK_TYPE(r3)				__ASMNL__ 	\
+			cmpwi	r10,USLOCK_TAG					__ASMNL__ 	\
+			beq+	1f								__ASMNL__ 	\
+			lis		r3,hi16(not_a_slock)			__ASMNL__ 	\
+			ori		r3,r3,lo16(not_a_slock) 		__ASMNL__ 	\
+			bl		EXT(panic)						__ASMNL__ 	\
+			lwz		r3,FM_ARG0(r1)					__ASMNL__ 	\
 1:
 	
 	.data
@@ -117,24 +106,26 @@ not_a_slock:
 			STRINGD	"not a simple lock!\n\000"
 			.text
 
-#define CHECK_NO_SIMPLELOCKS()							\
-			bt		24+disLkNmSimpb,2f			__ASMNL__ 	\
-			mfmsr	r11							__ASMNL__	\
-			rlwinm	r11,r11,0,MSR_FP_BIT+1,MSR_FP_BIT-1	__ASMNL__	\
-			rlwinm	r11,r11,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	__ASMNL__	\
-			rlwinm  r10,r11,0,MSR_EE_BIT+1,MSR_EE_BIT-1	__ASMNL__	\
-			mtmsr	r10							__ASMNL__	\
-			isync								__ASMNL__	\
-			mfsprg	r10,0						__ASMNL__	\
-			lwz		r10,PP_SIMPLE_LOCK_CNT(r10) __ASMNL__	\
-			cmpwi	r10,0 						__ASMNL__	\
-			beq+	1f 							__ASMNL__	\
-			lis		r3,hi16(simple_locks_held) __ASMNL__	\
-			ori		r3,r3,lo16(simple_locks_held) __ASMNL__	\
-			bl		EXT(panic)	 				__ASMNL__	\
-			lwz		r3,FM_ARG0(r1)	 			__ASMNL__ 	\
-1:												__ASMNL__	\
-			mtmsr	r11							__ASMNL__	\
+#define CHECK_NO_SIMPLELOCKS()									\
+			bt		24+disLkNmSimpb,2f				__ASMNL__	\
+			lis		r10,hi16(MASK(MSR_VEC))			__ASMNL__	\
+			ori		r10,r10,lo16(MASK(MSR_FP))		__ASMNL__	\
+			mfmsr	r11								__ASMNL__	\
+			andc	r11,r11,r10						__ASMNL__	\
+			ori		r10,r10,lo16(MASK(MSR_EE))		__ASMNL__	\
+			andc	r10,r11,r10						__ASMNL__	\
+			mtmsr	r10								__ASMNL__	\
+			isync									__ASMNL__	\
+			mfsprg	r10,0							__ASMNL__	\
+			lwz		r10,PP_SIMPLE_LOCK_CNT(r10)		__ASMNL__	\
+			cmpwi	r10,0 							__ASMNL__	\
+			beq+	1f 								__ASMNL__	\
+			lis		r3,hi16(simple_locks_held)		__ASMNL__	\
+			ori		r3,r3,lo16(simple_locks_held)	__ASMNL__	\
+			bl		EXT(panic)	 					__ASMNL__	\
+			lwz		r3,FM_ARG0(r1)	 				__ASMNL__ 	\
+1:													__ASMNL__	\
+			mtmsr	r11								__ASMNL__	\
 2:	
 	
 	.data
@@ -145,55 +136,58 @@ simple_locks_held:
 /* 
  * Verifies return to the correct thread in "unlock" situations.
  */
-
-#define CHECK_THREAD(thread_offset)						\
-			bt		24+disLkThreadb,2f			__ASMNL__ 	\
-			mfmsr	r11							__ASMNL__	\
-			rlwinm	r11,r11,0,MSR_FP_BIT+1,MSR_FP_BIT-1	__ASMNL__	\
-			rlwinm	r11,r11,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	__ASMNL__	\
-			rlwinm  r10,r11,0,MSR_EE_BIT+1,MSR_EE_BIT-1	__ASMNL__	\
-			mtmsr	r10							__ASMNL__	\
-			isync								__ASMNL__	\
-			mfsprg	r10,0						__ASMNL__	\
-			lwz		r10,PP_ACTIVE_THREAD(r10)	__ASMNL__	\
-			cmpwi	r10,0	 					__ASMNL__ 	\
-			beq-	1f 							__ASMNL__ 	\
-			lwz		r9,thread_offset(r3) 		__ASMNL__ 	\
-			cmpw	r9,r10	 					__ASMNL__ 	\
-			beq+	1f 							__ASMNL__ 	\
-			lis		r3,hi16(wrong_thread) 		__ASMNL__	\
-			ori		r3,r3,lo16(wrong_thread)	__ASMNL__ 	\
-			bl		EXT(panic)	 				__ASMNL__ 	\
-			lwz		r3,FM_ARG0(r1)	 			__ASMNL__ 	\
-1:												__ASMNL__	\
-			mtmsr	r11							__ASMNL__	\
+#define CHECK_THREAD(thread_offset)								\
+			bt		24+disLkThreadb,2f				__ASMNL__ 	\
+			lis		r10,hi16(MASK(MSR_VEC))			__ASMNL__	\
+			ori		r10,r10,lo16(MASK(MSR_FP))		__ASMNL__	\
+			mfmsr	r11								__ASMNL__	\
+			andc	r11,r11,r10						__ASMNL__	\
+			ori		r10,r10,lo16(MASK(MSR_EE))		__ASMNL__	\
+			andc	r10,r11,r10						__ASMNL__	\
+			mtmsr	r10								__ASMNL__	\
+			isync									__ASMNL__	\
+			mfsprg	r10,0							__ASMNL__	\
+			lwz		r10,PP_ACTIVE_THREAD(r10)		__ASMNL__	\
+			cmpwi	r10,0	 						__ASMNL__ 	\
+			beq-	1f 								__ASMNL__ 	\
+			lwz		r9,thread_offset(r3) 			__ASMNL__ 	\
+			cmpw	r9,r10	 						__ASMNL__ 	\
+			beq+	1f 								__ASMNL__ 	\
+			lis		r3,hi16(wrong_thread) 			__ASMNL__	\
+			ori		r3,r3,lo16(wrong_thread)		__ASMNL__ 	\
+			bl		EXT(panic)	 					__ASMNL__ 	\
+			lwz		r3,FM_ARG0(r1)	 				__ASMNL__ 	\
+1:													__ASMNL__	\
+			mtmsr	r11								__ASMNL__	\
 2:	
 	.data
 wrong_thread:
 	STRINGD	"wrong thread!\n\000"
 	.text
 
-#define CHECK_MYLOCK(thread_offset)					\
-			bt		24+disLkMyLckb,2f			__ASMNL__ 	\
-			mfmsr	r11							__ASMNL__	\
-			rlwinm	r11,r11,0,MSR_FP_BIT+1,MSR_FP_BIT-1	__ASMNL__	\
-			rlwinm	r11,r11,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	__ASMNL__	\
-			rlwinm  r10,r11,0,MSR_EE_BIT+1,MSR_EE_BIT-1	__ASMNL__	\
-			mtmsr	r10							__ASMNL__	\
-			isync								__ASMNL__	\
-			mfsprg	r10,0						__ASMNL__	\
-			lwz		r10,PP_ACTIVE_THREAD(r10)	__ASMNL__	\
-			cmpwi	r10,0	 					__ASMNL__	\
-			beq-	1f 							__ASMNL__	\
-			lwz		r9,	thread_offset(r3) 		__ASMNL__	\
-			cmpw	r9,r10	 					__ASMNL__	\
-			bne+	1f 							__ASMNL__	\
-			lis		r3,	HIGH_ADDR(mylock_attempt) __ASMNL__	\
-			ori		r3,r3,LOW_ADDR(mylock_attempt) __ASMNL__	\
-			bl		EXT(panic)	 				__ASMNL__	\
-			lwz		r3,FM_ARG0(r1)	 			__ASMNL__	\
-1:												__ASMNL__	\
-			mtmsr	r11							__ASMNL__	\
+#define CHECK_MYLOCK(thread_offset)								\
+			bt		24+disLkMyLckb,2f				__ASMNL__ 	\
+			lis		r10,hi16(MASK(MSR_VEC))			__ASMNL__	\
+			ori		r10,r10,lo16(MASK(MSR_FP))		__ASMNL__	\
+			mfmsr	r11								__ASMNL__	\
+			andc	r11,r11,r10						__ASMNL__	\
+			ori		r10,r10,lo16(MASK(MSR_EE))		__ASMNL__	\
+			andc	r10,r11,r10						__ASMNL__	\
+			mtmsr	r10								__ASMNL__	\
+			isync									__ASMNL__	\
+			mfsprg	r10,0							__ASMNL__	\
+			lwz		r10,PP_ACTIVE_THREAD(r10)		__ASMNL__	\
+			cmpwi	r10,0	 						__ASMNL__	\
+			beq-	1f 								__ASMNL__	\
+			lwz		r9,	thread_offset(r3) 			__ASMNL__	\
+			cmpw	r9,r10	 						__ASMNL__	\
+			bne+	1f 								__ASMNL__	\
+			lis		r3,	hi16(mylock_attempt)		__ASMNL__	\
+			ori		r3,r3,lo16(mylock_attempt)		__ASMNL__	\
+			bl		EXT(panic)	 					__ASMNL__	\
+			lwz		r3,FM_ARG0(r1)	 				__ASMNL__	\
+1:													__ASMNL__	\
+			mtmsr	r11								__ASMNL__	\
 2:
 	
 	.data
@@ -213,16 +207,17 @@ mylock_attempt:
 #endif	/* MACH_LDEBUG */
 	
 /*
- *      void hw_lock_init(hw_lock_t)
+ *		void hw_lock_init(hw_lock_t)
  *
- *      Initialize a hardware lock.  These locks should be cache aligned and a multiple
- *		of cache size.
+ *			Initialize a hardware lock.
  */
+			.align	5
+			.globl	EXT(hw_lock_init)
 
-ENTRY(hw_lock_init, TAG_NO_FRAME_USED)
+LEXT(hw_lock_init)
 
-			li	r0,	0							/* set lock to free == 0 */
-			stw	r0,	0(r3)						/* Initialize the lock */
+			li	r0,	0								; set lock to free == 0 
+			stw	r0,	0(r3)							; Initialize the lock 
 			blr
 	
 /*
@@ -231,429 +226,409 @@ ENTRY(hw_lock_init, TAG_NO_FRAME_USED)
  *      Unconditionally release lock.
  *      Release preemption level.
  */
-
-
 			.align	5
 			.globl	EXT(hw_lock_unlock)
 
 LEXT(hw_lock_unlock)
 
-#if 0
-			lis		r0,HIGH_ADDR(CutTrace)		/* (TEST/DEBUG) */
-			lis		r5,0xFFFF					/* (TEST/DEBUG) */
-			oris	r0,r0,LOW_ADDR(CutTrace)	/* (TEST/DEBUG) */
-			sc									/* (TEST/DEBUG) */
-#endif
-			sync								/* Flush writes done under lock */
-			li	r0,	0							/* set lock to free */
+			.globl  EXT(hwulckPatch_isync)
+LEXT(hwulckPatch_isync)   
+			isync 
+			.globl  EXT(hwulckPatch_eieio)
+LEXT(hwulckPatch_eieio)
+			eieio
+			li	r0,	0								; set lock to free
 			stw	r0,	0(r3)
 
-			b		epStart						/* Go enable preemption... */
-
-
-/* 
- *		Special case for internal use.  Uses same lock code, but sets up so 
- *		that there will be no disabling of preemption after locking.  Generally
- *		used for mutex locks when obtaining the interlock although there is
- *		nothing stopping other uses.
- */
+			b		epStart							; Go enable preemption...
 
-lockLock:	lis		r4,HIGH_ADDR(EXT(LockTimeOut))	/* Get the high part */
-			ori		r4,r4,LOW_ADDR(EXT(LockTimeOut))	/* And the low part */
-			cmplwi	cr1,r1,0					/* Set flag to disable disable preemption */
-			lwz		r4,0(r4)					/* Get the timerout value */
-			b		lockComm					/* Join on up... */
-	
 /*
  *      void hw_lock_lock(hw_lock_t)
  *
- *      Acquire lock, spinning until it becomes available.
- *      Return with preemption disabled.
- *		Apparently not used except by mach_perf.
- *		We will just set a default timeout and jump into the NORMAL timeout lock.
+ *			Acquire lock, spinning until it becomes available.
+ *			Return with preemption disabled.
+ *			We will just set a default timeout and jump into the NORMAL timeout lock.
  */
-
 			.align	5
 			.globl	EXT(hw_lock_lock)
 
 LEXT(hw_lock_lock)
-
-lockDisa:	lis		r4,HIGH_ADDR(EXT(LockTimeOut))	/* Get the high part */
-			ori		r4,r4,LOW_ADDR(EXT(LockTimeOut))	/* And the low part */
-			cmplw	cr1,r1,r1					/* Set flag to enable disable preemption */
-			lwz		r4,0(r4)					/* Get the timerout value */
-			b		lockComm					/* Join on up... */
+lockDisa:
+			li		r4,0							; no timeout value
+			b		lckcomm							; Join on up...
 
 /*
- *      unsigned int hw_lock_to(hw_lock_t, unsigned int timeout)
- *
- *      Try to acquire spin-lock. Return success (1) or failure (0).
- *      Attempt will fail after timeout ticks of the timebase.
- *		We try fairly hard to get this lock.  We disable for interruptions, but
- *		reenable after a "short" timeout (128 ticks, we may want to change this).
- *		After checking to see if the large timeout value (passed in) has expired and a
- *		sufficient number of cycles have gone by (to insure pending 'rupts are taken),
- *		we return either in abject failure, or disable and go back to the lock sniff routine.
- *		If the sniffer finds the lock free, it jumps right up and tries to grab it.
- *
- *		One programming note: NEVER DO NOTHING IN HERE NO HOW THAT WILL FORCE US TO CALL
- *		THIS WITH TRANSLATION OR INTERRUPTIONS EITHER ON OR OFF, GOSH DARN IT!
+ *		unsigned int hw_lock_to(hw_lock_t, unsigned int timeout)
  *
+ *			Try to acquire spin-lock. Return success (1) or failure (0).
+ *			Attempt will fail after timeout ticks of the timebase.
+ *			We try fairly hard to get this lock.  We disable for interruptions, but
+ *			reenable after a "short" timeout (128 ticks, we may want to change this).
+ *			After checking to see if the large timeout value (passed in) has expired and a
+ *			sufficient number of cycles have gone by (to insure pending 'rupts are taken),
+ *			we return either in abject failure, or disable and go back to the lock sniff routine.
+ *			If the sniffer finds the lock free, it jumps right up and tries to grab it.
  */
 			.align	5
 			.globl	EXT(hw_lock_to)
 
 LEXT(hw_lock_to)
 
-#if 0
-			lis		r0,HIGH_ADDR(CutTrace)		/* (TEST/DEBUG) */
-			lis		r5,0xEEEE					/* (TEST/DEBUG) */
-			oris	r0,r0,LOW_ADDR(CutTrace)	/* (TEST/DEBUG) */
-			sc									/* (TEST/DEBUG) */
-#endif
-
 #if CHECKNMI
-			mflr	r12							; (TEST/DEBUG) 
-			bl		EXT(ml_sense_nmi)			; (TEST/DEBUG)
-			mtlr	r12							; (TEST/DEBUG)
+			mflr	r12								; (TEST/DEBUG) 
+			bl		EXT(ml_sense_nmi)				; (TEST/DEBUG)
+			mtlr	r12								; (TEST/DEBUG)
 #endif
 
-			cmplw	cr1,r1,r1					/* Set flag to enable disable preemption */
-
-lockComm:	mfmsr	r9							/* Get the MSR value */
-			rlwinm	r9,r9,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-			mr		r5,r3						/* Get the address of the lock */
-			rlwinm	r9,r9,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-			rlwinm	r7,r9,0,MSR_EE_BIT+1,MSR_EE_BIT-1	/* Get MSR that is uninterruptible */
-	
-			mtmsr	r7							/* Turn off interruptions */
-			isync								; May have turned off vec and fp here 
-			mftb	r8							/* Get the low part of the time base */
+lckcomm:
+			mfsprg	r6,1							; Get the current activation 
+			lwz		r5,ACT_PREEMPT_CNT(r6)			; Get the preemption level
+			addi	r5,r5,1							; Bring up the disable count
+			stw		r5,ACT_PREEMPT_CNT(r6)			; Save it back 
+			mr		r5,r3							; Get the address of the lock
+			li		r8,0							; Set r8 to zero
+
+lcktry:		lwarx	r6,0,r5							; Grab the lock value
+			andi.	r3,r6,ILK_LOCKED				; Is it locked?
+			ori		r6,r6,ILK_LOCKED				; Set interlock 
+			bne--	lckspin							; Yeah, wait for it to clear...
+			stwcx.	r6,0,r5							; Try to seize that there durn lock
+			bne--	lcktry							; Couldn't get it...
+			li		r3,1							; return true 
+			isync									; Make sure we don't use a speculativily loaded value
+			blr										; Go on home...
+
+lckspin:	li		r6,lgKillResv					; Get killing field	
+			stwcx.	r6,0,r6							; Kill reservation
 			
-lcktry:		lwarx	r6,0,r5						/* Grab the lock value */
-			andi.	r3,r6,ILK_LOCKED			/* Is it locked? */
-			ori		r6,r6,ILK_LOCKED			/* Set interlock */
-			bne-	lcksniff					/* Yeah, wait for it to clear... */
-			stwcx.	r6,0,r5						/* Try to seize that there durn lock */
-			bne-	lcktry						/* Couldn't get it... */
-			li		r3,1						/* return true */
-			isync								/* Make sure we don't use a speculativily loaded value */
-			beq+	cr1,daPreComm				/* We got it, go disable preemption if we're supposed to... */
-			mtmsr	r9							; Restore interrupt state
-			blr									/* Go on home... */
+			mr.		r4,r4							; Test timeout value
+			bne++	lockspin0
+			lis		r4,hi16(EXT(LockTimeOut))		; Get the high part 
+			ori		r4,r4,lo16(EXT(LockTimeOut))	; And the low part
+			lwz		r4,0(r4)						; Get the timeout value
+lockspin0:
+			mr.		r8,r8							; Is r8 set to zero
+			bne++	lockspin1						; If yes, first spin attempt
+			lis		r0,hi16(MASK(MSR_VEC))			; Get vector enable
+			mfmsr	r9								; Get the MSR value
+			ori		r0,r0,lo16(MASK(MSR_FP))		; Get FP enable
+			ori		r7,r0,lo16(MASK(MSR_EE))		; Get EE bit on too
+			andc	r9,r9,r0						; Clear FP and VEC
+			andc	r7,r9,r7						; Clear EE as well
+			mtmsr	r7								; Turn off interruptions 
+			isync									; May have turned off vec and fp here 
+			mftb	r8								; Get timestamp on entry
+			b		lcksniff
+
+lockspin1:	mtmsr	r7								; Turn off interruptions 
+			mftb	r8								; Get timestamp on entry
+
+lcksniff:	lwz		r3,0(r5)						; Get that lock in here
+			andi.	r3,r3,ILK_LOCKED				; Is it free yet?
+			beq++	lckretry						; Yeah, try for it again...
 			
-			.align	5
-
-lcksniff:	lwz		r3,0(r5)					/* Get that lock in here */
-			andi.	r3,r3,ILK_LOCKED			/* Is it free yet? */
-			beq+	lcktry						/* Yeah, try for it again... */
+			mftb	r10								; Time stamp us now
+			sub		r10,r10,r8						; Get the elapsed time
+			cmplwi	r10,128							; Have we been spinning for 128 tb ticks?
+			blt++	lcksniff						; Not yet...
 			
-			mftb	r10							/* Time stamp us now */
-			sub		r10,r10,r8					/* Get the elapsed time */
-			cmplwi	r10,128						/* Have we been spinning for 128 tb ticks? */
-			blt+	lcksniff					/* Not yet... */
-			
-			mtmsr	r9							/* Say, any interrupts pending? */			
+			mtmsr	r9								; Say, any interrupts pending?
 
-/*			The following instructions force the pipeline to be interlocked to that only one
-			instruction is issued per cycle.  The insures that we stay enabled for a long enough
-			time; if it's too short, pending interruptions will not have a chance to be taken */
-			
-			subi	r4,r4,128					/* Back off elapsed time from timeout value */
-			or		r4,r4,r4					/* Do nothing here but force a single cycle delay */
-			mr.		r4,r4						/* See if we used the whole timeout	*/
-			li		r3,0						/* Assume a timeout return code */
-			or		r4,r4,r4					/* Do nothing here but force a single cycle delay */
-			
-			ble-	lckfail						/* We failed */
-			mtmsr	r7							/* Disable for interruptions */
-			mftb	r8							/* Get the low part of the time base */
-			b		lcksniff					/* Now that we've opened an enable window, keep trying... */
+;			The following instructions force the pipeline to be interlocked to that only one
+;			instruction is issued per cycle.  The insures that we stay enabled for a long enough
+;			time; if it's too short, pending interruptions will not have a chance to be taken
 
-lckfail:										/* We couldn't get the lock */			
-			li		r3,0						/* Set failure return code */
-			blr									/* Return, head hanging low... */
+			subi	r4,r4,128						; Back off elapsed time from timeout value
+			or		r4,r4,r4						; Do nothing here but force a single cycle delay
+			mr.		r4,r4							; See if we used the whole timeout
+			li		r3,0							; Assume a timeout return code
+			or		r4,r4,r4						; Do nothing here but force a single cycle delay
+			
+			ble--	lckfail							; We failed
+			b		lockspin1						; Now that we've opened an enable window, keep trying...
+lckretry:
+			mtmsr	r9								; Restore interrupt state
+			li		r8,1							; Insure that R8 is not 0
+			b		lcktry
+lckfail:											; We couldn't get the lock
+			li		r3,0							; Set failure return code
+			blr										; Return, head hanging low...
 
 
 /*
- *      unsigned int hw_lock_bit(hw_lock_t, unsigned int bit, unsigned int timeout)
- *
- *      Try to acquire spin-lock. The second parameter is the bit mask to test and set.
- *		multiple bits may be set. Return success (1) or failure (0).
- *      Attempt will fail after timeout ticks of the timebase.
- *		We try fairly hard to get this lock.  We disable for interruptions, but
- *		reenable after a "short" timeout (128 ticks, we may want to shorten this).
- *		After checking to see if the large timeout value (passed in) has expired and a
- *		sufficient number of cycles have gone by (to insure pending 'rupts are taken),
- *		we return either in abject failure, or disable and go back to the lock sniff routine.
- *		If the sniffer finds the lock free, it jumps right up and tries to grab it.
- *
- *		NOTE WELL!!!!  THE ROUTINE hw_lock_phys_vir KNOWS WHAT REGISTERS THIS GUY
- *		USES. THIS SAVES A TRANSLATION OFF TO ON TRANSITION AND BACK AND A SAVE AND
- *		RESTORE FROM THE STACK.
+ *		unsigned int hw_lock_bit(hw_lock_t, unsigned int bit, unsigned int timeout)
  *
+ *			Try to acquire spin-lock. The second parameter is the bit mask to test and set.
+ *			multiple bits may be set. Return success (1) or failure (0).
+ *			Attempt will fail after timeout ticks of the timebase.
+ *			We try fairly hard to get this lock.  We disable for interruptions, but
+ *			reenable after a "short" timeout (128 ticks, we may want to shorten this).
+ *			After checking to see if the large timeout value (passed in) has expired and a
+ *			sufficient number of cycles have gone by (to insure pending 'rupts are taken),
+ *			we return either in abject failure, or disable and go back to the lock sniff routine.
+ *			If the sniffer finds the lock free, it jumps right up and tries to grab it.
  */
-
 			.align	5
-			
-			nop									; Force loop alignment to cache line
-			nop
-			nop
-			nop
-			
 			.globl	EXT(hw_lock_bit)
 
 LEXT(hw_lock_bit)
 
-			mfmsr	r9							/* Get the MSR value */
-			rlwinm	r9,r9,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-			rlwinm	r9,r9,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-			rlwinm	r7,r9,0,MSR_EE_BIT+1,MSR_EE_BIT-1	/* Get MSR that is uninterruptible */	
+			li		r10,0			
 
-			mtmsr	r7							/* Turn off interruptions */
-			isync								; May have turned off vec and fp here 
-
-			mftb	r8							/* Get the low part of the time base */
-			
-bittry:		lwarx	r6,0,r3						/* Grab the lock value */
-			and.	r0,r6,r4					/* See if any of the lock bits are on */
-			or		r6,r6,r4					/* Turn on the lock bits */
-			bne-	bitsniff					/* Yeah, wait for it to clear... */
-			stwcx.	r6,0,r3						/* Try to seize that there durn lock */
-			beq+	bitgot						/* We got it, yahoo... */
-			b		bittry						/* Just start up again if the store failed... */
+bittry:		lwarx	r6,0,r3							; Grab the lock value 
+			and.	r0,r6,r4						; See if any of the lock bits are on 
+			or		r6,r6,r4						; Turn on the lock bits 
+			bne--	bitspin							; Yeah, wait for it to clear... 
+			stwcx.	r6,0,r3							; Try to seize that there durn lock 
+			bne--	bittry							; Just start up again if the store failed...
+		
+			li		r3,1							; Set good return code 
+			isync									; Make sure we don't use a speculativily loaded value 
+			blr
 
 			.align	5
+
+bitspin:	li		r11,lgKillResv					; Get killing field	
+			stwcx.	r11,0,r11						; Kill reservation
 			
-bitsniff:	lwz		r6,0(r3)					/* Get that lock in here */
-			and.	r0,r6,r4					/* See if any of the lock bits are on */
-			beq+	bittry						/* Yeah, try for it again... */
+			mr.		r10,r10							; Is r8 set to zero
+			li		r10,1							; Close gate
+			beq--	bit1sttime						; If yes, first spin attempt
+
+bitspin0:	mtmsr	r7								; Turn off interruptions 
+			mftb	r8								; Get the low part of the time base 
+
+bitsniff:	lwz		r6,0(r3)						; Get that lock in here 
+			and.	r0,r6,r4						; See if any of the lock bits are on 
+			beq++	bitretry						; Yeah, try for it again...
 			
-			mftb	r6							/* Time stamp us now */
-			sub		r6,r6,r8					/* Get the elapsed time */
-			cmplwi	r6,128						/* Have we been spinning for 128 tb ticks? */
-			blt+	bitsniff					/* Not yet... */
+			mftb	r6								; Time stamp us now 
+			sub		r6,r6,r8						; Get the elapsed time 
+			cmplwi	r6,128							; Have we been spinning for 128 tb ticks? 
+			blt++	bitsniff						; Not yet... 
 			
-			mtmsr	r9							/* Say, any interrupts pending? */			
+			mtmsr	r9								; Say, any interrupts pending? 
 
-/*			The following instructions force the pipeline to be interlocked to that only one
-			instruction is issued per cycle.  The insures that we stay enabled for a long enough
-			time. If it's too short, pending interruptions will not have a chance to be taken 
-*/
-			
-			subi	r5,r5,128					/* Back off elapsed time from timeout value */
-			or		r5,r5,r5					/* Do nothing here but force a single cycle delay */
-			mr.		r5,r5						/* See if we used the whole timeout	*/
-			or		r5,r5,r5					/* Do nothing here but force a single cycle delay */
+;			The following instructions force the pipeline to be interlocked to that only one
+;			instruction is issued per cycle.  The insures that we stay enabled for a long enough
+;			time. If it's too short, pending interruptions will not have a chance to be taken 
+
+			subi	r5,r5,128						; Back off elapsed time from timeout value
+			or		r5,r5,r5						; Do nothing here but force a single cycle delay
+			mr.		r5,r5							; See if we used the whole timeout
+			or		r5,r5,r5						; Do nothing here but force a single cycle delay
 			
-			ble-	bitfail						/* We failed */
-			mtmsr	r7							/* Disable for interruptions */
-			mftb	r8							/* Get the low part of the time base */
-			b		bitsniff					/* Now that we've opened an enable window, keep trying... */
+			bgt++	bitspin0						; Now that we've opened an enable window, keep trying...
+		
+			li		r3,0							; Set failure return code
+			blr										; Return, head hanging low...
+
+bitretry:	mtmsr	r9								; Enable for interruptions
+			b		bittry
+
+bit1sttime:	lis		r0,hi16(MASK(MSR_VEC))			; Get vector enable
+			mfmsr	r9								; Get the MSR value
+			ori		r0,r0,lo16(MASK(MSR_FP))		; Get FP enable
+			ori		r7,r0,lo16(MASK(MSR_EE))		; Get EE bit on too
+			andc	r9,r9,r0						; Clear FP and VEC
+			andc	r7,r9,r7						; Clear EE as well
+			mtmsr	r7								; Turn off interruptions 
+			isync									; May have turned off vec and fp here 
+			mftb	r8								; Get the low part of the time base 
+			b		bitsniff
 
 			.align	5
 
-bitgot:		mtmsr	r9							/* Enable for interruptions */
-			li		r3,1						/* Set good return code */
-			isync								/* Make sure we don't use a speculativily loaded value */
-			blr
-
-bitfail:	li		r3,0						/* Set failure return code */
-			blr									/* Return, head hanging low... */
-			
 
 /*
- *      unsigned int hw_unlock_bit(hw_lock_t, unsigned int bit)
+ *		unsigned int hw_unlock_bit(hw_lock_t, unsigned int bit)
  *
- *      Release bit based spin-lock. The second parameter is the bit mask to clear.
- *		Multiple bits may be cleared.
+ *			Release bit based spin-lock. The second parameter is the bit mask to clear.
+ *			Multiple bits may be cleared.
  *
- *		NOTE WELL!!!!  THE ROUTINE hw_lock_phys_vir KNOWS WHAT REGISTERS THIS GUY
- *		USES. THIS SAVES A TRANSLATION OFF TO ON TRANSITION AND BACK AND A SAVE AND
- *		RESTORE FROM THE STACK.
  */
-
 			.align	5
 			.globl	EXT(hw_unlock_bit)
 
 LEXT(hw_unlock_bit)
 
-			sync
-
-ubittry:	lwarx	r0,0,r3						/* Grab the lock value */
-			andc	r0,r0,r4					/* Clear the lock bits */
-			stwcx.	r0,0,r3						/* Try to clear that there durn lock */
-			bne-	ubittry						/* Try again, couldn't save it... */
+			.globl  EXT(hwulckbPatch_isync)
+LEXT(hwulckbPatch_isync)   
+			isync 
+			.globl  EXT(hwulckbPatch_eieio)
+LEXT(hwulckbPatch_eieio)
+			eieio
+ubittry:	lwarx	r0,0,r3							; Grab the lock value
+			andc	r0,r0,r4						; Clear the lock bits
+			stwcx.	r0,0,r3							; Try to clear that there durn lock
+			bne-	ubittry							; Try again, couldn't save it...
 
-			blr									/* Leave... */			
+			blr										; Leave...
 
 /*
- *      unsigned int hw_lock_mbits(hw_lock_t, unsigned int bits, unsigned int value, 
+ *		unsigned int hw_lock_mbits(hw_lock_t, unsigned int bits, unsigned int value, 
  *			unsigned int newb, unsigned int timeout)
  *
- *      Try to acquire spin-lock. The second parameter is the bit mask to check.
- *		The third is the value of those bits and the 4th is what to set them to.
- *		Return success (1) or failure (0).
- *      Attempt will fail after timeout ticks of the timebase.
- *		We try fairly hard to get this lock.  We disable for interruptions, but
- *		reenable after a "short" timeout (128 ticks, we may want to shorten this).
- *		After checking to see if the large timeout value (passed in) has expired and a
- *		sufficient number of cycles have gone by (to insure pending 'rupts are taken),
- *		we return either in abject failure, or disable and go back to the lock sniff routine.
- *		If the sniffer finds the lock free, it jumps right up and tries to grab it.
- *
+ *			Try to acquire spin-lock. The second parameter is the bit mask to check.
+ *			The third is the value of those bits and the 4th is what to set them to.
+ *			Return success (1) or failure (0).
+ *			Attempt will fail after timeout ticks of the timebase.
+ *			We try fairly hard to get this lock.  We disable for interruptions, but
+ *			reenable after a "short" timeout (128 ticks, we may want to shorten this).
+ *			After checking to see if the large timeout value (passed in) has expired and a
+ *			sufficient number of cycles have gone by (to insure pending 'rupts are taken),
+ *			we return either in abject failure, or disable and go back to the lock sniff routine.
+ *			If the sniffer finds the lock free, it jumps right up and tries to grab it.
  */
-
 			.align	5
-			
-			nop									; Force loop alignment to cache line
-			nop
-			nop
-			nop
-			
 			.globl	EXT(hw_lock_mbits)
 
 LEXT(hw_lock_mbits)
 
-			mfmsr	r9							; Get the MSR value
-			rlwinm	r9,r9,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-			rlwinm	r9,r9,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-			rlwinm	r8,r9,0,MSR_EE_BIT+1,MSR_EE_BIT-1	; Get MSR that is uninterruptible	
+			li		r10,0			
 
-			mtmsr	r8							; Turn off interruptions
-			isync								; May have turned off vectors or float here
-			mftb	r10							; Get the low part of the time base
-			
-mbittry:	lwarx	r12,0,r3					; Grab the lock value
-			and		r0,r12,r4					; Clear extra bits
-			andc	r12,r12,r4					; Clear all bits in the bit mask
-			or		r12,r12,r6					; Turn on the lock bits
-			cmplw	r0,r5						; Are these the right bits?
-			bne-	mbitsniff					; Nope, wait for it to clear...
-			stwcx.	r12,0,r3					; Try to seize that there durn lock
-			beq+	mbitgot						; We got it, yahoo...
-			b		mbittry						; Just start up again if the store failed...
+mbittry:	lwarx	r12,0,r3						; Grab the lock value
+			and		r0,r12,r4						; Clear extra bits
+			andc	r12,r12,r4						; Clear all bits in the bit mask
+			or		r12,r12,r6						; Turn on the lock bits
+			cmplw	r0,r5							; Are these the right bits?
+			bne--	mbitspin						; Nope, wait for it to clear...
+			stwcx.	r12,0,r3						; Try to seize that there durn lock
+			beq++	mbitgot							; We got it, yahoo...
+			b		mbittry							; Just start up again if the store failed...
 
 			.align	5
+mbitspin:	li		r11,lgKillResv					; Point to killing field
+			stwcx.	r11,0,r11						; Kill it
 			
-mbitsniff:	lwz		r12,0(r3)					; Get that lock in here
-			and		r0,r12,r4					; Clear extra bits
-			cmplw	r0,r5						; Are these the right bits?
-			beq+	mbittry						; Yeah, try for it again...
+			mr.		r10,r10							; Is r10 set to zero
+			bne++	mbitspin0						; If yes, first spin attempt
+			lis		r0,hi16(MASK(MSR_VEC))			; Get vector enable
+			mfmsr	r9								; Get the MSR value
+			ori		r0,r0,lo16(MASK(MSR_FP))		; Get FP enable
+			ori		r8,r0,lo16(MASK(MSR_EE))		; Get EE bit on too
+			andc	r9,r9,r0						; Clear FP and VEC
+			andc	r8,r9,r8						; Clear EE as well
+			mtmsr	r8								; Turn off interruptions
+			isync									; May have turned off vectors or float here
+			mftb	r10								; Get the low part of the time base
+			b		mbitsniff
+mbitspin0:
+			mtmsr	r8								; Turn off interruptions
+			mftb	r10								; Get the low part of the time base
+mbitsniff:
+			lwz		r12,0(r3)						; Get that lock in here
+			and		r0,r12,r4						; Clear extra bits
+			cmplw	r0,r5							; Are these the right bits?
+			beq++	mbitretry						; Yeah, try for it again...
 			
-			mftb	r11							; Time stamp us now
-			sub		r11,r11,r10					; Get the elapsed time
-			cmplwi	r11,128						; Have we been spinning for 128 tb ticks?
-			blt+	mbitsniff					; Not yet...
+			mftb	r11								; Time stamp us now
+			sub		r11,r11,r10						; Get the elapsed time
+			cmplwi	r11,128							; Have we been spinning for 128 tb ticks?
+			blt++	mbitsniff						; Not yet...
 			
-			mtmsr	r9							; Say, any interrupts pending?			
+			mtmsr	r9								; Say, any interrupts pending?			
 
 ;			The following instructions force the pipeline to be interlocked to that only one
 ;			instruction is issued per cycle.  The insures that we stay enabled for a long enough
 ;			time. If it is too short, pending interruptions will not have a chance to be taken 
 			
-			subi	r7,r7,128					; Back off elapsed time from timeout value
-			or		r7,r7,r7					; Do nothing here but force a single cycle delay
-			mr.		r7,r7						; See if we used the whole timeout
-			or		r7,r7,r7					; Do nothing here but force a single cycle delay
+			subi	r7,r7,128						; Back off elapsed time from timeout value
+			or		r7,r7,r7						; Do nothing here but force a single cycle delay
+			mr.		r7,r7							; See if we used the whole timeout
+			or		r7,r7,r7						; Do nothing here but force a single cycle delay
 			
-			ble-	mbitfail					; We failed
-			mtmsr	r8							; Disable for interruptions
-			mftb	r10							; Get the low part of the time base
-			b		mbitsniff					; Now that we have opened an enable window, keep trying...
+			ble--	mbitfail						; We failed
+			b		mbitspin0						; Now that we have opened an enable window, keep trying...
+mbitretry:
+			mtmsr	r9								; Enable for interruptions
+			li		r10,1							; Make sure this is non-zero
+			b		mbittry
 
 			.align	5
-
-mbitgot:	mtmsr	r9							; Enable for interruptions
-			li		r3,1						; Set good return code
-			isync								; Make sure we do not use a speculativily loaded value
+mbitgot:	
+			li		r3,1							; Set good return code
+			isync									; Make sure we do not use a speculativily loaded value
 			blr
 
-mbitfail:	li		r3,0						; Set failure return code
-			blr									; Return, head hanging low...
-			
+mbitfail:	li		r3,0							; Set failure return code
+			blr										; Return, head hanging low...
 
 /*
  *      unsigned int hw_cpu_sync(unsigned int *, unsigned int timeout)
  *
- *      Spin until word hits 0 or timeout. 
- *		Return success (1) or failure (0).
- *      Attempt will fail after timeout ticks of the timebase.
- *
- *		The theory is that a processor will bump a counter as it signals
- *		other processors.  Then it will spin untl the counter hits 0 (or
- *		times out).  The other processors, as it receives the signal will 
- *		decrement the counter.
+ *			Spin until word hits 0 or timeout. 
+ *			Return success (1) or failure (0).
+ *			Attempt will fail after timeout ticks of the timebase.
  *
- *		The other processors use interlocked update to decrement, this one
- *		does not need to interlock.
+ *			The theory is that a processor will bump a counter as it signals
+ *			other processors.  Then it will spin untl the counter hits 0 (or
+ *			times out).  The other processors, as it receives the signal will 
+ *			decrement the counter.
  *
+ *			The other processors use interlocked update to decrement, this one
+ *			does not need to interlock.
  */
-
 			.align	5
-			
 			.globl	EXT(hw_cpu_sync)
 
 LEXT(hw_cpu_sync)
 
-			mftb	r10							; Get the low part of the time base
-			mr		r9,r3						; Save the sync word address
-			li		r3,1						; Assume we work
+			mftb	r10								; Get the low part of the time base
+			mr		r9,r3							; Save the sync word address
+			li		r3,1							; Assume we work
 
-csynctry:	lwz		r11,0(r9)					; Grab the sync value
-			mr.		r11,r11						; Counter hit 0?
-			beqlr-								; Yeah, we are sunk...
-			mftb	r12							; Time stamp us now
+csynctry:	lwz		r11,0(r9)						; Grab the sync value
+			mr.		r11,r11							; Counter hit 0?
+			beqlr-									; Yeah, we are sunk...
+			mftb	r12								; Time stamp us now
 
-			sub		r12,r12,r10					; Get the elapsed time
-			cmplw	r4,r12						; Have we gone too long?
-			bge+	csynctry					; Not yet...
+			sub		r12,r12,r10						; Get the elapsed time
+			cmplw	r4,r12							; Have we gone too long?
+			bge+	csynctry						; Not yet...
 			
-			li		r3,0						; Set failure...
-			blr									; Return, head hanging low...
+			li		r3,0							; Set failure...
+			blr										; Return, head hanging low...
 
 /*
  *      unsigned int hw_cpu_wcng(unsigned int *, unsigned int, unsigned int timeout)
  *
- *      Spin until word changes or timeout. 
- *		Return success (1) or failure (0).
- *      Attempt will fail after timeout ticks of the timebase.
- *
- *		This is used to insure that a processor passes a certain point.
- *		An example of use is to monitor the last interrupt time in the 
- *		per_proc block.  This can be used to insure that the other processor
- *		has seen at least one interrupt since a specific time.
+ *			Spin until word changes or timeout. 
+ *			Return success (1) or failure (0).
+ *			Attempt will fail after timeout ticks of the timebase.
  *
+ *			This is used to insure that a processor passes a certain point.
+ *			An example of use is to monitor the last interrupt time in the 
+ *			per_proc block.  This can be used to insure that the other processor
+ *			has seen at least one interrupt since a specific time.
  */
-
 			.align	5
-			
 			.globl	EXT(hw_cpu_wcng)
 
 LEXT(hw_cpu_wcng)
 
-			mftb	r10							; Get the low part of the time base
-			mr		r9,r3						; Save the sync word address
-			li		r3,1						; Assume we work
+			mftb	r10								; Get the low part of the time base
+			mr		r9,r3							; Save the sync word address
+			li		r3,1							; Assume we work
 
-wcngtry:	lwz		r11,0(r9)					; Grab the  value
-			cmplw	r11,r4						; Do they still match?
-			bnelr-								; Nope, cool...
-			mftb	r12							; Time stamp us now
+wcngtry:	lwz		r11,0(r9)						; Grab the  value
+			cmplw	r11,r4							; Do they still match?
+			bnelr-									; Nope, cool...
+			mftb	r12								; Time stamp us now
 
-			sub		r12,r12,r10					; Get the elapsed time
-			cmplw	r5,r12						; Have we gone too long?
-			bge+	wcngtry						; Not yet...
+			sub		r12,r12,r10						; Get the elapsed time
+			cmplw	r5,r12							; Have we gone too long?
+			bge+	wcngtry							; Not yet...
 			
-			li		r3,0						; Set failure...
-			blr									; Return, head hanging low...
+			li		r3,0							; Set failure...
+			blr										; Return, head hanging low...
 			
 
 /*
- *      unsigned int hw_lock_try(hw_lock_t)
+ *		unsigned int hw_lock_try(hw_lock_t)
  *
- *      Try to acquire spin-lock. Return success (1) or failure (0)
- *      Returns with preemption disabled on success.
+ *			Try to acquire spin-lock. Return success (1) or failure (0)
+ *			Returns with preemption disabled on success.
  *
  */
 			.align	5
@@ -661,115 +636,101 @@ wcngtry:	lwz		r11,0(r9)					; Grab the  value
 
 LEXT(hw_lock_try)
 
-#if 0
-			lis		r0,HIGH_ADDR(CutTrace)		/* (TEST/DEBUG) */
-			lis		r5,0x9999					/* (TEST/DEBUG) */
-			oris	r0,r0,LOW_ADDR(CutTrace)	/* (TEST/DEBUG) */
-			sc									/* (TEST/DEBUG) */
-#endif
-			mfmsr	r9							/* Save the MSR value */
-			rlwinm	r9,r9,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-			rlwinm	r9,r9,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-			rlwinm	r7,r9,0,MSR_EE_BIT+1,MSR_EE_BIT-1	/* Clear interruption bit */
+			lis		r0,hi16(MASK(MSR_VEC))			; Get vector enable
+			mfmsr	r9								; Get the MSR value 
+			ori		r0,r0,lo16(MASK(MSR_FP))		; Get FP enable
+			ori		r7,r0,lo16(MASK(MSR_EE))		; Get EE bit on too
+			andc	r9,r9,r0						; Clear FP and VEC
+			andc	r7,r9,r7						; Clear EE as well
 
-#if	MACH_LDEBUG
-			lis	r5,	0x10						/* roughly 1E6 */
-			mtctr	r5
-#endif	/* MACH_LDEBUG */
-			
-			mtmsr	r7							/* Disable interruptions and thus, preemption */
-			isync								; May have turned off fp/vec here
-.L_lock_try_loop:	
+			mtmsr	r7								; Disable interruptions and thus, preemption
 
-#if	MACH_LDEBUG
-			bdnz+	0f							/* Count attempts */
-			mtmsr	r9							/* Restore enablement */
-			BREAKPOINT_TRAP						/* Get to debugger */
-			mtmsr	r7							/* Disable interruptions and thus, preemption */
-0:	
-#endif	/* MACH_LDEBUG */
+			lwz		r5,0(r3)						; Quick load
+			andi.	r6,r5,ILK_LOCKED				; TEST...
+			bne--	.L_lock_try_failed				; No go...
 
-			lwarx	r5,0,r3						/* Ld from addr of arg and reserve */
+.L_lock_try_loop:	
+			lwarx	r5,0,r3							; Ld from addr of arg and reserve
 
-			andi.	r6,r5,ILK_LOCKED			/* TEST... */
+			andi.	r6,r5,ILK_LOCKED				; TEST...
 			ori		r5,r5,ILK_LOCKED
-			bne-	.L_lock_try_failed			/* branch if taken. Predict free */
+			bne--	.L_lock_try_failedX				; branch if taken. Predict free 
 	
-			stwcx.	r5,0,r3						/* And SET (if still reserved) */
-			mfsprg	r6,0						/* Get the per_proc block */			
-			bne-	.L_lock_try_loop			/* If set failed, loop back */
+			stwcx.	r5,0,r3							; And SET (if still reserved)
+			bne--	.L_lock_try_loop				; If set failed, loop back 
 			
 			isync
 
-			lwz		r5,PP_PREEMPT_CNT(r6)		/* Get the preemption level */
-			addi	r5,r5,1						/* Bring up the disable count */
-			stw		r5,PP_PREEMPT_CNT(r6)		/* Save it back */
+			mfsprg	r6,1							; Get current activation 
+			lwz		r5,ACT_PREEMPT_CNT(r6)			; Get the preemption level
+			addi	r5,r5,1							; Bring up the disable count 
+			stw		r5,ACT_PREEMPT_CNT(r6)			; Save it back
 
- 			mtmsr	r9							/* Allow interruptions now */
-			li		r3,1						/* Set that the lock was free */
+ 			mtmsr	r9								; Allow interruptions now 
+			li		r3,1							; Set that the lock was free 
 			blr
 
+.L_lock_try_failedX:
+ 			li		r6,lgKillResv					; Killing field
+ 			stwcx.	r6,0,r6							; Kill reservation
+ 			
 .L_lock_try_failed:
- 			mtmsr	r9							/* Allow interruptions now */
-			li		r3,0						/* FAILURE - lock was taken */
+ 			mtmsr	r9								; Allow interruptions now 
+			li		r3,0							; FAILURE - lock was taken 
 			blr
 
 /*
- *      unsigned int hw_lock_held(hw_lock_t)
- *
- *      Return 1 if lock is held
- *      Doesn't change preemption state.
- *      N.B.  Racy, of course.
+ *		unsigned int hw_lock_held(hw_lock_t)
  *
+ *			Return 1 if lock is held
+ *			Doesn't change preemption state.
+ *			N.B.  Racy, of course.
  */
 			.align	5
 			.globl	EXT(hw_lock_held)
 
 LEXT(hw_lock_held)
 
-#if 0
-			lis		r0,HIGH_ADDR(CutTrace)		/* (TEST/DEBUG) */
-			lis		r5,0x8888					/* (TEST/DEBUG) */
-			oris	r0,r0,LOW_ADDR(CutTrace)	/* (TEST/DEBUG) */
-			sc									/* (TEST/DEBUG) */
-#endif
-			isync							/* Make sure we don't use a speculativily fetched lock */
-			lwz		r3, 0(r3)				/* Return value of lock */
+			isync									; Make sure we don't use a speculativily fetched lock 
+			lwz		r3, 0(r3)						; Get lock value 
+			andi.	r6,r3,ILK_LOCKED				; Extract the ILK_LOCKED bit
 			blr
 
 /*
  *		uint32_t hw_compare_and_store(uint32_t oldval, uint32_t newval, uint32_t *dest)
  *
- *		Compare old to area if equal, store new, and return true
- *		else return false and no store
- *		This is an atomic operation
- *
+ *			Compare old to area if equal, store new, and return true
+ *			else return false and no store
+ *			This is an atomic operation
  */
 			.align	5
 			.globl	EXT(hw_compare_and_store)
 
 LEXT(hw_compare_and_store)
 
-			mr		r6,r3						/* Save the old value */			
+			mr		r6,r3							; Save the old value
 
-cstry:		lwarx	r9,0,r5						/* Grab the area value */
-			li		r3,1						/* Assume it works */
-			cmplw	cr0,r9,r6					/* Does it match the old value? */
-			bne-	csfail						/* No, it must have changed... */
-			stwcx.	r4,0,r5						/* Try to save the new value */
-			bne-	cstry						/* Didn't get it, try again... */
-			isync								/* Just hold up prefetch */
-			blr									/* Return... */
+cstry:		lwarx	r9,0,r5							; Grab the area value
+			li		r3,1							; Assume it works
+			cmplw	cr0,r9,r6						; Does it match the old value?
+			bne--	csfail							; No, it must have changed...
+			stwcx.	r4,0,r5							; Try to save the new value
+			bne--	cstry							; Didn't get it, try again...
+			isync									; Just hold up prefetch
+			blr										; Return...
 			
-csfail:		li		r3,0						/* Set failure */
-			blr									/* Better luck next time... */
+csfail:		li		r3,lgKillResv					; Killing field
+			stwcx.	r3,0,r3							; Blow reservation
+			
+			li		r3,0							; Set failure
+			blr										; Better luck next time...
 
 
 /*
  *		uint32_t hw_atomic_add(uint32_t *dest, uint32_t delt)
  *
- *		Atomically add the second parameter to the first.
- *		Returns the result.
+ *			Atomically add the second parameter to the first.
+ *			Returns the result.
  *
  */
 			.align	5
@@ -777,20 +738,20 @@ csfail:		li		r3,0						/* Set failure */
 
 LEXT(hw_atomic_add)
 
-			mr		r6,r3						/* Save the area */			
+			mr		r6,r3							; Save the area
 
-addtry:		lwarx	r3,0,r6						/* Grab the area value */
-			add		r3,r3,r4					/* Add the value */
-			stwcx.	r3,0,r6						/* Try to save the new value */
-			bne-	addtry						/* Didn't get it, try again... */
-			blr									/* Return... */
+addtry:		lwarx	r3,0,r6							; Grab the area value
+			add		r3,r3,r4						; Add the value
+			stwcx.	r3,0,r6							; Try to save the new value
+			bne--	addtry							; Didn't get it, try again...
+			blr										; Return...
 
 
 /*
  *		uint32_t hw_atomic_sub(uint32_t *dest, uint32_t delt)
  *
- *		Atomically subtract the second parameter from the first.
- *		Returns the result.
+ *			Atomically subtract the second parameter from the first.
+ *			Returns the result.
  *
  */
 			.align	5
@@ -798,41 +759,40 @@ addtry:		lwarx	r3,0,r6						/* Grab the area value */
 
 LEXT(hw_atomic_sub)
 
-			mr		r6,r3						/* Save the area */			
+			mr		r6,r3							; Save the area
 
-subtry:		lwarx	r3,0,r6						/* Grab the area value */
-			sub		r3,r3,r4					/* Subtract the value */
-			stwcx.	r3,0,r6						/* Try to save the new value */
-			bne-	subtry						/* Didn't get it, try again... */
-			blr									/* Return... */
+subtry:		lwarx	r3,0,r6							; Grab the area value
+			sub		r3,r3,r4						; Subtract the value
+			stwcx.	r3,0,r6							; Try to save the new value
+			bne--	subtry							; Didn't get it, try again...
+			blr										; Return...
 
 
 /*
  *		uint32_t hw_atomic_or(uint32_t *dest, uint32_t mask)
  *
- *		Atomically ORs the second parameter into the first.
- *		Returns the result.
- *
+ *			Atomically ORs the second parameter into the first.
+ *			Returns the result.
  */
 			.align	5
 			.globl	EXT(hw_atomic_or)
 
 LEXT(hw_atomic_or)
 
-			mr		r6,r3						; Save the area 		
+			mr		r6,r3							; Save the area 		
 
-ortry:		lwarx	r3,0,r6						; Grab the area value
-			or		r3,r3,r4					; OR the value 
-			stwcx.	r3,0,r6						; Try to save the new value
-			bne-	ortry						; Did not get it, try again...
-			blr									; Return...
+ortry:		lwarx	r3,0,r6							; Grab the area value
+			or		r3,r3,r4						; OR the value 
+			stwcx.	r3,0,r6							; Try to save the new value
+			bne--	ortry							; Did not get it, try again...
+			blr										; Return...
 
 
 /*
  *		uint32_t hw_atomic_and(uint32_t *dest, uint32_t mask)
  *
- *		Atomically ANDs the second parameter with the first.
- *		Returns the result.
+ *			Atomically ANDs the second parameter with the first.
+ *			Returns the result.
  *
  */
 			.align	5
@@ -840,22 +800,22 @@ ortry:		lwarx	r3,0,r6						; Grab the area value
 
 LEXT(hw_atomic_and)
 
-			mr		r6,r3						; Save the area 		
+			mr		r6,r3							; Save the area 		
 
-andtry:		lwarx	r3,0,r6						; Grab the area value
-			and		r3,r3,r4					; AND the value 
-			stwcx.	r3,0,r6						; Try to save the new value
-			bne-	andtry						; Did not get it, try again...
-			blr									; Return...
+andtry:		lwarx	r3,0,r6							; Grab the area value
+			and		r3,r3,r4						; AND the value 
+			stwcx.	r3,0,r6							; Try to save the new value
+			bne--	andtry							; Did not get it, try again...
+			blr										; Return...
 
 
 /*
  *		void hw_queue_atomic(unsigned int * anchor, unsigned int * elem, unsigned int disp)
  *
- *		Atomically inserts the element at the head of the list
- *		anchor is the pointer to the first element
- *		element is the pointer to the element to insert
- *		disp is the displacement into the element to the chain pointer
+ *			Atomically inserts the element at the head of the list
+ *			anchor is the pointer to the first element
+ *			element is the pointer to the element to insert
+ *			disp is the displacement into the element to the chain pointer
  *
  */
 			.align	5
@@ -863,91 +823,92 @@ andtry:		lwarx	r3,0,r6						; Grab the area value
 
 LEXT(hw_queue_atomic)
 
-			mr		r7,r4						/* Make end point the same as start */
-			mr		r8,r5						/* Copy the displacement also */
-			b		hw_queue_comm				/* Join common code... */
+			mr		r7,r4							; Make end point the same as start
+			mr		r8,r5							; Copy the displacement also
+			b		hw_queue_comm					; Join common code...
 
 /*
  *		void hw_queue_atomic_list(unsigned int * anchor, unsigned int * first, unsigned int * last, unsigned int disp)
  *
- *		Atomically inserts the list of elements at the head of the list
- *		anchor is the pointer to the first element
- *		first is the pointer to the first element to insert
- *		last is the pointer to the last element to insert
- *		disp is the displacement into the element to the chain pointer
- *
+ *			Atomically inserts the list of elements at the head of the list
+ *			anchor is the pointer to the first element
+ *			first is the pointer to the first element to insert
+ *			last is the pointer to the last element to insert
+ *			disp is the displacement into the element to the chain pointer
  */
 			.align	5
 			.globl	EXT(hw_queue_atomic_list)
 
 LEXT(hw_queue_atomic_list)
 
-			mr		r7,r5						/* Make end point the same as start */
-			mr		r8,r6						/* Copy the displacement also */
+			mr		r7,r5							; Make end point the same as start
+			mr		r8,r6							; Copy the displacement also
 
 hw_queue_comm:
-			lwarx	r9,0,r3						/* Pick up the anchor */
-			stwx	r9,r8,r7					/* Chain that to the end of the new stuff */
-			eieio								; Make sure this store makes it before the anchor update
-			stwcx.	r4,0,r3						/* Try to chain into the front */
-			bne-	hw_queue_comm				/* Didn't make it, try again... */
-			
-			blr									/* Return... */
+			lwarx	r9,0,r3							; Pick up the anchor
+			stwx	r9,r8,r7						; Chain that to the end of the new stuff
+			eieio									; Make sure this store makes it before the anchor update
+			stwcx.	r4,0,r3							; Try to chain into the front
+			bne--	hw_queue_comm					; Didn't make it, try again...
+
+			blr										; Return...
 
 /*
  *		unsigned int *hw_dequeue_atomic(unsigned int *anchor, unsigned int disp)
  *
- *		Atomically removes the first element in a list and returns it.
- *		anchor is the pointer to the first element
- *		disp is the displacement into the element to the chain pointer
- *		Returns element if found, 0 if empty.
- *
+ *			Atomically removes the first element in a list and returns it.
+ *			anchor is the pointer to the first element
+ *			disp is the displacement into the element to the chain pointer
+ *			Returns element if found, 0 if empty.
  */
 			.align	5
 			.globl	EXT(hw_dequeue_atomic)
 
 LEXT(hw_dequeue_atomic)
 
-			mr		r5,r3						/* Save the anchor */
+			mr		r5,r3							; Save the anchor
 
 hw_dequeue_comm:
-			lwarx	r3,0,r5						/* Pick up the anchor */
-			mr.		r3,r3						/* Is the list empty? */
-			beqlr-								/* Leave it list empty... */
-			lwzx	r9,r4,r3					/* Get the next in line */
-			stwcx.	r9,0,r5						/* Try to chain into the front */
-			beqlr+								; Got the thing, go away with it...
-			b		hw_dequeue_comm				; Did not make it, try again...
+			lwarx	r3,0,r5							; Pick up the anchor
+			mr.		r3,r3							; Is the list empty?
+			beq--	hdcFail							; Leave it list empty...
+			lwzx	r9,r4,r3						; Get the next in line
+			stwcx.	r9,0,r5							; Try to chain into the front
+			beqlr++									; Got the thing, go away with it...
+			b		hw_dequeue_comm					; Did not make it, try again...
+
+hdcFail:	li		r4,lgKillResv					; Killing field
+			stwcx.	r4,0,r4							; Dump reservation
+			blr										; Leave...
+
 
 /*
- *	void mutex_init(mutex_t* l, etap_event_t etap)
+ *		void mutex_init(mutex_t* l, etap_event_t etap)
+ *
  */
+			.align	5
+			.globl	EXT(mutex_init)
 
-ENTRY(mutex_init,TAG_NO_FRAME_USED)
+LEXT(mutex_init)
 
 			PROLOG(0)
 			li	r10,	0
-			stw	r10,	LOCK_DATA(r3)		/* clear lock word */
-			sth	r10,	MUTEX_WAITERS(r3)	/* init waiter count */
+			stw	r10,	LOCK_DATA(r3)				; clear lock word
+			sth	r10,	MUTEX_WAITERS(r3)			; init waiter count
 			sth	r10,	MUTEX_PROMOTED_PRI(r3)
 #if	MACH_LDEBUG
-			stw	r10,	MUTEX_PC(r3)		/* init caller pc */
-			stw	r10,	MUTEX_THREAD(r3)	/* and owning thread */
+			stw	r10,	MUTEX_PC(r3)				; init caller pc
+			stw	r10,	MUTEX_THREAD(r3)			; and owning thread
 			li	r10,	MUTEX_TAG
-			stw	r10,	MUTEX_TYPE(r3)		/* set lock type */
+			stw	r10,	MUTEX_TYPE(r3)				; set lock type
 #endif	/* MACH_LDEBUG */
-
-#if	ETAP_LOCK_TRACE
-			bl	EXT(etap_mutex_init)		/* init ETAP data */
-#endif	/* ETAP_LOCK_TRACE */
-
 			EPILOG
 			blr
 
 /*
- *	void mutex_lock(mutex_t*)
+ *		void mutex_lock(mutex_t*)
+ *
  */
-
 			.align	5
 			.globl	EXT(mutex_lock)
 LEXT(mutex_lock)
@@ -956,21 +917,30 @@ LEXT(mutex_lock)
 LEXT(_mutex_lock)
 
 #if	!MACH_LDEBUG
-			mfsprg	r6,1					/* load the current thread */
+			mfsprg	r6,1							; load the current thread
+			lwz		r5,0(r3)						; Get the lock quickly
+			mr.		r5,r5							; Quick check
+			bne--	L_mutex_lock_slow				; Can not get it right now...
+
 L_mutex_lock_loop:
-			lwarx	r5,0,r3					/* load the mutex lock */
+			lwarx	r5,0,r3							; load the mutex lock
 			mr.		r5,r5
-			bne-	L_mutex_lock_slow		/* go to the slow path */
-			stwcx.	r6,0,r3					/* grab the lock */
-			bne-	L_mutex_lock_loop		/* loop back if failed */
-			isync							/* stop prefeteching */
+			bne--	L_mutex_lock_slowX				; go to the slow path
+			stwcx.	r6,0,r3							; grab the lock
+			bne--	L_mutex_lock_loop				; loop back if failed
+			isync									; stop prefeteching
 			blr
+
+L_mutex_lock_slowX:
+			li		r5,lgKillResv					; Killing field
+			stwcx.	r5,0,r5							; Kill reservation
+
 L_mutex_lock_slow:
 #endif
 #if CHECKNMI
-			mflr	r12							; (TEST/DEBUG) 
-			bl		EXT(ml_sense_nmi)			; (TEST/DEBUG)
-			mtlr	r12							; (TEST/DEBUG)
+			mflr	r12								; (TEST/DEBUG) 
+			bl		EXT(ml_sense_nmi)				; (TEST/DEBUG)
+			mtlr	r12								; (TEST/DEBUG)
 #endif
 
 			PROLOG(12)
@@ -990,37 +960,19 @@ L_mutex_lock_assert_wait_panic_str:
 L_mutex_lock_assert_wait_1:
 			lwz		r3,FM_ARG0(r1)
 #endif
-	
-#if	ETAP_LOCK_TRACE
-			li		r0,	0
-			stw		r0,SWT_HI(r1)			/* set wait time to 0 (HI) */
-			stw		r0,SWT_LO(r1)			/* set wait time to 0 (LO) */
-			stw		r0,MISSED(r1)			/* clear local miss marker */
-#endif	/* ETAP_LOCK_TRACE */
-
 			CHECK_SETUP(r12)	
 			CHECK_MUTEX_TYPE()
 			CHECK_NO_SIMPLELOCKS()
-
 .L_ml_retry:
-#if 0
-			mfsprg	r4,0						/* (TEST/DEBUG) */
-			lis		r0,HIGH_ADDR(CutTrace)		/* (TEST/DEBUG) */
-			lwz		r4,PP_ACTIVE_THREAD(r4)		/* (TEST/DEBUG) */
-			lis		r5,0xAAAA					/* (TEST/DEBUG) */
-			oris	r0,r0,LOW_ADDR(CutTrace)	/* (TEST/DEBUG) */
-			sc									/* (TEST/DEBUG) */
-#endif
-
-			bl		lockDisa				/* Go get a lock on the mutex's interlock lock */
-			mr.		r4,r3					/* Did we get it? */
-			lwz		r3,FM_ARG0(r1)			/* Restore the lock address */
-			bne+	mlGotInt				/* We got it just fine... */
-
-			lis		r3,HIGH_ADDR(mutex_failed1)	; Get the failed mutex message
-			ori		r3,r3,LOW_ADDR(mutex_failed1)	; Get the failed mutex message
-			bl		EXT(panic)				; Call panic
-			BREAKPOINT_TRAP					; We die here anyway, can not get the lock
+			bl		lockDisa						; Go get a lock on the mutex's interlock lock
+			mr.		r4,r3							; Did we get it?
+			lwz		r3,FM_ARG0(r1)					; Restore the lock address
+			bne+	mlGotInt						; We got it just fine...
+
+			lis		r3,hi16(mutex_failed1)			; Get the failed mutex message
+			ori		r3,r3,lo16(mutex_failed1)		; Get the failed mutex message
+			bl		EXT(panic)						; Call panic
+			BREAKPOINT_TRAP							; We die here anyway, can not get the lock
 	
 			.data
 mutex_failed1:
@@ -1029,29 +981,30 @@ mutex_failed1:
 			
 mlGotInt:
 			
-/*			Note that there is no reason to do a load and reserve here.  We already
-			hold the interlock lock and no one can touch this field unless they 
-			have that, so, we're free to play */
-			
-			lwz		r4,LOCK_DATA(r3)		/* Get the mutex's lock field */
-			rlwinm.	r9,r4,30,2,31			/* So, can we have it? */
-			bne-	mlInUse					/* Nope, sombody's playing already... */
+;			Note that there is no reason to do a load and reserve here.  We already
+;			hold the interlock lock and no one can touch this field unless they 
+;			have that, so, we're free to play
+
+			lwz		r4,LOCK_DATA(r3)				; Get the mutex's lock field
+			rlwinm.	r9,r4,30,2,31					; So, can we have it?
+			bne-	mlInUse							; Nope, sombody's playing already...
 
 #if	MACH_LDEBUG
-			mfmsr	r11						; Note: no need to deal with fp or vec here
-			rlwinm	r5,r11,0,MSR_EE_BIT+1,MSR_EE_BIT-1
+			li		r5,lo16(MASK(MSR_EE))			; Get the EE bit
+			mfmsr	r11								; Note: no need to deal with fp or vec here
+			andc	r5,r11,r5
 			mtmsr	r5
-			mfsprg	r9,0					/* Get the per_proc block */
-			lwz		r5,0(r1)				/* Get previous save frame */
-			lwz		r5,FM_LR_SAVE(r5)		/* Get our caller's address */
-			lwz		r8,	PP_ACTIVE_THREAD(r9)	/* Get the active thread */
-			stw		r5,MUTEX_PC(r3)		/* Save our caller */
-			mr.		r8,r8					/* Is there any thread? */
-			stw		r8,MUTEX_THREAD(r3)		/* Set the mutex's holding thread */
-			beq-	.L_ml_no_active_thread	/* No owning thread... */
-			lwz		r9,THREAD_MUTEX_COUNT(r8)	/* Get the mutex count */
-			addi	r9,r9,1					/* Bump it up */
-			stw		r9,THREAD_MUTEX_COUNT(r8)	/* Stash it back */
+			mfsprg	r9,0							; Get the per_proc block
+			lwz		r5,0(r1)						; Get previous save frame
+			lwz		r5,FM_LR_SAVE(r5)				; Get our caller's address
+			lwz		r8,	PP_ACTIVE_THREAD(r9)		; Get the active thread
+			stw		r5,MUTEX_PC(r3)					; Save our caller
+			mr.		r8,r8							; Is there any thread?
+			stw		r8,MUTEX_THREAD(r3)				; Set the mutex's holding thread
+			beq-	.L_ml_no_active_thread			; No owning thread...
+			lwz		r9,THREAD_MUTEX_COUNT(r8)		; Get the mutex count 
+			addi	r9,r9,1							; Bump it up 
+			stw		r9,THREAD_MUTEX_COUNT(r8)		; Stash it back 
 .L_ml_no_active_thread:
 			mtmsr	r11
 #endif	/* MACH_LDEBUG */
@@ -1062,112 +1015,85 @@ mlGotInt:
 			lwz		r3,FM_ARG0(r1)
 			beq		mlUnlock
 			ori		r5,r5,WAIT_FLAG
-mlUnlock:
-			sync
-			stw	r5,LOCK_DATA(r3)			/* grab the mutexlock and free the interlock */
 
-#if	ETAP_LOCK_TRACE
-			mflr	r4
-			lwz		r5,SWT_HI(r1)
-			lwz		r6,SWT_LO(r1)
-			bl	EXT(etap_mutex_hold)		/* collect hold timestamp */
-#endif	/* ETAP_LOCK_TRACE */
+mlUnlock:	eieio	
+			stw	r5,LOCK_DATA(r3)					; grab the mutexlock and free the interlock
 
-			EPILOG							/* Restore all saved registers */
+			EPILOG									; Restore all saved registers
+			b		epStart							; Go enable preemption...
 
-			b		epStart					/* Go enable preemption... */
-
-/*
- *			We come to here when we have a resource conflict.  In other words,
- *			the mutex is held.
- */
+;			We come to here when we have a resource conflict.  In other words,
+;			the mutex is held.
 
 mlInUse:
 
-#if	ETAP_LOCK_TRACE
-			lwz		r7,MISSED(r1)
-			cmpwi	r7,0					/* did we already take a wait timestamp ? */
-			bne		.L_ml_block				/* yup. carry-on */
-			bl		EXT(etap_mutex_miss)	/* get wait timestamp */
-			stw		r3,SWT_HI(r1)			/* store timestamp */
-			stw		r4,SWT_LO(r1)
-			li		r7,	1					/* mark wait timestamp as taken */
-			stw		r7,MISSED(r1)
-			lwz		r3,FM_ARG0(r1)			/* restore r3 (saved in prolog) */
-.L_ml_block:
-#endif	/* ETAP_LOCK_TRACE */
-
 			CHECK_SETUP(r12)	
-			CHECK_MYLOCK(MUTEX_THREAD)		/* Assert we don't own the lock already */
-	
+			CHECK_MYLOCK(MUTEX_THREAD)				; Assert we don't own the lock already */
 
-/*			Note that we come in here with the interlock set.  The wait routine
- *			will unlock it before waiting.
- */
-			ori		r4,r4,WAIT_FLAG			/* Set the wait flag */
-			stw	r4,LOCK_DATA(r3)
-			rlwinm	r4,r4,0,0,29			/* Extract the lock owner */
-			bl	EXT(mutex_lock_wait)		/* Wait for our turn at the lock */
+;			Note that we come in here with the interlock set.  The wait routine
+;			will unlock it before waiting.
+
+			ori		r4,r4,WAIT_FLAG					; Set the wait flag
+			stw		r4,LOCK_DATA(r3)
+			rlwinm	r4,r4,0,0,29					; Extract the lock owner
+			bl		EXT(mutex_lock_wait)			; Wait for our turn at the lock
 			
-			lwz	r3,FM_ARG0(r1)				/* restore r3 (saved in prolog) */
-			b	.L_ml_retry					/* and try again... */
+			lwz		r3,FM_ARG0(r1)					; restore r3 (saved in prolog)
+			b		.L_ml_retry						; and try again...
 
 	
 /*
- *	void _mutex_try(mutex_t*)
+ *		void _mutex_try(mutex_t*)
  *
  */
-	
 			.align	5
 			.globl	EXT(mutex_try)
 LEXT(mutex_try)
 			.globl	EXT(_mutex_try)
 LEXT(_mutex_try)
 #if	!MACH_LDEBUG
-			mfsprg	r6,1					/* load the current thread */
+			mfsprg	r6,1							; load the current thread
+			lwz		r5,0(r3)						; Get the lock value
+			mr.		r5,r5							; Quick check
+			bne--	L_mutex_try_slow				; Can not get it now...
+
 L_mutex_try_loop:
-			lwarx	r5,0,r3					/* load the lock value */
+			lwarx	r5,0,r3							; load the lock value
 			mr.		r5,r5
-			bne-	L_mutex_try_slow		/* branch to the slow  path */
-			stwcx.	r6,0,r3					/* grab the lock */
-			bne-	L_mutex_try_loop		/* retry if failed */
-			isync							/* stop prefetching */
+			bne--	L_mutex_try_slowX				; branch to the slow path
+			stwcx.	r6,0,r3							; grab the lock
+			bne--	L_mutex_try_loop				; retry if failed
+			isync									; stop prefetching
 			li		r3, 1
 			blr
+
+L_mutex_try_slowX:
+			li		r5,lgKillResv					; Killing field
+			stwcx.	r5,0,r5							; Kill reservation
+
 L_mutex_try_slow:
+
 #endif
 
-			PROLOG(8)						/* reserve space for SWT_HI and SWT_LO */
+			PROLOG(8)								; reserve space for SWT_HI and SWT_LO
 	
-#if	ETAP_LOCK_TRACE
-			li	r5,	0
-			stw	r5,	STW_HI(r1)				/* set wait time to 0 (HI) */
-			stw	r5,	SWT_LO(r1)				/* set wait time to 0 (LO) */
-#endif	/* ETAP_LOCK_TRACE */
-
-#if 0
-			lis		r0,HIGH_ADDR(CutTrace)		/* (TEST/DEBUG) */
-			lis		r5,0xBBBB					/* (TEST/DEBUG) */
-			oris	r0,r0,LOW_ADDR(CutTrace)	/* (TEST/DEBUG) */
-			sc									/* (TEST/DEBUG) */
-#endif
 			CHECK_SETUP(r12)	
 			CHECK_MUTEX_TYPE()
 			CHECK_NO_SIMPLELOCKS()
 			
-			lwz		r6,LOCK_DATA(r3)		/* Quick check */
-			rlwinm.	r6,r6,30,2,31			/* to see if someone has this lock already */
-			bne-	mtFail					/* Someone's got it already... */
-
-			bl		lockDisa				/* Go get a lock on the mutex's interlock lock */
-			mr.		r4,r3					/* Did we get it? */
-			lwz		r3,FM_ARG0(r1)			/* Restore the lock address */
-			bne+	mtGotInt				/* We got it just fine... */
-
-			lis		r3,HIGH_ADDR(mutex_failed2)	; Get the failed mutex message
-			ori		r3,r3,LOW_ADDR(mutex_failed2)	; Get the failed mutex message
-			bl		EXT(panic)				; Call panic
-			BREAKPOINT_TRAP					; We die here anyway, can not get the lock
+			lwz		r6,LOCK_DATA(r3)				; Quick check
+			rlwinm.	r6,r6,30,2,31					; to see if someone has this lock already
+			bne-	mtFail							; Someone's got it already...
+
+			bl		lockDisa						; Go get a lock on the mutex's interlock lock
+			mr.		r4,r3							; Did we get it? */
+			lwz		r3,FM_ARG0(r1)					; Restore the lock address
+			bne+	mtGotInt						; We got it just fine...
+
+			lis		r3,hi16(mutex_failed2)			; Get the failed mutex message
+			ori		r3,r3,lo16(mutex_failed2)		; Get the failed mutex message
+			bl		EXT(panic)						; Call panic
+			BREAKPOINT_TRAP							; We die here anyway, can not get the lock
 	
 			.data
 mutex_failed2:
@@ -1176,29 +1102,34 @@ mutex_failed2:
 			
 mtGotInt:
 			
-/*			Note that there is no reason to do a load and reserve here.  We already
-			hold the interlock and no one can touch at this field unless they 
-			have that, so, we're free to play */
+;			Note that there is no reason to do a load and reserve here.  We already
+;			hold the interlock and no one can touch at this field unless they 
+;			have that, so, we're free to play 
 			
-			lwz		r4,LOCK_DATA(r3)		/* Get the mutex's lock field */
-			rlwinm.	r9,r4,30,2,31			/* So, can we have it? */
-			bne-	mtInUse					/* Nope, sombody's playing already... */
+			lwz		r4,LOCK_DATA(r3)				; Get the mutex's lock field
+			rlwinm.	r9,r4,30,2,31					; So, can we have it?
+			bne-	mtInUse							; Nope, sombody's playing already...
 			
 #if	MACH_LDEBUG
-			mfmsr	r11
-			rlwinm	r5,r11,0,MSR_EE_BIT+1,MSR_EE_BIT-1
+			lis		r9,hi16(MASK(MSR_VEC))			; Get vector enable
+			mfmsr	r11								; Get the MSR value
+			ori		r9,r9,lo16(MASK(MSR_FP))		; Get FP enable
+			ori		r5,r9,lo16(MASK(MSR_EE))		; Get EE bit on too
+			andc	r11,r11,r9						; Clear FP and VEC
+			andc	r5,r11,r5						; Clear EE as well
+
 			mtmsr	r5
-			mfsprg	r9,0					/* Get the per_proc block */
-			lwz		r5,0(r1)				/* Get previous save frame */
-			lwz		r5,FM_LR_SAVE(r5)		/* Get our caller's address */
-			lwz		r8,	PP_ACTIVE_THREAD(r9)	/* Get the active thread */
-			stw		r5,MUTEX_PC(r3)		/* Save our caller */
-			mr.		r8,r8					/* Is there any thread? */
-			stw		r8,MUTEX_THREAD(r3)		/* Set the mutex's holding thread */
-			beq-	.L_mt_no_active_thread	/* No owning thread... */
-			lwz		r9,	THREAD_MUTEX_COUNT(r8)	/* Get the mutex count */
-			addi	r9,	r9,	1				/* Bump it up */
-			stw		r9,	THREAD_MUTEX_COUNT(r8)	/* Stash it back */
+			mfsprg	r9,0							; Get the per_proc block
+			lwz		r5,0(r1)						; Get previous save frame
+			lwz		r5,FM_LR_SAVE(r5)				; Get our caller's address
+			lwz		r8,	PP_ACTIVE_THREAD(r9)		; Get the active thread
+			stw		r5,MUTEX_PC(r3)					; Save our caller
+			mr.		r8,r8							; Is there any thread?
+			stw		r8,MUTEX_THREAD(r3)				; Set the mutex's holding thread
+			beq-	.L_mt_no_active_thread			; No owning thread...
+			lwz		r9,	THREAD_MUTEX_COUNT(r8)		; Get the mutex count
+			addi	r9,	r9,	1						; Bump it up 
+			stw		r9,	THREAD_MUTEX_COUNT(r8)		; Stash it back 
 .L_mt_no_active_thread:
 			mtmsr	r11
 #endif	/* MACH_LDEBUG */
@@ -1209,87 +1140,107 @@ mtGotInt:
 			lwz		r3,FM_ARG0(r1)
 			beq		mtUnlock
 			ori		r5,r5,WAIT_FLAG
-mtUnlock:
-			sync							/* Push it all out */
-			stw	r5,LOCK_DATA(r3)			/* grab the mutexlock and free the interlock */
 
-#if	ETAP_LOCK_TRACE
-			lwz		r4,0(r1)				/* Back chain the stack */
-			lwz		r5,SWT_HI(r1)
-			lwz		r4,FM_LR_SAVE(r4)		/* Get our caller's address */
-			lwz		r6,SWT_LO(r1)
-			bl	EXT(etap_mutex_hold)		/* collect hold timestamp */
-#endif	/* ETAP_LOCK_TRACE */
+mtUnlock:	eieio
+			stw	r5,LOCK_DATA(r3)					; grab the mutexlock and free the interlock
 
-			bl		epStart					/* Go enable preemption... */
+			bl		epStart							; Go enable preemption...
 
 			li		r3, 1
-			EPILOG							/* Restore all saved registers */
-			blr								/* Return... */
+			EPILOG									; Restore all saved registers
+			blr										; Return...
 
-/*
- *			We come to here when we have a resource conflict.  In other words,
- *			the mutex is held.
- */
+;			We come to here when we have a resource conflict.  In other words,
+;			the mutex is held.
 
 mtInUse:	
-			rlwinm	r4,r4,0,0,30			/* Get the unlock value */
-			stw		r4,LOCK_DATA(r3)		/* free the interlock */
-			bl		epStart					/* Go enable preemption... */
+			rlwinm	r4,r4,0,0,30					; Get the unlock value
+			stw		r4,LOCK_DATA(r3)				; free the interlock
+			bl		epStart							; Go enable preemption...
 
-mtFail:		li		r3,0					/* Set failure code */
-			EPILOG							/* Restore all saved registers */
-			blr								/* Return... */
+mtFail:		li		r3,0							; Set failure code
+			EPILOG									; Restore all saved registers
+			blr										; Return...
 
 		
 /*
- *	void mutex_unlock(mutex_t* l)
+ *		void mutex_unlock_rwcmb(mutex_t* l)
+ *
  */
+			.align	5
+			.globl	EXT(mutex_unlock_rwcmb)
+
+LEXT(mutex_unlock_rwcmb)
+			.globl	EXT(mulckPatch_isync)
+LEXT(mulckPatch_isync)
+			isync
+			.globl	EXT(mulckPatch_eieio)     
+LEXT(mulckPatch_eieio)
+			eieio
 
+			lwz		r5,0(r3)						; Get the lock
+			rlwinm.	r4,r5,0,30,31					; Quick check
+			bne--	L_mutex_unlock_slow				; Can not get it now...
+
+L_mutex_unlock_rwcmb_loop:
+			lwarx	r5,0,r3
+			rlwinm.	r4,r5,0,30,31					; Bail if pending waiter or interlock set
+			li		r5,0							; Clear the mutexlock
+			bne--	L_mutex_unlock_rwcmb_slowX
+			stwcx.	r5,0,r3
+			bne--	L_mutex_unlock_rwcmb_loop
+			blr
+
+L_mutex_unlock_rwcmb_slowX:
+			li		r5,lgKillResv					; Killing field
+			stwcx.	r5,0,r5							; Dump reservation
+			b		L_mutex_unlock_slow				; Join slow path...
+
+/*
+ *		void mutex_unlock(mutex_t* l)
+ *
+ */
 			.align	5
 			.globl	EXT(mutex_unlock)
 
 LEXT(mutex_unlock)
 #if	!MACH_LDEBUG
 			sync
+			lwz		r5,0(r3)						; Get the lock
+			rlwinm.	r4,r5,0,30,31					; Quick check
+			bne--	L_mutex_unlock_slow				; Can not get it now...
+
 L_mutex_unlock_loop:
 			lwarx	r5,0,r3
-			rlwinm.	r4,r5,0,30,31			/* Bail if pending waiter or interlock set */
-			li		r5,0					/* Clear the mutexlock */
-			bne-	L_mutex_unlock_slow
+			rlwinm.	r4,r5,0,30,31					; Bail if pending waiter or interlock set
+			li		r5,0							; Clear the mutexlock
+			bne--	L_mutex_unlock_slowX
 			stwcx.	r5,0,r3
-			bne-	L_mutex_unlock_loop
+			bne--	L_mutex_unlock_loop
 			blr
-L_mutex_unlock_slow:
+L_mutex_unlock_slowX:
+			li		r5,lgKillResv					; Killing field
+			stwcx.	r5,0,r5							; Dump reservation
+
 #endif
+
+L_mutex_unlock_slow:
+			
 			PROLOG(0)
 	
-#if	ETAP_LOCK_TRACE
-			bl		EXT(etap_mutex_unlock)	/* collect ETAP data */
-			lwz		r3,FM_ARG0(r1)			/* restore r3 (saved in prolog) */
-#endif	/* ETAP_LOCK_TRACE */
-
 			CHECK_SETUP(r12)	
 			CHECK_MUTEX_TYPE()
 			CHECK_THREAD(MUTEX_THREAD)
 
-#if 0
-			mfsprg	r4,0						/* (TEST/DEBUG) */
-			lis		r0,HIGH_ADDR(CutTrace)		/* (TEST/DEBUG) */
-			lwz		r4,PP_ACTIVE_THREAD(r4)	/* (TEST/DEBUG) */
-			lis		r5,0xCCCC					/* (TEST/DEBUG) */
-			oris	r0,r0,LOW_ADDR(CutTrace)	/* (TEST/DEBUG) */
-			sc									/* (TEST/DEBUG) */
-#endif
-			bl		lockDisa				/* Go get a lock on the mutex's interlock lock */
-			mr.		r4,r3					/* Did we get it? */
-			lwz		r3,FM_ARG0(r1)			/* Restore the lock address */
-			bne+	muGotInt				/* We got it just fine... */
-
-			lis		r3,HIGH_ADDR(mutex_failed3)	; Get the failed mutex message
-			ori		r3,r3,LOW_ADDR(mutex_failed3)	; Get the failed mutex message
-			bl		EXT(panic)				; Call panic
-			BREAKPOINT_TRAP					; We die here anyway, can not get the lock
+			bl		lockDisa						; Go get a lock on the mutex's interlock lock
+			mr.		r4,r3							; Did we get it?
+			lwz		r3,FM_ARG0(r1)					; Restore the lock address
+			bne+	muGotInt						; We got it just fine...
+
+			lis		r3,hi16(mutex_failed3)			; Get the failed mutex message
+			ori		r3,r3,lo16(mutex_failed3)		; Get the failed mutex message
+			bl		EXT(panic)						; Call panic
+			BREAKPOINT_TRAP							; We die here anyway, can not get the lock
 	
 			.data
 mutex_failed3:
@@ -1299,22 +1250,27 @@ mutex_failed3:
 			
 muGotInt:
 			lwz		r4,LOCK_DATA(r3)
-			andi.	r5,r4,WAIT_FLAG			/* are there any waiters ? */
+			andi.	r5,r4,WAIT_FLAG					; are there any waiters ?
 			rlwinm	r4,r4,0,0,29
-			beq+	muUnlock				/* Nope, we're done... */
+			beq+	muUnlock						; Nope, we're done...
 
-			bl		EXT(mutex_unlock_wakeup)	/* yes, wake a thread */
-			lwz		r3,FM_ARG0(r1)			/* restore r3 (saved in prolog) */
-			lwz		r5,LOCK_DATA(r3)		/* load the lock */
+			bl		EXT(mutex_unlock_wakeup)		; yes, wake a thread
+			lwz		r3,FM_ARG0(r1)					; restore r3 (saved in prolog)
+			lwz		r5,LOCK_DATA(r3)				; load the lock
 
 muUnlock:
 #if	MACH_LDEBUG
-			mfmsr	r11
-			rlwinm	r9,r11,0,MSR_EE_BIT+1,MSR_EE_BIT-1
+			lis		r8,hi16(MASK(MSR_VEC))			; Get vector enable
+			mfmsr	r11								; Get the MSR value
+			ori		r8,r8,lo16(MASK(MSR_FP))		; Get FP enable
+			ori		r9,r8,lo16(MASK(MSR_EE))		; Get EE bit on too
+			andc	r11,r11,r8						; Clear FP and VEC
+			andc	r9,r11,r9						; Clear EE as well
+
 			mtmsr	r9
 			mfsprg	r9,0					
 			lwz		r9,PP_ACTIVE_THREAD(r9)
-			stw		r9,MUTEX_THREAD(r3)	/* disown thread */
+			stw		r9,MUTEX_THREAD(r3)				; disown thread
 			cmpwi	r9,0
 			beq-	.L_mu_no_active_thread
 			lwz		r8,THREAD_MUTEX_COUNT(r9)
@@ -1324,139 +1280,115 @@ muUnlock:
 			mtmsr	r11
 #endif	/* MACH_LDEBUG */
 
-			andi.	r5,r5,WAIT_FLAG			/* Get the unlock value */
-			sync							/* Make sure it's all there before we release */
-			stw		r5,LOCK_DATA(r3)		/* unlock the interlock and lock */
-		
-			EPILOG							/* Deal with the stack now, enable_preemption doesn't always want one */
-			b		epStart					/* Go enable preemption... */
+			andi.	r5,r5,WAIT_FLAG					; Get the unlock value
+			eieio
+			stw		r5,LOCK_DATA(r3)				; unlock the interlock and lock
+
+			EPILOG									; Deal with the stack now, enable_preemption doesn't always want one
+			b		epStart							; Go enable preemption...
 
 /*
- *	void interlock_unlock(hw_lock_t lock)
+ *		void interlock_unlock(hw_lock_t lock)
  */
-
 			.align	5
 			.globl	EXT(interlock_unlock)
 
 LEXT(interlock_unlock)
 
-#if 0
-			lis		r0,HIGH_ADDR(CutTrace)		/* (TEST/DEBUG) */
-			lis		r5,0xDDDD					/* (TEST/DEBUG) */
-			oris	r0,r0,LOW_ADDR(CutTrace)	/* (TEST/DEBUG) */
-			sc									/* (TEST/DEBUG) */
-#endif
 			lwz		r10,LOCK_DATA(r3)
 			rlwinm	r10,r10,0,0,30
-			sync
+			eieio
 			stw		r10,LOCK_DATA(r3)
 
-			b		epStart					/* Go enable preemption... */
+			b		epStart							; Go enable preemption...
 
-/*
- *		Here is where we enable preemption.  We need to be protected
- *		against ourselves, we can't chance getting interrupted and modifying
- *		our processor wide preemption count after we'sve loaded it up. So,
- *		we need to disable all 'rupts.  Actually, we could use a compare
- *		and swap to do this, but, since there are no MP considerations
- *		(we are dealing with a CPU local field) it is much, much faster
- *		to disable.
+/*		
+ *		void _enable_preemption_no_check(void)
  *
- *		Note that if we are not genned MP, the calls here will be no-opped via
- *		a #define and since the _mp forms are the same, likewise a #define
- *		will be used to route to the other forms
+ *			This version does not check if we get preempted or not
  */
-
-/*		This version does not check if we get preempted or not */
-
-
 			.align	4
 			.globl	EXT(_enable_preemption_no_check)
 
 LEXT(_enable_preemption_no_check)
-			cmplw	cr1,r1,r1			/* Force zero cr so we know not to check if preempted */
-			b		epCommn				/* Join up with the other enable code... */
 
+			cmplw	cr1,r1,r1						; Force zero cr so we know not to check if preempted
+			b		epCommn							; Join up with the other enable code... 
 
-/*		This version checks if we get preempted or not */
-
+/*		
+ *		void _enable_preemption(void)
+ *
+ *			This version checks if we get preempted or not
+ */
 			.align	5
 			.globl	EXT(_enable_preemption)
 
 LEXT(_enable_preemption)
 
-epStart:	cmplwi	cr1,r1,0			/* Force non-zero cr so we know to check if preempted */
-
-/*
- *			Common enable preemption code 
- */
-
-epCommn:	mfmsr	r9					/* Save the old MSR */
-			rlwinm	r9,r9,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-			rlwinm	r9,r9,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-			rlwinm	r8,r9,0,MSR_EE_BIT+1,MSR_EE_BIT-1	/* Clear interruptions */
- 			mtmsr	r8					/* Interrupts off */
-			isync						; May have mess with vec/fp here
-						
-			mfsprg	r3,0				/* Get the per_proc block */
-			li		r8,-1				/* Get a decrimenter */
-			lwz		r5,PP_PREEMPT_CNT(r3)	/* Get the preemption level */
-			add.	r5,r5,r8			/* Bring down the disable count */
-#if 0
-			mfsprg	r4,1				; (TEST/DEBUG) Note the next 3 keep from interrpting too early
-			mr.		r4,r4				; (TEST/DEBUG)
-			beq-	epskptrc0			; (TEST/DEBUG)
-			lis		r0,hi16(CutTrace)	; (TEST/DEBUG)
-			lis		r4,0xBBBB			; (TEST/DEBUG)
-			oris	r0,r0,lo16(CutTrace)	; (TEST/DEBUG)
-			sc							; (TEST/DEBUG)
-epskptrc0:	mr.		r5,r5				; (TEST/DEBUG)
-#endif
-#if MACH_LDEBUG
-			blt-	epTooFar			/* Yeah, we did... */
-#endif /* MACH_LDEBUG */
-			stw		r5,PP_PREEMPT_CNT(r3)	/* Save it back */
-
-			beq+	epCheckPreempt		/* Go check if we need to be preempted... */
-
-epNoCheck:	mtmsr	r9					/* Restore the interrupt level */
-			blr							/* Leave... */
-
-#if MACH_LDEBUG
+;		Here is where we enable preemption.  We need to be protected
+;		against ourselves, we can't chance getting interrupted and modifying
+;		our processor wide preemption count after we'sve loaded it up. So,
+;		we need to disable all 'rupts.  Actually, we could use a compare
+;		and swap to do this, but, since there are no MP considerations
+;		(we are dealing with a CPU local field) it is much, much faster
+;		to disable.
+;
+;		Note that if we are not genned MP, the calls here will be no-opped via
+;		a #define and since the _mp forms are the same, likewise a #define
+;		will be used to route to the other forms
+
+epStart:
+			cmplwi	cr1,r1,0						; Force non-zero cr so we know to check if preempted
+
+epCommn:
+			mfsprg	r3,1							; Get current activation
+			li		r8,-1							; Get a decrementer
+			lwz		r5,ACT_PREEMPT_CNT(r3)			; Get the preemption level
+			add.	r5,r5,r8						; Bring down the disable count
+			blt-	epTooFar						; Yeah, we did...
+			stw		r5,ACT_PREEMPT_CNT(r3)			; Save it back
+			crandc	cr0_eq,cr0_eq,cr1_eq
+			beq+	epCheckPreempt					; Go check if we need to be preempted...
+			blr										; Leave...
 epTooFar:	
-			lis		r6,HIGH_ADDR(EXT(panic))	/* First half of panic call */
-			lis		r3,HIGH_ADDR(epTooFarStr)	/* First half of panic string */
-			ori		r6,r6,LOW_ADDR(EXT(panic))	/* Second half of panic call */
-			ori		r3,r3,LOW_ADDR(epTooFarStr)	/* Second half of panic string */
-			mtlr	r6					/* Get the address of the panic routine */
-			mtmsr	r9					/* Restore interruptions */
-			blrl						/* Panic... */
+			mr		r4,r5
+			lis		r3,hi16(epTooFarStr)			; First half of panic string
+			ori		r3,r3,lo16(epTooFarStr)			; Second half of panic string
+			bl		EXT(panic)
 
 			.data
 epTooFarStr:
-			STRINGD	"_enable_preemption: preemption_level <= 0!\000"
-			.text
-#endif /* MACH_LDEBUG */
+			STRINGD	"_enable_preemption: preemption_level %d\n\000"
 
+			.text
 			.align	5
-
 epCheckPreempt:
-			lwz		r7,PP_NEED_AST(r3)	/* Get the AST request address */
-			li		r5,AST_URGENT		/* Get the requests we do honor */
-			lwz		r7,0(r7)			/* Get the actual, real live, extra special AST word */
-			lis		r0,HIGH_ADDR(DoPreemptCall)	/* Just in case, get the top of firmware call */
-			and.	r7,r7,r5			; Should we preempt?
-			ori		r0,r0,LOW_ADDR(DoPreemptCall)	/* Merge in bottom part */
-			beq+	epCPno				; No preemption here...
-
-			andi.	r3,r9,lo16(MASK(MSR_EE))	; We cannot preempt if interruptions are off
-
-epCPno:		mtmsr	r9					/* Allow interrupts if we can */
-			beqlr+						; We probably will not preempt...
-			sc							/* Do the preemption */
-			blr							/* Now, go away now... */
+			lis		r0,hi16(MASK(MSR_VEC))			; Get vector enable
+			mfmsr	r9								; Get the MSR value
+			ori		r0,r0,lo16(MASK(MSR_FP))		; Get FP enable
+			andi.	r3,r9,lo16(MASK(MSR_EE))		; We cannot preempt if interruptions are off
+			beq+	epCPno							; No preemption here...
+			ori		r7,r0,lo16(MASK(MSR_EE))		; Get EE bit on too
+			andc	r9,r9,r0						; Clear FP and VEC
+			andc	r7,r9,r7						; Clear EE as well
+			mtmsr	r7								; Turn off interruptions 
+			isync									; May have turned off vec and fp here 
+			mfsprg	r3,0							; Get per_proc 
+			lwz		r7,PP_NEED_AST(r3)				; Get the AST request address
+			li		r5,AST_URGENT					; Get the requests we do honor
+			lwz		r7,0(r7)						; Get the actual, real live, extra special AST word
+			lis		r0,hi16(DoPreemptCall)			; Just in case, get the top of firmware call
+			and.	r7,r7,r5						; Should we preempt?
+			ori		r0,r0,lo16(DoPreemptCall)		; Merge in bottom part
+			mtmsr	r9								; Allow interrupts if we can
+epCPno:		
+			beqlr+									; We probably will not preempt...
+			sc										; Do the preemption
+			blr										; Now, go away now...
 
 /*
+ *		void disable_preemption(void)
+ *
  *			Here is where we disable preemption.  Since preemption is on a
  *			per processor basis (a thread runs on one CPU at a time) we don't
  *			need any cross-processor synchronization.  We do, however, need to
@@ -1465,355 +1397,273 @@ epCPno:		mtmsr	r9					/* Allow interrupts if we can */
  *			disablement, and this is platform specific code, we'll just kick the
  *			MSR. We'll save a couple of orders of magnitude over using SPLs.
  */
-
 			.align	5
-
-			nop							; Use these 5 nops to force daPreComm 
-			nop							; to a line boundary.
-			nop
-			nop
-			nop
-			
 			.globl	EXT(_disable_preemption)
 
 LEXT(_disable_preemption)
 
-daPreAll:	mfmsr	r9					/* Save the old MSR */
-			rlwinm	r9,r9,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-			rlwinm	r9,r9,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-			rlwinm	r8,r9,0,MSR_EE_BIT+1,MSR_EE_BIT-1	/* Clear interruptions */
- 			mtmsr	r8					/* Interrupts off */
-			isync						; May have mess with fp/vec
-			
-daPreComm:	mfsprg	r6,0				/* Get the per_proc block */
-			lwz		r5,PP_PREEMPT_CNT(r6)	/* Get the preemption level */
-			addi	r5,r5,1				/* Bring up the disable count */
-			stw		r5,PP_PREEMPT_CNT(r6)	/* Save it back */
-#if 0
-			mfsprg	r4,1				; (TEST/DEBUG) Note the next 3 keep from interrpting too early
-			mr.		r4,r4				; (TEST/DEBUG)
-			beq-	epskptrc1			; (TEST/DEBUG)
-			lis		r0,hi16(CutTrace)	; (TEST/DEBUG)
-			lis		r4,0xAAAA			; (TEST/DEBUG)
-			oris	r0,r0,lo16(CutTrace)	; (TEST/DEBUG)
-			sc							; (TEST/DEBUG)
-epskptrc1:								; (TEST/DEBUG)
-#endif
-
-;
-;		Set PREEMPTSTACK above to enable a preemption traceback stack. 		
-;
-;		NOTE: make sure that PREEMPTSTACK in aligned_data is
-;		set the same as it is here.  This is the number of
-;		traceback entries we can handle per processor
-;
-;		A value of 0 disables the stack.
-;
-#if PREEMPTSTACK
-			cmplwi	r5,PREEMPTSTACK		; Maximum depth
-			lwz		r6,CPU_ACTIVE_THREAD(r6)	; Get the pointer to the currently active thread
-			bgt-	nopredeb			; Too many to stack...
-			mr.		r6,r6				; During boot?
-			beq-	nopredeb			; Yes, do not do backtrace...
-			lwz		r6,THREAD_TOP_ACT(r6)	; Point to the active activation
-			lwz		r6,ACT_MACT_PCB(r6)		; Get the last savearea used
-			mr.		r0,r6				; Any saved context?
-			beq-	nosaveds			; No...
-			lwz		r0,saver1(r6)		; Get end of savearea chain
-
-nosaveds:	li		r11,0				; Clear callers callers callers return
-			li		r10,0				; Clear callers callers callers callers return
-			li		r8,0				; Clear callers callers callers callers callers return
-			lwz		r2,0(r1)			; Get callers callers stack frame
-			lwz		r12,8(r2)			; Get our callers return
-			lwz		r4,0(r2)			; Back chain
-
-			xor		r2,r4,r2			; Form difference
-			cmplwi	r2,8192				; Within a couple of pages?
-			mr		r2,r4				; Move register
-			bge-	nosaveher2			; No, no back chain then...
-			lwz		r11,8(r2)			; Get our callers return
-			lwz		r4,0(r2)			; Back chain
-
-			xor		r2,r4,r2			; Form difference
-			cmplwi	r2,8192				; Within a couple of pages?
-			mr		r2,r4				; Move register
-			bge-	nosaveher2			; No, no back chain then...
-			lwz		r10,8(r2)			; Get our callers return
-			lwz		r4,0(r2)			; Back chain
-
-			xor		r2,r4,r2			; Form difference
-			cmplwi	r2,8192				; Within a couple of pages?
-			mr		r2,r4				; Move register
-			bge-	nosaveher2			; No, no back chain then...
-			lwz		r8,8(r2)			; Get our callers return
-
-nosaveher2:
-			addi	r5,r5,-1			; Get index to slot
-			mfspr	r6,pir				; Get our processor
-			mflr	r4					; Get our return
-			rlwinm	r6,r6,8,0,23		; Index to processor slot
-			lis		r2,hi16(EXT(DBGpreempt))	; Stack high order
-			rlwinm	r5,r5,4,0,27		; Index to stack slot			
-			ori		r2,r2,lo16(EXT(DBGpreempt))	; Stack low order
-			add		r2,r2,r5			; Point to slot
-			add		r2,r2,r6			; Move to processor
-			stw		r4,0(r2)			; Save our return
-			stw		r11,4(r2)			; Save callers caller
-			stw		r10,8(r2)			; Save callers callers caller
-			stw		r8,12(r2)			; Save callers callers callers caller
-nopredeb:
-#endif
- 			mtmsr	r9					/* Allow interruptions now */
-			
-			blr							/* Return... */
+			mfsprg	r6,1							; Get the current activation
+			lwz		r5,ACT_PREEMPT_CNT(r6)			; Get the preemption level
+			addi	r5,r5,1							; Bring up the disable count
+			stw		r5,ACT_PREEMPT_CNT(r6)			; Save it back 
+			blr										; Return...
 
 /*
- *			Return the active thread for both inside and outside osfmk consumption
+ *		int get_preemption_level(void)
+ *
+ *			Return the current preemption level
  */
-  
 			.align	5
-			.globl	EXT(current_thread)
-
-LEXT(current_thread)
-
-#if 1
-			mfsprg	r3,1
-			lwz		r3,ACT_THREAD(r3)
-			blr
-#else
-			mfmsr	r9					/* Save the old MSR */
-			rlwinm	r9,r9,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-			rlwinm	r9,r9,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-			rlwinm	r8,r9,0,MSR_EE_BIT+1,MSR_EE_BIT-1	/* Clear interruptions */
- 			mtmsr	r8					/* Interrupts off */
- 			isync
-			mfsprg	r6,0				/* Get the per_proc */
-			lwz		r3,PP_ACTIVE_THREAD(r6)	/* Get the active thread */
-			mfsprg	r4,1
-			lwz	r4,ACT_THREAD(r4)
-			cmplw	cr0,r4,r3
-			beq		current_thread_cont
-			lis		r5,hi16(L_current_thread_paniced)
-			ori		r5,r5,lo16(L_current_thread_paniced)
-			lwz		r6,0(r5)
-			mr.		r6,r6
-			bne		current_thread_cont
-			stw		r9,0(r5)
-			mr		r5,r4
-			mr		r4,r3
-			lis		r3,hi16(L_current_thread_panic)
-			ori		r3,r3,lo16(L_current_thread_panic)
-			bl		EXT(panic)
+			.globl	EXT(get_preemption_level)
 
-			.data
-L_current_thread_panic:
-			STRINGD "current_thread: spr1 not sync %x %x %x\n\000"
-L_current_thread_paniced:
-			.long	0
-			.text
-current_thread_cont:
-#endif
-			mtmsr	r9					/* Restore interruptions to entry */
-			blr							/* Return... */
+LEXT(get_preemption_level)
+ 
+			mfsprg	r6,1							; Get current activation
+			lwz		r3,ACT_PREEMPT_CNT(r6)			; Get the preemption level
+			blr										; Return...
 
 /*
- *			Set the active thread 
+ *		int get_simple_lock_count(void)
+ *
+ *			Return the simple lock count
+ *
  */
 			.align	5
-			.globl	EXT(set_machine_current_thread)
-LEXT(set_machine_current_thread)
-
-			mfmsr	r9					/* Save the old MSR */
-			rlwinm	r9,r9,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-			rlwinm	r9,r9,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-			rlwinm	r8,r9,0,MSR_EE_BIT+1,MSR_EE_BIT-1	/* Clear interruptions */
- 			mtmsr	r8					/* Interrupts off */
-			isync						; May have messed with fp/vec
-			mfsprg	r6,0				/* Get the per_proc */
-			stw		r3,PP_ACTIVE_THREAD(r6)	/* Set the active thread */
-			mtmsr	r9					/* Restore interruptions to entry */
-			blr							/* Return... */
+			.globl	EXT(get_simple_lock_count)
 
-/*
- *			Set the current activation
- */
-			.align	5
-			.globl	EXT(set_machine_current_act)
-LEXT(set_machine_current_act)
-			mtsprg	1,r3				/* Set spr1 with the active thread */
-			blr							/* Return... */
+LEXT(get_simple_lock_count)
+ 
+#if	MACH_LDEBUG
+			lis		r3,hi16(MASK(MSR_VEC))			; Get vector enable
+			mfmsr	r9								; Get the MSR value
+			ori		r3,r3,lo16(MASK(MSR_FP))		; Get FP enable
+			ori		r8,r3,lo16(MASK(MSR_EE))		; Get EE bit on too
+			andc	r9,r9,r3						; Clear FP and VEC
+			andc	r8,r9,r8						; Clear EE as well
+ 			mtmsr	r8								; Interrupts off
+			isync									; May have messed with vec/fp
+			mfsprg	r6,0							; Get the per_proc
+			lwz		r3,PP_SIMPLE_LOCK_CNT(r6)		; Get the simple lock count
+			mtmsr	r9								; Restore interruptions to entry
+#else
+			li		r3,0							; simple lock count not updated
+#endif
+			blr										; Return...
 
 /*
- *			Return the current activation
+ *		void ppc_usimple_lock_init(simple_lock_t, etap_event_t)
+ *
+ *			Initialize a simple lock.
  */
 			.align	5
-			.globl	EXT(current_act)
-LEXT(current_act)
-			mfsprg	r3,1
-			blr
-
+			.globl	EXT(ppc_usimple_lock_init)
 
+LEXT(ppc_usimple_lock_init)
 
+			li	r0,	0								; set lock to free == 0 
+			stw	r0,	0(r3)							; Initialize the lock 
+			blr
+	
 /*
- *			Return the current preemption level
+ *		void ppc_usimple_lock(simple_lock_t)
+ *
  */
- 
 			.align	5
-			.globl	EXT(get_preemption_level)
-
-LEXT(get_preemption_level)
- 
-			mfmsr	r9					/* Save the old MSR */
-			rlwinm	r9,r9,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-			rlwinm	r9,r9,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-			rlwinm	r8,r9,0,MSR_EE_BIT+1,MSR_EE_BIT-1	/* Clear interruptions */
- 			mtmsr	r8					/* Interrupts off */
-			isync			
-			mfsprg	r6,0				/* Get the per_proc */
-			lwz		r3,PP_PREEMPT_CNT(r6)	/* Get the preemption level */
-			mtmsr	r9					/* Restore interruptions to entry */
-			blr							/* Return... */
+			.globl	EXT(ppc_usimple_lock)
 
+LEXT(ppc_usimple_lock)
 
-/*
- *			Return the cpu_data
- */
- 
-			.align	5
-			.globl	EXT(get_cpu_data)
+#if CHECKNMI
+			mflr	r12								; (TEST/DEBUG) 
+			bl		EXT(ml_sense_nmi)				; (TEST/DEBUG)
+			mtlr	r12								; (TEST/DEBUG)
+#endif
 
-LEXT(get_cpu_data)
- 
-			mfsprg	r3,0				/* Get the per_proc */
-			addi	r3,r3,PP_ACTIVE_THREAD		/* Get the pointer to the CPU data from per proc */
-			blr							/* Return... */
+			mfsprg	r6,1							; Get the current activation 
+			lwz		r5,ACT_PREEMPT_CNT(r6)			; Get the preemption level
+			addi	r5,r5,1							; Bring up the disable count
+			stw		r5,ACT_PREEMPT_CNT(r6)			; Save it back 
+			mr		r5,r3							; Get the address of the lock
+			li		r8,0							; Set r8 to zero
+			li		r4,0							; Set r4 to zero
+
+slcktry:	lwarx	r11,0,r5						; Grab the lock value
+			andi.	r3,r11,ILK_LOCKED				; Is it locked?
+			ori		r11,r6,ILK_LOCKED				; Set interlock 
+			bne--	slckspin						; Yeah, wait for it to clear...
+			stwcx.	r11,0,r5						; Try to seize that there durn lock
+			bne--	slcktry							; Couldn't get it...
+			isync									; Make sure we don't use a speculativily loaded value
+			blr										; Go on home...
+
+slckspin:	li		r11,lgKillResv					; Killing field
+			stwcx.	r11,0,r11						; Kill reservation
+
+			mr.		r4,r4							; Test timeout value
+			bne++	slockspin0
+			lis		r4,hi16(EXT(LockTimeOut))		; Get the high part 
+			ori		r4,r4,lo16(EXT(LockTimeOut))	; And the low part
+			lwz		r4,0(r4)						; Get the timerout value
+
+slockspin0:	mr.		r8,r8							; Is r8 set to zero
+			bne++	slockspin1						; If yes, first spin attempt
+			lis		r0,hi16(MASK(MSR_VEC))			; Get vector enable
+			mfmsr	r9								; Get the MSR value
+			ori		r0,r0,lo16(MASK(MSR_FP))		; Get FP enable
+			ori		r7,r0,lo16(MASK(MSR_EE))		; Get EE bit on too
+			andc	r9,r9,r0						; Clear FP and VEC
+			andc	r7,r9,r7						; Clear EE as well
+			mtmsr	r7								; Turn off interruptions 
+			isync									; May have turned off vec and fp here 
+			mftb	r8								; Get timestamp on entry
+			b		slcksniff
+
+slockspin1:	mtmsr	r7								; Turn off interruptions 
+			mftb	r8								; Get timestamp on entry
+
+slcksniff:	lwz		r3,0(r5)						; Get that lock in here
+			andi.	r3,r3,ILK_LOCKED				; Is it free yet?
+			beq++	slckretry						; Yeah, try for it again...
+			
+			mftb	r10								; Time stamp us now
+			sub		r10,r10,r8						; Get the elapsed time
+			cmplwi	r10,128							; Have we been spinning for 128 tb ticks?
+			blt++	slcksniff						; Not yet...
+			
+			mtmsr	r9								; Say, any interrupts pending?
 
+;			The following instructions force the pipeline to be interlocked to that only one
+;			instruction is issued per cycle.  The insures that we stay enabled for a long enough
+;			time; if it's too short, pending interruptions will not have a chance to be taken
 
-/*
- *			Return the simple lock count
- */
- 
-			.align	5
-			.globl	EXT(get_simple_lock_count)
+			subi	r4,r4,128						; Back off elapsed time from timeout value
+			or		r4,r4,r4						; Do nothing here but force a single cycle delay
+			mr.		r4,r4							; See if we used the whole timeout
+			li		r3,0							; Assume a timeout return code
+			or		r4,r4,r4						; Do nothing here but force a single cycle delay
+			
+			ble--	slckfail						; We failed
+			b		slockspin1						; Now that we've opened an enable window, keep trying...
+slckretry:
+			mtmsr	r9								; Restore interrupt state
+			li		r8,1							; Show already through once
+			b		slcktry
+slckfail:											; We couldn't get the lock
+			lis		r3,hi16(slckpanic_str)
+			ori		r3,r3,lo16(slckpanic_str)
+			mr		r4,r5
+			mflr	r5
+			bl		EXT(panic)
 
-LEXT(get_simple_lock_count)
- 
-			mfmsr	r9					/* Save the old MSR */
-			rlwinm	r9,r9,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-			rlwinm	r9,r9,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-			rlwinm	r8,r9,0,MSR_EE_BIT+1,MSR_EE_BIT-1	/* Clear interruptions */
- 			mtmsr	r8					/* Interrupts off */
-			isync						; May have messed with vec/fp
-			mfsprg	r6,0				/* Get the per_proc */
-			lwz		r3,PP_SIMPLE_LOCK_CNT(r6)	/* Get the simple lock count */
-			mtmsr	r9					/* Restore interruptions to entry */
-			blr							/* Return... */
+		.data
+slckpanic_str:
+		STRINGD "ppc_usimple_lock: simple lock deadlock detection l=0x%08X, pc=0x%08X\n\000"
+		.text
 
 /*
- *		fast_usimple_lock():
+ *		unsigned int ppc_usimple_lock_try(simple_lock_t)
  *
- *		If EE is off, get the simple lock without incrementing the preemption count and 
- *		mark The simple lock with SLOCK_FAST.
- *		If EE is on, call usimple_lock().
  */
 			.align	5
-			.globl	EXT(fast_usimple_lock)
+			.globl	EXT(ppc_usimple_lock_try)
 
-LEXT(fast_usimple_lock)
+LEXT(ppc_usimple_lock_try)
 
 #if CHECKNMI
-		b		EXT(usimple_lock)		; (TEST/DEBUG)  
+			mflr	r12								; (TEST/DEBUG) 
+			bl		EXT(ml_sense_nmi)				; (TEST/DEBUG)
+			mtlr	r12								; (TEST/DEBUG)
 #endif                  
-		mfmsr	r9
-		andi.   r7,r9,lo16(MASK(MSR_EE))
-		bne-	L_usimple_lock_c
-L_usimple_lock_loop:
-		lwarx   r4,0,r3
-		li      r5,ILK_LOCKED|SLOCK_FAST
-		mr.     r4,r4
-		bne-    L_usimple_lock_c
-		stwcx.  r5,0,r3
-		bne-    L_usimple_lock_loop
-		isync
-		blr
-L_usimple_lock_c:
-		b		EXT(usimple_lock)
+			lis		r0,hi16(MASK(MSR_VEC))			; Get vector enable
+			mfmsr	r9								; Get the MSR value 
+			ori		r0,r0,lo16(MASK(MSR_FP))		; Get FP enable
+			ori		r7,r0,lo16(MASK(MSR_EE))		; Get EE bit on too
+			andc	r9,r9,r0						; Clear FP and VEC
+			andc	r7,r9,r7						; Clear EE as well
+			mtmsr	r7								; Disable interruptions and thus, preemption
+			mfsprg	r6,1							; Get current activation 
+
+			lwz		r11,0(r3)						; Get the lock
+			andi.	r5,r11,ILK_LOCKED				; Check it...
+			bne--	slcktryfail						; Quickly fail...
+
+slcktryloop:	
+			lwarx	r11,0,r3						; Ld from addr of arg and reserve
+
+			andi.	r5,r11,ILK_LOCKED				; TEST...
+			ori		r5,r6,ILK_LOCKED
+			bne--	slcktryfailX					; branch if taken. Predict free 
+	
+			stwcx.	r5,0,r3							; And SET (if still reserved)
+			bne--	slcktryloop						; If set failed, loop back 
+			
+			isync
+
+			lwz		r5,ACT_PREEMPT_CNT(r6)			; Get the preemption level
+			addi	r5,r5,1							; Bring up the disable count 
+			stw		r5,ACT_PREEMPT_CNT(r6)			; Save it back
+
+ 			mtmsr	r9								; Allow interruptions now 
+			li		r3,1							; Set that the lock was free 
+			blr
+
+slcktryfailX:
+			li		r5,lgKillResv					; Killing field
+			stwcx.	r5,0,r5							; Kill reservation
+
+slcktryfail:
+ 			mtmsr	r9								; Allow interruptions now 
+			li		r3,0							; FAILURE - lock was taken 
+			blr
+
 
 /*
- *		fast_usimple_lock_try():
+ *		void ppc_usimple_unlock_rwcmb(simple_lock_t)
  *
- *		If EE is off, try to get the simple lock. The preemption count doesn't get incremented and
- *		if successfully held, the simple lock is marked with SLOCK_FAST.
- *		If EE is on, call usimple_lock_try()
  */
 			.align	5
-			.globl	EXT(fast_usimple_lock_try)
+			.globl	EXT(ppc_usimple_unlock_rwcmb)
 
-LEXT(fast_usimple_lock_try)
+LEXT(ppc_usimple_unlock_rwcmb)
 
 #if CHECKNMI
-		b		EXT(usimple_lock_try)		; (TEST/DEBUG)  
+			mflr	r12								; (TEST/DEBUG) 
+			bl		EXT(ml_sense_nmi)				; (TEST/DEBUG)
+			mtlr	r12								; (TEST/DEBUG)
 #endif                  
-		mfmsr	r9
-		andi.   r7,r9,lo16(MASK(MSR_EE))
-		bne-	L_usimple_lock_try_c
-L_usimple_lock_try_loop:
-		lwarx   r4,0,r3
-		li      r5,ILK_LOCKED|SLOCK_FAST
-		mr.		r4,r4
-		bne-	L_usimple_lock_try_fail
-		stwcx.  r5,0,r3
-		bne-    L_usimple_lock_try_loop
-		li		r3,1
-		isync
-		blr
-L_usimple_lock_try_fail:
-		li		r3,0
-		blr
-L_usimple_lock_try_c:
-		b		EXT(usimple_lock_try)
+			li		r0,0
+			.globl  EXT(sulckPatch_isync)
+LEXT(sulckPatch_isync)
+			isync
+			.globl  EXT(sulckPatch_eieio)
+LEXT(sulckPatch_eieio)
+			eieio
+			stw		r0, LOCK_DATA(r3)
+
+			b		epStart							; Go enable preemption...
 
 /*
- *		fast_usimple_unlock():
+ *		void ppc_usimple_unlock_rwmb(simple_lock_t)
  *
- *		If the simple lock is marked SLOCK_FAST, release it without decrementing the preemption count.
- *		Call usimple_unlock() otherwise.	
  */
 			.align	5
-			.globl	EXT(fast_usimple_unlock)
+			.globl	EXT(ppc_usimple_unlock_rwmb)
 
-LEXT(fast_usimple_unlock)
+LEXT(ppc_usimple_unlock_rwmb)
 
 #if CHECKNMI
-		b		EXT(usimple_unlock)			; (TEST/DEBUG)  
+			mflr	r12								; (TEST/DEBUG) 
+			bl		EXT(ml_sense_nmi)				; (TEST/DEBUG)
+			mtlr	r12								; (TEST/DEBUG)
 #endif                  
-		lwz		r5,LOCK_DATA(r3)
-		li		r0,0
-		cmpi	cr0,r5,ILK_LOCKED|SLOCK_FAST
-		bne-	L_usimple_unlock_c
-		sync
-#if 0
-		mfmsr	r9
-		andi.	r7,r9,lo16(MASK(MSR_EE))
-		beq		L_usimple_unlock_cont
-		lis		r3,hi16(L_usimple_unlock_panic)
-		ori		r3,r3,lo16(L_usimple_unlock_panic)
-		bl		EXT(panic)
+			li		r0,0
+			sync
+			stw		r0, LOCK_DATA(r3)
 
-		.data
-L_usimple_unlock_panic:
-		STRINGD "fast_usimple_unlock: interrupts not disabled\n\000"
-		.text
-L_usimple_unlock_cont:
-#endif
-		stw		r0, LOCK_DATA(r3)
-		blr
-L_usimple_unlock_c:
-		b		EXT(usimple_unlock)
+			b		epStart							; Go enable preemption...
 
 /*
- *		enter_funnel_section():
+ *		void enter_funnel_section(funnel_t *)
  *
  */
 			.align	5
@@ -1822,46 +1672,45 @@ L_usimple_unlock_c:
 LEXT(enter_funnel_section)
 
 #if	!MACH_LDEBUG
-		lis		r10,hi16(EXT(kdebug_enable))
-		ori		r10,r10,lo16(EXT(kdebug_enable))
-		lwz		r10,0(r10)
-		lis		r11,hi16(EXT(split_funnel_off))
-		ori		r11,r11,lo16(EXT(split_funnel_off))
-		lwz		r11,0(r11)
-		or.		r10,r11,r10							; Check kdebug_enable or split_funnel_off
-		bne-	L_enter_funnel_section_slow1		; If set, call the slow path
-		mfsprg	r6,1								; Get the current activation
-		lwz		r7,LOCK_FNL_MUTEX(r3)
-		mfmsr	r11
-		rlwinm	r11,r11,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-		rlwinm	r11,r11,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-		rlwinm  r10,r11,0,MSR_EE_BIT+1,MSR_EE_BIT-1
-		mtmsr	r10									; Turn off EE
-		isync										; May have messed with vec/fp
-		mr		r9,r6
+			lis		r10,hi16(EXT(kdebug_enable))
+			ori		r10,r10,lo16(EXT(kdebug_enable))
+			lwz		r10,0(r10)
+			lis		r11,hi16(EXT(split_funnel_off))
+			ori		r11,r11,lo16(EXT(split_funnel_off))
+			lwz		r11,0(r11)
+			or.		r10,r11,r10						; Check kdebug_enable or split_funnel_off
+			bne-	L_enter_funnel_section_slow		; If set, call the slow path
+			mfsprg	r6,1							; Get the current activation
+			lwz		r7,LOCK_FNL_MUTEX(r3)
+
+			lwz		r5,0(r7)						; Get lock quickly
+			mr.		r5,r5							; Locked?
+			bne--	L_enter_funnel_section_slow		; Yup...
+
 L_enter_funnel_section_loop:
-		lwarx	r5,0,r7								; Load the mutex lock
-		mr.		r5,r5
-		bne-	L_enter_funnel_section_slow			; Go to the slow path
-		stwcx.	r6,0,r7								; Grab the lock
-		bne-	L_enter_funnel_section_loop			; Loop back if failed
-		isync										; Stop prefeteching
-		lwz		r6,ACT_THREAD(r6)					; Get the current thread
-		li		r7,TH_FN_OWNED
-		stw		r7,THREAD_FUNNEL_STATE(r6)			; Set the funnel state
-		stw		r3,THREAD_FUNNEL_LOCK(r6)			; Set the funnel lock reference
-		mtmsr	r11
-		blr
+			lwarx	r5,0,r7							; Load the mutex lock
+			mr.		r5,r5
+			bne--	L_enter_funnel_section_slowX	; Go to the slow path
+			stwcx.	r6,0,r7							; Grab the lock
+			bne--	L_enter_funnel_section_loop		; Loop back if failed
+			isync									; Stop prefeteching
+			lwz		r6,ACT_THREAD(r6)				; Get the current thread
+			li		r7,TH_FN_OWNED
+			stw		r3,THREAD_FUNNEL_LOCK(r6)		; Set the funnel lock reference
+			stw		r7,THREAD_FUNNEL_STATE(r6)		; Set the funnel state
+			blr
+
+L_enter_funnel_section_slowX:
+			li		r4,lgKillResv					; Killing field
+			stwcx.	r4,0,r4							; Kill reservation
 
 L_enter_funnel_section_slow:
-		mtmsr	r11
-L_enter_funnel_section_slow1:
 #endif
-		li		r4,TRUE
-		b		EXT(thread_funnel_set)
+			li		r4,TRUE
+			b		EXT(thread_funnel_set)
 
 /*
- *		exit_funnel_section():
+ *		void exit_funnel_section(void)
  *
  */
 			.align	5
@@ -1869,42 +1718,61 @@ L_enter_funnel_section_slow1:
 
 LEXT(exit_funnel_section)
 
+			mfsprg	r6,1							; Get the current activation
+			lwz		r6,ACT_THREAD(r6)				; Get the current thread
+			lwz		r3,THREAD_FUNNEL_LOCK(r6)		; Get the funnel lock
+			mr.		r3,r3							; Check on funnel held
+			beq-	L_exit_funnel_section_ret		; 
 #if	!MACH_LDEBUG
-		mfsprg	r6,1								; Get the current activation
-		lwz		r6,ACT_THREAD(r6)					; Get the current thread
-		lwz		r3,THREAD_FUNNEL_LOCK(r6)			; Get the funnel lock
-		mr.		r3,r3								; Check on funnel held
-		beq-	L_exit_funnel_section_ret			; 
-		lis		r10,hi16(EXT(kdebug_enable))
-		ori		r10,r10,lo16(EXT(kdebug_enable))
-		lwz		r10,0(r10)
-		mr.		r10,r10
-		bne-	L_exit_funnel_section_slow1			; If set, call the slow path
-		lwz		r7,LOCK_FNL_MUTEX(r3)				; Get the funnel mutex lock
-		mfmsr	r11
-		rlwinm	r11,r11,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-		rlwinm	r11,r11,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-		rlwinm  r10,r11,0,MSR_EE_BIT+1,MSR_EE_BIT-1
-		mtmsr	r10									; Turn off EE
-		isync										; May have messed with fp/vec
-		sync
+			lis		r10,hi16(EXT(kdebug_enable))
+			ori		r10,r10,lo16(EXT(kdebug_enable))
+			lwz		r10,0(r10)
+			mr.		r10,r10
+			bne-	L_exit_funnel_section_slow		; If set, call the slow path
+			lwz		r7,LOCK_FNL_MUTEX(r3)			; Get the funnel mutex lock
+			.globl	EXT(retfsectPatch_isync)     
+LEXT(retfsectPatch_isync)
+			isync
+			.globl	EXT(retfsectPatch_eieio)     
+LEXT(retfsectPatch_eieio)
+			eieio
+
+			lwz		r5,0(r7)						; Get lock
+			rlwinm.	r4,r5,0,30,31					; Quick check for bail if pending waiter or interlock set 
+			bne--	L_exit_funnel_section_slow		; No can get...
+
 L_exit_funnel_section_loop:
-		lwarx	r5,0,r7
-		rlwinm.	r4,r5,0,30,31						; Bail if pending waiter or interlock set 
-		li		r5,0								; Clear the mutexlock 
-		bne-	L_exit_funnel_section_slow
-		stwcx.	r5,0,r7								; Release the funnel mutexlock
-		bne-	L_exit_funnel_section_loop
-		li		r7,0
-		stw		r7,THREAD_FUNNEL_STATE(r6)			; Clear the funnel state
-		stw		r7,THREAD_FUNNEL_LOCK(r6)			; Clear the funnel lock reference
-		mtmsr	r11
-L_exit_funnel_section_ret:
-		blr
+			lwarx	r5,0,r7
+			rlwinm.	r4,r5,0,30,31					; Bail if pending waiter or interlock set 
+			li		r5,0							; Clear the mutexlock 
+			bne--	L_exit_funnel_section_slowX
+			stwcx.	r5,0,r7							; Release the funnel mutexlock
+			bne--	L_exit_funnel_section_loop
+			li		r7,0
+			stw		r7,THREAD_FUNNEL_STATE(r6)		; Clear the funnel state
+			stw		r7,THREAD_FUNNEL_LOCK(r6)		; Clear the funnel lock reference
+			blr										; Return
+
+L_exit_funnel_section_slowX:
+			li		r4,lgKillResv					; Killing field
+			stwcx.	r4,0,r4							; Kill it
+
 L_exit_funnel_section_slow:
-		mtmsr	r11
-L_exit_funnel_section_slow1:
 #endif
-		li		r4,FALSE
-		b		EXT(thread_funnel_set)
+			li		r4,FALSE
+			b		EXT(thread_funnel_set)
+L_exit_funnel_section_ret:
+			blr
+
+;
+;                     This is bring up code
+;
+			.align  5
+			.globl  EXT(condStop)
+
+LEXT(condStop)
+
+XcondStop:	cmplw	r3,r4							; Check if these are equal
+			beq--	XcondStop						; Stop here until they are different
+			blr										; Return.
 
diff --git a/osfmk/ppc/hw_lock_types.h b/osfmk/ppc/hw_lock_types.h
index 54ffa016c..b51f04a95 100644
--- a/osfmk/ppc/hw_lock_types.h
+++ b/osfmk/ppc/hw_lock_types.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ppc/hw_perfmon.c b/osfmk/ppc/hw_perfmon.c
new file mode 100644
index 000000000..e2f424969
--- /dev/null
+++ b/osfmk/ppc/hw_perfmon.c
@@ -0,0 +1,945 @@
+/*
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ * 
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ * 
+ * @APPLE_LICENSE_HEADER_END@
+ */
+
+#include <kern/thread.h>
+#include <kern/thread_act.h>
+#include <ppc/exception.h>
+#include <ppc/savearea.h>
+#include <ppc/hw_perfmon.h>
+#include <ppc/hw_perfmon_mmcr.h>
+
+decl_simple_lock_data(,hw_perfmon_lock)
+static task_t hw_perfmon_owner = TASK_NULL;
+static int hw_perfmon_thread_count = 0;
+
+/* Notes:
+ * -supervisor/user level filtering is unnecessary because of the way PMCs and MMCRs are context switched
+ *  (can only count user events anyway)
+ * -marked filtering is unnecssary because each thread has its own virtualized set of PMCs and MMCRs
+ * -virtual counter PMI is passed up as a breakpoint exception
+ */
+
+int perfmon_init(void)
+{
+	simple_lock_init(&hw_perfmon_lock, FALSE);
+	return KERN_SUCCESS;
+}
+
+/* PMC Facility Owner:
+ * TASK_NULL - no one owns it
+ * kernel_task - owned by hw_perfmon
+ * other task - owned by another task
+ */
+
+int perfmon_acquire_facility(task_t task)
+{
+	kern_return_t retval = KERN_SUCCESS;
+  
+	simple_lock(&hw_perfmon_lock);
+  
+	if(hw_perfmon_owner==task) {
+#ifdef HWPERFMON_DEBUG
+		kprintf("perfmon_acquire_facility - ACQUIRED: already owner\n");
+#endif
+		retval = KERN_SUCCESS;
+		/* already own it */
+	} else if(hw_perfmon_owner==TASK_NULL) { /* no one owns it */
+		hw_perfmon_owner = task;
+		hw_perfmon_thread_count = 0;
+#ifdef HWPERFMON_DEBUG
+		kprintf("perfmon_acquire_facility - ACQUIRED: no current owner - made new owner\n");
+#endif
+		retval = KERN_SUCCESS;
+	} else { /* someone already owns it */
+		if(hw_perfmon_owner==kernel_task) {
+			if(hw_perfmon_thread_count==0) { /* kernel owns it but no threads using it */
+				hw_perfmon_owner = task;
+				hw_perfmon_thread_count = 0;
+#ifdef HWPERFMON_DEBUG
+				kprintf("perfmon_acquire_facility - ACQUIRED: kernel is current owner but no threads using it\n");
+#endif
+				retval = KERN_SUCCESS;
+			} else {
+#ifdef HWPERFMON_DEBUG
+				kprintf("perfmon_acquire_facility - DENIED: kernel is current owner and facility in use\n");
+#endif
+				retval = KERN_RESOURCE_SHORTAGE;
+			}
+		} else { /* non-kernel owner */
+#ifdef HWPERFMON_DEBUG
+			kprintf("perfmon_acquire_facility - DENIED: another active task owns the facility\n");
+#endif
+			retval = KERN_RESOURCE_SHORTAGE;
+		}
+	}
+  
+	simple_unlock(&hw_perfmon_lock);
+	return retval;
+}
+
+int perfmon_release_facility(task_t task)
+{
+	kern_return_t retval = KERN_SUCCESS;
+	task_t old_perfmon_owner = hw_perfmon_owner;
+  
+	simple_lock(&hw_perfmon_lock);
+  
+	if(task!=hw_perfmon_owner) {
+		retval = KERN_NO_ACCESS;
+	} else {
+		if(old_perfmon_owner==kernel_task) {
+			if(hw_perfmon_thread_count>0) {
+#ifdef HWPERFMON_DEBUG
+				kprintf("perfmon_release_facility - NOT RELEASED: kernel task is owner and has active perfmon threads\n");
+#endif
+				retval = KERN_NO_ACCESS;
+			} else {
+#ifdef HWPERFMON_DEBUG
+				kprintf("perfmon_release_facility - RELEASED: kernel task was owner\n");
+#endif
+				hw_perfmon_owner = TASK_NULL;
+				retval = KERN_SUCCESS;
+			}
+		} else {
+#ifdef HWPERFMON_DEBUG
+			kprintf("perfmon_release_facility - RELEASED: user task was owner\n");
+#endif
+			hw_perfmon_owner = TASK_NULL;
+			retval = KERN_SUCCESS;
+		}
+	}
+
+	simple_unlock(&hw_perfmon_lock);
+	return retval;
+}
+
+int perfmon_enable(thread_act_t thr_act)
+{
+	struct savearea *sv = thr_act->mact.pcb;
+	kern_return_t kr;
+	kern_return_t retval = KERN_SUCCESS;
+	int curPMC;
+  
+	if(thr_act->mact.specFlags & perfMonitor) {
+		return KERN_SUCCESS; /* already enabled */
+	} else if(perfmon_acquire_facility(kernel_task)!=KERN_SUCCESS) {
+		return KERN_RESOURCE_SHORTAGE; /* facility is in use */
+	} else { /* kernel_task owns the faciltity and this thread has not yet been counted */
+		simple_lock(&hw_perfmon_lock);
+		hw_perfmon_thread_count++;
+		simple_unlock(&hw_perfmon_lock);
+	}
+
+	sv->save_mmcr1 = 0;
+	sv->save_mmcr2 = 0;
+	
+	switch(machine_slot[0].cpu_subtype) {
+		case CPU_SUBTYPE_POWERPC_750:
+		case CPU_SUBTYPE_POWERPC_7400:
+		case CPU_SUBTYPE_POWERPC_7450:
+			{
+				ppc32_mmcr0_reg_t mmcr0_reg;
+		
+				mmcr0_reg.value = 0;
+				mmcr0_reg.field.disable_counters_always = TRUE;
+				mmcr0_reg.field.disable_counters_supervisor = TRUE; /* no choice */
+				sv->save_mmcr0 = mmcr0_reg.value;
+			}
+			break;
+		case CPU_SUBTYPE_POWERPC_970:
+			{
+				ppc64_mmcr0_reg_t mmcr0_reg;
+		
+				mmcr0_reg.value = 0;
+				mmcr0_reg.field.disable_counters_always = TRUE;
+				mmcr0_reg.field.disable_counters_supervisor = TRUE; /* no choice */
+				sv->save_mmcr0 = mmcr0_reg.value;
+			}
+			break;
+		default:
+			retval = KERN_FAILURE;
+			break;
+	}
+  
+	if(retval==KERN_SUCCESS) {
+		for(curPMC=0; curPMC<MAX_CPUPMC_COUNT; curPMC++) {
+			sv->save_pmc[curPMC] = 0;
+			thr_act->mact.pmcovfl[curPMC] = 0;
+		}
+		thr_act->mact.perfmonFlags = 0;
+		thr_act->mact.specFlags |= perfMonitor; /* enable perf monitor facility for this thread */
+		if(thr_act==current_act()) {
+			per_proc_info[cpu_number()].spcFlags |= perfMonitor; /* update per_proc */
+		}
+	}
+
+#ifdef HWPERFMON_DEBUG  
+	kprintf("perfmon_enable - mmcr0=0x%llx mmcr1=0x%llx mmcr2=0x%llx\n", sv->save_mmcr0, sv->save_mmcr1, sv->save_mmcr2);
+#endif  
+
+	return retval;
+}
+
+int perfmon_disable(thread_act_t thr_act)
+{
+	struct savearea *sv = thr_act->mact.pcb;
+	int curPMC;
+  
+	if(!(thr_act->mact.specFlags & perfMonitor)) {
+		return KERN_NO_ACCESS; /* not enabled */
+	} else {
+		simple_lock(&hw_perfmon_lock);
+		hw_perfmon_thread_count--;
+		simple_unlock(&hw_perfmon_lock);
+		perfmon_release_facility(kernel_task); /* will release if hw_perfmon_thread_count is 0 */
+	}
+  
+	thr_act->mact.specFlags &= ~perfMonitor; /* disable perf monitor facility for this thread */
+	if(thr_act==current_act()) {
+		per_proc_info[cpu_number()].spcFlags &= ~perfMonitor; /* update per_proc */
+	}
+	sv->save_mmcr0 = 0;
+	sv->save_mmcr1 = 0;
+	sv->save_mmcr2 = 0;
+  
+	for(curPMC=0; curPMC<MAX_CPUPMC_COUNT; curPMC++) {
+		sv->save_pmc[curPMC] = 0;
+		thr_act->mact.pmcovfl[curPMC] = 0;
+		thr_act->mact.perfmonFlags = 0;
+	}
+  
+#ifdef HWPERFMON_DEBUG
+	kprintf("perfmon_disable - mmcr0=0x%llx mmcr1=0x%llx mmcr2=0x%llx\n", sv->save_mmcr0, sv->save_mmcr1, sv->save_mmcr2);
+#endif  
+
+	return KERN_SUCCESS;
+}
+
+int perfmon_clear_counters(thread_act_t thr_act)
+{
+	struct savearea *sv = thr_act->mact.pcb;
+	int curPMC;
+
+#ifdef HWPERFMON_DEBUG
+	kprintf("perfmon_clear_counters (CPU%d)\n", cpu_number());
+#endif  
+
+	/* clear thread copy */
+	for(curPMC=0; curPMC<MAX_CPUPMC_COUNT; curPMC++) {
+		sv->save_pmc[curPMC] = 0;
+		thr_act->mact.pmcovfl[curPMC] = 0;
+	}
+  
+	return KERN_SUCCESS;
+}
+
+int perfmon_write_counters(thread_act_t thr_act, uint64_t *pmcs)
+{
+	struct savearea *sv = thr_act->mact.pcb;
+	int curPMC;
+  
+#ifdef HWPERFMON_DEBUG
+	kprintf("perfmon_write_counters (CPU%d): mmcr0 = %016llX, pmc1=%llX pmc2=%llX pmc3=%llX pmc4=%llX pmc5=%llX pmc6=%llX pmc7=%llX pmc8=%llX\n", cpu_number(), sv->save_mmcr0, pmcs[PMC_1], pmcs[PMC_2], pmcs[PMC_3], pmcs[PMC_4], pmcs[PMC_5], pmcs[PMC_6], pmcs[PMC_7], pmcs[PMC_8]);
+#endif  
+
+	/* update thread copy */
+	for(curPMC=0; curPMC<MAX_CPUPMC_COUNT; curPMC++) {
+		sv->save_pmc[curPMC] = pmcs[curPMC] & 0x7FFFFFFF;
+		thr_act->mact.pmcovfl[curPMC] = (pmcs[curPMC]>>31) & 0xFFFFFFFF;
+	}
+  
+	return KERN_SUCCESS;
+}
+
+int perfmon_read_counters(thread_act_t thr_act, uint64_t *pmcs)
+{
+	struct savearea *sv = thr_act->mact.pcb;
+	int curPMC;
+  
+	/* retrieve from thread copy */
+	for(curPMC=0; curPMC<MAX_CPUPMC_COUNT; curPMC++) {
+		pmcs[curPMC] = thr_act->mact.pmcovfl[curPMC]; 
+		pmcs[curPMC] = pmcs[curPMC]<<31;
+		pmcs[curPMC] |= (sv->save_pmc[curPMC] & 0x7FFFFFFF);
+	}
+
+	/* zero any unused counters on this platform */
+	switch(machine_slot[0].cpu_subtype) {
+		case CPU_SUBTYPE_POWERPC_750:
+		case CPU_SUBTYPE_POWERPC_7400:
+		case CPU_SUBTYPE_POWERPC_7450:
+			pmcs[PMC_7] = 0;
+			pmcs[PMC_8] = 0;
+			break;
+		default:
+			break;
+	}
+
+#ifdef HWPERFMON_DEBUG
+	kprintf("perfmon_read_counters (CPU%d): mmcr0 = %016llX pmc1=%llX pmc2=%llX pmc3=%llX pmc4=%llX pmc5=%llX pmc6=%llX pmc7=%llX pmc8=%llX\n", cpu_number(), sv->save_mmcr0, pmcs[PMC_1], pmcs[PMC_2], pmcs[PMC_3], pmcs[PMC_4], pmcs[PMC_5], pmcs[PMC_6], pmcs[PMC_7], pmcs[PMC_8]);
+#endif  
+
+	return KERN_SUCCESS;
+}
+
+int perfmon_start_counters(thread_act_t thr_act)
+{
+	struct savearea *sv = thr_act->mact.pcb;
+	kern_return_t retval = KERN_SUCCESS;
+
+	switch(machine_slot[0].cpu_subtype) {
+		case CPU_SUBTYPE_POWERPC_750:
+		case CPU_SUBTYPE_POWERPC_7400:
+			{
+				ppc32_mmcr0_reg_t mmcr0_reg;
+				mmcr0_reg.value = sv->save_mmcr0;
+				mmcr0_reg.field.disable_counters_always = FALSE;
+				/* XXXXX PMI broken on 750, 750CX, 750FX, 7400 and 7410 v1.2 and earlier XXXXX */
+				mmcr0_reg.field.on_pmi_stop_counting = FALSE;
+				mmcr0_reg.field.enable_pmi = FALSE; 
+				mmcr0_reg.field.enable_pmi_on_pmc1 = FALSE;
+				mmcr0_reg.field.enable_pmi_on_pmcn = FALSE;
+				sv->save_mmcr0 = mmcr0_reg.value;
+			}
+			break;
+		case CPU_SUBTYPE_POWERPC_7450:
+			{
+				ppc32_mmcr0_reg_t mmcr0_reg;
+				mmcr0_reg.value = sv->save_mmcr0;
+				mmcr0_reg.field.disable_counters_always = FALSE;
+				mmcr0_reg.field.on_pmi_stop_counting = TRUE;
+				mmcr0_reg.field.enable_pmi = TRUE;
+				mmcr0_reg.field.enable_pmi_on_pmc1 = TRUE;
+				mmcr0_reg.field.enable_pmi_on_pmcn = TRUE;
+				sv->save_mmcr0 = mmcr0_reg.value;
+			}
+			break;
+		case CPU_SUBTYPE_POWERPC_970:
+			{
+				ppc64_mmcr0_reg_t mmcr0_reg;
+				mmcr0_reg.value = sv->save_mmcr0;
+				mmcr0_reg.field.disable_counters_always = FALSE;
+				mmcr0_reg.field.on_pmi_stop_counting = TRUE;
+				mmcr0_reg.field.enable_pmi = TRUE;
+				mmcr0_reg.field.enable_pmi_on_pmc1 = TRUE;
+				mmcr0_reg.field.enable_pmi_on_pmcn = TRUE;
+				sv->save_mmcr0 = mmcr0_reg.value;
+			}
+			break;
+		default:
+			retval = KERN_FAILURE;
+			break;
+	}
+
+#ifdef HWPERFMON_DEBUG
+	kprintf("perfmon_start_counters (CPU%d) - mmcr0=0x%llx mmcr1=0x%llx mmcr2=0x%llx\n", cpu_number(), sv->save_mmcr0, sv->save_mmcr1, sv->save_mmcr2);
+#endif
+
+	return retval;
+}
+
+int perfmon_stop_counters(thread_act_t thr_act)
+{
+	struct savearea *sv = thr_act->mact.pcb;
+	kern_return_t retval = KERN_SUCCESS;
+
+	switch(machine_slot[0].cpu_subtype) {
+		case CPU_SUBTYPE_POWERPC_750:
+		case CPU_SUBTYPE_POWERPC_7400:
+		case CPU_SUBTYPE_POWERPC_7450:
+			{
+				ppc32_mmcr0_reg_t mmcr0_reg;
+				mmcr0_reg.value = sv->save_mmcr0;
+				mmcr0_reg.field.disable_counters_always = TRUE;
+				sv->save_mmcr0 = mmcr0_reg.value;
+			}
+			break;
+		case CPU_SUBTYPE_POWERPC_970:
+			{
+				ppc64_mmcr0_reg_t mmcr0_reg;
+				mmcr0_reg.value = sv->save_mmcr0;
+				mmcr0_reg.field.disable_counters_always = TRUE;
+				sv->save_mmcr0 = mmcr0_reg.value;
+			}
+			break;
+		default:
+			retval = KERN_FAILURE;
+			break;
+	}
+
+#ifdef HWPERFMON_DEBUG
+	kprintf("perfmon_stop_counters (CPU%d) - mmcr0=0x%llx mmcr1=0x%llx mmcr2=0x%llx\n", cpu_number(), sv->save_mmcr0, sv->save_mmcr1, sv->save_mmcr2);
+#endif
+
+	return retval;
+}
+
+int perfmon_set_event(thread_act_t thr_act, int pmc, int event)
+{
+	struct savearea *sv = thr_act->mact.pcb;
+	kern_return_t retval = KERN_SUCCESS;
+
+#ifdef HWPERFMON_DEBUG
+	kprintf("perfmon_set_event b4 (CPU%d) - pmc=%d, event=%d - mmcr0=0x%llx mmcr1=0x%llx mmcr2=0x%llx\n", cpu_number(), pmc, event, sv->save_mmcr0, sv->save_mmcr1, sv->save_mmcr2);
+#endif
+ 
+	switch(machine_slot[0].cpu_subtype) {
+		case CPU_SUBTYPE_POWERPC_750:
+		case CPU_SUBTYPE_POWERPC_7400:
+			{
+				ppc32_mmcr0_reg_t mmcr0_reg;
+				ppc32_mmcr1_reg_t mmcr1_reg;
+		
+				mmcr0_reg.value = sv->save_mmcr0;
+				mmcr1_reg.value = sv->save_mmcr1;
+		
+				switch(pmc) {
+					case PMC_1:
+						mmcr0_reg.field.pmc1_event = event;
+						sv->save_mmcr0 = mmcr0_reg.value;
+						break;
+					case PMC_2:
+						mmcr0_reg.field.pmc2_event = event;
+						sv->save_mmcr0 = mmcr0_reg.value;
+						break;
+					case PMC_3:
+						mmcr1_reg.field.pmc3_event = event;
+						sv->save_mmcr1 = mmcr1_reg.value;
+						break;
+					case PMC_4:
+						mmcr1_reg.field.pmc4_event = event;
+						sv->save_mmcr1 = mmcr1_reg.value;
+						break;
+					default:
+						retval = KERN_FAILURE;
+						break;
+				}
+			}
+			break;
+		case CPU_SUBTYPE_POWERPC_7450:
+			{
+				ppc32_mmcr0_reg_t mmcr0_reg;
+				ppc32_mmcr1_reg_t mmcr1_reg;
+
+				mmcr0_reg.value = sv->save_mmcr0;
+				mmcr1_reg.value = sv->save_mmcr1;
+ 
+				switch(pmc) {
+					case PMC_1:
+						mmcr0_reg.field.pmc1_event = event;
+						sv->save_mmcr0 = mmcr0_reg.value;
+						break;
+					case PMC_2:
+						mmcr0_reg.field.pmc2_event = event;
+						sv->save_mmcr0 = mmcr0_reg.value;
+						break;
+					case PMC_3:
+						mmcr1_reg.field.pmc3_event = event;
+						sv->save_mmcr1 = mmcr1_reg.value;
+						break;
+					case PMC_4:
+						mmcr1_reg.field.pmc4_event = event;
+						sv->save_mmcr1 = mmcr1_reg.value;
+						break;
+					case PMC_5:
+						mmcr1_reg.field.pmc5_event = event;
+						sv->save_mmcr1 = mmcr1_reg.value;
+						break;
+					case PMC_6:
+						mmcr1_reg.field.pmc6_event = event;
+						sv->save_mmcr1 = mmcr1_reg.value;
+						break;
+					default:
+						retval = KERN_FAILURE;
+						break;
+				}
+			}
+			break;
+		case CPU_SUBTYPE_POWERPC_970:
+			{
+				ppc64_mmcr0_reg_t mmcr0_reg;
+				ppc64_mmcr1_reg_t mmcr1_reg;
+	  
+				mmcr0_reg.value = sv->save_mmcr0;
+				mmcr1_reg.value = sv->save_mmcr1;
+	  
+				switch(pmc) {
+					case PMC_1:
+						mmcr0_reg.field.pmc1_event = event;
+						sv->save_mmcr0 = mmcr0_reg.value;
+						break;
+					case PMC_2:
+						mmcr0_reg.field.pmc2_event = event;
+						sv->save_mmcr0 = mmcr0_reg.value;
+						break;
+					case PMC_3:
+						mmcr1_reg.field.pmc3_event = event;
+						sv->save_mmcr1 = mmcr1_reg.value;
+						break;
+					case PMC_4:
+						mmcr1_reg.field.pmc4_event = event;
+						sv->save_mmcr1 = mmcr1_reg.value;
+						break;
+					case PMC_5:
+						mmcr1_reg.field.pmc5_event = event;
+						sv->save_mmcr1 = mmcr1_reg.value;
+						break;
+					case PMC_6:
+						mmcr1_reg.field.pmc6_event = event;
+						sv->save_mmcr1 = mmcr1_reg.value;
+						break;
+					case PMC_7:
+						mmcr1_reg.field.pmc7_event = event;
+						sv->save_mmcr1 = mmcr1_reg.value;
+						break;
+					case PMC_8:
+						mmcr1_reg.field.pmc8_event = event;
+						sv->save_mmcr1 = mmcr1_reg.value;
+						break;
+					default:
+						retval = KERN_FAILURE;
+						break;
+				}
+			}
+			break;
+		default:
+			retval = KERN_FAILURE;
+			break;
+	}
+
+#ifdef HWPERFMON_DEBUG
+	kprintf("perfmon_set_event (CPU%d) - pmc=%d, event=%d - mmcr0=0x%llx mmcr1=0x%llx mmcr2=0x%llx\n", cpu_number(), pmc, event, sv->save_mmcr0, sv->save_mmcr1, sv->save_mmcr2);
+#endif
+
+	return retval;
+}
+
+int perfmon_set_event_func(thread_act_t thr_act, uint32_t f)
+{
+	struct savearea *sv = thr_act->mact.pcb;
+	kern_return_t retval = KERN_SUCCESS;
+
+#ifdef HWPERFMON_DEBUG
+	kprintf("perfmon_set_event_func - func=%s\n", 
+		   f==PPC_PERFMON_FUNC_FPU ? "FUNC" :
+		   f==PPC_PERFMON_FUNC_ISU ? "ISU" :
+		   f==PPC_PERFMON_FUNC_IFU ? "IFU" :
+		   f==PPC_PERFMON_FUNC_VMX ? "VMX" :
+		   f==PPC_PERFMON_FUNC_IDU ? "IDU" :
+		   f==PPC_PERFMON_FUNC_GPS ? "GPS" :
+		   f==PPC_PERFMON_FUNC_LSU0 ? "LSU0" :
+		   f==PPC_PERFMON_FUNC_LSU1A ? "LSU1A" :
+		   f==PPC_PERFMON_FUNC_LSU1B ? "LSU1B" :
+		   f==PPC_PERFMON_FUNC_SPECA ? "SPECA" :
+		   f==PPC_PERFMON_FUNC_SPECB ? "SPECB" :
+		   f==PPC_PERFMON_FUNC_SPECC ? "SPECC" :
+		   "UNKNOWN");
+#endif /* HWPERFMON_DEBUG */
+
+	switch(machine_slot[0].cpu_subtype) {
+		case CPU_SUBTYPE_POWERPC_750:
+		case CPU_SUBTYPE_POWERPC_7400:
+		case CPU_SUBTYPE_POWERPC_7450:
+			retval = KERN_FAILURE; /* event functional unit only applies to 970 */
+			break;
+		case CPU_SUBTYPE_POWERPC_970:
+			{
+				ppc64_mmcr1_reg_t mmcr1_reg;
+				ppc_func_unit_t func_unit;
+
+				func_unit.value = f;
+				mmcr1_reg.value = sv->save_mmcr1;
+
+				mmcr1_reg.field.ttm0_select = func_unit.field.TTM0SEL;
+				mmcr1_reg.field.ttm1_select = func_unit.field.TTM1SEL;
+				mmcr1_reg.field.ttm2_select = 0; /* not used */
+				mmcr1_reg.field.ttm3_select = func_unit.field.TTM3SEL;
+				mmcr1_reg.field.speculative_event = func_unit.field.SPECSEL;
+				mmcr1_reg.field.lane0_select = func_unit.field.TD_CP_DBGxSEL;
+				mmcr1_reg.field.lane1_select = func_unit.field.TD_CP_DBGxSEL;
+				mmcr1_reg.field.lane2_select = func_unit.field.TD_CP_DBGxSEL;
+				mmcr1_reg.field.lane3_select = func_unit.field.TD_CP_DBGxSEL;
+
+				sv->save_mmcr1 = mmcr1_reg.value;
+			}
+			break;
+		default:
+			retval = KERN_FAILURE;
+			break;
+	}
+
+	return retval;
+}
+
+int perfmon_set_threshold(thread_act_t thr_act, int threshold)
+{
+	struct savearea *sv = thr_act->mact.pcb;
+	kern_return_t retval = KERN_SUCCESS;
+
+	switch(machine_slot[0].cpu_subtype) {
+		case CPU_SUBTYPE_POWERPC_750:
+			{
+				ppc32_mmcr0_reg_t mmcr0_reg;
+
+				mmcr0_reg.value = sv->save_mmcr0;
+
+				if(threshold>63) { /* no multiplier on 750 */
+					int newThreshold = 63;
+#ifdef HWPERFMON_DEBUG
+					kprintf("perfmon_set_threshold - WARNING: supplied threshold (%d) exceeds max threshold value - clamping to %d\n", threshold, newThreshold);
+#endif
+					threshold = newThreshold;
+				}
+				mmcr0_reg.field.threshold_value = threshold;
+
+				sv->save_mmcr0 = mmcr0_reg.value;
+			}
+			break;
+
+		case CPU_SUBTYPE_POWERPC_7400:
+		case CPU_SUBTYPE_POWERPC_7450:
+			{
+				ppc32_mmcr0_reg_t mmcr0_reg;
+				ppc32_mmcr2_reg_t mmcr2_reg;
+
+				mmcr0_reg.value = sv->save_mmcr0;
+				mmcr2_reg.value = sv->save_mmcr2;
+
+				if(threshold<=(2*63)) { /* 2x multiplier */
+					if(threshold%2 != 0) {
+						int newThreshold = 2*(threshold/2);
+#ifdef HWPERFMON_DEBUG
+						kprintf("perfmon_set_threshold - WARNING: supplied threshold (%d) is not evenly divisible by 2x multiplier - using threshold of %d instead\n", threshold, newThreshold);
+#endif
+						threshold = newThreshold;
+					}
+					mmcr2_reg.field.threshold_multiplier = 0;
+				} else if(threshold<=(32*63)) { /* 32x multiplier */
+					if(threshold%32 != 0) {
+						int newThreshold = 32*(threshold/32);
+#ifdef HWPERFMON_DEBUG
+						kprintf("perfmon_set_threshold - WARNING: supplied threshold (%d) is not evenly divisible by 32x multiplier - using threshold of %d instead\n", threshold, newThreshold);
+#endif
+						threshold = newThreshold;
+					}
+					mmcr2_reg.field.threshold_multiplier = 1;
+				} else {
+					int newThreshold = 32*63;
+#ifdef HWPERFMON_DEBUG
+					kprintf("perfmon_set_threshold - WARNING: supplied threshold (%d) exceeds max threshold value - clamping to %d\n", threshold, newThreshold);
+#endif
+					threshold = newThreshold;
+					mmcr2_reg.field.threshold_multiplier = 1;
+				}
+				mmcr0_reg.field.threshold_value = threshold;
+
+				sv->save_mmcr0 = mmcr0_reg.value;
+				sv->save_mmcr2 = mmcr2_reg.value;
+
+			}
+			break;
+		case CPU_SUBTYPE_POWERPC_970:
+			{
+				ppc64_mmcr0_reg_t mmcr0_reg;
+
+				mmcr0_reg.value = sv->save_mmcr0;
+
+				if(threshold>63) { /* multiplier is in HID1 on 970 - not context switching HID1 so always 1x */
+					int newThreshold = 63;
+#ifdef HWPERFMON_DEBUG
+					kprintf("perfmon_set_threshold - WARNING: supplied threshold (%d) exceeds max threshold value - clamping to %d\n", threshold, newThreshold);
+#endif
+					threshold = newThreshold;
+				}
+				mmcr0_reg.field.threshold_value = threshold;
+
+				sv->save_mmcr0 = mmcr0_reg.value;
+			}
+			break;
+		default:
+			retval = KERN_FAILURE;
+			break;
+	}
+
+#ifdef HWPERFMON_DEBUG
+	kprintf("perfmon_set_threshold - threshold=%d - mmcr0=0x%llx mmcr1=0x%llx mmcr2=0x%llx\n", threshold, sv->save_mmcr0, sv->save_mmcr1, sv->save_mmcr2);
+#endif
+
+	return retval;
+}
+
+int perfmon_set_tbsel(thread_act_t thr_act, int tbsel)
+{
+	struct savearea *sv = thr_act->mact.pcb;
+	kern_return_t retval = KERN_SUCCESS;
+
+	switch(machine_slot[0].cpu_subtype) {
+		case CPU_SUBTYPE_POWERPC_750:
+		case CPU_SUBTYPE_POWERPC_7400:
+		case CPU_SUBTYPE_POWERPC_7450:
+			{
+				ppc32_mmcr0_reg_t mmcr0_reg;
+
+				mmcr0_reg.value = sv->save_mmcr0;
+				switch(tbsel) {
+					case 0x0:
+					case 0x1:
+					case 0x2:
+					case 0x3:
+						mmcr0_reg.field.timebase_bit_selector = tbsel;
+						break;
+					default:
+						retval = KERN_FAILURE;
+				}
+				sv->save_mmcr0 = mmcr0_reg.value;
+			}
+			break;
+		case CPU_SUBTYPE_POWERPC_970:
+			{
+				ppc64_mmcr0_reg_t mmcr0_reg;
+
+				mmcr0_reg.value = sv->save_mmcr0;
+				switch(tbsel) {
+					case 0x0:
+					case 0x1:
+					case 0x2:
+					case 0x3:
+						mmcr0_reg.field.timebase_bit_selector = tbsel;
+						break;
+					default:
+						retval = KERN_FAILURE;
+				}
+				sv->save_mmcr0 = mmcr0_reg.value;
+			}
+			break;
+		default:
+			retval = KERN_FAILURE;
+			break;
+	}
+
+#ifdef HWPERFMON_DEBUG
+	kprintf("perfmon_set_tbsel - tbsel=%d - mmcr0=0x%llx mmcr1=0x%llx mmcr2=0x%llx\n", tbsel, sv->save_mmcr0, sv->save_mmcr1, sv->save_mmcr2);
+#endif
+
+	return retval;
+}
+
+int perfmon_control(struct savearea *ssp)
+{
+	mach_port_t thr_port = (mach_port_t)ssp->save_r3;
+	int action = (int)ssp->save_r4;
+	int pmc = (int)ssp->save_r5;
+	int val = (int)ssp->save_r6;
+	uint64_t *usr_pmcs_p = (uint64_t *)ssp->save_r7;
+	thread_act_t thr_act = THREAD_NULL;
+	uint64_t kern_pmcs[MAX_CPUPMC_COUNT];
+	kern_return_t retval = KERN_SUCCESS;
+	int error;  
+	boolean_t oldlevel;
+
+	thr_act = port_name_to_act(thr_port); // convert user space thread port name to a thread_act_t
+	if(!thr_act) {
+		ssp->save_r3 = KERN_INVALID_ARGUMENT;
+		return 1;  /* Return and check for ASTs... */
+	}
+
+	if(thr_act!=current_act()) {
+		thread_suspend(thr_act);
+	}
+
+#ifdef HWPERFMON_DEBUG
+	//  kprintf("perfmon_control: action=0x%x pmc=%d val=%d pmcs=0x%x\n", action, pmc, val, usr_pmcs_p);
+#endif  
+
+	oldlevel = ml_set_interrupts_enabled(FALSE);
+  
+	/* individual actions which do not require perfmon facility to be enabled */
+	if(action==PPC_PERFMON_DISABLE) {
+		retval = perfmon_disable(thr_act);
+	}
+	else if(action==PPC_PERFMON_ENABLE) {
+		retval = perfmon_enable(thr_act);
+	}
+  
+	else { /* individual actions which do require perfmon facility to be enabled */
+		if(!(thr_act->mact.specFlags & perfMonitor)) { /* perfmon not enabled */
+#ifdef HWPERFMON_DEBUG
+			kprintf("perfmon_control: ERROR - perfmon not enabled for this thread\n");
+#endif
+			retval = KERN_NO_ACCESS;
+			goto perfmon_return;
+		}
+	
+		if(action==PPC_PERFMON_SET_EVENT) {
+			retval = perfmon_set_event(thr_act, pmc, val);
+		}
+		else if(action==PPC_PERFMON_SET_THRESHOLD) {
+			retval = perfmon_set_threshold(thr_act, val);
+		}
+		else if(action==PPC_PERFMON_SET_TBSEL) {
+			retval = perfmon_set_tbsel(thr_act, val);
+		}
+		else if(action==PPC_PERFMON_SET_EVENT_FUNC) {
+			retval = perfmon_set_event_func(thr_act, val);
+		}
+		else if(action==PPC_PERFMON_ENABLE_PMI_BRKPT) {
+			if(val) {
+				thr_act->mact.perfmonFlags |= PERFMONFLAG_BREAKPOINT_FOR_PMI;
+			} else {
+				thr_act->mact.perfmonFlags &= ~PERFMONFLAG_BREAKPOINT_FOR_PMI;
+			}
+			retval = KERN_SUCCESS;
+		}
+	
+		/* combinable actions */
+		else {
+			if(action & PPC_PERFMON_STOP_COUNTERS) {
+				error = perfmon_stop_counters(thr_act);
+				if(error!=KERN_SUCCESS) {
+					retval = error;
+					goto perfmon_return;
+				}
+			}
+			if(action & PPC_PERFMON_CLEAR_COUNTERS) {
+				error = perfmon_clear_counters(thr_act);
+				if(error!=KERN_SUCCESS) {
+					retval = error;
+					goto perfmon_return;
+				}
+			}
+			if(action & PPC_PERFMON_WRITE_COUNTERS) {
+				if(error = copyin((void *)usr_pmcs_p, (void *)kern_pmcs, MAX_CPUPMC_COUNT*sizeof(uint64_t))) {
+					retval = error;
+					goto perfmon_return;
+				}
+				error = perfmon_write_counters(thr_act, kern_pmcs);
+				if(error!=KERN_SUCCESS) {
+					retval = error;
+					goto perfmon_return;
+				}
+			}
+			if(action & PPC_PERFMON_READ_COUNTERS) {
+				error = perfmon_read_counters(thr_act, kern_pmcs);
+				if(error!=KERN_SUCCESS) {
+					retval = error;
+					goto perfmon_return;
+				}
+				if(error = copyout((void *)kern_pmcs, (void *)usr_pmcs_p, MAX_CPUPMC_COUNT*sizeof(uint64_t))) {
+					retval = error;
+					goto perfmon_return;
+				}
+			}
+			if(action & PPC_PERFMON_START_COUNTERS) {
+				error = perfmon_start_counters(thr_act);
+				if(error!=KERN_SUCCESS) {
+					retval = error;
+					goto perfmon_return;
+				}
+			}
+		}
+	}
+  
+ perfmon_return:
+	ml_set_interrupts_enabled(oldlevel);
+
+#ifdef HWPERFMON_DEBUG
+	kprintf("perfmon_control (CPU%d): mmcr0 = %016llX, pmc1=%X pmc2=%X pmc3=%X pmc4=%X pmc5=%X pmc6=%X pmc7=%X pmc8=%X\n", cpu_number(), ssp->save_mmcr0, ssp->save_pmc[PMC_1], ssp->save_pmc[PMC_2], ssp->save_pmc[PMC_3], ssp->save_pmc[PMC_4], ssp->save_pmc[PMC_5], ssp->save_pmc[PMC_6], ssp->save_pmc[PMC_7], ssp->save_pmc[PMC_8]);
+#endif  
+ 
+	if(thr_act!=current_act()) {
+		thread_resume(thr_act);
+	}
+
+#ifdef HWPERFMON_DEBUG
+	if(retval!=KERN_SUCCESS) {
+		kprintf("perfmon_control - ERROR: retval=%d\n", retval);
+	}
+#endif /* HWPERFMON_DEBUG */
+
+	ssp->save_r3 = retval;
+	return 1;  /* Return and check for ASTs... */
+}
+
+int perfmon_handle_pmi(struct savearea *ssp)
+{
+	int curPMC;
+	kern_return_t retval = KERN_SUCCESS;
+	thread_act_t thr_act = current_act();
+
+#ifdef HWPERFMON_DEBUG
+		kprintf("perfmon_handle_pmi: got rupt\n");
+#endif
+
+	if(!(thr_act->mact.specFlags & perfMonitor)) { /* perfmon not enabled */
+#ifdef HWPERFMON_DEBUG
+		kprintf("perfmon_handle_pmi: ERROR - perfmon not enabled for this thread\n");
+#endif
+		return KERN_FAILURE;
+	}
+  
+	for(curPMC=0; curPMC<MAX_CPUPMC_COUNT; curPMC++) {
+		if(thr_act->mact.pcb->save_pmc[curPMC] & 0x80000000) {
+			if(thr_act->mact.pmcovfl[curPMC]==0xFFFFFFFF && (thr_act->mact.perfmonFlags & PERFMONFLAG_BREAKPOINT_FOR_PMI)) {
+				doexception(EXC_BREAKPOINT, EXC_PPC_PERFMON, (unsigned int)ssp->save_srr0); // pass up a breakpoint exception
+				return KERN_SUCCESS;
+			} else {
+				thr_act->mact.pmcovfl[curPMC]++;
+				thr_act->mact.pcb->save_pmc[curPMC] = 0;
+			}
+		}
+	}
+  
+	if(retval==KERN_SUCCESS) {
+		switch(machine_slot[0].cpu_subtype) {
+			case CPU_SUBTYPE_POWERPC_7450:
+				{
+					ppc32_mmcr0_reg_t mmcr0_reg;
+	
+					mmcr0_reg.value = thr_act->mact.pcb->save_mmcr0;
+					mmcr0_reg.field.disable_counters_always = FALSE;
+					mmcr0_reg.field.enable_pmi = TRUE;
+					thr_act->mact.pcb->save_mmcr0 = mmcr0_reg.value;
+				}
+				retval = KERN_SUCCESS;
+				break;
+			case CPU_SUBTYPE_POWERPC_970:
+				{
+					ppc64_mmcr0_reg_t mmcr0_reg;
+	
+					mmcr0_reg.value = thr_act->mact.pcb->save_mmcr0;
+					mmcr0_reg.field.disable_counters_always = FALSE;
+					mmcr0_reg.field.enable_pmi = TRUE;
+					thr_act->mact.pcb->save_mmcr0 = mmcr0_reg.value;
+				}
+				retval = KERN_SUCCESS;
+				break;
+			default:
+				retval = KERN_FAILURE;
+				break;
+		}
+	}
+
+	return retval;
+}
diff --git a/osfmk/ppc/hw_perfmon.h b/osfmk/ppc/hw_perfmon.h
new file mode 100644
index 000000000..1f70b3266
--- /dev/null
+++ b/osfmk/ppc/hw_perfmon.h
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ * 
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ * 
+ * @APPLE_LICENSE_HEADER_END@
+ */
+#ifndef _HW_PERFMON_H_
+#define _HW_PERFMON_H_
+
+#ifndef __ppc__
+#error This file is only useful on PowerPC.
+#endif
+
+#define MAX_CPUPMC_COUNT  8
+
+#define PMC_1    0
+#define PMC_2    1
+#define PMC_3    2
+#define PMC_4    3
+#define PMC_5    4
+#define PMC_6    5
+#define PMC_7    6
+#define PMC_8    7
+
+/* these actions can be combined and simultaneously performed with a single call to perfmon_control() */
+typedef enum {
+	PPC_PERFMON_CLEAR_COUNTERS =   0x0002,
+	PPC_PERFMON_START_COUNTERS =   0x0004,
+	PPC_PERFMON_STOP_COUNTERS  =   0x0008,
+	PPC_PERFMON_READ_COUNTERS  =   0x0010,
+	PPC_PERFMON_WRITE_COUNTERS =   0x0020
+} perfmon_multi_action_t;
+
+/* these actions can not be combined and each requires a separate call to perfmon_control() */
+typedef enum {
+	PPC_PERFMON_ENABLE =           0x00010000,
+	PPC_PERFMON_DISABLE =          0x00020000,
+	PPC_PERFMON_SET_EVENT =        0x00030000,
+	PPC_PERFMON_SET_THRESHOLD =    0x00040000,
+	PPC_PERFMON_SET_TBSEL =        0x00050000,
+	PPC_PERFMON_SET_EVENT_FUNC =   0x00060000,
+	PPC_PERFMON_ENABLE_PMI_BRKPT = 0x00070000
+} perfmon_single_action_t;
+
+/* used to select byte lane and speculative events (currently 970 only) */
+typedef enum {                        /* SPECSEL[0:1]  TD_CP_DBGxSEL[0:1]  TTM3SEL[0:1]  TTM1SEL[0:1]  TTM0SEL[0:1] */
+	PPC_PERFMON_FUNC_FPU =         0,   /*           00                  00            00            00            00 */
+	PPC_PERFMON_FUNC_ISU =         1,   /*           00                  00            00            00            01 */
+	PPC_PERFMON_FUNC_IFU =         2,   /*           00                  00            00            00            10 */
+	PPC_PERFMON_FUNC_VMX =         3,   /*           00                  00            00            00            11 */
+	PPC_PERFMON_FUNC_IDU =        64,   /*           00                  01            00            00            00 */
+	PPC_PERFMON_FUNC_GPS =        76,   /*           00                  01            00            11            00 */
+	PPC_PERFMON_FUNC_LSU0 =      128,   /*           00                  10            00            00            00 */
+	PPC_PERFMON_FUNC_LSU1A =     192,   /*           00                  11            00            00            00 */
+	PPC_PERFMON_FUNC_LSU1B =     240,   /*           00                  11            11            00            00 */
+	PPC_PERFMON_FUNC_SPECA =     256,   /*           01                  00            00            00            00 */
+	PPC_PERFMON_FUNC_SPECB =     512,   /*           10                  00            00            00            00 */
+	PPC_PERFMON_FUNC_SPECC =     768,   /*           11                  00            00            00            00 */
+} perfmon_functional_unit_t;
+
+#ifdef MACH_KERNEL_PRIVATE
+int perfmon_acquire_facility(task_t task);
+int perfmon_release_facility(task_t task);
+
+extern int perfmon_disable(thread_act_t thr_act);
+extern int perfmon_init(void);
+extern int perfmon_control(struct savearea *save);
+extern int perfmon_handle_pmi(struct savearea *ssp);
+
+/* perfmonFlags */
+#define PERFMONFLAG_BREAKPOINT_FOR_PMI     0x1
+
+#endif /* MACH_KERNEL_PRIVATE */
+
+/* 
+ * From user space:
+ * 
+ * int perfmon_control(thread_t thread, perfmon_action_t action, int pmc, u_int32_t val, u_int64_t *pmcs);
+ * 
+ * r3: thread
+ * r4: action
+ * r5: pmc
+ * r6: event/threshold/tbsel/count
+ * r7: pointer to space for PMC counts: uint64_t[MAX_CPUPMC_COUNT]
+ *
+ * perfmon_control(thread, PPC_PERFMON_CLEAR_COUNTERS, 0, 0, NULL);
+ * perfmon_control(thread, PPC_PERFMON_START_COUNTERS, 0, 0, NULL);
+ * perfmon_control(thread, PPC_PERFMON_STOP_COUNTERS, 0, 0, NULL);
+ * perfmon_control(thread, PPC_PERFMON_READ_COUNTERS, 0, 0, uint64_t *pmcs);
+ * perfmon_control(thread, PPC_PERFMON_WRITE_COUNTERS, 0, 0, uint64_t *pmcs);
+ * perfmon_control(thread, PPC_PERFMON_ENABLE, 0, 0, NULL);
+ * perfmon_control(thread, PPC_PERFMON_DISABLE, 0, 0, NULL);
+ * perfmon_control(thread, PPC_PERFMON_SET_EVENT, int pmc, int event, NULL);
+ * perfmon_control(thread, PPC_PERFMON_SET_THRESHOLD, 0, int threshold, NULL);
+ * perfmon_control(thread, PPC_PERFMON_SET_TBSEL, 0, int tbsel, NULL);
+ * perfmon_control(thread, PPC_PERFMON_SET_EVENT_FUNC, 0, perfmon_functional_unit_t func, NULL);
+ * perfmon_control(thread, PPC_PERFMON_ENABLE_PMI_BRKPT, 0, boolean_t enable, NULL);
+ *
+ */
+
+#endif /* _HW_PERFMON_H_ */
diff --git a/osfmk/ppc/hw_perfmon_mmcr.h b/osfmk/ppc/hw_perfmon_mmcr.h
new file mode 100644
index 000000000..13d636dcd
--- /dev/null
+++ b/osfmk/ppc/hw_perfmon_mmcr.h
@@ -0,0 +1,183 @@
+/*
+ * Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ * 
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ * 
+ * @APPLE_LICENSE_HEADER_END@
+ */
+ 
+#ifndef _HW_PERFMON_MMCR_H_
+#define _HW_PERFMON_MMCR_H_
+
+#ifndef __ppc__
+#error This file is only useful on PowerPC.
+#endif
+
+typedef struct {
+	uint32_t disable_counters_always : 1;     /*     0: disable counters */
+	uint32_t disable_counters_supervisor : 1; /*     1: disable counters (supervisor) */
+	uint32_t disable_counters_user : 1;       /*     2: disable counters (user) */
+	uint32_t disable_counters_marked : 1;     /*     3: disable counters (marked bit == 1) */
+	uint32_t disable_counters_unmarked : 1;   /*     4: disable counters (marked bit == 0) */
+	uint32_t enable_pmi : 1;                  /*     5: performance monitor interrupt enable */
+	uint32_t on_pmi_stop_counting : 1;        /*     6: disable counters (pmi) */
+	uint32_t timebase_bit_selector : 2;       /*   7-8: TBL bit for TB events */
+	uint32_t enable_timebase_pmi : 1;         /*     9: enable pmi on TBL bit transition */
+	uint32_t threshold_value : 6;             /* 10-15: threshold value */
+	uint32_t enable_pmi_on_pmc1 : 1;          /*    16: enable pmi on pmc1 overflow */
+	uint32_t enable_pmi_on_pmcn : 1;          /*    17: enable pmi on any pmc except pmc1 overflow */
+	uint32_t enable_pmi_trigger : 1;          /*    18: enable triggering of pmcn by pmc1 overflow */
+	uint32_t pmc1_event : 7;                  /* 19-25: pmc1 event select */
+	uint32_t pmc2_event : 6;                  /* 26-31: pmc2 event select */
+} ppc32_mmcr0_bits_t;
+
+typedef union {
+	uint32_t value;
+	ppc32_mmcr0_bits_t field;
+} ppc32_mmcr0_reg_t;
+
+typedef struct {
+	uint32_t pmc3_event : 5;
+	uint32_t pmc4_event : 5;
+	uint32_t pmc5_event : 5;
+	uint32_t pmc6_event : 6;
+	uint32_t /*reserved*/ : 11;
+} ppc32_mmcr1_bits_t;
+
+typedef union {
+	uint32_t value;
+	ppc32_mmcr1_bits_t field;
+} ppc32_mmcr1_reg_t;
+
+typedef struct {
+	uint32_t threshold_multiplier : 1;
+	uint32_t /*reserved*/ : 31;
+} ppc32_mmcr2_bits_t;
+
+typedef union {
+	uint32_t value;
+	ppc32_mmcr2_bits_t field;
+} ppc32_mmcr2_reg_t;
+
+typedef struct {
+	uint32_t /* reserved */ : 32;             /*  0-31: reserved */
+	uint32_t disable_counters_always : 1;     /*    32: disable counters */
+	uint32_t disable_counters_supervisor : 1; /*    33: disable counters (supervisor) */
+	uint32_t disable_counters_user : 1;       /*    34: disable counters (user) */
+	uint32_t disable_counters_marked : 1;     /*    35: disable counters (marked bit == 1) */
+	uint32_t disable_counters_unmarked : 1;   /*    36: disable counters (marked bit == 0) */
+	uint32_t enable_pmi : 1;                  /*    37: performance monitor interrupt enable */
+	uint32_t on_pmi_stop_counting : 1;        /*    38: disable counters (pmi) */
+	uint32_t timebase_bit_selector : 2;       /* 39-40: TBL bit for timebase events */
+	uint32_t enable_timebase_pmi : 1;         /*    41: enable pmi on TBL bit transition */
+	uint32_t threshold_value : 6;             /* 42-47: threshold value */
+	uint32_t enable_pmi_on_pmc1 : 1;          /*    48: enable pmi on pmc1 overflow */
+	uint32_t enable_pmi_on_pmcn : 1;          /*    49: enable pmi on any pmc except pmc1 overflow */
+	uint32_t enable_pmi_trigger : 1;          /*    50: enable triggering of pmcn by pmc1 overflow */
+	uint32_t pmc1_event : 5;                  /* 51-55: pmc1 event select */
+	uint32_t perfmon_event_occurred : 1;      /*    56: performance monitor event has occurred */
+	uint32_t /* reserved */ : 1;              /*    57: reserved */
+	uint32_t pmc2_event : 5;                  /* 58-62: pmc2 event select */
+	uint32_t disable_counters_hypervisor : 1; /*    63: disable counters (hypervisor) */
+} ppc64_mmcr0_bits_t;
+
+typedef union {
+	uint64_t value;
+	ppc64_mmcr0_bits_t field;
+} ppc64_mmcr0_reg_t;
+
+typedef struct {
+	uint32_t ttm0_select : 2;                 /*   0-1: FPU/ISU/IFU/VMX unit select */
+	uint32_t /* reserved */ : 1;              /*     2: reserved */
+	uint32_t ttm1_select : 2;                 /*   3-4: IDU/ISU/ISU unit select */
+	uint32_t /* reserved */ : 1;              /*     5: reserved */
+	uint32_t ttm2_select : 2;                 /*   6-7: IFU/LSU0 unit select */
+	uint32_t /* reserved */ : 1;              /*     8: reserved */
+	uint32_t ttm3_select : 2;                 /*  9-10: LSU1 select */
+	uint32_t /* reserved */ : 1;              /*    11: reserved */
+	uint32_t lane0_select : 2;                /* 12-13: Byte lane 0 unit select (TD_CP_DBG0SEL) */
+	uint32_t lane1_select : 2;                /* 14-15: Byte lane 1 unit select (TD_CP_DBG1SEL) */
+	uint32_t lane2_select : 2;                /* 16-17: Byte lane 2 unit select (TD_CP_DBG2SEL) */
+	uint32_t lane3_select : 2;                /* 18-19: Byte lane 3 unit select (TD_CP_DBG3SEL) */
+	uint32_t /* reserved */ : 4;              /* 20-23: reserved */
+	uint32_t pmc1_adder_lane_select : 1;      /*    24: PMC1 Event Adder Lane Select (PMC1_ADDER_SELECT) */
+	uint32_t pmc2_adder_lane_select : 1;      /*    25: PMC2 Event Adder Lane Select (PMC2_ADDER_SELECT) */
+	uint32_t pmc6_adder_lane_select : 1;      /*    26: PMC6 Event Adder Lane Select (PMC6_ADDER_SELECT) */
+	uint32_t pmc5_adder_lane_select : 1;      /*    27: PMC5 Event Adder Lane Select (PMC5_ADDER_SELECT) */
+	uint32_t pmc8_adder_lane_select : 1;      /*    28: PMC8 Event Adder Lane Select (PMC8_ADDER_SELECT) */
+	uint32_t pmc7_adder_lane_select : 1;      /*    29: PMC7 Event Adder Lane Select (PMC7_ADDER_SELECT) */
+	uint32_t pmc3_adder_lane_select : 1;      /*    30: PMC3 Event Adder Lane Select (PMC3_ADDER_SELECT) */
+	uint32_t pmc4_adder_lane_select : 1;      /*    31: PMC4 Event Adder Lane Select (PMC4_ADDER_SELECT) */
+	uint32_t pmc3_event : 5;                  /* 32-36: pmc3 event select */
+	uint32_t pmc4_event : 5;                  /* 37-41: pmc4 event select */
+	uint32_t pmc5_event : 5;                  /* 42-46: pmc5 event select */
+	uint32_t pmc6_event : 5;                  /* 47-51: pmc6 event select */
+	uint32_t pmc7_event : 5;                  /* 52-56: pmc7 event select */
+	uint32_t pmc8_event : 5;                  /* 57-61: pmc8 event select */
+	uint32_t speculative_event : 2;           /* 62-63: SPeCulative count event SELector */
+} ppc64_mmcr1_bits_t;
+
+typedef union {
+	uint64_t value;
+	ppc64_mmcr1_bits_t field;
+} ppc64_mmcr1_reg_t;
+
+typedef struct {
+	uint32_t /* reserved */ : 32;             /*  0-31: reserved */
+	uint32_t siar_sdar_same_instruction : 1;  /*    32: SIAR and SDAR are from same instruction */
+	uint32_t disable_counters_pmc1_pmc4 : 1;  /*    33: disable counters PMC1-PMC4 */
+	uint32_t disable_counters_pmc5_pmc8 : 1;  /*    34: disable counters PMC5-PMC8 */
+	uint32_t problem_state_siar : 1;          /*    35: MSR[PR] bit when SIAR set */
+	uint32_t hypervisor_state_siar : 1;       /*    36: MSR[HV] bit when SIAR set */
+	uint32_t /* reserved */ : 3;              /* 37-39: reserved */
+	uint32_t threshold_start_event : 3;       /* 40-42: threshold start event */
+	uint32_t threshold_end_event : 3;         /* 43-45: threshold end event */
+	uint32_t /* reserved */ : 3;              /* 46-48: reserved */
+	uint32_t imr_select : 1;                  /*    49: imr select */
+	uint32_t imr_mark : 2;                    /* 50-51: imr mark */
+	uint32_t imr_mask : 4;                    /* 52-55: imr mask */
+	uint32_t imr_match : 4;                   /* 56-59: imr match */
+	uint32_t disable_counters_tags_inactive : 1; /* 60: disable counters in tags inactive mode */
+	uint32_t disable_counters_tags_active : 1; /*   61: disable counters in tags active mode */
+	uint32_t disable_counters_wait_state : 1; /*    62: freeze counters in wait state (CNTL[31]=0) */
+	uint32_t sample_enable : 1;               /*    63: sampling enabled */
+} ppc64_mmcra_bits_t;
+
+typedef union {
+	uint64_t value;
+	ppc64_mmcra_bits_t field;
+} ppc64_mmcra_reg_t;
+
+/* PPC_PERFMON_FUNC_* values are taken apart to fill in the appropriate configuration bitfields: */
+typedef struct {
+	uint32_t /* reserved */ : 22;
+	uint32_t SPECSEL : 2;
+	uint32_t TD_CP_DBGxSEL : 2;
+	uint32_t TTM3SEL : 2;
+	uint32_t TTM1SEL : 2;
+	uint32_t TTM0SEL : 2;
+} ppc_func_bits_t;
+
+typedef union {
+	uint32_t value;
+	ppc_func_bits_t field;
+} ppc_func_unit_t;
+
+#endif /* _HW_PERFMON_MMCR_H_ */
diff --git a/osfmk/ppc/hw_vm.s b/osfmk/ppc/hw_vm.s
index 640a637f6..b5839084f 100644
--- a/osfmk/ppc/hw_vm.s
+++ b/osfmk/ppc/hw_vm.s
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -31,3064 +34,3935 @@
 #include <ppc/exception.h>
 #include <ppc/Performance.h>
 #include <ppc/exception.h>
-#include <ppc/pmap_internals.h>
 #include <mach/ppc/vm_param.h>
-#define PERFTIMES 0
+
+#define INSTRUMENT 0
 	
 			.text
 
-/*
- *
- *			Random notes and musings...
- *
- *			Access to mappings via the PTEG hash must be done with the list locked.
- *			Access via the physical entries is controlled by the physent lock.
- *			Access to mappings is controlled by the PTEG lock once they are queued.
- *			If they are not on the list, they don't really exist, so
- *			only one processor at a time can find them, so no access control is needed. 
- *
- *			The second half of the PTE is kept in the physical entry.  It is done this
- *			way, because there may be multiple mappings that refer to the same physical
- *			page (i.e., address aliases or synonymns).  We must do it this way, because
- *			maintenance of the reference and change bits becomes nightmarish if each mapping
- *			has its own. One side effect of this, and not necessarily a bad one, is that
- *			all mappings for a single page can have a single WIMG, protection state, and RC bits.
- *			The only "bad" thing, is the reference bit.  With a single copy, we can not get
- *			a completely accurate working set calculation, i.e., we can't tell which mapping was
- *			used to reference the page, all we can tell is that the physical page was 
- *			referenced.
- *
- *			The master copys of the reference and change bits are kept in the phys_entry.
- *			Other than the reference and change bits, changes to the phys_entry are not
- *			allowed if it has any mappings.  The master reference and change bits must be
- *			changed via atomic update.
- *
- *			Invalidating a PTE merges the RC bits into the phys_entry.
- *
- *			Before checking the reference and/or bits, ALL mappings to the physical page are
- *			invalidated.
- *			
- *			PTEs are never explicitly validated, they are always faulted in.  They are also
- *			not visible outside of the hw_vm modules.  Complete seperation of church and state.
- *
- *			Removal of a mapping is invalidates its PTE.
- *
- *			So, how do we deal with mappings to I/O space? We don't have a physent for it.
- *			Within the mapping is a copy of the second half of the PTE.  This is used
- *			ONLY when there is no physical entry.  It is swapped into the PTE whenever
- *			it is built.  There is no need to swap it back out, because RC is not
- *			maintained for these mappings.
- *
- *			So, I'm starting to get concerned about the number of lwarx/stcwx loops in
- *			this.  Satisfying a mapped address with no stealing requires one lock.  If we 
- *			steal an entry, there's two locks and an atomic update.  Invalidation of an entry
- *			takes one lock and, if there is a PTE, another lock and an atomic update.  Other 
- *			operations are multiples (per mapping) of the above.  Maybe we should look for
- *			an alternative.  So far, I haven't found one, but I haven't looked hard.
- */
+;
+;                                     0        0        1        2        3        4        4        5      6
+;                                     0        8        6        4        2        0        8        6      3 
+;                                    +--------+--------+--------+--------+--------+--------+--------+--------+
+;                                    |00000000|00000SSS|SSSSSSSS|SSSSSSSS|SSSSPPPP|PPPPPPPP|PPPPxxxx|xxxxxxxx|          - EA
+;                                    +--------+--------+--------+--------+--------+--------+--------+--------+
+;
+;                                                       0        0        1
+;                                                       0        8        6      
+;                                                      +--------+--------+--------+
+;                                                      |//////BB|BBBBBBBB|BBBB////|                                     - SID - base
+;                                                      +--------+--------+--------+
+;
+;                                     0        0        1
+;                                     0        8        6      
+;                                    +--------+--------+--------+
+;                                    |////////|11111111|111111//|                                                       - SID - copy 1
+;                                    +--------+--------+--------+
+;
+;                   0        0        1
+;                   0        8        6      
+;                  +--------+--------+--------+
+;                  |////////|//222222|22222222|                                                                         - SID - copy 2
+;                  +--------+--------+--------+
+;
+;          0        0        1
+;          0        8        6      
+;         +--------+--------+--------+
+;         |//////33|33333333|33//////|                                                                                  - SID - copy 3 - not needed
+;         +--------+--------+--------+                                                                                         for 65 bit VPN
+;
+;                   0        0        1        2        3        4        4  5   5  
+;                   0        8        6        4        2        0        8  1   5  
+;                  +--------+--------+--------+--------+--------+--------+--------+
+;                  |00000000|00000002|22222222|11111111|111111BB|BBBBBBBB|BBBB////|                                     - SID Hash - this is all
+;                  +--------+--------+--------+--------+--------+--------+--------+                                           SID copies ORed
+;                   0        0        1        2        3        4        4  5   5  
+;                   0        8        6        4        2        0        8  1   5  
+;                  +--------+--------+--------+--------+--------+--------+--------+
+;                  |00000000|0000000S|SSSSSSSS|SSSSSSSS|SSSSSS00|00000000|0000////|                                      - Shifted high order EA
+;                  +--------+--------+--------+--------+--------+--------+--------+                                           left shifted "segment"
+;                                                                                                                             part of EA to make
+;                                                                                                                             room for SID base
+;
+;
+;                   0        0        1        2        3        4        4  5   5  
+;                   0        8        6        4        2        0        8  1   5  
+;                  +--------+--------+--------+--------+--------+--------+--------+
+;                  |00000000|0000000V|VVVVVVVV|VVVVVVVV|VVVVVVVV|VVVVVVVV|VVVV////|                                     - VSID - SID Hash XORed
+;                  +--------+--------+--------+--------+--------+--------+--------+                                            with shifted EA
+;
+;                   0        0        1        2        3        4        4        5        6        7      7
+;                   0        8        6        4        2        0        8        6        4        2      9
+;                  +--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+
+;                  |00000000|0000000V|VVVVVVVV|VVVVVVVV|VVVVVVVV|VVVVVVVV|VVVVPPPP|PPPPPPPP|PPPPxxxx|xxxxxxxx|          - VPN
+;                  +--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+
+;
 
 
-/*			hw_add_map(struct mapping *mp, space_t space, vm_offset_t va) - Adds a mapping
+/*			addr64_t hw_add_map(struct pmap *pmap, struct mapping *mp) - Adds a mapping
  *
- *			Adds a mapping to the PTEG hash list.
+ *			Maps a page or block into a pmap
  *
- *			Interrupts must be disabled before calling.
- *
- *			Using the space and the virtual address, we hash into the hash table
- *			and get a lock on the PTEG hash chain.  Then we chain the 
- *			mapping to the front of the list.
+ *			Returns 0 if add worked or the vaddr of the first overlap if not
  *
+ * Make mapping - not block or I/O - note: this is low-level, upper should remove duplicates
+ *  
+ *  1) bump mapping busy count
+ *  2) lock pmap share
+ *  3) find mapping full path - finds all possible list previous elements
+ *  4) upgrade pmap to exclusive
+ *  5) add mapping to search list
+ *  6) find physent
+ *  7) lock physent
+ *  8) add to physent
+ *  9) unlock physent
+ * 10) unlock pmap
+ * 11) drop mapping busy count
+ * 
+ * 
+ * Make mapping - block or I/O - note: this is low-level, upper should remove duplicates
+ *  
+ *  1) bump mapping busy count
+ *  2) lock pmap share
+ *  3) find mapping full path - finds all possible list previous elements
+ *  4) upgrade pmap to exclusive
+ *  5) add mapping to search list
+ *  6) unlock pmap
+ *  7) drop mapping busy count
+ * 
  */
 
 			.align	5
 			.globl	EXT(hw_add_map)
 
 LEXT(hw_add_map)
-
-#if PERFTIMES && DEBUG
-			mr		r7,r3
-			mflr	r11
-			li		r3,20
-			bl		EXT(dbgLog2)						; Start of hw_add_map
-			mr		r3,r7
-			mtlr	r11
-#endif
-
-			mfmsr	r0							/* Get the MSR */
-			eqv		r6,r6,r6					/* Fill the bottom with foxes */
-			rlwinm	r0,r0,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-			rlwinm	r11,r4,6,6,25				/* Position the space for the VSID */
-			mfspr	r10,sdr1					/* Get hash table base and size */
-			rlwinm	r0,r0,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-			rlwimi	r11,r5,30,2,5				/* Insert the segment no. to make a VSID */
-			mfsprg	r12,2						; Get feature flags
-			rlwimi	r6,r10,16,0,15				/* Make table size -1 out of mask */
-			rlwinm	r7,r5,26,10,25				/* Isolate the page index */
-			or		r8,r10,r6					/* Point to the last byte in table */
-			rlwinm	r9,r5,4,0,3					; Move nybble 1 up to 0
-			xor		r7,r7,r11					/* Get primary hash */
-			mtcrf	0x04,r12					; Set the features			
-			andi.	r12,r0,0x7FCF				/* Disable translation and interruptions */
-			rlwinm	r11,r11,1,1,24				/* Position VSID for pte ID */
-			addi	r8,r8,1						/* Point to the PTEG Control Area */
-			xor		r9,r9,r5					; Splooch vaddr nybble 0 and 1 together
-			and		r7,r7,r6					/* Wrap the hash */
-			rlwimi	r11,r5,10,26,31				/* Move API into pte ID */
-			rlwinm	r9,r9,6,27,29				; Get splooched bits in place
-			add		r8,r8,r7					/* Point to our PCA entry */
-			rlwinm	r10,r4,2,27,29				; Get low 3 bits of the VSID for look-aside hash
-			
-			bt		pfNoMSRirb,hamNoMSR			; No MSR...
-
-			mtmsr	r12							; Translation and all off
-			isync								; Toss prefetch
-			b		hamNoMSRx
+ 			
+ 			stwu	r1,-(FM_ALIGN((31-17+1)*4)+FM_SIZE)(r1)	; Make some space on the stack
+			mflr	r0							; Save the link register
+			stw		r17,FM_ARG0+0x00(r1)		; Save a register
+			stw		r18,FM_ARG0+0x04(r1)		; Save a register
+			stw		r19,FM_ARG0+0x08(r1)		; Save a register
+ 			mfsprg	r19,2						; Get feature flags 
+			stw		r20,FM_ARG0+0x0C(r1)		; Save a register
+			stw		r21,FM_ARG0+0x10(r1)		; Save a register
+			mtcrf	0x02,r19					; move pf64Bit cr6
+			stw		r22,FM_ARG0+0x14(r1)		; Save a register
+			stw		r23,FM_ARG0+0x18(r1)		; Save a register
+			stw		r24,FM_ARG0+0x1C(r1)		; Save a register
+			stw		r25,FM_ARG0+0x20(r1)		; Save a register
+			stw		r26,FM_ARG0+0x24(r1)		; Save a register
+			stw		r27,FM_ARG0+0x28(r1)		; Save a register
+			stw		r28,FM_ARG0+0x2C(r1)		; Save a register
+			stw		r29,FM_ARG0+0x30(r1)		; Save a register
+			stw		r30,FM_ARG0+0x34(r1)		; Save a register
+			stw		r31,FM_ARG0+0x38(r1)		; Save a register
+			stw		r0,(FM_ALIGN((31-17+1)*4)+FM_SIZE+FM_LR_SAVE)(r1)	; Save the return
+
+			rlwinm	r11,r4,0,0,19				; Round down to get mapping block address
+  			mr		r28,r3						; Save the pmap
+  			mr		r31,r4						; Save the mapping
+			bt++	pf64Bitb,hamSF1				; skip if 64-bit (only they take the hint)
+			lwz		r20,pmapvr+4(r3)			; Get conversion mask for pmap
+			lwz		r21,mbvrswap+4(r11)			; Get conversion mask for mapping
+
+			b		hamSF1x						; Done...
+			
+hamSF1:		ld		r20,pmapvr(r3)				; Get conversion mask for pmap
+			ld		r21,mbvrswap(r11)			; Get conversion mask for mapping
+
+hamSF1x:	bl		EXT(mapSetUp)				; Turn off interrupts, translation, and possibly enter 64-bit
+			
+			mr		r17,r11						; Save the MSR
+			xor		r28,r28,r20					; Convert the pmap to physical addressing
+			xor		r31,r31,r21					; Convert the mapping to physical addressing
+			
+			la		r3,pmapSXlk(r28)			; Point to the pmap search lock
+			bl		sxlkShared					; Go get a shared lock on the mapping lists
+			mr.		r3,r3						; Did we get the lock?
+			lwz		r24,mpFlags(r31)			; Pick up the flags
+			bne--	hamBadLock					; Nope...
+
+			li		r21,0						; Remember that we have the shared lock
 			
-hamNoMSR:	mr		r4,r0						; Save R0
-			mr		r2,r3						; Save
-			li		r0,loadMSR					; Get the MSR setter SC
-			mr		r3,r12						; Get new MSR
-			sc									; Set it
-			mr		r0,r4						; Restore
-			mr		r3,r2						; Restore
-hamNoMSRx:
+;
+;			Note that we do a full search (i.e., no shortcut level skips, etc.)
+;			here so that we will know the previous elements so we can dequeue them
+;			later.
+;
 
-			la		r4,PCAhash(r8)				/* Point to the mapping hash area */
-			xor		r9,r9,r10					; Finish splooching nybble 0, 1, and the low bits of the VSID
-			isync								/* Get rid of anything prefetched before we ref storage */
-/*
- *			We've now got the address of our PCA, the hash chain anchor, our API subhash,
- *			and word 0 of the PTE (the virtual part). 
- *
- *			Now, we just lock the PCA.		
- */
+hamRescan:	lwz		r4,mpVAddr(r31)				; Get the new vaddr top half
+			lwz		r5,mpVAddr+4(r31)			; Get the new vaddr bottom half
+			mr		r3,r28						; Pass in pmap to search
+			lhz		r23,mpBSize(r31)			; Get the block size for later
+			mr		r29,r4						; Save top half of vaddr for later
+			mr		r30,r5						; Save bottom half of vaddr for later
+			
+#if INSTRUMENT
+			mfspr	r0,pmc1						; INSTRUMENT - saveinstr[16] - Take stamp before mapSearchFull
+			stw		r0,0x6100+(16*16)+0x0(0)	; INSTRUMENT - Save it
+			mfspr	r0,pmc2						; INSTRUMENT - Get stamp
+			stw		r0,0x6100+(16*16)+0x4(0)	; INSTRUMENT - Save it
+			mfspr	r0,pmc3						; INSTRUMENT - Get stamp
+			stw		r0,0x6100+(16*16)+0x8(0)	; INSTRUMENT - Save it
+			mfspr	r0,pmc4						; INSTRUMENT - Get stamp
+			stw		r0,0x6100+(16*16)+0xC(0)	; INSTRUMENT - Save it
+#endif			
+			
+			bl		EXT(mapSearchFull)			; Go see if we can find it
+			
+#if INSTRUMENT
+			mfspr	r0,pmc1						; INSTRUMENT - saveinstr[14] - Take stamp after mapSearchFull
+			stw		r0,0x6100+(17*16)+0x0(0)	; INSTRUMENT - Save it
+			mfspr	r0,pmc2						; INSTRUMENT - Get stamp
+			stw		r0,0x6100+(17*16)+0x4(0)	; INSTRUMENT - Save it
+			mfspr	r0,pmc3						; INSTRUMENT - Get stamp
+			stw		r0,0x6100+(17*16)+0x8(0)	; INSTRUMENT - Save it
+			mfspr	r0,pmc4						; INSTRUMENT - Get stamp
+			stw		r0,0x6100+(17*16)+0xC(0)	; INSTRUMENT - Save it
+#endif			
+			
+			andi.	r0,r24,mpNest				; See if we are a nest
+			rlwinm	r23,r23,12,0,19				; Convert standard block size to bytes
+			lis		r0,0x8000					; Get 0xFFFFFFFF80000000
+			li		r22,0						; Assume high part of size is 0
+			beq++	hamNoNest					; This is not a nest...
+			
+			rlwinm	r22,r23,16,16,31			; Convert partially converted size to segments
+			rlwinm	r23,r23,16,0,3				; Finish shift
+			
+hamNoNest:	add		r0,r0,r0					; Get 0xFFFFFFFF00000000 for 64-bit or 0 for 32-bit
+			mr.		r3,r3						; Did we find a mapping here?
+			or		r0,r0,r30					; Make sure a carry will propagate all the way in 64-bit
+			crmove	cr5_eq,cr0_eq				; Remember that if we found the mapping
+			addc	r9,r0,r23					; Add size to get last page in new range
+			or.		r0,r4,r5					; Are we beyond the end?
+			adde	r8,r29,r22					; Add the rest of the length on
+			bne--	cr5,hamOverlay				; Yeah, this is no good, can not double map...
+			rlwinm	r9,r9,0,0,31				; Clean top half of sum
+			beq++	hamFits						; We are at the end...
+			
+			cmplw	cr1,r9,r5					; Is the bottom part of our end less?
+			cmplw	r8,r4						; Is our end before the next (top part)
+			crand	cr0_eq,cr0_eq,cr1_lt		; Is the second half less and the first half equal?
+			cror	cr0_eq,cr0_eq,cr0_lt		; Or is the top half less
+			
+			bf--	cr0_eq,hamOverlay			; No, we do fit, there is an overlay...
 			
-			li		r12,1						/* Get the locked value */
-			dcbt	0,r4						/* We'll need the hash area in a sec, so get it */
-			add		r4,r4,r9					/* Point to the right mapping hash slot */
-			
-ptegLckx:	lwarx	r10,0,r8					/* Get the PTEG lock */
-			mr.		r10,r10						/* Is it locked? */
-			bne-	ptegLckwx					/* Yeah... */
-			stwcx.	r12,0,r8					/* Take take it */
-			bne-	ptegLckx					/* Someone else was trying, try again... */
-			b		ptegSXgx					/* All done... */
-
-			.align	4
-			
-ptegLckwx:	mr.		r10,r10						/* Check if it's already held */
-			beq+	ptegLckx					/* It's clear... */
-			lwz		r10,0(r8)					/* Get lock word again... */
-			b		ptegLckwx					/* Wait... */
-			
-			.align	4
-			
-ptegSXgx:	isync								/* Make sure we haven't used anything yet */
-
-			lwz		r7,0(r4)					/* Pick up the anchor of hash list */
-			stw		r3,0(r4)					/* Save the new head */
-			stw		r7,mmhashnext(r3)			/* Chain in the old head */
-			
-			stw		r4,mmPTEhash(r3)			/* Point to the head of the hash list */
-			
-			sync								/* Make sure the chain is updated */
-			stw		r10,0(r8)					/* Unlock the hash list */
-			mtmsr	r0							/* Restore translation and interruptions */
-			isync								/* Toss anything done with DAT off */
-#if PERFTIMES && DEBUG
-			mflr	r11
-			mr		r4,r3
-			li		r3,21
-			bl		EXT(dbgLog2)				; end of hw_add_map
-			mr		r3,r4
-			mtlr	r11
-#endif
-			blr									/* Leave... */
-
-
-/*			mp=hw_lock_phys_vir(space, va) - Finds and locks a physical entry by vaddr.
- *
- *			Returns the mapping with the associated physent locked if found, or a
- *			zero and no lock if not.  It we timed out trying to get a the lock on
- *			the physical entry, we retun a 1.  A physical entry can never be on an
- *			odd boundary, so we can distinguish between a mapping and a timeout code.
- *
- *			Interrupts must be disabled before calling.
- *
- *			Using the space and the virtual address, we hash into the hash table
- *			and get a lock on the PTEG hash chain.  Then we search the chain for the
- *			mapping for our virtual address.  From there, we extract the pointer to
- *			the physical entry.
- *
- *			Next comes a bit of monkey business.  we need to get a lock on the physical
- *			entry.  But, according to our rules, we can't get it after we've gotten the
- *			PTEG hash lock, we could deadlock if we do.  So, we need to release the
- *			hash lock.  The problem is, though, that as soon as we release it, some 
- *			other yahoo may remove our mapping between the time that we release the
- *			hash lock and obtain the phys entry lock.  So, we can't count on the 
- *			mapping once we release the lock.  Instead, after we lock the phys entry,
- *			we search the mapping list (phys_link) for our translation.  If we don't find it,
- *			we unlock the phys entry, bail out, and return a 0 for the mapping address.  If we 
- *			did find it, we keep the lock and return the address of the mapping block.
- *
- *			What happens when a mapping is found, but there is no physical entry?
- *			This is what happens when there is I/O area mapped.  It one of these mappings
- *			is found, the mapping is returned, as is usual for this call, but we don't
- *			try to lock anything.  There could possibly be some problems here if another
- *			processor releases the mapping while we still alre using it.  Hope this 
- *			ain't gonna happen.
- *
- *			Taaa-dahhh!  Easy as pie, huh?
- *
- *			So, we have a few hacks hacks for running translate off in here. 
- *			First, when we call the lock routine, we have carnel knowlege of the registers is uses. 
- *			That way, we don't need a stack frame, which we can't have 'cause the stack is in
- *			virtual storage.  But wait, as if that's not enough...  We need one more register.  So, 
- *			we cram the LR into the CTR and return from there.
- *
- */
-			.align	5
-			.globl	EXT(hw_lock_phys_vir)
-
-LEXT(hw_lock_phys_vir)
-
-#if PERFTIMES && DEBUG
-			mflr	r11
-			mr		r5,r3
-			li		r3,22
-			bl		EXT(dbgLog2)						; Start of hw_add_map
-			mr		r3,r5
-			mtlr	r11
-#endif
-			mfmsr	r12							/* Get the MSR */
-			eqv		r6,r6,r6					/* Fill the bottom with foxes */
-			mfsprg	r9,2						; Get feature flags 
-			rlwinm	r11,r3,6,6,25				/* Position the space for the VSID */
-			rlwinm	r12,r12,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-			mfspr	r5,sdr1						/* Get hash table base and size */
-			rlwimi	r11,r4,30,2,5				/* Insert the segment no. to make a VSID */
-			mtcrf	0x04,r9						; Set the features			
-			rlwinm	r12,r12,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-			rlwimi	r6,r5,16,0,15				/* Make table size -1 out of mask */
-			andi.	r0,r12,0x7FCF				/* Disable translation and interruptions */
-			rlwinm	r9,r4,4,0,3					; Move nybble 1 up to 0
-			rlwinm	r7,r4,26,10,25				/* Isolate the page index */
-			or		r8,r5,r6					/* Point to the last byte in table */
-			xor		r7,r7,r11					/* Get primary hash */
-			rlwinm	r11,r11,1,1,24				/* Position VSID for pte ID */
-			addi	r8,r8,1						/* Point to the PTEG Control Area */
-			xor		r9,r9,r4					; Splooch vaddr nybble 0 and 1 together
-			and		r7,r7,r6					/* Wrap the hash */
-			rlwimi	r11,r4,10,26,31				/* Move API into pte ID */
-			rlwinm	r9,r9,6,27,29				; Get splooched bits in place
-			add		r8,r8,r7					/* Point to our PCA entry */
-			rlwinm	r10,r3,2,27,29				; Get low 3 bits of the VSID for look-aside hash
-
-			bt		pfNoMSRirb,hlpNoMSR			; No MSR...
-
-			mtmsr	r0							; Translation and all off
-			isync								; Toss prefetch
-			b		hlpNoMSRx
+;
+;			Here we try to convert to an exclusive lock.  This will fail if someone else
+;			has it shared.
+;
+hamFits:	mr.		r21,r21						; Do we already have the exclusive lock?			
+			la		r3,pmapSXlk(r28)			; Point to the pmap search lock
 			
-hlpNoMSR:	mr		r3,r0						; Get the new MSR
-			li		r0,loadMSR					; Get the MSR setter SC
-			sc									; Set it
-hlpNoMSRx:
-
-			la		r3,PCAhash(r8)				/* Point to the mapping hash area */
-			xor		r9,r9,r10					; Finish splooching nybble 0, 1, and the low bits of the VSID
-			isync								/* Make sure translation is off before we ref storage */
-
-/*
- *			We've now got the address of our PCA, the hash chain anchor, our API subhash,
- *			and word 0 of the PTE (the virtual part). 
- *
- *			Now, we just lock the PCA and find our mapping, if it exists.				
- */
+			bne--	hamGotX						; We already have the exclusive...
+			
+			bl		sxlkPromote					; Try to promote shared to exclusive
+			mr.		r3,r3						; Could we?
+			beq++	hamGotX						; Yeah...
 			
-			dcbt	0,r3						/* We'll need the hash area in a sec, so get it */
-			add		r3,r3,r9					/* Point to the right mapping hash slot */
+;
+;			Since we could not promote our lock, we need to convert to it.
+;			That means that we drop the shared lock and wait to get it
+;			exclusive.  Since we release the lock, we need to do the look up
+;			again.
+;			
+			
+			la		r3,pmapSXlk(r28)			; Point to the pmap search lock
+			bl		sxlkConvert					; Convert shared to exclusive
+			mr.		r3,r3						; Could we?
+			bne--	hamBadLock					; Nope, we must have timed out...
 			
-ptegLcka:	lwarx	r10,0,r8					/* Get the PTEG lock */
-			li		r5,1						/* Get the locked value */
-			mr.		r10,r10						/* Is it locked? */
-			bne-	ptegLckwa					/* Yeah... */
-			stwcx.	r5,0,r8						/* Take take it */
-			bne-	ptegLcka					/* Someone else was trying, try again... */
-			b		ptegSXga					/* All done... */
+			li		r21,1						; Remember that we have the exclusive lock
+			b		hamRescan					; Go look again...
 			
-			.align	4
+			.align	5
 
-ptegLckwa:	mr.		r10,r10						/* Check if it's already held */
-			beq+	ptegLcka					/* It's clear... */
-			lwz		r10,0(r8)					/* Get lock word again... */
-			b		ptegLckwa					/* Wait... */
+hamGotX:	
+#if INSTRUMENT
+			mfspr	r3,pmc1						; INSTRUMENT - saveinstr[18] - Take stamp before mapSearchFull
+			stw		r3,0x6100+(18*16)+0x0(0)	; INSTRUMENT - Save it
+			mfspr	r3,pmc2						; INSTRUMENT - Get stamp
+			stw		r3,0x6100+(18*16)+0x4(0)	; INSTRUMENT - Save it
+			mfspr	r3,pmc3						; INSTRUMENT - Get stamp
+			stw		r3,0x6100+(18*16)+0x8(0)	; INSTRUMENT - Save it
+			mfspr	r3,pmc4						; INSTRUMENT - Get stamp
+			stw		r4,0x6100+(18*16)+0xC(0)	; INSTRUMENT - Save it
+#endif			
+			mr		r3,r28						; Get the pmap to insert into
+			mr		r4,r31						; Point to the mapping
+			bl		EXT(mapInsert)				; Insert the mapping into the list
+
+#if INSTRUMENT
+			mfspr	r4,pmc1						; INSTRUMENT - saveinstr[19] - Take stamp before mapSearchFull
+			stw		r4,0x6100+(19*16)+0x0(0)	; INSTRUMENT - Save it
+			mfspr	r4,pmc2						; INSTRUMENT - Get stamp
+			stw		r4,0x6100+(19*16)+0x4(0)	; INSTRUMENT - Save it
+			mfspr	r4,pmc3						; INSTRUMENT - Get stamp
+			stw		r4,0x6100+(19*16)+0x8(0)	; INSTRUMENT - Save it
+			mfspr	r4,pmc4						; INSTRUMENT - Get stamp
+			stw		r4,0x6100+(19*16)+0xC(0)	; INSTRUMENT - Save it
+#endif			
+	
+			lhz		r8,mpSpace(r31)				; Get the address space
+			mfsdr1	r7							; Get the hash table base/bounds
+			lwz		r4,pmapResidentCnt(r28)		; Get the mapped page count 
+			andi.	r0,r24,mpNest|mpBlock		; Is this a nest or block?
+
+			rlwimi	r8,r8,14,4,17				; Double address space
+			rlwinm	r9,r30,20,16,31				; Isolate the page number
+			rlwinm	r10,r30,18,14,17			; Shift EA[32:35] down to correct spot in VSID (actually shift up 14)
+			rlwimi	r8,r8,28,0,3				; Get the last nybble of the hash
+			rlwimi	r10,r29,18,0,13				; Shift EA[18:31] down to VSID (31-bit math works because of max hash table size)			
+			rlwinm	r7,r7,0,16,31				; Isolate length mask (or count)
+			addi	r4,r4,1						; Bump up the mapped page count
+			xor		r10,r10,r8					; Calculate the low 32 bits of the VSID
+			stw		r4,pmapResidentCnt(r28)		; Set the mapped page count 
+			xor		r9,r9,r10					; Get the hash to the PTEG
+			
+			bne--	hamDoneNP					; This is a block or nest, therefore, no physent...
+			
+			bl		mapPhysFindLock				; Go find and lock the physent
+			
+			bt++	pf64Bitb,ham64				; This is 64-bit...
+			
+			lwz		r11,ppLink+4(r3)			; Get the alias chain pointer
+			rlwinm	r7,r7,16,0,15				; Get the PTEG wrap size
+			slwi	r9,r9,6						; Make PTEG offset
+			ori		r7,r7,0xFFC0				; Stick in the bottom part
+			rlwinm	r12,r11,0,0,25				; Clean it up
+			and		r9,r9,r7					; Wrap offset into table
+			mr		r4,r31						; Set the link to install
+			stw		r9,mpPte(r31)				; Point the mapping at the PTEG (exact offset is invalid)
+			stw		r12,mpAlias+4(r31)			; Move to the mapping
+			bl		mapPhyCSet32				; Install the link
+			b		hamDone						; Go finish up...
 			
-			.align	4
+			.align	5
+			
+ham64:		li		r0,0xFF						; Get mask to clean up alias pointer
+			subfic	r7,r7,46					; Get number of leading zeros
+			eqv		r4,r4,r4					; Get all ones
+			ld		r11,ppLink(r3)				; Get the alias chain pointer
+			rldicl	r0,r0,62,0					; Rotate clean up mask to get 0xC0000000000000003F
+			srd		r4,r4,r7					; Get the wrap mask
+			sldi	r9,r9,7						; Change hash to PTEG offset
+			andc	r11,r11,r0					; Clean out the lock and flags
+			and		r9,r9,r4					; Wrap to PTEG
+			mr		r4,r31
+			stw		r9,mpPte(r31)				; Point the mapping at the PTEG (exact offset is invalid)
+			std		r11,mpAlias(r31)			; Set the alias pointer in the mapping
+
+			bl		mapPhyCSet64				; Install the link
+						
+hamDone:	bl		mapPhysUnlock				; Unlock the physent chain
 
-ptegSXga:	isync								/* Make sure we haven't used anything yet */
+hamDoneNP:	la		r3,pmapSXlk(r28)			; Point to the pmap search lock
+			bl		sxlkUnlock					; Unlock the search list
 
-			mflr	r0							/* Get the LR */
-			lwz		r9,0(r3)					/* Pick up the first mapping block */
-			mtctr	r0							/* Stuff it into the CTR */
+			mr		r3,r31						; Get the mapping pointer
+			bl		mapDropBusy					; Drop the busy count
 			
-findmapa:	
+			li		r3,0						; Set successful return
+			li		r4,0						; Set successful return
 
-			mr.		r3,r9						/* Did we hit the end? */
-			bne+	chkmapa						/* Nope... */
-			
-			stw		r3,0(r8)					/* Unlock the PTEG lock
-												   Note: we never saved anything while we 
-												   had the lock, so we don't need a sync 
-												   before we unlock it */
+hamReturn:	bt++	pf64Bitb,hamR64				; Yes...
 
-vbail:		mtmsr	r12							/* Restore translation and interruptions */
-			isync								/* Make sure translation is cool */
-#if PERFTIMES && DEBUG
-			mflr	r11
-			mr		r4,r3
-			li		r3,23
-			bl		EXT(dbgLog2)				; Start of hw_add_map
-			mr		r3,r4
-			mtlr	r11
-#endif
-			bctr								/* Return in abject failure... */
-			
-			.align	4
-
-chkmapa:	lwz		r10,mmPTEv(r3)				/* Pick up our virtual ID */
-			lwz		r9,mmhashnext(r3)			/* Pick up next mapping block */
-			cmplw	r10,r11						/* Have we found ourself? */
-			bne-	findmapa					/* Nope, still wandering... */
-			
-			lwz		r9,mmphysent(r3)			/* Get our physical entry pointer */
-			li		r5,0						/* Clear this out */
-			mr.		r9,r9						/* Is there, like, a physical entry? */
-			stw		r5,0(r8)					/* Unlock the PTEG lock
-												   Note: we never saved anything while we 
-												   had the lock, so we don't need a sync 
-												   before we unlock it */
-												   
-			beq-	vbail						/* If there is no physical entry, it's time
-												   to leave... */
-												   
-/*			Here we want to call hw_lock_bit.  We don't want to use the stack, 'cause it's
- *			in virtual storage, and we're in real.  So, we've carefully looked at the code
- *			in hw_lock_bit (and unlock) and cleverly don't use any of the registers that it uses.
- *			Be very, very aware of how you change this code.  By the way, it uses:
- *			R0, R6, R7, R8, and R9.  R3, R4, and R5 contain parameters
- *			Unfortunatly, we need to stash R9 still. So... Since we know we will not be interrupted
- *			('cause we turned off interruptions and translation is off) we will use SPRG3...
- */
- 
-			lwz		r10,mmPTEhash(r3)			/* Save the head of the hash-alike chain.  We need it to find ourselves later */
-			lis		r5,HIGH_ADDR(EXT(LockTimeOut))	/* Get address of timeout value */
-			la		r3,pephyslink(r9)			/* Point to the lock word */
-			ori		r5,r5,LOW_ADDR(EXT(LockTimeOut))	/* Get second half of address */
-			li		r4,PHYS_LOCK				/* Get the lock bit value */
-			lwz		r5,0(r5)					/* Pick up the timeout value */
-			mtsprg	3,r9						/* Save R9 in SPRG3 */
-			
-			bl		EXT(hw_lock_bit)			/* Go do the lock */
-			
-			mfsprg	r9,3						/* Restore pointer to the phys_entry */		
-			mr.		r3,r3						/* Did we timeout? */
-			lwz		r4,pephyslink(r9)			/* Pick up first mapping block */		
-			beq-	penterr						/* Bad deal, we timed out... */
+			mtmsr	r17							; Restore enables/translation/etc.
+			isync
+			b		hamReturnC					; Join common...
 
-			rlwinm	r4,r4,0,0,26				; Clear out the flags from first link
+hamR64:		mtmsrd	r17							; Restore enables/translation/etc.
+			isync								
 			
-findmapb:	mr.		r3,r4						/* Did we hit the end? */
-			bne+	chkmapb						/* Nope... */
+hamReturnC:	
+#if INSTRUMENT
+			mfspr	r0,pmc1						; INSTRUMENT - saveinstr[20] - Take stamp before mapSearchFull
+			stw		r0,0x6100+(20*16)+0x0(0)	; INSTRUMENT - Save it
+			mfspr	r0,pmc2						; INSTRUMENT - Get stamp
+			stw		r0,0x6100+(20*16)+0x4(0)	; INSTRUMENT - Save it
+			mfspr	r0,pmc3						; INSTRUMENT - Get stamp
+			stw		r0,0x6100+(20*16)+0x8(0)	; INSTRUMENT - Save it
+			mfspr	r0,pmc4						; INSTRUMENT - Get stamp
+			stw		r0,0x6100+(20*16)+0xC(0)	; INSTRUMENT - Save it
+#endif			
+			lwz		r0,(FM_ALIGN((31-17+1)*4)+FM_SIZE+FM_LR_SAVE)(r1)	; Get the return
+			lwz		r17,FM_ARG0+0x00(r1)		; Save a register
+			lwz		r18,FM_ARG0+0x04(r1)		; Save a register
+			lwz		r19,FM_ARG0+0x08(r1)		; Save a register
+			lwz		r20,FM_ARG0+0x0C(r1)		; Save a register
+			mtlr	r0							; Restore the return
+			lwz		r21,FM_ARG0+0x10(r1)		; Save a register
+			lwz		r22,FM_ARG0+0x14(r1)		; Save a register
+			lwz		r23,FM_ARG0+0x18(r1)		; Save a register
+			lwz		r24,FM_ARG0+0x1C(r1)		; Save a register
+			lwz		r25,FM_ARG0+0x20(r1)		; Save a register
+			lwz		r26,FM_ARG0+0x24(r1)		; Save a register
+			lwz		r27,FM_ARG0+0x28(r1)		; Save a register
+			lwz		r28,FM_ARG0+0x2C(r1)		; Save a register
+			lwz		r29,FM_ARG0+0x30(r1)		; Save a register
+			lwz		r30,FM_ARG0+0x34(r1)		; Save a register
+			lwz		r31,FM_ARG0+0x38(r1)		; Save a register
+			lwz		r1,0(r1)					; Pop the stack
 			
-			la		r3,pephyslink(r9)			/* Point to where the lock is */						
-			li		r4,PHYS_LOCK				/* Get the lock bit value */
-			bl		EXT(hw_unlock_bit)			/* Go unlock the physentry */
+			blr									; Leave...
 
-			li		r3,0						/* Say we failed */			
-			b		vbail						/* Return in abject failure... */
 			
-penterr:	li		r3,1						/* Set timeout */
-			b		vbail						/* Return in abject failure... */
-					
 			.align	5
 
-chkmapb:	lwz		r6,mmPTEv(r3)				/* Pick up our virtual ID */
-			lwz		r4,mmnext(r3)				/* Pick up next mapping block */
-			cmplw	r6,r11						/* Have we found ourself? */
-			lwz		r5,mmPTEhash(r3)			/* Get the start of our hash chain */
-			bne-	findmapb					/* Nope, still wandering... */
-			cmplw	r5,r10						/* On the same hash chain? */
-			bne-	findmapb					/* Nope, keep looking... */
+hamOverlay:	lwz		r22,mpFlags(r3)				; Get the overlay flags
+			li		r0,mpC|mpR					; Get a mask to turn off RC bits
+			lwz		r23,mpFlags(r31)			; Get the requested flags
+			lwz		r20,mpVAddr(r3)				; Get the overlay address
+			lwz		r8,mpVAddr(r31)				; Get the requested address
+			lwz		r21,mpVAddr+4(r3)			; Get the overlay address
+			lwz		r9,mpVAddr+4(r31)			; Get the requested address
+			lhz		r10,mpBSize(r3)				; Get the overlay length
+			lhz		r11,mpBSize(r31)			; Get the requested length
+			lwz		r24,mpPAddr(r3)				; Get the overlay physical address
+			lwz		r25,mpPAddr(r31)			; Get the requested physical address
+			andc	r21,r21,r0					; Clear RC bits
+			andc	r9,r9,r0					; Clear RC bits
+
+			la		r3,pmapSXlk(r28)			; Point to the pmap search lock
+			bl		sxlkUnlock					; Unlock the search list
+
+			rlwinm.	r0,r22,0,mpRIPb,mpRIPb		; Are we in the process of removing this one?
+			mr		r3,r20						; Save the top of the colliding address
+			rlwinm	r4,r21,0,0,19				; Save the bottom of the colliding address
+
+			bne++	hamRemv						; Removing, go say so so we help...
+			
+			cmplw	r20,r8						; High part of vaddr the same?
+			cmplw	cr1,r21,r9					; Low part?
+			crand	cr5_eq,cr0_eq,cr1_eq		; Remember if same
+			
+			cmplw	r10,r11						; Size the same?
+			cmplw	cr1,r24,r25					; Physical address?
+			crand	cr5_eq,cr5_eq,cr0_eq		; Remember
+			crand	cr5_eq,cr5_eq,cr1_eq		; Remember if same
+			
+			xor		r23,r23,r22					; Check for differences in flags
+			ori		r23,r23,mpFIP				; "Fault in Progress" is ok to be different
+			xori	r23,r23,mpFIP				; Force mpFIP off
+			rlwinm.	r0,r23,0,mpSpecialb,mpListsb-1	; See if any important flags are different
+			crand	cr5_eq,cr5_eq,cr0_eq		; Merge in final check
+			bf--	cr5_eq,hamReturn			; This is not the same, so we just return a collision...
+			
+			ori		r4,r4,mapRtMapDup			; Set duplicate
+			b		hamReturn					; And leave...
+			
+hamRemv:	ori		r4,r4,mapRtRemove			; We are in the process of removing the collision
+			b		hamReturn					; Come back yall...
+
+			.align	5
+			
+hamBadLock:	li		r3,0						; Set lock time out error code
+			li		r4,mapRtBadLk				; Set lock time out error code
+			b		hamReturn					; Leave....
+
+
 
-			b		vbail						/* Return in glorious triumph... */
 
 
 /*
- *			hw_rem_map(mapping) - remove a mapping from the system.
+ *			mapping *hw_rem_map(pmap, vaddr, addr64_t *next) - remove a mapping from the system.
  *
- *			Upon entry, R3 contains a pointer to a mapping block and the associated
- *			physical entry is locked if there is one.
- *
- *			If the mapping entry indicates that there is a PTE entry, we invalidate
- *			if and merge the reference and change information into the phys_entry.
+ *			Upon entry, R3 contains a pointer to a pmap.  Since vaddr is
+ *			a 64-bit quantity, it is a long long so it is in R4 and R5.
+ *			
+ *			We return the virtual address of the removed mapping as a 
+ *			R3.
  *
- *			Next, we remove the mapping from the phys_ent and the PTEG hash list.
+ *			Note that this is designed to be called from 32-bit mode with a stack.
  *
- *			Unlock any locks that are left, and exit.
+ *			We disable translation and all interruptions here.  This keeps is
+ *			from having to worry about a deadlock due to having anything locked
+ *			and needing it to process a fault.
  *
  *			Note that this must be done with both interruptions off and VM off
  *	
- *			Note that this code depends upon the VSID being of the format 00SXXXXX
- *			where S is the segment number.
- *
- *			  
+ *  Remove mapping via pmap, regular page, no pte
+ * 
+ *  1) lock pmap share
+ *  2) find mapping full path - finds all possible list previous elements
+ *  4) upgrade pmap to exclusive
+ *  3) bump mapping busy count
+ *  5) remove mapping from search list
+ *  6) unlock pmap
+ *  7) lock physent
+ *  8) remove from physent
+ *  9) unlock physent
+ * 10) drop mapping busy count
+ * 11) drain mapping busy count
+ * 
+ * 
+ * Remove mapping via pmap, regular page, with pte
+ * 
+ *  1) lock pmap share
+ *  2) find mapping full path - finds all possible list previous elements
+ *  3) upgrade lock to exclusive
+ *  4) bump mapping busy count
+ *  5) lock PTEG
+ *  6) invalidate pte and tlbie
+ *  7) atomic merge rc into physent
+ *  8) unlock PTEG
+ *  9) remove mapping from search list
+ * 10) unlock pmap
+ * 11) lock physent
+ * 12) remove from physent
+ * 13) unlock physent
+ * 14) drop mapping busy count
+ * 15) drain mapping busy count
+ * 
+ * 
+ * Remove mapping via pmap, I/O or block
+ * 
+ *  1) lock pmap share
+ *  2) find mapping full path - finds all possible list previous elements
+ *  3) upgrade lock to exclusive
+ *  4) bump mapping busy count
+ *	5) mark remove-in-progress
+ *	6) check and bump remove chunk cursor if needed
+ *	7) unlock pmap
+ *	8) if something to invalidate, go to step 11
+
+ *	9) drop busy
+ * 10) return with mapRtRemove to force higher level to call again
+ 
+ * 11) Lock PTEG
+ * 12) invalidate ptes, no tlbie
+ * 13) unlock PTEG
+ * 14) repeat 11 - 13 for all pages in chunk
+ * 15) if not final chunk, go to step 9
+ * 16) invalidate tlb entries for the whole block map but no more than the full tlb
+ * 17) lock pmap share
+ * 18) find mapping full path - finds all possible list previous elements
+ * 19) upgrade lock to exclusive
+ * 20) remove mapping from search list
+ * 21) drop mapping busy count
+ * 22) drain mapping busy count
+ *	
  */
 
 			.align	5
 			.globl	EXT(hw_rem_map)
 
 LEXT(hw_rem_map)
-#if PERFTIMES && DEBUG
-			mflr	r11
-			mr		r4,r3
-			li		r3,24
-			bl		EXT(dbgLog2)				; Start of hw_add_map
-			mr		r3,r4
-			mtlr	r11
-#endif
- 			mfsprg	r9,2						; Get feature flags 
-			mfmsr	r0							/* Save the MSR  */
-			rlwinm	r0,r0,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-			rlwinm	r0,r0,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-			rlwinm	r12,r0,0,MSR_EE_BIT+1,MSR_EE_BIT-1	/* Clear interruptions */
-			mtcrf	0x04,r9						; Set the features			
-			rlwinm	r12,r12,0,28,25				/* Clear IR and DR */
-
-			bt		pfNoMSRirb,lmvNoMSR			; No MSR...
 
-			mtmsr	r12							; Translation and all off
-			isync								; Toss prefetch
-			b		lmvNoMSRx
-			
-lmvNoMSR:	
-			mr		r6,r0
-			mr		r4,r3
-			li		r0,loadMSR					; Get the MSR setter SC
-			mr		r3,r12						; Get new MSR
-			sc									; Set it
-			mr		r3,r4
-			mr		r0,r6
+;
+;			NOTE NOTE NOTE - IF WE CHANGE THIS STACK FRAME STUFF WE NEED TO CHANGE
+;			THE HW_PURGE_* ROUTINES ALSO
+;
 
-lmvNoMSRx:
+#define hrmStackSize ((31-15+1)*4)+4
+			stwu	r1,-(FM_ALIGN(hrmStackSize)+FM_SIZE)(r1)	; Make some space on the stack
+			mflr	r0							; Save the link register
+			stw		r15,FM_ARG0+0x00(r1)		; Save a register
+			stw		r16,FM_ARG0+0x04(r1)		; Save a register
+			stw		r17,FM_ARG0+0x08(r1)		; Save a register
+			stw		r18,FM_ARG0+0x0C(r1)		; Save a register
+			stw		r19,FM_ARG0+0x10(r1)		; Save a register
+ 			mfsprg	r19,2						; Get feature flags 
+			stw		r20,FM_ARG0+0x14(r1)		; Save a register
+			stw		r21,FM_ARG0+0x18(r1)		; Save a register
+			mtcrf	0x02,r19					; move pf64Bit cr6
+			stw		r22,FM_ARG0+0x1C(r1)		; Save a register
+			stw		r23,FM_ARG0+0x20(r1)		; Save a register
+			stw		r24,FM_ARG0+0x24(r1)		; Save a register
+			stw		r25,FM_ARG0+0x28(r1)		; Save a register
+			stw		r26,FM_ARG0+0x2C(r1)		; Save a register
+			stw		r27,FM_ARG0+0x30(r1)		; Save a register
+			stw		r28,FM_ARG0+0x34(r1)		; Save a register
+			stw		r29,FM_ARG0+0x38(r1)		; Save a register
+			stw		r30,FM_ARG0+0x3C(r1)		; Save a register
+			stw		r31,FM_ARG0+0x40(r1)		; Save a register
+			stw		r6,FM_ARG0+0x44(r1)			; Save address to save next mapped vaddr
+			stw		r0,(FM_ALIGN(hrmStackSize)+FM_SIZE+FM_LR_SAVE)(r1)	; Save the return
+
+ 			bt++	pf64Bitb,hrmSF1				; skip if 64-bit (only they take the hint)
+			lwz		r9,pmapvr+4(r3)				; Get conversion mask
+			b		hrmSF1x						; Done...
+			
+hrmSF1:		ld		r9,pmapvr(r3)				; Get conversion mask
+
+hrmSF1x:	
+			bl		EXT(mapSetUp)				; Turn off interrupts, translation, and possibly enter 64-bit
+			
+			xor		r28,r3,r9					; Convert the pmap to physical addressing
 
-		
-			lwz		r6,mmPTEhash(r3)			/* Get pointer to hash list anchor */
-			lwz		r5,mmPTEv(r3)				/* Get the VSID */
-			dcbt	0,r6						/* We'll need that chain in a bit */
+;
+;			Here is where we join in from the hw_purge_* routines
+;
 
-			rlwinm	r7,r6,0,0,25				/* Round hash list down to PCA boundary */
-			li		r12,1						/* Get the locked value */
-			subi	r6,r6,mmhashnext			/* Make the anchor look like an entry */
+hrmJoin:	mfsprg	r19,2						; Get feature flags again (for alternate entries)
 
-ptegLck1:	lwarx	r10,0,r7					/* Get the PTEG lock */
-			mr.		r10,r10						/* Is it locked? */
-			bne-	ptegLckw1					/* Yeah... */
-			stwcx.	r12,0,r7					/* Try to take it */
-			bne-	ptegLck1					/* Someone else was trying, try again... */
-			b		ptegSXg1					/* All done... */
+			mr		r17,r11						; Save the MSR
+			mr		r29,r4						; Top half of vaddr
+			mr		r30,r5						; Bottom half of vaddr
 			
-			.align	4
-
-ptegLckw1:	mr.		r10,r10						/* Check if it's already held */
-			beq+	ptegLck1					/* It's clear... */
-			lwz		r10,0(r7)					/* Get lock word again... */
-			b		ptegLckw1					/* Wait... */
+			la		r3,pmapSXlk(r28)			; Point to the pmap search lock
+			bl		sxlkShared					; Go get a shared lock on the mapping lists
+			mr.		r3,r3						; Did we get the lock?
+			bne--	hrmBadLock					; Nope...
 			
-			.align	4
-
-ptegSXg1:	isync								/* Make sure we haven't used anything yet */
-
-			lwz		r12,mmhashnext(r3)			/* Prime with our forward pointer */
- 			lwz		r4,mmPTEent(r3)				/* Get the pointer to the PTE now that the lock's set */
+;
+;			Note that we do a full search (i.e., no shortcut level skips, etc.)
+;			here so that we will know the previous elements so we can dequeue them
+;			later. Note: we get back mpFlags in R7.
+;
 
-srchmaps:	mr.		r10,r6						/* Save the previous entry */
-			bne+	mapok						/* No error... */
+			mr		r3,r28						; Pass in pmap to search
+			mr		r4,r29						; High order of address
+			mr		r5,r30						; Low order of address
+			bl		EXT(mapSearchFull)			; Go see if we can find it
+			
+			andi.	r0,r7,lo16(mpPerm|mpSpecial|mpNest)	; Is this nested, special, or a perm mapping?
+			mr		r20,r7						; Remember mpFlags
+			rlwinm	r0,r7,0,mpRemovableb,mpRemovableb	; Are we allowed to remove it?
+			crmove	cr5_eq,cr0_eq				; Remember if we should remove this
+			mr.		r31,r3						; Did we? (And remember mapping address for later)
+			cmplwi	cr1,r0,0					; Are we allowed to remove?
+			mr		r15,r4						; Save top of next vaddr
+			crorc	cr5_eq,cr5_eq,cr1_eq		; cr5_eq is true if this is not removable
+			mr		r16,r5						; Save bottom of next vaddr
+			beq		hrmNotFound					; Nope, not found...
+ 			
+			bf--	cr5_eq,hrmPerm				; This one can't be removed...
+;
+;			Here we try to promote to an exclusive lock.  This will fail if someone else
+;			has it shared.
+;
 			
-			lis		r0,HIGH_ADDR(Choke)			/* We have a kernel choke!!! */
-			ori		r0,r0,LOW_ADDR(Choke)		
-			sc									/* Firmware Heimlich manuever */
-
-			.align	4			
-
-mapok:		lwz		r6,mmhashnext(r6)			/* Look at the next one */
-			cmplwi	cr5,r4,0					/* Is there a PTE? */
-			cmplw	r6,r3						/* Have we found ourselves? */
-			bne+	srchmaps					/* Nope, get your head together... */
+			la		r3,pmapSXlk(r28)			; Point to the pmap search lock
+			bl		sxlkPromote					; Try to promote shared to exclusive
+			mr.		r3,r3						; Could we?
+			beq++	hrmGotX						; Yeah...
 			
-			stw		r12,mmhashnext(r10)			/* Remove us from the queue */
-			rlwinm	r9,r5,1,0,3					/* Move in the segment */
-			rlwinm	r8,r4,6,4,19				/* Line PTEG disp up to a page */
-			rlwinm	r11,r5,5,4,19				/* Line up the VSID */
-			lwz		r10,mmphysent(r3)			/* Point to the physical entry */
+;
+;			Since we could not promote our lock, we need to convert to it.
+;			That means that we drop the shared lock and wait to get it
+;			exclusive.  Since we release the lock, we need to do the look up
+;			again.
+;			
+			
+			la		r3,pmapSXlk(r28)			; Point to the pmap search lock
+			bl		sxlkConvert					; Convert shared to exclusive
+			mr.		r3,r3						; Could we?
+			bne--	hrmBadLock					; Nope, we must have timed out...
+			
+			mr		r3,r28						; Pass in pmap to search
+			mr		r4,r29						; High order of address
+			mr		r5,r30						; Low order of address
+			bl		EXT(mapSearchFull)			; Rescan the list
+			
+			andi.	r0,r7,lo16(mpPerm|mpSpecial|mpNest)	; Is this nested, special, or a perm mapping?
+			rlwinm	r0,r7,0,mpRemovableb,mpRemovableb	; Are we allowed to remove it?
+			crmove	cr5_eq,cr0_eq				; Remember if we should remove this
+			mr.		r31,r3						; Did we lose it when we converted?
+			cmplwi	cr1,r0,0					; Are we allowed to remove?
+			mr		r20,r7						; Remember mpFlags
+			crorc	cr5_eq,cr5_eq,cr1_eq		; cr5_eq is true if this is not removable
+			mr		r15,r4						; Save top of next vaddr
+			mr		r16,r5						; Save bottom of next vaddr
+			beq--	hrmNotFound					; Yeah, we did, someone tossed it for us...
 		
-			beq+	cr5,nopte					/* There's no PTE to invalidate... */
+			bf--	cr5_eq,hrmPerm				; This one can't be removed...
+
+;
+;			We have an exclusive lock on the mapping chain. And we
+;			also have the busy count bumped in the mapping so it can
+;			not vanish on us.
+;
+
+hrmGotX:	mr		r3,r31						; Get the mapping
+			bl		mapBumpBusy					; Bump up the busy count
 			
-			xor		r8,r8,r11					/* Back hash to virt index */
-			lis		r12,HIGH_ADDR(EXT(tlb_system_lock))	/* Get the TLBIE lock */
-			rlwimi	r9,r5,22,4,9				/* Move in the API */
-			ori		r12,r12,LOW_ADDR(EXT(tlb_system_lock))	/* Grab up the bottom part */
-			mfspr	r11,pvr						/* Find out what kind of machine we are */
-			rlwimi	r9,r8,0,10,19				/* Create the virtual address */
-			rlwinm	r11,r11,16,16,31			/* Isolate CPU type */
+;
+;			Invalidate any PTEs associated with this
+;			mapping (more than one if a block) and accumulate the reference
+;			and change bits.
+;
+;			Here is also where we need to split 32- and 64-bit processing
+;
 
-			stw		r5,0(r4)					/* Make the PTE invalid */		
+			lwz		r21,mpPte(r31)				; Grab the offset to the PTE
+			rlwinm	r23,r29,0,1,0				; Copy high order vaddr to high if 64-bit machine
+			mfsdr1	r29							; Get the hash table base and size
+			rlwinm	r0,r20,0,mpBlockb,mpBlockb	; Is this a block mapping?
+			andi.	r2,r20,lo16(mpSpecial|mpNest)	; Is this nest or special mapping?
+			cmplwi	cr5,r0,0					; Remember if this is a block mapping
+			rlwinm	r0,r21,0,mpHValidb,mpHValidb	; See if we actually have a PTE
+			ori		r2,r2,0xFFFF				; Get mask to clean out hash table base (works for both 32- and 64-bit)
+			cmpwi	cr1,r0,0					; Have we made a PTE for this yet? 
+			rlwinm	r21,r21,0,0,30				; Clear out valid bit
+			crorc	cr0_eq,cr1_eq,cr0_eq		; No need to look at PTE if none or a special mapping
+			rlwimi	r23,r30,0,0,31				; Insert low under high part of address
+			andc	r29,r29,r2					; Clean up hash table base
+			li		r22,0						; Clear this on out (also sets RC to 0 if we bail)
+			mr		r30,r23						; Move the now merged vaddr to the correct register
+			add		r26,r29,r21					; Point to the PTEG slot
+			
+			bt++	pf64Bitb,hrmSplit64			; Go do 64-bit version...
+			
+			rlwinm	r9,r21,28,4,29				; Convert PTEG to PCA entry
+			bne-	cr5,hrmBlock32				; Go treat block specially...
+			subfic	r9,r9,-4					; Get the PCA entry offset
+			bt-		cr0_eq,hrmPysDQ32			; Skip next if no possible PTE...
+			add		r7,r9,r29					; Point to the PCA slot
 
-			cmplwi	cr1,r11,3					/* Is this a 603? */
-			sync								/* Make sure the invalid is stored */
-						
-tlbhang1:	lwarx	r5,0,r12					/* Get the TLBIE lock */
-			rlwinm	r11,r4,29,29,31				/* Get the bit position of entry */
-			mr.		r5,r5						/* Is it locked? */
-			lis		r6,0x8000					/* Start up a bit mask */
-			li		r5,1						/* Get our lock word */
-			bne-	tlbhang1					/* It's locked, go wait... */
-			stwcx.	r5,0,r12					/* Try to get it */
-			bne-	tlbhang1					/* We was beat... */
+	
+			bl		mapLockPteg					; Go lock up the PTEG (Note: we need to save R6 to set PCA)
+	
+			lwz		r21,mpPte(r31)				; Get the quick pointer again
+			lwz		r5,0(r26)					; Get the top of PTE
 			
-			srw		r6,r6,r11					/* Make a "free slot" mask */
-			lwz		r5,PCAallo(r7)				/* Get the allocation control bits */
-			rlwinm	r11,r6,24,8,15				/* Make the autogen bit to turn off */
-			or		r5,r5,r6					/* turn on the free bit */
-			rlwimi	r11,r11,24,16,23			/* Get lock bit mask to turn it off */
+			rlwinm.	r0,r21,0,mpHValidb,mpHValidb	; See if we actually have a PTE
+			rlwinm	r21,r21,0,0,30				; Clear out valid bit
+			rlwinm	r5,r5,0,1,31				; Turn off valid bit in PTE
+			stw		r21,mpPte(r31)				; Make sure we invalidate mpPte, still pointing to PTEG (keep walk_page from making a mistake)
+			beq-	hrmUlckPCA32				; Pte is gone, no need to invalidate...
 			
-			andc	r5,r5,r11					/* Turn off the lock and autogen bits in allocation flags */
-			li		r11,0						/* Lock clear value */
+			stw		r5,0(r26)					; Invalidate the PTE
 
-			tlbie	r9							/* Invalidate it everywhere */
+			li		r9,tlbieLock				; Get the TLBIE lock
 
+			sync								; Make sure the invalid PTE is actually in memory
+	
+hrmPtlb32:	lwarx	r5,0,r9						; Get the TLBIE lock 
+			mr.		r5,r5						; Is it locked?
+			li		r5,1						; Get locked indicator
+			bne-	hrmPtlb32					; It is locked, go spin...
+			stwcx.	r5,0,r9						; Try to get it
+			bne-	hrmPtlb32					; We was beat... 
+			
+			rlwinm.	r0,r19,0,pfSMPcapb,pfSMPcapb	; Can this processor do SMP?	
+					
+			tlbie	r30							; Invalidate it all corresponding TLB entries
 			
-			beq-	cr1,its603a					/* It's a 603, skip the tlbsync... */
-			
-			eieio								/* Make sure that the tlbie happens first */
-			tlbsync								/* wait for everyone to catch up */
-			isync								
+			beq-	hrmNTlbs					; Jump if we can not do a TLBSYNC....
 			
-its603a:	sync								/* Make sure of it all */
-			stw		r11,0(r12)					/* Clear the tlbie lock */
-			eieio								/* Make sure those RC bit are loaded */
-			stw		r5,PCAallo(r7)				/* Show that the slot is free */
-			stw		r11,mmPTEent(r3)			/* Clear the pointer to the PTE */
+			eieio								; Make sure that the tlbie happens first
+			tlbsync								; Wait for everyone to catch up
+			sync								; Make sure of it all
+			
+hrmNTlbs:	li		r0,0						; Clear this 
+			rlwinm	r2,r21,29,29,31				; Get slot number (8 byte entries)
+			stw		r0,tlbieLock(0)				; Clear the tlbie lock
+			lis		r0,0x8000					; Get bit for slot 0
+			eieio								; Make sure those RC bit have been stashed in PTE
+			
+			srw		r0,r0,r2					; Get the allocation hash mask
+			lwz		r22,4(r26)					; Get the latest reference and change bits
+			or		r6,r6,r0					; Show that this slot is free
+
+hrmUlckPCA32:			
+			eieio								; Make sure all updates come first
+			stw		r6,0(r7)					; Unlock the PTEG
+		
+;
+;			Now, it is time to remove the mapping and unlock the chain.
+;			But first, we need to make sure no one else is using this 
+;			mapping so we drain the busy now
+;			
 
-nopte:		mr.		r10,r10						/* See if there is a physical entry */
-			la		r9,pephyslink(r10)			/* Point to the physical mapping chain */
-			beq-	nophys						/* No physical entry, we're done... */
-			beq-	cr5,nadamrg					/* No PTE to merge... */
+hrmPysDQ32:	mr		r3,r31						; Point to the mapping
+			bl		mapDrainBusy				; Go wait until mapping is unused
 
-			lwz		r6,4(r4)					/* Get the latest reference and change bits */
-			la		r12,pepte1(r10)				/* Point right at the master copy */
-			rlwinm	r6,r6,0,23,24				/* Extract just the RC bits */
+			mr		r3,r28						; Get the pmap to remove from
+			mr		r4,r31						; Point to the mapping
+			bl		EXT(mapRemove)				; Remove the mapping from the list			
 
-mrgrc:		lwarx	r8,0,r12					/* Get the master copy */
-			or		r8,r8,r6					/* Merge in latest RC */
-			stwcx.	r8,0,r12					/* Save it back */
-			bne-	mrgrc						/* If it changed, try again... */
 			
-nadamrg:	li		r11,0						/* Clear this out */
-			lwz		r12,mmnext(r3)				/* Prime with our next */
+			lwz		r4,pmapResidentCnt(r28)		; Get the mapped page count 
+			andi.	r0,r20,lo16(mpSpecial|mpNest)	; Is this nest or special mapping?
+			cmplwi	cr1,r0,0					; Special thingie?
+			la		r3,pmapSXlk(r28)			; Point to the pmap search lock
+			subi	r4,r4,1						; Drop down the mapped page count
+			stw		r4,pmapResidentCnt(r28)		; Set the mapped page count 
+			bl		sxlkUnlock					; Unlock the search list
 
-			sync								; Make sure all is saved
+			bne--	cr1,hrmRetn32				; This one has no real memory associated with it so we are done...
 
-			stw		r11,0(r7)					/* Unlock the hash chain now so we don't
-												   lock out another processor during 
-												   our next little search */		
+			bl		mapPhysFindLock				; Go find and lock the physent
+
+			lwz		r9,ppLink+4(r3)				; Get first mapping
+
+			mr		r4,r22						; Get the RC bits we just got
+			bl		mapPhysMerge				; Go merge the RC bits
 			
-srchpmap:	mr.		r10,r9						/* Save the previous entry */
-			bne+	mapok1						/* No error... */
+			rlwinm	r9,r9,0,0,25				; Clear the flags from the mapping pointer
 			
-			lis		r0,HIGH_ADDR(Choke)			/* We have a kernel choke!!! */
-			ori		r0,r0,LOW_ADDR(Choke)			
-			sc									/* Firmware Heimlich maneuver */
+			cmplw	r9,r31						; Are we the first on the list?
+			bne-	hrmNot1st					; Nope...
 			
-			.align	4
+			li		r9,0						; Get a 0
+			lwz		r4,mpAlias+4(r31)			; Get our new forward pointer
+			stw		r9,mpAlias+4(r31)			; Make sure we are off the chain
+			bl		mapPhyCSet32				; Go set the physent link and preserve flags								
+			
+			b		hrmPhyDQd					; Join up and unlock it all...
 
-mapok1:		lwz		r9,mmnext(r9)				/* Look at the next one */
-			rlwinm	r8,r9,0,27,31				; Save the flags (including the lock)
-			rlwinm	r9,r9,0,0,26				; Clear out the flags from first link
-			cmplw	r9,r3						/* Have we found ourselves? */
-			bne+	srchpmap					/* Nope, get your head together... */
+			.align	5
 			
-			rlwimi	r12,r8,0,27,31				; Insert the lock and flags */
-			stw		r12,mmnext(r10)				/* Remove us from the queue */
+hrmPerm:	li		r8,-4096					; Get the value we need to round down to a page
+			and		r8,r8,r31					; Get back to a page
+			lwz		r8,mbvrswap+4(r8)			; Get last half of virtual to real swap
 			
-			mtmsr	r0							/* Interrupts and translation back on */
-			isync
-#if PERFTIMES && DEBUG
-			mflr	r11
-			li		r3,25
-			bl		EXT(dbgLog2)						; Start of hw_add_map
-			mtlr	r11
-#endif
-			blr									/* Return... */
+			la		r3,pmapSXlk(r28)			; Point to the pmap search lock
+			bl		sxlkUnlock					; Unlock the search list
+			
+			xor		r3,r31,r8					; Flip mapping address to virtual
+			ori		r3,r3,mapRtPerm				; Set permanent mapping error
+			b		hrmErRtn
+			
+hrmBadLock:	li		r3,mapRtBadLk				; Set bad lock
+			b		hrmErRtn
+			
+hrmEndInSight:
+			la		r3,pmapSXlk(r28)			; Point to the pmap search lock
+			bl		sxlkUnlock					; Unlock the search list
+			
+hrmDoneChunk:
+			mr		r3,r31						; Point to the mapping
+			bl		mapDropBusy					; Drop the busy here since we need to come back
+			li		r3,mapRtRemove				; Say we are still removing this
+			b		hrmErRtn
+
+			.align	5
+			
+hrmNotFound:
+			la		r3,pmapSXlk(r28)			; Point to the pmap search lock
+			bl		sxlkUnlock					; Unlock the search list
+			li		r3,0						; Make sure we know we did not find it
 
-			.align	4
+hrmErRtn:	bt++	pf64Bitb,hrmSF1z			; skip if 64-bit (only they take the hint)
 
-nophys:		li		r4,0						/* Make sure this is 0 */
-			sync								/* Make sure that chain is updated */
-			stw		r4,0(r7)					/* Unlock the hash chain */
-			mtmsr	r0							/* Interrupts and translation back on */
+			mtmsr	r17							; Restore enables/translation/etc.
 			isync
-#if PERFTIMES && DEBUG
-			mflr	r11
-			li		r3,25
-			bl		EXT(dbgLog2)						; Start of hw_add_map
-			mtlr	r11
-#endif
-			blr									/* Return... */
+			b		hrmRetnCmn					; Join the common return code...
 
-
-/*
- *			hw_prot(physent, prot) - Change the protection of a physical page
- *
- *			Upon entry, R3 contains a pointer to a physical entry which is locked.
- *			R4 contains the PPC protection bits.
- *
- *			The first thing we do is to slam the new protection into the phys entry.
- *			Then we scan the mappings and process each one.
- *
- *			Acquire the lock on the PTEG hash list for the mapping being processed.
- *
- *			If the current mapping has a PTE entry, we invalidate
- *			it and merge the reference and change information into the phys_entry.
- *
- *			Next, slam the protection bits into the entry and unlock the hash list.
- *
- *			Note that this must be done with both interruptions off and VM off
- *	
- *			  
- */
+hrmSF1z:	mtmsrd	r17							; Restore enables/translation/etc.
+			isync
+			b		hrmRetnCmn					; Join the common return code...
 
 			.align	5
-			.globl	EXT(hw_prot)
 
-LEXT(hw_prot)
-#if PERFTIMES && DEBUG
-			mflr	r11
-			mr		r7,r3
-//			lwz		r5,4(r3)
-			li		r5,0x1111
-			li		r3,26
-			bl		EXT(dbgLog2)				; Start of hw_add_map
-			mr		r3,r7
-			mtlr	r11
-#endif
- 			mfsprg	r9,2						; Get feature flags 
-			mfmsr	r0							/* Save the MSR  */
-			li		r5,pepte1					/* Get displacement to the second word of master pte */
-			rlwinm	r0,r0,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-			rlwinm	r0,r0,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-			rlwinm	r12,r0,0,MSR_EE_BIT+1,MSR_EE_BIT-1	/* Clear interruptions */
-			mtcrf	0x04,r9						; Set the features			
-			rlwinm	r12,r12,0,28,25				/* Clear IR and DR */
-
-			bt		pfNoMSRirb,hpNoMSR			; No MSR...
-
-			mtmsr	r12							; Translation and all off
-			isync								; Toss prefetch
-			b		hpNoMSRx
+hrmNot1st:	mr.		r8,r9						; Remember and test current node
+			beq-	hrmPhyDQd					; Could not find our node, someone must have unmapped us...
+			lwz		r9,mpAlias+4(r9)			; Chain to the next
+			cmplw	r9,r31						; Is this us?
+			bne-	hrmNot1st					; Not us...
+		
+			lwz		r9,mpAlias+4(r9)			; Get our forward pointer
+			stw		r9,mpAlias+4(r8)			; Unchain us
 			
-hpNoMSR:	
-			mr		r10,r0
-			mr		r7,r3
-			li		r0,loadMSR					; Get the MSR setter SC
-			mr		r3,r12						; Get new MSR
-			sc									; Set it
-			mr		r0,r10
-			mr		r3,r7
-hpNoMSRx:
+			nop									; For alignment
+			
+hrmPhyDQd:	bl		mapPhysUnlock				; Unlock the physent chain
 
+hrmRetn32:	rlwinm	r8,r31,0,0,19				; Find start of page
+			mr		r3,r31						; Copy the pointer to the mapping
+			lwz		r8,mbvrswap+4(r8)			; Get last half of virtual to real swap
+			bl		mapDrainBusy				; Go wait until mapping is unused
 
+			xor		r3,r31,r8					; Flip mapping address to virtual
 			
-			lwz		r10,pephyslink(r3)			/* Get the first mapping block */
-			rlwinm	r10,r10,0,0,26				; Clear out the flags from first link
+			mtmsr	r17							; Restore enables/translation/etc.
+			isync
 
-/*
- *			Note that we need to to do the interlocked update here because another processor
- *			can be updating the reference and change bits even though the physical entry
- *			is locked.  All modifications to the PTE portion of the physical entry must be
- *			done via interlocked update.
- */
+hrmRetnCmn:	lwz		r6,FM_ARG0+0x44(r1)			; Get address to save next mapped vaddr
+			lwz		r0,(FM_ALIGN(hrmStackSize)+FM_SIZE+FM_LR_SAVE)(r1)	; Restore the return
+			lwz		r17,FM_ARG0+0x08(r1)		; Restore a register
+			lwz		r18,FM_ARG0+0x0C(r1)		; Restore a register
+			mr.		r6,r6						; Should we pass back the "next" vaddr?
+			lwz		r19,FM_ARG0+0x10(r1)		; Restore a register
+			lwz		r20,FM_ARG0+0x14(r1)		; Restore a register
+			mtlr	r0							; Restore the return
+			
+			rlwinm	r16,r16,0,0,19				; Clean to a page boundary
+			beq		hrmNoNextAdr				; Do not pass back the next vaddr...
+			stw		r15,0(r6)					; Pass back the top of the next vaddr
+			stw		r16,4(r6)					; Pass back the bottom of the next vaddr
+
+hrmNoNextAdr:
+			lwz		r15,FM_ARG0+0x00(r1)		; Restore a register
+			lwz		r16,FM_ARG0+0x04(r1)		; Restore a register
+			lwz		r21,FM_ARG0+0x18(r1)		; Restore a register
+			rlwinm	r3,r3,0,0,31				; Clear top of register if 64-bit
+			lwz		r22,FM_ARG0+0x1C(r1)		; Restore a register
+			lwz		r23,FM_ARG0+0x20(r1)		; Restore a register
+			lwz		r24,FM_ARG0+0x24(r1)		; Restore a register
+			lwz		r25,FM_ARG0+0x28(r1)		; Restore a register
+			lwz		r26,FM_ARG0+0x2C(r1)		; Restore a register
+			lwz		r27,FM_ARG0+0x30(r1)		; Restore a register
+			lwz		r28,FM_ARG0+0x34(r1)		; Restore a register
+			lwz		r29,FM_ARG0+0x38(r1)		; Restore a register
+			lwz		r30,FM_ARG0+0x3C(r1)		; Restore a register
+			lwz		r31,FM_ARG0+0x40(r1)		; Restore a register
+			lwz		r1,0(r1)					; Pop the stack
+			blr									; Leave...
 
-protcng:	lwarx	r8,r5,r3					/* Get the master copy */
-			rlwimi	r8,r4,0,30,31				/* Move in the protection bits */
-			stwcx.	r8,r5,r3					/* Save it back */
-			bne-	protcng						/* If it changed, try again... */
+;
+;			Here is where we come when all is lost.  Somehow, we failed a mapping function
+;			that must work... All hope is gone.  Alas, we die.......
+;
+
+hrmPanic:	lis		r0,hi16(Choke)				; System abend
+			ori		r0,r0,lo16(Choke)			; System abend
+			li		r3,failMapping				; Show that we failed some kind of mapping thing
+			sc
 
 
+;
+;			Invalidate block mappings by invalidating a chunk of autogen PTEs in PTEGs hashed
+;			in the range. Then, if we did not finish, return a code indicating that we need to 
+;			be called again.  Eventually, we will finish and then, we will do a TLBIE for each 
+;			PTEG up to the point where we have cleared it all (64 for 32-bit architecture)
+;
+;			A potential speed up is that we stop the invalidate loop once we have walked through
+;			the hash table once. This really is not worth the trouble because we need to have
+;			mapped 1/2 of physical RAM in an individual block.  Way unlikely.
+;
+;			We should rethink this and see if we think it will be faster to check PTE and
+;			only invalidate the specific PTE rather than all block map PTEs in the PTEG.
+;
 
-protnext:	mr.		r10,r10						/* Are there any more mappings? */
-			beq-	protdone					/* Naw... */
+			.align	5
 			
-			lwz		r7,mmPTEhash(r10)			/* Get pointer to hash list anchor */
-			lwz		r5,mmPTEv(r10)				/* Get the virtual address */
-			rlwinm	r7,r7,0,0,25				/* Round hash list down to PCA boundary */
+hrmBlock32:	
+			lhz		r23,mpSpace(r31)			; Get the address space hash
+			lhz		r25,mpBSize(r31)			; Get the number of pages in block
+			lwz		r9,mpBlkRemCur(r31)			; Get our current remove position
+			ori		r0,r20,mpRIP				; Turn on the remove in progress flag
+			mfsdr1	r29							; Get the hash table base and size
+			rlwinm	r24,r23,maxAdrSpb,32-maxAdrSpb-maxAdrSpb,31-maxAdrSpb	; Get high order of hash
+			lwz		r27,mpVAddr+4(r31)			; Get the base vaddr
+			sub		r4,r25,r9					; Get number of pages left
+			cmplw	cr1,r9,r25					; Have we already hit the end?
+			addi	r10,r9,mapRemChunk			; Point to the start of the next chunk
+			addi	r2,r4,-mapRemChunk			; See if mapRemChunk or more
+			rlwinm	r26,r29,16,7,15				; Get the hash table size
+			srawi	r2,r2,31					; We have -1 if less than mapRemChunk or 0 if equal or more
+			stb		r0,mpFlags+3(r31)			; Save the flags with the mpRIP bit on
+			subi	r4,r4,mapRemChunk-1			; Back off for a running start (will be negative for more than mapRemChunk)
+			cmpwi	cr7,r2,0					; Remember if we have finished
+			slwi	r0,r9,12					; Make cursor into page offset
+			or		r24,r24,r23					; Get full hash
+			and		r4,r4,r2					; If more than a chunk, bring this back to 0
+			rlwinm	r29,r29,0,0,15				; Isolate the hash table base
+			add		r27,r27,r0					; Adjust vaddr to start of current chunk
+			addi	r4,r4,mapRemChunk-1			; Add mapRemChunk-1 to get max(num left,  chunksize)
+			
+			bgt-	cr1,hrmEndInSight			; Someone is already doing the last hunk...
+			
+			la		r3,pmapSXlk(r28)			; Point to the pmap search lock
+			stw		r10,mpBlkRemCur(r31)		; Set next chunk to do (note: this may indicate after end)
+			bl		sxlkUnlock					; Unlock the search list while we are invalidating
+			
+			rlwinm	r8,r27,4+maxAdrSpb,31-maxAdrSpb-3,31-maxAdrSpb	; Isolate the segment
+			rlwinm	r30,r27,26,6,25				; Shift vaddr to PTEG offset (and remember VADDR in R27)
+			xor		r24,r24,r8					; Get the proper VSID
+			rlwinm	r21,r27,26,10,25			; Shift page index to PTEG offset (and remember VADDR in R27)
+			ori		r26,r26,lo16(0xFFC0)		; Stick in the rest of the length
+			rlwinm	r22,r4,6,10,25				; Shift size to PTEG offset
+			rlwinm	r24,r24,6,0,25				; Shift hash to PTEG units
+			add		r22,r22,r30					; Get end address (in PTEG units)
+			
+hrmBInv32:	rlwinm	r23,r30,0,10,25				; Isolate just the page index 
+			xor		r23,r23,r24					; Hash it
+			and		r23,r23,r26					; Wrap it into the table
+			rlwinm	r3,r23,28,4,29				; Change to PCA offset
+			subfic	r3,r3,-4					; Get the PCA entry offset
+			add		r7,r3,r29					; Point to the PCA slot
+			cmplw	cr5,r30,r22					; Check if we reached the end of the range
+			addi	r30,r30,64					; bump to the next vaddr
+								
+			bl		mapLockPteg					; Lock the PTEG
+					
+			rlwinm.	r4,r6,16,0,7				; Position, save, and test block mappings in PCA
+			add		r5,r23,r29					; Point to the PTEG
+			li		r0,0						; Set an invalid PTE value
+			beq+	hrmBNone32					; No block map PTEs in this PTEG...
+			mtcrf	0x80,r4						; Set CRs to select PTE slots
+			mtcrf	0x40,r4						; Set CRs to select PTE slots
 
-			li		r12,1						/* Get the locked value */
+			bf		0,hrmSlot0					; No autogen here
+			stw		r0,0x00(r5)					; Invalidate PTE
 
-protLck1:	lwarx	r11,0,r7					/* Get the PTEG lock */
-			mr.		r11,r11						/* Is it locked? */
-			bne-	protLckw1					/* Yeah... */
-			stwcx.	r12,0,r7					/* Try to take it */
-			bne-	protLck1					/* Someone else was trying, try again... */
-			b		protSXg1					/* All done... */
-			
-			.align	4
+hrmSlot0:	bf		1,hrmSlot1					; No autogen here
+			stw		r0,0x08(r5)					; Invalidate PTE
 
-protLckw1:	mr.		r11,r11						/* Check if it's already held */
-			beq+	protLck1					/* It's clear... */
-			lwz		r11,0(r7)					/* Get lock word again... */
-			b		protLckw1					/* Wait... */
-			
-			.align	4
+hrmSlot1:	bf		2,hrmSlot2					; No autogen here
+			stw		r0,0x10(r5)					; Invalidate PTE
 
-protSXg1:	isync								/* Make sure we haven't used anything yet */
+hrmSlot2:	bf		3,hrmSlot3					; No autogen here
+			stw		r0,0x18(r5)					; Invalidate PTE
 
- 			lwz		r6,mmPTEent(r10)			/* Get the pointer to the PTE now that the lock's set */
+hrmSlot3:	bf		4,hrmSlot4					; No autogen here
+			stw		r0,0x20(r5)					; Invalidate PTE
 
-			rlwinm	r9,r5,1,0,3					/* Move in the segment */
-			lwz		r2,mmPTEr(r10)				; Get the mapping copy of the PTE
-			mr.		r6,r6						/* See if there is a PTE here */
-			rlwinm	r8,r5,31,2,25				/* Line it up */
-			rlwimi	r2,r4,0,30,31				; Move protection bits into the mapping copy
-		
-			beq+	protul						/* There's no PTE to invalidate... */
-			
-			xor		r8,r8,r6					/* Back hash to virt index */
-			rlwimi	r9,r5,22,4,9				/* Move in the API */
-			lis		r12,HIGH_ADDR(EXT(tlb_system_lock))	/* Get the TLBIE lock */
-			rlwinm	r5,r5,0,1,31				/* Clear the valid bit */
-			ori		r12,r12,LOW_ADDR(EXT(tlb_system_lock))	/* Grab up the bottom part */
-			mfspr	r11,pvr						/* Find out what kind of machine we are */
-			rlwimi	r9,r8,6,10,19				/* Create the virtual address */
-			rlwinm	r11,r11,16,16,31			/* Isolate CPU type */
-
-			stw		r5,0(r6)					/* Make the PTE invalid */		
-			cmplwi	cr1,r11,3					/* Is this a 603? */
-			sync								/* Make sure the invalid is stored */
-						
-tlbhangp:	lwarx	r11,0,r12					/* Get the TLBIE lock */
-			rlwinm	r8,r6,29,29,31				/* Get the bit position of entry */
-			mr.		r11,r11						/* Is it locked? */
-			lis		r5,0x8000					/* Start up a bit mask */
-			li		r11,1						/* Get our lock word */
-			bne-	tlbhangp					/* It's locked, go wait... */
-			stwcx.	r11,0,r12					/* Try to get it */
-			bne-	tlbhangp					/* We was beat... */
-			
-			li		r11,0						/* Lock clear value */
+hrmSlot4:	bf		5,hrmSlot5					; No autogen here
+			stw		r0,0x28(r5)					; Invalidate PTE
 
-			tlbie	r9							/* Invalidate it everywhere */
+hrmSlot5:	bf		6,hrmSlot6					; No autogen here
+			stw		r0,0x30(r5)					; Invalidate PTE
 
-			beq-	cr1,its603p					/* It's a 603, skip the tlbsync... */
-			
-			eieio								/* Make sure that the tlbie happens first */
-			tlbsync								/* wait for everyone to catch up */
-			isync								
-			
-its603p:	stw		r11,0(r12)					/* Clear the lock */
-			srw		r5,r5,r8					/* Make a "free slot" mask */
-			sync								/* Make sure of it all */
+hrmSlot6:	bf		7,hrmSlot7					; No autogen here
+			stw		r0,0x38(r5)					; Invalidate PTE
 
-			lwz		r6,4(r6)					/* Get the latest reference and change bits */
-			stw		r11,mmPTEent(r10)			/* Clear the pointer to the PTE */
-			rlwinm	r6,r6,0,23,24				/* Extract the RC bits */
-			lwz		r9,PCAallo(r7)				/* Get the allocation control bits */
-			rlwinm	r8,r5,24,8,15				/* Make the autogen bit to turn off */
-			rlwimi	r2,r6,0,23,24				; Put the latest RC bit in mapping copy
-			or		r9,r9,r5					/* Set the slot free */
-			rlwimi	r8,r8,24,16,23				/* Get lock bit mask to turn it off */
-			andc	r9,r9,r8					/* Clear the auto and lock bits */
-			li		r5,pepte1					/* Get displacement to the second word of master pte */
-			stw		r9,PCAallo(r7)				/* Store the allocation controls */
-			
-protmod:	lwarx	r11,r5,r3					/* Get the master copy */
-			or		r11,r11,r6					/* Merge in latest RC */
-			stwcx.	r11,r5,r3					/* Save it back */
-			bne-	protmod						/* If it changed, try again... */
-			
-protul:		li		r4,0						/* Get a 0 */
-			stw		r2,mmPTEr(r10)				; Save the updated mapping PTE
-			lwz		r10,mmnext(r10)				/* Get the next */
+hrmSlot7:	rlwinm	r0,r4,16,16,23				; Move in use to autogen
+			or		r6,r6,r4					; Flip on the free bits that corrospond to the autogens we cleared
+			andc	r6,r6,r0					; Turn off all the old autogen bits
 
-			sync								; Make sure stores are complete
+hrmBNone32:	eieio								; Make sure all updates come first
 
-			stw		r4,0(r7)					/* Unlock the hash chain */
-			b		protnext					/* Go get the next one */
+			stw		r6,0(r7)					; Unlock and set the PCA
 			
-			.align	4
+			bne+	cr5,hrmBInv32				; Go invalidate the next...
 
-protdone:	mtmsr	r0							/* Interrupts and translation back on */
-			isync
-#if PERFTIMES && DEBUG
-			mflr	r11
-			li		r3,27
-			bl		EXT(dbgLog2)				; Start of hw_add_map
-			mtlr	r11
-#endif
-			blr									/* Return... */
+			bge+	cr7,hrmDoneChunk			; We have not as yet done the last chunk, go tell our caller to call again...
 
+			mr		r3,r31						; Copy the pointer to the mapping
+			bl		mapDrainBusy				; Go wait until we are sure all other removers are done with this one
 
-/*
- *			hw_prot_virt(mapping, prot) - Change the protection of single page
- *
- *			Upon entry, R3 contains a pointer (real) to a mapping.
- *			R4 contains the PPC protection bits.
- *
- *			Acquire the lock on the PTEG hash list for the mapping being processed.
- *
- *			If the current mapping has a PTE entry, we invalidate
- *			it and merge the reference and change information into the phys_entry.
- *
- *			Next, slam the protection bits into the entry, merge the RC bits, 
- *			and unlock the hash list.
- *
- *			Note that this must be done with both interruptions off and VM off
- *	
- *			  
- */
+			sync								; Make sure memory is consistent
+			
+			subi	r5,r25,63					; Subtract TLB size from page count (note we are 0 based here)
+			li		r6,63						; Assume full invalidate for now
+			srawi	r5,r5,31					; Make 0 if we need a full purge, -1 otherwise
+			andc	r6,r6,r5					; Clear max if we have less to do
+			and		r5,r25,r5					; Clear count if we have more than max
+			lwz		r27,mpVAddr+4(r31)			; Get the base vaddr again
+			li		r7,tlbieLock				; Get the TLBIE lock
+			or		r5,r5,r6					; Get number of TLBIEs needed		
+					
+hrmBTLBlck:	lwarx	r2,0,r7						; Get the TLBIE lock
+			mr.		r2,r2						; Is it locked?
+			li		r2,1						; Get our lock value
+			bne-	hrmBTLBlck					; It is locked, go wait...
+			stwcx.	r2,0,r7						; Try to get it
+			bne-	hrmBTLBlck					; We was beat...
+	
+hrmBTLBi:	addic.	r5,r5,-1					; See if we did them all
+			tlbie	r27							; Invalidate it everywhere
+			addi	r27,r27,0x1000				; Up to the next page
+			bge+	hrmBTLBi					; Make sure we have done it all...
+			
+			rlwinm.	r0,r19,0,pfSMPcapb,pfSMPcapb	; Can this processor do SMP?	
+			li		r2,0						; Lock clear value
+			
+			sync								; Make sure all is quiet
+			beq-	hrmBNTlbs					; Jump if we can not do a TLBSYNC....
+			
+			eieio								; Make sure that the tlbie happens first
+			tlbsync								; Wait for everyone to catch up
+			sync								; Wait for quiet again
+
+hrmBNTlbs:	stw		r2,tlbieLock(0)				; Clear the tlbie lock
+			
+			la		r3,pmapSXlk(r28)			; Point to the pmap search lock
+			bl		sxlkShared					; Go get a shared lock on the mapping lists
+			mr.		r3,r3						; Did we get the lock?
+			bne-	hrmPanic					; Nope...
+			
+			lwz		r4,mpVAddr(r31)				; High order of address
+			lwz		r5,mpVAddr+4(r31)			; Low order of address
+			mr		r3,r28						; Pass in pmap to search
+			mr		r29,r4						; Save this in case we need it (only promote fails)
+			mr		r30,r5						; Save this in case we need it (only promote fails)
+			bl		EXT(mapSearchFull)			; Go see if we can find it
+			
+			mr.		r3,r3						; Did we? (And remember mapping address for later)
+			mr		r15,r4						; Save top of next vaddr
+			mr		r16,r5						; Save bottom of next vaddr
+			beq-	hrmPanic					; Nope, not found...
+			
+			cmplw	r3,r31						; Same mapping?
+			bne-	hrmPanic					; Not good...
+			
+			la		r3,pmapSXlk(r28)			; Point to the pmap search lock
+			bl		sxlkPromote					; Try to promote shared to exclusive
+			mr.		r3,r3						; Could we?
+			mr		r3,r31						; Restore the mapping pointer
+			beq+	hrmBDone1					; Yeah...
+			
+			la		r3,pmapSXlk(r28)			; Point to the pmap search lock
+			bl		sxlkConvert					; Convert shared to exclusive
+			mr.		r3,r3						; Could we?
+			bne--	hrmPanic					; Nope, we must have timed out...
+			
+			mr		r3,r28						; Pass in pmap to search
+			mr		r4,r29						; High order of address
+			mr		r5,r30						; Low order of address
+			bl		EXT(mapSearchFull)			; Rescan the list
+			
+			mr.		r3,r3						; Did we lose it when we converted?
+			mr		r15,r4						; Save top of next vaddr
+			mr		r16,r5						; Save bottom of next vaddr
+			beq--	hrmPanic					; Yeah, we did, someone tossed it for us...
+
+hrmBDone1:	bl		mapDrainBusy				; Go wait until mapping is unused
+
+			mr		r3,r28						; Get the pmap to remove from
+			mr		r4,r31						; Point to the mapping
+			bl		EXT(mapRemove)				; Remove the mapping from the list	
+					
+			lwz		r4,pmapResidentCnt(r28)		; Get the mapped page count 
+			la		r3,pmapSXlk(r28)			; Point to the pmap search lock
+			subi	r4,r4,1						; Drop down the mapped page count
+			stw		r4,pmapResidentCnt(r28)		; Set the mapped page count 
+			bl		sxlkUnlock					; Unlock the search list
+		
+			b		hrmRetn32					; We are all done, get out...
 
+;
+;			Here we handle the 64-bit version of hw_rem_map
+;
+		
 			.align	5
-			.globl	EXT(hw_prot_virt)
-
-LEXT(hw_prot_virt)
-#if PERFTIMES && DEBUG
-			mflr	r11
-			mr		r7,r3
-//			lwz		r5,4(r3)
-			li		r5,0x1111
-			li		r3,40
-			bl		EXT(dbgLog2)						; Start of hw_add_map
-			mr		r3,r7
-			mtlr	r11
-#endif
- 			mfsprg	r9,2						; Get feature flags 
-			mfmsr	r0							/* Save the MSR  */
-			rlwinm	r0,r0,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-			rlwinm	r0,r0,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-			rlwinm	r12,r0,0,MSR_EE_BIT+1,MSR_EE_BIT-1	/* Clear interruptions */
-			mtcrf	0x04,r9						; Set the features			
-			rlwinm	r12,r12,0,28,25				/* Clear IR and DR */
+		
+hrmSplit64:	rlwinm	r9,r21,27,5,29				; Convert PTEG to PCA entry
+			bne--	cr5,hrmBlock64				; Go treat block specially...
+			subfic	r9,r9,-4					; Get the PCA entry offset
+			bt--	cr0_eq,hrmPysDQ64			; Skip next if no possible PTE...
+			add		r7,r9,r29					; Point to the PCA slot
+			
+			bl		mapLockPteg					; Go lock up the PTEG
+	
+			lwz		r21,mpPte(r31)				; Get the quick pointer again
+			ld		r5,0(r26)					; Get the top of PTE
+			
+			rlwinm.	r0,r21,0,mpHValidb,mpHValidb	; See if we actually have a PTE
+			rlwinm	r21,r21,0,0,30				; Clear out valid bit
+			sldi	r23,r5,16					; Shift AVPN up to EA format
+			rldicr	r5,r5,0,62					; Clear the valid bit
+			rldimi	r23,r30,0,36				; Insert the page portion of the VPN
+			stw		r21,mpPte(r31)				; Make sure we invalidate mpPte but keep pointing to PTEG (keep walk_page from making a mistake)
+			beq--	hrmUlckPCA64				; Pte is gone, no need to invalidate...
+			
+			std		r5,0(r26)					; Invalidate the PTE
+
+			li		r9,tlbieLock				; Get the TLBIE lock
+
+			sync								; Make sure the invalid PTE is actually in memory
+
+hrmPtlb64:	lwarx	r5,0,r9						; Get the TLBIE lock 
+			rldicl	r23,r23,0,16				; Clear bits 0:15 cause they say to
+			mr.		r5,r5						; Is it locked?
+			li		r5,1						; Get locked indicator
+			bne--	hrmPtlb64w					; It is locked, go spin...
+			stwcx.	r5,0,r9						; Try to get it
+			bne--	hrmPtlb64					; We was beat... 
+					
+			tlbie	r23							; Invalidate it all corresponding TLB entries
+			
+			eieio								; Make sure that the tlbie happens first
+			tlbsync								; Wait for everyone to catch up
+			isync								
 			
-			bt		pfNoMSRirb,hpvNoMSR			; No MSR...
+			ptesync								; Make sure of it all
+			li		r0,0						; Clear this 
+			rlwinm	r2,r21,28,29,31				; Get slot number (16 byte entries)
+			stw		r0,tlbieLock(0)				; Clear the tlbie lock
+			oris	r0,r0,0x8000				; Assume slot 0
+			eieio								; Make sure those RC bit have been stashed in PTE
+			srw		r0,r0,r2					; Get slot mask to deallocate
 
-			mtmsr	r12							; Translation and all off
-			isync								; Toss prefetch
-			b		hpvNoMSRx
+			lwz		r22,12(r26)					; Get the latest reference and change bits
+			or		r6,r6,r0					; Make the guy we killed free
 			
-hpvNoMSR:	
-			mr		r5,r0
-			mr		r7,r3
-			li		r0,loadMSR					; Get the MSR setter SC
-			mr		r3,r12						; Get new MSR
-			sc									; Set it
-			mr		r3,r7
-			mr		r0,r5
-hpvNoMSRx:
+hrmUlckPCA64:
+			eieio								; Make sure all updates come first
+
+			stw		r6,0(r7)					; Unlock and change the PCA
+		
+hrmPysDQ64:	mr		r3,r31						; Point to the mapping
+			bl		mapDrainBusy				; Go wait until mapping is unused
+
+			mr		r3,r28						; Get the pmap to insert into
+			mr		r4,r31						; Point to the mapping
+			bl		EXT(mapRemove)				; Remove the mapping from the list			
+
+			andi.	r0,r20,lo16(mpSpecial|mpNest)	; Is this nest or special mapping?
+			lwz		r4,pmapResidentCnt(r28)		; Get the mapped page count 
+			cmplwi	cr1,r0,0					; Special thingie?
+			la		r3,pmapSXlk(r28)			; Point to the pmap search lock
+			subi	r4,r4,1						; Drop down the mapped page count
+			stw		r4,pmapResidentCnt(r28)		; Set the mapped page count 
+			bl		sxlkUnlock					; Unlock the search list
+		
+			bne--	cr1,hrmRetn64				; This one has no real memory associated with it so we are done...
 
+			bl		mapPhysFindLock				; Go find and lock the physent
 
+			li		r0,0xFF						; Get mask to clean up mapping pointer
+			ld		r9,ppLink(r3)				; Get first mapping
+			rldicl	r0,r0,62,0					; Rotate clean up mask to get 0xC0000000000000003F
+			mr		r4,r22						; Get the RC bits we just got
 			
-/*
- *			Note that we need to to do the interlocked update here because another processor
- *			can be updating the reference and change bits even though the physical entry
- *			is locked.  All modifications to the PTE portion of the physical entry must be
- *			done via interlocked update.
- */
+			bl		mapPhysMerge				; Go merge the RC bits
 			
-			lwz		r7,mmPTEhash(r3)			/* Get pointer to hash list anchor */
-			lwz		r5,mmPTEv(r3)				/* Get the virtual address */
-			rlwinm	r7,r7,0,0,25				/* Round hash list down to PCA boundary */
-
-			li		r12,1						/* Get the locked value */
-
-protvLck1:	lwarx	r11,0,r7					/* Get the PTEG lock */
-			mr.		r11,r11						/* Is it locked? */
-			bne-	protvLckw1					/* Yeah... */
-			stwcx.	r12,0,r7					/* Try to take it */
-			bne-	protvLck1					/* Someone else was trying, try again... */
-			b		protvSXg1					/* All done... */
+			andc	r9,r9,r0					; Clean up the mapping pointer
 			
-			.align	4
-
-protvLckw1:	mr.		r11,r11						/* Check if it's already held */
-			beq+	protvLck1					/* It's clear... */
-			lwz		r11,0(r7)					/* Get lock word again... */
-			b		protvLckw1					/* Wait... */
+			cmpld	r9,r31						; Are we the first on the list?
+			bne-	hrmNot1st64					; Nope...
 			
-			.align	4
-
-protvSXg1:	isync								/* Make sure we haven't used anything yet */
-
- 			lwz		r6,mmPTEent(r3)				/* Get the pointer to the PTE now that the lock's set */
- 			lwz		r2,mmPTEr(r3)				; Get the mapping copy if the real part
+			li		r9,0						; Get a 0
+			ld		r4,mpAlias(r31)				; Get our forward pointer
+			
+			std		r9,mpAlias(r31)				; Make sure we are off the chain
+			bl		mapPhyCSet64				; Go set the physent link and preserve flags								
 
-			rlwinm	r9,r5,1,0,3					/* Move in the segment */
-			cmplwi	cr7,r6,0					; Any PTE to invalidate?
-			rlwimi	r2,r4,0,30,31				; Move in the new protection bits
-			rlwinm	r8,r5,31,2,25				/* Line it up */
-		
-			beq+	cr7,pvnophys				/* There's no PTE to invalidate... */
-			
-			xor		r8,r8,r6					/* Back hash to virt index */
-			rlwimi	r9,r5,22,4,9				/* Move in the API */
-			lis		r12,HIGH_ADDR(EXT(tlb_system_lock))	/* Get the TLBIE lock */
-			rlwinm	r5,r5,0,1,31				/* Clear the valid bit */
-			ori		r12,r12,LOW_ADDR(EXT(tlb_system_lock))	/* Grab up the bottom part */
-			mfspr	r11,pvr						/* Find out what kind of machine we are */
-			rlwimi	r9,r8,6,10,19				/* Create the virtual address */
-			rlwinm	r11,r11,16,16,31			/* Isolate CPU type */
-
-			stw		r5,0(r6)					/* Make the PTE invalid */		
-			cmplwi	cr1,r11,3					/* Is this a 603? */
-			sync								/* Make sure the invalid is stored */
+			b		hrmPhyDQd64					; Join up and unlock it all...
+			
+hrmPtlb64w:	li		r5,lgKillResv				; Point to some spare memory
+			stwcx.	r5,0,r5						; Clear the pending reservation			
 						
-tlbhangpv:	lwarx	r11,0,r12					/* Get the TLBIE lock */
-			rlwinm	r8,r6,29,29,31				/* Get the bit position of entry */
-			mr.		r11,r11						/* Is it locked? */
-			lis		r5,0x8000					/* Start up a bit mask */
-			li		r11,1						/* Get our lock word */
-			bne-	tlbhangpv					/* It's locked, go wait... */
-			stwcx.	r11,0,r12					/* Try to get it */
-			bne-	tlbhangpv					/* We was beat... */
 			
-			li		r11,0						/* Lock clear value */
+hrmPtlb64x:	lwz		r5,0(r9)					; Do a regular load to avoid taking reservation
+			mr.		r5,r5						; is it locked?
+			beq++	hrmPtlb64					; Nope...
+			b		hrmPtlb64x					; Sniff some more...
+		
+			.align	5							
+			
+hrmNot1st64:
+			mr.		r8,r9						; Remember and test current node
+			beq-	hrmNotFound					; Could not find our node...
+			ld		r9,mpAlias(r9)				; Chain to the next
+			cmpld	r9,r31						; Is this us?
+			bne-	hrmNot1st64					; Not us...
+		
+			ld		r9,mpAlias(r9)				; Get our forward pointer
+			std		r9,mpAlias(r8)				; Unchain us
+			
+			nop									; For alignment
+			
+hrmPhyDQd64:	
+			bl		mapPhysUnlock				; Unlock the physent chain
 
-			tlbie	r9							/* Invalidate it everywhere */
+hrmRetn64:	rldicr	r8,r31,0,51					; Find start of page
+			mr		r3,r31						; Copy the pointer to the mapping
+			lwz		r8,mbvrswap+4(r8)			; Get last half of virtual to real swap
+			bl		mapDrainBusy				; Go wait until mapping is unused
 
-			beq-	cr1,its603pv				/* It's a 603, skip the tlbsync... */
+			xor		r3,r31,r8					; Flip mapping address to virtual
 			
-			eieio								/* Make sure that the tlbie happens first */
-			tlbsync								/* wait for everyone to catch up */
-			isync								
-			
-its603pv:	stw		r11,0(r12)					/* Clear the lock */
-			srw		r5,r5,r8					/* Make a "free slot" mask */
-			sync								/* Make sure of it all */
-
-			lwz		r6,4(r6)					/* Get the latest reference and change bits */
-			stw		r11,mmPTEent(r3)			/* Clear the pointer to the PTE */
-			rlwinm	r6,r6,0,23,24				/* Extract the RC bits */
-			lwz		r9,PCAallo(r7)				/* Get the allocation control bits */
-			rlwinm	r8,r5,24,8,15				/* Make the autogen bit to turn off */
-			lwz		r10,mmphysent(r3)			; Get any physical entry
-			or		r9,r9,r5					/* Set the slot free */
-			rlwimi	r8,r8,24,16,23				/* Get lock bit mask to turn it off */
-			andc	r9,r9,r8					/* Clear the auto and lock bits */
-			mr.		r10,r10						; Is there a physical entry?
-			li		r5,pepte1					/* Get displacement to the second word of master pte */
-			stw		r9,PCAallo(r7)				/* Store the allocation controls */
-			rlwimi	r2,r6,0,23,24				; Stick in RC bits
-			beq-	pvnophys					; No physical entry...
-			
-protvmod:	lwarx	r11,r5,r10					/* Get the master copy */
-			or		r11,r11,r6					/* Merge in latest RC */
-			stwcx.	r11,r5,r10					/* Save it back */
-			bne-	protvmod					/* If it changed, try again... */
-			
-pvnophys:	li		r4,0						/* Get a 0 */
-			stw		r2,mmPTEr(r3)				; Set the real part of the PTE
-
-			sync								; Make sure everything is stored
-
-			stw		r4,0(r7)					/* Unlock the hash chain */
-			mtmsr	r0							; Restore interrupts and translation
+			mtmsrd	r17							; Restore enables/translation/etc.
 			isync
+			
+			b		hrmRetnCmn					; Join the common return path...
 
-#if PERFTIMES && DEBUG
-			mflr	r11
-			li		r3,41
-			bl		EXT(dbgLog2)				
-			mtlr	r11
-#endif
-			blr									/* Return... */
 
-
-/*
- *			hw_attr_virt(mapping, attr) - Change the attributes of single page
- *
- *			Upon entry, R3 contains a pointer (real) to a mapping.
- *			R4 contains the WIMG bits.
- *
- *			Acquire the lock on the PTEG hash list for the mapping being processed.
- *
- *			If the current mapping has a PTE entry, we invalidate
- *			it and merge the reference and change information into the phys_entry.
- *
- *			Next, slam the WIMG bits into the entry, merge the RC bits, 
- *			and unlock the hash list.
- *
- *			Note that this must be done with both interruptions off and VM off
- *	
- *			  
- */
+;
+;			Check hrmBlock32 for comments.
+;
 
 			.align	5
-			.globl	EXT(hw_attr_virt)
+			
+hrmBlock64:				
+			lhz		r24,mpSpace(r31)			; Get the address space hash
+			lhz		r25,mpBSize(r31)			; Get the number of pages in block
+			lwz		r9,mpBlkRemCur(r31)			; Get our current remove position
+			ori		r0,r20,mpRIP				; Turn on the remove in progress flag
+			mfsdr1	r29							; Get the hash table base and size
+			ld		r27,mpVAddr(r31)			; Get the base vaddr
+			rlwinm	r5,r29,0,27,31				; Isolate the size
+			sub		r4,r25,r9					; Get number of pages left
+			cmplw	cr1,r9,r25					; Have we already hit the end?
+			addi	r10,r9,mapRemChunk			; Point to the start of the next chunk
+			addi	r2,r4,-mapRemChunk			; See if mapRemChunk or more
+			stb		r0,mpFlags+3(r31)			; Save the flags with the mpRIP bit on
+			srawi	r2,r2,31					; We have -1 if less than mapRemChunk or 0 if equal or more
+			subi	r4,r4,mapRemChunk-1			; Back off for a running start (will be negative for more than mapRemChunk)
+			cmpwi	cr7,r2,0					; Remember if we are doing the last chunk
+			and		r4,r4,r2					; If more than a chunk, bring this back to 0
+			srdi	r27,r27,12					; Change address into page index
+			addi	r4,r4,mapRemChunk-1			; Add mapRemChunk-1 to get max(num left,  chunksize)
+			add		r27,r27,r9					; Adjust vaddr to start of current chunk
+			
+			bgt--	cr1,hrmEndInSight			; Someone is already doing the last hunk...
+			
+			la		r3,pmapSXlk(r28)			; Point to the pmap search lock
+			stw		r10,mpBlkRemCur(r31)		; Set next chunk to do (note: this may indicate after end)
+			bl		sxlkUnlock					; Unlock the search list while we are invalidating
+			
+			rlwimi	r24,r24,14,4,17				; Insert a copy of space hash
+			eqv		r26,r26,r26					; Get all foxes here
+			rldimi	r24,r24,28,8				; Make a couple copies up higher
+			rldicr	r29,r29,0,47				; Isolate just the hash table base
+			subfic	r5,r5,46					; Get number of leading zeros
+			srd		r26,r26,r5					; Shift the size bits over		
+			mr		r30,r27						; Get start of chunk to invalidate
+			rldicr	r26,r26,0,56				; Make length in PTEG units
+			add		r22,r4,r30					; Get end page number
+									
+hrmBInv64:	srdi	r0,r30,2					; Shift page index over to form ESID
+			rldicr	r0,r0,0,49					; Clean all but segment portion
+			rlwinm	r2,r30,0,16,31				; Get the current page index
+			xor		r0,r0,r24					; Form VSID
+			xor		r8,r2,r0					; Hash the vaddr
+			sldi	r8,r8,7						; Make into PTEG offset
+			and		r23,r8,r26					; Wrap into the hash table
+			rlwinm	r3,r23,27,5,29				; Change to PCA offset (table is always 2GB or less so 32-bit instructions work here)
+			subfic	r3,r3,-4					; Get the PCA entry offset
+			add		r7,r3,r29					; Point to the PCA slot
+			
+			cmplw	cr5,r30,r22					; Have we reached the end of the range?
+								
+			bl		mapLockPteg					; Lock the PTEG
+						
+			rlwinm.	r4,r6,16,0,7				; Extract the block mappings in this here PTEG and see if there are any
+			add		r5,r23,r29					; Point to the PTEG
+			li		r0,0						; Set an invalid PTE value
+			beq++	hrmBNone64					; No block map PTEs in this PTEG...
+			mtcrf	0x80,r4						; Set CRs to select PTE slots
+			mtcrf	0x40,r4						; Set CRs to select PTE slots
 
-LEXT(hw_attr_virt)
-#if PERFTIMES && DEBUG
-			mflr	r11
-			mr		r7,r3
-//			lwz		r5,4(r3)
-			li		r5,0x1111
-			li		r3,40
-			bl		EXT(dbgLog2)						; Start of hw_add_map
-			mr		r3,r7
-			mtlr	r11
-#endif
-			mfsprg	r9,2						; Get feature flags 
- 			mfmsr	r0							/* Save the MSR  */
-			rlwinm	r0,r0,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-			rlwinm	r0,r0,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-			mtcrf	0x04,r9						; Set the features			
-			rlwinm	r12,r0,0,MSR_EE_BIT+1,MSR_EE_BIT-1	/* Clear interruptions */
-			rlwinm	r12,r12,0,28,25				/* Clear IR and DR */
 
-			bt		pfNoMSRirb,havNoMSR			; No MSR...
+			bf		0,hrmSlot0s					; No autogen here
+			std		r0,0x00(r5)					; Invalidate PTE
 
-			mtmsr	r12							; Translation and all off
-			isync								; Toss prefetch
-			b		havNoMSRx
-			
-havNoMSR:	
-			mr		r5,r0
-			mr		r7,r3
-			li		r0,loadMSR					; Get the MSR setter SC
-			mr		r3,r12						; Get new MSR
-			sc									; Set it
-			mr		r3,r7
-			mr		r0,r5
-havNoMSRx:
+hrmSlot0s:	bf		1,hrmSlot1s					; No autogen here
+			std		r0,0x10(r5)					; Invalidate PTE
 
-/*
- *			Note that we need to to do the interlocked update here because another processor
- *			can be updating the reference and change bits even though the physical entry
- *			is locked.  All modifications to the PTE portion of the physical entry must be
- *			done via interlocked update.
- */
-			
-			lwz		r7,mmPTEhash(r3)			/* Get pointer to hash list anchor */
-			lwz		r5,mmPTEv(r3)				/* Get the virtual address */
-			rlwinm	r7,r7,0,0,25				/* Round hash list down to PCA boundary */
+hrmSlot1s:	bf		2,hrmSlot2s					; No autogen here
+			std		r0,0x20(r5)					; Invalidate PTE
 
-			li		r12,1						/* Get the locked value */
+hrmSlot2s:	bf		3,hrmSlot3s					; No autogen here
+			std		r0,0x30(r5)					; Invalidate PTE
 
-attrvLck1:	lwarx	r11,0,r7					/* Get the PTEG lock */
-			mr.		r11,r11						/* Is it locked? */
-			bne-	attrvLckw1					/* Yeah... */
-			stwcx.	r12,0,r7					/* Try to take it */
-			bne-	attrvLck1					/* Someone else was trying, try again... */
-			b		attrvSXg1					/* All done... */
-			
-			.align	4
+hrmSlot3s:	bf		4,hrmSlot4s					; No autogen here
+			std		r0,0x40(r5)					; Invalidate PTE
 
-attrvLckw1:	mr.		r11,r11						/* Check if it's already held */
-			beq+	attrvLck1					/* It's clear... */
-			lwz		r11,0(r7)					/* Get lock word again... */
-			b		attrvLckw1					/* Wait... */
-			
-			.align	4
+hrmSlot4s:	bf		5,hrmSlot5s					; No autogen here
+			std		r0,0x50(r5)					; Invalidate PTE
 
-attrvSXg1:	isync								/* Make sure we haven't used anything yet */
+hrmSlot5s:	bf		6,hrmSlot6s					; No autogen here
+			std		r0,0x60(r5)					; Invalidate PTE
 
- 			lwz		r6,mmPTEent(r3)				/* Get the pointer to the PTE now that the lock's set */
- 			lwz		r2,mmPTEr(r3)				; Get the mapping copy if the real part
+hrmSlot6s:	bf		7,hrmSlot7s					; No autogen here
+			std		r0,0x70(r5)					; Invalidate PTE
 
-			rlwinm	r9,r5,1,0,3					/* Move in the segment */
-			mr.		r6,r6						/* See if there is a PTE here */
-			rlwimi	r2,r4,0,25,28				; Move in the new attribute bits
-			rlwinm	r8,r5,31,2,25				/* Line it up and check if empty */
-		
-			beq+	avnophys					/* There's no PTE to invalidate... */
-			
-			xor		r8,r8,r6					/* Back hash to virt index */
-			rlwimi	r9,r5,22,4,9				/* Move in the API */
-			lis		r12,HIGH_ADDR(EXT(tlb_system_lock))	/* Get the TLBIE lock */
-			rlwinm	r5,r5,0,1,31				/* Clear the valid bit */
-			ori		r12,r12,LOW_ADDR(EXT(tlb_system_lock))	/* Grab up the bottom part */
-			mfspr	r11,pvr						/* Find out what kind of machine we are */
-			rlwimi	r9,r8,6,10,19				/* Create the virtual address */
-			rlwinm	r11,r11,16,16,31			/* Isolate CPU type */
-			stw		r5,0(r6)					/* Make the PTE invalid */		
-			cmplwi	cr1,r11,3					/* Is this a 603? */
-			sync								/* Make sure the invalid is stored */
-						
-tlbhangav:	lwarx	r11,0,r12					/* Get the TLBIE lock */
-			rlwinm	r8,r6,29,29,31				/* Get the bit position of entry */
-			mr.		r11,r11						/* Is it locked? */
-			lis		r5,0x8000					/* Start up a bit mask */
-			li		r11,1						/* Get our lock word */
-			bne-	tlbhangav					/* It's locked, go wait... */
-			stwcx.	r11,0,r12					/* Try to get it */
-			bne-	tlbhangav					/* We was beat... */
+hrmSlot7s:	rlwinm	r0,r4,16,16,23				; Move in use to autogen
+			or		r6,r6,r4					; Flip on the free bits that corrospond to the autogens we cleared
+			andc	r6,r6,r0					; Turn off all the old autogen bits
+
+hrmBNone64:	eieio								; Make sure all updates come first
+			stw		r6,0(r7)					; Unlock and set the PCA
+
+			addi	r30,r30,1					; bump to the next PTEG
+			bne++	cr5,hrmBInv64				; Go invalidate the next...
+
+			bge+	cr7,hrmDoneChunk			; We have not as yet done the last chunk, go tell our caller to call again...
+
+			mr		r3,r31						; Copy the pointer to the mapping
+			bl		mapDrainBusy				; Go wait until we are sure all other removers are done with this one
+
+			sync								; Make sure memory is consistent
+
+			subi	r5,r25,255					; Subtract TLB size from page count (note we are 0 based here)
+			li		r6,255						; Assume full invalidate for now
+			srawi	r5,r5,31					; Make 0 if we need a full purge, -1 otherwise
+			andc	r6,r6,r5					; Clear max if we have less to do
+			and		r5,r25,r5					; Clear count if we have more than max
+			sldi	r24,r24,28					; Get the full XOR value over to segment position
+			ld		r27,mpVAddr(r31)			; Get the base vaddr
+			li		r7,tlbieLock				; Get the TLBIE lock
+			or		r5,r5,r6					; Get number of TLBIEs needed		
 			
-			li		r11,0						/* Lock clear value */
+hrmBTLBlcl:	lwarx	r2,0,r7						; Get the TLBIE lock
+			mr.		r2,r2						; Is it locked?
+			li		r2,1						; Get our lock value
+			bne--	hrmBTLBlcm					; It is locked, go wait...
+			stwcx.	r2,0,r7						; Try to get it
+			bne--	hrmBTLBlcl					; We was beat...
+	
+hrmBTLBj:	sldi	r2,r27,maxAdrSpb			; Move to make room for address space ID
+			rldicr	r2,r2,0,35-maxAdrSpb		; Clear out the extra
+			addic.	r5,r5,-1					; See if we did them all
+			xor		r2,r2,r24					; Make the VSID
+			rldimi	r2,r27,0,36					; Insert the page portion of the VPN
+			rldicl	r2,r2,0,16					; Clear bits 0:15 cause they say we gotta
 
-			tlbie	r9							/* Invalidate it everywhere */
+			tlbie	r2							; Invalidate it everywhere
+			addi	r27,r27,0x1000				; Up to the next page
+			bge++	hrmBTLBj					; Make sure we have done it all...
 
-			beq-	cr1,its603av				/* It's a 603, skip the tlbsync... */
+			sync								; Make sure all is quiet
 			
-			eieio								/* Make sure that the tlbie happens first */
-			tlbsync								/* wait for everyone to catch up */
+			eieio								; Make sure that the tlbie happens first
+			tlbsync								; wait for everyone to catch up
 			isync								
-			
-its603av:	stw		r11,0(r12)					/* Clear the lock */
-			srw		r5,r5,r8					/* Make a "free slot" mask */
-			sync								/* Make sure of it all */
-
-			lwz		r6,4(r6)					/* Get the latest reference and change bits */
-			stw		r11,mmPTEent(r3)			/* Clear the pointer to the PTE */
-			rlwinm	r6,r6,0,23,24				/* Extract the RC bits */
-			lwz		r9,PCAallo(r7)				/* Get the allocation control bits */
-			rlwinm	r8,r5,24,8,15				/* Make the autogen bit to turn off */
-			lwz		r10,mmphysent(r3)			; Get any physical entry
-			or		r9,r9,r5					/* Set the slot free */
-			rlwimi	r8,r8,24,16,23				/* Get lock bit mask to turn it off */
-			andc	r9,r9,r8					/* Clear the auto and lock bits */
-			mr.		r10,r10						; Is there a physical entry?
-			li		r5,pepte1					/* Get displacement to the second word of master pte */
-			stw		r9,PCAallo(r7)				/* Store the allocation controls */
-			rlwimi	r2,r6,0,23,24				; Stick in RC bits
-			beq-	avnophys					; No physical entry...			
-			
-attrvmod:	lwarx	r11,r5,r10					/* Get the master copy */
-			or		r11,r11,r6					/* Merge in latest RC */
-			stwcx.	r11,r5,r10					/* Save it back */
-			bne-	attrvmod					/* If it changed, try again... */
-			
-avnophys:	li		r4,0						/* Get a 0 */
-			stw		r2,mmPTEr(r3)				; Set the real part of the PTE
-
-			sync								; Make sure that everything is updated
-
-			stw		r4,0(r7)					/* Unlock the hash chain */
-			
-			rlwinm	r2,r2,0,0,19				; Clear back to page boundary
-			
-attrflsh:	cmplwi	r4,(4096-32)				; Are we about to do the last line on page?
-			dcbst	r2,r4						; Flush cache because we changed attributes
-			addi	r4,r4,32					; Bump up cache
-			blt+	attrflsh					; Do the whole page...
-			sync
 
-			li		r4,0
-attrimvl:	cmplwi	r4,(4096-32)				; Are we about to do the last line on page?
-			dcbi	r2,r4						; Invalidate dcache because we changed attributes
-			icbi	r2,r4						; Invalidate icache because we changed attributes
-			addi	r4,r4,32					; Bump up cache
-			blt+	attrimvl					; Do the whole page...
-			sync
+			li		r2,0						; Lock clear value
 
-			mtmsr	r0							; Restore interrupts and translation
-			isync
+			ptesync								; Wait for quiet again
+			sync								; Make sure that is done
+
+			stw		r2,tlbieLock(0)				; Clear the tlbie lock
+			
+			la		r3,pmapSXlk(r28)			; Point to the pmap search lock
+			bl		sxlkShared					; Go get a shared lock on the mapping lists
+			mr.		r3,r3						; Did we get the lock?
+			bne-	hrmPanic					; Nope...
+			
+			lwz		r4,mpVAddr(r31)				; High order of address
+			lwz		r5,mpVAddr+4(r31)			; Low order of address
+			mr		r3,r28						; Pass in pmap to search
+			mr		r29,r4						; Save this in case we need it (only promote fails)
+			mr		r30,r5						; Save this in case we need it (only promote fails)
+			bl		EXT(mapSearchFull)			; Go see if we can find it
+			
+			mr.		r3,r3						; Did we? (And remember mapping address for later)
+			mr		r15,r4						; Save top of next vaddr
+			mr		r16,r5						; Save bottom of next vaddr
+			beq-	hrmPanic					; Nope, not found...
+			
+			cmpld	r3,r31						; Same mapping?
+			bne-	hrmPanic					; Not good...
+			
+			la		r3,pmapSXlk(r28)			; Point to the pmap search lock
+			bl		sxlkPromote					; Try to promote shared to exclusive
+			mr.		r3,r3						; Could we?
+			mr		r3,r31						; Restore the mapping pointer
+			beq+	hrmBDone2					; Yeah...
+			
+			la		r3,pmapSXlk(r28)			; Point to the pmap search lock
+			bl		sxlkConvert					; Convert shared to exclusive
+			mr.		r3,r3						; Could we?
+			bne--	hrmPanic					; Nope, we must have timed out...
+			
+			mr		r3,r28						; Pass in pmap to search
+			mr		r4,r29						; High order of address
+			mr		r5,r30						; Low order of address
+			bl		EXT(mapSearchFull)			; Rescan the list
+			
+			mr.		r3,r3						; Did we lose it when we converted?
+			mr		r15,r4						; Save top of next vaddr
+			mr		r16,r5						; Save bottom of next vaddr
+			beq--	hrmPanic					; Yeah, we did, someone tossed it for us...
+
+hrmBDone2:	bl		mapDrainBusy				; Go wait until mapping is unused
+
+			mr		r3,r28						; Get the pmap to remove from
+			mr		r4,r31						; Point to the mapping
+			bl		EXT(mapRemove)				; Remove the mapping from the list	
+					
+			lwz		r4,pmapResidentCnt(r28)		; Get the mapped page count 
+			la		r3,pmapSXlk(r28)			; Point to the pmap search lock
+			subi	r4,r4,1						; Drop down the mapped page count
+			stw		r4,pmapResidentCnt(r28)		; Set the mapped page count 
+			bl		sxlkUnlock					; Unlock the search list
+		
+			b		hrmRetn64					; We are all done, get out...
+			
+hrmBTLBlcm:	li		r2,lgKillResv				; Get space unreserve line
+			stwcx.	r2,0,r2						; Unreserve it
+						
+hrmBTLBlcn:	lwz		r2,0(r7)					; Get the TLBIE lock
+			mr.		r2,r2						; Is it held?
+			beq++	hrmBTLBlcl					; Nope...
+			b		hrmBTLBlcn					; Yeah...
 
-#if PERFTIMES && DEBUG
-			mflr	r11
-			li		r3,41
-			bl		EXT(dbgLog2)				
-			mtlr	r11
-#endif
-			blr									/* Return... */
 
 
 /*
- *			hw_pte_comm(physent) - Do something to the PTE pointing to a physical page
- *
- *			Upon entry, R3 contains a pointer to a physical entry which is locked.
- *			Note that this must be done with both interruptions off and VM off
+ *			mapping *hw_purge_phys(physent) - remove a mapping from the system
  *
- *			First, we set up CRs 5 and 7 to indicate which of the 7 calls this is.
+ *			Upon entry, R3 contains a pointer to a physent.  
  *
- *			Now we scan the mappings to invalidate any with an active PTE.
- *
- *				Acquire the lock on the PTEG hash list for the mapping being processed.
+ *			This function removes the first mapping from a physical entry
+ *			alias list.  It locks the list, extracts the vaddr and pmap from
+ *			the first entry.  It then jumps into the hw_rem_map function.
+ *			NOTE: since we jump into rem_map, we need to set up the stack
+ *			identically.  Also, we set the next parm to 0 so we do not
+ *			try to save a next vaddr.
+ *			
+ *			We return the virtual address of the removed mapping as a 
+ *			R3.
  *
- *				If the current mapping has a PTE entry, we invalidate
- *				it and merge the reference and change information into the phys_entry.
+ *			Note that this is designed to be called from 32-bit mode with a stack.
  *
- *				Next, unlock the hash list and go on to the next mapping.
+ *			We disable translation and all interruptions here.  This keeps is
+ *			from having to worry about a deadlock due to having anything locked
+ *			and needing it to process a fault.
  *
+ *			Note that this must be done with both interruptions off and VM off
+ *	
+ * 
+ * Remove mapping via physical page (mapping_purge)
+ * 
+ *  1) lock physent
+ *  2) extract vaddr and pmap
+ *  3) unlock physent
+ *  4) do "remove mapping via pmap"
+ *  
  *	
- *			  
  */
 
 			.align	5
-			.globl	EXT(hw_inv_all)
-
-LEXT(hw_inv_all)
+			.globl	EXT(hw_purge_phys)
+
+LEXT(hw_purge_phys)
+			stwu	r1,-(FM_ALIGN(hrmStackSize)+FM_SIZE)(r1)	; Make some space on the stack
+			mflr	r0							; Save the link register
+			stw		r15,FM_ARG0+0x00(r1)		; Save a register
+			stw		r16,FM_ARG0+0x04(r1)		; Save a register
+			stw		r17,FM_ARG0+0x08(r1)		; Save a register
+			stw		r18,FM_ARG0+0x0C(r1)		; Save a register
+			stw		r19,FM_ARG0+0x10(r1)		; Save a register
+			stw		r20,FM_ARG0+0x14(r1)		; Save a register
+			stw		r21,FM_ARG0+0x18(r1)		; Save a register
+			stw		r22,FM_ARG0+0x1C(r1)		; Save a register
+			stw		r23,FM_ARG0+0x20(r1)		; Save a register
+			stw		r24,FM_ARG0+0x24(r1)		; Save a register
+			stw		r25,FM_ARG0+0x28(r1)		; Save a register
+			li		r6,0						; Set no next address return
+			stw		r26,FM_ARG0+0x2C(r1)		; Save a register
+			stw		r27,FM_ARG0+0x30(r1)		; Save a register
+			stw		r28,FM_ARG0+0x34(r1)		; Save a register
+			stw		r29,FM_ARG0+0x38(r1)		; Save a register
+			stw		r30,FM_ARG0+0x3C(r1)		; Save a register
+			stw		r31,FM_ARG0+0x40(r1)		; Save a register
+			stw		r6,FM_ARG0+0x44(r1)			; Save address to save next mapped vaddr
+			stw		r0,(FM_ALIGN(hrmStackSize)+FM_SIZE+FM_LR_SAVE)(r1)	; Save the return
+
+			bl		EXT(mapSetUp)				; Turn off interrupts, translation, and possibly enter 64-bit
+
+			bl		mapPhysLock					; Lock the physent
+			
+ 			bt++	pf64Bitb,hppSF				; skip if 64-bit (only they take the hint)
+		
+			lwz		r12,ppLink+4(r3)			; Grab the pointer to the first mapping
+ 			li		r0,0x3F						; Set the bottom stuff to clear
+			b		hppJoin						; Join the common...
+			
+hppSF:		li		r0,0xFF
+			ld		r12,ppLink(r3)				; Get the pointer to the first mapping
+			rldicl	r0,r0,62,0					; Rotate clean up mask to get 0xC0000000000000003F
+
+hppJoin:	andc.	r12,r12,r0					; Clean and test link
+			beq--	hppNone						; There are no more mappings on physical page
+			
+			lis		r28,hi16(EXT(pmapTrans))	; Get the top of the start of the pmap hash to pmap translate table
+			lhz		r7,mpSpace(r12)			; Get the address space hash
+			ori		r28,r28,lo16(EXT(pmapTrans))	; Get the top of the start of the pmap hash to pmap translate table
+			slwi	r0,r7,2						; Multiply space by 4
+			lwz		r4,mpVAddr(r12)				; Get the top of the vaddr
+			slwi	r7,r7,3						; Multiply space by 8
+			lwz		r5,mpVAddr+4(r12)			; and the bottom
+			add		r7,r7,r0					; Get correct displacement into translate table
+			lwz		r28,0(r28)					; Get the actual translation map
 	
-			li		r9,0x800					/* Indicate invalidate all */
-			li		r2,0						; No inadvertant modifications please
-			b		hw_pte_comm					/* Join in the fun... */
-
+			add		r28,r28,r7					; Point to the pmap translation
+					
+			bl		mapPhysUnlock				; Time to unlock the physical entry
+			
+ 			bt++	pf64Bitb,hppSF2				; skip if 64-bit (only they take the hint)
+			
+			lwz		r28,pmapPAddr+4(r28)		; Get the physical address of the pmap
+			b		hrmJoin						; Go remove the mapping...
+			
+hppSF2:		ld		r28,pmapPAddr(r28)			; Get the physical address of the pmap
+			b		hrmJoin						; Go remove the mapping...
 
 			.align	5
-			.globl	EXT(hw_tst_mod)
+			
+hppNone:	bl		mapPhysUnlock				; Time to unlock the physical entry
+
+			bt++	pf64Bitb,hppSF3				; skip if 64-bit (only they take the hint)...
+
+			mtmsr	r11							; Restore enables/translation/etc.
+			isync
+			b		hppRetnCmn					; Join the common return code...
 
-LEXT(hw_tst_mod)
+hppSF3:		mtmsrd	r11							; Restore enables/translation/etc.
+			isync
 
-			lwz		r8,pepte1(r3)				; Get the saved PTE image
-			li		r9,0x400					/* Indicate test modify */
-			li		r2,0						; No inadvertant modifications please
-			rlwinm.	r8,r8,25,31,31				; Make change bit into return code
-			beq+	hw_pte_comm					; Assume we do not know if it is set...
-			mr		r3,r8						; Set the return code
-			blr									; Return quickly...
+;
+;			NOTE: we have not used any registers other than the volatiles to this point
+;
 
- 			.align	5
-			.globl	EXT(hw_tst_ref)
+hppRetnCmn:	lwz		r12,(FM_ALIGN(hrmStackSize)+FM_SIZE+FM_LR_SAVE)(r1)	; Restore the return
 
-LEXT(hw_tst_ref)
-			lwz		r8,pepte1(r3)				; Get the saved PTE image
-			li		r9,0x200					/* Indicate test reference bit */
-			li		r2,0						; No inadvertant modifications please
-			rlwinm.	r8,r8,24,31,31				; Make reference bit into return code
-			beq+	hw_pte_comm					; Assume we do not know if it is set...
-			mr		r3,r8						; Set the return code
-			blr									; Return quickly...
+			li		r3,0						; Clear high order mapping address because we are 32-bit
+			mtlr	r12							; Restore the return
+			lwz		r1,0(r1)					; Pop the stack
+			blr									; Leave...
 
 /*
- *			Note that the following are all in one CR for ease of use later
+ *			mapping *hw_purge_map(pmap, vaddr, addr64_t *next) - remove a mapping from the system.
+ *
+ *			Upon entry, R3 contains a pointer to a pmap.  Since vaddr is
+ *			a 64-bit quantity, it is a long long so it is in R4 and R5.
+ *			
+ *			We return the virtual address of the removed mapping as a 
+ *			R3.
+ *
+ *			Note that this is designed to be called from 32-bit mode with a stack.
+ *
+ *			We disable translation and all interruptions here.  This keeps is
+ *			from having to worry about a deadlock due to having anything locked
+ *			and needing it to process a fault.
+ *
+ *			Note that this must be done with both interruptions off and VM off
+ *	
+ *  Remove a mapping which can be reestablished by VM
+ *
  */
-			.align	4
-			.globl	EXT(hw_set_mod)
 
-LEXT(hw_set_mod)
-			
-			li		r9,0x008					/* Indicate set modify bit */
-			li		r2,0x4						; Set set C, clear none
-			b		hw_pte_comm					/* Join in the fun... */
+			.align	5
+			.globl	EXT(hw_purge_map)
+
+LEXT(hw_purge_map)
+			stwu	r1,-(FM_ALIGN(hrmStackSize)+FM_SIZE)(r1)	; Make some space on the stack
+			mflr	r0							; Save the link register
+			stw		r15,FM_ARG0+0x00(r1)		; Save a register
+			stw		r16,FM_ARG0+0x04(r1)		; Save a register
+			stw		r17,FM_ARG0+0x08(r1)		; Save a register
+			stw		r18,FM_ARG0+0x0C(r1)		; Save a register
+			stw		r19,FM_ARG0+0x10(r1)		; Save a register
+ 			mfsprg	r19,2						; Get feature flags 
+			stw		r20,FM_ARG0+0x14(r1)		; Save a register
+			stw		r21,FM_ARG0+0x18(r1)		; Save a register
+			mtcrf	0x02,r19					; move pf64Bit cr6
+			stw		r22,FM_ARG0+0x1C(r1)		; Save a register
+			stw		r23,FM_ARG0+0x20(r1)		; Save a register
+			stw		r24,FM_ARG0+0x24(r1)		; Save a register
+			stw		r25,FM_ARG0+0x28(r1)		; Save a register
+			stw		r26,FM_ARG0+0x2C(r1)		; Save a register
+			stw		r27,FM_ARG0+0x30(r1)		; Save a register
+			stw		r28,FM_ARG0+0x34(r1)		; Save a register
+			stw		r29,FM_ARG0+0x38(r1)		; Save a register
+			stw		r30,FM_ARG0+0x3C(r1)		; Save a register
+			stw		r31,FM_ARG0+0x40(r1)		; Save a register
+			stw		r6,FM_ARG0+0x44(r1)			; Save address to save next mapped vaddr
+			stw		r0,(FM_ALIGN(hrmStackSize)+FM_SIZE+FM_LR_SAVE)(r1)	; Save the return
+
+ 			bt++	pf64Bitb,hpmSF1				; skip if 64-bit (only they take the hint)
+			lwz		r9,pmapvr+4(r3)				; Get conversion mask
+			b		hpmSF1x						; Done...
+			
+hpmSF1:		ld		r9,pmapvr(r3)				; Get conversion mask
+
+hpmSF1x:	
+			bl		EXT(mapSetUp)				; Turn off interrupts, translation, and possibly enter 64-bit
+
+			xor		r28,r3,r9					; Convert the pmap to physical addressing
+
+			mr		r17,r11						; Save the MSR
+
+			la		r3,pmapSXlk(r28)			; Point to the pmap search lock
+			bl		sxlkExclusive				; Go get an exclusive lock on the mapping lists
+			mr.		r3,r3						; Did we get the lock?
+			bne--	hrmBadLock					; Nope...
+;
+;			Note that we do a full search (i.e., no shortcut level skips, etc.)
+;			here so that we will know the previous elements so we can dequeue them
+;			later.
+;
+hpmSearch:
+			mr		r3,r28						; Pass in pmap to search
+			mr		r29,r4						; Top half of vaddr
+			mr		r30,r5						; Bottom half of vaddr
+			bl		EXT(mapSearchFull)			; Rescan the list
+			mr.		r31,r3						; Did we? (And remember mapping address for later)
+			or		r0,r4,r5					; Are we beyond the end?
+			mr		r15,r4						; Save top of next vaddr
+			cmplwi	cr1,r0,0					; See if there is another
+			mr		r16,r5						; Save bottom of next vaddr
+			bne--	hpmGotOne					; We found one, go check it out...
+
+hpmCNext:	bne++	cr1,hpmSearch				; There is another to check...
+			b		hrmNotFound					; No more in pmap to check...
+
+hpmGotOne:	lwz		r20,mpFlags(r3)				; Get the flags
+			andi.	r9,r20,lo16(mpSpecial|mpNest|mpPerm|mpBlock)	; Are we allowed to remove it?
+			beq++	hrmGotX						; Found, branch to remove the mapping...
+			b		hpmCNext					; Nope...
 
+/*
+ *			mapping *hw_purge_space(physent, pmap) - remove a mapping from the system based upon address space
+ *
+ *			Upon entry, R3 contains a pointer to a pmap.  
+ *			pa is a pointer to the physent
+ *
+ *			This function removes the first mapping for a specific pmap from a physical entry
+ *			alias list.  It locks the list, extracts the vaddr and pmap from
+ *			the first apporpriate entry.  It then jumps into the hw_rem_map function.
+ *			NOTE: since we jump into rem_map, we need to set up the stack
+ *			identically.  Also, we set the next parm to 0 so we do not
+ *			try to save a next vaddr.
+ *			
+ *			We return the virtual address of the removed mapping as a 
+ *			R3.
+ *
+ *			Note that this is designed to be called from 32-bit mode with a stack.
+ *
+ *			We disable translation and all interruptions here.  This keeps is
+ *			from having to worry about a deadlock due to having anything locked
+ *			and needing it to process a fault.
+ *
+ *			Note that this must be done with both interruptions off and VM off
+ *	
+ * 
+ * Remove mapping via physical page (mapping_purge)
+ * 
+ *  1) lock physent
+ *  2) extract vaddr and pmap
+ *  3) unlock physent
+ *  4) do "remove mapping via pmap"
+ *  
+ *	
+ */
 
-			.align	4
-			.globl	EXT(hw_clr_mod)
+			.align	5
+			.globl	EXT(hw_purge_space)
+
+LEXT(hw_purge_space)
+			stwu	r1,-(FM_ALIGN(hrmStackSize)+FM_SIZE)(r1)	; Make some space on the stack
+			mflr	r0							; Save the link register
+			stw		r15,FM_ARG0+0x00(r1)		; Save a register
+			stw		r16,FM_ARG0+0x04(r1)		; Save a register
+			stw		r17,FM_ARG0+0x08(r1)		; Save a register
+ 			mfsprg	r2,2						; Get feature flags 
+			stw		r18,FM_ARG0+0x0C(r1)		; Save a register
+			stw		r19,FM_ARG0+0x10(r1)		; Save a register
+			stw		r20,FM_ARG0+0x14(r1)		; Save a register
+			stw		r21,FM_ARG0+0x18(r1)		; Save a register
+			stw		r22,FM_ARG0+0x1C(r1)		; Save a register
+			mtcrf	0x02,r2						; move pf64Bit cr6
+			stw		r23,FM_ARG0+0x20(r1)		; Save a register
+			stw		r24,FM_ARG0+0x24(r1)		; Save a register
+			stw		r25,FM_ARG0+0x28(r1)		; Save a register
+			stw		r26,FM_ARG0+0x2C(r1)		; Save a register
+			stw		r27,FM_ARG0+0x30(r1)		; Save a register
+			li		r6,0						; Set no next address return
+			stw		r28,FM_ARG0+0x34(r1)		; Save a register
+			stw		r29,FM_ARG0+0x38(r1)		; Save a register
+			stw		r30,FM_ARG0+0x3C(r1)		; Save a register
+			stw		r31,FM_ARG0+0x40(r1)		; Save a register
+			stw		r6,FM_ARG0+0x44(r1)			; Save address to save next mapped vaddr
+			stw		r0,(FM_ALIGN(hrmStackSize)+FM_SIZE+FM_LR_SAVE)(r1)	; Save the return
+
+			bt++	pf64Bitb,hpsSF1				; skip if 64-bit (only they take the hint)
+
+			lwz		r9,pmapvr+4(r4)				; Get conversion mask for pmap
+
+			b		hpsSF1x						; Done...
+			
+hpsSF1:		ld		r9,pmapvr(r4)				; Get conversion mask for pmap
+
+hpsSF1x:	bl		EXT(mapSetUp)				; Turn off interrupts, translation, and possibly enter 64-bit
+			
+			xor		r4,r4,r9					; Convert the pmap to physical addressing
+
+			bl		mapPhysLock					; Lock the physent
+			 
+ 			lhz		r8,pmapSpace(r4)			; Get the space hash
+ 
+ 			bt++	pf64Bitb,hpsSF				; skip if 64-bit (only they take the hint)
+		
+			lwz		r12,ppLink+4(r3)			; Grab the pointer to the first mapping
+			
+hpsSrc32:	rlwinm.	r12,r12,0,0,25				; Clean and test mapping address
+			beq		hpsNone						; Did not find one...
+			
+			lhz		r10,mpSpace(r12)			; Get the space
+			
+			cmplw	r10,r8						; Is this one of ours?
+			beq		hpsFnd						; Yes...
+			
+			lwz		r12,mpAlias+4(r12)			; Chain on to the next
+			b		hpsSrc32					; Check it out...
 
-LEXT(hw_clr_mod)
+			.align	5
+		
+hpsSF:		li		r0,0xFF
+			ld		r12,ppLink(r3)				; Get the pointer to the first mapping
+			rldicl	r0,r0,62,0					; Rotate clean up mask to get 0xC0000000000000003F
+			
+hpsSrc64:	andc.	r12,r12,r0					; Clean and test mapping address
+			beq		hpsNone						; Did not find one...
+			
+			lhz		r10,mpSpace(r12)			; Get the space
+			
+			cmplw	r10,r8						; Is this one of ours?
+			beq		hpsFnd						; Yes...
+			
+			ld		r12,mpAlias(r12)			; Chain on to the next
+			b		hpsSrc64					; Check it out...
+			
+			.align	5
+			
+hpsFnd:		mr		r28,r4						; Set the pmap physical address
+			lwz		r4,mpVAddr(r12)				; Get the top of the vaddr
+			lwz		r5,mpVAddr+4(r12)			; and the bottom
+			
+			bl		mapPhysUnlock				; Time to unlock the physical entry
+			b		hrmJoin						; Go remove the mapping...
+			
+			.align	5
 			
-			li		r9,0x004					/* Indicate clear modify bit */
-			li		r2,0x1						; Set set none, clear C
-			b		hw_pte_comm					/* Join in the fun... */
+hpsNone:	bl		mapPhysUnlock				; Time to unlock the physical entry
 
+			bt++	pf64Bitb,hpsSF3				; skip if 64-bit (only they take the hint)...
 
-			.align	4
-			.globl	EXT(hw_set_ref)
+			mtmsr	r11							; Restore enables/translation/etc.
+			isync
+			b		hpsRetnCmn					; Join the common return code...
 
-LEXT(hw_set_ref)
-			
-			li		r9,0x002					/* Indicate set reference */
-			li		r2,0x8						; Set set R, clear none
-			b		hw_pte_comm					/* Join in the fun... */
+hpsSF3:		mtmsrd	r11							; Restore enables/translation/etc.
+			isync
 
-			.align	5
-			.globl	EXT(hw_clr_ref)
+;
+;			NOTE: we have not used any registers other than the volatiles to this point
+;
 
-LEXT(hw_clr_ref)
-			
-			li		r9,0x001					/* Indicate clear reference bit */
-			li		r2,0x2						; Set set none, clear R
-			b		hw_pte_comm					/* Join in the fun... */
+hpsRetnCmn:	lwz		r12,(FM_ALIGN(hrmStackSize)+FM_SIZE+FM_LR_SAVE)(r1)	; Restore the return
+
+			li		r3,0						; Set return code
+			mtlr	r12							; Restore the return
+			lwz		r1,0(r1)					; Pop the stack
+			blr									; Leave...
 
 
 /*
- *			This is the common stuff.
+ *			mapping *hw_find_space(physent, space) - finds the first mapping on physent for specified space
+ *
+ *			Upon entry, R3 contains a pointer to a physent.  
+ *			space is the space ID from the pmap in question
+ *
+ *			We return the virtual address of the found mapping in 
+ *			R3. Note that the mapping busy is bumped.
+ *
+ *			Note that this is designed to be called from 32-bit mode with a stack.
+ *
+ *			We disable translation and all interruptions here.  This keeps is
+ *			from having to worry about a deadlock due to having anything locked
+ *			and needing it to process a fault.
+ *	
  */
 
 			.align	5
+			.globl	EXT(hw_find_space)
+
+LEXT(hw_find_space)
+			stwu	r1,-(FM_SIZE)(r1)			; Make some space on the stack
+			mflr	r0							; Save the link register
+			mr		r8,r4						; Remember the space
+			stw		r0,(FM_SIZE+FM_LR_SAVE)(r1)	; Save the return
 
-hw_pte_comm:									/* Common routine for pte tests and manips */
+			bl		EXT(mapSetUp)				; Turn off interrupts, translation, and possibly enter 64-bit
+
+			bl		mapPhysLock					; Lock the physent
  
-#if PERFTIMES && DEBUG
-			mflr	r11
-			mr		r7,r3
-			lwz		r4,4(r3)
-			mr		r5,r9			
-			li		r3,28
-			bl		EXT(dbgLog2)						; Start of hw_add_map
-			mr		r3,r7
-			mtlr	r11
-#endif
- 			mfsprg	r8,2						; Get feature flags 
-			lwz		r10,pephyslink(r3)			/* Get the first mapping block */
-			mfmsr	r0							/* Save the MSR  */
-			rlwinm.	r10,r10,0,0,26				; Clear out the flags from first link and see if we are mapped
-			rlwinm	r0,r0,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-			rlwinm	r0,r0,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-			rlwinm	r12,r0,0,MSR_EE_BIT+1,MSR_EE_BIT-1	/* Clear interruptions */
-			mtcrf	0x04,r8						; Set the features			
-			rlwinm	r12,r12,0,28,25				/* Clear IR and DR */
-			beq-	comnmap						; No mapping
-			dcbt	br0,r10						; Touch the first mapping in before the isync
-			
-comnmap:
-
-			bt		pfNoMSRirb,hpcNoMSR			; No MSR...
-
-			mtmsr	r12							; Translation and all off
-			isync								; Toss prefetch
-			b		hpcNoMSRx
+ 			bt++	pf64Bitb,hfsSF				; skip if 64-bit (only they take the hint)
+		
+			lwz		r12,ppLink+4(r3)			; Grab the pointer to the first mapping
 			
-hpcNoMSR:	
-			mr		r5,r0
-			mr		r7,r3
-			li		r0,loadMSR					; Get the MSR setter SC
-			mr		r3,r12						; Get new MSR
-			sc									; Set it
-			mr		r3,r7
-			mr		r0,r5
-hpcNoMSRx:
+hfsSrc32:	rlwinm.	r12,r12,0,0,25				; Clean and test mapping address
+			beq		hfsNone						; Did not find one...
+			
+			lhz		r10,mpSpace(r12)			; Get the space
+			
+			cmplw	r10,r8						; Is this one of ours?
+			beq		hfsFnd						; Yes...
+			
+			lwz		r12,mpAlias+4(r12)			; Chain on to the next
+			b		hfsSrc32					; Check it out...
 
-			mtcrf	0x05,r9						/* Set the call type flags into cr5 and 7 */
+			.align	5
+		
+hfsSF:		li		r0,0xFF
+			ld		r12,ppLink(r3)				; Get the pointer to the first mapping
+			rldicl	r0,r0,62,0					; Rotate clean up mask to get 0xC0000000000000003F
+			
+hfsSrc64:	andc.	r12,r12,r0					; Clean and test mapping address
+			beq		hfsNone						; Did not find one...
+			
+			lhz		r10,mpSpace(r12)			; Get the space
+			
+			cmplw	r10,r8						; Is this one of ours?
+			beq		hfsFnd						; Yes...
+			
+			ld		r12,mpAlias(r12)			; Chain on to the next
+			b		hfsSrc64					; Check it out...
+			
+			.align	5
+			
+hfsFnd:		mr		r8,r3						; Save the physent
+			mr		r3,r12						; Point to the mapping
+			bl		mapBumpBusy					; If we found it, bump up the busy count so the mapping does not disapear
 
-			beq-	commdone					; Nothing us mapped to this page...
-			b		commnext					; Jump to first pass (jump here so we can align loop)
+			mr		r3,r8						; Get back the physical entry
+			li		r7,0xFFF					; Get a page size mask
+			bl		mapPhysUnlock				; Time to unlock the physical entry
 		
-			.align	5	
+			andc	r3,r12,r7					; Move the mapping back down to a page	
+			lwz		r3,mbvrswap+4(r3)			; Get last half of virtual to real swap
+			xor		r12,r3,r12					; Convert to virtual
+			b		hfsRet						; Time to return
+			
+			.align	5
+			
+hfsNone:	bl		mapPhysUnlock				; Time to unlock the physical entry
+			
+hfsRet:		bt++	pf64Bitb,hfsSF3				; skip if 64-bit (only they take the hint)...
 
-commnext:	lwz		r11,mmnext(r10)				; Get the pointer to the next mapping (if any)
-			lwz		r7,mmPTEhash(r10)			/* Get pointer to hash list anchor */
-			lwz		r5,mmPTEv(r10)				/* Get the virtual address */
-			mr.		r11,r11						; More mappings to go?
-			rlwinm	r7,r7,0,0,25				/* Round hash list down to PCA boundary */
-			beq-	commnxtch					; No more mappings...
-			dcbt	br0,r11						; Touch the next mapping
+			mtmsr	r11							; Restore enables/translation/etc.
+			isync
+			b		hfsRetnCmn					; Join the common return code...
 
-commnxtch:	li		r12,1						/* Get the locked value */
+hfsSF3:		mtmsrd	r11							; Restore enables/translation/etc.
+			isync
 
-commLck1:	lwarx	r11,0,r7					/* Get the PTEG lock */
-			mr.		r11,r11						/* Is it locked? */
-			bne-	commLckw1					/* Yeah... */
-			stwcx.	r12,0,r7					/* Try to take it */
-			bne-	commLck1					/* Someone else was trying, try again... */
-			b		commSXg1					/* All done... */
-			
-			.align	4
+;
+;			NOTE: we have not used any registers other than the volatiles to this point
+;
 
-commLckw1:	mr.		r11,r11						/* Check if it's already held */
-			beq+	commLck1					/* It's clear... */
-			lwz		r11,0(r7)					/* Get lock word again... */
-			b		commLckw1					/* Wait... */
-			
-			.align	4
+hfsRetnCmn:	mr		r3,r12						; Get the mapping or a 0 if we failed
+			lwz		r12,(FM_SIZE+FM_LR_SAVE)(r1)	; Restore the return
 
-commSXg1:	isync								/* Make sure we haven't used anything yet */
+			mtlr	r12							; Restore the return
+			lwz		r1,0(r1)					; Pop the stack
+			blr									; Leave...
 
- 			lwz		r6,mmPTEent(r10)			/* Get the pointer to the PTE now that the lock's set */
 
-			rlwinm	r9,r5,1,0,3					/* Move in the segment */
-			mr.		r6,r6						/* See if there is a PTE entry here */
-			rlwinm	r8,r5,31,2,25				/* Line it up and check if empty */
-		
-			beq+	commul						/* There's no PTE to invalidate... */
-			
-			xor		r8,r8,r6					/* Back hash to virt index */
-			rlwimi	r9,r5,22,4,9				/* Move in the API */
-			lis		r12,HIGH_ADDR(EXT(tlb_system_lock))		/* Get the TLBIE lock */
-			rlwinm	r5,r5,0,1,31				/* Clear the valid bit */
-			ori		r12,r12,LOW_ADDR(EXT(tlb_system_lock))	/* Grab up the bottom part */
-			rlwimi	r9,r8,6,10,19				/* Create the virtual address */
-
-			stw		r5,0(r6)					/* Make the PTE invalid */		
-			mfspr	r4,pvr						/* Find out what kind of machine we are */
-			sync								/* Make sure the invalid is stored */
-						
-tlbhangco:	lwarx	r11,0,r12					/* Get the TLBIE lock */
-			rlwinm	r8,r6,29,29,31				/* Get the bit position of entry */
-			mr.		r11,r11						/* Is it locked? */
-			lis		r5,0x8000					/* Start up a bit mask */
-			li		r11,1						/* Get our lock word */
-			bne-	tlbhangco					/* It's locked, go wait... */
-			stwcx.	r11,0,r12					/* Try to get it */
-			bne-	tlbhangco					/* We was beat... */
-			
-			rlwinm	r4,r4,16,16,31				/* Isolate CPU type */
-			li		r11,0						/* Lock clear value */
-			cmplwi	r4,3						/* Is this a 603? */
+;
+;			mapping *hw_find_map(pmap, va, *nextva) - Looks up a vaddr in a pmap
+;			Returns 0 if not found or the virtual address of the mapping if
+;			if is.  Also, the mapping has the busy count bumped.
+;
+			.align	5
+			.globl	EXT(hw_find_map)
 
-			tlbie	r9							/* Invalidate it everywhere */
+LEXT(hw_find_map)
+ 			stwu	r1,-(FM_ALIGN((31-25+1)*4)+FM_SIZE)(r1)	; Make some space on the stack
+			mflr	r0							; Save the link register
+			stw		r25,FM_ARG0+0x00(r1)		; Save a register
+			stw		r26,FM_ARG0+0x04(r1)		; Save a register
+			mr		r25,r6						; Remember address of next va
+			stw		r27,FM_ARG0+0x08(r1)		; Save a register
+			stw		r28,FM_ARG0+0x0C(r1)		; Save a register
+			stw		r29,FM_ARG0+0x10(r1)		; Save a register
+			stw		r30,FM_ARG0+0x14(r1)		; Save a register
+			stw		r31,FM_ARG0+0x18(r1)		; Save a register
+			stw		r0,(FM_ALIGN((31-26+1)*4)+FM_SIZE+FM_LR_SAVE)(r1)	; Save the return
 
-			beq-	its603co					/* It's a 603, skip the tlbsync... */
-			
-			eieio								/* Make sure that the tlbie happens first */
-			tlbsync								/* wait for everyone to catch up */
-			isync								
-			
-its603co:	stw		r11,0(r12)					/* Clear the lock */
-			srw		r5,r5,r8					/* Make a "free slot" mask */
-			sync								/* Make sure of it all */
+			lwz		r6,pmapvr(r3)				; Get the first part of the VR translation for pmap
+			lwz		r7,pmapvr+4(r3)				; Get the second part
 
-			lwz		r6,4(r6)					/* Get the latest reference and change bits */
-			lwz		r9,PCAallo(r7)				/* Get the allocation control bits */
-			stw		r11,mmPTEent(r10)			/* Clear the pointer to the PTE */
-			rlwinm	r8,r5,24,8,15				/* Make the autogen bit to turn off */
-			or		r9,r9,r5					/* Set the slot free */
-			rlwimi	r8,r8,24,16,23				/* Get lock bit mask to turn it off */
-			rlwinm	r4,r6,0,23,24				/* Extract the RC bits */
-			andc	r9,r9,r8					/* Clear the auto and lock bits */
-			li		r5,pepte1					/* Get displacement to the second word of master pte */
-			stw		r9,PCAallo(r7)				/* Store the allocation controls */
-			
-commmod:	lwarx	r11,r5,r3					/* Get the master copy */
-			or		r11,r11,r4					/* Merge in latest RC */
-			stwcx.	r11,r5,r3					/* Save it back */
-			bne-	commmod						/* If it changed, try again... */
-			b		commulnl					; Skip loading the old real part...
 
-commul:		lwz		r6,mmPTEr(r10)				; Get the real part
+			bl		EXT(mapSetUp)				; Turn off interrupts, translation, and possibly enter 64-bit
 
-commulnl:	rlwinm	r12,r2,5,23,24				; Get the "set" bits
-			rlwinm	r11,r2,7,23,24				; Get the "clear" bits
-			
-			or		r6,r6,r12					; Set the bits to come on
-			andc	r6,r6,r11					; Clear those to come off
+			mr		r27,r11						; Remember the old MSR
+			mr		r26,r12						; Remember the feature bits
 
-			stw		r6,mmPTEr(r10)				; Set the new RC
+			xor		r28,r3,r7					; Change the common 32- and 64-bit half
 
-			lwz		r10,mmnext(r10)				/* Get the next */
-			li		r4,0						/* Make sure this is 0 */
-			mr.		r10,r10						; Is there another mapping?
+			bf--	pf64Bitb,hfmSF1				; skip if 32-bit...
+			
+			rldimi	r28,r6,32,0					; Shift the fixed upper part of the physical over and cram in top
 
-			sync								; Make sure that all is saved
+hfmSF1:		mr		r29,r4						; Save top half of vaddr
+			mr		r30,r5						; Save the bottom half
+						
+			la		r3,pmapSXlk(r28)			; Point to the pmap search lock
+			bl		sxlkShared					; Go get a shared lock on the mapping lists
+			mr.		r3,r3						; Did we get the lock?
+			bne--	hfmBadLock					; Nope...
 
-			stw		r4,0(r7)					/* Unlock the hash chain */
-			bne+	commnext					; Go get the next if there is one...
+			mr		r3,r28						; get the pmap address
+			mr		r4,r29						; Get bits 0:31 to look for
+			mr		r5,r30						; Get bits 32:64
 			
-/*
- *			Now that all PTEs have been invalidated and the master RC bits are updated,
- *			we go ahead and figure out what the original call was and do that.  Note that
- *			another processor could be messing around and may have entered one of the 
- *			PTEs we just removed into the hash table.  Too bad...  You takes yer chances.
- *			If there's a problem with that, it's because some higher level was trying to
- *			do something with a mapping that it shouldn't.  So, the problem's really
- *			there, nyaaa, nyaaa, nyaaa... nyaaa, nyaaa... nyaaa! So there!
- */
+			bl		EXT(mapSearch)				; Go see if we can find it (note: R7 comes back with mpFlags)
 
-commdone:	li		r5,pepte1					/* Get displacement to the second word of master pte */
-			blt		cr5,commfini				/* We're finished, it was invalidate all... */
-			bgt		cr5,commtst					/* It was a test modified... */
-			beq		cr5,commtst					/* It was a test reference... */
+			rlwinm	r0,r7,0,mpRIPb,mpRIPb		; Find remove in progress bit
+			mr.		r31,r3						; Save the mapping if we found it
+			cmplwi	cr1,r0,0					; Are we removing?
+			mr		r29,r4						; Save next va high half
+			crorc	cr0_eq,cr0_eq,cr1_eq		; Not found or removing
+			mr		r30,r5						; Save next va low half
+			li		r6,0						; Assume we did not find it
+			li		r26,0xFFF					; Get a mask to relocate to start of mapping page
 
-/*
- *			Note that we need to to do the interlocked update here because another processor
- *			can be updating the reference and change bits even though the physical entry
- *			is locked.  All modifications to the PTE portion of the physical entry must be
- *			done via interlocked update.
- */
+			bt--	cr0_eq,hfmNotFnd			; We did not find it...
 
-			rlwinm	r12,r2,5,23,24				; Get the "set" bits
-			rlwinm	r11,r2,7,23,24				; Get the "clear" bits
+			bl		mapBumpBusy					; If we found it, bump up the busy count so the mapping does not disapear
 
-commcng:	lwarx	r8,r5,r3					/* Get the master copy */
-			or		r8,r8,r12					; Set the bits to come on
-			andc	r8,r8,r11					; Clear those to come off
-			stwcx.	r8,r5,r3					/* Save it back */
-			bne-	commcng						/* If it changed, try again... */
+			andc	r4,r31,r26					; Get back to the mapping page start
 
-			mtmsr	r0							/* Interrupts and translation back on */
-			isync
-#if PERFTIMES && DEBUG
-			mflr	r11
-			mr		r4,r3
-			li		r3,29
-			bl		EXT(dbgLog2)						; Start of hw_add_map
-			mr		r3,r4
-			mtlr	r11
-#endif
-			blr									/* Return... */
-
-			.align	4
-
-commtst:	lwz		r8,pepte1(r3)				/* Get the PTE */
-			bne-	cr5,commtcb					; This is for the change bit...
-			mtmsr	r0							; Interrupts and translation back on
-			rlwinm	r3,r8,24,31,31				; Copy reference bit to bit 31
-			isync								; Toss prefetching
-#if PERFTIMES && DEBUG
-			mflr	r11
-			mr		r4,r3
-			li		r3,29
-			bl		EXT(dbgLog2)						; Start of hw_add_map
-			mr		r3,r4
-			mtlr	r11
-#endif
-			blr									; Return...
+;			Note: we can treat 32- and 64-bit the same here. Because we are going from
+;			physical to virtual and we only do 32-bit virtual, we only need the low order
+;			word of the xor.
 
-			.align	4
+			lwz		r4,mbvrswap+4(r4)			; Get last half of virtual to real swap
+			li		r6,-1						; Indicate we found it and it is not being removed
+			xor		r31,r31,r4					; Flip to virtual
 
-commtcb:	rlwinm	r3,r8,25,31,31				; Copy change bit to bit 31
+hfmNotFnd:	la		r3,pmapSXlk(r28)			; Point to the pmap search lock
+			bl		sxlkUnlock					; Unlock the search list
 
-commfini:	mtmsr	r0							; Interrupts and translation back on
-			isync								; Toss prefetching
+			rlwinm	r3,r31,0,0,31				; Move mapping to return register and clear top of register if 64-bit
+			and		r3,r3,r6					; Clear if not found or removing
+
+hfmReturn:	bt++	pf64Bitb,hfmR64				; Yes...
+
+			mtmsr	r27							; Restore enables/translation/etc.
+			isync
+			b		hfmReturnC					; Join common...
+
+hfmR64:		mtmsrd	r27							; Restore enables/translation/etc.
+			isync								
+			
+hfmReturnC:	stw		r29,0(r25)					; Save the top of the next va
+			stw		r30,4(r25)					; Save the bottom of the next va
+			lwz		r0,(FM_ALIGN((31-25+1)*4)+FM_SIZE+FM_LR_SAVE)(r1)	; Save the return
+			lwz		r25,FM_ARG0+0x00(r1)		; Restore a register
+			lwz		r26,FM_ARG0+0x04(r1)		; Restore a register
+			and		r3,r3,r6					; Clear return if the mapping is being removed
+			lwz		r27,FM_ARG0+0x08(r1)		; Restore a register
+			mtlr	r0							; Restore the return
+			lwz		r28,FM_ARG0+0x0C(r1)		; Restore a register
+			lwz		r29,FM_ARG0+0x10(r1)		; Restore a register
+			lwz		r30,FM_ARG0+0x14(r1)		; Restore a register
+			lwz		r31,FM_ARG0+0x18(r1)		; Restore a register
+			lwz		r1,0(r1)					; Pop the stack
+			blr									; Leave...
+			
+			.align	5
+			
+hfmBadLock:	li		r3,1						; Set lock time out error code
+			b		hfmReturn					; Leave....
 
-#if PERFTIMES && DEBUG
-			mflr	r11
-			mr		r4,r3
-			li		r3,29
-			bl		EXT(dbgLog2)						; Start of hw_add_map
-			mr		r3,r4
-			mtlr	r11
-#endif
-			blr									; Return...
 
 /*
- *			unsigned int hw_test_rc(mapping *mp, boolean_t reset);
+ *			unsigned int hw_walk_phys(pp, preop, op, postop, parm) 
+ *				walks all mapping for a physical page and performs
+ *				specified operations on each.
  *
- *			Test the RC bits for a specific mapping.  If reset is non-zero, clear them.
- *			We return the RC value in the mapping if there is no PTE or if C is set.
- *			(Note: R is always set with C.) Otherwise we invalidate the PTE and
- *			collect the RC bits from there, also merging them into the global copy.
- *			
- *			For now, we release the PTE slot and leave it invalid.  In the future, we
- *			may consider re-validating and not releasing the slot.  It would be faster,
- *			but our current implementation says that we will have not PTEs valid
- *			without the reference bit set.
+ *			pp is unlocked physent
+ *			preop is operation to perform on physent before walk.  This would be
+ *				used to set cache attribute or protection
+ *			op is the operation to perform on each mapping during walk
+ *			postop is operation to perform in the phsyent after walk.  this would be
+ *				used to set or reset the RC bits.
+ *
+ *			We return the RC bits from before postop is run.
  *
- *			We will special case C==1 && not reset to just return the RC.
+ *			Note that this is designed to be called from 32-bit mode with a stack.
  *
- *			Probable state is worst performance state: C bit is off and there is a PTE.
+ *			We disable translation and all interruptions here.  This keeps is
+ *			from having to worry about a deadlock due to having anything locked
+ *			and needing it to process a fault.
+ *
+ *			We lock the physent, execute preop, and then walk each mapping in turn. 
+ *			If there is a PTE, it is invalidated and the RC merged into the physent.
+ *			Then we call the op function.
+ *			Then we revalidate the PTE.
+ *			Once all all mappings are finished, we save the physent RC and call the 
+ *			postop routine.  Then we unlock the physent and return the RC.
+ *	
+ * 
  */
 
-#define		htrReset 31
-
 			.align	5
-			.globl	EXT(hw_test_rc)
+			.globl	EXT(hw_walk_phys)
+
+LEXT(hw_walk_phys)
+			stwu	r1,-(FM_ALIGN((31-25+1)*4)+FM_SIZE)(r1)	; Make some space on the stack
+			mflr	r0							; Save the link register
+			stw		r25,FM_ARG0+0x00(r1)		; Save a register
+			stw		r26,FM_ARG0+0x04(r1)		; Save a register
+			stw		r27,FM_ARG0+0x08(r1)		; Save a register
+			stw		r28,FM_ARG0+0x0C(r1)		; Save a register
+			mr		r25,r7						; Save the parm
+			stw		r29,FM_ARG0+0x10(r1)		; Save a register
+			stw		r30,FM_ARG0+0x14(r1)		; Save a register
+			stw		r31,FM_ARG0+0x18(r1)		; Save a register
+			stw		r0,(FM_ALIGN((31-25+1)*4)+FM_SIZE+FM_LR_SAVE)(r1)	; Save the return
+
+			bl		EXT(mapSetUp)				; Turn off interrupts, translation, and possibly enter 64-bit
+		
+			mr		r26,r11						; Save the old MSR
+			lis		r27,hi16(hwpOpBase)			; Get high order of op base
+			slwi	r4,r4,7						; Convert preop to displacement
+			ori		r27,r27,lo16(hwpOpBase)		; Get low order of op base
+			slwi	r5,r5,7						; Convert op to displacement
+			add		r12,r4,r27					; Point to the preop routine
+			slwi	r28,r6,7					; Convert postop to displacement
+			mtctr	r12							; Set preop routine	
+			add		r28,r28,r27					; Get the address of the postop routine
+			add		r27,r5,r27					; Get the address of the op routine			
 
-LEXT(hw_test_rc)
+			bl		mapPhysLock					; Lock the physent
 
- 			mfsprg	r9,2						; Get feature flags 
-			mfmsr	r0							; Save the MSR 
-			rlwinm	r0,r0,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
- 			mr.		r4,r4						; See if we have a reset to do later
-			rlwinm	r0,r0,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-			rlwinm	r12,r0,0,MSR_EE_BIT+1,MSR_EE_BIT-1	; Clear interruption mask
-			crnot	htrReset,cr0_eq				; Remember reset
-			mtcrf	0x04,r9						; Set the features			
-			rlwinm	r12,r12,0,28,25				; Clear IR and DR
+			mr		r29,r3						; Save the physent address
+			
+			bt++	pf64Bitb,hwp64				; skip if 64-bit (only they take the hint)
 			
-			bt		pfNoMSRirb,htrNoMSR			; No MSR...
+			bctrl								; Call preop routine
+			bne-	hwpEarly32					; preop says to bail now...
+			
+ 			mtctr	r27							; Set up the op function address
+			lwz		r31,ppLink+4(r3)			; Grab the pointer to the first mapping
+			
+hwpSrc32:	rlwinm.	r31,r31,0,0,25				; Clean and test mapping address
+			beq		hwpNone32					; Did not find one...
 
-			mtmsr	r12							; Translation and all off
-			isync								; Toss prefetch
-			b		htrNoMSRx
+;
+;			Note: mapInvPte32 returns the PTE in R3 (or 0 if none), PTE high in R4, 
+;			PTE low in R5.  The PCA address is in R7.  The PTEG come back locked.
+;			If there is no PTE, PTE low is obtained from mapping
+;
+			bl		mapInvPte32					; Invalidate and lock PTE, also merge into physent
+		
+			bctrl								; Call the op function
+
+			crmove	cr1_eq,cr0_eq				; Save the return code
+						
+			mr.		r3,r3						; Was there a previously valid PTE?
+			beq-	hwpNxt32					; Nope...
 			
-htrNoMSR:	
-			mr		r2,r0
-			mr		r7,r3
-			li		r0,loadMSR					; Get the MSR setter SC
-			mr		r3,r12						; Get new MSR
-			sc									; Set it
-			mr		r3,r7
-			mr		r0,r2
-htrNoMSRx:
+			stw		r5,4(r3)					; Store second half of PTE
+			eieio								; Make sure we do not reorder
+			stw		r4,0(r3)					; Revalidate the PTE
 			
-			lwz		r2,mmPTEr(r3)				; Get the real part
-			lwz		r7,mmPTEhash(r3)			; Get pointer to hash list anchor
-			rlwinm.	r12,r2,0,24,24				; Is the change bit on?
-			lwz		r5,mmPTEv(r3)				; Get the virtual address
-			crnor	cr0_eq,cr0_eq,htrReset		; Set if C=1 && not reset
-			rlwinm	r7,r7,0,0,25				; Round hash list down to PCA boundary 
-			bt		cr0_eq,htrcset				; Special case changed but no reset case...
+			eieio								; Make sure all updates come first
+			stw		r6,0(r7)					; Unlock the PCA
+			
+hwpNxt32:	bne-	cr1,hwpEarly32				; op says to bail now...
+			lwz		r31,mpAlias+4(r31)			; Chain on to the next
+			b		hwpSrc32					; Check it out...
 
-			li		r12,1						; Get the locked value
+			.align	5
 
-htrLck1:	lwarx	r11,0,r7					; Get the PTEG lock
-			mr.		r11,r11						; Is it locked?
-			bne-	htrLckw1					; Yeah...
-			stwcx.	r12,0,r7					; Try to take it
-			bne-	htrLck1						; Someone else was trying, try again...
-			b		htrSXg1						; All done...
+hwpNone32:	mtctr	r28							; Get the post routine address
 			
-			.align	4
+			lwz		r30,ppLink+4(r29)			; Save the old RC
+			mr		r3,r29						; Get the physent address
+			bctrl								; Call post routine
 
-htrLckw1:	mr.		r11,r11						; Check if it is already held 
-			beq+	htrLck1						; It is clear... 
-			lwz		r11,0(r7)					; Get lock word again... 
-			b		htrLckw1					; Wait... 
+			bl		mapPhysUnlock				; Unlock the physent
 			
-			.align	4
+			mtmsr	r26							; Restore translation/mode/etc.
+			isync
+			
+			b		hwpReturn					; Go restore registers and return...
 
-htrSXg1:	isync								; Make sure we have not used anything yet
+			.align	5
 
- 			lwz		r6,mmPTEent(r3)				; Get the pointer to the PTE now that the lock is set
- 			lwz		r2,mmPTEr(r3)				; Get the mapping copy of the real part
+hwpEarly32:	lwz		r30,ppLink+4(r29)			; Save the old RC
+			mr		r3,r29						; Get the physent address
+			bl		mapPhysUnlock				; Unlock the physent
+			
+			mtmsr	r26							; Restore translation/mode/etc.
+			isync
+			
+			b		hwpReturn					; Go restore registers and return...
 
-			rlwinm	r9,r5,1,0,3					; Move in the segment
-			mr.		r6,r6						; Any PTE to invalidate?
-			rlwinm	r8,r5,31,2,25				; Line it up 
+			.align	5
 		
-			beq+	htrnopte					; There is no PTE to invalidate...
-			
-			xor		r8,r8,r6					; Back hash to virt index
-			rlwimi	r9,r5,22,4,9				; Move in the API
-			lis		r12,HIGH_ADDR(EXT(tlb_system_lock))	; Get the TLBIE lock
-			rlwinm	r5,r5,0,1,31				; Clear the valid bit
-			ori		r12,r12,LOW_ADDR(EXT(tlb_system_lock))	; Grab up the bottom part
-			mfspr	r11,pvr						; Find out what kind of machine we are
-			rlwimi	r9,r8,6,10,19				; Create the virtual address
-			rlwinm	r11,r11,16,16,31			; Isolate CPU type 
-
-			stw		r5,0(r6)					; Make the PTE invalid	
-			cmplwi	cr1,r11,3					; Is this a 603?
-			sync								; Make sure the invalid is stored
-						
-htrtlbhang:	lwarx	r11,0,r12					; Get the TLBIE lock
-			rlwinm	r8,r6,29,29,31				; Get the bit position of entry 
-			mr.		r11,r11						; Is it locked?
-			lis		r5,0x8000					; Start up a bit mask
-			li		r11,1						; Get our lock word 
-			bne-	htrtlbhang					; It is locked, go wait...
-			stwcx.	r11,0,r12					; Try to get it
-			bne-	htrtlbhang					; We was beat...
+hwp64:		bctrl								; Call preop routine
+			bne--	hwpEarly64					; preop says to bail now...
+			
+ 			mtctr	r27							; Set up the op function address
 			
-			li		r11,0						; Lock clear value 
+			li		r0,0xFF
+			ld		r31,ppLink(r3)				; Get the pointer to the first mapping
+			rldicl	r0,r0,62,0					; Rotate clean up mask to get 0xC0000000000000003F
+			
+hwpSrc64:	andc.	r31,r31,r0					; Clean and test mapping address
+			beq		hwpNone64					; Did not find one...
+;
+;			Note: mapInvPte64 returns the PTE in R3 (or 0 if none), PTE high in R4, 
+;			PTE low in R5. PTEG comes back locked if there is one
+;
+			bl		mapInvPte64					; Invalidate and lock PTEG, also merge into physent
 
-			tlbie	r9							;Invalidate it everywhere
+			bctrl								; Call the op function
 
-			beq-	cr1,htr603					; It is a 603, skip the tlbsync... 
+			crmove	cr1_eq,cr0_eq				; Save the return code
 			
-			eieio								; Make sure that the tlbie happens first
-			tlbsync								; wait for everyone to catch up
-			isync								
+			mr.		r3,r3						; Was there a previously valid PTE?
+			beq--	hwpNxt64					; Nope...
 			
-htr603:		stw		r11,0(r12)					; Clear the lock
-			srw		r5,r5,r8					; Make a "free slot" mask 
-			sync								; Make sure of it all 
-
-			lwz		r6,4(r6)					; Get the latest reference and change bits
-			stw		r11,mmPTEent(r3)			; Clear the pointer to the PTE 
-			rlwinm	r6,r6,0,23,24				; Extract the RC bits 
-			lwz		r9,PCAallo(r7)				; Get the allocation control bits 
-			rlwinm	r8,r5,24,8,15				; Make the autogen bit to turn off
-			lwz		r10,mmphysent(r3)			; Get any physical entry
-			or		r9,r9,r5					; Set the slot free 
-			rlwimi	r8,r8,24,16,23				; Get lock bit mask to turn it off
-			andc	r9,r9,r8					; Clear the auto and lock bits 
-			mr.		r10,r10						; Is there a physical entry?
-			li		r5,pepte1					; Get displacement to the second word of master pte
-			stw		r9,PCAallo(r7)				; Store the allocation controls
-			rlwimi	r2,r6,0,23,24				; Stick in RC bits
-			beq-	htrnopte					; No physical entry...
-			
-htrmrc:		lwarx	r11,r5,r10					; Get the master copy
-			or		r11,r11,r6					; Merge in latest RC
-			stwcx.	r11,r5,r10					; Save it back
-			bne-	htrmrc						; If it changed, try again... 
-
-htrnopte:	rlwinm	r5,r2,25,30,31				; Position RC and mask off
-			bf		htrReset,htrnorst			; No reset to do...
-			rlwinm	r2,r2,0,25,22				; Clear the RC if requested
-			
-htrnorst:	li		r4,0						; Get a 0 
-			stw		r2,mmPTEr(r3)				; Set the real part of the PTE
-			
-			sync								; Make sure that stuff is all stored
-
-			stw		r4,0(r7)					; Unlock the hash chain
+			std		r5,8(r3)					; Save bottom of PTE
+			eieio								; Make sure we do not reorder 
+			std		r4,0(r3)					; Revalidate the PTE
+			
+			eieio								; Make sure all updates come first
+			stw		r6,0(r7)					; Unlock the PCA
+
+hwpNxt64:	bne--	cr1,hwpEarly64				; op says to bail now...
+			ld		r31,mpAlias(r31)			; Chain on to the next
+			li		r0,0xFF
+			rldicl	r0,r0,62,0					; Rotate clean up mask to get 0xC0000000000000003F
+			b		hwpSrc64					; Check it out...
 	
-			mr		r3,r5						; Get the old RC to pass back
-			mtmsr	r0							; Restore interrupts and translation
+			.align	5
+			
+hwpNone64:	mtctr	r28							; Get the post routine address
+			
+			lwz		r30,ppLink+4(r29)			; Save the old RC
+			mr		r3,r29						; Get the physent address
+			bctrl								; Call post routine
+
+			bl		mapPhysUnlock				; Unlock the physent
+			
+			mtmsrd	r26							; Restore translation/mode/etc.
 			isync
-			blr									; Return...
+			b		hwpReturn					; Go restore registers and return...
 
-			.align	4
+			.align	5
 
-htrcset:	rlwinm	r3,r2,25,30,31				; Position RC and mask off
-			mtmsr	r0							; Restore interrupts and translation
-			isync
-			blr									; Return...
+hwpEarly64:	lwz		r30,ppLink+4(r29)			; Save the old RC
+			mr		r3,r29						; Get the physent address
+			bl		mapPhysUnlock				; Unlock the physent
+			
+			mtmsrd	r26							; Restore translation/mode/etc.
+			isync			
+
+hwpReturn:	lwz		r0,(FM_ALIGN((31-25+1)*4)+FM_SIZE+FM_LR_SAVE)(r1)	; Restore the return
+			lwz		r25,FM_ARG0+0x00(r1)		; Restore a register
+			lwz		r26,FM_ARG0+0x04(r1)		; Restore a register
+			mr		r3,r30						; Pass back the RC
+			lwz		r27,FM_ARG0+0x08(r1)		; Restore a register
+			lwz		r28,FM_ARG0+0x0C(r1)		; Restore a register
+			mtlr	r0							; Restore the return
+			lwz		r29,FM_ARG0+0x10(r1)		; Restore a register
+			lwz		r30,FM_ARG0+0x14(r1)		; Restore a register
+			lwz		r31,FM_ARG0+0x18(r1)		; Restore a register
+			lwz		r1,0(r1)					; Pop the stack
+			blr									; Leave...
 
 
-/*
- *			hw_phys_attr(struct phys_entry *pp, vm_prot_t prot, unsigned int wimg) - Sets the default physical page attributes
- *
- *			Note that this must be done with both interruptions off and VM off
- *			Move the passed in attributes into the pte image in the phys entry
- *	
- *			  
- */
+;
+;			The preop/op/postop function table.
+;			Each function must be 64-byte aligned and be no more than
+;			16 instructions.  If more than 16, we must fix address calculations
+;			at the start of hwpOpBase
+;
+;			The routine must set CR0_EQ in order to continue scan.
+;			If CR0_EQ is not set, an early return from the function is made.
+;
+
+			.align	7
+			
+hwpOpBase:
+
+;			Function 0 - No operation
+
+hwpNoop:	cmplw	r0,r0						; Make sure CR0_EQ is set
+			blr									; Just return...
 
 			.align	5
-			.globl	EXT(hw_phys_attr)
 
-LEXT(hw_phys_attr)
+;			This is the continuation of function 4 - Set attributes in mapping
 
-#if PERFTIMES && DEBUG
-			mflr	r11
-			mr		r8,r3
-			mr		r7,r5
-			mr		r5,r4
-//			lwz		r4,4(r3)
-			li		r4,0x1111
-			li		r3,30
-			bl		EXT(dbgLog2)						; Start of hw_add_map
-			mr		r3,r8
-			mr		r4,r5
-			mr		r5,r7
-			mtlr	r11
-#endif
-			mfsprg	r9,2						; Get feature flags 
-			mfmsr	r0							/* Save the MSR  */
-			rlwinm	r0,r0,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-			rlwinm	r0,r0,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-			andi.	r5,r5,0x0078				/* Clean up the WIMG */
-			rlwinm	r12,r0,0,MSR_EE_BIT+1,MSR_EE_BIT-1	/* Clear interruptions */
-			mtcrf	0x04,r9						; Set the features			
-			rlwimi	r5,r4,0,30,31				/* Move the protection into the wimg register */
-			la		r6,pepte1(r3)				/* Point to the default pte */
-			rlwinm	r12,r12,0,28,25				/* Clear IR and DR */
-
-			bt		pfNoMSRirb,hpaNoMSR			; No MSR...
-
-			mtmsr	r12							; Translation and all off
-			isync								; Toss prefetch
-			b		hpaNoMSRx
+;			We changed the attributes of a mapped page.  Make sure there are no cache paradoxes.
+;			NOTE: Do we have to deal with i-cache here?
+
+hwpSAM:		li		r11,4096						; Get page size
 			
-hpaNoMSR:	
-			mr		r10,r0
-			mr		r4,r3
-			li		r0,loadMSR					; Get the MSR setter SC
-			mr		r3,r12						; Get new MSR
-			sc									; Set it
-			mr		r3,r4
-			mr		r0,r10
-hpaNoMSRx:
-
-atmattr:	lwarx	r10,0,r6					/* Get the pte */
-			rlwimi	r10,r5,0,25,31				/* Move in the new attributes */
-			stwcx.	r10,0,r6					/* Try it on for size */
-			bne-	atmattr						/* Someone else was trying, try again... */
-		
-			mtmsr	r0							/* Interrupts and translation back on */
-			isync
-#if PERFTIMES && DEBUG
-			mflr	r11
-			mr		r4,r10
-			li		r3,31
-			bl		EXT(dbgLog2)						; Start of hw_add_map
-			mtlr	r11
-#endif
-			blr									/* All done... */
+hwpSAMinvd:	sub.	r11,r11,r9					; Back off a line
+			dcbf	r11,r5						; Flush the line in the data cache
+			bgt++	hwpSAMinvd					; Go do the rest of it...
+			
+			sync								; Make sure it is done
 
+			li		r11,4096						; Get page size
+			
+hwpSAMinvi:	sub.	r11,r11,r9					; Back off a line
+			icbi	r11,r5						; Flush the line in the icache
+			bgt++	hwpSAMinvi					; Go do the rest of it...
+			
+			sync								; Make sure it is done
 
+			cmpw	r0,r0						; Make sure we return CR0_EQ
+			blr									; Return...
 
-/*
- *			handlePF - handle a page fault interruption
- *
- *			If the fault can be handled, this routine will RFI directly,
- *			otherwise it will return with all registers as in entry.
- *
- *			Upon entry, state and all registers have been saved in savearea.
- *			This is pointed to by R13.
- *			IR and DR are off, interrupts are masked,
- *			Floating point be disabled.
- *			R3 is the interrupt code.
- *
- *			If we bail, we must restore cr5, and all registers except 6 and
- *			3.
- *
- */
-	
-			.align	5
-			.globl	EXT(handlePF)
 
-LEXT(handlePF)
+;			Function 1 - Set protection in physent
 
-/*
- *			This first part does a quick check to see if we can handle the fault.
- *			We can't handle any kind of protection exceptions here, so we pass
- *			them up to the next level.
- *
- *			The mapping lists are kept in MRS (most recently stolen)
- *			order on queues anchored within from the
- *			PTEG to which the virtual address hashes.  This is further segregated by
- *			the low-order 3 bits of the VSID XORed with the segment number and XORed
- *			with bits 4-7 of the vaddr in an attempt to keep the searches
- *			short.
- *			
- *			MRS is handled by moving the entry to the head of its list when stolen in the
- *			assumption that it will be revalidated soon.  Entries are created on the head 
- *			of the list because they will be used again almost immediately.
- *
- *			We need R13 set to the savearea, R3 set to the interrupt code, and R2
- *			set to the per_proc.
- *
- *			NOTE: In order for a page-fault redrive to work, the translation miss
- *			bit must be set in the DSISR (or SRR1 for IFETCH).  That must occur
- *			before we come here.
- */
+			.set	.,hwpOpBase+(1*128)			; Generate error if previous function too long
 
-			cmplwi	r3,T_INSTRUCTION_ACCESS		/* See if this is for the instruction */
-			lwz		r8,savesrr1(r13)			; Get the MSR to determine mode
-			beq-	gotIfetch					; We have an IFETCH here...
+hwpSPrtPhy:	li		r5,ppLink+4					; Get offset for flag part of physent
+
+hwpSPrtPhX:	lwarx	r4,r5,r29					; Get the old flags
+			rlwimi	r4,r25,0,ppPPb-32,ppPPe-32	; Stick in the new protection
+			stwcx.	r4,r5,r29					; Try to stuff it
+			bne--	hwpSPrtPhX					; Try again...
+;			Note: CR0_EQ is set because of stwcx.
+			blr									; Return...
 			
-			lwz		r7,savedsisr(r13)			/* Get the DSISR */
-			lwz		r6,savedar(r13)				/* Get the fault address */
-			b		ckIfProt					; Go check if this is a protection fault...
 
-gotIfetch:	mr		r7,r8						; IFETCH info is in SRR1
-			lwz		r6,savesrr0(r13)			/* Get the instruction address */
+;			Function 2 - Set protection in mapping
 
-ckIfProt:	rlwinm.	r7,r7,0,1,1					; Is this a protection exception?
-			beqlr-								; Yes... (probably not though)
+			.set	.,hwpOpBase+(2*128)			; Generate error if previous function too long
 
-/*
- *			We will need to restore registers if we bail after this point.
- *			Note that at this point several SRs have been changed to the kernel versions.
- *			Therefore, for these we must build these values.
- */
+hwpSPrtMap:	lwz		r9,mpFlags(r31)				; Get the mapping flags
+			lwz		r8,mpVAddr+4(r31)			; Get the protection part of mapping
+			rlwinm.	r9,r9,0,mpPermb,mpPermb		; Is the mapping permanent?
+			li		r0,lo16(mpPP)				; Get protection bits
+			crnot	cr0_eq,cr0_eq				; Change CR0_EQ to true if mapping is permanent
+			rlwinm	r2,r25,0,mpPPb-32,mpPPb-32+2	; Isolate new protection 
+			beqlr--								; Leave if permanent mapping (before we trash R5)...
+			andc	r5,r5,r0					; Clear the old prot bits
+			or		r5,r5,r2					; Move in the prot bits
+			rlwimi	r8,r5,0,20,31				; Copy into the mapping copy
+			cmpw	r0,r0						; Make sure we return CR0_EQ
+			stw		r8,mpVAddr+4(r31)			; Set the flag part of mapping
+			blr									; Leave...
+			
+;			Function 3 - Set attributes in physent
 
-#if PERFTIMES && DEBUG
-			mflr	r11
-			mr		r5,r6
-			mr		r4,r3
-			li		r3,32
-			bl		EXT(dbgLog2)						; Start of hw_add_map
-			mr		r3,r4
-			mtlr	r11
-			mfsprg	r2,0
-#endif
-			lwz		r3,PP_USERPMAP(r2)			; Get the user pmap (not needed if kernel access, but optimize for user??)
-			rlwinm.	r8,r8,0,MSR_PR_BIT,MSR_PR_BIT	; Supervisor state access?
-			rlwinm	r5,r6,6,26,29				; Get index to the segment slot
-			eqv		r1,r1,r1					; Fill the bottom with foxes
-			bne+	notsuper					; Go do the user mode interrupt stuff...
-			
-			cmplwi	cr1,r5,SR_COPYIN_NUM*4		; See if this is the copyin/copyout segment
-			rlwinm	r3,r6,24,8,11				; Make the kernel VSID
-			bne+	cr1,havevsid				; We are done if we do not want the copyin/out guy...
-			
-			mfsr	r3,SR_COPYIN				; Get the copy vsid
-			b		havevsid					; Join up...
-
-			.align	5
-
-notsuper:	addi	r5,r5,PMAP_SEGS				; Get offset to table
-			lwzx	r3,r3,r5					; Get the VSID
-
-havevsid:	mfspr	r5,sdr1						/* Get hash table base and size */
-			cror	cr1_eq,cr0_eq,cr0_eq		; Remember if kernel fault for later
-			rlwinm	r9,r6,2,2,5					; Move nybble 1 up to 0 (keep aligned with VSID)
-			rlwimi	r1,r5,16,0,15				/* Make table size -1 out of mask */
-			rlwinm	r3,r3,6,2,25				/* Position the space for the VSID */
-			rlwinm	r7,r6,26,10,25				/* Isolate the page index */
-			xor		r9,r9,r3					; Splooch vaddr nybble 0 (from VSID) and 1 together
-			or		r8,r5,r1					/* Point to the last byte in table */
-			xor		r7,r7,r3					/* Get primary hash */
-			rlwinm	r3,r3,1,1,24				/* Position VSID for pte ID */
-			addi	r8,r8,1						/* Point to the PTEG Control Area */
-			rlwinm	r9,r9,8,27,29				; Get splooched bits in place
-			and		r7,r7,r1					/* Wrap the hash */
-			rlwimi	r3,r6,10,26,31				/* Move API into pte ID */
-			add		r8,r8,r7					/* Point to our PCA entry */
-			rlwinm	r12,r3,27,27,29				; Get low 3 bits of the VSID for look-aside hash
-			la		r11,PCAhash(r8)				/* Point to the mapping hash area */
-			xor		r9,r9,r12					; Finish splooching nybble 0, 1, and the low bits of the VSID
+			.set	.,hwpOpBase+(3*128)			; Generate error if previous function too long
 
+hwpSAtrPhy:	li		r5,ppLink+4					; Get offset for flag part of physent
 
-/*
- *			We have about as much as we need to start searching the autogen (aka block maps)
- *			and mappings.  From here on, any kind of failure will bail, and
- *			contention will either bail or restart from here.
- *
- *			
- */
-			
-			li		r12,1						/* Get the locked value */
-			dcbt	0,r11						/* We'll need the hash area in a sec, so get it */
-			add		r11,r11,r9					/* Point to the right mapping hash slot */
-			
-ptegLck:	lwarx	r10,0,r8					/* Get the PTEG lock */
-			mr.		r10,r10						/* Is it locked? */
-			bne-	ptegLckw					/* Yeah... */
-			stwcx.	r12,0,r8					/* Take take it */
-			bne-	ptegLck						/* Someone else was trying, try again... */
-			b		ptegSXg						/* All done... */
+hwpSAtrPhX:	lwarx	r4,r5,r29					; Get the old flags
+			rlwimi	r4,r25,0,ppIb-32,ppGb-32	; Stick in the new attributes
+			stwcx.	r4,r5,r29					; Try to stuff it
+			bne--	hwpSAtrPhX					; Try again...
+;			Note: CR0_EQ is set because of stwcx.
+			blr									; Return...
 			
-			.align	4
+;			Function 4 - Set attributes in mapping
+
+			.set	.,hwpOpBase+(4*128)			; Generate error if previous function too long
 
-ptegLckw:	mr.		r10,r10						/* Check if it's already held */
-			beq+	ptegLck						/* It's clear... */
-			lwz		r10,0(r8)					/* Get lock word again... */
-			b		ptegLckw					/* Wait... */
+hwpSAtrMap:	lwz		r9,mpFlags(r31)				; Get the mapping flags
+			lwz		r8,mpVAddr+4(r31)			; Get the attribute part of mapping
+			li		r2,0x10						; Force on coherent
+			rlwinm.	r9,r9,0,mpPermb,mpPermb		; Is the mapping permanent?
+			li		r0,lo16(mpWIMG)				; Get wimg mask		
+			crnot	cr0_eq,cr0_eq				; Change CR0_EQ to true if mapping is permanent
+			rlwimi	r2,r2,mpIb-ppIb,mpIb-32,mpIb-32	; Copy in the cache inhibited bit
+			beqlr--								; Leave if permanent mapping (before we trash R5)...
+			andc	r5,r5,r0					; Clear the old wimg
+			rlwimi	r2,r2,32-(mpGb-ppGb),mpGb-32,mpGb-32	; Copy in the guarded bit
+			mfsprg	r9,2						; Feature flags
+			or		r5,r5,r2					; Move in the new wimg
+			rlwimi	r8,r5,0,20,31				; Copy into the mapping copy
+			lwz		r2,mpPAddr(r31)				; Get the physical address
+			li		r0,0xFFF					; Start a mask
+			andi.	r9,r9,pf32Byte+pf128Byte	; Get cache line size
+			rlwinm	r5,r0,0,1,0					; Copy to top half
+			stw		r8,mpVAddr+4(r31)			; Set the flag part of mapping
+			rlwinm	r2,r2,12,1,0				; Copy to top and rotate to make physical address with junk left
+			and		r5,r5,r2					; Clean stuff in top 32 bits
+			andc	r2,r2,r0					; Clean bottom too
+			rlwimi	r5,r2,0,0,31				; Insert low 23 to make full physical address
+			b		hwpSAM						; Join common
 			
-			.align	5
+;			NOTE: we moved the remainder of the code out of here because it
+;			did not fit in the 128 bytes allotted.  It got stuck into the free space
+;			at the end of the no-op function.
+
+
+
 			
-			nop									; Force ISYNC to last instruction in IFETCH
-			nop									
-			nop
+;			Function 5 - Clear reference in physent
 
-ptegSXg:	isync								/* Make sure we haven't used anything yet */
+			.set	.,hwpOpBase+(5*128)			; Generate error if previous function too long
 
-			lwz		r9,0(r11)					/* Pick up first mapping block */
-			mr		r5,r11						/* Get the address of the anchor */
-			mr		r7,r9						/* Save the first in line */
-			b		findmap						; Take space and force loop to cache line
-		
-findmap:	mr.		r12,r9						/* Are there more? */
-			beq-	tryAuto						/* Nope, nothing in mapping list for us... */
-			
-			lwz		r10,mmPTEv(r12)				/* Get unique PTE identification */
-			lwz		r9,mmhashnext(r12)			/* Get the chain, just in case */
-			cmplw	r10,r3						/* Did we hit our PTE? */
- 			lwz		r0,mmPTEent(r12)			/* Get the pointer to the hash table entry */
-			mr		r5,r12						/* Save the current as previous */
-			bne-	findmap						; Nothing here, try the next...
-
-;			Cache line boundary here
-
-			cmplwi	cr1,r0,0					/* Is there actually a PTE entry in the hash? */
-			lwz		r2,mmphysent(r12)			/* Get the physical entry */
-			bne-	cr1,MustBeOK				/* There's an entry in the hash table, so, this must 
-												   have been taken care of already... */
-			lis		r4,0x8000					; Tell PTE inserter that this was not an auto
-			cmplwi	cr2,r2,0					/* Is there a physical entry? */
-			li		r0,0x0100					/* Force on the reference bit whenever we make a PTE valid */
-			bne+	cr2,gotphys					/* Skip down if we have a physical entry */
-			li		r0,0x0180					/* When there is no physical entry, force on
-												   both R and C bits to keep hardware from
-												   updating the PTE to set them.  We don't
-												   keep track of RC for I/O areas, so this is ok */
-			
-gotphys:	lwz		r2,mmPTEr(r12)				; Get the second part of the PTE
-			b		insert						/* Go insert into the PTEG... */
-
-MustBeOK:	li		r10,0						/* Get lock clear value */
-			li		r3,T_IN_VAIN				/* Say that we handled it */
-			stw		r10,PCAlock(r8)				/* Clear the PTEG lock */
-
-#if PERFTIMES && DEBUG
-			mflr	r11
-			mr		r4,r3
-			li		r3,33
-			bl		EXT(dbgLog2)						; Start of hw_add_map
-			mr		r3,r4
-			mtlr	r11
-#endif
-			blr									/* Blow back and handle exception */
+hwpCRefPhy:	li		r5,ppLink+4					; Get offset for flag part of physent
 
+hwpCRefPhX:	lwarx	r4,r5,r29					; Get the old flags
+			rlwinm	r4,r4,0,ppRb+1-32,ppRb-1-32		; Clear R
+			stwcx.	r4,r5,r29					; Try to stuff it
+			bne--	hwpCRefPhX					; Try again...
+;			Note: CR0_EQ is set because of stwcx.
+			blr									; Return...
 
 			
-/*
- *			We couldn't find it in the mapping list.  As a last try, we will
- *			see if we can autogen it from the block mapped list.
- *	
- *			A block mapped area is defined as a contiguous virtual area that is mapped to 
- *			a contiguous physical area.  The olde-tyme IBM VM/XA Interpretive Execution
- *			architecture referred to this as a V=F, or Virtual = Fixed area. 
- *
- *			We consider a V=F area to be a single entity, adjacent areas can not be merged
- *			or overlapped.  The protection and memory attributes are the same and reference
- *			and change indications are not kept. The areas are not considered part of the
- *			physical RAM of the machine and do not have any associated physical table
- *			entries. Their primary use is intended for mapped I/O areas (e.g., framebuffers)
- *			although certain areas of RAM, such as the kernel V=R memory, can be mapped.
- *
- *			We also have a problem in the case of copyin/out: that access is done
- *			within the kernel for a user address. Unfortunately, the user isn't
- *			necessarily the current guy.  That means that we don't have access to the
- *			right autogen list. We can't support this kind of access. So, we need to do
- *			a quick check here and cause a fault if an attempt to copyin or out to
- *			any autogenned area.
- *
- *			The lists must be kept short.
- *
- *			NOTE:  kernel_pmap_store must be in V=R storage!!!!!!!!!!!!!!
- */
- 
-			.align	5
+;			Function 6 - Clear reference in mapping 
 
-tryAuto:	rlwinm.	r11,r3,0,5,24				; Check if this is a kernel VSID
-			lis		r10,HIGH_ADDR(EXT(kernel_pmap_store)+PMAP_BMAPS)	; Get the top part of kernel block map anchor
-			crandc	cr0_eq,cr1_eq,cr0_eq		; Set if kernel access and non-zero VSID (copyin or copyout)
-			mfsprg	r11,0						; Get the per_proc area
-			beq-	cr0,realFault					; Can not autogen for copyin/copyout...
-			ori		r10,r10,LOW_ADDR(EXT(kernel_pmap_store)+PMAP_BMAPS)	; Get the bottom part
-			beq-	cr1,bmInKernel				; We are in kernel... (cr1 set way back at entry)
-			
-			lwz		r10,PP_USERPMAP(r11)		; Get the user pmap
-			la		r10,PMAP_BMAPS(r10)			; Point to the chain anchor
-			b		bmInKernel					; Jump over alignment gap...
-			nop
-			nop
-			nop
-			nop
-			nop
-			nop						
-bmInKernel:
-#ifndef CHIP_ERRATA_MAX_V1
-			lwarx	r9,0,r10	
-#endif /* CHIP_ERRATA_MAX_V1 */
-
-bmapLck:	lwarx	r9,0,r10					; Get the block map anchor and lock
-			rlwinm.	r5,r9,0,31,31				; Is it locked?
-			ori		r5,r5,1						; Set the lock
-			bne-	bmapLckw					; Yeah...
-			stwcx.	r5,0,r10					; Lock the bmap list
-			bne-	bmapLck						; Someone else was trying, try again...
-			b		bmapSXg						; All done...
-			
-			.align	4
-
-bmapLckw:	rlwinm.	r5,r9,0,31,31				; Check if it is still held
-			beq+	bmapLck						; Not no more...
-			lwz		r9,0(r10)					; Get lock word again...
-			b		bmapLckw					; Check it out...
-			
-			.align	5
-			
-			nop									; Force ISYNC to last instruction in IFETCH
-			nop									
-			nop
-
-bmapSXg:	rlwinm.	r4,r9,0,0,26				; Clear out flags and lock
-			isync								; Make sure we have not used anything yet
-			bne+	findAuto					; We have something, let us go...
-			
-bmapNone:	stw		r9,0(r10)					; Unlock it, we have nothing here
-												; No sync here because we have not changed anything
-			
-/*
- *			When we come here, we know that we can't handle this.  Restore whatever
- *			state that we trashed and go back to continue handling the interrupt.
- */
+			.set	.,hwpOpBase+(6*128)			; Generate error if previous function too long
 
-realFault:	li		r10,0						/* Get lock clear value */
-			lwz		r3,saveexception(r13)		/* Figure out the exception code again */
-			stw		r10,PCAlock(r8)				/* Clear the PTEG lock */
-#if PERFTIMES && DEBUG
-			mflr	r11
-			mr		r4,r3
-			li		r3,33
-			bl		EXT(dbgLog2)						; Start of hw_add_map
-			mr		r3,r4
-			mtlr	r11
-#endif
-			blr									/* Blow back and handle exception */
-			
-			.align	5
-			
-findAuto:	mr.		r4,r4						; Is there more?
-			beq-	bmapNone					; No more...
-			lwz		r5,bmstart(r4)				; Get the bottom of range
-			lwz		r11,bmend(r4)				; Get the top of range
-			cmplw	cr0,r6,r5					; Are we before the entry?
-			cmplw	cr1,r6,r11					; Are we after the entry?
-			cror	cr1_eq,cr0_lt,cr1_gt		; Set cr1_eq if new not in range
-			bne+	cr1,faGot					; Found it...
-			
-			lwz		r4,bmnext(r4)				; Get the next one
-			b		findAuto					; Check it out...
-			
-faGot:		
-			lwz		r7,blkFlags(r4)				; Get the flags
-			rlwinm. r7,r7,0,blkRembit,blkRembit	; is this mapping partially removed
-			bne		bmapNone					; Pending remove, bail out
-			rlwinm	r6,r6,0,0,19				; Round to page
-			lwz		r2,bmPTEr(r4)				; Get the real part of the PTE
-			sub		r5,r6,r5					; Get offset into area
-			stw		r9,0(r10)					; Unlock it, we are done with it (no sync needed)
-			add		r2,r2,r5					; Adjust the real address
-			
-			lis		r4,0x8080					/* Indicate that this was autogened */
-			li		r0,0x0180					/* Autogenned areas always set RC bits.
-												   This keeps the hardware from having
-												   to do two storage writes */
-			
-/*
- *			Here where we insert the PTE into the hash.  The PTE image is in R3, R2. 
- *			The PTEG allocation controls are a bit map of the state of the PTEG. The
- *			PCAlock bits are a temporary lock for the specified PTE.  PCAfree indicates that
- *			the PTE slot is empty. PCAauto means that it comes from an autogen area.  These
- *			guys do not keep track of reference and change and are actually "wired".
- *			They're easy to maintain. PCAsteal
- *			is a sliding position mask used to "randomize" PTE slot stealing.  All 4 of these
- *			fields fit in a single word and are loaded and stored under control of the
- *			PTEG control area lock (PCAlock).
- *
- *			Note that PCAauto does not contribute to the steal calculations at all.  Originally
- *			it did, autogens were second in priority.  This can result in a pathalogical
- *			case where an instruction can not make forward progress, or one PTE slot
- *			thrashes.
- *
- *			Physically, the fields are arranged:
- *				0: PCAfree
- *				1: PCAauto
- *				2: PCAlock
- *				3: PCAsteal
- */
-			
-insert:		lwz		r10,PCAallo(r8)				/* Get the PTEG controls */
-			eqv		r6,r6,r6					/* Get all ones */		
-			mr		r11,r10						/* Make a copy */
-			rlwimi	r6,r10,8,16,23				/* Insert sliding steal position */
-			rlwimi	r11,r11,24,24,31			/* Duplicate the locked field */
-			addi	r6,r6,-256					/* Form mask */
-			rlwimi	r11,r11,16,0,15				/* This gives us a quadrupled lock mask */
-			rlwinm	r5,r10,31,24,0				/* Slide over the mask for next time */
-			mr		r9,r10						/* Make a copy to test */
-			not		r11,r11						/* Invert the quadrupled lock */
-			or		r2,r2,r0					/* Force on R, and maybe C bit */
-			and		r9,r9,r11					/* Remove the locked guys */
-			rlwimi	r5,r5,8,24,24				/* Wrap bottom bit to top in mask */
-			rlwimi	r9,r11,0,16,31				/* Put two copies of the unlocked entries at the end */
-			rlwinm	r6,r6,0,16,7				; Remove the autogens from the priority calculations
-			rlwimi	r10,r5,0,24,31				/* Move steal map back in */
-			and		r9,r9,r6					/* Set the starting point for stealing */
-
-/*			So, now we have in R9:
-				byte 0 = ~locked & free 
-				byte 1 = 0 
-				byte 2 = ~locked & (PCAsteal - 1)
-				byte 3 = ~locked
-
-				Each bit position represents (modulo 8) a PTE. If it is 1, it is available for 
-				allocation at its priority level, left to right.  
-				
-			Additionally, the PCA steal field in R10 has been rotated right one bit.
-*/
-			
-
-			rlwinm	r21,r10,8,0,7				; Isolate just the old autogen bits
-			cntlzw	r6,r9						/* Allocate a slot */
-			mr		r14,r12						/* Save our mapping for later */
-			cmplwi	r6,32						; Was there anything available?
-			rlwinm	r7,r6,29,30,31				/* Get the priority slot we got this from */
-			rlwinm	r6,r6,0,29,31				; Isolate bit position
-			srw		r11,r4,r6					/* Position the PTEG control bits */
-			slw		r21,r21,r6					; Move corresponding old autogen flag to bit 0
-			mr		r22,r11						; Get another copy of the selected slot
-			
-			beq-	realFault					/* Arghh, no slots! Take the long way 'round... */
-			
-												/* Remember, we've already set up the mask pattern
-												   depending upon how we got here:
-												     if got here from simple mapping, R4=0x80000000,
-												     if we got here from autogen it is 0x80800000. */
-			
-			rlwinm	r6,r6,3,26,28				/* Start calculating actual PTE address */
-			rlwimi	r22,r22,24,8,15				; Duplicate selected slot in second byte
-			rlwinm.	r11,r11,0,8,15				/* Isolate just the auto bit (remember about it too) */
-			andc	r10,r10,r22					/* Turn off the free and auto bits */
-			add		r6,r8,r6					/* Get position into PTEG control area */
- 			cmplwi	cr1,r7,1					/* Set the condition based upon the old PTE type */
-			sub		r6,r6,r1					/* Switch it to the hash table */
-			or		r10,r10,r11					/* Turn auto on if it is (PTEG control all set up now) */			
-			subi	r6,r6,1						/* Point right */
-			stw		r10,PCAallo(r8)				/* Allocate our slot */
-			dcbt	br0,r6						; Touch in the PTE
-			bne		wasauto						/* This was autogenned... */
-			
-			stw		r6,mmPTEent(r14)			/* Link the mapping to the PTE slot */
-			
-/*
- *			So, now we're here and what exactly do we have?  We've got: 
- *				1)	a full PTE entry, both top and bottom words in R3 and R2
- *				2)	an allocated slot in the PTEG.
- *				3)	R8 still points to the PTEG Control Area (PCA)
- *				4)	R6 points to the PTE entry.
- *				5)	R1 contains length of the hash table-1. We use this to back-translate
- *					a PTE to a virtual address so we can invalidate TLBs.
- *				6)	R11 has a copy of the PCA controls we set.
- *				7a)	R7 indicates what the PTE slot was before we got to it. 0 shows
- *					that it was empty and 2 or 3, that it was
- *					a we've stolen a live one. CR1 is set to LT for empty and GT
- *					otherwise.
- *				7b)	Bit 0 of R21 is 1 if the stolen PTE was autogenned
- *				8)	So far as our selected PTE, it should be valid if it was stolen
- *					and invalid if not.  We could put some kind of assert here to
- *					check, but I think that I'd rather leave it in as a mysterious,
- *					non-reproducable bug.
- *				9)	The new PTE's mapping has been moved to the front of its PTEG hash list
- *					so that it's kept in some semblance of a MRU list.
- *			   10)	R14 points to the mapping we're adding.
- *
- *			So, what do we have to do yet?
- *				1)	If we stole a slot, we need to invalidate the PTE completely.
- *				2)	If we stole one AND it was not an autogen, 
- *					copy the entire old PTE (including R and C bits) to its mapping.
- *				3)	Set the new PTE in the PTEG and make sure it is valid.
- *				4)	Unlock the PTEG control area.
- *				5)	Go back to the interrupt handler, changing the interrupt
- *					code to "in vain" which will restore the registers and bail out.
- *
- */
-wasauto:	oris	r3,r3,0x8000				/* Turn on the valid bit */
-			blt+	cr1,slamit					/* It was empty, go slam it on in... */
-			
-			lwz		r10,0(r6)					/* Grab the top part of the PTE */
-			rlwinm	r12,r6,6,4,19				/* Match up the hash to a page boundary */
-			rlwinm	r5,r10,5,4,19				/* Extract the VSID to a page boundary */
-			rlwinm	r10,r10,0,1,31				/* Make it invalid */
-			xor		r12,r5,r12					/* Calculate vaddr */
-			stw		r10,0(r6)					/* Invalidate the PTE */
-			rlwinm	r5,r10,7,27,29				; Move nybble 0 up to subhash position
-			rlwimi	r12,r10,1,0,3				/* Move in the segment portion */
-			lis		r9,HIGH_ADDR(EXT(tlb_system_lock))	/* Get the TLBIE lock */
-			xor		r5,r5,r10					; Splooch nybble 0 and 1
-			rlwimi	r12,r10,22,4,9				/* Move in the API */
-			ori		r9,r9,LOW_ADDR(EXT(tlb_system_lock))	/* Grab up the bottom part */
-			rlwinm	r4,r10,27,27,29				; Get low 3 bits of the VSID for look-aside hash
-			
-			sync								/* Make sure the invalid is stored */
-
-			xor		r4,r4,r5					; Finish splooching nybble 0, 1, and the low bits of the VSID
-						
-tlbhang:	lwarx	r5,0,r9						/* Get the TLBIE lock */
-		
-			rlwinm	r4,r4,0,27,29				; Clean up splooched hash value
+hwpCRefMap:	li		r0,lo16(mpR)				; Get reference bit
+			lwz		r8,mpVAddr+4(r31)			; Get the flag part of mapping
+			andc	r5,r5,r0					; Clear in PTE copy
+			andc	r8,r8,r0					; and in the mapping
+			cmpw	r0,r0						; Make sure we return CR0_EQ
+			stw		r8,mpVAddr+4(r31)			; Set the flag part of mapping
+			blr									; Return...
 
-			mr.		r5,r5						/* Is it locked? */
-			add		r4,r4,r8					/* Point to the offset into the PCA area */
-			li		r5,1						/* Get our lock word */
-			bne-	tlbhang						/* It's locked, go wait... */
-			
-			la		r4,PCAhash(r4)				/* Point to the start of the hash chain for the PTE we're replacing */
 			
-			stwcx.	r5,0,r9						/* Try to get it */
-			bne-	tlbhang						/* We was beat... */
-			
-			mfspr	r7,pvr						/* Find out what kind of machine we are */
-			li		r5,0						/* Lock clear value */
-			rlwinm	r7,r7,16,16,31				/* Isolate CPU type */
+;			Function 7 - Clear change in physent
 
-			tlbie	r12							/* Invalidate it everywhere */
+			.set	.,hwpOpBase+(7*128)			; Generate error if previous function too long
 
-			cmplwi	r7,3						/* Is this a 603? */
-			stw		r5,0(r9)					/* Clear the lock */
-			
-			beq-	its603						/* It's a 603, skip the tlbsync... */
-			
-			eieio								/* Make sure that the tlbie happens first */
-			tlbsync								/* wait for everyone to catch up */
-			isync								
-			
-its603:		rlwinm.	r21,r21,0,0,0				; See if we just stole an autogenned entry
-			sync								/* Make sure of it all */
+hwpCCngPhy:	li		r5,ppLink+4					; Get offset for flag part of physent
 
-			bne		slamit						; The old was an autogen, time to slam the new in...
-			
-			lwz		r9,4(r6)					/* Get the real portion of old PTE */
-			lwz		r7,0(r4)					/* Get the first element.  We can't get to here
-												   if we aren't working with a mapping... */
-			mr		r0,r7						; Save pointer to first element
-												   
-findold:	mr		r1,r11						; Save the previous guy
-			mr.		r11,r7						/* Copy and test the chain */
-			beq-	bebad						/* Assume it's not zero... */
+hwpCCngPhX:	lwarx	r4,r5,r29					; Get the old flags
+			rlwinm	r4,r4,0,ppCb+1-32,ppCb-1-32	; Clear C
+			stwcx.	r4,r5,r29					; Try to stuff it
+			bne--	hwpCCngPhX					; Try again...
+;			Note: CR0_EQ is set because of stwcx.
+			blr									; Return...
 			
-			lwz		r5,mmPTEv(r11)				/* See if this is the old active one */
-			cmplw	cr2,r11,r14					/* Check if this is actually the new one */
-			cmplw	r5,r10						/* Is this us?  (Note: valid bit kept off in mappings) */
-			lwz		r7,mmhashnext(r11)			/* Get the next one in line */
-			beq-	cr2,findold					/* Don't count the new one... */
-			cmplw	cr2,r11,r0					; Check if we are first on the list
-			bne+	findold						/* Not it (and assume the worst)... */
 			
-			lwz		r12,mmphysent(r11)			/* Get the pointer to the physical entry */
-			beq-	cr2,nomove					; We are first, no need to requeue...
+;			Function 8 - Clear change in mapping
 
-			stw		r11,0(r4)					; Chain us to the head
-			stw		r0,mmhashnext(r11)			; Chain the old head to us
-			stw		r7,mmhashnext(r1)			; Unlink us
+			.set	.,hwpOpBase+(8*128)			; Generate error if previous function too long
+
+hwpCCngMap:	li		r0,lo16(mpC)				; Get change bit
+			lwz		r8,mpVAddr+4(r31)			; Get the flag part of mapping
+			andc	r5,r5,r0					; Clear in PTE copy
+			andc	r8,r8,r0					; and in the mapping
+			cmpw	r0,r0						; Make sure we return CR0_EQ
+			stw		r8,mpVAddr+4(r31)			; Set the flag part of mapping
+			blr									; Return...
 
-nomove:		li		r5,0						/* Clear this on out */
-			
-			mr.		r12,r12						/* Is there a physical entry? */
-			stw		r5,mmPTEent(r11)			; Clear the PTE entry pointer
-			li		r5,pepte1					/* Point to the PTE last half */
-			stw		r9,mmPTEr(r11)				; Squirrel away the whole thing (RC bits are in here)
-			
-			beq-	mrgmrcx						; No physical entry for this one...
 			
-			rlwinm	r11,r9,0,23,24				/* Keep only the RC bits */
+;			Function 9 - Set reference in physent
 
-mrgmrcx:	lwarx	r9,r5,r12					/* Get the master copy */
-			or		r9,r9,r11					/* Merge in latest RC */
-			stwcx.	r9,r5,r12					/* Save it back */
-			bne-	mrgmrcx						/* If it changed, try again... */
+			.set	.,hwpOpBase+(9*128)			; Generate error if previous function too long
 
-/*
- *			Here's where we finish up.  We save the real part of the PTE, eieio it, to make sure it's
- *			out there before the top half (with the valid bit set).
- */
+hwpSRefPhy:	li		r5,ppLink+4					; Get offset for flag part of physent
+
+hwpSRefPhX:	lwarx	r4,r5,r29					; Get the old flags
+			ori		r4,r4,lo16(ppR)				; Set the reference
+			stwcx.	r4,r5,r29					; Try to stuff it
+			bne--	hwpSRefPhX					; Try again...
+;			Note: CR0_EQ is set because of stwcx.
+			blr									; Return...
 
-slamit:		stw		r2,4(r6)					/* Stash the real part */
-			li		r4,0						/* Get a lock clear value */
-			eieio								/* Erect a barricade */
-			stw		r3,0(r6)					/* Stash the virtual part and set valid on */
-
-			stw		r4,PCAlock(r8)				/* Clear the PCA lock */
-
-			li		r3,T_IN_VAIN				/* Say that we handled it */
-			sync								/* Go no further until the stores complete */
-#if PERFTIMES && DEBUG
-			mflr	r11
-			mr		r4,r3
-			li		r3,33
-			bl		EXT(dbgLog2)						; Start of hw_add_map
-			mr		r3,r4
-			mtlr	r11
-#endif
-			blr									/* Back to the fold... */
-					
-bebad:		lis		r0,HIGH_ADDR(Choke)			/* We have a kernel choke!!! */
-			ori		r0,r0,LOW_ADDR(Choke)				
-			sc									/* Firmware Heimlich maneuver */
 			
-/*
- *			This walks the hash table or DBATs to locate the physical address of a virtual one.
- *			The space is provided.  If it is the kernel space, the DBATs are searched first.  Failing
- *			that, the hash table is accessed. Zero is returned for failure, so it must be special cased.
- *			This is usually used for debugging, so we try not to rely
- *			on anything that we don't have to.
- */
+;			Function 10 - Set reference in mapping
+
+			.set	.,hwpOpBase+(10*128)		; Generate error if previous function too long
 
-ENTRY(LRA, TAG_NO_FRAME_USED)
+hwpSRefMap:	lwz		r8,mpVAddr+4(r31)			; Get the flag part of mapping
+			ori		r5,r5,lo16(mpR)				; Set reference in PTE low
+			ori		r8,r8,lo16(mpR)				; Set reference in mapping
+			cmpw	r0,r0						; Make sure we return CR0_EQ
+			stw		r8,mpVAddr+4(r31)			; Set the flag part of mapping
+			blr									; Return...
+			
+;			Function 11 - Set change in physent
 
-			mfsprg	r8,2						; Get feature flags 
-			mfmsr	r10							/* Save the current MSR */
-			rlwinm	r10,r10,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-			rlwinm	r10,r10,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-			mtcrf	0x04,r8						; Set the features			
-			xoris	r5,r3,HIGH_ADDR(PPC_SID_KERNEL)		/* Clear the top half if equal */
-			andi.	r9,r10,0x7FCF				/* Turn off interrupts and translation */
-			eqv		r12,r12,r12					/* Fill the bottom with foxes */
+			.set	.,hwpOpBase+(11*128)		; Generate error if previous function too long
 
-			bt		pfNoMSRirb,lraNoMSR			; No MSR...
+hwpSCngPhy:	li		r5,ppLink+4					; Get offset for flag part of physent
 
-			mtmsr	r9							; Translation and all off
-			isync								; Toss prefetch
-			b		lraNoMSRx
+hwpSCngPhX:	lwarx	r4,r5,r29					; Get the old flags
+			ori		r4,r4,lo16(ppC)				; Set the change bit
+			stwcx.	r4,r5,r29					; Try to stuff it
+			bne--	hwpSCngPhX					; Try again...
+;			Note: CR0_EQ is set because of stwcx.
+			blr									; Return...
 			
-lraNoMSR:	
-			mr		r7,r3
-			li		r0,loadMSR					; Get the MSR setter SC
-			mr		r3,r9						; Get new MSR
-			sc									; Set it
-			mr		r3,r7
-lraNoMSRx:
-
-			cmplwi	r5,LOW_ADDR(PPC_SID_KERNEL)	/* See if this is kernel space */
-			rlwinm	r11,r3,6,6,25				/* Position the space for the VSID */
-			isync								/* Purge pipe */
-			bne-	notkernsp					/* This is not for the kernel... */		
-			
-			mfspr	r5,dbat0u					/* Get the virtual address and length */
-			eqv		r8,r8,r8					/* Get all foxes */
-			rlwinm.	r0,r5,0,30,30				/* Check if valid for supervisor state */
-			rlwinm	r7,r5,0,0,14				/* Clean up the base virtual address */
-			beq-	ckbat1						/* not valid, skip this one... */
-			sub		r7,r4,r7					/* Subtract out the base */
-			rlwimi	r8,r5,15,0,14				/* Get area length - 1 */
-			mfspr	r6,dbat0l					/* Get the real part */
-			cmplw	r7,r8						/* Check if it is in the range */
-			bng+	fndbat						/* Yup, she's a good un... */
-
-ckbat1:		mfspr	r5,dbat1u					/* Get the virtual address and length */			
-			eqv		r8,r8,r8					/* Get all foxes */
-			rlwinm.	r0,r5,0,30,30				/* Check if valid for supervisor state */
-			rlwinm	r7,r5,0,0,14				/* Clean up the base virtual address */
-			beq-	ckbat2						/* not valid, skip this one... */
-			sub		r7,r4,r7					/* Subtract out the base */
-			rlwimi	r8,r5,15,0,14				/* Get area length - 1 */
-			mfspr	r6,dbat1l					/* Get the real part */
-			cmplw	r7,r8						/* Check if it is in the range */
-			bng+	fndbat						/* Yup, she's a good un... */
-			
-ckbat2:		mfspr	r5,dbat2u					/* Get the virtual address and length */
-			eqv		r8,r8,r8					/* Get all foxes */
-			rlwinm.	r0,r5,0,30,30				/* Check if valid for supervisor state */
-			rlwinm	r7,r5,0,0,14				/* Clean up the base virtual address */
-			beq-	ckbat3						/* not valid, skip this one... */
-			sub		r7,r4,r7					/* Subtract out the base */
-			rlwimi	r8,r5,15,0,14				/* Get area length - 1 */
-			mfspr	r6,dbat2l					/* Get the real part */
-			cmplw	r7,r8						/* Check if it is in the range */
-			bng-	fndbat						/* Yup, she's a good un... */
-			
-ckbat3:		mfspr	r5,dbat3u					/* Get the virtual address and length */
-			eqv		r8,r8,r8					/* Get all foxes */
-			rlwinm.	r0,r5,0,30,30				/* Check if valid for supervisor state */
-			rlwinm	r7,r5,0,0,14				/* Clean up the base virtual address */
-			beq-	notkernsp					/* not valid, skip this one... */
-			sub		r7,r4,r7					/* Subtract out the base */
-			rlwimi	r8,r5,15,0,14				/* Get area length - 1 */
-			mfspr	r6,dbat3l					/* Get the real part */
-			cmplw	r7,r8						/* Check if it is in the range */
-			bgt+	notkernsp					/* No good... */
-			
-fndbat:		rlwinm	r6,r6,0,0,14				/* Clean up the real address */
-			mtmsr	r10							/* Restore state */
-			add		r3,r7,r6					/* Relocate the offset to real */
-			isync								/* Purge pipe */
-			blr									/* Bye, bye... */
-
-notkernsp:	mfspr	r5,sdr1						/* Get hash table base and size */
-			rlwimi	r11,r4,30,2,5				/* Insert the segment no. to make a VSID */
-			rlwimi	r12,r5,16,0,15				/* Make table size -1 out of mask */
-			rlwinm	r7,r4,26,10,25				/* Isolate the page index */
-			andc	r5,r5,r12					/* Clean up the hash table */
-			xor		r7,r7,r11					/* Get primary hash */
-			rlwinm	r11,r11,1,1,24				/* Position VSID for pte ID */
-			and		r7,r7,r12					/* Wrap the hash */
-			rlwimi	r11,r4,10,26,31				/* Move API into pte ID */
-			add		r5,r7,r5					/* Point to the PTEG */
-			oris	r11,r11,0x8000				/* Slam on valid bit so's we don't match an invalid one */
-
-			li		r9,8						/* Get the number of PTEs to check */
-			lwz		r6,0(r5)					/* Preload the virtual half */
-			
-fndpte:		subi	r9,r9,1						/* Count the pte */
-			lwz		r3,4(r5)					/* Get the real half */
-			cmplw	cr1,r6,r11					/* Is this what we want? */
-			lwz		r6,8(r5)					/* Start to get the next virtual half */
-			mr.		r9,r9						/* Any more to try? */
-			addi	r5,r5,8						/* Bump to next slot */
-			beq		cr1,gotxlate				/* We found what we were looking for... */
-			bne+	fndpte						/* Go try the next PTE... */
-			
-			mtmsr	r10							/* Restore state */
-			li		r3,0						/* Show failure */
-			isync								/* Purge pipe */
-			blr									/* Leave... */
-
-gotxlate:	mtmsr	r10							/* Restore state */
-			rlwimi	r3,r4,0,20,31				/* Cram in the page displacement */
-			isync								/* Purge pipe */
-			blr									/* Return... */
+;			Function 12 - Set change in mapping
 
+			.set	.,hwpOpBase+(12*128)		; Generate error if previous function too long
 
+hwpSCngMap:	lwz		r8,mpVAddr+4(r31)			; Get the flag part of mapping
+			ori		r5,r5,lo16(mpC)				; Set change in PTE low
+			ori		r8,r8,lo16(mpC)				; Set chage in mapping
+			cmpw	r0,r0						; Make sure we return CR0_EQ
+			stw		r8,mpVAddr+4(r31)			; Set the flag part of mapping
+			blr									; Return...
 
-/*
- *			struct blokmap *hw_add_blk(pmap_t pmap, struct blokmap *bmr)
- *	
- *			This is used to add a block mapping entry to the MRU list whose top
- *			node is anchored at bmaps.  This is a real address and is also used as
- *			the lock.
- *
- *			Overlapping areas are not allowed.  If we find one, we return it's address and
- *			expect the upper layers to panic.  We only check this for a debug build...
- *
- */
+;			Function 13 - Test reference in physent
 
-			.align	5
-			.globl	EXT(hw_add_blk)
+			.set	.,hwpOpBase+(13*128)		; Generate error if previous function too long
+			
+hwpTRefPhy:	lwz		r0,ppLink+4(r29)			; Get the flags from physent	
+			rlwinm.	r0,r0,0,ppRb-32,ppRb-32		; Isolate reference bit and see if 0
+			blr									; Return (CR0_EQ set to continue if reference is off)...
 
-LEXT(hw_add_blk)
 
- 			mfsprg	r9,2						; Get feature flags 
-			lwz		r6,PMAP_PMAPVR(r3)			; Get the v to r translation
-			mfmsr	r0							/* Save the MSR  */
-			rlwinm	r0,r0,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-			rlwinm	r0,r0,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-			rlwinm	r12,r0,0,MSR_EE_BIT+1,MSR_EE_BIT-1	/* Clear interruptions */
-			mtcrf	0x04,r9						; Set the features			
-			xor		r3,r3,r6					; Get real address of bmap anchor
-			rlwinm	r12,r12,0,28,25				/* Clear IR and DR */
-			la		r3,PMAP_BMAPS(r3)			; Point to bmap header
-			
-			bt		pfNoMSRirb,habNoMSR			; No MSR...
+;			Function 14 - Test reference in mapping
 
-			mtmsr	r12							; Translation and all off
-			isync								; Toss prefetch
-			b		habNoMSRx
+			.set	.,hwpOpBase+(14*128)		; Generate error if previous function too long
 			
-habNoMSR:	
-			mr		r9,r0
-			mr		r8,r3
-			li		r0,loadMSR					; Get the MSR setter SC
-			mr		r3,r12						; Get new MSR
-			sc									; Set it
-			mr		r3,r8
-			mr		r0,r9
-habNoMSRx:
-			
-abLck:		lwarx	r9,0,r3						; Get the block map anchor and lock
-			rlwinm.	r8,r9,0,31,31				; Is it locked?
-			ori		r8,r9,1						; Set the lock
-			bne-	abLckw						; Yeah...
-			stwcx.	r8,0,r3						; Lock the bmap list
-			bne-	abLck						; Someone else was trying, try again...
-			b		abSXg						; All done...
-			
-			.align	4
+hwpTRefMap:	rlwinm.	r0,r5,0,mpRb-32,mpRb-32		; Isolate reference bit and see if 0
+			blr									; Return (CR0_EQ set to continue if reference is off)...
 
-abLckw:		rlwinm.	r5,r9,0,31,31				; Check if it is still held
-			beq+	abLck						; Not no more...
-			lwz		r9,0(r3)					; Get lock word again...
-			b		abLckw						; Check it out...
+;			Function 15 - Test change in physent
+
+			.set	.,hwpOpBase+(15*128)		; Generate error if previous function too long
 			
-			.align	5
+hwpTCngPhy:	lwz		r0,ppLink+4(r29)			; Get the flags from physent	
+			rlwinm.	r0,r0,0,ppCb-32,ppCb-32		; Isolate change bit and see if 0
+			blr									; Return (CR0_EQ set to continue if reference is off)...
+
+
+;			Function 16 - Test change in mapping
+
+			.set	.,hwpOpBase+(16*128)		; Generate error if previous function too long
 			
-			nop									; Force ISYNC to last instruction in IFETCH
-			nop									
+hwpTCngMap:	rlwinm.	r0,r5,0,mpCb-32,mpCb-32		; Isolate change bit and see if 0
+			blr									; Return (CR0_EQ set to continue if reference is off)...
+
+			.set	.,hwpOpBase+(17*128)		; Generate error if previous function too long
+
 
-abSXg:		rlwinm	r11,r9,0,0,26				; Clear out flags and lock
-			isync								; Make sure we have not used anything yet
 
 ;
+;			int hw_protect(pmap, va, prot, *nextva) - Changes protection on a specific mapping.
+;			
+;			Returns:
+;				mapRtOK     - if all is ok
+;				mapRtBadLk  - if mapping lock fails
+;				mapRtPerm   - if mapping is permanent
+;				mapRtNotFnd - if mapping is not found
+;				mapRtBlock  - if mapping is a block
 ;
-;
+			.align	5
+			.globl	EXT(hw_protect)
 
-			lwz		r7,bmstart(r4)				; Get start
-			lwz		r8,bmend(r4)				; Get end		
-			mr		r2,r11						; Get chain
-	
-abChk:		mr.		r10,r2						; End of chain?
-			beq		abChkD						; Yes, chain is ok...
-			lwz		r5,bmstart(r10)				; Get start of current area
-			lwz		r6,bmend(r10)				; Get end of current area
-			
-			cmplw	cr0,r8,r5					; Is the end of the new before the old?
-			cmplw	cr1,r8,r6					; Is the end of the new after the old?
-			cmplw	cr6,r6,r7					; Is the end of the old before the new?
-			cror	cr1_eq,cr0_lt,cr1_gt		; Set cr1_eq if new not in old
-			cmplw	cr7,r6,r8					; Is the end of the old after the new?
-			lwz		r2,bmnext(r10)				; Get pointer to the next
-			cror	cr6_eq,cr6_lt,cr7_gt		; Set cr2_eq if old not in new
-			crand	cr1_eq,cr1_eq,cr6_eq		; Set cr1_eq if no overlap
-			beq+	cr1,abChk					; Ok check the next...
-			
-			lwz		r8,blkFlags(r10)			; Get the flags
-			rlwinm.	r8,r8,0,blkRembit,blkRembit	; Check the blkRem bit
-			beq		abRet						; Is the mapping partially removed
-			ori		r10,r10,2					; Indicate that this block is partially removed
-abRet:
-			stw		r9,0(r3)					; Unlock
-			mtmsr	r0							; Restore xlation and rupts
-			mr		r3,r10						; Pass back the overlap
-			isync								;  
-			blr									; Return...
+LEXT(hw_protect)
+ 			stwu	r1,-(FM_ALIGN((31-24+1)*4)+FM_SIZE)(r1)	; Make some space on the stack
+			mflr	r0							; Save the link register
+			stw		r24,FM_ARG0+0x00(r1)		; Save a register
+			stw		r25,FM_ARG0+0x04(r1)		; Save a register
+			mr		r25,r7						; Remember address of next va
+			stw		r26,FM_ARG0+0x08(r1)		; Save a register
+			stw		r27,FM_ARG0+0x0C(r1)		; Save a register
+			stw		r28,FM_ARG0+0x10(r1)		; Save a register
+			mr		r24,r6						; Save the new protection flags
+			stw		r29,FM_ARG0+0x14(r1)		; Save a register
+			stw		r30,FM_ARG0+0x18(r1)		; Save a register
+			stw		r31,FM_ARG0+0x1C(r1)		; Save a register
+			stw		r0,(FM_ALIGN((31-24+1)*4)+FM_SIZE+FM_LR_SAVE)(r1)	; Save the return
 
-abChkD:		stw		r11,bmnext(r4)				; Chain this on in
-			rlwimi	r4,r9,0,27,31				; Copy in locks and flags
-			sync								; Make sure that is done
-			
-			stw		r4,0(r3)					; Unlock and chain the new first one
-			mtmsr	r0							; Restore xlation and rupts
-			li		r3,0						; Pass back a no failure return code
-			isync
-			blr									; Return...
+			lwz		r6,pmapvr(r3)				; Get the first part of the VR translation for pmap
+			lwz		r7,pmapvr+4(r3)				; Get the second part
 
 
-/*
- *			struct blokmap *hw_rem_blk(pmap_t pmap, vm_offset_t sva, vm_offset_t eva)
- *	
- *			This is used to remove a block mapping entry from the list that
- *			is anchored at bmaps.  bmaps is a virtual address and is also used as
- *			the lock.
- *
- *			Note that this function clears a single block that contains
- *			any address within the range sva to eva (inclusive).  To entirely
- *			clear any range, hw_rem_blk must be called repeatedly until it
- *			returns a 0.
- *
- *			The block is removed from the list and all hash table entries
- *			corresponding to the mapped block are invalidated and the TLB
- *			entries are purged.  If the block is large, this could take
- *			quite a while. We need to hash every possible address in the
- *			range and lock down the PCA.
- *
- *			If we attempt to remove a permanent entry, we will not do it.
- *			The block address will be ored with 1 and returned.
- *
- *
- */
+			bl		EXT(mapSetUp)				; Turn off interrupts, translation, and possibly enter 64-bit
 
-			.align	5
-			.globl	EXT(hw_rem_blk)
+			mr		r27,r11						; Remember the old MSR
+			mr		r26,r12						; Remember the feature bits
 
-LEXT(hw_rem_blk)
+			xor		r28,r3,r7					; Change the common 32- and 64-bit half
 
-  			mfsprg	r9,2						; Get feature flags
-			lwz		r6,PMAP_PMAPVR(r3)			; Get the v to r translation
-			mfmsr	r0							/* Save the MSR  */
-			rlwinm	r0,r0,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-			rlwinm	r0,r0,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-			rlwinm	r12,r0,0,MSR_EE_BIT+1,MSR_EE_BIT-1	/* Clear interruptions */
-			mtcrf	0x04,r9						; Set the features			
-			xor		r3,r3,r6					; Get real address of bmap anchor
-			rlwinm	r12,r12,0,28,25				/* Clear IR and DR */
-			la		r3,PMAP_BMAPS(r3)			; Point to the bmap chain head
+			bf--	pf64Bitb,hpSF1				; skip if 32-bit...
+			
+			rldimi	r28,r6,32,0					; Shift the fixed upper part of the physical over and cram in top
 
-			bt		pfNoMSRirb,hrbNoMSR			; No MSR...
+hpSF1:		mr		r29,r4						; Save top half of vaddr
+			mr		r30,r5						; Save the bottom half
+						
+			la		r3,pmapSXlk(r28)			; Point to the pmap search lock
+			bl		sxlkShared					; Go get a shared lock on the mapping lists
+			mr.		r3,r3						; Did we get the lock?
+			bne--	hpBadLock					; Nope...
 
-			mtmsr	r12							; Translation and all off
-			isync								; Toss prefetch
-			b		hrbNoMSRx
+			mr		r3,r28						; get the pmap address
+			mr		r4,r29						; Get bits 0:31 to look for
+			mr		r5,r30						; Get bits 32:64
 			
-hrbNoMSR:	
-			mr		r9,r0
-			mr		r8,r3
-			li		r0,loadMSR					; Get the MSR setter SC
-			mr		r3,r12						; Get new MSR
-			sc									; Set it
-			mr		r3,r8
-			mr		r0,r9
-hrbNoMSRx:
-			li		r7,0
-			cmp		cr5,r0,r7					; Request to invalidate the ptes
-			b		rbLck
-
-rbunlink:
-			lwz		r4,bmstart(r10)				; Get start of current mapping
-			lwz		r5,bmend(r10)				; Get end of current mapping
-			cmp		cr5,r3,r3					; Request to unlink the mapping
+			bl		EXT(mapSearch)				; Go see if we can find it (note: R7 comes back with mpFlags)
 
-rbLck:		lwarx	r9,0,r3						; Get the block map anchor and lock
-			rlwinm.	r8,r9,0,31,31				; Is it locked?
-			ori		r8,r9,1						; Set the lock
-			bne-	rbLckw						; Yeah...
-			stwcx.	r8,0,r3						; Lock the bmap list
-			bne-	rbLck						; Someone else was trying, try again...
-			b		rbSXg						; All done...
+			andi.	r7,r7,lo16(mpSpecial|mpNest|mpPerm|mpBlock|mpRIP)	; Are we allowed to change it or is it being removed?
+			mr.		r31,r3						; Save the mapping if we found it
+			cmplwi	cr1,r7,0					; Anything special going on?
+			mr		r29,r4						; Save next va high half
+			mr		r30,r5						; Save next va low half
 			
-			.align	4
+			beq--	hpNotFound					; Not found...
 
-rbLckw:		rlwinm.	r11,r9,0,31,31				; Check if it is still held
-			beq+	rbLck						; Not no more...
-			lwz		r9,0(r3)					; Get lock word again...
-			b		rbLckw						; Check it out...
+			bne--	cr1,hpNotAllowed			; Something special is happening...
 			
-			.align	5
+			bt++	pf64Bitb,hpDo64				; Split for 64 bit
+			
+			bl		mapInvPte32					; Invalidate and lock PTEG, also merge into physent
+						
+			rlwimi	r5,r24,0,mpPPb-32,mpPPb-32+2	; Stick in the new pp
+			mr.		r3,r3						; Was there a previously valid PTE?
+
+			stb		r5,mpVAddr+7(r31)			; Set the new pp field (do not muck with the rest)			
+
+			beq--	hpNoOld32					; Nope...
 			
-			nop									; Force ISYNC to last instruction in IFETCH
-			nop									
+			stw		r5,4(r3)					; Store second half of PTE
+			eieio								; Make sure we do not reorder
+			stw		r4,0(r3)					; Revalidate the PTE
+
+			eieio								; Make sure all updates come first
+			stw		r6,0(r7)					; Unlock PCA
+		
+hpNoOld32:	la		r3,pmapSXlk(r28)			; Point to the pmap search lock
+			bl		sxlkUnlock					; Unlock the search list
+
+			li		r3,mapRtOK					; Set normal return		
+			b		hpR32						; Join common...
 
-rbSXg:		rlwinm.	r2,r9,0,0,26				; Clear out flags and lock
-			mr		r10,r3						; Keep anchor as previous pointer
-			isync								; Make sure we have not used anything yet
+			.align	5			
 			
-			beq-	rbMT						; There is nothing in the list
 			
-rbChk:		mr		r12,r10						; Save the previous
-			mr.		r10,r2						; End of chain?
-			beq		rbMT						; Yes, nothing to do...
-			lwz		r11,bmstart(r10)			; Get start of current area
-			lwz		r6,bmend(r10)				; Get end of current area
+hpDo64:		bl		mapInvPte64					; Invalidate and lock PTEG, also merge into physent
+						
+			rldimi	r5,r24,0,mpPPb				; Stick in the new pp
+			mr.		r3,r3						; Was there a previously valid PTE?
+
+			stb		r5,mpVAddr+7(r31)			; Set the new pp field (do not muck with the rest)			
+
+			beq--	hpNoOld64					; Nope...
 			
-			cmplw	cr0,r5,r11					; Is the end of range before the start of the area?
-			cmplw	cr1,r4,r6					; Is the start of range after the end of the area?
-			cror	cr1_eq,cr0_lt,cr1_gt		; Set cr1_eq if new not in range
-			lwz		r2,bmnext(r10)				; Get the next one
-			beq+	cr1,rbChk					; Not this one, check the next...
+			std		r5,8(r3)					; Store second half of PTE
+			eieio								; Make sure we do not reorder
+			std		r4,0(r3)					; Revalidate the PTE
 
-			cmplw	cr1,r12,r3					; Is the current mapping the first one?
+			eieio								; Make sure all updates come first
+			stw		r6,0(r7)					; Unlock PCA
 
-			bne		cr5,rbblkRem				; Do we have to unchain the mapping
+hpNoOld64:	la		r3,pmapSXlk(r28)			; Point to the pmap search lock
+			bl		sxlkUnlock					; Unlock the search list
 
-			bne		cr1,rbnFirst				; Yes, is this the first mapping?
-			rlwimi	r9,r2,0,0,26				; Yes, Change the lock value
-			ori		r2,r9,1						; Turn on the lock bit
-rbnFirst:
-			stw		r2,bmnext(r12)				; Unchain us
-			sync
-			b		rbDone
+			li		r3,mapRtOK					; Set normal return		
+			b		hpR64						; Join common...
 
-rbblkRem:
-		
-			lwz		r8,blkFlags(r10)			; Get the flags
+			.align	5							
+						
+hpReturn:	bt++	pf64Bitb,hpR64				; Yes...
+
+hpR32:		mtmsr	r27							; Restore enables/translation/etc.
+			isync
+			b		hpReturnC					; Join common...
+
+hpR64:		mtmsrd	r27							; Restore enables/translation/etc.
+			isync								
+			
+hpReturnC:	stw		r29,0(r25)					; Save the top of the next va
+			stw		r30,4(r25)					; Save the bottom of the next va
+			lwz		r0,(FM_ALIGN((31-24+1)*4)+FM_SIZE+FM_LR_SAVE)(r1)	; Save the return
+			lwz		r24,FM_ARG0+0x00(r1)		; Save a register
+			lwz		r25,FM_ARG0+0x04(r1)		; Save a register
+			lwz		r26,FM_ARG0+0x08(r1)		; Save a register
+			mtlr	r0							; Restore the return
+			lwz		r27,FM_ARG0+0x0C(r1)		; Save a register
+			lwz		r28,FM_ARG0+0x10(r1)		; Save a register
+			lwz		r29,FM_ARG0+0x14(r1)		; Save a register
+			lwz		r30,FM_ARG0+0x18(r1)		; Save a register
+			lwz		r31,FM_ARG0+0x1C(r1)		; Save a register
+			lwz		r1,0(r1)					; Pop the stack
+			blr									; Leave...
+			
+			.align	5
 			
-			rlwinm.	r7,r8,0,blkPermbit,blkPermbit	; is this a permanent block?
+hpBadLock:	li		r3,mapRtBadLk				; Set lock time out error code
+			b		hpReturn					; Leave....
 			
-			bne-	rbPerm						; This is permanent, do not remove...
+hpNotFound:	la		r3,pmapSXlk(r28)			; Point to the pmap search lock
+			bl		sxlkUnlock					; Unlock the search list
+			
+			li		r3,mapRtNotFnd				; Set that we did not find the requested page
+			b		hpReturn					; Leave....
+			
+hpNotAllowed:	
+			rlwinm.	r0,r7,0,mpRIPb,mpRIPb		; Is it actually being removed?
+			la		r3,pmapSXlk(r28)			; Point to the pmap search lock
+			bne--	hpNotFound					; Yeah...
+			bl		sxlkUnlock					; Unlock the search list
+			
+			li		r3,mapRtBlock				; Assume it was a block
+			andi.	r7,r7,lo16(mpBlock)			; Is this a block?
+			bne++	hpReturn					; Yes, leave...
+			
+			li		r3,mapRtPerm				; Set that we hit a permanent page
+			b		hpReturn					; Leave....
 
-			rlwinm.	r7,r8,0,blkRembit,blkRembit	; is this mapping partially removed
 
-			beq		rbblkRemcont				; If not, check the max size
-			lwz		r11,bmcurrent(r10)			; If yes, resume for the current page
+;
+;			int hw_test_rc(pmap, va, reset) - tests RC on a specific va
+;			
+;			Returns following code ORed with RC from mapping
+;				mapRtOK     - if all is ok
+;				mapRtBadLk  - if mapping lock fails
+;				mapRtNotFnd - if mapping is not found
+;
+			.align	5
+			.globl	EXT(hw_test_rc)
 
-			cmp		cr5,r11,r6					; No partial remove left
-			beq		cr5, rbpendret				; But there is  a pending remove
+LEXT(hw_test_rc)
+ 			stwu	r1,-(FM_ALIGN((31-24+1)*4)+FM_SIZE)(r1)	; Make some space on the stack
+			mflr	r0							; Save the link register
+			stw		r24,FM_ARG0+0x00(r1)		; Save a register
+			stw		r25,FM_ARG0+0x04(r1)		; Save a register
+			stw		r26,FM_ARG0+0x08(r1)		; Save a register
+			stw		r27,FM_ARG0+0x0C(r1)		; Save a register
+			stw		r28,FM_ARG0+0x10(r1)		; Save a register
+			mr		r24,r6						; Save the reset request
+			stw		r29,FM_ARG0+0x14(r1)		; Save a register
+			stw		r30,FM_ARG0+0x18(r1)		; Save a register
+			stw		r31,FM_ARG0+0x1C(r1)		; Save a register
+			stw		r0,(FM_ALIGN((31-24+1)*4)+FM_SIZE+FM_LR_SAVE)(r1)	; Save the return
 
-rbblkRemcont:
-			bne		rbblkRemcont1				; Is it the first remove
+			lwz		r6,pmapvr(r3)				; Get the first part of the VR translation for pmap
+			lwz		r7,pmapvr+4(r3)				; Get the second part
 
-			oris	r8,r8,hi16(blkRem)			; Yes
-			stw		r8,blkFlags(r10)			; set the blkRem bit in blkFlags
 
-rbblkRemcont1:
-			lis		r5,hi16(BLKREMMAX*4096)			; Load maximun size tear down
-			ori		r5,r5,lo16(BLKREMMAX*4096)		; Load maximun size tear down
-			sub		r7,r6,r11					; Get the remaining size to tear down
-			cmp		cr5,r7,r5					; Compare against the maximun size
-			ble		cr5,rbfullblk				; If less or equal, go remove the mapping
+			bl		EXT(mapSetUp)				; Turn off interrupts, translation, and possibly enter 64-bit
 
-			add		r7,r11,r5					; Add the max size tear down to the current page
-			stw		r7,bmcurrent(r10)			; Update the current page
-			subi	r6,r7,1						; Set the current end of the partial tear down
-			b		rbcont
+			mr		r27,r11						; Remember the old MSR
+			mr		r26,r12						; Remember the feature bits
 
-rbfullblk:
-			stw		r6,bmcurrent(r10)			; Update the current page
+			xor		r28,r3,r7					; Change the common 32- and 64-bit half
 
-rbcont:
-			lwz		r8,bmspace(r10)				; Get the VSID
-			sync
-			stw		r9,0(r3)					; Unlock and chain the new first one
-			
-			eqv		r4,r4,r4					; Fill the bottom with foxes
-			mfspr	r12,sdr1					; Get hash table base and size
-			rlwinm	r8,r8,6,0,25				; Align VSID to PTEG
-			rlwimi	r4,r12,16,0,15				; Make table size - 1 out of mask
-			andc	r12,r12,r4					; Clean up address of hash table
-			rlwinm	r5,r11,26,6,25				; Rotate virtual start address into PTEG units
-			add		r12,r12,r4					; Point to PCA - 1
-			rlwinm	r6,r6,26,6,25				; Rotate virtual end address into PTEG units
-			addi	r12,r12,1					; Point to PCA base
-			sub		r6,r6,r5					; Get the total number of PTEGs to clear
-			cmplw	r6,r4						; See if this wraps all the way around
-			blt		rbHash						; Nope, length is right
-			subi	r6,r4,32+31					; Back down to correct length
-			
-rbHash:		rlwinm	r5,r5,0,10,25				; Keep only the page index
-			xor		r2,r8,r5					; Hash into table
-			and		r2,r2,r4					; Wrap into the table
-			add		r2,r2,r12					; Point right at the PCA
-
-rbLcka:		lwarx	r7,0,r2						; Get the PTEG lock
-			mr.		r7,r7						; Is it locked?
-			bne-	rbLckwa						; Yeah...
-			li		r7,1						; Get the locked value
-			stwcx.	r7,0,r2						; Take it
-			bne-	rbLcka						; Someone else was trying, try again...
-			b		rbSXga						; All done... 
-
-rbLckwa:	mr.		r7,r7						; Check if it is already held
-			beq+	rbLcka						; It is clear...
-			lwz		r7,0(r2)					; Get lock word again...
-			b		rbLckwa						; Wait...
-			
-rbSXga:		isync								; Make sure nothing used yet
-			lwz		r7,PCAallo(r2)				; Get the allocation word
-			rlwinm.	r11,r7,8,0,7				; Isolate the autogenerated PTEs
-			or		r7,r7,r11					; Release the autogen slots
-			beq+	rbAintNone					; There are not any here
-			mtcrf	0xC0,r11					; Set the branch masks for autogens
-			sub		r11,r2,r4					; Move back to the hash table + 1
-			rlwinm	r7,r7,0,16,7				; Clear the autogen field
-			subi	r11,r11,1					; Point to the PTEG
-			stw		r7,PCAallo(r2)				; Update the flags
-			li		r7,0						; Get an invalid PTE value
-
-			bf		0,rbSlot1					; No autogen here
-			stw		r7,0x00(r11)				; Invalidate PTE
-rbSlot1:	bf		1,rbSlot2					; No autogen here
-			stw		r7,0x08(r11)				; Invalidate PTE
-rbSlot2:	bf		2,rbSlot3					; No autogen here
-			stw		r7,0x10(r11)				; Invalidate PTE
-rbSlot3:	bf		3,rbSlot4					; No autogen here
-			stw		r7,0x18(r11)				; Invalidate PTE
-rbSlot4:	bf		4,rbSlot5					; No autogen here
-			stw		r7,0x20(r11)				; Invalidate PTE
-rbSlot5:	bf		5,rbSlot6					; No autogen here
-			stw		r7,0x28(r11)				; Invalidate PTE
-rbSlot6:	bf		6,rbSlot7					; No autogen here
-			stw		r7,0x30(r11)				; Invalidate PTE
-rbSlot7:	bf		7,rbSlotx					; No autogen here
-			stw		r7,0x38(r11)				; Invalidate PTE
-rbSlotx:
-
-rbAintNone:	li		r7,0						; Clear this out
-			sync								; To make SMP happy
-			addic.	r6,r6,-64					; Decrement the count
-			stw		r7,PCAlock(r2)				; Release the PTEG lock
-			addi	r5,r5,64					; Move up by adjusted page number
-			bge+	rbHash						; Not done...
-	
-			sync								; Make sure the memory is quiet
+			bf--	pf64Bitb,htrSF1				; skip if 32-bit...
 			
-;
-;			Here we take the easy way out and just purge the entire TLB. This is 
-;			certainly faster and definitly easier than blasting just the correct ones
-;			in the range, we only need one lock and one TLBSYNC. We would hope
-;			that most blocks are more than 64 pages (256K) and on every machine
-;			up to Book E, 64 TLBIEs will invalidate the entire table.
-;
+			rldimi	r28,r6,32,0					; Shift the fixed upper part of the physical over and cram in top
 
-			li		r5,64						; Get number of TLB entries to purge
-			lis		r12,HIGH_ADDR(EXT(tlb_system_lock))	; Get the TLBIE lock
-			li		r6,0						; Start at 0
-			ori		r12,r12,LOW_ADDR(EXT(tlb_system_lock))	; Grab up the bottom part
+htrSF1:		mr		r29,r4						; Save top half of vaddr
+			mr		r30,r5						; Save the bottom half
 						
-rbTlbL:		lwarx	r2,0,r12					; Get the TLBIE lock
-			mr.		r2,r2						; Is it locked?
-			li		r2,1						; Get our lock value
-			bne-	rbTlbL						; It is locked, go wait...
-			stwcx.	r2,0,r12					; Try to get it
-			bne-	rbTlbL						; We was beat...
-	
-rbTlbN:		addic.	r5,r5,-1					; See if we did them all
-			tlbie	r6							; Invalidate it everywhere
-			addi	r6,r6,0x1000				; Up to the next page
-			bgt+	rbTlbN						; Make sure we have done it all...
-			
-			mfspr	r5,pvr						; Find out what kind of machine we are
-			li		r2,0						; Lock clear value
-			
-			rlwinm	r5,r5,16,16,31				; Isolate CPU type
-			cmplwi	r5,3						; Is this a 603?
-			sync								; Make sure all is quiet
-			beq-	rbits603a					; It is a 603, skip the tlbsync...
+			la		r3,pmapSXlk(r28)			; Point to the pmap search lock
+			bl		sxlkShared					; Go get a shared lock on the mapping lists
+			mr.		r3,r3						; Did we get the lock?
+			li		r25,0						; Clear RC
+			bne--	htrBadLock					; Nope...
+
+			mr		r3,r28						; get the pmap address
+			mr		r4,r29						; Get bits 0:31 to look for
+			mr		r5,r30						; Get bits 32:64
 			
-			eieio								; Make sure that the tlbie happens first
-			tlbsync								; wait for everyone to catch up
-			isync								
+			bl		EXT(mapSearch)				; Go see if we can find it (R7 comes back with mpFlags)
 
-rbits603a:	sync								; Wait for quiet again
-			stw		r2,0(r12)					; Unlock invalidates
+			andi.	r0,r7,lo16(mpSpecial|mpNest|mpPerm|mpBlock|mpRIP)	; Are we allowed to change it or is it being removed?
+			mr.		r31,r3						; Save the mapping if we found it
+			cmplwi	cr1,r0,0					; Are we removing it?
+			crorc	cr0_eq,cr0_eq,cr1_eq		; Did we not find it or is it being removed?
 			
-			sync								; Make sure that is done
+			bt--	cr0_eq,htrNotFound			; Not found, something special, or being removed...
 			
-			ble		cr5,rbunlink				; If all ptes are flush, go unlink the mapping
-			mtmsr	r0							; Restore xlation and rupts
-			mr		r3,r10						; Pass back the removed block in progress
-			ori		r3,r3,2						; Indicate that the block remove isn't completed yet
-			isync
-			blr									; Return...
-
-rbpendret:
-			stw		r9,0(r3)					; Unlock
-			mtmsr	r0							; Restore xlation and rupts
-			mr		r3,r10						; Pass back the removed block in progress
-			ori		r3,r3,2						; Indicate that the block remove isn't completed yet
-			isync
-			blr									; Return...
+			bt++	pf64Bitb,htrDo64			; Split for 64 bit
+			
+			bl		mapInvPte32					; Invalidate and lock PTEG, also merge into physent
+						
+			cmplwi	cr1,r24,0					; Do we want to clear RC?
+			lwz		r12,mpVAddr+4(r31)			; Get the bottom of the mapping vaddr field
+			mr.		r3,r3						; Was there a previously valid PTE?
+			li		r0,lo16(mpR|mpC)			; Get bits to clear
 
+			and		r25,r5,r0					; Save the RC bits
+			beq++	cr1,htrNoClr32				; Nope...
+			
+			andc	r12,r12,r0					; Clear mapping copy of RC
+			andc	r5,r5,r0					; Clear PTE copy of RC
+			sth		r12,mpVAddr+6(r31)			; Set the new RC			
 
-rbMT:		stw		r9,0(r3)					; Unlock
-			mtmsr	r0							; Restore xlation and rupts
-			li		r3,0						; Say we did not find one
-			isync
-			blr									; Return...
+htrNoClr32:	beq--	htrNoOld32					; No previously valid PTE...
 			
-rbPerm:		stw		r9,0(r3)					; Unlock
-			mtmsr	r0							; Restore xlation and rupts
-			ori		r3,r10,1					; Say we did not remove it
-			isync
-			blr									; Return...
+			sth		r5,6(r3)					; Store updated RC
+			eieio								; Make sure we do not reorder
+			stw		r4,0(r3)					; Revalidate the PTE
 
-rbDone:		stw     r9,0(r3) 					; Unlock
-			mtmsr	r0							; Restore xlation and rupts
-			mr      r3,r10 						; Pass back the removed block
-			isync
-			blr									; Return...
+			eieio								; Make sure all updates come first
+			stw		r6,0(r7)					; Unlock PCA
 
-/*
- *			hw_select_mappings(struct mappingflush *mappingflush)
- *
- *			Input: PCA addr
- *			Ouput: up to 8 user mappings
- *
- *			hw_select_mappings() scans every PCA mapping hash lists and select
- *			the last user mapping if it exists.
- *
- */
+htrNoOld32:	la		r3,pmapSXlk(r28)			; Point to the pmap search lock
+			bl		sxlkUnlock					; Unlock the search list
+			li		r3,mapRtOK					; Set normal return		
+			b		htrR32						; Join common...
 
-			.align	5
-			.globl	EXT(hw_select_mappings)
+			.align	5			
+			
+			
+htrDo64:	bl		mapInvPte64					; Invalidate and lock PTEG, also merge into physent
+						
+			cmplwi	cr1,r24,0					; Do we want to clear RC?
+			lwz		r12,mpVAddr+4(r31)			; Get the bottom of the mapping vaddr field
+			mr.		r3,r3						; Was there a previously valid PTE?
+			li		r0,lo16(mpR|mpC)			; Get bits to clear
 
-LEXT(hw_select_mappings)
-			mr		r5,r3						; Get the mapping flush addr
-			mfmsr	r12							; Get the MSR 
-			rlwinm	r12,r12,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-			rlwinm	r12,r12,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-			mfsprg	r9,2						; Get feature flags
-			andi.	r0,r12,0x7FCF				; Disable translation and interruptions
-			mtcrf	0x04,r9						; Set the features
-			bt		pfNoMSRirb,hvmNoMSR			; No MSR...
-			mtmsr	r0
-			isync
-			b		hvmNoMSRx
-hvmNoMSR:
-			mr		r3,r0						; Get the new MSR
-			li		r0,loadMSR					; Get the MSR setter SC
-			sc
-hvmNoMSRx:
-			mr		r0,r12
-			li		r11,1						; Get the locked value 
-
-hvmptegLckx:   
-			lwz		r3,MFpcaptr(r5)				; Get the PCA pointer
-			lwarx	r10,0,r3					; Get the PTEG lock
-			mr.		r10,r10						; Is it locked?
-			bne-	hvmptegLckwx				; Yeah...
-			stwcx.	r11,0,r3					; Take take it
-			bne-	hvmptegLckx					; Someone else was trying, try again...
-			b		hvmptegSXgx					; All done...
-
-			.align  4
-
-hvmptegLckwx:
-			mr.		r10,r10						; Check if it is already held
-			beq+	hvmptegLckx					; It's clear...
-			lwz		r10,0(r3)					; Get lock word again...
-			b		hvmptegLckwx				; Wait...
-
-			.align  4
-
-hvmptegSXgx:
-			isync								; Make sure we haven't used anything yet
-
-			li		r11,8						; set count to 8 
-
-			lwz		r6,PCAhash(r3)				; load the first mapping hash list
-			la		r12,PCAhash(r3)				; Point to the mapping hash area
-			la		r4,MFmapping(r5)			; Point to the mapping flush mapping area
-			li		r7,0						; Load zero
-			stw		r7,MFmappingcnt(r5)			; Set the current count to 0
-hvmnexthash:
-			li		r10,0						; Mapping test
-
-hvmfindmap:
-			mr.		r6,r6						; Test if the hash list current pointer is zero
-			beq		hvmfindmapret				; Did we hit the end of the hash list
-			lwz		r7,mmPTEv(r6)				; Pick up our virtual ID
-			rlwinm	r8,r7,5,0,19				; Pick VSID 20 lower bits
-			mr.		r8,r8
-			beq		hvmfindmapnext				; Skip Kernel VSIDs
-			rlwinm	r8,r7,1,0,3					; Extract the Segment index 
-			rlwinm	r9,r7,22,4,9				; Extract API 6 upper bits
-			or		r8,r8,r9					; Add to the virtual address
-			rlwinm	r9,r7,31,6,25				; Pick VSID 19 lower bits
-			xor		r9,r9,r3					; Exclusive or with the PCA address
-			rlwinm	r9,r9,6,10,19				; Extract API 10 lower bits
-			or		r8,r8,r9					; Add to the virtual address
-
-			stw		r8,4(r4)					; Store the virtual address
-			lwz		r8,mmpmap(r6)				; Get the pmap
-			stw		r8,0(r4)					; Store the pmap
-			li		r10,1						; Found one
-
-hvmfindmapnext:
-			lwz		r6,mmhashnext(r6)			; Pick up next mapping block
-			b		hvmfindmap					; Scan the next mapping
-hvmfindmapret:
-			mr.		r10,r10						; Found mapping
-			beq		hvmnexthashprep				; If not, do not update the mappingflush array
-			lwz		r7,MFmappingcnt(r5)			; Get the current count
-			addi	r7,r7,1						; Increment the current count
-			stw		r7,MFmappingcnt(r5)			; Store the current count
-			addi	r4,r4,MFmappingSize			; Point to the next mapping flush entry
-hvmnexthashprep:
-			addi	r12,r12,4					; Load the next hash list
-			lwz		r6,0(r12)					; Load the next hash list entry
-			subi	r11,r11,1					; Decrement hash list index 
-			mr.		r11,r11						; Test for a remaining hash list
-			bne		hvmnexthash					; Loop to scan the next hash list
-
-			li		r10,0
-			stw		r10,0(r3)					; Unlock the hash list
-			mtmsr	r0							; Restore translation and interruptions
-			isync
-			blr
+			and		r25,r5,r0					; Save the RC bits
+			beq++	cr1,htrNoClr64				; Nope...
+			
+			andc	r12,r12,r0					; Clear mapping copy of RC
+			andc	r5,r5,r0					; Clear PTE copy of RC
+			sth		r12,mpVAddr+6(r31)			; Set the new RC			
 
-/*
- *			vm_offset_t hw_cvp_blk(pmap_t pmap, vm_offset_t va)
- *	
- *			This is used to translate a virtual address within a block mapping entry
- *			to a physical address.  If not found, 0 is returned.
- *
- */
+htrNoClr64:	beq--	htrNoOld64					; Nope, no pevious pte...
+			
+			sth		r5,14(r3)					; Store updated RC
+			eieio								; Make sure we do not reorder
+			std		r4,0(r3)					; Revalidate the PTE
 
-			.align	5
-			.globl	EXT(hw_cvp_blk)
+			eieio								; Make sure all updates come first
+			stw		r6,0(r7)					; Unlock PCA
 
-LEXT(hw_cvp_blk)
+htrNoOld64:	la		r3,pmapSXlk(r28)			; Point to the pmap search lock
+			bl		sxlkUnlock					; Unlock the search list
+			li		r3,mapRtOK					; Set normal return		
+			b		htrR64						; Join common...
 
- 			mfsprg	r9,2						; Get feature flags
- 			lwz		r6,PMAP_PMAPVR(r3)			; Get the v to r translation
-			mfmsr	r0							/* Save the MSR  */
-			rlwinm	r0,r0,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-			rlwinm	r0,r0,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-			rlwinm	r12,r0,0,MSR_EE_BIT+1,MSR_EE_BIT-1	/* Clear interruptions */
-			mtcrf	0x04,r9						; Set the features			
-			xor		r3,r3,r6					; Get real address of bmap anchor
-			rlwinm	r12,r12,0,28,25				/* Clear IR and DR */
-			la		r3,PMAP_BMAPS(r3)			; Point to chain header
+			.align	5							
+						
+htrReturn:	bt++	pf64Bitb,htrR64				; Yes...
 
-			bt		pfNoMSRirb,hcbNoMSR			; No MSR...
+htrR32:		mtmsr	r27							; Restore enables/translation/etc.
+			isync
+			b		htrReturnC					; Join common...
 
-			mtmsr	r12							; Translation and all off
-			isync								; Toss prefetch
-			b		hcbNoMSRx
+htrR64:		mtmsrd	r27							; Restore enables/translation/etc.
+			isync								
 			
-hcbNoMSR:	
-			mr		r9,r0
-			mr		r8,r3
-			li		r0,loadMSR					; Get the MSR setter SC
-			mr		r3,r12						; Get new MSR
-			sc									; Set it
-			mr		r3,r8
-			mr		r0,r9
-hcbNoMSRx:
-
-cbLck:		lwarx	r9,0,r3						; Get the block map anchor and lock
-			rlwinm.	r8,r9,0,31,31				; Is it locked?
-			ori		r8,r9,1						; Set the lock
-			bne-	cbLckw						; Yeah...
-			stwcx.	r8,0,r3						; Lock the bmap list
-			bne-	cbLck						; Someone else was trying, try again...
-			b		cbSXg						; All done...
-			
-			.align	4
-
-cbLckw:		rlwinm.	r5,r9,0,31,31				; Check if it is still held
-			beq+	cbLck						; Not no more...
-			lwz		r9,0(r3)					; Get lock word again...
-			b		cbLckw						; Check it out...
-			
-			.align	5
-			
-			nop									; Force ISYNC to last instruction in IFETCH
-			nop
-			nop
-			nop
-			nop
-
-cbSXg:		rlwinm.	r11,r9,0,0,26				; Clear out flags and lock
-			li		r2,0						; Assume we do not find anything			
-			isync								; Make sure we have not used anything yet
-
-cbChk:		mr.		r11,r11						; Is there more?
-			beq-	cbDone						; No more...
-			lwz		r5,bmstart(r11)				; Get the bottom of range
-			lwz		r12,bmend(r11)				; Get the top of range
-			cmplw	cr0,r4,r5					; Are we before the entry?
-			cmplw	cr1,r4,r12					; Are we after of the entry?
-			cror	cr1_eq,cr0_lt,cr1_gt		; Set cr1_eq if new not in range
-			beq-	cr1,cbNo					; We are not in the range...
-
-			lwz		r2,bmPTEr(r11)				; Get the real part of the PTE
-			sub		r5,r4,r5					; Get offset into area
-			rlwinm	r2,r2,0,0,19				; Clean out everything but the page
-			add		r2,r2,r5					; Adjust the real address
-
-cbDone:		stw		r9,0(r3)					; Unlock it, we are done with it (no sync needed)
-			mtmsr	r0							; Restore translation and interrupts...
-			isync								; Make sure it is on
-			mr		r3,r2						; Set return physical address
+htrReturnC:	lwz		r0,(FM_ALIGN((31-24+1)*4)+FM_SIZE+FM_LR_SAVE)(r1)	; Save the return
+			or		r3,r3,r25					; Send the RC bits back
+			lwz		r24,FM_ARG0+0x00(r1)		; Save a register
+			lwz		r25,FM_ARG0+0x04(r1)		; Save a register
+			lwz		r26,FM_ARG0+0x08(r1)		; Save a register
+			mtlr	r0							; Restore the return
+			lwz		r27,FM_ARG0+0x0C(r1)		; Save a register
+			lwz		r28,FM_ARG0+0x10(r1)		; Save a register
+			lwz		r29,FM_ARG0+0x14(r1)		; Save a register
+			lwz		r30,FM_ARG0+0x18(r1)		; Save a register
+			lwz		r31,FM_ARG0+0x1C(r1)		; Save a register
+			lwz		r1,0(r1)					; Pop the stack
 			blr									; Leave...
 			
 			.align	5
 			
-cbNo:		lwz		r11,bmnext(r11)				; Link next
-			b		cbChk						; Check it out...
+htrBadLock:	li		r3,mapRtBadLk				; Set lock time out error code
+			b		htrReturn					; Leave....
 			
+htrNotFound:	
+			la		r3,pmapSXlk(r28)			; Point to the pmap search lock
+			bl		sxlkUnlock					; Unlock the search list
 			
-/*
- *			hw_set_user_space(pmap) 
- *			hw_set_user_space_dis(pmap) 
- *
- * 			Indicate whether memory space needs to be switched.
+			li		r3,mapRtNotFnd				; Set that we did not find the requested page
+			b		htrReturn					; Leave....
+
+
+
+;
+;			mapPhysFindLock - find physent list and lock it
+;			R31 points to mapping
+;
+			.align	5
+			
+mapPhysFindLock:	
+			lbz		r4,mpFlags+1(r31)			; Get the index into the physent bank table
+			lis		r3,ha16(EXT(pmap_mem_regions))	; Get high order of physent table (note use of ha16 to get value appropriate for an addi of low part)
+			rlwinm	r4,r4,2,0,29				; Change index into byte offset
+			addi	r4,r4,lo16(EXT(pmap_mem_regions))	; Get low part of address of entry
+			add		r3,r3,r4					; Point to table entry
+			lwz		r5,mpPAddr(r31)				; Get physical page number
+			lwz		r7,mrStart(r3)				; Get the start of range
+			lwz		r3,mrPhysTab(r3)			; Get the start of the entries for this bank
+			sub		r6,r5,r7					; Get index to physent
+			rlwinm	r6,r6,3,0,28				; Get offset to physent
+			add		r3,r3,r6					; Point right to the physent
+			b		mapPhysLock					; Join in the lock...
+
+;
+;			mapPhysLock - lock a physent list
+;			R3 contains list header
+;
+			.align	5
+
+mapPhysLockS:
+			li		r2,lgKillResv				; Get a spot to kill reservation
+			stwcx.	r2,0,r2						; Kill it...
+			
+mapPhysLockT:
+			lwz		r2,ppLink(r3)				; Get physent chain header
+			rlwinm.	r2,r2,0,0,0					; Is lock clear?
+			bne--	mapPhysLockT				; Nope, still locked...
+			
+mapPhysLock:	
+			lwarx	r2,0,r3						; Get the lock
+			rlwinm.	r0,r2,0,0,0					; Is it locked?
+			oris	r0,r2,0x8000				; Set the lock bit
+			bne--	mapPhysLockS				; It is locked, spin on it...
+			stwcx.	r0,0,r3						; Try to stuff it back...
+			bne--	mapPhysLock					; Collision, try again...
+			isync								; Clear any speculations
+			blr									; Leave...
+			
+
+;
+;			mapPhysUnlock - unlock a physent list
+;			R3 contains list header
+;
+			.align	5
+			
+mapPhysUnlock:	
+			lwz		r0,ppLink(r3)				; Get physent chain header
+			rlwinm	r0,r0,0,1,31				; Clear the lock bit
+			eieio								; Make sure unlock comes last
+			stw		r0,ppLink(r3)				; Unlock the list
+			blr
+
+;
+;			mapPhysMerge - merge the RC bits into the master copy
+;			R3 points to the physent 
+;			R4 contains the RC bits
+;
+;			Note: we just return if RC is 0
+;
+			.align	5
+			
+mapPhysMerge:	
+			rlwinm.	r4,r4,PTE1_REFERENCED_BIT+(64-ppRb),ppRb-32,ppCb-32	; Isolate RC bits
+			la		r5,ppLink+4(r3)				; Point to the RC field
+			beqlr--								; Leave if RC is 0...
+			
+mapPhysMergeT:
+			lwarx	r6,0,r5						; Get the RC part
+			or		r6,r6,r4					; Merge in the RC
+			stwcx.	r6,0,r5						; Try to stuff it back...
+			bne--	mapPhysMergeT				; Collision, try again...
+			blr									; Leave...
+
+;
+;			Sets the physent link pointer and preserves all flags
+;			The list is locked
+;			R3 points to physent
+;			R4 has link to set
+;
+
+			.align	5
+
+mapPhyCSet32:
+			la		r5,ppLink+4(r3)				; Point to the link word
+
+mapPhyCSetR:
+			lwarx	r2,0,r5						; Get the link and flags
+			rlwimi	r4,r2,0,26,31				; Insert the flags
+			stwcx.	r4,0,r5						; Stick them back
+			bne--	mapPhyCSetR					; Someone else did something, try again...
+			blr									; Return...
+
+			.align	5
+
+mapPhyCSet64:
+			li		r0,0xFF						; Get mask to clean up mapping pointer
+			rldicl	r0,r0,62,0					; Rotate clean up mask to get 0xC0000000000000003F
+		
+mapPhyCSet64x:
+			ldarx	r2,0,r3						; Get the link and flags
+			and		r5,r2,r0					; Isolate the flags
+			or		r6,r4,r5					; Add them to the link
+			stdcx.	r6,0,r3						; Stick them back
+			bne--	mapPhyCSet64x				; Someone else did something, try again...
+			blr									; Return...						
+
+;
+;			mapBumpBusy - increment the busy count on a mapping
+;			R3 points to mapping
+;
+
+			.align	5
+
+mapBumpBusy:
+			lwarx	r4,0,r3						; Get mpBusy
+			addis	r4,r4,0x0100				; Bump the busy count
+			stwcx.	r4,0,r3						; Save it back
+			bne--	mapBumpBusy					; This did not work, try again...
+			blr									; Leave...
+
+;
+;			mapDropBusy - increment the busy count on a mapping
+;			R3 points to mapping
+;
+
+			.globl	EXT(mapping_drop_busy)
+			.align	5
+
+LEXT(mapping_drop_busy)
+mapDropBusy:
+			lwarx	r4,0,r3						; Get mpBusy
+			addis	r4,r4,0xFF00				; Drop the busy count
+			stwcx.	r4,0,r3						; Save it back
+			bne--	mapDropBusy					; This did not work, try again...
+			blr									; Leave...
+
+;
+;			mapDrainBusy - drain the busy count on a mapping
+;			R3 points to mapping
+;			Note: we already have a busy for ourselves. Only one
+;			busy per processor is allowed, so we just spin here
+;			waiting for the count to drop to 1.
+;			Also, the mapping can not be on any lists when we do this
+;			so all we are doing is waiting until it can be released.
+;
+
+			.align	5
+
+mapDrainBusy:
+			lwz		r4,mpFlags(r3)				; Get mpBusy
+			rlwinm	r4,r4,8,24,31				; Clean it up
+			cmplwi	r4,1						; Is is just our busy?
+			beqlr++								; Yeah, it is clear...
+			b		mapDrainBusy				; Try again...
+
+
+	
+;
+;			handleDSeg - handle a data segment fault
+;			handleISeg - handle an instruction segment fault
+;
+;			All that we do here is to map these to DSI or ISI and insure
+;			that the hash bit is not set.  This forces the fault code
+;			to also handle the missing segment.
+;
+;			At entry R2 contains per_proc, R13 contains savarea pointer,
+;			and R11 is the exception code.
+;
+
+			.align	5
+			.globl	EXT(handleDSeg)
+
+LEXT(handleDSeg)
+
+			li		r11,T_DATA_ACCESS			; Change fault to DSI
+			stw		r11,saveexception(r13)		; Change the exception code from seg fault to PTE miss
+			b		EXT(handlePF)				; Join common...
+
+			.align	5
+			.globl	EXT(handleISeg)
+
+LEXT(handleISeg)
+
+			li		r11,T_INSTRUCTION_ACCESS	; Change fault to ISI
+			stw		r11,saveexception(r13)		; Change the exception code from seg fault to PTE miss
+			b		EXT(handlePF)				; Join common...
+
+
+/*
+ *			handlePF - handle a page fault interruption
+ *
+ *			At entry R2 contains per_proc, R13 contains savarea pointer,
+ *			and R11 is the exception code.
+ *
+ *			This first part does a quick check to see if we can handle the fault.
+ *			We canot handle any kind of protection exceptions here, so we pass
+ *			them up to the next level.
+ *
+ *			NOTE: In order for a page-fault redrive to work, the translation miss
+ *			bit must be set in the DSISR (or SRR1 for IFETCH).  That must occur
+ *			before we come here.
+ */
+
+			.align	5
+			.globl	EXT(handlePF)
+
+LEXT(handlePF)
+
+ 			mfsprg	r12,2						; Get feature flags 
+			cmplwi	r11,T_INSTRUCTION_ACCESS		; See if this is for the instruction 
+			lwz		r8,savesrr1+4(r13)			; Get the MSR to determine mode
+			mtcrf	0x02,r12					; move pf64Bit to cr6
+			lis		r0,hi16(dsiNoEx|dsiProt|dsiInvMode|dsiAC)	; Get the types that we cannot handle here
+			lwz		r18,SAVflags(r13)			; Get the flags
+			
+			beq--	gotIfetch					; We have an IFETCH here...
+			
+			lwz		r27,savedsisr(r13)			; Get the DSISR
+			lwz		r29,savedar(r13)			; Get the first half of the DAR
+			lwz		r30,savedar+4(r13)			; And second half
+
+			b		ckIfProt					; Go check if this is a protection fault...
+
+gotIfetch:	andis.	r27,r8,hi16(dsiValid)		; Clean this up to construct a DSISR value
+			lwz		r29,savesrr0(r13)			; Get the first half of the instruction address
+			lwz		r30,savesrr0+4(r13)			; And second half
+			stw		r27,savedsisr(r13)			; Save the "constructed" DSISR
+
+ckIfProt:	and.	r4,r27,r0					; Is this a non-handlable exception?
+			li		r20,64						; Set a limit of 64 nests for sanity check
+			bne--	hpfExit						; Yes... (probably not though)
+
+;
+;			Note: if the RI is on, we are accessing user space from the kernel, therefore we
+;			should be loading the user pmap here.
+;
+
+			andi.	r0,r8,lo16(MASK(MSR_PR)|MASK(MSR_RI))	; Are we addressing user or kernel space?
+			lis		r8,hi16(EXT(kernel_pmap_phys))	; Assume kernel
+			mr		r19,r2						; Remember the per_proc
+			ori		r8,r8,lo16(EXT(kernel_pmap_phys))	; Assume kernel (bottom of address)
+			mr		r23,r30						; Save the low part of faulting address
+			beq--	hpfInKern					; Skip if we are in the kernel
+			la		r8,ppUserPmap(r19)			; Point to the current user pmap
+			
+hpfInKern:	mr		r22,r29						; Save the high part of faulting address
+			
+			bt--	pf64Bitb,hpf64a				; If 64-bit, skip the next bit...
+
+;
+;			On 32-bit machines we emulate a segment exception by loading unused SRs with a
+;			predefined value that corresponds to no address space.  When we see that value
+;			we turn off the PTE miss bit in the DSISR to drive the code later on that will
+;			cause the proper SR to be loaded.
+;
+
+			lwz		r28,4(r8)					; Pick up the pmap
+			rlwinm.	r18,r18,0,SAVredriveb,SAVredriveb	; Was this a redrive?
+			mr		r25,r28						; Save the original pmap (in case we nest)
+			bne		hpfNest						; Segs are not ours if so...
+			mfsrin	r4,r30						; Get the SR that was used for translation
+			cmplwi	r4,invalSpace				; Is this a simulated segment fault?
+			bne++	hpfNest						; No...
+			
+			rlwinm	r27,r27,0,dsiMissb+1,dsiMissb-1	; Clear the PTE miss bit in DSISR
+			b		hpfNest						; Join on up...
+			
+			.align	5
+
+			nop									; Push hpfNest to a 32-byte boundary
+			nop									; Push hpfNest to a 32-byte boundary
+			nop									; Push hpfNest to a 32-byte boundary
+			nop									; Push hpfNest to a 32-byte boundary
+			nop									; Push hpfNest to a 32-byte boundary
+			nop									; Push hpfNest to a 32-byte boundary
+
+hpf64a:		ld		r28,0(r8)					; Get the pmap pointer (64-bit)
+			mr		r25,r28						; Save the original pmap (in case we nest)
+
+;
+;			This is where we loop descending nested pmaps
+;
+
+hpfNest:	la		r3,pmapSXlk(r28)			; Point to the pmap search lock
+			addi	r20,r20,-1					; Count nest try
+			bl		sxlkShared					; Go get a shared lock on the mapping lists
+			mr.		r3,r3						; Did we get the lock?
+			bne--	hpfBadLock					; Nope...
+
+			mr		r3,r28						; Get the pmap pointer
+			mr		r4,r22						; Get top of faulting vaddr
+			mr		r5,r23						; Get bottom of faulting vaddr
+			bl		EXT(mapSearch)				; Go see if we can find it (R7 gets mpFlags)
+
+			rlwinm	r0,r7,0,mpRIPb,mpRIPb		; Are we removing this one?
+			mr.		r31,r3						; Save the mapping if we found it
+			cmplwi	cr1,r0,0					; Check for removal
+			crorc	cr0_eq,cr0_eq,cr1_eq		; Merge not found and removing
+			
+			bt--	cr0_eq,hpfNotFound			; Not found or removing...
+			
+			rlwinm.	r0,r7,0,mpNestb,mpNestb		; Are we nested?
+			mr		r26,r7						; Get the flags for this mapping (passed back from search call)
+			
+			lhz		r21,mpSpace(r31)			; Get the space
+
+			beq++	hpfFoundIt					; No, we found our guy...
+			
+
+#if pmapTransSize != 12
+#error pmapTrans entry size is not 12 bytes!!!!!!!!!!!! It is pmapTransSize
+#endif
+			rlwinm.	r0,r26,0,mpSpecialb,mpSpecialb	; Special handling?
+			cmplwi	cr1,r20,0					; Too many nestings?
+			bne--	hpfSpclNest					; Do we need to do special handling?
+
+hpfCSrch:	lhz		r21,mpSpace(r31)			; Get the space
+			lwz		r8,mpNestReloc(r31)			; Get the vaddr relocation
+			lwz		r9,mpNestReloc+4(r31)		; Get the vaddr relocation bottom half
+			la		r3,pmapSXlk(r28)			; Point to the old pmap search lock
+			lis		r0,0x8000					; Get 0xFFFFFFFF80000000
+			lis		r10,hi16(EXT(pmapTrans))	; Get the translate table
+			add		r0,r0,r0					; Get 0xFFFFFFFF00000000 for 64-bit or 0 for 32-bit
+			blt--	cr1,hpfNestTooMuch			; Too many nestings, must be a loop...
+			or		r23,r23,r0					; Make sure a carry will propagate all the way in 64-bit
+			slwi	r11,r21,3					; Multiply space by 8
+			ori		r10,r10,lo16(EXT(pmapTrans))	; Get the translate table low part
+			addc	r23,r23,r9					; Relocate bottom half of vaddr
+			lwz		r10,0(r10)					; Get the actual translation map
+			slwi	r12,r21,2					; Multiply space by 4
+			add		r10,r10,r11					; Add in the higher part of the index
+			rlwinm	r23,r23,0,0,31				; Clean up the relocated address (does nothing in 32-bit)
+			adde	r22,r22,r8					; Relocate the top half of the vaddr
+			add		r12,r12,r10					; Now we are pointing at the space to pmap translation entry
+			bl		sxlkUnlock					; Unlock the search list
+			
+			lwz		r28,pmapPAddr+4(r12)		; Get the physical address of the new pmap
+			bf--	pf64Bitb,hpfNest			; Done if 32-bit...
+			
+			ld		r28,pmapPAddr(r12)			; Get the physical address of the new pmap
+			b		hpfNest						; Go try the new pmap...
+
+;
+;			Error condition.  We only allow 64 nestings.  This keeps us from having to 
+;			check for recusive nests when we install them.
+;
+		
+			.align	5
+
+hpfNestTooMuch:
+			lwz		r20,savedsisr(r13)			; Get the DSISR
+			la		r3,pmapSXlk(r28)			; Point to the pmap search lock
+			bl		sxlkUnlock					; Unlock the search list (R3 good from above)
+			ori		r20,r20,1					; Indicate that there was a nesting problem 
+			stw		r20,savedsisr(r13)			; Stash it
+			lwz		r11,saveexception(r13)		; Restore the exception code
+			b		EXT(PFSExit)				; Yes... (probably not though)
+
+;
+;			Error condition - lock failed - this is fatal
+;
+		
+			.align	5
+
+hpfBadLock:
+			lis		r0,hi16(Choke)				; System abend
+			ori		r0,r0,lo16(Choke)			; System abend
+			li		r3,failMapping				; Show mapping failure
+			sc
+;
+;			Did not find any kind of mapping
+;
+
+			.align	5
+			
+hpfNotFound:
+			la		r3,pmapSXlk(r28)			; Point to the pmap search lock
+			bl		sxlkUnlock					; Unlock it
+			lwz		r11,saveexception(r13)		; Restore the exception code
+			
+hpfExit:										; We need this because we can not do a relative branch
+			b		EXT(PFSExit)				; Yes... (probably not though)
+
+
+;
+;			Here is where we handle special mappings.  So far, the only use is to load a 
+;			processor specific segment register for copy in/out handling.
+;
+;			The only (so far implemented) special map is used for copyin/copyout.
+;			We keep a mapping of a "linkage" mapping in the per_proc.
+;			The linkage mapping is basically a nested pmap that is switched in
+;			as part of context switch.  It relocates the appropriate user address
+;			space slice into the right place in the kernel.
+;
+
+			.align	5
+
+hpfSpclNest:	
+			la		r31,ppCIOmp(r19)			; Just point to the mapping
+			oris	r27,r27,hi16(dsiSpcNest)	; Show that we had a special nesting here
+			b		hpfCSrch					; Go continue search...
+
+
+;
+;			We have now found a mapping for the address we faulted on. 
+;			
+
+;
+;			Here we go about calculating what the VSID should be. We concatanate
+;			the space ID (14 bits wide) 3 times.  We then slide the vaddr over
+;			so that bits 0:35 are in 14:49 (leaves a hole for one copy of the space ID).
+;			Then we XOR and expanded space ID and the shifted vaddr.  This gives us
+;			the VSID.  
+;
+;			This is used both for segment handling and PTE handling
+;
+
+
+#if maxAdrSpb != 14
+#error maxAdrSpb (address space id size) is not 14 bits!!!!!!!!!!!!
+#endif
+
+			.align	5
+			
+hpfFoundIt:	lwz		r12,pmapFlags(r28)			; Get the pmap flags so we can find the keys for this segment
+			rlwinm.	r0,r27,0,dsiMissb,dsiMissb	; Did we actually miss the segment?
+			rlwinm	r15,r23,18,14,17			; Shift 32:35 (0:3) of vaddr just above space ID
+			rlwinm	r20,r21,28,22,31			; Shift upper 10 bits of space into high order
+			rlwinm	r14,r22,18,14,31			; Shift 0:17 of vaddr over
+			rlwinm	r0,r27,0,dsiSpcNestb,dsiSpcNestb	; Isolate special nest flag
+			rlwimi	r21,r21,14,4,17				; Make a second copy of space above first
+			cmplwi	cr5,r0,0					; Did we just do a special nesting?
+			rlwimi	r15,r22,18,0,13				; Shift 18:31 of vaddr just above shifted 32:35	
+			crorc	cr0_eq,cr0_eq,cr5_eq		; Force outselves through the seg load code if special nest
+			rlwimi	r21,r21,28,0,3				; Get low order of 3rd copy of space at top of register
+			xor		r14,r14,r20					; Calculate the top half of VSID
+			xor		r15,r15,r21					; Calculate the bottom half of the VSID
+			rlwinm	r14,r14,12,15,19			; Slide the top of the VSID over to correct position (trim for 65 bit addressing)
+			rlwinm	r12,r12,9,20,22				; Isolate and position key for cache entry
+			rlwimi	r14,r15,12,20,31			; Slide top of bottom of VSID over into the top
+			rlwinm	r15,r15,12,0,19				; Slide the last nybble into the low order segment position
+			or		r12,r12,r15					; Add key into the bottom of VSID
+;
+;			Note: ESID is in R22:R23 pair; VSID is in R14:R15; cache form VSID is R14:R12
+			
+			bne++	hpfPteMiss					; Nope, normal PTE miss...
+
+;
+;			Here is the only place that we make an entry in the pmap segment cache.
+;
+;			Note that we do not make an entry in the segment cache for special
+;			nested mappings.  This makes the copy in/out segment get refreshed
+;			when switching threads.
+;
+;			The first thing that we do is to look up the ESID we are going to load
+;			into a segment in the pmap cache.  If it is already there, this is
+;			a segment that appeared since the last time we switched address spaces.
+;			If all is correct, then it was another processors that made the cache
+;			entry.  If not, well, it is an error that we should die on, but I have
+;			not figured a good way to trap it yet.
+;
+;			If we get a hit, we just bail, otherwise, lock the pmap cache, select
+;			an entry based on the generation number, update the cache entry, and 
+;			also update the pmap sub-tag as well.  The sub-tag is a table of 4 bit
+;			entries that correspond to the last 4 bits (32:35 for 64-bit and 
+;			0:3 for 32-bit) of the ESID.
+;
+;			Then we unlock and bail.
+;
+;			First lock it.  Then select a free slot or steal one based on the generation
+;			number. Then store it, update the allocation flags, and unlock.
+;
+;			The cache entry contains an image of the ESID/VSID pair we would load for
+;			64-bit architecture.  For 32-bit, it is a simple transform to an SR image.
+;
+;			Remember, this cache entry goes in the ORIGINAL pmap (saved in R25), not
+;			the current one, which may have changed because we nested.
+;
+;			Also remember that we do not store the valid bit in the ESID.  If we 
+;			od, this will break some other stuff.
+;
+
+			bne--	cr5,hpfNoCacheEnt2			; Skip the cache entry if this is a "special nest" fault....
+			
+			mr		r3,r25						; Point to the pmap
+			mr		r4,r22						; ESID high half
+			mr		r5,r23						; ESID low half
+			bl		pmapCacheLookup				; Go see if this is in the cache already
+			
+			mr.		r3,r3						; Did we find it?
+			mr		r4,r11						; Copy this to a different register
+
+			bne--	hpfNoCacheEnt				; Yes, we found it, no need to make another entry...
+			
+			lwz		r10,pmapSCSubTag(r25)		; Get the first part of the sub-tag lookup table
+			lwz		r11,pmapSCSubTag+4(r25)		; Get the second part of the sub-tag lookup table
+			
+			cntlzw	r7,r4						; Find a free slot
+
+			subi	r6,r7,pmapSegCacheUse		; We end up with a negative if we find one
+			rlwinm	r30,r30,0,0,3				; Clean up the ESID
+			srawi	r6,r6,31					; Get 0xFFFFFFFF if we have one, 0 if not
+			addi	r5,r4,1						; Bump the generation number
+			and		r7,r7,r6					; Clear bit number if none empty
+			andc	r8,r4,r6					; Clear generation count if we found an empty
+			rlwimi	r4,r5,0,17,31				; Insert the new generation number into the control word			
+			or		r7,r7,r8					; Select a slot number
+			li		r8,0						; Clear
+			andi.	r7,r7,pmapSegCacheUse-1		; Wrap into the number we are using
+			oris	r8,r8,0x8000				; Get the high bit on
+			la		r9,pmapSegCache(r25)		; Point to the segment cache
+			slwi	r6,r7,4						; Get index into the segment cache
+			slwi	r2,r7,2						; Get index into the segment cache sub-tag index
+			srw		r8,r8,r7					; Get the mask
+			cmplwi	r2,32						; See if we are in the first or second half of sub-tag
+			li		r0,0						; Clear
+			rlwinm	r2,r2,0,27,31				; Wrap shift so we do not shift cache entries 8-F out
+			oris	r0,r0,0xF000				; Get the sub-tag mask
+			add		r9,r9,r6					; Point to the cache slot
+			srw		r0,r0,r2					; Slide sub-tag mask to right slot (shift work for either half)
+			srw		r5,r30,r2					; Slide sub-tag to right slot (shift work for either half)
+			
+			stw		r29,sgcESID(r9)				; Save the top of the ESID
+			andc	r10,r10,r0					; Clear sub-tag slot in case we are in top
+			andc	r11,r11,r0					; Clear sub-tag slot in case we are in bottom
+			stw		r30,sgcESID+4(r9)			; Save the bottom of the ESID
+			or		r10,r10,r5					; Stick in subtag in case top half
+			or		r11,r11,r5					; Stick in subtag in case bottom half
+			stw		r14,sgcVSID(r9)				; Save the top of the VSID
+			andc	r4,r4,r8					; Clear the invalid bit for the slot we just allocated
+			stw		r12,sgcVSID+4(r9)			; Save the bottom of the VSID and the key
+			bge		hpfSCSTbottom				; Go save the bottom part of sub-tag
+			
+			stw		r10,pmapSCSubTag(r25)		; Save the top of the sub-tag
+			b		hpfNoCacheEnt				; Go finish up...
+			
+hpfSCSTbottom:
+			stw		r11,pmapSCSubTag+4(r25)		; Save the bottom of the sub-tag
+
+
+hpfNoCacheEnt:	
+			eieio								; Make sure cache is updated before lock
+			stw		r4,pmapCCtl(r25)			; Unlock, allocate, and bump generation number
+
+
+hpfNoCacheEnt2:
+			lwz		r4,ppMapFlags(r19)			; Get the protection key modifier
+			bt++	pf64Bitb,hpfLoadSeg64		; If 64-bit, go load the segment...
+						
+;
+;			Make and enter 32-bit segment register
+;
+
+			lwz		r16,validSegs(r19)			; Get the valid SR flags
+			xor		r12,r12,r4					; Alter the storage key before loading segment register
+			rlwinm	r2,r30,4,28,31				; Isolate the segment we are setting
+			rlwinm	r6,r12,19,1,3				; Insert the keys and N bit			
+			lis		r0,0x8000					; Set bit 0
+			rlwimi	r6,r12,20,12,31				; Insert 4:23 the VSID
+			srw		r0,r0,r2					; Get bit corresponding to SR
+			rlwimi	r6,r14,20,8,11				; Get the last nybble of the SR contents			
+			or		r16,r16,r0					; Show that SR is valid
+		
+			mtsrin	r6,r30						; Set the actual SR
+			
+			stw		r16,validSegs(r19)			; Set the valid SR flags
+		
+			b		hpfPteMiss					; SR loaded, go do a PTE...
+			
+;
+;			Make and enter 64-bit segment look-aside buffer entry.
+;			Note that the cache entry is the right format except for valid bit.
+;			We also need to convert from long long to 64-bit register values.
+;
+
+
+			.align	5
+			
+hpfLoadSeg64:
+			ld		r16,validSegs(r19)			; Get the valid SLB entry flags
+			sldi	r8,r29,32					; Move high order address over
+			sldi	r10,r14,32					; Move high part of VSID over
+			
+			not		r3,r16						; Make valids be 0s
+			li		r0,1						; Prepare to set bit 0
+			
+			cntlzd	r17,r3						; Find a free SLB	
+			xor		r12,r12,r4					; Alter the storage key before loading segment table entry
+			or		r9,r8,r30					; Form full 64-bit address
+			cmplwi	r17,63						; Did we find a free SLB entry?		
+			sldi	r0,r0,63					; Get bit 0 set
+			or		r10,r10,r12					; Move in low part and keys
+			addi	r17,r17,1					; Skip SLB 0 always
+			blt++	hpfFreeSeg					; Yes, go load it...
+
+;
+;			No free SLB entries, select one that is in use and invalidate it
+;
+			lwz		r4,ppSegSteal(r19)			; Get the next slot to steal
+			addi	r17,r4,pmapSegCacheUse+1	; Select stealee from non-cached slots only
+			addi	r4,r4,1						; Set next slot to steal
+			slbmfee	r7,r17						; Get the entry that is in the selected spot
+			subi	r2,r4,63-pmapSegCacheUse	; Force steal to wrap
+			rldicr	r7,r7,0,35					; Clear the valid bit and the rest
+			srawi	r2,r2,31					; Get -1 if steal index still in range
+			slbie	r7							; Invalidate the in-use SLB entry
+			and		r4,r4,r2					; Reset steal index when it should wrap
+			isync								; 
+			
+			stw		r4,ppSegSteal(r19)			; Set the next slot to steal
+;
+;			We are now ready to stick the SLB entry in the SLB and mark it in use
+;
+
+hpfFreeSeg:	
+			subi	r4,r17,1					; Adjust shift to account for skipping slb 0
+			mr		r7,r9						; Get a copy of the ESID with bits 36:63 clear
+			srd		r0,r0,r4					; Set bit mask for allocation
+			oris	r9,r9,0x0800				; Turn on the valid bit
+			or		r16,r16,r0					; Turn on the allocation flag
+			rldimi	r9,r17,0,58					; Copy in the SLB entry selector
+			
+			beq++	cr5,hpfNoBlow				; Skip blowing away the SLBE if this is not a special nest...
+			slbie	r7							; Blow away a potential duplicate
+			
+hpfNoBlow:	slbmte	r10,r9						; Make that SLB entry
+
+			std		r16,validSegs(r19)			; Mark as valid
+			b		hpfPteMiss					; STE loaded, go do a PTE...
+			
+;
+;			The segment has been set up and loaded if need be.  Now we are ready to build the
+;			PTE and get it into the hash table.
+;
+;			Note that there is actually a race here.  If we start fault processing on
+;			a different pmap, i.e., we have descended into a nested pmap, it is possible
+;			that the nest could have been removed from the original pmap.  We would
+;			succeed with this translation anyway.  I do not think we need to worry
+;			about this (famous last words) because nobody should be unnesting anything 
+;			if there are still people activily using them.  It should be up to the
+;			higher level VM system to put the kibosh on this.
+;
+;			There is also another race here: if we fault on the same mapping on more than
+;			one processor at the same time, we could end up with multiple PTEs for the same
+;			mapping.  This is not a good thing....   We really only need one of the
+;			fault handlers to finish, so what we do is to set a "fault in progress" flag in
+;			the mapping.  If we see that set, we just abandon the handler and hope that by
+;			the time we restore context and restart the interrupted code, the fault has
+;			been resolved by the other guy.  If not, we will take another fault.
+;
+		
+;
+;			NOTE: IMPORTANT - CR7 contains a flag indicating if we have a block mapping or not.
+;			It is required to stay there until after we call mapSelSlot!!!!
+;
+
+			.align	5
+			
+hpfPteMiss:	lwarx	r0,0,r31					; Load the mapping flag field
+			lwz		r12,mpPte(r31)				; Get the quick pointer to PTE
+			li		r3,mpHValid					; Get the PTE valid bit
+			andi.	r2,r0,lo16(mpFIP)			; Are we handling a fault on the other side?
+			ori		r2,r0,lo16(mpFIP)			; Set the fault in progress flag
+			crnot	cr1_eq,cr0_eq				; Remember if FIP was on
+			and.	r12,r12,r3					; Isolate the valid bit
+			crorc	cr0_eq,cr1_eq,cr0_eq		; Bail if FIP is on.  Then, if already have PTE, bail...
+			beq--	hpfAbandon					; Yes, other processor is or already has handled this...
+			andi.	r0,r2,mpBlock				; Is this a block mapping?
+			crmove	cr7_eq,cr0_eq				; Remember if we have a block mapping
+			stwcx.	r2,0,r31					; Store the flags
+			bne--	hpfPteMiss					; Collision, try again...
+
+			bt++	pf64Bitb,hpfBldPTE64		; Skip down to the 64 bit stuff...
+
+;
+;			At this point we are about to do the 32-bit PTE generation.
+;
+;			The following is the R14:R15 pair that contains the "shifted" VSID:
+;
+;                             1        2        3        4        4        5      6 
+;           0        8        6        4        2        0        8        6      3
+;          +--------+--------+--------+--------+--------+--------+--------+--------+
+;          |00000000|0000000V|VVVVVVVV|VVVVVVVV|VVVVVVVV|VVVVVVVV|VVVV////|////////|    
+;          +--------+--------+--------+--------+--------+--------+--------+--------+                   
+;
+;			The 24 bits of the 32-bit architecture VSID is in the following:
+;
+;                             1        2        3        4        4        5      6 
+;           0        8        6        4        2        0        8        6      3
+;          +--------+--------+--------+--------+--------+--------+--------+--------+
+;          |////////|////////|////////|////VVVV|VVVVVVVV|VVVVVVVV|VVVV////|////////|    
+;          +--------+--------+--------+--------+--------+--------+--------+--------+                   
+;
+
+
+hpfBldPTE32:
+			lwz		r25,mpVAddr+4(r31)			; Grab the base virtual address for the mapping (32-bit portion)	
+			lwz		r24,mpPAddr(r31)			; Grab the base physical page number for the mapping	
+
+			mfsdr1	r27							; Get the hash table base address
+
+			rlwinm	r0,r23,0,4,19				; Isolate just the page index
+			rlwinm	r18,r23,10,26,31			; Extract the API
+			xor		r19,r15,r0					; Calculate hash << 12
+			mr		r2,r25						; Save the flag part of the mapping
+			rlwimi	r18,r14,27,1,4				; Move bits 28:31 of the "shifted" VSID into the PTE image
+			rlwinm	r16,r27,16,7,15				; Extract the hash table size
+			rlwinm	r25,r25,0,0,19				; Clear out the flags
+			slwi	r24,r24,12					; Change ppnum to physical address (note: 36-bit addressing no supported)
+			sub		r25,r23,r25					; Get offset in mapping to page (0 unless block map)
+			ori		r16,r16,lo16(0xFFC0)		; Slap in the bottom of the mask
+			rlwinm	r27,r27,0,0,15				; Extract the hash table base
+			rlwinm	r19,r19,26,6,25				; Shift hash over to make offset into hash table
+			add		r24,r24,r25					; Adjust to true physical address
+			rlwimi	r18,r15,27,5,24				; Move bits 32:31 of the "shifted" VSID into the PTE image
+			rlwimi	r24,r2,0,20,31				; Slap in the WIMG and prot
+			and		r19,r19,r16					; Wrap hash table offset into the hash table
+			ori		r24,r24,lo16(mpR)			; Turn on the reference bit right now
+			rlwinm	r20,r19,28,10,29			; Shift hash over to make offset into PCA
+			add		r19,r19,r27					; Point to the PTEG
+			subfic	r20,r20,-4					; Get negative offset to PCA
+			oris	r18,r18,lo16(0x8000)		; Make sure the valid bit is on
+			add		r20,r20,r27					; Point to the PCA slot
+		
+;
+;			We now have a valid PTE pair in R18/R24.  R18 is PTE upper and R24 is PTE lower.
+;			R19 contains the offset of the PTEG in the hash table. R20 has offset into the PCA.
+;		
+;			We need to check PTE pointer (mpPte) again after we lock the PTEG.  It is possible 
+;			that some other processor beat us and stuck in a PTE or that 
+;			all we had was a simple segment exception and the PTE was there the whole time.
+;			If we find one a pointer, we are done.
+;
+
+			mr		r7,r20						; Copy the PCA pointer
+			bl		mapLockPteg					; Lock the PTEG
+	
+			lwz		r12,mpPte(r31)				; Get the offset to the PTE
+			mr		r17,r6						; Remember the PCA image
+			mr		r16,r6						; Prime the post-select PCA image
+			andi.	r0,r12,mpHValid				; Is there a PTE here already?
+			li		r21,8						; Get the number of slots
+
+			bne-	cr7,hpfNoPte32				; Skip this for a block mapping...
+
+			bne-	hpfBailOut					; Someone already did this for us...
+
+;
+;			The mapSelSlot function selects a PTEG slot to use. As input, it uses R3 as a 
+;			pointer to the PCA.  When it returns, R3 contains 0 if an unoccupied slot was
+;			selected, 1 if it stole a non-block PTE, or 2 if it stole a block mapped PTE.
+;			R4 returns the slot index.
+;
+;			REMEMBER: CR7 indicates that we are building a block mapping.
+;
+
+hpfNoPte32:	subic.	r21,r21,1					; See if we have tried all slots
+			mr		r6,r17						; Get back the original PCA
+			rlwimi	r6,r16,0,8,15				; Insert the updated steal slot
+			blt-	hpfBailOut					; Holy Cow, all slots are locked...
+			
+			bl		mapSelSlot					; Go select a slot (note that the PCA image is already set up)
+
+			cmplwi	cr5,r3,1					; Did we steal a slot?			
+			rlwinm	r5,r4,3,26,28				; Convert index to slot offset
+			add		r19,r19,r5					; Point directly to the PTE
+			mr		r16,r6						; Remember the PCA image after selection
+			blt+	cr5,hpfInser32				; Nope, no steal...
+			
+			lwz		r6,0(r19)					; Get the old PTE
+			lwz		r7,4(r19)					; Get the real part of the stealee
+			rlwinm	r6,r6,0,1,31				; Clear the valid bit
+			bgt		cr5,hpfNipBM				; Do not try to lock a non-existant physent for a block mapping...
+			srwi	r3,r7,12					; Change phys address to a ppnum
+			bl		mapFindPhyTry				; Go find and try to lock physent (note: if R3 is 0, there is no physent for this page)
+			cmplwi	cr1,r3,0					; Check if this is in RAM
+			bne-	hpfNoPte32					; Could not get it, try for another...
+			
+			crmove	cr5_gt,cr1_eq				; If we did not find a physent, pretend that this is a block map
+			
+hpfNipBM:	stw		r6,0(r19)					; Set the invalid PTE
+
+			sync								; Make sure the invalid is stored
+			li		r9,tlbieLock				; Get the TLBIE lock
+			rlwinm	r10,r6,21,0,3				; Shift last 4 bits of space to segment part
+			
+hpfTLBIE32:	lwarx	r0,0,r9						; Get the TLBIE lock 
+			mfsprg	r4,0						; Get the per_proc
+			rlwinm	r8,r6,25,18,31				; Extract the space ID
+			rlwinm	r11,r6,25,18,31				; Extract the space ID
+			lwz		r7,hwSteals(r4)				; Get the steal count
+			srwi	r2,r6,7						; Align segment number with hash
+			rlwimi	r11,r11,14,4,17				; Get copy above ourselves
+			mr.		r0,r0						; Is it locked? 
+			srwi	r0,r19,6					; Align PTEG offset for back hash
+			xor		r2,r2,r11					; Get the segment number (plus a whole bunch of extra bits)
+ 			xor		r11,r11,r0					; Hash backwards to partial vaddr
+			rlwinm	r12,r2,14,0,3				; Shift segment up
+			mfsprg	r2,2						; Get feature flags 
+			li		r0,1						; Get our lock word 
+			rlwimi	r12,r6,22,4,9				; Move up the API
+			bne-	hpfTLBIE32					; It is locked, go wait...
+			rlwimi	r12,r11,12,10,19			; Move in the rest of the vaddr
+			
+			stwcx.	r0,0,r9						; Try to get it
+			bne-	hpfTLBIE32					; We was beat...
+			addi	r7,r7,1						; Bump the steal count
+			
+			rlwinm.	r0,r2,0,pfSMPcapb,pfSMPcapb	; Can this be an MP box?
+			li		r0,0						; Lock clear value 
+
+			tlbie	r12							; Invalidate it everywhere 
+
+			stw		r0,tlbieLock(0)				; Clear the tlbie lock
+			
+			beq-	hpfNoTS32					; Can not have MP on this machine...
+			
+			eieio								; Make sure that the tlbie happens first 
+			tlbsync								; Wait for everyone to catch up 
+			sync								; Make sure of it all
+			
+hpfNoTS32:	stw		r7,hwSteals(r4)				; Save the steal count
+			bgt		cr5,hpfInser32				; We just stole a block mapping...
+			
+			lwz		r4,4(r19)					; Get the RC of the just invalidated PTE
+			
+			la		r11,ppLink+4(r3)			; Point to the master RC copy
+			lwz		r7,ppLink+4(r3)				; Grab the pointer to the first mapping
+			rlwinm	r2,r4,27,ppRb-32,ppCb-32	; Position the new RC
+
+hpfMrgRC32:	lwarx	r0,0,r11					; Get the master RC
+			or		r0,r0,r2					; Merge in the new RC
+			stwcx.	r0,0,r11					; Try to stick it back
+			bne-	hpfMrgRC32					; Try again if we collided...
+			
+			
+hpfFPnch:	rlwinm.	r7,r7,0,0,25				; Clean and test mapping address
+			beq-	hpfLostPhys					; We could not find our mapping.  Kick the bucket...
+			
+			lhz		r10,mpSpace(r7)				; Get the space
+			lwz		r9,mpVAddr+4(r7)			; And the vaddr
+			cmplw	cr1,r10,r8					; Is this one of ours?
+			xor		r9,r12,r9					; Compare virtual address
+			cmplwi	r9,0x1000					; See if we really match
+			crand	cr0_eq,cr1_eq,cr0_lt		; See if both space and vaddr match
+			beq+	hpfFPnch2					; Yes, found ours...
+			
+			lwz		r7,mpAlias+4(r7)			; Chain on to the next
+			b		hpfFPnch					; Check it out...
+
+hpfFPnch2:	sub		r0,r19,r27					; Get offset to the PTEG
+			stw		r0,mpPte(r7)				; Invalidate the quick pointer (keep quick pointer pointing to PTEG)
+			bl		mapPhysUnlock				; Unlock the physent now
+			
+hpfInser32:	oris	r18,r18,lo16(0x8000)		; Make sure the valid bit is on
+
+			stw		r24,4(r19)					; Stuff in the real part of the PTE
+			eieio								; Make sure this gets there first
+
+			stw		r18,0(r19)					; Stuff the virtual part of the PTE and make it valid
+			mr		r17,r16						; Get the PCA image to save
+			b		hpfFinish					; Go join the common exit code...
+			
+			
+;
+;			At this point we are about to do the 64-bit PTE generation.
+;
+;			The following is the R14:R15 pair that contains the "shifted" VSID:
+;
+;                             1        2        3        4        4        5      6 
+;           0        8        6        4        2        0        8        6      3
+;          +--------+--------+--------+--------+--------+--------+--------+--------+
+;          |00000000|0000000V|VVVVVVVV|VVVVVVVV|VVVVVVVV|VVVVVVVV|VVVV////|////////|    
+;          +--------+--------+--------+--------+--------+--------+--------+--------+                   
+;
+;
+
+			.align	5
+
+hpfBldPTE64:
+			ld		r10,mpVAddr(r31)			; Grab the base virtual address for the mapping 
+			lwz		r24,mpPAddr(r31)			; Grab the base physical page number for the mapping	
+
+			mfsdr1	r27							; Get the hash table base address
+
+			sldi	r11,r22,32					; Slide top of adjusted EA over
+			sldi	r14,r14,32					; Slide top of VSID over
+			rlwinm	r5,r27,0,27,31				; Isolate the size
+			eqv		r16,r16,r16					; Get all foxes here
+			rlwimi	r15,r23,16,20,24			; Stick in EA[36:40] to make AVPN	
+			mr		r2,r10						; Save the flag part of the mapping
+			or		r11,r11,r23					; Stick in bottom of adjusted EA for full 64-bit value	
+			rldicr	r27,r27,0,45				; Clean up the hash table base
+			or		r15,r15,r14					; Stick in bottom of AVPN for full 64-bit value	
+			rlwinm	r0,r11,0,4,19				; Clear out everything but the page
+			subfic	r5,r5,46					; Get number of leading zeros
+			xor		r19,r0,r15					; Calculate hash
+			ori		r15,r15,1					; Turn on valid bit in AVPN to make top of PTE
+			srd		r16,r16,r5					; Shift over to get length of table
+			srdi	r19,r19,5					; Convert page offset to hash table offset
+			rldicr	r16,r16,0,56				; Clean up lower bits in hash table size			
+			rldicr	r10,r10,0,51				; Clear out flags
+			sldi	r24,r24,12					; Change ppnum to physical address
+			sub		r11,r11,r10					; Get the offset from the base mapping
+			and		r19,r19,r16					; Wrap into hash table
+			add		r24,r24,r11					; Get actual physical address of this page
+			srdi	r20,r19,5					; Convert PTEG offset to PCA offset
+			rldimi	r24,r2,0,52					; Insert the keys, WIMG, RC, etc.
+			subfic	r20,r20,-4					; Get negative offset to PCA
+			ori		r24,r24,lo16(mpR)			; Force on the reference bit
+			add		r20,r20,r27					; Point to the PCA slot		
+			add		r19,r19,r27					; Point to the PTEG
+			
+;
+;			We now have a valid PTE pair in R15/R24.  R15 is PTE upper and R24 is PTE lower.
+;			R19 contains the offset of the PTEG in the hash table. R20 has offset into the PCA.
+;		
+;			We need to check PTE pointer (mpPte) again after we lock the PTEG.  It is possible 
+;			that some other processor beat us and stuck in a PTE or that 
+;			all we had was a simple segment exception and the PTE was there the whole time.
+;			If we find one a pointer, we are done.
+;
+			
+			mr		r7,r20						; Copy the PCA pointer
+			bl		mapLockPteg					; Lock the PTEG
+	
+			lwz		r12,mpPte(r31)				; Get the offset to the PTE
+			mr		r17,r6						; Remember the PCA image
+			mr		r18,r6						; Prime post-selection PCA image
+			andi.	r0,r12,mpHValid				; See if we have a PTE now
+			li		r21,8						; Get the number of slots
+		
+			bne--	cr7,hpfNoPte64				; Skip this for a block mapping...
+
+			bne--	hpfBailOut					; Someone already did this for us...
+
+;
+;			The mapSelSlot function selects a PTEG slot to use. As input, it uses R3 as a 
+;			pointer to the PCA.  When it returns, R3 contains 0 if an unoccupied slot was
+;			selected, 1 if it stole a non-block PTE, or 2 if it stole a block mapped PTE.
+;			R4 returns the slot index.
+;
+;			REMEMBER: CR7 indicates that we are building a block mapping.
+;
+
+hpfNoPte64:	subic.	r21,r21,1					; See if we have tried all slots
+			mr		r6,r17						; Restore original state of PCA
+			rlwimi	r6,r18,0,8,15				; Insert the updated steal slot
+			blt-	hpfBailOut					; Holy Cow, all slots are locked...
+			
+			bl		mapSelSlot					; Go select a slot
+
+			cmplwi	cr5,r3,1					; Did we steal a slot?			
+			rlwinm	r5,r4,4,25,27				; Convert index to slot offset
+			mr		r18,r6						; Remember the PCA image after selection
+			add		r19,r19,r5					; Point directly to the PTE
+			lwz		r10,hwSteals(r2)			; Get the steal count
+			blt++	cr5,hpfInser64				; Nope, no steal...
+
+			ld		r6,0(r19)					; Get the old PTE
+			ld		r7,8(r19)					; Get the real part of the stealee
+			rldicr	r6,r6,0,62					; Clear the valid bit
+			bgt		cr5,hpfNipBMx				; Do not try to lock a non-existant physent for a block mapping...
+			srdi	r3,r7,12					; Change page address to a page number
+			bl		mapFindPhyTry				; Go find and try to lock physent (note: if R3 is 0, there is no physent for this page)
+			cmplwi	cr1,r3,0					; Check if this is in RAM
+			bne--	hpfNoPte64					; Could not get it, try for another...
+			
+			crmove	cr5_gt,cr1_eq				; If we did not find a physent, pretend that this is a block map
+			
+hpfNipBMx:	std		r6,0(r19)					; Set the invalid PTE
+			li		r9,tlbieLock				; Get the TLBIE lock
+
+			srdi	r11,r6,5					; Shift VSID over for back hash
+			mfsprg	r4,0						; Get the per_proc
+			xor		r11,r11,r19					; Hash backwards to get low bits of VPN
+			sync								; Make sure the invalid is stored
+			
+			sldi	r12,r6,16					; Move AVPN to EA position
+			sldi	r11,r11,5					; Move this to the page position
+			
+hpfTLBIE64:	lwarx	r0,0,r9						; Get the TLBIE lock 
+			mr.		r0,r0						; Is it locked? 
+			li		r0,1						; Get our lock word
+			bne--	hpfTLBIE65					; It is locked, go wait...
+			
+			stwcx.	r0,0,r9						; Try to get it
+			rldimi	r12,r11,0,41				; Stick the low part of the page number into the AVPN
+			rldicl	r8,r6,52,50					; Isolate the address space ID
+			bne--	hpfTLBIE64					; We was beat...
+			addi	r10,r10,1					; Bump the steal count
+			
+			rldicl	r11,r12,0,16				; Clear cause the book says so
+			li		r0,0						; Lock clear value 
+
+			tlbie	r11							; Invalidate it everywhere 
+
+			stw		r0,tlbieLock(0)				; Clear the tlbie lock
+
+			mr		r7,r8						; Get a copy of the space ID
+			eieio								; Make sure that the tlbie happens first
+			rldimi	r7,r7,14,36					; Copy address space to make hash value
+			tlbsync								; Wait for everyone to catch up
+			rldimi	r7,r7,28,22					; Add in a 3rd copy of the hash up top
+			isync								
+			srdi	r2,r6,26					; Shift original segment down to bottom
+			
+			ptesync								; Make sure of it all
+			xor		r7,r7,r2					; Compute original segment
+
+			stw		r10,hwSteals(r4)			; Save the steal count
+			bgt		cr5,hpfInser64				; We just stole a block mapping...
+			
+			rldimi	r12,r7,28,0					; Insert decoded segment
+			rldicl	r4,r12,0,13					; Trim to max supported address
+			
+			ld		r12,8(r19)					; Get the RC of the just invalidated PTE			
+
+			la		r11,ppLink+4(r3)			; Point to the master RC copy
+			ld		r7,ppLink(r3)				; Grab the pointer to the first mapping
+			rlwinm	r2,r12,27,ppRb-32,ppCb-32	; Position the new RC
+
+hpfMrgRC64:	lwarx	r0,0,r11					; Get the master RC
+			li		r12,0xFF					; Get mask to clean up alias pointer
+			or		r0,r0,r2					; Merge in the new RC
+			rldicl	r12,r12,62,0				; Rotate clean up mask to get 0xC0000000000000003F
+			stwcx.	r0,0,r11					; Try to stick it back
+			bne--	hpfMrgRC64					; Try again if we collided...
+	
+hpfFPnchx:	andc.	r7,r7,r12					; Clean and test mapping address
+			beq--	hpfLostPhys					; We could not find our mapping.  Kick the bucket...
+			
+			lhz		r10,mpSpace(r7)				; Get the space
+			ld		r9,mpVAddr(r7)				; And the vaddr
+			cmplw	cr1,r10,r8					; Is this one of ours?
+			xor		r9,r4,r9					; Compare virtual address
+			cmpldi	r9,0x1000					; See if we really match
+			crand	cr0_eq,cr1_eq,cr0_lt		; See if both space and vaddr match
+			beq++	hpfFPnch2x					; Yes, found ours...
+			
+			ld		r7,mpAlias(r7)				; Chain on to the next
+			b		hpfFPnchx					; Check it out...
+
+			.align	5
+
+hpfTLBIE65:	li		r7,lgKillResv				; Point to the reservatio kill area
+			stwcx.	r7,0,r7						; Kill reservation		
+			
+hpfTLBIE63: lwz		r0,0(r9)					; Get the TLBIE lock
+			mr.		r0,r0						; Is it locked?
+			beq++	hpfTLBIE64					; Yup, wait for it...
+			b		hpfTLBIE63					; Nope, try again..
+
+
+
+hpfFPnch2x:	sub		r0,r19,r27					; Get offset to PTEG
+			stw		r0,mpPte(r7)				; Invalidate the quick pointer (keep pointing at PTEG though)
+			bl		mapPhysUnlock				; Unlock the physent now
+			
+
+hpfInser64:	std		r24,8(r19)					; Stuff in the real part of the PTE
+			eieio								; Make sure this gets there first
+			std		r15,0(r19)					; Stuff the virtual part of the PTE and make it valid
+			mr		r17,r18						; Get the PCA image to set
+			b		hpfFinish					; Go join the common exit code...
+
+hpfLostPhys:
+			lis		r0,hi16(Choke)				; System abend - we must find the stolen mapping or we are dead
+			ori		r0,r0,lo16(Choke)			; System abend
+			sc
+			
+;
+;			This is the common code we execute when we are finished setting up the PTE.
+;
+	
+			.align	5
+			
+hpfFinish:	sub		r4,r19,r27					; Get offset of PTE
+			ori		r4,r4,lo16(mpHValid)		; Add valid bit to PTE offset
+			bne		cr7,hpfBailOut				; Do not set the PTE pointer for a block map
+			stw		r4,mpPte(r31)				; Remember our PTE
+			
+hpfBailOut:	eieio								; Make sure all updates come first
+			stw		r17,0(r20)					; Unlock and set the final PCA
+			
+;
+;			This is where we go if we have started processing the fault, but find that someone
+;			else has taken care of it.
+;
+
+hpfIgnore:	lwz		r2,mpFlags(r31)				; Get the mapping flags
+			rlwinm	r2,r2,0,mpFIPb+1,mpFIPb-1	; Clear the "fault in progress" flag
+			sth		r2,mpFlags+2(r31)			; Set it
+			
+			la		r3,pmapSXlk(r28)			; Point to the pmap search lock
+			bl		sxlkUnlock					; Unlock the search list
+
+			li		r11,T_IN_VAIN				; Say that it was handled
+			b		EXT(PFSExit)				; Leave...
+
+;
+;			This is where we go when we  find that someone else
+;			is in the process of handling the fault.
+;
+
+hpfAbandon:	li		r3,lgKillResv				; Kill off any reservation
+			stwcx.	r3,0,r3						; Do it
+			
+			la		r3,pmapSXlk(r28)			; Point to the pmap search lock
+			bl		sxlkUnlock					; Unlock the search list
+
+			li		r11,T_IN_VAIN				; Say that it was handled
+			b		EXT(PFSExit)				; Leave...
+			
+
+			
+/*
+ *			hw_set_user_space(pmap) 
+ *			hw_set_user_space_dis(pmap) 
+ *
+ * 			Indicate whether memory space needs to be switched.
  *			We really need to turn off interrupts here, because we need to be non-preemptable
  *
  *			hw_set_user_space_dis is used when interruptions are already disabled. Mind the
@@ -3097,255 +3971,1582 @@ cbNo:		lwz		r11,bmnext(r11)				; Link next
  */
 
 
-	
+	
+			.align	5
+			.globl	EXT(hw_set_user_space)
+
+LEXT(hw_set_user_space)
+
+			lis		r8,hi16(MASK(MSR_VEC))		; Get the vector enable
+			mfmsr	r10							; Get the current MSR 
+			ori		r8,r8,lo16(MASK(MSR_FP))	; Add in FP
+			ori		r9,r8,lo16(MASK(MSR_EE))	; Add in the EE
+			andc	r10,r10,r8					; Turn off VEC, FP for good
+			andc	r9,r10,r9					; Turn off EE also
+			mtmsr	r9							; Disable them 
+ 			isync								; Make sure FP and vec are off
+ 			mfsprg	r6,0						; Get the per_proc_info address
+			lwz		r2,ppUserPmapVirt(r6)		; Get our virtual pmap address
+			mfsprg	r4,2						; The the feature flags
+			lwz		r7,pmapvr(r3)				; Get the v to r translation
+ 			lwz		r8,pmapvr+4(r3)				; Get the v to r translation
+ 			mtcrf	0x80,r4						; Get the Altivec flag
+			xor		r4,r3,r8					; Get bottom of the real address of bmap anchor
+			cmplw	cr1,r3,r2					; Same address space as before?
+			stw		r7,ppUserPmap(r6)			; Show our real pmap address
+			crorc	cr1_eq,cr1_eq,pfAltivecb	; See if same address space or not altivec machine
+			stw		r4,ppUserPmap+4(r6)			; Show our real pmap address
+			stw		r3,ppUserPmapVirt(r6)		; Show our virtual pmap address
+			mtmsr	r10							; Restore interruptions 
+			beqlr--	cr1							; Leave if the same address space or not Altivec
+
+			dssall								; Need to kill all data streams if adrsp changed
+			sync
+			blr									; Return... 
+	
+			.align	5
+			.globl	EXT(hw_set_user_space_dis)
+
+LEXT(hw_set_user_space_dis)
+
+ 			lwz		r7,pmapvr(r3)				; Get the v to r translation
+ 			mfsprg	r4,2						; The the feature flags
+			lwz		r8,pmapvr+4(r3)				; Get the v to r translation
+			mfsprg	r6,0						; Get the per_proc_info address
+			lwz		r2,ppUserPmapVirt(r6)		; Get our virtual pmap address
+ 			mtcrf	0x80,r4						; Get the Altivec flag
+			xor		r4,r3,r8					; Get bottom of the real address of bmap anchor
+			cmplw	cr1,r3,r2					; Same address space as before?
+			stw		r7,ppUserPmap(r6)			; Show our real pmap address
+			crorc	cr1_eq,cr1_eq,pfAltivecb	; See if same address space or not altivec machine
+			stw		r4,ppUserPmap+4(r6)			; Show our real pmap address
+			stw		r3,ppUserPmapVirt(r6)		; Show our virtual pmap address
+			beqlr--	cr1							; Leave if the same
+
+			dssall								; Need to kill all data streams if adrsp changed
+			sync
+			blr									; Return...
+	
+/*			int mapalc1(struct mappingblok *mb) - Finds, allocates, and zeros a free 1-bit mapping entry
+ *
+ *			Lock must already be held on mapping block list
+ *			returns 0 if all slots filled.
+ *			returns n if a slot is found and it is not the last
+ *			returns -n if a slot is found and it is the last
+ *			when n and -n are returned, the corresponding bit is cleared
+ *			the mapping is zeroed out before return
+ *
+ */
+
+			.align	5
+			.globl	EXT(mapalc1)
+
+LEXT(mapalc1)
+			lwz		r4,mbfree(r3)				; Get the 1st mask 
+			lis		r0,0x8000					; Get the mask to clear the first free bit
+			lwz		r5,mbfree+4(r3)				; Get the 2nd mask 
+			mr		r12,r3						; Save the block ptr
+			cntlzw	r3,r4						; Get first 1-bit in 1st word
+			srw.	r9,r0,r3					; Get bit corresponding to first free one
+			cntlzw	r10,r5						; Get first free field in second word
+			andc	r4,r4,r9					; Turn 1-bit off in 1st word
+			bne		mapalc1f					; Found one in 1st word
+			
+			srw.	r9,r0,r10					; Get bit corresponding to first free one in 2nd word
+            li		r3,0						; assume failure return
+			andc	r5,r5,r9					; Turn it off
+			beqlr--								; There are no 1 bits left...
+            addi	r3,r10,32					; set the correct number
+            
+mapalc1f:
+            or.		r0,r4,r5					; any more bits set?
+            stw		r4,mbfree(r12)				; update bitmasks
+            stw		r5,mbfree+4(r12)
+            
+            slwi	r6,r3,6						; get (n * mpBasicSize), ie offset of mapping in block
+            addi	r7,r6,32
+            dcbz	r6,r12						; clear the 64-byte mapping
+            dcbz	r7,r12
+            
+            bnelr++								; return if another bit remains set
+            
+            neg		r3,r3						; indicate we just returned the last bit
+            blr
+
+
+/*			int mapalc2(struct mappingblok *mb) - Finds, allocates, and zero's a free 2-bit mapping entry
+ *
+ *			Lock must already be held on mapping block list
+ *			returns 0 if all slots filled.
+ *			returns n if a slot is found and it is not the last
+ *			returns -n if a slot is found and it is the last
+ *			when n and -n are returned, the corresponding bits are cleared
+ * 			We find runs of 2 consecutive 1 bits by cntlzw(n & (n<<1)).
+ *			the mapping is zero'd out before return
+ */
+
+			.align	5
+			.globl	EXT(mapalc2)
+LEXT(mapalc2)
+			lwz		r4,mbfree(r3)				; Get the first mask 
+			lis		r0,0x8000					; Get the mask to clear the first free bit
+			lwz		r5,mbfree+4(r3)				; Get the second mask 
+			mr		r12,r3						; Save the block ptr
+            slwi	r6,r4,1						; shift first word over
+            and		r6,r4,r6					; lite start of double bit runs in 1st word
+            slwi	r7,r5,1						; shift 2nd word over
+			cntlzw	r3,r6						; Get first free 2-bit run in 1st word
+            and		r7,r5,r7					; lite start of double bit runs in 2nd word
+			srw.	r9,r0,r3					; Get bit corresponding to first run in 1st word
+			cntlzw	r10,r7						; Get first free field in second word
+            srwi	r11,r9,1					; shift over for 2nd bit in 1st word
+			andc	r4,r4,r9					; Turn off 1st bit in 1st word
+            andc	r4,r4,r11					; turn off 2nd bit in 1st word
+			bne		mapalc2a					; Found two consecutive free bits in 1st word
+			
+			srw.	r9,r0,r10					; Get bit corresponding to first free one in second word
+            li		r3,0						; assume failure
+            srwi	r11,r9,1					; get mask for 2nd bit
+			andc	r5,r5,r9					; Turn off 1st bit in 2nd word
+            andc	r5,r5,r11					; turn off 2nd bit in 2nd word
+			beq--	mapalc2c					; There are no runs of 2 bits in 2nd word either
+            addi	r3,r10,32					; set the correct number
+            
+mapalc2a:
+            or.		r0,r4,r5					; any more bits set?
+            stw		r4,mbfree(r12)				; update bitmasks
+            stw		r5,mbfree+4(r12)
+            slwi	r6,r3,6						; get (n * mpBasicSize), ie offset of mapping in block
+            addi	r7,r6,32
+            addi	r8,r6,64
+            addi	r9,r6,96
+            dcbz	r6,r12						; zero out the 128-byte mapping
+            dcbz	r7,r12						; we use the slow 32-byte dcbz even on 64-bit machines
+            dcbz	r8,r12						; because the mapping may not be 128-byte aligned
+            dcbz	r9,r12
+            
+            bnelr++								; return if another bit remains set
+            
+            neg		r3,r3						; indicate we just returned the last bit
+            blr
+            
+mapalc2c:
+            rlwinm	r7,r5,1,31,31				; move bit 0 of 2nd word to bit 31
+            and.	r0,r4,r7					; is the 2-bit field that spans the 2 words free?
+            beqlr								; no, we failed
+            rlwinm	r4,r4,0,0,30				; yes, turn off bit 31 of 1st word
+            rlwinm	r5,r5,0,1,31				; turn off bit 0 of 2nd word
+            li		r3,31						; get index of this field
+            b		mapalc2a
+			
+
+;
+;			This routine initialzes the hash table and PCA.
+;			It is done here because we may need to be 64-bit to do it.
+;
+
+			.align	5
+			.globl	EXT(hw_hash_init)
+
+LEXT(hw_hash_init)
+
+ 			mfsprg	r10,2						; Get feature flags 
+			lis		r12,hi16(EXT(hash_table_size))		; Get hash table size address
+			mtcrf	0x02,r10					; move pf64Bit to cr6
+			lis		r11,hi16(EXT(hash_table_base))		; Get hash table base address
+			lis		r4,0xFF01					; Set all slots free and start steal at end
+			ori		r12,r12,lo16(EXT(hash_table_size))	; Get hash table size address
+			ori		r11,r11,lo16(EXT(hash_table_base))	; Get hash table base address
+
+			lwz		r12,0(r12)					; Get hash table size
+			li		r3,0						; Get start
+			bt++	pf64Bitb,hhiSF				; skip if 64-bit (only they take the hint)
+
+			lwz		r11,4(r11)					; Get hash table base
+			
+hhiNext32:	cmplw	r3,r12						; Have we reached the end?
+			bge-	hhiCPCA32					; Yes...			
+			dcbz	r3,r11						; Clear the line
+			addi	r3,r3,32					; Next one...
+			b		hhiNext32					; Go on...
+
+hhiCPCA32:	rlwinm	r12,r12,28,4,29				; Get number of slots * 4
+			li		r3,-4						; Displacement to first PCA entry
+			neg		r12,r12						; Get negative end of PCA	
+			
+hhiNPCA32:	stwx	r4,r3,r11					; Initialize the PCA entry
+			subi	r3,r3,4						; Next slot
+			cmpw	r3,r12						; Have we finished?
+			bge+	hhiNPCA32					; Not yet...
+			blr									; Leave...
+
+hhiSF:		mfmsr	r9							; Save the MSR
+			li		r8,1						; Get a 1
+			mr		r0,r9						; Get a copy of the MSR
+			ld		r11,0(r11)					; Get hash table base
+			rldimi	r0,r8,63,MSR_SF_BIT			; Set SF bit (bit 0)
+			mtmsrd	r0							; Turn on SF
+			isync
+			
+			
+hhiNext64:	cmpld	r3,r12						; Have we reached the end?
+			bge--	hhiCPCA64					; Yes...			
+			dcbz128	r3,r11						; Clear the line
+			addi	r3,r3,128					; Next one...
+			b		hhiNext64					; Go on...
+
+hhiCPCA64:	rlwinm	r12,r12,27,5,29				; Get number of slots * 4
+			li		r3,-4						; Displacement to first PCA entry
+			neg		r12,r12						; Get negative end of PCA	
+		
+hhiNPCA64:	stwx	r4,r3,r11					; Initialize the PCA entry
+			subi	r3,r3,4						; Next slot
+			cmpd	r3,r12						; Have we finished?
+			bge++	hhiNPCA64					; Not yet...
+
+			mtmsrd	r9							; Turn off SF if it was off
+			isync
+			blr									; Leave...
+			
+			
+;
+;			This routine sets up the hardware to start translation.
+;			Note that we do NOT start translation.
+;
+
+			.align	5
+			.globl	EXT(hw_setup_trans)
+
+LEXT(hw_setup_trans)
+
+ 			mfsprg	r11,0						; Get the per_proc block
+ 			mfsprg	r12,2						; Get feature flags 
+ 			li		r0,0						; Get a 0
+ 			li		r2,1						; And a 1
+			mtcrf	0x02,r12					; Move pf64Bit to cr6
+			stw		r0,validSegs(r11)			; Make sure we think all SR/STEs are invalid
+			stw		r0,validSegs+4(r11)			; Make sure we think all SR/STEs are invalid, part deux
+			sth		r2,ppInvSeg(r11)			; Force a reload of the SRs
+			sth		r0,ppCurSeg(r11)			; Set that we are starting out in kernel
+			
+			bt++	pf64Bitb,hstSF				; skip if 64-bit (only they take the hint)
+
+			li		r9,0						; Clear out a register
+			sync
+			isync
+			mtdbatu 0,r9						; Invalidate maps
+			mtdbatl 0,r9						; Invalidate maps
+			mtdbatu 1,r9						; Invalidate maps
+			mtdbatl 1,r9						; Invalidate maps
+			mtdbatu 2,r9						; Invalidate maps
+			mtdbatl 2,r9						; Invalidate maps
+			mtdbatu 3,r9						; Invalidate maps
+			mtdbatl 3,r9						; Invalidate maps
+
+			mtibatu 0,r9						; Invalidate maps
+			mtibatl 0,r9						; Invalidate maps
+			mtibatu 1,r9						; Invalidate maps
+			mtibatl 1,r9						; Invalidate maps
+			mtibatu 2,r9						; Invalidate maps
+			mtibatl 2,r9						; Invalidate maps
+			mtibatu 3,r9						; Invalidate maps
+			mtibatl 3,r9						; Invalidate maps
+
+			lis		r11,hi16(EXT(hash_table_base))		; Get hash table base address
+			lis		r12,hi16(EXT(hash_table_size))		; Get hash table size address
+			ori		r11,r11,lo16(EXT(hash_table_base))	; Get hash table base address
+			ori		r12,r12,lo16(EXT(hash_table_size))	; Get hash table size address
+			lwz		r11,4(r11)					; Get hash table base
+			lwz		r12,0(r12)					; Get hash table size
+			subi	r12,r12,1					; Back off by 1
+			rlwimi	r11,r12,16,23,31			; Stick the size into the sdr1 image
+			
+			mtsdr1	r11							; Ok, we now have the hash table set up
+			sync
+			
+			li		r12,invalSpace				; Get the invalid segment value
+			li		r10,0						; Start low
+			
+hstsetsr:	mtsrin	r12,r10						; Set the SR
+			addis	r10,r10,0x1000				; Bump the segment
+			mr.		r10,r10						; Are we finished?
+			bne+	hstsetsr					; Nope...	
+			sync
+			blr									; Return...
+
+;
+;			64-bit version
+;
+
+hstSF:		lis		r11,hi16(EXT(hash_table_base))		; Get hash table base address
+			lis		r12,hi16(EXT(hash_table_size))		; Get hash table size address
+			ori		r11,r11,lo16(EXT(hash_table_base))	; Get hash table base address
+			ori		r12,r12,lo16(EXT(hash_table_size))	; Get hash table size address
+			ld		r11,0(r11)					; Get hash table base
+			lwz		r12,0(r12)					; Get hash table size
+			cntlzw	r10,r12						; Get the number of bits
+			subfic	r10,r10,13					; Get the extra bits we need
+			or		r11,r11,r10					; Add the size field to SDR1
+			
+			mtsdr1	r11							; Ok, we now have the hash table set up
+			sync
+
+			li		r0,0						; Set an SLB slot index of 0
+			slbia								; Trash all SLB entries (except for entry 0 that is)
+			slbmfee	r7,r0						; Get the entry that is in SLB index 0
+			rldicr	r7,r7,0,35					; Clear the valid bit and the rest
+			slbie	r7							; Invalidate it
+
+			blr									; Return...
+
+
+;
+;			This routine turns on translation for the first time on a processor
+;
+
+			.align	5
+			.globl	EXT(hw_start_trans)
+
+LEXT(hw_start_trans)
+
+			
+			mfmsr	r10							; Get the msr
+			ori		r10,r10,lo16(MASK(MSR_IR) | MASK(MSR_DR))	; Turn on translation
+
+			mtmsr	r10							; Everything falls apart here
+			isync
+			
+			blr									; Back to it.
+
+
+
+;
+;			This routine validates a segment register.
+;				hw_map_seg(pmap_t pmap, addr64_t seg, addr64_t va)
+;
+;				r3 = virtual pmap
+;				r4 = segment[0:31]
+;				r5 = segment[32:63]
+;				r6 = va[0:31]
+;				r7 = va[32:63]
+;
+;			Note that we transform the addr64_t (long long) parameters into single 64-bit values.
+;			Note that there is no reason to apply the key modifier here because this is only
+;			used for kernel accesses.
+;
+
+			.align	5
+			.globl	EXT(hw_map_seg)
+
+LEXT(hw_map_seg)
+
+			lwz		r0,pmapSpace(r3)			; Get the space, we will need it soon
+			lwz		r9,pmapFlags(r3)			; Get the flags for the keys now
+ 			mfsprg	r10,2						; Get feature flags 
+			mfsprg	r12,0						; Get the per_proc
+
+;
+;			Note: the following code would problably be easier to follow if I split it,
+;			but I just wanted to see if I could write this to work on both 32- and 64-bit
+;			machines combined.
+;
+			
+;
+;			Here we enter with va[0:31] in r6[0:31] (or r6[32:63] on 64-bit machines)
+;			and va[32:63] in r7[0:31] (or r7[32:63] on 64-bit machines)
+
+			rlwinm	r4,r4,0,1,0					; Copy seg[0:31] into r4[0;31] - no-op for 32-bit
+			rlwinm	r7,r7,18,14,17				; Slide va[32:35] east to just west of space ID
+			mtcrf	0x02,r10					; Move pf64Bit and pfNoMSRirb to cr5 and 6
+			srwi	r8,r6,14					; Slide va[0:17] east to just west of the rest
+			rlwimi	r7,r6,18,0,13				; Slide va[18:31] east to just west of slid va[32:25]
+			rlwimi	r0,r0,14,4,17				; Dup address space ID above itself
+			rlwinm	r8,r8,0,1,0					; Dup low part into high (does nothing on 32-bit machines)
+			rlwinm	r2,r0,28,0,31				; Rotate rotate low nybble to top of low half
+			rlwimi	r2,r2,0,1,0					; Replicate bottom 32 into top 32
+			rlwimi	r8,r7,0,0,31				; Join va[0:17] with va[18:35] (just like mr on 32-bit machines)			
+
+			rlwimi	r2,r0,0,4,31				; We should now have 4 copies of the space
+												; concatenated together.   There is garbage
+												; at the top for 64-bit but we will clean
+												; that out later.
+			rlwimi	r4,r5,0,0,31				; Copy seg[32:63] into r4[32:63] - just like mr for 32-bit
+
+			
+;
+;			Here we exit with va[0:35] shifted into r8[14:51], zeros elsewhere, or
+;			va[18:35] shifted into r8[0:17], zeros elsewhere on 32-bit machines
+;			
+												
+;
+;			What we have now is:
+;
+;					 0        0        1        2        3        4        4        5      6
+;					 0        8        6        4        2        0        8        6      3	- for 64-bit machines
+;					+--------+--------+--------+--------+--------+--------+--------+--------+
+;			r2 =	|xxxx0000|AAAAAAAA|AAAAAABB|BBBBBBBB|BBBBCCCC|CCCCCCCC|CCDDDDDD|DDDDDDDD|	- hash value
+;					+--------+--------+--------+--------+--------+--------+--------+--------+
+;														 0        0        1        2      3	- for 32-bit machines
+;														 0        8        6        4      1
+;
+;					 0        0        1        2        3        4        4        5      6
+;					 0        8        6        4        2        0        8        6      3	- for 64-bit machines
+;					+--------+--------+--------+--------+--------+--------+--------+--------+
+;			r8 =	|00000000|000000SS|SSSSSSSS|SSSSSSSS|SSSSSSSS|SSSSSSSS|SS000000|00000000|	- shifted and cleaned EA
+;					+--------+--------+--------+--------+--------+--------+--------+--------+
+;														 0        0        1        2      3	- for 32-bit machines
+;														 0        8        6        4      1
+;
+;					 0        0        1        2        3        4        4        5      6
+;					 0        8        6        4        2        0        8        6      3	- for 64-bit machines
+;					+--------+--------+--------+--------+--------+--------+--------+--------+
+;			r4 =	|SSSSSSSS|SSSSSSSS|SSSSSSSS|SSSSSSSS|SSSS0000|00000000|00000000|00000000|	- Segment
+;					+--------+--------+--------+--------+--------+--------+--------+--------+
+;														 0        0        1        2      3	- for 32-bit machines
+;														 0        8        6        4      1
+
+
+			xor		r8,r8,r2					; Calculate VSID
+			
+			bf--	pf64Bitb,hms32bit			; Skip out if 32-bit...
+			
+			li		r0,1						; Prepare to set bit 0 (also to clear EE)
+			mfmsr	r6							; Get current MSR
+			li		r2,MASK(MSR_IR)|MASK(MSR_DR)	; Get the translation bits
+			mtmsrd	r0,1						; Set only the EE bit to 0
+			rlwinm	r6,r6,0,MSR_EE_BIT,MSR_EE_BIT	; See if EE bit is on
+			mfmsr	r11							; Get the MSR right now, after disabling EE
+			andc	r2,r11,r2					; Turn off translation now
+			rldimi	r2,r0,63,0					; Get bit 64-bit turned on
+			or		r11,r11,r6					; Turn on the EE bit if it was on
+			mtmsrd	r2							; Make sure translation and EE are off and 64-bit is on
+			isync								; Hang out a bit
+						
+			ld		r6,validSegs(r12)			; Get the valid SLB entry flags
+			sldi	r9,r9,9						; Position the key and noex bit
+			
+			rldimi	r5,r8,12,0					; Form the VSID/key
+			
+			not		r3,r6						; Make valids be 0s
+			
+			cntlzd	r7,r3						; Find a free SLB	
+			cmplwi	r7,63						; Did we find a free SLB entry?		
+			
+			slbie	r4							; Since this ESID may still be in an SLBE, kill it
+
+			oris	r4,r4,0x0800				; Turn on the valid bit in ESID
+			addi	r7,r7,1						; Make sure we skip slb 0
+			blt++	hmsFreeSeg					; Yes, go load it...
+
+;
+;			No free SLB entries, select one that is in use and invalidate it
+;
+			lwz		r2,ppSegSteal(r12)			; Get the next slot to steal
+			addi	r7,r2,pmapSegCacheUse+1		; Select stealee from non-cached slots only
+			addi	r2,r2,1						; Set next slot to steal
+			slbmfee	r3,r7						; Get the entry that is in the selected spot
+			subi	r8,r2,64-(pmapSegCacheUse+1)	; Force steal to wrap
+			rldicr	r3,r3,0,35					; Clear the valid bit and the rest
+			srawi	r8,r8,31					; Get -1 if steal index still in range
+			slbie	r3							; Invalidate the in-use SLB entry
+			and		r2,r2,r8					; Reset steal index when it should wrap
+			isync								; 
+			
+			stw		r2,ppSegSteal(r12)			; Set the next slot to steal
+;
+;			We are now ready to stick the SLB entry in the SLB and mark it in use
+;
+
+hmsFreeSeg:	subi	r2,r7,1						; Adjust for skipped slb 0
+			rldimi	r4,r7,0,58					; Copy in the SLB entry selector
+			srd		r0,r0,r2					; Set bit mask for allocation
+			rldicl	r5,r5,0,15					; Clean out the unsupported bits
+			or		r6,r6,r0					; Turn on the allocation flag
+			
+			slbmte	r5,r4						; Make that SLB entry
+
+			std		r6,validSegs(r12)			; Mark as valid
+			mtmsrd	r11							; Restore the MSR
+			isync
+			blr									; Back to it...
+
+			.align	5
+
+hms32bit:	rlwinm	r8,r8,0,8,31				; Clean up the VSID
+			rlwinm	r2,r4,4,28,31				; Isolate the segment we are setting
+			lis		r0,0x8000					; Set bit 0
+			rlwimi	r8,r9,28,1,3				; Insert the keys and N bit			
+			srw		r0,r0,r2					; Get bit corresponding to SR
+			addi	r7,r12,validSegs			; Point to the valid segment flags directly
+		
+			mtsrin	r8,r4						; Set the actual SR	
+			isync								; Need to make sure this is done
+		
+hmsrupt:	lwarx	r6,0,r7						; Get and reserve the valid segment flags
+			or		r6,r6,r0					; Show that SR is valid
+			stwcx.	r6,0,r7						; Set the valid SR flags
+			bne--	hmsrupt						; Had an interrupt, need to get flags again...
+
+			blr									; Back to it...
+
+
+;
+;			This routine invalidates a segment register.
+;
+
+			.align	5
+			.globl	EXT(hw_blow_seg)
+
+LEXT(hw_blow_seg)
+
+ 			mfsprg	r10,2						; Get feature flags 
+			mfsprg	r12,0						; Get the per_proc
+			mtcrf	0x02,r10					; move pf64Bit and pfNoMSRirb to cr5 and 6
+		
+			addi	r7,r12,validSegs			; Point to the valid segment flags directly
+			rlwinm	r9,r4,0,0,3					; Save low segment address and make sure it is clean
+			
+			bf--	pf64Bitb,hbs32bit			; Skip out if 32-bit...
+			
+			li		r0,1						; Prepare to set bit 0 (also to clear EE)
+			mfmsr	r6							; Get current MSR
+			li		r2,MASK(MSR_IR)|MASK(MSR_DR)	; Get the translation bits
+			mtmsrd	r0,1						; Set only the EE bit to 0
+			rlwinm	r6,r6,0,MSR_EE_BIT,MSR_EE_BIT	; See if EE bit is on
+			mfmsr	r11							; Get the MSR right now, after disabling EE
+			andc	r2,r11,r2					; Turn off translation now
+			rldimi	r2,r0,63,0					; Get bit 64-bit turned on
+			or		r11,r11,r6					; Turn on the EE bit if it was on
+			mtmsrd	r2							; Make sure translation and EE are off and 64-bit is on
+			isync								; Hang out a bit
+
+			rldimi	r9,r3,32,0					; Insert the top part of the ESID
+			
+			slbie	r9							; Invalidate the associated SLB entry
+			
+			mtmsrd	r11							; Restore the MSR
+			isync
+			blr									; Back to it.
+
+			.align	5
+
+hbs32bit:	lwarx	r4,0,r7						; Get and reserve the valid segment flags
+			rlwinm	r6,r9,4,28,31				; Convert segment to number
+			lis		r2,0x8000					; Set up a mask
+			srw		r2,r2,r6					; Make a mask
+			and.	r0,r4,r2					; See if this is even valid
+			li		r5,invalSpace				; Set the invalid address space VSID
+			beqlr								; Leave if already invalid...
+			
+			mtsrin	r5,r9						; Slam the segment register
+			isync								; Need to make sure this is done
+		
+hbsrupt:	andc	r4,r4,r2					; Clear the valid bit for this segment
+			stwcx.	r4,0,r7						; Set the valid SR flags
+			beqlr++								; Stored ok, no interrupt, time to leave...
+			
+			lwarx	r4,0,r7						; Get and reserve the valid segment flags again
+			b		hbsrupt						; Try again...
+
+;
+;			This routine invadates the entire pmap segment cache
+;
+;			Translation is on, interrupts may or may not be enabled.
+;
+
+			.align	5
+			.globl	EXT(invalidateSegs)
+
+LEXT(invalidateSegs)
+
+			la		r10,pmapCCtl(r3)			; Point to the segment cache control
+			eqv		r0,r0,r0					; Get all foxes
+			
+isInv:		lwarx	r4,0,r10					; Get the segment cache control value
+			rlwimi	r4,r0,0,0,15				; Slam in all invalid bits
+			rlwinm.	r0,r4,0,pmapCCtlLckb,pmapCCtlLckb	; Is it already locked?
+			bne--	isInv0						; Yes, try again...
+			
+			stwcx.	r4,0,r10					; Try to invalidate it
+			bne--	isInv						; Someone else just stuffed it...
+			blr									; Leave...
+			
+
+isInv0:		li		r4,lgKillResv				; Get reservation kill zone
+			stwcx.	r4,0,r4						; Kill reservation
+
+isInv1:		lwz		r4,pmapCCtl(r3)				; Get the segment cache control
+			rlwinm.	r0,r4,0,pmapCCtlLckb,pmapCCtlLckb	; Is it already locked?
+			bne--	isInv						; Nope...
+			b		isInv1						; Still locked do it again...
+			
+;
+;			This routine switches segment registers between kernel and user.
+;			We have some assumptions and rules:
+;				We are in the exception vectors
+;				pf64Bitb is set up
+;				R3 contains the MSR we going to
+;				We can not use R4, R13, R20, R21, R29
+;				R13 is the savearea
+;				R29 has the per_proc
+;
+;			We return R3 as 0 if we did not switch between kernel and user
+;			We also maintain and apply the user state key modifier used by VMM support;	
+;			If we go to the kernel it is set to 0, otherwise it follows the bit 
+;			in spcFlags.
+;
+
 			.align	5
-			.globl	EXT(hw_set_user_space)
+			.globl	EXT(switchSegs)
 
-LEXT(hw_set_user_space)
+LEXT(switchSegs)
+
+			lwz		r22,ppInvSeg(r29)			; Get the ppInvSeg (force invalidate) and ppCurSeg (user or kernel segments indicator)
+			lwz		r9,spcFlags(r29)			; Pick up the special user state flags
+			rlwinm	r2,r3,MSR_PR_BIT+1,31,31	; Isolate the problem mode bit
+			rlwinm	r3,r3,MSR_RI_BIT+1,31,31	; Isolate the recoverable interrupt bit
+			lis		r8,hi16(EXT(kernel_pmap_phys))	; Assume kernel
+			or		r2,r2,r3					; This will 1 if we will be using user segments
+			li		r3,0						; Get a selection mask
+			cmplw	r2,r22						; This will be EQ if same state and not ppInvSeg
+			ori		r8,r8,lo16(EXT(kernel_pmap_phys))	; Assume kernel (bottom of address)
+			sub		r3,r3,r2					; Form select mask - 0 if kernel, -1 if user
+			la		r19,ppUserPmap(r29)			; Point to the current user pmap
+
+;			The following line is an exercise of a generally unreadable but recompile-friendly programing practice
+			rlwinm	r30,r9,userProtKeybit+1+(63-sgcVSKeyUsr),sgcVSKeyUsr-32,sgcVSKeyUsr-32	; Isolate the user state protection key 
+
+			andc	r8,r8,r3					; Zero kernel pmap ptr if user, untouched otherwise
+			and		r19,r19,r3					; Zero user pmap ptr if kernel, untouched otherwise
+			and		r30,r30,r3					; Clear key modifier if kernel, leave otherwise
+			or		r8,r8,r19					; Get the pointer to the pmap we are using
+
+			beqlr								; We are staying in the same mode, do not touch segs...
+
+			lwz		r28,0(r8)					; Get top half of pmap address
+			lwz		r10,4(r8)					; Get bottom half
+
+			stw		r2,ppInvSeg(r29)			; Clear request for invalidate and save ppCurSeg
+			rlwinm	r28,r28,0,1,0				; Copy top to top
+			stw		r30,ppMapFlags(r29)			; Set the key modifier
+			rlwimi	r28,r10,0,0,31				; Insert bottom
+			
+			la		r10,pmapCCtl(r28)			; Point to the segment cache control
+			la		r9,pmapSegCache(r28)		; Point to the segment cache
+
+ssgLock:	lwarx	r15,0,r10					; Get and reserve the segment cache control
+			rlwinm.	r0,r15,0,pmapCCtlLckb,pmapCCtlLckb	; Someone have the lock?
+			ori		r16,r15,lo16(pmapCCtlLck)	; Set lock bit
+			bne--	ssgLock0					; Yup, this is in use...
+
+			stwcx.	r16,0,r10					; Try to set the lock
+			bne--	ssgLock						; Did we get contention?
+			
+			not		r11,r15						; Invert the invalids to valids
+			li		r17,0						; Set a mask for the SRs we are loading
+			isync								; Make sure we are all caught up
+
+			bf--	pf64Bitb,ssg32Enter			; If 32-bit, jump into it...
+		
+			li		r0,0						; Clear
+			slbia								; Trash all SLB entries (except for entry 0 that is)
+			li		r17,1						; Get SLB index to load (skip slb 0)
+			oris	r0,r0,0x8000				; Get set for a mask
+			b		ssg64Enter					; Start on a cache line...
 
-			mfmsr	r10							/* Get the current MSR */
-			rlwinm	r10,r10,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-			rlwinm	r10,r10,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-			rlwinm	r9,r10,0,MSR_EE_BIT+1,MSR_EE_BIT-1	/* Turn off 'rupts */
-			mtmsr	r9							/* Disable 'em */
- 			lwz		r7,PMAP_PMAPVR(r3)			; Get the v to r translation
-			lwz		r4,PMAP_SPACE(r3)			; Get the space
-			mfsprg	r6,0						/* Get the per_proc_info address */
-			xor		r3,r3,r7					; Get real address of bmap anchor
-			stw		r4,PP_USERSPACE(r6)			/* Show our new address space */
-			stw		r3,PP_USERPMAP(r6)			; Show our real pmap address
-			mtmsr	r10							/* Restore interruptions */
-			blr									/* Return... */
-	
 			.align	5
-			.globl	EXT(hw_set_user_space_dis)
 
-LEXT(hw_set_user_space_dis)
+ssgLock0:	li		r15,lgKillResv				; Killing field
+			stwcx.	r15,0,r15					; Kill reservation
 
- 			lwz		r7,PMAP_PMAPVR(r3)			; Get the v to r translation
-			lwz		r4,PMAP_SPACE(r3)			; Get the space
-			mfsprg	r6,0						; Get the per_proc_info address
-			xor		r3,r3,r7					; Get real address of bmap anchor
-			stw		r4,PP_USERSPACE(r6)			; Show our new address space
-			stw		r3,PP_USERPMAP(r6)			; Show our real pmap address
-			blr									; Return...
-	
+ssgLock1:	lwz		r15,pmapCCtl(r28)			; Get the segment cache controls
+			rlwinm.	r15,r15,0,pmapCCtlLckb,pmapCCtlLckb	; Someone have the lock?
+			beq++	ssgLock						; Yup, this is in use...
+			b		ssgLock1					; Nope, try again...
+;
+;			This is the 32-bit address space switch code.
+;			We take a reservation on the segment cache and walk through.
+;			For each entry, we load the specified entries and remember which
+;			we did with a mask.  Then, we figure out which segments should be
+;			invalid and then see which actually are.  Then we load those with the
+;			defined invalid VSID. 
+;			Afterwards, we unlock the segment cache.
+;
 
-/*			struct mapping *hw_cpv(struct mapping *mp) - Converts a physcial mapping CB address to virtual
- *
- */
+			.align	5
+
+ssg32Enter:	cntlzw	r12,r11						; Find the next slot in use
+			cmplwi	r12,pmapSegCacheUse			; See if we are done
+			slwi	r14,r12,4					; Index to the cache slot
+			lis		r0,0x8000					; Get set for a mask
+			add		r14,r14,r9					; Point to the entry
+		
+			bge-	ssg32Done					; All done...
+		
+			lwz		r5,sgcESID+4(r14)			; Get the ESID part
+			srw		r2,r0,r12					; Form a mask for the one we are loading
+			lwz		r7,sgcVSID+4(r14)			; And get the VSID bottom
+
+			andc	r11,r11,r2					; Clear the bit
+			lwz		r6,sgcVSID(r14)				; And get the VSID top
+
+			rlwinm	r2,r5,4,28,31				; Change the segment number to a number
+
+			xor		r7,r7,r30					; Modify the key before we actually set it
+			srw		r0,r0,r2					; Get a mask for the SR we are loading
+			rlwinm	r8,r7,19,1,3				; Insert the keys and N bit			
+			or		r17,r17,r0					; Remember the segment
+			rlwimi	r8,r7,20,12,31				; Insert 4:23 the VSID
+			rlwimi	r8,r6,20,8,11				; Get the last nybble of the SR contents			
+
+			mtsrin	r8,r5						; Load the segment
+			b		ssg32Enter					; Go enter the next...
+			
+			.align	5
+			
+ssg32Done:	lwz		r16,validSegs(r29)			; Get the valid SRs flags
+			stw		r15,pmapCCtl(r28)			; Unlock the segment cache controls
+
+			lis		r0,0x8000					; Get set for a mask
+			li		r2,invalSpace				; Set the invalid address space VSID
+
+			nop									; Align loop
+			nop									; Align loop
+			andc	r16,r16,r17					; Get list of SRs that were valid before but not now
+			nop									; Align loop
+
+ssg32Inval:	cntlzw	r18,r16						; Get the first one to invalidate
+			cmplwi	r18,16						; Have we finished?
+			srw		r22,r0,r18					; Get the mask bit
+			rlwinm	r23,r18,28,0,3				; Get the segment register we need
+			andc	r16,r16,r22					; Get rid of the guy we just did
+			bge		ssg32Really					; Yes, we are really done now...
+
+			mtsrin	r2,r23						; Invalidate the SR
+			b		ssg32Inval					; Do the next...
+			
+			.align	5
+
+ssg32Really:
+			stw		r17,validSegs(r29)			; Set the valid SR flags
+			li		r3,1						; Set kernel/user transition
+			blr
+
+;
+;			This is the 64-bit address space switch code.
+;			First we blow away all of the SLB entries.
+;			Walk through,
+;			loading the SLB.  Afterwards, we release the cache lock
+;
+;			Note that because we have to treat SLBE 0 specially, we do not ever use it...
+;			Its a performance thing...
+;
 
 			.align	5
-			.globl	EXT(hw_cpv)
 
-LEXT(hw_cpv)
+ssg64Enter:	cntlzw	r12,r11						; Find the next slot in use
+			cmplwi	r12,pmapSegCacheUse			; See if we are done
+			slwi	r14,r12,4					; Index to the cache slot
+			srw		r16,r0,r12					; Form a mask for the one we are loading
+			add		r14,r14,r9					; Point to the entry
+			andc	r11,r11,r16					; Clear the bit
+			bge--	ssg64Done					; All done...
+
+			ld		r5,sgcESID(r14)				; Get the ESID part
+			ld		r6,sgcVSID(r14)				; And get the VSID part
+			oris	r5,r5,0x0800				; Turn on the valid bit
+			or		r5,r5,r17					; Insert the SLB slot
+			xor		r6,r6,r30					; Modify the key before we actually set it
+			addi	r17,r17,1					; Bump to the next slot
+			slbmte	r6,r5						; Make that SLB entry
+			b		ssg64Enter					; Go enter the next...
 			
-			rlwinm.	r4,r3,0,0,19				; Round back to the mapping block allocation control block
-			mfmsr	r10							; Get the current MSR
-			beq-	hcpvret						; Skip if we are passed a 0...
-			rlwinm	r10,r10,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-			rlwinm	r10,r10,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-			andi.	r9,r10,0x7FEF				; Turn off interrupts and data translation
-			mtmsr	r9							; Disable DR and EE
-			isync
+			.align	5
 			
-			lwz		r4,mbvrswap(r4)				; Get the conversion value
-			mtmsr	r10							; Interrupts and DR back on
-			isync
-			xor		r3,r3,r4					; Convert to physical
+ssg64Done:	stw		r15,pmapCCtl(r28)			; Unlock the segment cache controls
 
-hcpvret:	rlwinm	r3,r3,0,0,26				; Clean out any flags
+			eqv		r16,r16,r16					; Load up with all foxes
+			subfic	r17,r17,64					; Get the number of 1 bits we need
+
+			sld		r16,r16,r17					; Get a mask for the used SLB entries
+			li		r3,1						; Set kernel/user transition
+			std		r16,validSegs(r29)			; Set the valid SR flags
 			blr
 
+;
+;			mapSetUp - this function sets initial state for all mapping functions.
+;			We turn off all translations (physical), disable interruptions, and 
+;			enter 64-bit mode if applicable.
+;
+;			We also return the original MSR in r11, the feature flags in R12,
+;			and CR6 set up so we can do easy branches for 64-bit
+;
+
+			.align	5
+			.globl	EXT(mapSetUp)
+
+LEXT(mapSetUp)
+
+			lis		r0,hi16(MASK(MSR_VEC))		; Get the vector mask
+ 			mfsprg	r12,2						; Get feature flags 
+ 			ori		r0,r0,lo16(MASK(MSR_FP))	; Get the FP as well
+			mtcrf	0x04,r12					; move pf64Bit and pfNoMSRirb to cr5 and 6
+			mfmsr	r11							; Save the MSR 
+			mtcrf	0x02,r12					; move pf64Bit and pfNoMSRirb to cr5 and 6
+			andc	r11,r11,r0					; Clear VEC and FP for good
+			ori		r0,r0,lo16(MASK(MSR_EE)|MASK(MSR_DR)|MASK(MSR_IR))	; Get rid of EE, IR, and DR
+			li		r2,1						; Prepare for 64 bit
+			andc	r0,r11,r0					; Clear the rest
+			bt		pfNoMSRirb,msuNoMSR			; No MSR...
+			bt++	pf64Bitb,msuSF				; skip if 64-bit (only they take the hint)
 
-/*			struct mapping *hw_cvp(struct mapping *mp) - Converts a virtual mapping CB address to physcial
- *
- *			Translation must be on for this
- *
- */
+			mtmsr	r0							; Translation and all off
+			isync								; Toss prefetch
+			blr									; Return...
+
+			.align	5
+
+msuSF:		rldimi	r0,r2,63,MSR_SF_BIT			; set SF bit (bit 0)
+			mtmsrd	r0							; set 64-bit mode, turn off EE, DR, and IR
+			isync								; synchronize
+			blr									; Return...
+
+			.align	5
+
+msuNoMSR:	mr		r2,r3						; Save R3 across call
+			mr		r3,r0						; Get the new MSR value
+			li		r0,loadMSR					; Get the MSR setter SC
+			sc									; Set it
+			mr		r3,r2						; Restore R3
+			blr									; Go back all set up...
+			
+
+;
+;			Find the physent based on a physical page and try to lock it (but not too hard) 
+;			Note that this table always has an entry that with a 0 table pointer at the end 
+;			
+;			R3 contains ppnum on entry
+;			R3 is 0 if no entry was found
+;			R3 is physent if found
+;			cr0_eq is true if lock was obtained or there was no entry to lock
+;			cr0_eq is false of there was an entry and it was locked
+;	
+
+			.align	5
+			
+mapFindPhyTry:	
+			lis		r9,hi16(EXT(pmap_mem_regions))		; Point to the start of the region table
+			mr		r2,r3						; Save our target
+			ori		r9,r9,lo16(EXT(pmap_mem_regions))	; Point to the start of the region table			
+
+mapFindPhz:	lwz		r3,mrPhysTab(r9)			; Get the actual table address
+			lwz		r5,mrStart(r9)				; Get start of table entry
+			lwz		r0,mrEnd(r9)				; Get end of table entry
+			addi	r9,r9,mrSize				; Point to the next slot
+			cmplwi	cr2,r3,0					; Are we at the end of the table?
+			cmplw	r2,r5						; See if we are in this table
+			cmplw	cr1,r2,r0					; Check end also
+			sub		r4,r2,r5					; Calculate index to physical entry
+			beq--	cr2,mapFindNo				; Leave if we did not find an entry...
+			cror	cr0_lt,cr0_lt,cr1_gt		; Set CR0_LT if it is NOT this entry
+			slwi	r4,r4,3						; Get offset to physical entry
+
+			blt--	mapFindPhz					; Did not find it...
+			
+			add		r3,r3,r4					; Point right to the slot
+	
+mapFindOv:	lwz		r2,0(r3)					; Get the lock contents right now
+			rlwinm.	r0,r2,0,0,0					; Is it locked?
+			bnelr--								; Yes it is...
+			
+			lwarx	r2,0,r3						; Get the lock
+			rlwinm.	r0,r2,0,0,0					; Is it locked?
+			oris	r0,r2,0x8000				; Set the lock bit
+			bne--	mapFindKl					; It is locked, go get rid of reservation and leave...
+			stwcx.	r0,0,r3						; Try to stuff it back...
+			bne--	mapFindOv					; Collision, try again...
+			isync								; Clear any speculations
+			blr									; Leave...
+
+mapFindKl:	li		r2,lgKillResv				; Killing field
+			stwcx.	r2,0,r2						; Trash reservation...
+			crclr	cr0_eq						; Make sure we do not think we got the lock
+			blr									; Leave...
+
+mapFindNo:	crset	cr0_eq						; Make sure that we set this
+			li		r3,0						; Show that we did not find it
+			blr									; Leave...			
+;
+;			pmapCacheLookup - This function will look up an entry in the pmap segment cache.
+;
+;			How the pmap cache lookup works:
+;
+;			We use a combination of three things: a mask of valid entries, a sub-tag, and the
+;			ESID (aka the "tag").  The mask indicates which of the cache slots actually contain
+;			an entry.  The sub-tag is a 16 entry 4 bit array that contains the low order 4 bits
+;			of the ESID, bits 32:36 of the effective for 64-bit and 0:3 for 32-bit.  The cache
+;			entry contains the full 36 bit ESID.
+;
+;			The purpose of the sub-tag is to limit the number of searches necessary when looking
+;			for an existing cache entry.  Because there are 16 slots in the cache, we could end up
+;			searching all 16 if an match is not found.  
+;
+;			Essentially, we will search only the slots that have a valid entry and whose sub-tag
+;			matches. More than likely, we will eliminate almost all of the searches.
+;		
+;			Inputs:
+;				R3 = pmap
+;				R4 = ESID high half
+;				R5 = ESID low half
+;
+;			Outputs:
+;				R3 = pmap cache slot if found, 0 if not
+;				R10 = pmapCCtl address
+;				R11 = pmapCCtl image
+;				pmapCCtl locked on exit
+;
+
+			.align	5
+
+pmapCacheLookup:		
+			la		r10,pmapCCtl(r3)			; Point to the segment cache control
+
+pmapCacheLookuq:		
+			lwarx	r11,0,r10					; Get the segment cache control value
+			rlwinm.	r0,r11,0,pmapCCtlLckb,pmapCCtlLckb	; Is it already locked?
+			ori		r0,r11,lo16(pmapCCtlLck)	; Turn on the lock bit
+			bne--	pmapCacheLookur				; Nope...
+			stwcx.	r0,0,r10					; Try to take the lock
+			bne--	pmapCacheLookuq				; Someone else just stuffed it, try again...
+
+			isync								; Make sure we get reservation first
+			lwz		r9,pmapSCSubTag(r3)			; Get the high part of the sub-tag
+			rlwimi	r5,r5,28,4,7				; Copy sub-tag just to right of itself (XX------)
+			lwz		r10,pmapSCSubTag+4(r3)		; And the bottom half
+			rlwimi	r5,r5,24,8,15				; Copy doubled sub-tag to right of itself (XXXX----)
+			lis		r8,0x8888					; Get some eights
+			rlwimi	r5,r5,16,16,31				; Copy quadrupled sub-tags to the right
+			ori		r8,r8,0x8888				; Fill the rest with eights
+
+			eqv		r10,r10,r5					; Get 0xF where we hit in bottom half
+			eqv		r9,r9,r5					; Get 0xF where we hit in top half
+			
+			rlwinm	r2,r10,1,0,30				; Shift over 1
+			rlwinm	r0,r9,1,0,30				; Shift over 1
+			and		r2,r2,r10					; AND the even/odd pair into the even
+			and		r0,r0,r9					; AND the even/odd pair into the even
+			rlwinm	r10,r2,2,0,28				; Shift over 2
+			rlwinm	r9,r0,2,0,28				; Shift over 2
+			and		r10,r2,r10					; AND the even of the ANDed pairs giving the AND of all 4 bits in 0, 4, ...
+			and		r9,r0,r9					; AND the even of the ANDed pairs giving the AND of all 4 bits in 0, 4, ...
+			
+			and		r10,r10,r8					; Clear out extras
+			and		r9,r9,r8					; Clear out extras
+			
+			rlwinm	r0,r10,3,1,28				; Slide adjacent next to each other
+			rlwinm	r2,r9,3,1,28				; Slide adjacent next to each other
+			or		r10,r0,r10					; Merge them
+			or		r9,r2,r9					; Merge them
+			rlwinm	r0,r10,6,2,26				; Slide adjacent pairs next to each other
+			rlwinm	r2,r9,6,2,26				; Slide adjacent pairs next to each other
+			or		r10,r0,r10					; Merge them
+			or		r9,r2,r9					; Merge them
+			rlwimi	r10,r10,12,4,7				; Stick in the low-order adjacent quad
+			rlwimi	r9,r9,12,4,7				; Stick in the low-order adjacent quad
+			not		r6,r11						; Turn invalid into valid
+			rlwimi	r9,r10,24,8,15				; Merge in the adjacent octs giving a hit mask
+			
+			la		r10,pmapSegCache(r3)		; Point at the cache slots
+			and.	r6,r9,r6					; Get mask of valid and hit
+			li		r0,0						; Clear
+			li		r3,0						; Assume not found
+			oris	r0,r0,0x8000				; Start a mask
+			beqlr++								; Leave, should usually be no hits...
+			
+pclNextEnt:	cntlzw	r5,r6						; Find an in use one
+			cmplwi	cr1,r5,pmapSegCacheUse		; Did we find one?
+			rlwinm	r7,r5,4,0,27				; Index to the cache entry
+			srw		r2,r0,r5					; Get validity mask bit
+			add		r7,r7,r10					; Point to the cache slot
+			andc	r6,r6,r2					; Clear the validity bit we just tried
+			bgelr--	cr1							; Leave if there are no more to check...
+			
+			lwz		r5,sgcESID(r7)				; Get the top half
+			
+			cmplw	r5,r4						; Only need to check top because sub-tag is the entire other half
+			
+			bne++	pclNextEnt					; Nope, try again...
+
+			mr		r3,r7						; Point to the slot
+			blr									; Leave....
 
 			.align	5
-			.globl	EXT(hw_cvp)
 
-LEXT(hw_cvp)
+pmapCacheLookur:
+			li		r11,lgKillResv				; The killing spot
+			stwcx.	r11,0,r11					; Kill the reservation
 			
-			rlwinm	r4,r3,0,0,19				; Round back to the mapping block allocation control block			
-			rlwinm	r3,r3,0,0,26				; Clean out any flags
-			lwz		r4,mbvrswap(r4)				; Get the conversion value
-			xor		r3,r3,r4					; Convert to virtual
+pmapCacheLookus:		
+			lwz		r11,pmapCCtl(r3)			; Get the segment cache control
+			rlwinm.	r0,r11,0,pmapCCtlLckb,pmapCCtlLckb	; Is it already locked?
+			beq++	pmapCacheLookup				; Nope...
+			b		pmapCacheLookus				; Yup, keep waiting...
+
+			
+
+
+;
+;			This routine, given a mapping, will find and lock the PTEG
+;			If mpPte does not point to a PTE (checked before and after lock), it will unlock the
+;			PTEG and return.  In this case we will have undefined in R4
+;			and the low 12 bits of mpVAddr valid in R5.  R3 will contain 0.
+;
+;			If the mapping is still valid, we will invalidate the PTE and merge
+;			the RC bits into the physent and also save them into the mapping.
+;
+;			We then return with R3 pointing to the PTE slot, R4 is the
+;			top of the PTE and R5 is the bottom.  R6 contains the PCA.
+;			R7 points to the PCA entry.
+;
+;			Note that we should NEVER be called on a block or special mapping.
+;			We could do many bad things.
+;
+
+			.align	5
+
+mapInvPte32:
+			lwz		r0,mpPte(r31)				; Grab the PTE offset
+			mfsdr1	r7							; Get the pointer to the hash table
+			lwz		r5,mpVAddr+4(r31)			; Grab the virtual address
+			rlwinm	r10,r7,0,0,15				; Clean up the hash table base
+			andi.	r3,r0,mpHValid				; Is there a possible PTE?
+			srwi	r7,r0,4						; Convert to PCA units
+			rlwinm	r7,r7,0,0,29				; Clean up PCA offset
+			mflr	r2							; Save the return
+			subfic	r7,r7,-4					; Convert to -4 based negative index
+			add		r7,r10,r7					; Point to the PCA directly
+			beqlr--								; There was no PTE to start with...
+			
+			bl		mapLockPteg					; Lock the PTEG
+
+			lwz		r0,mpPte(r31)				; Grab the PTE offset
+			mtlr	r2							; Restore the LR
+			andi.	r3,r0,mpHValid				; Is there a possible PTE?
+			beq-	mIPUnlock					; There is no PTE, someone took it so just unlock and leave...
+
+			rlwinm	r3,r0,0,0,30				; Clear the valid bit
+			add		r3,r3,r10					; Point to actual PTE
+			lwz		r4,0(r3)					; Get the top of the PTE
+			
+			li		r8,tlbieLock				; Get the TLBIE lock
+			rlwinm	r0,r4,0,1,31				; Clear the valid bit
+			stw		r0,0(r3)					; Invalidate the PTE
+
+			sync								; Make sure everyone sees the invalidate
+			
+mITLBIE32:	lwarx	r0,0,r8						; Get the TLBIE lock 
+			mfsprg	r2,2						; Get feature flags 
+			mr.		r0,r0						; Is it locked? 
+			li		r0,1						; Get our lock word 
+			bne-	mITLBIE32					; It is locked, go wait...
+			
+			stwcx.	r0,0,r8						; Try to get it
+			bne-	mITLBIE32					; We was beat...
+			
+			rlwinm.	r0,r2,0,pfSMPcapb,pfSMPcapb	; Can this be an MP box?
+			li		r0,0						; Lock clear value 
+
+			tlbie	r5							; Invalidate it everywhere 
+
+			stw		r0,tlbieLock(0)				; Clear the tlbie lock
+			
+			beq-	mINoTS32					; Can not have MP on this machine...
+			
+			eieio								; Make sure that the tlbie happens first 
+			tlbsync								; Wait for everyone to catch up 
+			sync								; Make sure of it all
+			
+mINoTS32:	lwz		r5,4(r3)					; Get the real part
+			srwi	r10,r5,12					; Change physical address to a ppnum
+
+mINmerge:	lbz		r11,mpFlags+1(r31)			; Get the offset to the physical entry table
+			lwz		r0,mpVAddr+4(r31)			; Get the flags part of the field
+			lis		r8,hi16(EXT(pmap_mem_regions))	; Get the top of the region table
+			ori		r8,r8,lo16(EXT(pmap_mem_regions))	; Get the bottom of the region table
+			rlwinm	r11,r11,2,0,29				; Change index into byte offset
+			add		r11,r11,r8					; Point to the bank table
+			lwz		r2,mrPhysTab(r11)			; Get the physical table bank pointer
+			lwz		r11,mrStart(r11)			; Get the start of bank
+			rlwimi	r0,r5,0,mpRb-32,mpCb-32		; Copy in the RC
+			addi	r2,r2,4						; Offset to last half of field
+			stw		r0,mpVAddr+4(r31)			; Set the new RC into the field
+			sub		r11,r10,r11					; Get the index into the table
+			rlwinm	r11,r11,3,0,28				; Get offset to the physent
+
+
+mImrgRC:	lwarx	r10,r11,r2					; Get the master RC
+			rlwinm	r0,r5,27,ppRb-32,ppCb-32	; Position the new RC
+			or		r0,r0,r10					; Merge in the new RC
+			stwcx.	r0,r11,r2					; Try to stick it back
+			bne--	mImrgRC						; Try again if we collided...
+			
+			blr									; Leave with the PCA still locked up...
+
+mIPUnlock:	eieio								; Make sure all updates come first
+				
+			stw		r6,0(r7)					; Unlock
 			blr
 
+;
+;			64-bit version
+;
+			.align	5
 
-/*			int mapalc(struct mappingblok *mb) - Finds, allocates, and checks a free mapping entry in a block
- *
- *			Lock must already be held on mapping block list
- *			returns 0 if all slots filled.
- *			returns n if a slot is found and it is not the last
- *			returns -n if a slot os found and it is the last
- *			when n and -n are returned, the corresponding bit is cleared
- *
- */
+mapInvPte64:
+			lwz		r0,mpPte(r31)				; Grab the PTE offset
+			ld		r5,mpVAddr(r31)				; Grab the virtual address
+			mfsdr1	r7							; Get the pointer to the hash table
+			rldicr	r10,r7,0,45					; Clean up the hash table base
+			andi.	r3,r0,mpHValid				; Is there a possible PTE?
+			srdi	r7,r0,5						; Convert to PCA units
+			rldicr	r7,r7,0,61					; Clean up PCA
+			subfic	r7,r7,-4					; Convert to -4 based negative index
+			mflr	r2							; Save the return
+			add		r7,r10,r7					; Point to the PCA directly
+			beqlr--								; There was no PTE to start with...
+			
+			bl		mapLockPteg					; Lock the PTEG
+			
+			lwz		r0,mpPte(r31)				; Grab the PTE offset again
+			mtlr	r2							; Restore the LR
+			andi.	r3,r0,mpHValid				; Is there a possible PTE?
+			beq--	mIPUnlock					; There is no PTE, someone took it so just unlock and leave...
+
+			rlwinm	r3,r0,0,0,30				; Clear the valid bit
+			add		r3,r3,r10					; Point to the actual PTE
+			ld		r4,0(r3)					; Get the top of the PTE
+
+			li		r8,tlbieLock				; Get the TLBIE lock
+			rldicr	r0,r4,0,62					; Clear the valid bit
+			std		r0,0(r3)					; Invalidate the PTE
+			
+			rldicr	r2,r4,16,35					; Shift the AVPN over to match VPN
+			sync								; Make sure everyone sees the invalidate
+			rldimi	r2,r5,0,36					; Cram in the page portion of the EA
+			
+mITLBIE64:	lwarx	r0,0,r8						; Get the TLBIE lock 
+			mr.		r0,r0						; Is it locked? 
+			li		r0,1						; Get our lock word 
+			bne--	mITLBIE64a					; It is locked, toss reservation and wait...
+			
+			stwcx.	r0,0,r8						; Try to get it
+			bne--	mITLBIE64					; We was beat...
+
+			rldicl	r2,r2,0,16					; Clear bits 0:15 because we are under orders
+			
+			li		r0,0						; Lock clear value 
+
+			tlbie	r2							; Invalidate it everywhere 
+
+			stw		r0,tlbieLock(0)				; Clear the tlbie lock
+			
+			eieio								; Make sure that the tlbie happens first 
+			tlbsync								; Wait for everyone to catch up 
+			isync								
+			ptesync								; Wait for quiet again
+			
+mINoTS64:	sync								; Make sure of it all
+
+			ld		r5,8(r3)					; Get the real part
+			srdi	r10,r5,12					; Change physical address to a ppnum
+			b		mINmerge					; Join the common 32-64-bit code...
+
+mITLBIE64a:	li		r5,lgKillResv				; Killing field
+			stwcx.	r5,0,r5						; Kill reservation
+			
+mITLBIE64b:	lwz		r0,0(r8)					; Get the TLBIE lock
+			mr.		r0,r0						; Is it locked?
+			beq++	mITLBIE64					; Nope, try again...
+			b		mITLBIE64b					; Yup, wait for it...
+
+;
+;			mapLockPteg - Locks a PTEG
+;			R7 points to PCA entry
+;			R6 contains PCA on return
+;
+;
 
 			.align	5
-			.globl	EXT(mapalc)
+			
+mapLockPteg:
+			lwarx	r6,0,r7						; Pick up the PCA
+			rlwinm.	r0,r6,0,PCAlockb,PCAlockb	; Is the PTEG locked?
+			ori		r0,r6,PCAlock				; Set the lock bit
+			bne--	mLSkill						; It is locked...
+			
+			stwcx.	r0,0,r7						; Try to lock the PTEG
+			bne--	mapLockPteg					; We collided...
+			
+			isync								; Nostradamus lied
+			blr									; Leave...
+				
+mLSkill:	li		r6,lgKillResv				; Get killing field
+			stwcx.	r6,0,r6						; Kill it
 
-LEXT(mapalc)
+mapLockPteh:
+			lwz		r6,0(r7)					; Pick up the PCA
+			rlwinm.	r0,r6,0,PCAlockb,PCAlockb	; Is the PTEG locked?
+			beq++	mapLockPteg					; Nope, try again...
+			b		mapLockPteh					; Yes, wait for it...
 			
-			lwz		r4,mbfree(r3)				; Get the first mask 
-			lis		r0,0x8000					; Get the mask to clear the first free bit
-			lwz		r5,mbfree+4(r3)				; Get the second mask 
-			mr		r12,r3						; Save the return
-			cntlzw	r8,r4						; Get first free field
-			lwz		r6,mbfree+8(r3)				; Get the third mask 
-			srw.	r9,r0,r8					; Get bit corresponding to first free one
-			lwz		r7,mbfree+12(r3)			; Get the fourth mask 
-			cntlzw	r10,r5						; Get first free field in second word
-			andc	r4,r4,r9					; Turn it off
-			bne		malcfnd0					; Found one...
+
+;
+;			The mapSelSlot function selects a PTEG slot to use. As input, it expects R6 
+;			to contain the PCA.  When it returns, R3 contains 0 if an unoccupied slot was
+;			selected, 1 if it stole a non-block PTE, or 2 if it stole a block mapped PTE.
+;			R4 returns the slot index.
+;
+;			CR7 also indicates that we have a block mapping
+;
+;			The PTEG allocation controls are a bit map of the state of the PTEG. 
+;			PCAfree indicates that the PTE slot is empty. 
+;			PCAauto means that it comes from an autogen area.  These
+;			guys do not keep track of reference and change and are actually "wired".
+;			They are easy to maintain. PCAsteal
+;			is a sliding position mask used to "randomize" PTE slot stealing.  All 4 of these
+;			fields fit in a single word and are loaded and stored under control of the
+;			PTEG control area lock (PCAlock).
+;
+;			Note that PCAauto does not contribute to the steal calculations at all.  Originally
+;			it did, autogens were second in priority.  This can result in a pathalogical
+;			case where an instruction can not make forward progress, or one PTE slot
+;			thrashes.
+;
+;			Note that the PCA must be locked when we get here.
+;
+;			Physically, the fields are arranged:
+;				0: PCAfree
+;				1: PCAsteal
+;				2: PCAauto
+;				3: PCAmisc
+;				
+;
+;			At entry, R6 contains new unlocked PCA image (real PCA is locked and untouched)
+;
+;			At exit:
+;
+;			R3 = 0 - no steal
+;			R3 = 1 - steal regular
+;			R3 = 2 - steal autogen
+;			R4 contains slot number
+;			R6 contains updated PCA image
+;
+
+			.align	5
 			
-			srw.	r9,r0,r10					; Get bit corresponding to first free one in second word
-			cntlzw	r11,r6						; Get first free field in third word
-			andc	r5,r5,r9					; Turn it off
-			bne		malcfnd1					; Found one...
+mapSelSlot:	lis		r10,0						; Clear autogen mask
+			li		r9,0						; Start a mask
+			beq		cr7,mSSnotblk				; Skip if this is not a block mapping
+			ori		r10,r10,lo16(0xFFFF)		; Make sure we mark a block mapping (autogen)
+
+mSSnotblk:	rlwinm	r11,r6,16,24,31				; Isolate just the steal mask
+			oris	r9,r9,0x8000				; Get a mask
+			cntlzw	r4,r6						; Find a slot or steal one
+			ori		r9,r9,lo16(0x8000)			; Insure that we have 0x80008000
+			rlwinm	r4,r4,0,29,31				; Isolate bit position
+			rlwimi	r11,r11,8,16,23				; Get set to march a 1 back into top of 8 bit rotate
+			srw		r2,r9,r4					; Get mask to isolate selected inuse and autogen flags
+			srwi	r11,r11,1					; Slide steal mask right
+			and		r8,r6,r2					; Isolate the old in use and autogen bits
+			andc	r6,r6,r2					; Allocate the slot and also clear autogen flag
+			addi	r0,r8,0x7F00				; Push autogen flag to bit 16
+			and		r2,r2,r10					; Keep the autogen part if autogen
+			addis	r8,r8,0xFF00				; Push in use to bit 0 and invert
+			or		r6,r6,r2					; Add in the new autogen bit 
+			rlwinm	r0,r0,17,31,31				; Get a 1 if the old was autogenned (always 0 if not in use)
+			rlwinm	r8,r8,1,31,31				; Isolate old in use
+			rlwimi	r6,r11,16,8,15				; Stick the new steal slot in
+
+			add		r3,r0,r8					; Get 0 if no steal, 1 if steal normal, 2 if steal autogen			
+			blr									; Leave...
 			
-			srw.	r9,r0,r11					; Get bit corresponding to first free one in third word
-			cntlzw	r10,r7						; Get first free field in fourth word
-			andc	r6,r6,r9					; Turn it off
-			bne		malcfnd2					; Found one...
+;
+;			Shared/Exclusive locks
+;
+;			A shared/exclusive lock allows multiple shares of a lock to be taken
+;			but only one exclusive.  A shared lock can be "promoted" to exclusive
+;			when it is the only share.  If there are multiple sharers, the lock
+;			must be "converted".  A promotion drops the share and gains exclusive as
+;			an atomic operation.  If anyone else has a share, the operation fails.
+;			A conversion first drops the share and then takes an exclusive lock.
+;
+;			We will want to add a timeout to this eventually.
+;
+;			R3 is set to 0 for success, non-zero for failure
+;
+
+;
+;			Convert a share into an exclusive
+;
+
+			.align	5
 			
-			srw.	r9,r0,r10					; Get bit corresponding to first free one in second word
-			li		r3,0						; Assume abject failure
-			andc	r7,r7,r9					; Turn it off
-			beqlr								; There are none any left...
+sxlkConvert:
+
+			lis		r0,0x8000					; Get the locked lock image
+#if 0
+			mflr	r0							; (TEST/DEBUG)
+			oris	r0,r0,0x8000				; (TEST/DEBUG)
+#endif
+		
+sxlkCTry:	lwarx	r2,0,r3						; Get the lock word
+			cmplwi	r2,1						; Does it just have our share?
+			subi	r2,r2,1						; Drop our share in case we do not get it
+			bne--	sxlkCnotfree				; No, we need to unlock...
+			stwcx.	r0,0,r3						; Try to take it exclusively
+			bne--	sxlkCTry					; Collision, try again...
 			
-			addi	r3,r10,96					; Set the correct bit number
-			stw		r7,mbfree+12(r12)			; Actually allocate the slot
+			isync
+			li		r3,0						; Set RC
+			blr									; Leave...
+
+sxlkCnotfree:
+			stwcx.	r2,0,r3						; Try to drop our share...	
+			bne--	sxlkCTry					; Try again if we collided...
+			b		sxlkExclusive				; Go take it exclusively...
+
+;
+;			Promote shared to exclusive
+;
+
+			.align	5
 			
-mapafin:	or		r4,r4,r5					; Merge the first two allocation maps
-			or		r6,r6,r7					; Then the last two
-			or.		r4,r4,r6					; Merge both halves
-			bnelr+								; Return if some left for next time...
+sxlkPromote:
+			lis		r0,0x8000					; Get the locked lock image
+#if 0
+			mflr	r0							; (TEST/DEBUG)
+			oris	r0,r0,0x8000				; (TEST/DEBUG)
+#endif
+		
+sxlkPTry:	lwarx	r2,0,r3						; Get the lock word
+			cmplwi	r2,1						; Does it just have our share?
+			bne--	sxlkPkill					; No, just fail (R3 is non-zero)...
+			stwcx.	r0,0,r3						; Try to take it exclusively
+			bne--	sxlkPTry					; Collision, try again...
 			
-			neg		r3,r3						; Indicate we just allocated the last one
+			isync
+			li		r3,0						; Set RC
 			blr									; Leave...
+
+sxlkPkill:	li		r2,lgKillResv				; Point to killing field
+			stwcx.	r2,0,r2						; Kill reservation
+			blr									; Leave
+
+
+
+;
+;			Take lock exclusivily
+;
+
+			.align	5
 			
-malcfnd0:	stw		r4,mbfree(r12)				; Actually allocate the slot
-			mr		r3,r8						; Set the correct bit number
-			b		mapafin						; Exit now...
+sxlkExclusive:
+			lis		r0,0x8000					; Get the locked lock image
+#if 0
+			mflr	r0							; (TEST/DEBUG)
+			oris	r0,r0,0x8000				; (TEST/DEBUG)
+#endif
+		
+sxlkXTry:	lwarx	r2,0,r3						; Get the lock word
+			mr.		r2,r2						; Is it locked?
+			bne--	sxlkXWait					; Yes...
+			stwcx.	r0,0,r3						; Try to take it
+			bne--	sxlkXTry					; Collision, try again...
 			
-malcfnd1:	stw		r5,mbfree+4(r12)			; Actually allocate the slot
-			addi	r3,r10,32					; Set the correct bit number
-			b		mapafin						; Exit now...
+			isync								; Toss anything younger than us
+			li		r3,0						; Set RC
+			blr									; Leave...
 			
-malcfnd2:	stw		r6,mbfree+8(r12)			; Actually allocate the slot
-			addi	r3,r11,64					; Set the correct bit number
-			b		mapafin						; Exit now...
+			.align	5
+
+sxlkXWait:	li		r2,lgKillResv				; Point to killing field
+			stwcx.	r2,0,r2						; Kill reservation
 			
+sxlkXWaiu:	lwz		r2,0(r3)					; Get the lock again
+			mr.		r2,r2						; Is it free yet?
+			beq++	sxlkXTry					; Yup...
+			b		sxlkXWaiu					; Hang around a bit more...
 
-/*
- * Log out all memory usage
- */
+;
+;			Take a share of the lock
+;
 
 			.align	5
-			.globl	EXT(logmem)
+			
+sxlkShared:	lwarx	r2,0,r3						; Get the lock word
+			rlwinm.	r0,r2,0,0,0					; Is it locked exclusively?
+			addi	r2,r2,1						; Up the share count
+			bne--	sxlkSWait					; Yes...
+			stwcx.	r2,0,r3						; Try to take it
+			bne--	sxlkShared					; Collision, try again...
+			
+			isync								; Toss anything younger than us
+			li		r3,0						; Set RC
+			blr									; Leave...
+			
+			.align	5
 
-LEXT(logmem)
+sxlkSWait:	li		r2,lgKillResv				; Point to killing field
+			stwcx.	r2,0,r2						; Kill reservation
 
-			mfmsr	r2							; Get the MSR	
-			lis		r10,hi16(EXT(DebugWork))		; High part of area
-			rlwinm	r2,r2,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-			lis		r12,hi16(EXT(mem_actual))	; High part of actual
-			rlwinm	r2,r2,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-			andi.	r0,r2,0x7FCF				; Interrupts and translation off
-			ori		r10,r10,lo16(EXT(DebugWork))	; Get the entry
-			mtmsr	r0							; Turn stuff off
-			ori		r12,r12,lo16(EXT(mem_actual))	; Get the actual
-			li		r0,1						; Get a one
-	
+sxlkSWaiu:	lwz		r2,0(r3)					; Get the lock again
+			rlwinm.	r0,r2,0,0,0					; Is it locked exclusively?
+			beq++	sxlkShared					; Nope...
+			b		sxlkSWaiu					; Hang around a bit more...
+
+;
+;			Unlock either exclusive or shared.
+;
+
+			.align	5
+			
+sxlkUnlock:	eieio								; Make sure we order our stores out
+		
+sxlkUnTry:	lwarx	r2,0,r3						; Get the lock
+			rlwinm.	r0,r2,0,0,0					; Do we hold it exclusively?
+			subi	r2,r2,1						; Remove our share if we have one
+			li		r0,0						; Clear this
+			bne--	sxlkUExclu					; We hold exclusive...
+			
+			stwcx.	r2,0,r3						; Try to lose our share
+			bne--	sxlkUnTry					; Collision...
+			blr									; Leave...
+			
+sxlkUExclu:	stwcx.	r0,0,r3						; Unlock and release reservation
+			beqlr++								; Leave if ok...
+			b		sxlkUnTry					; Could not store, try over...	
+			
+
+			.align	5
+			.globl	EXT(fillPage)
+
+LEXT(fillPage)
+
+ 			mfsprg	r0,2						; Get feature flags 
+			mtcrf	0x02,r0						; move pf64Bit to cr
+
+			rlwinm	r4,r4,0,1,0					; Copy fill to top of 64-bit register
+			lis		r2,0x0200					; Get vec
+			mr		r6,r4						; Copy
+			ori		r2,r2,0x2000				; Get FP
+			mr		r7,r4						; Copy
+			mfmsr	r5							; Get MSR
+			mr		r8,r4						; Copy
+			andc	r5,r5,r2					; Clear out permanent turn-offs
+			mr		r9,r4						; Copy
+			ori		r2,r2,0x8030				; Clear IR, DR and EE
+			mr		r10,r4						; Copy
+			andc	r0,r5,r2					; Kill them
+			mr		r11,r4						; Copy
+			mr		r12,r4						; Copy
+			bt++	pf64Bitb,fpSF1				; skip if 64-bit (only they take the hint)
+			
+			slwi	r3,r3,12					; Make into a physical address
+			mtmsr	r2							; Interrupts and translation off
+			isync
+			
+			li		r2,4096/32					; Get number of cache lines
+			
+fp32again:	dcbz	0,r3						; Clear
+			addic.	r2,r2,-1					; Count down
+			stw		r4,0(r3)					; Fill
+			stw		r6,4(r3)					; Fill
+			stw		r7,8(r3)					; Fill
+			stw		r8,12(r3)					; Fill
+			stw		r9,16(r3)					; Fill
+			stw		r10,20(r3)					; Fill
+			stw		r11,24(r3)					; Fill
+			stw		r12,28(r3)					; Fill
+			addi	r3,r3,32					; Point next
+			bgt+	fp32again					; Keep going
+
+			mtmsr	r5							; Restore all
 			isync
+			blr									; Return...
+			
+			.align	5
+			
+fpSF1:		li		r2,1
+			sldi	r2,r2,63					; Get 64-bit bit
+			or		r0,r0,r2					; Turn on 64-bit
+			sldi	r3,r3,12					; Make into a physical address
 
-			stw		r0,4(r10)					; Force logging off
-			lwz		r0,0(r12)					; Get the end of memory
-			
-			lis		r12,hi16(EXT(mem_size))		; High part of defined memory
-			ori		r12,r12,lo16(EXT(mem_size))	; Low part of defined memory
-			lwz		r12,0(r12)					; Make it end of defined
-			
-			cmplw	r0,r12						; Is there room for the data?
-			ble-	logmemexit					; No, do not even try...
-
-			stw		r12,0(r12)					; Set defined memory size
-			stw		r0,4(r12)					; Set the actual amount of memory
-			
-			lis		r3,hi16(EXT(hash_table_base))	; Hash table address
-			lis		r4,hi16(EXT(hash_table_size))	; Hash table size
-			lis		r5,hi16(EXT(pmap_mem_regions))	; Memory regions
-			lis		r6,hi16(EXT(mapCtl))		; Mappings
-			ori		r3,r3,lo16(EXT(hash_table_base))	
-			ori		r4,r4,lo16(EXT(hash_table_size))	
-			ori		r5,r5,lo16(EXT(pmap_mem_regions))	
-			ori		r6,r6,lo16(EXT(mapCtl))	
-			lwz		r3,0(r3)
-			lwz		r4,0(r4)
-			lwz		r5,4(r5)					; Get the pointer to the phys_ent table
-			lwz		r6,0(r6)					; Get the pointer to the current mapping block
-			stw		r3,8(r12)					; Save the hash table address
-			stw		r4,12(r12)					; Save the hash table size
-			stw		r5,16(r12)					; Save the physent pointer
-			stw		r6,20(r12)					; Save the mappings
-			
-			addi	r11,r12,0x1000				; Point to area to move hash table and PCA
-			
-			add		r4,r4,r4					; Double size for both
-			
-copyhash:	lwz		r7,0(r3)					; Copy both of them
-			lwz		r8,4(r3)
-			lwz		r9,8(r3)
-			lwz		r10,12(r3)
-			subic.	r4,r4,0x10
-			addi	r3,r3,0x10
-			stw		r7,0(r11)
-			stw		r8,4(r11)
-			stw		r9,8(r11)
-			stw		r10,12(r11)
-			addi	r11,r11,0x10
-			bgt+	copyhash
-			
-			rlwinm	r4,r12,20,12,31				; Get number of phys_ents
-
-copyphys:	lwz		r7,0(r5)					; Copy physents
-			lwz		r8,4(r5)
-			subic.	r4,r4,1
-			addi	r5,r5,8
-			stw		r7,0(r11)
-			stw		r8,4(r11)
-			addi	r11,r11,8
-			bgt+	copyphys
-			
-			addi	r11,r11,4095				; Round up to next page
-			rlwinm	r11,r11,0,0,19
-
-			lwz		r4,4(r6)					; Get the size of the mapping area
-			
-copymaps:	lwz		r7,0(r6)					; Copy the mappings
-			lwz		r8,4(r6)
-			lwz		r9,8(r6)
-			lwz		r10,12(r6)
-			subic.	r4,r4,0x10
-			addi	r6,r6,0x10
-			stw		r7,0(r11)
-			stw		r8,4(r11)
-			stw		r9,8(r11)
-			stw		r10,12(r11)
-			addi	r11,r11,0x10
-			bgt+	copymaps
-
-			sub		r11,r11,r12					; Get the total length we saved
-			stw		r11,24(r12)					; Save the size
-			
-logmemexit:	mtmsr	r2							; Back to normal
-			li		r3,0
+			mtmsrd	r0							; Interrupts and translation off
 			isync
+			
+			li		r2,4096/128					; Get number of cache lines
+						
+fp64again:	dcbz128	0,r3						; Clear
+			addic.	r2,r2,-1					; Count down
+			std		r4,0(r3)					; Fill
+			std		r6,8(r3)					; Fill
+			std		r7,16(r3)					; Fill
+			std		r8,24(r3)					; Fill
+			std		r9,32(r3)					; Fill
+			std		r10,40(r3)					; Fill
+			std		r11,48(r3)					; Fill
+			std		r12,56(r3)					; Fill
+			std		r4,64+0(r3)					; Fill
+			std		r6,64+8(r3)					; Fill
+			std		r7,64+16(r3)				; Fill
+			std		r8,64+24(r3)				; Fill
+			std		r9,64+32(r3)				; Fill
+			std		r10,64+40(r3)				; Fill
+			std		r11,64+48(r3)				; Fill
+			std		r12,64+56(r3)				; Fill
+			addi	r3,r3,128					; Point next
+			bgt+	fp64again					; Keep going
+
+			mtmsrd	r5							; Restore all
+			isync
+			blr									; Return...
+			
+			.align	5
+			.globl	EXT(mapLog)
+
+LEXT(mapLog)
+
+			mfmsr	r12
+			lis		r11,hi16(EXT(mapdebug))
+			ori		r11,r11,lo16(EXT(mapdebug))
+			lwz		r10,0(r11)
+			mr.		r10,r10
+			bne++	mLxx
+			mr		r10,r3
+mLxx:		rlwinm	r0,r12,0,MSR_DR_BIT+1,MSR_DR_BIT-1
+			mtmsr	r0
+			isync
+			stw		r4,0(r10)
+			stw		r4,4(r10)
+			stw		r5,8(r10)
+			stw		r6,12(r10)
+			mtmsr	r12
+			isync
+			addi	r10,r10,16
+			stw		r10,0(r11)
 			blr
+			
+#if 1
+			.align	5
+			.globl	EXT(checkBogus)
+
+LEXT(checkBogus)
+
+			BREAKPOINT_TRAP
+			blr									; No-op normally
+			
+#endif						
+
+
 
 
diff --git a/osfmk/ppc/instrumentation.h b/osfmk/ppc/instrumentation.h
new file mode 100644
index 000000000..1800a8485
--- /dev/null
+++ b/osfmk/ppc/instrumentation.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ * 
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ * 
+ * @APPLE_LICENSE_HEADER_END@
+ */
+/*
+ * @APPLE_FREE_COPYRIGHT@
+ */
+
+/*
+ * Here be the instrumentaion page layout
+ * Lovingly crafted by Bill Angell using traditional methods
+*/
+
+#ifndef _INSTRUMENTATION_H_
+#define _INSTRUMENTATION_H_
+
+#define INTRUMENTATION 1
+
+
+#define inBase 0x6000
+
+#define inEntry 0
+#define inAtGetTb 1
+#define inBeforeTrace 2
+#define inAfterSAAlloc 3
+#define inBeforeFilter 4
+#define inEatRuptQfret 5
+#define inEatRuptSAfree 6
+#define inPassupSwtchSeg 7
+#define inExceptionExit 8
+#define inMiddleOfSC 9
+#define inEatRuptSwtchSeg 10
+#define inPassup 11
+#define inCopyout 12
+#define inMUASbefore 13
+#define inMUAS
+
+#endif /* _INSTRUMENTATION_H_ */
diff --git a/osfmk/ppc/interrupt.c b/osfmk/ppc/interrupt.c
index 47e447e81..2074435fc 100644
--- a/osfmk/ppc/interrupt.c
+++ b/osfmk/ppc/interrupt.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -30,15 +33,15 @@
 #include <kern/thread.h>
 #include <kern/counters.h>
 #include <ppc/misc_protos.h>
+#include <ppc/trap.h>
 #include <ppc/proc_reg.h>
 #include <ppc/exception.h>
 #include <ppc/savearea.h>
 #include <pexpert/pexpert.h>
-#if	NCPUS > 1
-#include <ppc/POWERMAC/mp/MPPlugIn.h>
-#endif /* NCPUS > 1 */
 #include <sys/kdebug.h>
 
+perfTrap perfIntHook = 0;						/* Pointer to performance trap hook routine */
+
 struct savearea * interrupt(
         int type,
         struct savearea *ssp,
@@ -51,6 +54,10 @@ struct savearea * interrupt(
 	thread_act_t	act;
 
 	disable_preemption();
+
+	if(perfIntHook) {							/* Is there a hook? */
+		if(perfIntHook(type, ssp, dsisr, dar) == KERN_SUCCESS) return ssp;	/* If it succeeds, we are done... */
+	}
 	
 #if 0
 	{
@@ -108,7 +115,7 @@ struct savearea * interrupt(
 			
 		case T_DECREMENTER:
 			KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_EXCP_DECI, 0) | DBG_FUNC_NONE,
-				  isync_mfdec(), ssp->save_srr0, 0, 0, 0);
+				  isync_mfdec(), (unsigned int)ssp->save_srr0, 0, 0, 0);
 	
 #if 0
 			if (pcsample_enable) {
@@ -136,7 +143,7 @@ struct savearea * interrupt(
 			counter_always(c_incoming_interrupts++);
 	
 			KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_EXCP_INTR, 0) | DBG_FUNC_START,
-			   current_cpu, ssp->save_srr0, 0, 0, 0);
+			   current_cpu, (unsigned int)ssp->save_srr0, 0, 0, 0);
 	
 			per_proc_info[current_cpu].interrupt_handler(
 				per_proc_info[current_cpu].interrupt_target, 
diff --git a/osfmk/ppc/io_map.c b/osfmk/ppc/io_map.c
index 5ce5ab5e8..4a1824f32 100644
--- a/osfmk/ppc/io_map.c
+++ b/osfmk/ppc/io_map.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -42,6 +45,8 @@ extern vm_offset_t	virtual_avail;
  * outside the usual physical memory. If phys_addr is NULL then
  * steal the appropriate number of physical pages from the vm
  * system and map them.
+ *
+ * Note, this will onl
  */
 vm_offset_t
 io_map(phys_addr, size)
@@ -58,38 +63,68 @@ io_map(phys_addr, size)
 	assert (kernel_map != VM_MAP_NULL);			/* VM must be initialised */
 #endif
 
-	if (phys_addr != 0) {
-		/* make sure we map full contents of all the pages concerned */
-		size = round_page(size + (phys_addr & PAGE_MASK));
+	if (phys_addr != 0) {						/* If they supplied a physical address, use it */
 
-		/* Steal some free virtual addresses */
+		size = round_page_32(size + (phys_addr & PAGE_MASK));	/* Make sure we map all of it */
 
-		(void) kmem_alloc_pageable(kernel_map, &start, size);
+		(void) kmem_alloc_pageable(kernel_map, &start, size);	/* Get some virtual addresses to use */
 		
-		pmap_map_block(kernel_pmap, start, phys_addr, size, 
-		   VM_PROT_READ|VM_PROT_WRITE, PTE_WIMG_IO, 0);	/* Set up a block mapped area */
+		(void)mapping_make(kernel_pmap, (addr64_t)start, (ppnum_t)(phys_addr >> 12), 
+			(mmFlgBlock | mmFlgUseAttr | mmFlgCInhib | mmFlgGuarded),	/* Map as I/O page */
+			size >> 12, VM_PROT_READ|VM_PROT_WRITE);
 
-		return (start + (phys_addr & PAGE_MASK));
+		return (start + (phys_addr & PAGE_MASK));	/* Pass back the physical address */
 	
 	} else {
 	
-		/* Steal some free virtual addresses */
-		(void) kmem_alloc_pageable(kernel_map, &start, size);
+		(void) kmem_alloc_pageable(kernel_map, &start, size);	/* Get some virtual addresses */
 
 		mapping_prealloc(size);					/* Make sure there are enough free mappings */
-		/* Steal some physical pages and map them one by one */
+
 		for (i = 0; i < size ; i += PAGE_SIZE) {
 			m = VM_PAGE_NULL;
-			while ((m = vm_page_grab()) == VM_PAGE_NULL)
-				VM_PAGE_WAIT();
+			while ((m = vm_page_grab()) == VM_PAGE_NULL) {	/* Get a physical page */
+				VM_PAGE_WAIT();					/* Wait if we didn't have one */
+			}
 			vm_page_gobble(m);
-			(void) pmap_map_bd(start + i,
-					   m->phys_addr,
-					   m->phys_addr + PAGE_SIZE,
-					   VM_PROT_READ|VM_PROT_WRITE);
+			
+			(void)mapping_make(kernel_pmap, 
+				(addr64_t)(start + i), m->phys_page, 
+				(mmFlgBlock | mmFlgUseAttr | mmFlgCInhib | mmFlgGuarded),	/* Map as I/O page */
+				1, VM_PROT_READ|VM_PROT_WRITE);	
+			
 		}
 
 		mapping_relpre();						/* Allow mapping release */
 		return start;
 	}
 }
+
+
+/*
+ * Allocate and map memory for devices before the VM system comes alive.
+ */
+
+vm_offset_t io_map_spec(vm_offset_t phys_addr, vm_size_t size)
+{
+	vm_offset_t	start;
+	int		i;
+	unsigned int j;
+	vm_page_t 	m;
+
+
+	if(kernel_map != VM_MAP_NULL) {				/* If VM system is up, redirect to normal routine */
+		
+		return io_map(phys_addr, size);			/* Map the address */
+	
+	}
+	
+	size = round_page_32(size + (phys_addr - (phys_addr & -PAGE_SIZE)));	/* Extend the length to include it all */
+	start = pmap_boot_map(size);				/* Get me some virtual address */
+
+	(void)mapping_make(kernel_pmap, (addr64_t)start, (ppnum_t)(phys_addr >> 12), 
+		(mmFlgBlock | mmFlgUseAttr | mmFlgCInhib | mmFlgGuarded),	/* Map as I/O page */
+		size >> 12, VM_PROT_READ|VM_PROT_WRITE);
+
+	return (start + (phys_addr & PAGE_MASK));
+}
diff --git a/osfmk/ppc/io_map_entries.h b/osfmk/ppc/io_map_entries.h
index e7a329dc3..2082bdf2e 100644
--- a/osfmk/ppc/io_map_entries.h
+++ b/osfmk/ppc/io_map_entries.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -30,5 +33,6 @@
 extern vm_offset_t	io_map(
 				vm_offset_t		phys_addr,
 				vm_size_t		size);
+extern vm_offset_t io_map_spec(vm_offset_t phys_addr, vm_size_t size);
 
 #endif	/* _PPC_IO_MAP_ENTRIES_H_ */
diff --git a/osfmk/ppc/iso_font.h b/osfmk/ppc/iso_font.h
index 25ac9734f..26a96c403 100644
--- a/osfmk/ppc/iso_font.h
+++ b/osfmk/ppc/iso_font.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ppc/lock.h b/osfmk/ppc/lock.h
index e5ba906b8..cb7e07aed 100644
--- a/osfmk/ppc/lock.h
+++ b/osfmk/ppc/lock.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -62,6 +65,8 @@
 
 #include <kern/macro_help.h>
 #include <kern/assert.h>
+#include <mach/etap_events.h>
+#include <mach/etap.h>
 
 extern unsigned int LockTimeOut;			/* Number of hardware ticks of a lock timeout */
 
@@ -73,20 +78,27 @@ extern unsigned int LockTimeOut;			/* Number of hardware ticks of a lock timeout
 
 #include <ppc/hw_lock_types.h>
 
-#define simple_lock_init(l,t)   hw_lock_init(l)
 #define __slock_held_func__(l)  hw_lock_held(l)
 
-extern void                     fast_usimple_lock(simple_lock_t);
-extern void                     fast_usimple_unlock(simple_lock_t);
-extern unsigned int             fast_usimple_lock_try(simple_lock_t);
+extern void                     ppc_usimple_lock_init(simple_lock_t,etap_event_t);
+extern void                     ppc_usimple_lock(simple_lock_t);
+extern void                     ppc_usimple_unlock_rwmb(simple_lock_t);
+extern void                     ppc_usimple_unlock_rwcmb(simple_lock_t);
+extern unsigned int             ppc_usimple_lock_try(simple_lock_t);
+
+#define	MACHINE_SIMPLE_LOCK
 
-#define simple_lock(l)          fast_usimple_lock(l)
-#define simple_unlock(l)        fast_usimple_unlock(l)
-#define simple_lock_try(l)      fast_usimple_lock_try(l)  
-#define simple_lock_addr(l)     (&(l))
+#define simple_lock_init(l,t)	ppc_usimple_lock_init(l,t)
+#define simple_lock(l)			ppc_usimple_lock(l)
+#define simple_unlock(l)		ppc_usimple_unlock_rwcmb(l)
+#define simple_unlock_rwmb(l)		ppc_usimple_unlock_rwmb(l)
+#define simple_lock_try(l)		ppc_usimple_lock_try(l)  
+#define simple_lock_addr(l)		(&(l))
 #define thread_sleep_simple_lock(l, e, i) \
 				thread_sleep_fast_usimple_lock((l), (e), (i))
 
+#define mutex_unlock(l)		mutex_unlock_rwcmb(l)
+
 #endif /* !(NCPUS == 1 || ETAP_LOCK_TRACE || USLOCK_DEBUG) */
 
 #endif /* MACH_KERNEL_PRIVATE */
diff --git a/osfmk/ppc/low_trace.h b/osfmk/ppc/low_trace.h
index 30bbf3f98..389852db9 100644
--- a/osfmk/ppc/low_trace.h
+++ b/osfmk/ppc/low_trace.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -36,6 +39,7 @@
 #ifndef _LOW_TRACE_H_
 #define _LOW_TRACE_H_
 
+#pragma pack(4)							/* Make sure the structure stays as we defined it */
 typedef struct LowTraceRecord {
 
 	unsigned short	LTR_cpu;			/* 0000 - CPU address */
@@ -43,22 +47,29 @@ typedef struct LowTraceRecord {
 	unsigned int	LTR_timeHi;			/* 0004 - High order time */
 	unsigned int	LTR_timeLo;			/* 0008 - Low order time */
 	unsigned int	LTR_cr;				/* 000C - CR */
-	unsigned int	LTR_srr0;			/* 0010 - SRR0 */
-	unsigned int	LTR_srr1;			/* 0014 - SRR1 */
-	unsigned int	LTR_dar;			/* 0018 - DAR */
-	unsigned int	LTR_save;			/* 001C - savearea */
-	
-	unsigned int	LTR_lr;				/* 0020 - LR */
-	unsigned int	LTR_ctr;			/* 0024 - CTR */
-	unsigned int	LTR_r0;				/* 0028 - R0 */
-	unsigned int	LTR_r1;				/* 002C - R1 */
-	unsigned int	LTR_r2;				/* 0030 - R2 */
-	unsigned int	LTR_r3;				/* 0034 - R3 */
-	unsigned int	LTR_r4;				/* 0038 - R4 */
-	unsigned int	LTR_r5;				/* 003C - R5 */
+	unsigned int	LTR_dsisr;			/* 0010 - DSISR */
+	unsigned int	LTR_rsvd0;			/* 0014 - reserved */
+	uint64_t		LTR_srr0;			/* 0018 - SRR0 */
+
+	uint64_t		LTR_srr1;			/* 0020 - SRR1 */
+	uint64_t		LTR_dar;			/* 0028 - DAR */
+	uint64_t		LTR_save;			/* 0030 - savearea */
+	uint64_t		LTR_lr;				/* 0038 - LR */
+
+	uint64_t		LTR_ctr;			/* 0040 - CTR */
+	uint64_t		LTR_r0;				/* 0048 - R0 */
+	uint64_t		LTR_r1;				/* 0050 - R1 */
+	uint64_t		LTR_r2;				/* 0058 - R2 */
+
+	uint64_t		LTR_r3;				/* 0060 - R3 */
+	uint64_t		LTR_r4;				/* 0068 - R4 */
+	uint64_t		LTR_r5;				/* 0070 - R5 */
+	uint64_t		LTR_r6;				/* 0078 - R6 */
 
 } LowTraceRecord;		
+#pragma pack()
 
+#pragma pack(4)							/* Make sure the structure stays as we defined it */
 typedef struct traceWork {
 
 	unsigned int traceCurr;				/* Address of next slot */
@@ -66,8 +77,10 @@ typedef struct traceWork {
 	unsigned int traceStart;			/* Start of trace table */
 	unsigned int traceEnd;				/* End of trace table */
 	unsigned int traceMsnd;				/* Saved trace mask */
-	unsigned int traceGas[3];
+	unsigned int traceSize;				/* Size of trace table. Min 1 page */
+	unsigned int traceGas[2];
 } traceWork;
+#pragma pack()
 
 extern traceWork trcWork;
 extern unsigned int lastTrace;			/* Value of low-level exception trace controls */
diff --git a/osfmk/ppc/lowglobals.h b/osfmk/ppc/lowglobals.h
new file mode 100644
index 000000000..f6d3f36e2
--- /dev/null
+++ b/osfmk/ppc/lowglobals.h
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ * 
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ * 
+ * @APPLE_LICENSE_HEADER_END@
+ */
+/*
+ *		Header files for the Low Memory Globals (lg) 
+ */
+#ifndef	_LOW_MEMORY_GLOBALS_H_
+#define	_LOW_MEMORY_GLOBALS_H_
+
+#include <cpus.h>
+
+#include <mach/mach_types.h>
+#include <mach/vm_types.h>
+#include <mach/machine/vm_types.h>
+#include <mach/vm_prot.h>
+#include <ppc/proc_reg.h>
+#include <ppc/savearea.h>
+#include <ppc/low_trace.h>
+#include <ppc/Diagnostics.h>
+
+/*
+ * Don't change these structures unless you change the corresponding assembly code
+ * which is in lowmem_vectors.s
+ */
+ 
+/* 
+ *	This is where we put constants, pointers, and data areas that must be accessed
+ *	quickly through assembler.  They are designed to be accessed directly with 
+ *	absolute addresses, not via a base register.  This is a global area, and not
+ *	per processor.
+ */
+ 
+#pragma pack(4)								/* Make sure the structure stays as we defined it */
+typedef struct lowglo {
+
+	unsigned long	lgForceAddr[5*1024];	/* 0000 Force to page 5 */
+	unsigned char	lgVerCode[8];			/* 5000 System verification code */
+	unsigned long long lgZero;				/* 5008 Double constant 0 */
+	unsigned int	lgPPStart;				/* 5010 Start of per_proc blocks */
+	unsigned int	lgRsv014[27];			/* 5014 reserved */
+	traceWork		lgTrcWork;				/* 5080 Tracing control block - trcWork */
+	unsigned int	lgRsv0A0[24];			/* 50A0 reserved */
+	struct Saveanchor	lgSaveanchor;		/* 5100 Savearea anchor - saveanchor */
+	unsigned int	lgRsv140[16];			/* 5140 reserved */
+	unsigned int	lgTlbieLck;				/* 5180 TLBIE lock */
+	unsigned int	lgRsv184[31];			/* 5184 reserved - push to next line */
+	struct diagWork	lgdgWork;				/* 5200 Start of diagnostic work area */
+	unsigned int	lgRsv220[24];			/* 5220 reserved */
+	unsigned int	lgRst280[32];			/* 5280 reserved */
+	unsigned int	lgKillResv;				/* 5300 line used to kill reservations */
+	unsigned int	lgKillResvpad[31];		/* 5304 pad reservation kill line */
+	unsigned int	lgRsv380[768];			/* 5380 reserved - push to 1 page */
+
+} lowglo;
+
+extern lowglo lowGlo;
+
+#endif /* _LOW_MEMORY_GLOBALS_H_ */
diff --git a/osfmk/ppc/lowmem_vectors.s b/osfmk/ppc/lowmem_vectors.s
index f3ccdb123..918a92d61 100644
--- a/osfmk/ppc/lowmem_vectors.s
+++ b/osfmk/ppc/lowmem_vectors.s
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -23,38 +26,10 @@
  * @OSF_COPYRIGHT@
  */
 
-/*
- * Low-memory exception vector code for PowerPC MACH
- *
- * These are the only routines that are ever run with
- * VM instruction translation switched off.
- *
- * The PowerPC is quite strange in that rather than having a set
- * of exception vectors, the exception handlers are installed
- * in well-known addresses in low memory. This code must be loaded
- * at ZERO in physical memory. The simplest way of doing this is
- * to load the kernel at zero, and specify this as the first file
- * on the linker command line.
- *
- * When this code is loaded into place, it is loaded at virtual
- * address KERNELBASE, which is mapped to zero (physical).
- *
- * This code handles all powerpc exceptions and is always entered
- * in supervisor mode with translation off. It saves the minimum
- * processor state before switching back on translation and
- * jumping to the approprate routine.
- *
- * Vectors from 0x100 to 0x3fff occupy 0x100 bytes each (64 instructions)
- *
- * We use some of this space to decide which stack to use, and where to
- * save the context etc, before	jumping to a generic handler.
- */
-
 #include <assym.s>
 #include <debug.h>
 #include <cpus.h>
 #include <db_machine_commands.h>
-#include <mach_rt.h>
 	
 #include <mach_debug.h>
 #include <ppc/asm.h>
@@ -64,21 +39,11 @@
 #include <ppc/savearea.h>
 #include <mach/ppc/vm_param.h>
 
-#define TRCSAVE 0
-#define CHECKSAVE 0
-#define PERFTIMES 0
 #define ESPDEBUG 0
+#define INSTRUMENT 0
 
-#if TRCSAVE
-#error The TRCSAVE option is broken.... Fix it
-#endif
-
-#define featL1ena 24
-#define featSMP 25
-#define featAltivec 26
-#define wasNapping 27
-#define featFP 28
-#define specAccess 29
+#define featAltivec 29
+#define wasNapping 30
 
 #define	VECTOR_SEGMENT	.section __VECTORS, __interrupts
 
@@ -90,9 +55,19 @@
 EXT(ExceptionVectorsStart):							/* Used if relocating the exception vectors */
 baseR:												/* Used so we have more readable code */
 
-/* 
- * System reset - call debugger
- */
+;
+;			Handle system reset.
+;			We do not ever expect a hard reset so we do not actually check.
+;			When we come here, we check for a RESET_HANDLER_START (which means we are
+;			waking up from sleep), a RESET_HANDLER_BUPOR (which is using for bring up
+;			when starting directly from a POR), and RESET_HANDLER_IGNORE (which means
+;			ignore the interrupt).
+;
+;			Some machines (so far, 32-bit guys) will always ignore a non-START interrupt.
+;			The ones who do take it, check if the interrupt is too be ignored.  This is 
+;			always the case until the previous reset is handled (i.e., we have exited
+;			from the debugger).
+;
 			. = 0xf0
 			.globl	EXT(ResetHandler)
 EXT(ResetHandler):
@@ -117,8 +92,46 @@ EXT(ResetHandler):
 			mtlr	r4
 			blr
 
-resetexc:
-			mtcr	r11
+resetexc:	cmplwi	r13,RESET_HANDLER_BUPOR				; Special bring up POR sequence?
+			bne		resetexc2						; No...
+			lis		r4,hi16(EXT(resetPOR))			; Get POR code
+			ori		r4,r4,lo16(EXT(resetPOR))		; The rest
+			mtlr	r4								; Set it
+			blr										; Jump to it....
+
+resetexc2:	cmplwi	cr1,r13,RESET_HANDLER_IGNORE	; Are we ignoring these? (Software debounce)
+
+			mfsprg	r13,0							; Get per_proc
+			lwz		r13,pfAvailable(r13)			; Get the features
+			rlwinm.	r13,r13,0,pf64Bitb,pf64Bitb		; Is this a 64-bit machine?
+			cror	cr1_eq,cr0_eq,cr1_eq			; See if we want to take this
+			bne--	cr1,rxCont						; Yes, continue...
+			bne--	rxIg64							; 64-bit path...
+
+			mtcr	r11								; Restore the CR
+			mfsprg	r13,2							; Restore R13
+			mfsprg	r11,0							; Get per_proc
+			lwz		r11,pfAvailable(r11)			; Get the features
+			mtsprg	2,r11							; Restore sprg2
+			mfsprg	r11,3							; Restore R11
+			rfi										; Return and ignore the reset
+
+rxIg64:		mtcr	r11								; Restore the CR
+			mfsprg	r11,0							; Get per_proc
+			mtspr	hsprg0,r14						; Save a register
+			lwz		r14,UAW(r11)					; Get the User Assist Word
+			mfsprg	r13,2							; Restore R13
+			lwz		r11,pfAvailable(r11)			; Get the features
+			mtsprg	2,r11							; Restore sprg2
+			mfsprg	r11,3							; Restore R11
+			mtsprg	3,r14							; Set the UAW in sprg3
+			mfspr	r14,hsprg0						; Restore R14
+			rfid									; Return and ignore the reset
+
+rxCont:		mtcr	r11
+			li		r11,RESET_HANDLER_IGNORE		; Get set to ignore
+			stw		r11,lo16(EXT(ResetHandler)-EXT(ExceptionVectorsStart)+RESETHANDLER_TYPE)(br0)	; Start ignoring these
+			mfsprg	r13,1							/* Get the exception save area */
 			li		r11,T_RESET						/* Set 'rupt code */
 			b		.L_exception_entry				/* Join common... */
 
@@ -128,10 +141,81 @@ resetexc:
 
 			. = 0x200
 .L_handler200:
-			mtsprg	2,r13							/* Save R13 */
-			mtsprg	3,r11							/* Save R11 */
-			li		r11,T_MACHINE_CHECK				/* Set 'rupt code */
-			b		.L_exception_entry				/* Join common... */
+			mtsprg	2,r13							; Save R13 
+			mtsprg	3,r11							; Save R11
+
+			.globl	EXT(extPatchMCK)
+LEXT(extPatchMCK)									; This is patched to a nop for 64-bit 
+			b		h200aaa							; Skip 64-bit code... 
+
+;
+;			Fall through here for 970 MCKs.
+;
+
+			li		r11,1							; ?
+			sldi	r11,r11,32+3					; ?
+			mfspr	r13,hid4						; ?
+			or		r11,r11,r13						; ?
+			sync
+			mtspr	hid4,r11						; ?
+			isync
+			li		r11,1							; ?
+			sldi	r11,r11,32+8					; ?
+			andc	r13,r13,r11						; ?
+			lis		r11,0xE000						; Get the unlikeliest ESID possible
+			sync
+			mtspr	hid4,r13						; ?
+			isync									; ?
+			
+			srdi	r11,r11,1						; ?
+			slbie	r11								; ?
+			sync
+			isync
+		
+			li		r11,T_MACHINE_CHECK				; Set rupt code
+			b		.L_exception_entry				; Join common...
+
+;
+;			Preliminary checking of other MCKs
+;
+
+h200aaa:	mfsrr1	r11								; Get the SRR1
+			mfcr	r13								; Save the CR
+			
+			rlwinm.	r11,r11,0,dcmck,dcmck			; ?
+			beq+	notDCache						; ?
+			
+			sync
+			mfspr	r11,msscr0						; ?
+			dssall									; ?
+			sync
+			isync
+
+			oris	r11,r11,hi16(dl1hwfm)			; ?
+			mtspr	msscr0,r11						; ?
+			
+rstbsy:		mfspr	r11,msscr0						; ?
+			
+			rlwinm.	r11,r11,0,dl1hwf,dl1hwf			; ?
+			bne		rstbsy							; ?
+			
+			sync									; ?
+
+			mfsprg	r11,0							; Get the per_proc
+			mtcrf	255,r13							; Restore CRs
+			lwz		r13,hwMachineChecks(r11)		; Get old count
+			addi	r13,r13,1						; Count this one
+			stw		r13,hwMachineChecks(r11)		; Set new count
+			lwz		r11,pfAvailable(r11)			; Get the feature flags
+			mfsprg	r13,2							; Restore R13
+			mtsprg	2,r11							; Set the feature flags
+			mfsprg	r11,3							; Restore R11
+			rfi										; Return
+
+notDCache:	mtcrf	255,r13							; Restore CRs
+			li		r11,T_MACHINE_CHECK				; Set rupt code
+			b		.L_exception_entry				; Join common...
+
 
 /*
  * 			Data access - page fault, invalid memory rights for operation
@@ -144,16 +228,39 @@ resetexc:
 			li		r11,T_DATA_ACCESS				/* Set 'rupt code */
 			b		.L_exception_entry				/* Join common... */
 
+
+/*
+ * 			Data segment
+ */
+
+			. = 0x380
+.L_handler380:
+			mtsprg	2,r13							; Save R13
+			mtsprg	3,r11							; Save R11
+			li		r11,T_DATA_SEGMENT				; Set rupt code
+			b		.L_exception_entry				; Join common...
+
 /*
  * 			Instruction access - as for data access
  */
 
 			. = 0x400
 .L_handler400:
-			mtsprg	2,r13							/* Save R13 */
-			mtsprg	3,r11							/* Save R11 */
-			li		r11,T_INSTRUCTION_ACCESS		/* Set 'rupt code */
-			b		.L_exception_entry				/* Join common... */
+			mtsprg	2,r13							; Save R13
+			mtsprg	3,r11							; Save R11
+			li		r11,T_INSTRUCTION_ACCESS		; Set rupt code
+			b		.L_exception_entry				; Join common...
+
+/*
+ * 			Instruction segment
+ */
+
+			. = 0x480
+.L_handler480:
+			mtsprg	2,r13							; Save R13 
+			mtsprg	3,r11							; Save R11 
+			li		r11,T_INSTRUCTION_SEGMENT		; Set rupt code
+			b		.L_exception_entry				; Join common... 
 
 /*
  * 			External interrupt
@@ -161,10 +268,10 @@ resetexc:
 
 			. = 0x500
 .L_handler500:
-			mtsprg	2,r13							/* Save R13 */
-			mtsprg	3,r11							/* Save R11 */
-			li		r11,T_INTERRUPT					/* Set 'rupt code */
-			b		.L_exception_entry				/* Join common... */
+			mtsprg	2,r13							; Save R13 
+			mtsprg	3,r11							; Save R11
+			li		r11,T_INTERRUPT					; Set rupt code
+			b		.L_exception_entry				; Join common...
 
 /*
  * 			Alignment - many reasons
@@ -174,7 +281,7 @@ resetexc:
 .L_handler600:
 			mtsprg	2,r13							/* Save R13 */
 			mtsprg	3,r11							/* Save R11 */
-			li		r11,T_ALIGNMENT					/* Set 'rupt code */
+			li		r11,T_ALIGNMENT|T_FAM			/* Set 'rupt code */
 			b		.L_exception_entry				/* Join common... */
 
 /*
@@ -185,7 +292,20 @@ resetexc:
 .L_handler700:
 			mtsprg	2,r13							/* Save R13 */
 			mtsprg	3,r11							/* Save R11 */
-			li		r11,T_PROGRAM					/* Set 'rupt code */
+			
+#if 0
+			mfsrr1	r13								; (BRINGUP)
+			mfcr	r11								; (BRINGUP)
+			rlwinm.	r13,r13,0,12,12					; (BRINGUP)	
+			crmove	cr1_eq,cr0_eq					; (BRINGUP)
+			mfsrr1	r13								; (BRINGUP)
+			rlwinm.	r13,r13,0,MSR_PR_BIT,MSR_PR_BIT	; (BRINGUP)	
+			crorc	cr0_eq,cr1_eq,cr0_eq			; (BRINGUP)
+			bf--	cr0_eq,.						; (BRINGUP)
+			mtcrf	255,r11							; (BRINGUP)
+#endif
+		
+			li		r11,T_PROGRAM|T_FAM				/* Set 'rupt code */
 			b		.L_exception_entry				/* Join common... */
 
 /*
@@ -233,29 +353,6 @@ resetexc:
 			li		r11,T_RESERVED					/* Set 'rupt code */
 			b		.L_exception_entry				/* Join common... */
 
-#if 0
-hackxxxx1:
-			stmw	r29,4(br0)
-			lwz		r29,0(br0)
-			mr.		r29,r29
-			bne+	xxxx1
-			lis		r29,0x4000
-
-xxxx1:			
-			stw		r0,0(r29)
-			mfsrr0	r30
-			stw		r30,4(r29)
-			mtlr	r30
-			stw		r30,8(r29)
-
-			addi	r29,r29,12
-			stw		r29,0(br0)
-
-			lmw		r29,4(br0)
-			b		hackxxxx2
-#endif			
-
-
 ;
 ; 			System call - generated by the sc instruction
 ;
@@ -265,7 +362,7 @@ xxxx1:
 ;				0xFFFFFFFE - BlueBox only - kcNKIsPreemptiveTaskEnv
 ;				0x00007FF2 - User state only - thread info
 ;				0x00007FF3 - User state only - floating point / vector facility status
-;				0x00007FF4 - Kernel only - loadMSR
+;				0x00007FF4 - Kernel only - loadMSR - not used on 64-bit machines
 ;
 ;			Note: none handled if virtual machine is running
 ;				  Also, it we treat SCs as kernel SCs if the RI bit is set
@@ -273,80 +370,108 @@ xxxx1:
 
 			. = 0xC00
 .L_handlerC00:
+			mtsprg	3,r11							; Save R11
+			mfsprg	r11,2							; Get the feature flags
+
 			mtsprg	2,r13							; Save R13
+			rlwinm	r11,r11,pf64Bitb-4,4,4			; Get the 64-bit flag
 			mfsrr1	r13								; Get SRR1 for loadMSR
-			mtsprg	3,r11							; Save R11
-			rlwimi	r13,r13,MSR_PR_BIT,0,0			; Move PR bit to non-volatile CR0 bit 0
-			mfcr	r11								; Save the CR
-			mtcrf	0x81,r13						; Get the moved PR and the RI for testing
-			crnot	0,0								; Get !PR
-			cror	0,0,MSR_RI_BIT					; See if we have !PR or RI
-			mfsprg	r13,0							; Get the per_proc_area
-			bt-		0,uftInKern						; We are in the kernel...
-			
-			cmplwi	cr5,r0,0x7FF2					; Ultra fast path cthread info call?
-			cmpwi	cr6,r0,0x7FF3					; Ultra fast path facility status?
-			cror	cr1_eq,cr5_lt,cr6_gt			; Set true if not 0x7FF2 and not 0x7FF3 and not negative
-			lwz		r13,spcFlags(r13)				; Get the special flags
-			bt-		cr1_eq,notufp					; Exit if we can not be ultra fast...
-			
-			rlwimi	r13,r13,runningVMbit+1,31,31	; Move VM flag after the 3 blue box flags
-			not.	r0,r0							; Flip bits and kind of subtract 1			
-			mtcrf	1,r13							; Set BB and VMM flags in CR7
-
-			cmplwi	cr1,r0,1						; Is this a bb fast path?
-			not		r0,r0							; Restore to entry state			
-			bt-		31,notufp						; No fast paths if running VM (assume not)...
-			bf-		bbNoMachSCbit,ufpUSuft			; We are not running BlueBox...
-			bgt		cr1,notufp						; This can not be a bb ufp...
-#if 0
-			b		hackxxxx1
-hackxxxx2:
-#endif			
-			
-			rlwimi	r11,r13,bbPreemptivebit-cr0_eq,cr0_eq,cr0_eq	; Copy preemptive task flag into user cr0_eq
-			mfsprg	r13,0							; Get back pre_proc
+			rlwimi	r11,r13,MSR_PR_BIT-5,5,5		; Move the PR bit to bit 1
+			mfcr	r13								; Save the CR
 			
+			mtcrf	0x40,r11						; Get the top 3 CR bits to 64-bit, PR, sign
 			
-			bne		cr1,ufpIsBBpre					; This is the "isPreemptiveTask" call...
+			cmpwi	r0,lo16(-3)						; Eliminate all negatives but -1 and -2
+			mfsprg	r11,0							; Get the per_proc
+			bf--	5,uftInKern						; We came from the kernel...		
+			ble--	notufp							; This is a mach call			
+
+			lwz		r11,spcFlags(r11)				; Pick up the special flags
+
+			cmpwi	cr7,r0,lo16(-1)					; Is this a BlueBox call?
+			cmplwi	cr2,r0,0x7FF2					; Ultra fast path cthread info call?
+			cmplwi	cr3,r0,0x7FF3					; Ultra fast path facility status?
+			cror	cr4_eq,cr2_eq,cr3_eq			; Is this one of the two ufts we handle here?
 			
-			lwz		r0,ppbbTaskEnv(r13)				; Get the shadowed taskEnv from per_proc_area
+			ble--	cr7,uftBBCall					; We think this is blue box call...
 
-ufpIsBBpre:	
-			mtcrf	0xFF,r11						; Restore CR
-			mfsprg	r11,3							; Restore R11
-			mfsprg	r13,2							; Restore R13
-			rfi										; All done, go back...
+			rlwinm	r11,r11,16,16,31				; Extract spcFlags upper bits
+			andi.	r11,r11,hi16(runningVM|FamVMena|FamVMmode)
+			cmpwi	cr0,r11,hi16(runningVM|FamVMena|FamVMmode)	; Test in VM FAM
+			beq--	cr0,ufpVM						; fast paths running VM ...
 			
+			bne--	cr4_eq,notufp					; Bail ifthis is not a uft...
+
 ;
-;			Normal fast path...
+;			Handle normal user ultra-fast trap
 ;
+
+			li		r3,spcFlags						; Assume facility status - 0x7FF3
+
+			beq--	cr3,uftFacStat					; This is a facilities status call...
 	
-ufpUSuft:	bge+	notufp							; Bail if negative...  (ARRRGGG -- BRANCH TO A BRANCH!!!!!)
+			li		r3,UAW							; This is really a thread info call - 0x7FF2		
+			
+uftFacStat:	mfsprg	r11,0							; Get the per_proc
+			lwzx	r3,r11,r3						; Get the UAW or spcFlags field
+			
+uftExit:	bt++	4,uftX64						; Go do the 64-bit exit...
+			
+			lwz		r11,pfAvailable(r11)			; Get the feature flags
+			mtcrf	255,r13							; Restore the CRs
+			mfsprg	r13,2							; Restore R13
+			mtsprg	2,r11							; Set the feature flags
 			mfsprg	r11,3							; Restore R11
-			mfsprg	r3,0							; Get the per_proc_area
+
+			rfi										; Back to our guy...
+			
+uftX64:		mtspr	hsprg0,r14						; Save a register
+			
+			lwz		r14,UAW(r11)					; Get the User Assist Word
+			lwz		r11,pfAvailable(r11)			; Get the feature flags
+			
+			mtcrf	255,r13							; Restore the CRs
+			
 			mfsprg	r13,2							; Restore R13
-			bne-	cr5,isvecfp						; This is the facility stat call
-			lwz		r3,UAW(r3)						; Get the assist word
-			rfi										; All done, scream back... (no need to restore CR or R11, they are volatile)
-;
-isvecfp:	lwz		r3,spcFlags(r3)					; Get the facility status
-			rfi										; Bail back...
+			mtsprg	2,r11							; Set the feature flags
+			mfsprg	r11,3							; Restore R11
+			mtsprg	3,r14							; Set the UAW in sprg3
+			mfspr	r14,hsprg0						; Restore R14
+
+			rfid									; Back to our guy...
+			
 ;
-notufp:		mtcrf	0xFF,r11						; Restore the used CRs
-			li		r11,T_SYSTEM_CALL				; Set interrupt code
-			b		.L_exception_entry				; Join common...
+;			Handle BlueBox ultra-fast trap
+;			
+
+uftBBCall:	andi.	r11,r11,bbNoMachSC|bbPreemptive	; Clear what we do not need
+			cmplwi	r11,bbNoMachSC					; See if we are trapping syscalls
+			blt--	notufp							; No...
+			
+			rlwimi	r13,r11,bbPreemptivebit-cr0_eq,cr0_eq,cr0_eq	; Copy preemptive task flag into user cr0_eq
+
+			mfsprg	r11,0							; Get the per proc
 			
+			beq++	cr7,uftExit						; For MKIsPreemptiveTask we are done...
+
+			lwz		r0,ppbbTaskEnv(r11)				; Get the shadowed taskEnv from per_proc_area
+			b		uftExit							; We are really all done now...
+
+;			Kernel ultra-fast trap
+
 uftInKern:	cmplwi	r0,0x7FF4						; Ultra fast path loadMSR?
 			bne-	notufp							; Someone is trying to cheat...
-			
-			mtcrf	0xFF,r11						; Restore CR
-			lwz		r11,pfAvailable(r13)			; Pick up the feature flags
+
 			mtsrr1	r3								; Set new MSR
-			mfsprg	r13,2							; Restore R13
-			mtsprg	2,r11							; Set the feature flags into sprg2
-			mfsprg	r11,3							; Restore R11
-			rfi										; Blast back
+			
+			b		uftExit							; Go load the new MSR...
+			
+notufp:		mtcrf	0xFF,r13						; Restore the used CRs
+			li		r11,T_SYSTEM_CALL|T_FAM			; Set interrupt code
+			b		.L_exception_entry				; Join common...
+
+
+			
 			
 
 /*
@@ -367,55 +492,73 @@ uftInKern:	cmplwi	r0,0x7FF4						; Ultra fast path loadMSR?
 
 			. = 0xD00
 .L_handlerD00:
-			mtsprg	2,r13							; Save R13
 			mtsprg	3,r11							; Save R11
-			mfsrr1	r13								; Get the old MSR
-			mfcr	r11								; Get the CR
-			rlwinm.	r13,r13,0,MSR_PR_BIT,MSR_PR_BIT	; Are we in supervisor state?
-			beq-	notspectr						; Yes, not special trace...
-			mfsprg	r13,0							; Get the per_proc area
-			lhz		r13,PP_CPU_FLAGS(r13)			; Get the flags
-			rlwinm.	r13,r13,0,traceBEb+16,traceBEb+16	; Special trace enabled?
-			bne+	specbrtr						; Yeah...
-
-notspectr:	mtcr	r11								; Restore CR
-			li		r11,T_TRACE						; Set interrupt code
+			mfsprg	r11,2							; Get the feature flags
+			mtsprg	2,r13							; Save R13
+			rlwinm	r11,r11,pf64Bitb-4,4,4			; Get the 64-bit flag
+			mfcr	r13								; Get the CR
+			mtcrf	0x40,r11						; Set the CR
+			mfsrr1	r11								; Get the old MSR
+			rlwinm.	r11,r11,0,MSR_PR_BIT,MSR_PR_BIT	; Are we in supervisor state?
+			
+			mfsprg	r11,0							; Get the per_proc
+			lhz		r11,PP_CPU_FLAGS(r11)			; Get the flags
+			crmove	cr1_eq,cr0_eq					; Remember if we are in supervisor state
+			rlwinm.	r11,r11,0,traceBEb+16,traceBEb+16	; Special trace enabled?
+			cror	cr0_eq,cr0_eq,cr1_eq			; Is trace off or supervisor state?
+			bf--	cr0_eq,specbrtr					; No, we need to trace...
+
+notspectr:	mtcr	r13								; Restore CR
+			li		r11,T_TRACE|T_FAM				; Set interrupt code
 			b		.L_exception_entry				; Join common...
 
+			.align	5
+
 ;
 ;			We are doing the special branch trace
 ;
 
-specbrtr:	mfsprg	r13,0							; Get the per_proc area
-			stw		r1,emfp0(r13)					; Save in a scratch area
-			stw		r2,emfp0+4(r13)					; Save in a scratch area
-			stw		r3,emfp0+8(r13)					; Save in a scratch area
-
-			lis		r2,hi16(EXT(pc_trace_buf))		; Get the top of the buffer
-			lwz		r3,spcTRp(r13)					; Pick up buffer position			
-			mr.		r1,r1							; Is it time to count?
+specbrtr:	mfsprg	r11,0							; Get the per_proc area
+			bt++	4,sbxx64a						; Jump if 64-bit...
+			
+			stw		r1,tempr0+4(r11)				; Save in a scratch area
+			stw		r2,tempr1+4(r11)				; Save in a scratch area
+			stw		r3,tempr2+4(r11)				; Save in a scratch area
+			b		sbxx64b							; Skip...
+			
+sbxx64a:	std		r1,tempr0(r11)					; Save in a scratch area
+			std		r2,tempr1(r11)					; Save in a scratch area
+			std		r3,tempr2(r11)					; Save in a scratch area
+			
+sbxx64b:	lis		r2,hi16(EXT(pc_trace_buf))		; Get the top of the buffer
+			lwz		r3,spcTRp(r11)					; Pick up buffer position			
 			ori		r2,r2,lo16(EXT(pc_trace_buf))	; Get the bottom of the buffer
-			cmplwi	cr1,r3,4092						; Set cr1_eq if we should take exception			
+			cmplwi	cr2,r3,4092						; Set cr1_eq if we should take exception			
 			mfsrr0	r1								; Get the pc
 			stwx	r1,r2,r3						; Save it in the buffer
 			addi	r3,r3,4							; Point to the next slot
 			rlwinm	r3,r3,0,20,31					; Wrap the slot at one page
-			stw		r3,spcTRp(r13)					; Save the new slot
-			lwz		r1,emfp0(r13)					; Restore work register
-			lwz		r2,emfp0+4(r13)					; Restore work register
-			lwz		r3,emfp0+8(r13)					; Restore work register
-			beq		cr1,notspectr					; Buffer filled, make a rupt...
-			
-			mtcr	r11								; Restore the CR
-			mfsprg	r13,2							; Restore R13
-			mfsprg	r11,3							; Restore R11
-			rfi										; Bail back...
+			stw		r3,spcTRp(r11)					; Save the new slot
+
+			bt++	4,sbxx64c						; Jump if 64-bit...
+
+			lwz		r1,tempr0+4(r11)				; Restore work register
+			lwz		r2,tempr1+4(r11)				; Restore work register
+			lwz		r3,tempr2+4(r11)				; Restore work register
+			beq		cr2,notspectr					; Buffer filled, make a rupt...
+			b		uftExit							; Go restore and leave...
+
+sbxx64c:	ld		r1,tempr0(r11)					; Restore work register
+			ld		r2,tempr1(r11)					; Restore work register
+			ld		r3,tempr2(r11)					; Restore work register
+			beq		cr2,notspectr					; Buffer filled, make a rupt...
+			b		uftExit							; Go restore and leave...
 
 /*
  * 			Floating point assist
  */
 
-			. = 0xe00
+			. = 0xE00
 .L_handlerE00:
 			mtsprg	2,r13							/* Save R13 */
 			mtsprg	3,r11							/* Save R11 */
@@ -448,329 +591,43 @@ VMXhandler:
 
 	
 
-/*
- * Instruction translation miss - we inline this code.
- * Upon entry (done for us by the machine):
- *     srr0 :	 addr of instruction that missed
- *     srr1 :	 bits 0-3   = saved CR0
- *                    4     = lru way bit
- *                    16-31 = saved msr
- *     msr[tgpr] = 1  (so gpr0-3 become our temporary variables)
- *     imiss:	 ea that missed
- *     icmp :	 the compare value for the va that missed
- *     hash1:	 pointer to first hash pteg
- *     hash2:	 pointer to 2nd hash pteg
- *
- * Register usage:
- *     tmp0:	 saved counter
- *     tmp1:	 junk
- *     tmp2:	 pointer to pteg
- *     tmp3:	 current compare value
- *
- * This code is taken from the 603e User's Manual with
- * some bugfixes and minor improvements to save bytes and cycles
- *
- *	NOTE: Do not touch sprg2 in here
- */
+;
+;			Instruction translation miss exception - not supported
+;
 
-	. = 0x1000
+ 			. = 0x1000
 .L_handler1000:
-	mfspr	tmp2,	hash1
-	mfctr	tmp0				/* use tmp0 to save ctr */
-	mfspr	tmp3,	icmp
-
-.L_imiss_find_pte_in_pteg:
-	li	tmp1,	8			/* count */
-	subi	tmp2,	tmp2,	8		/* offset for lwzu */
-	mtctr	tmp1				/* count... */
-	
-.L_imiss_pteg_loop:
-	lwz	tmp1,	8(tmp2)			/* check pte0 for match... */
-	addi	tmp2,	tmp2,	8
-	cmpw	cr0,	tmp1,	tmp3
-#if 0	
-	bdnzf+	cr0,	.L_imiss_pteg_loop
-#else	
-	bc	0,2,	.L_imiss_pteg_loop
-#endif	
-	beq+	cr0,	.L_imiss_found_pte
-
-	/* Not found in PTEG, we must scan 2nd then give up */
-
-	andi.	tmp1,	tmp3,	MASK(PTE0_HASH_ID)
-	bne-	.L_imiss_do_no_hash_exception		/* give up */
-
-	mfspr	tmp2,	hash2
-	ori	tmp3,	tmp3,	MASK(PTE0_HASH_ID)
-	b	.L_imiss_find_pte_in_pteg
-
-.L_imiss_found_pte:
-
-	lwz	tmp1,	4(tmp2)				/* get pte1_t */
-	andi.	tmp3,	tmp1,	MASK(PTE1_WIMG_GUARD)	/* Fault? */
-	bne-	.L_imiss_do_prot_exception		/* Guarded - illegal */
-
-	/* Ok, we've found what we need to, restore and rfi! */
-
-	mtctr	tmp0					/* restore ctr */
-	mfsrr1	tmp3
-	mfspr	tmp0,	imiss
-	mtcrf	0x80,	tmp3				/* Restore CR0 */
-	mtspr	rpa,	tmp1				/* set the pte */
-	ori	tmp1,	tmp1,	MASK(PTE1_REFERENCED)	/* set referenced */
-	tlbli	tmp0
-	sth	tmp1,	6(tmp2)
-	rfi
-	
-.L_imiss_do_prot_exception:
-	/* set up srr1 to indicate protection exception... */
-	mfsrr1	tmp3
-	andi.	tmp2,	tmp3,	0xffff
-	addis	tmp2,	tmp2,	MASK(SRR1_TRANS_PROT) >> 16
-	b	.L_imiss_do_exception
-	
-.L_imiss_do_no_hash_exception:
-	/* clean up registers for protection exception... */
-	mfsrr1	tmp3
-	andi.	tmp2,	tmp3,	0xffff
-	addis	tmp2,	tmp2,	MASK(SRR1_TRANS_HASH) >> 16
-	
-	/* And the entry into the usual instruction fault handler ... */
-.L_imiss_do_exception:
-
-	mtctr	tmp0					/* Restore ctr */
-	mtsrr1	tmp2					/* Set up srr1 */
-	mfmsr	tmp0					
-	xoris	tmp0,	tmp0,	MASK(MSR_TGPR)>>16	/* no TGPR */
-	mtcrf	0x80,	tmp3				/* Restore CR0 */
-	mtmsr	tmp0					/* reset MSR[TGPR] */
-	b	.L_handler400				/* Instr Access */
+			mtsprg	2,r13							; Save R13
+			mtsprg	3,r11							; Save R11
+			li		r11,T_INVALID_EXCP0				; Set rupt code
+			b		.L_exception_entry				; Join common...
+
 	
-/*
- * Data load translation miss
- *
- * Upon entry (done for us by the machine):
- *     srr0 :	 addr of instruction that missed
- *     srr1 :	 bits 0-3   = saved CR0
- *                    4     = lru way bit
- *                    5     = 1 if store
- *                    16-31 = saved msr
- *     msr[tgpr] = 1  (so gpr0-3 become our temporary variables)
- *     dmiss:	 ea that missed
- *     dcmp :	 the compare value for the va that missed
- *     hash1:	 pointer to first hash pteg
- *     hash2:	 pointer to 2nd hash pteg
- *
- * Register usage:
- *     tmp0:	 saved counter
- *     tmp1:	 junk
- *     tmp2:	 pointer to pteg
- *     tmp3:	 current compare value
- *
- * This code is taken from the 603e User's Manual with
- * some bugfixes and minor improvements to save bytes and cycles
- *
- *	NOTE: Do not touch sprg2 in here
- */
 
-	. = 0x1100
+;
+;			Data load translation miss exception - not supported
+;
+
+ 			. = 0x1100
 .L_handler1100:
-	mfspr	tmp2,	hash1
-	mfctr	tmp0				/* use tmp0 to save ctr */
-	mfspr	tmp3,	dcmp
-
-.L_dlmiss_find_pte_in_pteg:
-	li	tmp1,	8			/* count */
-	subi	tmp2,	tmp2,	8		/* offset for lwzu */
-	mtctr	tmp1				/* count... */
-	
-.L_dlmiss_pteg_loop:
-	lwz	tmp1,	8(tmp2)			/* check pte0 for match... */
-	addi	tmp2,	tmp2,	8
-	cmpw	cr0,	tmp1,	tmp3
-#if 0 /* How to write this correctly? */	
-	bdnzf+	cr0,	.L_dlmiss_pteg_loop
-#else	
-	bc	0,2,	.L_dlmiss_pteg_loop
-#endif	
-	beq+	cr0,	.L_dmiss_found_pte
-
-	/* Not found in PTEG, we must scan 2nd then give up */
-
-	andi.	tmp1,	tmp3,	MASK(PTE0_HASH_ID)	/* already at 2nd? */
-	bne-	.L_dmiss_do_no_hash_exception		/* give up */
-
-	mfspr	tmp2,	hash2
-	ori	tmp3,	tmp3,	MASK(PTE0_HASH_ID)
-	b	.L_dlmiss_find_pte_in_pteg
-
-.L_dmiss_found_pte:
-
-	lwz	tmp1,	4(tmp2)				/* get pte1_t */
-
-	/* Ok, we've found what we need to, restore and rfi! */
-
-	mtctr	tmp0					/* restore ctr */
-	mfsrr1	tmp3
-	mfspr	tmp0,	dmiss
-	mtcrf	0x80,	tmp3				/* Restore CR0 */
-	mtspr	rpa,	tmp1				/* set the pte */
-	ori	tmp1,	tmp1,	MASK(PTE1_REFERENCED)	/* set referenced */
-	tlbld	tmp0					/* load up tlb */
-	sth	tmp1,	6(tmp2)				/* sth is faster? */
-	rfi
-	
-	/* This code is shared with data store translation miss */
-	
-.L_dmiss_do_no_hash_exception:
-	/* clean up registers for protection exception... */
-	mfsrr1	tmp3
-	/* prepare to set DSISR_WRITE_BIT correctly from srr1 info */
-	rlwinm	tmp1,	tmp3,	9,	6,	6
-	addis	tmp1,	tmp1,	MASK(DSISR_HASH) >> 16
-
-	/* And the entry into the usual data fault handler ... */
-
-	mtctr	tmp0					/* Restore ctr */
-	andi.	tmp2,	tmp3,	0xffff			/* Clean up srr1 */
-	mtsrr1	tmp2					/* Set srr1 */
-	mtdsisr	tmp1
-	mfspr	tmp2,	dmiss
-	mtdar	tmp2
-	mfmsr	tmp0
-	xoris	tmp0,	tmp0,	MASK(MSR_TGPR)>>16	/* no TGPR */
-	mtcrf	0x80,	tmp3				/* Restore CR0 */
-	sync						/* Needed on some */
-	mtmsr	tmp0					/* reset MSR[TGPR] */
-	b	.L_handler300				/* Data Access */
+			mtsprg	2,r13							; Save R13
+			mtsprg	3,r11							; Save R11
+			li		r11,T_INVALID_EXCP1				; Set rupt code
+			b		.L_exception_entry				; Join common...
+
 	
-/*
- * Data store translation miss (similar to data load)
- *
- * Upon entry (done for us by the machine):
- *     srr0 :	 addr of instruction that missed
- *     srr1 :	 bits 0-3   = saved CR0
- *                    4     = lru way bit
- *                    5     = 1 if store
- *                    16-31 = saved msr
- *     msr[tgpr] = 1  (so gpr0-3 become our temporary variables)
- *     dmiss:	 ea that missed
- *     dcmp :	 the compare value for the va that missed
- *     hash1:	 pointer to first hash pteg
- *     hash2:	 pointer to 2nd hash pteg
- *
- * Register usage:
- *     tmp0:	 saved counter
- *     tmp1:	 junk
- *     tmp2:	 pointer to pteg
- *     tmp3:	 current compare value
- *
- * This code is taken from the 603e User's Manual with
- * some bugfixes and minor improvements to save bytes and cycles
- *
- *	NOTE: Do not touch sprg2 in here
- */
 
-	. = 0x1200
+;
+;			Data store translation miss exception - not supported
+;
+
+ 			. = 0x1200
 .L_handler1200:
-	mfspr	tmp2,	hash1
-	mfctr	tmp0				/* use tmp0 to save ctr */
-	mfspr	tmp3,	dcmp
-
-.L_dsmiss_find_pte_in_pteg:
-	li	tmp1,	8			/* count */
-	subi	tmp2,	tmp2,	8		/* offset for lwzu */
-	mtctr	tmp1				/* count... */
-	
-.L_dsmiss_pteg_loop:
-	lwz	tmp1,	8(tmp2)			/* check pte0 for match... */
-	addi	tmp2,	tmp2,	8
-
-		cmpw	cr0,	tmp1,	tmp3
-#if 0 /* I don't know how to write this properly */	
-	bdnzf+	cr0,	.L_dsmiss_pteg_loop
-#else	
-	bc	0,2,	.L_dsmiss_pteg_loop
-#endif	
-	beq+	cr0,	.L_dsmiss_found_pte
-
-	/* Not found in PTEG, we must scan 2nd then give up */
-
-	andi.	tmp1,	tmp3,	MASK(PTE0_HASH_ID)	/* already at 2nd? */
-	bne-	.L_dmiss_do_no_hash_exception		/* give up */
-
-	mfspr	tmp2,	hash2
-	ori	tmp3,	tmp3,	MASK(PTE0_HASH_ID)
-	b	.L_dsmiss_find_pte_in_pteg
-
-.L_dsmiss_found_pte:
-
-	lwz	tmp1,	4(tmp2)				/* get pte1_t */
-	andi.	tmp3,	tmp1,	MASK(PTE1_CHANGED)	/* unchanged, check? */
-	beq-	.L_dsmiss_check_prot			/* yes, check prot */
-
-.L_dsmiss_resolved:
-	/* Ok, we've found what we need to, restore and rfi! */
-
-	mtctr	tmp0					/* restore ctr */
-	mfsrr1	tmp3
-	mfspr	tmp0,	dmiss
-	mtcrf	0x80,	tmp3				/* Restore CR0 */
-	mtspr	rpa,	tmp1				/* set the pte */
-	tlbld	tmp0					/* load up tlb */
-	rfi
-	
-.L_dsmiss_check_prot:
-	/* PTE is unchanged, we must check that we can write */
-	rlwinm.	tmp3,	tmp1,	30,	0,	1	/* check PP[1] */
-	bge-	.L_dsmiss_check_prot_user_kern
-	andi.	tmp3,	tmp1,	1			/* check PP[0] */
-	beq+	.L_dsmiss_check_prot_ok
-	
-.L_dmiss_do_prot_exception:
-	/* clean up registers for protection exception... */
-	mfsrr1	tmp3
-	/* prepare to set DSISR_WRITE_BIT correctly from srr1 info */
-	rlwinm	tmp1,	tmp3,	9,	6,	6
-	addis	tmp1,	tmp1,	MASK(DSISR_PROT) >> 16
-
-	/* And the entry into the usual data fault handler ... */
-
-	mtctr	tmp0					/* Restore ctr */
-	andi.	tmp2,	tmp3,	0xffff			/* Clean up srr1 */
-	mtsrr1	tmp2					/* Set srr1 */
-	mtdsisr	tmp1
-	mfspr	tmp2,	dmiss
-	mtdar	tmp2
-	mfmsr	tmp0
-	xoris	tmp0,	tmp0,	MASK(MSR_TGPR)>>16	/* no TGPR */
-	mtcrf	0x80,	tmp3				/* Restore CR0 */
-	sync						/* Needed on some */
-	mtmsr	tmp0					/* reset MSR[TGPR] */
-	b	.L_handler300				/* Data Access */
-	
-/* NB - if we knew we were on a 603e we could test just the MSR_KEY bit */
-.L_dsmiss_check_prot_user_kern:
-	mfsrr1	tmp3
-	andi.	tmp3,	tmp3,	MASK(MSR_PR)
-	beq+	.L_dsmiss_check_prot_kern
-	mfspr	tmp3,	dmiss				/* check user privs */
-	mfsrin	tmp3,	tmp3				/* get excepting SR */
-	andis.	tmp3,	tmp3,	0x2000			/* Test SR ku bit */
-	beq+	.L_dsmiss_check_prot_ok
-	b	.L_dmiss_do_prot_exception
-
-.L_dsmiss_check_prot_kern:
-	mfspr	tmp3,	dmiss				/* check kern privs */
-	mfsrin	tmp3,	tmp3
-	andis.	tmp3,	tmp3,	0x4000			/* Test SR Ks bit */
-	bne-	.L_dmiss_do_prot_exception
-
-.L_dsmiss_check_prot_ok:
-	/* Ok, mark as referenced and changed before resolving the fault */
-	ori	tmp1,	tmp1,	(MASK(PTE1_REFERENCED)|MASK(PTE1_CHANGED))
-	sth	tmp1,	6(tmp2)
-	b	.L_dsmiss_resolved
+			mtsprg	2,r13							; Save R13
+			mtsprg	3,r11							; Save R11
+			li		r11,T_INVALID_EXCP2				; Set rupt code
+			b		.L_exception_entry				; Join common...
+
 	
 /*
  * 			Instruction address breakpoint
@@ -794,8 +651,20 @@ VMXhandler:
 			li		r11,T_SYSTEM_MANAGEMENT			/* Set 'rupt code */
 			b		.L_exception_entry				/* Join common... */
 
+
+/*
+ * 			Soft Patch
+ */
+
+			. = 0x1500
+.L_handler1500:
+			mtsprg	2,r13							/* Save R13 */
+			mtsprg	3,r11							/* Save R11 */
+			li		r11,T_SOFT_PATCH				/* Set 'rupt code */
+			b		.L_exception_entry				/* Join common... */
+
 ;
-; 			Altivec Java Mode Assist interrupt
+; 			Altivec Java Mode Assist interrupt or Maintenace interrupt
 ;
 
 			. = 0x1600
@@ -806,7 +675,7 @@ VMXhandler:
 			b		.L_exception_entry				/* Join common... */
 
 ;
-; 			Thermal interruption
+; 			Altivec Java Mode Assist interrupt or Thermal interruption 
 ;
 
 			. = 0x1700
@@ -816,21 +685,46 @@ VMXhandler:
 			li		r11,T_THERMAL					/* Set 'rupt code */
 			b		.L_exception_entry				/* Join common... */
 
+;
+; 			Thermal interruption - 64-bit
+;
+
+			. = 0x1800
+.L_handler1800:
+			mtsprg	2,r13							/* Save R13 */
+			mtsprg	3,r11							/* Save R11 */
+			li		r11,T_ARCHDEP0					/* Set 'rupt code */
+			b		.L_exception_entry				/* Join common... */
+
 /*
  * There is now a large gap of reserved traps
  */
 
 /*
- * 			Run mode/ trace exception - single stepping on 601 processors
+ * 			Instrumentation interruption
  */
 
 			. = 0x2000
 .L_handler2000:
 			mtsprg	2,r13							/* Save R13 */
 			mtsprg	3,r11							/* Save R11 */
-			li		r11,T_RUNMODE_TRACE				/* Set 'rupt code */
+			li		r11,T_INSTRUMENTATION			/* Set 'rupt code */
 			b		.L_exception_entry				/* Join common... */
 
+			. = 0x2100
+
+/*
+ *	Filter Ultra Fast Path syscalls for VMM
+ */
+ufpVM:
+			cmpwi	cr2,r0,0x6004					; Is it vmm_dispatch
+			bne		cr2,notufp						; Exit If not
+			cmpwi	cr5,r3,kvmmResumeGuest			; Compare r3 with kvmmResumeGuest
+			cmpwi	cr2,r3,kvmmSetGuestRegister		; Compare r3 with kvmmSetGuestRegister
+			cror	cr1_eq,cr5_lt,cr2_gt			; Set true if out of VMM Fast syscall range
+			bt-		cr1_eq,notufp					; Exit if out of range
+			b		EXT(vmm_ufp)					; Ultra Fast Path syscall
+
 /*
  * .L_exception_entry(type)
  *
@@ -865,20 +759,28 @@ EXT(exception_entry):
  *	Note that if we are attempting to sleep (as opposed to nap or doze) all interruptions
  *	are ignored.
  */
-			mfsprg  r13,0							/* Load per_proc */     
-			lwz		r13,next_savearea(r13)			/* Get the exception save area */
 
-			stw		r1,saver1(r13)					; Save register 1
-			stw		r0,saver0(r13)					; Save register 0
-			dcbtst	0,r13							; We will need this in a bit
+
+			.globl	EXT(extPatch32)						
+			
+
+LEXT(extPatch32)
+			b		extEntry64						; Go do 64-bit (patched out for 32-bit)
+			mfsprg  r13,0							; Load per_proc
+			lwz		r13,next_savearea+4(r13)		; Get the exception save area
+			stw		r0,saver0+4(r13)				; Save register 0
+			stw		r1,saver1+4(r13)				; Save register 1
+
 			mfspr	r1,hid0							; Get HID0
-			mfcr	r0								; Save the CR
-			mtcrf	255,r1							; Get set to test for cache and sleep
+			mfcr	r0								; Save the whole CR
+			
+			mtcrf	0x20,r1							; Get set to test for sleep
+			cror	doze,doze,nap					; Remember if we are napping
 			bf		sleep,notsleep					; Skip if we are not trying to sleep
 			
-			mtcrf	255,r0							; Restore the CR
-			lwz		r0,saver0(r13)					; Restore R0
-			lwz		r1,saver1(r13)					; Restore R1
+			mtcrf	0x20,r0							; Restore the CR
+			lwz		r0,saver0+4(r13)				; Restore R0
+			lwz		r1,saver1+4(r13)				; Restore R1
 			mfsprg	r13,0							; Get the per_proc 
 			lwz		r11,pfAvailable(r13)			; Get back the feature flags
 			mfsprg	r13,2							; Restore R13
@@ -894,53 +796,93 @@ EXT(exception_entry):
 			.long	0
 			.long	0
 			
+
+;
+;			This is the 32-bit context saving stuff
+;
+
 			.align	5
 						
-notsleep:	stw		r2,saver2(r13)					; Save this one
-			crmove	featL1ena,dce					; Copy the cache enable bit
+notsleep:	stw		r2,saver2+4(r13)				; Save this one
+			bf		doze,notspdo					; Skip the next if we are not napping/dozing...
 			rlwinm	r2,r1,0,nap+1,doze-1			; Clear any possible nap and doze bits
 			mtspr	hid0,r2							; Clear the nap/doze bits
-			cmplw	r2,r1							; See if we were napping
-			la		r1,saver8(r13)					; Point to the next line in case we need it
-			crnot	wasNapping,cr0_eq				; Remember if we were napping
+notspdo:
+
+#if INSTRUMENT
+			mfspr	r2,pmc1							; INSTRUMENT - saveinstr[0] - Take earliest possible stamp
+			stw		r2,0x6100+(0x00*16)+0x0(0)		; INSTRUMENT - Save it
+			mfspr	r2,pmc2							; INSTRUMENT - Get stamp
+			stw		r2,0x6100+(0x00*16)+0x4(0)		; INSTRUMENT - Save it
+			mfspr	r2,pmc3							; INSTRUMENT - Get stamp
+			stw		r2,0x6100+(0x00*16)+0x8(0)		; INSTRUMENT - Save it
+			mfspr	r2,pmc4							; INSTRUMENT - Get stamp
+			stw		r2,0x6100+(0x00*16)+0xC(0)		; INSTRUMENT - Save it
+#endif			
+
+			la		r1,saver4(r13)					; Point to the next line in case we need it
+			crmove	wasNapping,doze					; Remember if we were napping
 			mfsprg	r2,0							; Get the per_proc area
-			bf-		featL1ena,skipz1				; L1 cache is disabled...
-			dcbz	0,r1							; Reserve our line in cache
+			dcbz	0,r1							; allocate r4-r7 32-byte line in cache
 			
 ;
 ;			Remember, we are setting up CR6 with feature flags
 ;
-skipz1:		lwz		r1,pfAvailable(r2)				; Get the CPU features flags			
-			stw		r3,saver3(r13)					; Save this one
-			la		r3,savesrr0(r13)				; Point to the last line
-			mtcrf	0xE0,r1							; Put the features flags (that we care about) in the CR
-			stw		r4,saver4(r13)					; Save this one
-			stw		r6,saver6(r13)					; Save this one
-			crmove	featSMP,pfSMPcapb				; See if we have a PIR
-			stw		r8,saver8(r13)					; Save this one
+			andi.	r1,r11,T_FAM					; Check FAM bit
+	
+			stw		r3,saver3+4(r13)					; Save this one
+			stw		r4,saver4+4(r13)					; Save this one
+			andc	r11,r11,r1						; Clear FAM bit
+			beq+	noFAM							; Is it FAM intercept
+			mfsrr1	r3								; Load srr1
+			rlwinm.	r3,r3,0,MSR_PR_BIT,MSR_PR_BIT	; Are we trapping from supervisor state?
+			beq+	noFAM							; From supervisor state
+			lwz		r1,spcFlags(r2)					; Load spcFlags 
+			rlwinm	r1,r1,1+FamVMmodebit,30,31		; Extract FamVMenabit and FamVMmodebit
+			cmpwi	cr0,r1,2						; Check FamVMena set without FamVMmode
+			bne+	noFAM							; Can this context be FAM intercept
+			lwz		r4,FAMintercept(r2)				; Load exceptions mask to intercept
+			srwi	r1,r11,2						; divide r11 by 4
+			lis		r3,0x8000						; Set r3 to 0x80000000
+			srw		r1,r3,r1						; Set bit for current exception
+			and.	r1,r1,r4						; And current exception with the intercept mask
+			beq+	noFAM							; Is it FAM intercept
+			b		EXT(vmm_fam_exc)
+noFAM:
+			lwz		r1,pfAvailable(r2)				; Get the CPU features flags			
+			la		r3,saver8(r13)					; Point to line with r8-r11
+			mtcrf	0xE2,r1							; Put the features flags (that we care about) in the CR
+			dcbz	0,r3							; allocate r8-r11 32-byte line in cache
+            la		r3,saver12(r13)					; point to r12-r15 line
+			lis		r4,hi16(MASK(MSR_VEC)|MASK(MSR_FP)|MASK(MSR_ME))	; Set up the MSR we will use throughout. Note that ME come on here if MCK
+			stw		r6,saver6+4(r13)				; Save this one
+			ori		r4,r4,lo16(MASK(MSR_VEC)|MASK(MSR_FP)|MASK(MSR_ME))	; Rest of MSR
+			stw		r8,saver8+4(r13)				; Save this one
 			crmove	featAltivec,pfAltivecb			; Set the Altivec flag
+			mtmsr	r4								; Set MSR
+			isync
 			mfsrr0	r6								; Get the interruption SRR0 
-			stw		r8,saver8(r13)					; Save this one
-			bf-		featL1ena,skipz1a				; L1 cache is disabled...
-			dcbz	0,r3							; Reserve our line in cache
-skipz1a:	crmove	featFP,pfFloatb					; Remember that we have floating point
-			stw		r7,saver7(r13)					; Save this one
+            la		r8,savesrr0(r13)				; point to line with SRR0, SRR1, CR, XER, and LR
+			dcbz	0,r3							; allocate r12-r15 32-byte line in cache
+            la		r3,saver16(r13)					; point to next line
+			dcbz	0,r8							; allocate 32-byte line with SRR0, SRR1, CR, XER, and LR
+			stw		r7,saver7+4(r13)				; Save this one
 			lhz		r8,PP_CPU_FLAGS(r2)				; Get the flags
 			mfsrr1	r7								; Get the interrupt SRR1
 			rlwinm	r8,r8,(((31-MSR_BE_BIT)+(traceBEb+16+1))&31),MSR_BE_BIT,MSR_BE_BIT	; Set BE bit if special trace is on
-			stw		r6,savesrr0(r13)				; Save the SRR0 
+			stw		r6,savesrr0+4(r13)				; Save the SRR0 
 			rlwinm	r6,r7,(((31-MSR_BE_BIT)+(MSR_PR_BIT+1))&31),MSR_BE_BIT,MSR_BE_BIT	; Move PR bit to BE bit
-			stw		r5,saver5(r13)					; Save this one 
+			stw		r5,saver5+4(r13)				; Save this one 
 			and		r8,r6,r8						; Remove BE bit only if problem state and special tracing on
 			mfsprg	r6,2							; Get interrupt time R13
 			mtsprg	2,r1							; Set the feature flags
 			andc	r7,r7,r8						; Clear BE bit if special trace is on and PR is set
 			mfsprg	r8,3							; Get rupt time R11
-			stw		r7,savesrr1(r13)				; Save SRR1 
-			rlwinm.	r7,r7,MSR_RI_BIT,MSR_RI_BIT		; Is this a special case access fault?
-			stw		r6,saver13(r13)					; Save rupt R1
-			crnot	specAccess,cr0_eq				; Set that we are doing a special access if RI is set
-			stw		r8,saver11(r13)					; Save rupt time R11
+			stw		r7,savesrr1+4(r13)				; Save SRR1 
+			stw		r8,saver11+4(r13)				; Save rupt time R11
+			stw		r6,saver13+4(r13)				; Save rupt R13
+			dcbz	0,r3							; allocate 32-byte line with r16-r19
+            la		r3,saver20(r13)					; point to next line
 
 getTB:		mftbu	r6								; Get the upper timebase
 			mftb	r7								; Get the lower timebase
@@ -948,18 +890,26 @@ getTB:		mftbu	r6								; Get the upper timebase
 			cmplw	r6,r8							; Did the top tick?
 			bne-	getTB							; Yeah, need to get it again...
 
+#if INSTRUMENT
+			mfspr	r6,pmc1							; INSTRUMENT - saveinstr[1] - Save halfway context save stamp
+			stw		r6,0x6100+(0x01*16)+0x0(0)		; INSTRUMENT - Save it
+			mfspr	r6,pmc2							; INSTRUMENT - Get stamp
+			stw		r6,0x6100+(0x01*16)+0x4(0)		; INSTRUMENT - Save it
+			mfspr	r6,pmc3							; INSTRUMENT - Get stamp
+			stw		r6,0x6100+(0x01*16)+0x8(0)		; INSTRUMENT - Save it
+			mfspr	r6,pmc4							; INSTRUMENT - Get stamp
+			stw		r6,0x6100+(0x01*16)+0xC(0)		; INSTRUMENT - Save it
+#endif			
+
 			stw		r8,ruptStamp(r2)				; Save the top of time stamp
 			stw		r8,SAVtime(r13)					; Save the top of time stamp
-			la		r6,saver16(r13)					; Point to the next cache line
 			stw		r7,ruptStamp+4(r2)				; Save the bottom of time stamp
 			stw		r7,SAVtime+4(r13)				; Save the bottom of time stamp
 
-			bf-		featL1ena,skipz2				; L1 cache is disabled...
-			dcbz	0,r6							; Allocate in cache 
-skipz2:			
-			stw		r9,saver9(r13)					; Save this one
+			dcbz	0,r3							; allocate 32-byte line with r20-r23
+			stw		r9,saver9+4(r13)				; Save this one
 
-			stw		r10,saver10(r13)				; Save this one
+			stw		r10,saver10+4(r13)				; Save this one
 			mflr	r4								; Get the LR
 			mfxer	r10								; Get the XER
 			
@@ -977,175 +927,492 @@ skipz2:
 			adde	r8,r8,r5						; Add high and carry to total
 			stw		r6,napTotal+4(r2)				; Save the low total
 			stw		r8,napTotal(r2)					; Save the high total
-			stw		r3,savesrr0(r13)				; Modify to return to nap/doze exit
+			stw		r3,savesrr0+4(r13)				; Modify to return to nap/doze exit
 			
-			rlwinm.		r3,r1,0,pfSlowNapb,pfSlowNapb			; Should HID1 be restored?
+			rlwinm.	r3,r1,0,pfSlowNapb,pfSlowNapb	; Should HID1 be restored?
 			beq		notInSlowNap
 
 			lwz		r3,pfHID1(r2)					; Get saved HID1 value
-			mtspr		hid1, r3					; Restore HID1
+			mtspr	hid1,r3							; Restore HID1
 
 notInSlowNap:
-			rlwinm.		r3,r1,0,pfNoL2PFNapb,pfNoL2PFNapb		; Should MSSCR0 be restored?
+			rlwinm.	r3,r1,0,pfNoL2PFNapb,pfNoL2PFNapb	; Should MSSCR0 be restored?
 			beq		notNapping
 
 			lwz		r3,pfMSSCR0(r2)					; Get saved MSSCR0 value
-			mtspr		msscr0, r3					; Restore MSSCR0
+			mtspr	msscr0,r3						; Restore MSSCR0
 			sync
 			isync
 
-notNapping:	stw		r12,saver12(r13)				; Save this one
+notNapping:	stw		r12,saver12+4(r13)				; Save this one
 						
-			stw		r14,saver14(r13)				; Save this one
-			stw		r15,saver15(r13)				; Save this one 
+			stw		r14,saver14+4(r13)				; Save this one
+			stw		r15,saver15+4(r13)				; Save this one 
 			la		r14,saver24(r13)				; Point to the next block to save into
-			stw		r0,savecr(r13)					; Save rupt CR
 			mfctr	r6								; Get the CTR 
-			stw		r16,saver16(r13)				; Save this one
-			stw		r4,savelr(r13)					; Save rupt LR
+			stw		r16,saver16+4(r13)				; Save this one
+            la		r15,savectr(r13)				; point to line with CTR, DAR, DSISR, Exception code, and VRSAVE
+			stw		r4,savelr+4(r13)				; Save rupt LR
 		
-			bf-		featL1ena,skipz4				; L1 cache is disabled...
-			dcbz	0,r14							; Allocate next save area line
-skipz4:			
-			stw		r17,saver17(r13)				; Save this one
-			stw		r18,saver18(r13)				; Save this one 
-			stw		r6,savectr(r13)					; Save rupt CTR
-			stw		r19,saver19(r13)				; Save this one
-			lis		r12,hi16(KERNEL_SEG_REG0_VALUE)	; Get the high half of the kernel SR0 value
+			dcbz	0,r14							; allocate 32-byte line with r24-r27
+            la		r16,saver28(r13)				; point to line with r28-r31
+			dcbz	0,r15							; allocate line with CTR, DAR, DSISR, Exception code, and VRSAVE
+			stw		r17,saver17+4(r13)				; Save this one
+			stw		r18,saver18+4(r13)				; Save this one 
+			stw		r6,savectr+4(r13)				; Save rupt CTR
+			stw		r0,savecr(r13)					; Save rupt CR
+			stw		r19,saver19+4(r13)				; Save this one
 			mfdar	r6								; Get the rupt DAR
-			stw		r20,saver20(r13)				; Save this one 
-			
-			bf+		specAccess,noSRsave				; Do not save SRs if this is not a special access...
-			mfsr	r14,sr0							; Get SR0
-			stw		r14,savesr0(r13)				; and save
-			mfsr	r14,sr1							; Get SR1
-			stw		r14,savesr1(r13)				; and save
-			mfsr	r14,sr2							; get SR2
-			stw		r14,savesr2(r13)				; and save
-			mfsr	r14,sr3							; get SR3
-			stw		r14,savesr3(r13)				; and save
-
-noSRsave:	mtsr	sr0,r12							; Set the kernel SR0 
-			stw		r21,saver21(r13)				; Save this one
-			addis	r12,r12,0x0010					; Point to the second segment of kernel
-			stw		r10,savexer(r13)				; Save the rupt XER
-			mtsr	sr1,r12							; Set the kernel SR1 
-			stw		r30,saver30(r13)				; Save this one 
-			addis	r12,r12,0x0010					; Point to the third segment of kernel
-			stw		r31,saver31(r13)				; Save this one 
-			mtsr	sr2,r12							; Set the kernel SR2 
-			stw		r22,saver22(r13)				; Save this one 
-			addis	r12,r12,0x0010					; Point to the third segment of kernel
-			stw		r23,saver23(r13)				; Save this one 
-			mtsr	sr3,r12							; Set the kernel SR3 
-			stw		r24,saver24(r13)				; Save this one 
-			stw		r25,saver25(r13)				; Save this one 
+			stw		r20,saver20+4(r13)				; Save this one 
+			dcbz	0,r16							; allocate 32-byte line with r28-r31
+
+			stw		r21,saver21+4(r13)				; Save this one
+			lwz		r21,spcFlags(r2)				; Get the special flags from per_proc
+			stw		r10,savexer+4(r13)				; Save the rupt XER
+			stw		r30,saver30+4(r13)				; Save this one 
+			lhz		r30,pfrptdProc(r2)				; Get the reported processor type
+			stw		r31,saver31+4(r13)				; Save this one 
+			stw		r22,saver22+4(r13)				; Save this one 
+			stw		r23,saver23+4(r13)				; Save this one 
+			stw		r24,saver24+4(r13)				; Save this one 
+			stw		r25,saver25+4(r13)				; Save this one 
 			mfdsisr	r7								; Get the rupt DSISR 
-			stw		r26,saver26(r13)				; Save this one		
-			stw		r27,saver27(r13)				; Save this one 
-			li		r10,emfp0						; Point to floating point save
-			stw		r28,saver28(r13)				; Save this one
-			stw		r29,saver29(r13)				; Save this one 
-			mfsr	r14,sr14						; Get the copyin/out segment register
-			stw		r6,savedar(r13)					; Save the rupt DAR 
-			bf-		featL1ena,skipz5a				; Do not do this if no L1...
-			dcbz	r10,r2							; Clear and allocate an L1 slot
-			
-skipz5a:	stw		r7,savedsisr(r13)				; Save the rupt code DSISR
+			stw		r26,saver26+4(r13)				; Save this one		
+			stw		r27,saver27+4(r13)				; Save this one 
+			andis.	r21,r21,hi16(perfMonitor)		; Is the performance monitor enabled?
+			stw		r28,saver28+4(r13)				; Save this one
+			cmpwi	cr1, r30,CPU_SUBTYPE_POWERPC_750	; G3?
+            la		r27,savevscr(r13)				; point to 32-byte line with VSCR and FPSCR
+			cmpwi	cr2,r30,CPU_SUBTYPE_POWERPC_7400	; This guy?
+			stw		r29,saver29+4(r13)				; Save R29
+			stw		r6,savedar+4(r13)				; Save the rupt DAR 
+			li		r10,savepmc						; Point to pmc savearea
+
+			beq+	noPerfMonSave32					; No perfmon on here...
+
+			dcbz	r10,r13							; Clear first part of pmc area
+			li		r10,savepmc+0x20				; Point to pmc savearea second part
+			li		r22,0							; r22:	zero
+			dcbz	r10,r13							; Clear second part of pmc area
+		
+			beq		cr1,perfMonSave32_750			; This is a G3...
+
+			beq		cr2,perfMonSave32_7400			; Regular olde G4...
+
+			mfspr	r24,pmc5						; Here for a 7450
+			mfspr	r25,pmc6
+			stw		r24,savepmc+16(r13)				; Save PMC5
+			stw		r25,savepmc+20(r13)				; Save PMC6
+			mtspr	pmc5,r22						; Leave PMC5 clear
+			mtspr	pmc6,r22						; Leave PMC6 clear
+
+perfMonSave32_7400:		
+			mfspr	r25,mmcr2
+			stw		r25,savemmcr2+4(r13)			; Save MMCR2
+			mtspr	mmcr2,r22						; Leave MMCR2 clear
+
+perfMonSave32_750:		
+			mfspr	r23,mmcr0
+			mfspr	r24,mmcr1
+			stw		r23,savemmcr0+4(r13)			; Save MMCR0
+			stw		r24,savemmcr1+4(r13)			; Save MMCR1 
+			mtspr	mmcr0,r22						; Leave MMCR0 clear
+			mtspr	mmcr1,r22						; Leave MMCR1 clear
+			mfspr	r23,pmc1
+			mfspr	r24,pmc2
+			mfspr	r25,pmc3
+			mfspr	r26,pmc4
+			stw		r23,savepmc+0(r13)				; Save PMC1
+			stw		r24,savepmc+4(r13)				; Save PMC2
+			stw		r25,savepmc+8(r13)				; Save PMC3
+			stw		r26,savepmc+12(r13)				; Save PMC4
+			mtspr	pmc1,r22						; Leave PMC1 clear 
+			mtspr	pmc2,r22						; Leave PMC2 clear
+			mtspr	pmc3,r22						; Leave PMC3 clear 		
+			mtspr	pmc4,r22						; Leave PMC4 clear
+
+noPerfMonSave32:		
+			dcbz	0,r27							; allocate line with VSCR and FPSCR 
+			
+			stw		r7,savedsisr(r13)				; Save the rupt code DSISR
 			stw		r11,saveexception(r13)			; Save the exception code 
-			stw		r14,savesr14(r13)				; Save copyin/copyout
 
 
 ;
-;			Here we will save some floating point and vector status
-;			and we also set a clean default status for a new interrupt level.
-;			Note that we assume that emfp0 is on an altivec boundary
-;			and that R10 points to it (as a displacemnt from R2).
+;			Everything is saved at this point, except for FPRs, and VMX registers.
+;			Time for us to get a new savearea and then trace interrupt if it is enabled.
 ;
 
-			lis		r8,hi16(MASK(MSR_VEC))			; Get the vector enable bit
-			mfmsr	r6								; Get the current MSR value
-			ori		r8,r8,lo16(MASK(MSR_FP))		; Add in the float enable
-			li		r19,0							; Assume no Altivec
-			or		r7,r6,r8						; Enable floating point
-			li		r9,0							; Get set to clear VRSAVE
-			mtmsr	r7								; Do it
-			isync
-			
-			bf		featAltivec,noavec				; No Altivec on this CPU...
-			addi	r14,r10,16						; Displacement to second vector register
-			stvxl	v0,r10,r2						; Save a register
-			stvxl	v1,r14,r2						; Save a second register
-			mfvscr	v0								; Get the vector status register
-			la		r28,savevscr(r13)				; Point to the status area
-			vspltish v1,1							; Turn on the non-Java bit and saturate
-			stvxl	v0,0,r28						; Save the vector status
-			vspltisw v0,1							; Turn on the saturate bit
-			mfspr	r19,vrsave						; Get the VRSAVE register
-			vxor	v1,v1,v0						; Turn off saturate	
-			mtspr	vrsave,r9						; Clear VRSAVE for each interrupt level
-			mtvscr	v1								; Set the non-java, no saturate status for new level
+			lwz		r25,traceMask(0)				; Get the trace mask
+			li		r0,SAVgeneral					; Get the savearea type value
+			lhz		r19,PP_CPU_NUMBER(r2)			; Get the logical processor number											
+			rlwinm	r22,r11,30,0,31					; Divide interrupt code by 2
+			stb		r0,SAVflags+2(r13)				; Mark valid context
+			addi	r22,r22,10						; Adjust code so we shift into CR5
+			li		r23,trcWork						; Get the trace work area address
+			rlwnm	r7,r25,r22,22,22				; Set CR5_EQ bit position to 0 if tracing allowed 
+			li		r26,0x8							; Get start of cpu mask
+			srw		r26,r26,r19						; Get bit position of cpu number
+			mtcrf	0x04,r7							; Set CR5 to show trace or not
+			and.	r26,r26,r25						; See if we trace this cpu
+			crandc	cr5_eq,cr5_eq,cr0_eq			; Turn off tracing if cpu is disabled
+;
+;			At this point, we can take another exception and lose nothing.
+;
 
-			lvxl	v0,r10,r2						; Restore first work register
-			lvxl	v1,r14,r2						; Restore second work register
+#if INSTRUMENT
+			mfspr	r26,pmc1						; INSTRUMENT - saveinstr[2] - Take stamp after save is done
+			stw		r26,0x6100+(0x02*16)+0x0(0)		; INSTRUMENT - Save it
+			mfspr	r26,pmc2						; INSTRUMENT - Get stamp
+			stw		r26,0x6100+(0x02*16)+0x4(0)		; INSTRUMENT - Save it
+			mfspr	r26,pmc3						; INSTRUMENT - Get stamp
+			stw		r26,0x6100+(0x02*16)+0x8(0)		; INSTRUMENT - Save it
+			mfspr	r26,pmc4						; INSTRUMENT - Get stamp
+			stw		r26,0x6100+(0x02*16)+0xC(0)		; INSTRUMENT - Save it
+#endif			
 
-noavec:		stw		r19,savevrsave(r13)				; Save the vector register usage flags
+			bne+	cr5,xcp32xit					; Skip all of this if no tracing here...
 
 ;
-;			We need to save the FPSCR as if it is normal context.
-;			This is because pending exceptions will cause an exception even if
-;			FP is disabled. We need to clear the FPSCR when we first start running in the
-;			kernel.
+;			We select a trace entry using a compare and swap on the next entry field.
+;			Since we do not lock the actual trace buffer, there is a potential that
+;			another processor could wrap an trash our entry.  Who cares?
 ;
 
-			bf-		featFP,nofpexe					; No possible floating point exceptions...
+			lwz		r25,traceStart(0)				; Get the start of trace table
+			lwz		r26,traceEnd(0)					; Get end of trace table
+	
+trcsel:		lwarx	r20,0,r23						; Get and reserve the next slot to allocate
 			
-			stfd	f0,emfp0(r2)					; Save FPR0	
-			stfd	f1,emfp1(r2)					; Save FPR1	
-			mffs	f0								; Get the FPSCR
-			fsub	f1,f1,f1						; Make a 0			
-			stfd	f0,savefpscrpad(r13)			; Save the FPSCR
-			mtfsf	0xFF,f1							; Clear it
-			lfd		f0,emfp0(r2)					; Restore FPR0	
-			lfd		f1,emfp1(r2)					; Restore FPR1	
+			addi	r22,r20,LTR_size				; Point to the next trace entry
+			cmplw	r22,r26							; Do we need to wrap the trace table?
+			bne+	gotTrcEnt						; No wrap, we got us a trace entry...
+			
+			mr		r22,r25							; Wrap back to start
 
-nofpexe:	mtmsr	r6								; Turn off FP and vector
+gotTrcEnt:	stwcx.	r22,0,r23						; Try to update the current pointer
+			bne-	trcsel							; Collision, try again...
+			
+#if ESPDEBUG
+			dcbf	0,r23							; Force to memory
+			sync
+#endif
+			
+			dcbz	0,r20							; Clear and allocate first trace line
+
+;
+;			Let us cut that trace entry now.
+;
+
+			lwz		r16,ruptStamp(r2)				; Get top of time base
+			lwz		r17,ruptStamp+4(r2)				; Get the bottom of time stamp
+
+			li		r14,32							; Offset to second line
+
+			lwz		r0,saver0+4(r13)				; Get back interrupt time R0
+			lwz		r1,saver1+4(r13)				; Get back interrupt time R1
+			lwz		r8,savecr(r13)					; Get the CR value
+			
+			dcbz	r14,r20							; Zap the second line
+			
+			sth		r19,LTR_cpu(r20)				; Stash the cpu number
+			li		r14,64							; Offset to third line
+			sth		r11,LTR_excpt(r20)				; Save the exception type 
+			lwz		r7,saver2+4(r13)				; Get back interrupt time R2
+			lwz		r3,saver3+4(r13)				; Restore this one
+		
+			dcbz	r14,r20							; Zap the third half
+			
+			mfdsisr	r9								; Get the DSISR
+			li		r14,96							; Offset to forth line
+			stw		r16,LTR_timeHi(r20)				; Set the upper part of TB 
+			stw		r17,LTR_timeLo(r20)				; Set the lower part of TB
+			lwz		r10,savelr+4(r13)				; Get the LR
+			mfsrr0	r17								; Get SRR0 back, it is still good
+			
+			dcbz	r14,r20							; Zap the forth half
+			lwz		r4,saver4+4(r13)				; Restore this one
+			lwz		r5,saver5+4(r13)				; Restore this one
+			mfsrr1	r18								; SRR1 is still good in here
+
+			stw		r8,LTR_cr(r20)					; Save the CR
+			lwz		r6,saver6+4(r13)				; Get R6
+			mfdar	r16								; Get this back
+			stw		r9,LTR_dsisr(r20)				; Save the DSISR
+			stw		r17,LTR_srr0+4(r20)				; Save the SSR0 
+			
+			stw		r18,LTR_srr1+4(r20)				; Save the SRR1 
+			stw		r16,LTR_dar+4(r20)				; Save the DAR
+			mfctr	r17								; Get the CTR (still good in register)
+			stw		r13,LTR_save+4(r20)				; Save the savearea 
+			stw		r10,LTR_lr+4(r20)				; Save the LR
+			
+			stw		r17,LTR_ctr+4(r20)				; Save off the CTR
+			stw		r0,LTR_r0+4(r20)				; Save off register 0 			
+			stw		r1,LTR_r1+4(r20)				; Save off register 1			
+			stw		r7,LTR_r2+4(r20)				; Save off register 2 	
+					
+		
+			stw		r3,LTR_r3+4(r20)				; Save off register 3
+			stw		r4,LTR_r4+4(r20)				; Save off register 4 
+			stw		r5,LTR_r5+4(r20)				; Save off register 5	
+			stw		r6,LTR_r6+4(r20)				; Save off register 6	
+
+#if ESPDEBUG
+			addi	r17,r20,32						; Second line
+			addi	r16,r20,64						; Third line
+			dcbst	br0,r20							; Force to memory
+			dcbst	br0,r17							; Force to memory
+			addi	r17,r17,32						; Fourth line
+			dcbst	br0,r16							; Force to memory
+			dcbst	br0,r17							; Force to memory
+			
+			sync									; Make sure it all goes
+#endif
+xcp32xit:	mr		r14,r11							; Save the interrupt code across the call
+			bl		EXT(save_get_phys_32)			; Grab a savearea
+			mfsprg	r2,0							; Get the per_proc info
+			li		r10,emfp0						; Point to floating point save
+			mr		r11,r14							; Get the exception code back
+			dcbz	r10,r2							; Clear for speed
+			stw		r3,next_savearea+4(r2)			; Store the savearea for the next rupt
+
+#if INSTRUMENT
+			mfspr	r4,pmc1							; INSTRUMENT - saveinstr[3] - Take stamp after next savearea
+			stw		r4,0x6100+(0x03*16)+0x0(0)		; INSTRUMENT - Save it
+			mfspr	r4,pmc2							; INSTRUMENT - Get stamp
+			stw		r4,0x6100+(0x03*16)+0x4(0)		; INSTRUMENT - Save it
+			mfspr	r4,pmc3							; INSTRUMENT - Get stamp
+			stw		r4,0x6100+(0x03*16)+0x8(0)		; INSTRUMENT - Save it
+			mfspr	r4,pmc4							; INSTRUMENT - Get stamp
+			stw		r4,0x6100+(0x03*16)+0xC(0)		; INSTRUMENT - Save it
+#endif			
+			b		xcpCommon						; Go join the common interrupt processing...
+
+;
+;
+;			This is the 64-bit context saving stuff
+;
+
+			.align	5
+						
+extEntry64:	mfsprg  r13,0							; Load per_proc
+			ld		r13,next_savearea(r13)			; Get the exception save area
+			std		r0,saver0(r13)					; Save register 0
+			lis		r0,hi16(MASK(MSR_VEC)|MASK(MSR_FP)|MASK(MSR_ME))	; Set up the MSR we will use throughout. Note that ME come on here if MCK
+			std		r1,saver1(r13)					; Save register 1
+			ori		r1,r0,lo16(MASK(MSR_VEC)|MASK(MSR_FP)|MASK(MSR_ME))	; Rest of MSR
+			lis		r0,0x0010						; Get rupt code transform validity mask
+			mtmsr	r1								; Set MSR
 			isync
+		
+			ori		r0,r0,0x0200					; Get rupt code transform validity mask
+			std		r2,saver2(r13)					; Save this one
+			lis		r1,0x00F0						; Top half of xform XOR
+			rlwinm	r2,r11,29,27,31					; Get high 5 bits of rupt code
+			std		r3,saver3(r13)					; Save this one
+			slw		r0,r0,r2						; Move transform validity bit to bit 0
+			std		r4,saver4(r13)					; Save this one
+			std		r5,saver5(r13)					; Save this one 
+			ori		r1,r1,0x04EC					; Bottom half of xform XOR
+			mfxer	r5								; Save the XER because we are about to muck with it
+			rlwinm	r4,r11,1,27,28					; Get bottom of interrupt code * 8
+			lis		r3,hi16(dozem|napm)				; Get the nap and doze bits
+			srawi	r0,r0,31						; Get 0xFFFFFFFF of xform valid, 0 otherwise
+			rlwnm	r4,r1,r4,24,31					; Extract the xform XOR
+			li		r1,saver16						; Point to the next line
+			and		r4,r4,r0						; Only keep transform if we are to use it
+			li		r2,lgKillResv					; Point to the killing field
+			mfcr	r0								; Save the CR
+			stwcx.	r2,0,r2							; Kill any pending reservation
+			dcbz128	r1,r13							; Blow away the line
+			sldi	r3,r3,32						; Position it
+			mfspr	r1,hid0							; Get HID0
+			andc	r3,r1,r3						; Clear nap and doze
+			xor		r11,r11,r4						; Transform 970 rupt code to standard keeping FAM bit
+			cmpld	r3,r1							; See if nap and/or doze was on
+			std		r6,saver6(r13)					; Save this one
+			mfsprg	r2,0							; Get the per_proc area
+			la		r6,savesrr0(r13)				; point to line with SRR0, SRR1, CR, XER, and LR
+			beq++	eE64NoNap						; No nap here,  skip all this...
+		
+			sync									; Make sure we are clean
+			mtspr	hid0,r3							; Set the updated hid0
+			mfspr	r1,hid0							; Yes, this is silly, keep it here
+			mfspr	r1,hid0							; Yes, this is a duplicate, keep it here
+			mfspr	r1,hid0							; Yes, this is a duplicate, keep it here
+			mfspr	r1,hid0							; Yes, this is a duplicate, keep it here
+			mfspr	r1,hid0							; Yes, this is a duplicate, keep it here
+			mfspr	r1,hid0							; Yes, this is a duplicate, keep it here
+			
+eE64NoNap:	crnot	wasNapping,cr0_eq				; Remember if we were napping
+			andi.	r1,r11,T_FAM					; Check FAM bit
+			beq++	eEnoFAM							; Is it FAM intercept
+			mfsrr1	r3								; Load srr1
+			andc	r11,r11,r1						; Clear FAM bit
+			rlwinm.	r3,r3,0,MSR_PR_BIT,MSR_PR_BIT	; Are we trapping from supervisor state?
+			beq+	eEnoFAM							; From supervisor state
+			lwz		r1,spcFlags(r2)					; Load spcFlags 
+			rlwinm	r1,r1,1+FamVMmodebit,30,31		; Extract FamVMenabit and FamVMmodebit
+			cmpwi	cr0,r1,2						; Check FamVMena set without FamVMmode
+			bne++	eEnoFAM							; Can this context be FAM intercept
+			lwz		r4,FAMintercept(r2)				; Load exceptions mask to intercept
+			li		r3,0							; Clear
+			srwi	r1,r11,2						; divide r11 by 4
+			oris	r3,r3,0x8000					; Set r3 to 0x80000000
+			srw		r1,r3,r1						; Set bit for current exception
+			and.	r1,r1,r4						; And current exception with the intercept mask
+			beq++	eEnoFAM							; Is it FAM intercept
+			b		EXT(vmm_fam_exc)
+
+			.align	5
+
+eEnoFAM:	lwz		r1,pfAvailable(r2)				; Get the CPU features flags	
+			dcbz128	0,r6							; allocate 128-byte line with SRR0, SRR1, CR, XER, and LR
 			
+;
+;			Remember, we are setting up CR6 with feature flags
+;
+			std		r7,saver7(r13)					; Save this one
+			mtcrf	0x80,r1							; Put the features flags (that we care about) in the CR
+			std		r8,saver8(r13)					; Save this one
+			mtcrf	0x40,r1							; Put the features flags (that we care about) in the CR
+			mfsrr0	r6								; Get the interruption SRR0 
+			lhz		r8,PP_CPU_FLAGS(r2)				; Get the flags
+			mtcrf	0x20,r1							; Put the features flags (that we care about) in the CR
+			mfsrr1	r7								; Get the interrupt SRR1
+			rlwinm	r8,r8,(((31-MSR_BE_BIT)+(traceBEb+16+1))&31),MSR_BE_BIT,MSR_BE_BIT	; Set BE bit if special trace is on
+			std		r6,savesrr0(r13)				; Save the SRR0 
+			mtcrf	0x02,r1							; Put the features flags (that we care about) in the CR
+			rlwinm	r6,r7,(((31-MSR_BE_BIT)+(MSR_PR_BIT+1))&31),MSR_BE_BIT,MSR_BE_BIT	; Move PR bit to BE bit
+			and		r8,r6,r8						; Remove BE bit only if problem state and special tracing on
+			std		r9,saver9(r13)					; Save this one
+			andc	r7,r7,r8						; Clear BE bit if special trace is on and PR is set
+			crmove	featAltivec,pfAltivecb			; Set the Altivec flag
+			std		r7,savesrr1(r13)				; Save SRR1 
+			mfsprg	r9,3							; Get rupt time R11
+			std		r10,saver10(r13)				; Save this one
+			mfsprg	r6,2							; Get interrupt time R13
+			std		r9,saver11(r13)					; Save rupt time R11
+			mtsprg	2,r1							; Set the feature flags
+			std		r12,saver12(r13)				; Save this one
+			mflr	r4								; Get the LR
+ 			mftb	r7								; Get the timebase
+			std		r6,saver13(r13)					; Save rupt R13
+			std		r7,ruptStamp(r2)				; Save the time stamp
+			std		r7,SAVtime(r13)					; Save the time stamp
+			
+			bf++	wasNapping,notNappingSF			; Skip if not waking up from nap...
+
+			ld		r6,napStamp(r2)					; Pick up nap stamp
+			lis		r3,hi16(EXT(machine_idle_ret))	; Get high part of nap/doze return
+			sub		r7,r7,r6						; Subtract stamp from now
+			ld		r6,napTotal(r2)					; Pick up total
+			add		r6,r6,r7						; Add low to total
+			ori		r3,r3,lo16(EXT(machine_idle_ret))	; Get low part of nap/doze return
+			std		r6,napTotal(r2)					; Save the high total
+			std		r3,savesrr0(r13)				; Modify to return to nap/doze exit
+			
+notNappingSF:	
+			std		r14,saver14(r13)				; Save this one
+			std		r15,saver15(r13)				; Save this one 
+			stw		r0,savecr(r13)					; Save rupt CR
+			mfctr	r6								; Get the CTR 
+			std		r16,saver16(r13)				; Save this one
+			std		r4,savelr(r13)					; Save rupt LR
+		
+			std		r17,saver17(r13)				; Save this one
+			li		r7,savepmc						; Point to pmc area
+			std		r18,saver18(r13)				; Save this one 
+			lwz		r17,spcFlags(r2)				; Get the special flags from per_proc
+			std		r6,savectr(r13)					; Save rupt CTR
+			std		r19,saver19(r13)				; Save this one
+			mfdar	r6								; Get the rupt DAR
+			std		r20,saver20(r13)				; Save this one 
+
+			dcbz128	r7,r13							; Clear out the pmc spot
+					
+			std		r21,saver21(r13)				; Save this one
+			std		r5,savexer(r13)					; Save the rupt XER
+			std		r22,saver22(r13)				; Save this one 
+			std		r23,saver23(r13)				; Save this one 
+			std		r24,saver24(r13)				; Save this one 
+			std		r25,saver25(r13)				; Save this one 
+			mfdsisr	r7								; Get the rupt DSISR 
+			std		r26,saver26(r13)				; Save this one		
+			andis.	r17,r17,hi16(perfMonitor)		; Is the performance monitor enabled?
+			std		r27,saver27(r13)				; Save this one 
+			li		r10,emfp0						; Point to floating point save
+			std		r28,saver28(r13)				; Save this one
+            la		r27,savevscr(r13)				; point to 32-byte line with VSCR and FPSCR
+			std		r29,saver29(r13)				; Save R29
+			std		r30,saver30(r13)				; Save this one 
+			std		r31,saver31(r13)				; Save this one 
+			std		r6,savedar(r13)					; Save the rupt DAR 
+			stw		r7,savedsisr(r13)				; Save the rupt code DSISR
+			stw		r11,saveexception(r13)			; Save the exception code 
+
+			beq++	noPerfMonSave64					; Performance monitor not on...
+
+			li		r22,0							; r22:	zero
+		
+			mfspr	r23,mmcr0_gp
+			mfspr	r24,mmcr1_gp
+			mfspr	r25,mmcra_gp
+			std		r23,savemmcr0(r13)				; Save MMCR0
+			std		r24,savemmcr1(r13)				; Save MMCR1 
+			std		r25,savemmcr2(r13)				; Save MMCRA
+			mtspr	mmcr0_gp,r22					; Leave MMCR0 clear
+			mtspr	mmcr1_gp,r22					; Leave MMCR1 clear
+			mtspr	mmcra_gp,r22					; Leave MMCRA clear 
+			mfspr	r23,pmc1_gp
+			mfspr	r24,pmc2_gp
+			mfspr	r25,pmc3_gp
+			mfspr	r26,pmc4_gp
+			stw		r23,savepmc+0(r13)				; Save PMC1
+			stw		r24,savepmc+4(r13)				; Save PMC2
+			stw		r25,savepmc+8(r13)				; Save PMC3
+			stw		r26,savepmc+12(r13)				; Save PMC4
+			mfspr	r23,pmc5_gp
+			mfspr	r24,pmc6_gp
+			mfspr	r25,pmc7_gp
+			mfspr	r26,pmc8_gp
+			stw		r23,savepmc+16(r13)				; Save PMC5
+			stw		r24,savepmc+20(r13)				; Save PMC6
+			stw		r25,savepmc+24(r13)				; Save PMC7
+			stw		r26,savepmc+28(r13)				; Save PMC8
+			mtspr	pmc1_gp,r22						; Leave PMC1 clear 
+			mtspr	pmc2_gp,r22						; Leave PMC2 clear
+			mtspr	pmc3_gp,r22						; Leave PMC3 clear 		
+			mtspr	pmc4_gp,r22						; Leave PMC4 clear 
+			mtspr	pmc5_gp,r22						; Leave PMC5 clear 
+			mtspr	pmc6_gp,r22						; Leave PMC6 clear
+			mtspr	pmc7_gp,r22						; Leave PMC7 clear 		
+			mtspr	pmc8_gp,r22						; Leave PMC8 clear 
+
+noPerfMonSave64:		
 
 ;
 ;			Everything is saved at this point, except for FPRs, and VMX registers.
 ;			Time for us to get a new savearea and then trace interrupt if it is enabled.
 ;
 
+			lwz		r25,traceMask(0)				; Get the trace mask
 			li		r0,SAVgeneral					; Get the savearea type value
-			lis		r23,hi16(EXT(trcWork))			; Get the trace work area address
-			mr		r14,r11							; Save the interrupt code across the call
+			lhz		r19,PP_CPU_NUMBER(r2)			; Get the logical processor number											
 			stb		r0,SAVflags+2(r13)				; Mark valid context
 			ori		r23,r23,lo16(EXT(trcWork))		; Get the rest
 			rlwinm	r22,r11,30,0,31					; Divide interrupt code by 2
-			lwz		r25,traceMask(r23)				; Get the trace mask
+			li		r23,trcWork						; Get the trace work area address
 			addi	r22,r22,10						; Adjust code so we shift into CR5
-
-			bl		EXT(save_get_phys)				; Grab a savearea
-			
-			mfsprg	r2,0							; Get back the per_proc block
-			rlwnm	r7,r25,r22,22,22				; Set CR5_EQ bit position to 0 if tracing allowed 
-			lhz		r19,PP_CPU_NUMBER(r2)			; Get the logical processor number											
 			li		r26,0x8							; Get start of cpu mask
-			mr		r11,r14							; Get the exception code back
+			rlwnm	r7,r25,r22,22,22				; Set CR5_EQ bit position to 0 if tracing allowed 
 			srw		r26,r26,r19						; Get bit position of cpu number
 			mtcrf	0x04,r7							; Set CR5 to show trace or not
 			and.	r26,r26,r25						; See if we trace this cpu
-			stw		r3,next_savearea(r2)			; Remember the savearea we just got for the next rupt
 			crandc	cr5_eq,cr5_eq,cr0_eq			; Turn off tracing if cpu is disabled
-;
-;			At this point, we can take another exception and lose nothing.
-;
-			
-			lwz		r0,saver0(r13)					; Get back interrupt time R0 (we need this whether we trace or not)
 
-			bne+	cr5,skipTrace					; Skip all of this if no tracing here...
+			bne++	cr5,xcp64xit					; Skip all of this if no tracing here...
 
 ;
 ;			We select a trace entry using a compare and swap on the next entry field.
@@ -1153,205 +1420,484 @@ nofpexe:	mtmsr	r6								; Turn off FP and vector
 ;			another processor could wrap an trash our entry.  Who cares?
 ;
 
-			lwz		r25,traceStart(r23)				; Get the start of trace table
-			lwz		r26,traceEnd(r23)				; Get end of trace table
-	
-trcsel:		lwarx	r20,0,r23						; Get and reserve the next slot to allocate
+			lwz		r25,traceStart(0)				; Get the start of trace table
+			lwz		r26,traceEnd(0)					; Get end of trace table
+
+trcselSF:	lwarx	r20,0,r23						; Get and reserve the next slot to allocate
 			
 			addi	r22,r20,LTR_size				; Point to the next trace entry
 			cmplw	r22,r26							; Do we need to wrap the trace table?
-			bne+	gotTrcEnt						; No wrap, we got us a trace entry...
+			bne+	gotTrcEntSF						; No wrap, we got us a trace entry...
 			
 			mr		r22,r25							; Wrap back to start
 
-gotTrcEnt:	stwcx.	r22,0,r23						; Try to update the current pointer
-			bne-	trcsel							; Collision, try again...
+gotTrcEntSF:	
+			stwcx.	r22,0,r23						; Try to update the current pointer
+			bne-	trcselSF						; Collision, try again...
 			
 #if ESPDEBUG
 			dcbf	0,r23							; Force to memory
 			sync
 #endif
-			
-			bf-		featL1ena,skipz6				; L1 cache is disabled...
-			dcbz	0,r20							; Clear and allocate first trace line
-skipz6:
 
 ;
 ;			Let us cut that trace entry now.
 ;
 
+			dcbz128	0,r20							; Zap the trace entry
 
-			li		r14,32							; Offset to second line
-
-			lwz		r16,ruptStamp(r2)				; Get top of time base
-			lwz		r17,ruptStamp+4(r2)				; Get the bottom of time stamp
-		
-			bf-		featL1ena,skipz7				; L1 cache is disabled...
-			dcbz	r14,r20							; Zap the second half
-
-skipz7:		stw		r16,LTR_timeHi(r20)				; Set the upper part of TB 
-			lwz		r1,saver1(r13)					; Get back interrupt time R1
-			stw		r17,LTR_timeLo(r20)				; Set the lower part of TB
-			lwz		r18,saver2(r13)					; Get back interrupt time R2
-			stw		r0,LTR_r0(r20)					; Save off register 0 			
-			lwz		r3,saver3(r13)					; Restore this one
+			ld		r16,ruptStamp(r2)				; Get top of time base
+			ld		r0,saver0(r13)					; Get back interrupt time R0 (we need this whether we trace or not)
+			std		r16,LTR_timeHi(r20)				; Set the upper part of TB 
+			ld		r1,saver1(r13)					; Get back interrupt time R1
+			ld		r18,saver2(r13)					; Get back interrupt time R2
+			std		r0,LTR_r0(r20)					; Save off register 0 			
+			ld		r3,saver3(r13)					; Restore this one
 			sth		r19,LTR_cpu(r20)				; Stash the cpu number
-			stw		r1,LTR_r1(r20)					; Save off register 1			
-			lwz		r4,saver4(r13)					; Restore this one
-			stw		r18,LTR_r2(r20)					; Save off register 2 			
-			lwz		r5,saver5(r13)					; Restore this one
-			stw		r3,LTR_r3(r20)					; Save off register 3
+			std		r1,LTR_r1(r20)					; Save off register 1			
+			ld		r4,saver4(r13)					; Restore this one
+			std		r18,LTR_r2(r20)					; Save off register 2 			
+			ld		r5,saver5(r13)					; Restore this one
+			ld		r6,saver6(r13)					; Get R6
+			std		r3,LTR_r3(r20)					; Save off register 3
 			lwz		r16,savecr(r13)					; Get the CR value
-			stw		r4,LTR_r4(r20)					; Save off register 4 
+			std		r4,LTR_r4(r20)					; Save off register 4 
 			mfsrr0	r17								; Get SRR0 back, it is still good
-			stw		r5,LTR_r5(r20)					; Save off register 5	
+			std		r5,LTR_r5(r20)					; Save off register 5	
+			std		r6,LTR_r6(r20)					; Save off register 6	
 			mfsrr1	r18								; SRR1 is still good in here
 			stw		r16,LTR_cr(r20)					; Save the CR
-			stw		r17,LTR_srr0(r20)				; Save the SSR0 
-			stw		r18,LTR_srr1(r20)				; Save the SRR1 
+			std		r17,LTR_srr0(r20)				; Save the SSR0 
+			std		r18,LTR_srr1(r20)				; Save the SRR1 
+						
 			mfdar	r17								; Get this back
-			lwz		r16,savelr(r13)					; Get the LR
-			stw		r17,LTR_dar(r20)				; Save the DAR
+			ld		r16,savelr(r13)					; Get the LR
+			std		r17,LTR_dar(r20)				; Save the DAR
 			mfctr	r17								; Get the CTR (still good in register)
-			stw		r16,LTR_lr(r20)					; Save the LR
-#if 0
-			lwz		r17,emfp1(r2)					; (TEST/DEBUG)
-#endif
-			stw		r17,LTR_ctr(r20)				; Save off the CTR
-			stw		r13,LTR_save(r20)				; Save the savearea 
+			std		r16,LTR_lr(r20)					; Save the LR
+			std		r17,LTR_ctr(r20)				; Save off the CTR
+			mfdsisr	r17								; Get the DSISR
+			std		r13,LTR_save(r20)				; Save the savearea 
+			stw		r17,LTR_dsisr(r20)				; Save the DSISR
 			sth		r11,LTR_excpt(r20)				; Save the exception type 
+
 #if ESPDEBUG
-			addi	r17,r20,32						; (TEST/DEBUG)
-			dcbst	br0,r20							; (TEST/DEBUG)
-			dcbst	br0,r17							; (TEST/DEBUG)
-			sync									; (TEST/DEBUG)
+			dcbf	0,r20							; Force to memory			
+			sync									; Make sure it all goes
 #endif
+xcp64xit:	mr		r14,r11							; Save the interrupt code across the call
+			bl		EXT(save_get_phys_64)			; Grab a savearea
+			mfsprg	r2,0							; Get the per_proc info
+			li		r10,emfp0						; Point to floating point save
+			mr		r11,r14							; Get the exception code back
+			dcbz128	r10,r2							; Clear for speed
+			std		r3,next_savearea(r2)			; Store the savearea for the next rupt
+			b		xcpCommon						; Go join the common interrupt processing...
 
 ;
-;			We are done with the trace, except for maybe modifying the exception
-;			code later on. So, that means that we need to save R20 and CR5.
-;			
-;			So, finish setting up the kernel registers now.
+;			All of the context is saved. Now we will get a
+;			fresh savearea.  After this we can take an interrupt.
 ;
 
-skipTrace:	lhz		r21,PP_CPU_NUMBER(r2)			; Get the logical processor number
-			lis		r12,hi16(EXT(hw_counts))		; Get the high part of the interrupt counters
-			lwz		r7,savesrr1(r13)				; Get the entering MSR
-			ori		r12,r12,lo16(EXT(hw_counts))	; Get the low part of the interrupt counters
-			rlwinm	r21,r21,8,20,23					; Get index to processor counts
+			.align	5
+
+xcpCommon:
+
+;
+;			Here we will save some floating point and vector status
+;			and we also set a clean default status for a new interrupt level.
+;			Note that we assume that emfp0 is on an altivec boundary
+;			and that R10 points to it (as a displacemnt from R2).
+;
+;			We need to save the FPSCR as if it is normal context.
+;			This is because pending exceptions will cause an exception even if
+;			FP is disabled. We need to clear the FPSCR when we first start running in the
+;			kernel.
+;
+
+			stfd	f0,emfp0(r2)					; Save FPR0	
+			stfd	f1,emfp1(r2)					; Save FPR1	
+			li		r19,0							; Assume no Altivec
+			mffs	f0								; Get the FPSCR
+			lfd		f1,Zero(0)						; Make a 0			
+			stfd	f0,savefpscrpad(r13)			; Save the FPSCR
+			li		r9,0							; Get set to clear VRSAVE
+			mtfsf	0xFF,f1							; Clear it
+			addi	r14,r10,16						; Displacement to second vector register
+			lfd		f0,emfp0(r2)					; Restore FPR0	
+			la		r28,savevscr(r13)				; Point to the status area
+			lfd		f1,emfp1(r2)					; Restore FPR1	
+
+			bf		featAltivec,noavec				; No Altivec on this CPU...
+			
+			stvxl	v0,r10,r2						; Save a register
+			stvxl	v1,r14,r2						; Save a second register
+			mfspr	r19,vrsave						; Get the VRSAVE register
+			mfvscr	v0								; Get the vector status register
+			vspltish v1,1							; Turn on the non-Java bit and saturate
+			stvxl	v0,0,r28						; Save the vector status
+			vspltisw v0,1							; Turn on the saturate bit
+			vxor	v1,v1,v0						; Turn off saturate	
+			mtvscr	v1								; Set the non-java, no saturate status for new level
+			mtspr	vrsave,r9						; Clear VRSAVE for each interrupt level
+
+			lvxl	v0,r10,r2						; Restore first work register
+			lvxl	v1,r14,r2						; Restore second work register
+
+noavec:		stw		r19,savevrsave(r13)				; Save the vector register usage flags
+			
+;
+;			We are now done saving all of the context.  Start filtering the interrupts.
+;			Note that a Redrive will count as an actual interrupt.
+;			Note also that we take a lot of system calls so we will start decode here.
+;
+
+Redrive:	
+
+
+#if INSTRUMENT
+			mfspr	r20,pmc1						; INSTRUMENT - saveinstr[4] - Take stamp before exception filter
+			stw		r20,0x6100+(0x04*16)+0x0(0)		; INSTRUMENT - Save it
+			mfspr	r20,pmc2						; INSTRUMENT - Get stamp
+			stw		r20,0x6100+(0x04*16)+0x4(0)		; INSTRUMENT - Save it
+			mfspr	r20,pmc3						; INSTRUMENT - Get stamp
+			stw		r20,0x6100+(0x04*16)+0x8(0)		; INSTRUMENT - Save it
+			mfspr	r20,pmc4						; INSTRUMENT - Get stamp
+			stw		r20,0x6100+(0x04*16)+0xC(0)		; INSTRUMENT - Save it
+#endif			
+			lwz		r22,SAVflags(r13)				; Pick up the flags
+			lwz		r0,saver0+4(r13)				; Get back interrupt time syscall number
+			mfsprg	r2,0							; Restore per_proc
+		
+			li		r20,lo16(xcpTable)				; Point to the vector table (note: this must be in 1st 64k of physical memory)
+			la		r12,hwCounts(r2)				; Point to the exception count area
+			rlwinm	r22,r22,SAVredriveb+1,31,31		; Get a 1 if we are redriving
+			add		r12,r12,r11						; Point to the count
+			lwzx	r20,r20,r11						; Get the interrupt handler
+			lwz		r25,0(r12)						; Get the old value
+			lwz		r23,hwRedrives(r2)				; Get the redrive count
+			xori	r24,r22,1						; Get the NOT of the redrive
+			mtctr	r20								; Point to the interrupt handler
 			mtcrf	0x80,r0							; Set our CR0 to the high nybble of possible syscall code
-			rlwinm	r6,r0,1,0,31					; Move sign bit to the end 
-			cmplwi	cr1,r11,T_SYSTEM_CALL			; Did we get a system call?
-			add		r12,r12,r21						; Point to the processor count area
+			add		r25,r25,r24						; Count this one if not a redrive
+			add		r23,r23,r24						; Count this one if if is a redrive
 			crandc	cr0_lt,cr0_lt,cr0_gt			; See if we have R0 equal to 0b10xx...x 
-			lwzx	r22,r12,r11						; Get the old value
-			cmplwi	cr3,r11,T_IN_VAIN				; Was this all in vain? All for nothing? 
-			addi	r22,r22,1						; Count this one
+			stw		r25,0(r12)						; Store it back
+			stw		r23,hwRedrives(r2)				; Save the redrive count
+			bctr									; Go process the exception...
+	
+
+;
+;			Exception vector filter table
+;
+
+			.align	7
+			
+xcpTable:
+			.long	EatRupt							; T_IN_VAIN			
+			.long	PassUpTrap						; T_RESET				
+			.long	MachineCheck					; T_MACHINE_CHECK		
+			.long	EXT(handlePF)					; T_DATA_ACCESS		
+			.long	EXT(handlePF)					; T_INSTRUCTION_ACCESS
+			.long	PassUpRupt						; T_INTERRUPT		
+			.long	EXT(AlignAssist)				; T_ALIGNMENT			
+			.long	EXT(Emulate)					; T_PROGRAM			
+			.long	PassUpFPU						; T_FP_UNAVAILABLE		
+			.long	PassUpRupt						; T_DECREMENTER		
+			.long	PassUpTrap						; T_IO_ERROR			
+			.long	PassUpTrap						; T_RESERVED			
+			.long	xcpSyscall						; T_SYSTEM_CALL			
+			.long	PassUpTrap						; T_TRACE				
+			.long	PassUpTrap						; T_FP_ASSIST			
+			.long	PassUpTrap						; T_PERF_MON				
+			.long	PassUpVMX						; T_VMX					
+			.long	PassUpTrap						; T_INVALID_EXCP0		
+			.long	PassUpTrap						; T_INVALID_EXCP1			
+			.long	PassUpTrap						; T_INVALID_EXCP2		
+			.long	PassUpTrap						; T_INSTRUCTION_BKPT		
+			.long	PassUpRupt						; T_SYSTEM_MANAGEMENT		
+			.long	EXT(AltivecAssist)				; T_ALTIVEC_ASSIST		
+			.long	PassUpRupt						; T_THERMAL				
+			.long	PassUpTrap						; T_INVALID_EXCP5		
+			.long	PassUpTrap						; T_INVALID_EXCP6			
+			.long	PassUpTrap						; T_INVALID_EXCP7			
+			.long	PassUpTrap						; T_INVALID_EXCP8			
+			.long	PassUpTrap						; T_INVALID_EXCP9			
+			.long	PassUpTrap						; T_INVALID_EXCP10		
+			.long	PassUpTrap						; T_INVALID_EXCP11		
+			.long	PassUpTrap						; T_INVALID_EXCP12	
+			.long	PassUpTrap						; T_INVALID_EXCP13		
+
+			.long	PassUpTrap						; T_RUNMODE_TRACE			
+
+			.long	PassUpRupt						; T_SIGP					
+			.long	PassUpTrap						; T_PREEMPT				
+			.long	conswtch						; T_CSWITCH				
+			.long	PassUpRupt						; T_SHUTDOWN				
+			.long	PassUpAbend						; T_CHOKE					
+
+			.long	EXT(handleDSeg)					; T_DATA_SEGMENT			
+			.long	EXT(handleISeg)					; T_INSTRUCTION_SEGMENT	
+
+			.long	WhoaBaby						; T_SOFT_PATCH			
+			.long	WhoaBaby						; T_MAINTENANCE			
+			.long	WhoaBaby						; T_INSTRUMENTATION		
+
+;
+;			Just what the heck happened here????
+;
+
+			.align	5
+			
+WhoaBaby:	b		.								; Open the hood and wait for help
+
+													
+;
+;			System call
+;
+		
+			.align	5
+
+xcpSyscall:	lis		r20,hi16(EXT(shandler))			; Assume this is a normal one, get handler address
+			rlwinm	r6,r0,1,0,31					; Move sign bit to the end 
+			ori		r20,r20,lo16(EXT(shandler))		; Assume this is a normal one, get handler address
+			bnl++	cr0,PassUp						; R0 not 0b10xxx...x, can not be any kind of magical system call, just pass it up...
+			lwz		r7,savesrr1+4(r13)				; Get the entering MSR (low half)
+			lwz		r1,dgFlags(0)					; Get the flags
 			cmplwi	cr2,r6,1						; See if original R0 had the CutTrace request code in it 
-			stwx	r22,r12,r11						; Store it back
 			
-			beq-	cr3,EatRupt						; Interrupt was all for nothing... 
-			cmplwi	cr3,r11,T_MACHINE_CHECK			; Did we get a machine check?
-			bne+	cr1,noCutT						; Not a system call...
-			bnl+	cr0,noCutT						; R0 not 0b10xxx...x, can not be any kind of magical system call...
 			rlwinm.	r7,r7,0,MSR_PR_BIT,MSR_PR_BIT	; Did we come from user state?
-			lis		r1,hi16(EXT(dgWork))			; Get the diagnostics flags
-			beq+	FCisok							; From supervisor state...
+			beq++	FCisok							; From supervisor state...
 
-			ori		r1,r1,lo16(EXT(dgWork))			; Again
-			lwz		r1,dgFlags(r1)					; Get the flags
 			rlwinm.	r1,r1,0,enaUsrFCallb,enaUsrFCallb	; Are they valid?
-			beq-	noCutT							; No...
+			beq++	PassUp							; No, treat as a normal one...
 
-FCisok:		beq-	cr2,isCutTrace					; This is a CutTrace system call...
+FCisok:		beq++	cr2,EatRupt						; This is a CutTrace system call, we are done with it...
 			
 ;
 ;			Here is where we call the firmware.  If it returns T_IN_VAIN, that means
 ;			that it has handled the interruption.  Remember: thou shalt not trash R13
-;			or R20 while you are away.  Anything else is ok.
+;			while you are away.  Anything else is ok.
 ;			
 
-			lwz		r3,saver3(r13)					; Restore the first parameter
-			bl		EXT(FirmwareCall)				; Go handle the firmware call....
-
-			cmplwi	r3,T_IN_VAIN					; Was it handled? 
-			mfsprg	r2,0							; Restore the per_proc
-			beq+	EatRupt							; Interrupt was handled...
-			mr		r11,r3							; Put the rupt code into the right register
-			b		filter							; Go to the normal system call handler...
-		
-			.align	5
-			
-isCutTrace:				
-			li		r7,-32768						; Get a 0x8000 for the exception code
-			bne-	cr5,EatRupt						; Tracing is disabled...
-			sth		r7,LTR_excpt(r20)				; Modify the exception type to a CutTrace
-			b		EatRupt							; Time to go home... 
-
-;			We are here because we did not have a CutTrace system call
-
-			.align	5
-
-noCutT:		beq-	cr3,MachineCheck				; Whoa... Machine check...
+			lwz		r3,saver3+4(r13)				; Restore the first parameter
+			b		EXT(FirmwareCall)				; Go handle the firmware call....
 
 ;
-;			The following interrupts are the only ones that can be redriven
-;			by the higher level code or emulation routines.
+;			Here is where we return from the firmware call
 ;
 
-Redrive:	cmplwi	cr0,r11,T_IN_VAIN				; Did the signal handler eat the signal?
-			mfsprg	r2,0							; Get the per_proc block 
-			beq+	cr0,EatRupt						; Bail now if we ate the rupt...
+			.align	5
+			.globl	EXT(FCReturn)
 
+LEXT(FCReturn)
+			cmplwi	r3,T_IN_VAIN					; Was it handled? 
+			beq+	EatRupt							; Interrupt was handled...
+			mr		r11,r3							; Put the rupt code into the right register
+			b		Redrive							; Go through the filter again...
+		
 
 ;
-;			Here ss where we check for the other fast-path exceptions: translation exceptions,
-;			emulated instructions, etc.
+;			Here is where we return from the PTE miss and segment exception handler
 ;
 
-filter:		cmplwi	cr3,r11,T_ALTIVEC_ASSIST		; Check for an Altivec denorm assist
-			cmplwi	cr4,r11,T_ALIGNMENT				; See if we got an alignment exception
-			cmplwi	cr1,r11,T_PROGRAM				; See if we got a program exception
-			cmplwi	cr2,r11,T_INSTRUCTION_ACCESS	; Check on an ISI 
-			bne+	cr3,noAltivecAssist				; It is not an assist...
-			b		EXT(AltivecAssist)				; It is an assist...
-	
 			.align	5
+			.globl	EXT(PFSExit)
 
-noAltivecAssist:
-			bne+	cr4,noAlignAssist				; No alignment here...
-			b		EXT(AlignAssist)				; Go try to emulate...
+LEXT(PFSExit)
 
-			.align	5
+#if 0
+			mfsprg	r2,0							; (BRINGUP)
+			lwz		r0,savedsisr(r13)				; (BRINGUP)
+			andis.	r0,r0,hi16(dsiAC)				; (BRINGUP)
+			beq++	didnthit						; (BRINGUP)
+			lwz		r0,20(0)						; (BRINGUP)
+			mr.		r0,r0							; (BRINGUP)
+			bne--	didnthit						; (BRINGUP)
+#if 0
+			li		r0,1							; (BRINGUP)
+			stw		r0,20(0)						; (BRINGUP)
+			lis		r0,hi16(Choke)					; (BRINGUP)
+			ori		r0,r0,lo16(Choke)				; (BRINGUP)
+			sc										; (BRINGUP)
+#endif
+			
+			lwz		r4,savesrr0+4(r13)				; (BRINGUP)
+			lwz		r8,savesrr1+4(r13)				; (BRINGUP)
+			lwz		r6,savedar+4(r13)				; (BRINGUP)
+			rlwinm.	r0,r8,0,MSR_IR_BIT,MSR_IR_BIT	; (BRINGUP)
+			mfmsr	r9								; (BRINGUP)
+			ori		r0,r9,lo16(MASK(MSR_DR))		; (BRINGUP)
+			beq--	hghg							; (BRINGUP)
+			mtmsr	r0								; (BRINGUP)
+			isync									; (BRINGUP)
+
+hghg:		lwz		r5,0(r4)						; (BRINGUP)
+			beq--	hghg1							; (BRINGUP)
+			mtmsr	r9								; (BRINGUP)
+			isync									; (BRINGUP)
+
+hghg1:		rlwinm	r7,r5,6,26,31					; (BRINGUP)
+			rlwinm	r27,r5,14,24,28					; (BRINGUP)
+			addi	r3,r13,saver0+4					; (BRINGUP)
+			lwzx	r3,r3,r27						; (BRINGUP)
+			
+#if 0
+			lwz		r27,patcharea+4(r2)				; (BRINGUP)
+			mr.		r3,r3							; (BRINGUP)
+			bne++	nbnbnb							; (BRINGUP)
+			addi	r27,r27,1						; (BRINGUP)
+			stw		r27,patcharea+4(r2)				; (BRINGUP)
+nbnbnb:					
+#endif			
+			
+			rlwinm.	r28,r8,0,MSR_DR_BIT,MSR_DR_BIT	; (BRINGUP)
+			rlwinm	r27,r6,0,0,29					; (BRINGUP)
+			ori		r28,r9,lo16(MASK(MSR_DR))		; (BRINGUP)
+			mfspr	r10,dabr						; (BRINGUP)
+			li		r0,0							; (BRINGUP)
+			mtspr	dabr,r0							; (BRINGUP)
+			cmplwi	cr1,r7,31						; (BRINGUP) 
+			beq--	qqq0							; (BRINGUP)
+			mtmsr	r28								; (BRINGUP)
+qqq0:
+			isync									; (BRINGUP)
+			
+			lwz		r27,0(r27)						; (BRINGUP) - Get original value
+			
+			bne		cr1,qqq1						; (BRINGUP)
+			
+			rlwinm	r5,r5,31,22,31					; (BRINGUP)
+			cmplwi	cr1,r5,151						; (BRINGUP)			
+			beq		cr1,qqq3						; (BRINGUP)
+			cmplwi	cr1,r5,407						; (BRINGUP)			
+			beq		cr1,qqq2						; (BRINGUP)
+			cmplwi	cr1,r5,215						; (BRINGUP)			
+			beq		cr1,qqq0q						; (BRINGUP)
+			cmplwi	cr1,r5,1014						; (BRINGUP)
+			beq		cr1,qqqm1						; (BRINGUP)
+
+			lis		r0,hi16(Choke)					; (BRINGUP)
+			ori		r0,r0,lo16(Choke)				; (BRINGUP)
+			sc										; (BRINGUP)
+			
+qqqm1:		rlwinm	r7,r6,0,0,26					; (BRINGUP)
+			stw		r0,0(r7)						; (BRINGUP)
+			stw		r0,4(r7)						; (BRINGUP)
+			stw		r0,8(r7)						; (BRINGUP)
+			stw		r0,12(r7)						; (BRINGUP)
+			stw		r0,16(r7)						; (BRINGUP)
+			stw		r0,20(r7)						; (BRINGUP)
+			stw		r0,24(r7)						; (BRINGUP)
+			stw		r0,28(r7)						; (BRINGUP)
+			b		qqq9
+		
+qqq1:		cmplwi	r7,38							; (BRINGUP)
+			bgt		qqq2							; (BRINGUP)
+			blt		qqq3							; (BRINGUP)
 
-noAlignAssist:
-			bne+	cr1,noEmulate					; No emulation here...
-			b		EXT(Emulate)					; Go try to emulate...
+qqq0q:		stb		r3,0(r6)						; (BRINGUP)
+			b		qqq9							; (BRINGUP)
+			
+qqq2:		sth		r3,0(r6)						; (BRINGUP)
+			b		qqq9							; (BRINGUP)
+			
+qqq3:		stw		r3,0(r6)						; (BRINGUP)
+			
+qqq9:		
+#if 0
+			rlwinm	r7,r6,0,0,29					; (BRINGUP)
+			lwz		r0,0(r7)						; (BRINGUP) - Get newest value
+#else
+			lis		r7,hi16(0x000792B8)				; (BRINGUP)
+			ori		r7,r7,lo16(0x000792B8)			; (BRINGUP)
+			lwz		r0,0(r7)						; (BRINGUP) - Get newest value
+#endif
+			mtmsr	r9								; (BRINGUP)
+			mtspr	dabr,r10						; (BRINGUP)
+			isync									; (BRINGUP)
 
-			.align	5
+#if 0
+			lwz		r28,patcharea+12(r2)			; (BRINGUP)
+			mr.		r28,r28							; (BRINGUP)
+			bne++	qqq12							; (BRINGUP)
+			lis		r28,0x4000						; (BRINGUP)
+
+qqq12:		stw		r27,0(r28)						; (BRINGUP)
+			lwz		r6,savedar+4(r13)				; (BRINGUP)
+			stw		r0,4(r28)						; (BRINGUP)
+			stw		r4,8(r28)						; (BRINGUP)
+			stw		r6,12(r28)						; (BRINGUP)
+			addi	r28,r28,16						; (BRINGUP)
+			mr.		r3,r3							; (BRINGUP)
+			stw		r28,patcharea+12(r2)			; (BRINGUP)
+			lwz		r10,patcharea+8(r2)				; (BRINGUP)
+			lwz		r0,patcharea+4(r2)				; (BRINGUP)
+#endif
 
-noEmulate:	cmplwi	cr3,r11,T_CSWITCH				; Are we context switching 
-			cmplwi	r11,T_DATA_ACCESS				; Check on a DSI 
-			beq-	cr2,DSIorISI					; It is a PTE fault...
-			beq-	cr3,conswtch					; It is a context switch... 
-			bne+	PassUp							; It is not a PTE fault...
+#if 1
+			stw		r0,patcharea(r2)				; (BRINGUP)
+#endif
 
-;
-;			This call will either handle the fault, in which case it will not
-;			return, or return to pass the fault up the line.
-;
+#if 0
+			xor		r28,r0,r27						; (BRINGUP) - See how much it changed
+			rlwinm	r28,r28,24,24,31				; (BRINGUP)
+			cmplwi	r28,1							; (BRINGUP)
+
+			ble++	qqq10							; (BRINGUP)
+
+			mr		r7,r0							; (BRINGUP)
+			li		r0,1							; (BRINGUP)
+			stw		r0,20(0)						; (BRINGUP)
+			lis		r0,hi16(Choke)					; (BRINGUP)
+			ori		r0,r0,lo16(Choke)				; (BRINGUP)
+			sc										; (BRINGUP)
+#endif
 
-DSIorISI:	mr		r3,r11							; Move the rupt code
-			
-			bl		EXT(handlePF)					; See if we can handle this fault
 
-			lwz		r0,savesrr1(r13)				; Get the MSR in use at exception time
-			mfsprg	r2,0							; Get back per_proc 
-			cmplwi	cr1,r3,T_IN_VAIN				; Was it handled?
-			andi.	r4,r0,lo16(MASK(MSR_RI))		; See if the recover bit is on
-			mr		r11,r3							; Put interrupt code back into the right register
-			beq+	cr1,EatRupt						; Yeah, just blast back to the user... 
-			beq+	PassUp							; Not on, normal case...
+qqq10:		addi	r4,r4,4							; (BRINGUP)
+			stw		r4,savesrr0+4(r13)				; (BRINGUP)
+				
+			li		r11,T_IN_VAIN					; (BRINGUP)
+			b		EatRupt							; (BRINGUP)
+			
+didnthit:											; (BRINGUP)
+#endif
+#if 0
+			lwz		r0,20(0)						; (BRINGUP)
+			mr.		r0,r0							; (BRINGUP)
+			beq++	opopop							; (BRINGUP)
+			li		r0,0							; (BRINGUP)
+			stw		r0,20(0)						; (BRINGUP)
+			lis		r0,hi16(Choke)					; (BRINGUP)
+			ori		r0,r0,lo16(Choke)				; (BRINGUP)
+			sc										; (BRINGUP)
+opopop:
+#endif
+			lwz		r0,savesrr1+4(r13)				; Get the MSR in use at exception time
+			cmplwi	cr1,r11,T_IN_VAIN				; Was it handled?
+			rlwinm.	r4,r0,0,MSR_PR_BIT,MSR_PR_BIT	; Are we trapping from supervisor state?
+			beq++	cr1,EatRupt						; Yeah, just blast back to the user... 
+			beq--	NoFamPf
+			mfsprg	r2,0							; Get back per_proc
+			lwz		r1,spcFlags(r2)					; Load spcFlags
+            rlwinm	r1,r1,1+FamVMmodebit,30,31		; Extract FamVMenabit and FamVMmodebit
+            cmpi	cr0,r1,2						; Check FamVMena set without FamVMmode
+			bne--	cr0,NoFamPf
+            lwz		r6,FAMintercept(r2)				; Load exceptions mask to intercept
+			li		r5,0							; Clear
+			srwi	r1,r11,2						; divide r11 by 4
+            oris	r5,r5,0x8000					; Set r5 to 0x80000000
+            srw		r1,r5,r1						; Set bit for current exception
+            and.	r1,r1,r6						; And current exception with the intercept mask
+            beq++	NoFamPf							; Is it FAM intercept
+			bl		EXT(vmm_fam_pf)
+			b		EatRupt
+
+NoFamPf:	andi.	r4,r0,lo16(MASK(MSR_RI))		; See if the recover bit is on
+			lis		r0,0x8000						; Get 0xFFFFFFFF80000000
+			add		r0,r0,r0						; Get 0xFFFFFFFF00000000
+			beq++	PassUpTrap						; Not on, normal case...
 ;
 ;			Here is where we handle the "recovery mode" stuff.
 ;			This is set by an emulation routine to trap any faults when it is fetching data or
@@ -1360,35 +1906,49 @@ DSIorISI:	mr		r3,r11							; Move the rupt code
 ;			If we get a fault, we turn off RI, set CR0_EQ to false, bump the PC, and set R0
 ;			and R1 to the DAR and DSISR, respectively.
 ;
-			lwz		r4,savesrr0(r13)				; Get the failing instruction address
+			lwz		r3,savesrr0(r13)				; Get the failing instruction address
+			lwz		r4,savesrr0+4(r13)				; Get the failing instruction address
 			lwz		r5,savecr(r13)					; Get the condition register
-			addi	r4,r4,4							; Skip failing instruction
-			lwz		r6,savedar(r13)					; Get the DAR
+			or		r4,r4,r0						; Fill the high part with foxes
+			lwz		r0,savedar(r13)					; Get the DAR
+			addic	r4,r4,4							; Skip failing instruction
+			lwz		r6,savedar+4(r13)				; Get the DAR
+			addze	r3,r3							; Propagate carry
 			rlwinm	r5,r5,0,3,1						; Clear CR0_EQ to let emulation code know we failed
 			lwz		r7,savedsisr(r13)				; Grab the DSISR
-			stw		r0,savesrr1(r13)				; Save the result MSR
-			stw		r4,savesrr0(r13)				; Save resume address
+			stw		r3,savesrr0(r13)				; Save resume address
+			stw		r4,savesrr0+4(r13)				; Save resume address
 			stw		r5,savecr(r13)					; And the resume CR
-			stw		r6,saver0(r13)					; Pass back the DAR
-			stw		r7,saver1(r13)					; Pass back the DSISR
+			stw		r0,saver0(r13)					; Pass back the DAR
+			stw		r6,saver0+4(r13)				; Pass back the DAR
+			stw		r7,saver1+4(r13)				; Pass back the DSISR
 			b		EatRupt							; Resume emulated code
 
 ;
 ;			Here is where we handle the context switch firmware call.  The old 
-;			context has been saved, and the new savearea in in saver3.  We will just
+;			context has been saved. The new savearea is in kind of hokey, the high order
+;			half is stored in saver7 and the low half is in saver3. We will just
 ;			muck around with the savearea pointers, and then join the exit routine 
 ;
 
 			.align	5
 
 conswtch:	
+			li		r0,0xFFF						; Get page boundary
 			mr		r29,r13							; Save the save
-			rlwinm	r30,r13,0,0,19					; Get the start of the savearea block
-			lwz		r5,saver3(r13)					; Switch to the new savearea
-			lwz		r30,SACvrswap(r30)				; get real to virtual translation
+			andc	r30,r13,r0						; Round down to page boundary (64-bit safe)
+			lwz		r5,saver3+4(r13)				; Switch to the new savearea
+			bf--	pf64Bitb,xcswNo64				; Not 64-bit...
+			lwz		r6,saver7+4(r13)				; Get the high order half
+			sldi	r6,r6,32						; Position high half
+			or		r5,r5,r6						; Merge them
+
+xcswNo64:	lwz		r30,SACvrswap+4(r30)			; get real to virtual translation
 			mr		r13,r5							; Switch saveareas
+			li		r0,0							; Clear this
 			xor		r27,r29,r30						; Flip to virtual
-			stw		r27,saver3(r5)					; Push the new savearea to the switch to routine
+			stw		r0,saver3(r5)					; Push the new virtual savearea to the switch to routine
+			stw		r27,saver3+4(r5)				; Push the new virtual savearea to the switch to routine
 			b		EatRupt							; Start it up... 
 
 ;
@@ -1401,89 +1961,437 @@ conswtch:
 
 MachineCheck:
 
-			lwz		r27,savesrr1(r13)				; ?
-			rlwinm.	r11,r27,0,dcmck,dcmck			; ?
-			beq+	notDCache						; ?
+			bt++	pf64Bitb,mck64					; ?
+			
+			lwz		r27,savesrr1+4(r13)				; Pick up srr1
+
+;
+;			Check if the failure was in 
+;			ml_probe_read.  If so, this is expected, so modify the PC to
+;			ml_proble_read_mck and then eat the exception.
+;
+			lwz		r30,savesrr0+4(r13)				; Get the failing PC
+			lis		r28,hi16(EXT(ml_probe_read_mck))	; High order part
+			lis		r27,hi16(EXT(ml_probe_read))	; High order part
+			ori		r28,r28,lo16(EXT(ml_probe_read_mck))	; Get the low part
+			ori		r27,r27,lo16(EXT(ml_probe_read))	; Get the low part
+			cmplw	r30,r28							; Check highest possible
+			cmplw	cr1,r30,r27						; Check lowest
+			bge-	PassUpTrap						; Outside of range
+			blt-	cr1,PassUpTrap					; Outside of range
+;
+;			We need to fix up the BATs here because the probe
+;			routine messed them all up... As long as we are at it,
+;			fix up to return directly to caller of probe.
+;
+		
+			lis		r11,hi16(EXT(shadow_BAT)+shdDBAT)	; Get shadow address
+			ori		r11,r11,lo16(EXT(shadow_BAT)+shdDBAT)	; Get shadow address
+			
+			lwz		r30,0(r11)						; Pick up DBAT 0 high
+			lwz		r28,4(r11)						; Pick up DBAT 0 low
+			lwz		r27,8(r11)						; Pick up DBAT 1 high
+			lwz		r18,16(r11)						; Pick up DBAT 2 high
+			lwz		r11,24(r11)						; Pick up DBAT 3 high
+			
+			sync
+			mtdbatu	0,r30							; Restore DBAT 0 high
+			mtdbatl	0,r28							; Restore DBAT 0 low
+			mtdbatu	1,r27							; Restore DBAT 1 high
+			mtdbatu	2,r18							; Restore DBAT 2 high
+			mtdbatu	3,r11							; Restore DBAT 3 high 
+			sync
+
+			lwz		r28,savelr+4(r13)				; Get return point
+			lwz		r27,saver0+4(r13)				; Get the saved MSR
+			li		r30,0							; Get a failure RC
+			stw		r28,savesrr0+4(r13)				; Set the return point
+			stw		r27,savesrr1+4(r13)				; Set the continued MSR
+			stw		r30,saver3+4(r13)				; Set return code
+			b		EatRupt							; Yum, yum, eat it all up...
+
+;
+;			64-bit machine checks
+;
+
+mck64:		
+
+;
+;			NOTE: WE NEED TO RETHINK RECOVERABILITY A BIT - radar 3167190
+;
+
+			ld		r23,savesrr0(r13)				; Grab the SRR0 in case we need bad instruction
+			ld		r20,savesrr1(r13)				; Grab the SRR1 so we can decode the thing
+			lwz		r21,savedsisr(r13)				; We might need this in a bit
+			ld		r22,savedar(r13)				; We might need this in a bit
+
+			lis		r8,AsyMCKSrc					; Get the Async MCK Source register address
+			mfsprg	r19,2							; Get the feature flags
+			ori		r8,r8,0x8000					; Set to read data
+			rlwinm.	r0,r19,0,pfSCOMFixUpb,pfSCOMFixUpb	; Do we need to fix the SCOM data?
 			
-			mfspr	r11,msscr0						; ?
-			dssall									; ?
 			sync
+
+			mtspr	scomc,r8						; Request the MCK source
+			mfspr	r24,scomd						; Get the source
+			mfspr	r8,scomc						; Get back the status (we just ignore it)
+			sync
+			isync							
+
+			lis		r8,AsyMCKRSrc					; Get the Async MCK Source AND mask address
+			li		r9,0							; Get and AND mask of 0
 			
-			lwz		r27,savesrr1(r13)				; ?
+			sync
 
-hiccup:		cmplw	r27,r27							; ?
-			bne-	hiccup							; ?
-			isync									; ?
+			mtspr	scomd,r9						; Set the AND mask to 0
+			mtspr	scomc,r8						; Write the AND mask and clear conditions
+			mfspr	r8,scomc						; Get back the status (we just ignore it)
+			sync
+			isync							
+
+			lis		r8,cFIR							; Get the Core FIR register address
+			ori		r8,r8,0x8000					; Set to read data
+			
+			sync
+
+			mtspr	scomc,r8						; Request the Core FIR
+			mfspr	r25,scomd						; Get the source
+			mfspr	r8,scomc						; Get back the status (we just ignore it)
+			sync
+			isync							
+			
+			lis		r8,cFIRrst						; Get the Core FIR AND mask address
+			
+			sync
+
+			mtspr	scomd,r9						; Set the AND mask to 0
+			mtspr	scomc,r8						; Write the AND mask and clear conditions
+			mfspr	r8,scomc						; Get back the status (we just ignore it)
+			sync
+			isync							
+			
+;			Note: bug in early chips where scom reads are shifted right by 1. We fix that here.
+;			Also note that we will lose bit 63
+
+			beq++	mckNoFix						; No fix up is needed
+			sldi	r24,r24,1						; Shift left 1
+			sldi	r25,r25,1						; Shift left 1
+			
+mckNoFix:	std		r24,savemisc0(r13)				; Save the MCK source in case we pass the error
+			std		r25,savemisc1(r13)				; Save the Core FIR in case we pass the error
+
+			rlwinm.	r0,r20,0,mckIFUE-32,mckIFUE-32	; Is this some kind of uncorrectable?
+			bne		mckUE							; Yeah...
+			
+			rlwinm.	r0,r20,0,mckLDST-32,mckLDST-32	; Some kind of load/store error?
+			bne		mckHandleLDST					; Yes...
+			
+			rldicl.	r0,r20,46,62					; Get the error cause code
+			beq		mckNotSure						; We need some more checks for this one...
+			
+			cmplwi	r0,2							; Check for TLB parity error
+			blt		mckSLBparity					; This is an SLB parity error...
+			bgt		mckhIFUE						; This is an IFetch tablewalk reload UE...
+			
+;			IFetch TLB parity error
+
+			isync
+			tlbiel	r23								; Locally invalidate TLB entry for iaddr
+			sync									; Wait for it
+			b		EatRupt							; All recovered...
+			
+;			SLB parity error.  This could be software caused.  We get one if there is
+;			more than 1 valid SLBE with a matching ESID. That one we do not want to
+;			try to recover from.  Search for it and if we get it, panic. 
+
+mckSLBparity:
+			crclr	cr0_eq							; Make sure we are not equal so we take correct exit
+
+			la		r3,emvr0(r2)					; Use this to keep track of valid ESIDs we find
+			li		r5,0							; Start with index 0
+
+mckSLBck:	la		r4,emvr0(r2)					; Use this to keep track of valid ESIDs we find
+			slbmfee	r6,r5							; Get the next SLBE
+			andis.	r0,r6,0x0800					; See if valid bit is on
+			beq		mckSLBnx						; Skip invalid and go to next
+			
+mckSLBck2:	cmpld	r4,r3							; Have we reached the end of the table?
+			beq		mckSLBne						; Yes, go enter this one...
+			ld		r7,0(r4)						; Pick up the saved ESID
+			cmpld	r6,r7							; Is this a match?
+			beq		mckSLBrec						; Whoops, I did bad, recover and pass up...
+			addi	r4,r4,8							; Next table entry
+			b		mckSLBck2						; Check the next...
+
+mckSLBnx:	addi	r5,r5,1							; Point to next SLBE
+			cmplwi	r5,64							; Have we checked all of them?
+			bne++	mckSLBck						; Not yet, check again...
+			b		mckSLBrec						; We looked at them all, go recover...
+			
+mckSLBne:	std		r6,0(r3)						; Save this ESID
+			addi	r3,r3,8							; Point to the new slot
+			b		mckSLBnx						; Go do the next SLBE...
+			
+;			Recover an SLB error
+			
+mckSLBrec:	li		r0,0							; Set an SLB slot index of 0
+			slbia									; Trash all SLB entries (except for entry 0 that is)
+			slbmfee	r7,r0							; Get the entry that is in SLB index 0
+			rldicr	r7,r7,0,35						; Clear the valid bit and the rest
+			slbie	r7								; Invalidate it
+			
+			li		r3,0							; Set the first SLBE
+			
+mckSLBclr:	slbmte	r0,r3							; Clear the whole entry to 0s
+			addi	r3,r3,1							; Bump index
+			cmplwi	cr1,r3,64						; Have we done them all?
+			bne++	cr1,mckSLBclr					; Yup....
+			
+			sth		r3,ppInvSeg(r2)					; Store non-zero to trigger SLB reload 
+			bne++	EatRupt							; This was not a programming error, all recovered...
+			b		PassUpTrap						; Pass the software error up...
+
+;
+;			Handle a load/store unit error.  We need to decode the DSISR
+;
+
+mckHandleLDST:
+			rlwinm.	r0,r21,0,mckL1DCPE,mckL1DCPE	; An L1 data cache parity error?
+			bne++	mckL1D							; Yeah, we dealt with this back in the vector...
+		
+			rlwinm.	r0,r21,0,mckL1DTPE,mckL1DTPE	; An L1 tag error?
+			bne++	mckL1T							; Yeah, we dealt with this back in the vector...
+		
+			rlwinm.	r0,r21,0,mckUEdfr,mckUEdfr		; Is the a "deferred" UE?
+			bne		mckDUE							; Yeah, go see if expected...
+		
+			rlwinm.	r0,r21,0,mckUETwDfr,mckUETwDfr	; Is the a "deferred" tablewalk UE?
+			bne		mckDTW							; Yeah, no recovery...
+			
+			rlwinm.	r0,r21,0,mckSLBPE,mckSLBPE		; SLB parity error?
+			bne		mckSLBparity					; Yeah, go attempt recovery....
+			
+;			This is a recoverable D-ERAT or TLB error
+
+			la		r9,hwMckERCPE(r2)				; Get DERAT parity error count
+
+mckInvDAR:	isync
+			tlbiel	r22								; Locally invalidate the TLB entry
+			sync
+			
+			lwz		r21,0(r9)						; Get count
+			addi	r21,r21,1						; Count this one
+			stw		r21,0(r9)						; Stick it back
+			
+			b		EatRupt							; All recovered...
+		
+;
+;			When we come here, we are not quite sure what the error is.  We need to
+;			dig a bit further.
+;
+;			R24 is interrupt source
+;			R25 is Core FIR
+;
+;			Note that both have been cleared already.
+;
+
+mckNotSure:
+			rldicl.	r0,r24,AsyMCKfir+1,63			; Something in the FIR?
+			bne--	mckFIR							; Yup, go check some more...
+			
+			rldicl.	r0,r24,AsyMCKhri+1,63			; Hang recovery?
+			bne--	mckHangRcvr						; Yup...
+			
+			rldicl.	r0,r24,AsyMCKext+1,63			; External signal?
+			bne--	mckExtMck						; Yup...
+
+;
+;			We really do not know what this one is or what to do with it...
+;
+			
+mckUnk:		lwz		r21,hwMckUnk(r2)				; Get unknown error count
+			addi	r21,r21,1						; Count it
+			stw		r21,hwMckUnk(r2)				; Stuff it
+			b		PassUpTrap						; Go south, young man...
+
+;
+;			Hang recovery.  This is just a notification so we only count.
+;
+			
+mckHangRcrvr:
+			lwz		r21,hwMckHang(r2)				; Get hang recovery count
+			addi	r21,r21,1						; Count this one
+			stw		r21,hwMckHang(r2)				; Stick it back
+			b		EatRupt							; All recovered...
+
+;
+;			Externally signaled MCK.  No recovery for the moment, but we this may be
+;			where we handle ml_probe_read problems eventually.
+;			
+mckExtMck:
+			lwz		r21,hwMckHang(r2)				; Get hang recovery count
+			addi	r21,r21,1						; Count this one
+			stw		r21,hwMckHang(r2)				; Stick it back
+			b		EatRupt							; All recovered...
+
+;
+;			Machine check cause is in a FIR.  Suss it out here.
+;			Core FIR is in R25 and has been cleared in HW.
+;			
+
+mckFIR:		rldicl.	r0,r25,cFIRICachePE+1,63		; I-Cache parity error?
+			la		r19,hwMckICachePE(r2)			; Point to counter
+			bne		mckInvICache					; Go invalidate I-Cache...
+
+			rldicl.	r0,r25,cFIRITagPE0+1,63			; I-Cache tag parity error?
+			la		r19,hwMckITagPE(r2)				; Point to counter
+			bne		mckInvICache					; Go invalidate I-Cache...
+
+			rldicl.	r0,r25,cFIRITagPE1+1,63			; I-Cache tag parity error?
+			la		r19,hwMckITagPE(r2)				; Point to counter
+			bne		mckInvICache					; Go invalidate I-Cache...
+
+			rldicl.	r0,r25,cFIRIEratPE+1,63			; IERAT parity error?
+			la		r19,hwMckIEratPE(r2)			; Point to counter
+			bne		mckInvERAT						; Go invalidate ERATs...
+
+			rldicl.	r0,r25,cFIRIFUL2UE+1,63			; IFetch got L2 UE?
+			bne		mckhIFUE						; Go count and pass up...
+
+			rldicl.	r0,r25,cFIRDCachePE+1,63		; D-Cache PE?
+			bne		mckL1D							; Handled, just go count...
+
+			rldicl.	r0,r25,cFIRDTagPE+1,63			; D-Cache tag PE?
+			bne		mckL1T							; Handled, just go count...
+
+			rldicl.	r0,r25,cFIRDEratPE+1,63			; DERAT PE?
+			la		r19,hwMckDEratPE(r2)			; Point to counter
+			bne		mckInvERAT						; Go invalidate ERATs...
+
+			rldicl.	r0,r25,cFIRTLBPE+1,63			; TLB PE?
+			la		r9,hwMckTLBPE(r2)				; Get TLB parity error count
+			bne		mckInvDAR						; Go recover...
+
+			rldicl.	r0,r25,cFIRSLBPE+1,63			; SLB PE?
+			bne		mckSLBparity					; Cope with it...
+			
+			b		mckUnk							; Have not a clue...
+
+;
+;			General recovery for I-Cache errors.  Just flush it completely.
+;
+
+			.align	7								; Force into cache line
+
+mckInvICache:
+			lis		r0,0x0080						; Get a 0x0080 (bit 9 >> 32)
+			mfspr	r21,hid1						; Get the current HID1
+			sldi	r0,r0,32						; Get the "forced ICBI match" bit
+			or		r0,r0,r21						; Set forced match
+			
+			isync
+			mtspr	hid1,r0							; Stick it
+			mtspr	hid1,r0							; Stick it again
+			isync
+		
+			li		r6,0							; Start at 0
+			
+mckIcbi:	icbi	0,r6							; Kill I$
+			addi	r6,r6,128						; Next line
+			andis.	r5,r6,1							; Have we done them all?
+			beq++	mckIcbi							; Not yet...
+
+			isync
+			mtspr	hid1,r21						; Restore original HID1
+			mtspr	hid1,r21						; Stick it again
+			isync
 			
-			oris	r11,r11,hi16(dl1hwfm)			; ?
-			mtspr	msscr0,r11						; ?
+			lwz		r5,0(r19)						; Get the counter
+			addi	r5,r5,1							; Count it
+			stw		r5,0(r19)						; Stuff it back
+			b		EatRupt							; All recovered...
 			
-rstbsy:		mfspr	r11,msscr0						; ?
+		
+;			General recovery for ERAT problems - handled in exception vector already
+
+mckInvERAT:	lwz		r21,0(r19)						; Get the exception count spot
+			addi	r21,r21,1						; Count this one
+			stw		r21,0(r19)						; Save count
+			b		EatRupt							; All recovered...
 			
-			rlwinm.	r11,r11,0,dl1hwf,dl1hwf			; ?
-			bne		rstbsy							; ?
+;			General hang recovery - this is a notification only, just count.	
 			
-			sync									; ?
+mckHangRcvr:			
+			lwz		r21,hwMckHang(r2)				; Get hang recovery count
+			addi	r21,r21,1						; Count this one
+			stw		r21,hwMckHang(r2)				; Stick it back
+			b		EatRupt							; All recovered...
 
-			b		EatRupt							; ?
 
-			.align	5
-			
-notDCache:
-;
-;			Check if the failure was in 
-;			ml_probe_read.  If so, this is expected, so modify the PC to
-;			ml_proble_read_mck and then eat the exception.
 ;
-			lwz		r30,savesrr0(r13)				; Get the failing PC
-			lis		r28,hi16(EXT(ml_probe_read_mck))	; High order part
-			lis		r27,hi16(EXT(ml_probe_read))	; High order part
-			ori		r28,r28,lo16(EXT(ml_probe_read_mck))	; Get the low part
-			ori		r27,r27,lo16(EXT(ml_probe_read))	; Get the low part
-			cmplw	r30,r28							; Check highest possible
-			cmplw	cr1,r30,r27						; Check lowest
-			bge-	PassUp							; Outside of range
-			blt-	cr1,PassUp						; Outside of range
-;
-;			We need to fix up the BATs here because the probe
-;			routine messed them all up... As long as we are at it,
-;			fix up to return directly to caller of probe.
+;			These are the uncorrectable errors, just count them then pass it along.
 ;
-		
-			lis		r11,hi16(EXT(shadow_BAT)+shdDBAT)	; Get shadow address
-			ori		r11,r11,lo16(EXT(shadow_BAT)+shdDBAT)	; Get shadow address
-			
-			lwz		r30,0(r11)						; Pick up DBAT 0 high
-			lwz		r28,4(r11)						; Pick up DBAT 0 low
-			lwz		r27,8(r11)						; Pick up DBAT 1 high
-			lwz		r18,16(r11)						; Pick up DBAT 2 high
-			lwz		r11,24(r11)						; Pick up DBAT 3 high
+	
+mckUE:		lwz		r21,hwMckUE(r2)					; Get general uncorrectable error count
+			addi	r21,r21,1						; Count it
+			stw		r21,hwMckUE(r2)					; Stuff it
+			b		PassUpTrap						; Go south, young man...
+	
+mckhIFUE:	lwz		r21,hwMckIUEr(r2)				; Get I-Fetch TLB reload uncorrectable error count
+			addi	r21,r21,1						; Count it
+			stw		r21,hwMckIUEr(r2)				; Stuff it
+			b		PassUpTrap						; Go south, young man...
+
+mckDUE:		lwz		r21,hwMckDUE(r2)				; Get deferred uncorrectable error count
+			addi	r21,r21,1						; Count it
+			stw		r21,hwMckDUE(r2)				; Stuff it
+			
+;
+;			Right here is where we end up after a failure on a ml_probe_read_64.
+;			We will check if that is the case, and if so, fix everything up and
+;			return from it.
+			
+			lis		r8,hi16(EXT(ml_probe_read_64))	; High of start
+			lis		r9,hi16(EXT(ml_probe_read_mck_64))	; High of end
+			ori		r8,r8,lo16(EXT(ml_probe_read_64))	; Low of start
+			ori		r9,r9,lo16(EXT(ml_probe_read_mck_64))	; Low of end
+			cmpld	r23,r8							; Too soon?
+			cmpld	cr1,r23,r9						; Too late?
+			
+			cror	cr0_lt,cr0_lt,cr1_gt			; Too soo or too late?
+			ld		r3,saver12(r13)					; Get the original MSR
+			ld		r5,savelr(r13)					; Get the return address
+			li		r4,0							; Get fail code
+			blt--	PassUpTrap						; This is a normal machine check, just pass up...
+			std		r5,savesrr0(r13)				; Set the return MSR
+			
+			std		r3,savesrr1(r13)				; Set the return address
+			std		r4,saver3(r13)					; Set failure return code
+			b		EatRupt							; Go return from ml_probe_read_64...
+
+mckDTW:		lwz		r21,hwMckDTW(r2)				; Get deferred tablewalk uncorrectable error count
+			addi	r21,r21,1						; Count it
+			stw		r21,hwMckDTW(r2)				; Stuff it
+			b		PassUpTrap						; Go south, young man...
+
+mckL1D:		lwz		r21,hwMckL1DPE(r2)				; Get data cache parity error count
+			addi	r21,r21,1						; Count it
+			stw		r21,hwMckL1DPE(r2)				; Stuff it
+			b		PassUpTrap						; Go south, young man...
+
+mckL1T:		lwz		r21,hwMckL1TPE(r2)				; Get TLB parity error count
+			addi	r21,r21,1						; Count it
+			stw		r21,hwMckL1TPE(r2)				; Stuff it
+			b		PassUpTrap						; Go south, young man...
 			
-			sync
-			mtdbatu	0,r30							; Restore DBAT 0 high
-			mtdbatl	0,r28							; Restore DBAT 0 low
-			mtdbatu	1,r27							; Restore DBAT 1 high
-			mtdbatu	2,r18							; Restore DBAT 2 high
-			mtdbatu	3,r11							; Restore DBAT 3 high 
-			sync
-
-			lwz		r27,saver6(r13)					; Get the saved R6 value
-			mtspr		hid0,r27					; Restore HID0
-			isync
-
-			lwz		r28,savelr(r13)					; Get return point
-			lwz		r27,saver0(r13)					; Get the saved MSR
-			li		r30,0							; Get a failure RC
-			stw		r28,savesrr0(r13)				; Set the return point
-			stw		r27,savesrr1(r13)				; Set the continued MSR
-			stw		r30,saver3(r13)					; Set return code
-			b		EatRupt							; Yum, yum, eat it all up...
 
 /*
  *			Here's where we come back from some instruction emulator.  If we come back with
  *			T_IN_VAIN, the emulation is done and we should just reload state and directly
  *			go back to the interrupted code. Otherwise, we'll check to see if
  *			we need to redrive with a different interrupt, i.e., DSI.
+ *			Note that this we are actually not redriving the rupt, rather changing it
+ *			into a different one.  Thus we clear the redrive bit.
  */
  
 			.align	5
@@ -1491,18 +2399,15 @@ notDCache:
 
 LEXT(EmulExit)
 
-			cmplwi	r11,T_IN_VAIN					; Was it emulated? 
+			cmplwi	cr1,r11,T_IN_VAIN				; Was it emulated?
 			lis		r1,hi16(SAVredrive)				; Get redrive request
-			mfsprg	r2,0							; Restore the per_proc area
-			beq+	EatRupt							; Yeah, just blast back to the user...
+			beq++	cr1,EatRupt						; Yeah, just blast back to the user...
 			lwz		r4,SAVflags(r13)				; Pick up the flags
 
 			and.	r0,r4,r1						; Check if redrive requested
-			andc	r4,r4,r1						; Clear redrive
 
-			beq+	PassUp							; No redrive, just keep on going...
+			beq++	PassUpTrap						; No redrive, just keep on going...
 
-			stw		r4,SAVflags(r13)				; Set the flags
 			b		Redrive							; Redrive the exception...
 		
 ;
@@ -1512,41 +2417,106 @@ LEXT(EmulExit)
 ; 			memory, otherwise we would need to switch on (at least) virtual data.
 ;			SRs are already set up.
 ;
-
+	
+			.align	5
+	
+PassUpTrap:	lis		r20,hi16(EXT(thandler))			; Get thandler address
+			ori		r20,r20,lo16(EXT(thandler))		; Get thandler address
+			b		PassUp							; Go pass it up...
+	
+PassUpRupt:	lis		r20,hi16(EXT(ihandler))			; Get ihandler address
+			ori		r20,r20,lo16(EXT(ihandler))		; Get ihandler address
+			b		PassUp							; Go pass it up...
+	
+			.align	5
+	
+PassUpFPU:	lis		r20,hi16(EXT(fpu_switch))		; Get FPU switcher address
+			ori		r20,r20,lo16(EXT(fpu_switch))	; Get FPU switcher address
+			b		PassUp							; Go pass it up...
+	
+PassUpVMX:	lis		r20,hi16(EXT(vec_switch))		; Get VMX switcher address
+			ori		r20,r20,lo16(EXT(vec_switch))	; Get VMX switcher address
+			bt++	featAltivec,PassUp				; We have VMX on this CPU...
+			li		r11,T_PROGRAM					; Say that it is a program exception
+			li		r20,8							; Set invalid instruction
+			stw		r11,saveexception(r13)			; Set the new the exception code
+			sth		r20,savesrr1+4(r13)				; Set the invalid instruction SRR code
+			
+			b		PassUpTrap						; Go pass it up...
+	
 			.align	5
+	
+PassUpAbend:	
+			lis		r20,hi16(EXT(chandler))			; Get choke handler address
+			ori		r20,r20,lo16(EXT(chandler))		; Get choke handler address
+			b		PassUp							; Go pass it up...
 
-PassUp:		lis		r2,hi16(EXT(exception_handlers))	; Get exception vector address
-			ori		r2,r2,lo16(EXT(exception_handlers))	; And low half
-			lwzx	r6,r2,r11						; Get the actual exception handler address
+			.align	5
 
-PassUpDeb:	mtsrr0	r6								; Set up the handler address
-			rlwinm	r5,r13,0,0,19					; Back off to the start of savearea block
+PassUp:		
+#if INSTRUMENT
+			mfspr	r29,pmc1						; INSTRUMENT - saveinstr[11] - Take stamp at passup or eatrupt
+			stw		r29,0x6100+(11*16)+0x0(0)		; INSTRUMENT - Save it
+			mfspr	r29,pmc2						; INSTRUMENT - Get stamp
+			stw		r29,0x6100+(11*16)+0x4(0)		; INSTRUMENT - Save it
+			mfspr	r29,pmc3						; INSTRUMENT - Get stamp
+			stw		r29,0x6100+(11*16)+0x8(0)		; INSTRUMENT - Save it
+			mfspr	r29,pmc4						; INSTRUMENT - Get stamp
+			stw		r29,0x6100+(11*16)+0xC(0)		; INSTRUMENT - Save it
+#endif			
 			
+			lwz		r10,SAVflags(r13)				; Pick up the flags
+
+			li		r0,0xFFF						; Get a page mask
+			li		r2,MASK(MSR_BE)|MASK(MSR_SE)	; Get the mask to save trace bits
+			andc	r5,r13,r0						; Back off to the start of savearea block
 			mfmsr	r3								; Get our MSR
-			rlwinm	r3,r3,0,MSR_BE_BIT+1,MSR_SE_BIT-1	; Clear all but the trace bits
-			li		r2,MSR_SUPERVISOR_INT_OFF		; Get our normal MSR value
-			lwz		r5,SACvrswap(r5)				; Get real to virtual conversion			
-			or		r2,r2,r3						; Keep the trace bits if they are on
+			rlwinm	r10,r10,0,SAVredriveb+1,SAVredriveb-1	; Clear the redrive before we pass it up
+			li		r21,MSR_SUPERVISOR_INT_OFF		; Get our normal MSR value
+			and		r3,r3,r2						; Clear all but trace
+			lwz		r5,SACvrswap+4(r5)				; Get real to virtual conversion			
+			or		r21,r21,r3						; Keep the trace bits if they are on
+			stw		r10,SAVflags(r13)				; Set the flags with the cleared redrive flag
 			mr		r3,r11							; Pass the exception code in the paramter reg
-			mtsrr1	r2								; Set up our normal MSR value
 			xor		r4,r13,r5						; Pass up the virtual address of context savearea
+			mfsprg	r29,0							; Get the per_proc block back
+			rlwinm	r4,r4,0,0,31					; Clean top half of virtual savearea if 64-bit
+
+			mr		r3,r21							; Pass in the MSR we will go to
+			bl		EXT(switchSegs)					; Go handle the segment registers/STB
+
+#if INSTRUMENT
+			mfspr	r30,pmc1						; INSTRUMENT - saveinstr[7] - Take stamp afer switchsegs
+			stw		r30,0x6100+(7*16)+0x0(0)			; INSTRUMENT - Save it
+			mfspr	r30,pmc2						; INSTRUMENT - Get stamp
+			stw		r30,0x6100+(7*16)+0x4(0)			; INSTRUMENT - Save it
+			mfspr	r30,pmc3						; INSTRUMENT - Get stamp
+			stw		r30,0x6100+(7*16)+0x8(0)			; INSTRUMENT - Save it
+			mfspr	r30,pmc4						; INSTRUMENT - Get stamp
+			stw		r30,0x6100+(7*16)+0xC(0)			; INSTRUMENT - Save it
+#endif			
+			lwz		r3,saveexception(r13)			; Recall the exception code
+			
+			mtsrr0	r20								; Set up the handler address
+			mtsrr1	r21								; Set up our normal MSR value
 
-			rfi										; Launch the exception handler
+			bt++	pf64Bitb,puLaunch				; Handle 64-bit machine...
 
-			.long	0								; Leave these here gol durn it!
-			.long	0
-			.long	0
-			.long	0
-			.long	0
-			.long	0
-			.long	0
-			.long	0
+			rfi										; Launch the exception handler
+			
+puLaunch:	rfid									; Launch the exception handler
 
 /*
- *			This routine is the only place where we return from an interruption.
- *			Anyplace else is wrong.  Even if I write the code, it's still wrong.
- *			Feel free to come by and slap me if I do do it--even though I may
- *			have had a good reason to do it.
+ *			This routine is the main place where we return from an interruption.
+ *
+ *			This is also where we release the quickfret list.  These are saveareas
+ *			that were released as part of the exception exit path in hw_exceptions.
+ *			In order to save an atomic operation (which actually will not work
+ *			properly on a 64-bit machine) we use holdQFret to indicate that the list
+ *			is in flux and should not be looked at here.  This comes into play only
+ *			when we take a PTE miss when we are queuing a savearea onto qfret.
+ *			Quite rare but could happen.  If the flag is set, this code does not
+ *			release the list and waits until next time.
  *
  *			All we need to remember here is that R13 must point to the savearea
  *			that has the context we need to load up. Translation and interruptions
@@ -1557,88 +2527,50 @@ PassUpDeb:	mtsrr0	r6								; Set up the handler address
  *			is any tomfoolery with savearea stacks, it must be taken care of 
  *			before we get here.
  *
- *			Speaking of tomfoolery, this is where we synthesize interruptions
- *			if we need to.
  */
  
  			.align	5
  
 EatRupt:	mfsprg	r29,0							; Get the per_proc block back
 			mr		r31,r13							; Move the savearea pointer to the far end of the register set
+			mfsprg	r27,2							; Get the processor features
 			
-			lwz		r30,quickfret(r29)				; Pick up the quick fret list, if any
+			lwz		r3,holdQFret(r29)				; Get the release hold off flag
 
-			mfsprg	r27,2							; Get the processor features
-			lwz		r21,savesrr1(r31)				; Get destination MSR
+			bt++	pf64Bitb,eat64a					; Skip down to the 64-bit version of this
+
+;
+;			This starts the 32-bit version
+;
+
+			mr.		r3,r3							; Should we hold off the quick release?
+			lwz		r30,quickfret+4(r29)			; Pick up the quick fret list, if any
+			la		r21,saver0(r31)					; Point to the first thing we restore
+			bne-	ernoqfret						; Hold off set, do not release just now...
 			
 erchkfret:	mr.		r3,r30							; Any savearea to quickly release?
 			beq+	ernoqfret						; No quickfrets...
-			lwz		r30,SAVprev(r30)				; Chain back now
+			lwz		r30,SAVprev+4(r30)				; Chain back now
 			
 			bl		EXT(save_ret_phys)				; Put it on the free list			
-			stw		r30,quickfret(r29)				; Dequeue previous guy (really, it is ok to wait until after the release)
+			stw		r30,quickfret+4(r29)			; Dequeue previous guy (really, it is ok to wait until after the release)
 			b		erchkfret						; Try the next one...
 
-
 			.align	5
 			
-ernoqfret:	mtcrf	0x60,r27						; Set CRs with thermal facilities
-			rlwinm.	r0,r21,0,MSR_EE_BIT,MSR_EE_BIT	; Are interruptions going to be enabled?
-			crandc	31,pfThermalb,pfThermIntb		; See if we have both thermometer and not interrupt facility
-			la		r21,saver0(r31)					; Point to the first thing we restore
-			crandc	31,cr0_eq,31					; Factor in enablement
-			bf		31,tempisok						; No thermal checking needed...
-
-;
-;			We get to here if 1) there is a thermal facility, and 2) the hardware
-;			will or cannot interrupt, and 3) the interrupt will be enabled after this point.
-;
-			
-			mfspr	r16,thrm3						; Get thermal 3		
-			mfspr	r14,thrm1						; Get thermal 2		
-			rlwinm.	r16,r16,0,thrme,thrme			; Is the themometer enabled?
-			mfspr	r15,thrm2						; Get thermal 2	
-			beq-	tempisok						; No thermometer...
-			rlwinm	r16,r14,2,28,31					; Cluster THRM1s TIE, V, TIN, and TIV at bottom 4 bits
-			srawi	r0,r15,31						; Make a mask of 1s if temprature over
-			rlwinm	r30,r15,2,28,31					; Cluster THRM2s TIE, V, TIN, and TIV at bottom 4 bits
-;
-;			Note that the following compare check that V, TIN, and TIV are set and that TIE is cleared.
-;			This insures that we only emulate when the hardware is not set to interrupt.
-;
-			cmplwi	cr0,r16,7						; Is there a valid pending interruption for THRM1?
-			cmplwi	cr1,r30,7						; Is there a valid pending interruption for THRM2?
-			and		r15,r15,r0						; Keep high temp if that interrupted, zero if not
-			cror	cr0_eq,cr0_eq,cr1_eq			; Merge both
-			andc	r14,r14,r0						; Keep low if high did not interrupt, zero if it did
-			bne+	tempisok						; Nope, temprature is in range
-			
-			li		r11,T_THERMAL					; Time to emulate a thermal interruption
-			or		r14,r14,r15						; Get contents of interrupting register
-			mr		r13,r31							; Make sure savearea is pointed to correctly
-			stw		r11,saveexception(r31)			; Set the exception code
-			stw		r14,savedar(r31)				; Set the contents of the interrupting register into the dar
-
-;
-;			This code is here to prevent a problem that will probably never happen.  If we are
-;			returning from an emulation routine (alignment, altivec assist, etc.) the SRs may
-;			not be set to the proper kernel values.  Then, if we were to emulate a thermal here,
-;			we would end up running in the kernel with a bogus SR.  So, to prevent
-;			this unfortunate circumstance, we slam the SRs here. (I worry too much...)
-;
-
-			lis		r30,hi16(KERNEL_SEG_REG0_VALUE)	; Get the high half of the kernel SR0 value
-			mtsr	sr0,r30							; Set the kernel SR0 
-			addis	r30,r30,0x0010					; Point to the second segment of kernel
-			mtsr	sr1,r30							; Set the kernel SR1 
-			addis	r30,r30,0x0010					; Point to the third segment of kernel
-			mtsr	sr2,r30							; Set the kernel SR2 
-			addis	r30,r30,0x0010					; Point to the third segment of kernel
-			mtsr	sr3,r30							; Set the kernel SR3
-			b		Redrive							; Go process this new interruption...
-
+ernoqfret:	
+#if INSTRUMENT
+			mfspr	r30,pmc1						; INSTRUMENT - saveinstr[5] - Take stamp at saveareas released
+			stw		r30,0x6100+(5*16)+0x0(0)			; INSTRUMENT - Save it
+			mfspr	r30,pmc2						; INSTRUMENT - Get stamp
+			stw		r30,0x6100+(5*16)+0x4(0)			; INSTRUMENT - Save it
+			mfspr	r30,pmc3						; INSTRUMENT - Get stamp
+			stw		r30,0x6100+(5*16)+0x8(0)			; INSTRUMENT - Save it
+			mfspr	r30,pmc4						; INSTRUMENT - Get stamp
+			stw		r30,0x6100+(5*16)+0xC(0)			; INSTRUMENT - Save it
+#endif			
 
-tempisok:	dcbt	0,r21							; Touch in the first thing we need
+			dcbt	0,r21							; Touch in the first thing we need
 			
 ;
 ;			Here we release the savearea.
@@ -1651,291 +2583,383 @@ tempisok:	dcbt	0,r21							; Touch in the first thing we need
 ;			savearea to the head of the local list.  Then, if it needs to trim, it will
 ;			start with the SECOND savearea, leaving ours intact.
 ;
-;			Build the SR values depending upon destination.  If we are going to the kernel,
-;			the SRs are almost all the way set up. SR14 (or the currently used copyin/out register)
-;			must be set to whatever it was at the last exception because it varies.  All the rest
-;			have been set up already.
-;
-;			If we are going into user space, we need to check a bit more. SR0, SR1, SR2, and
-;			SR14 (current implementation) must be restored always.  The others must be set if
-;			they are different that what was loaded last time (i.e., tasks have switched).  
-;			We check the last loaded address space ID and if the same, we skip the loads.  
-;			This is a performance gain because SR manipulations are slow.
-;
-;			There is also the special case when MSR_RI is set.  This happens when we are trying to
-;			make a special user state access when we are in the kernel.  If we take an exception when
-;			during that, the SRs may have been modified.  Therefore, we need to restore them to
-;			what they were before the exception because they could be non-standard.  We saved them
-;			during exception entry, so we will just load them here.
 ;
 
 			mr		r3,r31							; Get the exiting savearea in parm register
 			bl		EXT(save_ret_phys)				; Put it on the free list			
+#if INSTRUMENT
+			mfspr	r3,pmc1							; INSTRUMENT - saveinstr[6] - Take stamp afer savearea released
+			stw		r3,0x6100+(6*16)+0x0(0)			; INSTRUMENT - Save it
+			mfspr	r3,pmc2							; INSTRUMENT - Get stamp
+			stw		r3,0x6100+(6*16)+0x4(0)			; INSTRUMENT - Save it
+			mfspr	r3,pmc3							; INSTRUMENT - Get stamp
+			stw		r3,0x6100+(6*16)+0x8(0)			; INSTRUMENT - Save it
+			mfspr	r3,pmc4							; INSTRUMENT - Get stamp
+			stw		r3,0x6100+(6*16)+0xC(0)			; INSTRUMENT - Save it
+#endif			
 
-			li		r3,savesrr1						; Get offset to the srr1 value
+			lwz		r3,savesrr1+4(r31)				; Pass in the MSR we are going to
+			bl		EXT(switchSegs)					; Go handle the segment registers/STB
+#if INSTRUMENT
+			mfspr	r30,pmc1						; INSTRUMENT - saveinstr[10] - Take stamp afer switchsegs
+			stw		r30,0x6100+(10*16)+0x0(0)		; INSTRUMENT - Save it
+			mfspr	r30,pmc2						; INSTRUMENT - Get stamp
+			stw		r30,0x6100+(10*16)+0x4(0)		; INSTRUMENT - Save it
+			mfspr	r30,pmc3						; INSTRUMENT - Get stamp
+			stw		r30,0x6100+(10*16)+0x8(0)		; INSTRUMENT - Save it
+			mfspr	r30,pmc4						; INSTRUMENT - Get stamp
+			stw		r30,0x6100+(10*16)+0xC(0)		; INSTRUMENT - Save it
+#endif			
+			li		r3,savesrr1+4					; Get offset to the srr1 value
 
+			lhz		r9,PP_CPU_FLAGS(r29)			; Get the processor flags
 			lwarx	r26,r3,r31						; Get destination MSR and take reservation along the way (just so we can blow it away)
-			lwz		r7,PP_USERPMAP(r29)				; Pick up the user pmap we may launch
-			rlwinm.	r17,r26,0,MSR_RI_BIT,MSR_RI_BIT	; See if we are returning from a special fault
+			
+			rlwinm	r25,r26,27,22,22				; Move PR bit to BE
+			
 			cmplw	cr3,r14,r14						; Set that we do not need to stop streams
 
-			beq+	nSpecAcc						; Do not reload the kernel SRs if this is not a special access...
+			rlwinm	r9,r9,(((31-MSR_BE_BIT)+(traceBEb+16+1))&31),MSR_BE_BIT,MSR_BE_BIT	; Set BE bit if special trace is on
+			li		r21,emfp0						; Point to the fp savearea
+			and		r9,r9,r25						; Clear BE if supervisor state
+			or		r26,r26,r9						; Flip on the BE bit for special trace if needed
+			stwcx.	r26,r3,r31						; Blow away any reservations we hold (and set BE)
+
+			lwz		r25,savesrr0+4(r31)				; Get the SRR0 to use
+			
+			la		r28,saver4(r31)					; Point to the 32-byte line with r4-r7
+			dcbz	r21,r29							; Clear a work area
+			lwz		r0,saver0+4(r31)				; Restore R0			
+			dcbt	0,r28							; Touch in r4-r7 
+			lwz		r1,saver1+4(r31)				; Restore R1	
+			lwz		r2,saver2+4(r31)				; Restore R2	
+			la		r28,saver8(r31)					; Point to the 32-byte line with r8-r11
+			lwz		r3,saver3+4(r31)				; Restore R3
+            andis.	r6,r27,hi16(pfAltivec)			; Do we have altivec on the machine?
+            dcbt	0,r28							; touch in r8-r11
+			lwz		r4,saver4+4(r31)				; Restore R4
+            la		r28,saver12(r31)				; Point to the 32-byte line with r12-r15
+			mtsrr0	r25								; Restore the SRR0 now
+			lwz		r5,saver5+4(r31)				; Restore R5
+			mtsrr1	r26								; Restore the SRR1 now 
+			lwz		r6,saver6+4(r31)				; Restore R6			
+			
+			dcbt	0,r28							; touch in r12-r15
+			la		r28,saver16(r31)
+			
+			lwz		r7,saver7+4(r31)				; Restore R7
+			lwz		r8,saver8+4(r31)				; Restore R8	
+			lwz		r9,saver9+4(r31)				; Restore R9
+            
+            dcbt	0,r28							; touch in r16-r19
+            la		r28,saver20(r31)			
+            		
+			lwz		r10,saver10+4(r31)				; Restore R10
+			lwz		r11,saver11+4(r31)				; Restore R11			
+			
+			dcbt	0,r28							; touch in r20-r23
+			la		r28,savevscr(r31)				; Point to the status area
+			
+			lwz		r12,saver12+4(r31)				; Restore R12
+			lwz		r13,saver13+4(r31)				; Restore R13			
 
-			lwz		r14,savesr0(r31)				; Get SR0 at fault time
-			mtsr	sr0,r14							; Set SR0
-			lwz		r14,savesr1(r31)				; Get SR1 at fault time
-			mtsr	sr1,r14							; Set SR1
-			lwz		r14,savesr2(r31)				; Get SR2 at fault time
-			mtsr	sr2,r14							; Set SR2
-			lwz		r14,savesr3(r31)				; Get SR3 at fault timee
-			mtsr	sr3,r14							; Set SR3
-			b		segsdone						; We are all set up now...
+            la		r14,savectr+4(r31)
+			dcbt	0,r28							; Touch in VSCR and FPSCR
+            dcbt	0,r14							; touch in CTR, DAR, DSISR, VRSAVE, and Exception code
 
-			.align	5
+			lwz		r26,next_savearea+4(r29)		; Get the exception save area
+			la		r28,saver24(r31)
 
-nSpecAcc:	rlwinm.	r17,r26,0,MSR_PR_BIT,MSR_PR_BIT	; See if we are going to user or system
-			li		r14,PMAP_SEGS					; Point to segments 
-			bne+	gotouser						; We are going into user state...
+			lwz		r14,saver14+4(r31)				; Restore R14	
+			lwz		r15,saver15+4(r31)				; Restore R15			
 
-			lwz		r14,savesr14(r31)				; Get the copyin/out register at interrupt time
-			mtsr	sr14,r14						; Set SR14
-			b		segsdone						; We are all set up now...
-		
-			.align	5
 
-gotouser:	dcbt	r14,r7							; Touch the segment register contents
-			lwz		r9,spcFlags(r29)				; Pick up the special flags
-			lwz		r16,PP_LASTPMAP(r29)			; Pick up the last loaded pmap
-			addi	r14,r14,32						; Second half of pmap segments
-			rlwinm	r9,r9,userProtKeybit-2,2,2		; Isolate the user state protection key 
-			lwz		r15,PMAP_SPACE(r7)				; Get the primary space
-			lwz		r13,PMAP_VFLAGS(r7)				; Get the flags
-			dcbt	r14,r7							; Touch second page
-			oris	r15,r15,hi16(SEG_REG_PROT)		; Set segment 0 SR value
-			mtcrf	0x0F,r13						; Set CRs to correspond to the subordinate spaces
-			xor		r15,r15,r9						; Flip to proper segment register key
-			lhz		r9,PP_CPU_FLAGS(r29)			; Get the processor flags
+			stfd	f0,emfp0(r29)					; Save FP0
+			lwz		r27,savevrsave(r31)				; Get the vrsave
+            dcbt	0,r28							; touch in r24-r27
+			la		r28,savevscr(r31)				; Point to the status area
+			lfd		f0,savefpscrpad(r31)			; Get the fpscr
+            la		r22,saver28(r31)
+			mtfsf	0xFF,f0							; Restore fpscr		
+			lfd		f0,emfp0(r29)					; Restore the used register
 
-			addis	r13,r15,0x0000					; Get SR0 value
-			bf		16,nlsr0						; No alternate here...
-			lwz		r13,PMAP_SEGS+(0*4)(r7)			; Get SR0 value
+			beq		noavec3							; No Altivec on this CPU...
 			
-nlsr0:		mtsr	sr0,r13							; Load up the SR
-			rlwinm	r9,r9,(((31-MSR_BE_BIT)+(traceBEb+16+1))&31),MSR_BE_BIT,MSR_BE_BIT	; Set BE bit if special trace is on
+			stvxl	v0,r21,r29						; Save a vector register
+			lvxl	v0,0,r28						; Get the vector status
+			mtspr	vrsave,r27						; Set the vrsave
+			mtvscr	v0								; Set the vector status
+			lvxl	v0,r21,r29						; Restore work vector register
 
-			addis	r13,r15,0x0010					; Get SR1 value
-			bf		17,nlsr1						; No alternate here...
-			lwz		r13,PMAP_SEGS+(1*4)(r7)			; Get SR1 value
-			
-nlsr1:		mtsr	sr1,r13							; Load up the SR
-			or		r26,r26,r9						; Flip on the BE bit for special trace if needed
+noavec3:	dcbt	0,r22							; touch in r28-r31
+           	
+ 			lwz		r23,spcFlags(r29)				; Get the special flags from per_proc
+            la		r17,savesrr0(r31)
+			la		r26,saver0(r26)					; Point to the first part of the next savearea
+            dcbt	0,r17							; touch in SRR0, SRR1, CR, XER, LR 
+			lhz		r28,pfrptdProc(r29)				; Get the reported processor type
+
+			lwz		r16,saver16+4(r31)				; Restore R16
+			lwz		r17,saver17+4(r31)				; Restore R17
+			lwz		r18,saver18+4(r31)				; Restore R18	
+			lwz		r19,saver19+4(r31)				; Restore R19	
+			lwz		r20,saver20+4(r31)				; Restore R20
+			lwz		r21,saver21+4(r31)				; Restore R21
+			lwz		r22,saver22+4(r31)				; Restore R22
+
+			cmpwi	cr1,r28,CPU_SUBTYPE_POWERPC_750	; G3?
+
+			dcbz	0,r26							; Clear and allocate next savearea we use in the off chance it is still in when we next interrupt
+
+			andis.	r23,r23,hi16(perfMonitor)		; Is the performance monitor enabled?
+			lwz		r23,saver23+4(r31)				; Restore R23
+			cmpwi	cr2,r28,CPU_SUBTYPE_POWERPC_7400	; Yer standard G4?
+			lwz		r24,saver24+4(r31)				; Restore R24			
+			lwz		r25,saver25+4(r31)				; Restore R25			
+			lwz		r26,saver26+4(r31)				; Restore R26		
+			lwz		r27,saver27+4(r31)				; Restore R27			
+
+			beq+	noPerfMonRestore32				; No perf monitor... 
+
+			beq-	cr1,perfMonRestore32_750		; This is a G3...
+			beq-	cr2,perfMonRestore32_7400		; Standard G4...
+		
+			lwz		r28,savepmc+16(r31)
+			lwz		r29,savepmc+20(r31)
+			mtspr	pmc5,r28						; Restore PMC5
+			mtspr	pmc6,r29						; Restore PMC6
+
+perfMonRestore32_7400:
+			lwz		r28,savemmcr2+4(r31)
+			mtspr	mmcr2,r28						; Restore MMCR2
+
+perfMonRestore32_750:
+			lwz		r28,savepmc+0(r31)
+			lwz		r29,savepmc+4(r31)
+			mtspr	pmc1,r28						; Restore PMC1 
+			mtspr	pmc2,r29						; Restore PMC2 
+			lwz		r28,savepmc+8(r31)
+			lwz		r29,savepmc+12(r31)
+			mtspr	pmc3,r28						; Restore PMC3
+			mtspr	pmc4,r29						; Restore PMC4
+			lwz		r28,savemmcr1+4(r31)
+			lwz		r29,savemmcr0+4(r31)
+			mtspr	mmcr1,r28						; Restore MMCR1
+			mtspr	mmcr0,r29						; Restore MMCR0
+
+noPerfMonRestore32:		
+			lwz		r28,savecr(r31)					; Get CR to restore
+			lwz		r29,savexer+4(r31)				; Get XER to restore
+			mtcr	r28								; Restore the CR
+			lwz		r28,savelr+4(r31)				; Get LR to restore
+			mtxer	r29								; Restore the XER
+			lwz		r29,savectr+4(r31)				; Get the CTR to restore
+			mtlr	r28								; Restore the LR 
+			lwz		r28,saver30+4(r31)				; Get R30
+			mtctr	r29								; Restore the CTR
+			lwz		r29,saver31+4(r31)				; Get R31
+			mtsprg	2,r28							; Save R30 for later
+			lwz		r28,saver28+4(r31)				; Restore R28			
+			mtsprg	3,r29							; Save R31 for later
+			lwz		r29,saver29+4(r31)				; Restore R29
 
-			cmplw	cr3,r7,r16						; Are we running the same segs as last time?
+			mfsprg	r31,0							; Get per_proc
+			mfsprg	r30,2							; Restore R30 
+			lwz		r31,pfAvailable(r31)			; Get the feature flags
+			mtsprg	2,r31							; Set the feature flags
+			mfsprg	r31,3							; Restore R31
 
-			addis	r13,r15,0x0020					; Get SR2 value
-			bf		18,nlsr2						; No alternate here...
-			lwz		r13,PMAP_SEGS+(2*4)(r7)			; Get SR2 value
-			
-nlsr2:		mtsr	sr2,r13							; Load up the SR
+			rfi										; Click heels three times and think very hard that there is no place like home...
 
-			addis	r13,r15,0x0030					; Get SR3 value
-			bf		19,nlsr3						; No alternate here...
-			lwz		r13,PMAP_SEGS+(3*4)(r7)			; Get SR3 value
-			
-nlsr3:		mtsr	sr3,r13							; Load up the SR
+			.long	0								; Leave this here
+			.long	0
+			.long	0
+			.long	0
+			.long	0
+			.long	0
+			.long	0
+			.long	0
 
-			addis	r13,r15,0x00E0					; Get SR14 value
-			bf		30,nlsr14						; No alternate here...
-			lwz		r13,PMAP_SEGS+(14*4)(r7)		; Get SR14 value
-			
-nlsr14:		mtsr	sr14,r13						; Load up the SR
 
-			beq+	cr3,segsdone					; All done if same pmap as last time...
-			
-			stw		r7,PP_LASTPMAP(r29)				; Remember what we just loaded			
-			
-			addis	r13,r15,0x0040					; Get SR4 value
-			bf		20,nlsr4						; No alternate here...
-			lwz		r13,PMAP_SEGS+(4*4)(r7)			; Get SR4 value
-			
-nlsr4:		mtsr	sr4,r13							; Load up the SR
+;
+;			This starts the 64-bit version
+;
 
-			addis	r13,r15,0x0050					; Get SR5 value
-			bf		21,nlsr5						; No alternate here...
-			lwz		r13,PMAP_SEGS+(5*4)(r7)			; Get SR5 value
-			
-nlsr5:		mtsr	sr5,r13							; Load up the SR
+			.align	7
 
-			addis	r13,r15,0x0060					; Get SR6 value
-			bf		22,nlsr6						; No alternate here...
-			lwz		r13,PMAP_SEGS+(6*4)(r7)			; Get SR6 value
-			
-nlsr6:		mtsr	sr6,r13							; Load up the SR
+eat64a:		ld		r30,quickfret(r29)				; Pick up the quick fret list, if any
 
-			addis	r13,r15,0x0070					; Get SR7 value
-			bf		23,nlsr7						; No alternate here...
-			lwz		r13,PMAP_SEGS+(7*4)(r7)			; Get SR7 value
+			mr.		r3,r3							; Should we hold off the quick release?
+			la		r21,saver0(r31)					; Point to the first thing we restore
+			bne--	ernoqfre64						; Hold off set, do not release just now...
 			
-nlsr7:		mtsr	sr7,r13							; Load up the SR
-
-			addis	r13,r15,0x0080					; Get SR8 value
-			bf		24,nlsr8						; No alternate here...
-			lwz		r13,PMAP_SEGS+(8*4)(r7)			; Get SR8 value
+erchkfre64:	mr.		r3,r30							; Any savearea to quickly release?
+			beq+	ernoqfre64						; No quickfrets...
+			ld		r30,SAVprev(r30)				; Chain back now
 			
-nlsr8:		mtsr	sr8,r13							; Load up the SR
+			bl		EXT(save_ret_phys)				; Put it on the free list			
 
-			addis	r13,r15,0x0090					; Get SR9 value
-			bf		25,nlsr9						; No alternate here...
-			lwz		r13,PMAP_SEGS+(9*4)(r7)			; Get SR9 value
-			
-nlsr9:		mtsr	sr9,r13							; Load up the SR
+			std		r30,quickfret(r29)				; Dequeue previous guy (really, it is ok to wait until after the release)
+			b		erchkfre64						; Try the next one...
 
-			addis	r13,r15,0x00A0					; Get SR10 value
-			bf		26,nlsr10						; No alternate here...
-			lwz		r13,PMAP_SEGS+(10*4)(r7)		; Get SR10 value
+			.align	7
 			
-nlsr10:		mtsr	sr10,r13						; Load up the SR
-
-			addis	r13,r15,0x00B0					; Get SR11 value
-			bf		27,nlsr11						; No alternate here...
-			lwz		r13,PMAP_SEGS+(11*4)(r7)		; Get SR11 value
+ernoqfre64:	dcbt	0,r21							; Touch in the first thing we need
 			
-nlsr11:		mtsr	sr11,r13						; Load up the SR
+;
+;			Here we release the savearea.
+;
+;			Important!!!!  The savearea is released before we are done with it. When the
+;			local free savearea list (anchored at lclfree) gets too long, save_ret_phys
+;			will trim the list, making the extra saveareas allocatable by another processor
+;			The code in there must ALWAYS leave our savearea on the local list, otherwise
+;			we could be very, very unhappy.  The code there always queues the "just released"
+;			savearea to the head of the local list.  Then, if it needs to trim, it will
+;			start with the SECOND savearea, leaving ours intact.
+;
+;
 
-			addis	r13,r15,0x00C0					; Get SR12 value
-			bf		28,nlsr12						; No alternate here...
-			lwz		r13,PMAP_SEGS+(12*4)(r7)		; Get SR12 value
+			li		r3,lgKillResv					; Get spot to kill reservation
+			stdcx.	r3,0,r3							; Blow away any reservations we hold
 			
-nlsr12:		mtsr	sr12,r13						; Load up the SR
+			mr		r3,r31							; Get the exiting savearea in parm register
+			bl		EXT(save_ret_phys)				; Put it on the free list			
 
-			addis	r13,r15,0x00D0					; Get SR13 value
-			bf		29,nlsr13						; No alternate here...
-			lwz		r13,PMAP_SEGS+(13*4)(r7)		; Get SR13 value
-			
-nlsr13:		mtsr	sr13,r13						; Load up the SR
+			lwz		r3,savesrr1+4(r31)				; Pass in the MSR we will be going to
+			bl		EXT(switchSegs)					; Go handle the segment registers/STB
 
-			addis	r13,r15,0x00F0					; Get SR15 value
-			bf		31,nlsr15						; No alternate here...
-			lwz		r13,PMAP_SEGS+(15*4)(r7)		; Get SR15 value
-			
-nlsr15:		mtsr	sr15,r13						; Load up the SR
-			
-segsdone:	stwcx.	r26,r3,r31						; Blow away any reservations we hold
+			lhz		r9,PP_CPU_FLAGS(r29)			; Get the processor flags
+			ld		r26,savesrr1(r31)				; Get destination MSR
+			cmplw	cr3,r14,r14						; Set that we do not need to stop streams
+			rlwinm	r25,r26,27,22,22				; Move PR bit to BE
 
-			li		r21,emfp0						; Point to the fp savearea
-			lwz		r25,savesrr0(r31)				; Get the SRR0 to use
-			la		r28,saver8(r31)					; Point to the next line to use
-			dcbt	r21,r29							; Start moving in a work area
-			lwz		r0,saver0(r31)					; Restore R0			
-			dcbt	0,r28							; Touch it in 
-			lwz		r1,saver1(r31)					; Restore R1	
-			lwz		r2,saver2(r31)					; Restore R2	
-			la		r28,saver16(r31)				; Point to the next line to get
-			lwz		r3,saver3(r31)					; Restore R3
+			rlwinm	r9,r9,(((31-MSR_BE_BIT)+(traceBEb+16+1))&31),MSR_BE_BIT,MSR_BE_BIT	; Set BE bit if special trace is on
+			li		r21,emfp0						; Point to a workarea
+			and		r9,r9,r25						; Clear BE if supervisor state
+			or		r26,r26,r9						; Flip on the BE bit for special trace if needed
+
+			ld		r25,savesrr0(r31)				; Get the SRR0 to use
+			la		r28,saver16(r31)				; Point to the 128-byte line with r16-r31
+			dcbz128	r21,r29							; Clear a work area
+			ld		r0,saver0(r31)					; Restore R0			
+			dcbt	0,r28							; Touch in r16-r31 
+			ld		r1,saver1(r31)					; Restore R1	
+			ld		r2,saver2(r31)					; Restore R2	
+			ld		r3,saver3(r31)					; Restore R3
 			mtcrf	0x80,r27						; Get facility availability flags (do not touch CR1-7)
-			lwz		r4,saver4(r31)					; Restore R4
+			ld		r4,saver4(r31)					; Restore R4
 			mtsrr0	r25								; Restore the SRR0 now
-			lwz		r5,saver5(r31)					; Restore R5
+			ld		r5,saver5(r31)					; Restore R5
 			mtsrr1	r26								; Restore the SRR1 now 
-			lwz		r6,saver6(r31)					; Restore R6			
-			
-			dcbt	0,r28							; Touch that next line on in
-			la		r28,savevscr(r31)				; Point to the saved facility context
-			
-			lwz		r7,saver7(r31)					; Restore R7	
-			lwz		r8,saver8(r31)					; Restore R8	
-			lwz		r9,saver9(r31)					; Restore R9			
-			mfmsr	r26								; Get the current MSR
-			dcbt	0,r28							; Touch saved facility context		
-			lwz		r10,saver10(r31)				; Restore R10
-			lwz		r11,saver11(r31)				; Restore R11			
-			oris	r26,r26,hi16(MASK(MSR_VEC))		; Get the vector enable bit
-			lwz		r12,saver12(r31)				; Restore R12
-			ori		r26,r26,lo16(MASK(MSR_FP))		; Add in the float enable
-			lwz		r13,saver13(r31)				; Restore R13			
-			la		r28,saver24(r31)				; Point to the next line to do 
-
-;
-;			Note that floating point and vector will be enabled from here on until the RFI
-;
-
-			mtmsr	r26								; Turn on vectors and floating point
-			isync
-
-			dcbt	0,r28							; Touch next line to do	
+			ld		r6,saver6(r31)					; Restore R6			
+						
+			ld		r7,saver7(r31)					; Restore R7
+			ld		r8,saver8(r31)					; Restore R8	
+			ld		r9,saver9(r31)					; Restore R9
+            
+			la		r28,savevscr(r31)				; Point to the status area
+            		
+			ld		r10,saver10(r31)				; Restore R10
+			ld		r11,saver11(r31)				; Restore R11			
+			ld		r12,saver12(r31)				; Restore R12
+			ld		r13,saver13(r31)				; Restore R13			
 
-			lwz		r14,saver14(r31)				; Restore R14	
-			lwz		r15,saver15(r31)				; Restore R15			
+			ld		r26,next_savearea(r29)			; Get the exception save area
 
-			bf		pfAltivecb,noavec3				; No Altivec on this CPU...
+			ld		r14,saver14(r31)				; Restore R14	
+			ld		r15,saver15(r31)				; Restore R15			
+			lwz		r27,savevrsave(r31)				; Get the vrsave
+			
+			bf--	pfAltivecb,noavec2s				; Skip if no VMX...
 			
-			la		r28,savevscr(r31)				; Point to the status area
 			stvxl	v0,r21,r29						; Save a vector register
 			lvxl	v0,0,r28						; Get the vector status
-			lwz		r27,savevrsave(r31)				; Get the vrsave
 			mtvscr	v0								; Set the vector status
 
 			lvxl	v0,r21,r29						; Restore work vector register
-			beq+	cr3,noavec2						; SRs have not changed, no need to stop the streams...
-			dssall									; Kill all data streams
-			sync
 		
-noavec2:	mtspr	vrsave,r27						; Set the vrsave
-
-noavec3:	bf-		pfFloatb,nofphere				; Skip if no floating point...
+noavec2s:	mtspr	vrsave,r27						; Set the vrsave
 
+			lwz		r28,saveexception(r31)			; Get exception type
 			stfd	f0,emfp0(r29)					; Save FP0
 			lfd		f0,savefpscrpad(r31)			; Get the fpscr
 			mtfsf	0xFF,f0							; Restore fpscr		
 			lfd		f0,emfp0(r29)					; Restore the used register
-
-nofphere:	lwz		r16,saver16(r31)				; Restore R16
-			lwz		r17,saver17(r31)				; Restore R17
-			lwz		r18,saver18(r31)				; Restore R18	
-			lwz		r19,saver19(r31)				; Restore R19	
-			lwz		r20,saver20(r31)				; Restore R20
-			lwz		r21,saver21(r31)				; Restore R21
-			lwz		r22,saver22(r31)				; Restore R22
-
-			lwz		r23,saver23(r31)				; Restore R23
-			lwz		r24,saver24(r31)				; Restore R24			
-			lwz		r25,saver25(r31)				; Restore R25			
-			lwz		r26,saver26(r31)				; Restore R26		
-			lwz		r27,saver27(r31)				; Restore R27			
-
+			ld		r16,saver16(r31)				; Restore R16
+			lwz		r30,spcFlags(r29)				; Get the special flags from per_proc
+			ld		r17,saver17(r31)				; Restore R17
+			ld		r18,saver18(r31)				; Restore R18	
+			cmplwi	cr1,r28,T_RESET					; Are we returning from a reset?
+			ld		r19,saver19(r31)				; Restore R19	
+			ld		r20,saver20(r31)				; Restore R20
+			li		r27,0							; Get a zero
+			ld		r21,saver21(r31)				; Restore R21
+			la		r26,saver0(r26)					; Point to the first part of the next savearea
+			andis.	r30,r30,hi16(perfMonitor)		; Is the performance monitor enabled?
+			ld		r22,saver22(r31)				; Restore R22
+			ld		r23,saver23(r31)				; Restore R23
+			bne++	cr1,er64rrst					; We are not returning from a reset...
+			stw		r27,lo16(EXT(ResetHandler)-EXT(ExceptionVectorsStart)+RESETHANDLER_TYPE)(br0)	; Allow resets again
+
+er64rrst:	ld		r24,saver24(r31)				; Restore R24			
+
+			dcbz128	0,r26							; Clear and allocate next savearea we use in the off chance it is still in when we next interrupt
+
+			ld		r25,saver25(r31)				; Restore R25			
+			ld		r26,saver26(r31)				; Restore R26		
+			ld		r27,saver27(r31)				; Restore R27			
+
+			beq++	noPerfMonRestore64				; Nope... 
+
+			lwz		r28,savepmc+0(r31)
+			lwz		r29,savepmc+4(r31)
+			mtspr	pmc1_gp,r28						; Restore PMC1 
+			mtspr	pmc2_gp,r29						; Restore PMC2 
+			lwz		r28,savepmc+8(r31)
+			lwz		r29,savepmc+12(r31)
+			mtspr	pmc3_gp,r28						; Restore PMC3
+			mtspr	pmc4_gp,r29						; Restore PMC4
+			lwz		r28,savepmc+16(r31)
+			lwz		r29,savepmc+20(r31)
+			mtspr	pmc5_gp,r28						; Restore PMC5 
+			mtspr	pmc6_gp,r29						; Restore PMC6 
+			lwz		r28,savepmc+24(r31)
+			lwz		r29,savepmc+28(r31)
+			mtspr	pmc7_gp,r28						; Restore PMC7
+			mtspr	pmc8_gp,r29						; Restore PMC8
+			ld		r28,savemmcr1(r31)
+			ld		r29,savemmcr2(r31)
+			mtspr	mmcr1_gp,r28					; Restore MMCR1
+			mtspr	mmcra_gp,r29					; Restore MMCRA
+			ld		r28,savemmcr0(r31)
+			
+			mtspr	mmcr0_gp,r28					; Restore MMCR0
+
+noPerfMonRestore64:		
+			mfsprg	r30,0							; Get per_proc
 			lwz		r28,savecr(r31)					; Get CR to restore
-
-			lwz		r29,savexer(r31)				; Get XER to restore
+			ld		r29,savexer(r31)				; Get XER to restore
 			mtcr	r28								; Restore the CR
-			lwz		r28,savelr(r31)					; Get LR to restore
+			ld		r28,savelr(r31)					; Get LR to restore
 			mtxer	r29								; Restore the XER
-			lwz		r29,savectr(r31)				; Get the CTR to restore
+			ld		r29,savectr(r31)				; Get the CTR to restore
 			mtlr	r28								; Restore the LR 
-			lwz		r28,saver30(r31)				; Get R30
+			ld		r28,saver30(r31)				; Get R30
 			mtctr	r29								; Restore the CTR
-			lwz		r29,saver31(r31)				; Get R31
-			mtsprg	2,r28							; Save R30 for later
-			lwz		r28,saver28(r31)				; Restore R28			
+			ld		r29,saver31(r31)				; Get R31
+			mtspr	hsprg0,r28						; Save R30 for later
+			ld		r28,saver28(r31)				; Restore R28			
 			mtsprg	3,r29							; Save R31 for later
-			lwz		r29,saver29(r31)				; Restore R29
+			ld		r29,saver29(r31)				; Restore R29
 
-			mfsprg	r31,0							; Get per_proc
-			mfsprg	r30,2							; Restore R30 
-			lwz		r31,pfAvailable(r31)			; Get the feature flags
+			lwz		r31,pfAvailable(r30)			; Get the feature flags
+			lwz		r30,UAW(r30)					; Get the User Assist Word
 			mtsprg	2,r31							; Set the feature flags
 			mfsprg	r31,3							; Restore R31
+			mtsprg	3,r30							; Set the UAW
+			mfspr	r30,hsprg0						; Restore R30
 
-			rfi										; Click heels three times and think very hard that there is no place like home...
-
-			.long	0								; Leave this here
-			.long	0
-			.long	0
-			.long	0
-			.long	0
-			.long	0
-			.long	0
-			.long	0
-
+			rfid									; Click heels three times and think very hard that there is no place like home...
 
 
 	
@@ -1944,7 +2968,7 @@ nofphere:	lwz		r16,saver16(r31)				; Restore R16
  *
  *
  * ENTRY :	IR and/or DR and/or interruptions can be on
- *			R3 points to the physical address of a savearea
+ *			R3 points to the virtual address of a savearea
  */
 	
 			.align	5
@@ -1953,66 +2977,371 @@ nofphere:	lwz		r16,saver16(r31)				; Restore R16
 LEXT(exception_exit)
 
 			mfsprg	r29,2							; Get feature flags
-			mfmsr	r30								; Get the current MSR 
-			mtcrf	0x04,r29						; Set the features			
-			rlwinm	r30,r30,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
 			mr		r31,r3							; Get the savearea in the right register 
-			rlwinm	r30,r30,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-			li		r10,savesrr0					; Point to one of the first things we touch in the savearea on exit
-			andi.	r30,r30,0x7FCF					; Turn off externals, IR, and DR 
+			mtcrf	0x04,r29						; Set the features			
+			li		r0,1							; Get this just in case		
+			mtcrf	0x02,r29						; Set the features			
+			lis		r30,hi16(MASK(MSR_VEC)|MASK(MSR_FP)|MASK(MSR_ME))	; Set up the MSR we will use throughout. Note that ME come on here if MCK
+			rlwinm	r4,r3,0,0,19					; Round down to savearea block base
 			lis		r1,hi16(SAVredrive)				; Get redrive request
-
+			mfsprg	r2,0							; Get the per_proc block
+			ori		r30,r30,lo16(MASK(MSR_VEC)|MASK(MSR_FP)|MASK(MSR_ME))	; Rest of MSR
+			bt++	pf64Bitb,eeSixtyFour			; We are 64-bit...
+			
+			lwz		r4,SACvrswap+4(r4)				; Get the virtual to real translation
+			
 			bt		pfNoMSRirb,eeNoMSR				; No MSR...
 
 			mtmsr	r30								; Translation and all off
 			isync									; Toss prefetch
 			b		eeNoMSRx
 			
+			.align	5
+			
+eeSixtyFour:
+			ld		r4,SACvrswap(r4)				; Get the virtual to real translation
+			rldimi	r30,r0,63,MSR_SF_BIT			; Set SF bit (bit 0)
+			mtmsrd	r30								; Set 64-bit mode, turn off EE, DR, and IR
+			isync									; Toss prefetch
+			b		eeNoMSRx
+			
+			.align	5
+			
 eeNoMSR:	li		r0,loadMSR						; Get the MSR setter SC
 			mr		r3,r30							; Get new MSR
 			sc										; Set it
 
-eeNoMSRx:	dcbt	r10,r31							; Touch in the first stuff we restore
-			mfsprg	r2,0							; Get the per_proc block
+eeNoMSRx:	xor		r31,r31,r4						; Convert the savearea to physical addressing
 			lwz		r4,SAVflags(r31)				; Pick up the flags
 			mr		r13,r31							; Put savearea here also
 
+#if INSTRUMENT
+			mfspr	r5,pmc1							; INSTRUMENT - saveinstr[8] - stamp exception exit
+			stw		r5,0x6100+(8*16)+0x0(0)			; INSTRUMENT - Save it
+			mfspr	r5,pmc2							; INSTRUMENT - Get stamp
+			stw		r5,0x6100+(8*16)+0x4(0)			; INSTRUMENT - Save it
+			mfspr	r5,pmc3							; INSTRUMENT - Get stamp
+			stw		r5,0x6100+(8*16)+0x8(0)			; INSTRUMENT - Save it
+			mfspr	r5,pmc4							; INSTRUMENT - Get stamp
+			stw		r5,0x6100+(8*16)+0xC(0)			; INSTRUMENT - Save it
+#endif
+
+
 			and.	r0,r4,r1						; Check if redrive requested
-			andc	r4,r4,r1						; Clear redrive
 			
 			dcbt	br0,r2							; We will need this in just a sec
 
 			beq+	EatRupt							; No redrive, just exit...
 
 			lwz		r11,saveexception(r13)			; Restore exception code
-			stw		r4,SAVflags(r13)				; Set the flags
 			b		Redrive							; Redrive the exception...
+
+
 		
+			.align	12								; Force page alignment
 
-/*
- *		Start of the trace table
- */
- 
- 			.align	12								/* Align to 4k boundary */
-	
-			.globl EXT(traceTableBeg)
-EXT(traceTableBeg):									/* Start of trace table */
-/*			.fill	2048,4,0		  			       Make an 8k trace table for now */
-			.fill	13760,4,0						/* Make an .trace table for now */
-/*			.fill	240000,4,0		   				   Make an .trace table for now */
-			.globl EXT(traceTableEnd)
-EXT(traceTableEnd):									/* End of trace table */
-	
 			.globl EXT(ExceptionVectorsEnd)
 EXT(ExceptionVectorsEnd):							/* Used if relocating the exception vectors */
-#ifndef HACKALERTHACKALERT
-/* 
- *		This .long needs to be here because the linker gets confused and tries to 
- *		include the final label in a section in the next section if there is nothing 
- *		after it
- */
-	.long	0						/* (HACK/HACK/HACK) */
+
+
+
+
+;
+;			Here is where we keep the low memory globals
+;
+
+			. = 0x5000
+			.globl	EXT(lowGlo)
+			
+EXT(lowGlo):
+
+			.ascii	"Hagfish "						; 5000 Unique eyecatcher
+			.long	0								; 5008 Zero
+			.long	0								; 500C Zero cont...
+			.long	EXT(per_proc_info)				; 5010 pointer to per_procs
+			.long	0								; 5014 reserved
+			.long	0								; 5018 reserved
+			.long	0								; 501C reserved
+			.long	0								; 5020 reserved
+			.long	0								; 5024 reserved
+			.long	0								; 5028 reserved
+			.long	0								; 502C reserved
+			.long	0								; 5030 reserved
+			.long	0								; 5034 reserved
+			.long	0								; 5038 reserved
+			.long	0								; 503C reserved
+			.long	0								; 5040 reserved
+			.long	0								; 5044 reserved
+			.long	0								; 5048 reserved
+			.long	0								; 504C reserved
+			.long	0								; 5050 reserved
+			.long	0								; 5054 reserved
+			.long	0								; 5058 reserved
+			.long	0								; 505C reserved
+			.long	0								; 5060 reserved
+			.long	0								; 5064 reserved
+			.long	0								; 5068 reserved
+			.long	0								; 506C reserved
+			.long	0								; 5070 reserved
+			.long	0								; 5074 reserved
+			.long	0								; 5078 reserved
+			.long	0								; 507C reserved
+
+			.globl	EXT(trcWork)
+EXT(trcWork):
+			.long	0								; 5080 The next trace entry to use
+#if DEBUG
+			.long	0xFFFFFFFF 						; 5084 All enabled 
+#else
+			.long	0x00000000						; 5084 All disabled on non-debug systems
 #endif
+			.long	0								; 5088 Start of the trace table
+			.long	0								; 508C End (wrap point) of the trace
+			.long	0								; 5090 Saved mask while in debugger
+			.long	0								; 5094 Size of trace table (1 - 256 pages)
+			.long	0								; 5098 traceGas[0]
+			.long	0								; 509C traceGas[1]
+
+			.long	0								; 50A0 reserved			
+			.long	0								; 50A4 reserved			
+			.long	0								; 50A8 reserved			
+			.long	0								; 50AC reserved			
+			.long	0								; 50B0 reserved			
+			.long	0								; 50B4 reserved			
+			.long	0								; 50B8 reserved			
+			.long	0								; 50BC reserved			
+			.long	0								; 50C0 reserved			
+			.long	0								; 50C4 reserved			
+			.long	0								; 50C8 reserved			
+			.long	0								; 50CC reserved			
+			.long	0								; 50D0 reserved			
+			.long	0								; 50D4 reserved			
+			.long	0								; 50D8 reserved			
+			.long	0								; 50DC reserved			
+			.long	0								; 50E0 reserved			
+			.long	0								; 50E4 reserved			
+			.long	0								; 50E8 reserved			
+			.long	0								; 50EC reserved			
+			.long	0								; 50F0 reserved			
+			.long	0								; 50F4 reserved			
+			.long	0								; 50F8 reserved			
+			.long	0								; 50FC reserved			
+
+			.globl	EXT(saveanchor)
+
+EXT(saveanchor):									; 5100 saveanchor
+			.set	.,.+SVsize
+			
+			.long	0								; 5140 reserved
+			.long	0								; 5144 reserved
+			.long	0								; 5148 reserved
+			.long	0								; 514C reserved
+			.long	0								; 5150 reserved
+			.long	0								; 5154 reserved
+			.long	0								; 5158 reserved
+			.long	0								; 515C reserved
+			.long	0								; 5160 reserved
+			.long	0								; 5164 reserved
+			.long	0								; 5168 reserved
+			.long	0								; 516C reserved
+			.long	0								; 5170 reserved
+			.long	0								; 5174 reserved
+			.long	0								; 5178 reserved
+			.long	0								; 517C reserved
+			
+			.long	0								; 5180 tlbieLock
+
+			.long	0								; 5184 reserved
+			.long	0								; 5188 reserved
+			.long	0								; 518C reserved
+			.long	0								; 5190 reserved
+			.long	0								; 5194 reserved
+			.long	0								; 5198 reserved
+			.long	0								; 519C reserved
+			.long	0								; 51A0 reserved			
+			.long	0								; 51A4 reserved			
+			.long	0								; 51A8 reserved			
+			.long	0								; 51AC reserved			
+			.long	0								; 51B0 reserved			
+			.long	0								; 51B4 reserved			
+			.long	0								; 51B8 reserved			
+			.long	0								; 51BC reserved			
+			.long	0								; 51C0 reserved			
+			.long	0								; 51C4 reserved			
+			.long	0								; 51C8 reserved			
+			.long	0								; 51CC reserved			
+			.long	0								; 51D0 reserved			
+			.long	0								; 51D4 reserved			
+			.long	0								; 51D8 reserved			
+			.long	0								; 51DC reserved			
+			.long	0								; 51E0 reserved			
+			.long	0								; 51E4 reserved			
+			.long	0								; 51E8 reserved			
+			.long	0								; 51EC reserved			
+			.long	0								; 51F0 reserved			
+			.long	0								; 51F4 reserved			
+			.long	0								; 51F8 reserved			
+			.long	0								; 51FC reserved	
+			
+			.globl	EXT(dgWork)
+			
+EXT(dgWork):
+			
+			.long	0								; 5200 dgLock
+			.long	0								; 5204 dgFlags		
+			.long	0								; 5208 dgMisc0		
+			.long	0								; 520C dgMisc1		
+			.long	0								; 5210 dgMisc2		
+			.long	0								; 5214 dgMisc3		
+			.long	0								; 5218 dgMisc4		
+			.long	0								; 521C dgMisc5	
+				
+			.long	0								; 5220 reserved
+			.long	0								; 5224 reserved
+			.long	0								; 5228 reserved
+			.long	0								; 522C reserved
+			.long	0								; 5230 reserved
+			.long	0								; 5234 reserved
+			.long	0								; 5238 reserved
+			.long	0								; 523C reserved
+			.long	0								; 5240 reserved
+			.long	0								; 5244 reserved
+			.long	0								; 5248 reserved
+			.long	0								; 524C reserved
+			.long	0								; 5250 reserved
+			.long	0								; 5254 reserved
+			.long	0								; 5258 reserved
+			.long	0								; 525C reserved
+			.long	0								; 5260 reserved
+			.long	0								; 5264 reserved
+			.long	0								; 5268 reserved
+			.long	0								; 526C reserved
+			.long	0								; 5270 reserved
+			.long	0								; 5274 reserved
+			.long	0								; 5278 reserved
+			.long	0								; 527C reserved
+			
+			.long	0								; 5280 reserved
+			.long	0								; 5284 reserved
+			.long	0								; 5288 reserved
+			.long	0								; 528C reserved
+			.long	0								; 5290 reserved
+			.long	0								; 5294 reserved
+			.long	0								; 5298 reserved
+			.long	0								; 529C reserved
+			.long	0								; 52A0 reserved			
+			.long	0								; 52A4 reserved			
+			.long	0								; 52A8 reserved			
+			.long	0								; 52AC reserved			
+			.long	0								; 52B0 reserved			
+			.long	0								; 52B4 reserved			
+			.long	0								; 52B8 reserved			
+			.long	0								; 52BC reserved			
+			.long	0								; 52C0 reserved			
+			.long	0								; 52C4 reserved			
+			.long	0								; 52C8 reserved			
+			.long	0								; 52CC reserved			
+			.long	0								; 52D0 reserved			
+			.long	0								; 52D4 reserved			
+			.long	0								; 52D8 reserved			
+			.long	0								; 52DC reserved			
+			.long	0								; 52E0 reserved			
+			.long	0								; 52E4 reserved			
+			.long	0								; 52E8 reserved			
+			.long	0								; 52EC reserved			
+			.long	0								; 52F0 reserved			
+			.long	0								; 52F4 reserved			
+			.long	0								; 52F8 reserved			
+			.long	0								; 52FC reserved	
+
+			.globl	EXT(killresv)
+EXT(killresv):
+
+			.long	0								; 5300 Used to kill reservations
+			.long	0								; 5304 Used to kill reservations
+			.long	0								; 5308 Used to kill reservations
+			.long	0								; 530C Used to kill reservations
+			.long	0								; 5310 Used to kill reservations
+			.long	0								; 5314 Used to kill reservations
+			.long	0								; 5318 Used to kill reservations
+			.long	0								; 531C Used to kill reservations
+			.long	0								; 5320 Used to kill reservations
+			.long	0								; 5324 Used to kill reservations
+			.long	0								; 5328 Used to kill reservations
+			.long	0								; 532C Used to kill reservations
+			.long	0								; 5330 Used to kill reservations
+			.long	0								; 5334 Used to kill reservations
+			.long	0								; 5338 Used to kill reservations
+			.long	0								; 533C Used to kill reservations
+			.long	0								; 5340 Used to kill reservations
+			.long	0								; 5344 Used to kill reservations
+			.long	0								; 5348 Used to kill reservations
+			.long	0								; 534C Used to kill reservations
+			.long	0								; 5350 Used to kill reservations
+			.long	0								; 5354 Used to kill reservations
+			.long	0								; 5358 Used to kill reservations
+			.long	0								; 535C Used to kill reservations
+			.long	0								; 5360 Used to kill reservations
+			.long	0								; 5364 Used to kill reservations
+			.long	0								; 5368 Used to kill reservations
+			.long	0								; 536C Used to kill reservations
+			.long	0								; 5370 Used to kill reservations
+			.long	0								; 5374 Used to kill reservations
+			.long	0								; 5378 Used to kill reservations
+			.long	0								; 537C Used to kill reservations
+			
+			.long	0								; 5380 reserved
+			.long	0								; 5384 reserved
+			.long	0								; 5388 reserved
+			.long	0								; 538C reserved
+			.long	0								; 5390 reserved
+			.long	0								; 5394 reserved
+			.long	0								; 5398 reserved
+			.long	0								; 539C reserved
+			.long	0								; 53A0 reserved			
+			.long	0								; 53A4 reserved			
+			.long	0								; 53A8 reserved			
+			.long	0								; 53AC reserved			
+			.long	0								; 53B0 reserved			
+			.long	0								; 53B4 reserved			
+			.long	0								; 53B8 reserved			
+			.long	0								; 53BC reserved			
+			.long	0								; 53C0 reserved			
+			.long	0								; 53C4 reserved			
+			.long	0								; 53C8 reserved			
+			.long	0								; 53CC reserved			
+			.long	0								; 53D0 reserved			
+			.long	0								; 53D4 reserved			
+			.long	0								; 53D8 reserved			
+			.long	0								; 53DC reserved			
+			.long	0								; 53E0 reserved			
+			.long	0								; 53E4 reserved			
+			.long	0								; 53E8 reserved			
+			.long	0								; 53EC reserved			
+			.long	0								; 53F0 reserved			
+			.long	0								; 53F4 reserved			
+			.long	0								; 53F8 reserved			
+			.long	0								; 53FC reserved	
+
+
+;
+;	The "shared page" is used for low-level debugging
+;
+
+			. = 0x6000
+			.globl	EXT(sharedPage)
+
+EXT(sharedPage):									; Per processor data area
+		.long	0xC24BC195							; Comm Area validity value 
+		.long	0x87859393							; Comm Area validity value 
+		.long	0xE681A2C8							; Comm Area validity value 
+		.long	0x8599855A							; Comm Area validity value 
+		.long	0xD74BD296							; Comm Area validity value 
+		.long	0x8388E681							; Comm Area validity value 
+		.long	0xA2C88599							; Comm Area validity value 
+		.short	0x855A								; Comm Area validity value 
+		.short	1									; Comm Area version number
+		.fill	1016*4,1,0							; (filled with 0s)
 
 	.data
 	.align	ALIGN
@@ -2021,3 +3350,4 @@ EXT(exception_end):
 	.long	EXT(ExceptionVectorsEnd) -EXT(ExceptionVectorsStart) /* phys fn */
 
 
+
diff --git a/osfmk/ppc/mach_param.h b/osfmk/ppc/mach_param.h
index 49ac015de..d6f0b8148 100644
--- a/osfmk/ppc/mach_param.h
+++ b/osfmk/ppc/mach_param.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ppc/machine_cpu.h b/osfmk/ppc/machine_cpu.h
index 98dd13a77..1f81ca4b0 100644
--- a/osfmk/ppc/machine_cpu.h
+++ b/osfmk/ppc/machine_cpu.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ppc/machine_routines.c b/osfmk/ppc/machine_routines.c
index 0a1080cef..172e52aae 100644
--- a/osfmk/ppc/machine_routines.c
+++ b/osfmk/ppc/machine_routines.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -29,6 +32,12 @@
 #include <ppc/proc_reg.h>
 #include <kern/processor.h>
 
+unsigned int max_cpus_initialized = 0;
+extern int forcenap;
+
+#define	MAX_CPUS_SET	0x1
+#define	MAX_CPUS_WAIT	0x2
+
 boolean_t get_interrupts_enabled(void);
 
 /* Map memory map IO space */
@@ -53,7 +62,7 @@ ml_static_malloc(
 		return((vm_offset_t)NULL);
 	else {
 		vaddr = static_memory_end;
-		static_memory_end = round_page(vaddr+size);
+		static_memory_end = round_page_32(vaddr+size);
 		return(vaddr);
 	}
 }
@@ -80,14 +89,14 @@ ml_static_mfree(
 {
 	vm_offset_t paddr_cur, vaddr_cur;
 
-	for (vaddr_cur = round_page(vaddr);
-	     vaddr_cur < trunc_page(vaddr+size);
+	for (vaddr_cur = round_page_32(vaddr);
+	     vaddr_cur < trunc_page_32(vaddr+size);
 	     vaddr_cur += PAGE_SIZE) {
 		paddr_cur = pmap_extract(kernel_pmap, vaddr_cur);
 		if (paddr_cur != (vm_offset_t)NULL) {
 			vm_page_wire_count--;
-			pmap_remove(kernel_pmap, vaddr_cur, vaddr_cur+PAGE_SIZE);
-			vm_page_create(paddr_cur,paddr_cur+PAGE_SIZE);
+			pmap_remove(kernel_pmap, (addr64_t)vaddr_cur, (addr64_t)(vaddr_cur+PAGE_SIZE));
+			vm_page_create(paddr_cur>>12,(paddr_cur+PAGE_SIZE)>>12);
 		}
 	}
 }
@@ -138,40 +147,8 @@ void ml_init_interrupt(void)
 	(void) ml_set_interrupts_enabled(current_state);
 }
 
-boolean_t fake_get_interrupts_enabled(void)
-{
-	/*
-	 * The scheduler is not active on this cpu. There is no need to disable 
-	 * preemption. The current thread wont be dispatched on anhother cpu.
-	 */
-	return((per_proc_info[cpu_number()].cpu_flags & turnEEon) != 0);
-}
-
-boolean_t fake_set_interrupts_enabled(boolean_t enable)
-{
-	boolean_t interrupt_state_prev;
-
-	/*
-	 * The scheduler is not active on this cpu. There is no need to disable 
-	 * preemption. The current thread wont be dispatched on anhother cpu.
-	 */
-	interrupt_state_prev = 
-		(per_proc_info[cpu_number()].cpu_flags & turnEEon) != 0;
-	if (interrupt_state_prev != enable)
-		per_proc_info[cpu_number()].cpu_flags ^= turnEEon;
-	return(interrupt_state_prev);
-}
-
 /* Get Interrupts Enabled */
 boolean_t ml_get_interrupts_enabled(void)
-{
-	if (per_proc_info[cpu_number()].interrupts_enabled == TRUE)
-		return(get_interrupts_enabled());
-	else
-		return(fake_get_interrupts_enabled());
-}
-
-boolean_t get_interrupts_enabled(void)
 {
 	return((mfmsr() & MASK(MSR_EE)) != 0);
 }
@@ -253,21 +230,25 @@ ml_processor_register(
 	ipi_handler_t       *ipi_handler)
 {
 	kern_return_t ret;
-	int target_cpu;
+	int target_cpu, cpu;
+	int donap;
 
 	if (processor_info->boot_cpu == FALSE) {
 		 if (cpu_register(&target_cpu) != KERN_SUCCESS)
 			return KERN_FAILURE;
 	} else {
 		/* boot_cpu is always 0 */
-		target_cpu= 0;
+		target_cpu = 0;
 	}
 
 	per_proc_info[target_cpu].cpu_id = processor_info->cpu_id;
 	per_proc_info[target_cpu].start_paddr = processor_info->start_paddr;
 
+	donap = processor_info->supports_nap;		/* Assume we use requested nap */
+	if(forcenap) donap = forcenap - 1;			/* If there was an override, use that */
+	
 	if(per_proc_info[target_cpu].pf.Available & pfCanNap)
-	  if(processor_info->supports_nap) 
+	  if(donap) 
 		per_proc_info[target_cpu].pf.Available |= pfWillNap;
 
 	if(processor_info->time_base_enable !=  (void(*)(cpu_id_t, boolean_t ))NULL)
@@ -289,6 +270,8 @@ ml_enable_nap(int target_cpu, boolean_t nap_enabled)
 {
     boolean_t prev_value = (per_proc_info[target_cpu].pf.Available & pfCanNap) && (per_proc_info[target_cpu].pf.Available & pfWillNap);
     
+ 	if(forcenap) nap_enabled = forcenap - 1;		/* If we are to force nap on or off, do it */
+ 
  	if(per_proc_info[target_cpu].pf.Available & pfCanNap) {				/* Can the processor nap? */
 		if (nap_enabled) per_proc_info[target_cpu].pf.Available |= pfWillNap;	/* Is nap supported on this machine? */
 		else per_proc_info[target_cpu].pf.Available &= ~pfWillNap;		/* Clear if not */
@@ -296,12 +279,49 @@ ml_enable_nap(int target_cpu, boolean_t nap_enabled)
 
 	if(target_cpu == cpu_number()) 
 		__asm__ volatile("mtsprg 2,%0" : : "r" (per_proc_info[target_cpu].pf.Available));	/* Set live value */
-
+ 
     return (prev_value);
 }
 
 void
-ml_ppc_get_info(ml_ppc_cpu_info_t *cpu_info)
+ml_init_max_cpus(unsigned long max_cpus)
+{
+	boolean_t current_state;
+
+	current_state = ml_set_interrupts_enabled(FALSE);
+	if (max_cpus_initialized != MAX_CPUS_SET) {
+		if (max_cpus > 0 && max_cpus < NCPUS)
+			machine_info.max_cpus = max_cpus;
+		if (max_cpus_initialized == MAX_CPUS_WAIT)
+			wakeup((event_t)&max_cpus_initialized);
+		max_cpus_initialized = MAX_CPUS_SET;
+	}
+	(void) ml_set_interrupts_enabled(current_state);
+}
+
+int
+ml_get_max_cpus(void)
+{
+	boolean_t current_state;
+
+	current_state = ml_set_interrupts_enabled(FALSE);
+	if (max_cpus_initialized != MAX_CPUS_SET) {
+		max_cpus_initialized = MAX_CPUS_WAIT;
+		assert_wait((event_t)&max_cpus_initialized, THREAD_UNINT);
+		(void)thread_block(THREAD_CONTINUE_NULL);
+	}
+	(void) ml_set_interrupts_enabled(current_state);
+	return(machine_info.max_cpus);
+}
+
+int
+ml_get_current_cpus(void)
+{
+	return machine_info.avail_cpus;
+}
+
+void
+ml_cpu_get_info(ml_cpu_info_t *cpu_info)
 {
   if (cpu_info == 0) return;
   
diff --git a/osfmk/ppc/machine_routines.h b/osfmk/ppc/machine_routines.h
index dc0cef117..8569cd637 100644
--- a/osfmk/ppc/machine_routines.h
+++ b/osfmk/ppc/machine_routines.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -29,6 +32,7 @@
 #include <mach/mach_types.h>
 #include <mach/boolean.h>
 #include <kern/kern_types.h>
+#include <kern/sched_prim.h>
 #include <pexpert/pexpert.h>
 
 #include <sys/appleapiopts.h>
@@ -89,22 +93,65 @@ vm_offset_t ml_vtophys(
 boolean_t ml_probe_read(
 	vm_offset_t paddr,
 	unsigned int *val);
+boolean_t ml_probe_read_64(
+	addr64_t paddr,
+	unsigned int *val);
 
 /* Read physical address byte */
 unsigned int ml_phys_read_byte(
 	vm_offset_t paddr);
+unsigned int ml_phys_read_byte_64(
+	addr64_t paddr);
+
+/* Read physical address half word */
+unsigned int ml_phys_read_half(
+	vm_offset_t paddr);
+unsigned int ml_phys_read_half_64(
+	addr64_t paddr);
 
-/* Read physical address */
+/* Read physical address word*/
 unsigned int ml_phys_read(
 	vm_offset_t paddr);
+unsigned int ml_phys_read_64(
+	addr64_t paddr);
+unsigned int ml_phys_read_word(
+	vm_offset_t paddr);
+unsigned int ml_phys_read_word_64(
+	addr64_t paddr);
+
+/* Read physical address double word */
+unsigned long long ml_phys_read_double(
+	vm_offset_t paddr);
+unsigned long long ml_phys_read_double_64(
+	addr64_t paddr);
 
 /* Write physical address byte */
 void ml_phys_write_byte(
 	vm_offset_t paddr, unsigned int data);
+void ml_phys_write_byte_64(
+	addr64_t paddr, unsigned int data);
 
-/* Write physical address */
+/* Write physical address half word */
+void ml_phys_write_half(
+	vm_offset_t paddr, unsigned int data);
+void ml_phys_write_half_64(
+	addr64_t paddr, unsigned int data);
+
+/* Write physical address word */
 void ml_phys_write(
 	vm_offset_t paddr, unsigned int data);
+void ml_phys_write_64(
+	addr64_t paddr, unsigned int data);
+void ml_phys_write_word(
+	vm_offset_t paddr, unsigned int data);
+void ml_phys_write_word_64(
+	addr64_t paddr, unsigned int data);
+
+/* Write physical address double word */
+void ml_phys_write_double(
+	vm_offset_t paddr, unsigned long long data);
+void ml_phys_write_double_64(
+	addr64_t paddr, unsigned long long data);
 
 /* Struct for ml_processor_register */
 struct ml_processor_info_t {
@@ -149,9 +196,6 @@ boolean_t fake_get_interrupts_enabled(void);
 boolean_t fake_set_interrupts_enabled(
 	boolean_t enable);
 
-/* check pending timers */
-void machine_clock_assist(void);
-
 void machine_idle(void);
 
 void machine_signal_idle(
@@ -183,8 +227,20 @@ void ml_thread_policy(
 #define MACHINE_NETWORK_WORKLOOP	0x00000001
 #define MACHINE_NETWORK_NETISR		0x00000002
 
-/* Struct for ml_ppc_get_cpu_info */
-struct ml_ppc_cpu_info_t {
+/* Initialize the maximum number of CPUs */
+void ml_init_max_cpus(
+	unsigned long max_cpus);
+
+/* Return the maximum number of CPUs set by ml_init_max_cpus() */
+int ml_get_max_cpus(
+	void);
+
+/* Return the current number of CPUs */
+int ml_get_current_cpus(
+	void);
+
+/* Struct for ml_cpu_get_info */
+struct ml_cpu_info {
 	unsigned long		vector_unit;
 	unsigned long		cache_line_size;
 	unsigned long		l1_icache_size;
@@ -195,12 +251,13 @@ struct ml_ppc_cpu_info_t {
 	unsigned long		l3_cache_size;
 };
 
-typedef struct ml_ppc_cpu_info_t ml_ppc_cpu_info_t;
+typedef struct ml_cpu_info ml_cpu_info_t;
 
 /* Get processor info */
-void ml_ppc_get_info(ml_ppc_cpu_info_t *cpu_info);
+void ml_cpu_get_info(ml_cpu_info_t *cpu_info);
 
 void ml_set_processor_speed(unsigned long speed);
+void ml_set_processor_voltage(unsigned long voltage);
 
 #endif /* __APPLE_API_PRIVATE */
 
diff --git a/osfmk/ppc/machine_routines_asm.s b/osfmk/ppc/machine_routines_asm.s
index 436307c24..9177b2a2a 100644
--- a/osfmk/ppc/machine_routines_asm.s
+++ b/osfmk/ppc/machine_routines_asm.s
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -27,6 +30,106 @@
 #include <mach/ppc/vm_param.h>
 #include <ppc/exception.h>
 	
+    
+/*
+ * ml_set_physical()		 	-- turn off DR and (if 64-bit) turn SF on
+ *								   it is assumed that pf64Bit is already in cr6
+ * ml_set_physical_get_ffs() 	-- turn DR off, SF on, and get feature flags 
+ * ml_set_physical_disabled()	-- turn DR and EE off, SF on, get feature flags
+ * ml_set_translation_off()		-- turn DR, IR, and EE off, SF on, get feature flags
+ *
+ * Callable only from assembler, these return:
+ *	 r2 -- new MSR
+ *	r11 -- old MSR
+ *	r10 -- feature flags (pf64Bit etc, ie SPRG 2)
+ *	cr6 -- feature flags 24-27, ie pf64Bit, pf128Byte, and pf32Byte
+ *
+ * Uses r0 and r2.  ml_set_translation_off also uses r3 and cr5.
+ */
+
+        .align	4
+        .globl	EXT(ml_set_translation_off)
+LEXT(ml_set_translation_off)
+        mfsprg	r10,2						// get feature flags
+       	li		r0,0						; Clear this
+        mtcrf	0x02,r10					// move pf64Bit etc to cr6
+        ori		r0,r0,lo16(MASK(MSR_EE)+MASK(MSR_FP)+MASK(MSR_IR)+MASK(MSR_DR)) // turn off all 4
+        mfmsr	r11							// get MSR
+		oris	r0,r0,hi16(MASK(MSR_VEC))	// Turn off vector too
+        mtcrf	0x04,r10					// move pfNoMSRir etc to cr5
+        andc	r2,r11,r0					// turn off EE, IR, and DR
+        bt++	pf64Bitb,ml_set_physical_64	// skip if 64-bit (only they take the hint)
+        bf		pfNoMSRirb,ml_set_physical_32	// skip if we can load MSR directly
+        li		r0,loadMSR					// Get the MSR setter SC
+        mr		r3,r2						// copy new MSR to r2
+        sc									// Set it
+        blr
+        
+		.align	4
+		.globl	EXT(ml_set_physical_disabled)
+
+LEXT(ml_set_physical_disabled)
+		li		r0,0						; Clear
+        mfsprg	r10,2						// get feature flags
+        ori		r0,r0,lo16(MASK(MSR_EE))	// turn EE and fp off
+        mtcrf	0x02,r10					// move pf64Bit etc to cr6
+        b		ml_set_physical_join
+
+		.align	5
+		.globl	EXT(ml_set_physical_get_ffs)
+
+LEXT(ml_set_physical_get_ffs)
+        mfsprg	r10,2						// get feature flags
+        mtcrf	0x02,r10					// move pf64Bit etc to cr6
+
+		.globl	EXT(ml_set_physical)
+LEXT(ml_set_physical)
+
+        li		r0,0						// do not turn off interrupts
+
+ml_set_physical_join:
+		oris	r0,r0,hi16(MASK(MSR_VEC))	// Always gonna turn of vectors
+        mfmsr	r11							// get MSR
+        ori		r0,r0,lo16(MASK(MSR_DR)+MASK(MSR_FP))	// always turn off DR and FP bit
+        andc	r2,r11,r0					// turn off DR and maybe EE
+        bt++	pf64Bitb,ml_set_physical_64	// skip if 64-bit (only they take the hint)
+ml_set_physical_32:
+        mtmsr	r2							// turn off translation
+        isync
+        blr
+        
+ml_set_physical_64:
+        li		r0,1						// get a 1 to slam into SF
+        rldimi	r2,r0,63,MSR_SF_BIT			// set SF bit (bit 0)
+        mtmsrd	r2							// set 64-bit mode, turn off data relocation
+        isync								// synchronize
+        blr
+    
+
+/*
+ * ml_restore(old_MSR)
+ *
+ * Callable only from assembler, restores the MSR in r11 saved by ml_set_physical.
+ * We assume cr6 and r11 are as set by ml_set_physical, ie:
+ *	cr6 - pf64Bit flag (feature flags 24-27)
+ *	r11 - old MSR
+ */
+ 
+		.align	5
+		.globl	EXT(ml_restore)
+
+LEXT(ml_restore)
+        bt++	pf64Bitb,ml_restore_64		// handle 64-bit cpus (only they take the hint)
+        mtmsr	r11							// restore a 32-bit MSR
+        isync
+        blr
+        
+ml_restore_64:
+        mtmsrd	r11							// restore a 64-bit MSR
+        isync
+        blr
+
+    
 /* PCI config cycle probing
  *
  *	boolean_t ml_probe_read(vm_offset_t paddr, unsigned int *val)
@@ -44,16 +147,23 @@
 LEXT(ml_probe_read)
 
 			mfsprg	r9,2							; Get feature flags
+			
+			rlwinm.	r0,r9,0,pf64Bitb,pf64Bitb		; Are we on a 64-bit machine?
+			rlwinm	r3,r3,0,0,31					; Clean up for 64-bit machines
+			bne++	mpr64bit						; Go do this the 64-bit way...
+
+mpr32bit:	lis		r8,hi16(MASK(MSR_VEC))			; Get the vector flag
 			mfmsr	r0								; Save the current MSR
-			rlwinm	r0,r0,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-			rlwinm	r0,r0,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
+			ori		r8,r8,lo16(MASK(MSR_FP))		; Add the FP flag
+
 			neg		r10,r3							; Number of bytes to end of page
-			rlwinm	r2,r0,0,MSR_EE_BIT+1,MSR_EE_BIT-1	; Clear interruptions
+			andc	r0,r0,r8						; Clear VEC and FP
 			rlwinm.	r10,r10,0,20,31					; Clear excess junk and test for page bndry
+			ori		r8,r8,lo16(MASK(MSR_EE)|MASK(MSR_IR)|MASK(MSR_DR))		; Drop EE, IR, and DR
 			mr		r12,r3							; Save the load address
+			andc	r2,r0,r8						; Clear VEC, FP, and EE
 			mtcrf	0x04,r9							; Set the features			
 			cmplwi	cr1,r10,4						; At least 4 bytes left in page?
-			rlwinm	r2,r2,0,MSR_DR_BIT+1,MSR_IR_BIT-1	; Clear translation			
 			beq-	mprdoit							; We are right on the boundary...
 			li		r3,0
 			bltlr-	cr1								; No, just return failure...
@@ -129,9 +239,6 @@ mprNoMuM:
 			mtmsr	r2								; Turn translation back off
 			isync
 			
-			mtspr	hid0, r6							; Restore HID0
-			isync
-			
 			lis		r10,hi16(EXT(shadow_BAT)+shdDBAT)	; Get shadow address
 			ori		r10,r10,lo16(EXT(shadow_BAT)+shdDBAT)	; Get shadow address
 			
@@ -161,121 +268,421 @@ mprNoMuM:
 			.globl	EXT(ml_probe_read_mck)
 LEXT(ml_probe_read_mck)
 
-/* Read physical address
+    
+/* PCI config cycle probing - 64-bit
+ *
+ *	boolean_t ml_probe_read_64(addr64_t paddr, unsigned int *val)
+ *
+ *	Read the memory location at physical address paddr.
+ *  This is a part of a device probe, so there is a good chance we will
+ *  have a machine check here. So we have to be able to handle that.
+ *  We assume that machine checks are enabled both in MSR and HIDs
+ */
+
+;			Force a line boundry here
+			.align	6
+			.globl	EXT(ml_probe_read_64)
+
+LEXT(ml_probe_read_64)
+
+			mfsprg	r9,2							; Get feature flags
+			rlwinm	r3,r3,0,1,0						; Copy low 32 bits to top 32
+			rlwinm.	r0,r9,0,pf64Bitb,pf64Bitb		; Are we on a 64-bit machine?
+			rlwimi	r3,r4,0,0,31					; Insert low part of 64-bit address in bottom 32 bits			
+			
+			mr		r4,r5							; Move result to common register
+			beq--	mpr32bit						; Go do this the 32-bit way...
+
+mpr64bit:	andi.	r0,r3,3							; Check if we are on a word boundary
+			li		r0,0							; Clear the EE bit (and everything else for that matter)
+			bne--	mprFail							; Boundary not good...
+			mfmsr	r11								; Get the MSR
+			mtmsrd	r0,1							; Set the EE bit only (do not care about RI)
+			rlwinm	r11,r11,0,MSR_EE_BIT,MSR_EE_BIT	; Isolate just the EE bit
+			mfmsr	r10								; Refresh our view of the MSR (VMX/FP may have changed)
+			or		r12,r10,r11						; Turn on EE if on before we turned it off
+			ori		r0,r0,lo16(MASK(MSR_IR)|MASK(MSR_DR))	; Get the IR and DR bits
+			li		r2,1							; Get a 1
+			sldi	r2,r2,63						; Get the 64-bit bit
+			andc	r10,r10,r0						; Clear IR and DR
+			or		r10,r10,r2						; Set 64-bit
+			
+			li		r0,1							; Get a 1
+			mtmsrd	r10								; Translation and EE off, 64-bit on
+			isync			
+			
+			sldi	r0,r0,32+8						; Get the right bit to inhibit caching
+
+			mfspr	r8,hid4							; Get HID4
+			or		r2,r8,r0						; Set bit to make real accesses cache-inhibited
+			sync									; Sync up
+			mtspr	hid4,r2							; Make real accesses cache-inhibited
+			isync									; Toss prefetches
+			
+			lis		r7,0xE000						; Get the unlikeliest ESID possible
+			srdi	r7,r7,1							; Make 0x7FFFFFFFF0000000
+			slbie	r7								; Make sure the ERAT is cleared 
+			
+			sync
+			isync
+
+			eieio									; Make sure of all previous accesses
+			
+			lwz		r11,0(r3)						; Get it and maybe machine check here
+			
+			eieio									; Make sure of ordering again
+			sync									; Get caught up yet again
+			isync									; Do not go further till we are here
+
+			sync									; Sync up
+			mtspr	hid4,r8							; Make real accesses not cache-inhibited
+			isync									; Toss prefetches
+
+			lis		r7,0xE000						; Get the unlikeliest ESID possible
+			srdi	r7,r7,1							; Make 0x7FFFFFFFF0000000
+			slbie	r7								; Make sure the ERAT is cleared 
+
+			mtmsrd	r12								; Restore entry MSR
+			isync
+			
+			stw		r11,0(r4)						; Pass back the result
+			li		r3,1							; Indicate success
+			blr										; Leave...
+
+mprFail:	li		r3,0							; Set failure
+			blr										; Leave...
+
+;			Force a line boundry here. This means we will be able to check addresses better
+			.align	6
+			.globl	EXT(ml_probe_read_mck_64)
+LEXT(ml_probe_read_mck_64)
+
+
+/* Read physical address byte
  *
  *	unsigned int ml_phys_read_byte(vm_offset_t paddr)
+ *	unsigned int ml_phys_read_byte_64(addr64_t paddr)
  *
  *	Read the byte at physical address paddr. Memory should not be cache inhibited.
  */
 
 ;			Force a line boundry here
+
 			.align	5
+			.globl	EXT(ml_phys_read_byte_64)
+
+LEXT(ml_phys_read_byte_64)
+
+			rlwinm	r3,r3,0,1,0						; Copy low 32 bits to top 32
+			rlwimi	r3,r4,0,0,31					; Insert low part of 64-bit address in bottom 32 bits
+            b		ml_phys_read_byte_join			
+
 			.globl	EXT(ml_phys_read_byte)
 
 LEXT(ml_phys_read_byte)
+            rlwinm   r3,r3,0,0,31    				; truncate address to 32-bits
+ml_phys_read_byte_join:								; r3 = address to read (reg64_t)
+			mflr	r11								; Save the return
+			bl		rdwrpre							; Get set up, translation/interrupts off, 64-bit on, etc.
+			
+			lbz		r3,0(r3)						; Get the byte
+			b		rdwrpost						; Clean up and leave...
 
-			mfmsr	r10								; Save the current MSR
-			rlwinm	r10,r10,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-			rlwinm	r10,r10,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-			rlwinm	r4,r10,0,MSR_EE_BIT+1,MSR_EE_BIT-1	; Clear interruptions
-			rlwinm	r4,r4,0,MSR_DR_BIT+1,MSR_DR_BIT-1	; Clear translation	
 
-			mtmsr	r4								; Translation and all off
-			isync									; Toss prefetch
+/* Read physical address half word
+ *
+ *	unsigned int ml_phys_read_half(vm_offset_t paddr)
+ *	unsigned int ml_phys_read_half_64(addr64_t paddr)
+ *
+ *	Read the half word at physical address paddr. Memory should not be cache inhibited.
+ */
 
-			lbz		r3,0(r3)						; Get the byte
-			sync
+;			Force a line boundry here
 
-			mtmsr	r10								; Restore translation and rupts
-			isync
-			blr
+			.align	5
+			.globl	EXT(ml_phys_read_half_64)
+
+LEXT(ml_phys_read_half_64)
+
+			rlwinm	r3,r3,0,1,0						; Copy low 32 bits to top 32
+			rlwimi	r3,r4,0,0,31					; Insert low part of 64-bit address in bottom 32 bits
+            b		ml_phys_read_half_join		
+
+			.globl	EXT(ml_phys_read_half)
 
-/* Read physical address
+LEXT(ml_phys_read_half)
+            rlwinm   r3,r3,0,0,31    				; truncate address to 32-bits
+ml_phys_read_half_join:								; r3 = address to read (reg64_t)
+			mflr	r11								; Save the return
+			bl		rdwrpre							; Get set up, translation/interrupts off, 64-bit on, etc.
+			
+			lhz		r3,0(r3)						; Get the half word
+			b		rdwrpost						; Clean up and leave...
+
+
+/* Read physical address word
  *
  *	unsigned int ml_phys_read(vm_offset_t paddr)
+ *	unsigned int ml_phys_read_64(addr64_t paddr)
+ *	unsigned int ml_phys_read_word(vm_offset_t paddr)
+ *	unsigned int ml_phys_read_word_64(addr64_t paddr)
  *
  *	Read the word at physical address paddr. Memory should not be cache inhibited.
  */
 
 ;			Force a line boundry here
+
 			.align	5
+			.globl	EXT(ml_phys_read_64)
+			.globl	EXT(ml_phys_read_word_64)
+
+LEXT(ml_phys_read_64)
+LEXT(ml_phys_read_word_64)
+
+			rlwinm	r3,r3,0,1,0						; Copy low 32 bits to top 32
+			rlwimi	r3,r4,0,0,31					; Insert low part of 64-bit address in bottom 32 bits
+            b		ml_phys_read_word_join		
+
 			.globl	EXT(ml_phys_read)
+			.globl	EXT(ml_phys_read_word)
 
 LEXT(ml_phys_read)
+LEXT(ml_phys_read_word)
+            rlwinm   r3,r3,0,0,31    				; truncate address to 32-bits
+ml_phys_read_word_join:								; r3 = address to read (reg64_t)
+			mflr	r11								; Save the return
+			bl		rdwrpre							; Get set up, translation/interrupts off, 64-bit on, etc.
+			
+			lwz		r3,0(r3)						; Get the word
+			b		rdwrpost						; Clean up and leave...
 
-			mfmsr	r0								; Save the current MSR
-			rlwinm	r0,r0,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-			rlwinm	r0,r0,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-			rlwinm	r4,r0,0,MSR_EE_BIT+1,MSR_EE_BIT-1	; Clear interruptions
-			rlwinm	r4,r4,0,MSR_DR_BIT+1,MSR_DR_BIT-1	; Clear translation	
 
-			mtmsr	r4								; Translation and all off
-			isync									; Toss prefetch
+/* Read physical address double word
+ *
+ *	unsigned long long ml_phys_read_double(vm_offset_t paddr)
+ *	unsigned long long ml_phys_read_double_64(addr64_t paddr)
+ *
+ *	Read the double word at physical address paddr. Memory should not be cache inhibited.
+ */
+
+;			Force a line boundry here
+
+			.align	5
+			.globl	EXT(ml_phys_read_double_64)
+
+LEXT(ml_phys_read_double_64)
+
+			rlwinm	r3,r3,0,1,0						; Copy low 32 bits to top 32
+			rlwimi	r3,r4,0,0,31					; Insert low part of 64-bit address in bottom 32 bits			
+            b		ml_phys_read_double_join		
+
+			.globl	EXT(ml_phys_read_double)
+
+LEXT(ml_phys_read_double)
+            rlwinm   r3,r3,0,0,31    				; truncate address to 32-bits
+ml_phys_read_double_join:							; r3 = address to read (reg64_t)
+			mflr	r11								; Save the return
+			bl		rdwrpre							; Get set up, translation/interrupts off, 64-bit on, etc.
 			
-			lwz		r3,0(r3)						; Get the word
-			sync
+			lwz		r4,4(r3)						; Get the low word
+			lwz		r3,0(r3)						; Get the high word
+			b		rdwrpost						; Clean up and leave...
 
-			mtmsr	r0								; Restore translation and rupts
-			isync
-			blr
 
 /* Write physical address byte
  *
  *	void ml_phys_write_byte(vm_offset_t paddr, unsigned int data)
+ *	void ml_phys_write_byte_64(addr64_t paddr, unsigned int data)
  *
  *	Write the byte at physical address paddr. Memory should not be cache inhibited.
  */
 
-;			Force a line boundry here
 			.align	5
+			.globl	EXT(ml_phys_write_byte_64)
+
+LEXT(ml_phys_write_byte_64)
+
+			rlwinm	r3,r3,0,1,0						; Copy low 32 bits to top 32
+			rlwimi	r3,r4,0,0,31					; Insert low part of 64-bit address in bottom 32 bits			
+			mr		r4,r5							; Copy over the data
+            b		ml_phys_write_byte_join
+
 			.globl	EXT(ml_phys_write_byte)
 
 LEXT(ml_phys_write_byte)
+            rlwinm   r3,r3,0,0,31    				; truncate address to 32-bits
+ml_phys_write_byte_join:							; r3 = address to write (reg64_t), r4 = data
+			mflr	r11								; Save the return
+			bl		rdwrpre							; Get set up, translation/interrupts off, 64-bit on, etc.
+			
+			stb		r4,0(r3)						; Set the byte
+			b		rdwrpost						; Clean up and leave...
 
-			mfmsr	r0								; Save the current MSR
-			rlwinm	r0,r0,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-			rlwinm	r0,r0,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-			rlwinm	r5,r0,0,MSR_EE_BIT+1,MSR_EE_BIT-1	; Clear interruptions
-			rlwinm	r5,r5,0,MSR_DR_BIT+1,MSR_DR_BIT-1	; Clear translation	
 
-			mtmsr	r5								; Translation and all off
-			isync									; Toss prefetch
+/* Write physical address half word
+ *
+ *	void ml_phys_write_half(vm_offset_t paddr, unsigned int data)
+ *	void ml_phys_write_half_64(addr64_t paddr, unsigned int data)
+ *
+ *	Write the half word at physical address paddr. Memory should not be cache inhibited.
+ */
+
+			.align	5
+			.globl	EXT(ml_phys_write_half_64)
+
+LEXT(ml_phys_write_half_64)
+
+			rlwinm	r3,r3,0,1,0						; Copy low 32 bits to top 32
+			rlwimi	r3,r4,0,0,31					; Insert low part of 64-bit address in bottom 32 bits			
+			mr		r4,r5							; Copy over the data
+            b		ml_phys_write_half_join
+
+			.globl	EXT(ml_phys_write_half)
+
+LEXT(ml_phys_write_half)
+            rlwinm   r3,r3,0,0,31    				; truncate address to 32-bits
+ml_phys_write_half_join:							; r3 = address to write (reg64_t), r4 = data
+			mflr	r11								; Save the return
+			bl		rdwrpre							; Get set up, translation/interrupts off, 64-bit on, etc.
 			
-			stb		r4,0(r3)						; Set the byte
-			sync
+			sth		r4,0(r3)						; Set the half word
+			b		rdwrpost						; Clean up and leave...
 
-			mtmsr	r0								; Restore translation and rupts
-			isync
-			blr
 
-/* Write physical address
+/* Write physical address word
  *
  *	void ml_phys_write(vm_offset_t paddr, unsigned int data)
+ *	void ml_phys_write_64(addr64_t paddr, unsigned int data)
+ *	void ml_phys_write_word(vm_offset_t paddr, unsigned int data)
+ *	void ml_phys_write_word_64(addr64_t paddr, unsigned int data)
  *
  *	Write the word at physical address paddr. Memory should not be cache inhibited.
  */
 
-;			Force a line boundry here
 			.align	5
+			.globl	EXT(ml_phys_write_64)
+			.globl	EXT(ml_phys_write_word_64)
+
+LEXT(ml_phys_write_64)
+LEXT(ml_phys_write_word_64)
+
+			rlwinm	r3,r3,0,1,0						; Copy low 32 bits to top 32
+			rlwimi	r3,r4,0,0,31					; Insert low part of 64-bit address in bottom 32 bits			
+			mr		r4,r5							; Copy over the data
+            b		ml_phys_write_word_join
+
 			.globl	EXT(ml_phys_write)
+			.globl	EXT(ml_phys_write_word)
 
 LEXT(ml_phys_write)
+LEXT(ml_phys_write_word)
+            rlwinm   r3,r3,0,0,31    				; truncate address to 32-bits
+ml_phys_write_word_join:							; r3 = address to write (reg64_t), r4 = data
+			mflr	r11								; Save the return
+			bl		rdwrpre							; Get set up, translation/interrupts off, 64-bit on, etc.
+			
+			stw		r4,0(r3)						; Set the word
+			b		rdwrpost						; Clean up and leave...
 
-			mfmsr	r0								; Save the current MSR
-			rlwinm	r0,r0,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-			rlwinm	r0,r0,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-			rlwinm	r5,r0,0,MSR_EE_BIT+1,MSR_EE_BIT-1	; Clear interruptions
-			rlwinm	r5,r5,0,MSR_DR_BIT+1,MSR_DR_BIT-1	; Clear translation	
 
-			mtmsr	r5								; Translation and all off
-			isync									; Toss prefetch
+/* Write physical address double word
+ *
+ *	void ml_phys_write_double(vm_offset_t paddr, unsigned long long data)
+ *	void ml_phys_write_double_64(addr64_t paddr, unsigned long long data)
+ *
+ *	Write the double word at physical address paddr. Memory should not be cache inhibited.
+ */
+
+			.align	5
+			.globl	EXT(ml_phys_write_double_64)
+
+LEXT(ml_phys_write_double_64)
+
+			rlwinm	r3,r3,0,1,0						; Copy low 32 bits to top 32
+			rlwimi	r3,r4,0,0,31					; Insert low part of 64-bit address in bottom 32 bits			
+			mr		r4,r5							; Copy over the high data
+			mr		r5,r6							; Copy over the low data
+            b		ml_phys_write_double_join
+
+			.globl	EXT(ml_phys_write_double)
+
+LEXT(ml_phys_write_double)
+            rlwinm   r3,r3,0,0,31    				; truncate address to 32-bits
+ml_phys_write_double_join:							; r3 = address to write (reg64_t), r4,r5 = data (long long)
+			mflr	r11								; Save the return
+			bl		rdwrpre							; Get set up, translation/interrupts off, 64-bit on, etc.
+			
+			stw		r4,0(r3)						; Set the high word
+			stw		r5,4(r3)						; Set the low word
+			b		rdwrpost						; Clean up and leave...
+
+
+			.align	5
+
+rdwrpre:	mfsprg	r12,2							; Get feature flags 
+			lis		r8,hi16(MASK(MSR_VEC))			; Get the vector flag
+			mfmsr	r10								; Save the MSR 
+			ori		r8,r8,lo16(MASK(MSR_FP))		; Add the FP flag
+			mtcrf	0x02,r12						; move pf64Bit
+			andc	r10,r10,r8						; Clear VEC and FP
+			ori		r9,r8,lo16(MASK(MSR_EE)|MASK(MSR_IR)|MASK(MSR_DR))		; Drop EE, DR, and IR
+			li		r2,1							; Prepare for 64 bit
+			andc	r9,r10,r9						; Clear VEC, FP, DR, and EE
+			bf--	pf64Bitb,rdwrpre32				; Join 32-bit code...
+			
+			srdi	r7,r3,31						; Get a 1 if address is in I/O memory
+			rldimi	r9,r2,63,MSR_SF_BIT				; set SF bit (bit 0)
+			cmpldi	cr7,r7,1						; Is source in I/O memory?
+			mtmsrd	r9								; set 64-bit mode, turn off EE, DR, and IR
+			isync									; synchronize
+
+			sldi	r0,r2,32+8						; Get the right bit to turn off caching
+			
+			bnelr++	cr7								; We are not in the I/O area, all ready...
+			
+			mfspr	r8,hid4							; Get HID4
+			or		r2,r8,r0						; Set bit to make real accesses cache-inhibited
+			sync									; Sync up
+			mtspr	hid4,r2							; Make real accesses cache-inhibited
+			isync									; Toss prefetches
+			
+			lis		r7,0xE000						; Get the unlikeliest ESID possible
+			srdi	r7,r7,1							; Make 0x7FFFFFFFF0000000
+			slbie	r7								; Make sure the ERAT is cleared 
 			
-			stw		r4,0(r3)						; Set the word
 			sync
+			isync
+			blr										; Finally,  all ready...
+	
+			.align	5
+			
+rdwrpre32:	rlwimi	r9,r10,0,MSR_IR_BIT,MSR_IR_BIT	; Leave the IR bit unchanged
+			mtmsr	r9								; Drop EE, DR, and leave IR unchanged
+			isync
+			blr										; All set up, leave...
+			
+			.align	5
+			
+rdwrpost:	mtlr	r11								; Restore the return
+			bt++	pf64Bitb,rdwrpost64				; Join 64-bit code...
+			
+			mtmsr	r10								; Restore entry MSR (sans FP and VEC)
+			isync
+			blr										; Leave...
+			
+rdwrpost64:	bne++	cr7,rdwrpcok					; Skip enabling real mode caching if we did not change it...
+
+			sync									; Sync up
+			mtspr	hid4,r8							; Make real accesses not cache-inhibited
+			isync									; Toss prefetches
 
-			mtmsr	r0								; Restore translation and rupts
+			lis		r7,0xE000						; Get the unlikeliest ESID possible
+			srdi	r7,r7,1							; Make 0x7FFFFFFFF0000000
+			slbie	r7								; Make sure the ERAT is cleared 
+
+rdwrpcok:	mtmsrd	r10								; Restore entry MSR (sans FP and VEC)
 			isync
-			blr
+			blr										; Leave...
 
 
 /* set interrupts enabled or disabled
@@ -291,56 +698,42 @@ LEXT(ml_phys_write)
  
 LEXT(ml_set_interrupts_enabled)
 
-			mfsprg	r7,0
-			lwz		r4,PP_INTS_ENABLED(r7)
-			mr.		r4,r4
-			beq-	EXT(fake_set_interrupts_enabled)
+			andi.   r4,r3,1							; Are we turning interruptions on?
+			lis		r0,hi16(MASK(MSR_VEC))			; Get vector enable
 			mfmsr	r5								; Get the current MSR
-			rlwinm	r5,r5,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-			mr		r4,r3							; Save the old value
-			rlwinm	r5,r5,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
+			ori		r0,r0,lo16(MASK(MSR_EE)|MASK(MSR_FP))	; Get float enable and EE enable
 			rlwinm	r3,r5,17,31,31					; Set return value
-			rlwimi	r5,r4,15,16,16					; Insert new EE bit
-			andi.   r8,r5,lo16(MASK(MSR_EE))			; Interruptions
-			bne     CheckPreemption
-NoPreemption:
-			mtmsr   r5                              ; Slam enablement
-			blr
+			andc	r5,r5,r0						; Force VEC and FP off
+			bne	    CheckPreemption					; Interrupts going on, check ASTs...
 
-CheckPreemption:
-			lwz		r8,PP_NEED_AST(r7)
-			li		r6,AST_URGENT
-			lwz		r8,0(r8)
-			lwz		r7,PP_PREEMPT_CNT(r7)
-			lis		r0,HIGH_ADDR(DoPreemptCall)
-			and.	r8,r8,r6
-			ori		r0,r0,LOW_ADDR(DoPreemptCall)   
-			beq+	NoPreemption
-			cmpi	cr0, r7, 0
-			mtmsr	r5								; Restore the MSR now, before we can preempt
-			bnelr+									; Return if no premption
-			sc										; Preempt
+			mtmsr   r5                              ; Slam diable (always going disabled here)
+			isync									; Need this because FP/Vec might go off
 			blr
 
+			.align	5
 
-/*  Emulate a decremeter exception
- *
- *	void machine_clock_assist(void)
- *
- */
+CheckPreemption:
+			mfsprg	r7,0
+			ori		r5,r5,lo16(MASK(MSR_EE))		; Turn on the enable
+			lwz		r8,PP_NEED_AST(r7)				; Get pointer to AST flags
+			mfsprg	r9,1							; Get current activation
+			li		r6,AST_URGENT					; Get the type we will preempt for 
+			lwz		r7,ACT_PREEMPT_CNT(r9)			; Get preemption count
+			lwz		r8,0(r8)						; Get AST flags
+			lis		r0,hi16(DoPreemptCall)			; High part of Preempt FW call
+			cmpwi	cr1,r7,0						; Are preemptions masked off?
+			and.	r8,r8,r6						; Are we urgent?
+			crorc	cr1_eq,cr0_eq,cr1_eq			; Remember if preemptions are masked or not urgent
+			ori		r0,r0,lo16(DoPreemptCall)   	; Bottome of FW call
 
-;			Force a line boundry here
-			.align  5
-			.globl  EXT(machine_clock_assist)
- 
-LEXT(machine_clock_assist)
+			mtmsr	r5								; Restore the MSR now, before we can preempt
+			isync									; Need this because FP/Vec might go off
 
-			mfsprg	r7,0
-			lwz		r4,PP_INTS_ENABLED(r7)
-			mr.		r4,r4
-			beq-	EXT(CreateFakeDEC)
+			beqlr++	cr1								; Return if no premption...
+			sc										; Preempt
 			blr
 
+
 /*  Set machine into idle power-saving mode. 
  *
  *	void machine_idle_ppc(void)
@@ -351,23 +744,24 @@ LEXT(machine_clock_assist)
  *
  */
 
-
 ;			Force a line boundry here
 			.align	5
 			.globl	EXT(machine_idle_ppc)
 
 LEXT(machine_idle_ppc)
 
-			mfmsr	r3								; Get the current MSR
-			rlwinm	r3,r3,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-			rlwinm	r3,r3,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-			rlwinm	r5,r3,0,MSR_EE_BIT+1,MSR_EE_BIT-1	; Turn off interruptions
+			lis		r0,hi16(MASK(MSR_VEC))			; Get the vector flag
+			mfmsr	r3								; Save the MSR 
+			ori		r0,r0,lo16(MASK(MSR_FP))		; Add the FP flag
+			andc	r3,r3,r0						; Clear VEC and FP
+			ori		r0,r0,lo16(MASK(MSR_EE))		; Drop EE also
+			andc	r5,r3,r0						; Clear VEC, FP, DR, and EE
+
 			mtmsr	r5								; Hold up interruptions for now
 			isync									; May have messed with fp/vec
 			mfsprg	r12,0							; Get the per_proc_info
-			mfspr	r6,hid0							; Get the current power-saving mode
 			mfsprg	r11,2							; Get CPU specific features
-			rlwinm	r6,r6,0,sleep+1,doze-1			; Clear all possible power-saving modes (not DPM though)	
+			mfspr	r6,hid0							; Get the current power-saving mode
 			mtcrf	0xC7,r11						; Get the facility flags
 
 			lis		r4,hi16(napm)					; Assume we can nap
@@ -388,21 +782,21 @@ yesnap:		mftbu	r9								; Get the upper timebase
 			stw		r8,napStamp(r12)				; Set high order time stamp
 			stw		r7,napStamp+4(r12)				; Set low order nap stamp
 
-			rlwinm.	r7,r11,0,pfNoL2PFNapb,pfNoL2PFNapb			; Turn off L2 Prefetch before nap?
+			rlwinm.	r7,r11,0,pfNoL2PFNapb,pfNoL2PFNapb	; Turn off L2 Prefetch before nap?
 			beq	miL2PFok
 
 			mfspr	r7,msscr0						; Get currect MSSCR0 value
-			rlwinm	r7,r7,0,0,l2pfes-1					; Dissable L2 Prefetch
+			rlwinm	r7,r7,0,0,l2pfes-1				; Disable L2 Prefetch
 			mtspr	msscr0,r7						; Updates MSSCR0 value
 			sync
 			isync
 
 miL2PFok:
-			rlwinm.	r7,r11,0,pfSlowNapb,pfSlowNapb				; Should nap at slow speed?
+			rlwinm.	r7,r11,0,pfSlowNapb,pfSlowNapb	; Should nap at slow speed?
 			beq	minoslownap
 
 			mfspr	r7,hid1							; Get current HID1 value
-			oris	r7,r7,hi16(hid1psm)					; Select PLL1
+			oris	r7,r7,hi16(hid1psm)				; Select PLL1
 			mtspr	hid1,r7							; Update HID1 value
 
 minoslownap:
@@ -414,11 +808,31 @@ minoslownap:
 ;			is taken and set everything up to return directly to machine_idle_ret.
 ;			So, make sure everything we need there is already set up...
 ;
+
+			li		r10,hi16(dozem|napm|sleepm)		; Mask of power management bits
+		
+			bf--	pf64Bitb,mipNSF1				; skip if 32-bit...
+			
+			sldi	r4,r4,32						; Position the flags
+			sldi	r10,r10,32						; Position the masks
+
+		
+mipNSF1:	andc	r6,r6,r10						; Clean up the old power bits		
+
 			ori		r7,r5,lo16(MASK(MSR_EE))		; Flip on EE
 			or		r6,r6,r4						; Set nap or doze
 			oris	r5,r7,hi16(MASK(MSR_POW))		; Turn on power management in next MSR
+			
+			sync
 			mtspr	hid0,r6							; Set up the HID for nap/doze
+			mfspr	r6,hid0							; Yes, this is silly, keep it here
+			mfspr	r6,hid0							; Yes, this is a duplicate, keep it here
+			mfspr	r6,hid0							; Yes, this is a duplicate, keep it here
+			mfspr	r6,hid0							; Yes, this is a duplicate, keep it here
+			mfspr	r6,hid0							; Yes, this is a duplicate, keep it here
+			mfspr	r6,hid0							; Yes, this is a duplicate, keep it here
 			isync									; Make sure it is set
+		
 			mtmsr	r7								; Enable for interrupts
 			rlwinm.	r11,r11,0,pfAltivecb,pfAltivecb	; Do we have altivec?
 			beq-	minovec							; No...
@@ -475,30 +889,46 @@ deadsleep:	addi	r3,r3,1							; Make analyzer happy
 			b		deadsleep						; Die the death of 1000 joys...
 #endif	
 			
+			mfsprg	r12,0							; Get the per_proc_info
 			mfspr	r4,hid0							; Get the current power-saving mode
 			eqv		r10,r10,r10						; Get all foxes
 			mfsprg	r11,2							; Get CPU specific features
 
-			rlwinm.	r5,r11,0,pfNoL2PFNapb,pfNoL2PFNapb			; Turn off L2 Prefetch before sleep?
+			rlwinm.	r5,r11,0,pfNoL2PFNapb,pfNoL2PFNapb	; Turn off L2 Prefetch before sleep?
 			beq	mpsL2PFok
 
 			mfspr	r5,msscr0						; Get currect MSSCR0 value
-			rlwinm	r5,r5,0,0,l2pfes-1					; Dissable L2 Prefetch
+			rlwinm	r5,r5,0,0,l2pfes-1				; Disable L2 Prefetch
 			mtspr	msscr0,r5						; Updates MSSCR0 value
 			sync
 			isync
 
 mpsL2PFok:
+			rlwinm.	r5,r11,0,pf64Bitb,pf64Bitb		; PM bits are shifted on 64bit systems.
+			bne		mpsPF64bit
+
+			rlwinm	r4,r4,0,sleep+1,doze-1			; Clear all possible power-saving modes (not DPM though)
+			oris	r4,r4,hi16(sleepm)				; Set sleep
+			b	mpsClearDEC
+
+mpsPF64bit:
+			lis	r5, hi16(dozem|napm|sleepm)			; Clear all possible power-saving modes (not DPM though)
+			sldi	r5, r5, 32
+			andc	r4, r4, r5
+			lis	r5, hi16(napm)						; Set sleep
+//			lis	r5, hi16(dozem)						; Set sleep
+			sldi	r5, r5, 32
+			or	r4, r4, r5
+
+mpsClearDEC:
 			mfmsr	r5								; Get the current MSR
 			rlwinm	r10,r10,0,1,31					; Make 0x7FFFFFFF
-			rlwinm	r4,r4,0,sleep+1,doze-1			; Clear all possible power-saving modes (not DPM though)	
 			mtdec	r10								; Load decrimenter with 0x7FFFFFFF
 			isync									; and make sure,
 			mfdec	r9								; really sure, it gets there
 			
 			mtcrf	0x07,r11						; Get the cache flags, etc
 
-			oris	r4,r4,hi16(sleepm)				; Set sleep
 			rlwinm	r5,r5,0,MSR_DR_BIT+1,MSR_IR_BIT-1	; Turn off translation		
 ;
 ;			Note that we need translation off before we set the HID to sleep.  Otherwise
@@ -519,6 +949,12 @@ mpsNoMSRx:
 			ori		r3,r5,lo16(MASK(MSR_EE))		; Flip on EE
 			sync
 			mtspr	hid0,r4							; Set up the HID to sleep
+			mfspr	r4,hid0							; Yes, this is silly, keep it here
+			mfspr	r4,hid0							; Yes, this is a duplicate, keep it here
+			mfspr	r4,hid0							; Yes, this is a duplicate, keep it here
+			mfspr	r4,hid0							; Yes, this is a duplicate, keep it here
+			mfspr	r4,hid0							; Yes, this is a duplicate, keep it here
+			mfspr	r4,hid0							; Yes, this is a duplicate, keep it here
 
 			mtmsr	r3								; Enable for interrupts to drain decrimenter
 				
@@ -541,7 +977,8 @@ mpsNoMSRx:
 			oris	r5,r5,hi16(MASK(MSR_POW))		; Turn on power management in next MSR
 													; Leave EE off because power goes off shortly
 
-slSleepNow:	sync									; Sync it all up
+slSleepNow:
+			sync									; Sync it all up
 			mtmsr	r5								; Do sleep with interruptions enabled
 			isync									; Take a pill
 			b		slSleepNow						; Go back to sleep if we wake up...
@@ -573,14 +1010,25 @@ LEXT(cacheInit)
 			
 			mfsprg	r11,2							; Get CPU specific features
 			mfmsr	r7								; Get the current MSR
-			rlwinm	r4,r9,0,dpm+1,doze-1			; Clear all possible power-saving modes (also disable DPM)	
 			rlwinm	r7,r7,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
 			rlwinm	r7,r7,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
 			rlwimi	r11,r11,pfLClckb+1,31,31		; Move pfLClck to another position (to keep from using non-volatile CRs)
 			rlwinm	r5,r7,0,MSR_DR_BIT+1,MSR_IR_BIT-1	; Turn off translation		
 			rlwinm	r5,r5,0,MSR_EE_BIT+1,MSR_EE_BIT-1	; Turn off interruptions
 			mtcrf	0x87,r11						; Get the feature flags
+			lis		r10,hi16(dozem|napm|sleepm|dpmm)	; Mask of power management bits
+			bf--	pf64Bitb,cIniNSF1				; Skip if 32-bit...
+			
+			sldi	r10,r10,32						; Position the masks
+
+cIniNSF1:	andc	r4,r9,r10						; Clean up the old power bits		
 			mtspr	hid0,r4							; Set up the HID
+			mfspr	r4,hid0							; Yes, this is silly, keep it here
+			mfspr	r4,hid0							; Yes, this is a duplicate, keep it here
+			mfspr	r4,hid0							; Yes, this is a duplicate, keep it here
+			mfspr	r4,hid0							; Yes, this is a duplicate, keep it here
+			mfspr	r4,hid0							; Yes, this is a duplicate, keep it here
+			mfspr	r4,hid0							; Yes, this is a duplicate, keep it here
 
 			bt		pfNoMSRirb,ciNoMSR				; No MSR...
 
@@ -599,11 +1047,12 @@ ciNoMSRx:
 			dssall									; Stop streams
 			sync
 
-cinoDSS:	lis		r5,hi16(EXT(tlb_system_lock))	; Get the TLBIE lock
+cinoDSS:	li		r5,tlbieLock					; Get the TLBIE lock
 			li		r0,128							; Get number of TLB entries
-			ori		r5,r5,lo16(EXT(tlb_system_lock))	; Grab up the bottom part
 			
 			li		r6,0							; Start at 0
+			bf--	pf64Bitb,citlbhang				; Skip if 32-bit...
+			li		r0,1024							; Get the number of TLB entries
 
 citlbhang:	lwarx	r2,0,r5							; Get the TLBIE lock
 			mr.		r2,r2							; Is it locked?
@@ -627,14 +1076,19 @@ cipurgeTLB:	tlbie	r6								; Purge this entry
 			sync
 			isync
 			
-cinoSMP:	stw		r2,0(r5)						; Unlock TLBIE lock
+			bf--	pf64Bitb,cinoSMP				; Skip if 32-bit...
+			ptesync									; Wait for quiet again
+			sync
+			
+cinoSMP:	stw		r2,tlbieLock(0)					; Unlock TLBIE lock
+
+			bt++	pf64Bitb,cin64					; Skip if 64-bit...
 
-			cror	cr0_eq,pfL1ib,pfL1db			; Check for either I- or D-cache
-			bf-		cr0_eq,cinoL1					; No level 1 to flush...
 			rlwinm.	r0,r9,0,ice,dce					; Were either of the level 1s on?
 			beq-	cinoL1							; No, no need to flush...
 			
-			bf		pfL1fab,ciswdl1					; If no hw flush assist, go do by software...
+            rlwinm.	r0,r11,0,pfL1fab,pfL1fab		; do we have L1 flush assist?
+			beq		ciswdl1							; If no hw flush assist, go do by software...
 			
 			mfspr	r8,msscr0						; Get the memory system control register
 			oris	r8,r8,hi16(dl1hwfm)				; Turn on the hardware flush request
@@ -758,7 +1212,9 @@ cinoL1:
 ;
 ;			Flush and disable the level 2
 ;
-			bf		pfL2b,cinol2					; No level 2 cache to flush
+            mfsprg	r10,2							; need to check 2 features we did not put in CR
+            rlwinm.	r0,r10,0,pfL2b,pfL2b			; do we have L2?
+			beq		cinol2							; No level 2 cache to flush
 
 			mfspr	r8,l2cr							; Get the L2CR
 			lwz		r3,pfl2cr(r12)					; Get the L2CR value
@@ -773,7 +1229,8 @@ cinoL1:
 			bne-	ciinvdl2						; Yes, just invalidate and get PLL synced...		
 			
 ciflushl2:
-			bf		pfL2fab,ciswfl2					; Flush not in hardware...
+            rlwinm.	r0,r10,0,pfL2fab,pfL2fab		; hardware-assisted L2 flush?
+			beq		ciswfl2							; Flush not in hardware...
 			
 			mr		r10,r8							; Take a copy now
 			
@@ -824,7 +1281,7 @@ ciswfldl2a:	lwz		r0,0(r10)						; Load something to flush something
 			addi	r10,r10,32						; Next line
 			bdnz	ciswfldl2a						; Do the lot...
 			
-ciinvdl2:	rlwinm	r8,r3,0,l2e+1,31				; Use the saved L2CR and clear the enable bit
+ciinvdl2:	rlwinm	r3,r3,0,l2e+1,31				; Clear the enable bit
 			b		cinla							; Branch to next line...
 
 			.align  5
@@ -851,7 +1308,9 @@ ciinvl2:	sync
 			sync
 			isync
 ciinvdl2a:	mfspr	r2,l2cr							; Get the L2CR
-			bf		pfL2ib,ciinvdl2b				; Flush not in hardware...
+            mfsprg	r0,2							; need to check a feature in "non-volatile" set
+            rlwinm.	r0,r0,0,pfL2ib,pfL2ib			; flush in HW?
+			beq		ciinvdl2b						; Flush not in hardware...
 			rlwinm.	r2,r2,0,l2i,l2i					; Is the invalidate still going?
 			bne+	ciinvdl2a						; Assume so, this will take a looong time...
 			sync
@@ -903,7 +1362,7 @@ cihwfl3:	mfspr	r10,l3cr						; Get back the L3CR
 			rlwinm.	r10,r10,0,l3hwf,l3hwf			; Is the flush over?
 			bne+	cihwfl3							; Nope, keep going...
 
-ciinvdl3:	rlwinm	r8,r3,0,l3e+1,31				; Use saved L3CR value and clear the enable bit
+ciinvdl3:	rlwinm	r8,r3,0,l3e+1,31				; Clear the enable bit
 			sync									; Make sure of life, liberty, and justice
 			mtspr	l3cr,r8							; Disable L3
 			sync
@@ -953,11 +1412,13 @@ ciinvdl3c:	addi	r2,r2,-1						; ?
 			mtspr	l3cr,r3							; Enable it as desired
 			sync
 cinol3:
-			bf		pfL2b,cinol2a					; No level 2 cache to enable
+            mfsprg	r0,2							; need to check a feature in "non-volatile" set
+            rlwinm.	r0,r0,0,pfL2b,pfL2b				; is there an L2 cache?
+			beq		cinol2a							; No level 2 cache to enable
 
 			lwz		r3,pfl2cr(r12)					; Get the L2CR value
 			cmplwi		r3, 0						; Should the L2 be all the way off?
-			beq		cinol2a						: Yes, done with L2
+			beq		cinol2a							: Yes, done with L2
 			mtspr	l2cr,r3							; Enable it as desired
 			sync
 
@@ -986,6 +1447,161 @@ cinoexit:	mtspr	hid0,r9							; Turn off the invalidate (needed for some older m
 			blr										; Return...
 
 
+;
+;			Handle 64-bit architecture
+;			This processor can not run without caches, so we just push everything out
+;			and flush.  It will be relativily clean afterwards
+;
+			
+			.align	5
+			
+cin64:		
+			li		r10,hi16(dozem|napm|sleepm)		; Mask of power management bits we want cleared
+			sldi	r10,r10,32						; Position the masks
+			andc	r9,r9,r10						; Clean up the old power bits
+			mr		r4,r9	
+			isync
+			mtspr	hid0,r4							; Set up the HID
+			mfspr	r4,hid0							; Yes, this is silly, keep it here
+			mfspr	r4,hid0							; Yes, this is a duplicate, keep it here
+			mfspr	r4,hid0							; Yes, this is a duplicate, keep it here
+			mfspr	r4,hid0							; Yes, this is a duplicate, keep it here
+			mfspr	r4,hid0							; Yes, this is a duplicate, keep it here
+			mfspr	r4,hid0							; Yes, this is a duplicate, keep it here
+			isync
+
+			mfspr	r10,hid1						; Save hid1
+			mfspr	r4,hid4							; Save hid4
+			mr		r12,r10							; Really save hid1
+			mr		r11,r4							; Get a working copy of hid4
+
+			li		r0,0							; Get a 0
+			eqv		r2,r2,r2						; Get all foxes
+			
+			rldimi	r10,r0,55,7						; Clear I$ prefetch bits (7:8)
+			
+			isync
+			mtspr	hid1,r10						; Stick it
+			mtspr	hid1,r10						; Stick it again
+			isync
+
+			rldimi	r11,r2,38,25					; Disable D$ prefetch (25:25)
+			
+			sync
+			mtspr	hid4,r11						; Stick it
+			isync
+
+			li		r3,8							; Set bit 28+32
+			sldi	r3,r3,32						; Make it bit 28
+			or		r3,r3,r11						; Turn on the flash invalidate L1D$
+			
+			oris	r5,r11,0x0600					; Set disable L1D$ bits		
+			sync
+			mtspr	hid4,r3							; Invalidate
+			isync
+	
+			mtspr	hid4,r5							; Un-invalidate and disable L1D$
+			isync
+			
+			lis		r8,GUSModeReg					; Get the GUS mode ring address
+			mfsprg	r0,2							; Get the feature flags
+			ori		r8,r8,0x8000					; Set to read data
+			rlwinm.	r0,r0,pfSCOMFixUpb+1,31,31		; Set shift if we need a fix me up
+
+			sync
+
+			mtspr	scomc,r8						; Request the GUS mode
+			mfspr	r11,scomd						; Get the GUS mode
+			mfspr	r8,scomc						; Get back the status (we just ignore it)
+			sync
+			isync							
+
+			sld		r11,r11,r0						; Fix up if needed
+
+			ori		r6,r11,lo16(GUSMdmapen)			; Set the bit that means direct L2 cache address
+			lis		r8,GUSModeReg					; Get GUS mode register address
+				
+			sync
+
+			mtspr	scomd,r6						; Set that we want direct L2 mode
+			mtspr	scomc,r8						; Tell GUS we want direct L2 mode
+			mfspr	r3,scomc						; Get back the status
+			sync
+			isync							
+
+			li		r3,0							; Clear start point
+		
+cflushlp:	lis		r6,0x0040						; Pick 4MB line as our target
+			or		r6,r6,r3						; Put in the line offset
+			lwz		r5,0(r6)						; Load a line
+			addis	r6,r6,8							; Roll bit 42:44
+			lwz		r5,0(r6)						; Load a line
+			addis	r6,r6,8							; Roll bit 42:44
+			lwz		r5,0(r6)						; Load a line
+			addis	r6,r6,8							; Roll bit 42:44
+			lwz		r5,0(r6)						; Load a line
+			addis	r6,r6,8							; Roll bit 42:44
+			lwz		r5,0(r6)						; Load a line
+			addis	r6,r6,8							; Roll bit 42:44
+			lwz		r5,0(r6)						; Load a line
+			addis	r6,r6,8							; Roll bit 42:44
+			lwz		r5,0(r6)						; Load a line
+			addis	r6,r6,8							; Roll bit 42:44
+			lwz		r5,0(r6)						; Load a line
+
+			addi	r3,r3,128						; Next line
+			andis.	r5,r3,8							; Have we done enough?
+			beq++	cflushlp						; Not yet...
+			
+			sync
+
+			lis		r6,0x0040						; Pick 4MB line as our target
+
+cflushx:	dcbf	0,r6							; Flush line and invalidate
+			addi	r6,r6,128						; Next line
+			andis.	r5,r6,0x0080					; Have we done enough?
+			beq++	cflushx							; Keep on flushing...
+
+			mr		r3,r10							; Copy current hid1
+			rldimi	r3,r2,54,9						; Set force icbi match mode
+			
+			li		r6,0							; Set start if ICBI range
+			isync
+			mtspr	hid1,r3							; Stick it
+			mtspr	hid1,r3							; Stick it again
+			isync
+
+cflicbi:	icbi	0,r6							; Kill I$
+			addi	r6,r6,128						; Next line
+			andis.	r5,r6,1							; Have we done them all?
+			beq++	cflicbi							; Not yet...
+
+			lis		r8,GUSModeReg					; Get GUS mode register address
+				
+			sync
+
+			mtspr	scomd,r11						; Set that we do not want direct mode
+			mtspr	scomc,r8						; Tell GUS we do not want direct mode
+			mfspr	r3,scomc						; Get back the status
+			sync
+			isync							
+			
+			isync
+			mtspr	hid1,r12						; Restore entry hid1
+			mtspr	hid1,r12						; Stick it again
+			isync
+		
+			sync
+			mtspr	hid4,r4							; Restore entry hid4
+			isync
+
+			sync
+			mtmsr	r7								; Restore MSR to entry
+			isync
+			blr										; Return...
+			
+			
+
 /*  Disables all caches
  *
  *	void cacheDisable(void)
@@ -1009,13 +1625,16 @@ LEXT(cacheDisable)
 			
 cdNoAlt:	sync
 			
+			btlr	pf64Bitb						; No way to disable a 64-bit machine...
+			
 			mfspr	r5,hid0							; Get the hid
 			rlwinm	r5,r5,0,dce+1,ice-1				; Clear the I- and D- cache enables
 			mtspr	hid0,r5							; Turn off dem caches
 			sync
 
-			bf		pfL2b,cdNoL2					; Skip if no L2...
-			
+            rlwinm.	r0,r11,0,pfL2b,pfL2b			; is there an L2?
+			beq		cdNoL2							; Skip if no L2...
+
 			mfspr	r5,l2cr							; Get the L2
 			rlwinm	r5,r5,0,l2e+1,31				; Turn off enable bit
 
@@ -1259,36 +1878,99 @@ throtoff:	mfspr	r3,ictc							; Get the old throttle
 LEXT(ml_get_timebase)
 
 loop:
-        mftbu   r4
-        mftb    r5
-        mftbu   r6
-        cmpw    r6, r4
-        bne-    loop
+			mftbu   r4
+			mftb    r5
+			mftbu   r6
+			cmpw    r6, r4
+			bne-    loop
+			
+			stw     r4, 0(r3)
+			stw     r5, 4(r3)
+			
+			blr
 
-        stw     r4, 0(r3)
-        stw     r5, 4(r3)
+/*
+ *		unsigned int cpu_number(void)
+ *
+ *			Returns the current cpu number. 
+ */
 
-        blr
+			.align	5
+			.globl	EXT(cpu_number)
+
+LEXT(cpu_number)
+
+			mfsprg	r7,0							; Get per-proc block
+			lhz		r3,PP_CPU_NUMBER(r7)			; Get CPU number 
+			blr										; Return...
 
 /*
- *		The routine that implements cpu_number.
+ *		thread_t current_thread(void)
+ *
+ *			Return the active thread for both inside and outside osfmk consumption
  */
+			.align	5
+			.globl	EXT(current_thread)
 
-		.align  5
-		.globl  EXT(cpu_number)
- 
-LEXT(cpu_number)
+LEXT(current_thread)
+
+			mfsprg	r3,1
+			lwz		r3,ACT_THREAD(r3)
+			blr
+
+/*
+ *		set_machine_current_thread(thread_t)
+ *
+ *			Set the active thread 
+ */
+			.align	5
+			.globl	EXT(set_machine_current_thread)
+
+LEXT(set_machine_current_thread)
+
+			mfsprg	r6,0							; Get the per_proc
+			stw		r3,PP_ACTIVE_THREAD(r6)			; Set the active thread
+			blr										; Return...
+
+/*
+ *		void set_machine_current_act(thread_act_t)
+ *
+ *			Set the current activation
+ */
+			.align	5
+			.globl	EXT(set_machine_current_act)
+
+LEXT(set_machine_current_act)
+
+			mtsprg	1,r3							; Set spr1 with the active thread
+			blr										; Return...
+
+/*
+ *		thread_act_t current_act(void)
+ *
+ *			Return the current activation
+ */
+			.align	5
+			.globl	EXT(current_act)
+
+LEXT(current_act)
+
+			mfsprg	r3,1
+			blr
+
+/*
+ *		cpu_data_t* get_cpu_data(void)
+ *
+ *			Return the cpu_data
+ */
+			.align	5
+			.globl	EXT(get_cpu_data)
+
+LEXT(get_cpu_data)
  
-		mfmsr	r9						/* Save the old MSR */
-		rlwinm	r9,r9,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-		rlwinm	r9,r9,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-		rlwinm	r8,r9,0,17,15			/* Clear interruptions */
-		mtmsr	r8						/* Interrupts off */
-		isync
-		mfsprg	r7,0					/* Get per-proc block */
-		lhz		r3,PP_CPU_NUMBER(r7)	/* Get CPU number */
-		mtmsr	r9						/* Restore interruptions to entry */
-		blr								/* Return... */
+			mfsprg	r3,0							; Get the per_proc
+			addi	r3,r3,PP_ACTIVE_THREAD			; Get the pointer to the CPU data from per proc
+			blr										; Return...
 
 /*
 **      ml_sense_nmi()
@@ -1338,3 +2020,18 @@ sps1:
 
 sps2:
 			blr
+
+/*
+**      ml_set_processor_voltage()
+**
+*/
+;			Force a line boundry here
+			.align	5
+			.globl	EXT(ml_set_processor_voltage)
+
+LEXT(ml_set_processor_voltage)
+			mfspr	r4, hid2							; Get HID2 value
+			rlwimi	r4, r3, 31-hid2vmin, hid2vmin, hid2vmin				; Insert the voltage mode bit
+			mtspr	hid2, r4							; Set the voltage mode
+			sync									; Make sure it is done
+			blr
diff --git a/osfmk/ppc/machine_rpc.h b/osfmk/ppc/machine_rpc.h
index 087c562d5..92d5f6f4a 100644
--- a/osfmk/ppc/machine_rpc.h
+++ b/osfmk/ppc/machine_rpc.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ppc/machlimits.h b/osfmk/ppc/machlimits.h
index 453c62f15..be26348d3 100644
--- a/osfmk/ppc/machlimits.h
+++ b/osfmk/ppc/machlimits.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ppc/machparam.h b/osfmk/ppc/machparam.h
index 7df7e9afc..d45facf9c 100644
--- a/osfmk/ppc/machparam.h
+++ b/osfmk/ppc/machparam.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ppc/mappings.c b/osfmk/ppc/mappings.c
index 237e2bc12..5fc22ea7d 100644
--- a/osfmk/ppc/mappings.c
+++ b/osfmk/ppc/mappings.c
@@ -1,21 +1,24 @@
 /*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -46,12 +49,12 @@
 #include <kern/spl.h>
 
 #include <kern/misc_protos.h>
+#include <ppc/exception.h>
 #include <ppc/misc_protos.h>
 #include <ppc/proc_reg.h>
 
 #include <vm/pmap.h>
 #include <ppc/pmap.h>
-#include <ppc/pmap_internals.h>
 #include <ppc/mem.h>
 
 #include <ppc/new_screen.h>
@@ -63,20 +66,21 @@
 
 #define PERFTIMES 0
 
-#if PERFTIMES && DEBUG
-#define debugLog2(a, b, c) dbgLog2(a, b, c)
-#else
-#define debugLog2(a, b, c)
-#endif
-
 vm_map_t        mapping_map = VM_MAP_NULL;
-#define		MAPPING_MAP_SIZE	33554432	/* 32MB address space */
 
-unsigned int	incrVSID = 0;									/* VSID increment value */
+unsigned int	incrVSID = 0;						/* VSID increment value */
 unsigned int	mappingdeb0 = 0;						
-unsigned int	mappingdeb1 = 0;						
+unsigned int	mappingdeb1 = 0;
+int ppc_max_adrsp;									/* Maximum address spaces */			
+				
+addr64_t		*mapdebug;							/* (BRINGUP) */
+extern unsigned int DebugWork;						/* (BRINGUP) */
+						
 extern unsigned int	hash_table_size;						
-extern vm_offset_t mem_size;
+
+void mapping_verify(void);
+void mapping_phys_unused(ppnum_t pa);
+
 /*
  *	ppc_prot translates from the mach representation of protections to the PPC version.
  *  We also allow for a direct setting of the protection bits. This extends the mach
@@ -148,893 +152,487 @@ extern vm_offset_t mem_size;
 
 void mapping_init(void) {
 
-	unsigned int tmp;
+	unsigned int tmp, maxeff, rwidth;
+	
+	ppc_max_adrsp = maxAdrSp;									/* Set maximum address spaces */			
+	
+	maxeff = 32;												/* Assume 32-bit */
+	if(per_proc_info[0].pf.Available & pf64Bit) maxeff = 64;	/* Is this a 64-bit machine? */
+	
+	rwidth = per_proc_info[0].pf.pfMaxVAddr - maxAdrSpb;		/* Reduce address width by width of address space ID */
+	if(rwidth > maxeff) rwidth = maxeff;						/* If we still have more virtual than effective, clamp at effective */
 	
-	__asm__ volatile("cntlzw %0, %1" : "=r" (tmp) : "r" (hash_table_size));	/* Get number of leading 0s */
+	vm_max_address = 0xFFFFFFFFFFFFFFFFULL >> (64 - rwidth);		/* Get maximum effective address supported */
+	vm_max_physical = 0xFFFFFFFFFFFFFFFFULL >> (64 - per_proc_info[0].pf.pfMaxPAddr);	/* Get maximum physical address supported */
+	
+	if(per_proc_info[0].pf.Available & pf64Bit) {				/* Are we 64 bit? */
+		tmp = 12;												/* Size of hash space */
+	}
+	else {
+		__asm__ volatile("cntlzw %0, %1" : "=r" (tmp) : "r" (hash_table_size));	/* Get number of leading 0s */
+		tmp = 32 - tmp;											/* Size of hash space */
+	}
 
-	incrVSID = 1 << ((32 - tmp + 1) >> 1);						/* Get ceiling of sqrt of table size */
-	incrVSID |= 1 << ((32 - tmp + 1) >> 2);						/* Get ceiling of quadroot of table size */
+	incrVSID = 1 << ((tmp + 1) >> 1);							/* Get ceiling of sqrt of table size */
+	incrVSID |= 1 << ((tmp + 1) >> 2);							/* Get ceiling of quadroot of table size */
 	incrVSID |= 1;												/* Set bit and add 1 */
+
 	return;
 
 }
 
 
 /*
- *		mapping_remove(pmap_t pmap, vm_offset_t va);
- *			Given a pmap and virtual address, this routine finds the mapping and removes it from
- *			both its PTEG hash list and the physical entry list.  The mapping block will be added to
+ *		mapping_remove(pmap_t pmap, addr64_t va);
+ *			Given a pmap and virtual address, this routine finds the mapping and unmaps it.
+ *			The mapping block will be added to
  *			the free list.  If the free list threshold is reached, garbage collection will happen.
- *			We also kick back a return code to say whether or not we had one to remove.
- *
- *			We have a strict ordering here:  the mapping must be removed from the PTEG hash list before
- *			it can be removed from the physical entry list.  This allows us to get by with only the PTEG
- *			hash lock at page fault time. The physical entry lock must be held while we remove the mapping 
- *			from both lists. The PTEG lock is one of the lowest level locks.  No PTE fault, interruptions,
- *			losing control, getting other locks, etc., are allowed when you hold it. You do, and you die.
- *			It's just that simple!
- *
- *			When the phys_entry lock is held, the mappings chained to that one are guaranteed to stay around.
- *			However, a mapping's order on the PTEG hash chain is not.  The interrupt handler uses the PTEG
- *			lock to control the hash cahin and may move the position of the mapping for MRU calculations.
- *
- *			Note that mappings do not need to point to a physical entry. When they don't, it indicates 
- *			the mapping is outside of physical memory and usually refers to a memory mapped device of
- *			some sort.  Naturally, we can't lock what we don't have, so the phys entry lock and unlock
- *			routines return normally, but don't do anything.
- */
-
-boolean_t mapping_remove(pmap_t pmap, vm_offset_t va) {			/* Remove a single mapping for this VADDR 
-																   Returns TRUE if a mapping was found to remove */
-
-	mapping		*mp, *mpv;
-	register blokmap *blm;
-	spl_t 		s;
-	unsigned int *useadd, *useaddr;
-	int i;
-	
-	debugLog2(1, va, pmap->space);								/* start mapping_remove */
-
-	s=splhigh();												/* Don't bother me */
-	
-	mp = hw_lock_phys_vir(pmap->space, va);						/* Lock the physical entry for this mapping */
-
-	if(!mp) {													/* Did we find one? */
-		splx(s);											/* Allow 'rupts now */
-		if(mp = (mapping *)hw_rem_blk(pmap, va, va)) {			/* No normal pages, try to remove an odd-sized one */
-			
-			if((unsigned int)mp & 1) {							/* Make sure we don't unmap a permanent one */
-				blm = (blokmap *)hw_cpv((mapping *)((unsigned int)mp & 0xFFFFFFFC));		/* Get virtual address */
-				panic("mapping_remove: attempt to unmap a permanent mapping - pmap = %08X, va = %08X, mapping = %08X\n",
-					pmap, va, blm);
-			}
-			while ((unsigned int)mp & 2)
-				mp = (mapping *)hw_rem_blk(pmap, va, va);
-#if 0
-			blm = (blokmap *)hw_cpv(mp);						/* (TEST/DEBUG) */
-			kprintf("mapping_remove: removed block map - bm=%08X; start=%08X; end=%08X; PTEr=%08X\n",	/* (TEST/DEBUG) */
-			 blm, blm->start, blm->end, blm->PTEr);
-#endif
-			mapping_free(hw_cpv(mp));							/* Release it */
-			debugLog2(2, 1, 0);									/* End mapping_remove */
-			return TRUE;										/* Tell them we did it */
-		}
-		debugLog2(2, 0, 0);										/* end mapping_remove */
-		return FALSE;											/* Didn't find any, return FALSE... */
-	}
-	if((unsigned int)mp&1) {									/* Did we timeout? */
-		panic("mapping_remove: timeout locking physical entry\n");	/* Yeah, scream about it! */
-		splx(s);												/* Restore the interrupt level */
-		return FALSE;											/* Bad hair day, return FALSE... */
-	}
-	
-	mpv = hw_cpv(mp);											/* Get virtual address of mapping */
-#if DEBUG
-	if(hw_atomic_sub(&mpv->pmap->stats.resident_count, 1) < 0) panic("pmap resident count went negative\n");
-#else
-	(void)hw_atomic_sub(&mpv->pmap->stats.resident_count, 1);	/* Decrement the resident page count */
-#endif
-	useadd = (unsigned int *)&pmap->pmapUsage[(va >> pmapUsageShft) & pmapUsageMask];	/* Point to slot to bump */
-	useaddr = (unsigned int *)((unsigned int)useadd & -4);		/* Round down to word */
-	(void)hw_atomic_sub(useaddr, (useaddr == useadd) ? 0x00010000 : 1);	/* Increment the even or odd slot */
-
-#if 0
-	for(i = 0; i < (pmapUsageMask + 1); i++) {					/* (TEST/DEBUG) */
-		if((mpv->pmap->pmapUsage[i]) > 8192) {					/* (TEST/DEBUG) */
-			panic("mapping_remove: pmapUsage slot for %08X has invalid count (%d) for pmap %08X\n",
-				i * pmapUsageSize, mpv->pmap->pmapUsage[i], mpv->pmap);
-		}
-	}
-#endif
-	
-	hw_rem_map(mp);												/* Remove the corresponding mapping */
-	
-	if(mpv->physent)hw_unlock_bit((unsigned int *)&mpv->physent->phys_link, PHYS_LOCK);	/* Unlock physical entry associated with mapping */
-	
-	splx(s);													/* Was there something you needed? */
-		
-	mapping_free(mpv);											/* Add mapping to the free list */
-	debugLog2(2, 1, 0);											/* end mapping_remove */
-	return TRUE;												/* Tell them we did it */
-}
-
-/*
- *		mapping_purge_pmap(struct phys_entry *pp, pmap_t pmap) - release all mappings for this physent for the specified map
  *
- *		This guy releases any mappings that exist for a physical page on a specified map.
- *		We get the lock on the phys_entry, and hold it through out this whole routine.
- *		That way, no one can change the queue out from underneath us.  We keep fetching
- *		the physents mapping anchor until it is null, then we're done.  
+ *			We also pass back the next higher mapped address. This is done so that the higher level
+ *			pmap_remove function can release a range of addresses simply by calling mapping_remove
+ *			in a loop until it finishes the range or is returned a vaddr of 0.
  *
- *		For each mapping, we call the remove routine to remove it from the PTEG hash list and 
- *		decriment the pmap's residency count.  Then we release the mapping back to the free list.
+ *			Note that if the mapping is not found, we return the next VA ORed with 1
  *
  */
- 
 
-void mapping_purge_pmap(struct phys_entry *pp, pmap_t pmap) {		/* Remove all mappings from specified pmap for this physent */
+addr64_t mapping_remove(pmap_t pmap, addr64_t va) {		/* Remove a single mapping for this VADDR 
+														   Returns TRUE if a mapping was found to remove */
 
-	mapping		*mp, *mp_next, *mpv;
-	spl_t 		s;
-	unsigned int *useadd, *useaddr, uindx;
-	int i;
-		
-	s=splhigh();									/* Don't bother me */
+	mapping		*mp;
+	addr64_t	nextva;
 	
-	if(!hw_lock_bit((unsigned int *)&pp->phys_link, PHYS_LOCK, LockTimeOut)) {	/* Lock the physical entry */
-		panic("\nmapping_purge_pmap: Timeout attempting to lock physical entry at %08X: %08X %08X\n", 
-			pp, pp->phys_link, pp->pte1);	/* Complain about timeout */
-	}
+	disable_preemption();								/* Don't change threads */
 
-	mp = (mapping *)((unsigned int)pp->phys_link & ~PHYS_FLAGS);
-	
-	while(mp) {	/* Keep going so long as there's another */
-
-		mpv = hw_cpv(mp);					/* Get the virtual address */
-		if(mpv->pmap != pmap) {
-			mp = (mapping *)((unsigned int)mpv->next & ~PHYS_FLAGS);
-			continue;
-		}
-#if DEBUG
-		if(hw_atomic_sub(&mpv->pmap->stats.resident_count, 1) < 0) panic("pmap resident count went negative\n");
-#else
-		(void)hw_atomic_sub(&mpv->pmap->stats.resident_count, 1);	/* Decrement the resident page count */
-#endif
-
-		uindx = ((mpv->PTEv >> 24) & 0x78) | ((mpv->PTEv >> 3) & 7);	/* Join seg # and top 2 bits of API */
-		useadd = (unsigned int *)&mpv->pmap->pmapUsage[uindx];	/* Point to slot to bump */
-		useaddr = (unsigned int *)((unsigned int)useadd & -4);	/* Round down to word */
-		(void)hw_atomic_sub(useaddr, (useaddr == useadd) ? 0x00010000 : 1); /* Incr the even or odd slot */
-
-	
-	
-		mp_next = (mapping *)((unsigned int)mpv->next & ~PHYS_FLAGS);
-		hw_rem_map(mp);						/* Remove the mapping */
-		mapping_free(mpv);					/* Add mapping to the free list */
-		mp = mp_next;
+	while(1) {											/* Keep trying until we truely fail */
+		mp = hw_rem_map(pmap, va, &nextva);				/* Remove a mapping from this pmap */
+		if(((unsigned int)mp & mapRetCode) != mapRtRemove) break;	/* If it is gone, we are done */
 	}
-		
-	hw_unlock_bit((unsigned int *)&pp->phys_link, PHYS_LOCK);	/* We're done, unlock the physical entry */
-	splx(s);
-	return;
-}
-/*
- *		mapping_purge(struct phys_entry *pp) - release all mappings for this physent to the free list 
- *
- *		This guy releases any mappings that exist for a physical page.
- *		We get the lock on the phys_entry, and hold it through out this whole routine.
- *		That way, no one can change the queue out from underneath us.  We keep fetching
- *		the physents mapping anchor until it is null, then we're done.  
- *
- *		For each mapping, we call the remove routine to remove it from the PTEG hash list and 
- *		decriment the pmap's residency count.  Then we release the mapping back to the free list.
- *
- */
- 
-void mapping_purge(struct phys_entry *pp) {						/* Remove all mappings for this physent */
-
-	mapping		*mp, *mpv;
-	spl_t 		s;
-	unsigned int *useadd, *useaddr, uindx;
-	int i;
-		
-	s=splhigh();												/* Don't bother me */
-	debugLog2(3, pp->pte1, 0);									/* start mapping_purge */
-	
-	if(!hw_lock_bit((unsigned int *)&pp->phys_link, PHYS_LOCK, LockTimeOut)) {		/* Lock the physical entry */
-		panic("\nmapping_purge: Timeout attempting to lock physical entry at %08X: %08X %08X\n", 
-			pp, pp->phys_link, pp->pte1);	/* Complain about timeout */
-	}
-	
-	while(mp = (mapping *)((unsigned int)pp->phys_link & ~PHYS_FLAGS)) {	/* Keep going so long as there's another */
 
-		mpv = hw_cpv(mp);										/* Get the virtual address */
-#if DEBUG
-		if(hw_atomic_sub(&mpv->pmap->stats.resident_count, 1) < 0) panic("pmap resident count went negative\n");
-#else
-		(void)hw_atomic_sub(&mpv->pmap->stats.resident_count, 1);	/* Decrement the resident page count */
-#endif
+	enable_preemption();								/* Thread change ok */
 
-		uindx = ((mpv->PTEv >> 24) & 0x78) | ((mpv->PTEv >> 3) & 7);	/* Join segment number and top 2 bits of the API */
-		useadd = (unsigned int *)&mpv->pmap->pmapUsage[uindx];	/* Point to slot to bump */
-		useaddr = (unsigned int *)((unsigned int)useadd & -4);	/* Round down to word */
-		(void)hw_atomic_sub(useaddr, (useaddr == useadd) ? 0x00010000 : 1);	/* Increment the even or odd slot */
+	if(!mp) return (nextva | 1);						/* Nothing found to unmap */
 
-#if 0
-	for(i = 0; i < (pmapUsageMask + 1); i++) {					/* (TEST/DEBUG) */
-		if((mpv->pmap->pmapUsage[i]) > 8192) {					/* (TEST/DEBUG) */
-			panic("mapping_remove: pmapUsage slot for %08X has invalid count (%d) for pmap %08X\n",
-				i * pmapUsageSize, mpv->pmap->pmapUsage[i], mpv->pmap);
-		}
-	}
-#endif
-	
+	if((unsigned int)mp & mapRetCode) {					/* Was there a failure? */
 	
-		hw_rem_map(mp);											/* Remove the mapping */
-		mapping_free(mpv);										/* Add mapping to the free list */
+		panic("mapping_remove: hw_rem_map failed - pmap = %08X, va = %016llX, code = %08X\n",
+			pmap, va, mp);
 	}
-		
-	hw_unlock_bit((unsigned int *)&pp->phys_link, PHYS_LOCK);	/* We're done, unlock the physical entry */
 	
-	debugLog2(4, pp->pte1, 0);									/* end mapping_purge */
-	splx(s);													/* Was there something you needed? */
-	return;														/* Tell them we did it */
-}
+	mapping_free(mp);									/* Add mapping to the free list */
 
+	return nextva;										/* Tell them we did it */
+}
 
 /*
- *		mapping_make(pmap, pp, va, spa, prot, attr, locked) - map a virtual address to a real one 
+ *		mapping_make(pmap, va, pa, flags, size, prot) - map a virtual address to a real one 
  *
  *		This routine takes the given parameters, builds a mapping block, and queues it into the 
  *		correct lists.
  *		
- *		The pp parameter can be null.  This allows us to make a mapping that is not
- *		associated with any physical page.  We may need this for certain I/O areas.
+ *		pmap (virtual address)		is the pmap to map into
+ *		va   (virtual address)		is the 64-bit virtual address that is being mapped
+ *		pa	(physical page number)	is the physical page number (i.e., physcial address >> 12). This is
+ *									a 32-bit quantity.
+ *		Flags:
+ *			block					if 1, mapping is a block, size parameter is used. Note: we do not keep 
+ *									reference and change information or allow protection changes of blocks.
+ *									any changes must first unmap and then remap the area.
+ *			use attribute			Use specified attributes for map, not defaults for physical page
+ *			perm					Mapping is permanent
+ *			cache inhibited			Cache inhibited (used if use attribute or block set )
+ *			guarded					Guarded access (used if use attribute or block set )
+ *		size						size of block (not used if not block)
+ *		prot						VM protection bits
+ *		attr						Cachability/Guardedness    
+ *
+ *		Returns 0 if mapping was successful.  Returns vaddr that overlaps/collides.
+ *		Returns 1 for any other failure.
+ *
+ *		Note that we make an assumption that all memory in the range 0f 0x0000000080000000 to 0x00000000FFFFFFFF is reserved
+ *		for I/O and default the cache attrubutes appropriately.  The caller is free to set whatever they want however.
+ *
+ *		If there is any physical page that is not found in the physent table, the mapping is forced to be a
+ *		block mapping of length 1.  This keeps us from trying to update a physent during later mapping use,
+ *		e.g., fault handling.
+ *
  *
- *		If the phys_entry address is null, we neither lock or chain into it.
- *		If locked is 1, we already hold the lock on the phys_entry and won't get nor release it.
  */
  
-mapping *mapping_make(pmap_t pmap, struct phys_entry *pp, vm_offset_t va, vm_offset_t pa, vm_prot_t prot, int attr, boolean_t locked) {	/* Make an address mapping */
+addr64_t mapping_make(pmap_t pmap, addr64_t va, ppnum_t pa, unsigned int flags, unsigned int size, vm_prot_t prot) {	/* Make an address mapping */
 
-	register mapping *mp, *mpv;
-	unsigned int *useadd, *useaddr;
-	spl_t 		s;
-	int i;
+	register mapping *mp;
+	addr64_t colladdr;
+	unsigned int pindex, mflags, pattr, wimg;
+	phys_entry *physent;
+	int i, nlists;
 
-	debugLog2(5, va, pa);										/* start mapping_purge */
-	mpv = mapping_alloc();										/* Get a spare mapping block */
-	
-	mpv->pmap = pmap;											/* Initialize the pmap pointer */
-	mpv->physent = pp;											/* Initialize the pointer to the physical entry */
-	mpv->PTEr = ((unsigned int)pa & ~(PAGE_SIZE - 1)) | attr<<3 | ppc_prot(prot);	/* Build the real portion of the PTE */
-	mpv->PTEv = (((unsigned int)va >> 1) & 0x78000000) | (pmap->space << 7) | (((unsigned int)va >> 22) & 0x0000003F);	/* Build the VSID */
+	disable_preemption();										/* Don't change threads */
 
-	s=splhigh();												/* Don't bother from now on */
+	pindex = 0;
+	
+	mflags = 0x01000000;										/* Start building mpFlags field (busy count = 1) */
 	
-	mp = hw_cvp(mpv);											/* Get the physical address of this */
+	if(!(flags & mmFlgBlock)) {									/* Is this a block map? */
 
-	if(pp && !locked) {											/* Is there a physical entry? Or do we already hold the lock? */
-		if(!hw_lock_bit((unsigned int *)&pp->phys_link, PHYS_LOCK, LockTimeOut)) {	/* Lock the physical entry */
-			panic("\nmapping_make: Timeout attempting to lock physical entry at %08X: %08X %08X\n", 
-				pp, pp->phys_link, pp->pte1);					/* Complain about timeout */
+		size = 1;												/* Set size to 1 page if not block */
+	 
+		physent = mapping_phys_lookup(pa, &pindex);				/* Get physical entry */
+		if(!physent) {											/* Did we find the physical page? */
+			mflags |= mpBlock;									/* Force this to a block if no physent */
+			size = 1;											/* Force size to 1 page */
+			pattr = 0;											/* Assume normal, non-I/O memory */
+			if((pa & 0xFFF80000) == 0x00080000) pattr = mmFlgCInhib | mmFlgGuarded;	/* If this page is in I/O range, set I/O attributes */
 		}
-	}
+		else pattr = ((physent->ppLink & (ppI | ppG)) >> 4);	/* Get the default attributes from physent */
 		
-	if(pp) {													/* See of there is a physcial entry */
-		mpv->next = (mapping *)((unsigned int)pp->phys_link & ~PHYS_FLAGS);		/* Move the old anchor to the new mappings forward */
-		pp->phys_link = (mapping *)((unsigned int)mp | (unsigned int)pp->phys_link & PHYS_FLAGS);	/* Point the anchor at us.  Now we're on the list (keep the flags) */
+		if(flags & mmFlgUseAttr) pattr = flags & (mmFlgCInhib | mmFlgGuarded);	/* Use requested attributes */
 	}
-	
-	hw_add_map(mp, pmap->space, va);							/* Stick it on the PTEG hash list */
-	
-	(void)hw_atomic_add(&mpv->pmap->stats.resident_count, 1);	/* Increment the resident page count */
-	useadd = (unsigned int *)&pmap->pmapUsage[(va >> pmapUsageShft) & pmapUsageMask];	/* Point to slot to bump */
-	useaddr = (unsigned int *)((unsigned int)useadd & -4);		/* Round down to word */
-	(void)hw_atomic_add(useaddr, (useaddr == useadd) ? 0x00010000 : 1);	/* Increment the even or odd slot */
-#if 0
-	for(i = 0; i < (pmapUsageMask + 1); i++) {					/* (TEST/DEBUG) */
-		if((mpv->pmap->pmapUsage[i]) > 8192) {					/* (TEST/DEBUG) */
-			panic("mapping_remove: pmapUsage slot for %08X has invalid count (%d) for pmap %08X\n",
-				i * pmapUsageSize, mpv->pmap->pmapUsage[i], mpv->pmap);
-		}
+	else {														/* This is a block */
+		 
+		pattr = flags & (mmFlgCInhib | mmFlgGuarded);			/* Use requested attributes */
+		mflags |= mpBlock;										/* Show that this is a block */
 	}
-#endif
-
-	if(pp && !locked)hw_unlock_bit((unsigned int *)&pp->phys_link, PHYS_LOCK);	/* If we have one and we didn't hold on entry, unlock the physical entry */
-		
-	splx(s);													/* Ok for interruptions now */
-	debugLog2(6, pmap->space, prot);							/* end mapping_purge */
-	return mpv;													/* Leave... */
-}
-
-
-/*
- *		Enters optimal translations for odd-sized V=F blocks.
- *
- *		Builds a block map for each power-of-two hunk o' address
- *		that exists.  This is specific to the processor type.  
- *		PPC uses BAT register size stuff.  Future PPC might have
- *		something else.
- *
- *		The supplied va is expected to be maxoptimal vs the supplied boundary. We're too
- *		stupid to know otherwise so we only look at the va anyhow, so there...
- *
- */
- 
-void mapping_block_map_opt(pmap_t pmap, vm_offset_t va, vm_offset_t pa, vm_offset_t bnd, vm_size_t size, vm_prot_t prot, int attr) {	/* Maps optimal autogenned blocks */
-
-	register blokmap *blm, *oblm;
-	unsigned int	pg;
-	unsigned int	maxsize, boundary, leading, trailing, cbsize, minsize, tomin;
-	int				i, maxshft, nummax, minshft;
-
-#if 1
-	kprintf("mapping_block_map_opt: pmap=%08X; va=%08X; pa=%08X; ; bnd=%08X; size=%08X; prot=%08X; attr=%08X\n",	/* (TEST/DEBUG) */
-	 pmap, va, pa, bnd, size, prot, attr);
-#endif
 	
-	minsize = blokValid ^ (blokValid & (blokValid - 1));	/* Set minimum subblock size */
-	maxsize = 0x80000000 >> cntlzw(blokValid);		/* Set maximum subblock size */
+	wimg = 0x2;													/* Set basic PPC wimg to 0b0010 - Coherent */
+	if(pattr & mmFlgCInhib) wimg |= 0x4;						/* Add cache inhibited if we need to */
+	if(pattr & mmFlgGuarded) wimg |= 0x1;						/* Add guarded if we need to */
 	
-	minshft = 31 - cntlzw(minsize);					/* Shift to position minimum size */
-	maxshft = 31 - cntlzw(blokValid);				/* Shift to position maximum size */
+	mflags = mflags | (pindex << 16);							/* Stick in the physical entry table index */
 	
-	leading = ((va + bnd - 1) & -bnd) - va;			/* Get size of leading area */
-	trailing = size - leading;						/* Get size of trailing area */
-	tomin = ((va + minsize - 1) & -minsize) - va;	/* Get size needed to round up to the minimum block size */
+	if(flags & mmFlgPerm) mflags |= mpPerm;						/* Set permanent mapping */
 	
-#if 1
-	kprintf("mapping_block_map_opt: bnd=%08X; leading=%08X; trailing=%08X; tomin=%08X\n", bnd, leading, trailing, tomin);		/* (TEST/DEBUG) */
-#endif
-
-	if(tomin)pmap_map_block(pmap, va, pa, tomin, prot, attr, 0); /* Map up to minimum block size */
+	size = size - 1;											/* Change size to offset */
+	if(size > 0xFFFF) return 1;									/* Leave if size is too big */
 	
-	va = va + tomin;								/* Adjust virtual start */
-	pa = pa + tomin;								/* Adjust physical start */
-	leading = leading - tomin;						/* Adjust leading size */
+	nlists = mapSetLists(pmap);									/* Set number of lists this will be on */
 	
-/*
- *	Some of this code is very classic PPC.  We need to fix this up.
- */
- 
-	leading = leading >> minshft;					/* Position for bit testing */
-	cbsize = minsize;								/* Set the minimum size */
+	mp = mapping_alloc(nlists);									/* Get a spare mapping block with this many lists */
+
+                                                                /* the mapping is zero except that the mpLists field is set */
+	mp->mpFlags |= mflags;										/* Add in the rest of the flags to mpLists */
+	mp->mpSpace = pmap->space;									/* Set the address space/pmap lookup ID */
+	mp->mpBSize = size;											/* Set the size */
+	mp->mpPte = 0;												/* Set the PTE invalid */
+	mp->mpPAddr = pa;											/* Set the physical page number */
+	mp->mpVAddr = (va & ~mpHWFlags) | (wimg << 3) | ppc_prot(prot);	/* Add the protection and attributes to the field */
 	
-	for(i = 0; i < (maxshft - minshft + 1); i ++) {	/* Cycle through all block sizes, small to large */
+	while(1) {													/* Keep trying... */
+		colladdr = hw_add_map(pmap, mp);						/* Go add the mapping to the pmap */
+		if(!colladdr) {											/* All is ok... */
+			enable_preemption();								/* Ok to switch around here */
+			return 0;											/* Return... */
+		}
 		
-		if(leading & 1) {		
-			pmap_map_block(pmap, va, pa, cbsize, prot, attr, 0); /* Map up to next boundary */
-			pa = pa + cbsize;						/* Bump up physical address */
-			va = va + cbsize;						/* Bump up virtual address */
+		if((colladdr & mapRetCode) == mapRtRemove) {			/* Is our target being removed? */
+			(void)mapping_remove(pmap, colladdr);				/* Yes, go help out */
+			continue;											/* Try to add it now */
+		}
+		
+		if((colladdr & mapRetCode) == mapRtMapDup) {			/* Is our target already mapped (collision mapping must be identical)? */
+			mapping_free(mp);									/* Return mapping to the free list */
+			enable_preemption();								/* Ok to switch around here */
+			return 0;											/* Normal return */
 		}
-	
-		leading = leading >> 1;						/* Shift up to next size */
-		cbsize = cbsize << 1;						/* Here too */
-
-	}
-	
-	nummax = trailing >> maxshft;					/* Get number of max size blocks left */
-	for(i=0; i < nummax - 1; i++) {					/* Account for all max size block left but 1 */
-		pmap_map_block(pmap, va, pa, maxsize, prot, attr, 0); /* Map up to next boundary */
-
-		pa = pa + maxsize;							/* Bump up physical address */
-		va = va + maxsize;							/* Bump up virtual address */
-		trailing -= maxsize;						/* Back off what we just did */
-	}
-	
-	cbsize = maxsize;								/* Start at maximum size */
-	
-	for(i = 0; i < (maxshft - minshft + 1); i ++) {	/* Cycle through all block sizes, high to low */
 		
-		if(trailing & cbsize) {	
-			trailing &= ~cbsize;					/* Remove the block we are allocating */						
-			pmap_map_block(pmap, va, pa, cbsize, prot, attr, 0); /* Map up to next boundary */
-			pa = pa + cbsize;						/* Bump up physical address */
-			va = va + cbsize;						/* Bump up virtual address */
-		}	
-		cbsize = cbsize >> 1;						/* Next size down */
+		if(colladdr != mapRtBadLk) {							/* Did it collide? */
+			mapping_free(mp);									/* Yeah, toss the pending mapping */
+			enable_preemption();								/* Ok to switch around here */
+			return colladdr;									/* Pass back the overlapping address */
+		}
+			
+		panic("mapping_make: hw_add_map failed - code = %08X, pmap = %08X, va = %016llX, mapping = %08X\n",
+			colladdr, pmap, va, mp);							/* Die dead */
 	}
 	
-	if(trailing) pmap_map_block(pmap, va, pa, trailing, prot, attr, 0); /* Map up to end */
-	
-	return;													/* Return */
+	return 1;													/* Leave... */
 }
 
 
 /*
- *		Enters translations for odd-sized V=F blocks.
+ *		mapping *mapping_find(pmap, va, *nextva, full) - Finds a mapping 
  *
- *		Checks to insure that the request is at least ODDBLKMIN in size.  If smaller, the request
- *		will be split into normal-sized page mappings.
+ *		Looks up the vaddr and returns the mapping and the next mapped va
+ *		If full is true, it will descend through all nested pmaps to find actual mapping
  *
- *		The higher level VM map should be locked to insure that we don't have a
- *		double diddle here.
+ *		Must be called with interruptions disabled or we can hang trying to remove found mapping.
  *
- *		We panic if we get a block that overlaps with another. We do not merge adjacent
- *		blocks because removing any address within a block removes the entire block and if
- *		would really mess things up if we trashed too much.
+ *		Returns 0 if not found and the virtual address of the mapping if it is
+ *		Note that the mappings busy count is bumped. It is the responsibility of the caller
+ *		to drop the count.  If this is not done, any attempt to remove the mapping will hang.
  *
- *		Once a block is mapped, it is unmutable, that is, protection, catch mode, etc. can
- *		not be changed.  The block must be unmapped and then remapped with the new stuff.
- *		We also do not keep track of reference or change flags.
+ *		NOTE: The nextva field is not valid when full is TRUE.
  *
- *		Blocks are kept in MRU order anchored from the pmap. The chain is traversed only
- *		with interruptions and translation disabled and under the control of the lock located
- *		in the first block map. MRU is used because it is expected that the same entry 
- *		will be accessed repeatedly while PTEs are being generated to cover those addresses.
  *
  */
  
-void pmap_map_block(pmap_t pmap, vm_offset_t va, vm_offset_t pa, vm_size_t size, vm_prot_t prot, int attr, unsigned int flags) {	/* Map an autogenned block */
-
-	register blokmap *blm, *oblm, *oblm_virt;;
-	unsigned int pg;
+mapping *mapping_find(pmap_t pmap, addr64_t va, addr64_t *nextva, int full) {	/* Make an address mapping */
 
-#if 0
-	kprintf("pmap_map_block: pmap=%08X; va=%08X; pa=%08X; size=%08X; prot=%08X; attr=%08X\n",	/* (TEST/DEBUG) */
-	 pmap, va, pa, size, prot, attr);
-#endif
-
-	if(size < ODDBLKMIN) {									/* Is this below the minimum size? */
-		for(pg = 0; pg < size; pg += PAGE_SIZE) {			/* Add all pages in this block */
-			mapping_make(pmap, 0, va + pg, pa + pg, prot, attr, 0);	/* Map this page on in */
-#if 0
-			kprintf("pmap_map_block: mm: va=%08X; pa=%08X\n",	/* (TEST/DEBUG) */
-				va + pg, pa + pg);
-#endif
-		}
-		return;												/* All done */
-	}
-	
-	blm = (blokmap *)mapping_alloc();						/* Get a block mapping */
-	
-	blm->start = (unsigned int)va & -PAGE_SIZE;				/* Get virtual block start */
-	blm->end = (blm->start + size - 1) | (PAGE_SIZE - 1);	/* Get virtual block end */
-	blm->current = 0;
-	blm->PTEr = ((unsigned int)pa & -PAGE_SIZE) | attr<<3 | ppc_prot(prot);	/* Build the real portion of the base PTE */
-	blm->space = pmap->space;								/* Set the space (only needed for remove) */
-	blm->blkFlags = flags;									/* Set the block's flags */
-	
-#if 0
-	kprintf("pmap_map_block: bm=%08X; start=%08X; end=%08X; PTEr=%08X\n",	/* (TEST/DEBUG) */
-	 blm, blm->start, blm->end, blm->PTEr);
-#endif
-
-	blm = (blokmap *)hw_cvp((mapping *)blm);				/* Get the physical address of this */
-
-#if 0
-	kprintf("pmap_map_block: bm (real)=%08X; pmap->bmaps=%08X\n",	/* (TEST/DEBUG) */
-	 blm, pmap->bmaps);
-#endif
-
-	do {
-		oblm = hw_add_blk(pmap, blm); 
-		if ((unsigned int)oblm & 2) {
-			oblm_virt = (blokmap *)hw_cpv((mapping *)((unsigned int)oblm & 0xFFFFFFFC));
-			mapping_remove(pmap, oblm_virt->start);
-		};
-	} while ((unsigned int)oblm & 2);
-
-	if (oblm) {
-		oblm = (blokmap *)hw_cpv((mapping *) oblm);				/* Get the old block virtual address */
-		blm = (blokmap *)hw_cpv((mapping *)blm);				/* Back to the virtual address of this */
-		if((oblm->start != blm->start) ||					/* If we have a match, then this is a fault race and */
-				(oblm->end != blm->end) ||				/* is acceptable */
-				(oblm->PTEr != blm->PTEr))
-			panic("pmap_map_block: block map overlap - blm = %08X\n", oblm);/* Otherwise, Squeak loudly and carry a big stick */
-		mapping_free((struct mapping *)blm);
-	}
-
-#if 0
-	kprintf("pmap_map_block: pmap->bmaps=%08X\n",			/* (TEST/DEBUG) */
-	 blm, pmap->bmaps);
-#endif
-
-	return;													/* Return */
-}
-
-
-/*
- *		Optimally enters translations for odd-sized V=F blocks.
- *
- *		Checks to insure that the request is at least ODDBLKMIN in size.  If smaller, the request
- *		will be split into normal-sized page mappings.
- *
- *		This one is different than pmap_map_block in that it will allocate it's own virtual
- *		target address. Rather than allocating a single block,
- *		it will also allocate multiple blocks that are power-of-two aligned/sized.  This allows
- *		hardware-level mapping that takes advantage of BAT maps or large page sizes.
- *
- *		Most considerations for pmap_map_block apply.
- *
- *
- */
- 
-kern_return_t pmap_map_block_opt(vm_map_t map, vm_offset_t *va, 
-	vm_offset_t pa, vm_size_t size, vm_prot_t prot, int attr) {	/* Map an optimal autogenned block */
+	register mapping *mp;
+	addr64_t	curva;
+	pmap_t	curpmap;
+	int	nestdepth;
 
-	register blokmap *blm, *oblm;
-	unsigned int 	pg;
-    kern_return_t	err;
-	unsigned int	bnd;
+	curpmap = pmap;												/* Remember entry */
+	nestdepth = 0;												/* Set nest depth */
+	curva = (addr64_t)va;											/* Set current va */
 
-#if 1
-	kprintf("pmap_map_block_opt: map=%08X; pa=%08X; size=%08X; prot=%08X; attr=%08X\n",	/* (TEST/DEBUG) */
-		map, pa, size, prot, attr);
-#endif
+	while(1) {
 
-	if(size < ODDBLKMIN) {									/* Is this below the minimum size? */
-		err = vm_allocate(map, va, size, VM_FLAGS_ANYWHERE);	/* Make us some memories */
-		if(err) {
-#if DEBUG
-			kprintf("pmap_map_block_opt: vm_allocate() returned %d\n", err);	/* Say we died */
-#endif
-			return(err);									/* Pass back the error */
+		mp = hw_find_map(curpmap, curva, nextva);				/* Find the mapping for this address */
+		if((unsigned int)mp == mapRtBadLk) {					/* Did we lock up ok? */
+			panic("mapping_find: pmap lock failure - rc = %08X, pmap = %08X\n", mp, curpmap);	/* Die... */
 		}
-#if 1
-		kprintf("pmap_map_block_opt: small; vaddr = %08X\n", *va);	/* (TEST/DEBUG) */
-#endif
+		
+		if(!mp || !(mp->mpFlags & mpNest) || !full) break;		/* Are we a nest or are we only going one deep? */
 
-		for(pg = 0; pg < size; pg += PAGE_SIZE) {			/* Add all pages in this block */
-			mapping_make(map->pmap, 0, *va + pg, pa + pg, prot, attr, 0);	/* Map this page on in */
+		if(mp->mpFlags & mpSpecial) {							/* Don't chain through a special mapping */
+			mp = 0;												/* Set not found */
+			break;
 		}
-		return(KERN_SUCCESS);								/* All done */
-	}
-	
-	err = vm_map_block(map, va, &bnd, pa, size, prot);		/* Go get an optimal allocation */
 
-	if(err == KERN_INVALID_ADDRESS) {						/* Can we try a brute force block mapping? */
-		err = vm_allocate(map, va, size, VM_FLAGS_ANYWHERE);	/* Make us some memories */
-		if(err) {
-#if DEBUG
-			kprintf("pmap_map_block_opt: non-optimal vm_allocate() returned %d\n", err);	/* Say we died */
-#endif
-			return(err);									/* Pass back the error */
+		if(nestdepth++ > 64) {									/* Have we nested too far down? */
+			panic("mapping_find: too many nested pmaps - va = %016llX, curva = %016llX, pmap = %08X, curpmap = %08X\n",
+				va, curva, pmap, curpmap);
 		}
-#if 1
-		kprintf("pmap_map_block_opt: non-optimal - vaddr = %08X\n", *va);	/* (TEST/DEBUG) */
-#endif
-		pmap_map_block(map->pmap, *va, pa, size, prot, attr, 0);	/* Set up a block mapped area */
-		return KERN_SUCCESS;								/* All done now */
-	}
-
-	if(err != KERN_SUCCESS) {								/* We couldn't get any address range to map this... */
-#if DEBUG
-		kprintf("pmap_map_block_opt: vm_allocate() returned %d\n", err);	/* Say we couldn' do it */
-#endif
-		return(err);
+		
+		curva = curva + mp->mpNestReloc;						/* Relocate va to new pmap */
+		curpmap = pmapTrans[mp->mpSpace].pmapVAddr;				/* Get the address of the nested pmap */
+		mapping_drop_busy(mp);									/* We have everything we need from the mapping */
+		
 	}
 
-#if 1
-	kprintf("pmap_map_block_opt: optimal - vaddr=%08X; bnd=%08X\n", *va, bnd);	/* (TEST/DEBUG) */
-#endif
-	mapping_block_map_opt(map->pmap, *va, pa, bnd, size, prot, attr);	/* Go build the maps */
-	return(KERN_SUCCESS);									/* All done */
+	return mp;													/* Return the mapping if we found one */
 }
 
-
-#if 0
-
 /*
- *		Enters translations for odd-sized V=F blocks and merges adjacent or overlapping
- *		areas.
- *
- *		Once blocks are merged, they act like one block, i.e., if you remove it,
- *		it all goes...
+ *		 kern_return_t mapping_protect(pmap_t pmap, addt_t va, vm_prot_t prot, addr64_t *nextva) - change the protection of a virtual page
  *
- *		This can only be used during boot.  Ain't no way we can handle SMP
- *		or preemption easily, so we restrict it.  We don't check either. We
- *		assume only skilled professional programmers will attempt using this
- *		function. We assume no responsibility, either real or imagined, for
- *		injury or death resulting from unauthorized use of this function.
+ *		This routine takes a pmap and virtual address and changes
+ *		the protection.  If there are PTEs associated with the mappings, they will be invalidated before
+ *		the protection is changed. 
  *
- *		No user servicable parts inside. Notice to be removed by end-user only,
- *		under penalty of applicable federal and state laws.
+ *		We return success if we change the protection or if there is no page mapped at va.  We return failure if
+ *		the va corresponds to a block mapped area or the mapping is permanant.
  *
- *		See descriptions of pmap_map_block. Ignore the part where we say we panic for
- *		overlapping areas.  Note that we do panic if we can't merge.
  *
  */
- 
-void pmap_map_block_merge(pmap_t pmap, vm_offset_t va, vm_offset_t pa, vm_size_t size, vm_prot_t prot, int attr) {	/* Map an autogenned block */
 
-	register blokmap *blm, *oblm;
-	unsigned int pg;
-	spl_t 		s;
+int mapping_protect(pmap_t pmap, addr64_t va, vm_prot_t prot, addr64_t *nextva) {	/* Change protection of a virtual page */
 
-#if 1
-	kprintf("pmap_map_block_merge: pmap=%08X; va=%08X; pa=%08X; size=%08X; prot=%08X; attr=%08X\n",	/* (TEST/DEBUG) */
-	 pmap, va, pa, size, prot, attr);
-#endif
-
-	s=splhigh();												/* Don't bother from now on */
-	if(size < ODDBLKMIN) {										/* Is this below the minimum size? */
-		for(pg = 0; pg < size; pg += PAGE_SIZE) {				/* Add all pages in this block */
-			mapping_make(pmap, 0, va + pg, pa + pg, prot, attr, 0);	/* Map this page on in */
-		}
-		return;													/* All done */
-	}
+	int	ret;
 	
-	blm = (blokmap *)mapping_alloc();							/* Get a block mapping */
-	
-	blm->start = (unsigned int)va & -PAGE_SIZE;					/* Get virtual block start */
-	blm->end = (blm->start + size - 1) | (PAGE_SIZE - 1);		/* Get virtual block end */
-	blm->PTEr = ((unsigned int)pa & -PAGE_SIZE) | attr<<3 | ppc_prot(prot);	/* Build the real portion of the base PTE */
-	
-#if 1
-	kprintf("pmap_map_block_merge: bm=%08X; start=%08X; end=%08X; PTEr=%08X\n",	/* (TEST/DEBUG) */
-	 blm, blm->start, blm->end, blm->PTEr);
-#endif
-
-	blm = (blokmap *)hw_cvp((mapping *)blm);					/* Get the physical address of this */
+	ret = hw_protect(pmap, va, ppc_prot(prot), nextva);	/* Try to change the protect here */
 
-#if 1
-	kprintf("pmap_map_block_merge: bm (real)=%08X; pmap->bmaps=%08X\n",	/* (TEST/DEBUG) */
-	 blm, pmap->bmaps);
-#endif
+	switch (ret) {								/* Decode return code */
+	
+		case mapRtOK:							/* Changed */
+		case mapRtNotFnd:						/* Didn't find it */
+			return mapRtOK;						/* Ok, return... */
+			break;
 
-	if(oblm = hw_add_blk(pmap, blm)) {							/* Add to list and make sure we don't overlap anything */
-		panic("pmap_map_block_merge: block map overlap - blm = %08X\n", oblm);	/* Squeak loudly and carry a big stick */
+		case mapRtBlock:						/* Block map, just ignore request */
+		case mapRtNest:							/* Nested pmap, just ignore request */
+			return ret;							/* Pass back return code */
+			break;
+			
+		default:
+			panic("mapping_protect: hw_protect failed - rc = %d, pmap = %08X, va = %016llX\n", ret, pmap, va);
+		
 	}
 
-#if 1
-	kprintf("pmap_map_block_merge: pmap->bmaps=%08X\n",			/* (TEST/DEBUG) */
-	 blm, pmap->bmaps);
-#endif
-	splx(s);													/* Ok for interruptions now */
-
-	return;														/* Return */
 }
-#endif
 
 /*
- *		void mapping_protect_phys(phys_entry *pp, vm_prot_t prot) - change the protection of a physical page
+ *		void mapping_protect_phys(ppnum_t pa, vm_prot_t prot) - change the protection of a physical page
  *
  *		This routine takes a physical entry and runs through all mappings attached to it and changes
  *		the protection.  If there are PTEs associated with the mappings, they will be invalidated before
- *		the protection is changed.  We don't try to save the PTE.  We won't worry about the LRU calculations
- *		either (I don't think, maybe I'll change my mind later).  There is no limitation on changes, e.g., 
+ *		the protection is changed.  There is no limitation on changes, e.g., 
  *		higher to lower, lower to higher.
  *
+ *		Any mapping that is marked permanent is not changed
+ *
  *		Phys_entry is unlocked.
  */
 
-void mapping_protect_phys(struct phys_entry *pp, vm_prot_t prot, boolean_t locked) {	/* Change protection of all mappings to page */
-
-	spl_t				spl;
+void mapping_protect_phys(ppnum_t pa, vm_prot_t prot) {	/* Change protection of all mappings to page */
 	
-	debugLog2(9, pp->pte1, prot);								/* end remap */
-	spl=splhigh();												/* No interruptions during this */
-	if(!locked) {												/* Do we need to lock the physent? */
-		if(!hw_lock_bit((unsigned int *)&pp->phys_link, PHYS_LOCK, LockTimeOut)) {	/* Lock the physical entry */
-			panic("\nmapping_protect: Timeout attempting to lock physical entry at %08X: %08X %08X\n", 
-				pp, pp->phys_link, pp->pte1);						/* Complain about timeout */
-		}
-	}	
-
-	hw_prot(pp, ppc_prot(prot));								/* Go set the protection on this physical page */
-
-	if(!locked) hw_unlock_bit((unsigned int *)&pp->phys_link, PHYS_LOCK);	/* We're done, unlock the physical entry */
-	splx(spl);													/* Restore interrupt state */
-	debugLog2(10, pp->pte1, 0);									/* end remap */
+	unsigned int pindex;
+	phys_entry *physent;
 	
-	return;														/* Leave... */
-}
-
-/*
- *		void mapping_protect(pmap_t pmap, vm_offset_t vaddr, vm_prot_t prot) - change the protection of a virtual page
- *
- *		This routine takes a pmap and virtual address and changes
- *		the protection.  If there are PTEs associated with the mappings, they will be invalidated before
- *		the protection is changed.  We don't try to save the PTE.  We won't worry about the LRU calculations
- *		either (I don't think, maybe I'll change my mind later).  There is no limitation on changes, e.g., 
- *		higher to lower, lower to higher.
- *
- */
-
-void mapping_protect(pmap_t pmap, vm_offset_t vaddr, vm_prot_t prot) {	/* Change protection of a virtual page */
-
-	mapping		*mp, *mpv;
-	spl_t 		s;
-
-	debugLog2(9, vaddr, pmap);					/* start mapping_protect */
-	s = splhigh();								/* Don't bother me */
-		
-	mp = hw_lock_phys_vir(pmap->space, vaddr);	/* Lock the physical entry for this mapping */
-
-	if(!mp) {									/* Did we find one? */
-		splx(s);								/* Restore the interrupt level */
-		debugLog2(10, 0, 0);						/* end mapping_pmap */
-		return;									/* Didn't find any... */
-	}
-	if((unsigned int)mp & 1) {					/* Did we timeout? */
-		panic("mapping_protect: timeout locking physical entry\n");	/* Yeah, scream about it! */
-		splx(s);								/* Restore the interrupt level */
-		return;									/* Bad hair day... */
-	}
-		
-	hw_prot_virt(mp, ppc_prot(prot));			/* Go set the protection on this virtual mapping */
-
-	mpv = hw_cpv(mp);							/* Get virtual address of mapping */
-	if(mpv->physent) {							/* If there is a physical page, */
-		hw_unlock_bit((unsigned int *)&mpv->physent->phys_link, PHYS_LOCK);	/* Unlock the physical entry */
-	}
-	splx(s);									/* Restore interrupt state */
-	debugLog2(10, mpv->PTEr, 0);				/* end remap */
-	
-	return;										/* Leave... */
-}
-
-/*
- *		mapping_phys_attr(struct phys_entry *pp, vm_prot_t prot, unsigned int wimg) Sets the default physical page attributes
- *
- *		This routine takes a physical entry and sets the physical attributes.  There can be no mappings
- *		associated with this page when we do it.
- */
-
-void mapping_phys_attr(struct phys_entry *pp, vm_prot_t prot, unsigned int wimg) {	/* Sets the default physical page attributes */
-
-	debugLog2(11, pp->pte1, prot);								/* end remap */
-
-	if(!hw_lock_bit((unsigned int *)&pp->phys_link, PHYS_LOCK, LockTimeOut)) {	/* Lock the physical entry */
-		panic("\nmapping_phys_attr: Timeout attempting to lock physical entry at %08X: %08X %08X\n", 
-			pp, pp->phys_link, pp->pte1);						/* Complain about timeout */
+	physent = mapping_phys_lookup(pa, &pindex);					/* Get physical entry */
+	if(!physent) {												/* Did we find the physical page? */
+		panic("mapping_protect_phys: invalid physical page %08X\n", pa);
 	}
 
-	hw_phys_attr(pp, ppc_prot(prot), wimg);						/* Go set the default WIMG and protection */
+	hw_walk_phys(physent, hwpSPrtPhy, hwpSPrtMap, hwpNoop, ppc_prot(prot));	/* Set the new protection for page and mappings */
 
-	hw_unlock_bit((unsigned int *)&pp->phys_link, PHYS_LOCK);	/* We're done, unlock the physical entry */
-	debugLog2(12, pp->pte1, wimg);								/* end remap */
-	
-	return;														/* Leave... */
-}
-
-/*
- *		void mapping_invall(phys_entry *pp) - invalidates all ptes associated with a page
- *
- *		This routine takes a physical entry and runs through all mappings attached to it and invalidates
- *		any PTEs it finds.
- *
- *		Interruptions must be disabled and the physical entry locked at entry.
- */
-
-void mapping_invall(struct phys_entry *pp) {					/* Clear all PTEs pointing to a physical page */
-
-	hw_inv_all(pp);												/* Go set the change bit of a physical page */
-	
 	return;														/* Leave... */
 }
 
 
 /*
- *		void mapping_clr_mod(phys_entry *pp) - clears the change bit of a physical page
+ *		void mapping_clr_mod(ppnum_t pa) - clears the change bit of a physical page
  *
  *		This routine takes a physical entry and runs through all mappings attached to it and turns
- *		off the change bit.  If there are PTEs associated with the mappings, they will be invalidated before
- *		the change bit is changed.  We don't try to save the PTE.  We won't worry about the LRU calculations
- *		either (I don't think, maybe I'll change my mind later).
- *
- *		Interruptions must be disabled and the physical entry locked at entry.
+ *		off the change bit. 
  */
 
-void mapping_clr_mod(struct phys_entry *pp) {					/* Clears the change bit of a physical page */
+void mapping_clr_mod(ppnum_t pa) {								/* Clears the change bit of a physical page */
 
-	hw_clr_mod(pp);												/* Go clear the change bit of a physical page */
+	unsigned int pindex;
+	phys_entry *physent;
+	
+	physent = mapping_phys_lookup(pa, &pindex);					/* Get physical entry */
+	if(!physent) {												/* Did we find the physical page? */
+		panic("mapping_clr_mod: invalid physical page %08X\n", pa);
+	}
+
+	hw_walk_phys(physent, hwpNoop, hwpCCngMap, hwpCCngPhy, 0);	/* Clear change for page and mappings */
 	return;														/* Leave... */
 }
 
 
 /*
- *		void mapping_set_mod(phys_entry *pp) - set the change bit of a physical page
+ *		void mapping_set_mod(ppnum_t pa) - set the change bit of a physical page
  *
  *		This routine takes a physical entry and runs through all mappings attached to it and turns
- *		on the change bit.  If there are PTEs associated with the mappings, they will be invalidated before
- *		the change bit is changed.  We don't try to save the PTE.  We won't worry about the LRU calculations
- *		either (I don't think, maybe I'll change my mind later).
- *
- *		Interruptions must be disabled and the physical entry locked at entry.
+ *		on the change bit.  
  */
 
-void mapping_set_mod(struct phys_entry *pp) {					/* Sets the change bit of a physical page */
+void mapping_set_mod(ppnum_t pa) {								/* Sets the change bit of a physical page */
 
-	hw_set_mod(pp);												/* Go set the change bit of a physical page */
+	unsigned int pindex;
+	phys_entry *physent;
+	
+	physent = mapping_phys_lookup(pa, &pindex);					/* Get physical entry */
+	if(!physent) {												/* Did we find the physical page? */
+		panic("mapping_set_mod: invalid physical page %08X\n", pa);
+	}
+
+	hw_walk_phys(physent, hwpNoop, hwpSCngMap, hwpSCngPhy, 0);	/* Set change for page and mappings */
 	return;														/* Leave... */
 }
 
 
 /*
- *		void mapping_clr_ref(struct phys_entry *pp) - clears the reference bit of a physical page
+ *		void mapping_clr_ref(ppnum_t pa) - clears the reference bit of a physical page
  *
  *		This routine takes a physical entry and runs through all mappings attached to it and turns
- *		off the reference bit.  If there are PTEs associated with the mappings, they will be invalidated before
- *		the reference bit is changed.  We don't try to save the PTE.  We won't worry about the LRU calculations
- *		either (I don't think, maybe I'll change my mind later).
- *
- *		Interruptions must be disabled at entry.
+ *		off the reference bit.  
  */
 
-void mapping_clr_ref(struct phys_entry *pp) {					/* Clears the reference bit of a physical page */
+void mapping_clr_ref(ppnum_t pa) {								/* Clears the reference bit of a physical page */
 
-	mapping	*mp;
-
-	debugLog2(13, pp->pte1, 0);									/* end remap */
-	if(!hw_lock_bit((unsigned int *)&pp->phys_link, PHYS_LOCK, LockTimeOut)) {	/* Lock the physical entry for this mapping */
-		panic("Lock timeout getting lock on physical entry\n");	/* Just die... */
+	unsigned int pindex;
+	phys_entry *physent;
+	
+	physent = mapping_phys_lookup(pa, &pindex);					/* Get physical entry */
+	if(!physent) {												/* Did we find the physical page? */
+		panic("mapping_clr_ref: invalid physical page %08X\n", pa);
 	}
-	hw_clr_ref(pp);												/* Go clear the reference bit of a physical page */
-	hw_unlock_bit((unsigned int *)&pp->phys_link, PHYS_LOCK);	/* Unlock physical entry */
-	debugLog2(14, pp->pte1, 0);									/* end remap */
+
+	hw_walk_phys(physent, hwpNoop, hwpCRefMap, hwpCRefPhy, 0);	/* Clear reference for page and mappings */
 	return;														/* Leave... */
 }
 
 
 /*
- *		void mapping_set_ref(phys_entry *pp) - set the reference bit of a physical page
+ *		void mapping_set_ref(ppnum_t pa) - set the reference bit of a physical page
  *
  *		This routine takes a physical entry and runs through all mappings attached to it and turns
- *		on the reference bit.  If there are PTEs associated with the mappings, they will be invalidated before
- *		the reference bit is changed.  We don't try to save the PTE.  We won't worry about the LRU calculations
- *		either (I don't think, maybe I'll change my mind later).
- *
- *		Interruptions must be disabled and the physical entry locked at entry.
+ *		on the reference bit. 
  */
 
-void mapping_set_ref(struct phys_entry *pp) {					/* Sets the reference bit of a physical page */
+void mapping_set_ref(ppnum_t pa) {								/* Sets the reference bit of a physical page */
 
-	hw_set_ref(pp);												/* Go set the reference bit of a physical page */
+	unsigned int pindex;
+	phys_entry *physent;
+	
+	physent = mapping_phys_lookup(pa, &pindex);					/* Get physical entry */
+	if(!physent) {												/* Did we find the physical page? */
+		panic("mapping_set_ref: invalid physical page %08X\n", pa);
+	}
+
+	hw_walk_phys(physent, hwpNoop, hwpSRefMap, hwpSRefPhy, 0);	/* Set reference for page and mappings */
 	return;														/* Leave... */
 }
 
 
 /*
- *		void mapping_tst_mod(phys_entry *pp) - test the change bit of a physical page
+ *		void mapping_tst_mod(ppnum_t pa) - test the change bit of a physical page
  *
  *		This routine takes a physical entry and runs through all mappings attached to it and tests
- *		the changed bit.  If there are PTEs associated with the mappings, they will be invalidated before
- *		the changed bit is tested.  We don't try to save the PTE.  We won't worry about the LRU calculations
- *		either (I don't think, maybe I'll change my mind later).
- *
- *		Interruptions must be disabled and the physical entry locked at entry.
+ *		the changed bit. 
  */
 
-boolean_t mapping_tst_mod(struct phys_entry *pp) {				/* Tests the change bit of a physical page */
+boolean_t mapping_tst_mod(ppnum_t pa) {							/* Tests the change bit of a physical page */
 
-	return(hw_tst_mod(pp));										/* Go test the change bit of a physical page */
+	unsigned int pindex, rc;
+	phys_entry *physent;
+	
+	physent = mapping_phys_lookup(pa, &pindex);					/* Get physical entry */
+	if(!physent) {												/* Did we find the physical page? */
+		panic("mapping_tst_mod: invalid physical page %08X\n", pa);
+	}
+
+	rc = hw_walk_phys(physent, hwpTCngPhy, hwpTCngMap, hwpNoop, 0);	/* Set change for page and mappings */
+	return ((rc & (unsigned long)ppC) != 0);					/* Leave with change bit */
 }
 
 
 /*
- *		void mapping_tst_ref(phys_entry *pp) - tests the reference bit of a physical page
+ *		void mapping_tst_ref(ppnum_t pa) - tests the reference bit of a physical page
  *
  *		This routine takes a physical entry and runs through all mappings attached to it and tests
- *		the reference bit.  If there are PTEs associated with the mappings, they will be invalidated before
- *		the reference bit is changed.  We don't try to save the PTE.  We won't worry about the LRU calculations
- *		either (I don't think, maybe I'll change my mind later).
- *
- *		Interruptions must be disabled and the physical entry locked at entry.
+ *		the reference bit. 
  */
 
-boolean_t mapping_tst_ref(struct phys_entry *pp) {				/* Tests the reference bit of a physical page */
+boolean_t mapping_tst_ref(ppnum_t pa) {							/* Tests the reference bit of a physical page */
 
-	return(hw_tst_ref(pp));										/* Go test the reference bit of a physical page */
+	unsigned int pindex, rc;
+	phys_entry *physent;
+	
+	physent = mapping_phys_lookup(pa, &pindex);					/* Get physical entry */
+	if(!physent) {												/* Did we find the physical page? */
+		panic("mapping_tst_ref: invalid physical page %08X\n", pa);
+	}
+
+	rc = hw_walk_phys(physent, hwpTRefPhy, hwpTRefMap, hwpNoop, 0);	/* Test reference for page and mappings */
+	return ((rc & (unsigned long)ppR) != 0);					/* Leave with reference bit */
 }
 
 
 /*
- *		void mapping_phys_init(physent, wimg) - fills in the default processor dependent areas of the phys ent
+ *		phys_ent  *mapping_phys_lookup(ppnum_t pp, unsigned int *pindex) - tests the reference bit of a physical page
  *
- *		Currently, this sets the default word 1 of the PTE.  The only bits set are the WIMG bits
+ *		This routine takes a physical page number and returns the phys_entry associated with it.  It also
+ *		calculates the bank address associated with the entry
+ *		the reference bit. 
  */
 
-void mapping_phys_init(struct phys_entry *pp, unsigned int pa, unsigned int wimg) {		/* Initializes hw specific storage attributes */
-
-	pp->pte1 = (pa & -PAGE_SIZE) | ((wimg << 3) & 0x00000078);	/* Set the WIMG and phys addr in the default PTE1 */
+phys_entry *mapping_phys_lookup(ppnum_t pp, unsigned int *pindex) {	/* Finds the physical entry for the page */
 
-	return;														/* Leave... */
+	phys_entry *physent;
+	int i;
+	
+	for(i = 0; i < pmap_mem_regions_count; i++) {				/* Walk through the list */
+		if(!(unsigned int)pmap_mem_regions[i].mrPhysTab) continue;	/* Skip any empty lists */
+		if((pp < pmap_mem_regions[i].mrStart) || (pp > pmap_mem_regions[i].mrEnd)) continue;	/* This isn't ours */
+		
+		*pindex = (i * sizeof(mem_region_t)) / 4;				/* Make the word index to this list */
+		
+		return &pmap_mem_regions[i].mrPhysTab[pp - pmap_mem_regions[i].mrStart];	/* Return the physent pointer */
+	}
+	
+	return (phys_entry *)0;										/* Shucks, can't find it... */
+	
 }
 
 
+
+
 /*
  *		mapping_adjust(void) - Releases free mapping blocks and/or allocates new ones 
  *
@@ -1043,8 +641,8 @@ void mapping_phys_init(struct phys_entry *pp, unsigned int pa, unsigned int wimg
  *		The list will be replenshed from mapCtl.mapcrel if there are enough.  Otherwise,
  *		a new one is allocated.
  *
- *		This routine allocates and/or memory and must be called from a safe place. 
- *		Currently, vm_pageout_scan is the safest place. We insure that the 
+ *		This routine allocates and/or frees memory and must be called from a safe place. 
+ *		Currently, vm_pageout_scan is the safest place. 
  */
 
 thread_call_t				mapping_adjust_call;
@@ -1059,7 +657,7 @@ void mapping_adjust(void) {										/* Adjust free mappings */
 	extern int vm_page_free_count;
 
 	if(mapCtl.mapcmin <= MAPPERBLOK) {
-	        mapCtl.mapcmin = (mem_size / PAGE_SIZE) / 16;
+		mapCtl.mapcmin = (sane_size / PAGE_SIZE) / 16;
 
 #if DEBUG
 		kprintf("mapping_adjust: minimum entries rqrd = %08X\n", mapCtl.mapcmin);
@@ -1090,10 +688,10 @@ void mapping_adjust(void) {										/* Adjust free mappings */
 			mapCtl.mapcreln--;									/* Back off the count */
 			allocsize = MAPPERBLOK;								/* Show we allocated one block */			
 		}
-		else {													/* No free ones, try to get it */
+        else {													/* No free ones, try to get it */
 			
 			allocsize = (allocsize + MAPPERBLOK - 1) / MAPPERBLOK;	/* Get the number of pages we need */
-
+			
 			hw_lock_unlock((hw_lock_t)&mapCtl.mapclock);		/* Unlock our stuff */
 			splx(s);											/* Restore 'rupts */
 
@@ -1104,18 +702,21 @@ void mapping_adjust(void) {										/* Adjust free mappings */
 				}
 				if(retr == KERN_SUCCESS) break;					/* We got some memory, bail out... */
 			}
+		
 			allocsize = allocsize * MAPPERBLOK;					/* Convert pages to number of maps allocated */
 			s = splhigh();										/* Don't bother from now on */
 			if(!hw_lock_to((hw_lock_t)&mapCtl.mapclock, LockTimeOut)) {	/* Lock the control header */ 
 				panic("mapping_adjust - timeout getting control lock (2)\n");	/* Tell all and die */
 			}
 		}
+
 		if (retr != KERN_SUCCESS)
 			break;												/* Fail to alocate, bail out... */
 		for(; allocsize > 0; allocsize -= MAPPERBLOK) {			/* Release one block at a time */
 			mapping_free_init((vm_offset_t)mbn, 0, 1);			/* Initialize a non-permanent block */
 			mbn = (mappingblok *)((unsigned int)mbn + PAGE_SIZE);	/* Point to the next slot */
 		}
+
 		if ((mapCtl.mapcinuse + mapCtl.mapcfree + (mapCtl.mapcreln * (MAPPERBLOK + 1))) > mapCtl.mapcmaxalloc)
 		        mapCtl.mapcmaxalloc = mapCtl.mapcinuse + mapCtl.mapcfree + (mapCtl.mapcreln * (MAPPERBLOK + 1));
 	}
@@ -1136,11 +737,13 @@ void mapping_adjust(void) {										/* Adjust free mappings */
 
 	while((unsigned int)mbn) {									/* Toss 'em all */
 		mb = mbn->nextblok;										/* Get the next */
+		
 		kmem_free(mapping_map, (vm_offset_t) mbn, PAGE_SIZE);	/* Release this mapping block */
+	
 		mbn = mb;												/* Chain to the next */
 	}
 
-	__asm__ volatile("sync");									/* Make sure all is well */
+	__asm__ volatile("eieio");									/* Make sure all is well */
 	mapCtl.mapcrecurse = 0;										/* We are done now */
 	return;
 }
@@ -1159,18 +762,53 @@ void mapping_free(struct mapping *mp) {							/* Release a mapping */
 
 	mappingblok	*mb, *mbn;
 	spl_t			s;
-	unsigned int	full, mindx;
+	unsigned int	full, mindx, lists;
 
-	mindx = ((unsigned int)mp & (PAGE_SIZE - 1)) >> 5;			/* Get index to mapping */
+	mindx = ((unsigned int)mp & (PAGE_SIZE - 1)) >> 6;			/* Get index to mapping */
 	mb = (mappingblok *)((unsigned int)mp & -PAGE_SIZE);		/* Point to the mapping block */
+    lists = (mp->mpFlags & mpLists);							/* get #lists */
+    if ((lists == 0) || (lists > kSkipListMaxLists)) 			/* panic if out of range */
+        panic("mapping_free: mpLists invalid\n");
+
+#if 0
+	mp->mpFlags = 0x99999999;									/* (BRINGUP) */	
+	mp->mpSpace = 0x9999;										/* (BRINGUP) */	
+	mp->mpBSize = 0x9999;										/* (BRINGUP) */	
+	mp->mpPte   = 0x99999998;									/* (BRINGUP) */	
+	mp->mpPAddr = 0x99999999;									/* (BRINGUP) */	
+	mp->mpVAddr = 0x9999999999999999ULL;						/* (BRINGUP) */	
+	mp->mpAlias = 0x9999999999999999ULL;						/* (BRINGUP) */	
+	mp->mpList0 = 0x9999999999999999ULL;						/* (BRINGUP) */	
+	mp->mpList[0] = 0x9999999999999999ULL;						/* (BRINGUP) */	
+	mp->mpList[1] = 0x9999999999999999ULL;						/* (BRINGUP) */	
+	mp->mpList[2] = 0x9999999999999999ULL;						/* (BRINGUP) */	
+
+	if(lists > mpBasicLists) {									/* (BRINGUP) */	
+		mp->mpList[3] = 0x9999999999999999ULL;					/* (BRINGUP) */	
+		mp->mpList[4] = 0x9999999999999999ULL;					/* (BRINGUP) */	
+		mp->mpList[5] = 0x9999999999999999ULL;					/* (BRINGUP) */	
+		mp->mpList[6] = 0x9999999999999999ULL;					/* (BRINGUP) */	
+		mp->mpList[7] = 0x9999999999999999ULL;					/* (BRINGUP) */	
+		mp->mpList[8] = 0x9999999999999999ULL;					/* (BRINGUP) */	
+		mp->mpList[9] = 0x9999999999999999ULL;					/* (BRINGUP) */	
+		mp->mpList[10] = 0x9999999999999999ULL;					/* (BRINGUP) */	
+	}
+#endif	
+	
 
 	s = splhigh();												/* Don't bother from now on */
 	if(!hw_lock_to((hw_lock_t)&mapCtl.mapclock, LockTimeOut)) {	/* Lock the control header */ 
 		panic("mapping_free - timeout getting control lock\n");	/* Tell all and die */
 	}
 	
-	full = !(mb->mapblokfree[0] | mb->mapblokfree[1] | mb->mapblokfree[2] | mb->mapblokfree[3]);	/* See if full now */ 
+	full = !(mb->mapblokfree[0] | mb->mapblokfree[1]);			/* See if full now */ 
 	mb->mapblokfree[mindx >> 5] |= (0x80000000 >> (mindx & 31));	/* Flip on the free bit */
+    if ( lists > mpBasicLists ) {								/* if big block, lite the 2nd bit too */
+        mindx++;
+        mb->mapblokfree[mindx >> 5] |= (0x80000000 >> (mindx & 31));
+        mapCtl.mapcfree++;
+        mapCtl.mapcinuse--;
+    }
 	
 	if(full) {													/* If it was full before this: */
 		mb->nextblok = mapCtl.mapcnext;							/* Move head of list to us */
@@ -1185,8 +823,7 @@ void mapping_free(struct mapping *mp) {							/* Release a mapping */
 	mapCtl.mapcfreec++;											/* Count total calls */
 
 	if(mapCtl.mapcfree > mapCtl.mapcmin) {						/* Should we consider releasing this? */
-		if(((mb->mapblokfree[0] | 0x80000000) & mb->mapblokfree[1] & mb->mapblokfree[2] & mb->mapblokfree[3]) 
-		   == 0xFFFFFFFF) {										/* See if empty now */ 
+		if(((mb->mapblokfree[0] | 0x80000000) & mb->mapblokfree[1]) == 0xFFFFFFFF) {	/* See if empty now */ 
 
 			if(mapCtl.mapcnext == mb) {							/* Are we first on the list? */
 				mapCtl.mapcnext = mb->nextblok;					/* Unchain us */
@@ -1228,70 +865,169 @@ void mapping_free(struct mapping *mp) {							/* Release a mapping */
 
 
 /*
- *		mapping_alloc(void) - obtain a mapping from the free list 
+ *		mapping_alloc(lists) - obtain a mapping from the free list 
  *
- *		This routine takes a mapping off of the free list and returns it's address.
+ *		This routine takes a mapping off of the free list and returns its address.
+ *		The mapping is zeroed, and its mpLists count is set.  The caller passes in
+ *		the number of skiplists it would prefer; if this number is greater than 
+ *		mpBasicLists (ie, 4) then we need to allocate a 128-byte mapping, which is
+ *		just two consequtive free entries coallesced into one.  If we cannot find
+ *		two consequtive free entries, we clamp the list count down to mpBasicLists
+ *		and return a basic 64-byte node.  Our caller never knows the difference.
  *
- *		We do this by finding a free entry in the first block and allocating it.
- *		If this allocation empties the block, we remove it from the free list.
+ *		If this allocation empties a block, we remove it from the free list.
  *		If this allocation drops the total number of free entries below a threshold,
  *		we allocate a new block.
  *
  */
 
-mapping *mapping_alloc(void) {									/* Obtain a mapping */
+mapping *mapping_alloc(int lists) {								/* Obtain a mapping */
 
 	register mapping *mp;
 	mappingblok	*mb, *mbn;
 	spl_t			s;
 	int				mindx;
 	kern_return_t	retr;
-
+    int				big = (lists > mpBasicLists);				/* set flag if big block req'd */
+	pmap_t			refpmap, ckpmap;
+	unsigned int	space, i;
+	int				ref_count;
+	addr64_t		va, nextva;
+	extern	pmap_t	free_pmap_list;
+	extern	int		free_pmap_count;
+	decl_simple_lock_data(extern,free_pmap_lock)
+	boolean_t		found_mapping;
+	boolean_t		do_rescan;
+    
 	s = splhigh();												/* Don't bother from now on */
 	if(!hw_lock_to((hw_lock_t)&mapCtl.mapclock, LockTimeOut)) {	/* Lock the control header */ 
 		panic("mapping_alloc - timeout getting control lock\n");	/* Tell all and die */
 	}
 
-	if(!(mb = mapCtl.mapcnext)) {								/* Get the first block entry */
-		unsigned int			i;
-		struct mappingflush		mappingflush;
-		PCA						*pca_min, *pca_max;
-		PCA						*pca_base;
-
-		pca_min = (PCA *)(hash_table_base+hash_table_size);
-		pca_max = (PCA *)(hash_table_base+hash_table_size+hash_table_size);
-
-		while (mapCtl.mapcfree <= (MAPPERBLOK*2)) {
-			mapCtl.mapcflush.mappingcnt = 0;
-			pca_base = mapCtl.mapcflush.pcaptr;
-			do {
-				hw_select_mappings(&mapCtl.mapcflush);
-				mapCtl.mapcflush.pcaptr++;
-				if (mapCtl.mapcflush.pcaptr >= pca_max)
-					mapCtl.mapcflush.pcaptr = pca_min;
-			} while ((mapCtl.mapcflush.mappingcnt == 0) && (mapCtl.mapcflush.pcaptr != pca_base));
-
-			if ((mapCtl.mapcflush.mappingcnt == 0) && (mapCtl.mapcflush.pcaptr == pca_base)) {
-				hw_lock_unlock((hw_lock_t)&mapCtl.mapclock);
-				panic("mapping_alloc - all mappings are wired\n");
+	if(!((unsigned int)mapCtl.mapcnext)) {						/* Are there any free mappings? */
+	
+/*
+ *		No free mappings.  First, there may be some mapping blocks on the "to be released"
+ *		list.  If so, rescue one.  Otherwise, try to steal a couple blocks worth.
+ */
+
+		if(mbn = mapCtl.mapcrel) {								/* Try to rescue a block from impending doom */
+			mapCtl.mapcrel = mbn->nextblok;						/* Pop the queue */
+			mapCtl.mapcreln--;									/* Back off the count */
+			mapping_free_init((vm_offset_t)mbn, 0, 1);			/* Initialize a non-permanent block */
+			goto rescued;
+		}
+
+		hw_lock_unlock((hw_lock_t)&mapCtl.mapclock);
+
+		simple_lock(&free_pmap_lock);
+
+		if(!hw_lock_to((hw_lock_t)&mapCtl.mapclock, LockTimeOut)) {	/* Lock the control header */ 
+			panic("mapping_alloc - timeout getting control lock\n");	/* Tell all and die */
+		}
+
+		if (!((unsigned int)mapCtl.mapcnext)) {
+
+			refpmap = (pmap_t)cursor_pmap->pmap_link.next;
+			space = mapCtl.mapcflush.spacenum;
+			while (refpmap != cursor_pmap) {
+				if(((pmap_t)(refpmap->pmap_link.next))->spaceNum > space) break;
+				refpmap = (pmap_t)refpmap->pmap_link.next;
 			}
-			mappingflush = mapCtl.mapcflush;
-			hw_lock_unlock((hw_lock_t)&mapCtl.mapclock);
-			splx(s);
-			for (i=0;i<mappingflush.mappingcnt;i++)
-				mapping_remove(mappingflush.mapping[i].pmap, 
-				               mappingflush.mapping[i].offset);
-			s = splhigh();
-			if(!hw_lock_to((hw_lock_t)&mapCtl.mapclock, LockTimeOut)) {
-				panic("mapping_alloc - timeout getting control lock\n");
+
+			ckpmap = refpmap;
+			va = mapCtl.mapcflush.addr;
+			found_mapping = FALSE;
+
+			while (mapCtl.mapcfree <= (MAPPERBLOK*2)) {
+
+				hw_lock_unlock((hw_lock_t)&mapCtl.mapclock);
+
+				ckpmap = (pmap_t)ckpmap->pmap_link.next;
+
+				if ((ckpmap->stats.resident_count != 0) && (ckpmap != kernel_pmap)) {
+					do_rescan = TRUE;
+					for (i=0;i<8;i++) {
+						mp = hw_purge_map(ckpmap, va, &nextva);
+
+						if((unsigned int)mp & mapRetCode) {
+							panic("mapping_alloc: hw_purge_map failed - pmap = %08X, va = %16llX, code = %08X\n", ckpmap, va, mp);
+						}
+
+						if(!mp) { 
+							if (do_rescan)
+								do_rescan = FALSE;
+							else
+								break;
+						} else {
+							mapping_free(mp);
+							found_mapping = TRUE;
+						}
+
+						va = nextva;
+					}
+				}
+
+				if (ckpmap == refpmap) {
+					if (found_mapping == FALSE)
+						panic("no valid pmap to purge mappings\n");
+					else
+						found_mapping = FALSE;
+				}
+
+				if(!hw_lock_to((hw_lock_t)&mapCtl.mapclock, LockTimeOut)) {	/* Lock the control header */ 
+					panic("mapping_alloc - timeout getting control lock\n");	/* Tell all and die */
+				}
+
 			}
+
+			mapCtl.mapcflush.spacenum = ckpmap->spaceNum;
+			mapCtl.mapcflush.addr = nextva;
 		}
-		mb = mapCtl.mapcnext;
-	}
-	
-	if(!(mindx = mapalc(mb))) {									/* Allocate a slot */
-		panic("mapping_alloc - empty mapping block detected at %08X\n", mb);	/* Not allowed to find none */
-	}
+
+		simple_unlock(&free_pmap_lock);
+	}
+
+rescued:
+
+	mb = mapCtl.mapcnext;
+    
+    if ( big ) {												/* if we need a big (128-byte) mapping */
+        mapCtl.mapcbig++;										/* count attempts to allocate a big mapping */
+        mbn = NULL;												/* this will be prev ptr */
+        mindx = 0;
+        while( mb ) {											/* loop over mapping blocks with free entries */
+            mindx = mapalc2(mb);								/* try for 2 consequtive free bits in this block */
+
+           if ( mindx )	break;									/* exit loop if we found them */
+            mbn = mb;											/* remember previous block */
+            mb = mb->nextblok;									/* move on to next block */
+        }
+        if ( mindx == 0 ) {										/* if we couldn't find 2 consequtive bits... */
+            mapCtl.mapcbigfails++;								/* count failures */
+            big = 0;											/* forget that we needed a big mapping */
+            lists = mpBasicLists;								/* clamp list count down to the max in a 64-byte mapping */
+            mb = mapCtl.mapcnext;								/* back to the first block with a free entry */
+        }
+        else {													/* if we did find a big mapping */
+            mapCtl.mapcfree--;									/* Decrement free count twice */
+            mapCtl.mapcinuse++;									/* Bump in use count twice */
+            if ( mindx < 0 ) {									/* if we just used the last 2 free bits in this block */
+                if (mbn) {										/* if this wasn't the first block */
+                    mindx = -mindx;								/* make positive */
+                    mbn->nextblok = mb->nextblok;				/* unlink this one from the middle of block list */
+                    if (mb ==  mapCtl.mapclast)	{				/* if we emptied last block */
+                        mapCtl.mapclast = mbn;					/* then prev block is now last */
+                    }
+                }
+            }
+        }
+    }
+    
+    if ( !big ) {												/* if we need a small (64-byte) mapping */
+        if(!(mindx = mapalc1(mb))) 								/* Allocate a 1-bit slot */
+            panic("mapping_alloc - empty mapping block detected at %08X\n", mb);
+    }
 	
 	if(mindx < 0) {												/* Did we just take the last one */
 		mindx = -mindx;											/* Make positive */
@@ -1312,6 +1048,7 @@ mapping *mapping_alloc(void) {									/* Obtain a mapping */
  *	For early boot, we are set up to only rescue one block at a time.  This is because we prime
  *	the release list with as much as we need until threads start.
  */
+
 	if(mapCtl.mapcfree < mapCtl.mapcmin) {						/* See if we need to replenish */
 		if(mbn = mapCtl.mapcrel) {								/* Try to rescue a block from impending doom */
 			mapCtl.mapcrel = mbn->nextblok;						/* Pop the queue */
@@ -1331,7 +1068,9 @@ mapping *mapping_alloc(void) {									/* Obtain a mapping */
 	splx(s);													/* Restore 'rupts */
 	
 	mp = &((mapping *)mb)[mindx];								/* Point to the allocated mapping */
-    __asm__ volatile("dcbz 0,%0" : : "r" (mp));					/* Clean it up */
+    mp->mpFlags = lists;										/* set the list count */
+
+
 	return mp;													/* Send it back... */
 }
 
@@ -1343,7 +1082,7 @@ consider_mapping_adjust()
 
 	s = splhigh();												/* Don't bother from now on */
 	if(!hw_lock_to((hw_lock_t)&mapCtl.mapclock, LockTimeOut)) {	/* Lock the control header */ 
-		panic("mapping_alloc - timeout getting control lock\n");	/* Tell all and die */
+		panic("consider_mapping_adjust -- lock timeout\n");
 	}
 
         if (mapCtl.mapcfree < (mapCtl.mapcmin / 4)) {
@@ -1362,8 +1101,15 @@ consider_mapping_adjust()
 /*
  *		void mapping_free_init(mb, perm) - Adds a block of storage to the free mapping list
  *
- *		The mapping block is a page size area on a page boundary.  It contains 1 header and 127
- *		mappings.  This call adds and initializes a block for use.
+ *		The mapping block is a page size area on a page boundary.  It contains 1 header and 63
+ *		mappings.  This call adds and initializes a block for use.  Mappings come in two sizes,
+ *		64 and 128 bytes (the only difference is the number of skip-lists.)  When we allocate a
+ *		128-byte mapping we just look for two consequtive free 64-byte mappings, so most of the
+ *		code only deals with "basic" 64-byte mappings.  This works for two reasons:
+ *			- Only one in 256 mappings is big, so they are rare.
+ *			- If we cannot find two consequtive free mappings, we just return a small one.
+ *			  There is no problem with doing this, except a minor performance degredation.
+ *		Therefore, all counts etc in the mapping control structure are in units of small blocks.
  *	
  *		The header contains a chain link, bit maps, a virtual to real translation mask, and
  *		some statistics. Bit maps map each slot on the page (bit 0 is not used because it 
@@ -1395,33 +1141,38 @@ void mapping_free_init(vm_offset_t mbl, int perm, boolean_t locked) {
 	mappingblok	*mb;
 	spl_t		s;
 	int			i;
-	unsigned int	raddr;
+	addr64_t	raddr;
+	ppnum_t		pp;
 
-	mb = (mappingblok *)mbl;								/* Start of area */
-	
+	mb = (mappingblok *)mbl;								/* Start of area */	
 	
 	if(perm >= 0) {											/* See if we need to initialize the block */
 		if(perm) {
-			raddr = (unsigned int)mbl;						/* Perm means V=R */
+			raddr = (addr64_t)((unsigned int)mbl);			/* Perm means V=R */
 			mb->mapblokflags = mbPerm;						/* Set perm */
+//			mb->mapblokflags |= (unsigned int)mb;			/* (BRINGUP) */
 		}
 		else {
-			raddr = kvtophys(mbl);							/* Get real address */
+			pp = pmap_find_phys(kernel_pmap, (addr64_t)mbl);	/* Get the physical page */
+			if(!pp) {										/* What gives?  Where's the page? */
+				panic("mapping_free_init: could not find translation for vaddr %016llX\n", (addr64_t)mbl);
+			}
+			
+			raddr = (addr64_t)pp << 12;						/* Convert physical page to physical address */
 			mb->mapblokflags = 0;							/* Set not perm */
+//			mb->mapblokflags |= (unsigned int)mb;			/* (BRINGUP) */
 		}
 		
-		mb->mapblokvrswap = raddr ^ (unsigned int)mbl;		/* Form translation mask */
+		mb->mapblokvrswap = raddr ^ (addr64_t)((unsigned int)mbl);		/* Form translation mask */
 		
 		mb->mapblokfree[0] = 0x7FFFFFFF;					/* Set first 32 (minus 1) free */
 		mb->mapblokfree[1] = 0xFFFFFFFF;					/* Set next 32 free */
-		mb->mapblokfree[2] = 0xFFFFFFFF;					/* Set next 32 free */
-		mb->mapblokfree[3] = 0xFFFFFFFF;					/* Set next 32 free */
 	}
 	
 	s = splhigh();											/* Don't bother from now on */
 	if(!locked) {											/* Do we need the lock? */
 		if(!hw_lock_to((hw_lock_t)&mapCtl.mapclock, LockTimeOut)) {		/* Lock the control header */ 
-			panic("mapping_free_init - timeout getting control lock\n");	/* Tell all and die */
+			panic("mapping_free_init: timeout getting control lock\n");	/* Tell all and die */
 		}
 	}
 	
@@ -1447,7 +1198,8 @@ void mapping_free_init(vm_offset_t mbl, int perm, boolean_t locked) {
 	if(!locked) {											/* Do we need to unlock? */
 		hw_lock_unlock((hw_lock_t)&mapCtl.mapclock);		/* Unlock our stuff */
 	}
-		splx(s);											/* Restore 'rupts */
+
+	splx(s);												/* Restore 'rupts */
 	return;													/* All done, leave... */
 }
 
@@ -1484,9 +1236,9 @@ void mapping_prealloc(unsigned int size) {					/* Preallocates mapppings for lar
 		splx(s);											/* Restore 'rupts */
 		return;
 	}
-	if (!hw_compare_and_store(0, 1, &mapCtl.mapcrecurse)) {	                /* Make sure we aren't recursing */
+	if (!hw_compare_and_store(0, 1, &mapCtl.mapcrecurse)) {	    /* Make sure we aren't recursing */
 		hw_lock_unlock((hw_lock_t)&mapCtl.mapclock);			/* Unlock our stuff */
-		splx(s);							/* Restore 'rupts */
+		splx(s);											/* Restore 'rupts */
 		return;
 	}
 	nmapb = (nmapb + MAPPERBLOK - 1) / MAPPERBLOK;			/* Get number of blocks to get */
@@ -1496,9 +1248,8 @@ void mapping_prealloc(unsigned int size) {					/* Preallocates mapppings for lar
 	
 	for(i = 0; i < nmapb; i++) {							/* Allocate 'em all */
 		retr = kmem_alloc_wired(mapping_map, (vm_offset_t *)&mbn, PAGE_SIZE);	/* Find a virtual address to use */
-		if(retr != KERN_SUCCESS) {							/* Did we get some memory? */
-			panic("Whoops...  Not a bit of wired memory left for anyone\n");
-		}
+		if(retr != KERN_SUCCESS) 							/* Did we get some memory? */
+			break;
 		mapping_free_init((vm_offset_t)mbn, -1, 0);			/* Initialize on to the release queue */
 	}
 	if ((mapCtl.mapcinuse + mapCtl.mapcfree + (mapCtl.mapcreln * (MAPPERBLOK + 1))) > mapCtl.mapcmaxalloc)
@@ -1549,7 +1300,7 @@ void mapping_free_prime(void) {									/* Primes the mapping block release list
 	mappingblok	*mbn;
 	vm_offset_t     mapping_min;
 	
-	retr = kmem_suballoc(kernel_map, &mapping_min, MAPPING_MAP_SIZE,
+	retr = kmem_suballoc(kernel_map, &mapping_min, sane_size / 16,
 			     FALSE, TRUE, &mapping_map);
 
 	if (retr != KERN_SUCCESS)
@@ -1592,86 +1343,41 @@ mapping_fake_zone_info(int *count, vm_size_t *cur_size, vm_size_t *max_size, vm_
 
 
 /*
- *		vm_offset_t	mapping_p2v(pmap_t pmap, phys_entry *pp) - Finds first virtual mapping of a physical page in a space
+ *		addr64_t	mapping_p2v(pmap_t pmap, ppnum_t pa) - Finds first virtual mapping of a physical page in a space
  *
- *		Gets a lock on the physical entry.  Then it searches the list of attached mappings for one with
- *		the same space.  If it finds it, it returns the virtual address.
+ *		First looks up  the physical entry associated witht the physical page.  Then searches the alias
+ *		list for a matching pmap.  It grabs the virtual address from the mapping, drops busy, and returns 
+ *		that.
  *
- *		Note that this will fail if the pmap has nested pmaps in it.  Fact is, I'll check
- *		for it and fail it myself...
  */
 
-vm_offset_t	mapping_p2v(pmap_t pmap, struct phys_entry *pp) {		/* Finds first virtual mapping of a physical page in a space */
+addr64_t	mapping_p2v(pmap_t pmap, ppnum_t pa) {				/* Finds first virtual mapping of a physical page in a space */
 
-	spl_t				s;
-	register mapping	*mp, *mpv;
-	vm_offset_t			va;
-
-	if(pmap->vflags & pmapAltSeg) return 0;					/* If there are nested pmaps, fail immediately */
+	spl_t s;
+	mapping *mp;
+	unsigned int pindex;
+	phys_entry *physent;
+	addr64_t va;
 
-	s = splhigh();
-	if(!hw_lock_bit((unsigned int *)&pp->phys_link, PHYS_LOCK, LockTimeOut)) {	/* Try to get the lock on the physical entry */
-		splx(s);											/* Restore 'rupts */
-		panic("mapping_p2v: timeout getting lock on physent\n");			/* Arrrgghhhh! */
-		return(0);											/* Should die before here */
+	physent = mapping_phys_lookup(pa, &pindex);					/* Get physical entry */
+	if(!physent) {												/* Did we find the physical page? */
+		panic("mapping_p2v: invalid physical page %08X\n", pa);
 	}
-	
-	va = 0;													/* Assume failure */
-	
-	for(mpv = hw_cpv(pp->phys_link); mpv; mpv = hw_cpv(mpv->next)) {	/* Scan 'em all */
-		
-		if(!(((mpv->PTEv >> 7) & 0x000FFFFF) == pmap->space)) continue;	/* Skip all the rest if this is not the right space... */ 
-		
-		va = ((((unsigned int)mpv->PTEhash & -64) << 6) ^ (pmap->space  << 12)) & 0x003FF000;	/* Backward hash to the wrapped VADDR */
-		va = va | ((mpv->PTEv << 1) & 0xF0000000);			/* Move in the segment number */
-		va = va | ((mpv->PTEv << 22) & 0x0FC00000);			/* Add in the API for the top of the address */
-		break;												/* We're done now, pass virtual address back */
-	}
-	
-	hw_unlock_bit((unsigned int *)&pp->phys_link, PHYS_LOCK);				/* Unlock the physical entry */
-	splx(s);												/* Restore 'rupts */
-	return(va);												/* Return the result or 0... */
-}
-
-/*
- *	kvtophys(addr)
- *
- *	Convert a kernel virtual address to a physical address
- */
-vm_offset_t kvtophys(vm_offset_t va) {
 
-	register mapping		*mp, *mpv;
-	register blokmap		*bmp;
-	register vm_offset_t 	pa;
-	spl_t				s;
-	
-	s=splhigh();											/* Don't bother from now on */
-	mp = hw_lock_phys_vir(PPC_SID_KERNEL, va);				/* Find mapping and lock the physical entry for this mapping */
+	s = splhigh();											/* Make sure interruptions are disabled */
 
-	if((unsigned int)mp&1) {								/* Did the lock on the phys entry time out? */
-		splx(s);											/* Restore 'rupts */
-		panic("kvtophys: timeout obtaining lock on physical entry (vaddr=%08X)\n", va);	/* Scream bloody murder! */
-		return 0;
-	}
+	mp = hw_find_space(physent, pmap->space);				/* Go find the first mapping to the page from the requested pmap */
 
-	if(!mp) {												/* If it was not a normal page */
-		pa = hw_cvp_blk(kernel_pmap, va);					/* Try to convert odd-sized page (returns 0 if not found) */
-		splx(s);											/* Restore 'rupts */
-		return pa;											/* Return physical address */
+	if(mp) {												/* Did we find one? */
+		va = mp->mpVAddr & -4096;							/* If so, get the cleaned up vaddr */
+		mapping_drop_busy(mp);								/* Go ahead and relase the mapping now */
 	}
+	else va = 0;											/* Return failure */
 
-	mpv = hw_cpv(mp);										/* Convert to virtual addressing */
+	splx(s);												/* Restore 'rupts */
 	
-	if(!mpv->physent) {										/* Was there a physical entry? */
-		pa = (vm_offset_t)((mpv->PTEr & -PAGE_SIZE) | ((unsigned int)va & (PAGE_SIZE-1)));	/* Get physical address from physent */
-	}
-	else {
-		pa = (vm_offset_t)((mpv->physent->pte1 & -PAGE_SIZE) | ((unsigned int)va & (PAGE_SIZE-1)));	/* Get physical address from physent */
-		hw_unlock_bit((unsigned int *)&mpv->physent->phys_link, PHYS_LOCK);	/* Unlock the physical entry */
-	}
+	return va;												/* Bye, bye... */
 	
-	splx(s);												/* Restore 'rupts */
-	return pa;												/* Return the physical address... */
 }
 
 /*
@@ -1683,17 +1389,27 @@ vm_offset_t kvtophys(vm_offset_t va) {
 
 vm_offset_t phystokv(vm_offset_t pa) {
 
-	struct phys_entry	*pp;
-	vm_offset_t			va;
+	addr64_t	va;
+	ppnum_t pp;
 
-	pp = pmap_find_physentry(pa);							/* Find the physical entry */
-	if (PHYS_NULL == pp) {
-		return (vm_offset_t)NULL;							/* If none, return null */
-	}
-	if(!(va=mapping_p2v(kernel_pmap, pp))) {
+	pp = pa >> 12;											/* Convert to a page number */
+	
+	if(!(va = mapping_p2v(kernel_pmap, pp))) {
 		return 0;											/* Can't find it, return 0... */
 	}
-	return (va | (pa & (PAGE_SIZE-1)));						/* Build and return VADDR... */
+	
+	return (va | (pa & (PAGE_SIZE - 1)));					/* Build and return VADDR... */
+
+}
+
+/*
+ *	kvtophys(addr)
+ *
+ *	Convert a kernel virtual address to a physical address
+ */
+vm_offset_t kvtophys(vm_offset_t va) {
+
+	return pmap_extract(kernel_pmap, va);					/* Find mapping and lock the physical entry for this mapping */
 
 }
 
@@ -1715,346 +1431,203 @@ void ignore_zero_fault(boolean_t type) {				/* Sets up to ignore or honor any fa
 }
 
 
-/*
- *	Allocates a range of virtual addresses in a map as optimally as
- *	possible for block mapping.  The start address is aligned such
- *	that a minimum number of power-of-two sized/aligned blocks is
- *	required to cover the entire range. 
- *
- *	We also use a mask of valid block sizes to determine optimality.
+/* 
+ *		Copies data between a physical page and a virtual page, or 2 physical.  This is used to 
+ *		move data from the kernel to user state. Note that the "which" parm
+ *		says which of the parameters is physical and if we need to flush sink/source.  
+ *		Note that both addresses may be physicical but only one may be virtual
  *
- *	Note that the passed in pa is not actually mapped to the selected va,
- *	rather, it is used to figure the optimal boundary.  The actual 
- *	V to R mapping is done externally.
+ *		The rules are that the size can be anything.  Either address can be on any boundary
+ *		and span pages.  The physical data must be congiguous as must the virtual.
  *
- *	This function will return KERN_INVALID_ADDRESS if an optimal address 
- *	can not be found.  It is not necessarily a fatal error, the caller may still be
- *	still be able to do a non-optimal assignment.
- */
-
-kern_return_t vm_map_block(vm_map_t map, vm_offset_t *va, vm_offset_t *bnd, vm_offset_t pa, 
-	vm_size_t size, vm_prot_t prot) {
-
-	vm_map_entry_t	entry, next, tmp_entry, new_entry;
-	vm_offset_t		start, end, algnpa, endadr, strtadr, curradr;
-	vm_offset_t		boundary;
-	
-	unsigned int	maxsize, minsize, leading, trailing;
-	
-	assert(page_aligned(pa));
-	assert(page_aligned(size));
-
-	if (map == VM_MAP_NULL) return(KERN_INVALID_ARGUMENT);	/* Dude, like we need a target map */
-	
-	minsize = blokValid ^ (blokValid & (blokValid - 1));	/* Set minimum subblock size */
-	maxsize = 0x80000000 >> cntlzw(blokValid);	/* Set maximum subblock size */
-	
-	boundary = 0x80000000 >> cntlzw(size);		/* Get optimal boundary */
-	if(boundary > maxsize) boundary = maxsize;	/* Pin this at maximum supported hardware size */
-	
-	vm_map_lock(map);							/* No touchee no mapee */
-
- 	for(; boundary > minsize; boundary >>= 1) {	/* Try all optimizations until we find one */
-		if(!(boundary & blokValid)) continue;	/* Skip unavailable block sizes */
-		algnpa = (pa + boundary - 1) & -boundary;	/* Round physical up */
-		leading = algnpa - pa;					/* Get leading size */
-		
-		curradr = 0;							/* Start low */
-		
-		while(1) {								/* Try all possible values for this opt level */
-
-			curradr = curradr + boundary;		/* Get the next optimal address */
-			strtadr = curradr - leading;		/* Calculate start of optimal range */
-			endadr = strtadr + size;			/* And now the end */
-			
-			if((curradr < boundary) ||			/* Did address wrap here? */
-				(strtadr > curradr) ||			/* How about this way? */
-				(endadr < strtadr)) break;		/* We wrapped, try next lower optimization... */
-		
-			if(strtadr < map->min_offset) continue;	/* Jump to the next higher slot... */
-			if(endadr > map->max_offset) break;	/* No room right now... */
-			
-			if(vm_map_lookup_entry(map, strtadr, &entry)) continue;	/* Find slot, continue if allocated... */
-		
-			next = entry->vme_next;				/* Get the next entry */
-			if((next == vm_map_to_entry(map)) ||	/* Are we the last entry? */
-				(next->vme_start >= endadr)) {	/* or do we end before the next entry? */
-			
-				new_entry = vm_map_entry_insert(map, entry, strtadr, endadr, /* Yes, carve out our entry */
-					VM_OBJECT_NULL,
-					0,							/* Offset into object of 0 */
-					FALSE, 						/* No copy needed */
-					FALSE, 						/* Not shared */
-					FALSE,						/* Not in transition */
-					prot, 						/* Set the protection to requested */
-					prot,						/* We can't change protection */
-					VM_BEHAVIOR_DEFAULT, 		/* Use default behavior, but makes no never mind,
-												   'cause we don't page in this area */
-					VM_INHERIT_DEFAULT, 		/* Default inheritance */
-					0);							/* Nothing is wired */
-			
-				vm_map_unlock(map);				/* Let the world see it all */
-				*va = strtadr;					/* Tell everyone */
-				*bnd = boundary;				/* Say what boundary we are aligned to */
-				return(KERN_SUCCESS);			/* Leave, all is right with the world... */
-			}
-		}		
-	}	
-
-	vm_map_unlock(map);							/* Couldn't find a slot */
-	return(KERN_INVALID_ADDRESS);
-}
-
-/* 
- *		Copies data from a physical page to a virtual page.  This is used to 
- *		move data from the kernel to user state.
+ *		We can block when we try to resolve the virtual address at each page boundary.
+ *		We don't check protection on the physical page.
  *
- *		Note that it is invalid to have a source that spans a page boundry.
- *		This can block.
- *		We don't check protection either.
- *		And we don't handle a block mapped sink address either.
+ *		Note that we will not check the entire range and if a page translation fails,
+ *		we will stop with partial contents copied.
  *
  */
  
-kern_return_t copyp2v(vm_offset_t source, vm_offset_t sink, unsigned int size) {
+kern_return_t copypv(addr64_t source, addr64_t sink, unsigned int size, int which) {
  
 	vm_map_t map;
 	kern_return_t ret;
-	unsigned int spaceid;
-	int left, csize;
-	vm_offset_t pa;
-	register mapping *mpv, *mp;
+	addr64_t pa, nextva, vaddr, paddr;
+	register mapping *mp;
 	spl_t s;
+	unsigned int sz, left, lop, csize;
+	int needtran, bothphys;
+	unsigned int pindex;
+	phys_entry *physent;
+	vm_prot_t prot;
 
-	if((size == 0) || ((source ^ (source + size - 1)) & -PAGE_SIZE)) return KERN_FAILURE;	/* We don't allow a source page crosser */
-	map = current_act()->map;						/* Get the current map */
+	map = (which & cppvKmap) ? kernel_map : current_map_fast();
 
-	while(size) {
-		s=splhigh();								/* Don't bother me */
+	if((which & (cppvPsrc | cppvPsnk)) == 0 ) {		/* Make sure that only one is virtual */
+		panic("copypv: no more than 1 parameter may be virtual\n");	/* Not allowed */
+	}
 	
-		spaceid = map->pmap->pmapSegs[(unsigned int)sink >> 28];	/* Get space ID. Don't bother to clean top bits */
-
-		mp = hw_lock_phys_vir(spaceid, sink);		/* Lock the physical entry for the sink */
-		if(!mp) {									/* Was it there? */
-			splx(s);								/* Restore the interrupt level */
-			ret = vm_fault(map, trunc_page(sink), VM_PROT_READ | VM_PROT_WRITE, FALSE, NULL, 0);	/* Didn't find it, try to fault it in... */
-			if (ret == KERN_SUCCESS) continue;		/* We got it in, try again to find it... */
+	bothphys = 1;									/* Assume both are physical */
+	
+	if(!(which & cppvPsnk)) {						/* Is there a virtual page here? */
+		vaddr = sink;								/* Sink side is virtual */
+		bothphys = 0;								/* Show both aren't physical */
+		prot = VM_PROT_READ | VM_PROT_WRITE;		/* Sink always must be read/write */
+	} else if(!(which & cppvPsrc)) {				/* Source side is virtual */
+		vaddr = source;								/* Source side is virtual */
+		bothphys = 0;								/* Show both aren't physical */
+		prot = VM_PROT_READ; 						/* Virtual source is always read only */
+	}
 
-			return KERN_FAILURE;					/* Didn't find any, return no good... */
-		}
-		if((unsigned int)mp&1) {					/* Did we timeout? */
-			panic("dumpaddr: timeout locking physical entry for virtual address (%08X)\n", sink);	/* Yeah, scream about it! */
-			splx(s);								/* Restore the interrupt level */
-			return KERN_FAILURE;					/* Bad hair day, return FALSE... */
-		}
+	needtran = 1;									/* Show we need to map the virtual the first time */
+	s = splhigh();									/* Don't bother me */
 
-		mpv = hw_cpv(mp);							/* Convert mapping block to virtual */
+	while(size) {
 
-		if(mpv->PTEr & 1) {							/* Are we write protected? yes, could indicate COW */
-			hw_unlock_bit((unsigned int *)&mpv->physent->phys_link, PHYS_LOCK);	/* Unlock the sink */
-			splx(s);								/* Restore the interrupt level */
-			ret = vm_fault(map, trunc_page(sink), VM_PROT_READ | VM_PROT_WRITE, FALSE, NULL, 0);	/* check for a COW area */
-			if (ret == KERN_SUCCESS) continue;		/* We got it in, try again to find it... */
-			return KERN_FAILURE;					/* Didn't find any, return no good... */
+		if(!bothphys && (needtran || !(vaddr & 4095LL))) {	/* If first time or we stepped onto a new page, we need to translate */
+			if(!needtran) {							/* If this is not the first translation, we need to drop the old busy */
+				mapping_drop_busy(mp);				/* Release the old mapping now */
+			}
+			needtran = 0;
+			
+			while(1) {
+				mp = mapping_find(map->pmap, vaddr, &nextva, 1);	/* Find and busy the mapping */
+				if(!mp) {							/* Was it there? */
+					if(per_proc_info[cpu_number()].istackptr == 0)
+						panic("copypv: No vaild mapping on memory %s %x", "RD", vaddr);
+
+					splx(s);						/* Restore the interrupt level */
+					ret = vm_fault(map, trunc_page_32((vm_offset_t)vaddr), prot, FALSE, NULL, 0);	/* Didn't find it, try to fault it in... */
+				
+					if(ret != KERN_SUCCESS)return KERN_FAILURE;	/* Didn't find any, return no good... */
+					
+					s = splhigh();					/* Don't bother me */
+					continue;						/* Go try for the map again... */
+	
+				}
+		
+				/* Note that we have to have the destination writable.  So, if we already have it, or we are mapping the source,
+					we can just leave.
+				*/		
+				if((which & cppvPsnk) || !(mp->mpVAddr & 1)) break;		/* We got it mapped R/W or the source is not virtual, leave... */
+			
+				mapping_drop_busy(mp);				/* Go ahead and release the mapping for now */
+				if(per_proc_info[cpu_number()].istackptr == 0)
+					panic("copypv: No vaild mapping on memory %s %x", "RDWR", vaddr);
+				splx(s);							/* Restore the interrupt level */
+				
+				ret = vm_fault(map, trunc_page_32((vm_offset_t)vaddr), VM_PROT_READ | VM_PROT_WRITE, FALSE, NULL, 0);	/* check for a COW area */
+				if (ret != KERN_SUCCESS) return KERN_FAILURE;	/* We couldn't get it R/W, leave in disgrace... */
+				s = splhigh();						/* Don't bother me */
+			}
+			paddr = ((addr64_t)mp->mpPAddr << 12) + (vaddr - (mp->mpVAddr & -4096LL));        /* construct the physical address... this calculation works */
+			                                                                                  /* properly on both single page and block mappings */
+			if(which & cppvPsrc) sink = paddr;		/* If source is physical, then the sink is virtual */
+			else source = paddr;					/* Otherwise the source is */
 		}
-	 	left = PAGE_SIZE - (sink & PAGE_MASK);		/* Get amount left on sink page */
-
-		csize = size < left ? size : left;              /* Set amount to copy this pass */
-
-		pa = (vm_offset_t)((mpv->physent->pte1 & ~PAGE_MASK) | ((unsigned int)sink & PAGE_MASK));	/* Get physical address of sink */
-
-	 	bcopy_physvir((char *)source, (char *)pa, csize);	/* Do a physical copy, virtually */
-
-		hw_set_mod(mpv->physent);					/* Go set the change of the sink */
-
-		hw_unlock_bit((unsigned int *)&mpv->physent->phys_link, PHYS_LOCK);	/* Unlock the sink */
-	 	splx(s);									/* Open up for interrupts */
-
-	 	sink += csize;								/* Move up to start of next page */
-	 	source += csize;							/* Move up source */
-	 	size -= csize;								/* Set amount for next pass */
-	}
-	return KERN_SUCCESS;
-}
+			
+		lop = (unsigned int)(4096LL - (sink & 4095LL));		/* Assume sink smallest */
+		if(lop > (unsigned int)(4096LL - (source & 4095LL))) lop = (unsigned int)(4096LL - (source & 4095LL));	/* No, source is smaller */
+		
+		csize = size;								/* Assume we can copy it all */
+		if(lop < size) csize = lop;					/* Nope, we can't do it all */
+		
+		if(which & cppvFsrc) flush_dcache64(source, csize, 1);	/* If requested, flush source before move */
+		if(which & cppvFsnk) flush_dcache64(sink, csize, 1);	/* If requested, flush sink before move */
 
+		bcopy_physvir(source, sink, csize);			/* Do a physical copy, virtually */
+		
+		if(which & cppvFsrc) flush_dcache64(source, csize, 1);	/* If requested, flush source after move */
+		if(which & cppvFsnk) flush_dcache64(sink, csize, 1);	/* If requested, flush sink after move */
 
 /*
- * copy 'size' bytes from physical to physical address
- * the caller must validate the physical ranges 
- *
- * if flush_action == 0, no cache flush necessary
- * if flush_action == 1, flush the source
- * if flush_action == 2, flush the dest
- * if flush_action == 3, flush both source and dest
+ *		Note that for certain ram disk flavors, we may be copying outside of known memory.
+ *		Therefore, before we try to mark it modifed, we check if it exists.
  */
 
-kern_return_t copyp2p(vm_offset_t source, vm_offset_t dest, unsigned int size, unsigned int flush_action) {
-
-        switch(flush_action) {
-	case 1:
-	        flush_dcache(source, size, 1);
-		break;
-	case 2:
-	        flush_dcache(dest, size, 1);
-		break;
-	case 3:
-	        flush_dcache(source, size, 1);
-	        flush_dcache(dest, size, 1);
-		break;
-
+		if( !(which & cppvNoModSnk)) {
+		        physent = mapping_phys_lookup(sink >> 12, &pindex);	/* Get physical entry for sink */
+			if(physent) mapping_set_mod((ppnum_t)(sink >> 12));		/* Make sure we know that it is modified */
+		}
+		if( !(which & cppvNoRefSrc)) {
+		        physent = mapping_phys_lookup(source >> 12, &pindex);	/* Get physical entry for source */
+			if(physent) mapping_set_ref((ppnum_t)(source >> 12));		/* Make sure we know that it is modified */
+		}
+		size = size - csize;						/* Calculate what is left */
+		vaddr = vaddr + csize;						/* Move to next sink address */
+		source = source + csize;					/* Bump source to next physical address */
+		sink = sink + csize;						/* Bump sink to next physical address */
 	}
-        bcopy_phys((char *)source, (char *)dest, size);	/* Do a physical copy */
-
-        switch(flush_action) {
-	case 1:
-	        flush_dcache(source, size, 1);
-		break;
-	case 2:
-	        flush_dcache(dest, size, 1);
-		break;
-	case 3:
-	        flush_dcache(source, size, 1);
-	        flush_dcache(dest, size, 1);
-		break;
+	
+	if(!bothphys) mapping_drop_busy(mp);			/* Go ahead and release the mapping of the virtual page if any */
+	splx(s);										/* Open up for interrupts */
 
-	}
+	return KERN_SUCCESS;
 }
 
 
-
-#if DEBUG
 /*
- *		Dumps out the mapping stuff associated with a virtual address
+ *	Debug code 
  */
-void dumpaddr(space_t space, vm_offset_t va) {
-
-	mapping		*mp, *mpv;
-	vm_offset_t	pa;
-	spl_t 		s;
 
-	s=splhigh();											/* Don't bother me */
-
-	mp = hw_lock_phys_vir(space, va);						/* Lock the physical entry for this mapping */
-	if(!mp) {												/* Did we find one? */
-		splx(s);											/* Restore the interrupt level */
-		printf("dumpaddr: virtual address (%08X) not mapped\n", va);	
-		return;												/* Didn't find any, return FALSE... */
-	}
-	if((unsigned int)mp&1) {								/* Did we timeout? */
-		panic("dumpaddr: timeout locking physical entry for virtual address (%08X)\n", va);	/* Yeah, scream about it! */
-		splx(s);											/* Restore the interrupt level */
-		return;												/* Bad hair day, return FALSE... */
-	}
-	printf("dumpaddr: space=%08X; vaddr=%08X\n", space, va);	/* Say what address were dumping */
-	mpv = hw_cpv(mp);										/* Get virtual address of mapping */
-	dumpmapping(mpv);
-	if(mpv->physent) {
-		dumppca(mpv);
-		hw_unlock_bit((unsigned int *)&mpv->physent->phys_link, PHYS_LOCK);	/* Unlock physical entry associated with mapping */
-	}
-	splx(s);												/* Was there something you needed? */
-	return;													/* Tell them we did it */
-}
+void mapping_verify(void) {
 
+	spl_t		s;
+	mappingblok	*mb, *mbn;
+	int			relncnt;
+	unsigned int	dumbodude;
 
+	dumbodude = 0;
+	
+	s = splhigh();											/* Don't bother from now on */
 
-/*
- *		Prints out a mapping control block
- *
- */
- 
-void dumpmapping(struct mapping *mp) { 						/* Dump out a mapping */
-
-	printf("Dump of mapping block: %08X\n", mp);			/* Header */
-	printf("                 next: %08X\n", mp->next);                 
-	printf("             hashnext: %08X\n", mp->hashnext);                 
-	printf("              PTEhash: %08X\n", mp->PTEhash);                 
-	printf("               PTEent: %08X\n", mp->PTEent);                 
-	printf("              physent: %08X\n", mp->physent);                 
-	printf("                 PTEv: %08X\n", mp->PTEv);                 
-	printf("                 PTEr: %08X\n", mp->PTEr);                 
-	printf("                 pmap: %08X\n", mp->pmap);
-	
-	if(mp->physent) {									/* Print physent if it exists */
-		printf("Associated physical entry: %08X %08X\n", mp->physent->phys_link, mp->physent->pte1);
+	mbn = 0;												/* Start with none */
+	for(mb = mapCtl.mapcnext; mb; mb = mb->nextblok) {		/* Walk the free chain */
+		if((mb->mapblokflags & 0x7FFFFFFF) != mb) {			/* Is tag ok? */
+			panic("mapping_verify: flags tag bad, free chain; mb = %08X, tag = %08X\n", mb, mb->mapblokflags);
+		}
+		mbn = mb;											/* Remember the last one */
 	}
-	else {
-		printf("Associated physical entry: none\n");
+	
+	if(mapCtl.mapcnext && (mapCtl.mapclast != mbn)) {		/* Do we point to the last one? */
+		panic("mapping_verify: last pointer bad; mb = %08X, mapclast = %08X\n", mb, mapCtl.mapclast);
 	}
 	
-	dumppca(mp);										/* Dump out the PCA information */
+	relncnt = 0;											/* Clear count */
+	for(mb = mapCtl.mapcrel; mb; mb = mb->nextblok) {		/* Walk the release chain */
+		dumbodude |= mb->mapblokflags;						/* Just touch it to make sure it is mapped */
+		relncnt++;											/* Count this one */
+	}
 	
-	return;
-}
+	if(mapCtl.mapcreln != relncnt) {							/* Is the count on release queue ok? */
+		panic("mapping_verify: bad release queue count; mapcreln = %d, cnt = %d, ignore this = %08X\n", mapCtl.mapcreln, relncnt, dumbodude);
+	}
 
-/*
- *		Prints out a PTEG control area
- *
- */
- 
-void dumppca(struct mapping *mp) { 						/* PCA */
-
-	PCA				*pca;
-	unsigned int	*pteg;
-	
-	pca = (PCA *)((unsigned int)mp->PTEhash&-64);		/* Back up to the start of the PCA */
-	pteg=(unsigned int *)((unsigned int)pca-(((hash_table_base&0x0000FFFF)+1)<<16));
-	printf(" Dump of PCA: %08X\n", pca);		/* Header */
-	printf("     PCAlock: %08X\n", pca->PCAlock);                 
-	printf("     PCAallo: %08X\n", pca->flgs.PCAallo);                 
-	printf("     PCAhash: %08X %08X %08X %08X\n", pca->PCAhash[0], pca->PCAhash[1], pca->PCAhash[2], pca->PCAhash[3]);                 
-	printf("              %08X %08X %08X %08X\n", pca->PCAhash[4], pca->PCAhash[5], pca->PCAhash[6], pca->PCAhash[7]);                 
-	printf("Dump of PTEG: %08X\n", pteg);		/* Header */
-	printf("              %08X %08X %08X %08X\n", pteg[0], pteg[1], pteg[2], pteg[3]);                 
-	printf("              %08X %08X %08X %08X\n", pteg[4], pteg[5], pteg[6], pteg[7]);                 
-	printf("              %08X %08X %08X %08X\n", pteg[8], pteg[9], pteg[10], pteg[11]);                 
-	printf("              %08X %08X %08X %08X\n", pteg[12], pteg[13], pteg[14], pteg[15]);                 
-	return;
-}
+	splx(s);												/* Restore 'rupts */
 
-/*
- *		Dumps starting with a physical entry
- */
- 
-void dumpphys(struct phys_entry *pp) { 						/* Dump from physent */
-
-	mapping			*mp;
-	PCA				*pca;
-	unsigned int	*pteg;
-
-	printf("Dump from physical entry %08X: %08X %08X\n", pp, pp->phys_link, pp->pte1);
-	mp = hw_cpv(pp->phys_link);
-	while(mp) {
-		dumpmapping(mp);
-		dumppca(mp);
-		mp = hw_cpv(mp->next);
-	}
-	
 	return;
 }
 
-#endif
+void mapping_phys_unused(ppnum_t pa) {
 
+	unsigned int pindex;
+	phys_entry *physent;
 
-kern_return_t bmapvideo(vm_offset_t *info);
-kern_return_t bmapvideo(vm_offset_t *info) {
+	physent = mapping_phys_lookup(pa, &pindex);				/* Get physical entry */
+	if(!physent) return;									/* Did we find the physical page? */
 
-	extern struct vc_info vinfo;
+	if(!(physent->ppLink & ~(ppLock | ppN | ppFlags))) return;	/* No one else is here */
 	
-	(void)copyout((char *)&vinfo, (char *)info, sizeof(struct vc_info));	/* Copy out the video info */
-	return KERN_SUCCESS;
-}
-
-kern_return_t bmapmap(vm_offset_t va, vm_offset_t pa, vm_size_t size, vm_prot_t prot, int attr);
-kern_return_t bmapmap(vm_offset_t va, vm_offset_t pa, vm_size_t size, vm_prot_t prot, int attr) {
+	panic("mapping_phys_unused: physical page (%08X) in use, physent = %08X\n", pa, physent);
 	
-	pmap_map_block(current_act()->task->map->pmap, va, pa, size, prot, attr, 0);	/* Map it in */
-	return KERN_SUCCESS;
 }
-
-kern_return_t bmapmapr(vm_offset_t va);
-kern_return_t bmapmapr(vm_offset_t va) {
 	
-	mapping_remove(current_act()->task->map->pmap, va);	/* Remove map */
-	return KERN_SUCCESS;
-}
+	
+	
+	
+	
+	
+	
+	
+	
+	
diff --git a/osfmk/ppc/mappings.h b/osfmk/ppc/mappings.h
index 8c278ab08..6889313a8 100644
--- a/osfmk/ppc/mappings.h
+++ b/osfmk/ppc/mappings.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -25,71 +28,183 @@
 #ifndef	_PPC_MAPPINGS_H_
 #define	_PPC_MAPPINGS_H_
 
+#include <cpus.h>
+
+#include <mach/mach_types.h>
+#include <mach/vm_types.h>
+#include <mach/machine/vm_types.h>
+#include <mach/vm_prot.h>
+#include <mach/vm_statistics.h>
+#include <kern/assert.h>
+#include <kern/cpu_number.h>
+#include <kern/lock.h>
+#include <kern/queue.h>
+#include <ppc/proc_reg.h>
+
+/*
+ * Don't change these structures unless you change the assembly code
+ */
+
+/*
+ *	This control block serves as anchor for all virtual mappings of the same physical
+ *	page, i.e., aliases.  There is a table for each bank (mem_region).  All tables
+ *	must reside in V=R storage and within the first 2GB of memory. Also, the
+ *	mappings to which it points must be on at least a 64-byte boundary. These 
+ *	requirements allow a total of 2 bits for status and flags, and allow all address
+ *	calculations to be 32-bit.
+ */
+
+#pragma pack(4)							/* Make sure the structure stays as we defined it */
+typedef struct phys_entry {
+	addr64_t	ppLink;				/* Physical pointer to aliased mappings and flags */
+#define		ppLock		0x8000000000000000LL	/* Lock for alias chain */
+#define		ppN			0x4000000000000000LL	/* Not executable */
+#define		ppFlags		0x000000000000003FLL	/* Status and flags */
+#define		ppI			0x0000000000000020LL	/* Cache inhibited */
+#define		ppIb		58						/* Cache inhibited */
+#define		ppG			0x0000000000000010LL	/* Guarded */
+#define		ppGb		59						/* Guarded */
+#define		ppR			0x0000000000000008LL	/* Referenced */
+#define		ppRb		60						/* Referenced */
+#define		ppC			0x0000000000000004LL	/* Changed */
+#define		ppCb		61						/* Changed */
+#define		ppPP		0x0000000000000003LL	/* Protection */
+#define		ppPPb		62						/* Protection begin */
+#define		ppPPe		63						/* Protection end */
+} phys_entry;
+#pragma pack()
+
+/* Memory may be non-contiguous. This data structure contains info
+ * for mapping this non-contiguous space into the contiguous
+ * physical->virtual mapping tables. An array of this type is
+ * provided to the pmap system at bootstrap by ppc_vm_init.
+ *
+ */
+
+#pragma pack(4)							/* Make sure the structure stays as we defined it */
+typedef struct mem_region {
+	phys_entry			*mrPhysTab;	/* Base of region table */
+	ppnum_t				mrStart;	/* Start of region */
+	ppnum_t				mrEnd;		/* Last page in region */
+	ppnum_t				mrAStart;	/* Next page in region to allocate */
+	ppnum_t				mrAEnd;		/* Last page in region to allocate */
+} mem_region_t;
+#pragma pack()
+
+#define mrSize sizeof(mem_region_t)
+#define PMAP_MEM_REGION_MAX 26
+
+extern mem_region_t pmap_mem_regions[PMAP_MEM_REGION_MAX + 1];
+extern int          pmap_mem_regions_count;
+
+/* Prototypes */
+
+
+#pragma pack(4)							/* Make sure the structure stays as we defined it */
 typedef struct PCA {					/* PTEG Control Area */
-	unsigned int		PCAlock;		/* PCA lock */
 	union flgs {
 		unsigned int	PCAallo;		/* Allocation controls */
 		struct PCAalflgs {				/* Keep these in order!!! */
 			unsigned char	PCAfree;	/* Indicates the slot is free */
-			unsigned char	PCAauto;	/* Indicates that the PTE was autogenned */
-			unsigned char	PCAslck;	/* Indicates that the slot is locked */
 			unsigned char	PCAsteal;	/* Steal scan start position */
+			unsigned char	PCAauto;	/* Indicates that the PTE was autogenned */
+			unsigned char	PCAmisc;	/* Misc. flags */
+#define PCAlock 1						/* This locks up the associated PTEG */
+#define PCAlockb 31
 		} PCAalflgs;
 	} flgs;
-	unsigned int		PCAgas[6];		/* Filler to 32 byte boundary */
-	unsigned int		PCAhash[8];		/* PTEG hash chains */
 } PCA;
+#pragma pack()
 
-#define MAPFLAGS 0x0000001F
-#define BMAP 0x00000001
-
-typedef struct mapping {
-	struct mapping		*next;			/* MUST BE FIRST - chain off physent */
-	struct mapping		*hashnext;		/* Next mapping in same hash group */
-	unsigned int		*PTEhash;		/* Pointer to the head of the mapping hash list */
-	unsigned int		*PTEent;		/* Pointer to PTE if exists */
-	struct phys_entry	*physent;		/* Quick pointer back to the physical entry */
-	unsigned int		PTEv;			/* Virtual half of HW PTE */
-	unsigned int		PTEr;			/* Real half of HW PTE. This is used ONLY if
-										   there is no physical entry associated
-										   with this mapping, ie.e, physent==0 */
-	struct pmap 		*pmap;			/* Quick pointer back to the containing pmap */
-} mapping;
-
-/* 
- *	This control block maps odd size blocks of memory.  The mapping must
- *	be V=F (Virtual = Fixed), i.e., virtually and physically contiguous
- *	multiples of hardware size pages.
- *
- *	This control block overlays the mapping CB and is allocated from the
- *	same pool.
+/* Mappings currently come in two sizes: 64 and 128 bytes.  The only difference is the
+ * number of skiplists (ie, mpLists): 64-byte mappings have 1-4 lists and 128-byte mappings
+ * have from 5-12.  Only 1 in 256 mappings is large, so an average mapping is 64.25 bytes.
+ * All mappings are 64-byte aligned.
  *
- *	It is expected that only a small number of these exist for each address
- *	space and will typically be for I/O areas. It is further assumed that 
- *	there is a minimum size (ODDBLKMIN) for these blocks.  If smaller, the
- *	block will be split into N normal page mappings.
- *
- *	Binary tree for fast lookups. 
- */
+ * Special note on mpFIP and mpRIP:
+ *	These flags are manipulated under various locks.  RIP is always set under an
+ *	exclusive lock while FIP is shared.  The only worry is that there is a possibility that
+ *	FIP could be attempted by more than 1 processor at a time.  Obviously, one will win.
+ *	The other(s) bail all the way to user state and may refault (or not).  There are only
+ *	a few things in mpFlags that are not static, mpFIP, mpRIP, mpRemovable, and mpBusy.
+ *	
+ *	We organize these so that mpFIP is in a byte with static data and mpRIP and mpRemovable
+ *	is in another.  That means that we can use a store byte to update the guys without
+ *	worrying about load and reserve. Note that mpFIP must be set atomically because it is
+ *	under a share lock, but it may be clear with a simple store byte. So far as mpRIP
+ *	goes, it is in the same byte as mpRemovable.  However, mpRemovable is set atomically
+ *	but never cleared, and mpRIP will not ever be set until after mpRemovable. Note that
+ *	mpRIP is never cleared either.
+ *	
+ */   
+#pragma pack(4)							/* Make sure the structure stays as we defined it */
+typedef struct mapping {
+	unsigned int		mpFlags;		/* 0x000 - Various flags, lock bit. These are static except for lock */
+#define	mpBusy				0xFF000000	/*         Busy count */
+#define	mpPIndex			0x00FF0000	/*         Index into physical table (in words) */
+#define	mpSpecial			0x00008000	/*         Special mapping - processor specific. */
+#define	mpSpecialb			16			/*         Special mapping - processor specific. */
+#define	mpFIP				0x00004000	/*         Fault in progress */
+#define	mpFIPb				17			/*         Fault in progress */
+#define	mpNest				0x00001000	/*         Mapping describes nested pmap */
+#define	mpNestb				19			/*         Mapping describes nested pmap */
+#define mpPerm				0x00000800	/*         Mapping is permanent */
+#define mpPermb				20			/*         Mapping is permanent */
+#define mpBlock				0x00000400	/*         Mapping is a block map - used for V=F or I/O */
+#define mpBlockb			21			/*         Mapping is a block map - used for V=F or I/O */
+#define mpRIP				0x00000080	/*         Remove in progress - DO NOT MOVE */
+#define mpRIPb				24			/*         Remove in progress */
+#define	mpRemovable			0x00000040	/*         Mapping is removable - DO NOT MOVE */
+#define	mpRemovableb		25			/*         Mapping is removable */
+#define mpRSVD1				0x00002330	/*         Reserved for future use */
+#define mpLists				0x0000001F	/*         Number of skip lists mapping is on, max of 27 */
+#define mpListsb			27			/*         Number of skip lists mapping is on, max of 27 */
 
+	unsigned short		mpSpace;		/* 0x004 - Address space hash */
+	unsigned short		mpBSize;		/* 0x006 - Block size - 1 in pages - max block size 256MB */
+	unsigned int		mpPte;			/* 0x008 - Offset to PTEG in hash table. Offset to exact PTE if mpHValid set - NOTE: this MUST be 0 for block mappings */
+#define mpHValid			0x00000001	/* PTE is entered in hash table */
+#define mpHValidb			31			/* PTE is entered in hash table */
+	ppnum_t				mpPAddr;		/* 0x00C - Physical page number */
+	addr64_t			mpVAddr;		/* 0x010 - Starting virtual address */
+#define mpHWFlags			0x0000000000000FFFULL	/* Reference/Change, WIMG, AC, N, protection flags from PTE */
+#define mpPP				0x0000000000000007ULL	/* Protection flags */
+#define mpPPb				61
+#define mpKKN				0x0000000000000007ULL	/* Segment key and no execute flag (nested pmap) */
+#define mpKKNb				61
+#define mpWIMG				0x0000000000000078ULL	/* Attribute bits */
+#define mpWIMGb				57
+#define mpW					0x0000000000000040ULL
+#define mpWb				57
+#define mpI					0x0000000000000020ULL
+#define mpIb				58
+#define mpM					0x0000000000000010ULL
+#define mpMb				59
+#define mpG					0x0000000000000008ULL
+#define mpGb				60
+#define mpWIMGe				60
+#define mpC					0x0000000000000080ULL	/* Change bit */
+#define mpCb				56
+#define mpR					0x0000000000000100ULL	/* Reference bit */
+#define mpRb				55
+	addr64_t			mpAlias;		/* 0x018 - Pointer to alias mappings of physical page */
+#define mpNestReloc			mpAlias		/* 0x018 - Redefines mpAlias relocation value of vaddr to nested pmap value */
+#define mpBlkRemCur			mpAlias		/* 0x018 - Next offset in block map to remove (this is 4 bytes) */
+	addr64_t			mpList0;		/* 0x020 - Forward chain of mappings. This one is always used */
+	addr64_t			mpList[3];		/* 0x028 - Forward chain of mappings. Next higher order */
+/*										   0x040 - End of basic mapping */
+#define	mpBasicSize			64
+#define	mpBasicLists		4
+/* note the dependence on kSkipListMaxLists, which must be <= #lists in a 256-byte mapping (ie, <=28) */
+/*	addr64_t			mpList4[8];		   0x040 - First extended list entries */
+/*										   0x080 - End of first extended mapping */
+/*	addr64_t			mpList12[8];	   0x080 - Second extended list entries */
+/*										   0x0C0 - End of second extended mapping */
+/*	addr64_t			mpList20[8];	   0x0C0 - Third extended list entries */
+/*										   0x100 - End of third extended mapping */
 
-typedef struct blokmap {
-	struct blokmap		*next;			/* Next block in list */
-	unsigned int		start;			/* Start of block */
-	unsigned int		end;			/* End of block */
-	unsigned int		PTEr;			/* Real half of HW PTE at base address */
-	unsigned int		space;			/* Cached VSID */
-	unsigned int		blkFlags;		/* Flags for this block */
-#define blkPerm	0x80000000
-#define blkRem 	0x40000000
-#define blkPermbit	0
-#define blkRembit	1
-	unsigned int		current;		/* Partial block remove current start */
-	unsigned int		gas4;			/* Reserved */
-} blokmap;
-
-#define ODDBLKMIN (8 * PAGE_SIZE)
-#define	BLKREMMAX 128
+} mapping;
+#pragma pack()
 
 #define MAPPING_NULL	((struct mapping *) 0)
 
@@ -99,16 +214,15 @@ typedef struct blokmap {
 #define mapRWRW   0x00000002
 #define mapRORO   0x00000003
 
-
-typedef struct mfmapping {
-	struct pmap			*pmap;
-	vm_offset_t			offset;
-} mfmapping;
+/* All counts are in units of basic 64-byte mappings.  A 128-byte mapping is
+ * just two adjacent 64-byte entries.
+ */
+#pragma pack(4)							/* Make sure the structure stays as we defined it */
 
 typedef struct mappingflush {
-	PCA 				*pcaptr;
-	unsigned int		mappingcnt;
-	struct mfmapping	mapping[8];
+	addr64_t			addr;			/* Start address to search mapping */
+	unsigned int		spacenum;		/* Last space num to search pmap */
+	unsigned int		mapfgas[1];		/* Pad to 64 bytes */
 } mappingflush;
 
 typedef struct mappingctl {
@@ -123,69 +237,103 @@ typedef struct mappingctl {
 	int					mapcholdoff;	/* Hold off clearing release list */
 	unsigned int		mapcfreec;		/* Total calls to mapping free */
 	unsigned int		mapcallocc;		/* Total calls to mapping alloc */
+    unsigned int		mapcbig;		/* Count times a big mapping was requested of mapping_alloc */
+    unsigned int		mapcbigfails;	/* Times caller asked for a big one but we gave 'em a small one */
 	unsigned int		mapcmin;		/* Minimum free mappings to keep */
 	unsigned int		mapcmaxalloc;	/* Maximum number of mappings allocated at one time */
-	struct mappingflush	mapcflush;
 	unsigned int		mapcgas[1];		/* Pad to 64 bytes */
+	struct mappingflush	mapcflush;
 } mappingctl;
+#pragma pack()
 
-#define MAPPERBLOK 127
+/* MAPPERBLOK is the number of basic 64-byte mappings per block (ie, per page.) */
+#define MAPPERBLOK 63
 #define MAPALTHRSH (4*MAPPERBLOK)
 #define MAPFRTHRSH (2 * ((MAPALTHRSH + MAPPERBLOK - 1) / MAPPERBLOK))
 typedef struct mappingblok {
-	unsigned int		mapblokfree[4];	/* Bit map of free mapping entrys */
-	unsigned int		mapblokvrswap;	/* Virtual address XORed with physical address */
+	unsigned int		mapblokfree[2];	/* Bit map of free mapping entrys */
+	addr64_t			mapblokvrswap;	/* Virtual address XORed with physical address */
 	unsigned int		mapblokflags;	/* Various flags */
 #define mbPerm 0x80000000				/* Block is permanent */
 	struct mappingblok	*nextblok;		/* Pointer to the next mapping block */
 } mappingblok;
 
+#define mapRemChunk 128
+
+#define mapRetCode	0xF
+#define mapRtOK		0
+#define mapRtBadLk	1
+#define mapRtPerm	2
+#define mapRtNotFnd	3
+#define mapRtBlock	4
+#define mapRtNest	5
+#define mapRtRemove	6
+#define mapRtMapDup	7
+
 extern mappingctl	mapCtl;				/* Mapping allocation control */
 
-extern void 		mapping_phys_init(struct phys_entry *pp, unsigned int pa, unsigned int wimg);	/* Initializes hw specific storage attributes */
-extern boolean_t 	mapping_remove(pmap_t pmap, vm_offset_t va);	/* Remove a single mapping for this VADDR */
+extern addr64_t 	mapping_remove(pmap_t pmap, addr64_t va);	/* Remove a single mapping for this VADDR */
+extern mapping 		*mapping_find(struct pmap *pmap, addr64_t va, addr64_t *nextva, int full);	/* Finds a mapping */
 extern void 		mapping_free_init(vm_offset_t mbl, int perm, boolean_t locked);	/* Sets start and end of a block of mappings */
 extern void 		mapping_adjust(void);						/* Adjust free mapping count */
 extern void 		mapping_free_prime(void);					/* Primes the mapping block release list */
 extern void 		mapping_prealloc(unsigned int);				/* Preallocate mappings for large use */
 extern void 		mapping_relpre(void);						/* Releases preallocate request */
 extern void 		mapping_init(void);							/* Do initial stuff */
-extern void 		mapping_flush(void);
-extern mapping 		*mapping_alloc(void);						/* Obtain a mapping */
+extern mapping 	   *mapping_alloc(int lists);					/* Obtain a mapping */
 extern void 		mapping_free(struct mapping *mp);			/* Release a mapping */
-extern boolean_t 	mapping_tst_ref(struct phys_entry *pp);		/* Tests the reference bit of a physical page */
-extern boolean_t 	mapping_tst_mod(struct phys_entry *pp);		/* Tests the change bit of a physical page */
-extern void 		mapping_set_ref(struct phys_entry *pp);		/* Sets the reference bit of a physical page */
-extern void 		mapping_clr_ref(struct phys_entry *pp);		/* Clears the reference bit of a physical page */
-extern void 		mapping_set_mod(struct phys_entry *pp);		/* Sets the change bit of a physical page */
-extern void 		mapping_clr_mod(struct phys_entry *pp);		/* Clears the change bit of a physical page */
-extern void 		mapping_invall(struct phys_entry *pp);		/* Clear all PTEs pointing to a physical page */
-extern void 		mapping_protect_phys(struct phys_entry *pp, vm_prot_t prot, boolean_t locked);	/* Change protection of all mappings to page */
-extern void 		mapping_protect(pmap_t pmap, vm_offset_t vaddr, vm_prot_t prot);	/* Change protection of a single mapping to page */
-extern mapping 		*mapping_make(pmap_t pmap, struct phys_entry *pp, vm_offset_t va, vm_offset_t pa, vm_prot_t prot, int attr, boolean_t locked);	/* Make an address mapping */
-extern void 		mapping_purge(struct phys_entry *pp);		/* Remove all mappings for this physent */
-extern void		mapping_purge_pmap(struct phys_entry *pp, pmap_t pmap); /* Remove physent mappings for this pmap */
-extern vm_offset_t	mapping_p2v(pmap_t pmap, struct phys_entry *pp);	/* Finds first virtual mapping of a physical page in a space */
-extern void 		mapping_phys_attr(struct phys_entry *pp, vm_prot_t prot, unsigned int wimg);	/* Sets the default physical page attributes */
-extern void 		mapping_block_map_opt(pmap_t pmap, vm_offset_t va, vm_offset_t pa, vm_offset_t bnd, vm_size_t size, vm_prot_t prot, int attr);	/* Map a block optimally */
-extern int			mapalc(struct mappingblok *mb);				/* Finds and allcates a mapping entry */
+extern boolean_t 	mapping_tst_ref(ppnum_t pa);				/* Tests the reference bit of a physical page */
+extern boolean_t 	mapping_tst_mod(ppnum_t pa);				/* Tests the change bit of a physical page */
+extern void 		mapping_set_ref(ppnum_t pa);				/* Sets the reference bit of a physical page */
+extern void 		mapping_clr_ref(ppnum_t pa);				/* Clears the reference bit of a physical page */
+extern void 		mapping_set_mod(ppnum_t pa);				/* Sets the change bit of a physical page */
+extern void 		mapping_clr_mod(ppnum_t pa);				/* Clears the change bit of a physical page */
+extern void 		mapping_protect_phys(ppnum_t pa, vm_prot_t prot);	/* Change protection of all mappings to page */
+extern int	 		mapping_protect(pmap_t pmap, addr64_t va, vm_prot_t prot, addr64_t *nextva);	/* Change protection of a single mapping to page */
+extern addr64_t		mapping_make(pmap_t pmap, addr64_t va, ppnum_t pa, unsigned int flags, unsigned int size, vm_prot_t prot); /* Make a mapping */
+/* Flags for mapping_make */
+#define mmFlgBlock		0x80000000	/* This is a block map, use size for number of pages covered */
+#define mmFlgUseAttr	0x40000000	/* Use specified attributes */
+#define mmFlgPerm		0x20000000	/* Mapping is permanant */
+#define mmFlgCInhib		0x00000002	/* Cahching inhibited - use if mapFlgUseAttr set or block */
+#define mmFlgGuarded	0x00000001	/* Access guarded - use if mapFlgUseAttr set or block */
+extern void 		mapping_purge(ppnum_t pa);		/* Remove all mappings for this physent */
+extern addr64_t		mapping_p2v(pmap_t pmap, ppnum_t pa);	/* Finds first virtual mapping of a physical page in a space */
+extern void			mapping_drop_busy(struct mapping *mapping);	/* Drops busy count on mapping */
+extern phys_entry  *mapping_phys_lookup(ppnum_t pp, unsigned int *pindex);	/* Finds the physical entry for the page */
+extern int			mapalc1(struct mappingblok *mb);			/* Finds and allcates a 1-bit mapping entry */
+extern int			mapalc2(struct mappingblok *mb);			/* Finds and allcates a 2-bit mapping entry */
 extern void			ignore_zero_fault(boolean_t type);			/* Sets up to ignore or honor any fault on page 0 access for the current thread */
 
 
-extern mapping 		*hw_lock_phys_vir(space_t space, vm_offset_t va);	/* Finds and locks a physical entry by vaddr */
-extern mapping 		*hw_cpv(struct mapping *mapping);			/* Converts a physical mapping control block address to virtual */
-extern mapping 		*hw_cvp(struct mapping *mapping);			/* Converts a virtual mapping control block address to physical */
-extern void 		hw_rem_map(struct mapping *mapping);		/* Remove a mapping from the system */
-extern void			hw_add_map(struct mapping *mp, space_t space, vm_offset_t va);	/* Add a mapping to the PTEG hash list */
-extern void			hw_select_mappings(struct mappingflush *mappingflush); /* Select user mappings in a PTEG */
-extern blokmap 		*hw_rem_blk(pmap_t pmap, vm_offset_t sva, vm_offset_t eva);	/* Remove a block that falls within a range */
-extern vm_offset_t	hw_cvp_blk(pmap_t pmap, vm_offset_t va);	/* Convert mapped block virtual to physical */
-extern blokmap 		*hw_add_blk(pmap_t pmap, struct blokmap *bmr);	/* Add a block to the pmap */
-extern void 		hw_prot(struct phys_entry *pp, vm_prot_t prot);	/* Change the protection of a physical page */
-extern void 		hw_prot_virt(struct mapping *mp, vm_prot_t prot);	/* Change the protection of a virtual page */
-extern void 		hw_attr_virt(struct mapping *mp, unsigned int wimg);	/* Change the attributes of a virtual page */
-extern void 		hw_phys_attr(struct phys_entry *pp, vm_prot_t prot, unsigned int wimg);	/* Sets the default physical page attributes */
-extern unsigned int	hw_test_rc(struct mapping *mp, boolean_t reset);	/* Test and optionally reset the RC bit of specific mapping */
+extern mapping 		*hw_rem_map(struct pmap *pmap, addr64_t va, addr64_t *next);	/* Remove a mapping from the system */
+extern mapping 		*hw_purge_map(struct pmap *pmap, addr64_t va, addr64_t *next);	/* Remove a regular mapping from the system */
+extern mapping 		*hw_purge_space(struct phys_entry *pp, struct pmap *pmap);	/* Remove the first mapping for a specific pmap from physentry */
+extern mapping 		*hw_purge_phys(struct phys_entry *pp);		/* Remove the first mapping for a physentry */
+extern mapping 		*hw_find_map(struct pmap *pmap, addr64_t va, addr64_t *nextva);	/* Finds a mapping */
+extern addr64_t		hw_add_map(struct pmap *pmap, struct mapping *mp);	/* Add a mapping to a pmap */
+extern int	 		hw_protect(pmap_t pmap, addr64_t va, vm_prot_t prot, addr64_t *nextva);	/* Change the protection of a virtual page */
+extern unsigned int	hw_test_rc(pmap_t pmap, addr64_t va, boolean_t reset);	/* Test and optionally reset the RC bit of specific mapping */
+
+extern unsigned int	hw_phys_walk(struct phys_entry *pp, unsigned int preop, unsigned int op, /* Perform function on all mappings on a physical page */
+	unsigned int postop, unsigned int parm);	
+#define hwpNoop		0	/* No operation */
+#define hwpSPrtPhy	1	/* Sets protection in physent  */
+#define hwpSPrtMap	2	/* Sets protection in mapping  */
+#define hwpSAtrPhy	3	/* Sets attributes in physent  */
+#define hwpSAtrMap	4	/* Sets attributes in mapping  */
+#define hwpCRefPhy	5	/* Clears reference in physent  */
+#define hwpCRefMap	6	/* Clears reference in mapping  */
+#define hwpCCngPhy	7	/* Clears change in physent  */
+#define hwpCCngMap	8	/* Clears change in mapping  */
+#define hwpSRefPhy	9	/* Sets reference in physent  */
+#define hwpSRefMap	10	/* Sets reference in mapping  */
+#define hwpSCngPhy	11	/* Sets change in physent  */
+#define hwpSCngMap	12	/* Sets change in mapping  */
+#define hwpTRefPhy	13	/* Tests reference in physent  */
+#define hwpTRefMap	14	/* Tests reference in mapping  */
+#define hwpTCngPhy	15	/* Tests change in physent  */
+#define hwpTCngMap	16	/* Tests change in mapping  */
 
 extern boolean_t 	hw_tst_mod(struct phys_entry *pp);			/* Tests change bit */
 extern void 		hw_set_mod(struct phys_entry *pp);			/* Set change bit */
@@ -195,15 +343,17 @@ extern boolean_t 	hw_tst_ref(struct phys_entry *pp);			/* Tests reference bit */
 extern void 		hw_set_ref(struct phys_entry *pp);			/* Set reference bit */
 extern void 		hw_clr_ref(struct phys_entry *pp);			/* Clear reference bit */
 
-extern void 		hw_inv_all(struct phys_entry *pp);			/* Invalidate all PTEs associated with page */
 extern void 		hw_set_user_space(pmap_t pmap);				/* Indicate we need a space switch */
 extern void 		hw_set_user_space_dis(pmap_t pmap);			/* Indicate we need a space switch (already disabled) */
-kern_return_t		copyp2v(vm_offset_t source, vm_offset_t sink, unsigned int size);	/* Copy a physical page to a virtual address */
-extern void			*LRA(space_t space, void *vaddr);			/* Translate virtual to real using only HW tables */
-extern void 		dumpaddr(space_t space, vm_offset_t va);
-extern void			dumpmapping(struct mapping *mp);			/* Print contents of a mapping */
-extern void			dumppca(struct mapping *mp);				/* Print contents of a PCA */
-extern void			dumpphys(struct phys_entry *pp);			/* Prints stuff starting at phys */
+extern void 		hw_setup_trans(void);						/* Setup hardware for translation */
+extern void 		hw_start_trans(void);						/* Start translation for the first time */
+extern void 		hw_map_seg(pmap_t pmap, addr64_t seg, addr64_t va);		/* Validate a segment */
+extern void 		hw_blow_seg(addr64_t seg);					/* Invalidate a segment */
+extern void 		invalidateSegs(pmap_t pmap);				/* Invalidate the segment cache */
+extern struct phys_entry *pmap_find_physentry(ppnum_t pa);
+extern void			mapLog(unsigned int laddr, unsigned int type, addr64_t va);
+extern unsigned int	mapSkipListVerifyC(struct pmap *pmap, unsigned long long *dumpa);
+extern void			fillPage(ppnum_t pa, unsigned int fill);
 
 extern unsigned int	mappingdeb0;								/* (TEST/DEBUG) */
 extern unsigned int	incrVSID;									/* VSID increment value */
diff --git a/osfmk/ppc/mem.c b/osfmk/ppc/mem.c
deleted file mode 100644
index 5d2a9325f..000000000
--- a/osfmk/ppc/mem.c
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
- *
- * @APPLE_LICENSE_HEADER_START@
- * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
- * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
- * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
- * 
- * @APPLE_LICENSE_HEADER_END@
- */
-/*
- * @OSF_COPYRIGHT@
- */
-
-/* A marvelous selection of support routines for virtual memory */
-
-#include <cpus.h>
-#include <debug.h>
-#include <mach_kdb.h>
-#include <mach_vm_debug.h>
-
-#include <kern/cpu_number.h>
-#include <kern/misc_protos.h>
-#include <kern/assert.h>
-#include <ppc/misc_protos.h>
-#include <ppc/mem.h>
-#include <ppc/pmap_internals.h>		/* For pmap_pteg_overflow */
-
-/* These refer to physical addresses and are set and referenced elsewhere */
-
-unsigned int hash_table_base;
-unsigned int hash_table_size;
-
-unsigned int hash_function_mask;
-
-struct shadowBAT shadow_BAT;
-
-/* gather statistics about hash table usage */
-
-#if	DEBUG
-#define MEM_STATS 1
-#else
-#define MEM_STATS 0
-#endif /* DEBUG */
-
-#if MEM_STATS
-/* hash table usage information */
-struct hash_table_stats {
-	int find_pte_in_pteg_calls;
-	int find_pte_in_pteg_not_found;
-	int find_pte_in_pteg_location[8];
-	struct find_or_alloc_calls {
-		int found_primary;
-		int found_secondary;
-		int alloc_primary;
-		int alloc_secondary;
-		int overflow;
-		int not_found;
-	} find_or_alloc_calls[2];
-	
-} hash_table_stats[NCPUS];
-
-#define INC_STAT(LOC) \
-	hash_table_stats[cpu_number()].find_pte_in_pteg_location[LOC]++
-
-#else	/* MEM_STATS */
-#define INC_STAT(LOC)
-#endif	/* MEM_STATS */
-
-/* Set up the machine registers for the given hash table.
- * The table has already been zeroed.
- */
-void hash_table_init(unsigned int base, unsigned int size)
-{
-	sync();					/* SYNC: it's not just the law, it's a good idea... */
-	mtsdr1(hash_table_base | ((size-1)>>16));	/* Slam the SDR1 with the has table address */
-	sync();					/* SYNC: it's not just the law, it's a good idea... */
-	isync();
-}
-
diff --git a/osfmk/ppc/mem.h b/osfmk/ppc/mem.h
index ef9169ac8..a88c27ae4 100644
--- a/osfmk/ppc/mem.h
+++ b/osfmk/ppc/mem.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -31,25 +34,28 @@
 
 #include <ppc/proc_reg.h>
 #include <ppc/pmap.h>
-#include <ppc/pmap_internals.h>
 #include <mach/vm_types.h>
 
-extern vm_offset_t hash_table_base;
+extern addr64_t hash_table_base;
 extern unsigned int hash_table_size;
 
 void hash_table_init(vm_offset_t base, vm_offset_t size);
 
 #define MAX_BAT		4
 
+#pragma pack(1)							/* Make sure the structure stays as we defined it */
 typedef struct ppcBAT {
 	unsigned int	upper;	/* Upper half of BAT */
 	unsigned int	lower;	/* Lower half of BAT */
 } ppcBAT;
+#pragma pack()
 
+#pragma pack(1)							/* Make sure the structure stays as we defined it */
 struct shadowBAT {
 	ppcBAT	IBATs[MAX_BAT];	/* Instruction BATs */
 	ppcBAT	DBATs[MAX_BAT];	/* Data BAT */
 };
+#pragma pack()
 
 extern struct shadowBAT shadow_BAT;     
 
diff --git a/osfmk/ppc/misc.c b/osfmk/ppc/misc.c
index 5ed36d0e7..74e307f54 100644
--- a/osfmk/ppc/misc.c
+++ b/osfmk/ppc/misc.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ppc/misc_asm.s b/osfmk/ppc/misc_asm.s
index f4668f2ef..3d6c1974a 100644
--- a/osfmk/ppc/misc_asm.s
+++ b/osfmk/ppc/misc_asm.s
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -47,13 +50,13 @@ ENTRY(getrpc, TAG_NO_FRAME_USED)
 
 /* Mask and unmask interrupts at the processor level */	
 ENTRY(interrupt_disable, TAG_NO_FRAME_USED)
-	mfmsr	r0
-	rlwinm	r0,r0,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-	rlwinm	r0,r0,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-	rlwinm	r0,	r0,	0,	MSR_EE_BIT+1,	MSR_EE_BIT-1
-	mtmsr	r0
-	isync
-	blr
+			lis		r8,hi16(MASK(MSR_VEC))			; Get the vector flag
+			mfmsr	r0								; Save the MSR 
+			ori		r8,r8,lo16(MASK(MSR_EE)|MASK(MSR_FP))	; Add the FP flag
+			andc	r0,r0,r8						; Clear VEC, FP, DR, and EE
+			mtmsr	r0
+			isync
+			blr
 
 ENTRY(interrupt_enable, TAG_NO_FRAME_USED)
 
@@ -70,13 +73,13 @@ ENTRY(interrupt_enable, TAG_NO_FRAME_USED)
 
 /* Mask and unmask interrupts at the processor level */	
 ENTRY(db_interrupt_disable, TAG_NO_FRAME_USED)
-	mfmsr	r0
-	rlwinm	r0,r0,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-	rlwinm	r0,r0,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-	rlwinm	r0,	r0,	0,	MSR_EE_BIT+1,	MSR_EE_BIT-1
-	mtmsr	r0
-	isync
-	blr
+			lis		r8,hi16(MASK(MSR_VEC))			; Get the vector flag
+			mfmsr	r0								; Save the MSR 
+			ori		r8,r8,lo16(MASK(MSR_EE)|MASK(MSR_FP))	; Add the FP flag
+			andc	r0,r0,r8						; Clear VEC, FP, DR, and EE
+			mtmsr	r0
+			isync
+			blr
 
 ENTRY(db_interrupt_enable, TAG_NO_FRAME_USED)
 	mfmsr	r0
@@ -92,11 +95,12 @@ ENTRY(db_interrupt_enable, TAG_NO_FRAME_USED)
  
 ENTRY(Call_Debugger, TAG_NO_FRAME_USED)
 
+
+			lis		r8,hi16(MASK(MSR_VEC))			; Get the vector flag
 			mfmsr	r7				; Get the current MSR
-			rlwinm	r7,r7,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-			rlwinm	r7,r7,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
+			ori		r8,r8,lo16(MASK(MSR_EE)|MASK(MSR_FP))	; Add the FP flag
 			mflr	r0				; Save the return
-			rlwinm	r7,r7,0,MSR_EE_BIT+1,MSR_EE_BIT-1	; Turn off interruptions
+			andc	r7,r7,r8						; Clear VEC and FP
 			mtmsr	r7				; Do it 
 			isync
 			mfsprg	r8,0			; Get the per_proc block
@@ -119,9 +123,11 @@ cdNewDeb:	li		r0,0			; Clear this out
 			
 			bl		EXT(Call_DebuggerC)	; Call the "C" phase of this
 		
-			mfmsr	r0				; Get the MSR just in case it was enabled
+			lis		r8,hi16(MASK(MSR_VEC))			; Get the vector flag
+			mfmsr	r0				; Get the current MSR
+			ori		r8,r8,lo16(MASK(MSR_EE)|MASK(MSR_FP))	; Add the FP flag
 			addi	r1,r1,FM_SIZE	; Pop off first stack frame
-			rlwinm	r0,r0,0,MSR_EE_BIT+1,MSR_EE_BIT-1	; Turn off interruptions enable bit
+			andc	r0,r0,r8		; Turn off all the interesting stuff
 			mtmsr	r0
 		
 			mfsprg	r8,0			; Get the per_proc block address
@@ -189,6 +195,10 @@ ENTRY(mtdec, TAG_NO_FRAME_USED)
 	mtdec	ARG0
 	blr
 
+ENTRY(cntlzw, TAG_NO_FRAME_USED)
+	cntlzw	r3,r3
+	blr
+
 /* Decrementer frequency and realtime|timebase processor registers
  * are different between ppc601 and ppc603/4, we define them all.
  */
@@ -288,3 +298,11 @@ ENTRY(mfsda, TAG_NO_FRAME_USED)
 	mfspr	r3,sda
 	blr
 
+	.globl	EXT(hid0get64)
+	
+LEXT(hid0get64)
+
+	mfspr	r4,hid0					; Get the HID0
+	srdi	r3,r4,32				; Move top down
+	rlwinm	r4,r4,0,0,31			; Clean top
+	blr
diff --git a/osfmk/ppc/misc_protos.h b/osfmk/ppc/misc_protos.h
index 2b22949dc..e32760863 100644
--- a/osfmk/ppc/misc_protos.h
+++ b/osfmk/ppc/misc_protos.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -49,9 +52,10 @@ extern char *strcpy(char *dest, const char *src);
 extern void vprintf(const char *fmt, va_list args);
 extern void printf(const char *fmt, ...);
 
+extern void	bzero_nc(char* buf, int size); /* uncached-safe */
 extern void bcopy_nc(char *from, char *to, int size); /* uncached-safe */
-extern void bcopy_phys(char *from, char *to, int size); /* Physical to physical copy (ints must be disabled) */
-extern void bcopy_physvir(char *from, char *to, int size); /* Physical to physical copy virtually (ints must be disabled) */
+extern void bcopy_phys(addr64_t from, addr64_t to, int size); /* Physical to physical copy (ints must be disabled) */
+extern void bcopy_physvir(addr64_t from, addr64_t to, int size); /* Physical to physical copy virtually (ints must be disabled) */
 
 extern void ppc_init(boot_args *args);
 extern struct savearea *enterDebugger(unsigned int trap,
@@ -59,7 +63,10 @@ extern struct savearea *enterDebugger(unsigned int trap,
 				      unsigned int dsisr);
 
 extern void draw_panic_dialog(void);
-extern void ppc_vm_init(unsigned int mem_size, boot_args *args);
+extern void ppc_vm_init(uint64_t mem_size, boot_args *args);
+
+extern int ppcNull(struct savearea *);
+extern int ppcNullinst(struct savearea *);
 
 extern void autoconf(void);
 extern void machine_init(void);
@@ -72,13 +79,14 @@ extern void interrupt_init(void);
 extern void interrupt_enable(void);
 extern void interrupt_disable(void);
 extern void disable_bluebox_internal(thread_act_t act);
+extern uint64_t hid0get64(void);
 #if	MACH_KDB
 extern void db_interrupt_enable(void);
 extern void db_interrupt_disable(void);
 #endif	/* MACH_KDB */
 
 extern void phys_zero(vm_offset_t, vm_size_t);
-extern void phys_copy(vm_offset_t, vm_offset_t, vm_size_t);
+extern void phys_copy(addr64_t, addr64_t, vm_size_t);
 
 extern void Load_context(thread_t th);
 
@@ -91,6 +99,8 @@ extern void vec_save(struct facility_context *);
 extern void toss_live_fpu(struct facility_context *);
 extern void toss_live_vec(struct facility_context *);
 
+extern void condStop(unsigned int, unsigned int);
+
 extern int nsec_to_processor_clock_ticks(int nsec);
 
 extern void tick_delay(int ticks);
diff --git a/osfmk/ppc/model_dep.c b/osfmk/ppc/model_dep.c
index 05eb00f1f..6d1ae0b7a 100644
--- a/osfmk/ppc/model_dep.c
+++ b/osfmk/ppc/model_dep.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -83,6 +86,7 @@
 #include <ppc/FirmwareCalls.h>
 #include <ppc/setjmp.h>
 #include <ppc/exception.h>
+#include <ppc/hw_perfmon.h>
 
 #include <kern/clock.h>
 #include <kern/debug.h>
@@ -182,6 +186,7 @@ char *failNames[] = {
 	"No saveareas",				/* failNoSavearea */
 	"Savearea corruption",		/* failSaveareaCorr */
 	"Invalid live context",		/* failBadLiveContext */
+	"Unaligned stack",			/* failUnalignedStk */
 	"Unknown failure code"		/* Unknown failure code - must always be last */
 };
 
@@ -189,7 +194,6 @@ char *invxcption = "Unknown code";
 
 extern const char version[];
 extern char *trap_type[];
-extern vm_offset_t mem_actual;
 
 #if !MACH_KDB
 void kdb_trap(int type, struct savearea *regs);
@@ -299,13 +303,14 @@ machine_conf(void)
 {
 	machine_info.max_cpus = NCPUS;
 	machine_info.avail_cpus = 1;
-	machine_info.memory_size = mem_size;
+	machine_info.memory_size = mem_size;	/* Note that this will be 2 GB for >= 2 GB machines */
 }
 
 void
 machine_init(void)
 {
 	clock_config();
+	perfmon_init();
 }
 
 void slave_machine_init(void)
@@ -360,6 +365,7 @@ print_backtrace(struct savearea *ssp)
 	thread_act_t *act;
 	savearea *sv, *svssp;
 	int cpu;
+	savearea *psv;
 
 /*
  *	We need this lock to make sure we don't hang up when we double panic on an MP.
@@ -377,7 +383,7 @@ print_backtrace(struct savearea *ssp)
 	if(current_thread()) sv = (savearea *)current_act()->mact.pcb;	/* Find most current savearea if system has started */
 
 	fence = 0xFFFFFFFF;						/* Show we go all the way */
-	if(sv) fence = sv->save_r1;				/* Stop at previous exception point */
+	if(sv) fence = (unsigned int)sv->save_r1;	/* Stop at previous exception point */
 	
 	if(!svssp) {							/* Should we start from stack? */
 		kdb_printf("Latest stack backtrace for cpu %d:\n", cpu_number());
@@ -392,8 +398,9 @@ print_backtrace(struct savearea *ssp)
 	else {									/* Were we passed an exception? */
 		fence = 0xFFFFFFFF;					/* Show we go all the way */
 		if(svssp->save_hdr.save_prev) {
-			if((svssp->save_hdr.save_prev <= VM_MAX_KERNEL_ADDRESS) && ((unsigned int)LRA(PPC_SID_KERNEL, (void *)svssp->save_hdr.save_prev))) {	/* Valid address? */	
-				fence = svssp->save_hdr.save_prev->save_r1;	/* Stop at previous exception point */
+			if((svssp->save_hdr.save_prev <= vm_last_addr) && ((unsigned int)pmap_find_phys(kernel_pmap, (addr64_t)svssp->save_hdr.save_prev))) {	/* Valid address? */	
+				psv = (savearea *)((unsigned int)svssp->save_hdr.save_prev);	/* Get the 64-bit back chain converted to a regualr pointer */
+				fence = (unsigned int)psv->save_r1;	/* Stop at previous exception point */
 			}
 		}
 	
@@ -411,7 +418,7 @@ print_backtrace(struct savearea *ssp)
 	kdb_printf("Proceeding back via exception chain:\n");
 
 	while(sv) {								/* Do them all... */
-		if(!((sv <= VM_MAX_KERNEL_ADDRESS) && (unsigned int)LRA(PPC_SID_KERNEL, (void *)sv))) {	/* Valid address? */	
+		if(!((sv <= vm_last_addr) && (unsigned int)pmap_find_phys(kernel_pmap, (addr64_t)sv))) {	/* Valid address? */	
 			kdb_printf("   Exception state (sv=0x%08X) Not mapped or invalid. stopping...\n", sv);
 			break;
 		}
@@ -423,14 +430,15 @@ print_backtrace(struct savearea *ssp)
 		else {
 			fence = 0xFFFFFFFF;				/* Show we go all the way */
 			if(sv->save_hdr.save_prev) {
-				if((sv->save_hdr.save_prev <= VM_MAX_KERNEL_ADDRESS) && ((unsigned int)LRA(PPC_SID_KERNEL, (void *)sv->save_hdr.save_prev))) {	/* Valid address? */	
-					fence = sv->save_hdr.save_prev->save_r1;	/* Stop at previous exception point */
+				if((sv->save_hdr.save_prev <= vm_last_addr) && ((unsigned int)pmap_find_phys(kernel_pmap, (addr64_t)sv->save_hdr.save_prev))) {	/* Valid address? */	
+					psv = (savearea *)((unsigned int)sv->save_hdr.save_prev);	/* Get the 64-bit back chain converted to a regualr pointer */
+					fence = (unsigned int)psv->save_r1;	/* Stop at previous exception point */
 				}
 			}
 			dump_savearea(sv, fence);		/* Dump this savearea */	
 		}	
 		
-		sv = sv->save_hdr.save_prev;		/* Back chain */
+		sv = (savearea *)sv->save_hdr.save_prev;	/* Back chain */
 	}
 	
 	kdb_printf("\nKernel version:\n%s\n",version);	/* Print kernel version */
@@ -452,11 +460,11 @@ void dump_savearea(savearea *sv, unsigned int fence) {
 	else xcode = trap_type[sv->save_exception / 4];		/* Point to the type */
 	
 	kdb_printf("      PC=0x%08X; MSR=0x%08X; DAR=0x%08X; DSISR=0x%08X; LR=0x%08X; R1=0x%08X; XCP=0x%08X (%s)\n",
-		sv->save_srr0, sv->save_srr1, sv->save_dar, sv->save_dsisr,
-		sv->save_lr, sv->save_r1, sv->save_exception, xcode);
+		(unsigned int)sv->save_srr0, (unsigned int)sv->save_srr1, (unsigned int)sv->save_dar, sv->save_dsisr,
+		(unsigned int)sv->save_lr, (unsigned int)sv->save_r1, sv->save_exception, xcode);
 	
 	if(!(sv->save_srr1 & MASK(MSR_PR))) {		/* Are we in the kernel? */
-		dump_backtrace(sv->save_r1, fence);		/* Dump the stack back trace from  here if not user state */
+		dump_backtrace((unsigned int)sv->save_r1, fence);	/* Dump the stack back trace from  here if not user state */
 	}
 	
 	return;
@@ -478,23 +486,23 @@ void dump_backtrace(unsigned int stackptr, unsigned int fence) {
 	
 		if(!stackptr || (stackptr == fence)) break;		/* Hit stop point or end... */
 		
-		if(stackptr & 0x0000000f) {				/* Is stack pointer valid? */
+		if(stackptr & 0x0000000F) {				/* Is stack pointer valid? */
 			kdb_printf("\n         backtrace terminated - unaligned frame address: 0x%08X\n", stackptr);	/* No, tell 'em */
 			break;
 		}
 
-		raddr = (unsigned int)LRA(PPC_SID_KERNEL, (void *)stackptr);	/* Get physical frame address */
-		if(!raddr || (stackptr > VM_MAX_KERNEL_ADDRESS)) {		/* Is it mapped? */
+		raddr = (unsigned int)pmap_find_phys(kernel_pmap, (addr64_t)stackptr);	/* Get physical frame address */
+		if(!raddr || (stackptr > vm_last_addr)) {		/* Is it mapped? */
 			kdb_printf("\n         backtrace terminated - frame not mapped or invalid: 0x%08X\n", stackptr);	/* No, tell 'em */
 			break;
 		}
 	
-		if(raddr >= mem_actual) {					/* Is it within physical RAM? */
+		if(!mapping_phys_lookup(raddr, &dumbo)) {	/* Is it within physical RAM? */
 			kdb_printf("\n         backtrace terminated - frame outside of RAM: v=0x%08X, p=%08X\n", stackptr, raddr);	/* No, tell 'em */
 			break;
 		}
 	
-		ReadReal(raddr, &sframe[0]);				/* Fetch the stack frame */
+		ReadReal((addr64_t)((raddr << 12) | (stackptr & 4095)), &sframe[0]);	/* Fetch the stack frame */
 
 		bframes[i] = sframe[LRindex];				/* Save the link register */
 		
@@ -616,11 +624,11 @@ void SysChoked(int type, savearea *sv) {			/* The system is bad dead */
 	disableDebugOuput = FALSE;
 	debug_mode = TRUE;
 
-	failcode = sv->save_r3;							/* Get the failure code */
+	failcode = (unsigned int)sv->save_r3;			/* Get the failure code */
 	if(failcode > failUnknown) failcode = failUnknown;	/* Set unknown code code */
 	
-	kprintf("System Failure: cpu=%d; code=%08X (%s)\n", cpu_number(), sv->save_r3, failNames[failcode]);
-	kdb_printf("System Failure: cpu=%d; code=%08X (%s)\n", cpu_number(), sv->save_r3, failNames[failcode]);
+	kprintf("System Failure: cpu=%d; code=%08X (%s)\n", cpu_number(), (unsigned int)sv->save_r3, failNames[failcode]);
+	kdb_printf("System Failure: cpu=%d; code=%08X (%s)\n", cpu_number(), (unsigned int)sv->save_r3, failNames[failcode]);
 
 	print_backtrace(sv);							/* Attempt to print backtrace */
 	Call_DebuggerC(type, sv);						/* Attempt to get into debugger */
@@ -641,7 +649,8 @@ int Call_DebuggerC(
         struct savearea *saved_state)
 {
 	int				directcall, wait;
-	vm_offset_t		instr_ptr;
+	addr64_t		instr_ptr;
+	ppnum_t			instr_pp;
 	unsigned int 	instr;
 	int 			my_cpu, tcpu;
 
@@ -673,13 +682,16 @@ int Call_DebuggerC(
 		   my_cpu, debugger_is_slave[my_cpu], debugger_cpu, saved_state->save_srr0);
 	}
 	
-	if (instr_ptr = (vm_offset_t)LRA(PPC_SID_KERNEL, (void *)(saved_state->save_srr0))) {
-		instr = ml_phys_read(instr_ptr);				/* Get the trap that caused entry */
+	instr_pp = (vm_offset_t)pmap_find_phys(kernel_pmap, (addr64_t)(saved_state->save_srr0));
+
+	if (instr_pp) {
+		instr_ptr = (addr64_t)(((addr64_t)instr_pp << 12) | (saved_state->save_srr0 & 0xFFF));	/* Make physical address */
+		instr = ml_phys_read_64(instr_ptr);				/* Get the trap that caused entry */
 	} 
 	else instr = 0;
 
 #if 0
-	if (debugger_debug) kprintf("Call_DebuggerC(%d): instr_ptr = %08X, instr = %08X\n", my_cpu, instr_ptr, instr);	/* (TEST/DEBUG) */
+	if (debugger_debug) kprintf("Call_DebuggerC(%d): instr_pp = %08X, instr_ptr = %016llX, instr = %08X\n", my_cpu, instr_pp, instr_ptr, instr);	/* (TEST/DEBUG) */
 #endif
 
 	if (db_breakpoints_inserted) cpus_holding_bkpts++;	/* Bump up the holding count */
diff --git a/osfmk/ppc/movc.s b/osfmk/ppc/movc.s
index cb3188f33..6dee8f87a 100644
--- a/osfmk/ppc/movc.s
+++ b/osfmk/ppc/movc.s
@@ -1,21 +1,24 @@
 /*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -29,558 +32,876 @@
 #include <assym.s>
 #include <sys/errno.h>
 
+#define INSTRUMENT 0
+
+//<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
 /*
  * void pmap_zero_page(vm_offset_t pa)
  *
- * zero a page of physical memory.
+ * Zero a page of physical memory.  This routine runs in 32 or 64-bit mode,
+ * and handles 32 and 128-byte cache lines.
  */
 
-#if DEBUG
-	/* C debug stub in pmap.c calls this */
-ENTRY(pmap_zero_page_assembler, TAG_NO_FRAME_USED)
-#else
-ENTRY(pmap_zero_page, TAG_NO_FRAME_USED)
-#endif /* DEBUG */
-
-		mfmsr	r6								/* Get the MSR */
-		rlwinm	r6,r6,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-		rlwinm	r6,r6,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-		rlwinm	r7,	r6,	0,	MSR_DR_BIT+1,	MSR_DR_BIT-1	/* Turn off DR */
-		rlwinm	r7,r7,0,MSR_EE_BIT+1,MSR_EE_BIT-1	; Disable interruptions
-		li		r4,PPC_PGBYTES-CACHE_LINE_SIZE	/* Point to the end of the page */
-		mtmsr	r7								/* Set MSR to DR off */
-		isync									/* Ensure data translations are off */
-
-
-.L_phys_zero_loop:	
-		subic.	r5,r4,CACHE_LINE_SIZE			/* Point to the next one */
-		dcbz	r4, r3							/* Clear the whole thing to 0s */
-		subi	r4,r5,CACHE_LINE_SIZE			/* Point to the next one */
-		dcbz	r5, r3							/* Clear the next to zeros */
-		bgt+	.L_phys_zero_loop				/* Keep going until we do the page... */
-
-		sync									/* Make sure they're all done */
-		li		r4,PPC_PGBYTES-CACHE_LINE_SIZE	/* Point to the end of the page */
-
-.L_inst_inval_loop:	
-		subic.	r5,r4,CACHE_LINE_SIZE			/* Point to the next one */
-		icbi	r4, r3							/* Clear the whole thing to 0s */
-		subi	r4,r5,CACHE_LINE_SIZE			/* Point to the next one */
-		icbi	r5, r3							/* Clear the next to zeros */
-		bgt+	.L_inst_inval_loop				/* Keep going until we do the page... */
-
-		sync									/* Make sure they're all done */
-
-		mtmsr	r6		/* Restore original translations */
-		isync			/* Ensure data translations are on */
 
-		blr
+		.align	5
+		.globl	EXT(pmap_zero_page)
+
+LEXT(pmap_zero_page)
 
+        mflr	r12								// save return address
+        bl		EXT(ml_set_physical_disabled)	// turn DR and EE off, SF on, get features in r10
+        mtlr	r12								// restore return address
+        andi.	r9,r10,pf32Byte+pf128Byte		// r9 <- cache line size
+
+        subfic	r4,r9,PPC_PGBYTES				// r4 <- starting offset in page
+		
+		bt++	pf64Bitb,page0S4				// Go do the big guys...
+		
+		slwi	r3,r3,12						// get page address from page num
+		b		page_zero_1						// Jump to line aligned loop...
+
+        .align	5
+
+		nop
+		nop
+		nop
+		nop
+		nop
+		nop
+		nop
+		
+page0S4:
+		sldi	r3,r3,12						// get page address from page num
+
+page_zero_1:									// loop zeroing cache lines
+        sub.	r5,r4,r9						// more to go?
+        dcbz128	r3,r4							// zero either 32 or 128 bytes
+        sub		r4,r5,r9						// generate next offset
+        dcbz128	r3,r5
+        bne--	page_zero_1
+        
+        b		EXT(ml_restore)					// restore MSR and do the isync
+
+
+//<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
 /* void
  * phys_copy(src, dst, bytecount)
- *      vm_offset_t     src;
- *      vm_offset_t     dst;
+ *      addr64_t 	    src;
+ *      addr64_t 	    dst;
  *      int             bytecount
  *
  * This routine will copy bytecount bytes from physical address src to physical
- * address dst. 
+ * address dst.  It runs in 64-bit mode if necessary, but does not handle
+ * overlap or make any attempt to be optimal.  Length must be a signed word.
+ * Not performance critical.
  */
 
-ENTRY(phys_copy, TAG_NO_FRAME_USED)
-
-	/* Switch off data translations */
-	mfmsr	r6
-	rlwinm	r6,r6,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-	rlwinm	r6,r6,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-	rlwinm	r7,	r6,	0,	MSR_DR_BIT+1,	MSR_DR_BIT-1
-	rlwinm  r7,     r7,     0,      MSR_EE_BIT+1,   MSR_EE_BIT-1
-	mtmsr	r7
-	isync			/* Ensure data translations are off */
-
-	subi	r3,	r3,	4
-	subi	r4,	r4,	4
-
-	cmpwi	r5,	3
-	ble-	.L_phys_copy_bytes
-.L_phys_copy_loop:
-	lwz	r0,	4(r3)
-	addi	r3,	r3,	4
-	subi	r5,	r5,	4
-	stw	r0,	4(r4)
-	addi	r4,	r4,	4
-	cmpwi	r5,	3
-	bgt+	.L_phys_copy_loop
-
-	/* If no leftover bytes, we're done now */
-	cmpwi	r5,	0
-	beq+	.L_phys_copy_done
-	
-.L_phys_copy_bytes:
-	addi	r3,	r3,	3
-	addi	r4,	r4,	3
-.L_phys_copy_byte_loop:	
-	lbz	r0,	1(r3)
-	addi	r3,	r3,	1
-	subi	r5,	r5,	1
-	stb	r0,	1(r4)
-	addi	r4,	r4,	1
-	cmpwi	r5,	0
-	bne+	.L_phys_copy_byte_loop
-
-.L_phys_copy_done:
-	mtmsr	r6		/* Restore original translations */
-	isync			/* Ensure data translations are off */
-
-	blr
 
+		.align	5
+		.globl	EXT(phys_copy)
+
+LEXT(phys_copy)
+
+		rlwinm	r3,r3,0,1,0					; Duplicate high half of long long paddr into top of reg
+        mflr	r12								// get return address
+		rlwimi	r3,r4,0,0,31				; Combine bottom of long long to full 64-bits
+		rlwinm	r4,r5,0,1,0					; Duplicate high half of long long paddr into top of reg
+        bl		EXT(ml_set_physical_disabled)	// turn DR and EE off, SF on, get features in r10
+		rlwimi	r4,r6,0,0,31				; Combine bottom of long long to full 64-bits
+        mtlr	r12								// restore return address
+        subic.	r5,r7,4							// a word to copy?
+        b		phys_copy_2
+        
+		.align	5
+         
+phys_copy_1:									// loop copying words
+        subic.	r5,r5,4							// more to go?
+        lwz		r0,0(r3)
+        addi	r3,r3,4
+        stw		r0,0(r4)
+        addi	r4,r4,4
+phys_copy_2:
+        bge		phys_copy_1
+        addic.	r5,r5,4							// restore count
+        ble		phys_copy_4						// no more
+        
+        										// Loop is aligned here
+        
+phys_copy_3:									// loop copying bytes
+        subic.	r5,r5,1							// more to go?
+        lbz		r0,0(r3)
+        addi	r3,r3,1
+        stb		r0,0(r4)
+        addi	r4,r4,1
+        bgt		phys_copy_3
+phys_copy_4:        
+        b		EXT(ml_restore)					// restore MSR and do the isync
+
+
+//<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
 /* void
  * pmap_copy_page(src, dst)
- *      vm_offset_t     src;
- *      vm_offset_t     dst;
+ *      ppnum_t     src;
+ *      ppnum_t     dst;
  *
  * This routine will copy the physical page src to physical page dst
  * 
- * This routine assumes that the src and dst are page aligned and that the
- * destination is cached.
- *
- * We also must assume that noone will be executing within the destination
- * page.  We also assume that this will be used for paging
+ * This routine assumes that the src and dst are page numbers and that the
+ * destination is cached.  It runs on 32 and 64 bit processors, with and
+ * without altivec, and with 32 and 128 byte cache lines.
+ * We also must assume that no-one will be executing within the destination
+ * page, and that this will be used for paging.  Because this
+ * is a common routine, we have tuned loops for each processor class.
  *
  */
+#define	kSFSize	(FM_SIZE+160)
 
-#if DEBUG
-	/* if debug, we have a little piece of C around this
-	 * in pmap.c that gives some trace ability
-	 */
-ENTRY(pmap_copy_page_assembler, TAG_NO_FRAME_USED)
-#else
 ENTRY(pmap_copy_page, TAG_NO_FRAME_USED)
-#endif /* DEBUG */
-
-#if 0
-			mfpvr	r9							; Get the PVR
-			rlwinm	r9,r9,16,16,31				; Isolate the PPC processor
-			cmplwi	r9,PROCESSOR_VERSION_Max	; Do we have Altivec?
-			beq+	wegotaltivec				; Yeah...
-#endif
-		
-			mfmsr	r9							; Get the MSR
-			rlwinm	r9,r9,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-			rlwinm	r9,r9,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-			stwu	r1,-(FM_SIZE+32)(r1)		; Make a frame for us
-			rlwinm	r7,r9,0,MSR_EE_BIT+1,MSR_EE_BIT-1	; Disable interruptions
-			ori		r7,r7,lo16(MASK(MSR_FP))	; Turn on the FPU
-			mtmsr	r7							; Disable rupts and enable FPU
-			isync
-		
-			stfd	f0,FM_SIZE+0(r1)			; Save an FP register
-			rlwinm	r7,r7,0,MSR_DR_BIT+1,MSR_DR_BIT-1	; Clear the DDAT bit
-			stfd	f1,FM_SIZE+8(r1)			; Save an FP register
-			addi	r6,r3,PPC_PGBYTES			; Point to the start of the next page
-			stfd	f2,FM_SIZE+16(r1)			; Save an FP register
-			mr		r8,r4						; Save the destination
-			stfd	f3,FM_SIZE+24(r1)			; Save an FP register
-		
-			mtmsr	r7							; Set the new MSR
-			isync								; Ensure data translations are off
-
-			dcbt	br0, r3						/* Start in first input line */
-			li		r5,	CACHE_LINE_SIZE			/* Get the line size */
-
-.L_pmap_copy_page_loop:
-			dcbz	0, r4						/* Allocate a line for the output */
-			lfd		f0, 0(r3)					/* Get first 8 */
-			lfd		f1, 8(r3)					/* Get second 8 */
-			lfd		f2, 16(r3)					/* Get third 8 */
-			stfd	f0, 0(r4)					/* Put first 8 */
-			dcbt	r5, r3						/* Start next line coming in */
-			lfd		f3, 24(r3)					/* Get fourth 8 */
-			stfd	f1,	8(r4)					/* Put second 8 */
-			addi	r3,r3,CACHE_LINE_SIZE		/* Point to the next line in */
-			stfd	f2,	16(r4)					/* Put third 8 */
-			cmplw	cr0,r3,r6					/* See if we're finished yet */
-			stfd	f3,	24(r4)					/* Put fourth 8 */
-			dcbst	br0,r4						/* Force it out */
-			addi	r4,r4,CACHE_LINE_SIZE		/* Point to the next line out */
-			blt+	.L_pmap_copy_page_loop		/* Copy the whole page */
-			
-			sync								/* Make sure they're all done */
-			li		r4,PPC_PGBYTES-CACHE_LINE_SIZE	/* Point to the end of the page */
-
-invalinst:	
-			subic.	r5,r4,CACHE_LINE_SIZE		/* Point to the next one */
-			icbi	r4, r8						/* Trash the i-cache */
-			subi	r4,r5,CACHE_LINE_SIZE		/* Point to the next one */
-			icbi	r5, r8						/* Trash the i-cache */
-			bgt+	invalinst					/* Keep going until we do the page... */
-	
-			rlwimi	r7,r9,0,MSR_DR_BIT,MSR_DR_BIT	; Set DDAT if on
-			sync								; Make sure all invalidates done
-			
-			mtmsr	r7							; Set DDAT correctly
-			isync		
-			
-			lfd		f0,FM_SIZE+0(r1)			; Restore an FP register
-			lfd		f1,FM_SIZE+8(r1)			; Restore an FP register
-			lfd		f2,FM_SIZE+16(r1)			; Restore an FP register
-			lfd		f3,FM_SIZE+24(r1)			; Restore an FP register
-			
-			lwz		r1,0(r1)					; Pop up the stack
-	
-			mtmsr	r9							; Turn off FPU now and maybe rupts back on
-			isync								
-			blr
-		
-#if 0
-;
-;			This is not very optimal.  We just do it here for a test of 
-;			Altivec in the kernel.
-;
-wegotaltivec:
-			mfmsr	r9							; Get the MSR
-			lis		r8,hi16(0xC0000000)			; Make sure we keep the first 2 vector registers
-			rlwinm	r7,r9,0,MSR_EE_BIT+1,MSR_EE_BIT-1	; Disable interruptions
-			lis		r6,lo16(2*256+128)			; Specify 128 blocks of 2 vectors each
-			rlwinm	r7,r7,0,MSR_DR_BIT+1,MSR_DR_BIT-1	; Clear the DDAT bit
-			ori		r6,r6,32					; Set a 32-byte stride
-			mtsprg	256,r8						; Set VRSave
-			mtmsr	r7							; Disable rupts and turn xlate off
-			isync
-	
-			addi	r11,r3,4096					; Point to the next page
-			li		r10,16						; Get vector size
-
-avmovepg:	lvxl	v0,br0,r3					; Get first half of line
-			dcba	br0,r4						; Allocate output
-			lvxl	v1,r10,r3					; Get second half of line
-			stvxl	v0,br0,r4					; Save first half of line
-			addi	r3,r3,32					; Point to the next line
-			icbi	br0,r4						; Make the icache go away also
-			stvxl	v1,r10,r4					; Save second half of line
-			cmplw	r3,r11						; Have we reached the next page?
-			dcbst	br0,r4						; Make sure the line is on its way out
-			addi	r4,r4,32					; Point to the next line
-			blt+	avmovepg					; Move the next line...
-			
-			li		r8,0						; Clear this
-			sync								; Make sure all the memory stuff is done
-			mtsprg	256,r8						; Show we are not using VRs any more
-			mtmsr	r9							; Translation and interruptions back on
-			isync
-			blr
-#endif
-		
-
-	
-
-/*
- * int
- * copyin(src, dst, count)
- *	vm_offset_t	src;
- *	vm_offset_t	dst;
- *	int		count;
- *
- */
-
-ENTRY2(copyin, copyinmsg, TAG_NO_FRAME_USED)
-
-/* Preamble allowing us to call a sub-function */
-		mflr	r0
-		stw		r0,FM_LR_SAVE(r1)
-		stwu	r1,-(FM_SIZE+16)(r1)
-		
-		cmpli	cr0,r5,0
-		ble-	cr0,.L_copyinout_trivial
 
-/* we know we have a valid copyin to do now */
-/* Set up thread_recover in case we hit an illegal address */
+		lis		r2,hi16(MASK(MSR_VEC))			; Get the vector flag
+        mflr	r0								// get return
+ 		ori		r2,r2,lo16(MASK(MSR_FP))		; Add the FP flag
+		stw		r0,8(r1)						// save
+        stwu	r1,-kSFSize(r1)					// set up a stack frame for VRs or FPRs
+        mfmsr	r11								// save MSR at entry
+        mfsprg	r10,2							// get feature flags
+        andc	r11,r11,r2						// Clear out vec and fp
+        ori		r2,r2,lo16(MASK(MSR_EE))		// Get EE on also
+        andc	r2,r11,r2						// Clear out EE as well
+        mtcrf	0x02,r10						// we need to test pf64Bit
+        ori		r2,r2,MASK(MSR_FP)				// must enable FP for G3...
+        mtcrf	0x80,r10						// we need to test pfAltivec too
+        oris	r2,r2,hi16(MASK(MSR_VEC))		// enable altivec for G4 (ignored if G3)
+        mtmsr	r2								// turn EE off, FP and VEC on
+        isync
+        bt++	pf64Bitb,pmap_copy_64			// skip if 64-bit processor (only they take hint)
+ 		slwi	r3,r3,12						// get page address from page num
+		slwi	r4,r4,12						// get page address from page num
+        rlwinm	r12,r2,0,MSR_DR_BIT+1,MSR_DR_BIT-1	// get ready to turn off DR
+        bt		pfAltivecb,pmap_copy_g4			// altivec but not 64-bit means G4
+        
+        
+        // G3 -- copy using FPRs
+        
+        stfd	f0,FM_SIZE+0(r1)				// save the 4 FPRs we use to copy
+        stfd	f1,FM_SIZE+8(r1)
+        li		r5,PPC_PGBYTES/32				// count of cache lines in a page
+        stfd	f2,FM_SIZE+16(r1)
+        mtctr	r5
+        stfd	f3,FM_SIZE+24(r1)
+        mtmsr	r12								// turn off DR after saving FPRs on stack
+        isync
+        
+pmap_g3_copy_loop:								// loop over 32-byte cache lines
+        dcbz	0,r4							// avoid read of dest line
+        lfd		f0,0(r3)
+        lfd		f1,8(r3)
+        lfd		f2,16(r3)
+        lfd		f3,24(r3)
+        addi	r3,r3,32
+        stfd	f0,0(r4)
+        stfd	f1,8(r4)
+        stfd	f2,16(r4)
+        stfd	f3,24(r4)
+        dcbst	0,r4							// flush dest line to RAM
+        addi	r4,r4,32
+        bdnz	pmap_g3_copy_loop
+        
+        sync									// wait for stores to take
+        subi	r4,r4,PPC_PGBYTES				// restore ptr to destintation page
+        li		r6,PPC_PGBYTES-32				// point to last line in page
+pmap_g3_icache_flush:
+        subic.	r5,r6,32						// more to go?
+        icbi	r4,r6							// flush another line in icache
+        subi	r6,r5,32						// get offset to next line
+        icbi	r4,r5
+        bne		pmap_g3_icache_flush
+        
+        sync
+        mtmsr	r2								// turn DR back on
+        isync
+        lfd		f0,FM_SIZE+0(r1)				// restore the FPRs
+        lfd		f1,FM_SIZE+8(r1)
+        lfd		f2,FM_SIZE+16(r1)
+        lfd		f3,FM_SIZE+24(r1)        
+        
+        b		pmap_g4_restore					// restore MSR and done
+
+        
+        // G4 -- copy using VRs
+
+pmap_copy_g4:									// r2=(MSR-EE), r12=(r2-DR), r10=features, r11=old MSR
+        la		r9,FM_SIZE+16(r1)				// place where we save VRs to r9
+        li		r5,16							// load x-form offsets into r5-r9
+        li		r6,32							// another offset
+        stvx	v0,0,r9							// save some VRs so we can use to copy
+        li		r7,48							// another offset
+        stvx	v1,r5,r9
+        li		r0,PPC_PGBYTES/64				// we loop over 64-byte chunks
+        stvx	v2,r6,r9
+        mtctr	r0
+        li		r8,96							// get look-ahead for touch
+        stvx	v3,r7,r9
+        li		r9,128
+        mtmsr	r12								// now we've saved VRs on stack, turn off DR
+        isync									// wait for it to happen
+        b		pmap_g4_copy_loop
+        
+        .align	5								// align inner loops
+pmap_g4_copy_loop:								// loop over 64-byte chunks
+        dcbt	r3,r8							// touch 3 lines ahead
+        nop										// avoid a 17-word loop...
+        dcbt	r3,r9							// touch 4 lines ahead
+        nop										// more padding
+        dcba	0,r4							// avoid pre-fetch of 1st dest line
+        lvx		v0,0,r3							// offset 0
+        lvx		v1,r5,r3						// offset 16
+        lvx		v2,r6,r3						// offset 32
+        lvx		v3,r7,r3						// offset 48
+        addi	r3,r3,64
+        dcba	r6,r4							// avoid pre-fetch of 2nd line
+        stvx	v0,0,r4							// offset 0
+        stvx	v1,r5,r4						// offset 16
+        stvx	v2,r6,r4						// offset 32
+        stvx	v3,r7,r4						// offset 48
+        dcbf	0,r4							// push line 1
+        dcbf	r6,r4							// and line 2
+        addi	r4,r4,64
+        bdnz	pmap_g4_copy_loop
+
+        sync									// wait for stores to take
+        subi	r4,r4,PPC_PGBYTES				// restore ptr to destintation page
+        li		r8,PPC_PGBYTES-32				// point to last line in page
+pmap_g4_icache_flush:
+        subic.	r9,r8,32						// more to go?
+        icbi	r4,r8							// flush from icache
+        subi	r8,r9,32						// get offset to next line
+        icbi	r4,r9
+        bne		pmap_g4_icache_flush
+        
+        sync
+        mtmsr	r2								// turn DR back on
+        isync
+        la		r9,FM_SIZE+16(r1)				// get base of VR save area
+        lvx		v0,0,r9							// restore the VRs
+        lvx		v1,r5,r9
+        lvx		v2,r6,r9
+        lvx		v3,r7,r9        
+        
+pmap_g4_restore:								// r11=MSR
+        mtmsr	r11								// turn EE on, VEC and FR off
+        isync									// wait for it to happen
+        addi	r1,r1,kSFSize					// pop off our stack frame
+        lwz		r0,8(r1)						// restore return address
+        mtlr	r0
+        blr
+        
+        
+        // 64-bit/128-byte processor: copy using VRs
+        
+pmap_copy_64:									// r10=features, r11=old MSR
+ 		sldi	r3,r3,12						// get page address from page num
+		sldi	r4,r4,12						// get page address from page num
+		la		r9,FM_SIZE+16(r1)				// get base of VR save area
+        li		r5,16							// load x-form offsets into r5-r9
+        li		r6,32							// another offset
+        bf		pfAltivecb,pmap_novmx_copy		// altivec suppressed...
+        stvx	v0,0,r9							// save 8 VRs so we can copy wo bubbles
+        stvx	v1,r5,r9
+        li		r7,48							// another offset
+        li		r0,PPC_PGBYTES/128				// we loop over 128-byte chunks
+        stvx	v2,r6,r9
+        stvx	v3,r7,r9
+        addi	r9,r9,64						// advance base ptr so we can store another 4
+        mtctr	r0
+        li		r0,MASK(MSR_DR)					// get DR bit
+        stvx	v4,0,r9
+        stvx	v5,r5,r9
+        andc	r12,r2,r0						// turn off DR bit
+        li		r0,1							// get a 1 to slam into SF
+        stvx	v6,r6,r9
+        stvx	v7,r7,r9
+        rldimi	r12,r0,63,MSR_SF_BIT			// set SF bit (bit 0)
+        li		r8,-128							// offset so we can reach back one line
+        mtmsrd	r12								// now we've saved VRs, turn DR off and SF on
+        isync									// wait for it to happen
+        dcbt128	0,r3,1							// start a forward stream
+        b		pmap_64_copy_loop
+        
+        .align	5								// align inner loops
+pmap_64_copy_loop:								// loop over 128-byte chunks
+        dcbz128	0,r4							// avoid read of destination line
+        lvx		v0,0,r3							// offset 0
+        lvx		v1,r5,r3						// offset 16
+        lvx		v2,r6,r3						// offset 32
+        lvx		v3,r7,r3						// offset 48
+        addi	r3,r3,64						// don't have enough GPRs so add 64 2x
+        lvx		v4,0,r3							// offset 64
+        lvx		v5,r5,r3						// offset 80
+        lvx		v6,r6,r3						// offset 96
+        lvx		v7,r7,r3						// offset 112
+        addi	r3,r3,64
+        stvx	v0,0,r4							// offset 0
+        stvx	v1,r5,r4						// offset 16
+        stvx	v2,r6,r4						// offset 32
+        stvx	v3,r7,r4						// offset 48
+        addi	r4,r4,64
+        stvx	v4,0,r4							// offset 64
+        stvx	v5,r5,r4						// offset 80
+        stvx	v6,r6,r4						// offset 96
+        stvx	v7,r7,r4						// offset 112
+        addi	r4,r4,64
+        dcbf	r8,r4							// flush the line we just wrote
+        bdnz	pmap_64_copy_loop
+
+        sync									// wait for stores to take
+        subi	r4,r4,PPC_PGBYTES				// restore ptr to destintation page
+        li		r8,PPC_PGBYTES-128				// point to last line in page
+pmap_64_icache_flush:
+        subic.	r9,r8,128						// more to go?
+        icbi	r4,r8							// flush from icache
+        subi	r8,r9,128						// get offset to next line
+        icbi	r4,r9
+        bne		pmap_64_icache_flush
+        
+        sync
+        mtmsrd	r2								// turn DR back on, SF off
+        isync
+        la		r9,FM_SIZE+16(r1)				// get base address of VR save area on stack
+        lvx		v0,0,r9							// restore the VRs
+        lvx		v1,r5,r9
+        lvx		v2,r6,r9
+        lvx		v3,r7,r9
+        addi	r9,r9,64        
+        lvx		v4,0,r9
+        lvx		v5,r5,r9
+        lvx		v6,r6,r9
+        lvx		v7,r7,r9
+
+        b		pmap_g4_restore					// restore lower half of MSR and return
+
+ //
+ //		Copy on 64-bit without VMX
+ //
+
+pmap_novmx_copy:        
+		li		r0,PPC_PGBYTES/128				// we loop over 128-byte chunks
+		mtctr	r0
+		li		r0,MASK(MSR_DR)					// get DR bit
+		andc	r12,r2,r0						// turn off DR bit
+		li		r0,1							// get a 1 to slam into SF
+		rldimi	r12,r0,63,MSR_SF_BIT			// set SF bit (bit 0)
+		mtmsrd	r12								// now we've saved VRs, turn DR off and SF on
+		isync									// wait for it to happen
+		dcbt128	0,r3,1							// start a forward stream 
+       
+pmap_novmx_copy_loop:							// loop over 128-byte cache lines
+        dcbz128	0,r4							// avoid read of dest line
+        
+        ld		r0,0(r3)						// Load half a line
+        ld		r12,8(r3)
+        ld		r5,16(r3)
+        ld		r6,24(r3)
+        ld		r7,32(r3)
+        ld		r8,40(r3)
+        ld		r9,48(r3)
+        ld		r10,56(r3)
+        
+        std		r0,0(r4)						// Store half a line
+        std		r12,8(r4)
+        std		r5,16(r4)
+        std		r6,24(r4)
+        std		r7,32(r4)
+        std		r8,40(r4)
+        std		r9,48(r4)
+        std		r10,56(r4)
+        
+        ld		r0,64(r3)						// Load half a line
+        ld		r12,72(r3)
+        ld		r5,80(r3)
+        ld		r6,88(r3)
+        ld		r7,96(r3)
+        ld		r8,104(r3)
+        ld		r9,112(r3)
+        ld		r10,120(r3)
+        
+        addi	r3,r3,128
+ 
+        std		r0,64(r4)						// Store half a line
+        std		r12,72(r4)
+        std		r5,80(r4)
+        std		r6,88(r4)
+        std		r7,96(r4)
+        std		r8,104(r4)
+        std		r9,112(r4)
+        std		r10,120(r4)
+        
+        dcbf	0,r4							// flush the line we just wrote
+		addi	r4,r4,128
+        bdnz	pmap_novmx_copy_loop
+
+        sync									// wait for stores to take
+        subi	r4,r4,PPC_PGBYTES				// restore ptr to destintation page
+        li		r8,PPC_PGBYTES-128				// point to last line in page
+
+pmap_novmx_icache_flush:
+        subic.	r9,r8,128						// more to go?
+        icbi	r4,r8							// flush from icache
+        subi	r8,r9,128						// get offset to next line
+        icbi	r4,r9
+        bne		pmap_novmx_icache_flush
+        
+        sync
+        mtmsrd	r2								// turn DR back on, SF off
+        isync
+
+        b		pmap_g4_restore					// restore lower half of MSR and return
+
+
+
+//<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>	
 		
-		mfsprg  r8,1							/* Get the current act */ 
-		lwz		r10,ACT_THREAD(r8)
-		lis		r11,hi16(.L_copyinout_error)
-		lwz		r8,ACT_VMMAP(r8)
-		ori		r11,r11,lo16(.L_copyinout_error)
-		add		r9,r3,r5						/* Get the end of the source */
-		lwz		r8,VMMAP_PMAP(r8)				; Get the pmap
-		rlwinm	r12,r3,6,26,29					; Get index to the segment slot
-		subi	r9,r9,1							/* Make sure we don't go too far */
-		add		r8,r8,r12						; Start indexing to the segment value
-		stw		r11,THREAD_RECOVER(r10)
-		xor		r9,r9,r3						/* Smoosh 'em together */
-		lwz		r8,PMAP_SEGS(r8)				; Get the source SR value
-		rlwinm.	r9,r9,0,1,3						/* Top nybble equal? */
-		mtsr	SR_COPYIN,r8					; Set the SR
-		isync
-#if 0
-		lis		r0,HIGH_ADDR(EXT(dbgRegsCall))	/* (TEST/DEBUG) */	
-		ori		r0,r0,LOW_ADDR(EXT(dbgRegsCall))	/* (TEST/DEBUG) */	
-		sc										/* (TEST/DEBUG) */
-#endif
-	
-/* For optimization, we check if the copyin lies on a segment
- * boundary. If it doesn't, we can use a simple copy. If it
- * does, we split it into two separate copies in some C code.
- */
-	
-		bne-	.L_call_copyin_multiple			/* Nope, we went past the segment boundary... */
-
-		rlwinm	r3,r3,0,4,31
-		oris	r3,r3,(SR_COPYIN_NUM << (28-16))	/* Set the copyin segment as the source */
-	
-		bl		EXT(bcopy)
-		
-/* Now that copyin is done, we don't need a recovery point */
-
-		addi	r1,r1,FM_SIZE+16
-		mfsprg  r6,1							/* Get the current act */ 
-		lwz		r10,ACT_THREAD(r6)
-		li		r3,0
-		lwz		r0,FM_LR_SAVE(r1)
-		stw		r3,THREAD_RECOVER(r10)			/* Clear recovery */
-		mtlr	r0
-		blr
-	
-/* we get here via the exception handler if an illegal
- * user memory reference was made.
- */
-.L_copyinout_error:
-
-/* Now that copyin is done, we don't need a recovery point */
-	
-		mfsprg  r6,1							/* Get the current act */ 
-		addi	r1,r1,FM_SIZE+16
-		lwz		r10,ACT_THREAD(r6)
-		li		r4,0
-		lwz		r0,FM_LR_SAVE(r1)
-		stw		r4,THREAD_RECOVER(r10)			/* Clear recovery */
-		mtlr	r0
-		li		r3,EFAULT							; Indicate error (EFAULT) 
-		blr
-
-.L_copyinout_trivial:
-	/* The copyin/out was for either 0 bytes or a negative
-	 * number of bytes, return an appropriate value (0 == SUCCESS).
-	 * cr0 still contains result of comparison of len with 0.
-	 */
-	li	r3,	0
-	beq+	cr0,	.L_copyinout_negative
-	li	r3,	1
-.L_copyinout_negative:
-
-	/* unwind the stack */
-	addi	r1,	r1,	FM_SIZE+16
-	lwz	r0,	FM_LR_SAVE(r1)
-	mtlr	r0
-
-	blr
-
-.L_call_copyin_multiple:
-
-	/* unwind the stack */
-	addi	r1,	r1,	FM_SIZE+16
-	lwz	r0,	FM_LR_SAVE(r1)
-	mtlr	r0
-
-	b	EXT(copyin_multiple)				/* not a call - a jump! */
-
+// Stack frame format used by copyin, copyout, copyinstr and copyoutstr.
+// These routines all run both on 32 and 64-bit machines, though because they are called
+// by the BSD kernel they are always in 32-bit mode when entered.  The mapped ptr returned
+// by MapUserAddressSpace will be 64 bits however on 64-bit machines.  Beware to avoid
+// using compare instructions on this ptr.  This mapped ptr is kept globally in r31, so there
+// is no need to store or load it, which are mode-dependent operations since it could be
+// 32 or 64 bits.
+
+#define	kkFrameSize	(FM_SIZE+32)
+
+#define	kkBufSize	(FM_SIZE+0)
+#define	kkCR		(FM_SIZE+4)
+#define	kkSource	(FM_SIZE+8)
+#define	kkDest		(FM_SIZE+12)
+#define	kkCountPtr	(FM_SIZE+16)
+#define	kkR31Save	(FM_SIZE+20)
+ 
+ 
+// nonvolatile CR bits we use as flags in cr3
+
+#define	kk64bit		12
+#define	kkNull		13
+#define	kkIn		14
+#define	kkString	15
+#define	kkZero		15
+
+
+//<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
 /*
  * int
- * copyout(src, dst, count)
+ * copyoutstr(src, dst, maxcount, count)
  *	vm_offset_t	src;
  *	vm_offset_t	dst;
- *	int		count;
+ *	vm_size_t	maxcount; 
+ *	vm_size_t*	count;
  *
+ * Set *count to the number of bytes copied.
  */
 
-ENTRY2(copyout, copyoutmsg, TAG_NO_FRAME_USED)
+ENTRY(copyoutstr, TAG_NO_FRAME_USED)
+        mfcr	r2								// we use nonvolatile cr3
+        li		r0,0
+        crset	kkString						// flag as a string op
+        mr		r10,r4							// for copyout, dest ptr (r4) is in user space
+        stw		r0,0(r6)						// initialize #bytes moved
+        crclr	kkIn							// flag as copyout
+        b		copyJoin
 
-/* Preamble allowing us to call a sub-function */
-
-		mflr	r0
-		stw		r0,FM_LR_SAVE(r1)
-		stwu	r1,-(FM_SIZE+16)(r1)
-		
-#if 0
-		stw		r3,FM_SIZE+0(r1)				/* (TEST/DEBUG) */
-		stw		r4,FM_SIZE+4(r1)				/* (TEST/DEBUG) */
-		stw		r5,FM_SIZE+8(r1)				/* (TEST/DEBUG) */
-		mr		r6,r0							/* (TEST/DEBUG) */
-		
-		bl		EXT(tracecopyout)				/* (TEST/DEBUG) */
-		
-		lwz		r3,FM_SIZE+0(r1)				/* (TEST/DEBUG) */
-		lwz		r4,FM_SIZE+4(r1)				/* (TEST/DEBUG) */
-		lwz		r5,FM_SIZE+8(r1)				/* (TEST/DEBUG) */
-#endif
-	
-		cmpli	cr0,r5,0
-		ble-	cr0,.L_copyinout_trivial
-/* we know we have a valid copyout to do now */
-/* Set up thread_recover in case we hit an illegal address */
-		
-
-		mfsprg  r8,1							/* Get the current act */
-		lwz		r10,ACT_THREAD(r8)
-		lis		r11,HIGH_ADDR(.L_copyinout_error)
-		lwz		r8,ACT_VMMAP(r8)
-		rlwinm	r12,r4,6,26,29					; Get index to the segment slot
-		ori		r11,r11,LOW_ADDR(.L_copyinout_error)
-		add		r9,r4,r5						/* Get the end of the destination */
-		lwz		r8,VMMAP_PMAP(r8)
-		subi	r9,r9,1							/* Make sure we don't go too far */
-		add		r8,r8,r12						; Start indexing to the segment value
-		stw		r11,THREAD_RECOVER(r10)
-		xor		r9,r9,r4						/* Smoosh 'em together */
-		lwz		r8,PMAP_SEGS(r8)				; Get the source SR value
-		rlwinm.	r9,r9,0,1,3						/* Top nybble equal? */
-		mtsr	SR_COPYIN,r8
-		isync
-	
-	
-/* For optimisation, we check if the copyout lies on a segment
- * boundary. If it doesn't, we can use a simple copy. If it
- * does, we split it into two separate copies in some C code.
- */
-	
-		bne-	.L_call_copyout_multiple		/* Nope, we went past the segment boundary... */
-
-		rlwinm	r4,r4,0,4,31
-		oris	r4,r4,(SR_COPYIN_NUM << (28-16))	/* Set the copyin segment as the source */
-	
-		bl	EXT(bcopy)
-		
-/* Now that copyout is done, we don't need a recovery point */
-		mfsprg  r6,1							/* Get the current act */
-		addi	r1,r1,FM_SIZE+16
-		lwz		r10,ACT_THREAD(r6)
-		li		r3,0
-		lwz		r0,FM_LR_SAVE(r1)
-		stw		r3,THREAD_RECOVER(r10)			/* Clear recovery */
-		mtlr	r0
-		blr
-
-.L_call_copyout_multiple:
-	/* unwind the stack */
-	addi	r1,	r1,	FM_SIZE+16
-	lwz	r0,	FM_LR_SAVE(r1)
-	mtlr	r0
-
-	b	EXT(copyout_multiple)					/* not a call - a jump! */
 
+//<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
 /*
- * boolean_t
- * copyinstr(src, dst, count, maxcount)
+ * int
+ * copyinstr(src, dst, maxcount, count)
  *	vm_offset_t	src;
  *	vm_offset_t	dst;
  *	vm_size_t	maxcount; 
  *	vm_size_t*	count;
  *
  * Set *count to the number of bytes copied
- * 
  * If dst == NULL, don't copy, just count bytes.
  * Only currently called from klcopyinstr. 
  */
 
 ENTRY(copyinstr, TAG_NO_FRAME_USED)
-
-/* Preamble allowing us to call a sub-function */
-		mflr	r0
-		stw		r0,FM_LR_SAVE(r1)
-		stwu	r1,-(FM_SIZE+16)(r1)
-
-#if 0
-		stw		r3,FM_SIZE+0(r1)				/* (TEST/DEBUG) */
-		stw		r4,FM_SIZE+4(r1)				/* (TEST/DEBUG) */
-		stw		r5,FM_SIZE+8(r1)				/* (TEST/DEBUG) */
-		stw		r6,FM_SIZE+12(r1)				/* (TEST/DEBUG) */
-		mr		r7,r0							/* (TEST/DEBUG) */
-		
-		bl		EXT(tracecopystr)				/* (TEST/DEBUG) */
-		
-		lwz		r3,FM_SIZE+0(r1)				/* (TEST/DEBUG) */
-		lwz		r4,FM_SIZE+4(r1)				/* (TEST/DEBUG) */
-		lwz		r5,FM_SIZE+8(r1)				/* (TEST/DEBUG) */
-		stw		r6,FM_SIZE+12(r1)				/* (TEST/DEBUG) */
-#endif
-				
-		cmpli	cr0,r5,0
-		ble-	cr0,.L_copyinout_trivial
-
-/* we know we have a valid copyin to do now */
-/* Set up thread_recover in case we hit an illegal address */
-		
-		li		r0,0							
-		mfsprg  r8,1							/* Get the current act */
-		lwz		r10,ACT_THREAD(r8)
-		stw		r0,0(r6)						/* Clear result length */
-		lis		r11,HIGH_ADDR(.L_copyinout_error)
-		lwz		r8,ACT_VMMAP(r8)				; Get the map for this activation
-		rlwinm	r12,r3,6,26,29					; Get index to the segment slot
-		lwz		r8,VMMAP_PMAP(r8)
-		ori		r11,r11,LOW_ADDR(.L_copyinout_error)
-		add		r8,r8,r12						; Start indexing to the segment value
-		stw		r11,THREAD_RECOVER(r10)
-		rlwinm	r3,r3,0,4,31
-		lwz		r7,PMAP_SEGS(r8)				; Get the source SR value
-		oris	r3,r3,(SR_COPYIN_NUM << (28-16))	/* Set the copyin segment as the source */
-
-/* Copy byte by byte for now - TODO NMGS speed this up with
- * some clever (but fairly standard) logic for word copies.
- * We don't use a copyinstr_multiple since copyinstr is called
- * with INT_MAX in the linux server. Eugh.
+        mfcr	r2								// we use nonvolatile cr3
+        cmplwi	r4,0							// dst==NULL?
+        li		r0,0
+        crset	kkString						// flag as a string op
+        mr		r10,r3							// for copyin, source ptr (r3) is in user space
+        crmove	kkNull,cr0_eq					// remember if (dst==NULL)
+        stw		r0,0(r6)						// initialize #bytes moved
+        crset	kkIn							// flag as copyin (rather than copyout)
+        b		copyJoin1						// skip over the "crclr kkNull"
+
+
+//<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
+/*
+ * int
+ * copyout(src, dst, count)
+ *	vm_offset_t	src;
+ *	vm_offset_t	dst;
+ *	size_t		count;
  */
 
-		li		r9,0							/* Clear byte counter */
-
-/* If the destination is NULL, don't do writes,
- * just count bytes. We set CR7 outside the loop to save time
+			.align	5
+			.globl	EXT(copyout)
+			.globl	EXT(copyoutmsg)
+
+LEXT(copyout)
+LEXT(copyoutmsg)
+
+#if INSTRUMENT
+			mfspr	r12,pmc1						; INSTRUMENT - saveinstr[12] - Take stamp at copyout
+			stw		r12,0x6100+(12*16)+0x0(0)		; INSTRUMENT - Save it
+			mfspr	r12,pmc2						; INSTRUMENT - Get stamp
+			stw		r12,0x6100+(12*16)+0x4(0)		; INSTRUMENT - Save it
+			mfspr	r12,pmc3						; INSTRUMENT - Get stamp
+			stw		r12,0x6100+(12*16)+0x8(0)		; INSTRUMENT - Save it
+			mfspr	r12,pmc4						; INSTRUMENT - Get stamp
+			stw		r12,0x6100+(12*16)+0xC(0)		; INSTRUMENT - Save it
+#endif			
+        mfcr	r2								// save caller's CR
+        crclr	kkString						// not a string version
+        mr		r10,r4							// dest (r4) is user-space ptr
+        crclr	kkIn							// flag as copyout
+        b		copyJoin
+        
+
+//<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
+/*
+ * int
+ * copyin(src, dst, count)
+ *	vm_offset_t	src;
+ *	vm_offset_t	dst;
+ *	size_t		count;
  */
-		cmpwi	cr7,r4,0						/* Is the destination null? */
-		
-nxtseg:	mtsr	SR_COPYIN,r7					/* Set the source SR */
-		isync
 
-.L_copyinstr_loop:
-		lbz		r0,0(r3)						/* Get the source */
-		addic.	r5,r5,-1						/* Have we gone far enough? */
-		addi	r3,r3,1							/* Bump source pointer */
-		
-		cmpwi	cr1,r0,0						/* Did we hit a null? */
 
-		beq		cr7,.L_copyinstr_no_store		/* If we are just counting, skip the store... */
-	
-		stb		r0,0(r4)						/* Move to sink */
-		addi	r4,r4,1							/* Advance sink pointer */
+			.align	5
+			.globl	EXT(copyin)
+			.globl	EXT(copyinmsg)
+
+LEXT(copyin)
+LEXT(copyinmsg)
+
+        mfcr	r2								// save caller's CR
+        crclr	kkString						// not a string version
+        mr		r10,r3							// source (r3) is user-space ptr in copyin
+        crset	kkIn							// flag as copyin
+        
+        
+// Common code to handle setup for all the copy variants:
+//		r2 = caller's CR, since we use cr3
+//   r3-r6 = parameters
+//	   r10 = user-space ptr (r3 if copyin, r4 if copyout)
+//     cr3 = kkIn, kkString, kkNull flags
+
+copyJoin:
+        crclr	kkNull							// (dst==NULL) convention not used with this call
+copyJoin1:										// enter from copyinstr with kkNull set
+		mflr	r0								// get return address
+        cmplwi	r5,0							// buffer length 0?
+        lis		r9,0x1000						// r9 <- 0x10000000 (256MB)
+		stw		r0,FM_LR_SAVE(r1)				// save return
+        cmplw	cr1,r5,r9						// buffer length > 256MB ?
+        mfsprg	r8,2							// get the features
+        beq--	copyinout_0						// 0 length is degenerate case
+		stwu	r1,-kkFrameSize(r1)				// set up stack frame
+        stw		r2,kkCR(r1)						// save caller's CR since we use cr3
+        mtcrf	0x02,r8							// move pf64Bit to cr6
+        stw		r3,kkSource(r1)					// save args across MapUserAddressSpace
+        stw		r4,kkDest(r1)
+        stw		r5,kkBufSize(r1)
+        crmove	kk64bit,pf64Bitb				// remember if this is a 64-bit processor
+        stw		r6,kkCountPtr(r1)
+        stw		r31,kkR31Save(r1)				// we use r31 globally for mapped user ptr
+        li		r31,0							// no mapped ptr yet
+        
+        
+// Handle buffer length > 256MB.  This is an error (ENAMETOOLONG) on copyin and copyout.
+// The string ops are passed -1 lengths by some BSD callers, so for them we silently clamp
+// the buffer length to 256MB.  This isn't an issue if the string is less than 256MB
+// (as most are!), but if they are >256MB we eventually return ENAMETOOLONG.  This restriction
+// is due to MapUserAddressSpace; we don't want to consume more than two segments for
+// the mapping. 
+
+        ble++	cr1,copyin0						// skip if buffer length <= 256MB
+        bf		kkString,copyinout_too_big		// error if not string op
+        mr		r5,r9							// silently clamp buffer length to 256MB
+        stw		r9,kkBufSize(r1)				// update saved copy too
+
+
+// Set up thread_recover in case we hit an illegal address.
+
+copyin0:
+		mfsprg  r8,1							/* Get the current act */ 
+		lis		r2,hi16(copyinout_error)
+		lwz		r7,ACT_THREAD(r8)
+		ori		r2,r2,lo16(copyinout_error)
+		lwz		r3,ACT_VMMAP(r8)				// r3 <- vm_map virtual address
+		stw		r2,THREAD_RECOVER(r7)
+
+
+// Map user segment into kernel map, turn on 64-bit mode.
+//		r3 = vm map
+//		r5 = buffer length
+//	   r10 = user space ptr (r3 if copyin, r4 if copyout)
+        
+		mr		r6,r5							// Set length to map
+		li		r4,0							// Note: we only do this 32-bit for now
+        mr		r5,r10							// arg2 <- user space ptr
+#if INSTRUMENT
+			mfspr	r12,pmc1						; INSTRUMENT - saveinstr[13] - Take stamp before mapuseraddressspace
+			stw		r12,0x6100+(13*16)+0x0(0)		; INSTRUMENT - Save it
+			mfspr	r12,pmc2						; INSTRUMENT - Get stamp
+			stw		r12,0x6100+(13*16)+0x4(0)		; INSTRUMENT - Save it
+			mfspr	r12,pmc3						; INSTRUMENT - Get stamp
+			stw		r12,0x6100+(13*16)+0x8(0)		; INSTRUMENT - Save it
+			mfspr	r12,pmc4						; INSTRUMENT - Get stamp
+			stw		r12,0x6100+(13*16)+0xC(0)		; INSTRUMENT - Save it
+#endif			
+        bl		EXT(MapUserAddressSpace)		// set r3 <- address in kernel map of user operand
+#if INSTRUMENT
+			mfspr	r12,pmc1						; INSTRUMENT - saveinstr[14] - Take stamp after mapuseraddressspace
+			stw		r12,0x6100+(14*16)+0x0(0)		; INSTRUMENT - Save it
+			mfspr	r12,pmc2						; INSTRUMENT - Get stamp
+			stw		r12,0x6100+(14*16)+0x4(0)		; INSTRUMENT - Save it
+			mfspr	r12,pmc3						; INSTRUMENT - Get stamp
+			stw		r12,0x6100+(14*16)+0x8(0)		; INSTRUMENT - Save it
+			mfspr	r12,pmc4						; INSTRUMENT - Get stamp
+			stw		r12,0x6100+(14*16)+0xC(0)		; INSTRUMENT - Save it
+#endif			
+		or.		r0,r3,r4						// Did we fail the mapping?
+        mr		r31,r4							// r31 <- mapped ptr into user space (may be 64-bit)
+        beq--	copyinout_error					// was 0, so there was an error making the mapping
+        bf--	kk64bit,copyin1					// skip if a 32-bit processor
+ 
+ 		rldimi	r31,r3,32,0						// slam high-order bits into mapped ptr
+        mfmsr	r4								// if 64-bit, turn on SF so we can use returned ptr
+        li		r0,1
+        rldimi	r4,r0,63,MSR_SF_BIT				// light bit 0
+        mtmsrd	r4								// turn on 64-bit mode
+        isync									// wait for mode to change
+        
+        
+// Load r3-r5, substituting mapped ptr as appropriate.
+
+copyin1:
+        lwz		r5,kkBufSize(r1)				// restore length to copy
+        bf		kkIn,copyin2					// skip if copyout
+        lwz		r4,kkDest(r1)					// copyin: source is mapped, dest is r4 at entry
+        mr		r3,r31							// source is mapped ptr
+        b		copyin3
+copyin2:										// handle copyout
+        lwz		r3,kkSource(r1)					// source is kernel buffer (r3 at entry)
+        mr		r4,r31							// dest is mapped ptr into user space
+        
+        
+// Finally, all set up to copy:
+//		r3 = source ptr (mapped if copyin)
+//		r4 = dest ptr (mapped if copyout)
+//		r5 = length
+//	   r31 = mapped ptr returned by MapUserAddressSpace
+//	   cr3 = kkIn, kkString, kk64bit, and kkNull flags
+
+copyin3:
+        bt		kkString,copyString				// handle copyinstr and copyoutstr
+        bl		EXT(bcopy)						// copyin and copyout: let bcopy do the work
+        li		r3,0							// return success
+        
+        
+// Main exit point for copyin, copyout, copyinstr, and copyoutstr.  Also reached
+// from error recovery if we get a DSI accessing user space.  Clear recovery ptr, 
+// and pop off frame.  Note that we have kept
+// the mapped ptr into user space in r31, as a reg64_t type (ie, a 64-bit ptr on
+// 64-bit machines.)  We must unpack r31 into an addr64_t in (r3,r4) before passing
+// it to ReleaseUserAddressSpace.
+//		r3 = 0, EFAULT, or ENAMETOOLONG
+
+copyinx: 
+        lwz		r2,kkCR(r1)						// get callers cr3
+		mfsprg  r6,1							// Get the current act 
+		lwz		r10,ACT_THREAD(r6)
+		
+        bf--	kk64bit,copyinx1				// skip if 32-bit processor
+        mfmsr	r12
+        rldicl	r12,r12,0,MSR_SF_BIT+1			// if 64-bit processor, turn 64-bit mode off
+        mtmsrd	r12								// turn SF off and EE back on
+        isync									// wait for the mode to change
+copyinx1:
+        lwz		r31,kkR31Save(r1)				// restore callers r31
+        addi	r1,r1,kkFrameSize				// pop off our stack frame
+		lwz		r0,FM_LR_SAVE(r1)
+		li		r4,0
+		stw		r4,THREAD_RECOVER(r10)			// Clear recovery
+		mtlr	r0
+        mtcrf	0x10,r2							// restore cr3
+		blr
 
-.L_copyinstr_no_store:
 
-		addi	r9,r9,1							/* Count the character */
-		beq-	cr1,.L_copyinstr_done			/* We're done if we did a null... */
-		beq-	cr0,L_copyinstr_toobig			/* Also if we maxed the count... */
-	
-/* Check to see if the copyin pointer has moved out of the
- * copyin segment, if it has we must remap.
+/* We get here via the exception handler if an illegal
+ * user memory reference was made.  This error handler is used by
+ * copyin, copyout, copyinstr, and copyoutstr.  Registers are as
+ * they were at point of fault, so for example cr3 flags are valid.
  */
 
-		rlwinm.	r0,r3,0,4,31					/* Did we wrap around to 0? */
-		bne+	cr0,.L_copyinstr_loop			/* Nope... */
-
-		lwz		r7,PMAP_SEGS+4(r8)				; Get the next source SR value
-		addi	r8,r8,4							; Point to the next segment
-		oris	r3,r0,(SR_COPYIN_NUM << (28-16))	/* Reset the segment number */
-		b		nxtseg							/* Keep going... */
-	
-L_copyinstr_toobig:
-		li		r3,ENAMETOOLONG
-		b		L_copyinstr_return
-.L_copyinstr_done:
-		li		r3,0							/* Normal return */
-L_copyinstr_return:
-		li		r4,0							/* to clear thread_recover */
-		stw		r9,0(r6)						/* Set how many bytes we did */
-		stw		r4,THREAD_RECOVER(r10)			/* Clear recovery exit */
-
-		addi	r1,	r1,	FM_SIZE+16
-		lwz		r0,	FM_LR_SAVE(r1)
-		mtlr	r0
-		blr
+copyinout_error:
+        li		r3,EFAULT						// return error
+        b		copyinx
+
+copyinout_0:									// degenerate case: 0-length copy
+		mtcrf	0x10,r2							// restore cr3
+        li		r3,0							// return success
+        blr
+        
+copyinout_too_big:								// degenerate case
+        mtcrf	0x10,r2							// restore cr3
+        lwz		r1,0(r1)						// pop off stack frame
+        li		r3,ENAMETOOLONG
+        blr
+        
+
+//<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
+// Handle copyinstr and copyoutstr.  At this point the stack frame is set up,
+// the recovery ptr is set, the user's buffer is mapped, we're in 64-bit mode
+// if necessary, and:
+//		r3 = source ptr, mapped if copyinstr
+//		r4 = dest ptr, mapped if copyoutstr
+//		r5 = buffer length
+//	   r31 = mapped ptr returned by MapUserAddressSpace
+//     cr3 = kkIn, kkString, kkNull, and kk64bit flags
+// We do word copies unless the buffer is very short, then use a byte copy loop
+// for the leftovers if necessary.
+
+copyString:
+        li		r12,0							// Set header bytes count to zero
+        cmplwi	cr1,r5,20						// is buffer very short?
+        mtctr	r5								// assuming short, set up loop count for bytes
+        blt		cr1,copyinstr8					// too short for word loop
+        andi.	r12,r3,0x3						// is source ptr word aligned?
+        bne		copyinstr11						//  bytes loop
+copyinstr1:
+        srwi	r6,r5,2							// get #words in buffer
+        mtctr	r6								// set up word loop count
+        lis		r10,hi16(0xFEFEFEFF)			// load magic constants into r10 and r11
+        lis		r11,hi16(0x80808080)
+        ori		r10,r10,lo16(0xFEFEFEFF)
+        ori		r11,r11,lo16(0x80808080)
+        bf		kkNull,copyinstr6				// enter loop that copies
+        b		copyinstr5						// use loop that just counts
+        
+        
+// Word loop(s).  They do a word-parallel search for 0s, using the following
+// inobvious but very efficient test:
+//		y =  data + 0xFEFEFEFF
+//		z = ~data & 0x80808080
+// If (y & z)==0, then all bytes in dataword are nonzero.  We need two copies of
+// this loop, since if we test kkNull in the loop then it becomes 9 words long.
+
+        .align	5								// align inner loops for speed
+copyinstr5:										// version that counts but does not copy
+        lwz		r8,0(r3)						// get next word of source
+        addi	r3,r3,4							// increment source ptr
+        add		r9,r10,r8						// r9 =  data + 0xFEFEFEFF
+        andc	r7,r11,r8						// r7 = ~data & 0x80808080
+        and.	r7,r9,r7						// r7 = r9 & r7
+        bdnzt	cr0_eq,copyinstr5				// if r7==0, then all bytes are nonzero
+
+        b		copyinstr7
+
+        .align	5								// align inner loops for speed
+copyinstr6:										// version that counts and copies
+        lwz		r8,0(r3)						// get next word of source
+        addi	r3,r3,4							// increment source ptr
+        addi	r4,r4,4							// increment dest ptr while we wait for data
+        add		r9,r10,r8						// r9 =  data + 0xFEFEFEFF
+        andc	r7,r11,r8						// r7 = ~data & 0x80808080
+        and.	r7,r9,r7						// r7 = r9 & r7
+        stw		r8,-4(r4)						// pack all 4 bytes into buffer
+        bdnzt	cr0_eq,copyinstr6				// if r7==0, then all bytes are nonzero
+
+
+// Either 0 found or buffer filled.  The above algorithm has mapped nonzero bytes to 0
+// and 0 bytes to 0x80 with one exception: 0x01 bytes preceeding the first 0 are also
+// mapped to 0x80.  We must mask out these false hits before searching for an 0x80 byte.
+
+copyinstr7:
+        crnot	kkZero,cr0_eq					// 0 found iff cr0_eq is off
+        mfctr	r6								// get #words remaining in buffer
+        rlwinm	r2,r8,7,0,31					// move 0x01 bits to 0x80 position
+        slwi	r6,r6,2							// convert to #bytes remaining
+        andc	r7,r7,r2						// turn off false hits from 0x0100 worst case
+        rlwimi	r6,r5,0,30,31					// add in odd bytes leftover in buffer
+        srwi	r7,r7,8							// we want to count the 0 as a byte xferred
+        addi	r6,r6,4							// don't count last word xferred (yet)
+        cntlzw	r7,r7							// now we can find the 0 byte (ie, the 0x80)
+        srwi	r7,r7,3							// convert 8,16,24,32 to 1,2,3,4
+        sub.	r6,r6,r7						// account for nonzero bytes in last word
+        bt++	kkZero,copyinstr10				// 0 found, so done
+        
+        beq		copyinstr10						// r6==0, so buffer truly full
+        mtctr	r6								// 0 not found, loop over r6 bytes
+        b		copyinstr8						// enter byte loop for last 1-3 leftover bytes
+        
+
+// Byte loop.  This is used for very small buffers and for the odd bytes left over
+// after searching and copying words at a time.
+    
+        .align	5								// align inner loops for speed
+copyinstr8:										// loop over bytes of source
+        lbz		r0,0(r3)						// get next byte of source
+        addi	r3,r3,1
+        addi	r4,r4,1							// increment dest addr whether we store or not
+        cmpwi	r0,0							// the 0?
+        bt--	kkNull,copyinstr9				// don't store (was copyinstr with NULL ptr)
+        stb		r0,-1(r4)
+copyinstr9:
+        bdnzf	cr0_eq,copyinstr8				// loop if byte not 0 and more room in buffer
+        
+        mfctr	r6								// get #bytes left in buffer
+        crmove	kkZero,cr0_eq					// remember if 0 found or buffer filled
+
+        
+// Buffer filled or 0 found.  Unwind and return.
+//	r5 = kkBufSize, ie buffer length
+//  r6 = untransferred bytes remaining in buffer
+// r31 = mapped ptr returned by MapUserAddressSpace
+// cr3 = kkZero set iff 0 found
+
+copyinstr10:
+        lwz		r9,kkCountPtr(r1)				// get ptr to place to store count of bytes moved
+        sub		r2,r5,r6						// get #bytes we moved, counting the 0 iff any
+        add		r2,r2,r12						// add the header bytes count
+        li		r3,0							// assume 0 return status
+        stw		r2,0(r9)						// store #bytes moved
+        bt++	kkZero,copyinx					// we did find the 0 so return 0
+        li		r3,ENAMETOOLONG					// buffer filled
+        b		copyinx							// join main exit routine
+
+// Byte loop.  This is used on the header bytes for unaligned source 
+    
+        .align	5								// align inner loops for speed
+copyinstr11:
+        li		r10,4							// load word size
+        sub		r12,r10,r12						// set the header bytes count
+        mtctr	r12								// set up bytes loop count
+copyinstr12:									// loop over bytes of source
+        lbz		r0,0(r3)						// get next byte of source
+        addi	r3,r3,1
+        addi	r4,r4,1							// increment dest addr whether we store or not
+        cmpwi	r0,0							// the 0?
+        bt--	kkNull,copyinstr13				// don't store (was copyinstr with NULL ptr)
+        stb		r0,-1(r4)
+copyinstr13:
+        bdnzf	cr0_eq,copyinstr12				// loop if byte not 0 and more room in buffer
+        sub		r5,r5,r12						// substract the bytes copied
+        bne		cr0_eq,copyinstr1				// branch to word loop
+
+        mr		r5,r12							// Get the header bytes count
+        li		r12,0							// Clear the header bytes count
+        mfctr	r6								// get #bytes left in buffer
+        crmove	kkZero,cr0_eq					// remember if 0 found or buffer filled
+        b		copyinstr10
+
diff --git a/osfmk/ppc/mp.h b/osfmk/ppc/mp.h
index 2c7da0d11..4403d34cd 100644
--- a/osfmk/ppc/mp.h
+++ b/osfmk/ppc/mp.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ppc/net_filter.c b/osfmk/ppc/net_filter.c
deleted file mode 100644
index 3f9225a28..000000000
--- a/osfmk/ppc/net_filter.c
+++ /dev/null
@@ -1,750 +0,0 @@
-/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
- *
- * @APPLE_LICENSE_HEADER_START@
- * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
- * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
- * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
- * 
- * @APPLE_LICENSE_HEADER_END@
- */
-/*
- * @OSF_COPYRIGHT@
- * 
- */
-
-
-#if NET_FILTER_COMPILER
-
-
-#define USE_EXTRA_REGS 0
-
-#define REG_ZERO	0	/* Register we keep equal to 0. */
-#define REG_DATAADDR	3	/* Address of packet data, and filter return. */
-#define REG_DATALEN	4	/* Length of packet data in two-byte units. */
-#define REG_HDRADDR	5	/* Address of header data. */
-#define REG_RET		3	/* Where to put return value. */
-
-/* Originally we dealt in virtual register numbers which were essentially
-   indexes into this array, and only converted to machine register numbers
-   when emitting instructions.  But that meant a lot of conversions, so
-   instead we deal with machine register numbers all along, even though this
-   means wasting slots in the regs[] array.  */
-const unsigned char scratchregs[] = {
-    6, 7, 8, 9, 10, 11, 12,
-#if USE_EXTRA_REGS	/* Callee-saves regs available if we save them. */
-#define INITIAL_NSCRATCHREGS 8	/* Number of registers above. */
-    #error not yet written
-#endif
-};
-#define NSCRATCHREGS (sizeof scratchregs / sizeof scratchregs[0])
-#define NREGS 32
-#define NO_REG 1	/* This is the stack pointer!  Flag value.  */
-
-#define MAX_LI		0x7fff	/* Max unsigned value in an LI. */
-
-#define BCLR(cond)	((19 << 26) | (cond) | (16 << 1))
-#define BLR()		BCLR(COND_ALWAYS)
-#define BC(cond, off)	((16 << 26) | (cond) | ((off) << 2))
-#define COND(BO, BI)	(((BO) << (16 + 5)) | ((BI) << 16))
-#define COND_ALWAYS	COND(COND_IF_ALWAYS, 0)
-#define COND_EQ		COND(COND_IF_TRUE, COND_BIT(0, BIT_EQ))
-#define COND_NE		COND(COND_IF_FALSE, COND_BIT(0, BIT_EQ))
-#define COND_LE		COND(COND_IF_FALSE, COND_BIT(0, BIT_GT))
-#define COND_GE		COND(COND_IF_FALSE, COND_BIT(0, BIT_LT))
-#define COND_BIT(crf, bit) \
-			((crf) * 4 + (bit))
-#define BIT_EQ		2
-#define BIT_GT		1
-#define BIT_LT		0
-#define COND_IF_FALSE	0x04
-#define COND_IF_TRUE	0x0c
-#define COND_IF_ALWAYS	0x14
-
-/* For arithmetical instructions, a is the dest and b is the source;
-   for logical instructions, a is the source and b is the dest.  Ho hum.  */
-#define IMMED(opcode, a, b, imm) \
-			(((opcode) << 26) | ((a) << 21) | ((b) << 16) | \
-			 ((imm) & 0xffff))
-#define ADDI(dst, src, imm) \
-			IMMED(14, dst, src, imm)
-#define ADDIC(dst, src, imm) \
-			IMMED(12, dst, src, imm)
-#define SUBFIC(dst, src, imm) \
-			IMMED(8, dst, src, imm)
-#define LI(dst, imm)	ADDI(dst, 0, (imm))
-#define ANDI(dst, src, imm) \
-			IMMED(28, src, dst, imm)
-#define ORI(dst, src, imm) \
-			IMMED(24, src, dst, imm)
-#define XORI(dst, src, imm) \
-			IMMED(26, src, dst, imm)
-
-#define CMPL(lhs, rhs)	((31 << 26) | ((lhs) << 16) | ((rhs) << 11) | (32 << 1))
-#define CMPLI(lhs, imm)	((10 << 26) | ((lhs) << 16) | ((imm) & 0xffff))
-
-#define INTEGER_OP(opcode, a, b, c) \
-			((31 << 26) | ((a) << 21) | ((b) << 16) | \
-			 ((c) << 11) | ((opcode) << 1))
-#define ARITH_OP(opcode, dst, lhs, rhs) \
-			INTEGER_OP(opcode, dst, lhs, rhs)
-#define ADD(dst, lhs, rhs) \
-			ARITH_OP(OP_ADD, dst, lhs, rhs)
-#define ADDE(dst, lhs, rhs) \
-			ARITH_OP(OP_ADDE, dst, lhs, rhs)
-#define SUBF(dst, lhs, rhs) \
-			ARITH_OP(OP_SUBF, dst, lhs, rhs)
-#define SUBFC(dst, lhs, rhs) \
-			ARITH_OP(OP_SUBFC, dst, lhs, rhs)
-#define SUBFE(dst, lhs, rhs) \
-			ARITH_OP(OP_SUBFE, dst, lhs, rhs)
-#define LOGIC_OP(opcode, dst, lhs, rhs) \
-			INTEGER_OP(opcode, lhs, dst, rhs)
-#define OR(dst, lhs, rhs) \
-			LOGIC_OP(OP_OR, dst, lhs, rhs)
-#define XOR(dst, lhs, rhs) \
-			LOGIC_OP(OP_XOR, dst, lhs, rhs)
-#define OP_ADD 		266
-#define OP_ADDE		138
-#define OP_AND		28
-#define OP_OR		444
-#define OP_SRW		536
-#define OP_SUBF		40
-#define OP_SUBFC	8
-#define OP_SUBFE	136
-#define OP_XOR		316
-#define MR(dst, src)	OR(dst, src, src)
-
-#define LHZ(dst, base, offset) \
-			((40 << 26) | ((dst) << 21) | ((base) << 16) | \
-			 ((offset) & 0xffff))
-#define LHZX(dst, base, index) \
-			INTEGER_OP(279, dst, base, index)
-#define MFCR(dst)	INTEGER_OP(19, dst, 0, 0)
-
-#define RLWINM(dst, src, shiftimm, mbegin, mend) \
-			((21 << 26) | ((src) << 21) | ((dst) << 16) | \
-			 ((shiftimm) << 11) | ((mbegin) << 6) | ((mend) << 1))
-#define RLWNM(dst, src, shiftreg, mbegin, mend) \
-			((23 << 26) | ((src) << 21) | ((dst) << 16) | \
-			 ((shiftreg) << 11) | ((mbegin) << 6) | ((mend) << 1))
-
-/* Every NETF_arg generates at most four instructions (4 for PUSHIND).
-   Every NETF_op generates at most 3 instructions (3 for EQ and NEQ).  */
-#define MAX_INSTR_PER_ARG 4
-#define MAX_INSTR_PER_OP  3
-#define MAX_INSTR_PER_ITEM (MAX_INSTR_PER_ARG + MAX_INSTR_PER_OP)
-int junk_filter[MAX_INSTR_PER_ITEM];
-
-enum {NF_LITERAL, NF_HEADER, NF_DATA};
-struct common {	/* Keeps track of values we might want to avoid reloading. */
-    char type;	/* NF_LITERAL: immediate; NF_HEADER: header word;
-		   NF_DATA: data word. */
-    char nuses;	/* Number of remaining uses for this value. */
-    unsigned char reg;
-		/* Register this value is currently in, or NO_REG if none. */
-    unsigned short value;
-		/* Immediate value or header or data offset. */
-};
-struct reg {	/* Keeps track of the current contents of registers. */
-    unsigned char commoni;
-			/* Index in common[] of the contained value. */
-#define NOT_COMMON_VALUE NET_MAX_FILTER	/* When not a common[] value. */
-    unsigned char stacktimes;
-			/* Number of times register appears in stack. */
-};
-struct local {	/* Gather local arrays so we could kalloc() if needed.  */
-    struct common common[NET_MAX_FILTER];	/* Potentially common values. */
-    struct reg regs[NREGS];			/* Register statuses. */
-    unsigned char commonpos[NET_MAX_FILTER];	/* Index in common[] for the
-						   value loaded in each filter
-						   command. */
-    unsigned char stackregs[NET_FILTER_STACK_DEPTH];
-						/* Registers making up the
-						   stack. */
-#if USE_EXTRA_REGS
-    unsigned char maxreg;
-#endif
-};
-
-int allocate_register(struct local *s, int commoni);
-int compile_preamble(int *instructions, struct local *s);
-
-/* Compile a packet filter into POWERPC machine code.  We do everything in
-   the 7 caller-saves registers listed in scratchregs[], except when
-   USE_EXTRA_REGS is defined, in which case we may also allocate callee-
-   saves registers if needed.  (Not yet implemented on PPC.)
-
-   Rather than maintaining an explicit stack in memory, we allocate registers
-   dynamically to correspond to stack elements -- we can do this because we
-   know the state of the stack at every point in the filter program.  We also
-   attempt to keep around in registers values (immediates, or header or data
-   words) that are used later on, to avoid having to load them again.
-   Since there are only 7 registers being used, we might be forced to reload
-   a value that we could have kept if we had more.  We might even be unable
-   to contain the stack in the registers, in which case we return failure and
-   cause the filter to be interpreted by net_do_filter().  But for all current
-   filters I looked at, 7 registers is enough even to avoid reloads.  When
-   USE_EXTRA_REGS is defined there are about 28 available registers, which is
-   plenty.
-
-   We depend heavily on NET_MAX_FILTER and NET_FILTER_STACK_DEPTH being
-   small.  We keep indexes to arrays sized by them in char-sized fields,
-   originally because we tried allocating these arrays on the stack.
-   Even then we overflowed the small (4K) kernel stack, so we were forced
-   to allocate the arrays dynamically, which is the reason for the existence
-   of `struct local'.
-
-   We also depend on the filter being logically correct, for instance not
-   being longer than NET_MAX_FILTER or underflowing its stack.  This is
-   supposed to have been checked by parse_net_filter() before the filter
-   is compiled.
-
-   We are supposed to return 1 (TRUE) if the filter accepts the packet
-   and 0 (FALSE) otherwise.  In fact, we may return any non-zero value
-   for true, which is sufficient for our caller and convenient for us.
-
-   There are lots and lots of optimisations that we could do but don't.
-   This is supposedly a *micro*-kernel, after all.  Here are some things
-   that could be added without too much headache:
-   - Using the condition register.  We go to a lot of trouble to generate
-     integer truth values for EQ etc, but most of the time those values
-     are just ANDed or ORed together or used as arguments to COR etc.  So
-     we could compute the comparison values directly into CR bits and
-     operate on them using the CR logical instructions without (most of
-     the time) ever having to generate integer equivalents.
-   - More registers.  We could note the last uses of r3, r4, and
-     r5, and convert them to general registers after those uses.  But if
-     register shortage turns out to be a problem it is probably best just
-     to define USE_EXTRA_REGS and have done with it.
-   - Minimising range checks.  Every time we refer to a word in the data
-     part, we generate code to ensure that it is within bounds.  But often
-     the truth of these tests is implied by earlier tests.  Instead, at the
-     start of the filter and after every COR or CNAND we could insert
-     a single check when that is necessary.  (After CAND and CNOR we don't
-     need to check since if they terminate it will be to return FALSE
-     anyway so all we'd do would be to return it prematurely.)
-   - Remembering immediate values.  Instead of generating code as soon as we
-     see a PUSHLIT, we could remember that value and only generate code when
-     it is used.  This would enable us to generate certain shorter
-     instructions (like addi) that incorporate the immediate value instead
-     of ever putting it in a register.
- */
-
-filter_fct_t
-net_filter_alloc(filter_t *filter, unsigned int size, unsigned int *lenp)
-{
-    struct local *s;
-    int len, oldi, i, j, t, ncommon, sp;
-    int type, value, arg, op, reg, reg1, dst, commoni;
-    int returnfalseoffset;
-    int *instructions, *instp, *returnfalse;
-#if USE_EXTRA_REGS
-    int oldmaxreg;
-#endif
-    boolean_t compiling;
-
-#define SCHAR_MAX 127	/* machine/machlimits->h, anyone? */
-    assert(NET_MAX_FILTER <= SCHAR_MAX);
-    assert(NET_FILTER_STACK_DEPTH <= SCHAR_MAX);
-    assert(NREGS <= SCHAR_MAX);
-
-    assert(size < NET_MAX_FILTER);
-
-    s = (struct local *) kalloc(sizeof *s);
-
-#if USE_EXTRA_REGS
-    s->maxreg = INITIAL_NSCRATCHREGS;
-#endif
-    len = 0;
-    compiling = FALSE;
-    returnfalse = junk_filter;
-
-    /* This loop runs at least twice, once with compiling==FALSE to determine
-       the length of the instructions we will compile, and once with
-       compiling==TRUE to compile them.  The code generated on the two passes
-       must be the same.  In the USE_EXTRA_REGS case, the loop can be re-run
-       an extra time while !compiling, if we decide to use the callee-saves
-       registers.  This is because we may be able to generate better code with
-       the help of these registers than before.  */
-    while (1) {
-
-	/* Identify values that we can potentially preserve in a register to
-	   avoid having to reload them.  All immediate values and references to
-	   known offsets in the header or data are candidates.  The results of
-	   this loop are the same on every run, so with a bit of work we
-	   could run it just once; but this is not a time-critical
-	   application.  */
-	ncommon = 0;
-	for (i = 0; i < size; i++) {
-	    oldi = i;
-	    arg = NETF_ARG(filter[i]);
-	    if (arg == NETF_PUSHLIT) {
-		type = NF_LITERAL;
-		value = filter[++i];
-	    } else if (arg >= NETF_PUSHSTK) {
-		continue;
-	    } else if (arg >= NETF_PUSHHDR) {
-		type = NF_HEADER;
-		value = arg - NETF_PUSHHDR;
-	    } else if (arg >= NETF_PUSHWORD) {
-		type = NF_DATA;
-		value = arg - NETF_PUSHWORD;
-	    } else {
-		continue;
-	    }
-	    for (j = 0; j < ncommon; j++) {
-		if (s->common[j].type == type && s->common[j].value == value) {
-		    s->common[j].nuses++;
-		    break;
-		}
-	    }
-	    if (j == ncommon) {
-		s->common[j].type = type;
-		s->common[j].value = value;
-		s->common[j].nuses = 1;
-		ncommon++;
-	    }
-	    s->commonpos[oldi] = j;
-	}
-
-#if USE_EXTRA_REGS
-	oldmaxreg = s->maxreg;
-#endif
-
-	/* Initially, no registers hold common values or are on the stack.  */
-	for (i = 0; i < ncommon; i++)
-	    s->common[i].reg = NO_REG;
-	for (i = 0; i < NSCRATCHREGS; i++) {
-	    s->regs[scratchregs[i]].commoni = NOT_COMMON_VALUE;
-	    s->regs[scratchregs[i]].stacktimes = 0;
-	}
-
-	/* Now read through the filter and generate code. */
-	sp = -1;	/* sp points to top element */
-	for (i = 0; i < size; i++) {
-	    if (!compiling)
-		instp = junk_filter;
-
-	    assert(sp >= -1);
-	    assert(sp < NET_FILTER_STACK_DEPTH - 1);
-	    commoni = s->commonpos[i];
-	    arg = NETF_ARG(filter[i]);
-	    op = NETF_OP(filter[i]);
-
-	    /* Generate code to get the required value into a register and
-	       set `reg' to the number of this register. */
-	    switch (arg) {
-	    case NETF_PUSHLIT:
-		value = filter[++i];
-		reg = s->common[commoni].reg;
-		if (reg == NO_REG) {
-		    if ((reg = allocate_register(s, commoni)) == NO_REG)
-			goto fail;
-		    assert(value >= 0);	/* Comes from unsigned short. */
-		    *instp++ = ORI(reg, REG_ZERO, value);
-		}
-		s->common[commoni].nuses--;
-		break;
-	    case NETF_NOPUSH:
-		reg = s->stackregs[sp--];
-		s->regs[reg].stacktimes--;
-		break;
-	    case NETF_PUSHZERO:
-		reg = REG_ZERO;
-		break;
-	    case NETF_PUSHIND:
-	    case NETF_PUSHHDRIND:
-		reg1 = s->stackregs[sp--];
-		s->regs[reg1].stacktimes--;
-		if (arg == NETF_PUSHIND)
-		    *instp++ = CMPL(reg1, REG_DATALEN);
-		else
-		    *instp++ = CMPLI(reg1,
-				     NET_HDW_HDR_MAX/sizeof (unsigned short));
-		*instp = BC(COND_GE, returnfalse - instp);
-		instp++;
-		if ((reg = allocate_register(s, -1)) == NO_REG)
-		    goto fail;
-		*instp++ = ADD(reg, reg1, reg1);
-		*instp++ = LHZX(reg, (arg == NETF_PUSHIND) ?
-					REG_DATAADDR : REG_HDRADDR, reg);
-		break;
-	    default:
-		if (arg >= NETF_PUSHSTK)
-		    reg = s->stackregs[sp - (arg - NETF_PUSHSTK)];
-		else if (arg >= NETF_PUSHWORD) {
-		    assert(2 * (NETF_PUSHHDR - NETF_PUSHWORD) <= MAX_LI);
-		    assert(NETF_PUSHSTK - NETF_PUSHHDR <= MAX_LI);
-		    reg = s->common[commoni].reg;
-		    if (reg == NO_REG) {
-			if ((reg = allocate_register(s, commoni)) == NO_REG)
-			    goto fail;
-			if (arg < NETF_PUSHHDR) {
-			    value = arg - NETF_PUSHWORD;
-			    *instp++ = CMPLI(REG_DATALEN, value);
-			    *instp = BC(COND_LE, returnfalse - instp);
-			    instp++;
-			    reg1 = REG_DATAADDR;
-			} else {
-			    value = arg - NETF_PUSHHDR;
-			    reg1 = REG_HDRADDR;
-			}
-			*instp++ = LHZ(reg, reg1, 2 * value);
-		    }
-		    s->common[commoni].nuses--;
-		}
-	    }
-
-	    /* Now generate code to do `op' on `reg1' (lhs) and `reg' (rhs). */
-	    if (op != NETF_NOP) {
-		reg1 = s->stackregs[sp--];
-		s->regs[reg1].stacktimes--;
-	    }
-	    switch (op) {
-	    case NETF_OP(NETF_CAND):
-	    case NETF_OP(NETF_COR):
-	    case NETF_OP(NETF_CNAND):
-	    case NETF_OP(NETF_CNOR):
-		dst = -1;
-	    case NETF_OP(NETF_NOP):
-		break;
-	    default:
-		/* Allocate a register to put the result in. */
-		if ((dst = allocate_register(s, -1)) == NO_REG)
-		    goto fail;
-	    }
-	    switch (op) {
-	    case NETF_OP(NETF_NOP):
-		dst = reg;
-		break;
-	    case NETF_OP(NETF_EQ):
-	    case NETF_OP(NETF_NEQ):
-		/* We arrange for the truth value to end up in the carry
-		   flag and then put it in the destination register by
-		   adding-with-carry zero to itself.  To set the carry, we
-		   first make a value `x' that is zero if the values are
-		   equal; this is either their XOR, or, if we know the
-		   rhs is 0, the lhs.  Then to set the carry only when
-		   x==0 we do `subfic dst,x,0' (subtract x from 0, setting
-		   carry as not-borrow, so set only if x==0); to set it when
-		   x!=0 we do `addic dst,x,-1' (add -1 to x setting carry,
-		   so set unless x==0).  We're only interested in the carry
-		   from these operations, not dst.
-		   We don't test if reg1==REG_ZERO since in practice you
-		   write NETF_PUSHLIT|NETF_EQ; the other order is eccentric
-		   so you get an extra instruction, tough.  */
-		if (reg == REG_ZERO)
-		    t = reg1;
-		else {
-		    *instp++ = XOR(dst, reg1, reg);
-		    t = dst;
-		}
-		*instp++ = (op == NETF_OP(NETF_EQ)) ?
-			    SUBFIC(dst, t, 0) : ADDIC(dst, t, -1);
-		*instp++ = ADDE(dst, REG_ZERO, REG_ZERO);
-		break;
-	    case NETF_OP(NETF_LT):
-		/* LT and GT take advantage of the fact that all numbers are
-		   16-bit quantities, so the sign bit after a subtraction
-		   is a reliable indication of the relative magnitudes of
-		   the operands.  */
-		*instp++ = SUBF(dst, reg, reg1);	/* dst = reg1 - reg */
-		*instp++ = RLWINM(dst, dst, 1, 31, 31);	/* sign bit */
-		break;
-	    case NETF_OP(NETF_GT):
-		*instp++ = SUBF(dst, reg1, reg);	/* dst = reg - reg1 */
-		*instp++ = RLWINM(dst, dst, 1, 31, 31);	/* sign bit */
-		break;
-	    case NETF_OP(NETF_LE):
-		/* LE and GE use the carry (= not-borrow) flag.  When doing
-		   a - b, there is a borrow if b > a, so carry if b <= a. */
-		*instp++ = SUBFC(dst, reg1, reg);	/* dst = reg - reg1 */
-		*instp++ = ADDE(dst, REG_ZERO, REG_ZERO);/* ca if reg1 <= reg */
-		break;
-	    case NETF_OP(NETF_GE):
-		*instp++ = SUBFC(dst, reg, reg1);	/* dst = reg1 - reg */
-		*instp++ = ADDE(dst, REG_ZERO, REG_ZERO);/* ca if reg <= reg1 */
-		break;
-	    case NETF_OP(NETF_AND):
-		j = OP_AND;
-		goto logical;
-	    case NETF_OP(NETF_OR):
-		j = OP_OR;
-		goto logical;
-	    case NETF_OP(NETF_XOR):
-		j = OP_XOR;
-		goto logical;
-	    case NETF_OP(NETF_RSH):
-		j = OP_SRW;
-logical:
-		*instp++ = LOGIC_OP(j, dst, reg1, reg);
-		break;
-	    case NETF_OP(NETF_ADD):
-		j = OP_ADD;
-		goto arithmetical;
-	    case NETF_OP(NETF_SUB):
-		j = OP_SUBF;	/* First reg subtracted from second. */
-arithmetical:
-		*instp++ = ARITH_OP(j, dst, reg, reg1);
-		*instp++ = ANDI(dst, dst, 0xffff);
-		break;
-	    case NETF_OP(NETF_LSH):
-		*instp++ = RLWNM(dst, reg1, reg, 16, 31);
-		break;
-	    case NETF_OP(NETF_COR):
-	    case NETF_OP(NETF_CNAND):
-		*instp++ = CMPL(reg1, reg);
-		*instp++ = BCLR((op == NETF_OP(NETF_COR)) ? COND_EQ : COND_NE);
-		break;
-	    case NETF_OP(NETF_CAND):
-	    case NETF_OP(NETF_CNOR):
-		*instp++ = CMPL(reg1, reg);
-		*instp = BC((op == NETF_OP(NETF_CAND)) ? COND_NE : COND_EQ,
-			    returnfalse - instp);
-		instp++;
-		break;
-	    default:
-		printf("op == 0x%x\n", op);
-		panic("net_filter_alloc: bad op");
-		/* Should have been caught by parse_net_filter(). */
-	    }
-	    /* If the op generated a result, push it on the stack. */
-	    if (dst >= 0) {
-		s->stackregs[++sp] = dst;
-		s->regs[dst].stacktimes++;
-	    }
-	    if (!compiling) {
-		assert(instp - junk_filter <= MAX_INSTR_PER_ITEM);
-		len += instp - junk_filter;
-	    }
-	}
-	if (compiling) {
-	    /* If the stack contains any values, we are supposed to return 0 or
-	       1 according as the top-of-stack is zero or not.  Since the only
-	       place we are called requires just zero-false/nonzero-true, we
-	       simply copy the value into r3.  If the stack is empty, we
-	       leave the pointer value r3 intact to return TRUE.  */
-	    if (sp >= 0)
-		*instp++ = MR(REG_RET, s->stackregs[sp]);
-	    *instp++ = BLR();
-	    /* Branch here to return false.  We could avoid adding these
-	       instructions if they are not used, but practically every
-	       filter does use them (for failure values when trying to
-	       access values beyond the header or data length) so it's
-	       not worth the effort.  */
-	    assert(instp == returnfalse);
-	    *instp++ = LI(REG_RET, 0);
-	    *instp++ = BLR();
-	    break;
-	} else {
-	    len += 1 + (sp >= 0);
-			/* For the reach-the-end return instruction(s).  */
-#if USE_EXTRA_REGS
-	    if (s->maxreg > oldmaxreg) {
-		len = 0;
-		continue;
-	    }
-#endif
-	    len += compile_preamble(NULL, s);
-	    returnfalseoffset = len;
-	    len += 2;	/* For the return-false instructions.  */
-	}
-	if ((instructions = (int *) kalloc(len * sizeof (int))) == NULL)
-	    return NULL;
-	returnfalse = instructions + returnfalseoffset;
-	instp = instructions;
-	instp += compile_preamble(instp, s);
-	compiling = TRUE;
-    }
-
-    assert(instp - instructions == len);
-    *lenp = len * sizeof (int);
-    {
-	kern_return_t kr;
-	vm_machine_attribute_val_t val = MATTR_VAL_CACHE_SYNC;
-
-	kr = pmap_attribute(kernel_pmap, (vm_offset_t) instructions,
-			    len * sizeof (int), MATTR_CACHE, &val);
-	if (kr != KERN_SUCCESS) {
-	    printf("net_filter_alloc: pmap_attribute -> 0x%x\n", kr);
-	    return NULL;
-	}
-    }
-    kfree((vm_offset_t) s, sizeof *s);
-    return (filter_fct_t) instructions;
-fail:
-    assert(!compiling);
-    kfree((vm_offset_t) s, sizeof *s);
-    printf("net_filter_alloc: failed to compile (filter too complex)\n");
-    printf("-- will work, but more slowly; consider enabling USE_EXTRA_REGS\n");
-    return NULL;
-}
-
-
-/* Allocate a register.  Registers that are already being used to make up
-   the virtual stack are ineligible.  Among the others, we choose the one
-   whose value has the least number of subsequent uses (ideally, and
-   usually, 0) of the common value it already holds.  If commoni is >=
-   0, it is the index in common[] of the value we are going to put in
-   the allocated register, so we can update the various data structures
-   appropriately.  */
-int
-allocate_register(struct local *s, int commoni)
-{
-    int i, reg, bestreg, nuses, bestregnuses, maxreg;
-
-    bestreg = NO_REG;
-#if USE_EXTRA_REGS
-    maxreg = s->maxreg;
-#else
-    maxreg = NSCRATCHREGS;
-#endif
-    while (1) {
-	bestregnuses = NOT_COMMON_VALUE;
-	for (i = 0; i < maxreg; i++) {
-	    reg = scratchregs[i];
-	    if (s->regs[reg].stacktimes == 0) {
-		nuses = (s->regs[reg].commoni == NOT_COMMON_VALUE) ?
-			0 : s->common[s->regs[reg].commoni].nuses;
-		if (nuses < bestregnuses) {
-		    bestreg = reg;
-		    bestregnuses = nuses;
-		}
-	    }
-	}
-	if (bestreg != NO_REG)
-	    break;
-#if USE_EXTRA_REGS
-	if (maxreg == NSCRATCHREGS)
-	    return NO_REG;
-	s->maxreg = ++maxreg;
-#else
-	return NO_REG;
-#endif
-    }
-    if (bestregnuses > 0)
-	printf("net_filter_alloc: forced to reallocate r%d\n", bestreg);
-	/* With USE_EXTRA_REGS, we could push up the number of registers
-	   here to have one extra available for common values, but it's usually
-	   not worth the overhead of the extra save-and-restore in the preamble.
-	   Anyway, this never happens with typical filters.  */
-    if (s->regs[bestreg].commoni != NOT_COMMON_VALUE)
-	s->common[s->regs[bestreg].commoni].reg = NO_REG;
-    if (commoni >= 0) {
-	s->regs[bestreg].commoni = commoni;
-	s->common[commoni].reg = bestreg;
-    } else
-	s->regs[bestreg].commoni = NOT_COMMON_VALUE;
-    return bestreg;
-}
-
-
-#define FIXED_PREAMBLE_INSTRUCTIONS 1
-
-int
-compile_preamble(int *instructions, struct local *s)
-{
-    int *instp;
-    int len = FIXED_PREAMBLE_INSTRUCTIONS;
-#if USE_EXTRA_REGS
-#error this hp code must be ported to the ppc
-    int extra_regs, i, j, t, disp;
-
-    extra_regs = s->maxreg - INITIAL_NSCRATCHREGS;
-    if (extra_regs > 0) {
-	len = extra_regs * 2 + 4;
-	/* stw rp | (n-1) * stw | bl | stw | ldw rp | (n-1) * ldw | bv | ldw */
-    } else
-	return 0;
-#endif
-    if (instructions == NULL)
-	return len;
-    instp = instructions;
-
-    *instp++ = LI(REG_ZERO, 0);
-    assert(instp - instructions == FIXED_PREAMBLE_INSTRUCTIONS);
-
-#if USE_EXTRA_REGS
-#error this hp code must be ported to the ppc
-    /* Generate a wrapper function to save the callee-saves registers
-       before invoking the filter code we have generated.  It would be
-       marginally better to have the filter branch directly to the
-       postamble code on return, but the difference is trivial and it
-       is easier to have it always branch to (rp).  */
-#define FRAME_SIZE 128	/* This is plenty without being excessive. */
-    *instp++ = STW_NEG(REG_RTN, 20, REG_SP);		/* stw rp,-20(sp) */
-    i = INITIAL_NSCRATCHREGS;
-    t = STWM(scratchregs[i], FRAME_SIZE, REG_SP);	/* stwm r3,128(sp) */
-    j = FRAME_SIZE;
-    while (++i < s->maxreg) {
-	*instp++ = t;
-	j -= sizeof (int);
-	t = STW_NEG(scratchregs[i], j, REG_SP);		/* stw r4,-124(sp) &c */
-    }
-    disp = extra_regs + 2;	/* n * ldw | bv | ldw rp */
-    *instp++ = BL(disp, REG_RTN);			/* bl filter,rp */
-    *instp++ = t;					/* stw in delay slot */
-    *instp++ = LDW_NEG(FRAME_SIZE + 20, REG_SP, REG_RTN);
-							/* ldw -148(sp),rp */
-    while (--i > INITIAL_NSCRATCHREGS) {
-	*instp++ = LDW_NEG(j, REG_SP, scratchregs[i]);	/* ldw -124(sp),r4 &c */
-	j += sizeof (int);
-    }
-    *instp++ = BV(0, REG_RTN);				/* bv (rp) */
-    *instp++ = LDWM_NEG(FRAME_SIZE, REG_SP, scratchregs[i]);
-							/* ldwm -128(sp),r3
-							   in delay slot */
-#endif
-
-    assert(instp - instructions == len);
-    return len;
-}
-
-void
-net_filter_free(filter_fct_t fp, unsigned int len)
-{
-    kfree((vm_offset_t) fp, len);
-}
-
-#else	/* NET_FILTER_COMPILER */
-
-/*
- *	Compilation of a source network filter into ppc instructions
- *	- a small version that doesnt do anything, but doesn't take
- *	up any space either. Note that if using a single mklinux server
- *	with ethertalk enabled (standard situation), the filter passes
- *	everything through so no need to compile one. If running multi
- *      servers then there is more of a need. Ethertalk (in linux server)
- *      should really have a packet filter, but at time of writing
- *	it does not.
- */
-filter_fct_t
-net_filter_alloc(
-	filter_t	*fpstart,
-	unsigned int	fplen,
-	unsigned int	*len)
-{
-	*len = 0;
-	return ((filter_fct_t)0);
-}
-
-void
-net_filter_free(
-	filter_fct_t	fp,
-	unsigned int	len)
-{
-	assert(fp == (filter_fct_t)0 && len == 0);
-}
-#endif	/* NET_FILTER_COMPILER */
diff --git a/osfmk/ppc/new_screen.h b/osfmk/ppc/new_screen.h
index 0bec494ff..c68ff182b 100644
--- a/osfmk/ppc/new_screen.h
+++ b/osfmk/ppc/new_screen.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ppc/notify_interrupt.c b/osfmk/ppc/notify_interrupt.c
deleted file mode 100644
index 4e1c4ef9e..000000000
--- a/osfmk/ppc/notify_interrupt.c
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
- *
- * @APPLE_LICENSE_HEADER_START@
- * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
- * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
- * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
- * 
- * @APPLE_LICENSE_HEADER_END@
- */
-#include <mach/kern_return.h>
-#include <kern/thread.h>
-#include <ppc/exception.h>
-#include <kern/ipc_tt.h>
-#include <ipc/ipc_port.h>
-#include <ppc/atomic_switch.h>
-#include <kern/thread_act.h>
-
-int	debugNotify = 0;
-
-/*
-** Function:	NotifyInterruption
-**
-** Inputs:	port			- mach_port for main thread
-**		ppcInterrupHandler	- interrupt handler to execute
-**		interruptStatePtr	- current interrupt state
-**		emulatorDescriptor	- where in emulator to notify
-**		originalPC		- where the emulator was executing
-**		originalR2		- new R2
-**
-** Outputs:
-**
-** Notes:
-**
-*/
-
-unsigned long
-syscall_notify_interrupt(mach_port_t, UInt32, UInt32 *, EmulatorDescriptor *,
-				void **	, void **, void *);
-
-unsigned long
-syscall_notify_interrupt(	mach_port_t		port_thread,
-				UInt32			ppcInterruptHandler,
-				UInt32 *		interruptStatePtr,
-				EmulatorDescriptor *	emulatorDescriptor,
-				void **			originalPC,
-				void **			originalR2,
-				void			*othread )
-{
-    kern_return_t	result; 
-    struct ppc_saved_state	*mainPCB;
-    thread_t		thread, nthread;
-    thread_act_t	act;
-    UInt32		interruptState, currentState, postIntMask;
-    extern thread_act_t port_name_to_act(mach_port_t);
-    boolean_t		isSelf, runningInKernel;
-	static unsigned long	sequence =0;
-
-#define	COPYIN_INTSTATE() { \
-	(void) copyin((char *) interruptStatePtr, (char *)&interruptState, sizeof(interruptState)); \
-	if (emulatorDescriptor) \
-		(void) copyin((char *) &emulatorDescriptor->postIntMask, (char *)&postIntMask, sizeof(postIntMask));  }
-#define	COPYOUT_INTSTATE() (void) copyout((char *) &interruptState, (char *)interruptStatePtr, sizeof(interruptState))
-
-
-    act = port_name_to_act(port_thread);
-
-   
-    if (act == THR_ACT_NULL) 
-	return port_thread;
-
-    runningInKernel = (act->mact.ksp == 0);
-    isSelf = (current_act() == act);
-
-    if (!isSelf) {
-    	/* First.. suspend the thread */
-	    result = thread_suspend(act);
-	
-	    if (result) {
-		act_deallocate(act);
-		return port_thread;
-	   }
-	
-	    /* Now try to find and wait for any pending activitations
-	     * to complete.. (the following is an expansion of 
-	     * thread_set_state())
-	     */
-	
-	    thread = act_lock_thread(act);
-	    if (!act->active) {
-		act_unlock_thread(act);
-		act_deallocate(act);
-		return port_thread;
-	   }
-	
-	   thread_hold(act);
-	
-	   while (1) {
-		if (!thread || act != thread->top_act)
-			break;
-	
-		act_unlock_thread(act);
-		(void) thread_stop_wait(thread);
-		nthread = act_lock_thread(act);
-		if (nthread == thread)
-			break;
-		thread_unstop(thread);
-		thread = nthread;
-	   }
-	
-	}
-
-	COPYIN_INTSTATE()
-	if (isSelf)
-		currentState = kOutsideMain;
-	else
-    		currentState = (interruptState & kInterruptStateMask) >> kInterruptStateShift; 
-
-    if (debugNotify > 5) {
-	printf("\nNotifyInterruption: %X, %X, %X, %X, %X, %X\n",
-		port_thread, ppcInterruptHandler, interruptStatePtr,
-		emulatorDescriptor, originalPC, originalR2 );
-    }
-    mainPCB = USER_REGS(act);
-
-    switch (currentState)
-    {
-    case kNotifyPending:
-    case kInUninitialized:
-	if (debugNotify > 2)
-		printf("NotifyInterrupt: kInUninitialized\n");
-	break;
-		
-    case kInPseudoKernel:
-    case kOutsideMain:
-	if (debugNotify > 2)
-		printf("NotifyInterrupt: kInPseudoKernel/kOutsideMain\n");
-	interruptState = interruptState
-		| ((postIntMask >> kCR2ToBackupShift) & kBackupCR2Mask);
-	COPYOUT_INTSTATE();
-	break;
-		
-    case kInSystemContext:
-	if (debugNotify > 2) 
-		printf("kInSystemContext: old CR %x, postIntMask %x, new CR %x\n",
-		mainPCB->cr, postIntMask, mainPCB->cr | postIntMask);
-	mainPCB->cr |= postIntMask;
-	break;
-		
-    case kInAlternateContext:
-	if (debugNotify > 2)
-	printf("kInAlternateContext: IN InterruptState %x, postIntMask %x\n",
-			interruptState, postIntMask);
-	interruptState = interruptState | ((postIntMask >> kCR2ToBackupShift) & kBackupCR2Mask);
-	interruptState = (interruptState & ~kInterruptStateMask);
-
-	if (runningInKernel)
-		interruptState |= (kNotifyPending << kInterruptStateShift);
-	else
-		interruptState |= (kInPseudoKernel << kInterruptStateShift);
-		
-	(void) copyout((char *)&mainPCB->srr0, (char *)originalPC, sizeof(originalPC));
-	(void) copyout((char *)&mainPCB->r2, (char *)originalR2, sizeof(originalR2));
-	COPYOUT_INTSTATE();
-	if (debugNotify > 2)
-	printf("kInAlternateContext: Out interruptState %x, Old PC %x, New %x, R2 %x\n",
-		interruptState, mainPCB->srr0, ppcInterruptHandler, mainPCB->r2);
-
-	mainPCB->srr0 = ppcInterruptHandler;
-	break;
-		
-    case kInExceptionHandler:
-	if (debugNotify > 2)
-		printf("NotifyInterrupt: kInExceptionHandler\n");
-	interruptState = interruptState | ((postIntMask >> kCR2ToBackupShift) & kBackupCR2Mask);
-	COPYOUT_INTSTATE();
-	break;
-		
-    default:
-	if (debugNotify)
-		printf("NotifyInterrupt: default ");
-		printf("Interruption while running in unknown state\n");
-		printf("interruptState = 0x%X\n",currentState);
-	break;
-    }
-
-	if (!isSelf) {
-		if (thread && act == thread->top_act)
-			thread_unstop(thread);
-		thread_release(act);
-   		act_unlock_thread(act);
-   		thread_resume(act);
-	}
-
-    act_deallocate(act);
-
-   return port_thread;
-}
diff --git a/osfmk/ppc/pcb.c b/osfmk/ppc/pcb.c
index 9150455d6..8354f6419 100644
--- a/osfmk/ppc/pcb.c
+++ b/osfmk/ppc/pcb.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -128,30 +131,26 @@ machine_kernel_stack_init(
 	void		(*start_pos)(thread_t))
 {
     vm_offset_t	stack;
-    unsigned int			*kss;
+    unsigned int			*kss, *stck;
 	struct savearea 		*sv;
 
     assert(thread->top_act->mact.pcb);
     assert(thread->kernel_stack);
     stack = thread->kernel_stack;
 
-#if	MACH_ASSERT
-    if (watchacts & WA_PCB)
-		printf("machine_kernel_stack_init(thr=%x,stk=%x,start_pos=%x)\n", thread,stack,start_pos);
-#endif	/* MACH_ASSERT */
-	
 	kss = (unsigned int *)STACK_IKS(stack);
 	sv = thread->top_act->mact.pcb;						/* This for the sake of C */
 
-	sv->save_lr = (unsigned int) start_pos;				/* Set up the execution address */
-	sv->save_srr0 = (unsigned int) start_pos;			/* Here too */
+	sv->save_lr = (uint64_t) start_pos;					/* Set up the execution address */
+	sv->save_srr0 = (uint64_t) start_pos;				/* Here too */
 	sv->save_srr1  = MSR_SUPERVISOR_INT_OFF;			/* Set the normal running MSR */
-	sv->save_r1 = (vm_offset_t) ((int)kss - KF_SIZE);	/* Point to the top frame on the stack */
+	stck = (unsigned int *)((unsigned int)kss - KF_SIZE);	/* Point to the top frame */
+	sv->save_r1 = (uint64_t)stck;						/* Point to the top frame on the stack */
 	sv->save_fpscr = 0;									/* Clear all floating point exceptions */
 	sv->save_vrsave = 0;								/* Set the vector save state */
 	sv->save_vscr[3] = 0x00010000;						/* Supress java mode */
 
-	*((int *)sv->save_r1) = 0;							/* Zero the frame backpointer */
+	*stck = 0;											/* Zero the frame backpointer */
 	thread->top_act->mact.ksp = 0;						/* Show that the kernel stack is in use already */
 
 }
@@ -171,6 +170,8 @@ switch_context(
 	register struct thread_shuttle* retval;
 	pmap_t	new_pmap;
 	facility_context *fowner;
+	struct per_proc_info *ppinfo;
+	
 	
 #if	MACH_LDEBUG || MACH_KDB
 	log_thread_action("switch", 
@@ -179,10 +180,10 @@ switch_context(
 			  (long)__builtin_return_address(0));
 #endif
 
-	per_proc_info[cpu_number()].old_thread = (unsigned int)old;
-	per_proc_info[cpu_number()].cpu_flags &= ~traceBE;  /* disable branch tracing if on */
-	assert(old_act->kernel_loaded ||
-	       active_stacks[cpu_number()] == old_act->thread->kernel_stack);
+	ppinfo = getPerProc();								/* Get our processor block */
+
+	ppinfo->old_thread = (unsigned int)old;
+	ppinfo->cpu_flags &= ~traceBE; 						 /* disable branch tracing if on */
 	       
 	check_simple_locks();
 
@@ -191,13 +192,13 @@ switch_context(
 	 * so that it can be found by the other if needed
 	 */
 	if(real_ncpus > 1) {								/* This is potentially slow, so only do when actually SMP */
-		fowner = per_proc_info[cpu_number()].FPU_owner;	/* Cache this because it may change */
+		fowner = ppinfo->FPU_owner;						/* Cache this because it may change */
 		if(fowner) {									/* Is there any live context? */
 			if(fowner->facAct == old->top_act) {		/* Is it for us? */
 				fpu_save(fowner);						/* Yes, save it */
 			}
 		}
-		fowner = per_proc_info[cpu_number()].VMX_owner;	/* Cache this because it may change */
+		fowner = ppinfo->VMX_owner;						/* Cache this because it may change */
 		if(fowner) {									/* Is there any live context? */
 			if(fowner->facAct == old->top_act) {		/* Is it for us? */
 				vec_save(fowner);						/* Yes, save it */
@@ -205,12 +206,14 @@ switch_context(
 		}
 	}
 
-#if DEBUG
-	if (watchacts & WA_PCB) {
-		printf("switch_context(0x%08x, 0x%x, 0x%08x)\n",
-		       old,continuation,new);
+	/*
+	 * If old thread is running VM, save per proc userProtKey and FamVMmode spcFlags bits in the thread spcFlags
+ 	 * This bits can be modified in the per proc without updating the thread spcFlags
+	 */
+	if(old_act->mact.specFlags & runningVM) {
+		old_act->mact.specFlags &=  ~(userProtKey|FamVMmode);
+		old_act->mact.specFlags |= (ppinfo->spcFlags) & (userProtKey|FamVMmode);
 	}
-#endif /* DEBUG */
 
 	/*
 	 * We do not have to worry about the PMAP module, so switch.
@@ -221,6 +224,9 @@ switch_context(
 
 	if(new_act->mact.specFlags & runningVM) {			/* Is the new guy running a VM? */
 		pmap_switch(new_act->mact.vmmCEntry->vmmPmap);	/* Switch to the VM's pmap */
+		ppinfo->VMMareaPhys = new_act->mact.vmmCEntry->vmmContextPhys;
+		ppinfo->VMMXAFlgs = new_act->mact.vmmCEntry->vmmXAFlgs;
+		ppinfo->FAMintercept = new_act->mact.vmmCEntry->vmmFAMintercept;
 	}
 	else {												/* otherwise, we use the task's pmap */
 		new_pmap = new_act->task->map->pmap;
@@ -229,14 +235,25 @@ switch_context(
 		}
 	}
 
+	if(old_act->mact.cioSpace != invalSpace) {			/* Does our old guy have an active copyin/out? */
+		old_act->mact.cioSpace |= cioSwitchAway;		/* Show we switched away from this guy */
+		hw_blow_seg(copyIOaddr);						/* Blow off the first segment */
+		hw_blow_seg(copyIOaddr + 0x10000000ULL);		/* Blow off the second segment */
+	}
+
 	KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_SCHED,MACH_SCHED) | DBG_FUNC_NONE,
 		     (int)old, (int)new, old->sched_pri, new->sched_pri, 0);
 
+/*	*********** SWITCH HERE **************/
 	retval = Switch_context(old, continuation, new);
 	assert(retval != (struct thread_shuttle*)NULL);
+/*	*********** SWITCH HERE **************/
+
 
-	if (branch_tracing_enabled())
-	  per_proc_info[cpu_number()].cpu_flags |= traceBE;  /* restore branch tracing */
+	if (branch_tracing_enabled()) {
+		ppinfo = getPerProc();							/* Get our processor block */
+	  	ppinfo->cpu_flags |= traceBE;  					/* restore branch tracing */
+	}
 
 	/* We've returned from having switched context, so we should be
 	 * back in the original context.
@@ -255,11 +272,6 @@ thread_set_syscall_return(
 	kern_return_t	retval)
 {
 
-#if	MACH_ASSERT
-	if (watchacts & WA_PCB)
-		printf("thread_set_syscall_return(thr=%x,retval=%d)\n", thread,retval);
-#endif	/* MACH_ASSERT */
-
         thread->top_act->mact.pcb->save_r3 = retval;
 }
 
@@ -277,11 +289,6 @@ thread_machine_create(
 	unsigned int	*CIsTooLimited, i;
 
 
-#if	MACH_ASSERT
-    if (watchacts & WA_PCB)
-	printf("thread_machine_create(thr=%x,thr_act=%x,st=%x)\n", thread, thr_act, start_pos);
-#endif	/* MACH_ASSERT */
-
 	hw_atomic_add(&saveanchor.savetarget, 4);				/* Account for the number of saveareas we think we "need"
 															   for this activation */
 	assert(thr_act->mact.pcb == (savearea *)0);				/* Make sure there was no previous savearea */
@@ -293,15 +300,12 @@ thread_machine_create(
 	sv->save_hdr.save_prev = 0;								/* Clear the back pointer */
 	sv->save_hdr.save_flags = (sv->save_hdr.save_flags & ~SAVtype) | (SAVgeneral << SAVtypeshft);	/* Mark as in use */
 	sv->save_hdr.save_act = thr_act;						/* Set who owns it */
-	sv->save_vscr[3] = 0x00010000;							/* Supress java mode */
 	thr_act->mact.pcb = sv;									/* Point to the save area */
 	thr_act->mact.curctx = &thr_act->mact.facctx;			/* Initialize facility context */
 	thr_act->mact.facctx.facAct = thr_act;					/* Initialize facility context pointer to activation */
+	thr_act->mact.cioSpace = invalSpace;					/* Initialize copyin/out space to invalid */
+	thr_act->mact.preemption_count = 0;						/* Initialize preemption counter */
 
-#if	MACH_ASSERT
-	if (watchacts & WA_PCB)
-		printf("pcb_init(%x) pcb=%x\n", thr_act, sv);
-#endif	/* MACH_ASSERT */
 	/*
 	 * User threads will pull their context from the pcb when first
 	 * returning to user mode, so fill in all the necessary values.
@@ -309,13 +313,14 @@ thread_machine_create(
 	 * at the base of the kernel stack (see stack_attach()).
 	 */
 
-	sv->save_srr1 = MSR_EXPORT_MASK_SET;					/* Set the default user MSR */
+	sv->save_srr1 = (uint64_t)MSR_EXPORT_MASK_SET;			/* Set the default user MSR */
+	sv->save_fpscr = 0;										/* Clear all floating point exceptions */
+	sv->save_vrsave = 0;									/* Set the vector save state */
+	sv->save_vscr[0] = 0x00000000;					
+	sv->save_vscr[1] = 0x00000000;					
+	sv->save_vscr[2] = 0x00000000;					
+	sv->save_vscr[3] = 0x00010000;							/* Disable java mode and clear saturated */
 	
-	CIsTooLimited = (unsigned int *)(&sv->save_sr0);		/* Make a pointer 'cause C can't cast on the left */
-	for(i=0; i<16; i++) {									/* Initialize all SRs */
-		CIsTooLimited[i] = SEG_REG_PROT | (i << 20) | thr_act->task->map->pmap->space;	/* Set the SR value */
-	}
-
     return(KERN_SUCCESS);
 }
 
@@ -364,19 +369,22 @@ machine_switch_act(
 {
 	pmap_t		new_pmap;
 	facility_context *fowner;
+	struct per_proc_info *ppinfo;
+	
+	ppinfo = getPerProc();								/* Get our processor block */
 
 	/* Our context might wake up on another processor, so we must
 	 * not keep hot state in our FPU, it must go back to the pcb
 	 * so that it can be found by the other if needed
 	 */
 	if(real_ncpus > 1) {								/* This is potentially slow, so only do when actually SMP */
-		fowner = per_proc_info[cpu_number()].FPU_owner;	/* Cache this because it may change */
+		fowner = ppinfo->FPU_owner;						/* Cache this because it may change */
 		if(fowner) {									/* Is there any live context? */
 			if(fowner->facAct == old) {					/* Is it for us? */
 				fpu_save(fowner);						/* Yes, save it */
 			}
 		}
-		fowner = per_proc_info[cpu_number()].VMX_owner;	/* Cache this because it may change */
+		fowner = ppinfo->VMX_owner;						/* Cache this because it may change */
 		if(fowner) {									/* Is there any live context? */
 			if(fowner->facAct == old) {					/* Is it for us? */
 				vec_save(fowner);						/* Yes, save it */
@@ -384,6 +392,8 @@ machine_switch_act(
 		}
 	}
 
+	old->mact.cioSpace |= cioSwitchAway;				/* Show we switched away from this guy */
+
 	active_stacks[cpu] = thread->kernel_stack;
 
 	ast_context(new, cpu);
@@ -393,8 +403,8 @@ machine_switch_act(
 	 * Change space if needed
 	 */
 
-	if(new->mact.specFlags & runningVM) {			/* Is the new guy running a VM? */
-		pmap_switch(new->mact.vmmCEntry->vmmPmap);	/* Switch to the VM's pmap */
+	if(new->mact.specFlags & runningVM) {				/* Is the new guy running a VM? */
+		pmap_switch(new->mact.vmmCEntry->vmmPmap);		/* Switch to the VM's pmap */
 	}
 	else {												/* otherwise, we use the task's pmap */
 		new_pmap = new->task->map->pmap;
@@ -403,13 +413,14 @@ machine_switch_act(
 		}
 	}
 
+
 }
 
 void
 pcb_user_to_kernel(thread_act_t act)
 {
 
-	return;													/* Not needed, I hope... */
+	return;												/* Not needed, I hope... */
 }
 
 
@@ -424,8 +435,8 @@ void
 act_machine_sv_free(thread_act_t act)
 {
 	register savearea *pcb, *userpcb;
-	register savearea_vec *vsv, *vpsv;
-	register savearea_fpu *fsv, *fpsv;
+	register savearea_vec *vsv, *vpst, *vsvt;
+	register savearea_fpu *fsv, *fpst, *fsvt;
 	register savearea *svp;
 	register int i;
 
@@ -437,40 +448,68 @@ act_machine_sv_free(thread_act_t act)
  *
  *	Walk through and release all floating point and vector contexts that are not
  *	user state.  We will also blow away live context if it belongs to non-user state.
+ *	Note that the level can not change while we are in this code.  Nor can another
+ *	context be pushed on the stack.
+ *
+ *	We do nothing here if the current level is user.  Otherwise,
+ *	the live context is cleared.  Then we find the user saved context.
+ *	Next,  we take the sync lock (to keep us from munging things in *_switch).
+ *	The level is set to 0 and all stacked context other than user is dequeued.
+ *	Then we unlock.  Next, all of the old kernel contexts are released.
  *
  */
  
  	if(act->mact.curctx->VMXlevel) {						/* Is the current level user state? */
+ 		
  		toss_live_vec(act->mact.curctx);					/* Dump live vectors if is not user */
- 		act->mact.curctx->VMXlevel = 0;						/* Mark as user state */
- 	}
 
-	vsv = act->mact.curctx->VMXsave;						/* Get the top vector savearea */
- 	
-	while(vsv) {											/* Any VMX saved state? */
-		vpsv = vsv;											/* Remember so we can toss this */
-		if (!vsv->save_hdr.save_level) break;   			/* Done when hit user if any */
-		vsv = (savearea_vec *)vsv->save_hdr.save_prev;		/* Get one underneath our's */		
-		save_ret((savearea *)vpsv);							/* Release it */
-	}
+		vsv = act->mact.curctx->VMXsave;					/* Get the top vector savearea */
+		
+		while(vsv && vsv->save_hdr.save_level) vsv = (savearea_vec *)vsv->save_hdr.save_prev;	/* Find user context if any */
 	
-	act->mact.curctx->VMXsave = vsv;						/* Queue the user context to the top */
+		if(!hw_lock_to((hw_lock_t)&act->mact.curctx->VMXsync, LockTimeOut)) {	/* Get the sync lock */ 
+			panic("act_machine_sv_free - timeout getting VMX sync lock\n");	/* Tell all and die */
+		}
+		
+		vsvt = act->mact.curctx->VMXsave;					/* Get the top of the chain */
+		act->mact.curctx->VMXsave = vsv;					/* Point to the user context */
+		act->mact.curctx->VMXlevel = 0;						/* Set the level to user */
+		hw_lock_unlock((hw_lock_t)&act->mact.curctx->VMXsync);	/* Unlock */
+		
+		while(vsvt) {										/* Clear any VMX saved state */
+			if (vsvt == vsv) break;   						/* Done when hit user if any */
+			vpst = vsvt;									/* Remember so we can toss this */
+			vsvt = (savearea_vec *)vsvt->save_hdr.save_prev;	/* Get one underneath our's */		
+			save_ret((savearea *)vpst);						/* Release it */
+		}
+		
+	}
  
  	if(act->mact.curctx->FPUlevel) {						/* Is the current level user state? */
- 		toss_live_fpu(act->mact.curctx);					/* Dump live float if is not user */
- 		act->mact.curctx->FPUlevel = 0;						/* Mark as user state */
- 	}
+ 		
+ 		toss_live_fpu(act->mact.curctx);					/* Dump live floats if is not user */
 
-	fsv = act->mact.curctx->FPUsave;						/* Get the top float savearea */
+		fsv = act->mact.curctx->FPUsave;					/* Get the top floats savearea */
+		
+		while(fsv && fsv->save_hdr.save_level) fsv = (savearea_fpu *)fsv->save_hdr.save_prev;	/* Find user context if any */
 	
-	while(fsv) {											/* Any float saved state? */
-		fpsv = fsv;											/* Remember so we can toss this */
-		if (!fsv->save_hdr.save_level) break;   			/* Done when hit user if any */
-		fsv = (savearea_fpu *)fsv->save_hdr.save_prev;		/* Get one underneath our's */		
-		save_ret((savearea *)fpsv);							/* Release it */
+		if(!hw_lock_to((hw_lock_t)&act->mact.curctx->FPUsync, LockTimeOut)) {	/* Get the sync lock */ 
+			panic("act_machine_sv_free - timeout getting FPU sync lock\n");	/* Tell all and die */
+		}
+		
+		fsvt = act->mact.curctx->FPUsave;					/* Get the top of the chain */
+		act->mact.curctx->FPUsave = fsv;					/* Point to the user context */
+		act->mact.curctx->FPUlevel = 0;						/* Set the level to user */
+		hw_lock_unlock((hw_lock_t)&act->mact.curctx->FPUsync);	/* Unlock */
+		
+		while(fsvt) {										/* Clear any VMX saved state */
+			if (fsvt == fsv) break;   						/* Done when hit user if any */
+			fpst = fsvt;									/* Remember so we can toss this */
+			fsvt = (savearea_fpu *)fsvt->save_hdr.save_prev;	/* Get one underneath our's */		
+			save_ret((savearea *)fpst);						/* Release it */
+		}
+		
 	}
-	
-	act->mact.curctx->FPUsave = fsv;						/* Queue the user context to the top */
 
 /*
  * free all regular saveareas except a user savearea, if any
@@ -523,11 +562,6 @@ act_machine_destroy(thread_act_t act)
 	register savearea *svp;
 	register int i;
 
-#if	MACH_ASSERT
-	if (watchacts & WA_PCB)
-		printf("act_machine_destroy(0x%x)\n", act);
-#endif	/* MACH_ASSERT */
-
 /*
  *	This function will release all context.
  */
@@ -594,10 +628,6 @@ act_machine_create(task_t task, thread_act_t thr_act)
 
 void act_machine_init()
 {
-#if	MACH_ASSERT
-    if (watchacts & WA_PCB)
-	printf("act_machine_init()\n");
-#endif	/* MACH_ASSERT */
 
     /* Good to verify these once */
     assert( THREAD_MACHINE_STATE_MAX <= THREAD_STATE_MAX );
@@ -618,14 +648,6 @@ act_machine_return(int code)
 {
     thread_act_t thr_act = current_act();
 
-#if	MACH_ASSERT
-    if (watchacts & WA_EXIT)
-	printf("act_machine_return(0x%x) cur_act=%x(%d) thr=%x(%d)\n",
-	       code, thr_act, thr_act->ref_count,
-	       thr_act->thread, thr_act->thread->ref_count);
-#endif	/* MACH_ASSERT */
-
-
 	/*
 	 * This code is called with nothing locked.
 	 * It also returns with nothing locked, if it returns.
@@ -792,10 +814,14 @@ stack_handoff(thread_t old,
 	vm_offset_t stack;
 	pmap_t new_pmap;
 	facility_context *fowner;
+	int	my_cpu;
+	mapping *mp;
+	struct per_proc_info *ppinfo;
 	
 	assert(new->top_act);
 	assert(old->top_act);
 	
+	my_cpu = cpu_number();
 	stack = stack_detach(old);
 	new->kernel_stack = stack;
 	if (stack == old->stack_privilege) {
@@ -804,22 +830,32 @@ stack_handoff(thread_t old,
 		new->stack_privilege = stack;
 	}
 
-	per_proc_info[cpu_number()].cpu_flags &= ~traceBE;
+	ppinfo = getPerProc();								/* Get our processor block */
+
+	ppinfo->cpu_flags &= ~traceBE;						/* Turn off special branch trace */
 
 	if(real_ncpus > 1) {								/* This is potentially slow, so only do when actually SMP */
-		fowner = per_proc_info[cpu_number()].FPU_owner;	/* Cache this because it may change */
+		fowner = ppinfo->FPU_owner;						/* Cache this because it may change */
 		if(fowner) {									/* Is there any live context? */
 			if(fowner->facAct == old->top_act) {		/* Is it for us? */
 				fpu_save(fowner);						/* Yes, save it */
 			}
 		}
-		fowner = per_proc_info[cpu_number()].VMX_owner;	/* Cache this because it may change */
+		fowner = ppinfo->VMX_owner;						/* Cache this because it may change */
 		if(fowner) {									/* Is there any live context? */
 			if(fowner->facAct == old->top_act) {		/* Is it for us? */
 				vec_save(fowner);						/* Yes, save it */
 			}
 		}
 	}
+	/*
+	 * If old thread is running VM, save per proc userProtKey and FamVMmode spcFlags bits in the thread spcFlags
+ 	 * This bits can be modified in the per proc without updating the thread spcFlags
+	 */
+	if(old->top_act->mact.specFlags & runningVM) {			/* Is the current thread running a VM? */
+		old->top_act->mact.specFlags &= ~(userProtKey|FamVMmode);
+		old->top_act->mact.specFlags |= (ppinfo->spcFlags) & (userProtKey|FamVMmode);
+	}
 
 	KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_SCHED,MACH_STACK_HANDOFF) | DBG_FUNC_NONE,
 		     (int)old, (int)new, old->sched_pri, new->sched_pri, 0);
@@ -827,6 +863,9 @@ stack_handoff(thread_t old,
 
 	if(new->top_act->mact.specFlags & runningVM) {	/* Is the new guy running a VM? */
 		pmap_switch(new->top_act->mact.vmmCEntry->vmmPmap);	/* Switch to the VM's pmap */
+		ppinfo->VMMareaPhys = new->top_act->mact.vmmCEntry->vmmContextPhys;
+		ppinfo->VMMXAFlgs = new->top_act->mact.vmmCEntry->vmmXAFlgs;
+		ppinfo->FAMintercept = new->top_act->mact.vmmCEntry->vmmFAMintercept;
 	}
 	else {											/* otherwise, we use the task's pmap */
 		new_pmap = new->top_act->task->map->pmap;
@@ -836,16 +875,20 @@ stack_handoff(thread_t old,
 	}
 
 	thread_machine_set_current(new);
-	active_stacks[cpu_number()] = new->kernel_stack;
-	per_proc_info[cpu_number()].Uassist = new->top_act->mact.cthread_self;
+	active_stacks[my_cpu] = new->kernel_stack;
+	ppinfo->Uassist = new->top_act->mact.cthread_self;
 
-	per_proc_info[cpu_number()].ppbbTaskEnv = new->top_act->mact.bbTaskEnv;
-	per_proc_info[cpu_number()].spcFlags = new->top_act->mact.specFlags;
+	ppinfo->ppbbTaskEnv = new->top_act->mact.bbTaskEnv;
+	ppinfo->spcFlags = new->top_act->mact.specFlags;
+	
+	old->top_act->mact.cioSpace |= cioSwitchAway;	/* Show we switched away from this guy */
+	mp = (mapping *)&ppinfo->ppCIOmp;
+	mp->mpSpace = invalSpace;						/* Since we can't handoff in the middle of copy in/out, just invalidate */
 
 	if (branch_tracing_enabled()) 
-		per_proc_info[cpu_number()].cpu_flags |= traceBE;
+		ppinfo->cpu_flags |= traceBE;
     
-	if(trcWork.traceMask) dbgTrace(0x12345678, (unsigned int)old->top_act, (unsigned int)new->top_act);	/* Cut trace entry if tracing */    
+	if(trcWork.traceMask) dbgTrace(0x12345678, (unsigned int)old->top_act, (unsigned int)new->top_act, 0);	/* Cut trace entry if tracing */    
     
   return;
 }
diff --git a/osfmk/ppc/pmap.c b/osfmk/ppc/pmap.c
index 85fabb668..9205cae2f 100644
--- a/osfmk/ppc/pmap.c
+++ b/osfmk/ppc/pmap.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -96,6 +99,7 @@
 #include <kern/simple_lock.h>
 #include <mach/vm_attributes.h>
 #include <mach/vm_param.h>
+#include <vm/vm_kern.h>
 #include <kern/spl.h>
 
 #include <kern/misc_protos.h>
@@ -107,7 +111,6 @@
 #include <vm/vm_page.h>
 
 #include <ppc/pmap.h>
-#include <ppc/pmap_internals.h>
 #include <ppc/mem.h>
 #include <ppc/mappings.h>
 
@@ -115,35 +118,21 @@
 #include <ppc/Firmware.h>
 #include <ppc/savearea.h>
 #include <ppc/exception.h>
+#include <ppc/low_trace.h>
 #include <ddb/db_output.h>
 
-#if	DB_MACHINE_COMMANDS
-/* optionally enable traces of pmap operations in post-mortem trace table */
-/* #define PMAP_LOWTRACE 1 */
-#define PMAP_LOWTRACE 0
-#else	/* DB_MACHINE_COMMANDS */
-/* Can not trace even if we wanted to */
-#define PMAP_LOWTRACE 0
-#endif	/* DB_MACHINE_COMMANDS */
-
-#define PERFTIMES 0
-
-#if PERFTIMES && DEBUG
-#define debugLog2(a, b, c) dbgLog2(a, b, c)
-#else
-#define debugLog2(a, b, c)
-#endif
-
 extern unsigned int	avail_remaining;
 extern unsigned int	mappingdeb0;
 extern	struct 	Saveanchor saveanchor;						/* Aliged savearea anchor */
 extern int 		real_ncpus;									/* Number of actual CPUs */
-unsigned int debugbackpocket;								/* (TEST/DEBUG) */
+unsigned int 	debugbackpocket;							/* (TEST/DEBUG) */
 
-vm_offset_t		avail_next;
 vm_offset_t		first_free_virt;
 int          	current_free_region;						/* Used in pmap_next_page */
 
+pmapTransTab *pmapTrans;									/* Point to the hash to pmap translations */
+struct phys_entry *phys_table;
+
 /* forward */
 void pmap_activate(pmap_t pmap, thread_t th, int which_cpu);
 void pmap_deactivate(pmap_t pmap, thread_t th, int which_cpu);
@@ -153,28 +142,20 @@ void copy_to_phys(vm_offset_t sva, vm_offset_t dpa, int bytecount);
 int pmap_list_resident_pages(pmap_t pmap, vm_offset_t *listp, int space);
 #endif
 
-#if DEBUG
-#define PDB_USER	0x01	/* exported functions */
-#define PDB_MAPPING	0x02	/* low-level mapping routines */
-#define PDB_ENTER	0x04	/* pmap_enter specifics */
-#define PDB_COPY	0x08	/* copy page debugging */
-#define PDB_ZERO	0x10	/* zero page debugging */
-#define PDB_WIRED	0x20	/* things concerning wired entries */
-#define PDB_PTEG	0x40	/* PTEG overflows */
-#define PDB_LOCK	0x100	/* locks */
-#define PDB_IO		0x200	/* Improper use of WIMG_IO checks - PCI machines */
-
-int pmdebug=0;
-#endif
-
 /*  NOTE:  kernel_pmap_store must be in V=R storage and aligned!!!!!!!!!!!!!! */
 
 extern struct pmap	kernel_pmap_store;
 pmap_t		kernel_pmap;			/* Pointer to kernel pmap and anchor for in-use pmaps */		
+addr64_t	kernel_pmap_phys;		/* Pointer to kernel pmap and anchor for in-use pmaps, physical address */		
 pmap_t		cursor_pmap;			/* Pointer to last pmap allocated or previous if removed from in-use list */
+pmap_t		sharedPmap;				/* Pointer to common pmap for 64-bit address spaces */
 struct zone	*pmap_zone;				/* zone of pmap structures */
 boolean_t	pmap_initialized = FALSE;
 
+int ppc_max_pmaps;					/* Maximum number of concurrent address spaces allowed. This is machine dependent */	
+addr64_t vm_max_address;			/* Maximum effective address supported */
+addr64_t vm_max_physical;			/* Maximum physical address supported */
+
 /*
  * Physical-to-virtual translations are handled by inverted page table
  * structures, phys_tables.  Multiple mappings of a single page are handled
@@ -182,11 +163,6 @@ boolean_t	pmap_initialized = FALSE;
  * for phys_tables of the physical memory we know about, but more may be
  * added as it is discovered (eg. by drivers).
  */
-struct phys_entry *phys_table;		/* For debugging */
-
-lock_t	pmap_system_lock;
-
-decl_simple_lock_data(,tlb_system_lock)
 
 /*
  *	free pmap list. caches the first free_pmap_max pmaps that are freed up
@@ -200,121 +176,34 @@ decl_simple_lock_data(,free_pmap_lock)
  * Function to get index into phys_table for a given physical address
  */
 
-struct phys_entry *pmap_find_physentry(vm_offset_t pa)
+struct phys_entry *pmap_find_physentry(ppnum_t pa)
 {
 	int i;
-	struct phys_entry *entry;
+	unsigned int entry;
 
-	for (i = pmap_mem_regions_count-1; i >= 0; i--) {
-		if (pa < pmap_mem_regions[i].start)
-			continue;
-		if (pa >= pmap_mem_regions[i].end)
-			return PHYS_NULL;
+	for (i = pmap_mem_regions_count - 1; i >= 0; i--) {
+		if (pa < pmap_mem_regions[i].mrStart) continue;	/* See if we fit in this region */
+		if (pa > pmap_mem_regions[i].mrEnd) continue;	/* Check the end too */
 		
-		entry = &pmap_mem_regions[i].phys_table[(pa - pmap_mem_regions[i].start) >> PPC_PGSHIFT];
-		__asm__ volatile("dcbt 0,%0" : : "r" (entry));	/* We will use this in a little bit */
-		return entry;
+		entry = (unsigned int)pmap_mem_regions[i].mrPhysTab + ((pa - pmap_mem_regions[i].mrStart) * sizeof(phys_entry));
+		return (struct phys_entry *)entry;
 	}
-	kprintf("DEBUG : pmap_find_physentry 0x%08x out of range\n",pa);
-	return PHYS_NULL;
+//	kprintf("DEBUG - pmap_find_physentry: page 0x%08X not found\n", pa);
+	return 0;
 }
 
 /*
  * kern_return_t
  * pmap_add_physical_memory(vm_offset_t spa, vm_offset_t epa,
  *                          boolean_t available, unsigned int attr)
- *	Allocate some extra physentries for the physical addresses given,
- *	specifying some default attribute that on the powerpc specifies
- *      the default cachability for any mappings using these addresses
- *	If the memory is marked as available, it is added to the general
- *	VM pool, otherwise it is not (it is reserved for card IO etc).
+ *
+ *	THIS IS NOT SUPPORTED
  */
 kern_return_t pmap_add_physical_memory(vm_offset_t spa, vm_offset_t epa,
 				       boolean_t available, unsigned int attr)
 {
-	int i,j;
-	spl_t s;
-
-	/* Only map whole pages */
 	
 	panic("Forget it! You can't map no more memory, you greedy puke!\n");
-
-	spa = trunc_page(spa);
-	epa = round_page(epa);
-
-	/* First check that the region doesn't already exist */
-
-	assert (epa >= spa);
-	for (i = 0; i < pmap_mem_regions_count; i++) {
-		/* If we're below the next region, then no conflict */
-		if (epa < pmap_mem_regions[i].start)
-			break;
-		if (spa < pmap_mem_regions[i].end) {
-#if DEBUG
-			kprintf("pmap_add_physical_memory(0x%08x,0x%08x,0x%08x) - memory already present\n",spa,epa,attr);
-#endif /* DEBUG */
-			return KERN_NO_SPACE;
-		}
-	}
-
-#if DEBUG
-	kprintf("pmap_add_physical_memory; region insert spot: %d out of %d\n", i, pmap_mem_regions_count);	/* (TEST/DEBUG) */
-#endif
-
-	/* Check that we've got enough space for another region */
-	if (pmap_mem_regions_count == PMAP_MEM_REGION_MAX)
-		return KERN_RESOURCE_SHORTAGE;
-
-	/* Once here, i points to the mem_region above ours in physical mem */
-
-	/* allocate a new phys_table for this new region */
-#if DEBUG
-	kprintf("pmap_add_physical_memory; kalloc\n");	/* (TEST/DEBUG) */
-#endif
-
-	phys_table =  (struct phys_entry *)
-		kalloc(sizeof(struct phys_entry) * atop(epa-spa));
-#if DEBUG
-	kprintf("pmap_add_physical_memory; new phys_table: %08X\n", phys_table);	/* (TEST/DEBUG) */
-#endif
-
-	/* Initialise the new phys_table entries */
-	for (j = 0; j < atop(epa-spa); j++) {
-		
-		phys_table[j].phys_link = MAPPING_NULL;
-		
-		mapping_phys_init(&phys_table[j], spa+(j*PAGE_SIZE), attr);	/* Initialize the hardware specific portions */
-
-	}
-	s = splhigh();
-	
-	/* Move all the phys_table entries up some to make room in
-	 * the ordered list.
-	 */
-	for (j = pmap_mem_regions_count; j > i ; j--)
-		pmap_mem_regions[j] = pmap_mem_regions[j-1];
-
-	/* Insert a new entry with some memory to back it */
-
-	pmap_mem_regions[i].start 	     = spa;
-	pmap_mem_regions[i].end           = epa;
-	pmap_mem_regions[i].phys_table    = phys_table;
-
-	pmap_mem_regions_count++;
-	splx(s);
-	
-#if DEBUG
-	for(i=0; i<pmap_mem_regions_count; i++) {			/* (TEST/DEBUG) */
-		kprintf("region %d: %08X %08X %08X\n", i, pmap_mem_regions[i].start,
-			pmap_mem_regions[i].end, pmap_mem_regions[i].phys_table);	/* (TEST/DEBUG) */
-	}
-#endif
-
-	if (available) {
-		kprintf("warning : pmap_add_physical_mem() "
-		       "available not yet supported\n");
-	}
-
 	return KERN_SUCCESS;
 }
 
@@ -331,7 +220,10 @@ kern_return_t pmap_add_physical_memory(vm_offset_t spa, vm_offset_t epa,
  *	Pages with a contiguous virtual address range, the same protection, and attributes.
  *	therefore, we map it with a single block.
  *
+ *	Note that this call will only map into 32-bit space
+ *
  */
+
 vm_offset_t
 pmap_map(
 	vm_offset_t va,
@@ -340,71 +232,18 @@ pmap_map(
 	vm_prot_t prot)
 {
 
-
-	if (spa == epa)
-		return(va);
-
-	assert(epa > spa);
-	debugLog2(40, va, spa);								/* Log pmap_map call */
-
-	pmap_map_block(kernel_pmap, va, spa, epa - spa, prot, PTE_WIMG_DEFAULT, blkPerm);	/* Set up a permanent block mapped area */
-
-	debugLog2(41, epa, prot);							/* Log pmap_map call */
-
-	return(va);
-}
-
-/*
- * pmap_map_bd(va, spa, epa, prot)
- *	Back-door routine for mapping kernel VM at initialisation.
- *	Used for mapping memory outside the known physical memory
- *      space, with caching disabled. Designed for use by device probes.
- * 
- *	A virtual address range starting at "va" is mapped to the physical
- *	address range "spa" to "epa" with machine independent protection
- *	"prot".
- *
- *	"va", "spa", and "epa" are byte addresses and must be on machine
- *	independent page boundaries.
- *
- * WARNING: The current version of memcpy() can use the dcbz instruction
- * on the destination addresses.  This will cause an alignment exception
- * and consequent overhead if the destination is caching-disabled.  So
- * avoid memcpy()ing into the memory mapped by this function.
- *
- * also, many other pmap_ routines will misbehave if you try and change
- * protections or remove these mappings, they are designed to be permanent.
- *
- * These areas will be added to the autogen list, if possible.  Existing translations
- * are overridden and their mapping stuctures are released.  This takes place in
- * the autogen_map function.
- *
- * Locking:
- *	this routine is called only during system initialization when only
- *	one processor is active, so no need to take locks...
- */
-vm_offset_t
-pmap_map_bd(
-	vm_offset_t va,
-	vm_offset_t spa,
-	vm_offset_t epa,
-	vm_prot_t prot)
-{
-	register struct mapping *mp;
-	register struct phys_entry 	*pp;
+	addr64_t colladr;
 	
-
-	if (spa == epa)
-		return(va);
+	if (spa == epa) return(va);
 
 	assert(epa > spa);
 
-	debugLog2(42, va, epa);								/* Log pmap_map_bd call */
-
-	pmap_map_block(kernel_pmap, va, spa, epa - spa, prot, PTE_WIMG_IO, blkPerm);	/* Set up autogen area */
-
-	debugLog2(43, epa, prot);							/* Log pmap_map_bd exit */
+	colladr = mapping_make(kernel_pmap, (addr64_t)va, (ppnum_t)(spa >> 12), (mmFlgBlock | mmFlgPerm), (epa - spa) >> 12, prot & VM_PROT_ALL);
 
+	if(colladr) {											/* Was something already mapped in the range? */
+		panic("pmap_map: attempt to map previously mapped range - va = %08X, pa = %08X, epa = %08X, collision = %016llX\n",
+			va, spa, epa, colladr);
+	}				
 	return(va);
 }
 
@@ -414,303 +253,203 @@ pmap_map_bd(
  *	Called with mapping done by BATs. Page_size must already be set.
  *
  *	Parameters:
- *	mem_size:	Total memory present
+ *	msize:	Total memory present
  *	first_avail:	First virtual address available
- *	first_phys_avail:	First physical address available
+ *	kmapsize:	Size of kernel text and data
  */
 void
-pmap_bootstrap(unsigned int mem_size, vm_offset_t *first_avail, vm_offset_t *first_phys_avail, unsigned int kmapsize)
+pmap_bootstrap(uint64_t msize, vm_offset_t *first_avail, unsigned int kmapsize)
 {
 	register struct mapping *mp;
 	vm_offset_t 	addr;
 	vm_size_t 		size;
-	int 			i, num, j, rsize, mapsize, vmpagesz, vmmapsz;
-	unsigned int	 mask;
-	vm_offset_t		first_used_addr;
-	PCA				*pcaptr;
+	int 			i, num, j, rsize, mapsize, vmpagesz, vmmapsz, bank, nbits;
+	uint64_t		tmemsize;
+	uint_t			htslop;
+	vm_offset_t		first_used_addr, PCAsize;
+	struct phys_entry *phys_table;
 
-	*first_avail = round_page(*first_avail);
-	
-#if DEBUG
-	kprintf("first_avail=%08X; first_phys_avail=%08X; avail_remaining=%d\n", 
-		*first_avail, *first_phys_avail, avail_remaining);
-#endif
-
-	assert(PAGE_SIZE == PPC_PGBYTES);
+	*first_avail = round_page_32(*first_avail);				/* Make sure we start out on a page boundary */
+	vm_last_addr = VM_MAX_KERNEL_ADDRESS;					/* Set the highest address know to VM */
 
 	/*
 	 * Initialize kernel pmap
 	 */
 	kernel_pmap = &kernel_pmap_store;
+	kernel_pmap_phys = (addr64_t)&kernel_pmap_store;
 	cursor_pmap = &kernel_pmap_store;
 
-	lock_init(&pmap_system_lock,
-		  FALSE,		/* NOT a sleep lock */
-		  ETAP_VM_PMAP_SYS,
-		  ETAP_VM_PMAP_SYS_I);
-
 	simple_lock_init(&kernel_pmap->lock, ETAP_VM_PMAP_KERNEL);
 
 	kernel_pmap->pmap_link.next = (queue_t)kernel_pmap;		/* Set up anchor forward */
 	kernel_pmap->pmap_link.prev = (queue_t)kernel_pmap;		/* Set up anchor reverse */
 	kernel_pmap->ref_count = 1;
+	kernel_pmap->pmapFlags = pmapKeyDef;					/* Set the default keys */
+	kernel_pmap->pmapCCtl = pmapCCtlVal;					/* Initialize cache control */
 	kernel_pmap->space = PPC_SID_KERNEL;
-	kernel_pmap->pmapvr = 0;						/* Virtual = Real  */
-	kernel_pmap->bmaps = 0;							/* No block pages just yet */
-	for(i=0; i < 128; i++) {						/* Clear usage slots */
-		kernel_pmap->pmapUsage[i] = 0;
-	}
-	for(i=0; i < 16; i++) {							/* Initialize for laughs */
-		kernel_pmap->pmapSegs[i] = SEG_REG_PROT | (i << 20) | PPC_SID_KERNEL;
-	}
-
-	/*
-	 * Allocate: (from first_avail up)
-	 *      Aligned to its own size:
-     	 *       hash table (for mem size 2**x, allocate 2**(x-10) entries)
-	 *	 mapping table (same size and immediatly following hash table)
-	 */
-	/* hash_table_size must be a power of 2, recommended sizes are
-	 * taken from PPC601 User Manual, table 6-19. We take the next
-	 * highest size if mem_size is not a power of two.
-	 * TODO NMGS make this configurable at boot time.
-	 */
-
-	num = sizeof(pte_t) * (mem_size >> 10);
-
-	for (hash_table_size = 64 * 1024;	/* minimum size = 64Kbytes */
-	     hash_table_size < num; 
-	     hash_table_size *= 2)
-		continue;
+	kernel_pmap->pmapvr = 0;								/* Virtual = Real  */
 
-	if (num > (sizeof(pte_t) * 524288))
-		hash_table_size = hash_table_size/2; /* reduce by half above 512MB */
+/*
+ *	The hash table wants to have one pteg for every 2 physical pages.
+ *	We will allocate this in physical RAM, outside of kernel virtual memory,
+ *	at the top of the highest bank that will contain it.
+ *	Note that "bank" doesn't refer to a physical memory slot here, it is a range of
+ *	physically contiguous memory.
+ *
+ *	The PCA will go there as well, immediately before the hash table.
+ */
+ 
+	nbits = cntlzw(((msize << 1) - 1) >> 32);				/* Get first bit in upper half */
+	if(nbits == 32) nbits = nbits + cntlzw((uint_t)((msize << 1) - 1));	/* If upper half was empty, find bit in bottom half */
+ 	tmemsize = 0x8000000000000000ULL >> nbits;					/* Get memory size rounded up to power of 2 */
+ 	
+ 	if(tmemsize > 0x0000002000000000ULL) tmemsize = 0x0000002000000000ULL;	/* Make sure we don't make an unsupported hash table size */
 
-	/* Scale to within any physical memory layout constraints */
-	do {
-		num = atop(mem_size);	/* num now holds mem_size in pages */
+ 	hash_table_size = (uint_t)(tmemsize >> 13) * per_proc_info[0].pf.pfPTEG;	/* Get provisional hash_table_size */
+ 	if(hash_table_size < (256 * 1024)) hash_table_size = (256 * 1024);	/* Make sure we are at least minimum size */	
 
-		/* size of all structures that we're going to allocate */
+	while(1) {												/* Try to fit hash table in PCA into contiguous memory */
 
-		size = (vm_size_t) (
-			(InitialSaveBloks * PAGE_SIZE) +	/* Allow space for the initial context saveareas */
-			((InitialSaveBloks / 2) * PAGE_SIZE) +	/* For backpocket saveareas */
-			hash_table_size +					/* For hash table */
-			hash_table_size +					/* For PTEG allocation table */
-			(num * sizeof(struct phys_entry))	/* For the physical entries */
-			);
+		if(hash_table_size < (256 * 1024)) {				/* Have we dropped too short? This should never, ever happen */
+			panic("pmap_bootstrap: Can't find space for hash table\n");	/* This will never print, system isn't up far enough... */
+		}
 
-		mapsize = size = round_page(size);		/* Get size of area to map that we just calculated */
-		mapsize = mapsize + kmapsize;			/* Account for the kernel text size */
+		PCAsize = (hash_table_size / per_proc_info[0].pf.pfPTEG) * sizeof(PCA);	/* Get total size of PCA table */
+		PCAsize = round_page_32(PCAsize);					/* Make sure it is at least a page long */
+	
+		for(bank = pmap_mem_regions_count - 1; bank >= 0; bank--) {	/* Search backwards through banks */
+			
+			hash_table_base = ((addr64_t)pmap_mem_regions[bank].mrEnd << 12) - hash_table_size + PAGE_SIZE;	/* Get tenative address */
+			
+			htslop = hash_table_base & (hash_table_size - 1);	/* Get the extra that we will round down when we align */
+			hash_table_base = hash_table_base & -(addr64_t)hash_table_size;	/* Round down to correct boundary */
+			
+			if((hash_table_base - round_page_32(PCAsize)) >= ((addr64_t)pmap_mem_regions[bank].mrStart << 12)) break;	/* Leave if we fit */
+		}
+		
+		if(bank >= 0) break;								/* We are done if we found a suitable bank */
+		
+		hash_table_size = hash_table_size >> 1;				/* Try the next size down */
+	}
 
-		vmpagesz = round_page(num * sizeof(struct vm_page));	/* Allow for all vm_pages needed to map physical mem */
-		vmmapsz = round_page((num / 8) * sizeof(struct vm_map_entry));	/* Allow for vm_maps */
+	if(htslop) {											/* If there was slop (i.e., wasted pages for alignment) add a new region */
+		for(i = pmap_mem_regions_count - 1; i >= bank; i--) {	/* Copy from end to our bank, including our bank */
+			pmap_mem_regions[i + 1].mrStart  = pmap_mem_regions[i].mrStart;	/* Set the start of the bank */
+			pmap_mem_regions[i + 1].mrAStart = pmap_mem_regions[i].mrAStart;	/* Set the start of allocatable area */
+			pmap_mem_regions[i + 1].mrEnd    = pmap_mem_regions[i].mrEnd;	/* Set the end address of bank */
+			pmap_mem_regions[i + 1].mrAEnd   = pmap_mem_regions[i].mrAEnd;	/* Set the end address of allocatable area */
+		}
 		
-		mapsize = mapsize + vmpagesz + vmmapsz;	/* Add the VM system estimates into the grand total */
-
-		mapsize = mapsize + (4 * 1024 * 1024);	/* Allow for 4 meg of extra mappings */
-		mapsize = ((mapsize / PAGE_SIZE) + MAPPERBLOK - 1) / MAPPERBLOK;	/* Get number of blocks of mappings we need */
-		mapsize = mapsize + ((mapsize  + MAPPERBLOK - 1) / MAPPERBLOK);	/* Account for the mappings themselves */
-
-#if DEBUG
-		kprintf("pmap_bootstrap: initial vm_pages     = %08X\n", vmpagesz);
-		kprintf("pmap_bootstrap: initial vm_maps      = %08X\n", vmmapsz);
-		kprintf("pmap_bootstrap: size before mappings = %08X\n", size);
-		kprintf("pmap_bootstrap: kernel map size      = %08X\n", kmapsize);
-		kprintf("pmap_bootstrap: mapping blocks rqrd  = %08X\n", mapsize);
-#endif
+		pmap_mem_regions[i + 1].mrStart  = (hash_table_base + hash_table_size) >> 12;	/* Set the start of the next bank to the start of the slop area */
+		pmap_mem_regions[i + 1].mrAStart = (hash_table_base + hash_table_size) >> 12;	/* Set the start of allocatable area to the start of the slop area */
+		pmap_mem_regions[i].mrEnd        = (hash_table_base + hash_table_size - 4096) >> 12;	/* Set the end of our bank to the end of the hash table */
 		
-		size = size + (mapsize * PAGE_SIZE);	/* Get the true size we need */
+	}		
+	
+	pmap_mem_regions[bank].mrAEnd = (hash_table_base - PCAsize - 4096) >> 12;	/* Set the maximum allocatable in this bank */
+	
+	hw_hash_init();											/* Initiaize the hash table and PCA */
+	hw_setup_trans();										/* Set up hardware registers needed for translation */
+	
+/*
+ *	The hash table is now all initialized and so is the PCA.  Go on to do the rest of it.
+ *	This allocation is from the bottom up.
+ */	
+	
+	num = atop_64(msize);										/* Get number of pages in all of memory */
 
-		/* hash table must be aligned to its size */
+/* Figure out how much we need to allocate */
 
-		addr = (*first_avail +
-			(hash_table_size-1)) & ~(hash_table_size-1);
+	size = (vm_size_t) (
+		(InitialSaveBloks * PAGE_SIZE) +					/* Allow space for the initial context saveareas */
+		(BackPocketSaveBloks * PAGE_SIZE) +					/* For backpocket saveareas */
+		trcWork.traceSize +								/* Size of trace table */
+		((((1 << maxAdrSpb) * sizeof(pmapTransTab)) + 4095) & -4096) +	/* Size of pmap translate table */
+		(((num * sizeof(struct phys_entry)) + 4095) & -4096) 	/* For the physical entries */
+	);
 
-		if (addr + size > pmap_mem_regions[0].end) {
-			hash_table_size /= 2;
-		} else {
-			break;
-		}
-		/* If we have had to shrink hash table to too small, panic */
-		if (hash_table_size == 32 * 1024)
-			panic("cannot lay out pmap memory map correctly");
-	} while (1);
-	
-#if DEBUG
-	kprintf("hash table size=%08X, total size of area=%08X, addr=%08X\n", 
-		hash_table_size, size, addr);
-#endif
-	if (round_page(*first_phys_avail) < trunc_page(addr)) {
-		/* We are stepping over at least one page here, so
-		 * add this region to the free regions so that it can
-		 * be allocated by pmap_steal
-		 */
-		free_regions[free_regions_count].start = round_page(*first_phys_avail);
-		free_regions[free_regions_count].end = trunc_page(addr);
-
-		avail_remaining += (free_regions[free_regions_count].end -
-				    free_regions[free_regions_count].start) /
-					    PPC_PGBYTES;
-#if DEBUG
-		kprintf("ADDED FREE REGION from 0x%08x to 0x%08x, avail_remaining = %d\n",
-			free_regions[free_regions_count].start,free_regions[free_regions_count].end, 
-			avail_remaining);
-#endif /* DEBUG */
-		free_regions_count++;
-	}
+	mapsize = size = round_page_32(size);						/* Get size of area to map that we just calculated */
+	mapsize = mapsize + kmapsize;							/* Account for the kernel text size */
 
-	/* Zero everything - this also invalidates the hash table entries */
-	bzero((char *)addr, size);
+	vmpagesz = round_page_32(num * sizeof(struct vm_page));	/* Allow for all vm_pages needed to map physical mem */
+	vmmapsz = round_page_32((num / 8) * sizeof(struct vm_map_entry));	/* Allow for vm_maps */
+	
+	mapsize = mapsize + vmpagesz + vmmapsz;					/* Add the VM system estimates into the grand total */
 
-	/* Set up some pointers to our new structures */
+	mapsize = mapsize + (4 * 1024 * 1024);					/* Allow for 4 meg of extra mappings */
+	mapsize = ((mapsize / PAGE_SIZE) + MAPPERBLOK - 1) / MAPPERBLOK;	/* Get number of blocks of mappings we need */
+	mapsize = mapsize + ((mapsize  + MAPPERBLOK - 1) / MAPPERBLOK);	/* Account for the mappings themselves */
 
-	/* from here,  addr points to the next free address */
-	
-	first_used_addr = addr;	/* remember where we started */
+	size = size + (mapsize * PAGE_SIZE);					/* Get the true size we need */
 
-	/* Set up hash table address and dma buffer address, keeping
-	 * alignment. These mappings are all 1-1,  so dma_r == dma_v
-	 * 
-	 * If hash_table_size == dma_buffer_alignment, then put hash_table
-	 * first, since dma_buffer_size may be smaller than alignment, but
-	 * hash table alignment==hash_table_size.
-	 */
-	hash_table_base = addr;
-		
-	addr += hash_table_size;
-	addr += hash_table_size;							/* Add another for the PTEG Control Area */
-	assert((hash_table_base & (hash_table_size-1)) == 0);
+	/* hash table must be aligned to its size */
 
-	pcaptr = (PCA *)(hash_table_base+hash_table_size);	/* Point to the PCA table */
-	mapCtl.mapcflush.pcaptr = pcaptr;
-	
-	for(i=0; i < (hash_table_size/64) ; i++) {			/* For all of PTEG control areas: */
-		pcaptr[i].flgs.PCAalflgs.PCAfree=0xFF;			/* Mark all slots free */
-		pcaptr[i].flgs.PCAalflgs.PCAsteal=0x01;			/* Initialize steal position */
-	}
-	
- 	savearea_init(&addr);								/* Initialize the savearea chains and data */
- 
-	/* phys_table is static to help debugging,
-	 * this variable is no longer actually used
-	 * outside of this scope
-	 */
+	addr = *first_avail;									/* Set the address to start allocations */
+	first_used_addr = addr;									/* Remember where we started */
 
-	phys_table = (struct phys_entry *) addr;
+	bzero((char *)addr, size);								/* Clear everything that we are allocating */
 
-#if DEBUG
-	kprintf("hash_table_base                 =%08X\n", hash_table_base);
-	kprintf("phys_table                      =%08X\n", phys_table);
-	kprintf("pmap_mem_regions_count          =%08X\n", pmap_mem_regions_count);
-#endif
+ 	savearea_init(addr);									/* Initialize the savearea chains and data */
+
+	addr = (vm_offset_t)((unsigned int)addr + ((InitialSaveBloks + BackPocketSaveBloks) * PAGE_SIZE));	/* Point past saveareas */
+
+	trcWork.traceCurr = (unsigned int)addr;					/* Set first trace slot to use */
+	trcWork.traceStart = (unsigned int)addr;				/* Set start of trace table */
+	trcWork.traceEnd = (unsigned int)addr + trcWork.traceSize;		/* Set end of trace table */
 
-	for (i = 0; i < pmap_mem_regions_count; i++) {
+	addr = (vm_offset_t)trcWork.traceEnd;					/* Set next allocatable location */
 		
-		pmap_mem_regions[i].phys_table = phys_table;
-		rsize = (pmap_mem_regions[i].end - (unsigned int)pmap_mem_regions[i].start)/PAGE_SIZE;
+	pmapTrans = (pmapTransTab *)addr;						/* Point to the pmap to hash translation table */
 		
-#if DEBUG
-		kprintf("Initializing physical table for region %d\n", i);
-		kprintf("   table=%08X, size=%08X, start=%08X, end=%08X\n",
-			phys_table, rsize, pmap_mem_regions[i].start, 
-			(unsigned int)pmap_mem_regions[i].end);
-#endif		
+	pmapTrans[PPC_SID_KERNEL].pmapPAddr = (addr64_t)kernel_pmap;	/* Initialize the kernel pmap in the translate table */
+	pmapTrans[PPC_SID_KERNEL].pmapVAddr = kernel_pmap;		/* Initialize the kernel pmap in the translate table */
 		
-		for (j = 0; j < rsize; j++) {
-			phys_table[j].phys_link = MAPPING_NULL;
-			mapping_phys_init(&phys_table[j], (unsigned int)pmap_mem_regions[i].start+(j*PAGE_SIZE), 
-				PTE_WIMG_DEFAULT);						/* Initializes hw specific storage attributes */
-		}
-		phys_table = phys_table +
-			atop(pmap_mem_regions[i].end - pmap_mem_regions[i].start);
-	}
+	addr += ((((1 << maxAdrSpb) * sizeof(pmapTransTab)) + 4095) & -4096);	/* Point past pmap translate table */
 
-	/* restore phys_table for debug */
-	phys_table = (struct phys_entry *) addr;
+/*	NOTE: the phys_table must be within the first 2GB of physical RAM. This makes sure we only need to do 32-bit arithmetic */
 
-	addr += sizeof(struct phys_entry) * num;
-	
-	simple_lock_init(&tlb_system_lock, ETAP_VM_PMAP_TLB);
+	phys_table = (struct phys_entry *) addr;				/* Get pointer to physical table */
 
-	/* Initialise the registers necessary for supporting the hashtable */
-#if DEBUG
-	kprintf("*** hash_table_init: base=%08X, size=%08X\n", hash_table_base, hash_table_size);
-#endif
+	for (bank = 0; bank < pmap_mem_regions_count; bank++) {	/* Set pointer and initialize all banks of ram */
+		
+		pmap_mem_regions[bank].mrPhysTab = phys_table;		/* Set pointer to the physical table for this bank */
+		
+		phys_table = phys_table + (pmap_mem_regions[bank].mrEnd - pmap_mem_regions[bank].mrStart + 1);	/* Point to the next */
+	}
 
-	hash_table_init(hash_table_base, hash_table_size);
-			
+	addr += (((num * sizeof(struct phys_entry)) + 4095) & -4096);	/* Step on past the physical entries */
+	
 /*
  * 		Remaining space is for mapping entries.  Tell the initializer routine that
  * 		the mapping system can't release this block because it's permanently assigned
  */
 
-	mapping_init();									/* Initialize the mapping tables */
+	mapping_init();											/* Initialize the mapping tables */
 
 	for(i = addr; i < first_used_addr + size; i += PAGE_SIZE) {	/* Add initial mapping blocks */
-		mapping_free_init(i, 1, 0);					/* Pass block address and say that this one is not releasable */
+		mapping_free_init(i, 1, 0);							/* Pass block address and say that this one is not releasable */
 	}
-	mapCtl.mapcmin = MAPPERBLOK;					/* Make sure we only adjust one at a time */
-
-#if DEBUG
-
-	kprintf("mapping kernel memory from 0x%08x to 0x%08x, to address 0x%08x\n",
-		 first_used_addr, round_page(first_used_addr+size),
-		 first_used_addr);
-#endif /* DEBUG */
+	mapCtl.mapcmin = MAPPERBLOK;							/* Make sure we only adjust one at a time */
 
 	/* Map V=R the page tables */
 	pmap_map(first_used_addr, first_used_addr,
-		 round_page(first_used_addr+size), VM_PROT_READ | VM_PROT_WRITE);
-
-#if DEBUG
+		 round_page_32(first_used_addr + size), VM_PROT_READ | VM_PROT_WRITE);
 
-	for(i=first_used_addr; i < round_page(first_used_addr+size); i+=PAGE_SIZE) {	/* Step through all these mappings */
-		if(i != (j = kvtophys(i))) {							/* Verify that the mapping was made V=R */
-			kprintf("*** V=R mapping failed to verify: V=%08X; R=%08X\n", i, j);
-		}
-	}
-#endif
-
-	*first_avail = round_page(first_used_addr + size);
-	first_free_virt = round_page(first_used_addr + size);
+	*first_avail = round_page_32(first_used_addr + size);		/* Set next available page */
+	first_free_virt = *first_avail;							/* Ditto */
 
 	/* All the rest of memory is free - add it to the free
 	 * regions so that it can be allocated by pmap_steal
 	 */
-	free_regions[free_regions_count].start = *first_avail;
-	free_regions[free_regions_count].end = pmap_mem_regions[0].end;
 
-	avail_remaining += (free_regions[free_regions_count].end -
-			    free_regions[free_regions_count].start) /
-				    PPC_PGBYTES;
+	pmap_mem_regions[0].mrAStart = (*first_avail >> 12);	/* Set up the free area to start allocations (always in the first bank) */
 
-#if DEBUG
-	kprintf("ADDED FREE REGION from 0x%08x to 0x%08x, avail_remaining = %d\n",
-		free_regions[free_regions_count].start,free_regions[free_regions_count].end, 
-		avail_remaining);
-#endif /* DEBUG */
-
-	free_regions_count++;
-
-	current_free_region = 0;
-
-	avail_next = free_regions[current_free_region].start;
-	
-#if DEBUG
-	kprintf("Number of free regions=%d\n",free_regions_count);	/* (TEST/DEBUG) */
-	kprintf("Current free region=%d\n",current_free_region);	/* (TEST/DEBUG) */
-	for(i=0;i<free_regions_count; i++) {					/* (TEST/DEBUG) */
-		kprintf("Free region %3d - from %08X to %08X\n", i, free_regions[i].start,
-			free_regions[i].end);							/* (TEST/DEBUG) */
+	current_free_region = 0;								/* Set that we will start allocating in bank 0 */
+	avail_remaining = 0;									/* Clear free page count */
+	for(bank = 0; bank < pmap_mem_regions_count; bank++) {	/* Total up all of the pages in the system that are available */
+		avail_remaining += (pmap_mem_regions[bank].mrAEnd - pmap_mem_regions[bank].mrAStart) + 1;	/* Add in allocatable pages in this bank */
 	}
-	for (i = 0; i < pmap_mem_regions_count; i++) {			/* (TEST/DEBUG) */
-		kprintf("PMAP region %3d - from %08X to %08X; phys=%08X\n", i,	/* (TEST/DEBUG) */
-			pmap_mem_regions[i].start,						/* (TEST/DEBUG) */
-			pmap_mem_regions[i].end,						/* (TEST/DEBUG) */
-			pmap_mem_regions[i].phys_table);				/* (TEST/DEBUG) */
-	}
-#endif
+
 
 }
 
@@ -730,6 +469,7 @@ void
 pmap_init(void)
 {
 
+	addr64_t cva;
 
 	pmap_zone = zinit(pmapSize, 400 * pmapSize, 4096, "pmap");
 #if	ZONE_DEBUG
@@ -744,6 +484,7 @@ pmap_init(void)
 	free_pmap_list = 0;					/* Set that there are no free pmaps */
 	free_pmap_count = 0;
 	simple_lock_init(&free_pmap_lock, ETAP_VM_PMAP_CACHE);
+	
 }
 
 unsigned int pmap_free_pages(void)
@@ -751,63 +492,32 @@ unsigned int pmap_free_pages(void)
 	return avail_remaining;
 }
 
-boolean_t pmap_next_page(vm_offset_t *addrp)
+/*
+ *	This function allocates physical pages.
+ */
+
+/* Non-optimal, but only used for virtual memory startup.
+ * Allocate memory from a table of free physical addresses
+ * If there are no more free entries, too bad. 
+ */
+
+boolean_t pmap_next_page(ppnum_t *addrp)
 {
-	/* Non optimal, but only used for virtual memory startup.
-     * Allocate memory from a table of free physical addresses
-	 * If there are no more free entries, too bad. We have two
-	 * tables to look through, free_regions[] which holds free
-	 * regions from inside pmap_mem_regions[0], and the others...
-	 * pmap_mem_regions[1..]
-     */
-	 
-	/* current_free_region indicates the next free entry,
-	 * if it's less than free_regions_count, then we're still
-	 * in free_regions, otherwise we're in pmap_mem_regions
-	 */
+		int i;
 
-	if (current_free_region >= free_regions_count) {
-		/* We're into the pmap_mem_regions, handle this
-		 * separately to free_regions
-		 */
-
-		int current_pmap_mem_region = current_free_region -
-					 free_regions_count + 1;
-		if (current_pmap_mem_region > pmap_mem_regions_count)
-			return FALSE;
-		*addrp = avail_next;
-		avail_next += PAGE_SIZE;
-		avail_remaining--;
-		if (avail_next >= pmap_mem_regions[current_pmap_mem_region].end) {
-			current_free_region++;
-			current_pmap_mem_region++;
-			avail_next = pmap_mem_regions[current_pmap_mem_region].start;
-#if DEBUG
-			kprintf("pmap_next_page : next region start=0x%08x\n",avail_next);
-#endif /* DEBUG */
-		}
-		return TRUE;
-	}
+	if(current_free_region >= pmap_mem_regions_count) return FALSE;	/* Return failure if we have used everything... */
 	
-	/* We're in the free_regions, allocate next page and increment
-	 * counters
-	 */
-	*addrp = avail_next;
-
-	avail_next += PAGE_SIZE;
-	avail_remaining--;
-
-	if (avail_next >= free_regions[current_free_region].end) {
-		current_free_region++;
-		if (current_free_region < free_regions_count)
-			avail_next = free_regions[current_free_region].start;
-		else
-			avail_next = pmap_mem_regions[current_free_region -
-						 free_regions_count + 1].start;
-#if DEBUG
-		kprintf("pmap_next_page : next region start=0x%08x\n",avail_next);
-#endif 
+	for(i = current_free_region; i < pmap_mem_regions_count; i++) {	/* Find the next bank with free pages */
+		if(pmap_mem_regions[i].mrAStart <= pmap_mem_regions[i].mrAEnd) break;	/* Found one */
 	}
+	
+	current_free_region = i;										/* Set our current bank */
+	if(i >= pmap_mem_regions_count) return FALSE;					/* Couldn't find a free page */
+
+	*addrp = pmap_mem_regions[i].mrAStart;					/* Allocate the page */
+	pmap_mem_regions[i].mrAStart = pmap_mem_regions[i].mrAStart + 1;	/* Set the next one to go */
+	avail_remaining--;												/* Drop free count */
+
 	return TRUE;
 }
 
@@ -815,8 +525,8 @@ void pmap_virtual_space(
 	vm_offset_t *startp,
 	vm_offset_t *endp)
 {
-	*startp = round_page(first_free_virt);
-	*endp   = VM_MAX_KERNEL_ADDRESS;
+	*startp = round_page_32(first_free_virt);
+	*endp   = vm_last_addr;
 }
 
 /*
@@ -842,17 +552,8 @@ pmap_create(vm_size_t size)
 {
 	pmap_t pmap, ckpmap, fore, aft;
 	int s, i;
-	space_t sid;
-	unsigned int currSID;
-
-#if PMAP_LOWTRACE
-	dbgTrace(0xF1D00001, size, 0);			/* (TEST/DEBUG) */
-#endif
-
-#if DEBUG
-	if (pmdebug & PDB_USER)
-		kprintf("pmap_create(size=%x)%c", size, size ? '\n' : ' ');
-#endif
+	unsigned int currSID, hspace;
+	addr64_t physpmap;
 
 	/*
 	 * A software use-only map doesn't even need a pmap structure.
@@ -868,76 +569,70 @@ pmap_create(vm_size_t size)
 	s = splhigh();
 	simple_lock(&free_pmap_lock);
 	
-	if(free_pmap_list) {					/* Any free? */
-		pmap = free_pmap_list;				/* Yes, allocate it */
-		free_pmap_list = (pmap_t)pmap->bmaps;	/* Dequeue this one (we chain free ones through bmaps) */
+	if(free_pmap_list) {							/* Any free? */
+		pmap = free_pmap_list;						/* Yes, allocate it */
+		free_pmap_list = (pmap_t)pmap->freepmap;	/* Dequeue this one (we chain free ones through freepmap) */
 		free_pmap_count--;
 	}
 	else {
-		simple_unlock(&free_pmap_lock);		/* Unlock just in case */
+		simple_unlock(&free_pmap_lock);				/* Unlock just in case */
 		splx(s);
 
-		pmap = (pmap_t) zalloc(pmap_zone);	/* Get one */
+		pmap = (pmap_t) zalloc(pmap_zone);			/* Get one */
 		if (pmap == PMAP_NULL) return(PMAP_NULL);	/* Handle out-of-memory condition */
 		
-		bzero((char *)pmap, pmapSize);		/* Clean up the pmap */
+		bzero((char *)pmap, pmapSize);				/* Clean up the pmap */
 		
 		s = splhigh();
-		simple_lock(&free_pmap_lock);		/* Lock it back up	*/
+		simple_lock(&free_pmap_lock);				/* Lock it back up	*/
 		
-		ckpmap = cursor_pmap;				/* Get starting point for free ID search */
-		currSID = ckpmap->spaceNum;			/* Get the actual space ID number */
+		ckpmap = cursor_pmap;						/* Get starting point for free ID search */
+		currSID = ckpmap->spaceNum;					/* Get the actual space ID number */
 
-		while(1) {							/* Keep trying until something happens */
+		while(1) {									/* Keep trying until something happens */
 		
-			currSID = (currSID + 1) & SID_MAX;	/* Get the next in the sequence */
+			currSID = (currSID + 1) & (maxAdrSp - 1);	/* Get the next in the sequence */
+			if(((currSID * incrVSID) & (maxAdrSp - 1)) == invalSpace) continue;	/* Skip the space we have reserved */
 			ckpmap = (pmap_t)ckpmap->pmap_link.next;	/* On to the next in-use pmap */
 	
 			if(ckpmap->spaceNum != currSID) break;	/* If we are out of sequence, this is free */
 			
-			if(ckpmap == cursor_pmap) {		/* See if we have 2^20 already allocated */
-				panic("pmap_create: Maximum number (2^20) active address spaces reached\n");	/* Die pig dog */
+			if(ckpmap == cursor_pmap) {				/* See if we have 2^20 already allocated */
+				panic("pmap_create: Maximum number (%d) active address spaces reached\n", maxAdrSp);	/* Die pig dog */
 			}
 		}
 
-		pmap->space = (currSID * incrVSID) & SID_MAX;	/* Calculate the actual VSID */
-		pmap->spaceNum = currSID;			/* Set the space ID number */
-
+		pmap->space = (currSID * incrVSID) & (maxAdrSp - 1);	/* Calculate the actual VSID */
+		pmap->spaceNum = currSID;					/* Set the space ID number */
 /*
  *		Now we link into the chain just before the out of sequence guy.
  */
 
-		fore = (pmap_t)ckpmap->pmap_link.prev;	/* Get the current's previous */
-		pmap->pmap_link.next = (queue_t)ckpmap;	/* My next points to the current */
-		fore->pmap_link.next = (queue_t)pmap;	/* Current's previous's next points to me */
-		pmap->pmap_link.prev = (queue_t)fore;	/* My prev points to what the current pointed to */
-		ckpmap->pmap_link.prev = (queue_t)pmap;	/* Current's prev points to me */
+		fore = (pmap_t)ckpmap->pmap_link.prev;		/* Get the current's previous */
+		pmap->pmap_link.next = (queue_t)ckpmap;		/* My next points to the current */
+		fore->pmap_link.next = (queue_t)pmap;		/* Current's previous's next points to me */
+		pmap->pmap_link.prev = (queue_t)fore;		/* My prev points to what the current pointed to */
+		ckpmap->pmap_link.prev = (queue_t)pmap;		/* Current's prev points to me */
 
 		simple_lock_init(&pmap->lock, ETAP_VM_PMAP);
-		pmap->pmapvr = (unsigned int)pmap ^ (unsigned int)pmap_extract(kernel_pmap, (vm_offset_t)pmap);	/* Get physical pointer to the pmap and make mask */
+		
+		physpmap = ((addr64_t)pmap_find_phys(kernel_pmap, (addr64_t)pmap) << 12) | (addr64_t)((unsigned int)pmap & 0xFFF);	/* Get the physical address of the pmap */
+		
+		pmap->pmapvr = (addr64_t)((unsigned int)pmap) ^ physpmap;	/* Make V to R translation mask */
+		
+		pmapTrans[pmap->space].pmapPAddr = physpmap;	/* Set translate table physical to point to us */
+		pmapTrans[pmap->space].pmapVAddr = pmap;	/* Set translate table virtual to point to us */
+		
 	}
+
+	pmap->pmapFlags = pmapKeyDef;					/* Set default key */
+	pmap->pmapCCtl = pmapCCtlVal;					/* Initialize cache control */
 	pmap->ref_count = 1;
 	pmap->stats.resident_count = 0;
 	pmap->stats.wired_count = 0;
-	pmap->bmaps = 0;						/* Clear block map pointer to 0 */
-	pmap->vflags = 0;						/* Mark all alternates invalid for now */
-	for(i=0; i < 128; i++) {				/* Clean out usage slots */
-		pmap->pmapUsage[i] = 0;
-	}
-	for(i=0; i < 16; i++) {					/* Initialize for laughs */
-		pmap->pmapSegs[i] = SEG_REG_PROT | (i << 20) | pmap->space;
-	}
-	
-#if PMAP_LOWTRACE
-	dbgTrace(0xF1D00002, (unsigned int)pmap, (unsigned int)pmap->space);	/* (TEST/DEBUG) */
-#endif
-
-#if DEBUG
-	if (pmdebug & PDB_USER)
-		kprintf("-> %x, space id = %d\n", pmap, pmap->space);
-#endif
-
+	pmap->pmapSCSubTag = 0x0000000000000000ULL;		/* Make sure this is clean an tidy */
 	simple_unlock(&free_pmap_lock);
+
 	splx(s);
 	return(pmap);
 }
@@ -957,15 +652,6 @@ pmap_destroy(pmap_t pmap)
 	spl_t s;
 	pmap_t fore, aft;
 
-#if PMAP_LOWTRACE
-	dbgTrace(0xF1D00003, (unsigned int)pmap, 0);			/* (TEST/DEBUG) */
-#endif
-
-#if DEBUG
-	if (pmdebug & PDB_USER)
-		kprintf("pmap_destroy(pmap=%x)\n", pmap);
-#endif
-
 	if (pmap == PMAP_NULL)
 		return;
 
@@ -980,7 +666,7 @@ pmap_destroy(pmap_t pmap)
 		panic("PMAP_DESTROY: pmap not empty");
 #else
 	if(pmap->stats.resident_count != 0) {
-		pmap_remove(pmap, 0, 0xFFFFF000);
+		pmap_remove(pmap, 0, 0xFFFFFFFFFFFFF000ULL);
 	}
 #endif
 
@@ -994,9 +680,9 @@ pmap_destroy(pmap_t pmap)
 	 */
 	simple_lock(&free_pmap_lock);
 	
-	if (free_pmap_count <= free_pmap_max) {					/* Do we have enough spares? */
+	if (free_pmap_count <= free_pmap_max) {		/* Do we have enough spares? */
 		
-		pmap->bmaps = (struct blokmap *)free_pmap_list;		/* Queue in front */
+		pmap->freepmap = (struct blokmap *)free_pmap_list;	/* Queue in front */
 		free_pmap_list = pmap;
 		free_pmap_count++;
 		simple_unlock(&free_pmap_lock);
@@ -1008,6 +694,8 @@ pmap_destroy(pmap_t pmap)
 		fore->pmap_link.next = pmap->pmap_link.next;	/* My previous's next is my next */
 		aft->pmap_link.prev = pmap->pmap_link.prev;		/* My next's previous is my previous */	
 		simple_unlock(&free_pmap_lock);
+		pmapTrans[pmap->space].pmapPAddr = -1;			/* Invalidate the translate table physical */
+		pmapTrans[pmap->space].pmapVAddr = -1;			/* Invalidate the translate table virtual */
 		zfree(pmap_zone, (vm_offset_t) pmap);
 	}
 	splx(s);
@@ -1022,15 +710,6 @@ pmap_reference(pmap_t pmap)
 {
 	spl_t s;
 
-#if PMAP_LOWTRACE
-	dbgTrace(0xF1D00004, (unsigned int)pmap, 0);			/* (TEST/DEBUG) */
-#endif
-
-#if DEBUG
-	if (pmdebug & PDB_USER)
-		kprintf("pmap_reference(pmap=%x)\n", pmap);
-#endif
-
 	if (pmap != PMAP_NULL) hw_atomic_add(&pmap->ref_count, 1);	/* Bump the count */
 }
 
@@ -1045,17 +724,36 @@ void pmap_remove_some_phys(
 	     vm_offset_t pa)
 {
 	register struct phys_entry 	*pp;
-	register struct mapping 	*mp, *mpv;
+	register struct mapping 	*mp;
+	unsigned int pindex;
 
+	if (pmap == PMAP_NULL) {					/* This should never be called with a null pmap */
+		panic("pmap_remove_some_phys: null pmap\n");
+	}
 
-	if (pmap == PMAP_NULL) return;				/* Do nothing if no pmap */
-
-	pp = pmap_find_physentry(pa);				/* Get the physent for this page */
-	if (pp == PHYS_NULL) return;				/* Leave if not in physical RAM */
+	pp = mapping_phys_lookup(pa, &pindex);		/* Get physical entry */
+	if (pp == 0) return;						/* Leave if not in physical RAM */
 
-	mapping_purge_pmap(pp, pmap);	
+	while(1) {									/* Keep going until we toss all pages from this pmap */
+		if (pmap->pmapFlags & pmapVMhost) {
+			mp = hw_purge_phys(pp);				/* Toss a map */
+			if(!mp ) return;					
+			if((unsigned int)mp & mapRetCode) {		/* Was there a failure? */
+				panic("pmap_remove_some_phys: hw_purge_phys failed - pp = %08X, pmap = %08X, code = %08X\n",
+					pp, pmap, mp);
+			}
+		} else { 
+			mp = hw_purge_space(pp, pmap);			/* Toss a map */
+			if(!mp ) return;					
+			if((unsigned int)mp & mapRetCode) {		/* Was there a failure? */
+				panic("pmap_remove_some_phys: hw_purge_pmap failed - pp = %08X, pmap = %08X, code = %08X\n",
+					pp, pmap, mp);
+			}
+		}
+		mapping_free(mp);						/* Toss the mapping */
+	}
 
-	return;							/* Leave... */
+	return;										/* Leave... */
 }
 
 /*
@@ -1071,25 +769,13 @@ void pmap_remove_some_phys(
 void
 pmap_remove(
 	    pmap_t pmap,
-	    vm_offset_t sva,
-	    vm_offset_t eva)
+	    addr64_t sva,
+	    addr64_t eva)
 {
-	spl_t			spl;
-	struct mapping	*mp, *blm;
-	vm_offset_t		lpage;
-
-#if PMAP_LOWTRACE
-	dbgTrace(0xF1D00005, (unsigned int)pmap, sva|((eva-sva)>>12));	/* (TEST/DEBUG) */
-#endif
+	addr64_t		va, endva;
 
-#if DEBUG
-	if (pmdebug & PDB_USER)
-		kprintf("pmap_remove(pmap=%x, sva=%x, eva=%x)\n",
-		       pmap, sva, eva);
-#endif
+	if (pmap == PMAP_NULL) return;					/* Leave if software pmap */
 
-	if (pmap == PMAP_NULL)
-		return;
 
 	/* It is just possible that eva might have wrapped around to zero,
 	 * and sometimes we get asked to liberate something of size zero
@@ -1098,49 +784,17 @@ pmap_remove(
 	assert(eva >= sva);
 
 	/* If these are not page aligned the loop might not terminate */
-	assert((sva == trunc_page(sva)) && (eva == trunc_page(eva)));
-
-	/* We liberate addresses from high to low, since the stack grows
-	 * down. This means that we won't need to test addresses below
-	 * the limit of stack growth
-	 */
-
-	debugLog2(44, sva, eva);					/* Log pmap_map call */
-	
-	sva = trunc_page(sva);						/* Make it clean */
-	lpage = trunc_page(eva) - PAGE_SIZE;		/* Point to the last page contained in the range */
-
-/*
- *	Here we will remove all of the block mappings that overlap this range.
- *	hw_rem_blk removes one mapping in the range and returns.  If it returns
- *	0, there are no blocks in the range.
- */
-
-	while(mp = (mapping *)hw_rem_blk(pmap, sva, lpage)) {	/* Keep going until no more */
-		if((unsigned int)mp & 1) {							/* Make sure we don't unmap a permanent one */
-			blm = (struct mapping  *)hw_cpv((mapping *)((unsigned int)mp & 0xFFFFFFFC));		/* Get virtual address */
-			panic("mapping_remove: attempt to unmap a permanent mapping - pmap = %08X, va = %08X, mapping = %08X\n",
-				pmap, sva, blm);
-		}
-		if (!((unsigned int)mp & 2))
-			mapping_free(hw_cpv(mp));							/* Release it */
-	}
-	while (pmap->stats.resident_count && (eva > sva)) {
+	assert((sva == trunc_page_64(sva)) && (eva == trunc_page_64(eva)));
 
-		eva -= PAGE_SIZE;						/* Back up a page */
+	va = sva & -4096LL;							/* Round start down to a page */
+	endva = eva & -4096LL;						/* Round end down to a page */
 
-#if 1
-		if((0x00008000 >> (sva >> 28)) & pmap->vflags)
-		   panic("pmap_remove: attempt to remove nested vaddr; pmap = %08X, vaddr = %08X\n", pmap, sva);	/* (TEST/DEBUG) panic */
-#endif
-		if(!(pmap->pmapUsage[(eva >> pmapUsageShft) & pmapUsageMask])) {	/* See if this chunk has anything in it */
-			eva = eva & (-pmapUsageSize);		/* Back up into the previous slot */
-			continue;							/* Check the next... */
-		}
-		mapping_remove(pmap, eva);				/* Remove the mapping for this address */
+	while(1) {									/* Go until we finish the range */
+		va = mapping_remove(pmap, va);			/* Remove the mapping and see what's next */
+		va = va & -4096LL;						/* Make sure the "not found" indication is clear */
+		if((va == 0) || (va >= endva)) break;	/* End loop if we finish range or run off the end */
 	}
 
-	debugLog2(45, 0, 0);						/* Log pmap_map call */
 }
 
 /*
@@ -1152,24 +806,15 @@ pmap_remove(
  */
 void
 pmap_page_protect(
-	vm_offset_t pa,
+	ppnum_t pa,
 	vm_prot_t prot)
 {
 	register struct phys_entry 	*pp;
 	boolean_t 			remove;
+	unsigned int		pindex;
+	mapping				*mp;
 
 
-#if PMAP_LOWTRACE
-	dbgTrace(0xF1D00006, (unsigned int)pa, (unsigned int)prot);	/* (TEST/DEBUG) */
-#endif
-
-#if DEBUG
-	if (pmdebug & PDB_USER)
-		kprintf("pmap_page_protect(pa=%x, prot=%x)\n", pa, prot);
-#endif
-
-	debugLog2(46, pa, prot);					/* Log pmap_page_protect call */
-
 	switch (prot) {
 		case VM_PROT_READ:
 		case VM_PROT_READ|VM_PROT_EXECUTE:
@@ -1182,23 +827,31 @@ pmap_page_protect(
 			break;
 	}
 
-	pp = pmap_find_physentry(pa);				/* Get the physent for this page */
-	if (pp == PHYS_NULL) return;				/* Leave if not in physical RAM */
+
+	pp = mapping_phys_lookup(pa, &pindex);	/* Get physical entry */
+	if (pp == 0) return;						/* Leave if not in physical RAM */
 
 	if (remove) {								/* If the protection was set to none, we'll remove all mappings */
-		mapping_purge(pp);						/* Get rid of them all */
+		
+		while(1) {								/* Keep going until we toss all pages from this physical page */
+			mp = hw_purge_phys(pp);				/* Toss a map */
+			if(!mp ) return;					
+			if((unsigned int)mp & mapRetCode) {	/* Was there a failure? */
+				panic("pmap_page_protect: hw_purge_phys failed - pp = %08X, code = %08X\n",
+					pp, mp);
+			}
+			mapping_free(mp);					/* Toss the mapping */
+		}
 
-		debugLog2(47, 0, 0);					/* Log pmap_map call */
 		return;									/* Leave... */
 	}
-	
-	/*	When we get here, it means that we are to change the protection for a 
-	 *	physical page.  
-	 */
-	 
-	mapping_protect_phys(pp, prot, 0);			/* Change protection of all mappings to page. */
 
-	debugLog2(47, 1, 0);						/* Log pmap_map call */
+/*	When we get here, it means that we are to change the protection for a 
+ *	physical page.  
+ */
+ 
+	mapping_protect_phys(pa, prot & VM_PROT_ALL);	/* Change protection of all mappings to page. */
+
 }
 
 /*
@@ -1217,54 +870,24 @@ void pmap_protect(
 	     vm_offset_t eva,
 	     vm_prot_t prot)
 {
-	spl_t						spl;
-	register struct phys_entry 	*pp;
-	register struct mapping 	*mp, *mpv;
-
-#if PMAP_LOWTRACE
-	dbgTrace(0xF1D00008, (unsigned int)pmap, (unsigned int)(sva|((eva-sva)>>12)));	/* (TEST/DEBUG) */
-#endif
 
-#if DEBUG
-	if (pmdebug & PDB_USER)
-		kprintf("pmap_protect(pmap=%x, sva=%x, eva=%x, prot=%x)\n", pmap, sva, eva, prot);
-	
-	assert(sva < eva);
-#endif
+	addr64_t va, endva, nextva;
 
 	if (pmap == PMAP_NULL) return;				/* Do nothing if no pmap */
 
-	debugLog2(48, sva, eva);					/* Log pmap_map call */
-
 	if (prot == VM_PROT_NONE) {					/* Should we kill the address range?? */
-		pmap_remove(pmap, sva, eva);			/* Yeah, dump 'em */
-
-		debugLog2(49, prot, 0);								/* Log pmap_map call */
-
+		pmap_remove(pmap, (addr64_t)sva, (addr64_t)eva);	/* Yeah, dump 'em */
 		return;									/* Leave... */
 	}
 
-	sva = trunc_page(sva);						/* Start up a page boundary */
-	
-	while(sva < eva) {							/* Step through */
-
-		if(!(pmap->pmapUsage[(sva >> pmapUsageShft) & pmapUsageMask])) {	/* See if this chunk has anything in it */
-			sva = (sva + pmapUsageSize) &(-pmapUsageSize);	/* Jump up into the next slot if nothing here */
-			if(!sva) break;						/* We tried to wrap, kill loop... */
-			continue;							/* Check the next... */
-		}
-
-#if 1
-		if((0x00008000 >> (sva >> 28)) & pmap->vflags)
-		   panic("pmap_protect: attempt to protect nested vaddr; pmap = %08X, vaddr = %08X\n", pmap, sva);	/* (TEST/DEBUG) panic */
-#endif
+	va = sva & -4096LL;							/* Round start down to a page */
+	endva = eva & -4096LL;						/* Round end down to a page */
 
-		mapping_protect(pmap, sva, prot);		/* Change the protection on the page */
-		sva += PAGE_SIZE;						/* On to the next page */
+	while(1) {									/* Go until we finish the range */
+		(void)mapping_protect(pmap, va, prot & VM_PROT_ALL, &va);	/* Change the protection and see what's next */
+		if((va == 0) || (va >= endva)) break;	/* End loop if we finish range or run off the end */
 	}
 
-	debugLog2(49, prot, 1);						/* Log pmap_map call */
-	return;										/* Leave... */
 }
 
 
@@ -1283,61 +906,104 @@ void pmap_protect(
  *     insert this page into the given map NOW.
  */
 void
-pmap_enter(pmap_t pmap, vm_offset_t va, vm_offset_t pa, vm_prot_t prot, 
+pmap_enter(pmap_t pmap, vm_offset_t va, ppnum_t pa, vm_prot_t prot, 
 		unsigned int flags, boolean_t wired)
 {
-	spl_t				spl;
-	struct mapping		*mp;
-	struct phys_entry	*pp;
 	int					memattr;
+	pmap_t				opmap;
+	unsigned int		mflags;
+	addr64_t			colva;
 	
-#if PMAP_LOWTRACE
-	dbgTrace(0xF1D00009, (unsigned int)pmap, (unsigned int)va);	/* (TEST/DEBUG) */
-	dbgTrace(0xF1D04009, (unsigned int)pa, (unsigned int)prot);	/* (TEST/DEBUG) */
-#endif		
-	
-	if (pmap == PMAP_NULL) return;					/* If they gave us no pmap, just leave... */
-
-	debugLog2(50, va, pa);							/* Log pmap_map call */
-
-	pp = pmap_find_physentry(pa);					/* Get the physent for this physical page */
-
-	if((0x00008000 >> (va >> 28)) & pmap->vflags)
-	   panic("pmap_enter: attempt to map into nested vaddr; pmap = %08X, vaddr = %08X\n", pmap, va);	/* (TEST/DEBUG) panic */
+	if (pmap == PMAP_NULL) return;					/* Leave if software pmap */
 
-	spl=splhigh();									/* Have to disallow interrupts between the
-													   time we possibly clear a mapping and the time
-													   we get it remapped again.  An I/O SLIH could
-													   try to drive an IOR using the page before
-													   we get it mapped (Dude! This was a tough 
-													   bug!!!!) */
+	disable_preemption();							/* Don't change threads */
 
-	mapping_remove(pmap, va);						/* Remove any other mapping at this address */
-
-	if(flags & VM_WIMG_USE_DEFAULT) {
-	    if(pp) {
-			/* Set attr to the phys default */
-			memattr = ((pp->pte1&0x00000078) >> 3);	
-		} else {
-			memattr = PTE_WIMG_UNCACHED_COHERENT_GUARDED;
-		}
-	} else {
-		memattr = flags & VM_WIMG_MASK;
+	mflags = 0;										/* Make sure this is initialized to nothing special */
+	if(!(flags & VM_WIMG_USE_DEFAULT)) {			/* Are they supplying the attributes? */
+		mflags = mmFlgUseAttr | (flags & VM_MEM_GUARDED) | ((flags & VM_MEM_NOT_CACHEABLE) >> 1);	/* Convert to our mapping_make flags */
 	}
 	
+/*
+ *	It is possible to hang here if another processor is remapping any pages we collide with and are removing
+ */ 
 
-	/* Make the address mapping */
-	mp=mapping_make(pmap, pp, va, pa, prot, memattr, 0);	
+	while(1) {										/* Keep trying the enter until it goes in */
+	
+		colva = mapping_make(pmap, va, pa, mflags, 1, prot & VM_PROT_ALL);	/* Enter the mapping into the pmap */
+		
+		if(!colva) break;							/* If there were no collisions, we are done... */
+		
+		mapping_remove(pmap, colva);				/* Remove the mapping that collided */
+	}
 
-	splx(spl);										/* I'm not busy no more - come what may */
+	enable_preemption();							/* Thread change ok */
 
-	debugLog2(51, prot, 0);							/* Log pmap_map call */
+}
+
+/*
+ *		Enters translations for odd-sized V=F blocks.
+ *
+ *		The higher level VM map should be locked to insure that we don't have a
+ *		double diddle here.
+ *
+ *		We panic if we get a block that overlaps with another. We do not merge adjacent
+ *		blocks because removing any address within a block removes the entire block and if
+ *		would really mess things up if we trashed too much.
+ *
+ *		Once a block is mapped, it is unmutable, that is, protection, catch mode, etc. can
+ *		not be changed.  The block must be unmapped and then remapped with the new stuff.
+ *		We also do not keep track of reference or change flags.
+ *
+ *		Note that pmap_map_block_rc is the same but doesn't panic if collision.
+ *
+ */
+ 
+void pmap_map_block(pmap_t pmap, addr64_t va, ppnum_t pa, vm_size_t size, vm_prot_t prot, int attr, unsigned int flags) {	/* Map an autogenned block */
+
+	int					memattr;
+	unsigned int		mflags;
+	addr64_t			colva;
+
+	
+	if (pmap == PMAP_NULL) {						/* Did they give us a pmap? */
+		panic("pmap_map_block: null pmap\n");		/* No, like that's dumb... */
+	}
+
+//	kprintf("pmap_map_block: (%08X) va = %016llX, pa = %08X, size = %08X, prot = %08X, attr = %08X, flags = %08X\n", 	/* (BRINGUP) */
+//		current_act(), va, pa, size, prot, attr, flags);	/* (BRINGUP) */
 
-#if	DEBUG
-	if (pmdebug & (PDB_USER|PDB_ENTER))
-		kprintf("leaving pmap_enter\n");
-#endif
 
+	mflags = mmFlgBlock | mmFlgUseAttr | (attr & VM_MEM_GUARDED) | ((attr & VM_MEM_NOT_CACHEABLE) >> 1);	/* Convert to our mapping_make flags */
+	if(flags) mflags |= mmFlgPerm;					/* Mark permanent if requested */
+	
+	colva = mapping_make(pmap, va, pa, mflags, (size >> 12), prot);	/* Enter the mapping into the pmap */
+	
+	if(colva) {										/* If there was a collision, panic */
+		panic("pmap_map_block: collision at %016llX, pmap = %08X\n", colva, pmap);
+	}
+	
+	return;											/* Return */
+}
+
+int pmap_map_block_rc(pmap_t pmap, addr64_t va, ppnum_t pa, vm_size_t size, vm_prot_t prot, int attr, unsigned int flags) {	/* Map an autogenned block */
+
+	int					memattr;
+	unsigned int		mflags;
+	addr64_t			colva;
+
+	
+	if (pmap == PMAP_NULL) {						/* Did they give us a pmap? */
+		panic("pmap_map_block_rc: null pmap\n");	/* No, like that's dumb... */
+	}
+
+	mflags = mmFlgBlock | mmFlgUseAttr | (attr & VM_MEM_GUARDED) | ((attr & VM_MEM_NOT_CACHEABLE) >> 1);	/* Convert to our mapping_make flags */
+	if(flags) mflags |= mmFlgPerm;					/* Mark permanent if requested */
+	
+	colva = mapping_make(pmap, va, pa, mflags, (size >> 12), prot);	/* Enter the mapping into the pmap */
+	
+	if(colva) return 0;								/* If there was a collision, fail */
+	
+	return 1;										/* Return true of we worked */
 }
 
 /*
@@ -1345,101 +1011,90 @@ pmap_enter(pmap_t pmap, vm_offset_t va, vm_offset_t pa, vm_prot_t prot,
  *	returns the physical address corrsponding to the 
  *	virtual address specified by pmap and va if the
  *	virtual address is mapped and 0 if it is not.
+ *	Note: we assume nothing is ever mapped to phys 0.
+ *
+ *	NOTE: This call always will fail for physical addresses greater than 0xFFFFF000.
  */
 vm_offset_t pmap_extract(pmap_t pmap, vm_offset_t va) {
 
 	spl_t					spl;
-	register struct mapping	*mp, *mpv;
+	register struct mapping	*mp;
 	register vm_offset_t	pa;
-	unsigned int			seg;
-	pmap_t					actpmap;
-
-
-#if PMAP_LOWTRACE
-	dbgTrace(0xF1D0000B, (unsigned int)pmap, (unsigned int)va);	/* (TEST/DEBUG) */
-#endif
-#if DEBUG
-	if (pmdebug & PDB_USER)
-		kprintf("pmap_extract(pmap=%x, va=%x)\n", pmap, va);
-#endif
+	addr64_t				nextva;
+	ppnum_t					ppoffset;
+	unsigned int			gva;
 
-	seg = va >> 28;									/* Isolate segment */
-	if((0x00008000 >> seg) & pmap->vflags) actpmap = pmap->pmapPmaps[seg];	/* Set nested pmap if there is one */
-	else actpmap = pmap;							/* Otherwise use the one passed in */
-
-	pa = (vm_offset_t) 0;							/* Clear this to 0 */ 
+#ifdef BOGUSCOMPAT
+	panic("pmap_extract: THIS CALL IS BOGUS. NEVER USE IT EVER. So there...\n");	/* Don't use this */
+#else
 
-	debugLog2(52, actpmap->space, va);					/* Log pmap_map call */
+	gva = (unsigned int)va;							/* Make sure we don't have a sign */
 
 	spl = splhigh();								/* We can't allow any loss of control here */
-
-	if(mp=hw_lock_phys_vir(actpmap->space, va)) {	/* Find the mapping for this vaddr and lock physent */	
-		if((unsigned int)mp&1) {					/* Did the lock on the phys entry time out? */
-			panic("pmap_extract: timeout obtaining lock on physical entry\n");	/* Scream bloody murder! */
-			splx(spl);								/* Interruptions are cool now */
-			return 0;
-		}
-
-		mpv = hw_cpv(mp);							/* Get virtual address of mapping */
-		pa = (vm_offset_t)((mpv->PTEr & -PAGE_SIZE) | ((unsigned int)va & (PAGE_SIZE-1)));	/* Build the physical address */
-		if(mpv->physent) hw_unlock_bit((unsigned int *)&mpv->physent->phys_link, PHYS_LOCK);	/* Unlock the physical entry */
-		splx(spl);									/* Interruptions are cool now */
-
-		debugLog2(53, pa, 0);						/* Log pmap_map call */
-
-		return pa;									/* Return the physical address... */
+	
+	mp = mapping_find(pmap, (addr64_t)gva, &nextva,1);	/* Find the mapping for this address */
+	
+	if(!mp) {										/* Is the page mapped? */
+		splx(spl);									/* Enable interrupts */
+		return 0;									/* Pass back 0 if not found */
 	}
 
-	pa = hw_cvp_blk(pmap, va);						/* Try to convert odd-sized page (returns 0 if not found) */
-													/* Note no nested pmaps here */
+	ppoffset = (ppnum_t)(((gva & -4096LL) - (mp->mpVAddr & -4096LL)) >> 12);	/* Get offset from va to base va */
+	
+	
+	pa = mp->mpPAddr + ppoffset;					/* Remember ppage because mapping may vanish after drop call */
+			
+	mapping_drop_busy(mp);							/* We have everything we need from the mapping */
 	splx(spl);										/* Restore 'rupts */
-	debugLog2(53, pa, 0);							/* Log pmap_map call */
+
+	if(pa > maxPPage32) return 0;					/* Force large addresses to fail */
+	
+	pa = (pa << 12) | (va & 0xFFF);					/* Convert physical page number to address */
+	
+#endif
 	return pa;										/* Return physical address or 0 */
 }
 
 /*
- *	pmap_attribute_cache_sync
- *	Handle the machine attribute calls which involve sync the prcessor
- *	cache.
+ * ppnum_t pmap_find_phys(pmap, addr64_t va)
+ *	returns the physical page corrsponding to the 
+ *	virtual address specified by pmap and va if the
+ *	virtual address is mapped and 0 if it is not.
+ *	Note: we assume nothing is ever mapped to phys 0.
+ *
  */
-kern_return_t
-pmap_attribute_cache_sync(address, size, attribute, value)
-	vm_offset_t	address;
-	vm_size_t	size;
-	vm_machine_attribute_t	attribute;
-	vm_machine_attribute_val_t* value;	
-{
-	while(size) {
-		switch (*value) {					/* What type was that again? */
-			case MATTR_VAL_CACHE_SYNC:			/* It is sync I+D caches */
-				sync_cache(address, PAGE_SIZE);		/* Sync up dem caches */
-				break;					/* Done with this one here... */
-						
-			case MATTR_VAL_CACHE_FLUSH:			/* It is flush from all caches */
-				flush_dcache(address, PAGE_SIZE, TRUE);	/* Flush out the data cache */
-				invalidate_icache(address, 
-						PAGE_SIZE, TRUE);	/* Flush out the instruction cache */
-				break;					/* Done with this one here... */
-				
-			case MATTR_VAL_DCACHE_FLUSH:			/* It is flush from data cache(s) */
-				flush_dcache(address, PAGE_SIZE, TRUE);	/* Flush out the data cache */
-				break;					/* Done with this one here... */
-
-			case MATTR_VAL_ICACHE_FLUSH:			/* It is flush from instr cache(s) */
-				invalidate_icache(address, 
-						PAGE_SIZE, TRUE);	/* Flush out the instruction cache */
-				break;					/* Done with this one here... */
-		}
-		size -= PAGE_SIZE;
+ppnum_t pmap_find_phys(pmap_t pmap, addr64_t va) {
+
+	spl_t					spl;
+	register struct mapping	*mp;
+	ppnum_t					pa, ppoffset;
+	addr64_t				nextva, curva;
+
+	spl = splhigh();								/* We can't allow any loss of control here */
+	
+	mp = mapping_find(pmap, va, &nextva, 1);		/* Find the mapping for this address */
+	
+	if(!mp) {										/* Is the page mapped? */
+		splx(spl);									/* Enable interrupts */
+		return 0;									/* Pass back 0 if not found */
 	}
-	return KERN_SUCCESS;;
-}
+		
+	
+	ppoffset = (ppnum_t)(((va & -4096LL) - (mp->mpVAddr & -4096LL)) >> 12);	/* Get offset from va to base va */
 	
+	pa = mp->mpPAddr + ppoffset;					/* Get the actual physical address */
+
+	mapping_drop_busy(mp);							/* We have everything we need from the mapping */
+
+	splx(spl);										/* Restore 'rupts */
+	return pa;										/* Return physical address or 0 */
+}
+
 
 /*
  *	pmap_attributes:
  *
- *	Set/Get special memory attributes; Set is not implemented.
+ *	Set/Get special memory attributes; not implemented.
  *
  *	Note: 'VAL_GET_INFO' is used to return info about a page.
  *	  If less than 1 page is specified, return the physical page
@@ -1448,6 +1103,7 @@ pmap_attribute_cache_sync(address, size, attribute, value)
  *	  of resident pages and the number of shared (more than
  *	  one mapping) pages in the range;
  *
+ *
  */
 kern_return_t
 pmap_attribute(pmap, address, size, attribute, value)
@@ -1457,181 +1113,50 @@ pmap_attribute(pmap, address, size, attribute, value)
 	vm_machine_attribute_t	attribute;
 	vm_machine_attribute_val_t* value;	
 {
-	spl_t			s;
-	vm_offset_t 	sva, eva;
-	vm_offset_t		pa;
-	kern_return_t	ret;
-	register struct mapping	*mp, *mpv;
-	register struct phys_entry *pp;
-	int 			total, seg;
-	pmap_t			actpmap;
-
-	if (attribute != MATTR_CACHE)
-		return KERN_INVALID_ARGUMENT;
-
-	/* We can't get the caching attribute for more than one page
-	 * at a time
-	 */
-	if ((*value == MATTR_VAL_GET) &&
-	    (trunc_page(address) != trunc_page(address+size-1)))
-		return KERN_INVALID_ARGUMENT;
+	
+	return KERN_INVALID_ARGUMENT;
+
+}
 
-	if (pmap == PMAP_NULL)
-		return KERN_SUCCESS;
-
-	sva = trunc_page(address);
-	eva = round_page(address + size);
-	ret = KERN_SUCCESS;
-
-	debugLog2(54, address, attribute);						/* Log pmap_map call */
-
-	switch (*value) {
-		case MATTR_VAL_CACHE_SYNC:							/* sync I+D caches */
-		case MATTR_VAL_CACHE_FLUSH:							/* flush from all caches */
-		case MATTR_VAL_DCACHE_FLUSH:						/* flush from data cache(s) */
-		case MATTR_VAL_ICACHE_FLUSH:						/* flush from instr cache(s) */
-			sva = trunc_page(sva);
-			s = splhigh();
-
-			while (sva < eva) {	
-				seg = sva >> 28;							/* Isolate segment */
-				if((0x00008000 >> seg) & pmap->vflags) actpmap = pmap->pmapPmaps[seg];	/* Set nested pmap if there is one */
-				else actpmap = pmap;						/* Otherwise use the one passed in */
-			
 /*
- *				Note: the following should work ok with nested pmaps because there are not overlayed mappings 
+ * pmap_attribute_cache_sync(vm_offset_t pa)
+ * 
+ * Invalidates all of the instruction cache on a physical page and
+ * pushes any dirty data from the data cache for the same physical page
  */
-				if(!(actpmap->pmapUsage[(sva >> pmapUsageShft) & pmapUsageMask])) {	/* See if this chunk has anything in it */
-					sva = (sva + pmapUsageSize) & (-pmapUsageSize);	/* Jump up into the next slot if nothing here */
-					if(!sva) break;							/* We tried to wrap, kill loop... */
-					continue;								/* Check the next... */
-				}
-
-				if(!(mp = hw_lock_phys_vir(actpmap->space, sva))) {	/* Find the mapping for this vaddr and lock physent */
- 					sva += PAGE_SIZE;						/* Point to the next page */
-					continue;								/* Skip if the page is not mapped... */
-				}
-
-				if((unsigned int)mp&1) {					/* Did the lock on the phys entry time out? */
-					panic("pmap_attribute: timeout obtaining lock on physical entry\n");	/* Scream bloody murder! */
-					continue;
-				}
-				
-				mpv = hw_cpv(mp);							/* Get virtual address of mapping */
-				if((unsigned int)mpv->physent) {			/* Is there a physical entry? */
-					pa = (vm_offset_t)mpv->physent->pte1 & -PAGE_SIZE;	/* Yes, get the physical address from there */
-				} 
-				else {
-					pa = (vm_offset_t)(mpv->PTEr & PAGE_SIZE);	/* Otherwise from the mapping */
-				}
-
-				switch (*value) {							/* What type was that again? */
-					case MATTR_VAL_CACHE_SYNC:				/* It is sync I+D caches */
-						sync_cache(pa, PAGE_SIZE);			/* Sync up dem caches */
-						break;								/* Done with this one here... */
-					
-					case MATTR_VAL_CACHE_FLUSH:				/* It is flush from all caches */
-						flush_dcache(pa, PAGE_SIZE, TRUE);	/* Flush out the data cache */
-						invalidate_icache(pa, PAGE_SIZE, TRUE);	/* Flush out the instruction cache */
-						break;								/* Done with this one here... */
-					
-					case MATTR_VAL_DCACHE_FLUSH:			/* It is flush from data cache(s) */
-						flush_dcache(pa, PAGE_SIZE, TRUE);	/* Flush out the data cache */
-						break;								/* Done with this one here... */
-
-					case MATTR_VAL_ICACHE_FLUSH:			/* It is flush from instr cache(s) */
-						invalidate_icache(pa, PAGE_SIZE, TRUE);	/* Flush out the instruction cache */
-						break;								/* Done with this one here... */
-				}
-				if(mpv->physent) hw_unlock_bit((unsigned int *)&mpv->physent->phys_link, PHYS_LOCK);	/* Unlock the physical entry if it exists*/
- 				
- 				sva += PAGE_SIZE;							/* Point to the next page */
-			}
-			splx(s);
-			break;
-
-		case MATTR_VAL_GET_INFO:							/* Get info */
-			total = 0;
-			s = splhigh();									/* Lock 'em out */
-		
-			if (size <= PAGE_SIZE) {						/* Do they want just one page */
-				seg = sva >> 28;							/* Isolate segment */
-				if((0x00008000 >> seg) & pmap->vflags) actpmap = pmap->pmapPmaps[seg];	/* Set nested pmap if there is one */
-				else actpmap = pmap;						/* Otherwise use the one passed in */
-				if(!(mp = hw_lock_phys_vir(actpmap->space, sva))) {	/* Find the mapping for this vaddr and lock physent */
-					*value = 0;								/* Return nothing if no mapping */
-				}
-				else {
-					if((unsigned int)mp&1) {				/* Did the lock on the phys entry time out? */
-						panic("pmap_attribute: timeout obtaining lock on physical entry\n");	/* Scream bloody murder! */
-					}
-					mpv = hw_cpv(mp);						/* Get virtual address of mapping */
-					if(pp = mpv->physent) {					/* Check for a physical entry */
-						total = 0;							/* Clear the count */
-						for (mpv = (mapping *)hw_cpv((mapping *)((unsigned int)pp->phys_link & ~PHYS_FLAGS)); mpv != NULL; mpv = hw_cpv(mp->next)) total++;	/* Count the mapping */
-						*value = (vm_machine_attribute_val_t) ((pp->pte1 & -PAGE_SIZE) | total);	/* Pass back the physical address and the count of mappings */
-						hw_unlock_bit((unsigned int *)&pp->phys_link, PHYS_LOCK);	/* Clear the physical entry lock */
-					}
-					else {									/* This is the case for an I/O mapped area */
-						*value = (vm_machine_attribute_val_t) ((mpv->PTEr & -PAGE_SIZE) | 1);	/* Pass back the physical address and the count of mappings */
-					}
-				}
-			}
-			else {
-				total = 0;
-				while (sva < eva) {
-					seg = sva >> 28;						/* Isolate segment */
-					if((0x00008000 >> seg) & pmap->vflags) actpmap = pmap->pmapPmaps[seg];	/* Set nested pmap if there is one */
-					else actpmap = pmap;					/* Otherwise use the one passed in */
-					
-					if(!(actpmap->pmapUsage[(sva >> pmapUsageShft) & pmapUsageMask])) {	/* See if this chunk has anything in it */
-						sva = (sva + pmapUsageSize) & (-pmapUsageSize);	/* Jump up into the next slot if nothing here */
-						if(!sva) break;						/* We tried to wrap, kill loop... */
-						continue;							/* Check the next... */
-					}
-					if(mp = hw_lock_phys_vir(actpmap->space, sva)) {	/* Find the mapping for this vaddr and lock physent */
-						if((unsigned int)mp&1) {			/* Did the lock on the phys entry time out? */
-							panic("pmap_attribute: timeout obtaining lock on physical entry\n");	/* Scream bloody murder! */
-							continue;
-						}
-						mpv = hw_cpv(mp);					/* Get virtual address of mapping */
-						total += 65536 + (mpv->physent && ((mapping *)((unsigned int)mpv->physent->phys_link & -32))->next);	/* Count the "resident" and shared pages */
-						hw_unlock_bit((unsigned int *)&mpv->physent->phys_link, PHYS_LOCK);	/* Clear the physical entry lock */
-					}
-					sva += PAGE_SIZE;
-				}
-				*value = total;
-			}
-			splx(s);
-			break;
+ 
+kern_return_t pmap_attribute_cache_sync(ppnum_t pp, vm_size_t size,
+				vm_machine_attribute_t  attribute,
+				vm_machine_attribute_val_t* value) {
 	
-		case MATTR_VAL_GET:		/* return current value */
-		case MATTR_VAL_OFF:		/* turn attribute off */
-		case MATTR_VAL_ON:		/* turn attribute on */
-		default:
-			ret = KERN_INVALID_ARGUMENT;
-			break;
+	spl_t s;
+	unsigned int i, npages;
+	
+	npages = round_page_32(size) >> 12;			/* Get the number of pages to do */
+	
+	for(i = 0; i < npages; i++) {				/* Do all requested pages */
+		s = splhigh();							/* No interruptions here */
+		sync_ppage(pp + i);						/* Go flush data cache and invalidate icache */
+		splx(s);								/* Allow interruptions */
 	}
-
-	debugLog2(55, 0, 0);					/* Log pmap_map call */
-
-	return ret;
+	
+	return KERN_SUCCESS;
 }
 
 /*
- * pmap_sync_caches_phys(vm_offset_t pa)
+ * pmap_sync_caches_phys(ppnum_t pa)
  * 
  * Invalidates all of the instruction cache on a physical page and
  * pushes any dirty data from the data cache for the same physical page
  */
  
-void pmap_sync_caches_phys(vm_offset_t pa) {
+void pmap_sync_caches_phys(ppnum_t pa) {
 	
 	spl_t s;
-
-	s = splhigh();						/* No interruptions here */
-	sync_cache(trunc_page(pa), PAGE_SIZE);			/* Sync up dem caches */
-	splx(s);							/* Allow interruptions */
+	
+	s = splhigh();								/* No interruptions here */
+	sync_ppage(pa);								/* Sync up dem caches */
+	splx(s);									/* Allow interruptions */
 	return;
 }
 
@@ -1675,69 +1200,6 @@ pmap_deactivate(
 	return;
 }
 
-#if DEBUG
-
-/*
- * pmap_zero_page
- * pmap_copy page
- * 
- * are implemented in movc.s, these
- * are just wrappers to help debugging
- */
-
-extern void pmap_zero_page_assembler(vm_offset_t p);
-extern void pmap_copy_page_assembler(vm_offset_t src, vm_offset_t dst);
-
-/*
- * pmap_zero_page(pa)
- *
- * pmap_zero_page zeros the specified (machine independent) page pa.
- */
-void
-pmap_zero_page(
-	vm_offset_t p)
-{
-	register struct mapping *mp;
-	register struct phys_entry *pp;
-
-	if (pmdebug & (PDB_USER|PDB_ZERO))
-		kprintf("pmap_zero_page(pa=%x)\n", p);
-
-	/*
-	 * XXX can these happen?
-	 */
-	if (pmap_find_physentry(p) == PHYS_NULL)
-		panic("zero_page: physaddr out of range");
-
-	pmap_zero_page_assembler(p);
-}
-
-/*
- * pmap_copy_page(src, dst)
- *
- * pmap_copy_page copies the specified (machine independent)
- * page from physical address src to physical address dst.
- *
- * We need to invalidate the cache for address dst before
- * we do the copy. Apparently there won't be any mappings
- * to the dst address normally.
- */
-void
-pmap_copy_page(
-	vm_offset_t src,
-	vm_offset_t dst)
-{
-	register struct phys_entry *pp;
-
-	if (pmdebug & (PDB_USER|PDB_COPY))
-		kprintf("pmap_copy_page(spa=%x, dpa=%x)\n", src, dst);
-	if (pmdebug & PDB_COPY)
-		kprintf("pmap_copy_page: phys_copy(%x, %x, %x)\n",
-		       src, dst, PAGE_SIZE);
-
-	pmap_copy_page_assembler(src, dst);
-}
-#endif /* DEBUG */
 
 /*
  * pmap_pageable(pmap, s, e, pageable)
@@ -1767,7 +1229,7 @@ pmap_pageable(
 }
 /*
  *	Routine:	pmap_change_wiring
- *	NOTE USED ANYMORE.
+ *	NOT USED ANYMORE.
  */
 void
 pmap_change_wiring(
@@ -1784,6 +1246,8 @@ pmap_change_wiring(
  *	virtual address range determined by [s, e] and pmap,
  *	s and e must be on machine independent page boundaries and
  *	s must be less than or equal to e.
+ *
+ *  Note that this function will not descend nested pmaps.
  */
 void
 pmap_modify_pages(
@@ -1793,38 +1257,41 @@ pmap_modify_pages(
 {
 	spl_t		spl;
 	mapping		*mp;
+	ppnum_t		pa;
+	addr64_t		va, endva, nextva;
+	unsigned int	saveflags;
 
-#if PMAP_LOWTRACE
-	dbgTrace(0xF1D00010, (unsigned int)pmap, (unsigned int)(sva|((eva-sva)>>12)));	/* (TEST/DEBUG) */
-#endif
-
-#if DEBUG
-	if (pmdebug & PDB_USER) kprintf("pmap_modify_pages(pmap=%x, sva=%x, eva=%x)\n", pmap, sva, eva);
-#endif
-
-	if (pmap == PMAP_NULL) return;						/* If no pmap, can't do it... */
-
-	debugLog2(56, sva, eva);							/* Log pmap_map call */
+	if (pmap == PMAP_NULL) return;					/* If no pmap, can't do it... */
+	
+	va = sva & -4096;								/* Round to page */
+	endva = eva & -4096;							/* Round to page */
 
-	spl=splhigh();										/* Don't bother me */
+	while (va < endva) {							/* Walk through all pages */
 
-	for ( ; sva < eva; sva += PAGE_SIZE) {				/* Cycle through the whole range */	
-		mp = hw_lock_phys_vir(pmap->space, sva);		/* Lock the physical entry for this mapping */
-		if(mp) {										/* Did we find one? */
-			if((unsigned int)mp&1) {					/* Did the lock on the phys entry time out? */
-				panic("pmap_modify_pages: timeout obtaining lock on physical entry\n");	/* Scream bloody murder! */
-				continue;
-			}
-			mp = hw_cpv(mp);							/* Convert to virtual addressing */				
-			if(!mp->physent) continue;					/* No physical entry means an I/O page, we can't set attributes */
-			mapping_set_mod(mp->physent);				/* Set the modfied bit for this page */
-			hw_unlock_bit((unsigned int *)&mp->physent->phys_link, PHYS_LOCK);	/* Unlock the physical entry */
+		spl = splhigh();							/* We can't allow any loss of control here */
+	
+		mp = mapping_find(pmap, (addr64_t)va, &va, 0);	/* Find the mapping for this address */
+		
+		if(!mp) {									/* Is the page mapped? */
+			splx(spl);								/* Page not mapped, restore interruptions */
+			if((va == 0) || (va >= endva)) break;	/* We are done if there are no more or we hit the end... */
+			continue;								/* We are not done and there is more to check... */
 		}
+		
+		saveflags = mp->mpFlags;					/* Remember the flags */
+		pa = mp->mpPAddr;							/* Remember ppage because mapping may vanish after drop call */
+	
+		mapping_drop_busy(mp);						/* We have everything we need from the mapping */
+	
+		splx(spl);									/* Restore 'rupts */
+	
+		if(saveflags & (mpNest | mpBlock)) continue;	/* Can't mess around with these guys... */	
+		
+		mapping_set_mod(pa);						/* Set the modfied bit for this page */
+		
+		if(va == 0) break;							/* We hit the end of the pmap, might as well leave now... */
 	}
-	splx(spl);											/* Restore the interrupt level */
-
-	debugLog2(57, 0, 0);								/* Log pmap_map call */
-	return;												/* Leave... */
+	return;											/* Leave... */
 }
 
 /*
@@ -1837,36 +1304,9 @@ pmap_modify_pages(
 void
 pmap_clear_modify(vm_offset_t pa)
 {
-	register struct phys_entry	*pp;
-	spl_t		spl;
-
-#if PMAP_LOWTRACE
-	dbgTrace(0xF1D00011, (unsigned int)pa, 0);			/* (TEST/DEBUG) */
-#endif
-#if DEBUG
-	if (pmdebug & PDB_USER)
-		kprintf("pmap_clear_modify(pa=%x)\n", pa);
-#endif
-
-	pp = pmap_find_physentry(pa);						/* Find the physent for this page */
-	if (pp == PHYS_NULL) return;						/* If there isn't one, just leave... */
-
-	debugLog2(58, pa, 0);					/* Log pmap_map call */
 
-	spl=splhigh();										/* Don't bother me */
-
-	if(!hw_lock_bit((unsigned int *)&pp->phys_link, PHYS_LOCK, LockTimeOut)) {	/* Try to get the lock on the physical entry */
-		panic("pmap_clear_modify: Timeout getting lock on physent at %08X\n", pp);	/* Arrrgghhhh! */
-		splx(spl);										/* Restore 'rupts */
-		return;											/* Should die before here */
-	}
+	mapping_clr_mod((ppnum_t)pa);				/* Clear all change bits for physical page */
 
-	mapping_clr_mod(pp);								/* Clear all change bits for physical page */
-
-	hw_unlock_bit((unsigned int *)&pp->phys_link, PHYS_LOCK);	/* Unlock the physical entry */
- 	splx(spl);											/* Restore the interrupt level */
-
-	debugLog2(59, 0, 0);					/* Log pmap_map call */
 }
 
 /*
@@ -1877,40 +1317,8 @@ pmap_clear_modify(vm_offset_t pa)
 boolean_t
 pmap_is_modified(register vm_offset_t pa)
 {
-	register struct phys_entry	*pp;
-	spl_t		spl;
-	boolean_t	ret;
-
-
-#if PMAP_LOWTRACE
-	dbgTrace(0xF1D00012, (unsigned int)pa, 0);			/* (TEST/DEBUG) */
-#endif
-#if DEBUG
-	if (pmdebug & PDB_USER)
-		kprintf("pmap_is_modified(pa=%x)\n", pa);
-#endif
-
-	pp = pmap_find_physentry(pa);						/* Find the physent for this page */
-	if (pp == PHYS_NULL) return(FALSE);					/* Just indicate not set... */
+	return mapping_tst_mod((ppnum_t)pa);	/* Check for modified */
 	
-	debugLog2(60, pa, 0);					/* Log pmap_map call */
-
-	spl=splhigh();										/* Don't bother me */
-
-	if(!hw_lock_bit((unsigned int *)&pp->phys_link, PHYS_LOCK, LockTimeOut)) {	/* Try to get the lock on the physical entry */
-		panic("pmap_is_modified: Timeout getting lock on physent at %08X\n", pp);	/* Arrrgghhhh! */
-		splx(spl);										/* Restore 'rupts */
-		return 0;										/* Should die before here */
-	}
-	
-	ret = mapping_tst_mod(pp);							/* Check for modified */
-	
-	hw_unlock_bit((unsigned int *)&pp->phys_link, PHYS_LOCK);	/* Unlock the physical entry */
- 	splx(spl);											/* Restore the interrupt level */
-	
-	debugLog2(61, ret, 0);					/* Log pmap_map call */
-
-	return ret;										
 }
 
 /*
@@ -1922,29 +1330,7 @@ pmap_is_modified(register vm_offset_t pa)
 void
 pmap_clear_reference(vm_offset_t pa)
 {
-	register struct phys_entry	*pp;
-	spl_t		spl;
-
-
-#if PMAP_LOWTRACE
-	dbgTrace(0xF1D00013, (unsigned int)pa, 0);				/* (TEST/DEBUG) */
-#endif
-#if DEBUG
-	if (pmdebug & PDB_USER)
-		kprintf("pmap_clear_reference(pa=%x)\n", pa);
-#endif
-
-	pp = pmap_find_physentry(pa);							/* Find the physent for this page */
-	if (pp == PHYS_NULL) return;							/* If there isn't one, just leave... */
-
-	debugLog2(62, pa, 0);					/* Log pmap_map call */
-
-	spl=splhigh();											/* Don't bother me */
-	mapping_clr_ref(pp);									/* Clear all reference bits for physical page */
- 	splx(spl);												/* Restore the interrupt level */
-
-	debugLog2(63, 0, 0);					/* Log pmap_map call */
-
+	mapping_clr_ref((ppnum_t)pa);			/* Check for modified */
 }
 
 /*
@@ -1955,40 +1341,27 @@ pmap_clear_reference(vm_offset_t pa)
 boolean_t
 pmap_is_referenced(vm_offset_t pa)
 {
-	register struct phys_entry 	*pp;
-	spl_t		spl;
-	boolean_t	ret;
-
-
-#if PMAP_LOWTRACE
-	dbgTrace(0xF1D00014, (unsigned int)pa, 0);			/* (TEST/DEBUG) */
-#endif
-#if DEBUG
-	if (pmdebug & PDB_USER)
-		kprintf("pmap_is_referenced(pa=%x)\n", pa);
-#endif
+	return mapping_tst_ref((ppnum_t)pa);	/* Check for referenced */
+}
 
-	pp = pmap_find_physentry(pa);						/* Find the physent for this page */
-	if (pp == PHYS_NULL) return(FALSE);					/* Just indicate not set... */
-	
-	debugLog2(64, pa, 0);					/* Log pmap_map call */
+/*
+ * pmap_canExecute(ppnum_t pa)
+ *  returns 1 if instructions can execute
+ *  returns 0 if know not (i.e. guarded and/or non-executable set)
+ *  returns -1 if we don't know (i.e., the page is no RAM)
+ */
+int
+pmap_canExecute(ppnum_t pa)
+{		
+	phys_entry *physent;
+	unsigned int pindex;
 
-	spl=splhigh();										/* Don't bother me */
+	physent = mapping_phys_lookup(pa, &pindex);				/* Get physical entry */
 
-	if(!hw_lock_bit((unsigned int *)&pp->phys_link, PHYS_LOCK, LockTimeOut)) {	/* Try to get the lock on the physical entry */
-		panic("pmap_is_referenced: Timeout getting lock on physent at %08X\n", pp);	/* Arrrgghhhh! */
-		splx(spl);										/* Restore 'rupts */
-		return 0;										/* Should die before here */
-	}
-	
-	ret = mapping_tst_ref(pp);							/* Check for referenced */
-	
-	hw_unlock_bit((unsigned int *)&pp->phys_link, PHYS_LOCK);	/* Unlock the physical entry */
- 	splx(spl);											/* Restore the interrupt level */
-	
-	debugLog2(65, ret, 0);					/* Log pmap_map call */
+	if(!physent) return -1;									/* If there is no physical entry, we don't know... */
 
-	return ret;										
+	if((physent->ppLink & (ppN | ppG))) return 0;			/* If we are marked non-executable or guarded, say we can not execute */
+	return 1;												/* Good to go... */
 }
 
 #if	MACH_VM_DEBUG
@@ -2016,25 +1389,15 @@ pmap_copy_part_page(
 {
 	register struct phys_entry *pp_src, *pp_dst;
 	spl_t	s;
+	addr64_t fsrc, fdst;
 
+	assert(((dst <<12) & PAGE_MASK+dst_offset+len) <= PAGE_SIZE);
+	assert(((src <<12) & PAGE_MASK+src_offset+len) <= PAGE_SIZE);
 
-#if PMAP_LOWTRACE
-	dbgTrace(0xF1D00019, (unsigned int)src+src_offset, (unsigned int)dst+dst_offset);	/* (TEST/DEBUG) */
-	dbgTrace(0xF1D04019, (unsigned int)len, 0);			/* (TEST/DEBUG) */
-#endif
-	s = splhigh();
-
-        assert(((dst & PAGE_MASK)+dst_offset+len) <= PAGE_SIZE);
-        assert(((src & PAGE_MASK)+src_offset+len) <= PAGE_SIZE);
-
-	/*
-	 * Since the source and destination are physical addresses, 
-	 * turn off data translation to perform a  bcopy() in bcopy_phys().
-	 */
-	phys_copy((vm_offset_t) src+src_offset,
-		  (vm_offset_t) dst+dst_offset, len);
+	fsrc = ((addr64_t)src << 12) + src_offset;
+	fdst = ((addr64_t)dst << 12) + dst_offset;
 
-	splx(s);
+	phys_copy(fsrc, fdst, len);								/* Copy the stuff physically */
 }
 
 void
@@ -2046,24 +1409,16 @@ pmap_zero_part_page(
     panic("pmap_zero_part_page");
 }
 
-boolean_t pmap_verify_free(vm_offset_t pa) {
+boolean_t pmap_verify_free(ppnum_t pa) {
 
 	struct phys_entry	*pp;
+	unsigned int pindex;
 
-#if PMAP_LOWTRACE
-	dbgTrace(0xF1D00007, (unsigned int)pa, 0);				/* (TEST/DEBUG) */
-#endif
-
-#if DEBUG
-	if (pmdebug & PDB_USER)
-		kprintf("pmap_verify_free(pa=%x)\n", pa);
-#endif
-
-	if (!pmap_initialized) return(TRUE);
+	pp = mapping_phys_lookup(pa, &pindex);	/* Get physical entry */
+	if (pp == 0) return FALSE;					/* If there isn't one, show no mapping... */
 
-	pp = pmap_find_physentry(pa);							/* Look up the physical entry */
-	if (pp == PHYS_NULL) return FALSE;						/* If there isn't one, show no mapping... */
-	return ((mapping *)((unsigned int)pp->phys_link & ~PHYS_FLAGS) == MAPPING_NULL);	/* Otherwise, return TRUE if mapping exists... */
+	if(pp->ppLink & ~(ppLock | ppN | ppFlags)) return TRUE;	/* We have at least one mapping */
+	return FALSE;								/* No mappings */
 }
 
 
@@ -2073,13 +1428,9 @@ void pmap_switch(pmap_t map)
 {
 	unsigned int i;
 
-#if DEBUG
-	if (watchacts & WA_PCB) {
-		kprintf("Switching to map at 0x%08x, space=%d\n",
-		       map,map->space);
-	}
-#endif /* DEBUG */
 
+	hw_blow_seg(copyIOaddr);					/* Blow off the first segment */
+	hw_blow_seg(copyIOaddr + 0x10000000ULL);	/* Blow off the second segment */
 
 /* when changing to kernel space, don't bother
  * doing anything, the kernel is mapped from here already.
@@ -2093,113 +1444,117 @@ void pmap_switch(pmap_t map)
 }
 
 /*
- *	kern_return_t pmap_nest(grand, subord, vaddr, size)
+ *	kern_return_t pmap_nest(grand, subord, vstart, size)
  *
  *	grand  = the pmap that we will nest subord into
  *	subord = the pmap that goes into the grand
- *	vaddr  = start of range in pmap to be inserted
- *	size   = size of range in pmap to be inserted
+ *	vstart  = start of range in pmap to be inserted
+ *	nstart  = start of range in pmap nested pmap
+ *	size   = Size of nest area (up to 16TB)
  *
  *	Inserts a pmap into another.  This is used to implement shared segments.
  *	On the current PPC processors, this is limited to segment (256MB) aligned
  *	segment sized ranges.
+ *
+ *	We actually kinda allow recursive nests.  The gating factor is that we do not allow 
+ *	nesting on top of something that is already mapped, i.e., the range must be empty.
+ *
+ *	
+ *
+ *	Note that we depend upon higher level VM locks to insure that things don't change while
+ *	we are doing this.  For example, VM should not be doing any pmap enters while it is nesting
+ *	or do 2 nests at once.
  */
 
-kern_return_t pmap_nest(pmap_t grand, pmap_t subord, vm_offset_t vaddr, vm_size_t size) {
-			
-	unsigned int oflags, seg, grandr;
-	int i;
+kern_return_t pmap_nest(pmap_t grand, pmap_t subord, addr64_t vstart, addr64_t nstart, uint64_t size) {
+		
+	addr64_t nextva, vend, colladdr;
+	unsigned int msize;
+	int i, nlists, asize;
+	spl_t	s;
+	mapping *mp;
 	
-	if(size != 0x10000000) return KERN_INVALID_VALUE;	/* We can only do this for 256MB for now */
-	if(vaddr & 0x0FFFFFFF) return KERN_INVALID_VALUE;	/* We can only do this aligned to 256MB */
-
-	while(1) {									/* Test and set the subordinate flag */
-		oflags = subord->vflags & ~pmapAltSeg;	/* Get old unset value */
-		if(subord->vflags & pmapAltSeg) {		/* Are trying to nest one already nested? */
-			panic("pmap_nest: Attempt to nest an already nested pmap\n");
-		}
-		if(hw_compare_and_store(oflags, oflags | pmapSubord, &subord->vflags)) break;	/* Done if we got it set */
-	}
 	
-	simple_lock(&grand->lock);					/* Lock the superior pmap */
-
-	if(grand->vflags & pmapSubord) {			/* Are we only one level deep? */
-		simple_unlock(&grand->lock);			/* Unlock the superior pmap */
-		panic("pmap_nest: Attempt to nest into subordinate pmap\n");
-		return KERN_FAILURE;					/* Shame on you */
-	}
-
-	seg = vaddr >> 28;							/* Isolate the segment number */
-	if((0x00008000 >> seg) & grand->vflags) {	/* See if it is already in use */
-		simple_unlock(&grand->lock);			/* Unlock the superior pmap */
-		panic("pmap_nest: Attempt to nest into already nested segment\n");
-		return KERN_FAILURE;					/* Shame on you */
+	if(size & 0x0FFFFFFFULL) return KERN_INVALID_VALUE;	/* We can only do this for multiples of 256MB */
+	if((size >> 28) > 65536)  return KERN_INVALID_VALUE;	/* Max size we can nest is 16TB */
+	if(vstart & 0x0FFFFFFFULL) return KERN_INVALID_VALUE;	/* We can only do this aligned to 256MB */
+	if(nstart & 0x0FFFFFFFULL) return KERN_INVALID_VALUE;	/* We can only do this aligned to 256MB */
+	
+	if(size == 0) {								/*	Is the size valid? */
+		panic("pmap_nest: size is invalid - %016llX\n", size);
 	}
 	
-	grand->pmapPmaps[seg] = subord;				/* Set the pointer to the subordinate */
-	grand->pmapSegs[seg] = SEG_REG_PROT | (seg << 20) | subord->space;		/* Set the vsid to the subordinate's vsid */
-	grand->vflags |= (0x00008000 >> seg);		/* Set in-use bit */
+	msize = (size >> 28) - 1;							/* Change size to blocks of 256MB */
+	
+	nlists = mapSetLists(grand);						/* Set number of lists this will be on */
 
-	grandr = (unsigned int)grand ^ grand->pmapvr;	/* Get real address of the grand pmap */
+	mp = mapping_alloc(nlists);							/* Get a spare mapping block */
 	
-	simple_unlock(&grand->lock);				/* Unlock the grand pmap */
+	mp->mpFlags = 0x01000000 | mpNest | nlists;			/* Set the flags. Make sure busy count is 1 */
+	mp->mpSpace = subord->space;						/* Set the address space/pmap lookup ID */
+	mp->mpBSize = msize;								/* Set the size */
+	mp->mpPte = 0;										/* Set the PTE invalid */
+	mp->mpPAddr = 0;									/* Set the physical page number */
+	mp->mpVAddr = vstart;								/* Set the address */
+	mp->mpNestReloc = nstart - vstart;					/* Set grand to nested vaddr relocation value */
 	
-
-/*
- *	Note that the following will force the segment registers to be reloaded following
- *	the next interrupt on all processors if they are using the pmap we just changed.
- *
- */
-
-
-	for(i=0; i < real_ncpus; i++) {							/* Cycle through processors */
-		(void)hw_compare_and_store((unsigned int)grandr, 0, &per_proc_info[i].Lastpmap);	/* Clear if ours */
+	colladdr = hw_add_map(grand, mp);					/* Go add the mapping to the pmap */
+	
+	if(colladdr) {										/* Did it collide? */
+		vend = vstart + size - 4096;					/* Point to the last page we would cover in nest */	
+		panic("pmap_nest: attempt to nest into a non-empty range - pmap = %08X, start = %016llX, end = %016llX\n",
+			grand, vstart, vend);
 	}
-		
-	return KERN_SUCCESS;						/* Bye, bye, butterfly... */
+	
+	return KERN_SUCCESS;
 }
 
-
 /*
- *	kern_return_t pmap_unnest(grand, vaddr, size)
+ *	kern_return_t pmap_unnest(grand, vaddr)
  *
  *	grand  = the pmap that we will nest subord into
- *	vaddr  = start of range in pmap to be inserted
- *	size   = size of range in pmap to be inserted
+ *	vaddr  = start of range in pmap to be unnested
  *
  *	Removes a pmap from another.  This is used to implement shared segments.
  *	On the current PPC processors, this is limited to segment (256MB) aligned
  *	segment sized ranges.
  */
 
-kern_return_t pmap_unnest(pmap_t grand, vm_offset_t vaddr, vm_size_t size) {
+kern_return_t pmap_unnest(pmap_t grand, addr64_t vaddr) {
 			
 	unsigned int oflags, seg, grandr, tstamp;
 	int i, tcpu, mycpu;
+	addr64_t nextva;
+	spl_t s;
+	mapping *mp;
 		
-	if(size != 0x10000000) return KERN_INVALID_VALUE;	/* We can only do this for 256MB for now */
-	if(vaddr & 0x0FFFFFFF) return KERN_INVALID_VALUE;	/* We can only do this aligned to 256MB */
-
-	simple_lock(&grand->lock);					/* Lock the superior pmap */
-	disable_preemption();						/* It's all for me! */
-
-	seg = vaddr >> 28;							/* Isolate the segment number */
-	if(!((0x00008000 >> seg) & grand->vflags)) {	/* See if it is already in use */
-		enable_preemption();					/* Ok, your turn */
-		simple_unlock(&grand->lock);			/* Unlock the superior pmap */
-		panic("pmap_unnest: Attempt to unnest an unnested segment\n");
-		return KERN_FAILURE;					/* Shame on you */
+	s = splhigh();										/* Make sure interruptions are disabled */
+
+	mp = mapping_find(grand, vaddr, &nextva, 0);		/* Find the nested map */
+
+	if(((unsigned int)mp & mapRetCode) != mapRtOK) {	/* See if it was even nested */
+		panic("pmap_unnest: Attempt to unnest an unnested segment - va = %016llX\n", vaddr);
+	}
+
+	if(!(mp->mpFlags & mpNest)) {						/* Did we find something other than a nest? */
+		panic("pmap_unnest: Attempt to unnest something that is not a nest - va = %016llX\n", vaddr);
 	}
 	
-	grand->pmapPmaps[seg] = (pmap_t)0;			/* Clear the pointer to the subordinate */
-	grand->pmapSegs[seg] = grand->space;		/* Set the pointer to the subordinate's vsid */
-	grand->pmapSegs[seg] = SEG_REG_PROT | (seg << 20) | grand->space;		/* Set the vsid to the grand's vsid */
-	grand->vflags &= ~(0x00008000 >> seg);		/* Clear in-use bit */
+	if(mp->mpVAddr != vaddr) {							/* Make sure the address is the same */
+		panic("pmap_unnest: Attempt to unnest something that is not at start of nest - va = %016llX\n", vaddr);
+	}
 
-	grandr = (unsigned int)grand ^ grand->pmapvr;	/* Get real address of the grand pmap */
+	(void)hw_atomic_or(&mp->mpFlags, mpRemovable);		/* Show that this mapping is now removable */
 	
-	simple_unlock(&grand->lock);				/* Unlock the superior pmap */
+	mapping_drop_busy(mp);								/* Go ahead and relase the mapping now */
 
+	disable_preemption();								/* It's all for me! */
+	splx(s);											/* Restore 'rupts */
+		
+	(void)mapping_remove(grand, vaddr);					/* Toss the nested pmap mapping */
+	
+	invalidateSegs(grand);								/* Invalidate the pmap segment cache */
+	
 /*
  *	Note that the following will force the segment registers to be reloaded 
  *	on all processors (if they are using the pmap we just changed) before returning.
@@ -2215,72 +1570,233 @@ kern_return_t pmap_unnest(pmap_t grand, vm_offset_t vaddr, vm_size_t size) {
  */
 
 
-	mycpu = cpu_number();						/* Who am I? Am I just a dream? */
-	for(i=0; i < real_ncpus; i++) {				/* Cycle through processors */
-		if(hw_compare_and_store((unsigned int)grandr, 0, &per_proc_info[i].Lastpmap)) {	/* Clear if ours and kick the other guy if he was using it */
-			if(i == mycpu) continue;				/* Don't diddle ourselves */
-			tstamp = per_proc_info[i].ruptStamp[1];	/* Save the processor's last interrupt time stamp */
+	mycpu = cpu_number();								/* Who am I? Am I just a dream? */
+	for(i=0; i < real_ncpus; i++) {						/* Cycle through processors */
+		if((unsigned int)grand == per_proc_info[i].ppUserPmapVirt) {	/* Is this guy using the changed pmap? */
+			
+			per_proc_info[i].ppInvSeg = 1;				/* Show that we need to invalidate the segments */
+			
+			if(i == mycpu) continue;					/* Don't diddle ourselves */
+		
+			tstamp = per_proc_info[i].ruptStamp[1];		/* Save the processor's last interrupt time stamp */
 			if(cpu_signal(i, SIGPwake, 0, 0) != KERN_SUCCESS) {	/* Make sure we see the pmap change */
 				continue;
 			}
+			
 			if(!hw_cpu_wcng(&per_proc_info[i].ruptStamp[1], tstamp, LockTimeOut)) {	/* Wait for the other processors to enter debug */
 				panic("pmap_unnest: Other processor (%d) did not see interruption request\n", i);
 			}
 		}
 	}
 
-	enable_preemption();						/* Others can run now */
-	return KERN_SUCCESS;						/* Bye, bye, butterfly... */
+	enable_preemption();								/* Others can run now */
+	return KERN_SUCCESS;								/* Bye, bye, butterfly... */
 }
 
 
-void pmap_ver(pmap_t pmap, vm_offset_t sva, vm_offset_t eva) {
+/*
+ *	void MapUserAddressSpaceInit(void)
+ *
+ *	Initialized anything we need to in order to map user address space slices into
+ *	the kernel.  Primarily used for copy in/out.
+ *
+ *	Currently we only support one 512MB slot for this purpose.  There are two special
+ *	mappings defined for the purpose: the special pmap nest, and linkage mapping.
+ *
+ *	The special pmap nest (which is allocated in this function) is used as a place holder
+ *	in the kernel's pmap search list. It is 512MB long and covers the address range
+ *	starting at copyIOaddr.  It points to no actual memory and when the fault handler 
+ *	hits in it, it knows to look in the per_proc and start using the linkage
+ *	mapping contained therin.
+ *
+ *	The linkage mapping is used to glue the user address space slice into the 
+ *	kernel.  It contains the relocation information used to transform the faulting
+ *	kernel address into the user address space.  It also provides the link to the
+ *	user's pmap.  This is pointed to by the per_proc and is switched in and out
+ *	whenever there is a context switch.
+ *
+ */
 
-	int cnt, i, j, k;
-	vm_offset_t xx;
+void MapUserAddressSpaceInit(void) {
+		
+	addr64_t colladdr;
+	int nlists, asize;
+	mapping *mp;
+	
+	nlists = mapSetLists(kernel_pmap);					/* Set number of lists this will be on */
+	
+	mp = mapping_alloc(nlists);							/* Get a spare mapping block */
 	
-	if(!pmap) return;
+	mp->mpFlags = 0x01000000 |mpNest | mpSpecial | nlists;	/* Set the flags. Make sure busy count is 1 */
+	mp->mpSpace = kernel_pmap->space;					/* Set the address space/pmap lookup ID */
+	mp->mpBSize = 1;									/* Set the size to 2 segments */
+	mp->mpPte = 0;										/* Means nothing */
+	mp->mpPAddr = 0;									/* Means nothing */
+	mp->mpVAddr = copyIOaddr;							/* Set the address range we cover */
+	mp->mpNestReloc = 0;								/* Means nothing */
+	
+	colladdr = hw_add_map(kernel_pmap, mp);				/* Go add the mapping to the pmap */
+	
+	if(colladdr) {										/* Did it collide? */
+		panic("MapUserAddressSpaceInit: MapUserAddressSpace range already mapped\n");
+	}
+	
+	return;
+}
+
+/*
+ *	addr64_t MapUserAddressSpace(vm_map_t map, vm_offset_t va, size)
+ *
+ *	map  = the vm_map that we are mapping into the kernel
+ *	va = start of the address range we are mapping
+ *	size  = size of the range.  No greater than 256MB and not 0.
+ *	Note that we do not test validty, we chose to trust our fellows...
+ *
+ *	Maps a slice of a user address space into a predefined kernel range
+ *	on a per-thread basis.  In the future, the restriction of a predefined
+ *	range will be loosened.
+ *
+ *	Builds the proper linkage map to map the user range
+ *  We will round this down to the previous segment boundary and calculate
+ *	the relocation to the kernel slot
+ *
+ *	We always make a segment table entry here if we need to.  This is mainly because of
+ *	copyin/out and if we don't, there will be multiple segment faults for
+ *	each system call.  I have seen upwards of 30000 per second.
+ *
+ *	We do check, however, to see if the slice is already mapped and if so,
+ *	we just exit.  This is done for performance reasons.  It was found that 
+ *	there was a considerable boost in copyin/out performance if we did not
+ *	invalidate the segment at ReleaseUserAddressSpace time, so we dumped the
+ *	restriction that you had to bracket MapUserAddressSpace.  Further, there 
+ *	is a yet further boost if you didn't need to map it each time.  The theory
+ *	behind this is that many times copies are to or from the same segment and
+ *	done multiple times within the same system call.  To take advantage of that,
+ *	we check cioSpace and cioRelo to see if we've already got it.  
+ *
+ *	We also need to half-invalidate the slice when we context switch or go
+ *	back to user state.  A half-invalidate does not clear the actual mapping,
+ *	but it does force the MapUserAddressSpace function to reload the segment
+ *	register/SLBE.  If this is not done, we can end up some pretty severe
+ *	performance penalties. If we map a slice, and the cached space/relocation is
+ *	the same, we won't reload the segment registers.  Howver, since we ran someone else,
+ *	our SR is cleared and we will take a fault.  This is reasonable if we block
+ *	while copying (e.g., we took a page fault), but it is not reasonable when we 
+ *	just start.  For this reason, we half-invalidate to make sure that the SR is
+ *	explicitly reloaded.
+ *	 
+ *	Note that we do not go to the trouble of making a pmap segment cache
+ *	entry for these guys because they are very short term -- 99.99% of the time
+ *	they will be unmapped before the next context switch.
+ *
+ */
 
-	sva = trunc_page(sva);
-	eva = trunc_page(eva);
+addr64_t MapUserAddressSpace(vm_map_t map, addr64_t va, unsigned int size) {
+		
+	addr64_t baddrs, reladd;
+	thread_act_t act;
+	mapping *mp;
+	struct per_proc_info *perproc;
 	
-	for(i = 0; i < (pmapUsageMask + 1); i++) {	/* Step through them all */
-		if((pmap->pmapUsage[i]) > 8192) {		/* See if this is a sane number */
-			panic("pmap_ver: pmapUsage slot for %08X has invalid count (%d) for pmap %08X\n",
-				i * pmapUsageSize, pmap->pmapUsage[i], pmap);
-		}
+	baddrs = va & 0xFFFFFFFFF0000000ULL;				/* Isolate the segment */
+	act = current_act();								/* Remember our activation */
+
+	reladd = baddrs - copyIOaddr;						/* Get the relocation from user to kernel */
+	
+	if((act->mact.cioSpace == map->pmap->space) && (act->mact.cioRelo == reladd)) {	/* Already mapped? */
+		return ((va & 0x0FFFFFFFULL) | copyIOaddr);		/* Pass back the kernel address we are to use */
 	}
-	j = 0;
-	while(1) {									/* Try multiple times */
-		cnt = 0;
-		for(i = 0; i < (pmapUsageMask + 1); i++) {	/* Step through them all */
-			cnt = cnt + pmap->pmapUsage[i];			/* Sum all slots */
-		}
-		if(cnt == pmap->stats.resident_count) break;	/* We're ok if we match... */
+
+	disable_preemption();								/* Don't move... */	
+	perproc = getPerProc();								/* Get our per_proc_block */
+	
+	mp = (mapping *)&perproc->ppCIOmp;					/* Make up for C */
+	act->mact.cioRelo = reladd;							/* Relocation from user to kernel */
+	mp->mpNestReloc = reladd;							/* Relocation from user to kernel */
+	
+	act->mact.cioSpace = map->pmap->space;				/* Set the address space/pmap lookup ID */
+	mp->mpSpace = map->pmap->space;						/* Set the address space/pmap lookup ID */
+	
+/*
+ *	Here we make an assumption that we are going to be using the base pmap's address space.
+ *	If we are wrong, and that would be very, very, very rare, the fault handler will fix us up.
+ */ 
+
+	hw_map_seg(map->pmap,  copyIOaddr, baddrs);			/* Make the entry for the first segment */
+
+	enable_preemption();								/* Let's move */
+	return ((va & 0x0FFFFFFFULL) | copyIOaddr);			/* Pass back the kernel address we are to use */
+}
+
+/*
+ *	void ReleaseUserAddressMapping(addr64_t kva)
+ *
+ *	kva = kernel address of the user copy in/out slice
+ *
+ */
+
+void ReleaseUserAddressSpace(addr64_t kva) {
 		
-		j++;
-		for(i = 0; i < 100000; i++) {
-			k = j + i;
-		}
-		if(j >= 10) {
-			panic("pmap_ver: pmapUsage total (%d) does not match resident count (%d) for pmap %08X\n",
-				cnt, pmap->stats.resident_count, pmap);
-		}
+	int i;
+	addr64_t nextva, vend, kaddr, baddrs;
+	unsigned int msize;
+	thread_act_t act;
+	mapping *mp;
+	
+	if(kva == 0) return;								/* Handle a 0 */
+		
+	disable_preemption();								/* Don't move... */
+	
+	act = current_act();								/* Remember our activation */
+
+	if(act->mact.cioSpace == invalSpace) {				/* We only support one at a time */
+		panic("ReleaseUserAddressMapping: attempt release undefined copy in/out user address space slice\n");
 	}
+
+	act->mact.cioSpace = invalSpace;					/* Invalidate space */
+	mp = (mapping *)&per_proc_info[cpu_number()].ppCIOmp;	/* Make up for C */
+	mp->mpSpace = invalSpace;							/* Trash it in the per_proc as well */
 	
-	for(xx = sva; xx < eva; xx += PAGE_SIZE) {	/* See if any slots not clear */
-		if(pmap_extract(pmap, xx)) {
-			panic("pmap_ver: range (%08X to %08X) not empty at %08X for pmap %08X\n",
-				sva, eva, xx, pmap);
-		}
+	hw_blow_seg(copyIOaddr);							/* Blow off the first segment */
+	hw_blow_seg(copyIOaddr + 0x10000000ULL);			/* Blow off the second segment */
+	
+	enable_preemption();								/* Let's move */
+	
+	return;												/* Let's leave */
+}
+
+
+
+/*
+ *	kern_return_t pmap_boot_map(size)
+ *
+ *	size   = size of virtual address range to be mapped
+ *
+ *	This function is used to assign a range of virtual addresses before VM in 
+ *	initialized.  It starts at VM_MAX_KERNEL_ADDRESS and works downward.
+ *	The variable vm_last_addr contains the current highest possible VM
+ *	assignable address.  It is a panic to attempt to call this after VM has
+ *	started up.  The only problem is, is that we may not have the serial or
+ *	framebuffer mapped, so we'll never know we died.........
+ */
+
+vm_offset_t pmap_boot_map(vm_size_t size) {
+			
+	if(kernel_map != VM_MAP_NULL) {				/* Has VM already started? */
+		panic("pmap_boot_map: VM started\n");
 	}
+	
+	size = round_page_32(size);					/* Make sure this is in pages */
+	vm_last_addr = vm_last_addr - size;			/* Allocate the memory */
+	return (vm_last_addr + 1);					/* Return the vaddr we just allocated */
+
 }
 
 
+
 /* temporary workaround */
 boolean_t
 coredumpok(vm_map_t map, vm_offset_t va)
 {
   return TRUE;
 }
-
diff --git a/osfmk/ppc/pmap.h b/osfmk/ppc/pmap.h
index 0a4d2e97e..1958a3fbd 100644
--- a/osfmk/ppc/pmap.h
+++ b/osfmk/ppc/pmap.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -56,45 +59,99 @@
 #include <kern/queue.h>
 #include <vm/pmap.h>
 
+#define maxPPage32 0x000FFFFF			/* Maximum page number in 32-bit machines */
+
+typedef uint32_t shexlock;
+
+#pragma pack(4)							/* Make sure the structure stays as we defined it */
+
+struct sgc {
+	uint64_t	sgcESID;				/* ESID portion of segment cache */
+#define sgcESmsk	0xFFFFFFFFF0000000ULL	/* ESID portion of segment register cache */
+	uint64_t	sgcVSID;				/* VSID portion of segment cache */
+#define sgcVSmsk	0xFFFFFFFFFFFFF000ULL	/* VSID mask */
+#define sgcVSKeys	0x0000000000000C00ULL	/* Protection keys */
+#define sgcVSKeyUsr	53					/* User protection key */
+#define sgcVSNoEx	0x0000000000000200ULL	/* No execute */
+};
+#pragma pack()
+
+typedef struct sgc sgc;
+
+#pragma pack(4)							/* Make sure the structure stays as we defined it */
 struct pmap {
-	queue_head_t	pmap_link;		/* MUST BE FIRST */
-	unsigned int	pmapvr;			/* Virtual to real conversion mask */
-	space_t			space;			/* space for this pmap */
-#define BMAPLOCK 0x00000001
-	struct blokmap	*bmaps;			/* Physical pointer to odd-size page maps */
-	int				ref_count;		/* reference count */
-	unsigned int	vflags;			/* Alternate map validity flags */
-#define pmapBatVal  0xFF000000
-#define pmapBatDVal 0xF0000000
-#define pmapBatIVal 0x0F000000
-#define pmapFlags   0x00FF0000
-#define pmapSubord  0x00800000
-#define pmapAltSeg	0x0000FFFF
-	unsigned int	spaceNum;		/* Space number */
-/*	PPC line boundary here - 020 */
-	unsigned int	pmapSegs[16];	/* Contents of segment register if different than base space */
-/*	PPC line boundary here - 060 */
-	struct pmap		*pmapPmaps[16];	/* Pointer to next lower level of pmaps */
-/*	PPC line boundary here - 0A0 */
-/*	Note: this must start on a word boundary */
-	unsigned short	pmapUsage[128];	/* Count of pages mapped into 32mb (8192 page) slots */
-#define pmapUsageShft 25
-#define pmapUsageMask 0x0000007F
-#define pmapUsageSize (32*1024*1024)
-	
-/*	PPC line boundary here - 1A0 */
-	struct pmap_statistics	stats;	/* statistics */
-	decl_simple_lock_data(,lock)	/* lock on map */
+	queue_head_t	pmap_link;			/* MUST BE FIRST */
+	addr64_t		pmapvr;				/* Virtual to real conversion mask */
+	shexlock		pmapSXlk;			/* Shared/Exclusive lock for mapping changes */
+	unsigned int	space;				/* space for this pmap */
+#define invalSpace 0x00000001			/* Predefined always invalid space */
+	int				ref_count;			/* reference count */
+	unsigned int	pmapFlags;			/* Flags */
+#define pmapKeys	0x00000007			/* Keys and no execute bit to use with this pmap */
+#define pmapKeyDef	0x00000006			/* Default keys - Sup = 1, user = 1, no ex = 0 */
+#define pmapVMhost	0x00000010			/* pmap with Virtual Machines attached to it */
+	unsigned int	spaceNum;			/* Space number */
+	unsigned int	pmapCCtl;			/* Cache control */
+#define pmapCCtlVal	0xFFFF0000			/* Valid entries */
+#define pmapCCtlLck	0x00008000			/* Lock bit */
+#define pmapCCtlLckb	16				/* Lock bit */
+#define pmapCCtlGen	0x00007FFF			/* Generation number */
+
+#define pmapSegCacheCnt 16				/* Maximum number of cache entries */
+#define pmapSegCacheUse	16				/* Number of cache entries to use */
+
+	struct pmap		*freepmap;			/* Free pmaps */
+
+	unsigned int	pmapRsv1[3];
+/*											0x038 */
+	uint64_t		pmapSCSubTag;		/* Segment cache sub-tags. This is a 16 entry 4 bit array */
+/*											0x040 */
+	sgc			pmapSegCache[pmapSegCacheCnt];	/* SLD values cached for quick load */
+
+/*											0x140 */	
+/* if fanout is 4, then shift is 1, if fanout is 8 shift is 2, etc */
+#define	kSkipListFanoutShift	1
+/* with n lists, we can handle (fanout**n) pages optimally */
+#define	kSkipListMaxLists		12    
+    unsigned char	pmapCurLists;		/*  0x140 - max #lists any mapping in this pmap currently has */
+    unsigned char	pmapRsv2[3];
+    uint32_t		pmapRandNum;		/* 0x144 - used by mapSetLists() as a random number generator */
+    addr64_t		pmapSkipLists[kSkipListMaxLists];	/* 0x148 - the list headers */
+/* following statistics conditionally gathered */
+    uint64_t		pmapSearchVisits;	/* 0x1A8 - nodes visited searching pmaps */
+    uint32_t		pmapSearchCnt;		/* 0x1B0 - number of calls to mapSearch or mapSearchFull */
+
+	unsigned int	pmapRsv3[3];
+
+/*											0x1C0 */	
+
+	struct pmap_statistics	stats;		/* statistics */
+	decl_simple_lock_data(,lock)		/* lock on map */
 	
 /* Need to pad out to a power of 2 - right now it is 512 bytes */
 #define pmapSize 512
 };
+#pragma pack()
+
+#pragma pack(4)
+struct pmapTransTab {
+	addr64_t		pmapPAddr;			/* Physcial address of pmap */
+	unsigned int	pmapVAddr;			/* Virtual address of pmap */
+};
+#pragma pack()							/* Make sure the structure stays as we defined it */
+
+typedef struct pmapTransTab pmapTransTab;
 
 #define PMAP_NULL  ((pmap_t) 0)
 
 extern pmap_t	kernel_pmap;			/* The kernel's map */
 extern pmap_t	cursor_pmap;			/* The pmap to start allocations with */
-
+extern pmap_t	sharedPmap;
+extern unsigned int sharedPage;
+extern int ppc_max_adrsp;				/* Maximum number of concurrent address spaces allowed. */	
+extern addr64_t vm_max_address;			/* Maximum effective address supported */
+extern addr64_t vm_max_physical;		/* Maximum physical address supported */
+extern pmapTransTab *pmapTrans;			/* Space to pmap translate table */
 #define	PMAP_SWITCH_USER(th, map, my_cpu) th->map = map;	
 
 #define PMAP_ACTIVATE(pmap, th, cpu)
@@ -102,10 +159,13 @@ extern pmap_t	cursor_pmap;			/* The pmap to start allocations with */
 #define PMAP_CONTEXT(pmap,th)
 
 #define pmap_kernel_va(VA)	\
-	(((VA) >= VM_MIN_KERNEL_ADDRESS) && ((VA) <= VM_MAX_KERNEL_ADDRESS))
+	(((VA) >= VM_MIN_KERNEL_ADDRESS) && ((VA) <= vm_last_addr))
 
 #define	PPC_SID_KERNEL  0       /* Must change KERNEL_SEG_REG0_VALUE if !0 */
-#define SID_MAX	((1<<20) - 1)	/* Space ID=20 bits, segment_id=SID + 4 bits */
+
+#define maxAdrSp 16384
+#define maxAdrSpb 14
+#define copyIOaddr 0x00000000E0000000ULL
 
 #define pmap_kernel()			(kernel_pmap)
 #define	pmap_resident_count(pmap)	((pmap)->stats.resident_count)
@@ -113,9 +173,6 @@ extern pmap_t	cursor_pmap;			/* The pmap to start allocations with */
 #define pmap_copy(dpmap,spmap,da,len,sa)
 #define	pmap_update()
 
-#define pmap_phys_address(x)	((x) << PPC_PGSHIFT)
-#define pmap_phys_to_frame(x)	((x) >> PPC_PGSHIFT)
-
 #define PMAP_DEFAULT_CACHE	0
 #define PMAP_INHIBIT_CACHE	1
 #define PMAP_GUARDED_CACHE	2
@@ -123,14 +180,17 @@ extern pmap_t	cursor_pmap;			/* The pmap to start allocations with */
 #define PMAP_NO_GUARD_CACHE	8
 
 /* corresponds to cached, coherent, not writethru, not guarded */
-#define VM_WIMG_DEFAULT		VM_MEM_COHERENT
-#define VM_WIMG_IO		VM_MEM_COHERENT | 	\
-				VM_MEM_NOT_CACHEABLE | VM_MEM_GUARDED
+#define VM_WIMG_DEFAULT		(VM_MEM_COHERENT)
+#define	VM_WIMG_COPYBACK	(VM_MEM_COHERENT)
+#define VM_WIMG_IO		(VM_MEM_COHERENT | 	\
+				VM_MEM_NOT_CACHEABLE | VM_MEM_GUARDED)
+#define VM_WIMG_WTHRU		(VM_MEM_WRITE_THROUGH | VM_MEM_COHERENT | VM_MEM_GUARDED)
+/* write combining mode, aka store gather */
+#define VM_WIMG_WCOMB		(VM_MEM_NOT_CACHEABLE | VM_MEM_COHERENT) 
 
 /* 
  * prototypes.
  */
-extern void 		ppc_protection_init(void);
 extern vm_offset_t phystokv(vm_offset_t pa);					/* Get kernel virtual address from physical */
 extern vm_offset_t kvtophys(vm_offset_t va);					/* Get physical address from kernel virtual */
 extern vm_offset_t	pmap_map(vm_offset_t va,
@@ -141,18 +201,9 @@ extern kern_return_t    pmap_add_physical_memory(vm_offset_t spa,
 						 vm_offset_t epa,
 						 boolean_t available,
 						 unsigned int attr);
-extern vm_offset_t	pmap_map_bd(vm_offset_t va,
-				    vm_offset_t spa,
-				    vm_offset_t epa,
-				    vm_prot_t prot);
-extern void		pmap_bootstrap(unsigned int mem_size,
+extern void		pmap_bootstrap(uint64_t msize,
 				       vm_offset_t *first_avail,
-				       vm_offset_t *first_phys_avail, unsigned int kmapsize);
-extern void		pmap_block_map(vm_offset_t pa,
-				       vm_size_t size,
-				       vm_prot_t prot,
-				       int entry, 
-				       int dtlb);
+				       unsigned int kmapsize);
 extern void		pmap_switch(pmap_t);
 
 extern vm_offset_t pmap_extract(pmap_t pmap,
@@ -160,23 +211,29 @@ extern vm_offset_t pmap_extract(pmap_t pmap,
 
 extern void pmap_remove_all(vm_offset_t pa);
 
-extern boolean_t pmap_verify_free(vm_offset_t pa);
+extern boolean_t pmap_verify_free(ppnum_t pa);
 extern void sync_cache(vm_offset_t pa, unsigned length);
+extern void sync_cache64(addr64_t pa, unsigned length);
+extern void sync_ppage(ppnum_t pa);
+extern void	sync_cache_virtual(vm_offset_t va, unsigned length);
 extern void flush_dcache(vm_offset_t va, unsigned length, boolean_t phys);
+extern void flush_dcache64(addr64_t va, unsigned length, boolean_t phys);
 extern void invalidate_dcache(vm_offset_t va, unsigned length, boolean_t phys);
+extern void invalidate_dcache64(addr64_t va, unsigned length, boolean_t phys);
 extern void invalidate_icache(vm_offset_t va, unsigned length, boolean_t phys);
-extern void pmap_sync_caches_phys(vm_offset_t pa);
-extern void invalidate_cache_for_io(vm_offset_t va, unsigned length, boolean_t phys);
-extern void pmap_map_block(pmap_t pmap, vm_offset_t va, vm_offset_t pa, vm_size_t size,
-	 vm_prot_t prot, int attr, unsigned int flags);	/* Map a block */
-extern kern_return_t pmap_map_block_opt(vm_map_t map, vm_offset_t *va, 
-     vm_offset_t pa, vm_size_t size, vm_prot_t prot, int attr);	/* Map a block allocating an optimal virtual address */
-extern kern_return_t vm_map_block(vm_map_t map, vm_offset_t *va, vm_offset_t *bnd, vm_offset_t pa, 
-	vm_size_t size, vm_prot_t prot);
-
-extern kern_return_t pmap_nest(pmap_t grand, pmap_t subord, vm_offset_t vaddr, vm_size_t size);
-
-extern void pmap_ver(pmap_t pmap, vm_offset_t sva, vm_offset_t eva);
+extern void invalidate_icache64(addr64_t va, unsigned length, boolean_t phys);
+extern void pmap_sync_caches_phys(ppnum_t pa);
+extern void pmap_map_block(pmap_t pmap, addr64_t va, ppnum_t pa, vm_size_t size, vm_prot_t prot, int attr, unsigned int flags);
+extern int pmap_map_block_rc(pmap_t pmap, addr64_t va, ppnum_t pa, vm_size_t size, vm_prot_t prot, int attr, unsigned int flags);
+
+extern kern_return_t pmap_nest(pmap_t grand, pmap_t subord, addr64_t vstart, addr64_t nstart, uint64_t size);
+extern ppnum_t pmap_find_phys(pmap_t pmap, addr64_t va);
+extern addr64_t MapUserAddressSpace(vm_map_t map, addr64_t va, unsigned int size);
+extern void ReleaseUserAddressSpace(addr64_t kva);
+extern kern_return_t pmap_attribute_cache_sync(ppnum_t pp, vm_size_t size,
+				vm_machine_attribute_t  attribute,
+				vm_machine_attribute_val_t* value);
+extern int pmap_canExecute(ppnum_t pa);
 
 #endif /* _PPC_PMAP_H_ */
 
diff --git a/osfmk/ppc/pmap_internals.h b/osfmk/ppc/pmap_internals.h
deleted file mode 100644
index 88f6cf295..000000000
--- a/osfmk/ppc/pmap_internals.h
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
- *
- * @APPLE_LICENSE_HEADER_START@
- * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
- * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
- * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
- * 
- * @APPLE_LICENSE_HEADER_END@
- */
-/*
- * @OSF_COPYRIGHT@
- */
-
-/* Things that don't need to be exported from pmap. Putting
- * them here and not in pmap.h avoids major recompiles when
- * modifying something either here or in proc_reg.h
- */
-
-#ifndef _PMAP_INTERNALS_H_
-#define _PMAP_INTERNALS_H_
-
-/*
- *	Definition of the flags in the low 5 bits of the phys_link field of the phys_entry
- */
- 
-#define PHYS_LOCK	0x00000001
-#define PHYS_FLAGS	0x0000001F
-
-#ifndef ASSEMBLER
-
-#include <cpus.h>
-#include <mach_ldebug.h>
-#include <debug.h>
-
-#include <mach/vm_types.h>
-#include <mach/machine/vm_types.h>
-#include <mach/vm_prot.h>
-#include <mach/vm_statistics.h>
-#include <kern/assert.h>
-#include <kern/cpu_number.h>
-#include <kern/lock.h>
-#include <kern/queue.h>
-#include <ppc/proc_reg.h>
-
-
-/* Page table entries are stored in groups (PTEGS) in a hash table */
-
-#if __PPC__
-#if _BIG_ENDIAN == 0
-error - bitfield structures are not checked for bit ordering in words
-#endif /* _BIG_ENDIAN */
-#endif /* __PPC__ */
-
-/*
- * Don't change these structures unless you change the assembly code
- */
-
-struct phys_entry {
-	struct mapping	*phys_link;		/* MUST BE FIRST - chain of mappings and flags in the low 5 bits, see above */
-	unsigned int	pte1;			/* referenced/changed/wimg - info update atomically */
-};
-
- 
-#define PHYS_NULL	((struct phys_entry *)0)
-
-/* Memory may be non-contiguous. This data structure contains info
- * for mapping this non-contiguous space into the contiguous
- * physical->virtual mapping tables. An array of this type is
- * provided to the pmap system at bootstrap by ppc_vm_init.
- *
- * NB : regions must be in order in this structure.
- */
-
-typedef struct mem_region {
-	vm_offset_t start;	/* Address of base of region */
-	struct phys_entry *phys_table; /* base of region's table */
-	unsigned int end;       /* End address+1 */
-} mem_region_t;
-
-/* PMAP_MEM_REGION_MAX has a PowerMac dependancy - at least the value of
- * kMaxRAMBanks in ppc/POWERMAC/nkinfo.h
- */
-#define PMAP_MEM_REGION_MAX 26
-
-extern mem_region_t pmap_mem_regions[PMAP_MEM_REGION_MAX];
-extern int          pmap_mem_regions_count;
-
-/* keep track of free regions of physical memory so that we can offer
- * them up via pmap_next_page later on
- */
-
-#define FREE_REGION_MAX 8
-extern mem_region_t free_regions[FREE_REGION_MAX];
-extern int          free_regions_count;
-
-/* Prototypes */
-
-struct phys_entry *pmap_find_physentry(vm_offset_t pa);
-
-
-#if	DEBUG
-extern int pmdebug;
-#define PDB_LOCK	0x100
-#define LOCKPRINTF(args)	if (pmdebug & PDB_LOCK) printf args; else
-#else	/* DEBUG */
-#define LOCKPRINTF(args)
-#endif	/* DEBUG */
-
-extern vm_offset_t	hash_table_base;
-extern unsigned int	hash_table_size;
-
-#endif
-#endif /* _PMAP_INTERNALS_H_ */
diff --git a/osfmk/ppc/ppc_disasm.i b/osfmk/ppc/ppc_disasm.i
index a3976c9ea..688f81bbc 100644
--- a/osfmk/ppc/ppc_disasm.i
+++ b/osfmk/ppc/ppc_disasm.i
@@ -36,6 +36,8 @@ in 010011ddd00sss000000000000000000 mcrf $crf($d),$crf($s)
 in 010011cccccccccc000000000010000l $br($c,0,$l,lr,0)
 in 010011dddddaaaaabbbbb0oooo000010 cr$crop($o) $crb($d),$crb($a),$crb($b)
 in 01001100000000000000000001100100 rfi
+in 01001100000000000000000000100100 rfid
+in 01001100000000000000001000100100 hrfid
 in 01001100000000000000000100101100 isync
 in 010011cccccccccc000001000010000l $br($c,0,$l,ctr,0)
 in 010111dddddaaaaabbbbbffffftttttr rlwnm{|.}[$r] \
@@ -43,7 +45,7 @@ in 010111dddddaaaaabbbbbffffftttttr rlwnm{|.}[$r] \
 in 0101xxdddddaaaaasssssffffftttttr rl{wimi|winm|?|?}[$x]{|.}[$r] \
 				    $reg($a),$reg($d),$dec($s),$dec($f),$dec($t)
 in 011110dddddaaaaasssssffffff0xxSr rld{icl|icr|ic|imi}[$x]{|.}[$r] \
-				    $reg($a),$reg($d),$dec($[sssssS]),$dec($f)
+				    $reg($a),$reg($d),$dec($[Ssssss]),$dec($f)
 in 011110dddddaaaaabbbbbffffff100xr rldc{l|r}[$x]{|.}[$r] \
 				    $reg($a),$reg($d),$reg($b),$dec($f)
 in 011111ddd0laaaaabbbbb0000u000000 cmp{|l}[$u] \
@@ -56,6 +58,7 @@ in 011111dddddaaaaabbbbb000u0010w1r mulh{d|w}[$w]{u|}[$u]{|.}[$r] \
 in 011111dddddaaaaabbbbbott0001010r add{c|e||?}[$t]{|o}[$o]{|.}[$r] \
 				    $reg($d),$reg($a),$reg($b)
 in 011111ddddd0000000000000m0100110 mf{cr|msr}[$m] $reg($d)
+in 011111ddddd0ffffffff000000100110 mfcr $hex($f),$reg($d)
 in 011111dddddaaaaabbbbb000w0101000 l{w|d}[$w]arx $reg($d),$reg0($a),$reg($b)
 in 011111dddddaaaaabbbbb0000u101010 ld{|u}[$u]x $reg($d),$reg0($a),$reg($b)
 in 011111dddddaaaaabbbbb0ooou101110 $ldst($o){|u}[$u]x \
@@ -72,6 +75,7 @@ in 011111dddddaaaaabbbbb0001111100r nor{|.}[$r] $reg($a),$reg($d),$reg($b)
 in 011111dddddaaaaabbbbbo01z001000r subf{|z}[$z]e{|o}[$o]{|.}[$r] \
 				    $reg($d),$reg($a)
 in 011111ddddd0ffffffff000100100m00 mt{crf $hex($f),|msr}[$m] $reg($d)
+in 011111ddddd000000000000101100100 mtmsrd $reg($d)
 in 011111sssssaaaaabbbbb0010u101010 std{|u}[$u]x $reg($s),$reg0($a),$reg($b)
 in 011111sssssaaaaabbbbb001w0101101 st{w|d}[$w]cx. $reg($s),$reg0($a),$reg($b)
 in 011111dddddaaaaa00000o011001010r addze{|o}[$o]{|.}[$r] $reg($d),$reg($a)
@@ -97,6 +101,9 @@ in 011111dddddaaaaabbbbbo111u010w1r div{d|w}[$w]{u|}[$u]{|o}[$o]{|.}[$r] \
 in 01111100000aaaaabbbbb01110101100 dcbi $reg0($a),$reg($b)
 in 011111sssssaaaaabbbbb0111011100r nand{|.}[$r] $reg($a),$reg($s),$reg($b)
 in 01111100000000000000001111100100 slbia
+in 011111ddddd00000bbbbb01100100100 slbmte $reg($d),$reg($b)
+in 011111ddddd00000bbbbb11010100110 slbmfev $reg($d),$reg($b)
+in 011111ddddd00000bbbbb11100100110 slbmfee $reg($d),$reg($b)
 in 011111ddd00000000000010000000000 mcrxr $crf($d)
 in 011111dddddaaaaabbbbb10000101010 lswx $reg($d),$reg0($a),$reg($b)
 in 011111dddddaaaaabbbbb1w000101100 l{w|h}[$w]brx $reg($d),$reg0($a),$reg($b)
@@ -108,15 +115,17 @@ in 011111sssssaaaaabbbbb1000011011r srd{|.}[$r] $reg($a),$reg($s),$reg($b)
 in 01111100000000000000010001101100 tlbsync
 in 011111ddddd0rrrr0000010010101100 mfsr $reg($d),$dec($r)
 in 011111dddddaaaaannnnn10010101010 lswi $reg($d),$reg0($a),$dec($n)
-in 01111100000000000000010010101100 sync
+in 011111000ll000000000010010101100 {sync|?|ptesync|?}[$l]
 in 011111ddddd00000bbbbb10100100110 mfsrin $reg($d),$reg($b)
 in 011111sssssaaaaabbbbb10100101010 stswx $reg($s),$reg0($a),$reg($b)
 in 011111sssssaaaaabbbbb1w100101100 st{w|h}[$w]brx $reg($s),$reg0($a),$reg($b)
 in 011111sssssaaaaabbbbb101du101110 stf{s|d}[$d]{|u}[$u]x \
 				    $fr($s),{$reg0($a)|$reg($a)}[$u],$reg($b)
 in 011111sssssaaaaannnnn10110101010 stswi $reg($s),$reg0($a),$dec($n)
-in 011111dddddaaaaasssss1100111000r srawi{|.}[$r] $reg($a),$reg($s),$dec($s)
+in 011111dddddaaaaasssss1100111000r srawi{|.}[$r] $reg($a),$reg($d),$dec($s)
+in 011111dddddaaaaasssss110011101Sr sradi{|.}[$r] $reg($a),$reg($d),$dec($[Ssssss])
 in 01111100000000000000011010101100 eieio
+in 00000000000000000000001000000000 attn
 in 011111sssssaaaaa00000111xx11010r exts{h|b|w|?}[$x]{|.}[$r] $reg($a),$reg($s)
 in 01111100000aaaaabbbbb11110101100 icbi $reg0($a),$reg($b)
 in 011111sssssaaaaabbbbb11110101110 stfiwx $fr($s),$reg0($a),$reg($b)
@@ -196,6 +205,11 @@ spr 1000n11111 hid$dec($n)
 spr 1001011111 iabr
 spr 1010111111 dabr
 spr 1111111111 pir
+spr 0000110000 hspr0
+spr 0000110001 hspr1
+spr 0000110110 hdec0
+spr 0000111010 hsrr0
+spr 0000111011 hsrr1
 spr xxxxxxxxxx ?
 
 reg0 00000 0
diff --git a/osfmk/ppc/ppc_init.c b/osfmk/ppc/ppc_init.c
index e52131729..7c3f7a70d 100644
--- a/osfmk/ppc/ppc_init.c
+++ b/osfmk/ppc/ppc_init.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -24,6 +27,7 @@
  */
 
 #include <debug.h>
+#include <mach_ldebug.h>
 #include <mach_kdb.h>
 #include <mach_kdp.h>
 
@@ -42,70 +46,52 @@
 #include <ppc/low_trace.h>
 #include <ppc/Diagnostics.h>
 #include <ppc/mem.h>
+#include <ppc/mappings.h>
 
 #include <pexpert/pexpert.h>
 
-extern const char version[];
-extern const char version_variant[];
-
 extern unsigned int intstack_top_ss;	/* declared in start.s */
-extern unsigned int debstackptr;	/* declared in start.s */
+extern unsigned int debstackptr;		/* declared in start.s */
 extern unsigned int debstack_top_ss;	/* declared in start.s */
 
-extern void thandler(void);     /* trap handler */
-extern void ihandler(void);     /* interrupt handler */
-extern void shandler(void);     /* syscall handler */
-extern void chandler(void);     /* system choke */
-extern void fpu_switch(void);   /* fp handler */
-extern void vec_switch(void);   /* vector handler */
-extern void atomic_switch_trap(void);   /* fast path atomic thread switch */
-
-void (*exception_handlers[])(void) = {
-	thandler,	/* 0x000   INVALID EXCEPTION (T_IN_VAIN) */
-	thandler,	/* 0x100   System reset (T_RESET) */
-	thandler,	/* 0x200   Machine check (T_MACHINE_CHECK) */
-	thandler,	/* 0x300   Data access (T_DATA_ACCESS) */
-	thandler,	/* 0x400   Instruction access (T_INSTRUCTION_ACCESS) */
-	ihandler,	/* 0x500   External interrupt (T_INTERRUPT) */
-	thandler,	/* 0x600   Alignment (T_ALIGNMENT) */
-	thandler,	/* 0x700   fp exc, ill/priv instr, trap  (T_PROGRAM) */
-	fpu_switch,	/* 0x800   Floating point disabled (T_FP_UNAVAILABLE) */
-	ihandler,	/* 0x900   Decrementer (T_DECREMENTER) */
-	thandler,	/* 0xA00   I/O controller interface (T_IO_ERROR) */
-	thandler,	/* 0xB00   INVALID EXCEPTION (T_RESERVED) */
-	shandler,	/* 0xC00   System call exception (T_SYSTEM_CALL) */
-	thandler,	/* 0xD00   Trace (T_TRACE) */
-	thandler,	/* 0xE00   FP assist (T_FP_ASSIST) */
-	thandler,	/* 0xF00   Performance monitor (T_PERF_MON) */
-	vec_switch,	/* 0xF20   VMX (T_VMX) */
-	thandler,	/* 0x1000  INVALID EXCEPTION (T_INVALID_EXCP0) */
-	thandler,	/* 0x1100  INVALID EXCEPTION (T_INVALID_EXCP1) */
-	thandler,	/* 0x1200  INVALID EXCEPTION (T_INVALID_EXCP2) */
-	thandler,	/* 0x1300  instruction breakpoint (T_INSTRUCTION_BKPT) */
-	ihandler,	/* 0x1400  system management (T_SYSTEM_MANAGEMENT) */
-	thandler,	/* 0x1600  Altivec Assist (T_ALTIVEC_ASSIST) */
-	ihandler,	/* 0x1700  Thermal interruption (T_THERMAL) */
-	thandler,	/* 0x1800  INVALID EXCEPTION (T_INVALID_EXCP5) */
-	thandler,	/* 0x1900  INVALID EXCEPTION (T_INVALID_EXCP6) */
-	thandler,	/* 0x1A00  INVALID EXCEPTION (T_INVALID_EXCP7) */
-	thandler,	/* 0x1B00  INVALID EXCEPTION (T_INVALID_EXCP8) */
-	thandler,	/* 0x1C00  INVALID EXCEPTION (T_INVALID_EXCP9) */
-	thandler,	/* 0x1D00  INVALID EXCEPTION (T_INVALID_EXCP10) */
-	thandler,	/* 0x1E00  INVALID EXCEPTION (T_INVALID_EXCP11) */
-	thandler,	/* 0x1F00  INVALID EXCEPTION (T_INVALID_EXCP12) */
-	thandler,	/* 0x1F00  INVALID EXCEPTION (T_INVALID_EXCP13) */
-	thandler,	/* 0x2000  Run Mode/Trace (T_RUNMODE_TRACE) */
-
-	ihandler,	/* Software  Signal processor (T_SIGP) */
-	thandler,	/* Software  Preemption (T_PREEMPT) */
-	ihandler,	/* Software  INVALID EXCEPTION (T_CSWITCH) */ 
-	ihandler,	/* Software  Shutdown Context (T_SHUTDOWN) */
-	chandler	/* Software  System choke (crash) (T_CHOKE) */
-};
-
 int pc_trace_buf[1024] = {0};
 int pc_trace_cnt = 1024;
 
+extern unsigned int extPatchMCK;
+extern unsigned int extPatch32;
+extern unsigned int hwulckPatch_isync;
+extern unsigned int hwulckPatch_eieio;
+extern unsigned int hwulckbPatch_isync;
+extern unsigned int hwulckbPatch_eieio;
+extern unsigned int mulckPatch_isync;
+extern unsigned int mulckPatch_eieio;
+extern unsigned int sulckPatch_isync;
+extern unsigned int sulckPatch_eieio;
+extern unsigned int retfsectPatch_eieio;
+extern unsigned int retfsectPatch_isync;
+
+int forcenap = 0;
+
+patch_entry_t patch_table[PATCH_TABLE_SIZE] = {
+	&extPatch32,			0x60000000, PATCH_FEATURE,		PatchExt32,
+	&extPatchMCK,			0x60000000, PATCH_PROCESSOR,	CPU_SUBTYPE_POWERPC_970,
+	&hwulckPatch_isync,		0x60000000, PATCH_FEATURE,		PatchLwsync,
+	&hwulckPatch_eieio,		0x7c2004ac, PATCH_FEATURE,		PatchLwsync,
+	&hwulckbPatch_isync,		0x60000000, PATCH_FEATURE,		PatchLwsync,
+	&hwulckbPatch_eieio,		0x7c2004ac, PATCH_FEATURE,		PatchLwsync,
+	&mulckPatch_isync,		0x60000000, PATCH_FEATURE,		PatchLwsync,
+	&mulckPatch_eieio,		0x7c2004ac, PATCH_FEATURE,		PatchLwsync,
+	&sulckPatch_isync,		0x60000000, PATCH_FEATURE,		PatchLwsync,
+	&sulckPatch_eieio,		0x7c2004ac, PATCH_FEATURE,		PatchLwsync,
+#if	!MACH_LDEBUG
+	&retfsectPatch_isync,	0x60000000, PATCH_FEATURE,		PatchLwsync,
+	&retfsectPatch_eieio,	0x7c2004ac, PATCH_FEATURE,		PatchLwsync
+#else
+	0,						0,			PATCH_INVALID, 		0,
+	0,						0,			PATCH_INVALID, 		0
+#endif
+	};
+
 void ppc_init(boot_args *args)
 {
 	int i;
@@ -113,9 +99,11 @@ void ppc_init(boot_args *args)
 	char *str;
 	unsigned long	addr, videoAddr;
 	unsigned int	maxmem;
+	uint64_t		xmaxmem;
 	unsigned int	cputrace;
-	bat_t		    bat;
+	unsigned int	novmx;
 	extern vm_offset_t static_memory_end;
+	mapping *mp;
 	
 	/*
 	 * Setup per_proc info for first cpu.
@@ -134,7 +122,11 @@ void ppc_init(boot_args *args)
 	set_machine_current_act(&pageout_act);
 	pageout_thread.top_act = &pageout_act;
 	pageout_act.thread = &pageout_thread;
-	per_proc_info[0].pp_preemption_count = 1;
+	pageout_act.mact.curctx = &pageout_act.mact.facctx;
+	pageout_act.mact.facctx.facAct = &pageout_act;
+	pageout_act.mact.cioSpace = invalSpace;					/* Initialize copyin/out space to invalid */
+	pageout_act.mact.preemption_count = 1;
+	per_proc_info[0].pp_preemption_count = -1;
 	per_proc_info[0].pp_simple_lock_count = 0;
 	per_proc_info[0].pp_interrupt_level = 0;
 	per_proc_info[0].active_stacks = (unsigned int)
@@ -143,6 +135,9 @@ void ppc_init(boot_args *args)
 		&need_ast[0];
 	per_proc_info[0].FPU_owner = 0;
 	per_proc_info[0].VMX_owner = 0;
+	mp = (mapping *)per_proc_info[0].ppCIOmp;
+	mp->mpFlags = 0x01000000 | mpSpecial | 1;
+	mp->mpSpace = invalSpace;
 
 	machine_slot[0].is_cpu = TRUE;
 
@@ -156,95 +151,24 @@ void ppc_init(boot_args *args)
 	master_cpu = 0;
 	master_processor = cpu_to_processor(master_cpu);
 
-	/* Set up segment registers as VM through space 0 */
-	for (i=0; i<=15; i++) {
-	  isync();
-	  mtsrin((KERNEL_SEG_REG0_VALUE | (i << 20)), i * 0x10000000);
-	  sync();
-	}
-
-	static_memory_end = round_page(args->topOfKernelData);;
-        /* Get platform expert set up */
-	PE_init_platform(FALSE, args);
-
-
-	/* This is how the BATs get configured */
-	/* IBAT[0] maps Segment 0 1:1 */
-	/* DBAT[0] maps Segment 0 1:1 */
-	/* DBAT[2] maps the I/O Segment 1:1 */
-	/* DBAT[3] maps the Video Segment 1:1 */
-
-
-	/* Initialize shadow IBATs */
-	shadow_BAT.IBATs[0].upper=BAT_INVALID;
-	shadow_BAT.IBATs[0].lower=BAT_INVALID;
-	shadow_BAT.IBATs[1].upper=BAT_INVALID;
-	shadow_BAT.IBATs[1].lower=BAT_INVALID;
-	shadow_BAT.IBATs[2].upper=BAT_INVALID;
-	shadow_BAT.IBATs[2].lower=BAT_INVALID;
-	shadow_BAT.IBATs[3].upper=BAT_INVALID;
-	shadow_BAT.IBATs[3].lower=BAT_INVALID;
-
-	/* Initialize shadow DBATs */
-	shadow_BAT.DBATs[0].upper=BAT_INVALID;
-	shadow_BAT.DBATs[0].lower=BAT_INVALID;
-	shadow_BAT.DBATs[1].upper=BAT_INVALID;
-	shadow_BAT.DBATs[1].lower=BAT_INVALID;
-	shadow_BAT.DBATs[2].upper=BAT_INVALID;
-	shadow_BAT.DBATs[2].lower=BAT_INVALID;
-	shadow_BAT.DBATs[3].upper=BAT_INVALID;
-	shadow_BAT.DBATs[3].lower=BAT_INVALID;
+	static_memory_end = round_page_32(args->topOfKernelData);;
+      
+	PE_init_platform(FALSE, args);				/* Get platform expert set up */
 
+	if (!PE_parse_boot_arg("novmx", &novmx)) novmx=0;	/* Special run without VMX? */
+	if(novmx) {									/* Yeah, turn it off */
+		for(i = 0; i < NCPUS; i++) {			/* Cycle through all potential processors */
+			per_proc_info[i].pf.Available &= ~pfAltivec;	/* Turn off Altivec available */
+		}
+		__asm__ volatile("mtsprg 2,%0" : : "r" (per_proc_info[0].pf.Available));	/* Set live value */
+	}
 
-	/* If v_baseAddr is non zero, use DBAT3 to map the video segment */
-	videoAddr = args->Video.v_baseAddr & 0xF0000000;
-	if (videoAddr) {
-		/* start off specifying 1-1 mapping of video seg */
-		bat.upper.word	     = videoAddr;
-		bat.lower.word	     = videoAddr;
-		
-		bat.upper.bits.bl    = 0x7ff;	/* size = 256M */
-		bat.upper.bits.vs    = 1;
-		bat.upper.bits.vp    = 0;
-		
-		bat.lower.bits.wimg  = PTE_WIMG_IO;
-		bat.lower.bits.pp    = 2;	/* read/write access */
-				
-		shadow_BAT.DBATs[3].upper = bat.upper.word;
-		shadow_BAT.DBATs[3].lower = bat.lower.word;
-		
-		sync();isync();
-		
-		mtdbatu(3, BAT_INVALID); /* invalidate old mapping */
-		mtdbatl(3, bat.lower.word);
-		mtdbatu(3, bat.upper.word);
-		sync();isync();
+	if (!PE_parse_boot_arg("fn", &forcenap)) forcenap = 0;	/* If force nap not set, make 0 */
+	else {
+		if(forcenap < 2) forcenap = forcenap + 1;			/* Else set 1 for off, 2 for on */
+		else forcenap = 0;									/* Clear for error case */
 	}
 	
-	/* Use DBAT2 to map the io segment */
-	addr = get_io_base_addr() & 0xF0000000;
-	if (addr != videoAddr) {
-		/* start off specifying 1-1 mapping of io seg */
-		bat.upper.word	     = addr;
-		bat.lower.word	     = addr;
-		
-		bat.upper.bits.bl    = 0x7ff;	/* size = 256M */
-		bat.upper.bits.vs    = 1;
-		bat.upper.bits.vp    = 0;
-		
-		bat.lower.bits.wimg  = PTE_WIMG_IO;
-		bat.lower.bits.pp    = 2;	/* read/write access */
-				
-		shadow_BAT.DBATs[2].upper = bat.upper.word;
-		shadow_BAT.DBATs[2].lower = bat.lower.word;
-		
-		sync();isync();
-		mtdbatu(2, BAT_INVALID); /* invalidate old mapping */
-		mtdbatl(2, bat.lower.word);
-		mtdbatu(2, bat.upper.word);
-		sync();isync();
-	}
-
 	if (!PE_parse_boot_arg("diag", &dgWork.dgFlags)) dgWork.dgFlags=0;	/* Set diagnostic flags */
 	if(dgWork.dgFlags & enaExpTrace) trcWork.traceMask = 0xFFFFFFFF;	/* If tracing requested, enable it */
 
@@ -252,54 +176,29 @@ void ppc_init(boot_args *args)
 		trcWork.traceMask = (trcWork.traceMask & 0xFFFFFFF0) | (cputrace & 0xF);	/* Limit to 4 */
 	}
 
-#if 0
-	GratefulDebInit((bootBumbleC *)&(args->Video));	/* Initialize the GratefulDeb debugger */
-#endif
-
-	printf_init();						/* Init this in case we need debugger */
-	panic_init();						/* Init this in case we need debugger */
-
-	/* setup debugging output if one has been chosen */
-	PE_init_kprintf(FALSE);
-	kprintf("kprintf initialized\n");
-
-	/* create the console for verbose or pretty mode */
-	PE_create_console();
-
-	/* setup console output */
-	PE_init_printf(FALSE);
-
-	kprintf("version_variant = %s\n", version_variant);
-	kprintf("version         = %s\n", version);
-
+	if(!PE_parse_boot_arg("tb", &trcWork.traceSize)) {	/* See if non-default trace buffer size */
 #if DEBUG
-	printf("\n\n\nThis program was compiled using gcc %d.%d for powerpc\n",
-	       __GNUC__,__GNUC_MINOR__);
-
-	/* Processor version information */
-	{       
-		unsigned int pvr;
-		__asm__ ("mfpvr %0" : "=r" (pvr));
-		printf("processor version register : 0x%08x\n",pvr);
-	}
-	for (i = 0; i < kMaxDRAMBanks; i++) {
-		if (args->PhysicalDRAM[i].size) 
-			printf("DRAM at 0x%08x size 0x%08x\n",
-			       args->PhysicalDRAM[i].base,
-			       args->PhysicalDRAM[i].size);
+		trcWork.traceSize = 32;					/* Default 32 page trace table for DEBUG */
+#else
+		trcWork.traceSize = 8;					/* Default 8 page trace table for RELEASE */
+#endif
 	}
-#endif /* DEBUG */
 
-	/*   
-	 * VM initialization, after this we're using page tables...
-	 */
+	if(trcWork.traceSize < 1) trcWork.traceSize = 1;	/* Minimum size of 1 page */
+	if(trcWork.traceSize > 256) trcWork.traceSize = 256;	/* Maximum size of 256 pages */
+	trcWork.traceSize = trcWork.traceSize * 4096;	/* Change page count to size */
+
 	if (!PE_parse_boot_arg("maxmem", &maxmem))
-		maxmem=0;
+		xmaxmem=0;
 	else
-		maxmem = maxmem * (1024 * 1024);
+		xmaxmem = (uint64_t)maxmem * (1024 * 1024);
 
-	ppc_vm_init(maxmem, args);
+/*   
+ * VM initialization, after this we're using page tables...
+ */
 
+	ppc_vm_init(xmaxmem, args);
+	
 	PE_init_platform(TRUE, args);
 	
 	machine_startup(args);
@@ -311,23 +210,10 @@ ppc_init_cpu(
 	int i;
 
 	if(!(proc_info->next_savearea)) 		/* Do we have a savearea set up already? */
-		proc_info->next_savearea = (savearea *)save_get_init();	/* Get a savearea  */
+		proc_info->next_savearea = (vm_offset_t)save_get_init();	/* Get a savearea  */
 	
 	cpu_init();
-
-	proc_info->pp_preemption_count = 1;
-	proc_info->pp_simple_lock_count = 0;
-	proc_info->pp_interrupt_level = 0;
-
-	proc_info->Lastpmap = 0;				/* Clear last used space */
-
-	/* Set up segment registers as VM through space 0 */
-	for (i=0; i<=15; i++) {
-	  isync();
-	  mtsrin((KERNEL_SEG_REG0_VALUE | (i << 20)), i * 0x10000000);
-	  sync();
-	}
-
+	
 	ppc_vm_cpu_init(proc_info);
 
 	ml_thrm_init();							/* Start thermal monitoring on this processor */
diff --git a/osfmk/ppc/ppc_vm_init.c b/osfmk/ppc/ppc_vm_init.c
index 0fe096d90..833cc3642 100644
--- a/osfmk/ppc/ppc_vm_init.c
+++ b/osfmk/ppc/ppc_vm_init.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -44,42 +47,50 @@
 #include <ppc/boot.h>
 #include <ppc/misc_protos.h>
 #include <ppc/pmap.h>
-#include <ppc/pmap_internals.h>
 #include <ppc/mem.h>
 #include <ppc/mappings.h>
 #include <ppc/exception.h>
 #include <ppc/mp.h>
+#include <ppc/lowglobals.h>
 
-#ifdef	__MACHO__
 #include <mach-o/mach_header.h>
-#endif
 
-extern unsigned int intstack[];	/* declared in start.s */
-extern unsigned int intstack_top_ss;	/* declared in start.s */
+extern const char version[];
+extern const char version_variant[];
 
-vm_offset_t mem_size;	/* Size of actual physical memory present
-						   minus any performance buffer and possibly limited
-						   by mem_limit in bytes */
-vm_offset_t mem_actual;	/* The "One True" physical memory size 
-						   actually, it's the highest physical address + 1 */
-						  
+extern unsigned int intstack[];			/* declared in aligned_data.s */
+extern unsigned int intstack_top_ss;	/* declared in aligned_data.s */
 
-mem_region_t pmap_mem_regions[PMAP_MEM_REGION_MAX];
-int	 pmap_mem_regions_count = 0;	/* No non-contiguous memory regions */
+addr64_t hash_table_base;				/* Hash table base */
+unsigned int hash_table_size;			/* Hash table size */
+vm_offset_t taproot_addr;				/* (BRINGUP) */
+unsigned int taproot_size;				/* (BRINGUP) */
+unsigned int serialmode;				/* Serial mode keyboard and console control */
+extern int disableConsoleOutput;
 
-mem_region_t free_regions[FREE_REGION_MAX];
-int	     free_regions_count;
+struct shadowBAT shadow_BAT;
 
-#ifndef __MACHO__  
-extern unsigned long etext;
-#endif
+/*
+ *	NOTE: mem_size is bogus on large memory machines.  We will pin it to 0x80000000 if there is more than 2 GB
+ *	This is left only for compatibility and max_mem should be used.
+ */
+vm_offset_t mem_size;					/* Size of actual physical memory present
+										   minus any performance buffer and possibly limited
+										   by mem_limit in bytes */
+uint64_t	mem_actual;					/* The "One True" physical memory size 
+						  				   actually, it's the highest physical address + 1 */
+uint64_t	max_mem;					/* Size of physical memory (bytes), adjusted by maxmem */
+uint64_t	sane_size;					/* Memory size to use for defaults calculations */
+						  
+
+mem_region_t pmap_mem_regions[PMAP_MEM_REGION_MAX + 1];
+int	 pmap_mem_regions_count = 0;		/* Assume no non-contiguous memory regions */
 
 unsigned int avail_remaining = 0;
 vm_offset_t first_avail;
 vm_offset_t static_memory_end;
-extern vm_offset_t avail_next;
+addr64_t vm_last_addr = VM_MAX_KERNEL_ADDRESS;	/* Highest kernel virtual address known to the VM system */
 
-#ifdef __MACHO__
 extern struct mach_header _mh_execute_header;
 vm_offset_t sectTEXTB;
 int sectSizeTEXT;
@@ -91,230 +102,293 @@ vm_offset_t sectKLDB;
 int sectSizeKLD;
 
 vm_offset_t end, etext, edata;
-#endif
 
 extern unsigned long exception_entry;
 extern unsigned long exception_end;
 
 
-void ppc_vm_init(unsigned int mem_limit, boot_args *args)
+void ppc_vm_init(uint64_t mem_limit, boot_args *args)
 {
 	unsigned int htabmask;
-	unsigned int i, j, batsize, kmapsize;
-	vm_offset_t  addr;
+	unsigned int i, j, batsize, kmapsize, pvr;
+	vm_offset_t  addr, ioAddr, videoAddr;
 	int boot_task_end_offset;
 	const char *cpus;
 	mapping		*mp;
-	vm_offset_t first_phys_avail;
 	vm_offset_t		sizeadj, oldstart;
+	unsigned int *xtaproot, bank_shift;
+	uint64_t	cbsize, xhid0;
 
-	/* Now retrieve addresses for end, edata, and etext 
-	 * from MACH-O headers.
-	 */
-	sectTEXTB = (vm_offset_t)getsegdatafromheader(
-		&_mh_execute_header, "__TEXT", &sectSizeTEXT);
-	sectDATAB = (vm_offset_t)getsegdatafromheader(
-		&_mh_execute_header, "__DATA", &sectSizeDATA);
-	sectLINKB = (vm_offset_t)getsegdatafromheader(
-		&_mh_execute_header, "__LINKEDIT", &sectSizeLINK);
-	sectKLDB = (vm_offset_t)getsegdatafromheader(
-		&_mh_execute_header, "__KLD", &sectSizeKLD);
-
-	etext = (vm_offset_t) sectTEXTB + sectSizeTEXT;
-	edata = (vm_offset_t) sectDATAB + sectSizeDATA;
-	end = round_page(getlastaddr());					/* Force end to next page */
-#if DEBUG
-	kprintf("sectTEXT: %x, size: %x\n", sectTEXTB, sectSizeTEXT);
-	kprintf("sectDATA: %x, size: %x\n", sectDATAB, sectSizeDATA);
-	kprintf("sectLINK: %x, size: %x\n", sectLINKB, sectSizeLINK);
-	kprintf("sectKLD:  %x, size: %x\n", sectKLDB, sectSizeKLD);
-	kprintf("end: %x\n", end);
-#endif
 
-/* Stitch valid memory regions together - they may be contiguous
- * even though they're not already glued together
+/*
+ *	Invalidate all shadow BATs
  */
-	mem_actual = args->PhysicalDRAM[0].base + args->PhysicalDRAM[0].size;	/* Initialize to the first region size */
-	addr = 0;											/* temp use as pointer to previous memory region... */
-	for (i = 1; i < kMaxDRAMBanks; i++) {
-	  	
-		if (args->PhysicalDRAM[i].size == 0) continue;	/* If region is empty, skip it */
-		
-	  	if((args->PhysicalDRAM[i].base + args->PhysicalDRAM[i].size) > mem_actual) {	/* New high? */
-			mem_actual = args->PhysicalDRAM[i].base + args->PhysicalDRAM[i].size;	/* Take the high bid */
-		}
-		
-		if (args->PhysicalDRAM[i].base ==				/* Does the end of the last hit the start of the next? */
-		  args->PhysicalDRAM[addr].base +
-		  args->PhysicalDRAM[addr].size) {
-			kprintf("region 0x%08x size 0x%08x joining region 0x%08x size 0x%08x\n",
-			  args->PhysicalDRAM[addr].base, args->PhysicalDRAM[addr].size,
-			  args->PhysicalDRAM[i].base, args->PhysicalDRAM[i].size);
-			
-			args->PhysicalDRAM[addr].size += args->PhysicalDRAM[i].size;	/* Join them */
-			args->PhysicalDRAM[i].size = 0;
-			continue;
-		}
-		/* This is now last non-zero region to compare against */
-		addr = i;
-	}
 
-	/* Go through the list of memory regions passed in via the args
+	/* Initialize shadow IBATs */
+	shadow_BAT.IBATs[0].upper=BAT_INVALID;
+	shadow_BAT.IBATs[0].lower=BAT_INVALID;
+	shadow_BAT.IBATs[1].upper=BAT_INVALID;
+	shadow_BAT.IBATs[1].lower=BAT_INVALID;
+	shadow_BAT.IBATs[2].upper=BAT_INVALID;
+	shadow_BAT.IBATs[2].lower=BAT_INVALID;
+	shadow_BAT.IBATs[3].upper=BAT_INVALID;
+	shadow_BAT.IBATs[3].lower=BAT_INVALID;
+
+	/* Initialize shadow DBATs */
+	shadow_BAT.DBATs[0].upper=BAT_INVALID;
+	shadow_BAT.DBATs[0].lower=BAT_INVALID;
+	shadow_BAT.DBATs[1].upper=BAT_INVALID;
+	shadow_BAT.DBATs[1].lower=BAT_INVALID;
+	shadow_BAT.DBATs[2].upper=BAT_INVALID;
+	shadow_BAT.DBATs[2].lower=BAT_INVALID;
+	shadow_BAT.DBATs[3].upper=BAT_INVALID;
+	shadow_BAT.DBATs[3].lower=BAT_INVALID;
+
+
+	/*
+	 * Go through the list of memory regions passed in via the boot_args
 	 * and copy valid entries into the pmap_mem_regions table, adding
 	 * further calculated entries.
+	 *
+	 * boot_args version 1 has address instead of page numbers
+	 * in the PhysicalDRAM banks, set bank_shift accordingly.
 	 */
 	
+	bank_shift = 0;
+	if (args->Version == kBootArgsVersion1) bank_shift = 12;
+	
 	pmap_mem_regions_count = 0;
-	mem_size = 0;   /* Will use to total memory found so far */
-
-	for (i = 0; i < kMaxDRAMBanks; i++) {
-		if (args->PhysicalDRAM[i].size == 0)
-			continue;
-
-		/* The following should only happen if memory size has
-		   been artificially reduced with -m */
-		if (mem_limit > 0 &&
-		    mem_size + args->PhysicalDRAM[i].size > mem_limit)
-			args->PhysicalDRAM[i].size = mem_limit - mem_size;
+	max_mem = 0;   															/* Will use to total memory found so far */
+	mem_actual = 0;															/* Actual size of memory */
+	
+	if (mem_limit == 0) mem_limit = 0xFFFFFFFFFFFFFFFFULL;					/* If there is no set limit, use all */
+	
+	for (i = 0; i < kMaxDRAMBanks; i++) {									/* Look at all of the banks */
+		
+		cbsize = (uint64_t)args->PhysicalDRAM[i].size << (12 - bank_shift);	/* Remember current size */
+		
+		if (!cbsize) continue;												/* Skip if the bank is empty */
+		
+		mem_actual = mem_actual + cbsize;									/* Get true memory size */
 
-		/* We've found a region, tally memory */
+		if(mem_limit == 0) continue;										/* If we hit restriction, just keep counting */
 
-		pmap_mem_regions[pmap_mem_regions_count].start =
-			args->PhysicalDRAM[i].base;
-		pmap_mem_regions[pmap_mem_regions_count].end =
-			args->PhysicalDRAM[i].base +
-			args->PhysicalDRAM[i].size;
+		if (cbsize > mem_limit) cbsize = mem_limit;							/* Trim to max allowed */
+		max_mem += cbsize;													/* Total up what we have so far */
+		mem_limit = mem_limit - cbsize;										/* Calculate amount left to do */
+		
+		pmap_mem_regions[pmap_mem_regions_count].mrStart  = args->PhysicalDRAM[i].base >> bank_shift;	/* Set the start of the bank */
+		pmap_mem_regions[pmap_mem_regions_count].mrAStart = pmap_mem_regions[pmap_mem_regions_count].mrStart;		/* Set the start of allocatable area */
+		pmap_mem_regions[pmap_mem_regions_count].mrEnd    = ((uint64_t)args->PhysicalDRAM[i].base >> bank_shift) + (cbsize >> 12) - 1;	/* Set the end address of bank */
+		pmap_mem_regions[pmap_mem_regions_count].mrAEnd   = pmap_mem_regions[pmap_mem_regions_count].mrEnd;	/* Set the end address of allocatable area */
 
 		/* Regions must be provided in ascending order */
 		assert ((pmap_mem_regions_count == 0) ||
-			pmap_mem_regions[pmap_mem_regions_count].start >
-			pmap_mem_regions[pmap_mem_regions_count-1].start);
-
-		if (pmap_mem_regions_count > 0) {		
-			/* we add on any pages not in the first memory
-			 * region to the avail_remaining count. The first
-			 * memory region is used for mapping everything for
-			 * bootup and is taken care of specially.
-			 */
-			avail_remaining +=
-				args->PhysicalDRAM[i].size / PPC_PGBYTES;
-		}
-		
-		/* Keep track of how much memory we've found */
-
-		mem_size += args->PhysicalDRAM[i].size;
+			pmap_mem_regions[pmap_mem_regions_count].mrStart >
+			pmap_mem_regions[pmap_mem_regions_count-1].mrStart);
 
-		/* incremement number of regions found */
-		pmap_mem_regions_count++;
+		pmap_mem_regions_count++;											/* Count this region */
 	}
+	
+	mem_size = (unsigned int)max_mem;										/* Get size of memory */
+	if(max_mem > 0x0000000080000000ULL) mem_size = 0x80000000;				/* Pin at 2 GB */
 
-	kprintf("mem_size: %d M\n",mem_size / (1024 * 1024));
+	sane_size = max_mem;													/* Calculate a sane value to use for init */
+	if(sane_size > (addr64_t)(VM_MAX_KERNEL_ADDRESS + 1)) 
+		sane_size = (addr64_t)(VM_MAX_KERNEL_ADDRESS + 1);					/* If flush with ram, use addressible portion */
 
-	/* 
-	 * Initialize the pmap system, using space above `first_avail'
-	 * for the necessary data structures.
-	 * NOTE : assume that we'll have enough space mapped in already
-	 */
 
-	first_phys_avail = static_memory_end;
-	first_avail = adjust_bat_limit(first_phys_avail, 0, FALSE, FALSE);
+/* 
+ * Initialize the pmap system, using space above `first_avail'
+ * for the necessary data structures.
+ * NOTE : assume that we'll have enough space mapped in already
+ */
+
+	first_avail = static_memory_end;
+
+/* Now retrieve addresses for end, edata, and etext 
+ * from MACH-O headers.
+ */
+	sectTEXTB = (vm_offset_t)getsegdatafromheader(
+		&_mh_execute_header, "__TEXT", &sectSizeTEXT);
+	sectDATAB = (vm_offset_t)getsegdatafromheader(
+		&_mh_execute_header, "__DATA", &sectSizeDATA);
+	sectLINKB = (vm_offset_t)getsegdatafromheader(
+		&_mh_execute_header, "__LINKEDIT", &sectSizeLINK);
+	sectKLDB = (vm_offset_t)getsegdatafromheader(
+		&_mh_execute_header, "__KLD", &sectSizeKLD);
+
+	etext = (vm_offset_t) sectTEXTB + sectSizeTEXT;
+	edata = (vm_offset_t) sectDATAB + sectSizeDATA;
+	end = round_page_32(getlastaddr());					/* Force end to next page */
 	
-	kmapsize = (round_page(exception_end) - trunc_page(exception_entry)) +	/* Get size we will map later */
-		(round_page(sectTEXTB+sectSizeTEXT) - trunc_page(sectTEXTB)) +
-		(round_page(sectDATAB+sectSizeDATA) - trunc_page(sectDATAB)) +
-		(round_page(sectLINKB+sectSizeLINK) - trunc_page(sectLINKB)) +
-		(round_page(sectKLDB+sectSizeKLD) - trunc_page(sectKLDB)) +
-		(round_page(static_memory_end) - trunc_page(end));
+	kmapsize = (round_page_32(exception_end) - trunc_page_32(exception_entry)) +	/* Get size we will map later */
+		(round_page_32(sectTEXTB+sectSizeTEXT) - trunc_page_32(sectTEXTB)) +
+		(round_page_32(sectDATAB+sectSizeDATA) - trunc_page_32(sectDATAB)) +
+		(round_page_32(sectLINKB+sectSizeLINK) - trunc_page_32(sectLINKB)) +
+		(round_page_32(sectKLDB+sectSizeKLD) - trunc_page_32(sectKLDB)) +
+		(round_page_32(static_memory_end) - trunc_page_32(end));
 
-	pmap_bootstrap(mem_size,&first_avail,&first_phys_avail, kmapsize);
+	pmap_bootstrap(max_mem, &first_avail, kmapsize);
 
-#ifdef	__MACHO__
-#if DEBUG
-	kprintf("Mapping memory:\n");
-	kprintf("   exception vector: %08X, %08X - %08X\n", trunc_page(exception_entry), 
-		trunc_page(exception_entry), round_page(exception_end));
-	kprintf("          sectTEXTB: %08X, %08X - %08X\n", trunc_page(sectTEXTB), 
-		trunc_page(sectTEXTB), round_page(sectTEXTB+sectSizeTEXT));
-	kprintf("          sectDATAB: %08X, %08X - %08X\n", trunc_page(sectDATAB), 
-		trunc_page(sectDATAB), round_page(sectDATAB+sectSizeDATA));
-	kprintf("          sectLINKB: %08X, %08X - %08X\n", trunc_page(sectLINKB), 
-		trunc_page(sectLINKB), round_page(sectLINKB+sectSizeLINK));
-	kprintf("           sectKLDB: %08X, %08X - %08X\n", trunc_page(sectKLDB), 
-		trunc_page(sectKLDB), round_page(sectKLDB+sectSizeKLD));
-	kprintf("                end: %08X, %08X - %08X\n", trunc_page(end), 
-		trunc_page(end), static_memory_end);
-#endif /* DEBUG */
-	pmap_map(trunc_page(exception_entry), trunc_page(exception_entry), 
-		round_page(exception_end), VM_PROT_READ|VM_PROT_EXECUTE);
-	pmap_map(trunc_page(sectTEXTB), trunc_page(sectTEXTB), 
-		round_page(sectTEXTB+sectSizeTEXT), VM_PROT_READ|VM_PROT_EXECUTE);
-	pmap_map(trunc_page(sectDATAB), trunc_page(sectDATAB), 
-		round_page(sectDATAB+sectSizeDATA), VM_PROT_READ|VM_PROT_WRITE);
-
-
-       /* The KLD and LINKEDIT segments are unloaded in toto after boot completes,
-        * but via ml_static_mfree(), through IODTFreeLoaderInfo(). Hence, we have
-        * to map both segments page-by-page.
-        */
-	for (addr = trunc_page(sectKLDB);
-             addr < round_page(sectKLDB+sectSizeKLD);
+	pmap_map(trunc_page_32(exception_entry), trunc_page_32(exception_entry), 
+		round_page_32(exception_end), VM_PROT_READ|VM_PROT_EXECUTE);
+
+	pmap_map(trunc_page_32(sectTEXTB), trunc_page_32(sectTEXTB), 
+		round_page_32(sectTEXTB+sectSizeTEXT), VM_PROT_READ|VM_PROT_EXECUTE);
+
+	pmap_map(trunc_page_32(sectDATAB), trunc_page_32(sectDATAB), 
+		round_page_32(sectDATAB+sectSizeDATA), VM_PROT_READ|VM_PROT_WRITE);
+
+/* The KLD and LINKEDIT segments are unloaded in toto after boot completes,
+* but via ml_static_mfree(), through IODTFreeLoaderInfo(). Hence, we have
+* to map both segments page-by-page.
+*/
+	
+	for (addr = trunc_page_32(sectKLDB);
+             addr < round_page_32(sectKLDB+sectSizeKLD);
              addr += PAGE_SIZE) {
 
-            pmap_enter(kernel_pmap, addr, addr, 
+            pmap_enter(kernel_pmap, addr, addr>>12, 
 			VM_PROT_READ|VM_PROT_WRITE, 
 			VM_WIMG_USE_DEFAULT, TRUE);
+
 	}
 
-	for (addr = trunc_page(sectLINKB);
-             addr < round_page(sectLINKB+sectSizeLINK);
+	for (addr = trunc_page_32(sectLINKB);
+             addr < round_page_32(sectLINKB+sectSizeLINK);
              addr += PAGE_SIZE) {
 
-            pmap_enter(kernel_pmap, addr, addr, 
+           pmap_enter(kernel_pmap, addr, addr>>12, 
 			VM_PROT_READ|VM_PROT_WRITE, 
 			VM_WIMG_USE_DEFAULT, TRUE);
+
 	}
 
+	pmap_enter(kernel_pmap, &sharedPage, (unsigned int)&sharedPage >> 12,	/* Make sure the sharedPage is mapped */
+		VM_PROT_READ|VM_PROT_WRITE, 
+		VM_WIMG_USE_DEFAULT, TRUE);
+
+	pmap_enter(kernel_pmap, &lowGlo, (unsigned int)&lowGlo >> 12,			/* Make sure the low memory globals are mapped */
+		VM_PROT_READ|VM_PROT_WRITE, 
+		VM_WIMG_USE_DEFAULT, TRUE);
+		
 /*
  *	We need to map the remainder page-by-page because some of this will
  *	be released later, but not all.  Ergo, no block mapping here 
  */
-	for(addr = trunc_page(end); addr < round_page(static_memory_end); addr += PAGE_SIZE) {
-		pmap_enter(kernel_pmap, addr, addr, 
+
+	for(addr = trunc_page_32(end); addr < round_page_32(static_memory_end); addr += PAGE_SIZE) {
+
+		pmap_enter(kernel_pmap, addr, addr>>12, 
 			VM_PROT_READ|VM_PROT_WRITE, 
 			VM_WIMG_USE_DEFAULT, TRUE);
-	}
-#endif /* __MACHO__ */
 
-#if DEBUG
-	for (i=0 ; i < free_regions_count; i++) {
-		kprintf("Free region start 0x%08x end 0x%08x\n",
-		       free_regions[i].start,free_regions[i].end);
 	}
-#endif
+
+	MapUserAddressSpaceInit();			/* Go initialize copy in/out */
 
 /*
- *	Note: the shadow BAT registers were already loaded in ppc_init.c
+ *	At this point, there is enough mapped memory and all hw mapping structures are
+ *	allocated and initialized.  Here is where we turn on translation for the
+ *	VERY first time....
+ *
+ *	NOTE: Here is where our very first interruption will happen.
+ *
  */
 
+	hw_start_trans();					/* Start translating */
+
+#if 0
+	GratefulDebInit((bootBumbleC *)&(args->Video));	/* Initialize the GratefulDeb debugger */
+#endif
 
-	LoadIBATs((unsigned int *)&shadow_BAT.IBATs[0]);		/* Load up real IBATs from shadows */
-	LoadDBATs((unsigned int *)&shadow_BAT.DBATs[0]);		/* Load up real DBATs from shadows */
+
+	printf_init();						/* Init this in case we need debugger */
+	panic_init();						/* Init this in case we need debugger */
+	PE_init_kprintf(TRUE);				/* Note on PPC we only call this after VM is set up */
+
+	kprintf("kprintf initialized\n");
+
+	serialmode = 0;						/* Assume normal keyboard and console */
+	if(PE_parse_boot_arg("serial", &serialmode)) {		/* Do we want a serial keyboard and/or console? */
+		kprintf("Serial mode specified: %08X\n", serialmode);
+	}
+	if(serialmode & 1) {				/* Start serial if requested */
+		(void)switch_to_serial_console();	/* Switch into serial mode */
+		disableConsoleOutput = FALSE;	/* Allow printfs to happen */
+	}
+	
+	kprintf("max_mem: %ld M\n", (unsigned long)(max_mem >> 20));
+	kprintf("version_variant = %s\n", version_variant);
+	kprintf("version         = %s\n\n", version);
+	__asm__ ("mfpvr %0" : "=r" (pvr));
+	kprintf("proc version    = %08x\n", pvr);
+	if(per_proc_info[0].pf.Available & pf64Bit) {	/* 64-bit processor? */
+		xhid0 = hid0get64();			/* Get the hid0 */
+		if(xhid0 & (1ULL << (63 - 19))) kprintf("Time base is externally clocked\n");
+		else kprintf("Time base is internally clocked\n");
+	}
+
+
+	taproot_size = PE_init_taproot(&taproot_addr);	/* (BRINGUP) See if there is a taproot */
+	if(taproot_size) {					/* (BRINGUP) */
+		kprintf("TapRoot card configured to use vaddr = %08X, size = %08X\n", taproot_addr, taproot_size);
+		bcopy_nc((void *)version, (void *)(taproot_addr + 16), strlen(version));	/* (BRINGUP) Pass it our kernel version */
+		__asm__ volatile("eieio");		/* (BRINGUP) */
+		xtaproot = (unsigned int *)taproot_addr;	/* (BRINGUP) */
+		xtaproot[0] = 1;				/* (BRINGUP) */
+		__asm__ volatile("eieio");		/* (BRINGUP) */
+	}
+
+	PE_create_console();				/* create the console for verbose or pretty mode */
+
+	/* setup console output */
+	PE_init_printf(FALSE);
 
 #if DEBUG
-	for(i=0; i<4; i++) kprintf("DBAT%1d: %08X %08X\n", 
-		i, shadow_BAT.DBATs[i].upper, shadow_BAT.DBATs[i].lower);
-	for(i=0; i<4; i++) kprintf("IBAT%1d: %08X %08X\n", 
-		i, shadow_BAT.IBATs[i].upper, shadow_BAT.IBATs[i].lower);
+	printf("\n\n\nThis program was compiled using gcc %d.%d for powerpc\n",
+	       __GNUC__,__GNUC_MINOR__);
+
+
+	/* Processor version information */
+	{       
+		unsigned int pvr;
+		__asm__ ("mfpvr %0" : "=r" (pvr));
+		printf("processor version register : %08X\n", pvr);
+	}
+
+	kprintf("Args at %08X\n", args);
+	for (i = 0; i < pmap_mem_regions_count; i++) {
+			printf("DRAM at %08X size %08X\n",
+			       args->PhysicalDRAM[i].base,
+			       args->PhysicalDRAM[i].size);
+	}
+#endif /* DEBUG */
+
+#if DEBUG
+	kprintf("Mapped memory:\n");
+	kprintf("   exception vector: %08X, %08X - %08X\n", trunc_page_32(exception_entry), 
+		trunc_page_32(exception_entry), round_page_32(exception_end));
+	kprintf("          sectTEXTB: %08X, %08X - %08X\n", trunc_page_32(sectTEXTB), 
+		trunc_page_32(sectTEXTB), round_page_32(sectTEXTB+sectSizeTEXT));
+	kprintf("          sectDATAB: %08X, %08X - %08X\n", trunc_page_32(sectDATAB), 
+		trunc_page_32(sectDATAB), round_page_32(sectDATAB+sectSizeDATA));
+	kprintf("          sectLINKB: %08X, %08X - %08X\n", trunc_page_32(sectLINKB), 
+		trunc_page_32(sectLINKB), round_page_32(sectLINKB+sectSizeLINK));
+	kprintf("           sectKLDB: %08X, %08X - %08X\n", trunc_page_32(sectKLDB), 
+		trunc_page_32(sectKLDB), round_page_32(sectKLDB+sectSizeKLD));
+	kprintf("                end: %08X, %08X - %08X\n", trunc_page_32(end), 
+		trunc_page_32(end), static_memory_end);
+
 #endif
+
+	return;
 }
 
 void ppc_vm_cpu_init(
 	struct per_proc_info *proc_info)
 {
-	hash_table_init(hash_table_base, hash_table_size);
-
-	LoadIBATs((unsigned int *)&shadow_BAT.IBATs[0]);
-	LoadDBATs((unsigned int *)&shadow_BAT.DBATs[0]);
-
-	sync();isync();
+	hw_setup_trans();									/* Set up hardware needed for translation */
+	hw_start_trans();									/* Start translating */
 }
diff --git a/osfmk/ppc/proc_reg.h b/osfmk/ppc/proc_reg.h
index 87e0955a7..5327ebe8d 100644
--- a/osfmk/ppc/proc_reg.h
+++ b/osfmk/ppc/proc_reg.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -52,7 +55,8 @@
 
 /* Defines for decoding the MSR bits */
 
-#define MSR_SF_BIT	0
+#define MSR_SF_BIT		0
+#define MSR_HV_BIT		3
 #define MSR_RES1_BIT	1
 #define MSR_RES2_BIT	2
 #define MSR_RES3_BIT	3
@@ -139,18 +143,33 @@
 #define SR_UNUSED_BY_KERN_NUM 13
 #define SR_COPYIN_NAME	sr14
 #define SR_COPYIN_NUM	14
+#define BAT_INVALID 0
 
 
 /* DSISR bits on data access exceptions */
 
 #define DSISR_IO_BIT		0	/* NOT USED on 601 */
 #define DSISR_HASH_BIT		1
+#define DSISR_NOEX_BIT		3
 #define DSISR_PROT_BIT		4
 #define DSISR_IO_SPC_BIT	5
 #define DSISR_WRITE_BIT		6
 #define DSISR_WATCH_BIT		9
 #define DSISR_EIO_BIT		11
 
+#define dsiMiss 			0x40000000
+#define dsiMissb 			1
+#define dsiNoEx				0x10000000
+#define dsiProt				0x08000000
+#define dsiInvMode			0x04000000
+#define dsiStore			0x02000000
+#define dsiAC				0x00400000
+#define dsiSeg				0x00200000
+#define dsiValid			0x5E600000
+#define dsiSpcNest			0x00010000	/* Special nest - software flag */
+#define dsiSpcNestb			15			/* Special nest - software flag */
+#define dsiSoftware			0x0000FFFF
+
 /* SRR1 bits on data/instruction translation exceptions */
 
 #define SRR1_TRANS_HASH_BIT	1
@@ -165,41 +184,20 @@
 #define SRR1_PRG_PRV_INS_BIT	13
 #define SRR1_PRG_TRAP_BIT	14
 
-/* BAT information */
-
-/* Constants used when setting mask values */
-
-#define BAT_INVALID 0
-
 /*
  * Virtual to physical mapping macros/structures.
  * IMPORTANT NOTE: there is one mapping per HW page, not per MACH page.
  */
 
-#define CACHE_LINE_SIZE	32
-#define CACHE_LINE_POW2 5
-#define cache_align(x)	(((x) + CACHE_LINE_SIZE-1) & ~(CACHE_LINE_SIZE - 1))
-
 #define PTE1_WIMG_GUARD_BIT	28	/* Needed for assembler */
 #define PTE1_REFERENCED_BIT	23	/* ditto */
 #define PTE1_CHANGED_BIT	24
 #define PTE0_HASH_ID_BIT	25
 
-#define PTE_NULL ((pte_t*) NULL) /* No pte found/associated with this */
-#define PTE_EMPTY 0x7fffffbf 	 /* Value in the pte0.word of a free pte */
-
-#define PTE_WIMG_CB_CACHED			0 	/* cached, writeback */
-#define PTE_WIMG_CB_CACHED_GUARDED		1 	/* cached, writeback, guarded */
-#define PTE_WIMG_CB_CACHED_COHERENT		2 	/* cached, writeback, coherent (default) */
-#define PTE_WIMG_CB_CACHED_COHERENT_GUARDED	3 	/* cached, writeback, coherent, guarded */
-#define PTE_WIMG_UNCACHED			4 	/* uncached */
-#define PTE_WIMG_UNCACHED_GUARDED		5	/* uncached, guarded */
-#define PTE_WIMG_UNCACHED_COHERENT		6	/* uncached, coherentt */
-#define PTE_WIMG_UNCACHED_COHERENT_GUARDED	7	/* uncached, coherent, guarded */
-#define PTE_WIMG_WT_CACHED			8 	/* cached, writethru */
-#define PTE_WIMG_WT_CACHED_GUARDED		9 	/* cached, writethru, guarded */
-#define PTE_WIMG_WT_CACHED_COHERENT		10 	/* cached, writethru, coherent */
-#define PTE_WIMG_WT_CACHED_COHERENT_GUARDED	11 	/* cached, writethru, coherent, guarded */
+#define PTE_WIMG_CB_CACHED_COHERENT		0 	/* cached, writeback, coherent (default) */
+#define PTE_WIMG_CB_CACHED_COHERENT_GUARDED	1 	/* cached, writeback, coherent, guarded */
+#define PTE_WIMG_UNCACHED_COHERENT		2	/* uncached, coherentt */
+#define PTE_WIMG_UNCACHED_COHERENT_GUARDED	3	/* uncached, coherent, guarded */
 
 #define PTE_WIMG_DEFAULT 	PTE_WIMG_CB_CACHED_COHERENT
 #define PTE_WIMG_IO		PTE_WIMG_UNCACHED_COHERENT_GUARDED
@@ -209,191 +207,14 @@
 #ifndef ASSEMBLER
 #ifdef __GNUC__
 
-#if _BIG_ENDIAN == 0
-#error - bitfield structures are not checked for bit ordering in words
-#endif /* _BIG_ENDIAN */
-
 /* Structures and types for machine registers */
 
-typedef union {
-	unsigned int word;
-	struct {
-		unsigned int htaborg    : 16;
-		unsigned int reserved   : 7;
-		unsigned int htabmask   : 9;
-	} bits;
-} sdr1_t;
-
-/* Block mapping registers.  These values are model dependent. 
- * Eventually, we will need to up these to 64 bit values.
- */
-
-#define blokValid 0x1FFE0000
-#define batMin 0x00020000
-#define batMax 0x10000000
-#define batICnt 4
-#define batDCnt 4
-
-/* BAT register structures.
- * Not used for standard mappings, but may be used
- * for mapping devices. Note that the 601 has a
- * different BAT layout than the other PowerPC processors
- */
-
-typedef union {
-	unsigned int word;
-	struct {
-		unsigned int blpi	: 15;
-		unsigned int reserved	: 10;
-		unsigned int wim	: 3;
-		unsigned int ks		: 1;
-		unsigned int ku		: 1;
-		unsigned int pp		: 2;
-	} bits;
-} bat601u_t;
-
-typedef union {
-	unsigned int word;
-	struct {
-		unsigned int pbn	: 15;
-		unsigned int reserved	: 10;
-		unsigned int valid	: 1;
-		unsigned int bsm	: 6;
-	} bits;
-} bat601l_t;
-
-typedef struct bat601_t {
-	bat601u_t	upper;
-	bat601l_t	lower;
-} bat601_t;
-
-typedef union {
-	unsigned int word;
-	struct {
-		unsigned int bepi	: 15;
-		unsigned int reserved	: 4;
-		unsigned int bl		: 11;
-		unsigned int vs		: 1;
-		unsigned int vp		: 1;
-	} bits;
-} batu_t;
-
-typedef union {
-	unsigned int word;
-	struct {
-		unsigned int brpn	: 15;
-		unsigned int reserved	: 10;
-		unsigned int wimg	: 4;
-		unsigned int reserved2	: 1;
-		unsigned int pp		: 2;
-	} bits;
-} batl_t;
-
-typedef struct bat_t {
-	batu_t	upper;
-	batl_t	lower;
-} bat_t;
-
-/* PTE entries
- * Used extensively for standard mappings
- */
-
-typedef	union {
-	unsigned int word;
-	struct {
-		unsigned int valid      : 1;
-		unsigned int segment_id : 24;
-		unsigned int hash_id    : 1;
-		unsigned int page_index : 6; /* Abbreviated */
-	} bits;
-	struct {
-		unsigned int valid      : 1;
-		unsigned int not_used   : 5;
-		unsigned int segment_id : 19; /* Least Sig 19 bits */
-		unsigned int hash_id    : 1;
-		unsigned int page_index : 6;
-	} hash_bits;
-} pte0_t;
-
-typedef	union {
-	unsigned int word;
-	struct {
-		unsigned int phys_page  : 20;
-		unsigned int reserved3  : 3;
-		unsigned int referenced : 1;
-		unsigned int changed    : 1;
-		unsigned int wimg       : 4;
-		unsigned int reserved1  : 1;
-		unsigned int protection : 2;
-	} bits;
-} pte1_t;
-
-typedef struct pte_t {
-	pte0_t pte0;
-	pte1_t pte1;
-} pte_t;
-
-/*
- * A virtual address is decoded into various parts when looking for its PTE
- */
-
-typedef struct va_full_t {
-	unsigned int seg_num    : 4;
-	unsigned int page_index : 16;
-	unsigned int byte_ofs   : 12;
-} va_full_t;
-
-typedef struct va_abbrev_t { /* use bits.abbrev for abbreviated page index */
-	unsigned int seg_num    : 4;
-	unsigned int page_index : 6;
-	unsigned int junk       : 10;
-	unsigned int byte_ofs   : 12;
-} va_abbrev_t;
-
-typedef union {
-	unsigned int word;
-	va_full_t    full;
-	va_abbrev_t  abbrev;
-} virtual_addr_t;
-
-/* A physical address can be split up into page and offset */
-
-typedef struct pa_t {
-	unsigned int page_no : 20;
-	unsigned int offset  : 12;
-} pa_t;
-
-typedef union {
-	unsigned int word;
-	pa_t         bits;
-} physical_addr_t;
 
 /*
  * C-helper inline functions for accessing machine registers follow.
  */
 
 
-#ifdef	__ELF__
-#define	__CASMNL__	";"
-#else
-#define	__CASMNL__ "@"
-#endif
-
-/* Return the current GOT pointer */
-
-extern unsigned int get_got(void);
-
-extern __inline__ unsigned int get_got(void)
-{
-        unsigned int result;
-#ifndef __ELF__
-        __asm__ volatile("mr %0,	r2" : "=r" (result));
-#else
-        __asm__ volatile("mr %0,	2" : "=r" (result));
-#endif
-        return result;
-}
-
 /*
  * Various memory/IO synchronisation instructions
  */
@@ -423,25 +244,6 @@ extern __inline__ unsigned int get_got(void)
         __asm__ volatile("isync")
 
 
-/*
- *		This guy will make sure all tlbs on all processors finish their tlbies
- */
-#define tlbsync() \
-        __asm__ volatile("tlbsync")
-
-
-		/*	Invalidate TLB entry. Caution, requires context synchronization.
-		*/
-extern void tlbie(unsigned int val);
-
-extern __inline__ void tlbie(unsigned int val)
-{
-        __asm__ volatile("tlbie %0" : : "r" (val));
-        return;
-}
-
-
-
 /*
  * Access to various system registers
  */
@@ -477,54 +279,6 @@ extern __inline__ unsigned int mfmsr(void)
         return result;
 }
 
-/* mtsr and mfsr must be macros since SR must be hardcoded */
-
-#if __ELF__
-#define mtsr(SR, REG)							     \
-	__asm__ volatile("sync" __CASMNL__ "mtsr %0, %1 " __CASMNL__ "isync" : : "i" (SR), "r" (REG));
-#define mfsr(REG, SR) \
-	__asm__ volatile("mfsr %0, %1" : "=r" (REG) : "i" (SR));
-#else
-#define mtsr(SR, REG)							     \
-	__asm__ volatile("sync" __CASMNL__ "mtsr sr%0, %1 " __CASMNL__ "isync" : : "i" (SR), "r" (REG)); 
-
-#define mfsr(REG, SR) \
-	__asm__ volatile("mfsr %0, sr%1" : "=r" (REG) : "i" (SR));
-#endif
-
-
-extern void mtsrin(unsigned int val, unsigned int reg);
-
-extern __inline__ void mtsrin(unsigned int val, unsigned int reg)
-{
-        __asm__ volatile("sync" __CASMNL__ "mtsrin %0, %1" __CASMNL__ " isync" : : "r" (val), "r" (reg));
-        return;
-}
-
-extern unsigned int mfsrin(unsigned int reg);
-
-extern __inline__ unsigned int mfsrin(unsigned int reg)
-{
-	unsigned int result;
-        __asm__ volatile("mfsrin %0, %1" : "=r" (result) : "r" (reg));
-        return result;
-}
-
-extern void mtsdr1(unsigned int val);
-
-extern __inline__ void mtsdr1(unsigned int val)
-{
-        __asm__ volatile("mtsdr1 %0" : : "r" (val));
-        return;
-}
-
-extern void mtdar(unsigned int val);
-
-extern __inline__ void mtdar(unsigned int val)
-{
-        __asm__ volatile("mtdar %0" : : "r" (val));
-        return;
-}
 
 extern unsigned int mfdar(void);
 
@@ -543,23 +297,6 @@ extern __inline__ void mtdec(unsigned int val)
         return;
 }
 
-extern int isync_mfdec(void);
-
-extern __inline__ int isync_mfdec(void)
-{
-        int result;
-        __asm__ volatile("isync" __CASMNL__ "mfdec %0" : "=r" (result));
-        return result;
-}
-
-/* Read and write the value from the real-time clock
- * or time base registers. Note that you have to
- * use the right ones depending upon being on
- * 601 or 603/604. Care about carries between
- * the words and using the right registers must be
- * done by the calling function.
- */
-
 extern void mttb(unsigned int val);
 
 extern __inline__ void mttb(unsigned int val)
@@ -594,48 +331,6 @@ extern __inline__ unsigned int mftbu(void)
         return result;
 }
 
-extern void mtrtcl(unsigned int val);
-
-extern __inline__ void mtrtcl(unsigned int val)
-{
-        __asm__ volatile("mtspr  21,%0" : : "r" (val));
-        return;
-}
-
-extern unsigned int mfrtcl(void);
-
-extern __inline__ unsigned int mfrtcl(void)
-{
-        unsigned int result;
-        __asm__ volatile("mfspr %0,5" : "=r" (result));
-        return result;
-}
-
-extern void mtrtcu(unsigned int val);
-
-extern __inline__ void mtrtcu(unsigned int val)
-{
-        __asm__ volatile("mtspr 20,%0" : : "r" (val));
-        return;
-}
-
-extern unsigned int mfrtcu(void);
-
-extern __inline__ unsigned int mfrtcu(void)
-{
-        unsigned int result;
-        __asm__ volatile("mfspr %0,4" : "=r" (result));
-        return result;
-}
-
-extern void mtl2cr(unsigned int val);
-
-extern __inline__ void mtl2cr(unsigned int val)
-{
-  __asm__ volatile("mtspr l2cr, %0" : : "r" (val));
-  return;
-}
-
 extern unsigned int mfl2cr(void);
 
 extern __inline__ unsigned int mfl2cr(void)
@@ -693,18 +388,6 @@ extern unsigned long   mfsda(void);
 
 /* macros since the argument n is a hard-coded constant */
 
-#define mtibatu(n, reg) __asm__ volatile("mtibatu " # n ", %0" : : "r" (reg))
-#define mtibatl(n, reg) __asm__ volatile("mtibatl " # n ", %0" : : "r" (reg))
-
-#define mtdbatu(n, reg) __asm__ volatile("mtdbatu " # n ", %0" : : "r" (reg))
-#define mtdbatl(n, reg) __asm__ volatile("mtdbatl " # n ", %0" : : "r" (reg))
-
-#define mfibatu(reg, n) __asm__ volatile("mfibatu %0, " # n : "=r" (reg))
-#define mfibatl(reg, n) __asm__ volatile("mfibatl %0, " # n : "=r" (reg))
-
-#define mfdbatu(reg, n) __asm__ volatile("mfdbatu %0, " # n : "=r" (reg))
-#define mfdbatl(reg, n) __asm__ volatile("mfdbatl %0, " # n : "=r" (reg))
-
 #define mtsprg(n, reg)  __asm__ volatile("mtsprg  " # n ", %0" : : "r" (reg))
 #define mfsprg(reg, n)  __asm__ volatile("mfsprg  %0, " # n : "=r" (reg))
 
diff --git a/osfmk/ppc/rtclock.c b/osfmk/ppc/rtclock.c
index 2df172cfb..ae0df313a 100644
--- a/osfmk/ppc/rtclock.c
+++ b/osfmk/ppc/rtclock.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -41,6 +44,7 @@
 #include <kern/spl.h>
 
 #include <machine/mach_param.h>	/* HZ */
+#include <machine/commpage.h>
 #include <ppc/proc_reg.h>
 
 #include <pexpert/pexpert.h>
@@ -120,6 +124,9 @@ static boolean_t		rtclock_initialized;
 static uint64_t			rtclock_tick_deadline[NCPUS];
 static uint64_t		 	rtclock_tick_interval;
 
+static uint32_t			rtclock_sec_divisor;
+static uint32_t			rtclock_ns_per_tick;
+
 static void		timespec_to_absolutetime(
 							mach_timespec_t		timespec,
 							uint64_t			*result);
@@ -181,6 +188,9 @@ timebase_callback(
 	LOCK_RTC(s);
 	rtclock.timebase_const.numer = numer;
 	rtclock.timebase_const.denom = denom;
+    rtclock_sec_divisor = freq->timebase_num / freq->timebase_den;
+    rtclock_ns_per_tick = NSEC_PER_SEC / rtclock_sec_divisor;
+    commpage_set_timestamp(0,0,0,0);
 	UNLOCK_RTC(s);
 }
 
@@ -558,6 +568,62 @@ calend_init(void)
 	return (1);
 }
 
+/*
+ * Get the current clock microtime and sync the timestamp
+ * on the commpage.  Only called from ppc_gettimeofday(),
+ * ie in response to a system call from user mode.
+ */
+void
+clock_gettimeofday(
+	uint32_t			*secp,
+	uint32_t			*usecp)
+{
+	uint64_t			now;
+    UnsignedWide		wide_now;
+	UnsignedWide		t64;
+	uint32_t			t32;
+	uint32_t			numer, denom;
+    uint32_t			secs,usecs;
+    mach_timespec_t		curr_time;
+	spl_t				s;
+
+	LOCK_RTC(s);
+	if (!rtclock.calend_is_set) {
+		UNLOCK_RTC(s);
+		return;
+	}
+
+	numer = rtclock.timebase_const.numer;
+	denom = rtclock.timebase_const.denom;
+
+	clock_get_uptime(&now);
+    wide_now = *((UnsignedWide*) &now);
+
+	umul_64by32(wide_now, numer, &t64, &t32);
+
+	udiv_96by32(t64, t32, denom, &t64, &t32);
+
+	udiv_96by32to32and32(t64, t32, NSEC_PER_SEC,
+								&curr_time.tv_sec, &curr_time.tv_nsec);
+
+	ADD_MACH_TIMESPEC(&curr_time, &rtclock.calend_offset);
+    
+	secs = curr_time.tv_sec;
+	usecs = curr_time.tv_nsec / NSEC_PER_USEC;
+    *secp = secs;
+    *usecp = usecs;
+
+    t32 = curr_time.tv_nsec - (usecs * NSEC_PER_USEC);
+    t32 = t32 / rtclock_ns_per_tick;
+    now -= t32;
+
+    commpage_set_timestamp(now,secs,usecs,rtclock_sec_divisor);
+    
+	UNLOCK_RTC(s);
+
+	return;
+} 
+
 /*
  * Get the current clock time.
  */
@@ -595,6 +661,7 @@ calend_settime(
 	rtclock.calend_offset = *new_time;
 	SUB_MACH_TIMESPEC(&rtclock.calend_offset, &curr_time);
 	rtclock.calend_is_set = TRUE;
+    commpage_set_timestamp(0,0,0,0);  /* disable timestamp */
 	UNLOCK_RTC(s);
 
 	PESetGMTTimeOfDay(new_time->tv_sec);
@@ -642,8 +709,10 @@ clock_adjust_calendar(
 	spl_t		s;
 
 	LOCK_RTC(s);
-	if (rtclock.calend_is_set)
+	if (rtclock.calend_is_set) {
 		ADD_MACH_TIMESPEC_NSEC(&rtclock.calend_offset, nsec);
+        commpage_set_timestamp(0,0,0,0);  /* disable timestamp */
+    }
 	UNLOCK_RTC(s);
 }
 
@@ -663,6 +732,7 @@ clock_initialize_calendar(void)
 	rtclock.calend_offset.tv_nsec = 0;
 	SUB_MACH_TIMESPEC(&rtclock.calend_offset, &curr_time);
 	rtclock.calend_is_set = TRUE;
+    commpage_set_timestamp(0,0,0,0);  /* disable timestamp */
 	UNLOCK_RTC(s);
 }
 
diff --git a/osfmk/ppc/savearea.c b/osfmk/ppc/savearea.c
index 1b59e82cc..af1ae6e7e 100644
--- a/osfmk/ppc/savearea.c
+++ b/osfmk/ppc/savearea.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -44,7 +47,6 @@
 #include <ppc/proc_reg.h>
 #include <ppc/mem.h>
 #include <ppc/pmap.h>
-#include <ppc/pmap_internals.h>
 #include <ppc/Firmware.h>
 #include <ppc/mappings.h>
 #include <ppc/exception.h>
@@ -123,25 +125,26 @@ unsigned int	backchain = 0;									/* Debug flag */
  *		Allocate our initial context save areas.  As soon as we do this,
  *		we can take an interrupt. We do the saveareas here, 'cause they're guaranteed
  *		to be at least page aligned.
+ *
+ *		Note: these initial saveareas are all to be allocated from V=R, less than 4GB
+ *		space.
  */
 
 
-void savearea_init(vm_offset_t *addrx) {
+void savearea_init(vm_offset_t addr) {
 
-	savearea_comm	*savec, *savec2, *saveprev;
-	vm_offset_t		save, save2, addr;
+	savearea_comm	*savec;
+	vm_offset_t	save;
 	int i;
 
 	
 	saveanchor.savetarget	= InitialSaveTarget;		/* Initial target value */
 	saveanchor.saveinuse	= 0;						/* Number of areas in use */
 
-	saveanchor.savefree = 0;							/* Remember the start of the free chain */
+	saveanchor.savefree    = 0;							/* Remember the start of the free chain */
 	saveanchor.savefreecnt = 0;							/* Remember the length */
-	saveanchor.savepoolfwd = (unsigned int *)&saveanchor;	/* Remember pool forward */
-	saveanchor.savepoolbwd = (unsigned int *)&saveanchor;	/* Remember pool backward */
-
-	addr = *addrx;										/* Make this easier for ourselves */
+	saveanchor.savepoolfwd = (addr64_t)&saveanchor;		/* Remember pool forward */
+	saveanchor.savepoolbwd = (addr64_t)&saveanchor;		/* Remember pool backward */
 
 	save = 	addr;										/* Point to the whole block of blocks */	
 
@@ -150,7 +153,7 @@ void savearea_init(vm_offset_t *addrx) {
  */
 
 
-	for(i=0; i < 8; i++) {								/* Initialize the back pocket saveareas */
+	for(i=0; i < BackPocketSaveBloks; i++) {			/* Initialize the back pocket saveareas */
 
 		savec = (savearea_comm *)save;					/* Get the control area for this one */
 
@@ -158,7 +161,7 @@ void savearea_init(vm_offset_t *addrx) {
 		savec->sac_vrswap = 0;							/* V=R, so the translation factor is 0 */
 		savec->sac_flags = sac_perm;					/* Mark it permanent */
 		savec->sac_flags |= 0x0000EE00;					/* Debug eyecatcher */
-		save_queue((savearea *)savec);					/* Add page to savearea lists */
+		save_queue((uint32_t)savec >> 12);				/* Add page to savearea lists */
 		save += PAGE_SIZE;								/* Jump up to the next one now */
 	
 	}
@@ -175,8 +178,8 @@ void savearea_init(vm_offset_t *addrx) {
 	saveanchor.savefree = 0;							/* Remember the start of the free chain */
 	saveanchor.savefreecnt = 0;							/* Remember the length */
 	saveanchor.saveadjust = 0;							/* Set none needed yet */
-	saveanchor.savepoolfwd = (unsigned int *)&saveanchor;	/* Remember pool forward */
-	saveanchor.savepoolbwd = (unsigned int *)&saveanchor;	/* Remember pool backward */
+	saveanchor.savepoolfwd = (addr64_t)&saveanchor;		/* Remember pool forward */
+	saveanchor.savepoolbwd = (addr64_t)&saveanchor;		/* Remember pool backward */
 
 	for(i=0; i < InitialSaveBloks; i++) {				/* Initialize the saveareas */
 
@@ -186,40 +189,37 @@ void savearea_init(vm_offset_t *addrx) {
 		savec->sac_vrswap = 0;							/* V=R, so the translation factor is 0 */
 		savec->sac_flags = sac_perm;					/* Mark it permanent */
 		savec->sac_flags |= 0x0000EE00;					/* Debug eyecatcher */
-		save_queue((savearea *)savec);					/* Add page to savearea lists */
+		save_queue((uint32_t)savec >> 12);				/* Add page to savearea lists */
 		save += PAGE_SIZE;								/* Jump up to the next one now */
 	
 	}
 
-	*addrx = save;										/* Move the free storage lowwater mark */
-
 /*
  *	We now have a free list that has our initial number of entries  
  *	The local qfret lists is empty.  When we call save_get below it will see that
  *	the local list is empty and fill it for us.
  *
- *	It is ok to call save_get_phys here because even though if we are translation on, we are still V=R and
- *	running with BAT registers so no interruptions.  Regular interruptions will be off.  Using save_get
- *	would be wrong if the tracing was enabled--it would cause an exception.
+ *	It is ok to call save_get here because all initial saveareas are V=R in less
+ *  than 4GB space, so 32-bit addressing is ok.
+ *
  */
 
-	save2 = (vm_offset_t)save_get_phys();				/* This will populate the local list  
-														   and get the first one for the system */
-	per_proc_info[0].next_savearea = (unsigned int)save2; /* Tell the exception handler about it */
-	
+/*
+ * This will populate the local list  and get the first one for the system
+ */ 	
+	per_proc_info[0].next_savearea = (vm_offset_t)save_get();
+
 /*
  *	The system is now able to take interruptions
  */
-	
 	return;
-
 }
 
 
 
 
 /*
- *		Returns a savearea.  If the free list needs size adjustment it happens here.
+ *		Obtains a savearea.  If the free list needs size adjustment it happens here.
  *		Don't actually allocate the savearea until after the adjustment is done.
  */
 
@@ -267,8 +267,10 @@ void save_release(struct savearea *save) {				/* Release a save area */
 
 void save_adjust(void) {
 	
-	savearea_comm	*sctl, *sctlnext, *freepool, *freepage, *realpage;
+	savearea_comm	*sctl, *sctlnext, *freepage;
 	kern_return_t ret;
+	uint64_t vtopmask;
+	ppnum_t physpage;
 
 	if(saveanchor.saveadjust < 0) 					{	/* Do we need to adjust down? */
 			
@@ -291,15 +293,18 @@ void save_adjust(void) {
 				panic("Whoops...  Not a bit of wired memory left for saveareas\n");
 			}
 			
-			realpage = (savearea_comm *)pmap_extract(kernel_pmap, (vm_offset_t)freepage);	/* Get the physical */
+			physpage = pmap_find_phys(kernel_pmap, (vm_offset_t)freepage);	/* Find physical page */
+			if(!physpage) {								/* See if we actually have this mapped*/
+				panic("save_adjust: wired page not mapped - va = %08X\n", freepage);	/* Die */
+			}
 			
 			bzero((void *)freepage, PAGE_SIZE);			/* Clear it all to zeros */
 			freepage->sac_alloc = 0;					/* Mark all entries taken */
-			freepage->sac_vrswap = (unsigned int)freepage ^ (unsigned int)realpage;		/* Form mask to convert V to R and vice versa */
+			freepage->sac_vrswap = ((uint64_t)physpage << 12) ^ (uint64_t)freepage;	/* XOR to calculate conversion mask */
 	
 			freepage->sac_flags |= 0x0000EE00;			/* Set debug eyecatcher */
 						
-			save_queue((savearea *)realpage);			/* Add all saveareas on page to free list */
+			save_queue(physpage);						/* Add all saveareas on page to free list */
 		}
 	}
 }
diff --git a/osfmk/ppc/savearea.h b/osfmk/ppc/savearea.h
index 554cd2bb8..6710b8eb8 100644
--- a/osfmk/ppc/savearea.h
+++ b/osfmk/ppc/savearea.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -29,7 +32,10 @@
 #ifdef __APPLE_API_PRIVATE
 
 #ifdef	MACH_KERNEL_PRIVATE
-#include <mach/ppc/vm_types.h>
+#include <stdint.h>
+#include <mach/vm_types.h>
+
+#pragma pack(4)							/* Make sure the structure stays as we defined it */
 typedef struct savearea_comm {
 
 /*
@@ -42,32 +48,35 @@ typedef struct savearea_comm {
  */
 
 
-/*	Keep the save_prev, sac_next, and sac_prev in these positions, some assemble code depends upon it to
+/*	Keep the save_prev, sac_next, and sac_prev in these positions, some assembler code depends upon it to
  *	match up with fields in saveanchor.
  */
-	struct savearea	*save_prev;					/* The address of the previous (or next) savearea */
-	unsigned int	*sac_next;					/* Points to next savearea page that has a free slot  - real */
-	unsigned int	*sac_prev;					/* Points to previous savearea page that has a free slot  - real */
-	unsigned int	save_flags;					/* Various flags */
+                                                /* offset 0x000 */
+	addr64_t		save_prev;					/* The address of the previous (or next) savearea */
+	addr64_t		sac_next;					/* Points to next savearea page that has a free slot  - real */
+	addr64_t		sac_prev;					/* Points to previous savearea page that has a free slot  - real */
 	unsigned int	save_level;					/* Context ID */
+	unsigned int	save_01C;
+
+												/*	 0x20 */
 	unsigned int	save_time[2];				/* Context save time - for debugging or performance */
 	struct thread_activation	*save_act;		/* Associated activation  */
-
-/*                                                 0x20 */
-
-	unsigned int	sac_vrswap;					/* XOR mask to swap V to R or vice versa */
-	unsigned int	sac_alloc;					/* Bitmap of allocated slots */
+    unsigned int	save_02c;
+	uint64_t		sac_vrswap;					/* XOR mask to swap V to R or vice versa */
+	unsigned int	save_flags;					/* Various flags */
 	unsigned int	sac_flags;					/* Various flags */
-	unsigned int	save_misc0;					/* Various stuff */
-	unsigned int	save_misc1;					/* Various stuff */
-	unsigned int	save_misc2;					/* Various stuff */
-	unsigned int	save_misc3;					/* Various stuff */
-	unsigned int	save_misc4;					/* Various stuff */
-
-	unsigned int	save_040[8];				/* Fill 32 bytes */
+    
+                                                /* offset 0x040 */
+	uint64_t		save_misc0;					/* Various stuff */
+	uint64_t		save_misc1;					/* Various stuff */
+	unsigned int	sac_alloc;					/* Bitmap of allocated slots */
+    unsigned int	save_054;
+    unsigned int	save_misc2;
+    unsigned int	save_misc3;
 
 												/* offset 0x0060 */
 } savearea_comm;
+#pragma pack()
 #endif
 
 #ifdef BSD_KERNEL_PRIVATE
@@ -81,107 +90,91 @@ typedef struct savearea_comm {
  *	This type of savearea contains all of the general context.
  */
  
+#pragma pack(4)							/* Make sure the structure stays as we defined it */
 typedef struct savearea {
 
 	savearea_comm	save_hdr;					/* Stuff common to all saveareas */
 
 	unsigned int	save_060[8];				/* Fill 32 bytes */
-												/* offset 0x0080 */
-	unsigned int 	save_r0;
-	unsigned int 	save_r1;
-	unsigned int 	save_r2;
-	unsigned int 	save_r3;
-	unsigned int 	save_r4;
-	unsigned int 	save_r5;
-	unsigned int 	save_r6;
-	unsigned int 	save_r7;
-	
-												/* offset 0x0A0 */
-	unsigned int 	save_r8;
-	unsigned int 	save_r9;
-	unsigned int 	save_r10;
-	unsigned int 	save_r11;
-	unsigned int 	save_r12;
-	unsigned int 	save_r13;
-	unsigned int 	save_r14;
-	unsigned int 	save_r15;
-	
-												/* offset 0x0C0 */
-	unsigned int 	save_r16;
-	unsigned int 	save_r17;
-	unsigned int 	save_r18;
-	unsigned int 	save_r19;
-	unsigned int 	save_r20;
-	unsigned int 	save_r21;
-	unsigned int 	save_r22;
-	unsigned int 	save_r23;
-	
-												/* offset 0x0E0 */
-	unsigned int 	save_r24;
-	unsigned int 	save_r25;
-	unsigned int 	save_r26;	
-	unsigned int 	save_r27;
-	unsigned int 	save_r28;
-	unsigned int 	save_r29;
-	unsigned int 	save_r30;
-	unsigned int 	save_r31;
-	
-												/* offset 0x100 */
-	unsigned int 	save_srr0;
-	unsigned int 	save_srr1;
+
+                                                /* offset 0x0080 */
+	uint64_t	 	save_r0;
+	uint64_t	 	save_r1;
+	uint64_t	 	save_r2;
+	uint64_t	 	save_r3;
+                                                /* offset 0x0A0 */
+	uint64_t	 	save_r4;
+	uint64_t	 	save_r5;
+	uint64_t	 	save_r6;
+	uint64_t	 	save_r7;
+                                                /* offset 0x0C0 */
+	uint64_t	 	save_r8;
+	uint64_t	 	save_r9;
+	uint64_t	 	save_r10;
+	uint64_t	 	save_r11;
+                                                /* offset 0x0E0 */
+	uint64_t	 	save_r12;
+	uint64_t	 	save_r13;
+	uint64_t	 	save_r14;
+	uint64_t	 	save_r15;
+                                                /* offset 0x100 */
+	uint64_t	 	save_r16;
+	uint64_t	 	save_r17;
+	uint64_t	 	save_r18;
+	uint64_t	 	save_r19;
+                                                /* offset 0x120 */
+	uint64_t	 	save_r20;
+	uint64_t	 	save_r21;
+	uint64_t	 	save_r22;
+	uint64_t	 	save_r23;
+                                                /* offset 0x140 */
+	uint64_t	 	save_r24;
+	uint64_t	 	save_r25;
+	uint64_t	 	save_r26;	
+	uint64_t	 	save_r27;
+                                                /* offset 0x160 */
+	uint64_t	 	save_r28;
+	uint64_t		save_r29;
+	uint64_t	 	save_r30;
+	uint64_t	 	save_r31;
+                                                /* offset 0x180 */
+	uint64_t	 	save_srr0;
+ 	uint64_t	 	save_srr1;
+	uint64_t	 	save_xer;
+	uint64_t	 	save_lr;
+                                                /* offset 0x1A0 */
+	uint64_t	 	save_ctr;
+	uint64_t	 	save_dar;
 	unsigned int	save_cr;
-	unsigned int 	save_xer;
-	unsigned int 	save_lr;
-	unsigned int 	save_ctr;
-	unsigned int 	save_dar;
 	unsigned int 	save_dsisr;
-			
-
-												/* offset 0x120 */
-	unsigned int	save_vscr[4];	
+	unsigned int	save_exception; 
+	unsigned int	save_vrsave;
+                                                /* offset 0x1C0 */
+	unsigned int	save_vscr[4];
 	unsigned int	save_fpscrpad;
 	unsigned int	save_fpscr;
-	unsigned int	save_exception;
-	unsigned int	save_vrsave;
-
-												/* offset 0x140 */
-	unsigned int 	save_sr0;
-	unsigned int 	save_sr1;
-	unsigned int 	save_sr2;
-	unsigned int 	save_sr3;
-	unsigned int 	save_sr4;
-	unsigned int 	save_sr5;
-	unsigned int 	save_sr6;
-	unsigned int 	save_sr7;
-
-												/* offset 0x160 */
-	unsigned int 	save_sr8;
-	unsigned int 	save_sr9;
-	unsigned int 	save_sr10;
-	unsigned int 	save_sr11;
-	unsigned int 	save_sr12;
-	unsigned int 	save_sr13;
-	unsigned int 	save_sr14;
-	unsigned int 	save_sr15;
-
-												/* offset 0x180 */
-	unsigned int	save_180[8];
-	unsigned int	save_1A0[8];
-	unsigned int	save_1C0[8];
+    unsigned int	save_1d8[2];
+                                                /* offset 0x1E0 */
 	unsigned int	save_1E0[8];
-	unsigned int	save_200[8];
-	unsigned int	save_220[8];
-	unsigned int	save_240[8];
-	unsigned int	save_260[8];
-
+                                                /* offset 0x200 - keep on 128 byte bndry */
+    uint32_t        save_pmc[8]; 
+    uint64_t        save_mmcr0;					/* offset 0x220 */
+    uint64_t        save_mmcr1;
+    uint64_t        save_mmcr2;
+
+	unsigned int	save_238[2];
+												/* offset 0x240 */
+	unsigned int	save_instr[16];				/* Instrumentation */
 												/* offset 0x280 */
 } savearea;
+#pragma pack()
 
 
 /*
  *	This type of savearea contains all of the floating point context.
  */
  
+#pragma pack(4)							/* Make sure the structure stays as we defined it */
 typedef struct savearea_fpu {
 
 	savearea_comm	save_hdr;					/* Stuff common to all saveareas */
@@ -239,6 +232,7 @@ typedef struct savearea_fpu {
 
 												/* offset 0x280 */
 } savearea_fpu;
+#pragma pack()
 
 	
 
@@ -246,6 +240,7 @@ typedef struct savearea_fpu {
  *	This type of savearea contains all of the vector context.
  */
  
+#pragma pack(4)							/* Make sure the structure stays as we defined it */
 typedef struct savearea_vec {
 
 	savearea_comm	save_hdr;					/* Stuff common to all saveareas */
@@ -289,10 +284,12 @@ typedef struct savearea_vec {
 
 												/* offset 0x280 */
 } savearea_vec;
+#pragma pack()
 #endif /* MACH_KERNEL_PRIVATE || BSD_KERNEL_PRIVATE */
 
 #ifdef	MACH_KERNEL_PRIVATE
 
+#pragma pack(4)							/* Make sure the structure stays as we defined it */
 struct Saveanchor {
 
 /*	
@@ -301,20 +298,24 @@ struct Saveanchor {
  *	updated with translation and interrupts disabled. This is because it is 
  *	locked during exception processing and if we were to take a PTE miss while the
  *	lock were held, well, that would be very bad now wouldn't it? 
+ *  Note that the first 24 bytes must be the same format as a savearea header.
  */
 
-	unsigned int	savelock;				/* Lock word for savearea free list manipulation */
-	unsigned int	*savepoolfwd;			/* Forward anchor for the free pool */
-	unsigned int	*savepoolbwd;			/* Backward anchor for the free pool */
-	volatile unsigned int	savefree;		/* Anchor for the global free list */
-	volatile unsigned int	savefreecnt;	/* Number of saveareas on global free list */
-	volatile int	saveadjust;				/* If 0 number of saveareas is ok, otherwise number to change (positive means grow, negative means shrink */
-	volatile int	saveinuse;				/* Number of areas in use counting those on the local free list */
-	volatile int	savetarget;				/* Number of savearea's needed */
-	int				savemaxcount;			/* Maximum saveareas ever allocated */
-
+	unsigned int			savelock;		/* 000 Lock word for savearea free list manipulation */
+    int						saveRSVD4;		/* 004 reserved */
+	addr64_t				savepoolfwd;	/* 008 Forward anchor for the free pool */
+	addr64_t				savepoolbwd;	/* 010 Backward anchor for the free pool */
+	volatile addr64_t		savefree;		/* 018 Anchor for the global free list */
+	volatile unsigned int	savefreecnt;	/* 020 Number of saveareas on global free list */
+	volatile int			saveadjust;		/* 024 If 0 number of saveareas is ok, otherwise # to change (pos means grow, neg means shrink */
+	volatile int			saveinuse;		/* 028 Number of areas in use counting those on the local free list */
+	volatile int			savetarget;		/* 02C Number of savearea's needed */
+	int						savemaxcount;	/* 030 Maximum saveareas ever allocated */
+	unsigned int			saveRSVD034[3];	/* 034 reserved */
+/*											   040 */
 
 };
+#pragma pack()
 
 
 #define sac_cnt		(4096 / sizeof(savearea))	/* Number of saveareas per page */
@@ -332,20 +333,24 @@ struct Saveanchor {
 #define InitialSaveAreas 	(2 * FreeListMin)	/* The number of saveareas to make at boot time */
 #define InitialSaveTarget	FreeListMin		/* The number of saveareas for an initial target. This should be the minimum ever needed. */
 #define	InitialSaveBloks	(InitialSaveAreas + sac_cnt - 1) / sac_cnt	/* The number of savearea blocks to allocate at boot */
+#define BackPocketSaveBloks	8				/* Number of pages of back pocket saveareas */
+
+void			save_queue(ppnum_t);		/* Add a new savearea block to the free list */
+addr64_t		save_get_init(void);		/* special savearea-get for cpu initialization (returns physical address) */
+struct savearea	*save_get(void);			/* Obtains a savearea from the free list (returns virtual address) */
+reg64_t			save_get_phys_32(void);		/* Obtains a savearea from the free list (returns phys addr in r3) */
+reg64_t			save_get_phys_64(void);		/* Obtains a savearea from the free list (returns phys addr in r3) */
+struct savearea	*save_alloc(void);			/* Obtains a savearea and allocates blocks if needed */
+struct savearea	*save_cpv(addr64_t);		/* Converts a physical savearea address to virtual */
+void			save_ret(struct savearea *);	/* Returns a savearea to the free list by virtual address */
+void			save_ret_wMSR(struct savearea *, reg64_t);	/* returns a savearea and restores an MSR */
+void			save_ret_phys(reg64_t);		/* Returns a savearea to the free list by physical address */
+void			save_adjust(void);			/* Adjust size of the global free list */
+struct savearea_comm	*save_trim_free(void);	/* Remove free pages from savearea pool */
+int				save_recover(void);			/* returns nonzero if we can recover enough from the free pool */
+void 			savearea_init(vm_offset_t addr);	/* Boot-time savearea initialization */
 
 
-void 			save_release(struct savearea *);	/* Release a save area  */
-struct savectl	*save_dequeue(void);			/* Find and dequeue one that is all empty */
-unsigned int	save_queue(struct savearea *);	/* Add a new savearea block to the free list */
-struct savearea	*save_get(void);				/* Obtains a savearea from the free list (returns virtual address) */
-struct savearea	*save_get_phys(void);			/* Obtains a savearea from the free list (returns physical address) */
-struct savearea	*save_alloc(void);				/* Obtains a savearea and allocates blocks if needed */
-struct savearea	*save_cpv(struct savearea *);	/* Converts a physical savearea address to virtual */
-void			save_ret(struct savearea *);	/* Returns a savearea to the free list */
-void			save_ret_phys(struct savearea *);	/* Returns a savearea to the free list */
-void			save_adjust(void);				/* Adjust size of the global free list */
-struct savearea_comm	*save_trim_freet(void);			/* Remove free pages from savearea pool */
-
 #endif /* MACH_KERNEL_PRIVATE */
 #endif /* __APPLE_API_PRIVATE */
 
@@ -355,6 +360,9 @@ struct savearea_comm	*save_trim_freet(void);			/* Remove free pages from saveare
 #define SAVrststk	0x00010000				/* Indicates that the current stack should be reset to empty */
 #define SAVsyscall	0x00020000				/* Indicates that the savearea is associated with a syscall */
 #define SAVredrive	0x00040000				/* Indicates that the low-level fault handler associated */
+#define SAVredriveb	13						/* Indicates that the low-level fault handler associated */
+#define	SAVinstrument 0x00080000			/* Indicates that we should return instrumentation data */
+#define	SAVinstrumentb 12					/* Indicates that we should return instrumentation data */
 #define SAVtype		0x0000FF00				/* Shows type of savearea */
 #define SAVtypeshft	8						/* Shift to position type */
 #define SAVempty	0x86					/* Savearea is on free list */
@@ -362,4 +370,6 @@ struct savearea_comm	*save_trim_freet(void);			/* Remove free pages from saveare
 #define SAVfloat	0x02					/* Savearea contains floating point context */
 #define SAVvector	0x03					/* Savearea contains vector context */
 
+
+
 #endif /* _PPC_SAVEAREA_H_ */
diff --git a/osfmk/ppc/savearea_asm.s b/osfmk/ppc/savearea_asm.s
index d3891b019..fe332b864 100644
--- a/osfmk/ppc/savearea_asm.s
+++ b/osfmk/ppc/savearea_asm.s
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -34,574 +37,796 @@
 #include <ppc/exception.h>
 #include <ppc/Performance.h>
 #include <ppc/exception.h>
-#include <ppc/pmap_internals.h>
 #include <ppc/savearea.h>
 #include <mach/ppc/vm_param.h>
 	
 			.text
 
+/* Register usage conventions in this code:
+ *	r9 = return address
+ * r10 = per-proc ptr
+ * r11 = MSR at entry
+ * cr6 = feature flags (ie, pf64Bit)
+ *
+ * Because much of this code deals with physical addresses,
+ * there are parallel paths for 32- and 64-bit machines.
+ */
+ 
+ 
 /*
- *			This routine will add a savearea block to the free list.
- *			Note really well: we can take NO exceptions of any kind,
- *			including a PTE miss once the savearea lock is held. That's
- *			a guaranteed deadlock.  That means we must disable for interrutions
- *			and turn all translation off.
+ * ***********************
+ * * s a v e _ q u e u e *
+ * ***********************
  *
+ *	void save_queue(ppnum_t pagenum);
+ *
+ *			This routine will add a savearea block to the free list.
  *			We also queue the block to the free pool list.  This is a
  *			circular double linked list. Because this block has no free entries,
  *			it gets queued to the end of the list
- *
  */
-
 			.align	5
 			.globl	EXT(save_queue)
 
 LEXT(save_queue)
+            mflr	r9							; get return address
+            mr		r8,r3						; move pagenum out of the way
+            bl		saveSetup					; turn translation off, 64-bit on, load many regs
+            bf--	pf64Bitb,saveQueue32		; skip if 32-bit processor
+            
+            sldi	r2,r8,12					; r2 <-- phys address of page
+			li		r8,sac_cnt					; Get the number of saveareas per page
+			mr		r4,r2						; Point to start of chain
+			li		r0,SAVempty					; Get empty marker
 
-			mfsprg	r9,2						; Get the feature flags
-			mr		r11,r3						; Save the block
-			mtcrf	0x04,r9						; Set the features			
-			mfmsr	r12							; Get the MSR
-			rlwinm	r12,r12,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-			rlwinm	r12,r12,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-			lis		r10,hi16(EXT(saveanchor))	; Get the high part of the anchor
-			andi.	r3,r12,0x7FCF				; Turn off all translation and rupts
-			ori		r10,r10,lo16(EXT(saveanchor))	; Bottom half of the anchor 
-
-			bt		pfNoMSRirb,sqNoMSR			; No MSR...
-
-			mtmsr	r3							; Translation and all off
-			isync								; Toss prefetch
-			b		sqNoMSRx
-			
-sqNoMSR:	li		r0,loadMSR					; Get the MSR setter SC
-			sc									; Set it
-sqNoMSRx:
-			
-			rlwinm.	r3,r11,0,0,19				; (TEST/DEBUG)
-#if 0
-			bne+	notrapit					; (TEST/DEBUG)
-			BREAKPOINT_TRAP						; (TEST/DEBUG) 
-notrapit:										; (TEST/DEBUG)
-#endif
+saveQueue64a:	
+            addic.	r8,r8,-1					; Keep track of how many we did
+			stb		r0,SAVflags+2(r4)			; Set empty
+			addi	r7,r4,SAVsize				; Point to the next slot
+			ble-	saveQueue64b				; We are done with the chain
+			std		r7,SAVprev(r4)				; Set this chain
+			mr		r4,r7						; Step to the next
+			b		saveQueue64a				; Fill the whole block...
+
+saveQueue64b:
+			bl		savelock					; Go lock the save anchor 
 
+			ld		r7,SVfree(0)				; Get the free save area list anchor 
+			lwz		r6,SVfreecnt(0)				; Get the number of free saveareas
 
+			std		r2,SVfree(0)				; Queue in the new one 
+			addi	r6,r6,sac_cnt				; Count the ones we are linking in 
+			std		r7,SAVprev(r4)				; Queue the old first one off of us
+			stw		r6,SVfreecnt(0)				; Save the new count
+			b		saveQueueExit
+
+            ; Handle 32-bit processor.
+            
+saveQueue32:            
+            slwi	r2,r8,12					; r2 <-- phys address of page
 			li		r8,sac_cnt					; Get the number of saveareas per page
-			mr		r4,r11						; Point to start of chain
+			mr		r4,r2						; Point to start of chain
 			li		r0,SAVempty					; Get empty marker
 
-sqchain:	addic.	r8,r8,-1					; Keep track of how many we did
+saveQueue32a:	
+            addic.	r8,r8,-1					; Keep track of how many we did
 			stb		r0,SAVflags+2(r4)			; Set empty
-			addi	r9,r4,SAVsize				; Point to the next slot
-			ble-	sqchaindn					; We are done with the chain
-			stw		r9,SAVprev(r4)				; Set this chain
-			mr		r4,r9						; Step to the next
-			b		sqchain						; Fill the whole block...
-
-			.align	5
+			addi	r7,r4,SAVsize				; Point to the next slot
+			ble-	saveQueue32b				; We are done with the chain
+			stw		r7,SAVprev+4(r4)			; Set this chain
+			mr		r4,r7						; Step to the next
+			b		saveQueue32a				; Fill the whole block...
 
-sqchaindn:	mflr	r9							; Save the return address
+saveQueue32b:
 			bl		savelock					; Go lock the save anchor 
 
-			lwz		r7,SVfree(r10)				; Get the free save area list anchor 
-			lwz		r6,SVfreecnt(r10)			; Get the number of free saveareas
+			lwz		r7,SVfree+4(0)				; Get the free save area list anchor 
+			lwz		r6,SVfreecnt(0)				; Get the number of free saveareas
 
-			stw		r11,SVfree(r10)				; Queue in the new one 
+			stw		r2,SVfree+4(0)				; Queue in the new one 
 			addi	r6,r6,sac_cnt				; Count the ones we are linking in 
-			stw		r7,SAVprev(r4)				; Queue the old first one off of us
-			stw		r6,SVfreecnt(r10)			; Save the new count
-			
+			stw		r7,SAVprev+4(r4)			; Queue the old first one off of us
+			stw		r6,SVfreecnt(0)				; Save the new count
+
+saveQueueExit:									; join here from 64-bit path		
 			bl		saveunlock					; Unlock the list and set the adjust count
-			
 			mtlr	r9							; Restore the return
-			mtmsr	r12							; Restore interrupts and translation 
-			isync								; Dump any speculations 
 
 #if FPVECDBG
-			mfsprg	r2,0						; (TEST/DEBUG)
-			lwz		r2,next_savearea(r2)		; (TEST/DEBUG)
+			mfsprg	r2,1						; (TEST/DEBUG)
 			mr.		r2,r2						; (TEST/DEBUG)
-			beqlr-								; (TEST/DEBUG)
+			beq--	saveRestore					; (TEST/DEBUG)
 			lis		r0,hi16(CutTrace)			; (TEST/DEBUG)
 			li		r2,0x2201					; (TEST/DEBUG)
 			oris	r0,r0,lo16(CutTrace)		; (TEST/DEBUG)
 			sc									; (TEST/DEBUG)
 #endif
-
-			blr									; Leave... 
+            b		saveRestore					; Restore interrupts and translation
 
 /*
- *			This routine will obtain a savearea.
- *			Note really well: we can take NO exceptions of any kind,
- *			including a PTE miss during this process. That's
- *			a guaranteed deadlock or screwup.  That means we must disable for interrutions
- *			and turn all translation off.
- *
- *			We pass back the virtual address of the one we just obtained
- *			or a zero if none to allocate.
+ * *****************************
+ * * s a v e _ g e t _ i n i t *
+ * *****************************
  *
- *			First we try the local list.  If that is below a threshold, we will
- *			lock the free list and replenish.
- *
- *			If there are no saveareas in either list, we will install the 
- *			backpocket and choke.
- *
- *			The save_get_phys call assumes that translation and interruptions are
- *			already off and that the returned address is physical.
+ *	addr64_t  save_get_init(void);
  *
  *			Note that save_get_init is used in initial processor startup only.  It
  *			is used because translation is on, but no tables exist yet and we have
  *			no V=R BAT registers that cover the entire physical memory.
- *
- *
- *			NOTE!!! NEVER USE R0, R2, or R12 IN HERE THAT WAY WE DON'T NEED A
- *			STACK FRAME IN FPU_SAVE, FPU_SWITCH, VEC_SAVE, OR VEC_SWITCH.
  */
- 
 			.align	5
 			.globl	EXT(save_get_init)
 
 LEXT(save_get_init)
+            mflr	r9							; get return address
+            bl		saveSetup					; turn translation off, 64-bit on, load many regs
+            bfl--	pf64Bitb,saveGet32			; Get r3 <- savearea, r5 <- page address (with SAC)
+            btl++	pf64Bitb,saveGet64			; get one on a 64-bit machine
+            bl		saveRestore					; restore translation etc
+            mtlr	r9
+            
+            ; unpack the physaddr in r3 into a long long in (r3,r4)
+            
+            mr		r4,r3						; copy low word of phys address to r4
+            li		r3,0						; assume upper word was 0
+            bflr--	pf64Bitb					; if 32-bit processor, return
+            srdi	r3,r4,32					; unpack reg64_t to addr64_t on 64-bit machine
+            rlwinm	r4,r4,0,0,31
+            blr
+            
 
-			mfsprg	r9,2						; Get the feature flags
-			mfmsr	r12							; Get the MSR 
-			rlwinm	r12,r12,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-			rlwinm	r12,r12,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-			mtcrf	0x04,r9						; Set the features			
-			andi.	r3,r12,0x7FCF				; Turn off all translation and interrupts
-
-			bt		pfNoMSRirb,sgiNoMSR			; No MSR...
-
-			mtmsr	r3							; Translation and all off
-			isync								; Toss prefetch
-			b		sgiGetPhys					; Go get the savearea...
-			
-sgiNoMSR:	li		r0,loadMSR					; Get the MSR setter SC
-			sc									; Set it
-
-sgiGetPhys:	mflr	r11							; Save R11 (save_get_phys does not use this one)
-			bl		EXT(save_get_phys)			; Get a savearea
-			mtlr	r11							; Restore return
-			
-			mtmsr	r12							; Restore translation and exceptions
-			isync								; Make sure about it
-			blr									; Return...
- 
+/*
+ * *******************
+ * * s a v e _ g e t *
+ * *******************
+ *
+ *	savearea *save_get(void);
+ *
+ *			Allocate a savearea, returning a virtual address.  NOTE: we must preserve
+ *			r0, r2, and r12.  Our callers in cswtch.s depend on this.
+ */
 			.align	5
 			.globl	EXT(save_get)
 
 LEXT(save_get)
-			
-			crclr	cr1_eq						; Clear CR1_eq to indicate we want virtual address
-			mfsprg	r9,2						; Get the feature flags
-			mfmsr	r11							; Get the MSR 
-			rlwinm.	r3,r11,0,MSR_EE_BIT,MSR_EE_BIT	;	Are interrupts enabled here?
-			beq+	sgnomess					; Nope, do not mess with fp or vec...
-			rlwinm	r11,r11,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-			rlwinm	r11,r11,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-
-sgnomess:	mtcrf	0x04,r9						; Set the features			
-			andi.	r3,r11,0x7FCF				; Turn off all translation and interrupts
-
-			bt		pfNoMSRirb,sgNoMSR			; No MSR...
-
-			mtmsr	r3							; Translation and all off
-			isync								; Toss prefetch
-			b		csaveget
-			
-sgNoMSR:	mr		r9,r0						; Save this
-			li		r0,loadMSR					; Get the MSR setter SC
-			sc									; Set it
-			mr		r0,r9						; Restore it
+            mflr	r9							; get return address
+            mr		r5,r0						; copy regs before saveSetup nails them
+            bl		saveSetup					; turn translation off, 64-bit on, load many regs
+            bf--	pf64Bitb,svgt1				; skip if 32-bit processor
+            
+            std		r5,tempr0(r10)				; save r0 in per-proc across call to saveGet64
+            std		r2,tempr2(r10)				; and r2
+            std		r12,tempr4(r10)				; and r12
+            bl		saveGet64					; get r3 <- savearea, r5 <- page address (with SAC)
+            ld		r0,tempr0(r10)				; restore callers regs
+            ld		r2,tempr2(r10)
+            ld		r12,tempr4(r10)
+            b		svgt2
+            
+svgt1:											; handle 32-bit processor
+            stw		r5,tempr0+4(r10)			; save r0 in per-proc across call to saveGet32
+            stw		r2,tempr2+4(r10)			; and r2
+            stw		r12,tempr4+4(r10)			; and r12
+            bl		saveGet32					; get r3 <- savearea, r5 <- page address (with SAC)
+            lwz		r0,tempr0+4(r10)			; restore callers regs
+            lwz		r2,tempr2+4(r10)
+            lwz		r12,tempr4+4(r10)
+            
+svgt2:
+			lwz		r5,SACvrswap+4(r5)			; Get the virtual to real translation (only need low word)
+            mtlr	r9							; restore return address
+            xor		r3,r3,r5					; convert physaddr to virtual
+            rlwinm	r3,r3,0,0,31				; 0 upper word if a 64-bit machine
 
-			b		csaveget					; Join the common...
-
-			.align	5
-			.globl	EXT(save_get_phys)
-
-LEXT(save_get_phys)
-			
-			crset	cr1_eq						; Clear CR1_ne to indicate we want physical address
-
-csaveget:	mfsprg	r9,0						; Get the per proc
-			lis		r10,hi16(EXT(saveanchor))	; Get the high part of the anchor
-			lwz		r8,lclfreecnt(r9)			; Get the count
-			lwz		r3,lclfree(r9)				; Get the start of local savearea list
-			cmplwi	r8,LocalSaveMin				; Are we too low?
-			ori		r10,r10,lo16(EXT(saveanchor))	; Bottom half of the anchor 
-			ble-	sglow						; We are too low and need to grow list...
-			
-sgreserve:	lis		r10,0x5555					; Get top of empty indication
-			li		r6,0						; zero value
-			lwz		r4,SAVprev(r3)				; Chain to the next one
-			stw		r6,SAVflags(r3)				; Clear flags
-			ori		r10,r10,0x5555				; And the bottom
-			subi	r8,r8,1						; Back down count
-			stw		r10,SAVprev(r3)				; Trash this
-			stw		r10,SAVlevel(r3)			; Trash this
-			stw		r4,lclfree(r9)				; Unchain first savearea
-			rlwinm	r5,r3,0,0,19				; Back up to first page where SAC is
-			stw		r10,SAVact(r3)				; Trash this
-			stw		r8,lclfreecnt(r9)			; Set new count
-			
-			btlr+	cr1_eq						; Return now if physical request
-			
-			lwz		r5,SACvrswap(r5)			; Get the virtual to real translation
-			
-			mtmsr	r11							; Restore translation and exceptions
-			isync								; Make sure about it
-	
 #if FPVECDBG
-;			Note: we do not trace the physical request because this ususally comes from the
-;			exception vector code
-
-			mr		r6,r0						; (TEST/DEBUG)
-			mr		r7,r2						; (TEST/DEBUG) 
+            mr		r6,r0						; (TEST/DEBUG)
+            mr		r7,r2						; (TEST/DEBUG)
+			mfsprg	r2,1						; (TEST/DEBUG)
+			mr.		r2,r2						; (TEST/DEBUG)
+			beq--	svgDBBypass					; (TEST/DEBUG)
 			lis		r0,HIGH_ADDR(CutTrace)		; (TEST/DEBUG)
 			li		r2,0x2203					; (TEST/DEBUG)
 			oris	r0,r0,LOW_ADDR(CutTrace)	; (TEST/DEBUG)
 			sc									; (TEST/DEBUG) 
-			mr		r0,r6						; (TEST/DEBUG)
-			mr		r2,r7						; (TEST/DEBUG)
+svgDBBypass:									; (TEST/DEBUG)
+            mr		r0,r6						; (TEST/DEBUG)
+            mr		r2,r7						; (TEST/DEBUG) 
 #endif			
-			
-			xor		r3,r3,r5					; Get the virtual address 
-			blr									; Leave...
+            b		saveRestore					; restore MSR and return to our caller
+            
+            
+/*
+ * ***********************************
+ * * s a v e _ g e t _ p h y s _ 3 2 *
+ * ***********************************
+ *
+ *	reg64_t	save_get_phys(void);
+ *
+ * 			This is the entry normally called from lowmem_vectors.s with
+ *			translation and interrupts already off.
+ *			MUST NOT TOUCH CR7
+ */
+			.align	5
+			.globl	EXT(save_get_phys_32)
 
-;
-;			Here is the slow path which is executed when there are not enough in the local list
-;
-					
+LEXT(save_get_phys_32)
+            mfsprg	r10,0						; get the per-proc ptr
+			b		saveGet32					; Get r3 <- savearea, r5 <- page address (with SAC)
+
+
+/*
+ * ***********************************
+ * * s a v e _ g e t _ p h y s _ 6 4 *
+ * ***********************************
+ *
+ *	reg64_t	save_get_phys_64(void);
+ *
+ * 			This is the entry normally called from lowmem_vectors.s with
+ *			translation and interrupts already off, and in 64-bit mode.
+ *			MUST NOT TOUCH CR7
+ */
 			.align	5
-						
-sglow:		mflr	r9							; Save the return
+			.globl	EXT(save_get_phys_64)
+
+LEXT(save_get_phys_64)
+            mfsprg	r10,0						; get the per-proc ptr
+ 			b		saveGet64					; Get r3 <- savearea, r5 <- page address (with SAC)
+            
+
+/*
+ * *********************
+ * * s a v e G e t 6 4 *
+ * *********************
+ *
+ *			This is the internal routine to allocate a savearea on a 64-bit processor.  
+ *			Note that we must not take any exceptions of any kind, including PTE misses, as that
+ *			would deadlock trying to reenter this routine.  We pass back the 64-bit physical address.
+ *			First we try the local list.  If that is below a threshold, we try the global free list,
+ *			which requires taking a lock, and replenish.  If there are no saveareas in either list,
+ *			we will install the  backpocket and choke.  This routine assumes that the caller has
+ *			turned translation off, masked interrupts,  turned on 64-bit mode, and set up:
+ *				r10 = per-proc ptr
+ *
+ *			We return:
+ *				r3 = 64-bit physical address of the savearea
+ *				r5 = 64-bit physical address of the page the savearea is in, with SAC
+ *
+ *			We destroy:
+ *				r2-r8.
+ *		
+ * 			MUST NOT TOUCH CR7
+ */
+
+saveGet64:            
+			lwz		r8,lclfreecnt(r10)			; Get the count
+			ld		r3,lclfree(r10)				; Get the start of local savearea list
+			cmplwi	r8,LocalSaveMin				; Are we too low?
+			ble--	saveGet64GetGlobal			; We are too low and need to grow list...
+
+            ; Get it from the per-processor local list.
+            
+saveGet64GetLocal:
+            li		r2,0x5555					; get r2 <-- 0x55555555 55555555, our bugbug constant
+			ld		r4,SAVprev(r3)				; Chain to the next one
+			oris	r2,r2,0x5555
+			subi	r8,r8,1						; Back down count
+            rldimi	r2,r2,32,0
+
+			std		r2,SAVprev(r3)				; bug next ptr
+			stw		r2,SAVlevel(r3)				; bug context ID
+            li		r6,0
+			std		r4,lclfree(r10)				; Unchain first savearea
+			stw		r2,SAVact(r3)				; bug activation ptr
+			rldicr	r5,r3,0,51					; r5 <-- page ptr, where SAC is kept
+			stw		r8,lclfreecnt(r10)			; Set new count
+			stw		r6,SAVflags(r3)				; clear the flags
+
+            blr
+
+            ; Local list was low so replenish from global list.
+            ;	 r7 = return address to caller of saveGet64
+            ;	 r8 = lclfreecnt
+            ;	r10 = per-proc ptr
+            
+saveGet64GetGlobal:
+            mflr	r7							; save return adress
+			subfic	r5,r8,LocalSaveTarget		; Get the number of saveareas we need to grab to get to target
 			bl		savelock					; Go lock up the anchor
-			mtlr	r9							; Restore the return
 			
-			subfic	r5,r8,LocalSaveTarget		; Get the number of saveareas we need to grab to get to target
-			lwz		r9,SVfreecnt(r10)			; Get the number on this list
-			lwz		r8,SVfree(r10)				; Get the head of the save area list 
+			lwz		r2,SVfreecnt(0)				; Get the number on this list
+			ld		r8,SVfree(0)				; Get the head of the save area list 
 			
-			sub		r3,r9,r5					; Get number left after we swipe enough for local list
-			srawi	r3,r3,31					; Get 0 if enough or 0xFFFFFFFF if not
+			sub		r3,r2,r5					; Get number left after we swipe enough for local list
+			sradi	r3,r3,63					; Get 0 if enough or -1 if not
 			andc	r4,r5,r3					; Get number to get if there are enough, 0 otherwise
-			and		r5,r9,r3					; Get 0 if there are enough, number on list otherwise
-			or.		r5,r4,r5					; Get the number we will move
-			beq-	sgnofree					; There are none to get...
+			and		r5,r2,r3					; Get 0 if there are enough, number on list otherwise
+			or.		r5,r4,r5					; r5 <- number we will move from global to local list
+			beq--	saveGet64NoFree				; There are none to get...
 			
 			mtctr	r5							; Get loop count
 			mr		r6,r8						; Remember the first in the list
-			
-sgtrimf:	bdz		sgtfdone					; Count down and branch when we hit 0...
-			lwz		r8,SAVprev(r8)				; Get the next
-			b		sgtrimf						; Keep going...
 
-			.align	5
-			
-sgtfdone:	lwz		r7,SAVprev(r8)				; Get the next one
-			lwz		r4,SVinuse(r10)				; Get the in use count
-			sub		r9,r9,r5					; Count down what we stole
-			stw		r7,SVfree(r10)				; Set the new first in list
+saveGet64c:
+            bdz		saveGet64d					; Count down and branch when we hit 0...
+			ld		r8,SAVprev(r8)				; Get the next
+			b		saveGet64c					; Keep going...
+
+saveGet64d:			
+            ld		r3,SAVprev(r8)				; Get the next one
+			lwz		r4,SVinuse(0)				; Get the in use count
+			sub		r2,r2,r5					; Count down what we stole
+			std		r3,SVfree(0)				; Set the new first in list
 			add		r4,r4,r5					; Count the ones we just put in the local list as "in use"
-			stw		r9,SVfreecnt(r10)			; Set the new count
-			mfsprg	r9,0						; Get the per proc
-			stw		r4,SVinuse(r10)				; Set the new in use count
+			stw		r2,SVfreecnt(0)				; Set the new count
+			stw		r4,SVinuse(0)				; Set the new in use count
 			
-			lwz		r4,lclfree(r9)				; Get the old head of list
-			lwz		r3,lclfreecnt(r9)			; Get the old count
-			stw		r6,lclfree(r9)				; Set the new head of the list
+			ld		r4,lclfree(r10)				; Get the old head of list
+			lwz		r3,lclfreecnt(r10)			; Get the old count
+			std		r6,lclfree(r10)				; Set the new head of the list
 			add		r3,r3,r5					; Get the new count
-			stw		r4,SAVprev(r8)				; Point to the old head
-			stw		r3,lclfreecnt(r9)			; Set the new count
+			std		r4,SAVprev(r8)				; Point to the old head
+			stw		r3,lclfreecnt(r10)			; Set the new count
 
-			mflr	r9							; Save the return
 			bl		saveunlock					; Update the adjust field and unlock
-			mtlr	r9							; Restore return
-			b		csaveget					; Start over and finally allocate the savearea...
-			
-;
-;			The local list is below the repopulate threshold and the free list is empty.
-;			First we check if there are any left in the local list and if so, we allow
-;			them to be allocated.  If not, we release the backpocket list and choke.  
-;			There is nothing more that we can do at this point.  Hopefully we stay alive
-;			long enough to grab some much-needed panic information.
-;
-			
-sgnofree:	mfsprg	r9,0						; Get the per proc
-			lwz		r8,lclfreecnt(r9)			; Get the count
-			lwz		r3,lclfree(r9)				; Get the start of local savearea list
+            mtlr	r7							; restore return address
+			b		saveGet64					; Start over and finally allocate the savearea...
+			
+            ; The local list is below the repopulate threshold and the global list is empty.
+            ; First we check if there are any left in the local list and if so, we allow
+            ; them to be allocated.  If not, we release the backpocket list and choke.  
+            ; There is nothing more that we can do at this point.  Hopefully we stay alive
+            ; long enough to grab some much-needed panic information.
+            ;	 r7 = return address to caller of saveGet64 
+            ;	r10 = per-proc ptr
+
+saveGet64NoFree:			
+			lwz		r8,lclfreecnt(r10)			; Get the count
 			mr.		r8,r8						; Are there any reserve to get?
-
-			mflr	r9							; Save the return
-			beq-	sgchoke						; No, go choke and die...
+			beq--	saveGet64Choke				; No, go choke and die...
 			bl		saveunlock					; Update the adjust field and unlock
-			mtlr	r9							; Restore return
-
-			mfsprg	r9,0						; Get the per proc again
-			lwz		r3,lclfree(r9)				; Get the start of local savearea list
-			lwz		r8,lclfreecnt(r9)			; Get the count
-			b		sgreserve					; We have some left, dip on in...
+			ld		r3,lclfree(r10)				; Get the start of local savearea list
+			lwz		r8,lclfreecnt(r10)			; Get the count
+            mtlr	r7							; restore return address
+			b		saveGet64GetLocal			; We have some left, dip on in...
 			
-;
 ;			We who are about to die salute you.  The savearea chain is messed up or
 ;			empty.  Add in a few so we have enough to take down the system.
-;
 
-sgchoke:	lis		r9,hi16(EXT(backpocket))	; Get high order of back pocket
+saveGet64Choke:
+            lis		r9,hi16(EXT(backpocket))	; Get high order of back pocket
 			ori		r9,r9,lo16(EXT(backpocket))	; and low part
 			
-			lwz		r8,SVfreecnt(r9)			; Get the new number of free elements
-			lwz		r7,SVfree(r9)				; Get the head of the chain
-			lwz		r6,SVinuse(r10)				; Get total in the old list
+			lwz		r8,SVfreecnt-saveanchor(r9)	; Get the new number of free elements
+			ld		r7,SVfree-saveanchor(r9)	; Get the head of the chain
+			lwz		r6,SVinuse(0)				; Get total in the old list
 
-			stw		r8,SVfreecnt(r10)			; Set the new number of free elements
+			stw		r8,SVfreecnt(0)				; Set the new number of free elements
 			add		r6,r6,r8					; Add in the new ones
-			stw		r7,SVfree(r10)				; Set the new head of the chain
-			stw		r6,SVinuse(r10)				; Set total in the new list
+			std		r7,SVfree(0)				; Set the new head of the chain
+			stw		r6,SVinuse(0)				; Set total in the new list
 
+saveGetChokeJoin:								; join in the fun from 32-bit mode
 			lis		r0,hi16(Choke)				; Set choke firmware call
 			li		r7,0						; Get a clear register to unlock
 			ori		r0,r0,lo16(Choke)			; Set the rest of the choke call
 			li		r3,failNoSavearea			; Set failure code
 
-			sync								; Make sure all is committed
-			stw		r7,SVlock(r10)				; Unlock the free list
+			eieio								; Make sure all is committed
+			stw		r7,SVlock(0)				; Unlock the free list
 			sc									; System ABEND
 
 
-
 /*
- *			This routine will return a savearea to the free list.
- *			Note really well: we can take NO exceptions of any kind,
- *			including a PTE miss once the savearea lock is held. That's
- *			a guaranteed deadlock.  That means we must disable for interrutions
- *			and turn all translation off.
- *
- *			We take a virtual address for save_ret.  For save_ret_phys we
- *			assume we are already physical/interrupts off and the address is physical.
+ * *********************
+ * * s a v e G e t 3 2 *
+ * *********************
  *
- *			Here's a tricky bit, and important:
+ *			This is the internal routine to allocate a savearea on a 32-bit processor.  
+ *			Note that we must not take any exceptions of any kind, including PTE misses, as that
+ *			would deadlock trying to reenter this routine.  We pass back the 32-bit physical address.
+ *			First we try the local list.  If that is below a threshold, we try the global free list,
+ *			which requires taking a lock, and replenish.  If there are no saveareas in either list,
+ *			we will install the  backpocket and choke.  This routine assumes that the caller has
+ *			turned translation off, masked interrupts, and set up:
+ *				r10 = per-proc ptr
  *
- *			When we trim the list, we NEVER trim the very first one.  This is because that is
- *			the very last one released and the exception exit code will release the savearea
- *			BEFORE it is done using it. Wouldn't be too good if another processor started
- *			using it, eh?  So for this case, we are safe so long as the savearea stays on
- *			the local list.  (Note: the exit routine needs to do this because it is in the 
- *			process of restoring all context and it needs to keep it until the last second.)
+ *			We return:
+ *				r3 = 32-bit physical address of the savearea
+ *				r5 = 32-bit physical address of the page the savearea is in, with SAC
  *
+ *			We destroy:
+ *				r2-r8.
  */
 
-;
-;			Note: when called from interrupt enabled code, we want to turn off vector and
-;			floating point because we can not guarantee that the enablement will not change
-;			while we hold a copy of the MSR.  We force it off so that the lazy switcher will
-;			turn it back on if used.  However, we need to NOT change it save_ret or save_get
-;			is called with interrupts disabled.  This is because both of these routine are
-;			called from within the context switcher and changing the enablement would be
-;			very, very bad..... (especially from within the lazt switcher)
-;
+saveGet32:            
+			lwz		r8,lclfreecnt(r10)			; Get the count
+			lwz		r3,lclfree+4(r10)			; Get the start of local savearea list
+			cmplwi	r8,LocalSaveMin				; Are we too low?
+			ble-	saveGet32GetGlobal			; We are too low and need to grow list...
+
+            ; Get savearea from per-processor local list.
+            
+saveGet32GetLocal:
+            li		r2,0x5555					; get r2 <-- 0x55555555, our bugbug constant
+			lwz		r4,SAVprev+4(r3)			; Chain to the next one
+			oris	r2,r2,0x5555
+			subi	r8,r8,1						; Back down count
 
-			.align	5
-			.globl	EXT(save_ret)
+			stw		r2,SAVprev+4(r3)			; bug next ptr
+			stw		r2,SAVlevel(r3)				; bug context ID
+            li		r6,0
+			stw		r4,lclfree+4(r10)			; Unchain first savearea
+			stw		r2,SAVact(r3)				; bug activation ptr
+			rlwinm	r5,r3,0,0,19				; r5 <-- page ptr, where SAC is kept
+			stw		r8,lclfreecnt(r10)			; Set new count
+			stw		r6,SAVflags(r3)				; clear the flags
+
+            blr
+
+            ; Local list was low so replenish from global list.
+            ;	 r7 = return address to caller of saveGet32
+            ;	 r8 = lclfreecnt
+            ;	r10 = per-proc ptr
+            
+saveGet32GetGlobal:
+            mflr	r7							; save return adress
+			subfic	r5,r8,LocalSaveTarget		; Get the number of saveareas we need to grab to get to target
+			bl		savelock					; Go lock up the anchor
+			
+			lwz		r2,SVfreecnt(0)				; Get the number on this list
+			lwz		r8,SVfree+4(0)				; Get the head of the save area list 
+			
+			sub		r3,r2,r5					; Get number left after we swipe enough for local list
+			srawi	r3,r3,31					; Get 0 if enough or -1 if not
+			andc	r4,r5,r3					; Get number to get if there are enough, 0 otherwise
+			and		r5,r2,r3					; Get 0 if there are enough, number on list otherwise
+			or.		r5,r4,r5					; r5 <- number we will move from global to local list
+			beq-	saveGet32NoFree				; There are none to get...
+			
+			mtctr	r5							; Get loop count
+			mr		r6,r8						; Remember the first in the list
 
-LEXT(save_ret)
+saveGet32c:
+            bdz		saveGet32d					; Count down and branch when we hit 0...
+			lwz		r8,SAVprev+4(r8)			; Get the next
+			b		saveGet32c					; Keep going...
 
-			mfmsr	r12							; Get the MSR 
-			rlwinm.	r9,r12,0,MSR_EE_BIT,MSR_EE_BIT	;	Are interrupts enabled here?
-			beq+	EXT(save_ret_join)			; Nope, do not mess with fp or vec...
-			rlwinm	r12,r12,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-			rlwinm	r12,r12,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
+saveGet32d:			
+            lwz		r3,SAVprev+4(r8)			; Get the next one
+			lwz		r4,SVinuse(0)				; Get the in use count
+			sub		r2,r2,r5					; Count down what we stole
+			stw		r3,SVfree+4(0)				; Set the new first in list
+			add		r4,r4,r5					; Count the ones we just put in the local list as "in use"
+			stw		r2,SVfreecnt(0)				; Set the new count
+			stw		r4,SVinuse(0)				; Set the new in use count
+			
+			lwz		r4,lclfree+4(r10)			; Get the old head of list
+			lwz		r3,lclfreecnt(r10)			; Get the old count
+			stw		r6,lclfree+4(r10)			; Set the new head of the list
+			add		r3,r3,r5					; Get the new count
+			stw		r4,SAVprev+4(r8)			; Point to the old head
+			stw		r3,lclfreecnt(r10)			; Set the new count
 
-			.globl	EXT(save_ret_join)
+			bl		saveunlock					; Update the adjust field and unlock
+            mtlr	r7							; restore return address
+			b		saveGet32					; Start over and finally allocate the savearea...
+			
+            ; The local list is below the repopulate threshold and the global list is empty.
+            ; First we check if there are any left in the local list and if so, we allow
+            ; them to be allocated.  If not, we release the backpocket list and choke.  
+            ; There is nothing more that we can do at this point.  Hopefully we stay alive
+            ; long enough to grab some much-needed panic information.
+            ;	 r7 = return address to caller of saveGet32
+            ;	r10 = per-proc ptr
+
+saveGet32NoFree:			
+			lwz		r8,lclfreecnt(r10)			; Get the count
+			mr.		r8,r8						; Are there any reserve to get?
+			beq-	saveGet32Choke				; No, go choke and die...
+			bl		saveunlock					; Update the adjust field and unlock
+			lwz		r3,lclfree+4(r10)			; Get the start of local savearea list
+			lwz		r8,lclfreecnt(r10)			; Get the count
+            mtlr	r7							; restore return address
+			b		saveGet32GetLocal			; We have some left, dip on in...
+			
+;			We who are about to die salute you.  The savearea chain is messed up or
+;			empty.  Add in a few so we have enough to take down the system.
 
-LEXT(save_ret_join)
-			crclr	cr1_eq						; Clear CR1_ne to indicate we have virtual address
-			mfsprg	r9,2						; Get the feature flags
-			rlwinm	r6,r3,0,0,19				; Round back down to the savearea page block
-			lwz		r5,SACvrswap(r6)			; Get the conversion to real
-			mtcrf	0x04,r9						; Set the features			
-			mfsprg	r9,0						; Get the per proc
-			xor		r8,r3,r5					; Get the real address of the savearea
-			andi.	r3,r12,0x7FCF				; Turn off all translation and rupts
+saveGet32Choke:
+            lis		r9,hi16(EXT(backpocket))	; Get high order of back pocket
+			ori		r9,r9,lo16(EXT(backpocket))	; and low part
+			
+			lwz		r8,SVfreecnt-saveanchor(r9)	; Get the new number of free elements
+			lwz		r7,SVfree+4-saveanchor(r9)	; Get the head of the chain
+			lwz		r6,SVinuse(0)				; Get total in the old list
 
-			bt		pfNoMSRirb,srNoMSR			; No MSR...
+			stw		r8,SVfreecnt(0)				; Set the new number of free elements
+			add		r6,r6,r8					; Add in the new ones (why?)
+			stw		r7,SVfree+4(0)				; Set the new head of the chain
+			stw		r6,SVinuse(0)				; Set total in the new list
+            
+            b		saveGetChokeJoin
 
-			mtmsr	r3							; Translation and all off
-			isync								; Toss prefetch
-			b		srcommon
-			
-			.align	5
-			
-srNoMSR:	li		r0,loadMSR					; Get the MSR setter SC
-			sc									; Set it
-srNoMSRx:	b		srcommon					; Join up below...
 
+/*
+ * *******************
+ * * s a v e _ r e t *
+ * *******************
+ *
+ *	void	save_ret(struct savearea *);				// normal call
+ *	void	save_ret_wMSR(struct savearea *,reg64_t); 	// passes MSR to restore as 2nd arg
+ *
+ *			Return a savearea passed by virtual address to the free list.
+ *			Note really well: we can take NO exceptions of any kind,
+ *			including a PTE miss once the savearea lock is held. That's
+ *			a guaranteed deadlock.  That means we must disable for interrutions
+ *			and turn all translation off.
+ */
+            .globl	EXT(save_ret_wMSR)			; alternate entry pt w MSR to restore in r4
+            
+LEXT(save_ret_wMSR)
+            crset	31							; set flag for save_ret_wMSR
+            b		svrt1						; join common code
+            
+            .align	5
+            .globl	EXT(save_ret)
+            
+LEXT(save_ret)
+            crclr	31							; clear flag for save_ret_wMSR
+svrt1:											; join from save_ret_wMSR
+            mflr	r9							; get return address
+            rlwinm	r7,r3,0,0,19				; get virtual address of SAC area at start of page
+            mr		r8,r3						; save virtual address
+            lwz		r5,SACvrswap+0(r7)			; get 64-bit converter from V to R
+            lwz		r6,SACvrswap+4(r7)			; both halves, though only bottom used on 32-bit machine
+#if FPVECDBG
+			lis		r0,HIGH_ADDR(CutTrace)		; (TEST/DEBUG)
+			li		r2,0x2204					; (TEST/DEBUG)
+			oris	r0,r0,LOW_ADDR(CutTrace)	; (TEST/DEBUG) 
+			sc									; (TEST/DEBUG) 
+#endif
+            bl		saveSetup					; turn translation off, 64-bit on, load many regs
+            bf++	31,svrt3					; skip if not save_ret_wMSR
+            mr		r11,r4						; was save_ret_wMSR, so overwrite saved MSR
+svrt3:
+            bf--	pf64Bitb,svrt4				; skip if a 32-bit processor
+            
+            ; Handle 64-bit processor.
+            
+            rldimi	r6,r5,32,0					; merge upper and lower halves of SACvrswap together
+            xor		r3,r8,r6					; get r3 <- 64-bit physical address of this savearea
+            bl		saveRet64					; return it
+            mtlr	r9							; restore return address
+            b		saveRestore64				; restore MSR
+            
+            ; Handle 32-bit processor.
+            
+svrt4:
+            xor		r3,r8,r6					; get r3 <- 32-bit physical address of this savearea
+            bl		saveRet32					; return it
+            mtlr	r9							; restore return address
+            b		saveRestore32				; restore MSR
+ 
 
+/*
+ * *****************************
+ * * s a v e _ r e t _ p h y s *
+ * *****************************
+ *
+ *	void	save_ret_phys(reg64_t);
+ *
+ *			Called from lowmem vectors to return (ie, free) a savearea by physical address.
+ *			Translation and interrupts are already off, and 64-bit mode is set if defined.
+ *			We can take _no_ exceptions of any kind in this code, including PTE miss, since
+ *			that would result in a deadlock.  We expect:
+ *				r3 = phys addr of savearea
+ *			   msr = IR, DR, and EE off, SF on
+ *             cr6 = pf64Bit flag
+ *			We destroy:
+ *				r0,r2-r10.
+ */
 			.align	5
 			.globl	EXT(save_ret_phys)
 
 LEXT(save_ret_phys)
+            mfsprg	r10,0						; get the per-proc ptr
+            bf--	pf64Bitb,saveRet32			; handle 32-bit machine
+            b		saveRet64					; handle 64-bit machine
+            
 
-			mfsprg	r9,0						; Get the per proc
-			crset	cr1_eq						; Clear CR1_ne to indicate we have physical address
-			mr		r8,r3						; Save the savearea address
-
-			nop
-
-srcommon:	
+/*
+ * *********************
+ * * s a v e R e t 6 4 *
+ * *********************
+ *
+ *			This is the internal routine to free a savearea, passed by 64-bit physical
+ *			address.  We assume that IR, DR, and EE are all off, that SF is on, and:
+ *				r3 = phys address of the savearea
+ *			   r10 = per-proc ptr
+ *			We destroy:
+ *				r0,r2-r8.
+ */
+            .align	5
+ saveRet64:
 			li		r0,SAVempty					; Get marker for free savearea
-			lwz		r7,lclfreecnt(r9)			; Get the local count
-			lwz		r6,lclfree(r9)				; Get the old local header
+			lwz		r7,lclfreecnt(r10)			; Get the local count
+			ld		r6,lclfree(r10)				; Get the old local header
 			addi	r7,r7,1						; Pop up the free count
-			stw		r6,SAVprev(r8)				; Plant free chain pointer
+			std		r6,SAVprev(r3)				; Plant free chain pointer
 			cmplwi	r7,LocalSaveMax				; Has the list gotten too long?
-			stb		r0,SAVflags+2(r8)			; Mark savearea free
-			stw		r8,lclfree(r9)				; Chain us on in
-			stw		r7,lclfreecnt(r9)			; Bump up the count
-			bgt-	srtrim						; List is too long, go trim it...
-			
-			btlr	cr1_eq						; Leave if we were a physical request...
+			stb		r0,SAVflags+2(r3)			; Mark savearea free
+			std		r3,lclfree(r10)				; Chain us on in
+			stw		r7,lclfreecnt(r10)			; Bump up the count
+			bltlr++								; List not too long, so done
 			
-			mtmsr	r12							; Restore translation and exceptions
-			isync								; Make sure about it
-	
-#if FPVECDBG
-			lis		r0,HIGH_ADDR(CutTrace)		; (TEST/DEBUG)
-			li		r2,0x2204					; (TEST/DEBUG)
-			mr		r3,r8						; (TEST/DEBUG)
-			oris	r0,r0,LOW_ADDR(CutTrace)	; (TEST/DEBUG) 
-			sc									; (TEST/DEBUG) 
-#endif
-			blr									; Leave...
-
-;
-;			The local savearea chain has gotten too long.  Trim it down to the target.
-;			Note: never trim the first one, just skip over it.
-;
-
-			.align	5
+/*			The local savearea chain has gotten too long.  Trim it down to the target.
+ *			Here's a tricky bit, and important:
+ *
+ *			When we trim the list, we NEVER trim the very first one.  This is because that is
+ *			the very last one released and the exception exit code will release the savearea
+ *			BEFORE it is done using it. Wouldn't be too good if another processor started
+ *			using it, eh?  So for this case, we are safe so long as the savearea stays on
+ *			the local list.  (Note: the exit routine needs to do this because it is in the 
+ *			process of restoring all context and it needs to keep it until the last second.)
+ */
 
-srtrim:		
-			mr		r2,r8						; Save the guy we are releasing
-			lwz		r8,SAVprev(r8)				; Skip over the first
+            mflr	r0							; save return to caller of saveRet64
+			mr		r2,r3						; r2 <- 1st one on local list, which must not be trimmed
+			ld		r3,SAVprev(r3)				; Skip over the first
 			subi	r7,r7,LocalSaveTarget		; Figure out how much to trim	
-			mr		r6,r8						; Save the first one to trim
+			mr		r6,r3						; r6 <- first one to trim
 			mr		r5,r7						; Save the number we are trimming
 			
-srtrimming:	addic.	r7,r7,-1					; Any left to do?
-			ble-	srtrimmed					; Nope...
-			lwz		r8,SAVprev(r8)				; Skip to the next one
-			b		srtrimming					; Keep going...
+saveRet64a:
+            addic.	r7,r7,-1					; Any left to do?
+			ble--	saveRet64b					; Nope...
+			ld		r3,SAVprev(r3)				; Skip to the next one
+			b		saveRet64a					; Keep going...
 			
-			.align	5
-
-srtrimmed:	lis		r10,hi16(EXT(saveanchor))	; Get the high part of the anchor	
-			lwz		r7,SAVprev(r8)				; Point to the next one
-			ori		r10,r10,lo16(EXT(saveanchor))	; Bottom half of the anchor 
+saveRet64b:										; r3 <- last one to trim
+			ld		r7,SAVprev(r3)				; Point to the first one not to trim
 			li		r4,LocalSaveTarget			; Set the target count
-			stw		r7,SAVprev(r2)				; Trim stuff leaving the one just released as first
-			stw		r4,lclfreecnt(r9)			; Set the current count
+			std		r7,SAVprev(r2)				; Trim stuff leaving the one just released as first
+			stw		r4,lclfreecnt(r10)			; Set the current count
 			
-			mflr	r9							; Save the return
 			bl		savelock					; Lock up the anchor
 			
-			lwz		r3,SVfree(r10)				; Get the old head of the free list
-			lwz		r4,SVfreecnt(r10)			; Get the number of free ones
-			lwz		r7,SVinuse(r10)				; Get the number that are in use
-			stw		r6,SVfree(r10)				; Point to the first trimmed savearea
+			ld		r8,SVfree(0)				; Get the old head of the free list
+			lwz		r4,SVfreecnt(0)				; Get the number of free ones
+			lwz		r7,SVinuse(0)				; Get the number that are in use
+			std		r6,SVfree(0)				; Point to the first trimmed savearea
 			add		r4,r4,r5					; Add number trimmed to free count
-			stw		r3,SAVprev(r8)				; Chain the old head to the tail of the trimmed guys
+			std		r8,SAVprev(r3)				; Chain the old head to the tail of the trimmed guys
 			sub		r7,r7,r5					; Remove the trims from the in use count
-			stw		r4,SVfreecnt(r10)			; Set new free count
-			stw		r7,SVinuse(r10)				; Set new in use count
-
-			bl		saveunlock					; Set adjust count and unlock the saveanchor
+			stw		r4,SVfreecnt(0)				; Set new free count
+			stw		r7,SVinuse(0)				; Set new in use count
 
-			mtlr	r9							; Restore the return
+			mtlr	r0							; Restore the return to our caller
+			b		saveunlock					; Set adjust count, unlock the saveanchor, and return
+            
 
-			btlr+	cr1_eq						; Leave if we were a physical request...
+/*
+ * *********************
+ * * s a v e R e t 3 2 *
+ * *********************
+ *
+ *			This is the internal routine to free a savearea, passed by 32-bit physical
+ *			address.  We assume that IR, DR, and EE are all off, and:
+ *				r3 = phys address of the savearea
+ *			   r10 = per-proc ptr
+ *			We destroy:
+ *				r0,r2-r8.
+ */
+            .align	5
+ saveRet32:
+			li		r0,SAVempty					; Get marker for free savearea
+			lwz		r7,lclfreecnt(r10)			; Get the local count
+			lwz		r6,lclfree+4(r10)			; Get the old local header
+			addi	r7,r7,1						; Pop up the free count
+			stw		r6,SAVprev+4(r3)			; Plant free chain pointer
+			cmplwi	r7,LocalSaveMax				; Has the list gotten too long?
+			stb		r0,SAVflags+2(r3)			; Mark savearea free
+			stw		r3,lclfree+4(r10)			; Chain us on in
+			stw		r7,lclfreecnt(r10)			; Bump up the count
+			bltlr+								; List not too long, so done
 			
-			mtmsr	r12							; Restore translation and exceptions
-			isync								; Make sure about it
-	
-#if FPVECDBG
-			lis		r0,HIGH_ADDR(CutTrace)		; (TEST/DEBUG)
-			mr		r3,r2						; (TEST/DEBUG)
-			li		r2,0x2205					; (TEST/DEBUG)
-			oris	r0,r0,LOW_ADDR(CutTrace)	; (TEST/DEBUG) 
-			sc									; (TEST/DEBUG) 
-#endif
-			blr									; Leave...
-
+/*			The local savearea chain has gotten too long.  Trim it down to the target.
+ *			Here's a tricky bit, and important:
+ *
+ *			When we trim the list, we NEVER trim the very first one.  This is because that is
+ *			the very last one released and the exception exit code will release the savearea
+ *			BEFORE it is done using it. Wouldn't be too good if another processor started
+ *			using it, eh?  So for this case, we are safe so long as the savearea stays on
+ *			the local list.  (Note: the exit routine needs to do this because it is in the 
+ *			process of restoring all context and it needs to keep it until the last second.)
+ */
 
-;
-;			NOTE: This is the most complicated part of savearea maintainence. 
-;			      Expect errors here.......
-;
-;			save_trim_free - this routine will trim the free list down to the target count.
-;			It trims the list and, if the pool page was fully allocated, puts that page on 
-;			the start of the pool list.
-;
-;			If the savearea being released is the last on a pool page (i.e., all entries
-;			are released), the page is dequeued from the pool and queued to any other 
-;			found during this scan.  Note that this queue is maintained virtually.
-;
-;			When the scan is done, the saveanchor lock is released and the list of
-;			freed pool pages is returned.
+            mflr	r0							; save return to caller of saveRet32
+			mr		r2,r3						; r2 <- 1st one on local list, which must not be trimmed
+			lwz		r3,SAVprev+4(r3)			; Skip over the first
+			subi	r7,r7,LocalSaveTarget		; Figure out how much to trim	
+			mr		r6,r3						; r6 <- first one to trim
+			mr		r5,r7						; Save the number we are trimming
+			
+saveRet32a:
+            addic.	r7,r7,-1					; Any left to do?
+			ble-	saveRet32b					; Nope...
+			lwz		r3,SAVprev+4(r3)			; Skip to the next one
+			b		saveRet32a					; Keep going...
+			
+saveRet32b:										; r3 <- last one to trim
+			lwz		r7,SAVprev+4(r3)			; Point to the first one not to trim
+			li		r4,LocalSaveTarget			; Set the target count
+			stw		r7,SAVprev+4(r2)			; Trim stuff leaving the one just released as first
+			stw		r4,lclfreecnt(r10)			; Set the current count
+			
+			bl		savelock					; Lock up the anchor
+			
+			lwz		r8,SVfree+4(0)				; Get the old head of the free list
+			lwz		r4,SVfreecnt(0)				; Get the number of free ones
+			lwz		r7,SVinuse(0)				; Get the number that are in use
+			stw		r6,SVfree+4(0)				; Point to the first trimmed savearea
+			add		r4,r4,r5					; Add number trimmed to free count
+			stw		r8,SAVprev+4(r3)			; Chain the old head to the tail of the trimmed guys
+			sub		r7,r7,r5					; Remove the trims from the in use count
+			stw		r4,SVfreecnt(0)				; Set new free count
+			stw		r7,SVinuse(0)				; Set new in use count
 
+			mtlr	r0							; Restore the return to our caller
+			b		saveunlock					; Set adjust count, unlock the saveanchor, and return
 
-;			For latency sake we may want to revisit this code. If we are trimming a
-;			large number of saveareas, we could be disabled and holding the savearea lock
-;			for quite a while.  It may be that we want to break the trim down into parts.
-;			Possibly trimming the free list, then individually pushing them into the free pool.
-;
-;			This function expects to be called with translation on and a valid stack.
-;
 
+/*
+ * *******************************
+ * * s a v e _ t r i m _ f r e e *
+ * *******************************
+ *
+ *	struct savearea_comm	*save_trim_free(void);
+ *
+ *			Trim the free list down to the target count, ie by -(SVadjust) save areas.
+ *			It trims the list and, if a pool page was fully allocated, puts that page on 
+ *			the start of the pool list.
+ *
+ *			If the savearea being released is the last on a pool page (i.e., all entries
+ *			are released), the page is dequeued from the pool and queued to any other 
+ *			found during this scan.  Note that this queue is maintained virtually.
+ *
+ *			When the scan is done, the saveanchor lock is released and the list of
+ *			freed pool pages is returned to our caller.
+ *
+ *			For latency sake we may want to revisit this code. If we are trimming a
+ *			large number of saveareas, we could be disabled and holding the savearea lock
+ *			for quite a while.  It may be that we want to break the trim down into parts.
+ *			Possibly trimming the free list, then individually pushing them into the free pool.
+ *
+ *			This function expects to be called with translation on and a valid stack.
+ *			It uses the standard ABI, ie we destroy r2 and r3-r11, and return the ptr in r3.
+ */
 			.align	5
 			.globl	EXT(save_trim_free)
 
 LEXT(save_trim_free)
 
 			subi	r1,r1,(FM_ALIGN(16)+FM_SIZE)	; Make space for 4 registers on stack
-			mfsprg	r9,2						; Get the feature flags
+            mflr	r9							; save our return address
 			stw		r28,FM_SIZE+0(r1)			; Save R28
-			mfmsr	r12							; Get the MSR 
-			rlwinm	r12,r12,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-			rlwinm	r12,r12,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-			stw		r29,FM_SIZE+4(r1)			; Save R28
-			mtcrf	0x04,r9						; Set the features			
-			stw		r30,FM_SIZE+8(r1)			; Save R28
-			lis		r10,hi16(EXT(saveanchor))	; Get the high part of the anchor	
-			stw		r31,FM_SIZE+12(r1)			; Save R28
-			andi.	r3,r12,0x7FCF				; Turn off all translation and rupts
-			ori		r10,r10,lo16(EXT(saveanchor))	; Bottom half of the anchor 
-			mflr	r9							; Save the return
-
-			bt		pfNoMSRirb,stNoMSR			; No MSR...
-
-			mtmsr	r3							; Translation and all off
-			isync								; Toss prefetch
-			b		stNoMSRx
-			
-			.align	5
-			
-stNoMSR:	li		r0,loadMSR					; Get the MSR setter SC
-			sc									; Set it
-			
-stNoMSRx:	bl		savelock					; Go lock up the anchor
+			stw		r29,FM_SIZE+4(r1)			; Save R29
+			stw		r30,FM_SIZE+8(r1)			; Save R30
+			stw		r31,FM_SIZE+12(r1)			; Save R31
+
+            bl		saveSetup					; turn off translation and interrupts, load many regs
+            bl		savelock					; Go lock up the anchor
 
-			lwz		r8,SVadjust(r10)			; How many do we need to clear out?
+			lwz		r8,SVadjust(0)				; How many do we need to clear out?
 			li		r3,0						; Get a 0
 			neg.	r8,r8						; Get the actual we need to toss (adjust is neg if too many)
-			lwz		r7,SVfree(r10)				; Get the first on the free list
-			bgt+	stneedtrim					; Yeah, we still need it...
-			
-			mtlr	r9							; Restore return
-			stw		r3,SVlock(r10)				; Quick unlock (no need for sync or to set adjust, nothing changed)
+            ble-	save_trim_free1				; skip if no trimming needed anymore
+            bf--	pf64Bitb,saveTrim32			; handle 32-bit processors
+            b		saveTrim64					; handle 64-bit processors
 
-			mtmsr	r12							; Restore translation and exceptions
-			isync								; Make sure about it
+save_trim_free1:								; by the time we were called, no need to trim anymore			
+			stw		r3,SVlock(0)				; Quick unlock (no need for sync or to set adjust, nothing changed)
+			mtlr	r9							; Restore return
 	
 #if FPVECDBG
 			lis		r0,HIGH_ADDR(CutTrace)		; (TEST/DEBUG)
@@ -609,34 +834,42 @@ stNoMSRx:	bl		savelock					; Go lock up the anchor
 			oris	r0,r0,LOW_ADDR(CutTrace)	; (TEST/DEBUG) 
 			sc									; (TEST/DEBUG) 
 #endif
-			addi	r1,r1,(FM_ALIGN(16)+FM_SIZE)	; Pop stack - have not trashed register so no need to reload
-			blr									; Leave...
+			addi	r1,r1,(FM_ALIGN(16)+FM_SIZE); Pop stack - have not trashed register so no need to reload
+			b		saveRestore					; restore translation and EE, turn SF off, return to our caller
 
-			.align	5
-			
-stneedtrim:	mr		r6,r7						; Save the first one 
+
+/*
+ * ***********************
+ * * s a v e T r i m 3 2 *
+ * ***********************
+ *
+ *	Handle "save_trim_free" on 32-bit processors.  At this point, translation and interrupts
+ *  are off, the savearea anchor is locked, and:
+ *		 r8 = #pages to trim (>0)
+ *	     r9 = return address
+ *	 	r10 = per-proc ptr
+ *		r11 = MSR at entry
+ */
+
+saveTrim32:	
+			lwz		r7,SVfree+4(0)				; Get the first on the free list
+            mr		r6,r7						; Save the first one 
 			mr		r5,r8						; Save the number we are trimming
 			
-			nop
-			nop
-			
 sttrimming:	addic.	r5,r5,-1					; Any left to do?
 			ble-	sttrimmed					; Nope...
-			lwz		r7,SAVprev(r7)				; Skip to the next one
+			lwz		r7,SAVprev+4(r7)			; Skip to the next one
 			b		sttrimming					; Keep going...
-			
-			.align	5
 
-sttrimmed:	lwz		r5,SAVprev(r7)				; Get the next one (for new head of free list)
-			lwz		r4,SVfreecnt(r10)			; Get the free count
-			stw		r5,SVfree(r10)				; Set new head
+sttrimmed:	lwz		r5,SAVprev+4(r7)			; Get the next one (for new head of free list)
+			lwz		r4,SVfreecnt(0)				; Get the free count
+			stw		r5,SVfree+4(0)				; Set new head
 			sub		r4,r4,r8					; Calculate the new free count
 			li		r31,0						; Show we have no free pool blocks yet
-			cmplwi	cr1,r5,0					; Make sure this is not equal
-			stw		r4,SVfreecnt(r10)			; Set new free count
+			crclr	cr1_eq						; dont exit loop before 1st iteration
+			stw		r4,SVfreecnt(0)				; Set new free count
 			lis		r30,hi16(sac_empty)			; Get what empty looks like
 			
-;
 ;			NOTE: The savearea size must be 640 (0x280).  We are doing a divide by shifts and stuff
 ;			here.
 ;
@@ -644,6 +877,17 @@ sttrimmed:	lwz		r5,SAVprev(r7)				; Get the next one (for new head of free list)
 #error Savearea size is not 640!!!!!!!!!!!!
 #endif
 
+            ; Loop over each savearea we are trimming.
+            ;	 r6 = next savearea to trim
+            ;	 r7 = last savearea to trim
+            ;	 r8 = #pages to trim (>0)
+            ;    r9 = return address
+            ;	r10 = per-proc ptr
+            ;	r11 = MSR at entry
+            ;	r30 = what SACalloc looks like when all saveareas are free
+            ;	r31 = free pool block list
+            ;	cr1 = beq set if we just trimmed the last, ie if we are done
+
 sttoss:		beq+	cr1,stdone					; All done now...
 
 			cmplw	cr1,r6,r7					; Have we finished the loop?
@@ -661,7 +905,7 @@ sttoss:		beq+	cr1,stdone					; All done now...
 			srw		r4,r4,r0					; Get the allocation mask
 			or		r5,r5,r4					; Free this entry
 			cmplw	r5,r4						; Is this the only free entry?
-			lwz		r6,SAVprev(r6)				; Chain to the next trimmed savearea
+			lwz		r6,SAVprev+4(r6)			; Chain to the next trimmed savearea
 			cmplw	cr7,r30,r5					; Does this look empty?
 			stw		r5,SACalloc(r2)				; Save back the allocation bits
 			beq-	stputpool					; First free entry, go put it into the pool...
@@ -673,19 +917,19 @@ sttoss:		beq+	cr1,stdone					; All done now...
 			
 			lwz		r29,SACflags(r2)			; Get the flags
 			cmplwi	cr5,r31,0					; Is this guy on the release list?
-			lwz		r28,SACnext(r2)				; Get the forward chain
+			lwz		r28,SACnext+4(r2)			; Get the forward chain
 
 			rlwinm.	r0,r29,0,sac_permb,sac_permb	; Is this a permanently allocated area? (also sets 0 needed below)
 			bne-	sttoss						; This is permanent entry, do not try to release...
 
-			lwz		r29,SACprev(r2)				; and the previous
+			lwz		r29,SACprev+4(r2)			; and the previous
 			beq-	cr5,stnot1st				; Not first
-			lwz		r0,SACvrswap(r31)			; Load the previous pool page vr conversion
+			lwz		r0,SACvrswap+4(r31)			; Load the previous pool page vr conversion
 			
-stnot1st:	stw		r28,SACnext(r29)			; Previous guy points to my next
+stnot1st:	stw		r28,SACnext+4(r29)			; Previous guy points to my next
 			xor		r0,r0,r31					; Make the last guy virtual
-			stw		r29,SACprev(r28)			; Next guy points back to my previous 			
-			stw		r0,SAVprev(r2)				; Store the old top virtual as my back chain
+			stw		r29,SACprev+4(r28)			; Next guy points back to my previous 			
+			stw		r0,SAVprev+4(r2)			; Store the old top virtual as my back chain
 			mr		r31,r2						; My physical is now the head of the chain
 			b		sttoss						; Get the next one...
 			
@@ -693,31 +937,136 @@ stnot1st:	stw		r28,SACnext(r29)			; Previous guy points to my next
 ;			A pool block that had no free entries now has one.  Stick it on the pool list.
 ;
 			
-			.align	5
-			
-stputpool:	lwz		r28,SVpoolfwd(r10)			; Get the first guy on the list
-			stw		r2,SVpoolfwd(r10)			; Put us on the top of the list
-			stw		r28,SACnext(r2)				; We point to the old top
-			stw		r2,SACprev(r28)				; Old top guy points back to us
-			stw		r10,SACprev(r2)				; Our back points to the anchor
+stputpool:	lwz		r28,SVpoolfwd+4(0)			; Get the first guy on the list
+			li		r0,saveanchor				; Point to the saveanchor
+			stw		r2,SVpoolfwd+4(0)			; Put us on the top of the list
+			stw		r28,SACnext+4(r2)			; We point to the old top
+			stw		r2,SACprev+4(r28)			; Old top guy points back to us
+			stw		r0,SACprev+4(r2)			; Our back points to the anchor
 			b		sttoss						; Go on to the next one...
+
+
+/*
+ * ***********************
+ * * s a v e T r i m 6 4 *
+ * ***********************
+ *
+ *	Handle "save_trim_free" on 64-bit processors.  At this point, translation and interrupts
+ *  are off, SF is on, the savearea anchor is locked, and:
+ *		 r8 = #pages to trim (>0)
+ *	     r9 = return address
+ *	 	r10 = per-proc ptr
+ *		r11 = MSR at entry
+ */
+
+saveTrim64:	
+			ld		r7,SVfree(0)				; Get the first on the free list
+            mr		r6,r7						; Save the first one 
+			mr		r5,r8						; Save the number we are trimming
 			
-;
-;			We are all done.  Relocate pool release head, restore all, and go.
-;			
+sttrimming64:	
+            addic.	r5,r5,-1					; Any left to do?
+			ble--	sttrimmed64					; Nope...
+			ld		r7,SAVprev(r7)				; Skip to the next one
+			b		sttrimming64				; Keep going...
 
-			.align	5
+sttrimmed64:
+            ld		r5,SAVprev(r7)				; Get the next one (for new head of free list)
+			lwz		r4,SVfreecnt(0)				; Get the free count
+			std		r5,SVfree(0)				; Set new head
+			sub		r4,r4,r8					; Calculate the new free count
+			li		r31,0						; Show we have no free pool blocks yet
+			crclr	cr1_eq						; dont exit loop before 1st iteration
+			stw		r4,SVfreecnt(0)				; Set new free count
+			lis		r30,hi16(sac_empty)			; Get what empty looks like
 			
+
+            ; Loop over each savearea we are trimming.
+            ;	 r6 = next savearea to trim
+            ;	 r7 = last savearea to trim
+            ;	 r8 = #pages to trim (>0)
+            ;    r9 = return address
+            ;	r10 = per-proc ptr
+            ;	r11 = MSR at entry
+            ;	r30 = what SACalloc looks like when all saveareas are free
+            ;	r31 = free pool block list
+            ;	cr1 = beq set if we just trimmed the last, ie if we are done
+            ;
+            ; WARNING: as in the 32-bit path, this code is doing a divide by 640 (SAVsize).
+
+sttoss64:
+            beq++	cr1,stdone					; All done now...
+
+			cmpld	cr1,r6,r7					; Have we finished the loop?
+
+			lis		r0,0x0044					; Get top of table	
+			rldicr	r2,r6,0,51					; r2 <- phys addr of savearea block (with control area)
+			ori		r0,r0,0x2200				; Finish shift table
+			rlwinm	r4,r6,25,27,30				; Get (addr >> 7) & 0x1E (same as twice high nybble)
+			lwz		r5,SACalloc(r2)				; Get the allocation bits
+			addi	r4,r4,1						; Shift 1 extra
+			rlwinm	r3,r6,25,31,31				; Get (addr >> 7) & 1
+			rlwnm	r0,r0,r4,29,31				; Get partial index
+			lis		r4,lo16(0x8000)				; Get the bit mask
+			add		r0,r0,r3					; Make the real index
+			srw		r4,r4,r0					; Get the allocation mask
+			or		r5,r5,r4					; Free this entry
+			cmplw	r5,r4						; Is this the only free entry?
+			ld		r6,SAVprev(r6)				; Chain to the next trimmed savearea
+			cmplw	cr7,r30,r5					; Does this look empty?
+			stw		r5,SACalloc(r2)				; Save back the allocation bits
+			beq--	stputpool64					; First free entry, go put it into the pool...
+			bne++	cr7,sttoss64				; Not an empty block
+			
+;			We have an empty block.  Remove it from the pool list.
+			
+			lwz		r29,SACflags(r2)			; Get the flags
+			cmpldi	cr5,r31,0					; Is this guy on the release list?
+			ld		r28,SACnext(r2)				; Get the forward chain
+
+			rlwinm.	r0,r29,0,sac_permb,sac_permb	; Is this a permanently allocated area? (also sets 0 needed below)
+			bne--	sttoss64					; This is permanent entry, do not try to release...
+
+			ld		r29,SACprev(r2)				; and the previous
+			beq--	cr5,stnot1st64				; Not first
+			ld		r0,SACvrswap(r31)			; Load the previous pool page vr conversion
+			
+stnot1st64:	
+            std		r28,SACnext(r29)			; Previous guy points to my next
+			xor		r0,r0,r31					; Make the last guy virtual
+			std		r29,SACprev(r28)			; Next guy points back to my previous 			
+			std		r0,SAVprev(r2)				; Store the old top virtual as my back chain
+			mr		r31,r2						; My physical is now the head of the chain
+			b		sttoss64					; Get the next one...
+			
+;			A pool block that had no free entries now has one.  Stick it on the pool list.
+			
+stputpool64:
+            ld		r28,SVpoolfwd(0)			; Get the first guy on the list
+			li		r0,saveanchor				; Point to the saveanchor
+			std		r2,SVpoolfwd(0)				; Put us on the top of the list
+			std		r28,SACnext(r2)				; We point to the old top
+			std		r2,SACprev(r28)				; Old top guy points back to us
+			std		r0,SACprev(r2)				; Our back points to the anchor
+			b		sttoss64					; Go on to the next one...
+			
+
+;			We are all done.  Relocate pool release head, restore all, and go.  This code
+;			is used both by the 32 and 64-bit paths.
+;  				 r9 = return address
+;				r10 = per-proc ptr
+;				r11 = MSR at entry
+;				r31 = free pool block list
+
 stdone:		bl		saveunlock					; Unlock the saveanchor and set adjust field
 
 			mr.		r3,r31						; Move release chain and see if there are any
 			li		r5,0						; Assume either V=R or no release chain
 			beq-	stnorel						; Nothing to release...
-			lwz		r5,SACvrswap(r31)			; Get the vr conversion
-
-stnorel:	mtmsr	r12							; Restore translation and exceptions
-			isync								; Make sure about it
+			lwz		r5,SACvrswap+4(r31)			; Get the vr conversion (only need low half if 64-bit)
 
+stnorel:	
+            bl		saveRestore					; restore translation and exceptions, turn off SF
 			mtlr	r9							; Restore the return
 			
 			lwz		r28,FM_SIZE+0(r1)			; Restore R28
@@ -726,6 +1075,7 @@ stnorel:	mtmsr	r12							; Restore translation and exceptions
 			lwz		r31,FM_SIZE+12(r1)			; Restore R31
 			addi	r1,r1,(FM_ALIGN(16)+FM_SIZE)	; Pop the stack
 			xor		r3,r3,r5					; Convert release chain address to virtual
+            rlwinm	r3,r3,0,0,31				; if 64-bit, clear upper half of virtual address
 							
 #if FPVECDBG
 			lis		r0,HIGH_ADDR(CutTrace)		; (TEST/DEBUG)
@@ -734,70 +1084,69 @@ stnorel:	mtmsr	r12							; Restore translation and exceptions
 			sc									; (TEST/DEBUG) 
 #endif
 			blr									; Return...
-			
-;
-;			save_recover - here we scan the free pool and see if we can get
-;			enough free saveareas to hit target.
-;
-;			If we empty a pool block, remove it from the pool list
-;
-;
+            
+            
+/*
+ * ***************************
+ * * s a v e _ r e c o v e r *
+ * ***************************
+ *
+ *	int save_recover(void);
+ *
+ *	Returns nonzero if we can get enough saveareas to hit the target.  We scan the free
+ * 	pool.  If we empty a pool block, we remove it from the pool list.
+ */			
 			
 			.align	5
 			.globl	EXT(save_recover)
 
 LEXT(save_recover)
-			mfsprg	r9,2						; Get the feature flags
-			mfmsr	r12							; Get the MSR 
-			rlwinm	r12,r12,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-			rlwinm	r12,r12,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-			mtcrf	0x04,r9						; Set the features			
-			lis		r10,hi16(EXT(saveanchor))	; Get the high part of the anchor	
-			andi.	r3,r12,0x7FCF				; Turn off all translation and rupts
-			ori		r10,r10,lo16(EXT(saveanchor))	; Bottom half of the anchor 
-			mflr	r9							; Save the return
-
-			bt		pfNoMSRirb,srcNoMSR			; No MSR...
-
-			mtmsr	r3							; Translation and all off
-			isync								; Toss prefetch
-			b		srcNoMSRx
-			
-			.align	5
-			
-srcNoMSR:	li		r0,loadMSR					; Get the MSR setter SC
-			sc									; Set it
-			
-srcNoMSRx:	bl		savelock					; Go lock up the anchor
+            mflr	r9							; save return address
+            bl		saveSetup					; turn translation and interrupts off, SF on, load many regs
+            bl		savelock					; lock the savearea anchor
 
-			lwz		r8,SVadjust(r10)			; How many do we need to clear get?
+			lwz		r8,SVadjust(0)				; How many do we need to clear get?
 			li		r3,0						; Get a 0
 			mr.		r8,r8						; Do we need any?
-			bgt+	srcneedmore					; Yeah, we still need it...
-			
+            ble--	save_recover1				; not any more
+            bf--	pf64Bitb,saveRecover32		; handle 32-bit processor
+            b		saveRecover64				; handle 64-bit processor
+            
+save_recover1:									; by the time we locked the anchor, no longer short
 			mtlr	r9							; Restore return
-			stw		r3,SVlock(r10)				; Quick unlock (no need for sync or to set adjust, nothing changed)
-
-			mtmsr	r12							; Restore translation and exceptions
-			isync								; Make sure about it
-	
+			stw		r3,SVlock(0)				; Quick unlock (no need for sync or to set adjust, nothing changed)
 #if FPVECDBG
 			lis		r0,HIGH_ADDR(CutTrace)		; (TEST/DEBUG)
 			li		r2,0x2208					; (TEST/DEBUG)
 			oris	r0,r0,LOW_ADDR(CutTrace)	; (TEST/DEBUG) 
 			sc									; (TEST/DEBUG) 
 #endif
-			blr									; Leave...
+			b		saveRestore					; turn translation etc back on, return to our caller
 
-			.align	5
-	
-srcneedmore:
-			mr		r6,r10						; Start at pool anchor
-			cmplwi	cr1,r10,0					; Make sure we start as not equal					
-			lwz		r7,SVfreecnt(r10)			; Get the current free count
-			
-srcnpool:	lwz		r6,SACnext(r6)				; Point to the next one
-			cmplw	r6,r10						; Have we wrapped?
+
+/*
+ * *****************************
+ * * s a v e R e c o v e r 3 2 *
+ * *****************************
+ *
+ *	Handle "save_recover" on 32-bit processors.  At this point, translation and interrupts
+ *  are off, the savearea anchor is locked, and:
+ *		 r8 = #pages to recover
+ *	     r9 = return address
+ *	 	r10 = per-proc ptr
+ *		r11 = MSR at entry
+ */
+
+saveRecover32:
+			li		r6,saveanchor				; Start at pool anchor
+			crclr	cr1_eq						; initialize the loop test					
+			lwz		r7,SVfreecnt(0)				; Get the current free count
+
+
+; Loop over next block in free pool.  r6 is the ptr to the last block we looked at.
+
+srcnpool:	lwz		r6,SACnext+4(r6)			; Point to the next one
+			cmplwi	r6,saveanchor				; Have we wrapped?
 			beq-	srcdone						; Yes, did not have enough...
 			
 			lwz		r5,SACalloc(r6)				; Pick up the allocation for this pool block
@@ -810,6 +1159,16 @@ srcnpool:	lwz		r6,SACnext(r6)				; Point to the next one
 #error Savearea size is not 640!!!!!!!!!!!!
 #endif
 
+; Loop over free savearea in current block.
+;		 r5 = bitmap of free saveareas in block at r6 (ie, SACalloc)
+;		 r6 = ptr to current free pool block
+;		 r7 = free count
+;		 r8 = #pages more we still need to recover
+;	     r9 = return address
+;	 	r10 = per-proc ptr
+;		r11 = MSR at entry
+;		cr1 = beq if (r8==0)
+
 srcnext:	beq-	cr1,srcdone					; We have no more to get...
 
 			lis		r3,0x8000					; Get the top bit on
@@ -825,130 +1184,273 @@ srcnext:	beq-	cr1,srcdone					; We have no more to get...
 			stw		r5,SACalloc(r6)				; Set new allocation bits
 			
 			add		r2,r2,r6					; Get the actual address of the savearea
-			lwz		r3,SVfree(r10)				; Get the head of the chain
+			lwz		r3,SVfree+4(0)				; Get the head of the chain
 			cmplwi	cr1,r8,0					; Do we actually need any more?
-			stw		r2,SVfree(r10)				; Push ourselves in the front
-			stw		r3,SAVprev(r2)				; Chain the rest of the list behind 
+			stw		r2,SVfree+4(0)				; Push ourselves in the front
+			stw		r3,SAVprev+4(r2)			; Chain the rest of the list behind 
 			
 			bne+	srcnext						; The pool block is not empty yet, try for another...
 			
-			lwz		r2,SACnext(r6)				; Get the next pointer
-			lwz		r3,SACprev(r6)				; Get the previous pointer
-			stw		r3,SACprev(r2)				; The previous of my next points to my previous
-			stw		r2,SACnext(r3)				; The next of my previous points to my next
+			lwz		r2,SACnext+4(r6)			; Get the next pointer
+			lwz		r3,SACprev+4(r6)			; Get the previous pointer
+			stw		r3,SACprev+4(r2)			; The previous of my next points to my previous
+			stw		r2,SACnext+4(r3)			; The next of my previous points to my next
 			bne+	cr1,srcnpool				; We still have more to do...
-			
-srcdone:	stw		r7,SVfreecnt(r10)			; Set the new free count
+
+
+; Join here from 64-bit path when we have recovered all the saveareas we need to.
+
+srcdone:	stw		r7,SVfreecnt(0)				; Set the new free count
 			bl		saveunlock					; Unlock the save and set adjust field
 
 			mtlr	r9							; Restore the return
-			mtmsr	r12							; Restore translation and exceptions
-			isync								; Make sure about it
-	
 #if FPVECDBG
 			lis		r0,HIGH_ADDR(CutTrace)		; (TEST/DEBUG)
 			li		r2,0x2209					; (TEST/DEBUG)
 			oris	r0,r0,LOW_ADDR(CutTrace)	; (TEST/DEBUG) 
 			sc									; (TEST/DEBUG) 
 #endif
-			blr									; Leave...
+			b		saveRestore					; turn xlate and EE back on, SF off, and return to our caller
+
+
+/*
+ * *****************************
+ * * s a v e R e c o v e r 6 4 *
+ * *****************************
+ *
+ *	Handle "save_recover" on 64-bit processors.  At this point, translation and interrupts
+ *  are off, the savearea anchor is locked, and:
+ *		 r8 = #pages to recover
+ *	     r9 = return address
+ *	 	r10 = per-proc ptr
+ *		r11 = MSR at entry
+ */
+
+saveRecover64:
+			li		r6,saveanchor				; Start at pool anchor
+			crclr	cr1_eq						; initialize the loop test					
+			lwz		r7,SVfreecnt(0)				; Get the current free count
+
+
+; Loop over next block in free pool.  r6 is the ptr to the last block we looked at.
+
+srcnpool64:	
+            ld		r6,SACnext(r6)				; Point to the next one
+			cmpldi	r6,saveanchor				; Have we wrapped?
+			beq--	srcdone						; Yes, did not have enough...
 			
+			lwz		r5,SACalloc(r6)				; Pick up the allocation for this pool block
+			
+
+; Loop over free savearea in current block.
+;		 r5 = bitmap of free saveareas in block at r6 (ie, SACalloc)
+;		 r6 = ptr to current free pool block
+;		 r7 = free count
+;		 r8 = #pages more we still need to recover
+;	     r9 = return address
+;	 	r10 = per-proc ptr
+;		r11 = MSR at entry
+;		cr1 = beq if (r8==0)
 ;
-;			Here is where we lock the saveanchor lock
-;			We assume R10 points to the saveanchor
-;			We trash R7 and R3
-;
+; WARNING: as in the 32-bit path, we depend on (SAVsize==640)
 
-			.align	5
-	
-savelock:	lwarx	r7,0,r10					; Grab the lock value 
-			li		r3,1						; Use part of the delay time 
-			mr.		r7,r7						; Is it locked? */
-			bne-	sllcks						; Yeah, wait for it to clear...
-			stwcx.	r3,0,r10					; Try to seize that there durn lock
-			beq+	sllckd						; Got it...
-			b		savelock					; Collision, try again...
+srcnext64:	
+            beq--	cr1,srcdone					; We have no more to get...
 
-			.align	5
+			lis		r3,0x8000					; Get the top bit on
+			cntlzw	r4,r5						; Find a free slot
+			addi	r7,r7,1						; Bump up the free count
+			srw		r3,r3,r4					; Make a mask
+			slwi	r0,r4,7						; First multiply by 128
+			subi	r8,r8,1						; Decrement the need count
+			slwi	r2,r4,9						; Then multiply by 512
+			andc.	r5,r5,r3					; Clear out the "free" bit
+			add		r2,r2,r0					; Sum to multiply by 640	
 			
-sllcks:		lwz		r7,SVlock(r10)				; Get that lock in here
-			mr.		r7,r7						; Is it free yet?
-			beq+	savelock					; Yeah, try for it again...
-			b		sllcks						; Sniff away...
+			stw		r5,SACalloc(r6)				; Set new allocation bits
+			
+			add		r2,r2,r6					; Get the actual address of the savearea
+			ld		r3,SVfree(0)				; Get the head of the chain
+			cmplwi	cr1,r8,0					; Do we actually need any more?
+			std		r2,SVfree(0)				; Push ourselves in the front
+			std		r3,SAVprev(r2)				; Chain the rest of the list behind 
 			
-			nop									; Force isync to last in ifetch buffer
-			nop
-			nop
+			bne++	srcnext64					; The pool block is not empty yet, try for another...
 			
-sllckd:		isync								; Make sure translation is off
-			blr									; Return....
-
+			ld		r2,SACnext(r6)				; Get the next pointer
+			ld		r3,SACprev(r6)				; Get the previous pointer
+			std		r3,SACprev(r2)				; The previous of my next points to my previous
+			std		r2,SACnext(r3)				; The next of my previous points to my next
+			bne++	cr1,srcnpool64				; We still have more to do...
+            
+            b		srcdone
 
-;
-;			This is the common routine that sets the saveadjust field and unlocks the savearea 
-;			anchor.
-;			
-;			Note that we can not use R9 here because we use it to save the LR across the call.
-;			Also, R10 is assumed to point to the saveanchor. R3 is also reserved.
-;
 
+/* 
+ * *******************
+ * * s a v e l o c k *
+ * *******************
+ *
+ *			Lock the savearea anchor, so we can manipulate the free list.
+ *              msr = interrupts and translation off
+ *			We destroy:
+ *				r8, r3, r12
+ */			
 			.align	5
 
+savelock:	lwz		r8,SVlock(0)				; See if lock is held
+            cmpwi	r8,0
+			li		r12,saveanchor				; Point to the saveanchor
+			bne--	savelock					; loop until lock released...
+		
+savelock0:	lwarx	r8,0,r12					; Grab the lock value 
+			cmpwi	r8,0						; taken?
+            li		r8,1						; get nonzero to lock it with
+			bne--	savelock1					; already locked, wait for it to clear...
+			stwcx.	r8,0,r12					; Try to seize that there durn lock
+            isync								; assume we got it
+            beqlr++								; reservation not lost, so we have the lock
+			b		savelock0					; Try again...
+			
+savelock1:	li		r8,lgKillResv				; Point to killing field
+			stwcx.	r8,0,r8						; Kill reservation
+			b		savelock					; Start over....
+		
+
+/*
+ * ***********************
+ * * s a v e u n l o c k *
+ * ***********************
+ *
+ *
+ *			This is the common routine that sets the saveadjust field and unlocks the savearea 
+ *			anchor.
+ *				msr = interrupts and translation off
+ *			We destroy:
+ *				r2, r5, r6, r8.
+ */
+			.align	5
 saveunlock:
-			lwz		r6,SVfreecnt(r10)			; and the number on the free list
-			lwz		r5,SVinuse(r10)				; Pick up the in use count
-			cmplwi	r6,FreeListMin				; Do we have at least the minimum?
-			blt-	sutooshort					; Do not have minumum....
-			lwz		r7,SVtarget(r10)			; Get the target
+			lwz		r6,SVfreecnt(0)				; and the number on the free list
+			lwz		r5,SVinuse(0)				; Pick up the in use count
+            subic.	r8,r6,FreeListMin			; do we have at least the minimum?
+			lwz		r2,SVtarget(0)				; Get the target
+            neg		r8,r8						; assuming we are short, get r8 <- shortfall
+            blt--	saveunlock1					; skip if fewer than minimum on free list
 			
 			add		r6,r6,r5					; Get the total number of saveareas
-			addi	r5,r7,-SaveLowHysteresis	; Find bottom
+			addi	r5,r2,-SaveLowHysteresis	; Find low end of acceptible range
 			sub		r5,r6,r5					; Make everything below hysteresis negative
-			sub		r7,r7,r6					; Get the distance from the target
-			rlwinm	r5,r5,0,0,31				; Clear negative bit
+			sub		r2,r2,r6					; Get the distance from the target
 			addi	r5,r5,-(SaveLowHysteresis + SaveHighHysteresis + 1)	; Subtract full hysteresis range
 			srawi	r5,r5,31					; Get 0xFFFFFFFF if outside range or 0 if inside
-			and		r7,r7,r5					; Get 0 if in range or distance to target if not
+			and		r8,r2,r5					; r8 <- 0 if in range or distance to target if not
 
-			li		r8,0						; Set a clear value
-			stw		r7,SVadjust(r10)			; Set the adjustment value			
-
-			sync								; Make sure everything is done
-			stw		r8,SVlock(r10)				; Unlock the savearea chain 
+saveunlock1:
+			li		r5,0						; Set a clear value
+			stw		r8,SVadjust(0)				; Set the adjustment value			
+			eieio								; Make sure everything is done
+			stw		r5,SVlock(0)				; Unlock the savearea chain 
 			blr
-			
-			.align	5
-			
-sutooshort:	subfic	r6,r6,FreeListMin			; Get the number needed to hit minimum
-			li		r8,0						; Set a clear value
-			stw		r6,SVadjust(r10)			; Set the adjustment value			
-
-			sync								; Make sure everything is done
-			stw		r8,SVlock(r10)				; Unlock the savearea chain 
-			blr
-
-
 
 
 /*
- *			struct savearea	*save_cpv(struct savearea *);	 Converts a physical savearea address to virtual
+ * *******************
+ * * s a v e _ c p v *
+ * *******************
+ *
+ *	struct savearea	*save_cpv(addr64_t saveAreaPhysAddr);
+ *
+ *          Converts a physical savearea address to virtual.  Called with translation on
+ *			and in 32-bit mode.  Note that the argument is passed as a long long in (r3,r4).
  */
 
 			.align	5
 			.globl	EXT(save_cpv)
 
 LEXT(save_cpv)
+            mflr	r9							; save return address
+            mr		r8,r3						; save upper half of phys address here
+            bl		saveSetup					; turn off translation and interrupts, turn SF on
+			rlwinm	r5,r4,0,0,19				; Round back to the start of the physical savearea block
+            bf--	pf64Bitb,save_cpv1			; skip if 32-bit processor
+            rldimi	r5,r8,32,0					; r5 <- 64-bit phys address of block
+save_cpv1:
+			lwz		r6,SACvrswap+4(r5)			; Get the conversion to virtual (only need low half if 64-bit)
+            mtlr	r9							; restore return address
+            xor		r3,r4,r6					; convert phys to virtual
+            rlwinm	r3,r3,0,0,31				; if 64-bit, zero upper half of virtual address
+            b		saveRestore					; turn translation etc back on, SF off, and return r3
+				
 			
-			mfmsr	r10							; Get the current MSR
-			rlwinm	r10,r10,0,MSR_FP_BIT+1,MSR_FP_BIT-1	; Force floating point off
-			rlwinm	r10,r10,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1	; Force vectors off
-			rlwinm	r4,r3,0,0,19				; Round back to the start of the physical savearea block
-			andi.	r9,r10,0x7FEF				; Turn off interrupts and data translation
-			mtmsr	r9							; Disable DR and EE
-			isync
-			
-			lwz		r4,SACvrswap(r4)			; Get the conversion to virtual
-			mtmsr	r10							; Interrupts and DR back on
-			isync
-			xor		r3,r3,r4					; Convert to physical
-			blr
+/*
+ * *********************
+ * * s a v e S e t u p *
+ * *********************
+ *
+ * This routine is called at the start of all the save-area subroutines.
+ * It turns off translation, disabled interrupts, turns on 64-bit mode,
+ * and sets up cr6 with the feature flags (especially pf64Bit).
+ * 
+ * Note that most save-area routines cannot take _any_ interrupt (such as a
+ * PTE miss) once the savearea anchor is locked, since that would result in
+ * instant deadlock as we need a save-area to process any exception.
+ * We set up:
+ *		r10 = per-proc ptr
+ *		r11 = old MSR
+ *		cr5 = pfNoMSRir feature flag
+ *		cr6 = pf64Bit   feature flag
+ *
+ * We use r0, r3, r10, and r11.
+ */
+ 
+saveSetup:
+            mfmsr	r11							; get msr
+			mfsprg	r3,2						; get feature flags
+			li		r0,0
+            mtcrf	0x2,r3						; copy pf64Bit to cr6
+            ori		r0,r0,lo16(MASK(MSR_IR)+MASK(MSR_DR)+MASK(MSR_EE))
+            mtcrf	0x4,r3						; copy pfNoMSRir to cr5
+            andc	r3,r11,r0					; turn off IR, DR, and EE
+            li		r0,1						; get a 1 in case its a 64-bit machine
+            bf--	pf64Bitb,saveSetup1			; skip if not a 64-bit machine
+			rldimi	r3,r0,63,MSR_SF_BIT			; turn SF (bit 0) on
+            mtmsrd	r3							; turn translation and interrupts off, 64-bit mode on
+            isync								; wait for it to happen
+            mfsprg	r10,0						; get per-proc ptr
+            blr
+saveSetup1:										; here on 32-bit machines
+            bt-		pfNoMSRirb,saveSetup2		; skip if cannot turn off IR with a mtmsr
+            mtmsr	r3							; turn translation and interrupts off
+            isync								; wait for it to happen
+            mfsprg	r10,0						; get per-proc ptr
+            blr
+saveSetup2:										; here if pfNoMSRir set for this machine
+            li		r0,loadMSR					; we will "mtmsr r3" via system call
+            sc
+            mfsprg	r10,0						; get per-proc ptr
+            blr
+        
+			
+/*
+ * *************************
+ * * s a v e R e s t o r e *
+ * *************************
+ *
+ * Undoes the effect of calling "saveSetup", ie it turns relocation and interrupts back on,
+ * and turns 64-bit mode back off.
+ *		r11 = old MSR
+ *		cr6 = pf64Bit   feature flag
+ */
+ 
+saveRestore:
+            bt++	pf64Bitb,saveRestore64		; handle a 64-bit processor
+saveRestore32:
+            mtmsr	r11							; restore MSR
+            isync								; wait for translation to start up
+            blr
+saveRestore64:									; 64-bit processor
+            mtmsrd	r11							; restore MSR
+            isync								; wait for changes to happen
+            blr
+
diff --git a/osfmk/ppc/sched_param.h b/osfmk/ppc/sched_param.h
index b6430899b..9a2fd0bf2 100644
--- a/osfmk/ppc/sched_param.h
+++ b/osfmk/ppc/sched_param.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ppc/screen_switch.h b/osfmk/ppc/screen_switch.h
index cbf92e7cf..8136071c5 100644
--- a/osfmk/ppc/screen_switch.h
+++ b/osfmk/ppc/screen_switch.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ppc/serial_console.c b/osfmk/ppc/serial_console.c
index 2e5768c74..54899e411 100644
--- a/osfmk/ppc/serial_console.c
+++ b/osfmk/ppc/serial_console.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -36,7 +39,6 @@
 #include <ppc/POWERMAC/video_console_entries.h>
 #include <ppc/misc_protos.h>
 #include <ppc/POWERMAC/serial_io.h>
-#include <ppc/POWERMAC/mp/mp.h>
 #include <kern/cpu_number.h>
 #include <ppc/Firmware.h>
 #include <ppc/proc_reg.h>
@@ -99,6 +101,7 @@ unsigned int killprint = 0;
 unsigned int debcnputc = 0;
 extern unsigned int	mappingdeb0;
 extern int debugger_holdoff[NCPUS];
+extern int debugger_cpu;
 
 static void _cnputc(char c)
 {
diff --git a/osfmk/ppc/serial_defs.h b/osfmk/ppc/serial_defs.h
index 508165fab..e58bd12bd 100644
--- a/osfmk/ppc/serial_defs.h
+++ b/osfmk/ppc/serial_defs.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ppc/setjmp.h b/osfmk/ppc/setjmp.h
index a1a0b34c4..88d639fa8 100644
--- a/osfmk/ppc/setjmp.h
+++ b/osfmk/ppc/setjmp.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ppc/skiplists.s b/osfmk/ppc/skiplists.s
new file mode 100644
index 000000000..4bb4a7808
--- /dev/null
+++ b/osfmk/ppc/skiplists.s
@@ -0,0 +1,1304 @@
+/*
+ * Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ * 
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ * 
+ * @APPLE_LICENSE_HEADER_END@
+ */
+
+/* skiplists.s
+ *
+ * These are the subroutines that manage the skip-list data structures used for the
+ * resident mappings for each pmap.  We used to use a much simpler hash-based scheme,
+ * but it didn't scale well for 64-bit address spaces and multi-GB real memories.
+ * Here's a brief tutorial on skip-lists:
+ *
+ * The basic idea is that each mapping is on one or more singly-linked lists, sorted
+ * in increasing order by virtual address.  The number of lists a mapping is on is an
+ * invariant property determined when the mapping is created, using an exponentially-
+ * distributed random number.  Every mapping is on the first list.  Ideally, each
+ * successive list has only 1/F as many nodes on it as the previous, where F is the
+ * "fanout."  With a max of n lists, up to F**n nodes can be handled optimally.
+ *
+ * Searching, adding, and deleting from a skip-list can all be done in O(ln(n)) time.
+ * Because the first skip-list is just a sorted list of all mappings, it is also
+ * efficient to purge a sparsely populated pmap of all the mappings in a large range,
+ * for example when tearing down an address space.  Large-range deletes are the
+ * primary advantage of skip-lists over a hash, btw.
+ *
+ * We currently use a fanout of 4 and a maximum of 12 lists (cf kSkipListFanoutShift
+ * and kSkipListMaxLists.)  Thus, we can optimally handle pmaps with as many as 4**12 
+ * pages, which is 64GB of resident physical memory per pmap.  Pmaps can be larger than
+ * this, albeit with diminishing efficiency.
+ *
+ * The major problem with skip-lists is that we could waste a lot of space with 12
+ * 64-bit link fields in every mapping.  So we currently have two sizes of mappings:
+ * 64-byte nodes with 4 list links, and 128-byte nodes with 12.  Only one in every
+ * (4**4)==256 mappings requires the larger node, so the average size is 64.25 bytes.
+ * In practice, the additional complexity of the variable node size is entirely
+ * contained in the allocate and free routines.
+ *
+ * The other, mostly theoretic problem with skip-lists is that they have worst cases
+ * where performance becomes nearly linear.  These worst-cases are quite rare but there
+ * is no practical way to prevent them.
+ */   
+ 
+
+; set nonzero to accumulate skip-list stats on a per-map basis:
+#define	SKIPLISTSTATS	1
+
+; cr7 bit set when mapSearchFull() finds a match on a high list:
+#define	bFullFound	28
+
+#include <assym.s>
+#include <debug.h>
+#include <ppc/asm.h>
+#include <ppc/proc_reg.h>
+#include <ppc/exception.h>
+
+
+/*
+ *  *********************
+ * 	* m a p S e a r c h *
+ *	*********************
+ *
+ * Given a pmap and a virtual address (VA), find the mapping for that address.
+ * This is the fast call, that does not set up the previous-ptr vector or make
+ * consistency checks.  When called:
+ *		the pmap is locked (shared or exclusive)
+ *		translation is off, interrupts masked
+ *		64-bit mode is enabled (if on a 64-bit machine)
+ *		cr6 is loaded with the corresponding feature flags (in particular, pf64Bit)
+ *		r3 = pmap ptr
+ *		r4 = high 32 bits of key to search for (0 if a 32-bit processor)
+ *		r5 = low 32 bits of key (low 12 bits may be nonzero garbage)
+ *		r7 = mpFlags field if found.  Undefined if not
+ *
+ * We return the mapping ptr (or 0) in r3, and the next VA (or 0 if no more) in r4 and r5.
+ * Except for cr6 (which is global), we trash nonvolatile regs.  Called both on 32- and 64-bit
+ * machines, though we quickly branch into parallel code paths.
+ */ 
+            .text
+			.align	5
+            .globl	EXT(mapSearch)
+LEXT(mapSearch)
+            lbz		r7,pmapCurLists(r3)		; get largest #lists any mapping is on
+            la		r8,pmapSkipLists+4(r3)	; point to lists in pmap, assuming 32-bit machine
+            rlwinm	r5,r5,0,0,19			; zero low 12 bits of key
+            mr		r6,r3					; save pmap ptr here so we can accumulate statistics
+            li		r9,0					; initialize prev ptr
+            addic.	r7,r7,-1				; get base-0 number of last list, and test for 0
+            li		r2,0					; initialize count of mappings visited
+            slwi	r7,r7,3					; get offset of last list in use
+            blt--	mapSrchPmapEmpty		; pmapCurLists==0 (ie, no mappings)
+            lwzx	r3,r8,r7				; get 32-bit ptr to 1st mapping in highest list
+            bf--	pf64Bitb,mapSrch32c		; skip if 32-bit processor
+            subi	r8,r8,4					; we use all 64 bits of ptrs
+            rldimi	r5,r4,32,0				; r5 <- 64-bit va
+            ldx		r3,r8,r7				; get 64-bit ptr to 1st mapping in highest list
+            b		mapSrch64c				; enter 64-bit search loop
+
+            
+            ; 64-bit processors.  Check next mapping.
+            ;   r2 = count of mappings visited so far
+            ;	r3 = current mapping ptr
+            ;	r4 = va of current mapping (ie, of r3)
+            ;	r5 = va to search for (the "key") (low 12 bits are 0)
+            ;	r6 = pmap ptr
+            ;	r7 = current skip list number * 8
+            ;	r8 = ptr to skip list vector of mapping pointed to by r9 (or pmap, if r9==0)
+            ;	r9 = prev ptr, or 0 if none
+            
+            .align	5
+mapSrch64a:									; loop over each mapping
+            ld		r4,mpVAddr(r3)			; get va for this mapping (plus flags in low 12 bits)
+            addi	r2,r2,1					; count mappings visited
+            rldicr	r4,r4,0,51				; zero low 12 bits of mapping va
+            cmpld	cr1,r5,r4				; compare the vas
+            blt		cr1,mapSrch64d			; key is less, try next list
+            la		r8,mpList0(r3)			; point to skip list vector in this mapping
+            mr		r9,r3					; remember prev ptr
+            beq--	cr1,mapSrch64Found		; this is the correct mapping
+            ldx		r3,r7,r8				; get ptr to next mapping in current list
+mapSrch64c:
+            mr.		r3,r3					; was there another mapping on current list?
+            bne++	mapSrch64a				; was another, so loop
+mapSrch64d:
+            subic.	r7,r7,8					; move on to next list offset
+            ldx		r3,r7,r8				; get next mapping on next list (if any)
+            bge++	mapSrch64c				; loop to try next list
+          
+            ; Mapping not found, check to see if prev node was a block mapping or nested pmap.
+            ; If not, or if our address is not covered by the block or nested map, return 0.
+            ; Note the advantage of keeping the check for block mappings (and nested pmaps)
+            ; out of the inner loop; we do the special case work at most once per search, and
+            ; never for the most-common case of finding a scalar mapping.  The full searches
+            ; must check _in_ the inner loop, to get the prev ptrs right.
+
+            mr.		r9,r9					; was there a prev ptr?
+            li		r3,0					; assume we are going to return null
+            ld		r4,pmapSkipLists(r6)	; assume prev ptr null... so next is first
+            beq--	mapSrch64Exit			; prev ptr was null, search failed
+            lwz		r0,mpFlags(r9)			; get flag bits from prev mapping
+            ld		r10,mpVAddr(r9)			; re-fetch base address of prev ptr
+            ld		r4,mpList0(r9)			; get 64-bit ptr to next mapping, if any
+            andi.	r0,r0,mpBlock+mpNest	; block mapping or nested pmap?
+            lhz		r11,mpBSize(r9)			; get #pages/#segments in block/submap mapping
+            rldicr	r10,r10,0,51			; zero low 12 bits of mapping va
+            beq		mapSrch64Exit			; prev mapping was just a scalar page, search failed
+            cmpwi	r0,mpBlock				; block mapping or nested pmap?
+            sldi	r0,r11,12				; assume block mapping, get size in bytes - 4k
+            beq		mapSrch64f				; we guessed right, it was a block mapping
+            addi	r11,r11,1				; mpBSize is 1 too low
+            sldi	r11,r11,28				; in a nested pmap, mpBSize is in units of segments
+            subi	r0,r11,4096				; get address of last page in submap
+mapSrch64f:
+            add		r10,r10,r0				; r10 <- last page in this mapping
+            cmpld	r5,r10					; does this mapping cover our page?
+            bgt		mapSrch64Exit			; no, search failed
+            mr		r3,r9					; yes, we found it
+
+            ; found the mapping
+            ;   r2 = count of nodes visited
+            ;	r3 = the mapping
+            ;	r6 = pmap ptr
+            
+mapSrch64Found:								; WARNING: can drop down to here
+            ld		r4,mpList0(r3)			; get ptr to next mapping
+            lwz		r7,mpFlags(r3)			; Get the flags for our caller
+            
+            ;   r2 = count of nodes visited
+            ;	r3 = return value (ie, found mapping or 0)
+            ;   r4 = next mapping (or 0 if none)
+            ;	r6 = pmap ptr
+            ;	r7 = mpFlags
+            
+mapSrch64Exit:								; WARNING: can drop down to here
+            mr.		r5,r4					; next ptr null?
+#if	SKIPLISTSTATS
+            lwz		r10,pmapSearchCnt(r6)	; prepare to accumulate statistics
+            ld		r8,pmapSearchVisits(r6)
+            addi	r10,r10,1				; count searches
+            add		r8,r8,r2				; count nodes visited
+            stw		r10,pmapSearchCnt(r6)
+            std		r8,pmapSearchVisits(r6)
+#endif
+            beqlr-							; next ptr was null, so return 0 in r4 and r5
+            lwz		r5,mpVAddr+4(r4)		; get VA of next node
+            lwz		r4,mpVAddr+0(r4)
+            blr
+
+            
+            ; 32-bit processors.  Check next mapping.
+            ;   r2 = count of mappings visited so far
+            ;	r3 = current mapping ptr
+            ;	r4 = va of current mapping (ie, of r3)
+            ;	r5 = va to search for (the "key") (low 12 bits are 0)
+            ;	r6 = pmap ptr
+            ;	r7 = current skip list number * 8
+            ;	r8 = ptr to skip list vector of mapping pointed to by r9 (or pmap, if r9==0)
+            ;	r9 = prev ptr, or 0 if none
+            
+            .align	4
+mapSrch32a:									; loop over each mapping
+            lwz		r4,mpVAddr+4(r3)		; get va for this mapping (plus flags in low 12 bits)
+            addi	r2,r2,1					; count mappings visited
+            rlwinm	r4,r4,0,0,19			; zero low 12 bits of mapping va
+            cmplw	cr1,r5,r4				; compare the vas
+            blt		cr1,mapSrch32d			; key is less, try next list
+            la		r8,mpList0+4(r3)		; point to skip list vector in this mapping
+            mr		r9,r3					; remember prev ptr
+            beq-	cr1,mapSrch32Found		; this is the correct mapping
+            lwzx	r3,r7,r8				; get ptr to next mapping in current list
+mapSrch32c:
+            mr.		r3,r3					; was there another mapping on current list?
+            bne+	mapSrch32a				; was another, so loop
+mapSrch32d:
+            subic.	r7,r7,8					; move on to next list offset
+            lwzx	r3,r7,r8				; get next mapping on next list (if any)
+            bge+	mapSrch32c				; loop to try next list
+          
+            ; Mapping not found, check to see if prev node was a block mapping or nested pmap.
+            ; If not, or if our address is not covered by the block or nested map, return 0.
+            ; Note the advantage of keeping the check for block mappings (and nested pmaps)
+            ; out of the inner loop; we do the special case work at most once per search, and
+            ; never for the most-common case of finding a scalar mapping.  The full searches
+            ; must check _in_ the inner loop, to get the prev ptrs right.
+
+            mr.		r9,r9					; was there a prev ptr?
+            li		r3,0					; assume we are going to return null
+            lwz		r4,pmapSkipLists+4(r6)	; assume prev ptr null... so next is first
+            beq-	mapSrch32Exit			; prev ptr was null, search failed
+            lwz		r0,mpFlags(r9)			; get flag bits from prev mapping
+            lwz		r10,mpVAddr+4(r9)		; re-fetch base address of prev ptr
+            andi.	r0,r0,mpBlock+mpNest	; block mapping or nested pmap?
+            lwz		r4,mpList0+4(r9)		; get ptr to next mapping, if any
+            beq		mapSrch32Exit			; prev mapping was just a scalar page, search failed
+            lhz		r11,mpBSize(r9)			; get #pages/#segments in block/submap mapping
+            cmpwi	r0,mpBlock				; block mapping or nested pmap?
+            rlwinm	r10,r10,0,0,19			; zero low 12 bits of block mapping va
+            slwi	r0,r11,12				; assume block mapping, get size in bytes - 4k
+            beq		mapSrch32f				; we guessed right, it was a block mapping
+            addi	r11,r11,1				; mpBSize is 1 too low
+            slwi	r11,r11,28				; in a nested pmap, mpBSize is in units of segments
+            subi	r0,r11,4096				; get address of last page in submap
+mapSrch32f:
+            add		r10,r10,r0				; r10 <- last page in this mapping
+            cmplw	r5,r10					; does this mapping cover our page?
+            bgt		mapSrch32Exit			; no, search failed
+            mr		r3,r9					; yes, we found it
+
+            ; found the mapping
+            ;   r2 = count of nodes visited
+            ;	r3 = the mapping
+            ;	r6 = pmap ptr
+            
+mapSrch32Found:								; WARNING: can drop down to here
+            lwz		r4,mpList0+4(r3)		; get ptr to next mapping
+            lwz		r7,mpFlags(r3)			; Get mpFlags for our caller
+            ;   r2 = count of nodes visited
+            ;	r3 = return value (ie, found mapping or 0)
+            ;   r4 = next mapping (or 0 if none)
+            ;	r6 = pmap ptr
+            ;	r7 = mpFlags
+            
+mapSrch32Exit:
+            mr.		r5,r4					; next ptr null?
+#if	SKIPLISTSTATS
+            lwz		r10,pmapSearchCnt(r6)	; prepare to accumulate statistics
+            lwz		r8,pmapSearchVisits(r6)
+            lwz		r9,pmapSearchVisits+4(r6)
+            addi	r10,r10,1				; count searches
+            addc	r9,r9,r2				; count nodes visited
+            addze	r8,r8
+            stw		r10,pmapSearchCnt(r6)
+            stw		r8,pmapSearchVisits(r6)
+            stw		r9,pmapSearchVisits+4(r6)
+#endif
+            beqlr-							; next ptr was null, so return 0 in r4 and r5
+            lwz		r5,mpVAddr+4(r4)		; get VA of next node
+            lwz		r4,mpVAddr+0(r4)
+            blr
+
+            ; Here when the pmap is empty (ie, pmapCurLists==0), both in 32 and 64-bit mode,
+            ; and from both mapSearch and mapSearchFull.
+            ;	r6 = pmap ptr
+            
+mapSrchPmapEmpty:
+            li		r3,0					; return null
+            li		r4,0					; return 0 as virtual address of next node
+            li		r5,0
+#if	SKIPLISTSTATS
+            lwz		r7,pmapSearchCnt(r6)	; prepare to accumulate statistics
+            addi	r7,r7,1					; count searches
+            stw		r7,pmapSearchCnt(r6)
+#endif
+            blr
+            
+
+/*
+ *  *****************************
+ * 	* m a p S e a r c h F u l l *
+ *	*****************************
+ *
+ * Given a pmap and a virtual address (VA), find the mapping for that address.
+ * This is the "full" call, that sets up a vector of ptrs to the previous node
+ * (or to the pmap, if there is no previous node) for each list that the mapping
+ * in on.  We also make consistency checks on the skip-lists.  When called:
+ *		the pmap is locked (shared or exclusive)
+ *		translation is off, interrupts masked
+ *		64-bit mode is enabled (if on a 64-bit machine)
+ *		cr6 is loaded with the corresponding feature flags (in particular, pf64Bit)
+ *		r3 = pmap ptr
+ *		r4 = high 32 bits of key to search for (0 if a 32-bit processor)
+ *		r5 = low 32 bits of key (low 12 bits may be nonzero garbage)
+ *
+ * We return the mapping ptr (or 0) in r3, and the next VA (or 0 if no more) in r4 and r5.
+ * Except for cr6 (which is global), we trash nonvolatile regs.  Called both on 32- and 64-bit
+ * machines, though we quickly branch into parallel code paths.
+ */ 
+            .text
+			.align	5
+            .globl	EXT(mapSearchFull)
+LEXT(mapSearchFull)
+            lbz		r7,pmapCurLists(r3)		; get largest #lists any mapping is on
+            la		r8,pmapSkipLists+4(r3)	; point to lists in pmap, assuming 32-bit machine
+            rlwinm	r5,r5,0,0,19			; zero low 12 bits of key
+            mr		r6,r3					; save pmap ptr here so we can accumulate statistics
+            li		r2,0					; initialize count of mappings visited
+            mfsprg	r12,0					; get the per-proc data ptr
+            crclr	bFullFound				; we have not found the mapping yet
+            addic.	r7,r7,-1				; get base-0 number of last list, and test for 0
+            subi	r9,r8,mpList0+4			; initialize prev ptr to be a fake mapping
+            slwi	r7,r7,3					; get (offset*8) of last list
+            la		r12,skipListPrev+4(r12)	; point to vector of prev ptrs, assuming 32-bit machine
+            blt--	mapSrchPmapEmpty		; pmapCurLists==0 (ie, no mappings)
+            lwzx	r3,r8,r7				; get 32-bit ptr to 1st mapping in highest list
+            li		r10,0					; initialize prev ptrs VA to 0 too
+            bf--	pf64Bitb,mapSrchFull32c	; skip if 32-bit processor
+            subi	r8,r8,4					; we use all 64 bits of ptrs
+            subi	r12,r12,4
+            rldimi	r5,r4,32,0				; r5 <- 64-bit va
+            ldx		r3,r8,r7				; get 64-bit ptr to 1st mapping in highest list
+            b		mapSrchFull64c			; enter 64-bit search loop
+
+            
+            ; 64-bit processors.  Check next mapping.
+            ;   r2 = count of mappings visited so far
+            ;	r3 = current mapping ptr
+            ;	r4 = va of current mapping (ie, of r3)
+            ;	r5 = va to search for (the "key") (low 12 bits are 0)
+            ;	r6 = pmap ptr
+            ;	r7 = current skip list number * 8
+            ;	r8 = ptr to skip list vector of mapping pointed to by r9
+            ;	r9 = prev ptr, ie highest mapping that comes before search target (initially the pmap)
+            ;  r10 = prev mappings va, or 0 if r9==pmap 
+            ;  r12 = ptr to the skipListPrev vector in the per-proc
+            
+            .align	5
+mapSrchFull64a:								; loop over each mapping
+            ld		r4,mpVAddr(r3)			; get va for this mapping (plus flags in low 12 bits)
+            addi	r2,r2,1					; count mappings visited
+            lwz		r0,mpFlags(r3)			; get mapping flag bits
+            cmpld	cr0,r10,r4				; make sure VAs come in strictly ascending order
+            rldicr	r4,r4,0,51				; zero low 12 bits of mapping va
+            cmpld	cr1,r5,r4				; compare the vas
+            bge--	cr0,mapSkipListPanic	; die if keys are out of order
+            andi.	r0,r0,mpBlock+mpNest	; is it a scalar mapping? (ie, of a single page)
+            blt		cr1,mapSrchFull64d		; key is less, try next list
+            beq		cr1,mapSrchFull64Found	; this is the correct mapping
+            bne--	cr0,mapSrchFull64e		; handle block mapping or nested pmap
+mapSrchFull64b:
+            la		r8,mpList0(r3)			; point to skip list vector in this mapping
+            mr		r9,r3					; current becomes previous
+            ldx		r3,r7,r8				; get ptr to next mapping in current list
+            mr		r10,r4					; remember prev ptrs VA
+mapSrchFull64c:
+            mr.		r3,r3					; was there another mapping on current list?
+            bne++	mapSrchFull64a			; was another, so loop
+mapSrchFull64d:
+            stdx	r9,r7,r12				; save prev ptr in per-proc vector
+            subic.	r7,r7,8					; move on to next list offset
+            ldx		r3,r7,r8				; get next mapping on next list (if any)
+            bge++	mapSrchFull64c			; loop to try next list
+          
+            ; Mapping not found, return 0 and next higher key
+
+            li		r3,0					; return null
+            bt--	bFullFound,mapSkipListPanic	; panic if it was on earlier list
+            ld		r4,mpList0(r9)			; get 64-bit ptr to next mapping, if any
+            b		mapSrch64Exit
+            
+            ; Block mapping or nested pmap, and key > base.  We must compute the va of
+            ; the end of the block to see if key fits within it.
+
+mapSrchFull64e:            
+            lhz		r11,mpBSize(r3)			; get #pages/#segments in block/submap mapping (if nonscalar)
+            cmpwi	r0,mpBlock				; distinguish between block mapping and nested pmaps
+            sldi	r0,r11,12				; assume block mapping, get size in bytes - 4k
+            beq		mapSrchFull64f			; we guessed right, it was a block mapping
+            addi	r11,r11,1				; mpBSize is 1 too low
+            sldi	r11,r11,28				; in a nested pmap, mpBSize is in units of segments
+            subi	r0,r11,4096				; get address of last page in submap
+mapSrchFull64f:
+            add		r4,r4,r0				; r4 <- last page in this mapping
+            cmpld	r5,r4					; does this mapping cover our page?
+            bgt		mapSrchFull64b			; no, try next mapping (r4 is advanced to end of range)
+
+
+            ; found the mapping
+            ;   r2 = count of nodes visited
+            ;	r3 = the mapping
+            ;	r6 = pmap ptr
+            ;	r7 = current skip list number * 8
+            ;	r8 = ptr to prev mappings (ie, r9) skip-list vector
+            ;	r9 = prev ptr, ie highest mapping that comes before search target
+            ;  r10 = prev mappings va
+            ;  r12 = ptr to the skipListPrev vector in the per-proc
+            
+mapSrchFull64Found:							; WARNING: can drop down to here
+            cmpwi	r7,0					; are we in the last skip-list?
+            crset	bFullFound				; remember that we found the mapping
+            bne		mapSrchFull64d			; mapSearchFull must search all lists to get prev ptrs
+            ld		r4,mpList0(r3)			; get ptr to next mapping
+            stdx	r9,r7,r12				; save prev ptr in last list
+            lwz		r7,mpFlags(r3)			; Get the flags for our caller
+            b		mapSrch64Exit
+
+            
+            ; 32-bit processors.  Check next mapping.
+            ;   r2 = count of nodes visited
+            ;	r3 = ptr to next mapping in current list
+            ;	r5 = va to search for (the "key") (low 12 bits are 0)
+            ;	r6 = pmap ptr
+            ;	r7 = current skip list number * 8
+            ;	r8 = ptr to skip list vector of mapping pointed to by r9
+            ;	r9 = prev ptr, ie highest mapping that comes before search target (initially the pmap)
+            ;  r10 = prev mappings va, or 0 if r9==pmap 
+            ;  r12 = ptr to the skipListPrev vector in the per-proc
+            
+            .align	4
+mapSrchFull32a:								; loop over each mapping
+            lwz		r4,mpVAddr+4(r3)		; get va for this mapping (plus flags in low 12 bits)
+            addi	r2,r2,1					; count mappings visited
+            lwz		r0,mpFlags(r3)			; get mapping flag bits
+            cmplw	cr0,r10,r4				; make sure VAs come in strictly ascending order
+            rlwinm	r4,r4,0,0,19			; zero low 12 bits of mapping va
+            cmplw	cr1,r5,r4				; compare the vas
+            bge-	cr0,mapSkipListPanic	; die if keys are out of order
+            andi.	r0,r0,mpBlock+mpNest	; is it a scalar mapping? (ie, of a single page)
+            blt		cr1,mapSrchFull32d		; key is less than this va, try next list
+            beq-	cr1,mapSrchFull32Found	; this is the correct mapping
+            bne-	cr0,mapSrchFull32e		; handle block mapping or nested pmap
+mapSrchFull32b:
+            la		r8,mpList0+4(r3)		; point to skip list vector in this mapping
+            mr		r9,r3					; current becomes previous
+            lwzx	r3,r7,r8				; get ptr to next mapping in current list
+            mr		r10,r4					; remember prev ptrs VA
+mapSrchFull32c:
+            mr.		r3,r3					; next becomes current
+            bne+	mapSrchFull32a			; was another, so loop
+mapSrchFull32d:
+            stwx	r9,r7,r12				; save prev ptr in per-proc vector
+            subic.	r7,r7,8					; move on to next list offset
+            lwzx	r3,r7,r8				; get next mapping on lower list (if any)
+            bge+	mapSrchFull32c			; loop to try next list
+
+            ; mapping not found, return 0 and next-key
+            
+            li		r3,0					; return null
+            bt-		bFullFound,mapSkipListPanic	; panic if it was on an earlier list
+            lwz		r4,mpList0+4(r9)		; get ptr to next mapping
+            b		mapSrch32Exit
+            
+            ; Block mapping or nested pmap, and key > base.  We must compute the va of
+            ; the end of the block to see if our key fits within it.
+
+mapSrchFull32e:            
+            lhz		r11,mpBSize(r3)			; get #pages/#segments in block/submap mapping (if nonscalar)
+            cmpwi	r0,mpBlock				; distinguish between block mapping and nested pmaps
+            slwi	r0,r11,12				; assume block mapping, get size in bytes - 4k
+            beq		mapSrchFull32f			; we guessed right, it was a block mapping
+            addi	r11,r11,1				; mpBSize is 1 too low
+            slwi	r11,r11,28				; in a nested pmap, mpBSize is in units of segments
+            subi	r0,r11,4096				; get address of last page in submap
+mapSrchFull32f:
+            add		r4,r4,r0				; r4 <- last page in this mapping
+            cmplw	r5,r4					; does this mapping cover our page?
+            bgt		mapSrchFull32b			; no, try next mapping
+            
+            
+            ; found the mapping
+            ;   r2 = count of nodes visited
+            ;	r3 = the mapping
+            ;	r6 = pmap ptr
+            ;	r7 = current skip list number * 8
+            ;	r9 = prev ptr, ie highest mapping that comes before search target, or 0
+            ;  r10 = prev mappings va
+            ;  r12 = ptr to the skipListPrev vector in the per-proc
+            
+mapSrchFull32Found:							; WARNING: can drop down to here
+            cmpwi	r7,0					; are we in the last skip-list?
+            crset	bFullFound				; remember that we found the mapping
+            bne		mapSrchFull32d			; mapSearchFull must search all lists to get prev ptrs
+            lwz		r4,mpList0+4(r3)		; get ptr to next mapping
+            stwx	r9,r7,r12				; save prev ptr in last list
+            lwz		r7,mpFlags(r3)			; Get mpFlags for our caller
+            b		mapSrch32Exit
+
+
+/*
+ * 	*********************
+ * 	* m a p I n s e r t *
+ *	*********************
+ *
+ * Insert a mapping into pmap skip-lists.  The caller has already called mapSearchFull to 
+ * determine that this mapping does not overlap other mappings in the pmap.  As a side effect 
+ * of calling mapSearchFull, the per-proc skipListPrev array is set up with a vector of the 
+ * previous ptrs for each skip list.  When called:
+ *		the pmap is locked (exclusive)
+ *		translation is off, interrupts masked
+ *		64-bit mode is enabled (if on a 64-bit machine)
+ *		mapSearchFull has just been called for this mappings key
+ *		cr6 is loaded with the corresponding feature flags (in particular, pf64Bit)
+ *		r3 = pmap ptr
+ *		r4 = mapping ptr
+ *
+ * There is no return value.  Except for cr6 (which is global), we trash nonvolatile regs.
+ */ 
+
+			.align	5
+			.globl	EXT(mapInsert)
+LEXT(mapInsert)
+            lwz		r8,mpFlags(r4)			; get this mappings flags
+            lbz		r7,pmapCurLists(r3)		; get current max# lists any mapping is on
+            la		r10,pmapSkipLists+4(r3)	; r10 <-- base of pmap list headers, assuming 32-bit machine
+            la		r11,mpList0+4(r4)		; r11 <-- base of this mappings list vector
+            mfsprg	r12,0					; get ptr to our per-proc
+            andi.	r9,r8,mpLists			; get #lists this mapping is on (1<=n<=27)
+            la		r12,skipListPrev+4(r12)	; r12 <-- base of prev ptr vector
+            sub.	r6,r9,r7				; is this mapping on more lists than any other?
+            slwi	r8,r9,3					; get #lists * 8
+            subi	r8,r8,8					; get offset to topmost (last) list in use
+            bf--	pf64Bitb,mapIns32		; handle 32-bit processor
+            subi	r10,r10,4				; we use all 8 bytes of the ptr fields
+            subi	r11,r11,4
+            subi	r12,r12,4
+            ble++	mapIns64a				; not new max #lists
+            
+            ; 64-bit processor: We must increase pmapCurLists.  Since mapSearchFull() only
+            ; sets up the first pmapCurLists prev ptrs, we must initialize the new ones to
+            ; point to the pmap.  While we are at it, we verify that the unused list hdrs in
+            ; the pmap are 0.
+            
+            cmpwi	r9,kSkipListMaxLists	; in range?
+            stb		r9,pmapCurLists(r3)		; remember new max
+            mtctr	r6						; set up count of new lists
+            mr		r5,r8					; copy offset to last list
+            subi	r0,r10,mpList0			; r0 <-- fake mapping ptr (to pmap) for null prev ptrs
+            bgt--	mapSkipListPanic		; choke if this mapping is on too many lists
+mapIns64NewList:
+            ldx		r6,r5,r10				; get pmap list head
+            stdx	r0,r5,r12				; initialize prev ptr
+            subi	r5,r5,8					; get next list offset
+            cmpdi	r6,0					; was list hdr null?
+            bdnzt	cr0_eq,mapIns64NewList	; loop if more lists to initialize and list hdr was 0
+            bne--	mapSkipListPanic		; die if pmap list hdr was not null
+            b		mapIns64a
+            
+            ; 64-bit processor: loop over each list this mapping is on
+            ;	 r4 = mapping
+            ;	 r8 = next list offset
+            ;	r10 = ptr to base of pmap list header vector
+            ;	r11 = ptr to base of new mappings list vector
+            ;	r12 = ptr to base of prev ptr vector in per-proc
+            
+            .align	5
+mapIns64a:
+            ldx		r5,r8,r12				; get prev ptr from per-proc vector
+            cmpwi	cr1,r8,0				; more to go?
+            la		r7,mpList0(r5)			; get base of prev mappings list vector
+            ldx		r9,r8,r7				; ***
+            stdx	r4,r8,r7				; * insert new mapping in middle of this list
+            stdx	r9,r8,r11				; ***
+            subi	r8,r8,8					; get next list offset
+            bne++	cr1,mapIns64a			; more lists to go
+            blr								; done		
+
+            ; Handle 32-bit processor.  First, increase pmapCurLists if necessary; cr0 is bgt
+            ; iff the new mapping has more lists.  Since mapSearchFull() only sets up the first
+            ; pmapCurLists prev ptrs, we must initialize any new ones to point to the pmap.
+            ; While we are at it, we verify that the unused list hdrs in the pmap are 0.
+            
+mapIns32:
+            ble+	mapIns32a				; skip if new mapping does not use extra lists
+            cmpwi	r9,kSkipListMaxLists	; in range?
+            stb		r9,pmapCurLists(r3)		; remember new max
+            mtctr	r6						; set up count of new lists
+            mr		r5,r8					; copy offset to last list
+            subi	r0,r10,mpList0+4		; r0 <-- fake mapping ptr (to pmap) for null prev ptrs
+            bgt-	mapSkipListPanic		; choke if this mapping is on too many lists
+mapIns32NewList:
+            lwzx	r6,r5,r10				; get pmap list head
+            stwx	r0,r5,r12				; initialize prev ptr
+            subi	r5,r5,8					; get next list offset
+            cmpwi	r6,0					; was list hdr null?
+            bdnzt	cr0_eq,mapIns32NewList	; loop if more lists to initialize and list hdr was 0
+            bne-	mapSkipListPanic		; die if pmap list hdr was not null
+            b		mapIns32a
+            
+            ; 32-bit processor: loop over each list this mapping is on
+            ;	 r4 = mapping
+            ;	 r8 = next list offset
+            ;	r10 = ptr to base of pmap list header vector
+            ;	r11 = ptr to base of new mappings list vector
+            ;	r12 = ptr to base of prev ptr vector
+            
+            .align	4
+mapIns32a:
+            lwzx	r5,r8,r12				; get prev ptr from per-proc vector
+            cmpwi	cr1,r8,0				; more to go?
+            la		r7,mpList0+4(r5)		; get base of prev mappings list vector
+            lwzx	r9,r8,r7				; ***
+            stwx	r4,r8,r7				; * insert new mapping in middle of this list
+            stwx	r9,r8,r11				; ***
+            subi	r8,r8,8					; get next list offset
+            bne+	cr1,mapIns32a			; more lists to go
+            blr								; done		
+
+
+/*
+ * 	*********************
+ * 	* m a p R e m o v e *
+ *	*********************
+ *
+ * Remove a mapping from pmap skip-lists.  The caller has already called mapSearchFull to 
+ * find the mapping, which sets up the skipListPrev array with a vector of the previous
+ * ptrs for each skip list.  When called:
+ *		the pmap is locked (exclusive)
+ *		translation is off, interrupts masked
+ *		64-bit mode is enabled (if on a 64-bit machine)
+ *		mapSearchFull has just been called for this mappings key
+ *		cr6 is loaded with the corresponding feature flags (in particular, pf64Bit)
+ *		r3 = pmap ptr
+ *		r4 = mapping ptr
+ *
+ * There is no return value.  Except for cr6 (which is global), we trash nonvolatile regs.
+ */ 
+
+			.align	5
+			.globl	EXT(mapRemove)
+LEXT(mapRemove)
+            lwz		r8,mpFlags(r4)			; get this mappings flags
+            lbz		r10,pmapCurLists(r3)	; get current #lists in use
+            la		r11,mpList0+4(r4)		; r11 <-- base of this mappings list vector
+            mfsprg	r12,0					; get ptr to our per-proc
+            andi.	r9,r8,mpLists			; get #lists this mapping is on (1<=n<=27)
+            slwi	r8,r9,3					; get #lists * 8
+            cmpw	cr5,r9,r10				; compare mpLists to pmapCurLists
+            la		r12,skipListPrev+4(r12)	; r12 <-- base of prev ptr vector
+            bgt--	cr5,mapSkipListPanic	; die if mpLists > pmapCurLists
+            subi	r8,r8,8					; get offset to topmast (last) list this mapping is in
+            bf--	pf64Bitb,mapRem32a		; skip if 32-bit processor
+            subi	r11,r11,4				; we use all 64 bits of list links on 64-bit machines
+            subi	r12,r12,4
+            b		mapRem64a
+
+            ; 64-bit processor: loop over each list this mapping is on
+            ;	 r3 = pmap
+            ;	 r4 = mapping
+            ;	 r8 = offset to next list
+            ;	r10 = pmapCurLists
+            ;	r11 = ptr to base of mapping list vector
+            ;	r12 = ptr to base of prev ptr vector in per-proc
+            ;	cr5 = beq if (mpLists == pmapCurLists)
+
+            .align	5
+mapRem64a:
+            ldx		r5,r8,r12				; get prev ptr from per-proc vector
+            ldx		r9,r8,r11				; get next ptr from mapping
+            cmpwi	cr1,r8,0				; more to go?
+            la		r7,mpList0(r5)			; get base of prev mappings list vector
+            stdx	r9,r8,r7				; point to next from prev
+            subi	r8,r8,8					; get next list offset
+            bne++	cr1,mapRem64a			; loop if another list to unlink from
+            
+            ; Did we reduce #lists in use by removing last mapping in last list?
+            
+            bnelr++	cr5						; if (mpLists!=pmapCurLists) cannot have removed last map
+            la		r5,pmapSkipLists(r3)	; point to vector of list hdrs
+mapRem64b:
+            subic.	r10,r10,1				; get base-0 list#
+            slwi	r8,r10,3				; get offset to last list
+            ldx		r0,r8,r5				; get last list ptr
+            cmpdi	cr1,r0,0				; null?
+            bnelr	cr1						; not null, so we are done
+            stb		r10,pmapCurLists(r3)	; was null, so decrement pmapCurLists
+            bgt		mapRem64b				; loop to see if more than one list was emptied
+            blr
+            
+            
+            ; 32-bit processor: loop over each list this mapping is on
+            ;	 r3 = pmap
+            ;	 r4 = mapping
+            ;	 r8 = offset to next list
+            ;	r10 = pmapCurLists
+            ;	r11 = ptr to base of mapping list vector
+            ;	r12 = ptr to base of prev ptr vector in per-proc
+            ;	cr5 = beq if (mpLists == pmapCurLists)
+            
+            .align	4
+mapRem32a:
+            lwzx	r5,r8,r12				; get prev ptr from per-proc vector
+            lwzx	r9,r8,r11				; get next ptr from mapping
+            cmpwi	cr1,r8,0				; more to go?
+            la		r7,mpList0+4(r5)		; get base of prev mappings list vector
+            stwx	r9,r8,r7				; point to next from prev
+            subi	r8,r8,8					; get next list offset
+            bne+	cr1,mapRem32a			; loop if another list to unlink from
+            
+            ; Did we reduce #lists in use by removing last mapping in last list?
+            
+            bnelr+	cr5						; if (mpLists!=pmapCurLists) cannot have removed last map
+            la		r5,pmapSkipLists+4(r3)	; point to vector of list hdrs
+mapRem32b:
+            subic.	r10,r10,1				; get base-0 list#
+            slwi	r8,r10,3				; get offset to last list
+            lwzx	r0,r8,r5				; get last list ptr
+            cmpwi	cr1,r0,0				; null?
+            bnelr	cr1						; not null, so we are done
+            stb		r10,pmapCurLists(r3)	; was null, so decrement pmapCurLists
+            bgt		mapRem32b				; loop to see if more than one list was emptied
+            blr
+            
+
+/*
+ * *************************
+ * * m a p S e t L i s t s *
+ * *************************
+ *
+ * Called to decide how many skip-lists the next mapping will be on.  For each pmap,
+ * we maintain a psuedo-random sequence based on a linear feedback shift register.  The
+ * next number is generated by rotating the old value left by 1 and XORing with a
+ * polynomial (actually 4 8-bit polynomials concatanated) and adding 1.
+ * The simple (unclamped) number of lists a mapping is on is the number of trailing 0s
+ * in the pseudo-random sequence, shifted by the (log2-1) of the fanout F, plus one.  
+ * This seems to give us a near perfect distribution, in the sense that about F times more nodes
+ * are allocated on n lists, as are on (n+1) lists.
+ *
+ * At one point we used a simple counter to assign lists.  While this gave perfect
+ * distribution, there were certain access pattern that would drive a worst case 
+ * distribution (e.g., insert low, then high, then low, etc.).  Unfortunately,
+ * these patterns were not too uncommon.  We changed to a less-than-perfect assignment,
+ * but one that works consistently across all known access patterns.
+ *
+ * Also, we modify the "simple" trailing-0-based list count, to account for an important
+ * observation: because VM does a lot of removing and restoring of mappings in the process of
+ * doing copy-on-write etc, it is common to have the pmap's "random number" (ie, the
+ * count of created mappings) be much larger than the number of mappings currently in the
+ * pmap.  This means the simple list count will often be larger than justified by the number of 
+ * mappings in the pmap.  To avoid this common situation, we clamp the list count to be no more
+ * than ceil(logBaseF(pmapResidentCnt)).
+ *
+ * Finally, we also clamp the list count to kSkipListMaxLists.
+ *
+ * We are passed the pmap ptr in r3.  Called with translation on, interrupts enabled,
+ * and in 32-bit mode.
+ */
+            .align	5
+			.globl	EXT(mapSetLists)
+LEXT(mapSetLists)
+            lwz		r5,pmapRandNum(r3)		; get the per-pmap counter of mapping creates
+            lwz		r4,pmapResidentCnt(r3)	; get number of mappings in this pmap
+			lis		r11,hi16(0xA7CBF5B9)	; Get polynomial (I just made this up...)
+			li		r0,-1					; get a mask of 1s
+			ori		r11,r11,lo16(0xA7CBF5B9)	; Get polynomial (I just made this up...)
+			rlwinm	r5,r5,1,0,31			; Rotate
+			cntlzw	r7,r4					; get magnitude of pmapResidentCnt
+			xor		r5,r5,r11				; Munge with poly
+			srw		r7,r0,r7				; r7 <- mask for magnitude of pmapResidentCnt
+			addi	r6,r5,1					; increment pmapRandNum non-atomically
+            andc	r8,r5,r6				; get a mask for trailing zeroes in pmapRandNum
+            stw		r6,pmapRandNum(r3)		; update "random number"
+			and		r8,r8,r7				; clamp trailing 0s to magnitude of pmapResidentCnt
+            rlwinm	r8,r8,0,32-(kSkipListMaxLists*(kSkipListFanoutShift+1))+1,31 ; clamp to kSkipListMaxLists
+            cntlzw	r9,r8					; count leading 0s in the mask
+            subfic	r10,r9,32				; r10 <- trailing zero count
+            srwi	r11,r10,kSkipListFanoutShift ; shift by 1 if fanout is 4, 2 if 8, etc
+            addi	r3,r11,1				; every mapping is on at least one list
+            blr
+            
+
+/*
+ * *************************************
+ * * m a p S k i p L i s t V e r i f y *
+ * *************************************
+ *
+ * This does a fairly thorough sweep through a pmaps skip-list data structure, doing
+ * consistency checks.  It is typically called (from hw_exceptions.s) from debug or
+ * instrumented builds.  It is probably not a good idea to call this in production builds,
+ * as it must run with exceptions disabled and can take a long time to verify a big pmap.
+ * It runs in O(n*ln(n)).
+ *
+ * Called on a bl, with the pmap ptr in r20.  We assume the pmap is locked (shared) and
+ * that EE and DR are off.  We check all 64 bits of ptrs even on 32-bit machines.
+ * We use r20-r31, cr0, cr1, and cr7.  If we return, no inconsistencies were found.
+ *
+ * You will notice we make little attempt to schedule the code; clarity is deemed more
+ * important than speed.
+ */
+ 
+ 
+ /*
+  *			mapSkipListVerifyC is a version that is callable from C.
+  *			This should be called only from the debugger, IT DOES NOT LOCK THE PMAP!!!!
+  */
+ 
+			.globl	EXT(mapSkipListVerifyC)
+LEXT(mapSkipListVerifyC)
+
+ 			stwu	r1,-(FM_ALIGN((31-13+1)*4)+FM_SIZE)(r1)	; Make some space on the stack
+			mflr	r0							; Save the link register
+			stmw	r13,FM_ARG0(r1)				; Save all registers
+			stw		r0,(FM_ALIGN((31-13+1)*4)+FM_SIZE+FM_LR_SAVE)(r1)	; Save the return
+			
+			lwz		r15,pmapvr(r3)				; Get the V to R translation
+			lwz		r16,pmapvr+4(r3)			; Get the V to R translation
+			mr		r19,r4						; Save register dump area
+			
+			bl		EXT(mapSetUp)				; Get set up
+			
+			mr		r17,r11
+			xor		r20,r3,r16					; Translate 32-bit portion
+			bf--	pf64Bitb,mslvc32a			; Skip if 32-bit...
+			
+			rldimi	r20,r15,32,0				; Shift the fixed upper part of the physical over and cram in top
+			
+mslvc32a:	lis		r18,hi16(EXT(DebugWork))
+			ori		r18,r18,lo16(EXT(DebugWork))
+			li		r0,0x4262
+			stw		r0,4(r18)					; Make sure the test knows to run
+			
+			bl		EXT(mapSkipListVerify)		; Run the test
+
+			li		r0,0						
+			stw		r0,4(r18)					; Remove explicit call flag
+
+			bt++	pf64Bitb,mslvc64a			; This is 64-bit...
+
+			mtmsr	r17							; Restore enables/translation/etc.
+			isync
+			
+			li		r0,0
+			stw		r0,0x000+0(r19)
+			stw		r0,0x000+4(r19)
+			stw		r0,0x008+0(r19)
+			stw		r1,0x008+4(r19)
+			stw		r0,0x010+0(r19)
+			stw		r2,0x010+4(r19)
+			stw		r0,0x018+0(r19)
+			stw		r3,0x018+4(r19)
+			stw		r0,0x020+0(r19)
+			stw		r4,0x020+4(r19)
+			stw		r0,0x028+0(r19)
+			stw		r5,0x028+4(r19)
+			stw		r0,0x030+0(r19)
+			stw		r6,0x030+4(r19)
+			stw		r0,0x038+0(r19)
+			stw		r7,0x038+4(r19)
+			stw		r0,0x040+0(r19)
+			stw		r8,0x040+4(r19)
+			stw		r0,0x048+0(r19)
+			stw		r9,0x048+4(r19)
+			stw		r0,0x050+0(r19)
+			stw		r10,0x050+4(r19)
+			stw		r0,0x058+0(r19)
+			stw		r11,0x058+4(r19)
+			stw		r0,0x060+0(r19)
+			stw		r12,0x060+4(r19)
+			stw		r0,0x068+0(r19)
+			stw		r13,0x068+4(r19)
+			stw		r0,0x070+0(r19)
+			stw		r14,0x070+4(r19)
+			stw		r0,0x078+0(r19)
+			stw		r15,0x078+4(r19)
+			stw		r0,0x080+0(r19)
+			stw		r16,0x080+4(r19)
+			stw		r0,0x088+0(r19)
+			stw		r17,0x088+4(r19)
+			stw		r0,0x090+0(r19)
+			stw		r18,0x090+4(r19)
+			stw		r0,0x098+0(r19)
+			stw		r19,0x098+4(r19)
+			stw		r0,0x0A0+0(r19)
+			stw		r20,0x0A0+4(r19)
+			stw		r0,0x0A8+0(r19)
+			stw		r21,0x0A8+4(r19)
+			stw		r0,0x0B0+0(r19)
+			stw		r22,0x0B0+4(r19)
+			stw		r0,0x0B8+0(r19)
+			stw		r23,0x0B8+4(r19)
+			stw		r0,0x0C0+0(r19)
+			stw		r24,0x0C0+4(r19)
+			stw		r0,0x0C8+0(r19)
+			stw		r25,0x0C8+4(r19)
+			stw		r0,0x0D0+0(r19)
+			stw		r26,0x0D0+4(r19)
+			stw		r0,0x0D8+0(r19)
+			stw		r27,0x0D8+4(r19)
+			stw		r0,0x0E0+0(r19)
+			stw		r28,0x0E0+4(r19)
+			stw		r0,0x0E8+0(r19)
+			stw		r29,0x0E8+4(r19)
+			stw		r0,0x0F0+0(r19)
+			stw		r30,0x0F0+4(r19)
+			stw		r0,0x0F8+0(r19)
+			stw		r31,0x0F8+4(r19)
+			
+			b		mslvcreturn					; Join common...
+
+mslvc64a:	mtmsrd	r17							; Restore enables/translation/etc.
+			isync								
+			
+			std		r0,0x000(r19)
+			std		r1,0x008(r19)
+			std		r2,0x010(r19)
+			std		r3,0x018(r19)
+			std		r4,0x020(r19)
+			std		r5,0x028(r19)
+			std		r6,0x030(r19)
+			std		r7,0x038(r19)
+			std		r8,0x040(r19)
+			std		r9,0x048(r19)
+			std		r10,0x050(r19)
+			std		r11,0x058(r19)
+			std		r12,0x060(r19)
+			std		r13,0x068(r19)
+			std		r14,0x070(r19)
+			std		r15,0x078(r19)
+			std		r16,0x080(r19)
+			std		r17,0x088(r19)
+			std		r18,0x090(r19)
+			std		r19,0x098(r19)
+			std		r20,0x0A0(r19)
+			std		r21,0x0A8(r19)
+			std		r22,0x0B0(r19)
+			std		r23,0x0B8(r19)
+			std		r24,0x0C0(r19)
+			std		r25,0x0C8(r19)
+			std		r26,0x0D0(r19)
+			std		r27,0x0D8(r19)
+			std		r28,0x0E0(r19)
+			std		r29,0x0E8(r19)
+			std		r30,0x0F0(r19)
+			std		r31,0x0F8(r19)
+			
+			
+mslvcreturn:
+			lwz		r0,(FM_ALIGN((31-13+1)*4)+FM_SIZE+FM_LR_SAVE)(r1)	; Get the return
+			lmw		r13,FM_ARG0(r1)				; Get the registers
+			mtlr	r0							; Restore the return
+			lwz		r1,0(r1)					; Pop the stack
+			blr
+
+ 
+			.globl	EXT(mapSkipListVerify)
+LEXT(mapSkipListVerify)
+            mflr	r31						; save LR so we can bl to mapVerifyDie
+            
+            ; If we have already found an inconsistency and died, don not do so again, to
+            ; avoid a loop.
+            
+			lis		r27,hi16(EXT(DebugWork))
+			ori		r27,r27,lo16(EXT(DebugWork))
+			lwz		r0,4(r27)				; Get the explicit entry flag
+			lwz		r27,0(r27)				; Get lockout
+			cmplwi	r0,0x4262				; Should we run anyway?
+			beq--	mslvAnyway				; Yes...
+            cmpwi	r27,0					; have we already found an error?
+            bnelr--							; yes, just return wo checking again
+
+mslvAnyway:           
+            ; Not recursive call, so initialize.
+            
+            mfsprg	r23,2					; get the feature flags
+            mtcrf	0x02,r23				; put pf64Bit where we can test it
+            lbz		r26,pmapCurLists(r20)	; get #lists that are in use
+            lwz		r21,pmapResidentCnt(r20); get #mappings in this pmap
+            cmpwi	r26,kSkipListMaxLists	; in range?
+            bgtl--	mapVerifyDie			; pmapCurLists is too big
+            
+            ; To prevent infinite loops, set limit of (pmapCurLists*pmapResidentCnt) iterations.
+            ; Since we walk each list this is the max number of mappings we could visit.
+            
+            li		r23,0					; initialize count
+mapVer0:
+            subic.	r26,r26,1				; loop pmapCurLists times (but at least once)
+            add		r23,r23,r21				; compute (pmapCurLists*pmapResidentCnt) 
+            bgt		mapVer0					; this will be a 64-bit qty on 64-bit machines
+            
+            li		r22,kSkipListMaxLists	; initialize list#
+            bf--	pf64Bitb,mapVer32		; go handle a 32-bit processor
+            
+            ; 64-bit machine.
+            ;
+            ; Loop over each list, counting mappings in each.  We first check whether or not
+            ; the list is empty (ie, if the pmapSlipLists ptr is null.)  All lists above
+            ; pmapCurLists should be empty, and no list at or below pmapCurLists should be.
+            ;	r20 = pmap ptr
+            ;	r21 = decrementing counter of mappings in this pmap
+            ;	r22 = next list# (1...kSkipListMaxLists)
+            ;	r23 = decrementing counter for infinite loop check
+            
+mapVer64:
+            slwi	r25,r22,3				; get offset to next skiplist
+            la		r26,pmapSkipLists(r20)	; get ptr to base of skiplist vector
+            subi	r25,r25,8
+            ldx		r26,r25,r26				; get 1st mapping on this list, if any
+            lbz		r28,pmapCurLists(r20)	; get #lists in use
+            cmpdi	cr6,r26,0				; set cr6_eq if this list is null ("null")
+            cmpw	cr7,r22,r28				; set cr7_gt if this list is > pmapCurLists ("high")
+            crxor	cr0_eq,cr6_eq,cr7_gt	; cr0_eq <-- (null & !high) | (!null & high)
+            beql--	mapVerifyDie			; die if this list is null when it should not be, etc
+            b		mapVer64g
+           
+            ; Loop over each node in the list.
+            ;	r20 = pmap ptr
+            ;	r21 = decrementing counter of mappings in this pmap
+            ;	r22 = this list# (1...kSkipListMaxLists)
+            ;	r23 = decrementing counter for infinite loop check
+            ;	r25 = offset to this skiplist (ie, ((r22<<3)-8))
+            ;	r26 = mapping
+            
+mapVer64a:
+            lwz		r29,mpFlags(r26)		; get bits for this mapping
+            ld		r28,mpVAddr(r26)		; get key
+            subic.	r23,r23,1				; check for loops
+            bltl--	mapVerifyDie			; we have visited > (pmapCurLists*pmapResidentCnt) nodes
+            andi.	r30,r26,mpBasicSize-1	; test address for alignment
+            bnel--	mapVerifyDie			; not aligned
+            andi.	r27,r29,mpLists			; get #lists this mapping is supposed to be on
+            cmpw	cr1,r27,r22				; is it supposed to be on this list?
+            bltl--	cr1,mapVerifyDie		; mappings mpLists is too low
+            cmpwi	r27,kSkipListMaxLists	; too big?
+            bgtl--	mapVerifyDie			; mappings mpLists > max
+            rldicr	r28,r28,0,51			; clear low 12 bits of va
+            bne++	cr1,mapVer64f			; jump if this is not highest list for this node
+            
+            ; This is the "highest" (last) list this mapping is on.
+            ; Do some additional checks (so we only do them once per mapping.)
+            ; First, if a block mapping or nested pmap, compute block end.
+            
+            andi.	r29,r29,mpBlock+mpNest	; is it block mapping or nested pmap?
+            subi	r21,r21,1				; count mappings in this pmap
+            beq++	mapVer64b				; not nested or pmap
+            lhz		r27,mpBSize(r26)		; get #pages or #segments
+            cmpwi	r29,mpBlock				; which one is it?
+            sldi	r29,r27,12				; assume block mapping, units are (pages-1)
+            beq		mapVer64b				; guessed correctly
+            addi	r27,r27,1				; units of nested pmap are (#segs-1)
+            sldi	r29,r27,28				; convert to #bytes
+            subi	r29,r29,4096			; get offset to last byte in nested pmap
+            
+            ; Here with r29 = size of block - 4k, or 0 if mapping is a scalar page.
+
+mapVer64b:
+            add		r24,r28,r29				; r24 <- address of last valid page in this mapping
+            la		r28,mpList0(r26)		; get base of this mappings vector            
+            lwz		r27,mpFlags(r26)		; Get the number of lists
+            andi.	r27,r27,mpLists			; get #lists this mapping is on (1<=n<=27)
+            cmplwi	r27,mpBasicLists		; Into bigger mapping?
+            li		r27,mpBasicLists*8-8	; Assume normal
+            ble+	mapVer64c				; It is...
+            li		r27,kSkipListMaxLists*8-8	; initialize list offset for inner loop
+            
+            ; Inner loop over each list link in this mappingss mpList vector.
+            ;	r24 = address of last valid page in this mapping
+            ;	r27 = offset for next list in inner loop
+            ;	r28 = base of this mappings list links
+            
+mapVer64c:
+            cmpw	cr1,r27,r25				; higher, lower, or same?
+            ldx		r29,r27,r28				; get link to next mapping at this level
+            mr.		r29,r29					; null?
+            beq		mapVer64d				; link null, which is always OK
+            bgtl--	cr1,mapVerifyDie		; a mapping has a non-null list higher than its mpLists
+            ld		r30,mpVAddr(r29)		; get next mappings va
+            rldicr	r30,r30,0,51			; zero low 12 bits
+            cmpld	r30,r24					; compare next key with ours
+            blel--	mapVerifyDie			; a next node has key <= to ours
+mapVer64d:
+            subic.	r27,r27,8				; move on to next list
+            bne++	mapVer64c				; loop if more to go
+            
+            ; Next node on current list, or next list if current done, or return if no more lists.
+            
+mapVer64f:
+            la		r28,mpList0(r26)		; get base of this mappings vector
+            ldx		r26,r25,r28				; get next mapping on this list
+mapVer64g:
+            mr.		r26,r26					; is there one?
+            bne++	mapVer64a				; yes, handle
+            subic.	r22,r22,1				; is there another list?
+            bgt++	mapVer64				; loop if so
+            
+            cmpwi	r21,0					; did we find all the mappings in the pmap?
+            bnel--	mapVerifyDie			; no
+            mtlr	r31						; restore return address
+            li		r3,0
+            blr
+            
+            
+            ; Handle 32-bit machine.
+            
+mapVer32:
+            lwz		r24,mpFlags(r20)		; Get number of lists
+            la		r30,pmapSkipLists(r20)	; first, check the pmap list hdrs
+            andi.	r24,r24,mpLists			; Clean the number of lists
+            bl		mapVerUpperWordsAre0	; are the upper words of each list all 0?
+            
+            ; Loop over each list, counting mappings in each.  We first check whether or not
+            ; the list is empty.  All lists above pmapCurLists should be empty, and no list
+            ; at or below pmapCurLists should be.
+            ;
+            ;	r20 = pmap ptr
+            ;	r21 = decrementing counter of mappings in this pmap
+            ;	r22 = next list# (1...kSkipListMaxLists)
+            ;	r23 = decrementing counter for infinite loop check
+            
+mapVer32NextList:
+            lbz		r28,pmapCurLists(r20)	; get #lists in use
+            slwi	r25,r22,3				; get offset to next skiplist
+            la		r26,pmapSkipLists+4(r20) ; get ptr to base of skiplist vector
+            subi	r25,r25,8
+            lwzx	r26,r25,r26				; get the 1st mapping on this list, or 0
+            cmpw	cr7,r22,r28				; set cr7_gt if this list is > pmapCurLists ("high")
+            cmpwi	cr6,r26,0				; set cr6_eq if this list is null ("null")
+            crxor	cr0_eq,cr6_eq,cr7_gt	; cr0_eq <-- (null & !high) | (!null & high)
+            beql-	mapVerifyDie			; die if this list is null when it should not be, etc
+            b		mapVer32g
+           
+            ; Loop over each node in the list.
+            ;	r20 = pmap ptr
+            ;	r21 = decrementing counter of mappings in this pmap
+            ;	r22 = this list# (1...kSkipListMaxLists)
+            ;	r23 = decrementing counter for infinite loop check
+            ;	r25 = offset to this skiplist (ie, ((r22<<3)-8))
+            ;	r26 = mapping
+            
+mapVer32a:
+            lwz		r29,mpFlags(r26)		; get bits for this mapping
+            andi.	r30,r26,mpBasicSize-1	; test address for alignment
+            lwz		r24,mpVAddr+0(r26)		; get upper word of key
+            bnel-	mapVerifyDie			; mapping address not 64-byte aligned
+            lwz		r28,mpVAddr+4(r26)		; get lower word of key
+            subic.	r23,r23,1				; check for loops
+            bltl-	mapVerifyDie			; we have visited > (pmapCurLists*pmapResidentCnt) nodes
+            cmpwi	r24,0					; upper word of key (ie, va) should be 0
+            bnel-	mapVerifyDie			; was not
+            andi.	r27,r29,mpLists			; get #lists this mapping is supposed to be on
+            cmpw	cr1,r27,r22				; is it supposed to be on this list?
+            bltl-	cr1,mapVerifyDie		; mappings mpLists is too low
+            cmpwi	r27,kSkipListMaxLists	; too big?
+            bgtl-	mapVerifyDie			; mappings mpLists > max
+            rlwinm	r28,r28,0,0,19			; clear low 12 bits of va
+            bne+	cr1,mapVer32f			; jump if this is not highest list for this node
+            
+            ; This is the "highest" (last) list this mapping is on.
+            ; Do some additional checks (so we only do them once per mapping.)
+            ; First, make sure upper words of the mpList vector are 0.
+
+            subi	r21,r21,1				; count mappings in this pmap
+            lwz		r24,mpFlags(r26)		; Get number of lists
+            la		r30,mpList0(r26)		; point to base of skiplist vector
+			andi.	r24,r24,mpLists			; Clean the number of lists
+			bl		mapVerUpperWordsAre0	; make sure upper words are all 0 (uses r24 and r27)
+            
+            ; Then, if a block mapping or nested pmap, compute block end.
+            
+            andi.	r29,r29,mpBlock+mpNest	; is it block mapping or nested pmap?
+            beq+	mapVer32b				; no
+            lhz		r27,mpBSize(r26)		; get #pages or #segments
+            cmpwi	r29,mpBlock				; which one is it?
+            slwi	r29,r27,12				; assume block mapping, units are pages
+            beq		mapVer32b				; guessed correctly
+            addi	r27,r27,1				; units of nested pmap are (#segs-1)
+            slwi	r29,r27,28				; convert to #bytes
+            subi	r29,r29,4096			; get offset to last byte in nested pmap
+            
+            ; Here with r29 = size of block - 4k, or 0 if mapping is a scalar page.
+
+mapVer32b:
+            add		r24,r28,r29				; r24 <- address of last valid page in this mapping
+            la		r28,mpList0+4(r26)		; get base of this mappings vector            
+            lwz		r27,mpFlags(r26)		; Get the number of lists
+            andi.	r27,r27,mpLists			; get #lists this mapping is on (1<=n<=27)
+            cmplwi	r27,mpBasicLists		; Into bigger mapping?
+            li		r27,mpBasicLists*8-8	; Assume normal
+            ble+	mapVer32c				; It is...
+            li		r27,kSkipListMaxLists*8-8	; initialize list offset for inner loop
+            
+            ; Inner loop over each list in this mappings mpList vector.
+            ;	r24 = address of last valid page in this mapping
+            ;	r27 = offset for next list in inner loop
+            ;	r28 = base of this mappings list links
+            
+mapVer32c:
+            cmpw	cr1,r27,r25				; higher, lower, or same?
+            lwzx	r29,r27,r28				; get link to next mapping at this level
+            mr.		r29,r29					; null?
+            beq		mapVer32d				; link null, which is always OK
+           
+           
+            bgtl-	cr1,mapVerifyDie		; a mapping has a non-null list higher than its mpLists
+            lwz		r30,mpVAddr+4(r29)		; get next mappings va
+            rlwinm	r30,r30,0,0,19			; zero low 12 bits
+            cmplw	r30,r24					; compare next key with ours
+            blel-	mapVerifyDie			; a next node has key <= to ours
+mapVer32d:
+            subic.	r27,r27,8				; move on to next list
+            bne+	mapVer32c				; loop if more to go
+            
+            ; Next node on current list, or next list if current done, or return if no more lists.
+            
+mapVer32f:
+            la		r28,mpList0+4(r26)		; get base of this mappings vector again
+            lwzx	r26,r25,r28				; get next mapping on this list
+mapVer32g:
+            mr.		r26,r26					; is there one?
+            bne+	mapVer32a				; yes, handle
+            subic.	r22,r22,1				; is there another list?
+            bgt+	mapVer32NextList		; loop if so
+            
+            cmpwi	r21,0					; did we find all the mappings in the pmap?
+            bnel-	mapVerifyDie			; no
+            mtlr	r31						; restore return address
+            li		r3,0
+            blr
+
+            ; Subroutine to verify that the upper words of a vector of kSkipListMaxLists
+            ; doublewords are 0.
+            ;	r30 = ptr to base of vector
+            ; Uses r24 and r27.
+            
+mapVerUpperWordsAre0:
+			cmplwi	r24,mpBasicLists		; Do we have more than basic?
+            li		r24,mpBasicLists*8		; Assume basic
+            ble++	mapVerUpper1			; We have the basic size
+            li		r24,kSkipListMaxLists*8	; Use max size
+            
+mapVerUpper1:
+            subic.	r24,r24,8				; get offset to next doubleword
+            lwzx	r27,r24,r30				; get upper word
+            cmpwi	cr1,r27,0				; 0 ?
+            bne-	cr1,mapVerifyDie		; die if not, passing callers LR
+            bgt+	mapVerUpper1			; loop if more to go
+            blr
+            
+            ; bl here if mapSkipListVerify detects an inconsistency.
+
+mapVerifyDie:
+			mflr	r3
+			mtlr	r31						; Restore return
+			lis		r31,hi16(EXT(DebugWork))
+			ori		r31,r31,lo16(EXT(DebugWork))
+			lwz		r0,4(r31)				; Get the explicit entry flag
+			cmplwi	r0,0x4262				; Should we run anyway?
+			beqlr--							; Explicit call, return...
+			
+            li		r0,1
+			stw		r0,0(r31)				; Lock out further calls
+            BREAKPOINT_TRAP					; hopefully, enter debugger
+            b		.-4
+            
+            
+/*
+ * Panic (choke, to be exact) because of messed up skip lists.  The LR points back
+ * to the original caller of the skip-list function.
+ */
+ 
+mapSkipListPanic:							; skip-lists are screwed up
+            lis		r0,hi16(Choke)
+            ori		r0,r0,lo16(Choke)
+            li      r3,failSkipLists		; get choke code
+            sc								; choke
+            b		.-4
+            
+
diff --git a/osfmk/ppc/spec_reg.h b/osfmk/ppc/spec_reg.h
index 93b670fae..ad15ec476 100644
--- a/osfmk/ppc/spec_reg.h
+++ b/osfmk/ppc/spec_reg.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -27,17 +30,13 @@
 #define _PPC_SPEC_REG_H_
 
 /* Defines for PVRs */
-#define PROCESSOR_VERSION_601		1
-#define PROCESSOR_VERSION_603		3
-#define PROCESSOR_VERSION_604		4
-#define PROCESSOR_VERSION_603e		6
-#define PROCESSOR_VERSION_750		8
+#define PROCESSOR_VERSION_750		8	/* ? */
 #define PROCESSOR_VERSION_750FX		0x7000  /* ? */
-#define PROCESSOR_VERSION_604e		9
-#define PROCESSOR_VERSION_604ev		10	/* ? */
 #define PROCESSOR_VERSION_7400		12	/* ? */
 #define PROCESSOR_VERSION_7410		0x800C	/* ? */
 #define PROCESSOR_VERSION_7450		0x8000	/* ? */
 #define PROCESSOR_VERSION_7455		0x8001	/* ? */
+#define PROCESSOR_VERSION_7457		0x8002	/* ? */
+#define PROCESSOR_VERSION_970		0x0039	/* ? */
 
 #endif /* _PPC_SPEC_REG_H_ */
diff --git a/osfmk/ppc/start.s b/osfmk/ppc/start.s
index 12714d551..29c228362 100644
--- a/osfmk/ppc/start.s
+++ b/osfmk/ppc/start.s
@@ -3,25 +3,31 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
 /*
  * @OSF_COPYRIGHT@
  */
+
+#define __APPLE_API_PRIVATE
+
 #include <cpus.h>
 #include <mach_kdb.h>
 #include <mach_kdp.h>
@@ -29,98 +35,58 @@
 #include <ppc/asm.h>
 #include <ppc/proc_reg.h>
 #include <ppc/spec_reg.h>
+#include <machine/cpu_capabilities.h>
 #include <mach/ppc/vm_param.h>
 #include <assym.s>
 	
-#define ptFilter 0
-#define ptVersion 4
-#define ptRevision 6
-#define ptFeatures 8
-#define ptInitRout 12
-#define ptRptdProc 16
-#define ptTempMax 20
-#define ptTempThr 24
-#define ptLineSize 28
-#define ptl1iSize 32
-#define ptl1dSize 36
-#define ptSize 40
+#define ptFilter	0
+#define ptVersion	4
+#define ptRevision	6
+#define ptFeatures	8
+#define ptCPUCap	12
+#define ptPatch		16
+#define ptInitRout	20
+#define ptRptdProc	24
+#define ptTempMax	28
+#define ptTempThr	32
+#define ptLineSize	36
+#define ptl1iSize	40
+#define ptl1dSize	44
+#define ptPTEG		48
+#define ptMaxVAddr	52
+#define ptMaxPAddr	56
+#define ptSize		60
 
 #define bootCPU 10
 #define firstInit 9
 #define firstBoot 8
 
-/* Defines for PVRs */
-#define PROCESSOR_VERSION_601		1
-#define PROCESSOR_VERSION_603		3
-#define PROCESSOR_VERSION_604		4
-#define PROCESSOR_VERSION_603e		6
-#define PROCESSOR_VERSION_750		8
-#define PROCESSOR_VERSION_750FX		0x7000  /* ? */
-#define PROCESSOR_VERSION_604e		9
-#define PROCESSOR_VERSION_604ev		10	/* ? */
-#define PROCESSOR_VERSION_7400		12	/* ? */
-#define PROCESSOR_VERSION_7410		0x800C	/* ? */
-#define PROCESSOR_VERSION_7450		0x8000	/* ? */
-#define PROCESSOR_VERSION_7455		0x8001	/* ? */
-
 /*
  * Interrupt and bootup stack for initial processor
  */
 
 	.file	"start.s"
 	
-	.data
-
-		/* Align on page boundry */
-	.align  PPC_PGSHIFT
-		/* Red zone for interrupt stack, one page (will be unmapped)*/
-	.set	., .+PPC_PGBYTES
-		/* intstack itself */
-
-     .globl  EXT(FixedStackStart)
-EXT(FixedStackStart):
-     
-	 .globl  EXT(intstack)
-EXT(intstack):
-	.set	., .+INTSTACK_SIZE*NCPUS
-	
-	/* Debugger stack - used by the debugger if present */
-	/* NOTE!!! Keep the debugger stack right after the interrupt stack */
-#if MACH_KDP || MACH_KDB
-    .globl  EXT(debstack)
-EXT(debstack):
-	.set	., .+KERNEL_STACK_SIZE*NCPUS
-     
-	 .globl  EXT(FixedStackEnd)
-EXT(FixedStackEnd):
-
-	.align	ALIGN
-    .globl  EXT(intstack_top_ss)
-EXT(intstack_top_ss):
-	.long	EXT(intstack)+INTSTACK_SIZE-FM_SIZE			/* intstack_top_ss points to the top of interrupt stack */
-
-	.align	ALIGN
-    .globl  EXT(debstack_top_ss)	
-EXT(debstack_top_ss):
-
-	.long	EXT(debstack)+KERNEL_STACK_SIZE-FM_SIZE		/* debstack_top_ss points to the top of debug stack */
-
-    .globl  EXT(debstackptr)
-EXT(debstackptr):	
-	.long	EXT(debstack)+KERNEL_STACK_SIZE-FM_SIZE
-
-#endif /* MACH_KDP || MACH_KDB */
-
 /*
  * All CPUs start here.
  *
  * This code is called from SecondaryLoader
  *
  * Various arguments are passed via a table:
- *   ARG0 = pointer to other startup parameters
+ *   R3 = pointer to other startup parameters
  */
 	.text
-	
+
+ENTRY(resetPOR,TAG_NO_FRAME_USED)
+
+			li		r12,0								; Get a 0
+			stw		r12,0xF0(0)							; Make sure the special flag is clear
+			mtmsrd	r12									; Make sure we are in 32-bit mode
+			isync										; Really make sure
+			lwz		r3,0xF4(0)							; Get the boot_args pointer
+			b		startJoin							; Join up...
+
+
 ENTRY(_start_cpu,TAG_NO_FRAME_USED)
 			crclr	bootCPU								; Set non-boot processor
 			crclr	firstInit							; Set not first time init
@@ -140,11 +106,12 @@ ENTRY(_start_cpu,TAG_NO_FRAME_USED)
 			mtspr	tbl,r17								; Clear bottom so we do not tick
 			mtspr	tbu,r15								; Set top
 			mtspr	tbl,r16								; Then bottom again
-			
 			b		allstart
 			
 ENTRY(_start,TAG_NO_FRAME_USED)
 
+startJoin:
+			mflr		r2					; Save the return address
 			lis		r30,hi16(EXT(per_proc_info))		; Set current per_proc
 			ori		r30,r30,lo16(EXT(per_proc_info))	; Set current per_proc
 			crset	bootCPU								; Set boot processor
@@ -162,52 +129,22 @@ ENTRY(_start,TAG_NO_FRAME_USED)
 			ori		r20,r20,LOW_ADDR(fwdisplock)		; Get address of the firmware display lock
 			stw		r19,0(r20)							; Make sure the lock is free
 			
-allstart:	mr		r31,r3								; Save away arguments
-			lis		r23,hi16(EXT(per_proc_info))		; Set base per_proc
-			ori		r23,r23,lo16(EXT(per_proc_info))	; Set base per_proc
-
-			mtsprg	0,r30								; Set the per_proc
+allstart:
+			mr		r31,r3								; Save away arguments
 
-			mfspr	r6,hid0								; Get the HID0
-			li		r7,MSR_VM_OFF						; Get real mode MSR			
-			rlwinm	r6,r6,0,sleep+1,doze-1				; Remove any vestiges of sleep
-			mtspr	hid0,r6								; Set the insominac HID0
-			mtmsr	r7									; Set the real mode SRR
-			isync					
+			crand	firstBoot,bootCPU,firstInit			; Indicate if we are on the initial first processor startup
 
-;			Map in the first 256Mb in both instruction and data BATs
+			mtsprg	0,r30								; Set the per_proc
 
-			li		r7,((0x7FF<<2)|2)  					; Set up for V=R 256MB in supervisor space
-			li      r8,((2<<3)|2)						; Physical address = 0, coherent, R/W
 			li		r9,0								; Clear out a register
-			
-			mtsprg	1,r9								; Clear the extra SPRGs
+			mtsprg	1,r9								; Clear the SPRGs
 			mtsprg	2,r9
 			mtsprg	3,r9
 
-			sync
-			isync
-			mtdbatu 0,r7								; Map bottom 256MB
-			mtdbatl 0,r8								; Map bottom 256MB
-			mtdbatu 1,r9								; Invalidate maps
-			mtdbatl 1,r9								; Invalidate maps
-			mtdbatu 2,r9								; Invalidate maps
-			mtdbatl 2,r9								; Invalidate maps
-			mtdbatu 3,r9								; Invalidate maps
-			mtdbatl 3,r9								; Invalidate maps
-			sync
-			isync
-			mtibatu 0,r7								; Map bottom 256MB
-			mtibatl 0,r8								; Map bottom 256MB
-			mtibatu 1,r9								; Invalidate maps
-			mtibatl 1,r9								; Invalidate maps
-			mtibatu 2,r9								; Invalidate maps
-			mtibatl 2,r9								; Invalidate maps
-			mtibatu 3,r9								; Invalidate maps
-			mtibatl 3,r9								; Invalidate maps
-			sync
-			isync
-			
+			li		r7,MSR_VM_OFF						; Get real mode MSR			
+			mtmsr	r7									; Set the real mode SRR
+			isync					
+
 			lis		r26,hi16(processor_types)			; Point to processor table
 			ori		r26,r26,lo16(processor_types)		; Other half
 			mfpvr	r10									; Get the PVR
@@ -223,21 +160,26 @@ nextPVR:	lwz		r28,ptFilter(r26)					; Get the filter
 donePVR:	lwz		r20,ptInitRout(r26)					; Grab the special init routine
 			mtlr	r20									; Setup to call the init
 
-			bf		firstInit,notFirst					; Not first boot, go...
+			bf		firstBoot,notFirst					; Not first boot, go...
 			
 ;			
 ;			The following code just does a general initialization of the features just
 ;			after the initial first-time boot.  This is not done after waking up or on
-;			any "secondary" processor.
+;			any "secondary" processor.  Just after the boot-processor init, we copy the
+;			features to any possible per_proc.
 ;
 ;			We are just setting defaults.   The specific initialization code will modify these
 ;			if necessary. 
 ;			
+			lis		r18,hi16(EXT(_cpu_capabilities))	; Get the address of _cpu_capabilities
+			ori		r18,r18,lo16(EXT(_cpu_capabilities))
+			lwz		r17,ptCPUCap(r26)					; Get the default cpu capabilities
+			stw		r17, 0(r18)							; Save the default value in _cpu_capabilities
 			
 			lwz		r17,ptFeatures(r26)					; Pick up the features
 			
-			lwz		r13,ptRptdProc(r26)					; Get the reported processor
-			sth		r13,pfrptdProc(r30)					; Set the reported processor
+			lwz		r18,ptRptdProc(r26)					; Get the reported processor
+			sth		r18,pfrptdProc(r30)					; Set the reported processor
 			
 			lwz		r13,ptTempMax(r26)					; Get maximum operating temperature
 			stw		r13,thrmmaxTemp(r30)				; Set the maximum
@@ -250,18 +192,63 @@ donePVR:	lwz		r20,ptInitRout(r26)					; Grab the special init routine
 			stw		r13,pfl1iSize(r30)					; Save it
 			lwz		r13,ptl1dSize(r26)					; Get dcache size
 			stw		r13,pfl1dSize(r30)					; Save it
+			lwz		r13,ptPTEG(r26)						; Get PTEG size address
+			stw		r13,pfPTEG(r30)						; Save it
+			lwz		r13,ptMaxVAddr(r26)					; Get max virtual address
+			stw		r13,pfMaxVAddr(r30)					; Save it
+			lwz		r13,ptMaxPAddr(r26)					; Get max physical address
+			stw		r13,pfMaxPAddr(r30)					; Save it
+			lis		r11,hi16(EXT(patch_table))
+			ori		r11,r11,lo16(EXT(patch_table))
+			lwz		r19,ptPatch(r26)					; Get ptPatch field
+			li		r12,PATCH_TABLE_SIZE
+			mtctr   r12
+patch_loop:
+			lwz		r16,patchType(r11)					; Load the patch type
+			lwz		r15,patchValue(r11)					; Load the patch value
+			cmplwi	cr1,r16,PATCH_FEATURE				; Is it a patch feature entry
+			and.	r14,r15,r19							; Is it set in the patch feature
+			crandc	cr0_eq,cr1_eq,cr0_eq				; Do we have a match
+			beq		patch_apply							; Yes, patch memory
+			cmplwi	cr1,r16,PATCH_PROCESSOR				; Is it a patch processor entry
+			cmplw	cr0,r15,r18							; Check matching processor
+			crand	cr0_eq,cr1_eq,cr0_eq				; Do we have a match
+			bne		patch_skip							; No, skip patch memory
+patch_apply:
+			lwz		r13,patchAddr(r11)					; Load the address to patch
+			lwz		r14,patchData(r11)					; Load the patch data
+			stw		r14,0(r13)							; Patch the location
+			dcbf	0,r13								; Flush the old one
+			sync										; Make sure we see it all
+			icbi	0,r13								; Flush the i-cache
+			isync										; Hang out
+			sync										; Hang out some more...
+patch_skip:
+			addi	r11,r11,peSize						; Point to the next patch entry
+			bdnz    patch_loop							; Loop if in the range
 			b		doOurInit							; Go do processor specific initialization...
 
 notFirst:	lwz		r17,pfAvailable(r30)				; Get our features
-			rlwinm.	r0,r17,0,pfValidb,pfValidb			; Have we set up this CPU yet?
-			bne		doOurInit							; Yeah, must be wakeup...
 
+doOurInit:	mr.		r20,r20								; See if initialization routine
+			crand	firstBoot,bootCPU,firstInit			; Indicate if we are on the initial first processor startup
+			bnelrl										; Do the initialization
+			
+			ori		r17,r17,lo16(pfValid)				; Set the valid bit
+			stw		r17,pfAvailable(r30)				; Set the available features
+
+			bf		firstBoot,nofeatcpy					; Skip feature propagate if not first time boot...
+
+			li		r2,NCPUS							; Get number of CPUs
 			lis		r23,hi16(EXT(per_proc_info))		; Set base per_proc
 			ori		r23,r23,lo16(EXT(per_proc_info))	; Set base per_proc
+			addi	r6,r23,ppSize						; Point to the next one
 			
-			la		r7,pfAvailable(r30)					; Point to features of our processor
+cpyFCpu:	addic.	r2,r2,-1							; Count down
 			la		r8,pfAvailable(r23)					; Point to features of boot processor
+			la		r7,pfAvailable(r6)					; Point to features of our processor
 			li		r9,(pfSize+thrmSize)/4				; Get size of a features area
+			ble--	nofeatcpy							; Copied all we need
 			
 cpyFeat:	subi	r9,r9,1								; Count word
 			lwz		r0,0(r8)							; Get boot cpu features
@@ -270,18 +257,75 @@ cpyFeat:	subi	r9,r9,1								; Count word
 			addi	r7,r7,4								; Next out
 			addi	r8,r8,4								; Next in
 			bgt		cpyFeat								; Copy all boot cpu features to us...
-			
-			lwz		r17,pfAvailable(r30)				; Get our newly initialized features			
 
-doOurInit:	
-			mr.		r20,r20								; See if initialization routine
-			crand	firstBoot,bootCPU,firstInit			; Indicate if we are on the initial first processor startup
-			bnelrl										; Do the initialization
+			lwz		r17,pfAvailable(r6)					; Get our newly initialized features			
+			addi	r6,r6,ppSize						; Point to the next one
+			b		cpyFCpu								; Do the next per_proc...
 			
-			ori		r17,r17,lo16(pfValid)				; Set the valid bit
-			stw		r17,pfAvailable(r30)				; Set the available features
+
+nofeatcpy:	rlwinm.	r0,r17,0,pf64Bitb,pf64Bitb			; Is this a 64-bit machine?
 			mtsprg	2,r17								; Remember the feature flags
+
+			bne++	start64								; Skip following if 64-bit...
+
+			mfspr	r6,hid0								; Get the HID0
+			rlwinm	r6,r6,0,sleep+1,doze-1				; Remove any vestiges of sleep
+			mtspr	hid0,r6								; Set the insominac HID0
+			isync					
+		
+;			Clear the BAT registers
+
+			li		r9,0								; Clear out a register
+			sync
+			isync
+			mtdbatu 0,r9								; Invalidate maps
+			mtdbatl 0,r9								; Invalidate maps
+			mtdbatu 1,r9								; Invalidate maps
+			mtdbatl 1,r9								; Invalidate maps
+			mtdbatu 2,r9								; Invalidate maps
+			mtdbatl 2,r9								; Invalidate maps
+			mtdbatu 3,r9								; Invalidate maps
+			mtdbatl 3,r9								; Invalidate maps
+			sync
+			isync
+			mtibatu 0,r9								; Invalidate maps
+			mtibatl 0,r9								; Invalidate maps
+			mtibatu 1,r9								; Invalidate maps
+			mtibatl 1,r9								; Invalidate maps
+			mtibatu 2,r9								; Invalidate maps
+			mtibatl 2,r9								; Invalidate maps
+			mtibatu 3,r9								; Invalidate maps
+			mtibatl 3,r9								; Invalidate maps
+			sync
+			isync
+			b		startcommon							; Go join up the common start routine
 			
+start64:	lis		r5,hi16(startcommon)				; Get top of address of continue point
+			mfspr	r6,hid0								; Get the HID0
+			ori		r5,r5,lo16(startcommon)				; Get low of address of continue point
+			lis		r9,hi16(MASK(MSR_HV))				; ?
+			lis		r20,hi16(dozem|napm|sleepm)			; Get mask of power saving features	
+			li		r7,MSR_VM_OFF						; Get real mode MSR, 64-bit off	
+			sldi	r9,r9,32							; Slide into position
+			sldi	r20,r20,32							; Slide power stuff into position
+			or		r9,r9,r7							; Form initial MSR
+			andc	r6,r6,r20							; Remove any vestiges of sleep
+			isync
+			mtspr	hid0,r6								; Set the insominac HID0
+			mfspr	r6,hid0								; Get it
+			mfspr	r6,hid0								; Get it
+			mfspr	r6,hid0								; Get it
+			mfspr	r6,hid0								; Get it
+			mfspr	r6,hid0								; Get it
+			mfspr	r6,hid0								; Get it
+			isync
+			mtsrr0	r5									; Set the continue point
+			mtsrr1	r9									; Set our normal disabled MSR				
+			rfid										; Tally ho...
+			
+			.align	5					
+
+startcommon:
 			rlwinm.	r0,r17,0,pfFloatb,pfFloatb			; See if there is floating point
 			beq-	noFloat								; Nope, this is a really stupid machine...
 			
@@ -343,7 +387,9 @@ noFloat:	rlwinm.	r0,r17,0,pfAltivecb,pfAltivecb		; See if there is Altivec
 
 			mtspr	vrsave,r0							; Set that no VRs are used yet */
 			
-			vspltisw	v1,0							; Clear a register
+			vspltish v1,1								; Turn on the non-Java bit and saturate
+			vspltisw v0,1								; Turn on the saturate bit
+			vxor	v1,v1,v0							; Turn off saturate	and leave non-Java set
 			lvx		v0,br0,r5							; Initialize VR0
 			mtvscr	v1									; Clear the vector status register
 			vor		v2,v0,v0							; Copy into the next register
@@ -402,12 +448,16 @@ noSMP:		rlwinm.	r0,r17,0,pfThermalb,pfThermalb		; See if there is an TAU
 noThermometer:
 			
 			bl		EXT(cacheInit)						; Initializes all caches (including the TLB)
+
+			rlwinm.	r0,r17,0,pf64Bitb,pf64Bitb			; Is this a 64-bit machine?
+			beq++	isnot64								; Skip following if not 64-bit...
 			
-			li		r0,MSR_SUPERVISOR_INT_OFF			; Make sure we do not have FP enabled
-			mtmsr	r0									; Set the standard MSR values
-			isync
+			mfmsr	r29									; Get the MSR
+			rlwinm	r29,r29,0,0,31						; Make sure that 64-bit mode is off
+			mtmsrd	r29									; Set it
+			isync										; Make sure
 			
-			bf		bootCPU,callcpu						; Not the boot processor...
+isnot64:	bf		bootCPU,callcpu					
 
 			lis		r29,HIGH_ADDR(EXT(intstack_top_ss))	; move onto interrupt stack
 			ori		r29,r29,LOW_ADDR(EXT(intstack_top_ss))
@@ -419,6 +469,8 @@ noThermometer:
 			mr		r1,r29
 			mr		r3,r31								; Restore any arguments we may have trashed
 
+;			Note that we exit from here with translation still off
+
 			bl	EXT(ppc_init)							; Jump into boot init code
 			BREAKPOINT_TRAP
 
@@ -432,6 +484,8 @@ callcpu:
 			mr		r1,r29								; move onto new stack
 			mr		r3,r31								; Restore any arguments we may have trashed
 
+;			Note that we exit from here with translation still off
+
 			bl		EXT(ppc_init_cpu)					; Jump into cpu init code
 			BREAKPOINT_TRAP								; Should never return
 
@@ -484,10 +538,10 @@ init750CX:
 			bf	firstBoot, init750						; No init for wakeup....
 			mfspr	r13,hid1							; Get HID1
 			li	r14,lo16(0xFD5F)						; Get valid
-			rlwinm	r13,r13,4,28,31							; Isolate
-			slw	r14,r14,r13							; Position
-			rlwimi	r17,r14,15-pfCanNapb,pfCanNapb,pfCanNapb			; Set it			
-			b	init750								; Join common...
+			rlwinm	r13,r13,4,28,31						; Isolate
+			slw	r14,r14,r13								; Position
+			rlwimi	r17,r14,15-pfCanNapb,pfCanNapb,pfCanNapb	; Set it			
+			b	init750									; Join common...
 
 
 ;			750FX
@@ -502,9 +556,9 @@ init750FXnb:
 			lwz	r13, pfHID0(r30)						; Get HID0
 			lwz	r11, pfHID1(r30)						; Get HID1
 
-			rlwinm.	r0, r11, 0, hid1ps, hid1ps					; Isolate the hid1ps bit
+			rlwinm.	r0, r11, 0, hid1ps, hid1ps			; Isolate the hid1ps bit
 			beq	init750FXnb2							; Clear BTIC if hid1ps set
-			rlwinm	r13, r13, 0, btic+1, btic-1					; Clear the BTIC bit
+			rlwinm	r13, r13, 0, btic+1, btic-1			; Clear the BTIC bit
 
 init750FXnb2:
 			sync
@@ -512,9 +566,9 @@ init750FXnb2:
 			isync
 			sync
 
-			rlwinm  r12, r11, 0, hid1ps+1, hid1ps-1					; Select PLL0
+			rlwinm  r12, r11, 0, hid1ps+1, hid1ps-1		; Select PLL0
 			mtspr	hid1, r12							; Restore PLL config
-			mftb	r13								; Wait 5000 ticks (> 200 us)
+			mftb	r13									; Wait 5000 ticks (> 200 us)
 
 init750FXnbloop:
 			mftb	r14
@@ -524,6 +578,21 @@ init750FXnbloop:
 			mtspr	hid1, r11							; Select the desired PLL
 			blr
 
+;			750FX vers 2.0 or later
+init750FXV2:
+			bf	firstBoot, init750FXV2nb					; Wake from sleep
+
+			mfspr	r11, hid2
+			stw	r11, pfHID2(r30)						; Save the HID2 value
+			b	init750FX							; Continue with 750FX init
+
+init750FXV2nb:
+			lwz	r13, pfHID2(r30)						; Get HID2
+			rlwinm	r13, r13, 0, hid2vmin+1, hid2vmin-1				; Clear the vmin bit
+			mtspr	hid2, r13							; Restore HID2 value
+			sync									; Wait for it to be done
+			b	init750FX
+
 ;			7400
 
 init7400:	bf		firstBoot,i7400nb					; Do different if not initial boot...
@@ -537,7 +606,7 @@ i7400hl2:	lis		r14,hi16(256*1024)					; Base L2 size
 			rlwinm	r15,r15,4,30,31						 
 			slw		r14,r14,r15							; Set 256KB, 512KB, 1MB, or 2MB
 			
-			stw		r13,pfl2crOriginal(r30)					; Shadow the L2CR
+			stw		r13,pfl2crOriginal(r30)				; Shadow the L2CR
 			stw		r13,pfl2cr(r30)						; Shadow the L2CR
 			stw		r14,pfl2Size(r30)					; Set the L2 size
 			
@@ -555,7 +624,7 @@ i7400hl2:	lis		r14,hi16(256*1024)					; Base L2 size
 			
 i7400nb:
 			li		r11,0
-			mtspr		l2cr,r11						; Make sure L2CR is zero
+			mtspr	l2cr,r11							; Make sure L2CR is zero
 			lwz		r11,pfHID0(r30)						; Get HID0
 			sync
 			mtspr	hid0,r11							; Set the HID
@@ -595,17 +664,25 @@ init7410:	li		r13,0								; Clear
 ;			745X - Any 7450 family processor
 
 init745X:
-			bf		firstBoot,init745Xnb					; Do different if not initial boot...
+			bf		firstBoot,init745Xnb				; Do different if not initial boot...
 
 			mfspr	r13,l2cr							; Get the L2CR
 			rlwinm.	r0,r13,0,l2e,l2e					; Any L2?
 			bne+	init745Xhl2							; Yes...
 			rlwinm	r17,r17,0,pfL2b+1,pfL2b-1			; No L2, turn off feature
 			
-init745Xhl2:	lis		r14,hi16(256*1024)					; Base L2 size
+init745Xhl2:
+			mfpvr	r14								; Get processor version
+			rlwinm	r14,r14,16,16,31						; Isolate processor version
+			cmpli	cr0, r14, PROCESSOR_VERSION_7457
+			lis		r14,hi16(512*1024)					; 512KB L2
+			beq	init745Xhl2_2
+
+			lis		r14,hi16(256*1024)					; Base L2 size
 			rlwinm	r15,r13,22,12,13					; Convert to 256k, 512k, or 768k
 			add		r14,r14,r15							; Add in minimum
-			
+
+init745Xhl2_2:
 			stw		r13,pfl2crOriginal(r30)					; Shadow the L2CR
 			stw		r13,pfl2cr(r30)						; Shadow the L2CR
 			stw		r14,pfl2Size(r30)					; Set the L2 size
@@ -617,24 +694,24 @@ init745Xhl2:	lis		r14,hi16(256*1024)					; Base L2 size
 			bne+	init745Xhl3							; Yes...
 			rlwinm	r17,r17,0,pfL3b+1,pfL3b-1			; No L3, turn off feature
 
-init745Xhl3:	cmplwi	cr0,r13,0							; No L3 if L3CR is zero
-			beq-	init745Xnone							; Go turn off the features...
+init745Xhl3:	cmplwi	cr0,r13,0						; No L3 if L3CR is zero
+			beq-	init745Xnone						; Go turn off the features...
 			lis		r14,hi16(1024*1024)					; Base L3 size
 			rlwinm	r15,r13,4,31,31						; Get size multiplier
 			slw		r14,r14,r15							; Set 1 or 2MB
 			
-			stw		r13,pfl3crOriginal(r30)					; Shadow the L3CR
+			stw		r13,pfl3crOriginal(r30)				; Shadow the L3CR
 			stw		r13,pfl3cr(r30)						; Shadow the L3CR
 			stw		r14,pfl3Size(r30)					; Set the L3 size
 			b		init745Xfin							; Return....
 				
 init745Xnone:
-			rlwinm	r17,r17,0,pfL3fab+1,pfL3b-1					; No 3rd level cache or assist
+			rlwinm	r17,r17,0,pfL3fab+1,pfL3b-1			; No 3rd level cache or assist
 			rlwinm	r11,r17,pfWillNapb-pfCanNapb,pfCanNapb,pfCanNapb		; Set pfCanNap if pfWillNap is set
 			or	r17,r17,r11
 
 init745Xfin:
-			rlwinm	r17,r17,0,pfWillNapb+1,pfWillNapb-1				; Make sure pfWillNap is not set
+			rlwinm	r17,r17,0,pfWillNapb+1,pfWillNapb-1	; Make sure pfWillNap is not set
 
 			mfspr	r11,hid0							; Get the current HID0
 			stw		r11,pfHID0(r30)						; Save the HID0 value
@@ -701,6 +778,73 @@ init7450done:
 			b	init745X							; Continue with standard init
 
 
+init970:	
+			li		r20,0								; Clear this
+			mtspr	hior,r20							; Make sure that  0 is interrupt prefix
+			bf		firstBoot,init970nb					; No init for wakeup or second processor....
+
+
+			mfspr	r11,hid0							; Get original hid0
+			std		r11,pfHID0(r30)						; Save original
+			mfspr	r11,hid1							; Get original hid1
+			std		r11,pfHID1(r30)						; Save original
+			mfspr	r11,hid4							; Get original hid4
+			std		r11,pfHID4(r30)						; Save original
+			mfspr	r11,hid5							; Get original hid5
+			std		r11,pfHID5(r30)						; Save original
+		
+;
+;			We can not query or change the L2 size.  We will just
+;			phoney up a L2CR to make sysctl "happy" and set the
+;			L2 size to 512K.
+;
+
+			lis		r0,0x8000							; Synthesize a "valid" but non-existant L2CR
+			stw		r0,pfl2crOriginal(r30)				; Set a dummy L2CR
+			stw		r0,pfl2cr(r30)						; Set a dummy L2CR
+			lis		r0,8								; Get 512K
+			stw		r0,pfl2Size(r30)					; Set the L2 size
+
+			blr
+			
+;
+;			Start up code for second processor or wake up from sleep
+;
+			
+init970nb:	ld		r11,pfHID0(r30)						; Get it
+			isync
+			mtspr	hid0,r11							; Stuff it
+			mfspr	r11,hid0							; Get it
+			mfspr	r11,hid0							; Get it
+			mfspr	r11,hid0							; Get it
+			mfspr	r11,hid0							; Get it
+			mfspr	r11,hid0							; Get it
+			mfspr	r11,hid0							; Get it
+			isync
+		
+			ld		r11,pfHID1(r30)						; Get it
+			isync
+			mtspr	hid1,r11							; Stick it
+			mtspr	hid1,r11							; Stick it again
+			isync
+		
+			ld		r11,pfHID4(r30)						; Get it
+			sync
+			mtspr	hid4,r11							; Stick it
+			isync
+			
+			ld		r11,pfHID5(r30)						; Get it
+			mtspr	hid5,r11							; Set it
+			isync
+			blr											; Leave...
+		
+
+;			Unsupported Processors
+initUnsupported:
+			mtlr	r2					; Restore the return address
+			blr						; Return to the booter
+
+
 ;
 ;	Processor to feature table
 
@@ -710,6 +854,8 @@ init7450done:
 ;	.short	ptVersion		- Version code from PVR.  Always start with 0 which is default
 ;	.short	ptRevision		- Revision code from PVR. A zero value denotes the generic attributes if not specific
 ;	.long	ptFeatures		- Available features
+;	.long	ptCPUCap		- Default value for _cpu_capabilities
+;	.long	ptPatch			- Patch features
 ;	.long	ptInitRout		- Initilization routine.  Can modify any of the other attributes.
 ;	.long	ptRptdProc		- Processor type reported
 ;	.long	ptTempMax		- Maximum operating temprature
@@ -717,322 +863,371 @@ init7450done:
 ;	.long	ptLineSize		- Level 1 cache line size
 ;	.long	ptl1iSize		- Level 1 instruction cache size
 ;	.long	ptl1dSize		- Level 1 data cache size
+;	.long	ptPTEG			- Size of PTEG
+;	.long	ptMaxVAddr		- Maximum effective address
+;	.long	ptMaxPAddr		- Maximum physical address
+;
 	
 	.align	2
 processor_types:
 
-	
-;	601 (generic)
-
-	.align	2
-	.long	0xFFFF0000		; All revisions
-	.short	PROCESSOR_VERSION_601
-	.short	0
-	.long	pfFloat | pfSMPcap | pfL1i | pfL1d
-	.long	0
-	.long	CPU_SUBTYPE_POWERPC_ALL
-	.long	0
-	.long	0
-	.long	32
-	.long	32*1024
-	.long	32*1024
-	
-;	603 (generic)
-
-	.align	2
-	.long	0xFFFF0000		; All revisions
-	.short	PROCESSOR_VERSION_603
-	.short	0
-	.long	pfFloat | pfL1i | pfL1d
-	.long	0
-	.long	CPU_SUBTYPE_POWERPC_603
-	.long	0
-	.long	0
-	.long	32
-	.long	32*1024
-	.long	32*1024
-	
-;	603e (generic)
-
-	.align	2
-	.long	0xFFFF0000		; All revisions
-	.short	PROCESSOR_VERSION_603e
-	.short	0
-	.long	pfFloat | pfL1i | pfL1d
-	.long	0
-	.long	CPU_SUBTYPE_POWERPC_603e
-	.long	0
-	.long	0
-	.long	32
-	.long	32*1024
-	.long	32*1024
-	
-;	604 (generic)
-
-	.align	2
-	.long	0xFFFF0000		; All revisions
-	.short	PROCESSOR_VERSION_604
-	.short	0
-	.long	pfFloat | pfSMPcap | pfL1i | pfL1d
-	.long	0
-	.long	CPU_SUBTYPE_POWERPC_604
-	.long	0
-	.long	0
-	.long	32
-	.long	32*1024
-	.long	32*1024
-	
-;	604e (generic)
-
-	.align	2
-	.long	0xFFFF0000		; All revisions
-	.short	PROCESSOR_VERSION_604e
-	.short	0
-	.long	pfFloat | pfSMPcap | pfL1i | pfL1d
-	.long	0
-	.long	CPU_SUBTYPE_POWERPC_604e
-	.long	0
-	.long	0
-	.long	32
-	.long	32*1024
-	.long	32*1024
-	
-;	604ev (generic)
-
-	.align	2
-	.long	0xFFFF0000		; All revisions
-	.short	PROCESSOR_VERSION_604ev
-	.short	0
-	.long	pfFloat | pfSMPcap | pfL1i | pfL1d
-	.long	0
-	.long	CPU_SUBTYPE_POWERPC_604e
-	.long	0
-	.long	0
-	.long	32
-	.long	32*1024
-	.long	32*1024
-
 ;       750 (ver 2.2)
 
-        .align  2
-        .long   0xFFFFFFFF              ; Exact match
-        .short  PROCESSOR_VERSION_750
-        .short  0x4202
-        .long   pfFloat | pfCanSleep | pfCanNap | pfCanDoze | pfL1i | pfL1d | pfL2
-        .long   init750
-        .long   CPU_SUBTYPE_POWERPC_750
-        .long   105
-        .long   90
-        .long   32
-        .long   32*1024
-        .long   32*1024
+			.align  2
+			.long   0xFFFFFFFF              ; Exact match
+			.short  PROCESSOR_VERSION_750
+			.short  0x4202
+			.long   pfFloat | pfCanSleep | pfCanNap | pfCanDoze | pf32Byte | pfL2
+			.long   kCache32 | kHasGraphicsOps | kHasStfiwx
+			.long	PatchExt32
+			.long   init750
+			.long   CPU_SUBTYPE_POWERPC_750
+			.long   105
+			.long   90
+			.long   32
+			.long   32*1024
+			.long   32*1024
+			.long	64
+			.long	52
+			.long	32
 
 ;       750CX (ver 2.x)
 
-        .align  2
-        .long   0xFFFF0F00              ; 2.x vers
-        .short  PROCESSOR_VERSION_750
-        .short  0x0200
-        .long   pfFloat | pfCanSleep | pfCanNap | pfCanDoze | pfL1i | pfL1d | pfL2
-        .long   init750CX
-        .long   CPU_SUBTYPE_POWERPC_750
-        .long   105
-        .long   90
-        .long   32
-        .long   32*1024
-        .long   32*1024
-	
+			.align  2
+			.long   0xFFFF0F00              ; 2.x vers
+			.short  PROCESSOR_VERSION_750
+			.short  0x0200
+			.long   pfFloat | pfCanSleep | pfCanNap | pfCanDoze | pf32Byte | pfL2
+			.long   kCache32 | kHasGraphicsOps | kHasStfiwx
+			.long	PatchExt32
+			.long   init750CX
+			.long   CPU_SUBTYPE_POWERPC_750
+			.long   105
+			.long   90
+			.long   32
+			.long   32*1024
+			.long   32*1024
+			.long	64
+			.long	52
+			.long	32
+
 ;	750 (generic)
 
-	.align	2
-	.long	0xFFFF0000		; All revisions
-	.short	PROCESSOR_VERSION_750
-	.short	0
-	.long	pfFloat | pfCanSleep | pfCanNap | pfCanDoze | pfThermal | pfL1i | pfL1d | pfL2
-	.long	init750
-	.long	CPU_SUBTYPE_POWERPC_750
-	.long	105
-	.long	90
-	.long	32
-	.long	32*1024
-	.long	32*1024
-	
+			.align	2
+			.long	0xFFFF0000		; All revisions
+			.short	PROCESSOR_VERSION_750
+			.short	0
+			.long	pfFloat | pfCanSleep | pfCanNap | pfCanDoze | pfThermal | pf32Byte | pfL2
+			.long   kCache32 | kHasGraphicsOps | kHasStfiwx
+			.long	PatchExt32
+			.long	init750
+			.long	CPU_SUBTYPE_POWERPC_750
+			.long	105
+			.long	90
+			.long	32
+			.long	32*1024
+			.long	32*1024
+			.long	64
+			.long	52
+			.long	32
+
+;       750FX (ver 1.x)
+
+			.align  2
+			.long   0xFFFF0F00              ; 1.x vers
+			.short  PROCESSOR_VERSION_750FX
+			.short  0x0100
+			.long   pfFloat | pfCanSleep | pfCanNap | pfCanDoze | pfSlowNap | pfNoMuMMCK | pf32Byte | pfL2
+			.long   kCache32 | kHasGraphicsOps | kHasStfiwx
+			.long	PatchExt32
+			.long   init750FX
+			.long   CPU_SUBTYPE_POWERPC_750
+			.long   105
+			.long   90
+			.long   32
+			.long   32*1024
+			.long   32*1024
+			.long	64
+			.long	52
+			.long	32
+
 ;       750FX (generic)
 
-        .align  2
-        .long   0xFFFF0000              ; All revisions
-        .short  PROCESSOR_VERSION_750FX
-        .short  0
-        .long   pfFloat | pfCanSleep | pfCanNap | pfCanDoze | pfSlowNap | pfNoMuMMCK | pfL1i | pfL1d | pfL2
-        .long   init750FX
-        .long   CPU_SUBTYPE_POWERPC_750
-        .long   105
-        .long   90
-        .long   32
-        .long   32*1024
-        .long   32*1024
-	
+			.align  2
+			.long   0xFFFF0000              ; All revisions
+			.short  PROCESSOR_VERSION_750FX
+			.short  0
+			.long   pfFloat | pfCanSleep | pfCanNap | pfCanDoze | pfSlowNap | pfNoMuMMCK | pf32Byte | pfL2
+			.long   kCache32 | kHasGraphicsOps | kHasStfiwx
+			.long	PatchExt32
+			.long   init750FXV2
+			.long   CPU_SUBTYPE_POWERPC_750
+			.long   105
+			.long   90
+			.long   32
+			.long   32*1024
+			.long   32*1024
+			.long	64
+			.long	52
+			.long	32
+
 ;	7400 (ver 2.0 - ver 2.7)
 
-	.align	2
-	.long	0xFFFFFFF8		; All revisions
-	.short	PROCESSOR_VERSION_7400
-	.short	0x0200
-	.long	pfFloat | pfAltivec | pfSMPcap | pfCanSleep | pfCanNap | pfCanDoze | pfThermal | pfL1i | pfL1d | pfL1fa | pfL2 | pfL2fa
-	.long	init7400v2_7
-	.long	CPU_SUBTYPE_POWERPC_7400
-	.long	105
-	.long	90
-	.long	32
-	.long	32*1024
-	.long	32*1024
-	
+			.align	2
+			.long	0xFFFFFFF8		; ver 2.0 - 2.7
+			.short	PROCESSOR_VERSION_7400
+			.short	0x0200
+			.long	pfFloat | pfAltivec | pfSMPcap | pfCanSleep | pfCanNap | pfCanDoze | pfThermal | pf32Byte | pfL1fa | pfL2 | pfL2fa | pfHasDcba
+			.long   kHasAltivec | kCache32 | kDcbaAvailable | kDataStreamsAvailable | kHasGraphicsOps | kHasStfiwx
+			.long	PatchExt32
+			.long	init7400v2_7
+			.long	CPU_SUBTYPE_POWERPC_7400
+			.long	105
+			.long	90
+			.long	32
+			.long	32*1024
+			.long	32*1024
+			.long	64
+			.long	52
+			.long	32
+
 ;	7400 (generic)
 
-	.align	2
-	.long	0xFFFF0000		; All revisions
-	.short	PROCESSOR_VERSION_7400
-	.short	0
-	.long	pfFloat | pfAltivec | pfSMPcap | pfCanSleep | pfCanNap | pfCanDoze | pfThermal | pfL1i | pfL1d | pfL1fa | pfL2 | pfL2fa
-	.long	init7400
-	.long	CPU_SUBTYPE_POWERPC_7400
-	.long	105
-	.long	90
-	.long	32
-	.long	32*1024
-	.long	32*1024
-	
+			.align	2
+			.long	0xFFFF0000		; All revisions
+			.short	PROCESSOR_VERSION_7400
+			.short	0
+			.long	pfFloat | pfAltivec | pfSMPcap | pfCanSleep | pfCanNap | pfCanDoze | pfThermal | pf32Byte | pfL1fa | pfL2 | pfL2fa | pfHasDcba
+			.long   kHasAltivec | kCache32 | kDcbaAvailable | kDataStreamsRecommended | kDataStreamsAvailable | kHasGraphicsOps | kHasStfiwx
+			.long	PatchExt32
+			.long	init7400
+			.long	CPU_SUBTYPE_POWERPC_7400
+			.long	105
+			.long	90
+			.long	32
+			.long	32*1024
+			.long	32*1024
+			.long	64
+			.long	52
+			.long	36
+
 ;	7410 (ver 1.1)
 
-	.align	2
-	.long	0xFFFFFFFF		; Exact match
-	.short	PROCESSOR_VERSION_7400
-	.short	0x1101
-	.long	pfFloat | pfAltivec | pfSMPcap | pfCanSleep | pfCanNap | pfCanDoze | pfL1i | pfL1d | pfL1fa | pfL2 | pfL2fa
-	.long	init7410
-	.long	CPU_SUBTYPE_POWERPC_7400
-	.long	105
-	.long	90
-	.long	32
-	.long	32*1024
-	.long	32*1024
+			.align	2
+			.long	0xFFFFFFFF		; Exact match
+			.short	PROCESSOR_VERSION_7400
+			.short	0x1101
+			.long	pfFloat | pfAltivec | pfSMPcap | pfCanSleep | pfCanNap | pfCanDoze | pf32Byte | pfL1fa | pfL2 | pfL2fa | pfHasDcba
+			.long   kHasAltivec | kCache32 | kDcbaAvailable | kDataStreamsRecommended | kDataStreamsAvailable | kHasGraphicsOps | kHasStfiwx
+			.long	PatchExt32
+			.long	init7410
+			.long	CPU_SUBTYPE_POWERPC_7400
+			.long	105
+			.long	90
+			.long	32
+			.long	32*1024
+			.long	32*1024
+			.long	64
+			.long	52
+			.long	36
 
 ;	7410 (generic)
 
-	.align	2
-	.long	0xFFFF0000		; All other revisions
-	.short	PROCESSOR_VERSION_7410
-	.short	0
-	.long	pfFloat | pfAltivec | pfSMPcap | pfCanSleep | pfCanNap | pfCanDoze | pfL1i | pfL1d | pfL1fa | pfL2 | pfL2fa
-	.long	init7410
-	.long	CPU_SUBTYPE_POWERPC_7400
-	.long	105
-	.long	90
-	.long	32
-	.long	32*1024
-	.long	32*1024
+			.align	2
+			.long	0xFFFF0000		; All other revisions
+			.short	PROCESSOR_VERSION_7410
+			.short	0
+			.long	pfFloat | pfAltivec | pfSMPcap | pfCanSleep | pfCanNap | pfCanDoze | pf32Byte | pfL1fa | pfL2 | pfL2fa | pfHasDcba
+			.long   kHasAltivec | kCache32 | kDcbaAvailable | kDataStreamsRecommended | kDataStreamsAvailable | kHasGraphicsOps | kHasStfiwx
+			.long	PatchExt32
+			.long	init7410
+			.long	CPU_SUBTYPE_POWERPC_7400
+			.long	105
+			.long	90
+			.long	32
+			.long	32*1024
+			.long	32*1024
+			.long	64
+			.long	52
+			.long	36
 
 ;	7450 (ver 1.xx)
 
-	.align	2
-	.long	0xFFFFFF00		; Just revisions 1.xx
-	.short	PROCESSOR_VERSION_7450
-	.short	0x0100
-	.long	pfFloat | pfAltivec | pfSMPcap | pfCanSleep | pfNoMSRir | pfNoL2PFNap | pfLClck | pfL1i | pfL1d | pfL2 | pfL2fa | pfL2i | pfL3 | pfL3fa
-	.long	init7450
-	.long	CPU_SUBTYPE_POWERPC_7450
-	.long	105
-	.long	90
-	.long	32
-	.long	32*1024
-	.long	32*1024
+			.align	2
+			.long	0xFFFFFF00		; Just revisions 1.xx
+			.short	PROCESSOR_VERSION_7450
+			.short	0x0100
+			.long	pfFloat | pfAltivec | pfSMPcap | pfCanSleep | pfNoMSRir | pfNoL2PFNap | pfLClck | pf32Byte | pfL2 | pfL2fa | pfL2i | pfL3 | pfL3fa  | pfHasDcba
+			.long   kHasAltivec | kCache32 | kDcbaAvailable | kDataStreamsRecommended | kDataStreamsAvailable | kHasGraphicsOps | kHasStfiwx
+			.long	PatchExt32
+			.long	init7450
+			.long	CPU_SUBTYPE_POWERPC_7450
+			.long	105
+			.long	90
+			.long	32
+			.long	32*1024
+			.long	32*1024
+			.long	64
+			.long	52
+			.long	36
 
 ;	7450 (2.0)
 
-	.align	2
-	.long	0xFFFFFFFF		; Just revision 2.0
-	.short	PROCESSOR_VERSION_7450
-	.short	0x0200
-	.long	pfFloat | pfAltivec | pfSMPcap | pfCanSleep | pfNoMSRir | pfNoL2PFNap | pfLClck | pfL1i | pfL1d | pfL2 | pfL2fa | pfL2i | pfL3 | pfL3fa
-	.long	init7450
-	.long	CPU_SUBTYPE_POWERPC_7450
-	.long	105
-	.long	90
-	.long	32
-	.long	32*1024
-	.long	32*1024
+			.align	2
+			.long	0xFFFFFFFF		; Just revision 2.0
+			.short	PROCESSOR_VERSION_7450
+			.short	0x0200
+			.long	pfFloat | pfAltivec | pfSMPcap | pfCanSleep | pfNoMSRir | pfNoL2PFNap | pfLClck | pf32Byte | pfL2 | pfL2fa | pfL2i | pfL3 | pfL3fa | pfHasDcba
+			.long   kHasAltivec | kCache32 | kDcbaAvailable | kDataStreamsRecommended | kDataStreamsAvailable | kHasGraphicsOps | kHasStfiwx
+			.long	PatchExt32
+			.long	init7450
+			.long	CPU_SUBTYPE_POWERPC_7450
+			.long	105
+			.long	90
+			.long	32
+			.long	32*1024
+			.long	32*1024
+			.long	64
+			.long	52
+			.long	36
 
 ;	7450 (2.1)
 
-	.align	2
-	.long	0xFFFF0000		; All other revisions
-	.short	PROCESSOR_VERSION_7450
-	.short	0
-	.long	pfFloat | pfAltivec | pfSMPcap | pfCanSleep | pfWillNap | pfNoMSRir | pfNoL2PFNap | pfLClck | pfL1i | pfL1d | pfL2 | pfL2fa | pfL2i | pfL3 | pfL3fa
-	.long	init7450
-	.long	CPU_SUBTYPE_POWERPC_7450
-	.long	105
-	.long	90
-	.long	32
-	.long	32*1024
-	.long	32*1024
+			.align	2
+			.long	0xFFFF0000		; All other revisions
+			.short	PROCESSOR_VERSION_7450
+			.short	0
+			.long	pfFloat | pfAltivec | pfSMPcap | pfCanSleep | pfWillNap | pfNoMSRir | pfNoL2PFNap | pfLClck | pf32Byte | pfL2 | pfL2fa | pfL2i | pfL3 | pfL3fa | pfHasDcba
+			.long   kHasAltivec | kCache32 | kDcbaAvailable | kDataStreamsRecommended | kDataStreamsAvailable | kHasGraphicsOps | kHasStfiwx
+			.long	PatchExt32
+			.long	init7450
+			.long	CPU_SUBTYPE_POWERPC_7450
+			.long	105
+			.long	90
+			.long	32
+			.long	32*1024
+			.long	32*1024
+			.long	64
+			.long	52
+			.long	36
 
 ;	7455 (1.xx)  Just like 7450 2.0
 
-	.align	2
-	.long	0xFFFFFF00		; Just revisions 1.xx
-	.short	PROCESSOR_VERSION_7455
-	.short	0x0100
-	.long	pfFloat | pfAltivec | pfSMPcap | pfCanSleep | pfNoMSRir | pfNoL2PFNap | pfLClck | pfL1i | pfL1d | pfL2 | pfL2fa | pfL2i | pfL3 | pfL3fa
-	.long	init745X
-	.long	CPU_SUBTYPE_POWERPC_7450
-	.long	105
-	.long	90
-	.long	32
-	.long	32*1024
-	.long	32*1024
+			.align	2
+			.long	0xFFFFFF00		; Just revisions 1.xx
+			.short	PROCESSOR_VERSION_7455
+			.short	0x0100
+			.long	pfFloat | pfAltivec | pfSMPcap | pfCanSleep | pfNoMSRir | pfNoL2PFNap | pfLClck | pf32Byte | pfL2 | pfL2fa | pfL2i | pfL3 | pfL3fa | pfHasDcba
+			.long   kHasAltivec | kCache32 | kDcbaAvailable | kDataStreamsRecommended | kDataStreamsAvailable | kHasGraphicsOps | kHasStfiwx
+			.long	PatchExt32
+			.long	init745X
+			.long	CPU_SUBTYPE_POWERPC_7450
+			.long	105
+			.long	90
+			.long	32
+			.long	32*1024
+			.long	32*1024
+			.long	64
+			.long	52
+			.long	36
 
 ;	7455 (2.0)
 
-	.align	2
-	.long	0xFFFFFFFF		; Just revision 2.0
-	.short	PROCESSOR_VERSION_7455
-	.short	0x0200
-	.long	pfFloat | pfAltivec | pfSMPcap | pfCanSleep | pfWillNap | pfNoMSRir | pfNoL2PFNap | pfLClck | pfL1i | pfL1d | pfL2 | pfL2fa | pfL2i | pfL3 | pfL3fa
-	.long	init745X
-	.long	CPU_SUBTYPE_POWERPC_7450
-	.long	105
-	.long	90
-	.long	32
-	.long	32*1024
-	.long	32*1024
+			.align	2
+			.long	0xFFFFFFFF		; Just revision 2.0
+			.short	PROCESSOR_VERSION_7455
+			.short	0x0200
+			.long	pfFloat | pfAltivec | pfSMPcap | pfCanSleep | pfWillNap | pfNoMSRir | pfNoL2PFNap | pfLClck | pf32Byte | pfL2 | pfL2fa | pfL2i | pfL3 | pfL3fa | pfHasDcba
+			.long   kHasAltivec | kCache32 | kDcbaAvailable | kDataStreamsRecommended | kDataStreamsAvailable | kHasGraphicsOps | kHasStfiwx
+			.long	PatchExt32
+			.long	init745X
+			.long	CPU_SUBTYPE_POWERPC_7450
+			.long	105
+			.long	90
+			.long	32
+			.long	32*1024
+			.long	32*1024
+			.long	64
+			.long	52
+			.long	36
 
 ;	7455 (2.1)
 
-	.align	2
-	.long	0xFFFF0000		; All other revisions
-	.short	PROCESSOR_VERSION_7455
-	.short	0
-	.long	pfFloat | pfAltivec | pfSMPcap | pfCanSleep | pfCanNap | pfNoMSRir | pfNoL2PFNap | pfLClck | pfL1i | pfL1d | pfL2 | pfL2fa | pfL2i | pfL3 | pfL3fa
-	.long	init745X
-	.long	CPU_SUBTYPE_POWERPC_7450
-	.long	105
-	.long	90
-	.long	32
-	.long	32*1024
-	.long	32*1024
-
-;	Default dumb loser machine
+			.align	2
+			.long	0xFFFF0000		; All other revisions
+			.short	PROCESSOR_VERSION_7455
+			.short	0
+			.long	pfFloat | pfAltivec | pfSMPcap | pfCanSleep | pfCanNap | pfNoMSRir | pfNoL2PFNap | pfLClck | pf32Byte | pfL2 | pfL2fa | pfL2i | pfL3 | pfL3fa | pfHasDcba
+			.long   kHasAltivec | kCache32 | kDcbaAvailable | kDataStreamsRecommended | kDataStreamsAvailable | kHasGraphicsOps | kHasStfiwx
+			.long	PatchExt32
+			.long	init745X
+			.long	CPU_SUBTYPE_POWERPC_7450
+			.long	105
+			.long	90
+			.long	32
+			.long	32*1024
+			.long	32*1024
+			.long	64
+			.long	52
+			.long	36
+
+;	7457
+
+			.align	2
+			.long	0xFFFF0000		; All revisions
+			.short	PROCESSOR_VERSION_7457
+			.short	0
+			.long	pfFloat | pfAltivec | pfSMPcap | pfCanSleep | pfCanNap | pfNoMSRir | pfNoL2PFNap | pfLClck | pf32Byte | pfL2 | pfL2fa | pfL2i | pfL3 | pfL3fa | pfHasDcba
+			.long   kHasAltivec | kCache32 | kDcbaAvailable | kDataStreamsRecommended | kDataStreamsAvailable | kHasGraphicsOps | kHasStfiwx
+			.long	PatchExt32
+			.long	init745X
+			.long	CPU_SUBTYPE_POWERPC_7450
+			.long	105
+			.long	90
+			.long	32
+			.long	32*1024
+			.long	32*1024
+			.long	64
+			.long	52
+			.long	36
+
+;	970
+
+			.align	2
+			.long	0xFFFF0000		; All versions so far
+			.short	PROCESSOR_VERSION_970
+			.short	0
+			.long	pfFloat | pfAltivec | pfSMPcap | pfCanSleep | pfCanNap | pf128Byte | pf64Bit | pfL2 | pfSCOMFixUp
+			.long   kHasAltivec | k64Bit | kCache128 | kDataStreamsAvailable | kDcbtStreamsRecommended | kDcbtStreamsAvailable | kHasGraphicsOps | kHasStfiwx | kHasFsqrt
+			.long	PatchLwsync
+			.long	init970
+			.long	CPU_SUBTYPE_POWERPC_970
+			.long	105
+			.long	90
+			.long	128
+			.long	64*1024
+			.long	32*1024
+			.long	128
+			.long	65
+			.long	42
+
+;	All other processors are not supported
+
+			.align	2
+			.long	0x00000000		; Matches everything
+			.short	0
+			.short	0
+			.long	pfFloat | pf32Byte
+			.long   kCache32 | kHasGraphicsOps | kHasStfiwx
+			.long	PatchExt32
+			.long	initUnsupported
+			.long	CPU_SUBTYPE_POWERPC_ALL
+			.long	105
+			.long	90
+			.long	32
+			.long	32*1024
+			.long	32*1024
+			.long	64
+			.long	52
+			.long	32
 
-	.align	2
-	.long	0x00000000		; Matches everything
-	.short	0
-	.short	0
-	.long	pfFloat | pfL1i | pfL1d
-	.long	0
-	.long	CPU_SUBTYPE_POWERPC_ALL
-	.long	105
-	.long	90
-	.long	32
-	.long	32*1024
-	.long	32*1024
diff --git a/osfmk/ppc/status.c b/osfmk/ppc/status.c
index 8e7a65b05..3f80e92ad 100644
--- a/osfmk/ppc/status.c
+++ b/osfmk/ppc/status.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -44,6 +47,8 @@ extern void thread_bootstrap_return(void);
 extern struct   Saveanchor saveanchor;
 extern int      real_ncpus;                     /* Number of actual CPUs */
 
+#define       USRSTACK        0xc0000000
+
 kern_return_t
 thread_userstack(
     thread_t,
@@ -66,6 +71,7 @@ thread_entrypoint(
 unsigned int get_msr_exportmask(void);
 unsigned int get_msr_nbits(void);
 unsigned int get_msr_rbits(void);
+void ppc_checkthreadstate(void *, int);
 void thread_set_child(thread_act_t child, int pid);
 void thread_set_parent(thread_act_t parent, int pid);
 		
@@ -77,6 +83,9 @@ unsigned int state_count[] = {
 	PPC_THREAD_STATE_COUNT,
 	PPC_FLOAT_STATE_COUNT,
 	PPC_EXCEPTION_STATE_COUNT,
+	PPC_VECTOR_STATE_COUNT,
+	PPC_THREAD_STATE64_COUNT,
+	PPC_EXCEPTION_STATE64_COUNT,
 };
 
 /*
@@ -101,32 +110,29 @@ act_machine_get_state(
 	unsigned int vrvalidwrk;
 
 	register struct ppc_thread_state *ts;
+	register struct ppc_thread_state64 *xts;
 	register struct ppc_exception_state *es;
+	register struct ppc_exception_state64 *xes;
 	register struct ppc_float_state *fs;
 	register struct ppc_vector_state *vs;
 	
-	
-#if	MACH_ASSERT
-    if (watchacts & WA_STATE)
-	printf("act_%x act_machine_get_state(thr_act=%x,flav=%x,st=%x,cnt@%x=%x)\n",
-	       current_act(), thr_act, flavor, tstate,
-	       count, (count ? *count : 0));
-#endif	/* MACH_ASSERT */
-
 	genuser = find_user_regs(thr_act);						/* Find the current user general context for this activation */
 
 	switch (flavor) {
 		
 		case THREAD_STATE_FLAVOR_LIST:
 			
-			if (*count < 3)  {
+			if (*count < 6)  {
 				return (KERN_INVALID_ARGUMENT);
 			}
 		
 			tstate[0] = PPC_THREAD_STATE;
 			tstate[1] = PPC_FLOAT_STATE;
 			tstate[2] = PPC_EXCEPTION_STATE;
-			*count = 3;
+			tstate[3] = PPC_VECTOR_STATE;
+			tstate[4] = PPC_THREAD_STATE64;
+			tstate[5] = PPC_EXCEPTION_STATE64;
+			*count = 6;
 		
 			return KERN_SUCCESS;
 	
@@ -141,46 +147,46 @@ act_machine_get_state(
 			sv = genuser;									/* Copy this over */
 			
 			if(sv) {										/* Is there a save area yet? */
-				ts->r0	= sv->save_r0;
-				ts->r1	= sv->save_r1;
-				ts->r2	= sv->save_r2;
-				ts->r3	= sv->save_r3;
-				ts->r4	= sv->save_r4;
-				ts->r5	= sv->save_r5;
-				ts->r6	= sv->save_r6;
-				ts->r7	= sv->save_r7;
-				ts->r8	= sv->save_r8;
-				ts->r9	= sv->save_r9;
-				ts->r10	= sv->save_r10;
-				ts->r11	= sv->save_r11;
-				ts->r12	= sv->save_r12;
-				ts->r13	= sv->save_r13;
-				ts->r14	= sv->save_r14;
-				ts->r15	= sv->save_r15;
-				ts->r16	= sv->save_r16;
-				ts->r17	= sv->save_r17;
-				ts->r18	= sv->save_r18;
-				ts->r19	= sv->save_r19;
-				ts->r20	= sv->save_r20;
-				ts->r21	= sv->save_r21;
-				ts->r22	= sv->save_r22;
-				ts->r23	= sv->save_r23;
-				ts->r24	= sv->save_r24;
-				ts->r25	= sv->save_r25;
-				ts->r26	= sv->save_r26;
-				ts->r27	= sv->save_r27;
-				ts->r28	= sv->save_r28;
-				ts->r29	= sv->save_r29;
-				ts->r30	= sv->save_r30;
-				ts->r31	= sv->save_r31;
-				ts->cr	= sv->save_cr;
-				ts->xer	= sv->save_xer;
-				ts->lr	= sv->save_lr;
-				ts->ctr	= sv->save_ctr;
-				ts->srr0 = sv->save_srr0;
-				ts->srr1 = sv->save_srr1;
+				ts->r0	= (unsigned int)sv->save_r0;
+				ts->r1	= (unsigned int)sv->save_r1;
+				ts->r2	= (unsigned int)sv->save_r2;
+				ts->r3	= (unsigned int)sv->save_r3;
+				ts->r4	= (unsigned int)sv->save_r4;
+				ts->r5	= (unsigned int)sv->save_r5;
+				ts->r6	= (unsigned int)sv->save_r6;
+				ts->r7	= (unsigned int)sv->save_r7;
+				ts->r8	= (unsigned int)sv->save_r8;
+				ts->r9	= (unsigned int)sv->save_r9;
+				ts->r10	= (unsigned int)sv->save_r10;
+				ts->r11	= (unsigned int)sv->save_r11;
+				ts->r12	= (unsigned int)sv->save_r12;
+				ts->r13	= (unsigned int)sv->save_r13;
+				ts->r14	= (unsigned int)sv->save_r14;
+				ts->r15	= (unsigned int)sv->save_r15;
+				ts->r16	= (unsigned int)sv->save_r16;
+				ts->r17	= (unsigned int)sv->save_r17;
+				ts->r18	= (unsigned int)sv->save_r18;
+				ts->r19	= (unsigned int)sv->save_r19;
+				ts->r20	= (unsigned int)sv->save_r20;
+				ts->r21	= (unsigned int)sv->save_r21;
+				ts->r22	= (unsigned int)sv->save_r22;
+				ts->r23	= (unsigned int)sv->save_r23;
+				ts->r24	= (unsigned int)sv->save_r24;
+				ts->r25	= (unsigned int)sv->save_r25;
+				ts->r26	= (unsigned int)sv->save_r26;
+				ts->r27	= (unsigned int)sv->save_r27;
+				ts->r28	= (unsigned int)sv->save_r28;
+				ts->r29	= (unsigned int)sv->save_r29;
+				ts->r30	= (unsigned int)sv->save_r30;
+				ts->r31	= (unsigned int)sv->save_r31;
+				ts->cr	= (unsigned int)sv->save_cr;
+				ts->xer	= (unsigned int)sv->save_xer;
+				ts->lr	= (unsigned int)sv->save_lr;
+				ts->ctr	= (unsigned int)sv->save_ctr;
+				ts->srr0 = (unsigned int)sv->save_srr0;
+				ts->srr1 = (unsigned int)sv->save_srr1;
 				ts->mq	= 0;							/* MQ register (601 only) */
-				ts->vrsave	= sv->save_vrsave;			/* VRSAVE register (Altivec only) */
+				ts->vrsave	= (unsigned int)sv->save_vrsave;			/* VRSAVE register (Altivec only) */
 			}
 			else {										/* No user state yet. Save seemingly random values. */
 						
@@ -201,6 +207,75 @@ act_machine_get_state(
 			*count = PPC_THREAD_STATE_COUNT;			/* Pass back the amount we actually copied */
 			return KERN_SUCCESS;
 	
+	
+		case PPC_THREAD_STATE64:
+	
+			if (*count < PPC_THREAD_STATE64_COUNT) {	/* Is the count ok? */
+				return KERN_INVALID_ARGUMENT;
+			}
+		
+			xts = (struct ppc_thread_state64 *) tstate;
+
+			sv = genuser;								/* Copy this over */
+			
+			if(sv) {									/* Is there a save area yet? */
+				xts->r0		= sv->save_r0;
+				xts->r1		= sv->save_r1;
+				xts->r2		= sv->save_r2;
+				xts->r3		= sv->save_r3;
+				xts->r4		= sv->save_r4;
+				xts->r5		= sv->save_r5;
+				xts->r6		= sv->save_r6;
+				xts->r7		= sv->save_r7;
+				xts->r8		= sv->save_r8;
+				xts->r9		= sv->save_r9;
+				xts->r10	= sv->save_r10;
+				xts->r11	= sv->save_r11;
+				xts->r12	= sv->save_r12;
+				xts->r13	= sv->save_r13;
+				xts->r14	= sv->save_r14;
+				xts->r15	= sv->save_r15;
+				xts->r16	= sv->save_r16;
+				xts->r17	= sv->save_r17;
+				xts->r18	= sv->save_r18;
+				xts->r19	= sv->save_r19;
+				xts->r20	= sv->save_r20;
+				xts->r21	= sv->save_r21;
+				xts->r22	= sv->save_r22;
+				xts->r23	= sv->save_r23;
+				xts->r24	= sv->save_r24;
+				xts->r25	= sv->save_r25;
+				xts->r26	= sv->save_r26;
+				xts->r27	= sv->save_r27;
+				xts->r28	= sv->save_r28;
+				xts->r29	= sv->save_r29;
+				xts->r30	= sv->save_r30;
+				xts->r31	= sv->save_r31;
+				xts->cr		= sv->save_cr;
+				xts->xer	= sv->save_xer;
+				xts->lr		= sv->save_lr;
+				xts->ctr	= sv->save_ctr;
+				xts->srr0 	= sv->save_srr0;
+				xts->srr1 	= sv->save_srr1;
+				xts->vrsave	= sv->save_vrsave;			/* VRSAVE register (Altivec only) */
+			}
+			else {										/* No user state yet. Save seemingly random values. */
+						
+				for(i=0; i < 32; i++) {					/* Fill up with defaults */
+					((unsigned long long *)&xts->r0)[i] = ((unsigned long long *)&FloatInit)[0];
+				}
+				xts->cr		= 0;
+				xts->xer	= 0;
+				xts->lr		= ((unsigned long long *)&FloatInit)[0];
+				xts->ctr	= ((unsigned long long *)&FloatInit)[0];
+				xts->srr0	= ((unsigned long long *)&FloatInit)[0];
+				xts->srr1 	= MSR_EXPORT_MASK_SET;
+				xts->vrsave	= 0;						/* VRSAVE register (Altivec only) */
+			}
+		
+			*count = PPC_THREAD_STATE64_COUNT;			/* Pass back the amount we actually copied */
+			return KERN_SUCCESS;
+	
 		case PPC_EXCEPTION_STATE:
 	
 			if (*count < PPC_EXCEPTION_STATE_COUNT) {
@@ -208,17 +283,10 @@ act_machine_get_state(
 			}
 		
 			es = (struct ppc_exception_state *) tstate;
+			sv = genuser;								/* Copy this over */
 		
-			sv = thr_act->mact.pcb;						/* Start with the normal savearea */
-			while(sv) {									/* Find the user context */
-				if(sv->save_srr1 & MASK(MSR_PR)) {		/* Are we looking at the user context? */
-					break;								/* Outta here */
-				}
-				sv = sv->save_hdr.save_prev;			/* Back chain */
-			}
-
 			if(sv) {									/* See if valid state yet */
-				es->dar = sv->save_dar;
+				es->dar = (unsigned int)sv->save_dar;
 				es->dsisr = sv->save_dsisr;
 				es->exception = sv->save_exception;
 			}
@@ -231,6 +299,29 @@ act_machine_get_state(
 			*count = PPC_EXCEPTION_STATE_COUNT;
 			return KERN_SUCCESS;
 	
+		case PPC_EXCEPTION_STATE64:
+	
+			if (*count < PPC_EXCEPTION_STATE64_COUNT) {
+				return KERN_INVALID_ARGUMENT;
+			}
+		
+			xes = (struct ppc_exception_state64 *) tstate;
+			sv = genuser;								/* Copy this over */
+		
+			if(sv) {									/* See if valid state yet */
+				xes->dar = sv->save_dar;
+				xes->dsisr = sv->save_dsisr;
+				xes->exception = sv->save_exception;
+			}
+			else {										/* Nope, not yet */
+				xes->dar = 0;
+				xes->dsisr = 0;
+				xes->exception = ((unsigned int *)&FloatInit)[0];
+			}
+		
+			*count = PPC_EXCEPTION_STATE64_COUNT;
+			return KERN_SUCCESS;
+	
 		case PPC_FLOAT_STATE: 
 		
 			if (*count < PPC_FLOAT_STATE_COUNT)  {
@@ -241,14 +332,7 @@ act_machine_get_state(
 		
 			fs = (struct ppc_float_state *) tstate;		/* Point to destination */
 			
-			fsv = (savearea_fpu *)thr_act->mact.curctx->FPUsave;	/* Start with the top FPU savearea */
-			
-			while(fsv) {								/* Find the user context */
-				if(!fsv->save_hdr.save_level) {			/* Are we looking at the user context? */
-					break;								/* Outta here */
-				}
-				fsv = (savearea_fpu *)fsv->save_hdr.save_prev;	/* Back chain */
-			}
+			fsv = find_user_fpu(thr_act);				/* Get the user's fpu savearea */
 			
 			if(fsv) {									/* See if we have any */
 				bcopy((char *)&fsv->save_fp0, (char *)fs, 32*8); /* 32 registers  */
@@ -279,14 +363,7 @@ act_machine_get_state(
 		
 			vs = (struct ppc_vector_state *) tstate;	/* Point to destination */
 			
-			vsv = (savearea_vec *)thr_act->mact.curctx->VMXsave;	/* Start with the top vector savearea */
-			
-			while(vsv) {								/* Find the user context */
-				if(!vsv->save_hdr.save_level) {			/* Are we looking at the user context? */
-					break;								/* Outta here */
-				}
-				vsv = (savearea_vec *)vsv->save_hdr.save_prev;	/* Back chain */
-			}
+			vsv = find_user_vec(thr_act);				/* Find the vector savearea */
 			
 			if(vsv) {									/* See if we have any */
 				
@@ -297,7 +374,7 @@ act_machine_get_state(
 					vs->save_vscr[0] = 0;				/* Set an initial value if no general user yet */
 					vs->save_vscr[1] = 0;
 					vs->save_vscr[2] = 0;
-					vs->save_vscr[3] = 0x00010000;
+					vs->save_vscr[3] = 0x00010000;		/* Always start with Java mode off */
 				}
 				for(i=0; i < 32; i++) {					/* Copy the saved registers and invalidate the others */
 					for(j=0; j < 4; j++) {
@@ -319,7 +396,7 @@ act_machine_get_state(
 					vs->save_vscr[0] = 0;				/* Set an initial value if no general user yet */
 					vs->save_vscr[1] = 0;
 					vs->save_vscr[2] = 0;
-					vs->save_vscr[3] = 0x00010000;
+					vs->save_vscr[3] = 0x00010000;		/* Always start with Java mode off */
 				}
 				vs->save_vrvalid = 0;					/* Clear the valid flags */
 			}
@@ -355,18 +432,14 @@ act_machine_set_state(
 	unsigned int	i;
 	int				clgn;
 	register struct ppc_thread_state *ts;
+	register struct ppc_thread_state64 *xts;
 	register struct ppc_exception_state *es;
+	register struct ppc_exception_state *xes;
 	register struct ppc_float_state *fs;
 	register struct ppc_vector_state *vs;
 	
     int	kernel_act = thr_act->kernel_loading ||	thr_act->kernel_loaded;
 
-#if	MACH_ASSERT
-    if (watchacts & WA_STATE)
-	printf("act_%x act_machine_set_state(thr_act=%x,flav=%x,st=%x,cnt=%x)\n",
-	       current_act(), thr_act, flavor, tstate, count);
-#endif	/* MACH_ASSERT */
-		
 //	dbgTrace((unsigned int)thr_act, (unsigned int)sv, flavor);	/* (TEST/DEBUG) */
 
 	clgn = count;											/* Get the count */
@@ -378,6 +451,13 @@ act_machine_set_state(
 				return KERN_INVALID_ARGUMENT;				/* Yeah, just leave... */
 			}
 			break;
+	
+		case PPC_THREAD_STATE64:
+			
+			if (clgn < PPC_THREAD_STATE64_COUNT)  {			/* Is it too short? */
+				return KERN_INVALID_ARGUMENT;				/* Yeah, just leave... */
+			}
+			break;
 			
 		case PPC_EXCEPTION_STATE:
 			
@@ -385,6 +465,12 @@ act_machine_set_state(
 				return KERN_INVALID_ARGUMENT;				/* Yeah, just leave... */
 			}
 			
+		case PPC_EXCEPTION_STATE64:
+			
+			if (clgn < PPC_EXCEPTION_STATE64_COUNT)  {		/* Is it too short? */
+				return KERN_INVALID_ARGUMENT;				/* Yeah, just leave... */
+			}
+			
 			break;
 			
 		case PPC_FLOAT_STATE:
@@ -413,70 +499,135 @@ act_machine_set_state(
 	switch (flavor) {
 		
 		case PPC_THREAD_STATE:
-		case PPC_EXCEPTION_STATE:
 				
 			ts = (struct ppc_thread_state *)tstate;
-										
-			if(flavor == PPC_THREAD_STATE) {				/* Are we updating plain state? */
-			
-				genuser->save_r0	= ts->r0;
-				genuser->save_r1	= ts->r1;
-				genuser->save_r2	= ts->r2;
-				genuser->save_r3	= ts->r3;
-				genuser->save_r4	= ts->r4;
-				genuser->save_r5	= ts->r5;
-				genuser->save_r6	= ts->r6;
-				genuser->save_r7	= ts->r7;
-				genuser->save_r8	= ts->r8;
-				genuser->save_r9	= ts->r9;
-				genuser->save_r10	= ts->r10;
-				genuser->save_r11	= ts->r11;
-				genuser->save_r12	= ts->r12;
-				genuser->save_r13	= ts->r13;
-				genuser->save_r14	= ts->r14;
-				genuser->save_r15	= ts->r15;
-				genuser->save_r16	= ts->r16;
-				genuser->save_r17	= ts->r17;
-				genuser->save_r18	= ts->r18;
-				genuser->save_r19	= ts->r19;
-				genuser->save_r20	= ts->r20;
-				genuser->save_r21	= ts->r21;
-				genuser->save_r22	= ts->r22;
-				genuser->save_r23	= ts->r23;
-				genuser->save_r24	= ts->r24;
-				genuser->save_r25	= ts->r25;
-				genuser->save_r26	= ts->r26;
-				genuser->save_r27	= ts->r27;
-				genuser->save_r28	= ts->r28;
-				genuser->save_r29	= ts->r29;
-				genuser->save_r30	= ts->r30;
-				genuser->save_r31	= ts->r31;
-			
-				genuser->save_cr	= ts->cr;
-				genuser->save_xer	= ts->xer;
-				genuser->save_lr	= ts->lr;
-				genuser->save_ctr	= ts->ctr;
-				genuser->save_srr0	= ts->srr0;
-				genuser->save_vrsave	= ts->vrsave;					/* VRSAVE register (Altivec only) */
 
-				genuser->save_srr1 = MSR_PREPARE_FOR_IMPORT(genuser->save_srr1, ts->srr1);	/* Set the bits we can change */
-	
-				if(!kernel_act) genuser->save_srr1 |= MSR_EXPORT_MASK_SET;	/* If not a kernel guy, force the magic bits on */	
-			
-				genuser->save_srr1 &= ~(MASK(MSR_FP) | MASK(MSR_VEC));	/* Make sure we don't enable the floating point unit */
-			
-				return KERN_SUCCESS;
+			genuser->save_r0	= (uint64_t)ts->r0;
+			genuser->save_r1	= (uint64_t)ts->r1;
+			genuser->save_r2	= (uint64_t)ts->r2;
+			genuser->save_r3	= (uint64_t)ts->r3;
+			genuser->save_r4	= (uint64_t)ts->r4;
+			genuser->save_r5	= (uint64_t)ts->r5;
+			genuser->save_r6	= (uint64_t)ts->r6;
+			genuser->save_r7	= (uint64_t)ts->r7;
+			genuser->save_r8	= (uint64_t)ts->r8;
+			genuser->save_r9	= (uint64_t)ts->r9;
+			genuser->save_r10	= (uint64_t)ts->r10;
+			genuser->save_r11	= (uint64_t)ts->r11;
+			genuser->save_r12	= (uint64_t)ts->r12;
+			genuser->save_r13	= (uint64_t)ts->r13;
+			genuser->save_r14	= (uint64_t)ts->r14;
+			genuser->save_r15	= (uint64_t)ts->r15;
+			genuser->save_r16	= (uint64_t)ts->r16;
+			genuser->save_r17	= (uint64_t)ts->r17;
+			genuser->save_r18	= (uint64_t)ts->r18;
+			genuser->save_r19	= (uint64_t)ts->r19;
+			genuser->save_r20	= (uint64_t)ts->r20;
+			genuser->save_r21	= (uint64_t)ts->r21;
+			genuser->save_r22	= (uint64_t)ts->r22;
+			genuser->save_r23	= (uint64_t)ts->r23;
+			genuser->save_r24	= (uint64_t)ts->r24;
+			genuser->save_r25	= (uint64_t)ts->r25;
+			genuser->save_r26	= (uint64_t)ts->r26;
+			genuser->save_r27	= (uint64_t)ts->r27;
+			genuser->save_r28	= (uint64_t)ts->r28;
+			genuser->save_r29	= (uint64_t)ts->r29;
+			genuser->save_r30	= (uint64_t)ts->r30;
+			genuser->save_r31	= (uint64_t)ts->r31;
+		
+			genuser->save_cr	= ts->cr;
+			genuser->save_xer	= (uint64_t)ts->xer;
+			genuser->save_lr	= (uint64_t)ts->lr;
+			genuser->save_ctr	= (uint64_t)ts->ctr;
+			genuser->save_srr0	= (uint64_t)ts->srr0;
+			genuser->save_vrsave	= ts->vrsave;					/* VRSAVE register (Altivec only) */
+
+			genuser->save_srr1 = MSR_PREPARE_FOR_IMPORT(genuser->save_srr1, ts->srr1);	/* Set the bits we can change */
+
+			if(!kernel_act) genuser->save_srr1 |= MSR_EXPORT_MASK_SET;	/* If not a kernel guy, force the magic bits on */	
+		
+			genuser->save_srr1 &= ~(MASK(MSR_FP) | MASK(MSR_VEC));	/* Make sure we don't enable the floating point unit */
+		
+			return KERN_SUCCESS;
+
+
+		case PPC_THREAD_STATE64:
 				
-			}
+			xts = (struct ppc_thread_state64 *)tstate;
+
+			genuser->save_r0	= xts->r0;
+			genuser->save_r1	= xts->r1;
+			genuser->save_r2	= xts->r2;
+			genuser->save_r3	= xts->r3;
+			genuser->save_r4	= xts->r4;
+			genuser->save_r5	= xts->r5;
+			genuser->save_r6	= xts->r6;
+			genuser->save_r7	= xts->r7;
+			genuser->save_r8	= xts->r8;
+			genuser->save_r9	= xts->r9;
+			genuser->save_r10	= xts->r10;
+			genuser->save_r11	= xts->r11;
+			genuser->save_r12	= xts->r12;
+			genuser->save_r13	= xts->r13;
+			genuser->save_r14	= xts->r14;
+			genuser->save_r15	= xts->r15;
+			genuser->save_r16	= xts->r16;
+			genuser->save_r17	= xts->r17;
+			genuser->save_r18	= xts->r18;
+			genuser->save_r19	= xts->r19;
+			genuser->save_r20	= xts->r20;
+			genuser->save_r21	= xts->r21;
+			genuser->save_r22	= xts->r22;
+			genuser->save_r23	= xts->r23;
+			genuser->save_r24	= xts->r24;
+			genuser->save_r25	= xts->r25;
+			genuser->save_r26	= xts->r26;
+			genuser->save_r27	= xts->r27;
+			genuser->save_r28	= xts->r28;
+			genuser->save_r29	= xts->r29;
+			genuser->save_r30	= xts->r30;
+			genuser->save_r31	= xts->r31;
+		
+			genuser->save_cr	= xts->cr;
+			genuser->save_xer	= xts->xer;
+			genuser->save_lr	= xts->lr;
+			genuser->save_ctr	= xts->ctr;
+			genuser->save_srr0	= xts->srr0;
+			genuser->save_vrsave	= xts->vrsave;					/* VRSAVE register (Altivec only) */
 
+			genuser->save_srr1 = MSR_PREPARE_FOR_IMPORT(genuser->save_srr1, xts->srr1);	/* Set the bits we can change */
+
+			if(!kernel_act) genuser->save_srr1 |= MSR_EXPORT_MASK_SET;	/* If not a kernel guy, force the magic bits on */	
+		
+			genuser->save_srr1 &= ~(MASK(MSR_FP) | MASK(MSR_VEC));	/* Make sure we don't enable the floating point unit */
+		
+			return KERN_SUCCESS;
+				
+				
+		case PPC_EXCEPTION_STATE:
+			
 			es = (struct ppc_exception_state *) tstate;
 		
-			genuser->save_dar = es->dar;
+			genuser->save_dar = (uint64_t)es->dar;
 			genuser->save_dsisr = es->dsisr;
 			genuser->save_exception = es->exception;
 
 			return KERN_SUCCESS;
 	
+/*
+ *		It's pretty worthless to try to change this stuff, but we'll do it anyway.
+ */
+ 
+		case PPC_EXCEPTION_STATE64:
+			
+			xes = (struct ppc_exception_state *) tstate;
+		
+			genuser->save_dar 	= xes->dar;
+			genuser->save_dsisr = xes->dsisr;
+			genuser->save_exception = xes->exception;
+
+			return KERN_SUCCESS;
+	
 		case PPC_FLOAT_STATE:
 
 			toss_live_fpu(thr_act->mact.curctx);			/* Toss my floating point if live anywhere */
@@ -500,7 +651,7 @@ act_machine_set_state(
 						fsvn = (savearea_fpu *)fsvo->save_hdr.save_prev;	/* Skip on to the next */
 					}
 					
-					fsvo->save_hdr.save_prev = (savearea *)fsv;		/* Queue us on in */
+					fsvo->save_hdr.save_prev = (addr64_t)fsv;		/* Queue us on in */
 				}
 				
 			}
@@ -538,7 +689,7 @@ act_machine_set_state(
 						vsvn = (savearea_vec *)vsvo->save_hdr.save_prev;	/* Skip on to the next */
 					}
 					
-					vsvo->save_hdr.save_prev = (savearea *)vsv;	/* Queue us on in */
+					vsvo->save_hdr.save_prev = (addr64_t)vsv;	/* Queue us on in */
 				}
 				
 			}
@@ -649,7 +800,7 @@ savearea *get_user_regs(thread_act_t act) {
 		if(sv->save_srr1 & MASK(MSR_PR)) return sv;	/* We found a user state context... */
 
 		osv = sv;									/* Save the last one */
-		sv = sv->save_hdr.save_prev;				/* Get the previous context */
+		sv = (savearea *)sv->save_hdr.save_prev;	/* Get the previous context */
 	}
 
 	sv = save_alloc();								/* Get one */
@@ -659,7 +810,7 @@ savearea *get_user_regs(thread_act_t act) {
 	sv->save_hdr.save_level = 0;					/* Mark user state */
 	
 	if(osv) {										/* Did we already have one? */
-		osv->save_hdr.save_prev = sv;				/* Chain us on the end */
+		osv->save_hdr.save_prev = (addr64_t)sv;		/* Chain us on the end */
 	}
 	else {											/* We are the first */
 		act->mact.pcb = sv;							/* Put it there */
@@ -671,10 +822,10 @@ savearea *get_user_regs(thread_act_t act) {
 	}
 	sv->save_cr	= 0;
 	sv->save_xer	= 0;
-	sv->save_lr	= ((unsigned int *)&FloatInit)[0];
-	sv->save_ctr	= ((unsigned int *)&FloatInit)[1];
-	sv->save_srr0	= ((unsigned int *)&FloatInit)[0];
-	sv->save_srr1 = MSR_EXPORT_MASK_SET;
+	sv->save_lr	= (uint64_t)FloatInit;
+	sv->save_ctr	= (uint64_t)FloatInit;
+	sv->save_srr0	= (uint64_t)FloatInit;
+	sv->save_srr1 = (uint64_t)MSR_EXPORT_MASK_SET;
 
 	sv->save_fpscr = 0;								/* Clear all floating point exceptions */
 
@@ -682,14 +833,7 @@ savearea *get_user_regs(thread_act_t act) {
 	sv->save_vscr[0] = 0x00000000;					
 	sv->save_vscr[1] = 0x00000000;					
 	sv->save_vscr[2] = 0x00000000;					
-	sv->save_vscr[3] = 0x00010000;					/* Supress java mode and clear saturated */
-	
-	spc = (unsigned int)act->map->pmap->space;		/* Get the space we're in */
-	
-	srs = (unsigned int *)&sv->save_sr0;			/* Point to the SRs */
-	for(i = 0; i < 16; i++) {						/* Fill in the SRs for the new context */
-		srs[i] = SEG_REG_PROT | (i<<20) | spc;		/* Set the SR */
-	}
+	sv->save_vscr[3] = 0x00010000;					/* Disable java mode and clear saturated */
 	
 	return sv;										/* Bye bye... */
 }
@@ -709,7 +853,7 @@ savearea *find_user_regs(thread_act_t act) {
 		if(sv->save_srr1 & MASK(MSR_PR)) {			/* Are we looking at the user context? */
 			break;									/* Outta here */
 		}
-		sv = sv->save_hdr.save_prev;				/* Get the previous context */
+		sv = (savearea *)sv->save_hdr.save_prev;	/* Get the previous context */
 	}
 	
 	return sv;										/* Bye bye... */
@@ -771,8 +915,13 @@ thread_userstack(
 {
         struct ppc_thread_state *state;
 
-	if (customstack)
-		*customstack = 0;
+        /*
+         * Set a default.
+         */
+        if (*user_stack == 0)
+                *user_stack = USRSTACK;
+		if (customstack)
+			*customstack = 0;
 
         switch (flavor) {
         case PPC_THREAD_STATE:
@@ -781,13 +930,14 @@ thread_userstack(
  
                 state = (struct ppc_thread_state *) tstate;
     
-                /* If a valid user stack is specified, use it. */
-		if (state->r1)
-			*user_stack = state->r1;
-
-		if (customstack && state->r1)
-			*customstack = 1;
+                /*
+                 * If a valid user stack is specified, use it.
+                 */
+                *user_stack = state->r1 ? state->r1: USRSTACK;
 
+				if (customstack && state->r1)
+					*customstack = 1;
+					
                 break;
         default :
                 return (KERN_INVALID_ARGUMENT);
@@ -809,7 +959,7 @@ void thread_setuserstack(struct thread_activation *act, unsigned int user_stack)
 	
 	sv = get_user_regs(act);		/* Get the user state registers */
 	
-	sv->save_r1 = user_stack;
+	sv->save_r1 = (uint64_t)user_stack;
 	
 	return;
 }    
@@ -828,7 +978,7 @@ unsigned int thread_adjuserstack(struct thread_activation *act, int adjust)
 	
 	sv->save_r1 += adjust;			/* Adjust the stack */
 	
-	return sv->save_r1;				/* Return the adjusted stack */
+	return (unsigned int)sv->save_r1;	/* Return the adjusted stack */
 	
 }    
 
@@ -845,7 +995,7 @@ void thread_setentrypoint(struct thread_activation *act, unsigned int entry)
 	
 	sv = get_user_regs(act);		/* Get the user state registers */
 	
-	sv->save_srr0 = entry;
+	sv->save_srr0 = (uint64_t)entry;
 	
 	return;
 }    
@@ -901,14 +1051,32 @@ unsigned int get_msr_rbits(void)
 	return (MASK(MSR_PR)|MASK(MSR_ME)|MASK(MSR_IR)|MASK(MSR_DR)|MASK(MSR_EE));
 }
 
+void ppc_checkthreadstate(void * tsptr, int flavor)
+{
+	if (flavor == PPC_THREAD_STATE64) {
+		struct ppc_thread_state64 *ts64 =(struct ppc_thread_state64 *)tsptr;
+
+		/* Make sure naughty bits are off and necessary bits are on */
+		ts64->srr1 &= ~(MASK(MSR_POW)|MASK(MSR_ILE)|MASK(MSR_IP)|MASK(MSR_LE));
+		ts64->srr1 |= (MASK(MSR_PR)|MASK(MSR_ME)|MASK(MSR_IR)|MASK(MSR_DR)|MASK(MSR_EE));
+	} else {
+		struct ppc_thread_state *ts =(struct ppc_thread_state *)tsptr;
+
+		/* Make sure naughty bits are off and necessary bits are on */
+		ts->srr1 &= ~(MASK(MSR_POW)|MASK(MSR_ILE)|MASK(MSR_IP)|MASK(MSR_LE));
+		ts->srr1 |= (MASK(MSR_PR)|MASK(MSR_ME)|MASK(MSR_IR)|MASK(MSR_DR)|MASK(MSR_EE));
+	}
+	return;
+}
+
 void  thread_set_child(thread_act_t child, int pid)
 {
 	struct savearea *child_state;
 	
 	child_state = get_user_regs(child);
 	
-	child_state->save_r3 = pid;
-	child_state->save_r4 = 1;
+	child_state->save_r3 = (uint_t)pid;
+	child_state->save_r4 = 1ULL;
 }
 void  thread_set_parent(thread_act_t parent, int pid)
 {
@@ -916,7 +1084,7 @@ void  thread_set_parent(thread_act_t parent, int pid)
 	
 	parent_state = get_user_regs(parent);
 	
-	parent_state->save_r3 = pid;
+	parent_state->save_r3 = (uint64_t)pid;
 	parent_state->save_r4 = 0;
 }
 
@@ -980,7 +1148,7 @@ void *act_thread_csave(void) {
 		fsv->save_hdr.save_misc2 = 0xDEBB1ED0;		/* Eye catcher for debug */
 		fsv->save_hdr.save_misc3 = 0xE5DA11A5;		/* Eye catcher for debug */
 
-		sv->save_hdr.save_misc0 = (unsigned int)fsv;	/* Remember this one */
+		sv->save_hdr.save_misc0 = (uint64_t)fsv;	/* Remember this one */
 
 		bcopy((char *)((unsigned int)ofsv + sizeof(savearea_comm)),	/* Copy everything but the headers */
 			(char *)((unsigned int)fsv + sizeof(savearea_comm)), 
@@ -1000,7 +1168,7 @@ void *act_thread_csave(void) {
 		vsv->save_hdr.save_misc2 = 0xDEBB1ED0;		/* Eye catcher for debug */
 		vsv->save_hdr.save_misc3 = 0xE5DA11A5;		/* Eye catcher for debug */
 
-		sv->save_hdr.save_misc1 = (unsigned int)vsv;	/* Chain in the floating point */
+		sv->save_hdr.save_misc1 = (uint64_t)vsv;	/* Chain in the floating point */
 
 		bcopy((char *)((unsigned int)ovsv + sizeof(savearea_comm)),	/* Copy everything but the headers */
 			(char *)((unsigned int)vsv + sizeof(savearea_comm)), 
@@ -1059,17 +1227,12 @@ void act_thread_catt(void *ctx) {
 	
 	spc = (unsigned int)act->map->pmap->space;		/* Get the space we're in */
 	
-	srs = (unsigned int *)&sv->save_sr0;			/* Point to the SRs */
-	for(i = 0; i < 16; i++) {						/* Fill in the SRs for the new context */
-		srs[i] = SEG_REG_PROT | (i<<20) | spc;		/* Set the SRs */
-	}
-	
 	osv = act->mact.pcb;							/* Get the top general savearea */
 	psv = 0;
 	while(osv) {									/* Any saved state? */
 		if(osv->save_srr1 & MASK(MSR_PR)) break;	/* Leave if this is user state */
 		psv = osv;									/* Save previous savearea address */
-		osv = osv->save_hdr.save_prev;				/* Get one underneath our's */
+		osv = (savearea *)osv->save_hdr.save_prev;	/* Get one underneath our's */
 	}
 	
 	if(osv) {										/* Did we find one? */
@@ -1080,7 +1243,7 @@ void act_thread_catt(void *ctx) {
 		
 	}
 
-	if(psv)	psv->save_hdr.save_prev = sv;			/* Chain us to the end or */
+	if(psv)	psv->save_hdr.save_prev = (addr64_t)sv;	/* Chain us to the end or */
 	else act->mact.pcb = (pcb_t)sv;					/* to the start if the only one */
 	
 	ovsv = act->mact.curctx->VMXsave;				/* Get the top vector savearea */
@@ -1100,7 +1263,7 @@ void act_thread_catt(void *ctx) {
 	}
 	
 	if(vsv) {										/* Are we sticking any vector on this one? */
-		if(pvsv) pvsv->save_hdr.save_prev = (savearea *)vsv;	/* Yes, chain us to the end or */
+		if(pvsv) pvsv->save_hdr.save_prev = (addr64_t)vsv;	/* Yes, chain us to the end or */
 		else act->mact.curctx->VMXsave = vsv;		/* to the start if the only one */
 
 		vsv->save_hdr.save_misc2 = 0;				/* Eye catcher for debug */
@@ -1125,7 +1288,7 @@ void act_thread_catt(void *ctx) {
 	}
 	
 	if(fsv) {										/* Are we sticking any vector on this one? */
-		if(pfsv) pfsv->save_hdr.save_prev = (savearea *)fsv;	/* Yes, chain us to the end or */
+		if(pfsv) pfsv->save_hdr.save_prev = (addr64_t)fsv;	/* Yes, chain us to the end or */
 		else act->mact.curctx->FPUsave = fsv;		/* to the start if the only one */
 
 		fsv->save_hdr.save_misc2 = 0;				/* Eye catcher for debug */
diff --git a/osfmk/ppc/task.h b/osfmk/ppc/task.h
index 3d5259fac..f6f1f64cf 100644
--- a/osfmk/ppc/task.h
+++ b/osfmk/ppc/task.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ppc/testjump.c b/osfmk/ppc/testjump.c
index 5debfb6dc..ea4436522 100644
--- a/osfmk/ppc/testjump.c
+++ b/osfmk/ppc/testjump.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ppc/thread.h b/osfmk/ppc/thread.h
index 9b323dab9..50a5de4fe 100644
--- a/osfmk/ppc/thread.h
+++ b/osfmk/ppc/thread.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ppc/thread_act.h b/osfmk/ppc/thread_act.h
index 9d0a0cbb1..2aaa57da4 100644
--- a/osfmk/ppc/thread_act.h
+++ b/osfmk/ppc/thread_act.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -58,9 +61,11 @@ struct facility_context {
 	savearea_fpu	*FPUsave;		/* The floating point savearea */
 	savearea		*FPUlevel;		/* The floating point context level */
 	unsigned int	FPUcpu;			/* The last processor to enable floating point */
+	unsigned int	FPUsync;		/* Sync lock */
 	savearea_vec	*VMXsave;		/* The VMX savearea */
 	savearea		*VMXlevel;		/* The VMX context level */
 	unsigned int	VMXcpu;			/* The last processor to enable vector */
+	unsigned int	VMXsync;		/* Sync lock */
 	struct thread_activation *facAct;	/* Activation associated with context */
 };
 
@@ -90,7 +95,12 @@ typedef struct MachineThrAct {
 	struct vmmCntrlEntry *vmmCEntry;	/* Pointer current emulation context or 0 */
 	struct vmmCntrlTable *vmmControl;	/* Pointer to virtual machine monitor control table */
 	uint64_t		qactTimer;		/* Time thread needs to interrupt. This is a single-shot timer. Zero is unset */
+	unsigned int	cioSpace;		/* Address space ID for in progress copyin/out */
+#define	cioSwitchAway 0x80000000	/* Context switched away from thread since MapUserAddressSpace */
+#define cioSwitchAwayb 0
+	addr64_t		cioRelo;		/* Relocation value for in progress copyin/out */
 	unsigned int	ksp;			/* points to TOP OF STACK or zero */
+	unsigned int	preemption_count;	/* preemption count */
 	unsigned int	bbDescAddr;		/* Points to Blue Box Trap descriptor area in kernel (page aligned) */
 	unsigned int	bbUserDA;		/* Points to Blue Box Trap descriptor area in user (page aligned) */
 	unsigned int	bbTableStart;	/* Points to Blue Box Trap dispatch area in user */
@@ -98,6 +108,8 @@ typedef struct MachineThrAct {
 	unsigned int	bbTaskID;		/* Opaque task ID for Blue Box threads */
 	unsigned int	bbTaskEnv;		/* Opaque task data reference for Blue Box threads */
 	unsigned int	specFlags;		/* Special flags */
+    unsigned int    pmcovfl[8];     /* PMC overflow count */
+    unsigned int    perfmonFlags;   /* Perfmon facility flags */
 
 /* special flags bits */
 
@@ -109,27 +121,33 @@ typedef struct MachineThrAct {
 #define vectorCngbit			6
 #define timerPopbit				7
 #define userProtKeybit			8
-#define trapUnalignbit			9
-#define notifyUnalignbit		10
+#define FamVMenabit		 	    11
+#define FamVMmodebit			12
+#define perfMonitorbit          13
 /*	NOTE: Do not move or assign bit 31 without changing exception vector ultra fast path code */
 #define bbThreadbit				28
 #define bbNoMachSCbit	 		29
 #define bbPreemptivebit			30
 #define spfReserved1			31	/* See note above */
 
-#define ignoreZeroFault		(1<<(31-ignoreZeroFaultbit))
-#define floatUsed			(1<<(31-floatUsedbit))
-#define vectorUsed			(1<<(31-vectorUsedbit))
-#define runningVM			(1<<(31-runningVMbit))
-#define floatCng			(1<<(31-floatCngbit))
-#define vectorCng			(1<<(31-vectorCngbit))
-#define timerPop			(1<<(31-timerPopbit))
-#define userProtKey			(1<<(31-userProtKeybit))
-#define trapUnalign			(1<<(31-trapUnalignbit))
-#define notifyUnalign		(1<<(31-notifyUnalignbit))
-#define bbThread			(1<<(31-bbThreadbit))
-#define bbNoMachSC			(1<<(31-bbNoMachSCbit))
-#define bbPreemptive		(1<<(31-bbPreemptivebit))
+#define ignoreZeroFault		0x80000000  /* (1<<(31-ignoreZeroFaultbit)) */
+#define floatUsed			0x40000000  /* (1<<(31-floatUsedbit)) */
+#define vectorUsed			0x20000000  /* (1<<(31-vectorUsedbit)) */
+
+#define runningVM			0x08000000  /* (1<<(31-runningVMbit)) */
+#define floatCng			0x04000000  /* (1<<(31-floatCngbit)) */
+#define vectorCng			0x02000000  /* (1<<(31-vectorCngbit)) */
+#define timerPop			0x01000000  /* (1<<(31-timerPopbit)) */
+
+#define userProtKey			0x00800000  /* (1<<(31-userProtKeybit)) */
+
+#define	FamVMena			0x00100000  /* (1<<(31-FamVMenabit)) */
+#define	FamVMmode			0x00080000  /* (1<<(31-FamVMmodebit)) */
+#define perfMonitor         0x00040000  /* (1<<(31-perfMonitorbit)) */
+
+#define bbThread			0x00000008  /* (1<<(31-bbThreadbit)) */
+#define bbNoMachSC			0x00000004  /* (1<<(31-bbNoMachSCbit)) */
+#define bbPreemptive		0x00000002  /* (1<<(31-bbPreemptivebit)) */
 
 #define fvChkb 0
 #define fvChk 0x80000000
diff --git a/osfmk/ppc/trap.c b/osfmk/ppc/trap.c
index de7d7cd3e..fd3514628 100644
--- a/osfmk/ppc/trap.c
+++ b/osfmk/ppc/trap.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -41,8 +44,11 @@
 #include <ppc/proc_reg.h>	/* for SR_xxx definitions */
 #include <ppc/pmap.h>
 #include <ppc/mem.h>
+#include <ppc/mappings.h>
 #include <ppc/Firmware.h>
 #include <ppc/low_trace.h>
+#include <ppc/Diagnostics.h>
+#include <ppc/hw_perfmon.h>
 
 #include <sys/kdebug.h>
 
@@ -78,7 +84,7 @@ extern char init_task_failure_data[];
  */
 #define UPDATE_PPC_EXCEPTION_STATE {							\
 	thread_act_t thr_act = current_act();						\
-	thr_act->mact.pcb->save_dar = dar;							\
+	thr_act->mact.pcb->save_dar = (uint64_t)dar;				\
 	thr_act->mact.pcb->save_dsisr = dsisr;						\
 	thr_act->mact.pcb->save_exception = trapno / T_VECTOR_SIZE;	/* back to powerpc */ \
 }
@@ -86,13 +92,13 @@ extern char init_task_failure_data[];
 static void unresolved_kernel_trap(int trapno,
 				   struct savearea *ssp,
 				   unsigned int dsisr,
-				   unsigned int dar,
+				   addr64_t dar,
 				   char *message);
 
 struct savearea *trap(int trapno,
 			     struct savearea *ssp,
 			     unsigned int dsisr,
-			     unsigned int dar)
+			     addr64_t dar)
 {
 	int exception;
 	int code;
@@ -103,12 +109,13 @@ struct savearea *trap(int trapno,
 	unsigned int offset;
 	thread_act_t thr_act;
 	boolean_t intr;
+	
 #ifdef MACH_BSD
 	time_value_t tv;
 #endif /* MACH_BSD */
 
 	if(perfTrapHook) {							/* Is there a hook? */
-		if(perfTrapHook(trapno, ssp, dsisr, dar) == KERN_SUCCESS) return ssp;	/* If it succeeds, we are done... */
+		if(perfTrapHook(trapno, ssp, dsisr, (unsigned int)dar) == KERN_SUCCESS) return ssp;	/* If it succeeds, we are done... */
 	}
 
 #if 0
@@ -141,14 +148,13 @@ struct savearea *trap(int trapno,
 			ast_taken(AST_PREEMPT, FALSE);
 			break;	
 
+		case T_PERF_MON:
+			perfmon_handle_pmi(ssp);
+			break;
+
 		case T_RESET:					/* Reset interruption */
-#if 0
-			kprintf("*** Reset exception ignored; srr0 = %08X, srr1 = %08X\n",
-				ssp->save_srr0, ssp->save_srr1);
-#else
-			panic("Unexpected Reset exception; srr0 = %08X, srr1 = %08X\n",
-				ssp->save_srr0, ssp->save_srr1);
-#endif
+			if (!Call_Debugger(trapno, ssp))
+				unresolved_kernel_trap(trapno, ssp, dsisr, dar, NULL);
 			break;						/* We just ignore these */
 		
 		/*
@@ -168,10 +174,40 @@ struct savearea *trap(int trapno,
 		case T_FP_UNAVAILABLE:
 		case T_IO_ERROR:
 		case T_RESERVED:
-		case T_ALIGNMENT:
 		default:
 			unresolved_kernel_trap(trapno, ssp, dsisr, dar, NULL);
 			break;
+
+
+		case T_ALIGNMENT:
+/*
+*			If enaNotifyEMb is set, we get here, and
+*			we have actually already emulated the unaligned access.
+*			All that we want to do here is to ignore the interrupt. This is to allow logging or
+*			tracing of unaligned accesses.  
+*/
+			
+			KERNEL_DEBUG_CONSTANT(
+				MACHDBG_CODE(DBG_MACH_EXCP_ALNG, 0) | DBG_FUNC_NONE,
+				(int)ssp->save_srr0 - 4, (int)dar, (int)dsisr, (int)ssp->save_lr, 0);
+			break;
+
+		case T_EMULATE:
+/*
+*			If enaNotifyEMb is set we get here, and
+*			we have actually already emulated the instruction.
+*			All that we want to do here is to ignore the interrupt. This is to allow logging or
+*			tracing of emulated instructions.  
+*/
+
+			KERNEL_DEBUG_CONSTANT(
+				MACHDBG_CODE(DBG_MACH_EXCP_EMUL, 0) | DBG_FUNC_NONE,
+				(int)ssp->save_srr0 - 4, (int)((savearea_comm *)ssp)->save_misc2, (int)dsisr, (int)ssp->save_lr, 0);
+			break;
+
+
+
+
 			
 		case T_TRACE:
 		case T_RUNMODE_TRACE:
@@ -205,28 +241,29 @@ struct savearea *trap(int trapno,
 			mp_enable_preemption();
 #endif	/* MACH_KDB */
 
-			if(intr) ml_set_interrupts_enabled(TRUE);	/* Enable if we were */
-
-			/* simple case : not SR_COPYIN segment, from kernel */
-			if ((dar >> 28) != SR_COPYIN_NUM) {
-				map = kernel_map;
+			if(ssp->save_dsisr & dsiInvMode) {			/* Did someone try to reserve cache inhibited? */
+				panic("trap: disallowed access to cache inhibited memory - %016llX\n", dar);
+			}
 
-				offset = dar;
+			if(intr) ml_set_interrupts_enabled(TRUE);	/* Enable if we were */
+			
+			if(((dar >> 28) < 0xE) | ((dar >> 28) > 0xF))  {	/* Is this a copy in/out? */
+			
+				offset = (unsigned int)dar;				/* Set the failing address */
+				map = kernel_map;						/* No, this is a normal kernel access */
 				
-
 /*
  *	Note: Some ROM device drivers will access page 0 when they start.  The IOKit will 
  *	set a flag to tell us to ignore any access fault on page 0.  After the driver is
  *	opened, it will clear the flag.
  */
-				if((0 == (dar & -PAGE_SIZE)) && 	/* Check for access of page 0 and */
-				  ((thr_act->mact.specFlags) & ignoreZeroFault)) {
-									/* special case of ignoring page zero faults */
-					ssp->save_srr0 += 4;			/* Point to next instruction */
+				if((0 == (offset & -PAGE_SIZE)) && 		/* Check for access of page 0 and */
+				  ((thr_act->mact.specFlags) & ignoreZeroFault)) {	/* special case of ignoring page zero faults */
+					ssp->save_srr0 += 4;				/* Point to next instruction */
 					break;
 				}
 
-				code = vm_fault(map, trunc_page(offset),
+				code = vm_fault(map, trunc_page_32(offset),
 						dsisr & MASK(DSISR_WRITE) ? PROT_RW : PROT_RO,
 						FALSE, THREAD_UNINT, NULL, 0);
 
@@ -234,7 +271,8 @@ struct savearea *trap(int trapno,
 					unresolved_kernel_trap(trapno, ssp, dsisr, dar, NULL);
 				} else { 
 					ssp->save_hdr.save_flags |= SAVredrive;	/* Tell low-level to re-try fault */
-					ssp->save_dsisr |= MASK(DSISR_HASH);	/* Make sure this is marked as a miss */
+					ssp->save_dsisr = (ssp->save_dsisr & 
+						~((MASK(DSISR_NOEX) | MASK(DSISR_PROT)))) | MASK(DSISR_HASH);	/* Make sure this is marked as a miss */
 				}
 				break;
 			}
@@ -242,13 +280,10 @@ struct savearea *trap(int trapno,
 			/* If we get here, the fault was due to a copyin/out */
 
 			map = thr_act->map;
+			
+			offset = (unsigned int)(thr_act->mact.cioRelo + dar);	/* Compute the user space address */
 
-			/* Mask out SR_COPYIN and mask in original segment */
-
-			offset = (dar & 0x0fffffff) |
-				((mfsrin(dar)<<8) & 0xF0000000);
-
-			code = vm_fault(map, trunc_page(offset),
+			code = vm_fault(map, trunc_page_32(offset),
 					dsisr & MASK(DSISR_WRITE) ? PROT_RW : PROT_RO,
 					FALSE, THREAD_UNINT, NULL, 0);
 
@@ -270,7 +305,8 @@ struct savearea *trap(int trapno,
 			}
 			else { 
 				ssp->save_hdr.save_flags |= SAVredrive;	/* Tell low-level to re-try fault */
-				ssp->save_dsisr |= MASK(DSISR_HASH);	/* Make sure this is marked as a miss */
+				ssp->save_dsisr = (ssp->save_dsisr & 
+					~((MASK(DSISR_NOEX) | MASK(DSISR_PROT)))) | MASK(DSISR_HASH);	/* Make sure this is marked as a miss */
 			}
 			
 			break;
@@ -296,14 +332,15 @@ struct savearea *trap(int trapno,
 
 			map = kernel_map;
 			
-			code = vm_fault(map, trunc_page(ssp->save_srr0),
+			code = vm_fault(map, trunc_page_64(ssp->save_srr0),
 					PROT_EXEC, FALSE, THREAD_UNINT, NULL, 0);
 
 			if (code != KERN_SUCCESS) {
 				unresolved_kernel_trap(trapno, ssp, dsisr, dar, NULL);
 			} else { 
 				ssp->save_hdr.save_flags |= SAVredrive;	/* Tell low-level to re-try fault */
-				ssp->save_srr1 |= MASK(DSISR_HASH);		/* Make sure this is marked as a miss */
+				ssp->save_srr1 = (ssp->save_srr1 & 
+					~((unsigned long long)(MASK(DSISR_NOEX) | MASK(DSISR_PROT)))) | MASK(DSISR_HASH);		/* Make sure this is marked as a miss */
 			}
 			break;
 
@@ -343,6 +380,10 @@ struct savearea *trap(int trapno,
 			unresolved_kernel_trap(trapno, ssp, dsisr, dar, NULL);
 			break;	
 
+		case T_PERF_MON:
+			perfmon_handle_pmi(ssp);
+			break;
+
 			/*
 			 * These trap types should never be seen by trap()
 			 * Some are interrupts that should be seen by
@@ -362,40 +403,41 @@ struct savearea *trap(int trapno,
 
 			ml_set_interrupts_enabled(FALSE);					/* Turn off interruptions */
 
-			panic("Unexpected user state trap(cpu %d): 0x%08x DSISR=0x%08x DAR=0x%08x PC=0x%08x, MSR=0x%08x\n",
+			panic("Unexpected user state trap(cpu %d): 0x%08X DSISR=0x%08X DAR=0x%016llX PC=0x%016llX, MSR=0x%016llX\n",
 			       cpu_number(), trapno, dsisr, dar, ssp->save_srr0, ssp->save_srr1);
 			break;
 
 		case T_RESET:
-#if 0
-			kprintf("*** Reset exception ignored; srr0 = %08X, srr1 = %08X\n",
-				ssp->save_srr0, ssp->save_srr1);
-#else
-			panic("Unexpected Reset exception: srr0 = %0x08x, srr1 = %0x08x\n",
-				ssp->save_srr0, ssp->save_srr1);
-#endif
+			ml_set_interrupts_enabled(FALSE);					/* Turn off interruptions */
+			if (!Call_Debugger(trapno, ssp))
+				panic("Unexpected Reset exception: srr0 = %016llx, srr1 = %016llx\n",
+					ssp->save_srr0, ssp->save_srr1);
 			break;						/* We just ignore these */
 
 		case T_ALIGNMENT:
 /*
-*			If notifyUnaligned is set, we have actually already emulated the unaligned access.
+*			If enaNotifyEMb is set, we get here, and
+*			we have actually already emulated the unaligned access.
 *			All that we want to do here is to ignore the interrupt. This is to allow logging or
-*			tracing of unaligned accesses.  Note that if trapUnaligned is also set, it takes 
-*			precedence and we will take a bad access fault.
+*			tracing of unaligned accesses.  
 */
-
-			if(thr_act->mact.specFlags & notifyUnalign) {
 			
-				KERNEL_DEBUG_CONSTANT(
-						MACHDBG_CODE(DBG_MACH_EXCP_ALNG, 0) | DBG_FUNC_NONE,
-								(int)ssp->save_srr0, (int)dar, (int)dsisr, (int)ssp->save_lr, 0);
-			}
-			
-			if((!(thr_act->mact.specFlags & notifyUnalign)) || (thr_act->mact.specFlags & trapUnalign)) {
-				code = EXC_PPC_UNALIGNED;
-				exception = EXC_BAD_ACCESS;
-				subcode = dar;
-			}
+			KERNEL_DEBUG_CONSTANT(
+				MACHDBG_CODE(DBG_MACH_EXCP_ALNG, 0) | DBG_FUNC_NONE,
+				(int)ssp->save_srr0 - 4, (int)dar, (int)dsisr, (int)ssp->save_lr, 0);
+			break;
+
+		case T_EMULATE:
+/*
+*			If enaNotifyEMb is set we get here, and
+*			we have actually already emulated the instruction.
+*			All that we want to do here is to ignore the interrupt. This is to allow logging or
+*			tracing of emulated instructions.  
+*/
+
+			KERNEL_DEBUG_CONSTANT(
+				MACHDBG_CODE(DBG_MACH_EXCP_EMUL, 0) | DBG_FUNC_NONE,
+				(int)ssp->save_srr0 - 4, (int)((savearea_comm *)ssp)->save_misc2, (int)dsisr, (int)ssp->save_lr, 0);
 			break;
 
 		case T_TRACE:			/* Real PPC chips */
@@ -405,11 +447,10 @@ struct savearea *trap(int trapno,
 		  }
 		  /* fall through */
 
-		case T_INSTRUCTION_BKPT:	/* 603  PPC chips */
-		case T_RUNMODE_TRACE:		/* 601  PPC chips */
+		case T_INSTRUCTION_BKPT:
 			exception = EXC_BREAKPOINT;
 			code = EXC_PPC_TRACE;
-			subcode = ssp->save_srr0;
+			subcode = (unsigned int)ssp->save_srr0;
 			break;
 
 		case T_PROGRAM:
@@ -428,19 +469,32 @@ struct savearea *trap(int trapno,
 				UPDATE_PPC_EXCEPTION_STATE
 				exception = EXC_BAD_INSTRUCTION;
 				code = EXC_PPC_UNIPL_INST;
-				subcode = ssp->save_srr0;
-			} else if (ssp->save_srr1 & MASK(SRR1_PRG_PRV_INS)) {
+				subcode = (unsigned int)ssp->save_srr0;
+			} else if ((unsigned int)ssp->save_srr1 & MASK(SRR1_PRG_PRV_INS)) {
 
 				UPDATE_PPC_EXCEPTION_STATE;
 				exception = EXC_BAD_INSTRUCTION;
 				code = EXC_PPC_PRIVINST;
-				subcode = ssp->save_srr0;
+				subcode = (unsigned int)ssp->save_srr0;
 			} else if (ssp->save_srr1 & MASK(SRR1_PRG_TRAP)) {
 				unsigned int inst;
-
-				if (copyin((char *) ssp->save_srr0, (char *) &inst, 4 ))
-					panic("copyin failed\n");
+				char *iaddr;
+				
+				iaddr = (char *)ssp->save_srr0;		/* Trim from long long and make a char pointer */
+				if (copyin(iaddr, (char *) &inst, 4 )) panic("copyin failed\n");
+				
+				if(dgWork.dgFlags & enaDiagTrap) {	/* Is the diagnostic trap enabled? */
+					if((inst & 0xFFFFFFF0) == 0x0FFFFFF0) {	/* Is this a TWI 31,R31,0xFFFx? */
+						if(diagTrap(ssp, inst & 0xF)) {	/* Call the trap code */
+							ssp->save_srr0 += 4ULL;	/* If we eat the trap, bump pc */
+							exception = 0;			/* Clear exception */
+							break;					/* All done here */
+						}
+					}
+				}
+				
 				UPDATE_PPC_EXCEPTION_STATE;
+				
 				if (inst == 0x7FE00008) {
 					exception = EXC_BREAKPOINT;
 					code = EXC_PPC_BREAKPOINT;
@@ -448,7 +502,7 @@ struct savearea *trap(int trapno,
 					exception = EXC_SOFTWARE;
 					code = EXC_PPC_TRAP;
 				}
-				subcode = ssp->save_srr0;
+				subcode = (unsigned int)ssp->save_srr0;
 			}
 			break;
 			
@@ -456,23 +510,31 @@ struct savearea *trap(int trapno,
 			UPDATE_PPC_EXCEPTION_STATE;
 			exception = EXC_ARITHMETIC;
 			code = EXC_PPC_ALTIVECASSIST;
-			subcode = ssp->save_srr0;
+			subcode = (unsigned int)ssp->save_srr0;
 			break;
 
 		case T_DATA_ACCESS:
 			map = thr_act->map;
+
+			if(ssp->save_dsisr & dsiInvMode) {			/* Did someone try to reserve cache inhibited? */
+				UPDATE_PPC_EXCEPTION_STATE;				/* Don't even bother VM with this one */
+				exception = EXC_BAD_ACCESS;
+				subcode = (unsigned int)dar;
+				break;
+			}
 			
-			code = vm_fault(map, trunc_page(dar),
+			code = vm_fault(map, trunc_page_64(dar),
 				 dsisr & MASK(DSISR_WRITE) ? PROT_RW : PROT_RO,
 				 FALSE, THREAD_ABORTSAFE, NULL, 0);
 
 			if ((code != KERN_SUCCESS) && (code != KERN_ABORTED)) {
 				UPDATE_PPC_EXCEPTION_STATE;
 				exception = EXC_BAD_ACCESS;
-				subcode = dar;
+				subcode = (unsigned int)dar;
 			} else { 
 				ssp->save_hdr.save_flags |= SAVredrive;	/* Tell low-level to re-try fault */
-				ssp->save_dsisr |= MASK(DSISR_HASH);	/* Make sure this is marked as a miss */
+				ssp->save_dsisr = (ssp->save_dsisr & 
+					~((MASK(DSISR_NOEX) | MASK(DSISR_PROT)))) | MASK(DSISR_HASH);	/* Make sure this is marked as a miss */
 			}
 			break;
 			
@@ -482,16 +544,17 @@ struct savearea *trap(int trapno,
 			 */
 			map = thr_act->map;
 			
-			code = vm_fault(map, trunc_page(ssp->save_srr0),
+			code = vm_fault(map, trunc_page_64(ssp->save_srr0),
 					PROT_EXEC, FALSE, THREAD_ABORTSAFE, NULL, 0);
 
 			if ((code != KERN_SUCCESS) && (code != KERN_ABORTED)) {
 				UPDATE_PPC_EXCEPTION_STATE;
 				exception = EXC_BAD_ACCESS;
-				subcode = ssp->save_srr0;
+				subcode = (unsigned int)ssp->save_srr0;
 			} else { 
 				ssp->save_hdr.save_flags |= SAVredrive;	/* Tell low-level to re-try fault */
-				ssp->save_srr1 |= MASK(DSISR_HASH);		/* Make sure this is marked as a miss */
+				ssp->save_srr1 = (ssp->save_srr1 & 
+					~((unsigned long long)(MASK(DSISR_NOEX) | MASK(DSISR_PROT)))) | MASK(DSISR_HASH);		/* Make sure this is marked as a miss */
 			}
 			break;
 
@@ -513,6 +576,7 @@ struct savearea *trap(int trapno,
 	if (exception) {
 		/* if this is the init task, save the exception information */
 		/* this probably is a fatal exception */
+#if 0
 		if(bsd_init_task == current_task()) {
 			char *buf;
         		int i;
@@ -521,7 +585,7 @@ struct savearea *trap(int trapno,
 
 
 			buf += sprintf(buf, "Exception Code = 0x%x, Subcode = 0x%x\n", code, subcode);
-			buf += sprintf(buf, "DSISR = 0x%08x, DAR = 0x%08x\n"
+			buf += sprintf(buf, "DSISR = 0x%08x, DAR = 0x%016llx\n"
 								, dsisr, dar);
 
 			for (i=0; i<32; i++) {
@@ -532,12 +596,12 @@ struct savearea *trap(int trapno,
 			}
 
         		buf += sprintf(buf, "\n\n");
-        		buf += sprintf(buf, "cr        = 0x%08x\t\t",ssp->save_cr);
-        		buf += sprintf(buf, "xer       = 0x%08x\n",ssp->save_xer);
-        		buf += sprintf(buf, "lr        = 0x%08x\t\t",ssp->save_lr);
-        		buf += sprintf(buf, "ctr       = 0x%08x\n",ssp->save_ctr); 
-        		buf += sprintf(buf, "srr0(iar) = 0x%08x\t\t",ssp->save_srr0);
-        		buf += sprintf(buf, "srr1(msr) = 0x%08B\n",ssp->save_srr1,
+        		buf += sprintf(buf, "cr        = 0x%08X\t\t",ssp->save_cr);
+        		buf += sprintf(buf, "xer       = 0x%08X\n",ssp->save_xer);
+        		buf += sprintf(buf, "lr        = 0x%016llX\t\t",ssp->save_lr);
+        		buf += sprintf(buf, "ctr       = 0x%016llX\n",ssp->save_ctr); 
+        		buf += sprintf(buf, "srr0(iar) = 0x%016llX\t\t",ssp->save_srr0);
+        		buf += sprintf(buf, "srr1(msr) = 0x%016llX\n",ssp->save_srr1,
                    	   "\x10\x11""EE\x12PR\x13""FP\x14ME\x15""FE0\x16SE\x18"
                     	   "FE1\x19""AL\x1a""EP\x1bIT\x1c""DT");
         		buf += sprintf(buf, "\n\n");
@@ -552,7 +616,7 @@ struct savearea *trap(int trapno,
                                		break;
                         	if (!copyin(addr,(char*)stack_buf, 
 							3 * sizeof(int))) {
-                               		buf += sprintf(buf, "0x%08x : 0x%08x\n"
+                               		buf += sprintf(buf, "0x%08X : 0x%08X\n"
 						,addr,stack_buf[2]);
                                		addr = (char*)stack_buf[0];
                         	} else {
@@ -562,6 +626,7 @@ struct savearea *trap(int trapno,
         		}
 			buf[0] = '\0';
 		}
+#endif
 		doexception(exception, code, subcode);
 	}
 	/* AST delivery
@@ -589,22 +654,23 @@ extern int pmdebug;
 int syscall_trace(int retval, struct savearea *ssp)
 {
 	int i, argc;
-
 	int kdarg[3];
-	/* Always prepare to trace mach system calls */
-	if (kdebug_enable && (ssp->save_r0 & 0x80000000)) {
-	  /* Mach trap */
-	  kdarg[0]=0;
-	  kdarg[1]=0;
-	  kdarg[2]=0;
-	  argc = mach_trap_table[-(ssp->save_r0)].mach_trap_arg_count;
-	  if (argc > 3)
-	    argc = 3;
-	  for (i=0; i < argc; i++)
-	    kdarg[i] = (int)*(&ssp->save_r3 + i);
-	  KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_EXCP_SC, (-(ssp->save_r0))) | DBG_FUNC_START,
-		       kdarg[0], kdarg[1], kdarg[2], 0, 0);
-	}	    
+/* Always prepare to trace mach system calls */
+
+	kdarg[0]=0;
+	kdarg[1]=0;
+	kdarg[2]=0;
+	
+	argc = mach_trap_table[-((unsigned int)ssp->save_r0)].mach_trap_arg_count;
+	
+	if (argc > 3)
+		argc = 3;
+	
+	for (i=0; i < argc; i++)
+		kdarg[i] = (int)*(&ssp->save_r3 + i);
+	
+	KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_EXCP_SC, (-(ssp->save_r0))) | DBG_FUNC_START,
+		kdarg[0], kdarg[1], kdarg[2], 0, 0);
 
 	return retval;
 }
@@ -617,11 +683,8 @@ extern int syscall_trace_end(int, struct savearea *);
 
 int syscall_trace_end(int retval, struct savearea *ssp)
 {
-	if (kdebug_enable && (ssp->save_r0 & 0x80000000)) {
-	  /* Mach trap */
-	  KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_EXCP_SC,(-(ssp->save_r0))) | DBG_FUNC_END,
-		       retval, 0, 0, 0, 0);
-	}	    
+	KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_EXCP_SC,(-((unsigned int)ssp->save_r0))) | DBG_FUNC_END,
+		retval, 0, 0, 0, 0);
 	return retval;
 }
 
@@ -697,7 +760,7 @@ char *trap_type[] = {
 	"INVALID EXCEPTION",
 	"INVALID EXCEPTION",
 	"INVALID EXCEPTION",
-	"INVALID EXCEPTION",
+	"Emulate",
 	"0x2000 - Run Mode/Trace",
 	"Signal Processor",
 	"Preemption",
@@ -710,7 +773,7 @@ int TRAP_TYPES = sizeof (trap_type) / sizeof (trap_type[0]);
 void unresolved_kernel_trap(int trapno,
 			    struct savearea *ssp,
 			    unsigned int dsisr,
-			    unsigned int dar,
+			    addr64_t dar,
 			    char *message)
 {
 	char *trap_name;
@@ -731,7 +794,7 @@ void unresolved_kernel_trap(int trapno,
 	if (message == NULL)
 		message = trap_name;
 
-	kdb_printf("\n\nUnresolved kernel trap(cpu %d): %s DAR=0x%08x PC=0x%08x\n",
+	kdb_printf("\n\nUnresolved kernel trap(cpu %d): %s DAR=0x%016llX PC=0x%016llX\n",
 	       cpu_number(), trap_name, dar, ssp->save_srr0);
 
 	print_backtrace(ssp);
@@ -750,7 +813,7 @@ thread_syscall_return(
         register thread_act_t   thr_act = current_act();
         register struct savearea *regs = USER_REGS(thr_act);
 
-	if (kdebug_enable && (regs->save_r0 & 0x80000000)) {
+	if (kdebug_enable && ((unsigned int)regs->save_r0 & 0x80000000)) {
 	  /* Mach trap */
 	  KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_EXCP_SC,(-(regs->save_r0))) | DBG_FUNC_END,
 		       ret, 0, 0, 0, 0);
diff --git a/osfmk/ppc/trap.h b/osfmk/ppc/trap.h
index fdc3ef828..31c2026f3 100644
--- a/osfmk/ppc/trap.h
+++ b/osfmk/ppc/trap.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -75,12 +78,13 @@ extern void			thread_exception_return(void);
 extern struct savearea*	trap(int trapno,
 				     struct savearea *ss,
 				     unsigned int dsisr,
-				     unsigned int dar);
+				     addr64_t dar);
 
 typedef kern_return_t (*perfTrap)(int trapno, struct savearea *ss, 
-	unsigned int dsisr, unsigned int dar);
+	unsigned int dsisr, addr64_t dar);
 
 extern perfTrap perfTrapHook;
+extern perfTrap perfIntHook;
 
 extern struct savearea* interrupt(int intno,
 					 struct savearea *ss,
diff --git a/osfmk/ppc/vm_tuning.h b/osfmk/ppc/vm_tuning.h
index a0254bc7c..a856bfc35 100644
--- a/osfmk/ppc/vm_tuning.h
+++ b/osfmk/ppc/vm_tuning.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/ppc/vmachmon.c b/osfmk/ppc/vmachmon.c
index ae22aab36..21ac0a1e3 100644
--- a/osfmk/ppc/vmachmon.c
+++ b/osfmk/ppc/vmachmon.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -24,9 +27,6 @@
 **
 ** C routines that we are adding to the MacOS X kernel.
 **
-** Weird Apple PSL stuff goes here...
-**
-** Until then, Copyright 2000, Connectix
 -----------------------------------------------------------------------*/
 
 #include <mach/mach_types.h>
@@ -40,7 +40,6 @@
 #include <ppc/exception.h>
 #include <ppc/mappings.h>
 #include <ppc/thread_act.h>
-#include <ppc/pmap_internals.h>
 #include <vm/vm_kern.h>
 
 #include <ppc/vmachmon.h>
@@ -73,8 +72,10 @@ vmmCntrlEntry *vmm_get_entry(
 	vmmCntrlTable *CTable;
 	vmmCntrlEntry *CEntry;
 
+	index = index & vmmTInum;								/* Clean up the index */
+
 	if (act->mact.vmmControl == 0) return NULL;				/* No control table means no vmm */
-	if ((index - 1) >= kVmmMaxContextsPerThread) return NULL;	/* Index not in range */	
+	if ((index - 1) >= kVmmMaxContexts) return NULL;		/* Index not in range */	
 
 	CTable = act->mact.vmmControl;							/* Make the address a bit more convienient */
 	CEntry = &CTable->vmmc[index - 1];						/* Point to the entry */
@@ -84,6 +85,39 @@ vmmCntrlEntry *vmm_get_entry(
 	return CEntry;
 }
 
+/*-----------------------------------------------------------------------
+** vmm_get_adsp
+**
+** This function verifies and returns the pmap for an address space.
+** If there is none and the request is valid, a pmap will be created.
+**
+** Inputs:
+**		act - pointer to current thread activation
+**		index - index into vmm control table (this is a "one based" value)
+**
+** Outputs:
+**		address of a pmap or 0 if not found or could no be created
+**		Note that if there is no pmap for the address space it will be created.
+-----------------------------------------------------------------------*/
+
+pmap_t vmm_get_adsp(thread_act_t act, vmm_thread_index_t index)
+{
+	pmap_t pmap;
+
+	if (act->mact.vmmControl == 0) return NULL;				/* No control table means no vmm */
+	if ((index - 1) >= kVmmMaxContexts) return NULL;		/* Index not in range */	
+
+	pmap = act->mact.vmmControl->vmmAdsp[index - 1];		/* Get the pmap */
+	if(pmap) return pmap;									/* We've got it... */
+
+	pmap = pmap_create(0);									/* Make a fresh one */
+	act->mact.vmmControl->vmmAdsp[index - 1] = pmap;		/* Remember it */
+/*
+ *	Note that if the create fails, we will return a null.
+ */
+	return pmap;											/* Return it... */
+}
+
 
 
 /*************************************************************************************
@@ -137,10 +171,60 @@ int vmm_get_version(struct savearea *save)
 int vmm_get_features(struct savearea *save)
 {
 	save->save_r3 = kVmmCurrentFeatures;		/* Return the features */
+	if(per_proc_info->pf.Available & pf64Bit) {
+		save->save_r3 &= ~kVmmFeature_LittleEndian;	/* No little endian here */
+		save->save_r3 |= kVmmFeature_SixtyFourBit;	/* Set that we can do 64-bit */
+	}
 	return 1;
 }
 
 
+/*-----------------------------------------------------------------------
+** vmm_max_addr
+**
+** This function returns the maximum addressable virtual address sported
+**
+** Outputs:
+**		Returns max address
+-----------------------------------------------------------------------*/
+
+addr64_t vmm_max_addr(thread_act_t act) 
+{
+	return vm_max_address;							/* Return the maximum address */
+}
+
+/*-----------------------------------------------------------------------
+** vmm_get_XA
+**
+** This function retrieves the eXtended Architecture flags for the specifed VM.
+** 
+** We need to return the result in the return code rather than in the return parameters
+** because we need an architecture independent format so the results are actually 
+** usable by the host. For example, the return parameters for 64-bit are 8 bytes wide vs.
+** 4 for 32-bit. 
+** 
+**
+** Inputs:
+**		act - pointer to current thread activation structure
+**		index - index returned by vmm_init_context
+**
+** Outputs:
+**		Return code is set to the XA flags.  If the index is invalid or the
+**		context has not been created, we return 0.
+-----------------------------------------------------------------------*/
+
+unsigned int vmm_get_XA(
+	thread_act_t 		act,
+	vmm_thread_index_t 	index)
+{
+	vmmCntrlEntry 		*CEntry;
+
+	CEntry = vmm_get_entry(act, index);				/* Convert index to entry */		
+	if (CEntry == NULL) return 0;					/* Either this isn't a vmm or the index is bogus */
+	
+	return CEntry->vmmXAFlgs;						/* Return the flags */
+}
+
 /*-----------------------------------------------------------------------
 ** vmm_init_context
 **
@@ -170,7 +254,7 @@ int vmm_init_context(struct savearea *save)
 	vmmCntrlTable		*CTable;
 	vm_offset_t			conkern;
 	vmm_state_page_t *	vks;
-	vm_offset_t			conphys;
+	ppnum_t				conphys;
 	kern_return_t 		ret;
 	pmap_t				new_pmap;	
 	int					cvi, i;
@@ -248,11 +332,11 @@ int vmm_init_context(struct savearea *save)
 		act->mact.vmmControl = CTable;			/* Initialize the table anchor */
 	}
 
-	for(cvi = 0; cvi < kVmmMaxContextsPerThread; cvi++) {	/* Search to find a free slot */
+	for(cvi = 0; cvi < kVmmMaxContexts; cvi++) {	/* Search to find a free slot */
 		if(!(CTable->vmmc[cvi].vmmFlags & vmmInUse)) break;	/* Bail if we find an unused slot */
 	}
 	
-	if(cvi >= kVmmMaxContextsPerThread) {		/* Did we find one? */
+	if(cvi >= kVmmMaxContexts) {				/* Did we find one? */
 		ml_set_interrupts_enabled(FALSE);		/* Set back interruptions */
 		save->save_r3 = KERN_RESOURCE_SHORTAGE;	/* No empty slots... */	
 		return 1;
@@ -269,7 +353,7 @@ int vmm_init_context(struct savearea *save)
 		goto return_in_shame;
 
 	/* Map the vmm state into the kernel's address space. */
-	conphys = pmap_extract(act->map->pmap, (vm_offset_t)vmm_user_state);
+	conphys = pmap_find_phys(act->map->pmap, (addr64_t)vmm_user_state);
 
 	/* Find a virtual address to use. */
 	ret = kmem_alloc_pageable(kernel_map, &conkern, PAGE_SIZE);
@@ -282,6 +366,7 @@ int vmm_init_context(struct savearea *save)
 	}
 	
 	/* Map it into the kernel's address space. */
+
 	pmap_enter(kernel_pmap, conkern, conphys, 
 		VM_PROT_READ | VM_PROT_WRITE, 
 		VM_WIMG_USE_DEFAULT, TRUE);
@@ -290,17 +375,6 @@ int vmm_init_context(struct savearea *save)
 	vks = (vmm_state_page_t *)conkern;
 	bzero((char *)vks, PAGE_SIZE);
 	
-	/* Allocate a new pmap for the new vmm context. */
-	new_pmap = pmap_create(0);
-	if (new_pmap == PMAP_NULL) {
-		(void) vm_map_unwire(act->map,			/* Couldn't get a pmap, unwire the user page */
-			(vm_offset_t)vmm_user_state,
-			(vm_offset_t)vmm_user_state + PAGE_SIZE,
-			TRUE);
-		
-		kmem_free(kernel_map, conkern, PAGE_SIZE);	/* Release the kernel address */
-		goto return_in_shame;
-	}
 	
 	/* We're home free now. Simply fill in the necessary info and return. */
 	
@@ -308,8 +382,8 @@ int vmm_init_context(struct savearea *save)
 	vks->thread_index = cvi + 1;				/* Tell the user the index for this virtual machine */
 	
 	CTable->vmmc[cvi].vmmFlags = vmmInUse;		/* Mark the slot in use and make sure the rest are clear */
-	CTable->vmmc[cvi].vmmPmap = new_pmap;		/* Remember the pmap for this guy */
 	CTable->vmmc[cvi].vmmContextKern = vks;		/* Remember the kernel address of comm area */
+	CTable->vmmc[cvi].vmmContextPhys = (vmm_state_page_t *)conphys;	/* Remember the state page physical addr */
 	CTable->vmmc[cvi].vmmContextUser = vmm_user_state;		/* Remember user address of comm area */
 	
 	CTable->vmmc[cvi].vmmFacCtx.FPUsave = 0;	/* Clear facility context control */
@@ -321,6 +395,12 @@ int vmm_init_context(struct savearea *save)
 	CTable->vmmc[cvi].vmmFacCtx.facAct = act;	/* Point back to the activation */
 
 	hw_atomic_add((int *)&saveanchor.savetarget, 2);	/* Account for the number of extra saveareas we think we might "need" */
+
+	if (!(act->map->pmap->pmapFlags & pmapVMhost)) {
+		simple_lock(&(act->map->pmap->lock));
+		act->map->pmap->pmapFlags |= pmapVMhost;
+		simple_unlock(&(act->map->pmap->lock));
+	}
 	
 	ml_set_interrupts_enabled(FALSE);			/* Set back interruptions */
 	save->save_r3 = KERN_SUCCESS;				/* Hip, hip, horay... */	
@@ -348,6 +428,12 @@ return_in_shame:
 **
 ** Outputs:
 **		kernel return code indicating success or failure
+**
+** Strangeness note:
+**		This call will also trash the address space with the same ID.  While this 
+**		is really not too cool, we have to do it because we need to make
+**		sure that old VMM users (not that we really have any) who depend upon 
+**		the address space going away with the context still work the same.
 -----------------------------------------------------------------------*/
 
 kern_return_t vmm_tear_down_context(
@@ -375,11 +461,14 @@ kern_return_t vmm_tear_down_context(
 		toss_live_vec(&CEntry->vmmFacCtx);			/* Get rid of any live context here */
 		save_release((savearea *)CEntry->vmmFacCtx.VMXsave);	/* Release it */
 	}
-
-	mapping_remove(CEntry->vmmPmap, 0xFFFFF000);	/* Remove final page explicitly because we might have mapped it */	
-	pmap_remove(CEntry->vmmPmap, 0, 0xFFFFF000);	/* Remove all entries from this map */
-	pmap_destroy(CEntry->vmmPmap);					/* Toss the pmap for this context */
-	CEntry->vmmPmap = NULL;							/* Clean it up */
+	
+	CEntry->vmmPmap = 0;							/* Remove this trace */
+	if(act->mact.vmmControl->vmmAdsp[index - 1]) {	/* Check if there is an address space assigned here */
+		mapping_remove(act->mact.vmmControl->vmmAdsp[index - 1], 0xFFFFFFFFFFFFF000LL);	/* Remove final page explicitly because we might have mapped it */	
+		pmap_remove(act->mact.vmmControl->vmmAdsp[index - 1], 0, 0xFFFFFFFFFFFFF000LL);	/* Remove all entries from this map */
+		pmap_destroy(act->mact.vmmControl->vmmAdsp[index - 1]);	/* Toss the pmap for this context */
+		act->mact.vmmControl->vmmAdsp[index - 1] = NULL;	/* Clean it up */
+	}
 	
 	(void) vm_map_unwire(							/* Unwire the user comm page */
 		act->map,
@@ -389,8 +478,10 @@ kern_return_t vmm_tear_down_context(
 	
 	kmem_free(kernel_map, (vm_offset_t)CEntry->vmmContextKern, PAGE_SIZE);	/* Remove kernel's view of the comm page */
 	
+	CTable = act->mact.vmmControl;					/* Get the control table address */
+	CTable->vmmGFlags = CTable->vmmGFlags & ~vmmLastAdSp;	/* Make sure we don't try to automap into this */
+
 	CEntry->vmmFlags = 0;							/* Clear out all of the flags for this entry including in use */
-	CEntry->vmmPmap = 0;							/* Clear pmap pointer */
 	CEntry->vmmContextKern = 0;						/* Clear the kernel address of comm area */
 	CEntry->vmmContextUser = 0;						/* Clear the user address of comm area */
 	
@@ -402,14 +493,26 @@ kern_return_t vmm_tear_down_context(
 	CEntry->vmmFacCtx.VMXcpu = 0;					/* Clear facility context control */
 	CEntry->vmmFacCtx.facAct = 0;					/* Clear facility context control */
 	
-	CTable = act->mact.vmmControl;					/* Get the control table address */
-	for(cvi = 0; cvi < kVmmMaxContextsPerThread; cvi++) {	/* Search to find a free slot */
+	for(cvi = 0; cvi < kVmmMaxContexts; cvi++) {	/* Search to find a free slot */
 		if(CTable->vmmc[cvi].vmmFlags & vmmInUse) {	/* Return if there are still some in use */
 			ml_set_interrupts_enabled(FALSE);		/* No more interruptions */
 			return KERN_SUCCESS;					/* Leave... */
 		}
 	}
 
+/*
+ *	When we have tossed the last context, toss any address spaces left over before releasing
+ *	the VMM control block 
+ */
+
+	for(cvi = 1; cvi <= kVmmMaxContexts; cvi++) {	/* Look at all slots */
+		if(!act->mact.vmmControl->vmmAdsp[index - 1]) continue;	/* Nothing to remove here */
+		mapping_remove(act->mact.vmmControl->vmmAdsp[index - 1], 0xFFFFFFFFFFFFF000LL);	/* Remove final page explicitly because we might have mapped it */	
+		pmap_remove(act->mact.vmmControl->vmmAdsp[index - 1], 0, 0xFFFFFFFFFFFFF000LL);	/* Remove all entries from this map */
+		pmap_destroy(act->mact.vmmControl->vmmAdsp[index - 1]);	/* Toss the pmap for this context */
+		act->mact.vmmControl->vmmAdsp[index - 1] = 0;	/* Clear just in case */
+	}		
+
 	kfree((vm_offset_t)CTable, sizeof(vmmCntrlTable));	/* Toss the table because to tossed the last context */
 	act->mact.vmmControl = 0;						/* Unmark us as vmm */
 
@@ -418,6 +521,83 @@ kern_return_t vmm_tear_down_context(
 	return KERN_SUCCESS;
 }
 
+
+/*-----------------------------------------------------------------------
+** vmm_set_XA
+**
+** This function sets the eXtended Architecture flags for the specifed VM.
+** 
+** We need to return the result in the return code rather than in the return parameters
+** because we need an architecture independent format so the results are actually 
+** usable by the host. For example, the return parameters for 64-bit are 8 bytes wide vs.
+** 4 for 32-bit. 
+** 
+** Note that this function does a lot of the same stuff as vmm_tear_down_context
+** and vmm_init_context.
+**
+** Inputs:
+**		act - pointer to current thread activation structure
+**		index - index returned by vmm_init_context
+**		flags - the extended architecture flags
+**		
+**
+** Outputs:
+**		KERN_SUCCESS if vm is valid and initialized. KERN_FAILURE if not.
+**		Also, the internal flags are set and, additionally, the VM is completely reset.
+-----------------------------------------------------------------------*/
+
+kern_return_t vmm_set_XA(
+	thread_act_t 		act,
+	vmm_thread_index_t 	index,
+	unsigned int xaflags)
+{
+	vmmCntrlEntry 		*CEntry;
+	vmmCntrlTable		*CTable;
+	vmm_state_page_t 	*vks;
+	vmm_version_t 		version;
+
+	if(xaflags & ~vmm64Bit) return KERN_FAILURE;	/* We only support this one kind now */
+
+	CEntry = vmm_get_entry(act, index);				/* Convert index to entry */		
+	if (CEntry == NULL) return KERN_FAILURE;		/* Either this isn't a vmm or the index is bogus */
+
+	ml_set_interrupts_enabled(TRUE);				/* This can take a bit of time so pass interruptions */
+	
+	if(CEntry->vmmFacCtx.FPUsave) {					/* Is there any floating point context? */
+		toss_live_fpu(&CEntry->vmmFacCtx);			/* Get rid of any live context here */
+		save_release((savearea *)CEntry->vmmFacCtx.FPUsave);	/* Release it */
+	}
+
+	if(CEntry->vmmFacCtx.VMXsave) {					/* Is there any vector context? */
+		toss_live_vec(&CEntry->vmmFacCtx);			/* Get rid of any live context here */
+		save_release((savearea *)CEntry->vmmFacCtx.VMXsave);	/* Release it */
+	}
+
+	CTable = act->mact.vmmControl;					/* Get the control table address */
+	CTable->vmmGFlags = CTable->vmmGFlags & ~vmmLastAdSp;	/* Make sure we don't try to automap into this */
+	
+	CEntry->vmmFlags &= vmmInUse;					/* Clear out all of the flags for this entry except in use */
+	CEntry->vmmXAFlgs = (xaflags & vmm64Bit) | (CEntry->vmmXAFlgs & ~vmm64Bit);	/* Set the XA flags */
+	CEntry->vmmFacCtx.FPUsave = 0;					/* Clear facility context control */
+	CEntry->vmmFacCtx.FPUlevel = 0;					/* Clear facility context control */
+	CEntry->vmmFacCtx.FPUcpu = 0;					/* Clear facility context control */
+	CEntry->vmmFacCtx.VMXsave = 0;					/* Clear facility context control */
+	CEntry->vmmFacCtx.VMXlevel = 0;					/* Clear facility context control */
+	CEntry->vmmFacCtx.VMXcpu = 0;					/* Clear facility context control */
+	
+	vks = CEntry->vmmContextKern;					/* Get address of the context page */
+	version = vks->interface_version;				/* Save the version code */
+	bzero((char *)vks, 4096);						/* Clear all */
+
+	vks->interface_version = version;				/* Set our version code */
+	vks->thread_index = index % vmmTInum;			/* Tell the user the index for this virtual machine */
+	
+	ml_set_interrupts_enabled(FALSE);				/* No more interruptions */
+	
+	return KERN_SUCCESS;							/* Return the flags */
+}
+
+
 /*-----------------------------------------------------------------------
 ** vmm_tear_down_all
 **
@@ -458,7 +638,8 @@ void vmm_tear_down_all(thread_act_t act) {
 	
 	if(CTable = act->mact.vmmControl) {				/* Do we have a vmm control block? */
 
-		for(cvi = 1; cvi <= kVmmMaxContextsPerThread; cvi++) {	/* Look at all slots */
+
+		for(cvi = 1; cvi <= kVmmMaxContexts; cvi++) {	/* Look at all slots */
 			if(CTable->vmmc[cvi - 1].vmmFlags & vmmInUse) {	/* Is this one in use */
 				ret = vmm_tear_down_context(act, cvi);	/* Take down the found context */
 				if(ret != KERN_SUCCESS) {			/* Did it go away? */
@@ -467,6 +648,10 @@ void vmm_tear_down_all(thread_act_t act) {
 				}
 			}
 		}		
+
+/*
+ *		Note that all address apces should be gone here.
+ */
 		if(act->mact.vmmControl) {						/* Did we find one? */
 			panic("vmm_tear_down_all: control table did not get deallocated\n");	/* Table did not go away */
 		}
@@ -479,8 +664,7 @@ void vmm_tear_down_all(thread_act_t act) {
 ** vmm_map_page
 **
 ** This function maps a page from within the client's logical
-** address space into the alternate address space of the
-** Virtual Machine Monitor context. 
+** address space into the alternate address space.
 **
 ** The page need not be locked or resident.  If not resident, it will be faulted
 ** in by this code, which may take some time.   Also, if the page is not locked,
@@ -495,7 +679,7 @@ void vmm_tear_down_all(thread_act_t act) {
 **
 ** Inputs:
 **		act   - pointer to current thread activation
-**		index - index of vmm state for this page
+**		index - index of address space to map into
 **		va    - virtual address within the client's address
 **			    space
 **		ava   - virtual address within the alternate address
@@ -515,73 +699,55 @@ void vmm_tear_down_all(thread_act_t act) {
 
 kern_return_t vmm_map_page(
 	thread_act_t 		act,
-	vmm_thread_index_t 	index,
-	vm_offset_t 		cva,
-	vm_offset_t 		ava,
+	vmm_adsp_id_t	 	index,
+	addr64_t	 		cva,
+	addr64_t	 		ava,
 	vm_prot_t 			prot)
 {
 	kern_return_t		ret;
 	vmmCntrlEntry 		*CEntry;
-	vm_offset_t			phys_addr;
-	register mapping 	*mpv, *mp, *nmpv, *nmp;
+	register mapping 	*mp;
 	struct phys_entry 	*pp;
-	pmap_t				mpmap;
 	vm_map_t 			map;
+	addr64_t			ova, nextva;
+	pmap_t				pmap;
+
+	pmap = vmm_get_adsp(act, index);			/* Get the pmap for this address space */
+	if(!pmap) return KERN_FAILURE;				/* Bogus address space, no VMs, or we can't make a pmap, failure... */
+
+	if(ava > vm_max_address) return kVmmInvalidAddress;	/* Does the machine support an address of this size? */
 
-	CEntry = vmm_get_entry(act, index);			/* Get and validate the index */
-	if (CEntry == NULL)return KERN_FAILURE;		/* No good, failure... */
-	
-/*
- *	Find out if we have already mapped the address and toss it out if so.
- */
-	mp = hw_lock_phys_vir(CEntry->vmmPmap->space, ava);	/* See if there is already a mapping */
-	if((unsigned int)mp & 1) {					/* Did we timeout? */
-		panic("vmm_map_page: timeout locking physical entry for alternate virtual address (%08X)\n", ava);	/* Yeah, scream about it! */
-		return KERN_FAILURE;					/* Bad hair day, return FALSE... */
-	}
-	if(mp) {									/* If it was there, toss it */
-		mpv = hw_cpv(mp);						/* Convert mapping block to virtual */
-		hw_unlock_bit((unsigned int *)&mpv->physent->phys_link, PHYS_LOCK);	/* We're done, unlock the physical entry */
-		(void)mapping_remove(CEntry->vmmPmap, ava);	/* Throw away the mapping. we're about to replace it */
-	}
 	map = current_act()->map;					/* Get the current map */
 	
 	while(1) {									/* Keep trying until we get it or until we fail */
-		if(hw_cvp_blk(map->pmap, cva)) return KERN_FAILURE;	/* Make sure that there is no block map at this address */
 
-		mp = hw_lock_phys_vir(map->pmap->space, cva);	/* Lock the physical entry for emulator's page */
-		if((unsigned int)mp&1) {				/* Did we timeout? */
-			panic("vmm_map_page: timeout locking physical entry for emulator virtual address (%08X)\n", cva);	/* Yeah, scream about it! */
-			return KERN_FAILURE;				/* Bad hair day, return FALSE... */
-		}
+		mp = mapping_find(map->pmap, cva, &nextva, 0);	/* Find the mapping for this address */
 		
-		if(mp) {								/* We found it... */
-			mpv = hw_cpv(mp);					/* Convert mapping block to virtual */
-			
-			if(!mpv->physent) return KERN_FAILURE;	/* If there is no physical entry (e.g., I/O area), we won't map it */
-			
-			if(!(mpv->PTEr & 1)) break;			/* If we are writable go ahead and map it... */
-	
-			hw_unlock_bit((unsigned int *)&mpv->physent->phys_link, PHYS_LOCK);	/* Unlock the map before we try to fault the write bit on */
-		}
+		if(mp) break;							/* We found it */
 
 		ml_set_interrupts_enabled(TRUE);		/* Enable interruptions */
-		ret = vm_fault(map, trunc_page(cva), VM_PROT_READ | VM_PROT_WRITE, FALSE, NULL, 0);	/* Didn't find it, try to fault it in read/write... */
+		ret = vm_fault(map, trunc_page_32((vm_offset_t)cva), VM_PROT_READ | VM_PROT_WRITE, FALSE);	/* Didn't find it, try to fault it in read/write... */
 		ml_set_interrupts_enabled(FALSE);		/* Disable interruptions */
 		if (ret != KERN_SUCCESS) return KERN_FAILURE;	/* There isn't a page there, return... */
 	}
 
-/*
- *	Now we make a mapping using all of the attributes of the source page except for protection.
- *	Also specify that the physical entry is locked.
- */
-	nmpv = mapping_make(CEntry->vmmPmap, mpv->physent, (ava & -PAGE_SIZE),
-		(mpv->physent->pte1 & -PAGE_SIZE), prot, ((mpv->physent->pte1 >> 3) & 0xF), 1); 
-
-	hw_unlock_bit((unsigned int *)&mpv->physent->phys_link, PHYS_LOCK);	/* Unlock the physical entry now, we're done with it */
+	if(mp->mpFlags & (mpBlock | mpNest | mpSpecial)) {	/* If this is a block, a nest, or some other special thing, we can't map it */
+		mapping_drop_busy(mp);					/* We have everything we need from the mapping */
+		return KERN_FAILURE;					/* Leave in shame */
+	}
 	
-	CEntry->vmmLastMap = ava & -PAGE_SIZE;		/* Remember the last mapping we made */
-	CEntry->vmmFlags |= vmmMapDone;				/* Set that we did a map operation */
+	while(1) {										/* Keep trying the enter until it goes in */
+		ova = mapping_make(pmap, ava, mp->mpPAddr, 0, 1, prot);	/* Enter the mapping into the pmap */
+		if(!ova) break;							/* If there were no collisions, we are done... */
+		mapping_remove(pmap, ova);				/* Remove the mapping that collided */
+	}
+
+	mapping_drop_busy(mp);						/* We have everything we need from the mapping */
+
+	if (!((per_proc_info[cpu_number()].spcFlags) & FamVMmode)) {
+		act->mact.vmmControl->vmmLastMap = ava & 0xFFFFFFFFFFFFF000ULL;	/* Remember the last mapping we made */
+		act->mact.vmmControl->vmmGFlags = (act->mact.vmmControl->vmmGFlags & ~vmmLastAdSp) | index;	/* Remember last address space */
+	}
 
 	return KERN_SUCCESS;
 }
@@ -596,6 +762,11 @@ kern_return_t vmm_map_page(
 **
 **	See description of vmm_map_page for details. 
 **
+** Inputs:
+**		Index is used for both the context and the address space ID.
+**		index[24:31] is the context id and index[16:23] is the address space.
+**		if the address space ID is 0, the context ID is used for it.
+**
 ** Outputs:
 **		Normal exit is to run the VM.  Abnormal exit is triggered via a 
 **		non-KERN_SUCCESS return from vmm_map_page or later during the 
@@ -605,70 +776,100 @@ kern_return_t vmm_map_page(
 vmm_return_code_t vmm_map_execute(
 	thread_act_t 		act,
 	vmm_thread_index_t 	index,
-	vm_offset_t 		cva,
-	vm_offset_t 		ava,
+	addr64_t	 		cva,
+	addr64_t	 		ava,
 	vm_prot_t 			prot)
 {
 	kern_return_t		ret;
 	vmmCntrlEntry 		*CEntry;
+	unsigned int		adsp;
+	vmm_thread_index_t	cndx;
 
-	CEntry = vmm_get_entry(act, index);			/* Get and validate the index */
+	cndx = index & 0xFF;							/* Clean it up */
 
+	CEntry = vmm_get_entry(act, cndx);				/* Get and validate the index */
 	if (CEntry == NULL) return kVmmBogusContext;	/* Return bogus context */
 	
-	ret = vmm_map_page(act, index, cva, ava, prot);	/* Go try to map the page on in */
+	if (((per_proc_info[cpu_number()].spcFlags) & FamVMmode) && (CEntry != act->mact.vmmCEntry))
+		return kVmmBogusContext;			/* Yes, invalid index in Fam */
+	
+	adsp = (index >> 8) & 0xFF;						/* Get any requested address space */
+	if(!adsp) adsp = (index & 0xFF);				/* If 0, use context ID as address space ID */
+	
+	ret = vmm_map_page(act, adsp, cva, ava, prot);	/* Go try to map the page on in */
 	
-	if(ret == KERN_SUCCESS) vmm_execute_vm(act, index);	/* Return was ok, launch the VM */
 	
-	return kVmmInvalidAddress;					/* We had trouble mapping in the page */	
+	if(ret == KERN_SUCCESS) {
+		act->mact.vmmControl->vmmLastMap = ava & 0xFFFFFFFFFFFFF000ULL;	/* Remember the last mapping we made */
+		act->mact.vmmControl->vmmGFlags = (act->mact.vmmControl->vmmGFlags & ~vmmLastAdSp) | cndx;	/* Remember last address space */
+		vmm_execute_vm(act, cndx);				/* Return was ok, launch the VM */
+	}
+	
+	return ret;										/* We had trouble mapping in the page */	
 	
 }
 
 /*-----------------------------------------------------------------------
 ** vmm_map_list
 **
-** This function maps a list of pages into the alternate's logical
-** address space.
+** This function maps a list of pages into various address spaces
 **
 ** Inputs:
 **		act   - pointer to current thread activation
-**		index - index of vmm state for this page
+**		index - index of default address space (used if not specifed in list entry
 **		count - number of pages to release
+**		flavor - 0 if 32-bit version, 1 if 64-bit
 **		vmcpComm in the comm page contains up to kVmmMaxMapPages to map
 **
 ** Outputs:
 **		kernel return code indicating success or failure
 **		KERN_FAILURE is returned if kVmmMaxUnmapPages is exceeded
 **		or the vmm_map_page call fails.
+**		We return kVmmInvalidAddress if virtual address size is not supported
 -----------------------------------------------------------------------*/
 
 kern_return_t vmm_map_list(
 	thread_act_t 		act,
-	vmm_thread_index_t 	index,
-	unsigned int		cnt)
+	vmm_adsp_id_t 		index,
+	unsigned int		cnt,
+	unsigned int		flavor)
 {
 	vmmCntrlEntry 		*CEntry;
 	boolean_t			ret;
 	unsigned int 		i;
-	vmmMapList			*lst;
-	vm_offset_t 		cva;
-	vm_offset_t 		ava;
+	vmmMList			*lst;
+	vmmMList64			*lstx;
+	addr64_t	 		cva;
+	addr64_t	 		ava;
 	vm_prot_t 			prot;
+	vmm_adsp_id_t 		adsp;
 
-	CEntry = vmm_get_entry(act, index);				/* Get and validate the index */
-	if (CEntry == NULL)return -1;					/* No good, failure... */
+	CEntry = vmm_get_entry(act, index);				/* Convert index to entry */		
+	if (CEntry == NULL) return KERN_FAILURE;		/* Either this isn't a vmm or the index is bogus */
 	
 	if(cnt > kVmmMaxMapPages) return KERN_FAILURE;	/* They tried to map too many */
 	if(!cnt) return KERN_SUCCESS;					/* If they said none, we're done... */
 	
-	lst = &((vmm_comm_page_t *)CEntry->vmmContextKern)->vmcpComm[0];	/* Point to the first entry */
+	lst = (vmmMList *)&((vmm_comm_page_t *)CEntry->vmmContextKern)->vmcpComm[0];	/* Point to the first entry */
+	lstx = (vmmMList64 *)&((vmm_comm_page_t *)CEntry->vmmContextKern)->vmcpComm[0];	/* Point to the first entry */
 	
 	for(i = 0; i < cnt; i++) {						/* Step and release all pages in list */
-		cva = lst[i].vmlva;							/* Get the actual address */	
-		ava = lst[i].vmlava & -vmlFlgs;				/* Get the alternate address */	
-		prot = lst[i].vmlava & vmlProt;				/* Get the protection bits */	
+		if(flavor) {								/* Check if 32- or 64-bit addresses */
+			cva = lstx[i].vmlva;					/* Get the 64-bit actual address */	
+			ava = lstx[i].vmlava;					/* Get the 64-bit guest address */	
+		}
+		else {
+			cva = lst[i].vmlva;						/* Get the 32-bit actual address */	
+			ava = lst[i].vmlava;					/* Get the 32-bit guest address */	
+		}
+
+		prot = ava & vmmlProt;						/* Extract the protection bits */	
+		adsp = (ava & vmmlAdID) >> 4;				/* Extract an explicit address space request */	
+		if(!adsp) adsp = index - 1;					/* If no explicit, use supplied default */
+		ava = ava &= 0xFFFFFFFFFFFFF000ULL;			/* Clean up the address */
+		
 		ret = vmm_map_page(act, index, cva, ava, prot);	/* Go try to map the page on in */
-		if(ret != KERN_SUCCESS) return KERN_FAILURE;	/* Bail if any error */
+		if(ret != KERN_SUCCESS) return ret;			/* Bail if any error */
 	}
 	
 	return KERN_SUCCESS	;							/* Return... */
@@ -694,45 +895,36 @@ kern_return_t vmm_map_list(
 **	    this call could return the wrong one.  Moral of the story: no aliases.
 -----------------------------------------------------------------------*/
 
-vm_offset_t vmm_get_page_mapping(
+addr64_t vmm_get_page_mapping(
 	thread_act_t 		act,
-	vmm_thread_index_t 	index,
-	vm_offset_t 		va)
+	vmm_adsp_id_t	 	index,
+	addr64_t	 		va)
 {
 	vmmCntrlEntry 		*CEntry;
-	vm_offset_t			ova;
-	register mapping 	*mpv, *mp, *nmpv, *nmp;
+	register mapping 	*mp;
 	pmap_t				pmap;
+	addr64_t			nextva, sva;
+	ppnum_t				pa;
 
-	CEntry = vmm_get_entry(act, index);						/* Get and validate the index */
-	if (CEntry == NULL)return -1;							/* No good, failure... */
+	pmap = vmm_get_adsp(act, index);						/* Get and validate the index */
+	if (!pmap)return -1;									/* No good, failure... */
 
-	mp = hw_lock_phys_vir(CEntry->vmmPmap->space, va);		/* Look up the mapping */
-	if((unsigned int)mp & 1) {								/* Did we timeout? */
-		panic("vmm_get_page_mapping: timeout locking physical entry for alternate virtual address (%08X)\n", va);	/* Yeah, scream about it! */
-		return -1;											/* Bad hair day, return FALSE... */
-	}
+	mp = mapping_find(pmap, va, &nextva, 0);				/* Find our page */
+	
 	if(!mp) return -1;										/* Not mapped, return -1 */
 
-	mpv = hw_cpv(mp);										/* Convert mapping block to virtual */
-	pmap = current_act()->map->pmap;						/* Get the current pmap */
-	ova = -1;												/* Assume failure for now */
+	pa = mp->mpPAddr;										/* Remember the page address */
+
+	mapping_drop_busy(mp);									/* Go ahead and relase the mapping now */
 	
-	for(nmpv = hw_cpv(mpv->physent->phys_link); nmpv; nmpv = hw_cpv(nmpv->next)) {	/* Scan 'em all */
-		
-		if(nmpv->pmap != pmap) continue;					/* Skip all the rest if this is not the right pmap... */ 
-		
-		ova = ((((unsigned int)nmpv->PTEhash & -64) << 6) ^ (pmap->space  << 12)) & 0x003FF000;	/* Backward hash to the wrapped VADDR */
-		ova = ova | ((nmpv->PTEv << 1) & 0xF0000000);		/* Move in the segment number */
-		ova = ova | ((nmpv->PTEv << 22) & 0x0FC00000);		/* Add in the API for the top of the address */
-		break;												/* We're done now, pass virtual address back */
-	}
+	pmap = current_act()->map->pmap;						/* Get the current pmap */
+	sva = mapping_p2v(pmap, pa);							/* Now find the source virtual */
 
-	hw_unlock_bit((unsigned int *)&mpv->physent->phys_link, PHYS_LOCK);	/* We're done, unlock the physical entry */
+	if(sva != 0) return sva;								/* We found it... */
 	
-	if(ova == -1) panic("vmm_get_page_mapping: could not back-map alternate va (%08X)\n", va);	/* We are bad wrong if we can't find it */
+	panic("vmm_get_page_mapping: could not back-map alternate va (%016llX)\n", va);	/* We are bad wrong if we can't find it */
 
-	return ova;
+	return -1;
 }
 
 /*-----------------------------------------------------------------------
@@ -753,19 +945,20 @@ vm_offset_t vmm_get_page_mapping(
 
 kern_return_t vmm_unmap_page(
 	thread_act_t 		act,
-	vmm_thread_index_t 	index,
-	vm_offset_t 		va)
+	vmm_adsp_id_t	 	index,
+	addr64_t	 		va)
 {
 	vmmCntrlEntry 		*CEntry;
-	boolean_t			ret;
+	addr64_t			nadd;
+	pmap_t				pmap;
 	kern_return_t		kern_result = KERN_SUCCESS;
 
-	CEntry = vmm_get_entry(act, index);						/* Get and validate the index */
-	if (CEntry == NULL)return -1;							/* No good, failure... */
+	pmap = vmm_get_adsp(act, index);						/* Get and validate the index */
+	if (!pmap)return -1;									/* No good, failure... */
 	
-	ret = mapping_remove(CEntry->vmmPmap, va);				/* Toss the mapping */
+	nadd = mapping_remove(pmap, va);						/* Toss the mapping */
 	
-	return (ret ? KERN_SUCCESS : KERN_FAILURE);				/* Return... */
+	return ((nadd & 1) ? KERN_FAILURE : KERN_SUCCESS);		/* Return... */
 }
 
 /*-----------------------------------------------------------------------
@@ -778,6 +971,7 @@ kern_return_t vmm_unmap_page(
 **		act   - pointer to current thread activation
 **		index - index of vmm state for this page
 **		count - number of pages to release
+**		flavor - 0 if 32-bit, 1 if 64-bit
 **		vmcpComm in the comm page contains up to kVmmMaxUnmapPages to unmap
 **
 ** Outputs:
@@ -787,28 +981,46 @@ kern_return_t vmm_unmap_page(
 
 kern_return_t vmm_unmap_list(
 	thread_act_t 		act,
-	vmm_thread_index_t 	index,
-	unsigned int 		cnt)
+	vmm_adsp_id_t	 	index,
+	unsigned int 		cnt,
+	unsigned int		flavor)
 {
 	vmmCntrlEntry 		*CEntry;
 	boolean_t			ret;
 	kern_return_t		kern_result = KERN_SUCCESS;
 	unsigned int		*pgaddr, i;
+	addr64_t			gva;
+	vmmUMList			*lst;
+	vmmUMList64			*lstx;
+	pmap_t				pmap;
+	int					adsp;
 
-	CEntry = vmm_get_entry(act, index);						/* Get and validate the index */
-	if (CEntry == NULL)return -1;							/* No good, failure... */
-	
-	if(cnt > kVmmMaxUnmapPages) return KERN_FAILURE;		/* They tried to unmap too many */
-	if(!cnt) return KERN_SUCCESS;							/* If they said none, we're done... */
+	CEntry = vmm_get_entry(act, index);				/* Convert index to entry */		
+	if (CEntry == NULL) return KERN_FAILURE;		/* Either this isn't a vmm or the index is bogus */
 	
-	pgaddr = &((vmm_comm_page_t *)CEntry->vmmContextKern)->vmcpComm[0];	/* Point to the first entry */
+	if(cnt > kVmmMaxUnmapPages) return KERN_FAILURE;	/* They tried to unmap too many */
+	if(!cnt) return KERN_SUCCESS;					/* If they said none, we're done... */
 	
-	for(i = 0; i < cnt; i++) {								/* Step and release all pages in list */
+	lst = lstx = &((vmm_comm_page_t *)CEntry->vmmContextKern)->vmcpComm[0];	/* Point to the first entry */
 	
-		(void)mapping_remove(CEntry->vmmPmap, pgaddr[i]);	/* Toss the mapping */
+	for(i = 0; i < cnt; i++) {						/* Step and release all pages in list */
+		if(flavor) {								/* Check if 32- or 64-bit addresses */
+			gva = lstx[i].vmlava;					/* Get the 64-bit guest address */	
+		}
+		else {
+			gva = lst[i].vmlava;					/* Get the 32-bit guest address */	
+		}
+
+		adsp = (gva & vmmlAdID) >> 4;				/* Extract an explicit address space request */	
+		if(!adsp) adsp = index - 1;					/* If no explicit, use supplied default */
+		pmap = act->mact.vmmControl->vmmAdsp[adsp];	/* Get the pmap for this request */
+		if(!pmap) continue;							/* Ain't nuthin' mapped here, no durn map... */
+
+		gva = gva &= 0xFFFFFFFFFFFFF000ULL;			/* Clean up the address */		
+		(void)mapping_remove(pmap, gva);			/* Toss the mapping */
 	}
 	
-	return KERN_SUCCESS	;									/* Return... */
+	return KERN_SUCCESS	;							/* Return... */
 }
 
 /*-----------------------------------------------------------------------
@@ -830,18 +1042,19 @@ kern_return_t vmm_unmap_list(
 
 void vmm_unmap_all_pages(
 	thread_act_t 		act,
-	vmm_thread_index_t 	index)
+	vmm_adsp_id_t	 	index)
 {
 	vmmCntrlEntry 		*CEntry;
+	pmap_t				pmap;
 
-	CEntry = vmm_get_entry(act, index);						/* Convert index to entry */		
-	if (CEntry == NULL) return;								/* Either this isn't vmm thread or the index is bogus */
+	pmap = vmm_get_adsp(act, index);						/* Convert index to entry */		
+	if (!pmap) return;										/* Either this isn't vmm thread or the index is bogus */
 	
 /*
  *	Note: the pmap code won't deal with the last page in the address space, so handle it explicitly
  */
-	mapping_remove(CEntry->vmmPmap, 0xFFFFF000);			/* Remove final page explicitly because we might have mapped it */	
-	pmap_remove(CEntry->vmmPmap, 0, 0xFFFFF000);			/* Remove all entries from this map */
+	mapping_remove(pmap, 0xFFFFFFFFFFFFF000LL);				/* Remove final page explicitly because we might have mapped it */	
+	pmap_remove(pmap, 0, 0xFFFFFFFFFFFFF000LL);				/* Remove all entries from this map */
 	return;
 }
 
@@ -869,30 +1082,36 @@ void vmm_unmap_all_pages(
 
 boolean_t vmm_get_page_dirty_flag(
 	thread_act_t 				act,
-	vmm_thread_index_t 	index,
-	vm_offset_t 		va,
+	vmm_adsp_id_t	 	index,
+	addr64_t	 		va,
 	unsigned int		reset)
 {
 	vmmCntrlEntry 		*CEntry;
 	register mapping 	*mpv, *mp;
 	unsigned int		RC;
+	pmap_t				pmap;
 
-	CEntry = vmm_get_entry(act, index);						/* Convert index to entry */		
-	if (CEntry == NULL) return 1;							/* Either this isn't vmm thread or the index is bogus */
-	
-	mp = hw_lock_phys_vir(CEntry->vmmPmap->space, va);		/* Look up the mapping */
-	if((unsigned int)mp & 1) {								/* Did we timeout? */
-		panic("vmm_get_page_dirty_flag: timeout locking physical entry for alternate virtual address (%08X)\n", va);	/* Yeah, scream about it! */
-		return 1;											/* Bad hair day, return dirty... */
-	}
-	if(!mp) return 1;										/* Not mapped, return dirty... */
+	pmap = vmm_get_adsp(act, index);						/* Convert index to entry */		
+	if (!pmap) return 1;									/* Either this isn't vmm thread or the index is bogus */
 	
-	RC = hw_test_rc(mp, reset);								/* Fetch the RC bits and clear if requested */	
+	RC = hw_test_rc(pmap, (addr64_t)va, reset);				/* Fetch the RC bits and clear if requested */	
 
-	mpv = hw_cpv(mp);										/* Convert mapping block to virtual */
-	hw_unlock_bit((unsigned int *)&mpv->physent->phys_link, PHYS_LOCK);		/* We're done, unlock the physical entry */
+	switch (RC & mapRetCode) {								/* Decode return code */
+	
+		case mapRtOK:										/* Changed */
+			return ((RC & (unsigned int)mpC) == (unsigned int)mpC);	/* Return if dirty or not */
+			break;
+	
+		case mapRtNotFnd:									/* Didn't find it */
+			return 1;										/* Return dirty */
+			break;
+			
+		default:
+			panic("vmm_get_page_dirty_flag: hw_test_rc failed - rc = %d, pmap = %08X, va = %016llX\n", RC, pmap, va);
+		
+	}
 
-	return (RC & 1);										/* Return the change bit */
+	return 1;												/* Return the change bit */
 }
 
 
@@ -916,31 +1135,38 @@ boolean_t vmm_get_page_dirty_flag(
 
 kern_return_t vmm_protect_page(
 	thread_act_t 		act,
-	vmm_thread_index_t 	index,
-	vm_offset_t 		va,
+	vmm_adsp_id_t	 	index,
+	addr64_t	 		va,
 	vm_prot_t			prot)
 {
 	vmmCntrlEntry 		*CEntry;
-	register mapping 	*mpv, *mp;
-	unsigned int		RC;
+	addr64_t			nextva;
+	int	ret;
+	pmap_t				pmap;
 
-	CEntry = vmm_get_entry(act, index);						/* Convert index to entry */		
-	if (CEntry == NULL) return KERN_FAILURE;				/* Either this isn't vmm thread or the index is bogus */
-	
-	mp = hw_lock_phys_vir(CEntry->vmmPmap->space, va);		/* Look up the mapping */
-	if((unsigned int)mp & 1) {								/* Did we timeout? */
-		panic("vmm_protect_page: timeout locking physical entry for virtual address (%08X)\n", va);	/* Yeah, scream about it! */
-		return 1;											/* Bad hair day, return dirty... */
-	}
-	if(!mp) return KERN_SUCCESS;							/* Not mapped, just return... */
+	pmap = vmm_get_adsp(act, index);						/* Convert index to entry */		
+	if (!pmap) return KERN_FAILURE;							/* Either this isn't vmm thread or the index is bogus */
 	
-	hw_prot_virt(mp, prot);									/* Set the protection */	
+	ret = hw_protect(pmap, va, prot, &nextva);				/* Try to change the protect here */
 
-	mpv = hw_cpv(mp);										/* Convert mapping block to virtual */
-	hw_unlock_bit((unsigned int *)&mpv->physent->phys_link, PHYS_LOCK);		/* We're done, unlock the physical entry */
+	switch (ret) {											/* Decode return code */
+	
+		case mapRtOK:										/* All ok... */
+			break;											/* Outta here */
+			
+		case mapRtNotFnd:									/* Didn't find it */
+			return KERN_SUCCESS;							/* Ok, return... */
+			break;
+			
+		default:
+			panic("vmm_protect_page: hw_protect failed - rc = %d, pmap = %08X, va = %016llX\n", ret, pmap, (addr64_t)va);
+		
+	}
 
-	CEntry->vmmLastMap = va & -PAGE_SIZE;					/* Remember the last mapping we changed */
-	CEntry->vmmFlags |= vmmMapDone;							/* Set that we did a map operation */
+	if (!((per_proc_info[cpu_number()].spcFlags) & FamVMmode)) {
+		act->mact.vmmControl->vmmLastMap = va & 0xFFFFFFFFFFFFF000ULL;	/* Remember the last mapping we made */
+		act->mact.vmmControl->vmmGFlags = (act->mact.vmmControl->vmmGFlags & ~vmmLastAdSp) | index;	/* Remember last address space */
+	}
 
 	return KERN_SUCCESS;									/* Return */
 }
@@ -952,7 +1178,10 @@ kern_return_t vmm_protect_page(
 ** This function sets the protection bits of a mapped page
 ** and then directly starts executing.
 **
-**	See description of vmm_protect_page for details. 
+**	See description of vmm_protect_page for details
+**
+** Inputs:
+**		See vmm_protect_page and vmm_map_execute
 **
 ** Outputs:
 **		Normal exit is to run the VM.  Abnormal exit is triggered via a 
@@ -963,21 +1192,33 @@ kern_return_t vmm_protect_page(
 vmm_return_code_t vmm_protect_execute(
 	thread_act_t 		act,
 	vmm_thread_index_t 	index,
-	vm_offset_t 		va,
+	addr64_t	 		va,
 	vm_prot_t			prot)
 {
 	kern_return_t		ret;
 	vmmCntrlEntry 		*CEntry;
+	unsigned int		adsp;
+	vmm_thread_index_t	cndx;
 
-	CEntry = vmm_get_entry(act, index);					/* Get and validate the index */
-
-	if (CEntry == NULL) return kVmmBogusContext;		/* Return bogus context */
+	cndx = index & 0xFF;							/* Clean it up */
+	CEntry = vmm_get_entry(act, cndx);				/* Get and validate the index */
+	if (CEntry == NULL) return kVmmBogusContext;	/* Return bogus context */
 	
-	ret = vmm_protect_page(act, index, va, prot);		/* Go try to change access */
+	adsp = (index >> 8) & 0xFF;						/* Get any requested address space */
+	if(!adsp) adsp = (index & 0xFF);				/* If 0, use context ID as address space ID */
 	
-	if(ret == KERN_SUCCESS) vmm_execute_vm(act, index);	/* Return was ok, launch the VM */
+	if (((per_proc_info[cpu_number()].spcFlags) & FamVMmode) && (CEntry != act->mact.vmmCEntry))
+		return kVmmBogusContext;			/* Yes, invalid index in Fam */
+	
+	ret = vmm_protect_page(act, adsp, va, prot);	/* Go try to change access */
+	
+	if(ret == KERN_SUCCESS) {
+		act->mact.vmmControl->vmmLastMap = va & 0xFFFFFFFFFFFFF000ULL;	/* Remember the last mapping we made */
+		act->mact.vmmControl->vmmGFlags = (act->mact.vmmControl->vmmGFlags & ~vmmLastAdSp) | cndx;	/* Remember last address space */
+		vmm_execute_vm(act, cndx);	/* Return was ok, launch the VM */
+	}
 	
-	return kVmmInvalidAddress;							/* We had trouble of some kind (shouldn't happen) */	
+	return ret;										/* We had trouble of some kind (shouldn't happen) */	
 	
 }
 
@@ -1014,9 +1255,6 @@ kern_return_t vmm_get_float_state(
 
 	fpu_save(&CEntry->vmmFacCtx);					/* Save context if live */
 
-	CEntry->vmmContextKern->vmm_proc_state.ppcFPSCRshadow.i[0] = CEntry->vmmContextKern->vmm_proc_state.ppcFPSCR.i[0];	/* Copy FPSCR */
-	CEntry->vmmContextKern->vmm_proc_state.ppcFPSCRshadow.i[1] = CEntry->vmmContextKern->vmm_proc_state.ppcFPSCR.i[1];	/* Copy FPSCR */
-	
 	if(sv = CEntry->vmmFacCtx.FPUsave) {			/* Is there context yet? */
 		bcopy((char *)&sv->save_fp0, (char *)&(CEntry->vmmContextKern->vmm_proc_state.ppcFPRs), 32 * 8); /* 32 registers */
 		return KERN_SUCCESS;
@@ -1063,10 +1301,6 @@ kern_return_t vmm_get_vector_state(
 	act->mact.specFlags &= ~vectorCng;				/* Clear the special flag */
 	CEntry->vmmContextKern->vmmStat &= ~vmmVectCngd;	/* Clear the change indication */
 	
-	for(j=0; j < 4; j++) {							/* Set value for vscr */
-		CEntry->vmmContextKern->vmm_proc_state.ppcVSCRshadow.i[j] = CEntry->vmmContextKern->vmm_proc_state.ppcVSCR.i[j];
-	}
-
 	if(sv = CEntry->vmmFacCtx.VMXsave) {			/* Is there context yet? */
 
 		vrvalidwrk = sv->save_vrvalid;				/* Get the valid flags */
@@ -1145,6 +1379,10 @@ kern_return_t vmm_set_timer(
 **
 ** This function causes the timer for a specified VM to be
 ** returned in return_params[0] and return_params[1].
+** Note that this is kind of funky for 64-bit VMs because we
+** split the timer into two parts so that we still set parms 0 and 1.
+** Obviously, we don't need to do this because the parms are 8 bytes
+** wide.
 ** 
 **
 ** Inputs:
@@ -1166,14 +1404,18 @@ kern_return_t vmm_get_timer(
 	CEntry = vmm_get_entry(act, index);				/* Convert index to entry */		
 	if (CEntry == NULL) return KERN_FAILURE;		/* Either this isn't vmm thread or the index is bogus */
 
-	CEntry->vmmContextKern->return_params[0] = (CEntry->vmmTimer >> 32);	/* Return the last timer value */
-	CEntry->vmmContextKern->return_params[1] = (uint32_t)CEntry->vmmTimer;	/* Return the last timer value */
-	
+	if(CEntry->vmmXAFlgs & vmm64Bit) {				/* A 64-bit virtual machine? */
+		CEntry->vmmContextKern->vmmRet.vmmrp64.return_params[0] = (uint32_t)(CEntry->vmmTimer >> 32);	/* Return the last timer value */
+		CEntry->vmmContextKern->vmmRet.vmmrp64.return_params[1] = (uint32_t)CEntry->vmmTimer;	/* Return the last timer value */
+	}
+	else {
+		CEntry->vmmContextKern->vmmRet.vmmrp32.return_params[0] = (CEntry->vmmTimer >> 32);	/* Return the last timer value */
+		CEntry->vmmContextKern->vmmRet.vmmrp32.return_params[1] = (uint32_t)CEntry->vmmTimer;	/* Return the last timer value */
+	}
 	return KERN_SUCCESS;
 }
 
 
-
 /*-----------------------------------------------------------------------
 ** vmm_timer_pop
 **
@@ -1211,7 +1453,7 @@ void vmm_timer_pop(
 	CTable = act->mact.vmmControl;					/* Make this easier */	
 	any = 0;										/* Haven't found a running unexpired timer yet */
 	
-	for(cvi = 0; cvi < kVmmMaxContextsPerThread; cvi++) {	/* Cycle through all and check time now */
+	for(cvi = 0; cvi < kVmmMaxContexts; cvi++) {	/* Cycle through all and check time now */
 
 		if(!(CTable->vmmc[cvi].vmmFlags & vmmInUse)) continue;	/* Do not check if the entry is empty */
 		
@@ -1329,7 +1571,7 @@ int vmm_stop_vm(struct savearea *save)
 		return 1;								/* Return... */
 	}
 
-	for(cvi = 0; cvi < kVmmMaxContextsPerThread; cvi++) {	/* Search slots */
+	for(cvi = 0; cvi < kVmmMaxContexts; cvi++) {	/* Search slots */
 		if((0x80000000 & vmmask) && (CTable->vmmc[cvi].vmmFlags & vmmInUse)) {	/* See if we need to stop and if it is in use */
 			hw_atomic_or(&CTable->vmmc[cvi].vmmFlags, vmmXStop);	/* Set this one to stop */
 		}
diff --git a/osfmk/ppc/vmachmon.h b/osfmk/ppc/vmachmon.h
index 7db97cd9f..c2af36c86 100644
--- a/osfmk/ppc/vmachmon.h
+++ b/osfmk/ppc/vmachmon.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -24,10 +27,6 @@
 **
 ** C routines that we are adding to the MacOS X kernel.
 **
-** Wierd Apple PSL stuff goes here...
-**
-** Until then, Copyright 2000, Connectix
-**
 -----------------------------------------------------------------------*/
 
 #include <ppc/exception.h>
@@ -52,44 +51,78 @@ typedef union vmm_fp_register_t {
 	unsigned char			b[8];
 } vmm_fp_register_t;
 
-typedef struct vmm_processor_state_t {
 
-	unsigned long			ppcPC;
-	unsigned long			ppcMSR;
+typedef struct vmm_regs32_t {
 
-	unsigned long			ppcGPRs[32];
+	unsigned long			ppcPC;						/* 000 */
+	unsigned long			ppcMSR;						/* 004 */
 
-	unsigned long			ppcCR;
-	unsigned long			ppcXER;
-	unsigned long			ppcLR;
-	unsigned long			ppcCTR;
-	unsigned long			ppcMQ;						/* Obsolete */
-	unsigned long			ppcVRSave;
-														/* 32-byte bndry */
-	vmm_vector_register_t	ppcVSCR;
-	vmm_fp_register_t		ppcFPSCR;
+	unsigned long			ppcGPRs[32];				/* 008 */
+
+	unsigned long			ppcCR;						/* 088 */
+	unsigned long			ppcXER;						/* 08C */
+	unsigned long			ppcLR;						/* 090 */
+	unsigned long			ppcCTR;						/* 094 */
+	unsigned long			ppcMQ;						/* 098 - Obsolete */
+	unsigned long			ppcVRSave;					/* 09C */
+	unsigned long			ppcRsrvd0A0[40];			/* 0A0 */
+														/* 140 */
+} vmm_regs32_t;
+
+#pragma pack(4)							/* Make sure the structure stays as we defined it */
+typedef struct vmm_regs64_t {
+
+	unsigned long long		ppcPC;						/* 000 */
+	unsigned long long		ppcMSR;						/* 008 */
+
+	unsigned long long		ppcGPRs[32];				/* 010 */
+
+	unsigned long long		ppcXER;						/* 110 */
+	unsigned long long		ppcLR;						/* 118 */
+	unsigned long long		ppcCTR;						/* 120 */
+	unsigned long			ppcCR;						/* 128 */
+	unsigned long			ppcVRSave;					/* 12C */
+	unsigned long			ppcRsvd130[4];				/* 130 */
+														/* 140 */
+} vmm_regs64_t;
+#pragma pack()
+	
 	
-	unsigned long			ppcReserved1[34];			/* Future processor state can go here */
+#pragma pack(4)							/* Make sure the structure stays as we defined it */
+typedef union vmm_regs_t {
+	vmm_regs32_t			ppcRegs32;
+	vmm_regs64_t			ppcRegs64;
+} vmm_regs_t;
+#pragma pack()
+
+#pragma pack(4)							/* Make sure the structure stays as we defined it */
+typedef struct vmm_processor_state_t {
+														/* 32-byte bndry */
+	vmm_regs_t				ppcRegs;					/* Define registers areas */
 	
 /*	We must be 16-byte aligned here */
 
-	vmm_vector_register_t	ppcVRs[32];
-	vmm_vector_register_t	ppcVSCRshadow;
+	vmm_vector_register_t	ppcVRs[32];					/* These are only valid after a kVmmGetVectorState */
+	vmm_vector_register_t	ppcVSCR;					/* This is always loaded/saved at host/guest transition */
 	
 /*	We must be 8-byte aligned here */
 
-	vmm_fp_register_t		ppcFPRs[32];
-	vmm_fp_register_t		ppcFPSCRshadow;
+	vmm_fp_register_t		ppcFPRs[32];				/* These are only valid after a kVmmGetFloatState */
+	vmm_fp_register_t		ppcFPSCR;					/* This is always loaded/saved at host/guest transition */
 	unsigned long			ppcReserved2[2];			/* Pad out to multiple of 16 bytes */
 } vmm_processor_state_t;
+#pragma pack()
 
 typedef unsigned long vmm_return_code_t;
 
 typedef unsigned long vmm_thread_index_t;
+#define vmmTInum 0x000000FF
+#define vmmTIadsp 0x0000FF00
+typedef unsigned long vmm_adsp_id_t;
 
 enum {
 	kVmmCurMajorVersion					= 0x0001,
-	kVmmCurMinorVersion					= 0x0004,
+	kVmmCurMinorVersion					= 0x0006,
 	kVmmMinMajorVersion					= 0x0001,
 };
 #define kVmmCurrentVersion ((kVmmCurMajorVersion << 16) | kVmmCurMinorVersion)
@@ -100,11 +133,77 @@ enum {
 	kVmmFeature_Stop					= 0x00000002,
 	kVmmFeature_ExtendedMapping			= 0x00000004,
 	kVmmFeature_ListMapping				= 0x00000008,
+	kVmmFeature_FastAssist				= 0x00000010,
+	kVmmFeature_XA						= 0x00000020,
+	kVmmFeature_SixtyFourBit			= 0x00000040,
+	kVmmFeature_MultAddrSpace			= 0x00000080,
+};
+#define kVmmCurrentFeatures (kVmmFeature_LittleEndian | kVmmFeature_Stop | kVmmFeature_ExtendedMapping \
+	| kVmmFeature_ListMapping | kVmmFeature_FastAssist | kVmmFeature_XA | kVmmFeature_MultAddrSpace)
+
+enum {
+	vmm64Bit							= 0x80000000,
 };
-#define kVmmCurrentFeatures (kVmmFeature_LittleEndian | kVmmFeature_Stop | kVmmFeature_ExtendedMapping | kVmmFeature_ListMapping)
+
 
 typedef unsigned long vmm_version_t;
 
+typedef struct vmm_ret_parms32_t {
+	unsigned long 			return_params[4];
+} vmm_ret_parms32_t;
+
+typedef struct vmm_ret_parms64_t {
+	unsigned long long		return_params[4];
+} vmm_ret_parms64_t;
+
+#pragma pack(4)							/* Make sure the structure stays as we defined it */
+typedef union vmm_ret_parms_t {
+	vmm_ret_parms64_t		vmmrp64;		/* 64-bit flavor */
+	vmm_ret_parms32_t		vmmrp32;		/* 32-bit flavor */
+	unsigned int			retgas[11];		/* Force this to be 11 words long */
+} vmm_ret_parms_t;
+#pragma pack()
+
+#pragma pack(4)							/* Make sure the structure stays as we defined it */
+typedef struct vmm_fastassist_state32_t {
+	unsigned long fastassist_dispatch;
+	unsigned long fastassist_refcon;
+
+	unsigned long fastassist_dispatch_code;
+	unsigned long fastassist_parameter[5];
+
+	unsigned long guest_register[8];
+
+	unsigned long guest_pc;
+	unsigned long guest_msr;
+
+	unsigned long fastassist_intercepts;
+	unsigned long fastassist_reserved1;
+} vmm_fastassist_state32_t;
+
+typedef struct vmm_fastassist_state64_t {
+	unsigned long long fastassist_dispatch;
+	unsigned long long fastassist_refcon;
+
+	unsigned long long fastassist_dispatch_code;
+	unsigned long long fastassist_parameter[5];
+
+	unsigned long long guest_register[8];
+
+	unsigned long long guest_pc;
+	unsigned long long guest_msr;
+
+	unsigned long fastassist_intercepts;
+	unsigned long fastassist_reserved1;
+} vmm_fastassist_state64_t;
+
+typedef union vmm_fastassist_state_t {
+	vmm_fastassist_state64_t		vmmfs64;		/* 64-bit flavor */
+	vmm_fastassist_state32_t		vmmfs32;		/* 32-bit flavor */
+} vmm_fastassist_state_t;
+#pragma pack()
+
+#pragma pack(4)							/* Make sure the structure stays as we defined it */
 typedef struct vmm_state_page_t {
 	/* This structure must remain below 4Kb (one page) in size */
 	vmm_version_t			interface_version;
@@ -123,15 +222,24 @@ typedef struct vmm_state_page_t {
 #define vmmXStartb		4
 #define vmmKey			0x04000000
 #define vmmKeyb			5
+#define vmmFamEna		0x02000000
+#define vmmFamEnab		6
+#define vmmFamSet		0x01000000
+#define vmmFamSetb		7
+
 	vmm_return_code_t		return_code;
-	unsigned long			return_params[4];
-	unsigned long			gas[7];		/* For alignment */
+	vmm_ret_parms_t			vmmRet;
 
 	/* The next portion of the structure must remain 32-byte aligned */
 	vmm_processor_state_t	vmm_proc_state;
 
+	/* The next portion of the structure must remain 16-byte aligned */
+	vmm_fastassist_state_t	vmm_fastassist_state;
+
 } vmm_state_page_t;
+#pragma pack()
 
+#pragma pack(4)							/* Make sure the structure stays as we defined it */
 typedef struct vmm_comm_page_t {
 	union {
 		vmm_state_page_t	vmcpState;					/* Reserve area for state */
@@ -139,29 +247,48 @@ typedef struct vmm_comm_page_t {
 	} vmcpfirst;
 	unsigned int			vmcpComm[256];				/* Define last 1024 bytes as a communications area - function specific */
 } vmm_comm_page_t;
+#pragma pack()
 
 enum {
 	/* Function Indices (passed in r3) */
-	kVmmGetVersion				= 0,
-	kVmmvGetFeatures,
-	kVmmInitContext,
-	kVmmTearDownContext,
-	kVmmTearDownAll,
-	kVmmMapPage,
-	kVmmGetPageMapping,
-	kVmmUnmapPage,
-	kVmmUnmapAllPages,
-	kVmmGetPageDirtyFlag,
-	kVmmGetFloatState,
-	kVmmGetVectorState,
-	kVmmSetTimer,
-	kVmmGetTimer,
-	kVmmExecuteVM,
-	kVmmProtectPage,
-	kVmmMapExecute,
-	kVmmProtectExecute,
-	kVmmMapList,
-	kVmmUnmapList,
+	kVmmGetVersion				= 0,					/* Get VMM system version */
+	kVmmvGetFeatures,									/* Get VMM supported features */
+	kVmmInitContext,									/* Initialize a context */
+	kVmmTearDownContext,								/* Destroy a context */
+	kVmmTearDownAll,									/* Destory all contexts */
+	kVmmMapPage,										/* Map a host to guest address space */
+	kVmmGetPageMapping,									/* Get host address of a guest page */
+	kVmmUnmapPage,										/* Unmap a guest page */
+	kVmmUnmapAllPages,									/* Unmap all pages in a guest address space */
+	kVmmGetPageDirtyFlag,								/* Check if guest page modified */
+	kVmmGetFloatState,									/* Retrieve guest floating point context */
+	kVmmGetVectorState,									/* Retrieve guest vector context */
+	kVmmSetTimer,										/* Set a guest timer */
+	kVmmGetTimer,										/* Get a guest timer */
+	kVmmExecuteVM,										/* Launch a guest */
+	kVmmProtectPage,									/* Set protection attributes for a guest page */
+	kVmmMapExecute,										/* Map guest page and launch */
+	kVmmProtectExecute,									/* Set prot attributes and launch */
+	kVmmMapList,										/* Map a list of pages into guest address spaces */
+	kVmmUnmapList,										/* Unmap a list of pages from guest address spaces */
+	kvmmExitToHost,
+	kvmmResumeGuest,
+	kvmmGetGuestRegister,
+	kvmmSetGuestRegister,
+	
+	kVmmSetXA,											/* Set extended architecture features for a VM */
+	kVmmGetXA,											/* Get extended architecture features from a VM */
+
+	kVmmMapPage64,										/* Map a host to guest address space - supports 64-bit */
+	kVmmGetPageMapping64,								/* Get host address of a guest page - supports 64-bit  */
+	kVmmUnmapPage64,									/* Unmap a guest page - supports 64-bit  */
+	kVmmGetPageDirtyFlag64,								/* Check if guest page modified - supports 64-bit  */
+	kVmmProtectPage64,									/* Set protection attributes for a guest page - supports 64-bit */
+	kVmmMapExecute64,									/* Map guest page and launch - supports 64-bit  */
+	kVmmProtectExecute64,								/* Set prot attributes and launch - supports 64-bit  */
+	kVmmMapList64,										/* Map a list of pages into guest address spaces - supports 64-bit  */
+	kVmmUnmapList64,									/* Unmap a list of pages from guest address spaces - supports 64-bit  */
+	kVmmMaxAddr,										/* Returns the maximum virtual address that is mappable  */
 };
 
 #define kVmmReturnNull					0
@@ -174,7 +301,37 @@ enum {
 #define kVmmReturnSystemCall			12
 #define kVmmReturnTraceException		13
 #define kVmmAltivecAssist				22
-#define kVmmInvalidAddress				4096
+#define kVmmInvalidAddress				0x1000
+#define kVmmInvalidAdSpace				0x1001
+
+/*
+ *	Notes on guest address spaces.
+ *
+ *	Address spaces are loosely coupled to virtual machines.  The default is for
+ *	a guest with an index of 1 to use address space 1, 2 to use 2, etc.  However,
+ *	any guest may be launched using any address space and any address space may be the
+ *	target for a map or unmap function.  Note that the (un)map list functions may pass in
+ *	an address space ID on a page-by-page basis.
+ *	
+ *	An address space is instantiated either explicitly by mapping something into it, or 
+ *	implicitly by launching a guest with it.
+ *
+ *	An address space is destroyed explicitly by kVmmTearDownAll or kVmmUnmapAllPages.  It is
+ *	destroyed implicitly by kVmmTearDownContext.  The latter is done in order to remain
+ *	backwards compatible with the previous implementation, which does not have decoupled
+ *	guests and address spaces.
+ *
+ *	An address space supports the maximum virtual address supported by the processor.  
+ *	The 64-bit variant of the mapping functions can be used on non-64-bit machines.  If an
+ *	unmappable address (e.g., an address larger than 4GB-1 on a 32-bit machine) is requested, 
+ *	the operation fails with a kVmmInvalidAddress return code.
+ *
+ *	Note that for 64-bit calls, both host and guest are specified at 64-bit values.
+ *
+ */
+
+
+
 
 /*
  *	Storage Extended Protection modes
@@ -199,25 +356,45 @@ enum {
 #define kVmmProtRORO (kVmmProtXtnd | 0x00000003)
 
 /*
- *	Map list format
+ *	Map list formats
+ *	The last 12 bits in the guest virtual address is used as flags as follows:
+ *		0x007 - for the map calls, this is the key to set
+ *		0x3F0 - for both map and unmap, this is the address space ID upon which to operate.
+ *				Note that if 0, the address space ID from the function call is used instead.
  */
 
-typedef struct vmmMapList {
-	unsigned int	vmlva;			/* Virtual address in emulator address space */
-	unsigned int	vmlava;			/* Virtual address in alternate address space */
-#define vmlFlgs 0x00000FFF			/* Flags passed in in vmlava low order 12 bits */
-#define vmlProt 0x00000003			/* Protection flags for the page */
-} vmmMapList;
+typedef struct vmmMList {
+	unsigned int	vmlva;			/* Virtual address in host address space */
+	unsigned int	vmlava;			/* Virtual address in guest address space */
+} vmmMList;
+
+typedef struct vmmMList64 {
+	unsigned long long	vmlva;		/* Virtual address in host address space */
+	unsigned long long	vmlava;		/* Virtual address in guest address space */
+} vmmMList64;
+
+typedef struct vmmUMList {
+	unsigned int	vmlava;			/* Virtual address in guest address space */
+} vmmUMList;
+
+typedef struct vmmUMList64 {
+	unsigned long long	vmlava;		/* Virtual address in guest address space */
+} vmmUMList64;
 
+#define vmmlFlgs 0x00000FFF			/* Flags passed in in vmlava low order 12 bits */
+#define vmmlProt 0x00000007			/* Protection flags for the page */
+#define vmmlAdID 0x000003F0			/* Guest address space ID - used only if non-zero */
+#define vmmlRsvd 0x00000C08			/* Reserved for future */
 
 /*************************************************************************************
 	Internal Emulation Types
 **************************************************************************************/
 
-#define kVmmMaxContextsPerThread		32
+#define kVmmMaxContexts					32
 #define kVmmMaxUnmapPages				64
 #define kVmmMaxMapPages					64
 
+#pragma pack(4)							/* Make sure the structure stays as we defined it */
 typedef struct vmmCntrlEntry {						/* Virtual Machine Monitor control table entry */
 	unsigned int	vmmFlags;						/* Assorted control flags */
 #define vmmInUse 		0x80000000
@@ -228,23 +405,32 @@ typedef struct vmmCntrlEntry {						/* Virtual Machine Monitor control table ent
 #define vmmVectCngdb	2
 #define vmmTimerPop		0x10000000
 #define vmmTimerPopb	3
-#define vmmMapDone		0x08000000
-#define vmmMapDoneb		4
+#define vmmFAMmode		0x04000000
+#define vmmFAMmodeb		5
 #define vmmXStop		0x00800000
 #define vmmXStopb		8
 #define vmmSpfSave		0x000000FF
 #define vmmSpfSaveb		24
-	pmap_t			vmmPmap;						/* pmap for alternate context's view of task memory */
+	unsigned int	vmmXAFlgs;						/* Extended Architecture flags */
 	vmm_state_page_t *vmmContextKern;				/* Kernel address of context communications area */
+	ppnum_t			vmmContextPhys;				/* Physical address of context communications area */
 	vmm_state_page_t *vmmContextUser;				/* User address of context communications area */
 	facility_context vmmFacCtx;						/* Header for vector and floating point contexts */
+	pmap_t			vmmPmap;						/* Last dispatched pmap */
 	uint64_t		vmmTimer;						/* Last set timer value. Zero means unset */
-	vm_offset_t		vmmLastMap;						/* Last vaddr mapping into virtual machine */
+	unsigned int	vmmFAMintercept;				/* FAM intercepted exceptions */
 } vmmCntrlEntry;
+#pragma pack()
 
+#pragma pack(4)							/* Make sure the structure stays as we defined it */
 typedef struct vmmCntrlTable {						/* Virtual Machine Monitor Control table */
-	vmmCntrlEntry	vmmc[kVmmMaxContextsPerThread];	/* One entry for each possible Virtual Machine Monitor context */
+	unsigned int	vmmGFlags;						/* Global flags */
+#define vmmLastAdSp 0xFF							/* Remember the address space that was mapped last */
+	addr64_t		vmmLastMap;						/* Last vaddr mapping made */
+	vmmCntrlEntry	vmmc[kVmmMaxContexts];			/* One entry for each possible Virtual Machine Monitor context */
+	pmap_t			vmmAdsp[kVmmMaxContexts];		/* Guest address space pmaps */
 } vmmCntrlTable;
+#pragma pack()
 
 /* function decls for kernel level routines... */
 extern void vmm_execute_vm(thread_act_t act, vmm_thread_index_t index);
@@ -255,20 +441,22 @@ extern kern_return_t vmm_get_vector_state(thread_act_t act, vmm_thread_index_t i
 extern kern_return_t vmm_set_timer(thread_act_t act, vmm_thread_index_t index, unsigned int timerhi, unsigned int timerlo);
 extern kern_return_t vmm_get_timer(thread_act_t act, vmm_thread_index_t index);
 extern void vmm_tear_down_all(thread_act_t act);
-extern kern_return_t vmm_map_page(thread_act_t act, vmm_thread_index_t hindex, vm_offset_t cva,
-	vm_offset_t ava, vm_prot_t prot);
-extern vmm_return_code_t vmm_map_execute(thread_act_t act, vmm_thread_index_t hindex, vm_offset_t cva,
-	vm_offset_t ava, vm_prot_t prot);
-extern kern_return_t vmm_protect_page(thread_act_t act, vmm_thread_index_t hindex, vm_offset_t va,
+extern kern_return_t vmm_map_page(thread_act_t act, vmm_thread_index_t hindex, addr64_t cva,
+	addr64_t ava, vm_prot_t prot);
+extern vmm_return_code_t vmm_map_execute(thread_act_t act, vmm_thread_index_t hindex, addr64_t cva,
+	addr64_t ava, vm_prot_t prot);
+extern kern_return_t vmm_protect_page(thread_act_t act, vmm_thread_index_t hindex, addr64_t va,
 	vm_prot_t prot);
-extern vmm_return_code_t vmm_protect_execute(thread_act_t act, vmm_thread_index_t hindex, vm_offset_t va,
+extern vmm_return_code_t vmm_protect_execute(thread_act_t act, vmm_thread_index_t hindex, addr64_t va,
 	vm_prot_t prot);
-extern vm_offset_t vmm_get_page_mapping(thread_act_t act, vmm_thread_index_t index,
-	vm_offset_t va);
-extern kern_return_t vmm_unmap_page(thread_act_t act, vmm_thread_index_t index, vm_offset_t va);
+extern addr64_t vmm_get_page_mapping(thread_act_t act, vmm_thread_index_t index,
+	addr64_t va);
+extern kern_return_t vmm_unmap_page(thread_act_t act, vmm_thread_index_t index, addr64_t va);
 extern void vmm_unmap_all_pages(thread_act_t act, vmm_thread_index_t index);
 extern boolean_t vmm_get_page_dirty_flag(thread_act_t act, vmm_thread_index_t index,
-	vm_offset_t va, unsigned int reset);
+	addr64_t va, unsigned int reset);
+extern kern_return_t vmm_set_XA(thread_act_t act, vmm_thread_index_t index, unsigned int xaflags);
+extern unsigned int vmm_get_XA(thread_act_t act, vmm_thread_index_t index);
 extern int vmm_get_features(struct savearea *);
 extern int vmm_get_version(struct savearea *);
 extern int vmm_init_context(struct savearea *);
@@ -278,8 +466,14 @@ extern void vmm_force_exit(thread_act_t act, struct savearea *);
 extern int vmm_stop_vm(struct savearea *save);
 extern void vmm_timer_pop(thread_act_t act);
 extern void vmm_interrupt(ReturnHandler *rh, thread_act_t act);
-extern kern_return_t vmm_map_list(thread_act_t act, vmm_thread_index_t index, unsigned int cnt);
-extern kern_return_t vmm_unmap_list(thread_act_t act, vmm_thread_index_t index, unsigned int cnt);
+extern kern_return_t vmm_map_list(thread_act_t act, vmm_thread_index_t index, unsigned int cnt, unsigned int flavor);
+extern kern_return_t vmm_unmap_list(thread_act_t act, vmm_thread_index_t index, unsigned int cnt, unsigned int flavor);
+extern vmm_return_code_t vmm_resume_guest(vmm_thread_index_t index, unsigned long pc, 
+	unsigned long vmmCntrl, unsigned long vmmCntrMaskl);
+extern vmm_return_code_t vmm_exit_to_host(vmm_thread_index_t index);
+extern unsigned long vmm_get_guest_register(vmm_thread_index_t index, unsigned long reg_index);
+extern vmm_return_code_t vmm_set_guest_register(vmm_thread_index_t index, unsigned long reg_index, unsigned long reg_value);
+extern addr64_t vmm_max_addr(thread_act_t act);
 
 #endif
 
diff --git a/osfmk/ppc/vmachmon_asm.s b/osfmk/ppc/vmachmon_asm.s
index e3ffb412e..1a4a67381 100644
--- a/osfmk/ppc/vmachmon_asm.s
+++ b/osfmk/ppc/vmachmon_asm.s
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -30,6 +33,9 @@
  *	facility.
  */
 
+#define vmmMapDone 31
+#define vmmDoing64 30
+
 
 /*
  *	int vmm_dispatch(savearea, act);
@@ -44,7 +50,7 @@
  *		R30 = current savearea
  */
  
- 			.align	5								/* Line up on cache line */
+ 			.align	5												; Line up on cache line
 			.globl	EXT(vmm_dispatch_table)
 
 LEXT(vmm_dispatch_table)
@@ -53,27 +59,80 @@ LEXT(vmm_dispatch_table)
 			/* OK to add new routines, but they must be added at the bottom. */
 
 			.long	EXT(vmm_get_version_sel)						; Get the version of the VMM interface
+			.long	0												; Not valid in Fam
 			.long	EXT(vmm_get_features_sel)						; Get the features of the VMM interface
+			.long	0												; Not valid in Fam
 			.long	EXT(vmm_init_context_sel)						; Initializes a new VMM context
+			.long	0												; Not valid in Fam
 			.long	EXT(vmm_tear_down_context)						; Tears down a previously-allocated VMM context
+			.long	0												; Not valid in Fam
 			.long	EXT(vmm_tear_down_all)							; Tears down all VMMs 
-			.long	EXT(vmm_map_page)								; Maps a page from the main address space into the VM space 
-			.long	EXT(vmm_get_page_mapping)						; Returns client va associated with VM va
-			.long	EXT(vmm_unmap_page)								; Unmaps a page from the VM space
-			.long	EXT(vmm_unmap_all_pages)						; Unmaps all pages from the VM space 
-			.long	EXT(vmm_get_page_dirty_flag)					; Gets the change bit for a page and optionally clears it
+			.long	0												; Not valid in Fam
+			.long	EXT(vmm_map_page32)								; Maps a page from the main address space into the VM space - supports 32-bit
+			.long	1												; Valid in Fam
+			.long	EXT(vmm_get_page_mapping32)						; Returns client va associated with VM va - supports 32-bit
+			.long	1												; Valid in Fam
+			.long	EXT(vmm_unmap_page32)							; Unmaps a page from the VM space - supports 32-bit
+			.long	1												; Valid in Fam
+			.long	EXT(vmm_unmap_all_pages)						; Unmaps all pages from the VM space
+			.long	1												; Valid in Fam
+			.long	EXT(vmm_get_page_dirty_flag32)					; Gets the change bit for a page and optionally clears it - supports 32-bit
+			.long	1												; Valid in Fam
 			.long	EXT(vmm_get_float_state)						; Gets current floating point state
+			.long	0												; not valid in Fam
 			.long	EXT(vmm_get_vector_state)						; Gets current vector state
+			.long	0												; Not valid in Fam
 			.long	EXT(vmm_set_timer)								; Sets a timer value
+			.long	1												; Valid in Fam
 			.long	EXT(vmm_get_timer)								; Gets a timer value
+			.long	1												; Valid in Fam
 			.long	EXT(switchIntoVM)								; Switches to the VM context
-			.long	EXT(vmm_protect_page)							; Sets protection values for a page
-			.long	EXT(vmm_map_execute)							; Maps a page an launches VM
-			.long	EXT(vmm_protect_execute)						; Sets protection values for a page and launches VM
-			.long	EXT(vmm_map_list)								; Maps a list of pages
-			.long	EXT(vmm_unmap_list)								; Unmaps a list of pages
-
-			.set	vmm_count,(.-EXT(vmm_dispatch_table))/4			; Get the top number
+			.long	1												; Valid in Fam
+			.long	EXT(vmm_protect_page32)							; Sets protection values for a page - supports 32-bit
+			.long	1												; Valid in Fam
+			.long	EXT(vmm_map_execute32)							; Maps a page an launches VM - supports 32-bit
+			.long	1												; Not valid in Fam
+			.long	EXT(vmm_protect_execute32)						; Sets protection values for a page and launches VM - supports 32-bit
+			.long	1												; Valid in Fam
+			.long	EXT(vmm_map_list32)								; Maps a list of pages - supports 32-bit
+			.long	1												; Valid in Fam
+			.long	EXT(vmm_unmap_list32)							; Unmaps a list of pages - supports 32-bit
+			.long	1												; Valid in Fam
+			.long	EXT(vmm_fam_reserved)							; exit from Fam to host
+			.long	1												; Valid in Fam
+			.long	EXT(vmm_fam_reserved)							; resume guest from Fam
+			.long	1												; Valid in Fam
+			.long	EXT(vmm_fam_reserved)							; get guest register from Fam
+			.long	1												; Valid in Fam
+			.long	EXT(vmm_fam_reserved)							; Set guest register from Fam
+			.long	1												; Valid in Fam
+			.long	EXT(vmm_set_XA)									; Set extended architecture features for a VM 
+			.long	0												; Not valid in Fam
+			.long	EXT(vmm_get_XA)									; Get extended architecture features from a VM 
+			.long	1												; Valid in Fam
+			.long	EXT(vmm_map_page)								; Map a host to guest address space - supports 64-bit 
+			.long	1												; Valid in Fam
+			.long	EXT(vmm_get_page_mapping)						; Get host address of a guest page - supports 64-bit 
+			.long	1												; Valid in Fam
+			.long	EXT(vmm_unmap_page)								; Unmap a guest page - supports 64-bit 
+			.long	1												; Valid in Fam
+			.long	EXT(vmm_get_page_dirty_flag)					; Check if guest page modified - supports 64-bit 
+			.long	1												; Valid in Fam
+			.long	EXT(vmm_protect_page)							; Sets protection values for a page - supports 64-bit
+			.long	1												; Valid in Fam
+			.long	EXT(vmm_map_execute)							; Map guest page and launch - supports 64-bit 
+			.long	1												; Valid in Fam
+			.long	EXT(vmm_protect_execute)						; Set prot attributes and launch - supports 64-bit 
+			.long	1												; Valid in Fam
+			.long	EXT(vmm_map_list64)								; Map a list of pages into guest address spaces - supports 64-bit 
+			.long	1												; Valid in Fam
+			.long	EXT(vmm_unmap_list64)							; Unmap a list of pages from guest address spaces - supports 64-bit 
+			.long	1												; Valid in Fam
+			.long	EXT(vmm_max_addr)								; Returns the maximum virtual address 
+			.long	1												; Valid in Fam
+
+
+			.set	vmm_count,(.-EXT(vmm_dispatch_table))/8			; Get the top number
 
 
 			.align	5
@@ -81,34 +140,53 @@ LEXT(vmm_dispatch_table)
 
 LEXT(vmm_dispatch)
 
-			lwz		r11,saver3(r30)				; Get the selector
+			lwz		r11,saver3+4(r30)			; Get the selector
 			mr		r3,r4						; All of our functions want the activation as the first parm
 			lis		r10,hi16(EXT(vmm_dispatch_table))	; Get top half of table
 			cmplwi	r11,kVmmExecuteVM			; Should we switch to the VM now?
 			cmplwi	cr1,r11,vmm_count			; See if we have a valid selector
 			ori		r10,r10,lo16(EXT(vmm_dispatch_table))	; Get low half of table
-			lwz		r4,saver4(r30)				; Get 1st parameter after selector
+			lwz		r4,saver4+4(r30)			; Get 1st parameter after selector
 			beq+	EXT(switchIntoVM)			; Yes, go switch to it....
-			rlwinm	r11,r11,2,0,29				; Index into table
-			bgt-	cr1,vmmBogus				; It is a bogus entry
-			lwzx	r10,r10,r11					; Get address of routine
-			lwz		r5,saver5(r30)				; Get 2nd parameter after selector
-			lwz		r6,saver6(r30)				; Get 3rd parameter after selector
-			mtlr	r10							; Set the routine address
-			lwz		r7,saver7(r30)				; Get 4th parameter after selector
-;
-;			NOTE: currently the most paramters for any call is 4.  We will support at most 8 because we
-;			do not want to get into any stack based parms.  However, here is where we need to add
-;			code for the 5th - 8th parms if we need them.
+			rlwinm	r11,r11,3,0,28				; Index into table
+			bge-	cr1,vmmBogus				; It is a bogus entry
+			add		r12,r10,r11					; Get the vmm dispatch syscall entry
+			mfsprg	r10,0						; Get the per_proc
+			lwz		r13,0(r12)					; Get address of routine
+			lwz		r12,4(r12)					; Get validity flag
+			lwz		r5,spcFlags(r10)			; Get per_proc special flags
+			cmpwi	cr1,r12,0					; Check Fam valid 
+			rlwinm.	r5,r5,0,FamVMmodebit,FamVMmodebit	; Test FamVMmodebit
+			crand	cr0_eq,cr1_eq,cr0_gt		; In Fam and Invalid syscall	
+			beq		vmmBogus					; Intercept to host
+			lwz		r5,saver5+4(r30)			; Get 2nd parameter after selector - note that some of these parameters may actually be long longs
+			lwz		r6,saver6+4(r30)			; Get 3rd parameter after selector
+			mtlr	r13							; Set the routine address
+			lwz		r7,saver7+4(r30)			; Get 4th parameter after selector
+			lwz		r8,saver8+4(r30)			; Get 5th parameter after selector
+			lwz		r9,saver9+4(r30)			; Get 6th parameter after selector
+;
+;			NOTE: some of the above parameters are actually long longs.  We have glue code that transforms
+;			all needed parameters and/or adds 32-/64-bit flavors to the needed functions.
 ;			
 
 			blrl								; Call function
-			
-			stw		r3,saver3(r30)				; Pass back the return code
+
+vmmRetPt:	li		r0,0						; Clear this out			
+			stw		r0,saver3(r30)				; Make sure top of RC is clear
+			stw		r3,saver3+4(r30)			; Pass back the return code
+			stw		r0,saver4(r30)				; Make sure bottom of RC is clear (just in case)
+			stw		r4,saver4+4(r30)			; Pass back the bottom return code (just in case)
 			li		r3,1						; Set normal return with check for AST
 			b		EXT(ppcscret)				; Go back to handler...
 			
-vmmBogus:	li		r3,0						; Bogus selector, treat like a bogus system call
+vmmBogus:	
+			mfsprg	r10,0						; Get the per_proc
+			mfsprg	r3,1						; Load current activation
+			lwz		r5,spcFlags(r10)			; Get per_proc special flags
+			rlwinm.	r5,r5,0,FamVMmodebit,FamVMmodebit	; Test FamVMmodebit
+			bne		vmmexitcall					; Do it to it		
+			li		r3,0						; Bogus selector, treat like a bogus system call
 			b		EXT(ppcscret)				; Go back to handler...
 
 
@@ -137,18 +215,113 @@ LEXT(vmm_get_features_sel)						; Selector based version of get features
 
 LEXT(vmm_init_context_sel)						; Selector based version of init context
 
-			lwz		r4,saver4(r30)				; Get the passed in version
-			lwz		r5,saver5(r30)				; Get the passed in comm area
+			lwz		r4,saver4+4(r30)			; Get the passed in version
+			lwz		r5,saver5+4(r30)			; Get the passed in comm area
 			lis		r3,hi16(EXT(vmm_init_context))
-			stw		r4,saver3(r30)				; Cheat and move this parameter over
+			stw		r4,saver3+4(r30)			; Cheat and move this parameter over
 			ori		r3,r3,lo16(EXT(vmm_init_context))
-			stw		r5,saver4(r30)				; Cheat and move this parameter over
+			stw		r5,saver4+4(r30)			; Cheat and move this parameter over
 
 selcomm:	mtlr	r3							; Set the real routine address
 			mr		r3,r30						; Pass in the savearea
 			blrl								; Call the function
 			b		EXT(ppcscret)				; Go back to handler...
 
+			.align	5
+			.globl	EXT(vmm_map_page32)
+
+LEXT(vmm_map_page32)
+			mr		r9,r7											; Move prot to correct parm
+			mr		r8,r6											; Move guest address to low half of long long
+			li		r7,0											; Clear high half of guest address
+			mr		r6,r5											; Move host address to low half of long long
+			li		r5,0											; Clear high half of host address
+			b		EXT(vmm_map_page)								; Transition to real function...
+
+			.align	5
+			.globl	EXT(vmm_get_page_mapping32)
+
+LEXT(vmm_get_page_mapping32)
+			mr		r6,r5											; Move guest address to low half of long long
+			li		r5,0											; Clear high half of guest address
+			bl		EXT(vmm_get_page_mapping)						; Transition to real function...
+			mr		r3,r4											; Convert addr64_t to vm_offset_t, dropping top half
+			b		vmmRetPt										; Join normal return...
+
+			.align	5
+			.globl	EXT(vmm_unmap_page32)
+
+LEXT(vmm_unmap_page32)
+			mr		r6,r5											; Move guest address to low half of long long
+			li		r5,0											; Clear high half of guest address
+			b		EXT(vmm_unmap_page)								; Transition to real function...
+
+			.align	5
+			.globl	EXT(vmm_get_page_dirty_flag32)
+
+LEXT(vmm_get_page_dirty_flag32)
+			mr		r7,r6											; Move reset flag
+			mr		r6,r5											; Move guest address to low half of long long
+			li		r5,0											; Clear high half of guest address
+			b		EXT(vmm_get_page_dirty_flag)					; Transition to real function...
+
+			.align	5
+			.globl	EXT(vmm_protect_page32)
+
+LEXT(vmm_protect_page32)
+			mr		r7,r6											; Move protection bits
+			mr		r6,r5											; Move guest address to low half of long long
+			li		r5,0											; Clear high half of guest address
+			b		EXT(vmm_protect_page)							; Transition to real function...
+
+			.align	5
+			.globl	EXT(vmm_map_execute32)
+
+LEXT(vmm_map_execute32)
+			mr		r9,r7											; Move prot to correct parm
+			mr		r8,r6											; Move guest address to low half of long long
+			li		r7,0											; Clear high half of guest address
+			mr		r6,r5											; Move host address to low half of long long
+			li		r5,0											; Clear high half of host address
+			b		EXT(vmm_map_execute)							; Transition to real function...
+
+			.align	5
+			.globl	EXT(vmm_protect_execute32)
+			
+LEXT(vmm_protect_execute32)
+			mr		r7,r6											; Move protection bits
+			mr		r6,r5											; Move guest address to low half of long long
+			li		r5,0											; Clear high half of guest address
+			b		EXT(vmm_protect_execute)						; Transition to real function...
+
+			.align	5
+			.globl	EXT(vmm_map_list32)
+			
+LEXT(vmm_map_list32)
+			li		r6,0											; Set 32-bit flavor
+			b		EXT(vmm_map_list)								; Go to common routine...
+
+			.align	5
+			.globl	EXT(vmm_map_list64)
+			
+LEXT(vmm_map_list64)
+			li		r6,1											; Set 64-bit flavor
+			b		EXT(vmm_map_list)								; Go to common routine...
+
+			.align	5
+			.globl	EXT(vmm_map_list32)
+			
+LEXT(vmm_unmap_list32)
+			li		r6,0											; Set 32-bit flavor
+			b		EXT(vmm_unmap_list)								; Go to common routine...
+
+			.align	5
+			.globl	EXT(vmm_map_list64)
+			
+LEXT(vmm_unmap_list64)
+			li		r6,1											; Set 64-bit flavor
+			b		EXT(vmm_unmap_list)								; Go to common routine...
+
 /*
  *			Here is where we transition to the virtual machine.
  *
@@ -163,12 +336,6 @@ selcomm:	mtlr	r3							; Set the real routine address
  *			calls.  This is called, but never returned from.  We always go directly back to the
  *			user from here.
  *
- *			Still need to figure out final floats and vectors. For now, we will go brute
- *			force and when we go into the VM, we will force save any normal floats and 
- *			vectors. Then we will hide them and swap the VM copy (if any) into the normal
- *			chain.  When we exit VM we will do the opposite.  This is not as fast as I would
- *			like it to be.
- *
  *
  */
  
@@ -177,7 +344,6 @@ selcomm:	mtlr	r3							; Set the real routine address
  			.globl	EXT(vmm_execute_vm)
 
 LEXT(vmm_execute_vm)
-
  			lwz		r30,ACT_MACT_PCB(r3)		; Restore the savearea pointer because it could be trash here
  			b		EXT(switchIntoVM)			; Join common...
  
@@ -186,27 +352,43 @@ LEXT(vmm_execute_vm)
  			.globl	EXT(switchIntoVM)
 
 LEXT(switchIntoVM)
-
-			lwz		r5,vmmControl(r3)			; Pick up the control table address
+			mfsprg	r10,0						; Get the per_proc
+			rlwinm	r31,r4,24,24,31				; Get the address space
+			rlwinm	r4,r4,0,24,31				; Isolate the context id
+			lwz		r28,vmmControl(r3)			; Pick up the control table address
 			subi	r4,r4,1						; Switch to zero offset
-			rlwinm.	r2,r5,0,0,30				; Is there a context there? (Note: we will ignore bit 31 so that we 
+			rlwinm.	r2,r28,0,0,30				; Is there a context there? (Note: we will ignore bit 31 so that we 
 												;   do not try this while we are transitioning off to on
-			cmplwi	cr1,r4,kVmmMaxContextsPerThread	; Is the index valid?
+			cmplwi	cr1,r4,kVmmMaxContexts		; Is the index valid?
 			beq-	vmmBogus					; Not started, treat like a bogus system call
+			subic.	r31,r31,1					; Make address space 0 based and test if we use default
 			mulli	r2,r4,vmmCEntrySize			; Get displacement from index
-			bgt-	cr1,swvmmBogus				; Index is bogus...
-			add		r2,r2,r5					; Point to the entry
-			
+			bge-	cr1,swvmmBogus				; Index is bogus...
+			add		r2,r2,r28					; Point to the entry
+			bge--	swvmmDAdsp					; There was an explicit address space request
+			mr		r31,r4						; Default the address space to the context ID
+
+swvmmDAdsp:	la		r2,vmmc(r2)					; Get the offset to the context array
+			lwz		r8,vmmGFlags(r28)			; Get the general flags
 			lwz		r4,vmmFlags(r2)				; Get the flags for the selected entry
+			crset	vmmMapDone					; Assume we will be mapping something
 			lwz		r5,vmmContextKern(r2)		; Get the context area address
 			rlwinm.	r26,r4,0,vmmInUseb,vmmInUseb	; See if the slot is in use
-			bne+	swvmChkIntcpt				; We are so cool. Go do check for immediate intercepts...
-			
-swvmmBogus:	li		r2,kVmmBogusContext			; Set bogus index return
-			li		r3,1						; Set normal return with check for AST	
-			stw		r2,saver3(r30)				; Pass back the return code
-			b		EXT(ppcscret)				; Go back to handler...
-
+			cmplwi	cr1,r31,kVmmMaxContexts		; See if we have a valid address space ID
+			rlwinm	r8,r8,0,24,31				; Clean up address space
+			beq--	swvmmBogus					; This context is no good...
+
+			la		r26,vmmAdsp(r28)			; Point to the pmaps
+			sub		r8,r8,r31					; Get diff between launching address space - 1 and last mapped into (should be 1 if the same)
+			rlwinm	r31,r31,2,0,29				; Index to the pmap
+			cmplwi	r8,1						; See if we have the same address space
+			bge--	cr1,swvmmBogAdsp			; Address space is no good...
+			lwzx	r31,r26,r31					; Get the requested address space pmap
+			li		r0,0						; Get a 0 in case we need to trash redrive
+			lwz		r15,spcFlags(r10)			; Get per_proc special flags
+			beq		swvmmAdspOk					; Do not invalidate address space if we are launching the same
+			crclr	vmmMapDone					; Clear map done flag
+			stb		r0,vmmGFlags+3(r28)			; Clear the last mapped address space ID so we will not redrive later
 ;
 ;			Here we check for any immediate intercepts.  So far, the only
 ;			two of these are a timer pop and and external stop.  We will not dispatch if
@@ -214,7 +396,10 @@ swvmmBogus:	li		r2,kVmmBogusContext			; Set bogus index return
 ;			to 0) or to set a future time, or if it is external stop, set the vmmXStopRst flag.
 ;
 
-swvmChkIntcpt:
+swvmmAdspOk:
+			rlwinm.	r0,r15,0,FamVMmodebit,FamVMmodebit	; Test FamVMmodebit
+			stw		r31,vmmPmap(r2)				; Save the last dispatched address space
+			bne		vmmFamGuestResume		
 			lwz		r6,vmmCntrl(r5)				; Get the control field
 			rlwinm.	r7,r6,0,vmmXStartb,vmmXStartb	; Clear all but start bit
 			beq+	swvmChkStop					; Do not reset stop
@@ -229,23 +414,18 @@ swvmtryx:	lwarx	r4,r8,r2					; Pick up the flags
 
 swvmChkStop:			
 			rlwinm.	r26,r4,0,vmmXStopb,vmmXStopb	; Is this VM stopped?
-			beq+	swvmNoStop					; Nope...
-				
-			li		r2,kVmmStopped				; Set stopped return
-			li		r3,1						; Set normal return with check for AST
-			stw		r2,saver3(r30)				; Pass back the return code
-			stw		r2,return_code(r5)			; Save the exit code
-			b		EXT(ppcscret)				; Go back to handler...
+			bne--	swvmSetStop					; Yes...
 			
-swvmNoStop:			
 			rlwinm.	r26,r4,0,vmmTimerPopb,vmmTimerPopb	; Did the timer go pop?
-			beq+	swvmDoSwitch				; No...
-		
-			li		r2,kVmmReturnNull			; Set null return
-			li		r3,1						; Set normal return with check for AST
-			stw		r2,saver3(r30)				; Pass back the return code
-			stw		r2,return_code(r5)			; Save the exit code
-			b		EXT(ppcscret)				; Go back to handler...
+			cmplwi	cr1,r31,0					; Is there actually an address space defined?
+			bne--	svvmTimerPop				; Yes...
+
+;
+;			Special note: we need to intercept any attempt to launch a guest into a non-existent address space.
+;			We will just go emulate an ISI if there is not one.
+;
+
+			beq--	cr1,swvmEmulateISI			; We are trying to launch into an undefined address space.  This is not so good...
 
 ;
 ;			Here is where we actually swap into the VM (alternate) context.
@@ -269,15 +449,34 @@ swvmDoSwitch:
 			stw		r11,deferctx(r3)			; Start using the virtual machine facility context when we exit
 
 			lwz		r11,ACT_MACT_SPF(r26)		; Get the special flags
-			lwz		r3,vmmPmap(r27)				; Get the pointer to the PMAP
+			mr		r3,r31						; Get the pointer to the PMAP
 			oris	r15,r11,hi16(runningVM)	; 	; Show that we are swapped to the VM right now
 			bl		EXT(hw_set_user_space_dis)	; Swap the address spaces
 			lwz		r17,vmmFlags(r27)			; Get the status flags
-			mfsprg	r10,0						; Get the per_proc
-			rlwinm.	r0,r17,0,vmmMapDoneb,vmmMapDoneb	; Did we just do a map function?
+			lwz		r20,vmmContextKern(r27)		; Get the state page kernel addr
+			lwz		r21,vmmCntrl(r20)			; Get vmmCntrl
+			rlwinm.	r22,r21,0,vmmFamEnab,vmmFamEnab	; Is vmmFamEnab set?
+			lwz		r22,vmmXAFlgs(r27)			; Get the eXtended Architecture flags
+			stw		r22,VMMXAFlgs(r10)			; Store vmmXAFlgs in per_proc VMMXAFlgs
+			beq		swvmNoFam					; No Fam intercept
+			rlwinm.	r22,r22,0,0,0				; Are we doing a 64-bit virtual machine?
+			rlwimi	r15,r21,32+vmmFamSetb-FamVMmodebit,FamVMmodebit,FamVMmodebit	; Set FamVMmode bit
+			rlwinm	r21,r21,0,vmmFamSetb+1,vmmFamSetb-1	; Clear FamSet bit
+			bne		swvmXfamintercpt
+			lwz		r22,famintercepts(r20)		; Load intercept bit field
+			b		swvmfamintercptres
+swvmXfamintercpt:
+			lwz		r22,faminterceptsX(r20)		; Load intercept bit field
+swvmfamintercptres:
+			stw		r21,vmmCntrl(r20)			; Update vmmCntrl
+			lwz		r19,vmmContextPhys(r27)		; Get vmmFAMarea address
+			stw		r22,vmmFAMintercept(r27)	; Get vmmFAMintercept
+			stw		r22,FAMintercept(r10)		; Store vmmFAMintercept in per_proc FAMintercept
+			stw		r19,VMMareaPhys(r10)		; Store VMMareaPhys
+			oris	r15,r15,hi16(FamVMena)		; Set FamVMenabit
+swvmNoFam:
 			stw		r27,vmmCEntry(r26)			; Remember what context we are running
-			andc	r17,r17,r0					; Turn off map flag
-			beq+	swvmNoMap					; No mapping done...
+			bf++	vmmMapDone,swvmNoMap		; We have not mapped anything or it was not for this address space
 
 ;
 ;			This little bit of hoopala here (triggered by vmmMapDone) is
@@ -288,17 +487,24 @@ swvmDoSwitch:
 ;			double faults from happening.  Note that there is only a gain if the VM
 ;			takes a fault, then the emulator resolves it only, and then begins
 ;			the VM execution again.  It seems like this should be the normal case.
+;
+;			Note that we need to revisit this when we move the virtual machines to the task because
+;			then it will be possible for more than one thread to access this stuff at the same time.
 ;
 			
 			lwz		r3,SAVflags(r30)			; Pick up the savearea flags
-			lwz		r2,vmmLastMap(r27)			; Get the last mapped address
+			lwz		r2,vmmLastMap(r28)			; Get the last mapped address
+			lwz		r14,vmmLastMap+4(r28)		; Get the last mapped address low half
 			li		r20,T_DATA_ACCESS			; Change to DSI fault
 			oris	r3,r3,hi16(SAVredrive)		; Set exception redrive
 			stw		r2,savedar(r30)				; Set the DAR to the last thing we mapped
+			stw		r14,savedar+4(r30)			; Set the DAR to the last thing we mapped
 			stw		r3,SAVflags(r30)			; Turn on the redrive request
 			lis		r2,hi16(MASK(DSISR_HASH))	; Set PTE/DBAT miss
+			li		r0,0						; Clear
 			stw		r20,saveexception(r30)		; Say we need to emulate a DSI
 			stw		r2,savedsisr(r30)			; Pretend we have a PTE miss			
+			stb		r0,vmmGFlags+3(r28)			; Show that the redrive has been taken care of
 			
 swvmNoMap:	lwz		r20,vmmContextKern(r27)		; Get the comm area
 			rlwimi	r15,r17,32-(floatCngbit-vmmFloatCngdb),floatCngbit,vectorCngbit	; Shift and insert changed bits			
@@ -338,15 +544,18 @@ swvmNoMap:	lwz		r20,vmmContextKern(r27)		; Get the comm area
 			ori		r18,r18,lo16(EXT(per_proc_info))	; Set base per_proc
 			li		r16,FPUowner				; Displacement to float owner
 			add		r19,r18,r19					; Point to the owner per_proc
-			li		r0,0						; Clear this out	
 			
 swvminvfpu:	lwarx	r18,r16,r19					; Get the owner
-			cmplw	r18,r25						; Does he still have this context?
-			bne		swvminvfpv					; Nope...		
-			stwcx.	r0,r16,r19					; Try to invalidate it
-			bne-	swvminvfpu					; Try again if there was a collision...
-			
-swvminvfpv:	lwz		r3,FPUsave(r25)				; Get the FPU savearea
+
+			sub		r0,r18,r25					; Subtract one from the other
+			sub		r3,r25,r18					; Subtract the other from the one
+			or		r3,r3,r0					; Combine them
+			srawi	r3,r3,31					; Get a 0 if equal or -1 of not
+			and		r18,r18,r3					; Make 0 if same, unchanged if not
+			stwcx.	r18,r16,r19					; Try to invalidate it
+			bne--	swvminvfpu					; Try again if there was a collision...
+
+			lwz		r3,FPUsave(r25)				; Get the FPU savearea
 			dcbt	r14,r17						; Touch in first line of new stuff
 			mr.		r3,r3						; Is there one?
 			bne+	swvmGotFloat				; Yes...
@@ -357,7 +566,7 @@ swvminvfpv:	lwz		r3,FPUsave(r25)				; Get the FPU savearea
 			stw		r26,SAVact(r3)				; Save our activation
 			li		r0,0						; Get a zero
 			stb		r7,SAVflags+2(r3)			; Set that this is floating point
-			stw		r0,SAVprev(r3)				; Clear the back chain
+			stw		r0,SAVprev+4(r3)			; Clear the back chain
 			stw		r0,SAVlevel(r3)				; We are always at level 0 (user state)
 			
 			stw		r3,FPUsave(r25)				; Chain us to context
@@ -370,11 +579,6 @@ swvmGotFloat:
 			
 			bl		EXT(bcopy)					; Copy the new values
 			
-			lwz		r14,vmmppcFPSCRshadow(r17)	; Get the fpscr pad
-			lwz		r10,vmmppcFPSCRshadow+4(r17)	; Get the fpscr
-			stw		r14,savefpscrpad(r30)		; Save the new fpscr pad
-			stw		r10,savefpscr(r30)			; Save the new fpscr
-
 			lwz		r11,ACT_MACT_SPF(r26)		; Get the special flags
 			stw		r15,vmmCntrl(r17)			; Save the control flags sans vmmFloatLoad
 			rlwinm	r11,r11,0,floatCngbit+1,floatCngbit-1	; Clear the changed bit here
@@ -406,13 +610,16 @@ swvmNoNewFloats:
 			ori		r18,r18,lo16(EXT(per_proc_info))	; Set base per_proc
 			li		r16,VMXowner				; Displacement to vector owner
 			add		r19,r18,r19					; Point to the owner per_proc	
-			li		r0,0						; Clear this out	
 			
 swvminvvec:	lwarx	r18,r16,r19					; Get the owner
-			cmplw	r18,r25						; Does he still have this context?
-			bne		swvminvved					; Nope...		
-			stwcx.	r0,r16,r19					; Try to invalidate it
-			bne-	swvminvvec					; Try again if there was a collision...
+
+			sub		r0,r18,r25					; Subtract one from the other
+			sub		r3,r25,r18					; Subtract the other from the one
+			or		r3,r3,r0					; Combine them
+			srawi	r3,r3,31					; Get a 0 if equal or -1 of not
+			and		r18,r18,r3					; Make 0 if same, unchanged if not
+			stwcx.	r18,r16,r19					; Try to invalidate it
+			bne--	swvminvfpu					; Try again if there was a collision...
 			
 swvminvved:	lwz		r3,VMXsave(r25)				; Get the vector savearea
 			dcbt	r14,r17						; Touch in first line of new stuff
@@ -425,7 +632,7 @@ swvminvved:	lwz		r3,VMXsave(r25)				; Get the vector savearea
 			stw		r26,SAVact(r3)				; Save our activation
 			li		r0,0						; Get a zero
 			stb		r7,SAVflags+2(r3)			; Set that this is vector
-			stw		r0,SAVprev(r3)				; Clear the back chain
+			stw		r0,SAVprev+4(r3)			; Clear the back chain
 			stw		r0,SAVlevel(r3)				; We are always at level 0 (user state)
 			
 			stw		r3,VMXsave(r25)				; Chain us to context
@@ -438,21 +645,12 @@ swvmGotVect:
 			
 			bl		EXT(bcopy)					; Copy the new values
 
-			lwz		r11,vmmppcVSCRshadow+0(r17)	; Get the VSCR
-			lwz		r14,vmmppcVSCRshadow+4(r17)	; Get the VSCR
-			lwz		r10,vmmppcVSCRshadow+8(r17)	; Get the VSCR
-			lwz		r9,vmmppcVSCRshadow+12(r17)	; Get the VSCR
 			lwz		r8,savevrsave(r30)			; Get the current VRSave
 			
-			stw		r11,savevscr+0(r30)			; Set the VSCR
-			stw		r14,savevscr+4(r30)			; Set the VSCR
-			stw		r10,savevscr+8(r30)			; Set the VSCR
-			stw		r9,savevscr+12(r30)			; Set the VSCR
-			stw		r8,savevrvalid(r21)			; Set the current VRSave as valid saved
-			
 			lwz		r11,ACT_MACT_SPF(r26)		; Get the special flags
 			stw		r15,vmmCntrl(r17)			; Save the control flags sans vmmVectLoad
 			rlwinm	r11,r11,0,vectorCngbit+1,vectorCngbit-1	; Clear the changed bit here
+			stw		r8,savevrvalid(r21)			; Set the current VRSave as valid saved
 			lwz		r14,vmmStat(r17)			; Get the status flags
 			mfsprg	r10,0						; Get the per_proc
 			stw		r11,ACT_MACT_SPF(r26)		; Get the special flags
@@ -465,6 +663,76 @@ swvmNoNewVects:
 			lwz		r16,ACT_THREAD(r26)			; Restore the thread pointer
 			b		EXT(ppcscret)				; Go back to handler...
 
+			.align	5
+			
+swvmmBogus:	li		r2,kVmmBogusContext			; Set bogus index return
+			li		r0,0						; Clear
+			li		r3,1						; Set normal return with check for AST	
+			stw		r0,saver3(r30)				; Clear upper half
+			stw		r2,saver3+4(r30)			; Pass back the return code
+			b		EXT(ppcscret)				; Go back to handler...
+			
+swvmmBogAdsp:
+			li		r2,kVmmInvalidAdSpace		; Set bogus address space return
+			li		r0,0						; Clear
+			li		r3,1						; Set normal return with check for AST	
+			stw		r0,saver3(r30)				; Clear upper half
+			stw		r2,saver3+4(r30)			; Pass back the return code
+			b		EXT(ppcscret)				; Go back to handler...
+				
+swvmSetStop:
+			li		r2,kVmmStopped				; Set stopped return
+			li		r0,0						; Clear
+			li		r3,1						; Set normal return with check for AST
+			stw		r0,saver3(r30)				; Clear upper half
+			stw		r2,saver3+4(r30)			; Pass back the return code
+			stw		r2,return_code(r5)			; Save the exit code
+			b		EXT(ppcscret)				; Go back to handler...
+		
+svvmTimerPop:
+			li		r2,kVmmReturnNull			; Set null return
+			li		r0,0						; Clear
+			li		r3,1						; Set normal return with check for AST
+			stw		r0,saver3(r30)				; Clear upper half
+			stw		r2,saver3+4(r30)			; Pass back the return code
+			stw		r2,return_code(r5)			; Save the exit code
+			b		EXT(ppcscret)				; Go back to handler...
+		
+swvmEmulateISI:
+			mfsprg	r10,2						; Get feature flags
+			lwz		r11,vmmXAFlgs(r28)			; Get the eXtended Architecture flags			
+			mtcrf	0x02,r10					; Move pf64Bit to its normal place in CR6
+			rlwinm.	r11,r11,0,0,0				; Are we doing a 64-bit virtual machine?		
+			li		r2,kVmmReturnInstrPageFault	; Set ISI
+			crnot	vmmDoing64,cr0_eq			; Remember if this is a 64-bit VM
+			li		r0,0						; Clear
+			li		r3,1						; Set normal return with check for AST
+			stw		r0,saver3(r30)				; Clear upper half
+			stw		r2,saver3+4(r30)			; Pass back the return code
+			stw		r2,return_code(r5)			; Save the exit code
+			lis		r7,hi16(MASK(DSISR_HASH))	; Pretend like we got a PTE miss
+			bt		vmmDoing64,vmISI64			; Go do this for a 64-bit VM...
+
+			lwz		r10,vmmppcpc(r5)			; Get the PC as failing address
+			stw		r10,return_params+0(r5)		; Save PC as first return parm
+			stw		r7,return_params+4(r5)		; Save the pseudo-DSISR as second return parm
+			b		EXT(ppcscret)				; Go back to handler...
+
+vmISI64:	ld		r10,vmmppcXpc(r5)			; Get the PC as failing address
+			std		r10,return_paramsX+0(r5)	; Save PC as first return parm
+			std		r7,return_paramsX+8(r5)		; Save the pseudo-DSISR as second return parm
+			b		EXT(ppcscret)				; Go back to handler...
+
+;
+;			These syscalls are invalid, FAM syscall fast path 
+;
+
+			.align	5
+			.globl	EXT(vmm_fam_reserved)
+
+LEXT(vmm_fam_reserved)
+			li		r3,0						; Force exception
+			b		EXT(ppcscret)				; Go back to handler...
 
 ;
 ;			Here is where we exit from vmm mode.  We do this on any kind of exception.
@@ -482,6 +750,7 @@ swvmNoNewVects:
 
 LEXT(vmm_exit)
 
+vmmexitcall:
 			lwz		r2,vmmCEntry(r3)			; Get the context that is active
 			lwz		r12,ACT_VMMAP(r3)			; Get the VM_MAP for this guy
 			lwz		r11,ACT_MACT_SPF(r3)		; Get the special flags
@@ -497,7 +766,16 @@ LEXT(vmm_exit)
 			stw		r19,vmmFlags(r2)			; Set the status flags
 			rlwinm	r11,r11,0,userProtKeybit+1,userProtKeybit-1	; Set back to normal protection key
 			mfsprg	r10,0						; Get the per_proc block
+			rlwinm	r11,r11,0,FamVMenabit+1,FamVMenabit-1	; Clear FamVMEnable
+			lwz		r18,spcFlags(r10)			; Get per_proc copy of the special flags
+			lwz		r5,vmmContextKern(r2)		; Get the state page kernel addr 
+			rlwinm	r11,r11,0,FamVMmodebit+1,FamVMmodebit-1	; Clear FamVMMode
+			lwz		r6,vmmCntrl(r5)				; Get the control field
+			rlwimi	r19,r18,FamVMmodebit-vmmFAMmodeb,vmmFAMmodeb,vmmFAMmodeb	; Shift and insert changed bits			
+			rlwimi	r6,r18,FamVMmodebit-vmmFamSetb,vmmFamSetb,vmmFamSetb		; Shift and insert changed bits			
+			rlwimi	r6,r18,userProtKeybit-vmmKeyb,vmmKeyb,vmmKeyb				; Shift and insert changed bits			
 			stw		r11,ACT_MACT_SPF(r16)		; Get the special flags
+			stw		r6,vmmCntrl(r5)				; Store the control field
 			stw		r11,spcFlags(r10)			; Set per_proc copy of the special flags
 			
 			mr		r26,r16						; Save the activation pointer
@@ -512,7 +790,7 @@ LEXT(vmm_exit)
 			mr		r3,r16						; Restore activation address
 			stw		r19,vmmStat(r5)				; Save the changed and popped flags
 			bl		swapCtxt					; Exchange the VM context for the emulator one
-			stw		r8,saver3(r30)				; Set the return code as the return value also
+			stw		r8,saver3+4(r30)			; Set the return code as the return value also
 			b		EXT(retFromVM)				; Go back to handler...
 
 
@@ -554,6 +832,15 @@ LEXT(vmm_force_exit)
 			rlwinm	r9,r9,0,userProtKeybit+1,userProtKeybit-1	; Set back to normal protection key
 			stw		r0,vmmCEntry(r26)			; Clear pointer to active context
 			mfsprg	r10,0						; Get the per_proc block
+			lwz		r18,spcFlags(r10)			; Get per_proc copy of the special flags
+			rlwinm	r9,r9,0,FamVMenabit+1,FamVMenabit-1	; Clear Fam Enable
+			rlwinm	r9,r9,0,FamVMmodebit+1,FamVMmodebit-1	; Clear Fam Enable
+			lwz		r5,vmmContextKern(r2)		; Get the context area address
+			lwz		r6,vmmCntrl(r5)				; Get the control field
+			rlwimi	r19,r18,FamVMmodebit-vmmFAMmodeb,vmmFAMmodeb,vmmFAMmodeb	; Shift and insert changed bits			
+			rlwimi	r6,r18,FamVMmodebit-vmmFamSetb,vmmFamSetb,vmmFamSetb		; Shift and insert changed bits			
+			rlwimi	r6,r18,userProtKeybit-vmmKeyb,vmmKeyb,vmmKeyb				; Shift and insert changed bits			
+			stw		r6,vmmCntrl(r5)				; Store the control field
 			stw		r9,ACT_MACT_SPF(r26)		; Get the special flags
 			stw		r9,spcFlags(r10)			; Set per_proc copy of the special flags
 			
@@ -575,7 +862,7 @@ LEXT(vmm_force_exit)
 			lis		r9,hi16(SAVredrive)			; Get exception redrive bit
 			rlwinm	r8,r8,30,24,31				; Convert exception to return code
 			andc	r7,r7,r9					; Make sure redrive is off because we are intercepting
-			stw		r8,saver3(r30)				; Set the return code as the return value also
+			stw		r8,saver3+4(r30)			; Set the return code as the return value also
 			stw		r7,SAVflags(r30)			; Set the savearea flags
 			
 
@@ -593,27 +880,32 @@ vfeNotRun:	lmw		r13,FM_ARG0(r1)				; Restore all non-volatile registers
 ;
 			.align	5
 
-swapCtxt:	la		r6,vmmppcpc(r5)				; Point to the first line
+swapCtxt:	
+			mfsprg	r10,2						; Get feature flags
+			la		r6,vmmppcpc(r5)				; Point to the first line
+			mtcrf	0x02,r10					; Move pf64Bit to its normal place in CR6
 			
 			lwz		r14,saveexception(r30)		; Get the exception code
 			dcbt	0,r6						; Touch in the first line of the context area
-			lwz		r7,savesrr0(r30)			; Start moving context	
-			lwz		r8,savesrr1(r30)				
-			lwz		r9,saver0(r30)				
+			bt++	pf64Bitb,swap64				; Go do this swap on a 64-bit machine...
+			
+			lwz		r7,savesrr0+4(r30)			; Start moving context	
+			lwz		r8,savesrr1+4(r30)				
+			lwz		r9,saver0+4(r30)				
 			cmplwi	cr1,r14,T_SYSTEM_CALL		; Are we switching because of a system call?
-			lwz		r10,saver1(r30)				
-			lwz		r11,saver2(r30)				
-			lwz		r12,saver3(r30)				
-			lwz		r13,saver4(r30)	
+			lwz		r10,saver1+4(r30)				
+			lwz		r11,saver2+4(r30)				
+			lwz		r12,saver3+4(r30)				
+			lwz		r13,saver4+4(r30)	
 			la		r6,vmmppcr6(r5)				; Point to second line		
-			lwz		r14,saver5(r30)				
+			lwz		r14,saver5+4(r30)				
 			
 			dcbt	0,r6						; Touch second line of context area
 			
 			lwz		r15,vmmppcpc(r5)			; First line of context	
 			lis		r22,hi16(MSR_IMPORT_BITS)	; Get the MSR bits that are controllable by user
 			lwz		r23,vmmppcmsr(r5)				
-			ori		r22,r25,lo16(MSR_IMPORT_BITS)	; Get the rest of the MSR bits that are controllable by user
+			ori		r22,r22,lo16(MSR_IMPORT_BITS)	; Get the rest of the MSR bits that are controllable by user
 			lwz		r17,vmmppcr0(r5)				
 			lwz		r18,vmmppcr1(r5)		
 			and		r23,r23,r22					; Keep only the controllable bits		
@@ -643,28 +935,31 @@ swapCtxt:	la		r6,vmmppcpc(r5)				; Point to the first line
 			stw		r13,return_params+4(r5)		; Save the second return
 			stw		r14,return_params+8(r5)		; Save the third return
 
-swapnotsc:	stw		r15,savesrr0(r30)			; Save vm context into the savearea	
-			stw		r23,savesrr1(r30)				
-			stw		r17,saver0(r30)				
-			stw		r18,saver1(r30)		
-			stw		r19,saver2(r30)		
-			stw		r20,saver3(r30)				
-			stw		r21,saver4(r30)		
+swapnotsc:	li		r6,0						; Clear this out
+			stw		r6,savesrr0(r30)			; Insure that high order is clear
+			stw		r15,savesrr0+4(r30)			; Save vm context into the savearea	
+			stw		r6,savesrr1(r30)			; Insure that high order is clear
+			stw		r23,savesrr1+4(r30)				
+			stw		r17,saver0+4(r30)				
+			stw		r18,saver1+4(r30)		
+			stw		r19,saver2+4(r30)		
+			stw		r20,saver3+4(r30)				
+			stw		r21,saver4+4(r30)		
 			la		r6,vmmppcr14(r5)			; Point to fourth line		
-			stw		r22,saver5(r30)				
+			stw		r22,saver5+4(r30)				
 			
 			dcbt	0,r6						; Touch fourth line
 
 ;			Swap 8 registers
 			
-			lwz		r7,saver6(r30)				; Read savearea	
-			lwz		r8,saver7(r30)				
-			lwz		r9,saver8(r30)				
-			lwz		r10,saver9(r30)				
-			lwz		r11,saver10(r30)				
-			lwz		r12,saver11(r30)				
-			lwz		r13,saver12(r30)				
-			lwz		r14,saver13(r30)				
+			lwz		r7,saver6+4(r30)			; Read savearea	
+			lwz		r8,saver7+4(r30)				
+			lwz		r9,saver8+4(r30)				
+			lwz		r10,saver9+4(r30)				
+			lwz		r11,saver10+4(r30)				
+			lwz		r12,saver11+4(r30)				
+			lwz		r13,saver12+4(r30)				
+			lwz		r14,saver13+4(r30)				
 
 			lwz		r15,vmmppcr6(r5)			; Read vm context 
 			lwz		r24,vmmppcr7(r5)				
@@ -687,25 +982,25 @@ swapnotsc:	stw		r15,savesrr0(r30)			; Save vm context into the savearea
 
 			dcbt	0,r6						; Touch fifth line
 
-			stw		r15,saver6(r30)				; Write vm context 
-			stw		r24,saver7(r30)				
-			stw		r17,saver8(r30)				
-			stw		r18,saver9(r30)		
-			stw		r19,saver10(r30)		
-			stw		r20,saver11(r30)				
-			stw		r21,saver12(r30)				
-			stw		r22,saver13(r30)				
+			stw		r15,saver6+4(r30)			; Write vm context 
+			stw		r24,saver7+4(r30)				
+			stw		r17,saver8+4(r30)				
+			stw		r18,saver9+4(r30)		
+			stw		r19,saver10+4(r30)		
+			stw		r20,saver11+4(r30)				
+			stw		r21,saver12+4(r30)				
+			stw		r22,saver13+4(r30)				
 
 ;			Swap 8 registers
 			
-			lwz		r7,saver14(r30)				; Read savearea	
-			lwz		r8,saver15(r30)				
-			lwz		r9,saver16(r30)				
-			lwz		r10,saver17(r30)				
-			lwz		r11,saver18(r30)				
-			lwz		r12,saver19(r30)				
-			lwz		r13,saver20(r30)				
-			lwz		r14,saver21(r30)				
+			lwz		r7,saver14+4(r30)			; Read savearea	
+			lwz		r8,saver15+4(r30)				
+			lwz		r9,saver16+4(r30)				
+			lwz		r10,saver17+4(r30)				
+			lwz		r11,saver18+4(r30)				
+			lwz		r12,saver19+4(r30)				
+			lwz		r13,saver20+4(r30)				
+			lwz		r14,saver21+4(r30)				
 
 			lwz		r15,vmmppcr14(r5)			; Read vm context 
 			lwz		r24,vmmppcr15(r5)				
@@ -728,25 +1023,25 @@ swapnotsc:	stw		r15,savesrr0(r30)			; Save vm context into the savearea
 			
 			dcbt	0,r6						; Touch sixth line
 
-			stw		r15,saver14(r30)			; Write vm context 
-			stw		r24,saver15(r30)				
-			stw		r17,saver16(r30)				
-			stw		r18,saver17(r30)		
-			stw		r19,saver18(r30)		
-			stw		r20,saver19(r30)				
-			stw		r21,saver20(r30)				
-			stw		r22,saver21(r30)				
+			stw		r15,saver14+4(r30)			; Write vm context 
+			stw		r24,saver15+4(r30)				
+			stw		r17,saver16+4(r30)				
+			stw		r18,saver17+4(r30)		
+			stw		r19,saver18+4(r30)		
+			stw		r20,saver19+4(r30)				
+			stw		r21,saver20+4(r30)				
+			stw		r22,saver21+4(r30)				
 
 ;			Swap 8 registers
 			
-			lwz		r7,saver22(r30)				; Read savearea	
-			lwz		r8,saver23(r30)				
-			lwz		r9,saver24(r30)				
-			lwz		r10,saver25(r30)				
-			lwz		r11,saver26(r30)				
-			lwz		r12,saver27(r30)				
-			lwz		r13,saver28(r30)				
-			lwz		r14,saver29(r30)				
+			lwz		r7,saver22+4(r30)			; Read savearea	
+			lwz		r8,saver23+4(r30)				
+			lwz		r9,saver24+4(r30)				
+			lwz		r10,saver25+4(r30)				
+			lwz		r11,saver26+4(r30)				
+			lwz		r12,saver27+4(r30)				
+			lwz		r13,saver28+4(r30)				
+			lwz		r14,saver29+4(r30)				
 
 			lwz		r15,vmmppcr22(r5)			; Read vm context 
 			lwz		r24,vmmppcr23(r5)				
@@ -769,23 +1064,23 @@ swapnotsc:	stw		r15,savesrr0(r30)			; Save vm context into the savearea
 
 			dcbt	0,r6						; Touch seventh line
 
-			stw		r15,saver22(r30)			; Write vm context 
-			stw		r24,saver23(r30)				
-			stw		r17,saver24(r30)				
-			stw		r18,saver25(r30)		
-			stw		r19,saver26(r30)		
-			stw		r20,saver27(r30)				
-			stw		r21,saver28(r30)				
-			stw		r22,saver29(r30)				
+			stw		r15,saver22+4(r30)			; Write vm context 
+			stw		r24,saver23+4(r30)				
+			stw		r17,saver24+4(r30)				
+			stw		r18,saver25+4(r30)		
+			stw		r19,saver26+4(r30)		
+			stw		r20,saver27+4(r30)				
+			stw		r21,saver28+4(r30)				
+			stw		r22,saver29+4(r30)				
 
 ;			Swap 8 registers
 			
-			lwz		r7,saver30(r30)				; Read savearea	
-			lwz		r8,saver31(r30)				
+			lwz		r7,saver30+4(r30)			; Read savearea	
+			lwz		r8,saver31+4(r30)				
 			lwz		r9,savecr(r30)				
-			lwz		r10,savexer(r30)				
-			lwz		r11,savelr(r30)				
-			lwz		r12,savectr(r30)				
+			lwz		r10,savexer+4(r30)				
+			lwz		r11,savelr+4(r30)				
+			lwz		r12,savectr+4(r30)				
 			lwz		r14,savevrsave(r30)				
 
 			lwz		r15,vmmppcr30(r5)			; Read vm context 
@@ -804,12 +1099,12 @@ swapnotsc:	stw		r15,savesrr0(r30)			; Save vm context into the savearea
 			stw		r12,vmmppcctr(r5)				
 			stw		r14,vmmppcvrsave(r5)				
 
-			stw		r15,saver30(r30)			; Write vm context 
-			stw		r24,saver31(r30)				
+			stw		r15,saver30+4(r30)			; Write vm context 
+			stw		r24,saver31+4(r30)				
 			stw		r17,savecr(r30)				
-			stw		r18,savexer(r30)		
-			stw		r19,savelr(r30)		
-			stw		r20,savectr(r30)				
+			stw		r18,savexer+4(r30)		
+			stw		r19,savelr+4(r30)		
+			stw		r20,savectr+4(r30)				
 			stw		r22,savevrsave(r30)				
 
 ;			Swap 8 registers
@@ -865,7 +1160,7 @@ swapnotsc:	stw		r15,savesrr0(r30)			; Save vm context into the savearea
 ;			Set exit returns for a DSI or alignment exception
 ;
 
-swapDSI:	lwz		r10,savedar(r30)			; Get the DAR
+swapDSI:	lwz		r10,savedar+4(r30)			; Get the DAR
 			lwz		r7,savedsisr(r30)			; and the DSISR
 			stw		r10,return_params+0(r5)		; Save DAR as first return parm
 			stw		r7,return_params+4(r5)		; Save DSISR as second return parm
@@ -891,3 +1186,1156 @@ swapSC:		lwz		r10,vmmppcr6(r5)			; Get the fourth paramter
 			stw		r10,return_params+12(r5)	; Save it
 			blr									; Return...
 
+;
+;			Here is the swap for 64-bit machines
+;
+
+swap64:		lwz		r22,vmmXAFlgs(r27)			; Get the eXtended Architecture flags			
+			ld		r7,savesrr0(r30)			; Start moving context	
+			ld		r8,savesrr1(r30)				
+			ld		r9,saver0(r30)				
+			cmplwi	cr1,r14,T_SYSTEM_CALL		; Are we switching because of a system call?
+			ld		r10,saver1(r30)				
+			ld		r11,saver2(r30)		
+			rlwinm.	r22,r22,0,0,0				; Are we doing a 64-bit virtual machine?		
+			ld		r12,saver3(r30)				
+			crnot	vmmDoing64,cr0_eq			; Remember if this is a 64-bit VM
+			ld		r13,saver4(r30)	
+			la		r6,vmmppcr6(r5)				; Point to second line		
+			ld		r14,saver5(r30)				
+			
+			dcbt	0,r6						; Touch second line of context area
+			
+			bt		vmmDoing64,sw64x1			; Skip to 64-bit stuff
+			
+			lwz		r15,vmmppcpc(r5)			; First line of context	
+			lis		r22,hi16(MSR_IMPORT_BITS)	; Get the MSR bits that are controllable by user
+			lwz		r23,vmmppcmsr(r5)				
+			ori		r22,r25,lo16(MSR_IMPORT_BITS)	; Get the rest of the MSR bits that are controllable by user
+			lwz		r17,vmmppcr0(r5)				
+			lwz		r18,vmmppcr1(r5)		
+			and		r23,r23,r22					; Keep only the controllable bits		
+			lwz		r19,vmmppcr2(r5)		
+			oris	r23,r23,hi16(MSR_EXPORT_MASK_SET)	; Force on the required bits
+			lwz		r20,vmmppcr3(r5)				
+			ori		r23,r23,lo16(MSR_EXPORT_MASK_SET)	; Force on the other required bits
+			lwz		r21,vmmppcr4(r5)				
+			lwz		r22,vmmppcr5(r5)				
+
+			dcbt	0,r6						; Touch third line of context area
+		
+			stw		r7,vmmppcpc(r5)				; Save emulator context into the context area	
+			stw		r8,vmmppcmsr(r5)				
+			stw		r9,vmmppcr0(r5)				
+			stw		r10,vmmppcr1(r5)				
+			stw		r11,vmmppcr2(r5)				
+			stw		r12,vmmppcr3(r5)				
+			stw		r13,vmmppcr4(r5)				
+			stw		r14,vmmppcr5(r5)			
+
+;			
+;			Save the first 3 parameters if we are an SC (we will take care of the last later)
+;
+			bne+	cr1,sw64x1done				; Skip next if not an SC exception...	
+			stw		r12,return_params+0(r5)		; Save the first return
+			stw		r13,return_params+4(r5)		; Save the second return
+			stw		r14,return_params+8(r5)		; Save the third return
+			b		sw64x1done					; We are done with this section...
+
+sw64x1:		ld		r15,vmmppcXpc(r5)			; First line of context	
+			li		r0,1						; Get a 1 to turn on 64-bit
+			lis		r22,hi16(MSR_IMPORT_BITS)	; Get the MSR bits that are controllable by user (we will also allow 64-bit here)
+			sldi	r0,r0,63					; Get 64-bit bit
+			ld		r23,vmmppcXmsr(r5)				
+			ori		r22,r25,lo16(MSR_IMPORT_BITS)	; Get the rest of the MSR bits that are controllable by user
+			ld		r17,vmmppcXr0(r5)		
+			or		r22,r22,r0					; Add the 64-bit bit		
+			ld		r18,vmmppcXr1(r5)		
+			and		r23,r23,r22					; Keep only the controllable bits		
+			ld		r19,vmmppcXr2(r5)		
+			oris	r23,r23,hi16(MSR_EXPORT_MASK_SET)	; Force on the required bits
+			ld		r20,vmmppcXr3(r5)				
+			ori		r23,r23,lo16(MSR_EXPORT_MASK_SET)	; Force on the other required bits
+			ld		r21,vmmppcXr4(r5)				
+			ld		r22,vmmppcXr5(r5)				
+
+			dcbt	0,r6						; Touch third line of context area
+		
+			std		r7,vmmppcXpc(r5)			; Save emulator context into the context area	
+			std		r8,vmmppcXmsr(r5)				
+			std		r9,vmmppcXr0(r5)				
+			std		r10,vmmppcXr1(r5)				
+			std		r11,vmmppcXr2(r5)				
+			std		r12,vmmppcXr3(r5)				
+			std		r13,vmmppcXr4(r5)				
+			std		r14,vmmppcXr5(r5)			
+
+;			
+;			Save the first 3 parameters if we are an SC (we will take care of the last later)
+;
+			bne+	cr1,sw64x1done				; Skip next if not an SC exception...	
+			std		r12,return_paramsX+0(r5)	; Save the first return
+			std		r13,return_paramsX+8(r5)	; Save the second return
+			std		r14,return_paramsX+16(r5)	; Save the third return
+
+sw64x1done:	
+			std		r15,savesrr0(r30)			; Save vm context into the savearea	
+			std		r23,savesrr1(r30)				
+			std		r17,saver0(r30)				
+			std		r18,saver1(r30)		
+			std		r19,saver2(r30)		
+			std		r20,saver3(r30)				
+			std		r21,saver4(r30)		
+			la		r6,vmmppcr14(r5)			; Point to fourth line		
+			std		r22,saver5(r30)				
+			
+			dcbt	0,r6						; Touch fourth line
+
+;			Swap 8 registers
+			
+			ld		r7,saver6(r30)			; Read savearea	
+			ld		r8,saver7(r30)				
+			ld		r9,saver8(r30)				
+			ld		r10,saver9(r30)				
+			ld		r11,saver10(r30)				
+			ld		r12,saver11(r30)				
+			ld		r13,saver12(r30)				
+			ld		r14,saver13(r30)				
+			
+			bt		vmmDoing64,sw64x2			; Skip to 64-bit stuff
+
+			lwz		r15,vmmppcr6(r5)			; Read vm context 
+			lwz		r24,vmmppcr7(r5)				
+			lwz		r17,vmmppcr8(r5)				
+			lwz		r18,vmmppcr9(r5)		
+			lwz		r19,vmmppcr10(r5)		
+			lwz		r20,vmmppcr11(r5)				
+			lwz		r21,vmmppcr12(r5)				
+			lwz		r22,vmmppcr13(r5)				
+
+			stw		r7,vmmppcr6(r5)				; Write context	
+			stw		r8,vmmppcr7(r5)				
+			stw		r9,vmmppcr8(r5)				
+			stw		r10,vmmppcr9(r5)				
+			stw		r11,vmmppcr10(r5)				
+			stw		r12,vmmppcr11(r5)				
+			stw		r13,vmmppcr12(r5)	
+			la		r6,vmmppcr22(r5)			; Point to fifth line			
+			stw		r14,vmmppcr13(r5)				
+
+			dcbt	0,r6						; Touch fifth line
+			b		sw64x2done					; We are done with this section...
+
+sw64x2:		ld		r15,vmmppcXr6(r5)			; Read vm context 
+			ld		r24,vmmppcXr7(r5)				
+			ld		r17,vmmppcXr8(r5)				
+			ld		r18,vmmppcXr9(r5)		
+			ld		r19,vmmppcXr10(r5)		
+			ld		r20,vmmppcXr11(r5)				
+			ld		r21,vmmppcXr12(r5)				
+			ld		r22,vmmppcXr13(r5)				
+
+			std		r7,vmmppcXr6(r5)				; Write context	
+			std		r8,vmmppcXr7(r5)				
+			std		r9,vmmppcXr8(r5)				
+			std		r10,vmmppcXr9(r5)				
+			std		r11,vmmppcXr10(r5)				
+			std		r12,vmmppcXr11(r5)				
+			std		r13,vmmppcXr12(r5)	
+			la		r6,vmmppcXr22(r5)			; Point to fifth line			
+			std		r14,vmmppcXr13(r5)				
+
+			dcbt	0,r6						; Touch fifth line
+
+sw64x2done:	std		r15,saver6(r30)			; Write vm context 
+			std		r24,saver7(r30)				
+			std		r17,saver8(r30)				
+			std		r18,saver9(r30)		
+			std		r19,saver10(r30)		
+			std		r20,saver11(r30)				
+			std		r21,saver12(r30)				
+			std		r22,saver13(r30)				
+
+;			Swap 8 registers
+			
+			ld		r7,saver14(r30)			; Read savearea	
+			ld		r8,saver15(r30)				
+			ld		r9,saver16(r30)				
+			ld		r10,saver17(r30)				
+			ld		r11,saver18(r30)				
+			ld		r12,saver19(r30)				
+			ld		r13,saver20(r30)				
+			ld		r14,saver21(r30)				
+
+			bt		vmmDoing64,sw64x3			; Skip to 64-bit stuff
+
+			lwz		r15,vmmppcr14(r5)			; Read vm context 
+			lwz		r24,vmmppcr15(r5)				
+			lwz		r17,vmmppcr16(r5)				
+			lwz		r18,vmmppcr17(r5)		
+			lwz		r19,vmmppcr18(r5)		
+			lwz		r20,vmmppcr19(r5)				
+			lwz		r21,vmmppcr20(r5)				
+			lwz		r22,vmmppcr21(r5)				
+
+			stw		r7,vmmppcr14(r5)			; Write context	
+			stw		r8,vmmppcr15(r5)				
+			stw		r9,vmmppcr16(r5)				
+			stw		r10,vmmppcr17(r5)				
+			stw		r11,vmmppcr18(r5)				
+			stw		r12,vmmppcr19(r5)				
+			stw		r13,vmmppcr20(r5)
+			la		r6,vmmppcr30(r5)			; Point to sixth line				
+			stw		r14,vmmppcr21(r5)				
+			
+			dcbt	0,r6						; Touch sixth line
+			b		sw64x3done					; Done with this section...
+
+sw64x3:		ld		r15,vmmppcXr14(r5)			; Read vm context 
+			ld		r24,vmmppcXr15(r5)				
+			ld		r17,vmmppcXr16(r5)				
+			ld		r18,vmmppcXr17(r5)		
+			ld		r19,vmmppcXr18(r5)		
+			ld		r20,vmmppcXr19(r5)				
+			ld		r21,vmmppcXr20(r5)				
+			ld		r22,vmmppcXr21(r5)				
+
+			std		r7,vmmppcXr14(r5)			; Write context	
+			std		r8,vmmppcXr15(r5)				
+			std		r9,vmmppcXr16(r5)				
+			std		r10,vmmppcXr17(r5)				
+			std		r11,vmmppcXr18(r5)				
+			std		r12,vmmppcXr19(r5)				
+			std		r13,vmmppcXr20(r5)
+			la		r6,vmmppcXr30(r5)			; Point to sixth line				
+			std		r14,vmmppcXr21(r5)				
+			
+			dcbt	0,r6						; Touch sixth line
+
+sw64x3done:	std		r15,saver14(r30)			; Write vm context 
+			std		r24,saver15(r30)				
+			std		r17,saver16(r30)				
+			std		r18,saver17(r30)		
+			std		r19,saver18(r30)		
+			std		r20,saver19(r30)				
+			std		r21,saver20(r30)				
+			std		r22,saver21(r30)				
+
+;			Swap 8 registers
+			
+			ld		r7,saver22(r30)			; Read savearea	
+			ld		r8,saver23(r30)				
+			ld		r9,saver24(r30)				
+			ld		r10,saver25(r30)				
+			ld		r11,saver26(r30)				
+			ld		r12,saver27(r30)				
+			ld		r13,saver28(r30)				
+			ld		r14,saver29(r30)				
+
+			bt		vmmDoing64,sw64x4			; Skip to 64-bit stuff
+
+			lwz		r15,vmmppcr22(r5)			; Read vm context 
+			lwz		r24,vmmppcr23(r5)				
+			lwz		r17,vmmppcr24(r5)				
+			lwz		r18,vmmppcr25(r5)		
+			lwz		r19,vmmppcr26(r5)		
+			lwz		r20,vmmppcr27(r5)				
+			lwz		r21,vmmppcr28(r5)				
+			lwz		r22,vmmppcr29(r5)				
+
+			stw		r7,vmmppcr22(r5)			; Write context	
+			stw		r8,vmmppcr23(r5)				
+			stw		r9,vmmppcr24(r5)				
+			stw		r10,vmmppcr25(r5)				
+			stw		r11,vmmppcr26(r5)				
+			stw		r12,vmmppcr27(r5)				
+			stw		r13,vmmppcr28(r5)	
+			la		r6,vmmppcvscr(r5)			; Point to seventh line			
+			stw		r14,vmmppcr29(r5)				
+			dcbt	0,r6						; Touch seventh line
+			b		sw64x4done					; Done with this section...
+			
+sw64x4:		ld		r15,vmmppcXr22(r5)			; Read vm context 
+			ld		r24,vmmppcXr23(r5)				
+			ld		r17,vmmppcXr24(r5)				
+			ld		r18,vmmppcXr25(r5)		
+			ld		r19,vmmppcXr26(r5)		
+			ld		r20,vmmppcXr27(r5)				
+			ld		r21,vmmppcXr28(r5)				
+			ld		r22,vmmppcXr29(r5)				
+
+			std		r7,vmmppcXr22(r5)			; Write context	
+			std		r8,vmmppcXr23(r5)				
+			std		r9,vmmppcXr24(r5)				
+			std		r10,vmmppcXr25(r5)				
+			std		r11,vmmppcXr26(r5)				
+			std		r12,vmmppcXr27(r5)				
+			std		r13,vmmppcXr28(r5)	
+			la		r6,vmmppcvscr(r5)			; Point to seventh line			
+			std		r14,vmmppcXr29(r5)				
+
+			dcbt	0,r6						; Touch seventh line
+
+sw64x4done:	std		r15,saver22(r30)			; Write vm context 
+			std		r24,saver23(r30)				
+			std		r17,saver24(r30)				
+			std		r18,saver25(r30)		
+			std		r19,saver26(r30)		
+			std		r20,saver27(r30)				
+			std		r21,saver28(r30)				
+			std		r22,saver29(r30)				
+
+;			Swap 8 registers
+			
+			ld		r7,saver30(r30)			; Read savearea	
+			ld		r8,saver31(r30)				
+			lwz		r9,savecr(r30)				
+			ld		r10,savexer(r30)				
+			ld		r11,savelr(r30)				
+			ld		r12,savectr(r30)				
+			lwz		r14,savevrsave(r30)				
+
+			bt		vmmDoing64,sw64x5			; Skip to 64-bit stuff
+
+			lwz		r15,vmmppcr30(r5)			; Read vm context 
+			lwz		r24,vmmppcr31(r5)				
+			lwz		r17,vmmppccr(r5)				
+			lwz		r18,vmmppcxer(r5)		
+			lwz		r19,vmmppclr(r5)		
+			lwz		r20,vmmppcctr(r5)				
+			lwz		r22,vmmppcvrsave(r5)				
+
+			stw		r7,vmmppcr30(r5)			; Write context	
+			stw		r8,vmmppcr31(r5)				
+			stw		r9,vmmppccr(r5)				
+			stw		r10,vmmppcxer(r5)				
+			stw		r11,vmmppclr(r5)				
+			stw		r12,vmmppcctr(r5)				
+			stw		r14,vmmppcvrsave(r5)	
+			b		sw64x5done					; Done here...		
+
+sw64x5:		ld		r15,vmmppcXr30(r5)			; Read vm context 
+			ld		r24,vmmppcXr31(r5)				
+			lwz		r17,vmmppcXcr(r5)				
+			ld		r18,vmmppcXxer(r5)		
+			ld		r19,vmmppcXlr(r5)		
+			ld		r20,vmmppcXctr(r5)				
+			lwz		r22,vmmppcXvrsave(r5)				
+
+			std		r7,vmmppcXr30(r5)			; Write context	
+			std		r8,vmmppcXr31(r5)				
+			stw		r9,vmmppcXcr(r5)				
+			std		r10,vmmppcXxer(r5)				
+			std		r11,vmmppcXlr(r5)				
+			std		r12,vmmppcXctr(r5)				
+			stw		r14,vmmppcXvrsave(r5)				
+
+sw64x5done:	std		r15,saver30(r30)			; Write vm context 
+			std		r24,saver31(r30)				
+			stw		r17,savecr(r30)				
+			std		r18,savexer(r30)		
+			std		r19,savelr(r30)		
+			std		r20,savectr(r30)				
+			stw		r22,savevrsave(r30)				
+
+;			Swap 8 registers
+			
+			lwz		r7,savevscr+0(r30)			; Read savearea	
+			lwz		r8,savevscr+4(r30)				
+			lwz		r9,savevscr+8(r30)				
+			lwz		r10,savevscr+12(r30)				
+			lwz		r11,savefpscrpad(r30)				
+			lwz		r12,savefpscr(r30)				
+
+			lwz		r15,vmmppcvscr+0(r5)		; Read vm context 
+			lwz		r24,vmmppcvscr+4(r5)				
+			lwz		r17,vmmppcvscr+8(r5)				
+			lwz		r18,vmmppcvscr+12(r5)		
+			lwz		r19,vmmppcfpscrpad(r5)		
+			lwz		r20,vmmppcfpscr(r5)				
+
+			stw		r7,vmmppcvscr+0(r5)			; Write context	
+			stw		r8,vmmppcvscr+4(r5)				
+			stw		r9,vmmppcvscr+8(r5)				
+			stw		r10,vmmppcvscr+12(r5)				
+			stw		r11,vmmppcfpscrpad(r5)				
+			stw		r12,vmmppcfpscr(r5)				
+
+			stw		r15,savevscr+0(r30)			; Write vm context 
+			stw		r24,savevscr+4(r30)				
+			stw		r17,savevscr+8(r30)				
+			stw		r18,savevscr+12(r30)		
+			stw		r19,savefpscrpad(r30)		
+			stw		r20,savefpscr(r30)				
+
+			
+;
+;			Cobble up the exception return code and save any specific return values
+;
+			
+			lwz		r7,saveexception(r30)		; Pick up the exception code
+			rlwinm	r8,r7,30,24,31				; Convert exception to return code
+			cmplwi	r7,T_DATA_ACCESS			; Was this a DSI?
+			stw		r8,return_code(r5)			; Save the exit code
+			cmplwi	cr1,r7,T_INSTRUCTION_ACCESS	; Exiting because of an ISI?
+			beq+	swapDSI64					; Yeah...
+			cmplwi	r7,T_ALIGNMENT				; Alignment exception?
+			beq+	cr1,swapISI64				; We had an ISI...
+			cmplwi	cr1,r7,T_SYSTEM_CALL		; Exiting because of an system call?
+			beq+	swapDSI64					; An alignment exception looks like a DSI...
+			beq+	cr1,swapSC64				; We had a system call...
+			
+			blr									; Return...
+
+;
+;			Set exit returns for a DSI or alignment exception
+;
+
+swapDSI64:	ld		r10,savedar(r30)			; Get the DAR
+			lwz		r7,savedsisr(r30)			; and the DSISR
+			bt		vmmDoing64,sw64DSI			; Skip to 64-bit stuff...
+
+
+			stw		r10,return_params+0(r5)		; Save DAR as first return parm
+			stw		r7,return_params+4(r5)		; Save DSISR as second return parm
+			blr									; Return...
+
+sw64DSI:	std		r10,return_paramsX+0(r5)	; Save DAR as first return parm
+			std		r7,return_paramsX+8(r5)		; Save DSISR as second return parm (note that this is expanded to 64 bits)
+			blr									; Return...
+
+;
+;			Set exit returns for a ISI
+;
+
+swapISI64:	bt		vmmDoing64,sw64ISI			; Skip to 64-bit stuff...
+			lwz		r7,vmmppcmsr(r5)			; Get the SRR1 value
+			lwz		r10,vmmppcpc(r5)			; Get the PC as failing address
+			rlwinm	r7,r7,0,1,4					; Save the bits that match the DSISR
+			stw		r10,return_params+0(r5)		; Save PC as first return parm
+			stw		r7,return_params+4(r5)		; Save the pseudo-DSISR as second return parm
+			blr									; Return...
+
+sw64ISI:	ld		r7,vmmppcXmsr(r5)			; Get the SRR1 value
+			ld		r10,vmmppcXpc(r5)			; Get the PC as failing address
+			rlwinm	r7,r7,0,1,4					; Save the bits that match the DSISR
+			std		r10,return_paramsX+0(r5)		; Save PC as first return parm
+			std		r7,return_paramsX+8(r5)		; Save the pseudo-DSISR as second return parm
+			blr									; Return...
+
+;
+;			Set exit returns for a system call (note: we did the first 3 earlier)
+;			Do we really need to pass parameters back here????
+;
+
+swapSC64:	bt		vmmDoing64,sw64SC			; Skip to 64-bit stuff...
+			lwz		r10,vmmppcr6(r5)			; Get the fourth paramter
+			stw		r10,return_params+12(r5)	; Save it
+			blr									; Return...
+
+sw64SC:		ld		r10,vmmppcXr6(r5)			; Get the fourth paramter
+			std		r10,return_paramsX+24(r5)	; Save it
+			blr									; Return...
+
+;
+;			vmmFamGuestResume:
+;				Restore Guest context from Fam mode.
+;
+
+vmmFamGuestResume:
+			mfsprg	r10,0							; Get the per_proc
+			lwz		r27,vmmCEntry(r3)				; Get the context that is active
+			lwz		r4,VMMXAFlgs(r10)				; Get the eXtended Architecture flags			
+			rlwinm.	r4,r4,0,0,0						; Are we doing a 64-bit virtual machine?		
+			lwz		r15,spcFlags(r10)				; Get per_proc special flags
+			mr		r26,r3							; Save the activation pointer
+			lwz		r20,vmmContextKern(r27)			; Get the comm area
+			rlwinm	r15,r15,0,FamVMmodebit+1,FamVMmodebit-1	; Clear FamVMmodebit
+			stw		r15,spcFlags(r10)				; Update the special flags
+			bne		fgrX
+			lwz		r7,famguestpc(r20)				; Load famguest ctx pc
+			bf++	vmmMapDone,fgrNoMap				; No mapping done for this space.
+			lwz		r3,SAVflags(r30)				; Pick up the savearea flags
+			lwz		r2,vmmLastMap(r28)				; Get the last mapped address
+			lwz		r6,vmmLastMap+4(r28)			; Get the last mapped address
+			li		r4,T_DATA_ACCESS				; Change to DSI fault
+			oris	r3,r3,hi16(SAVredrive)			; Set exception redrive
+			stw		r2,savedar(r30)					; Set the DAR to the last thing we mapped
+			stw		r6,savedar+4(r30)				; Set the DAR to the last thing we mapped
+			stw		r3,SAVflags(r30)				; Turn on the redrive request
+			lis		r2,hi16(MASK(DSISR_HASH))		; Set PTE/DBAT miss
+			stw		r4,saveexception(r30)			; Say we need to emulate a DSI
+			li		r0,0							; Clear
+			stw		r2,savedsisr(r30)				; Pretend we have a PTE miss
+			stb		r0,vmmGFlags+3(r28)				; Show that the redrive has been taken care of
+fgrNoMap:
+			lwz		r4,savesrr1+4(r30)				; Get the saved MSR value
+			stw		r7,savesrr0+4(r30)				; Set savearea pc
+			lwz		r5,famguestmsr(r20)				; Load famguest ctx msr
+			lis		r6,hi16(MSR_IMPORT_BITS)		; Get the MSR bits that are controllable by user
+			ori		r6,r6,lo16(MSR_IMPORT_BITS)		; Get the rest of the MSR bits that are controllable by user
+			and		r5,r5,r6						; Keep only the controllable bits
+			oris	r5,r5,hi16(MSR_EXPORT_MASK_SET)	; Force on the required bits
+			ori		r5,r5,lo16(MSR_EXPORT_MASK_SET)	; Force on the other required bits
+			rlwimi	r5,r4,0,MSR_FP_BIT,MSR_FP_BIT	; Propagate guest FP
+			rlwimi	r5,r4,0,MSR_VEC_BIT,MSR_VEC_BIT	; Propagate guest Vector	
+			stw		r5,savesrr1+4(r30)				; Set savearea srr1
+			lwz		r4,famguestr0(r20)				; Load famguest ctx r0
+			lwz		r5,famguestr1(r20)				; Load famguest ctx r1
+			lwz		r6,famguestr2(r20)				; Load famguest ctx r2
+			lwz		r7,famguestr3(r20)				; Load famguest ctx r3
+			stw		r4,saver0+4(r30)				; Set savearea r0
+			stw		r5,saver1+4(r30)				; Set savearea r1
+			stw		r6,saver2+4(r30)				; Set savearea r2
+			stw		r7,saver3+4(r30)				; Set savearea r3
+			lwz		r4,famguestr4(r20)				; Load famguest ctx r4
+			lwz		r5,famguestr5(r20)				; Load famguest ctx r5
+			lwz		r6,famguestr6(r20)				; Load famguest ctx r6
+			lwz		r7,famguestr7(r20)				; Load famguest ctx r7
+			stw		r4,saver4+4(r30)				; Set savearea r4
+			stw		r5,saver5+4(r30)				; Set savearea r5
+			stw		r6,saver6+4(r30)				; Set savearea r6
+			stw		r7,saver7+4(r30)				; Set savearea r7
+			b		fgrret
+fgrX:
+			ld		r7,famguestXpc(r20)				; Load famguest ctx pc
+			bf++	vmmMapDone,fgrXNoMap			; No mapping done for this space.
+			lwz		r3,SAVflags(r30)				; Pick up the savearea flags
+			ld		r2,vmmLastMap(r28)				; Get the last mapped address
+			li		r4,T_DATA_ACCESS				; Change to DSI fault
+			oris	r3,r3,hi16(SAVredrive)			; Set exception redrive
+			std		r2,savedar(r30)					; Set the DAR to the last thing we mapped
+			stw		r3,SAVflags(r30)				; Turn on the redrive request
+			lis		r2,hi16(MASK(DSISR_HASH))		; Set PTE/DBAT miss
+			stw		r4,saveexception(r30)			; Say we need to emulate a DSI
+			li		r0,0							; Clear
+			stw		r2,savedsisr(r30)				; Pretend we have a PTE miss
+			stb		r0,vmmGFlags+3(r28)				; Show that the redrive has been taken care of
+fgrXNoMap:
+			ld		r4,savesrr1(r30)				; Get the saved MSR value
+			std		r7,savesrr0(r30)				; Set savearea pc
+			ld		r5,famguestXmsr(r20)			; Load famguest ctx msr
+			lis		r6,hi16(MSR_IMPORT_BITS)		; Get the MSR bits that are controllable by user
+			ori		r6,r6,lo16(MSR_IMPORT_BITS)		; Get the rest of the MSR bits that are controllable by user
+			and		r5,r5,r6						; Keep only the controllable bits
+			oris	r5,r5,hi16(MSR_EXPORT_MASK_SET)	; Force on the required bits
+			ori		r5,r5,lo16(MSR_EXPORT_MASK_SET)	; Force on the other required bits
+			rlwimi	r5,r4,0,MSR_FP_BIT,MSR_FP_BIT	; Propagate guest FP
+			rlwimi	r5,r4,0,MSR_VEC_BIT,MSR_VEC_BIT	; Propagate guest Vector	
+			std		r5,savesrr1(r30)				; Set savearea srr1
+			ld		r4,famguestXr0(r20)				; Load famguest ctx r0
+			ld		r5,famguestXr1(r20)				; Load famguest ctx r1
+			ld		r6,famguestXr2(r20)				; Load famguest ctx r2
+			ld		r7,famguestXr3(r20)				; Load famguest ctx r3
+			std		r4,saver0(r30)					; Set savearea r0
+			std		r5,saver1(r30)					; Set savearea r1
+			std		r6,saver2(r30)					; Set savearea r2
+			std		r7,saver3(r30)					; Set savearea r3
+			ld		r4,famguestXr4(r20)				; Load famguest ctx r4
+			ld		r5,famguestXr5(r20)				; Load famguest ctx r5
+			ld		r6,famguestXr6(r20)				; Load famguest ctx r6
+			ld		r7,famguestXr7(r20)				; Load famguest ctx r7
+			std		r4,saver4(r30)					; Set savearea r4
+			std		r5,saver5(r30)					; Set savearea r5
+			std		r6,saver6(r30)					; Set savearea r6
+			std		r7,saver7(r30)					; Set savearea r7
+fgrret:
+			li		r3,1							; Show normal exit with check for AST
+			lwz		r16,ACT_THREAD(r26)				; Restore the thread pointer
+			b		EXT(ppcscret)					; Go back to handler...
+
+;
+;			FAM Intercept exception handler
+;
+
+			.align	5
+			.globl	EXT(vmm_fam_exc)
+
+LEXT(vmm_fam_exc)
+			lwz		r4,VMMXAFlgs(r2)				; Get the eXtended Architecture flags			
+			lwz		r1,pfAvailable(r2)				; Get the CPU features flags
+			rlwinm.	r4,r4,0,0,0						; Are we doing a 64-bit virtual machine?		
+			bne		fexcX
+			lwz		r4,saver4+4(r13)				; Load savearea r4
+			cmplwi	r11,T_ALIGNMENT					; Alignment exception?
+			lwz		r3,VMMareaPhys(r2)				; Load phys state page addr
+			mtcrf   0x02,r1							; Move pf64Bit to its normal place in CR6
+			cmplwi	cr1,r11,T_PROGRAM				; Exiting because of an PRG?
+            bt++    pf64Bitb,fexcVMareaPhys64		; Go do this on a 64-bit machine...
+			slwi	r3,r3,12						; Change ppnum to physical address
+			b		fexcVMareaPhysres
+fexcVMareaPhys64:
+			mtxer	r5								; Restore xer
+			lwz		r5,saver5+4(r13)				; Load savearea r5
+			lwz		r6,saver6+4(r13)				; Load savearea r6
+			sldi	r3,r3,12						; Change ppnum to physical address
+fexcVMareaPhysres:
+			stw		r4,famguestr4(r3)				; Save r4 in famguest ctx
+			stw		r5,famguestr5(r3)				; Save r5 in famguest ctx
+			stw		r6,famguestr6(r3)				; Save r6 in famguest ctx
+			stw		r7,famguestr7(r3)				; Save r7 in famguest ctx
+			lwz		r4,saver0+4(r13)				; Load savearea r0
+			lwz		r5,saver1+4(r13)				; Load savearea r1
+			lwz		r6,saver2+4(r13)				; Load savearea r2
+			lwz		r7,saver3+4(r13)				; Load savearea r3
+			stw		r4,famguestr0(r3)				; Save r0 in famguest ctx
+			stw		r5,famguestr1(r3)				; Save r1 in famguest ctx
+			stw		r6,famguestr2(r3)				; Save r2 in famguest ctx
+			stw		r7,famguestr3(r3)				; Save r3 in famguest ctx
+			lwz		r4,spcFlags(r2)					; Load per_proc spcFlags
+			oris	r4,r4,hi16(FamVMmode)			; Set FAM mode
+			stw		r4,spcFlags(r2)					; Update per_proc spcFlags
+			mfsrr0  r2								; Get the interrupt srr0
+			mfsrr1  r4								; Get the interrupt srr1
+			stw		r2,famguestpc(r3)				; Save srr0 in famguest ctx
+			stw		r4,famguestmsr(r3)				; Save srr1 in famguest ctx
+			li		r6,lo16(MASK(MSR_FE0)|MASK(MSR_SE)|MASK(MSR_BE)|MASK(MSR_FE1))
+			andc	r6,r4,r6						; Clear SE BE FE0 FE1
+			mtsrr1	r6								; Set srr1
+			mr		r6,r3							; Set r6 with  phys state page addr
+			rlwinm	r7,r11,30,24,31					; Convert exception to return code
+			beq+	cr1,fexcPRG						; We had a program exception...
+			bne+	fexcret	
+													; We had an Alignment...
+			mfdar	r3								; Load dar
+			mfdsisr	r4								; Load dsisr
+			stw		r3,famparam+0x4(r6)				; Set famparam 1 with dar
+			stw		r4,famparam+0x8(r6)				; Set famparam 2 with dsir
+			b		fexcret							;
+fexcPRG:
+			stw		r4,famparam+0x4(r6)				; Set famparam 1 with srr1
+			mr		r3,r4							; Set r3 with dsisr
+			lwz		r4,famguestr4(r6)				; Load r4 from famguest context
+fexcret:
+			lwz		r5,famguestr5(r6)				; Load r5 from famguest context
+			lwz		r13,famhandler(r6)				; Load user address to resume
+			stw		r2,famparam(r6)					; Set famparam 0 with srr0
+			stw		r7,famdispcode(r6)				; Save the exit code
+			lwz		r1,famrefcon(r6)				; load refcon
+            bt++    pf64Bitb,fexcrfi64				; Go do this on a 64-bit machine...
+			mtcr	r0								; Restore cr
+			mtsrr0	r13								; Load srr0
+			mr		r0,r7							; Set dispatch code
+			lwz		r7,famguestr7(r6)				; Load r7 from famguest context
+			lwz		r6,famguestr6(r6)				; Load r6 from famguest context
+			mfsprg	r13,2							; Restore r13
+			mfsprg  r11,3							; Restore r11
+			rfi
+fexcrfi64:
+			mtcr	r0								; Restore cr
+			mtsrr0	r13								; Load srr0
+			mr		r0,r7							; Set dispatch code
+			lwz		r7,famguestr7(r6)				; Load r7 from famguest context
+			lwz		r6,famguestr6(r6)				; Load r6 from famguest context
+			mfsprg	r13,2							; Restore r13
+			mfsprg  r11,3							; Restore r11
+			rfid
+fexcX:
+			mtxer	r5								; Restore xer
+			ld		r4,saver4(r13)					; Load savearea r4
+			ld		r5,saver5(r13)					; Load savearea r5
+			ld		r6,saver6(r13)					; Load savearea r6
+			cmplwi	r11,T_ALIGNMENT					; Alignment exception?
+			lwz		r3,VMMareaPhys(r2)				; Load phys state page addr
+			mtcrf   0x02,r1							; Move pf64Bit to its normal place in CR6
+			cmplwi	cr1,r11,T_PROGRAM				; Exiting because of an PRG?
+			sldi	r3,r3,12						; Change ppnum to physical address
+			std		r4,famguestXr4(r3)				; Save r4 in famguest ctx
+			std		r5,famguestXr5(r3)				; Save r5 in famguest ctx
+			std		r6,famguestXr6(r3)				; Save r6 in famguest ctx
+			std		r7,famguestXr7(r3)				; Save r7 in famguest ctx
+			ld		r4,saver0(r13)					; Load savearea r0
+			ld		r5,saver1(r13)					; Load savearea r1
+			ld		r6,saver2(r13)					; Load savearea r2
+			ld		r7,saver3(r13)					; Load savearea r3
+			std		r4,famguestXr0(r3)				; Save r0 in famguest ctx
+			std		r5,famguestXr1(r3)				; Save r1 in famguest ctx
+			std		r6,famguestXr2(r3)				; Save r2 in famguest ctx
+			std		r7,famguestXr3(r3)				; Save r3 in famguest ctx
+			lwz		r4,spcFlags(r2)					; Load per_proc spcFlags
+			oris	r4,r4,hi16(FamVMmode)			; Set FAM mode
+			stw		r4,spcFlags(r2)					; Update per_proc spcFlags
+			mfsrr0  r2								; Get the interrupt srr0
+			mfsrr1  r4								; Get the interrupt srr1
+			std		r2,famguestXpc(r3)				; Save srr0 in famguest ctx
+			std		r4,famguestXmsr(r3)				; Save srr1 in famguest ctx
+			li		r6,lo16(MASK(MSR_FE0)|MASK(MSR_SE)|MASK(MSR_BE)|MASK(MSR_FE1))
+			andc	r6,r4,r6						; Clear SE BE FE0 FE1
+			mtsrr1	r6								; Set srr1
+			mr		r6,r3							; Set r6 with  phys state page addr
+			rlwinm	r7,r11,30,24,31					; Convert exception to return code
+			beq+	cr1,fexcXPRG					; We had a program exception...
+			bne+	fexcXret	
+													; We had an Alignment...
+			mfdar	r3								; Load dar
+			mfdsisr	r4								; Load dsisr
+			std		r3,famparamX+0x8(r6)			; Set famparam 1 with dar
+			std		r4,famparamX+0x10(r6)			; Set famparam 2 with dsir
+			b		fexcXret
+fexcXPRG:
+			std		r4,famparamX+0x8(r6)			; Set famparam 1 with srr1
+			mr		r3,r4							; Set r3 with dsisr
+			ld		r4,famguestXr4(r6)				; Load r4 from famguest context
+fexcXret:
+			ld		r5,famguestXr5(r6)				; Load r5 from famguest context
+			ld		r13,famhandlerX(r6)				; Load user address to resume
+			std		r2,famparamX(r6)				; Set famparam 0 with srr0
+			std		r7,famdispcodeX(r6)				; Save the exit code
+			ld		r1,famrefconX(r6)				; load refcon
+			mtcr	r0								; Restore cr
+			mtsrr0	r13								; Load srr0
+			mr		r0,r7							; Set dispatch code
+			ld		r7,famguestXr7(r6)				; Load r7 from famguest context
+			ld		r6,famguestXr6(r6)				; Load r6 from famguest context
+			mfsprg	r13,2							; Restore r13
+			mfsprg  r11,3							; Restore r11
+			rfid
+
+;
+;			FAM Intercept DSI ISI fault handler
+;
+
+			.align	5
+			.globl	EXT(vmm_fam_pf)
+
+LEXT(vmm_fam_pf)
+			lwz		r4,VMMXAFlgs(r2)				; Get the eXtended Architecture flags			
+			lwz		r3,VMMareaPhys(r2)				; Load phys state page addr
+			rlwinm.	r4,r4,0,0,0						; Are we doing a 64-bit virtual machine?		
+			bne		fpfX
+			lwz		r4,saver0+4(r13)				; Load savearea r0
+			lwz		r5,saver1+4(r13)				; Load savearea r1
+			lwz		r6,saver2+4(r13)				; Load savearea r2
+			lwz		r7,saver3+4(r13)				; Load savearea r3
+            bt++    pf64Bitb,fpfVMareaPhys64		; Go do this on a 64-bit machine...
+			slwi	r3,r3,12						; Change ppnum to physical address
+			b		fpfVMareaPhysret
+fpfVMareaPhys64:
+			sldi	r3,r3,12						; Change ppnum to physical address
+fpfVMareaPhysret:
+			stw		r4,famguestr0(r3)				; Save r0 in famguest
+			stw		r5,famguestr1(r3)				; Save r1 in famguest
+			stw		r6,famguestr2(r3)				; Save r2 in famguest
+			stw		r7,famguestr3(r3)				; Save r3 in famguest
+			lwz		r4,saver4+4(r13)				; Load savearea r0
+			lwz		r5,saver5+4(r13)				; Load savearea r1
+			lwz		r6,saver6+4(r13)				; Load savearea r2
+			lwz		r7,saver7+4(r13)				; Load savearea r3
+			stw		r4,famguestr4(r3)				; Save r4 in famguest
+			lwz		r4,spcFlags(r2)					; Load spcFlags
+			stw		r5,famguestr5(r3)				; Save r5 in famguest
+			lwz		r5,savesrr0+4(r13)				; Get the interrupt srr0
+			stw		r6,famguestr6(r3)				; Save r6 in famguest
+			lwz		r6,savesrr1+4(r13)				; Load srr1
+			oris	r4,r4,hi16(FamVMmode)			; Set FAM mode
+			stw		r7,famguestr7(r3)				; Save r7 in famguest
+			stw		r4,spcFlags(r2)					; Update spcFlags
+			lwz		r1,famrefcon(r3)				; Load refcon
+			lwz		r2,famhandler(r3)				; Load famhandler to resume
+			stw		r5,famguestpc(r3)				; Save srr0
+			stw		r5,saver2+4(r13)				; Store srr0 in savearea r2
+			stw		r5,famparam(r3)					; Store srr0 in fam param 0
+			stw		r6,famguestmsr(r3)				; Save srr1 in famguestmsr
+			cmplwi	cr1,r11,T_INSTRUCTION_ACCESS	; Was this a ISI?
+			rlwinm	r7,r11,30,24,31					; Convert exception to return code
+			beq+	cr1,fpfISI						; We had an ISI...
+; fpfDSI
+			lwz		r6,savedar+4(r13)				; Load dar from savearea
+			lwz		r4,savedsisr(r13)				; Load dsisr from savearea
+			stw		r6,famparam+0x4(r3)				; Store dar in fam param 1
+			stw		r6,saver3+4(r13)				; Store dar in savearea r3
+			stw		r4,famparam+0x8(r3)				; Store dsisr in fam param 2
+			stw		r4,saver4+4(r13)				; Store dsisr in savearea r4
+			b		fpfret
+fpfISI:	
+			rlwinm	r6,r6,0,1,4						; Save the bits that match the DSISR
+			stw		r6,famparam+0x4(r3)				; Store srr1 in fam param 1 
+			stw		r6,saver3+4(r13)				; Store srr1 in savearea r3
+fpfret:
+			stw		r7,saver0+4(r13)				; Set dispatch code
+			stw		r7,famdispcode(r3)				; Set dispatch code
+			stw		r1,saver1+4(r13)				; Store refcon in savearea r1
+			stw		r2,savesrr0+4(r13)				; Store famhandler in srr0
+			blr
+fpfX:
+			ld		r4,saver0(r13)					; Load savearea r0
+			ld		r5,saver1(r13)					; Load savearea r1
+			ld		r6,saver2(r13)					; Load savearea r2
+			ld		r7,saver3(r13)					; Load savearea r3
+			sldi	r3,r3,12						; Change ppnum to physical address
+			std		r4,famguestXr0(r3)				; Save r0 in famguest
+			std		r5,famguestXr1(r3)				; Save r1 in famguest
+			std		r6,famguestXr2(r3)				; Save r2 in famguest
+			std		r7,famguestXr3(r3)				; Save r3 in famguest
+			ld		r4,saver4(r13)					; Load savearea r0
+			ld		r5,saver5(r13)					; Load savearea r1
+			ld		r6,saver6(r13)					; Load savearea r2
+			ld		r7,saver7(r13)					; Load savearea r3
+			std		r4,famguestXr4(r3)				; Save r4 in famguest
+			lwz		r4,spcFlags(r2)					; Load spcFlags
+			std		r5,famguestXr5(r3)				; Save r5 in famguest
+			ld		r5,savesrr0(r13)				; Get the interrupt srr0
+			std		r6,famguestXr6(r3)				; Save r6 in famguest
+			ld		r6,savesrr1(r13)				; Load srr1
+			oris	r4,r4,hi16(FamVMmode)			; Set FAM mode
+			std		r7,famguestXr7(r3)				; Save r7 in famguest
+			stw		r4,spcFlags(r2)					; Update spcFlags
+			ld		r1,famrefconX(r3)				; Load refcon
+			ld		r2,famhandlerX(r3)				; Load famhandler to resume
+			std		r5,famguestXpc(r3)				; Save srr0
+			std		r5,saver2(r13)					; Store srr0 in savearea r2
+			std		r5,famparamX(r3)				; Store srr0 in fam param 0
+			std		r6,famguestXmsr(r3)				; Save srr1 in famguestmsr
+			cmplwi	cr1,r11,T_INSTRUCTION_ACCESS	; Was this a ISI?
+			rlwinm	r7,r11,30,24,31					; Convert exception to return code
+			beq+	cr1,fpfXISI						; We had an ISI...
+; fpfXDSI
+			ld		r6,savedar(r13)					; Load dar from savearea
+			lwz		r4,savedsisr(r13)				; Load dsisr from savearea
+			std		r6,famparamX+0x8(r3)			; Store dar in fam param 1
+			std		r6,saver3(r13)					; Store dar in savearea r3
+			std		r4,famparamX+0x10(r3)				; Store dsisr in fam param 2
+			std		r4,saver4(r13)					; Store dsisr in savearea r4
+			b		fpfXret
+fpfXISI:	
+			rlwinm	r6,r6,0,1,4						; Save the bits that match the DSISR
+			std		r6,famparamX+0x8(r3)			; Store srr1 in fam param 1 
+			std		r6,saver3(r13)					; Store srr1 in savearea r3
+fpfXret:
+			std		r7,saver0(r13)					; Set dispatch code
+			std		r7,famdispcodeX(r3)				; Set dispatch code
+			std		r1,saver1(r13)					; Store refcon in savearea r1
+			std		r2,savesrr0(r13)				; Store famhandler in srr0
+			blr
+
+;
+;			Ultra Fast Path FAM syscalls
+;
+
+			.align	5
+			.globl	EXT(vmm_ufp)
+
+LEXT(vmm_ufp)
+			mfsprg	r3,0							; Get the per_proc area
+			mr		r11,r13							; Saved cr in r11
+			lwz		r13,VMMXAFlgs(r3)				; Get the eXtended Architecture flags			
+			rlwinm.	r13,r13,0,0,0						; Are we doing a 64-bit virtual machine?		
+			lwz		r13,pfAvailable(r3)				; Get feature flags
+			mtcrf	0x02,r13						; Put pf64Bitb etc in cr6
+			lwz		r13,VMMareaPhys(r3)				; Load fast assist area
+            bt++    pf64Bitb,ufpVMareaPhys64		; Go do this on a 64-bit machine...
+			slwi	r13,r13,12						; Change ppnum to physical address
+			b		ufpVMareaPhysret
+ufpVMareaPhys64:
+			sldi	r13,r13,12						; Change ppnum to physical address
+ufpVMareaPhysret:
+			bne		ufpX
+			bt		cr5_eq,ufpResumeGuest			; if kvmmResumeGuest, branch to ResumeGuest
+			cmpwi	cr7,r4,0						; Compare first arg with 0
+			cmpwi	cr5,r4,7						; Compare first arg with 7
+			cror	cr1_eq,cr7_lt,cr5_gt			; Is it in 0 to 7 range
+			beq		cr1,ufpVMret					; Return if not in the range
+			slwi	r4,r4,2							; multiply index by 4
+			la		r3,famguestr0(r13)				; Load the base address
+			bt		cr2_eq,ufpSetGuestReg			; Set/get selector
+; ufpGetGuestReg
+			lwzx	r3,r4,r3						; Load the guest register
+			b		ufpVMret						; Return
+ufpSetGuestReg:
+			stwx	r5,r4,r3						; Update the guest register
+			li		r3,0							; Set return value
+			b		ufpVMret						; Return
+ufpResumeGuest:
+			lwz		r7,spcFlags(r3)					; Pick up the special flags
+			mtsrr0	r4								; Set srr0
+			rlwinm.	r6,r6,0,vmmKeyb,vmmKeyb			; Check vmmKeyb in maskCntrl
+			rlwinm	r7,r7,0,FamVMmodebit+1,FamVMmodebit-1	; Clear FamVMmodebit
+			stw		r7,spcFlags(r3)					; Update the special flags
+			mfsrr1	r6								; Get the current MSR value
+
+			lwz		r4,famguestmsr(r13)				; Load guest srr1
+			lis		r1,hi16(MSR_IMPORT_BITS)		; Get the MSR bits that are controllable by user
+			ori		r1,r1,lo16(MSR_IMPORT_BITS)		; Get the rest of the MSR bits that are controllable by user
+			and		r4,r4,r1						; Keep only the controllable bits
+			oris	r4,r4,hi16(MSR_EXPORT_MASK_SET)	; Force on the required bits
+			ori		r4,r4,lo16(MSR_EXPORT_MASK_SET)	; Force on the other required bits
+			rlwimi	r4,r6,0,MSR_FP_BIT,MSR_FP_BIT	; Propagate guest FP
+			rlwimi	r4,r6,0,MSR_VEC_BIT,MSR_VEC_BIT	; Propagate guest Vector	
+			beq		ufpnokey						; Branch if not key switch
+			mr		r2,r7							; Save r7
+			rlwimi	r7,r5,32+vmmKeyb-userProtKeybit,userProtKeybit,userProtKeybit	; Set the protection key
+			cmpw	cr0,r7,r2						; Is userProtKeybit changed?						
+			beq		ufpnokey						; No, go to ResumeGuest_nokey
+			mr		r5,r3							; Get the per_proc area
+			stw		r7,spcFlags(r3)					; Update the special flags
+
+            bt++    pf64Bitb,ufpsave64			; Go do this on a 64-bit machine...
+
+			lwz		r3,next_savearea+4(r5)			; Get the exception save area
+			stw		r8,saver8+4(r3)					; Save r8
+			stw		r9,saver9+4(r3)					; Save r9
+			stw		r10,saver10+4(r3)				; Save r10
+			stw		r11,saver11+4(r3)				; Save r11
+			stw		r12,saver12+4(r3)				; Save r12
+			stw		r13,saver13+4(r3)				; Save r12
+			stw		r14,saver14+4(r3)				; Save r14
+			stw		r15,saver15+4(r3)				; Save r15
+			stw		r16,saver16+4(r3)				; Save r16
+			stw		r17,saver17+4(r3)				; Save r17
+			stw		r18,saver18+4(r3)				; Save r18
+			stw		r19,saver19+4(r3)				; Save r19
+			stw		r20,saver20+4(r3)				; Save r20
+			stw		r21,saver21+4(r3)				; Save r21
+			stw		r22,saver22+4(r3)				; Save r22
+			stw		r23,saver23+4(r3)				; Save r23
+			stw		r24,saver24+4(r3)				; Save r24
+			stw		r25,saver25+4(r3)				; Save r25
+			stw		r26,saver26+4(r3)				; Save r26
+			stw		r27,saver27+4(r3)				; Save r27
+			stw		r28,saver28+4(r3)				; Save r28
+			stw		r29,saver29+4(r3)				; Save r29
+			stw		r30,saver30+4(r3)				; Save r30
+			stw		r31,saver31+4(r3)				; Save r31
+			b		ufpsaveres						; Continue
+
+ufpsave64:
+			ld		r3,next_savearea(r5)			; Get the exception save area
+			std		r8,saver8(r3)					; Save r8
+			std		r9,saver9(r3)					; Save r9
+			std		r10,saver10(r3)					; Save r10
+			std		r11,saver11(r3)					; Save r11
+			std		r12,saver12(r3)					; Save r12
+			std		r13,saver13(r3)					; Save r12
+			std		r14,saver14(r3)					; Save r14
+			std		r15,saver15(r3)					; Save r15
+			std		r16,saver16(r3)					; Save r16
+			std		r17,saver17(r3)					; Save r17
+			std		r18,saver18(r3)					; Save r18
+			std		r19,saver19(r3)					; Save r19
+			std		r20,saver20(r3)					; Save r20
+			std		r21,saver21(r3)					; Save r21
+			std		r22,saver22(r3)					; Save r22
+			std		r23,saver23(r3)					; Save r23
+			std		r24,saver24(r3)					; Save r24
+			std		r25,saver25(r3)					; Save r25
+			std		r26,saver26(r3)					; Save r26
+			std		r27,saver27(r3)					; Save r27
+			std		r28,saver28(r3)					; Save r28
+			std		r29,saver29(r3)					; Save r29
+			mfxer	r2								; Get xer
+			std		r30,saver30(r3)					; Save r30
+			std		r31,saver31(r3)					; Save r31
+			std		r2,savexer(r3)					; Save xer
+
+ufpsaveres:
+			mflr	r20								; Get lr
+			li		r2,1							; Set to  1
+			stw		r7,spcFlags(r5)					; Update the special flags
+			mr		r13,r3							; Set current savearea
+			mr		r21,r4							; Save r4
+			sth		r2,ppInvSeg(r5)					; Force a reload of the SRs
+			mr		r29,r5							; Get the per_proc area
+			mr		r3,r4							; Set MSR value we going to
+			bl		EXT(switchSegs)					; Go handle the segment registers/STB
+			mr		r3,r13							; Set current savearea
+			mr		r4,r21							; Restore r4
+			mtlr	r20								; Set lr
+
+            bt++    pf64Bitb,ufprestore64			; Go do this on a 64-bit machine...
+			lwz		r8,saver8+4(r3)					; Load r8
+			lwz		r9,saver9+4(r3)					; Load r9
+			lwz		r10,saver10+4(r3)				; Load r10
+			lwz		r11,saver11+4(r3)				; Load r11
+			lwz		r12,saver12+4(r3)				; Load r12
+			lwz		r13,saver13+4(r3)				; Load r12
+			lwz		r14,saver14+4(r3)				; Load r14
+			lwz		r15,saver15+4(r3)				; Load r15
+			lwz		r16,saver16+4(r3)				; Load r16
+			lwz		r17,saver17+4(r3)				; Load r17
+			lwz		r18,saver18+4(r3)				; Load r18
+			lwz		r19,saver19+4(r3)				; Load r19
+			lwz		r20,saver20+4(r3)				; Load r20
+			lwz		r21,saver21+4(r3)				; Load r21
+			lwz		r22,saver22+4(r3)				; Load r22
+			lwz		r23,saver23+4(r3)				; Load r23
+			lwz		r24,saver24+4(r3)				; Load r24
+			lwz		r25,saver25+4(r3)				; Load r25
+			lwz		r26,saver26+4(r3)				; Load r26
+			lwz		r27,saver27+4(r3)				; Load r27
+			lwz		r28,saver28+4(r3)				; Load r28
+			lwz		r29,saver29+4(r3)				; Load r29
+			lwz		r30,saver30+4(r3)				; Load r30
+			lwz		r31,saver31+4(r3)				; Load r31
+			b		ufpnokey						; Continue
+ufprestore64:
+			ld		r2,savexer(r3)					; Load xer
+			ld		r8,saver8(r3)					; Load r8
+			ld		r9,saver9(r3)					; Load r9
+			ld		r10,saver10(r3)					; Load r10
+			mtxer	r2								; Restore xer
+			ld		r11,saver11(r3)					; Load r11
+			ld		r12,saver12(r3)					; Load r12
+			ld		r13,saver13(r3)					; Load r12
+			ld		r14,saver14(r3)					; Load r14
+			ld		r15,saver15(r3)					; Load r15
+			ld		r16,saver16(r3)					; Load r16
+			ld		r17,saver17(r3)					; Load r17
+			ld		r18,saver18(r3)					; Load r18
+			ld		r19,saver19(r3)					; Load r19
+			ld		r20,saver20(r3)					; Load r20
+			ld		r21,saver21(r3)					; Load r21
+			ld		r22,saver22(r3)					; Load r22
+			ld		r23,saver23(r3)					; Load r23
+			ld		r24,saver24(r3)					; Load r24
+			ld		r25,saver25(r3)					; Load r25
+			ld		r26,saver26(r3)					; Load r26
+			ld		r27,saver27(r3)					; Load r27
+			ld		r28,saver28(r3)					; Load r28
+			ld		r29,saver29(r3)					; Load r29
+			ld		r30,saver30(r3)					; Load r30
+			ld		r31,saver31(r3)					; Load r31
+ufpnokey:
+			mfsprg	r3,0							; Get the per_proc area
+			mtsrr1	r4								; Set srr1
+			lwz		r0,famguestr0(r13)				; Load r0 
+			lwz		r1,famguestr1(r13)				; Load r1
+			lwz		r2,famguestr2(r13)				; Load r2
+			lwz		r3,famguestr3(r13)				; Load r3
+			lwz		r4,famguestr4(r13)				; Load r4
+			lwz		r5,famguestr5(r13)				; Load r5
+			lwz		r6,famguestr6(r13)				; Load r6
+			lwz		r7,famguestr7(r13)				; Load r7
+ufpVMret:
+			mfsprg	r13,2							; Restore R13
+            bt++    pf64Bitb,ufpVMrfi64				; Go do this on a 64-bit machine...
+			mtcrf	0xFF,r11						; Restore CR
+			mfsprg	r11,3							; Restore R11
+			rfi										; All done, go back...
+ufpVMrfi64:
+			mtcrf	0xFF,r11						; Restore CR
+			mfsprg	r11,3							; Restore R11
+			rfid
+
+ufpX:
+			bt		cr5_eq,ufpXResumeGuest			; if kvmmResumeGuest, branch to ResumeGuest
+			cmpwi	cr7,r4,0						; Compare first arg with 0
+			cmpwi	cr5,r4,7						; Compare first arg with 7
+			cror	cr1_eq,cr7_lt,cr5_gt			; Is it in 0 to 7 range
+			beq		cr1,ufpXVMret					; Return if not in the range
+			slwi	r4,r4,3							; multiply index by 8
+			la		r3,famguestXr0(r13)				; Load the base address
+			bt		cr2_eq,ufpXSetGuestReg			; Set/get selector
+; ufpXGetGuestReg
+			ldx	r3,r4,r3							; Load the guest register
+			b			ufpXVMret					; Return
+ufpXSetGuestReg:
+			stdx	r5,r4,r3						; Update the guest register
+			li		r3,0							; Set return value
+			b		ufpXVMret						; Return
+ufpXResumeGuest:
+			lwz		r7,spcFlags(r3)					; Pick up the special flags
+			mtsrr0	r4								; Set srr0
+			rlwinm.	r6,r6,0,vmmKeyb,vmmKeyb			; Check vmmKeyb in maskCntrl
+			rlwinm	r7,r7,0,FamVMmodebit+1,FamVMmodebit-1	; Clear FamVMmodebit
+			stw		r7,spcFlags(r3)					; Update the special flags
+			mfsrr1	r6								; Get the current MSR value
+
+			ld		r4,famguestXmsr(r13)			; Load guest srr1
+			lis		r1,hi16(MSR_IMPORT_BITS)		; Get the MSR bits that are controllable by user
+			ori		r1,r1,lo16(MSR_IMPORT_BITS)		; Get the rest of the MSR bits that are controllable by user
+			and		r4,r4,r1						; Keep only the controllable bits
+			oris	r4,r4,hi16(MSR_EXPORT_MASK_SET)	; Force on the required bits
+			ori		r4,r4,lo16(MSR_EXPORT_MASK_SET)	; Force on the other required bits
+			rlwimi	r4,r6,0,MSR_FP_BIT,MSR_FP_BIT	; Propagate guest FP
+			rlwimi	r4,r6,0,MSR_VEC_BIT,MSR_VEC_BIT	; Propagate guest Vector	
+			beq		ufpXnokey						; Branch if not key switch
+			mr		r2,r7							; Save r7
+			rlwimi	r7,r5,32+vmmKeyb-userProtKeybit,userProtKeybit,userProtKeybit	; Set the protection key
+			cmpw	cr0,r7,r2						; Is userProtKeybit changed?						
+			beq		ufpXnokey						; No, go to ResumeGuest_nokey
+			mr		r5,r3							; Get the per_proc area
+			stw		r7,spcFlags(r3)					; Update the special flags
+
+			ld		r3,next_savearea(r5)			; Get the exception save area
+			std		r8,saver8(r3)					; Save r8
+			std		r9,saver9(r3)					; Save r9
+			std		r10,saver10(r3)					; Save r10
+			std		r11,saver11(r3)					; Save r11
+			std		r12,saver12(r3)					; Save r12
+			std		r13,saver13(r3)					; Save r12
+			std		r14,saver14(r3)					; Save r14
+			std		r15,saver15(r3)					; Save r15
+			std		r16,saver16(r3)					; Save r16
+			std		r17,saver17(r3)					; Save r17
+			std		r18,saver18(r3)					; Save r18
+			std		r19,saver19(r3)					; Save r19
+			std		r20,saver20(r3)					; Save r20
+			std		r21,saver21(r3)					; Save r21
+			std		r22,saver22(r3)					; Save r22
+			std		r23,saver23(r3)					; Save r23
+			std		r24,saver24(r3)					; Save r24
+			std		r25,saver25(r3)					; Save r25
+			std		r26,saver26(r3)					; Save r26
+			std		r27,saver27(r3)					; Save r27
+			std		r28,saver28(r3)					; Save r28
+			std		r29,saver29(r3)					; Save r29
+			mfxer	r2								; Get xer
+			std		r30,saver30(r3)					; Save r30
+			std		r31,saver31(r3)					; Save r31
+			std		r2,savexer(r3)					; Save xer
+
+			mflr	r20								; Get lr
+			li		r2,1							; Set to  1
+			stw		r7,spcFlags(r5)					; Update the special flags
+			mr		r13,r3							; Set current savearea
+			mr		r21,r4							; Save r4
+			sth		r2,ppInvSeg(r5)					; Force a reload of the SRs
+			mr		r29,r5							; Get the per_proc area
+			mr		r3,r4							; Set MSR value we going to
+			bl		EXT(switchSegs)					; Go handle the segment registers/STB
+			mr		r3,r13							; Set current savearea
+			mr		r4,r21							; Restore r4
+			mtlr	r20								; Set lr
+
+			ld		r2,savexer(r3)					; Load xer
+			ld		r8,saver8(r3)					; Load r8
+			ld		r9,saver9(r3)					; Load r9
+			ld		r10,saver10(r3)					; Load r10
+			mtxer	r2								; Restore xer
+			ld		r11,saver11(r3)					; Load r11
+			ld		r12,saver12(r3)					; Load r12
+			ld		r13,saver13(r3)					; Load r12
+			ld		r14,saver14(r3)					; Load r14
+			ld		r15,saver15(r3)					; Load r15
+			ld		r16,saver16(r3)					; Load r16
+			ld		r17,saver17(r3)					; Load r17
+			ld		r18,saver18(r3)					; Load r18
+			ld		r19,saver19(r3)					; Load r19
+			ld		r20,saver20(r3)					; Load r20
+			ld		r21,saver21(r3)					; Load r21
+			ld		r22,saver22(r3)					; Load r22
+			ld		r23,saver23(r3)					; Load r23
+			ld		r24,saver24(r3)					; Load r24
+			ld		r25,saver25(r3)					; Load r25
+			ld		r26,saver26(r3)					; Load r26
+			ld		r27,saver27(r3)					; Load r27
+			ld		r28,saver28(r3)					; Load r28
+			ld		r29,saver29(r3)					; Load r29
+			ld		r30,saver30(r3)					; Load r30
+			ld		r31,saver31(r3)					; Load r31
+ufpXnokey:
+			mtsrr1	r4								; Set srr1
+			ld		r0,famguestXr0(r13)				; Load r0 
+			ld		r1,famguestXr1(r13)				; Load r1
+			ld		r2,famguestXr2(r13)				; Load r2
+			ld		r3,famguestXr3(r13)				; Load r3
+			ld		r4,famguestXr4(r13)				; Load r4
+			ld		r5,famguestXr5(r13)				; Load r5
+			ld		r6,famguestXr6(r13)				; Load r6
+			ld		r7,famguestXr7(r13)				; Load r7
+ufpXVMret:
+			mfsprg	r13,2							; Restore R13
+			mtcrf	0xFF,r11						; Restore CR
+			mfsprg	r11,3							; Restore R11
+			rfid
+
diff --git a/osfmk/ppc/xpr.h b/osfmk/ppc/xpr.h
index 133cb3a1b..fe1642dd0 100644
--- a/osfmk/ppc/xpr.h
+++ b/osfmk/ppc/xpr.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/profiling/i386/profile-asm.s b/osfmk/profiling/i386/profile-asm.s
index d4272c053..65c6760a9 100644
--- a/osfmk/profiling/i386/profile-asm.s
+++ b/osfmk/profiling/i386/profile-asm.s
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/profiling/i386/profile-md.c b/osfmk/profiling/i386/profile-md.c
index 80016e279..4bb803fd9 100644
--- a/osfmk/profiling/i386/profile-md.c
+++ b/osfmk/profiling/i386/profile-md.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/profiling/i386/profile-md.h b/osfmk/profiling/i386/profile-md.h
index 7fa90283e..c7bcdb124 100644
--- a/osfmk/profiling/i386/profile-md.h
+++ b/osfmk/profiling/i386/profile-md.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/profiling/machine/profile-md.h b/osfmk/profiling/machine/profile-md.h
index c66d76ffc..98095a0fa 100644
--- a/osfmk/profiling/machine/profile-md.h
+++ b/osfmk/profiling/machine/profile-md.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/profiling/ppc/profile-md.h b/osfmk/profiling/ppc/profile-md.h
index d6b4fa4fd..905ed9384 100644
--- a/osfmk/profiling/ppc/profile-md.h
+++ b/osfmk/profiling/ppc/profile-md.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/profiling/profile-internal.h b/osfmk/profiling/profile-internal.h
index 242d290e8..7846ad4f1 100644
--- a/osfmk/profiling/profile-internal.h
+++ b/osfmk/profiling/profile-internal.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/profiling/profile-kgmon.c b/osfmk/profiling/profile-kgmon.c
index e2eb6272a..ccadc6f04 100644
--- a/osfmk/profiling/profile-kgmon.c
+++ b/osfmk/profiling/profile-kgmon.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/profiling/profile-mk.c b/osfmk/profiling/profile-mk.c
index 84174f599..900fa22df 100644
--- a/osfmk/profiling/profile-mk.c
+++ b/osfmk/profiling/profile-mk.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/profiling/profile-mk.h b/osfmk/profiling/profile-mk.h
index 89bf6681c..51756a87d 100644
--- a/osfmk/profiling/profile-mk.h
+++ b/osfmk/profiling/profile-mk.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/sys/scsi.h b/osfmk/sys/scsi.h
index 319b0e2e2..5d8a6a455 100644
--- a/osfmk/sys/scsi.h
+++ b/osfmk/sys/scsi.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/sys/sdi.h b/osfmk/sys/sdi.h
index 13d487ea6..260a6bee2 100644
--- a/osfmk/sys/sdi.h
+++ b/osfmk/sys/sdi.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/sys/sdi_edt.h b/osfmk/sys/sdi_edt.h
index ac6576c05..9304b5118 100644
--- a/osfmk/sys/sdi_edt.h
+++ b/osfmk/sys/sdi_edt.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/sys/syslog.h b/osfmk/sys/syslog.h
index aed42097f..a026d9acf 100644
--- a/osfmk/sys/syslog.h
+++ b/osfmk/sys/syslog.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/sys/time.h b/osfmk/sys/time.h
index f2fa500d9..fbc95ae9d 100644
--- a/osfmk/sys/time.h
+++ b/osfmk/sys/time.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/sys/tm.h b/osfmk/sys/tm.h
index db34b6f84..4081e6cbe 100644
--- a/osfmk/sys/tm.h
+++ b/osfmk/sys/tm.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/sys/types.h b/osfmk/sys/types.h
index e1e72d576..6919899fc 100644
--- a/osfmk/sys/types.h
+++ b/osfmk/sys/types.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/sys/varargs.h b/osfmk/sys/varargs.h
index 19c3b94b9..8f26649ed 100644
--- a/osfmk/sys/varargs.h
+++ b/osfmk/sys/varargs.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/sys/version.h b/osfmk/sys/version.h
index fa9a638ba..4f2468581 100644
--- a/osfmk/sys/version.h
+++ b/osfmk/sys/version.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/vm/bsd_vm.c b/osfmk/vm/bsd_vm.c
index c7136d470..4db7b48bd 100644
--- a/osfmk/vm/bsd_vm.c
+++ b/osfmk/vm/bsd_vm.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/vm/cpm.h b/osfmk/vm/cpm.h
index b84f9ffbd..3c2bb78de 100644
--- a/osfmk/vm/cpm.h
+++ b/osfmk/vm/cpm.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/vm/device_vm.c b/osfmk/vm/device_vm.c
index 59532b21d..bbc1726db 100644
--- a/osfmk/vm/device_vm.c
+++ b/osfmk/vm/device_vm.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -199,7 +202,7 @@ kern_return_t
 device_pager_populate_object(
 	memory_object_t		device,
 	memory_object_offset_t	offset,
-	vm_offset_t		phys_addr,
+	ppnum_t			page_num,
 	vm_size_t		size)
 {
 	device_pager_t	device_object;
@@ -218,7 +221,7 @@ device_pager_populate_object(
 		return KERN_FAILURE;
 
 	kr =  vm_object_populate_with_private(
-				vm_object, offset, phys_addr, size);
+				vm_object, offset, page_num, size);
 	if(kr != KERN_SUCCESS)
 		return kr;
 
diff --git a/osfmk/vm/memory_object.c b/osfmk/vm/memory_object.c
index b65cc9948..c3e0f22f0 100644
--- a/osfmk/vm/memory_object.c
+++ b/osfmk/vm/memory_object.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -132,7 +135,7 @@ vm_object_update(vm_object_t, vm_object_offset_t,
 
 #define	memory_object_should_return_page(m, should_return) \
     (should_return != MEMORY_OBJECT_RETURN_NONE && \
-     (((m)->dirty || ((m)->dirty = pmap_is_modified((m)->phys_addr))) || \
+     (((m)->dirty || ((m)->dirty = pmap_is_modified((m)->phys_page))) || \
       ((m)->precious && (should_return) == MEMORY_OBJECT_RETURN_ALL) || \
       (should_return) == MEMORY_OBJECT_RETURN_ANYTHING))
 
@@ -255,7 +258,7 @@ memory_object_lock_page(
 
 	if (prot != VM_PROT_NO_CHANGE) {
 		if ((m->page_lock ^ prot) & prot) {
-			pmap_page_protect(m->phys_addr, VM_PROT_ALL & ~prot);
+			pmap_page_protect(m->phys_page, VM_PROT_ALL & ~prot);
 		}
 #if 0
 		/* code associated with the vestigial 
@@ -300,7 +303,7 @@ memory_object_lock_page(
 		vm_page_unlock_queues();
 
 		if (!should_flush)
-			pmap_page_protect(m->phys_addr, VM_PROT_NONE);
+			pmap_page_protect(m->phys_page, VM_PROT_NONE);
 
 		if (m->dirty)
 			return(MEMORY_OBJECT_LOCK_RESULT_MUST_CLEAN);
@@ -406,7 +409,7 @@ memory_object_lock_request(
 	if ((prot & ~VM_PROT_ALL) != 0 && prot != VM_PROT_NO_CHANGE)
 		return (KERN_INVALID_ARGUMENT);
 
-	size = round_page(size);
+	size = round_page_64(size);
 
 	/*
 	 *	Lock the object, and acquire a paging reference to
@@ -960,7 +963,7 @@ vm_object_set_attributes_common(
 		temporary = TRUE;
 	if (cluster_size != 0) {
 		int	pages_per_cluster;
-		pages_per_cluster = atop(cluster_size);
+		pages_per_cluster = atop_32(cluster_size);
 		/*
 		 * Cluster size must be integral multiple of page size,
 		 * and be a power of 2 number of pages.
@@ -1096,7 +1099,7 @@ memory_object_change_attributes(
                 perf = (memory_object_perf_info_t) attributes;
 
 		may_cache = perf->may_cache;
-		cluster_size = round_page(perf->cluster_size);
+		cluster_size = round_page_32(perf->cluster_size);
 
 		break;
 	    }
@@ -1421,7 +1424,7 @@ host_default_memory_manager(
 			mutex_unlock(&memory_manager_default_lock);
 			return KERN_INVALID_ARGUMENT;
 #else
-			cluster_size = round_page(cluster_size);
+			cluster_size = round_page_32(cluster_size);
 #endif
 		}
 		memory_manager_default_cluster = cluster_size;
@@ -1548,12 +1551,12 @@ memory_object_deactivate_pages(
 				if ((m->wire_count == 0) && (!m->private) && (!m->gobbled) && (!m->busy)) {
 
 					m->reference = FALSE;
-					pmap_clear_reference(m->phys_addr);
+					pmap_clear_reference(m->phys_page);
 
 					if ((kill_page) && (object->internal)) {
 				        	m->precious = FALSE;
 					        m->dirty = FALSE;
-						pmap_clear_modify(m->phys_addr);
+						pmap_clear_modify(m->phys_page);
 						vm_external_state_clr(object->existence_map, offset);
 					}
 					VM_PAGE_QUEUES_REMOVE(m);
@@ -1607,7 +1610,7 @@ memory_object_page_op(
 	memory_object_control_t	control,
 	memory_object_offset_t	offset,
 	int			ops,
-	vm_offset_t		*phys_entry,
+	ppnum_t			*phys_entry,
 	int			*flags)
 {
 	vm_object_t		object;
@@ -1623,8 +1626,8 @@ memory_object_page_op(
 	if(ops & UPL_POP_PHYSICAL) {
 		if(object->phys_contiguous) {
 			if (phys_entry) {
-				*phys_entry = (vm_offset_t)
-						object->shadow_offset;
+				*phys_entry = (ppnum_t)
+					(object->shadow_offset >> 12);
 			}
 			vm_object_unlock(object);
 			return KERN_SUCCESS;
@@ -1675,7 +1678,7 @@ memory_object_page_op(
 			if(dst_page->busy) *flags |= UPL_POP_BUSY;
 		}
 		if (phys_entry)
-			*phys_entry = dst_page->phys_addr;
+			*phys_entry = dst_page->phys_page;
 	
 		/* The caller should have made a call either contingent with */
 		/* or prior to this call to set UPL_POP_BUSY */
diff --git a/osfmk/vm/memory_object.h b/osfmk/vm/memory_object.h
index a169bd3c3..1e328e979 100644
--- a/osfmk/vm/memory_object.h
+++ b/osfmk/vm/memory_object.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/vm/pmap.h b/osfmk/vm/pmap.h
index 26337c7e7..02793058b 100644
--- a/osfmk/vm/pmap.h
+++ b/osfmk/vm/pmap.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -84,6 +87,20 @@
  *	many address spaces.
  */
 
+/* Copy between a physical page and a virtual address */
+extern kern_return_t 	copypv(
+				addr64_t source, 
+				addr64_t sink, 
+				unsigned int size, 
+				int which);	
+#define cppvPsnk 	1
+#define cppvPsrc 	2
+#define cppvFsnk 	4
+#define cppvFsrc 	8
+#define cppvNoModSnk   16
+#define cppvNoRefSrc   32
+#define cppvKmap   	64	/* User the kernel's vm_map */
+
 #if !defined(MACH_KERNEL_PRIVATE)
 
 typedef void *pmap_t;
@@ -138,7 +155,7 @@ extern void		pmap_init(void);	/* Initialization,
  *	However, for best performance pmap_free_pages should be accurate.
  */
 
-extern boolean_t	pmap_next_page(vm_offset_t *paddr);
+extern boolean_t	pmap_next_page(ppnum_t *pnum);
 						/* During VM initialization,
 						 * return the next unused
 						 * physical page.
@@ -165,14 +182,14 @@ extern void		pmap_switch(pmap_t);
 extern void		pmap_enter(	/* Enter a mapping */
 				pmap_t		pmap,
 				vm_offset_t	v,
-				vm_offset_t	pa,
+				ppnum_t		pn,
 				vm_prot_t	prot,
 				unsigned int	flags,
 				boolean_t	wired);
 
 extern void		pmap_remove_some_phys(
 				pmap_t		pmap,
-				vm_offset_t	pa);
+				ppnum_t		pn);
 
 
 /*
@@ -180,36 +197,36 @@ extern void		pmap_remove_some_phys(
  */
 
 extern void		pmap_page_protect(	/* Restrict access to page. */
-				vm_offset_t	phys,
+				ppnum_t	phys,
 				vm_prot_t	prot);
 
 extern void		(pmap_zero_page)(
-				vm_offset_t	phys);
+				ppnum_t		pn);
 
 extern void		(pmap_zero_part_page)(
-				vm_offset_t	p,
+				ppnum_t		pn,
 				vm_offset_t     offset,
 				vm_size_t       len);
 
 extern void		(pmap_copy_page)(
-				vm_offset_t	src,
-				vm_offset_t	dest);
+				ppnum_t		src,
+				ppnum_t		dest);
 
 extern void		(pmap_copy_part_page)(
-				vm_offset_t	src,
+				ppnum_t		src,
 				vm_offset_t	src_offset,
-				vm_offset_t	dst,
+				ppnum_t		dst,
 				vm_offset_t	dst_offset,
 				vm_size_t	len);
 
 extern void		(pmap_copy_part_lpage)(
 				vm_offset_t	src,
-				vm_offset_t	dst,
+				ppnum_t		dst,
 				vm_offset_t	dst_offset,
 				vm_size_t	len);
 
 extern void		(pmap_copy_part_rpage)(
-				vm_offset_t	src,
+				ppnum_t		src,
 				vm_offset_t	src_offset,
 				vm_offset_t	dst,
 				vm_size_t	len);
@@ -218,7 +235,7 @@ extern void		(pmap_copy_part_rpage)(
  * debug/assertions. pmap_verify_free returns true iff
  * the given physical page is mapped into no pmap.
  */
-extern boolean_t	pmap_verify_free(vm_offset_t paddr);
+extern boolean_t	pmap_verify_free(ppnum_t pn);
 
 /*
  *	Statistics routines
@@ -266,8 +283,8 @@ extern kern_return_t	(pmap_attribute)(	/* Get/Set special memory
 
 extern kern_return_t	(pmap_attribute_cache_sync)(  /* Flush appropriate 
 						       * cache based on
-						       * phys addr sent */
-				vm_offset_t	addr, 
+						       * page number sent */
+				ppnum_t		pn, 
 				vm_size_t	size, 
 				vm_machine_attribute_t attribute, 
 				vm_machine_attribute_val_t* value);
@@ -314,7 +331,7 @@ extern kern_return_t	(pmap_attribute_cache_sync)(  /* Flush appropriate
 		pmap_enter(					\
 			(pmap),					\
 			(virtual_address),			\
-			(page)->phys_addr,			\
+			(page)->phys_page,			\
 			(protection) & ~(page)->page_lock,	\
 			flags,					\
 			(wired)					\
@@ -328,15 +345,15 @@ extern kern_return_t	(pmap_attribute_cache_sync)(  /* Flush appropriate
  *	by the hardware.
  */
 				/* Clear reference bit */
-extern void		pmap_clear_reference(vm_offset_t paddr);
+extern void		pmap_clear_reference(ppnum_t	 pn);
 				/* Return reference bit */
-extern boolean_t	(pmap_is_referenced)(vm_offset_t paddr);
+extern boolean_t	(pmap_is_referenced)(ppnum_t	 pn);
 				/* Set modify bit */
-extern void             pmap_set_modify(vm_offset_t paddr);
+extern void             pmap_set_modify(ppnum_t	 pn);
 				/* Clear modify bit */
-extern void		pmap_clear_modify(vm_offset_t paddr);
+extern void		pmap_clear_modify(ppnum_t pn);
 				/* Return modify bit */
-extern boolean_t	pmap_is_modified(vm_offset_t paddr);
+extern boolean_t	pmap_is_modified(ppnum_t pn);
 
 /*
  *	Routines that operate on ranges of virtual addresses.
@@ -391,8 +408,9 @@ extern void		pmap_change_wiring(	/* Specify pageability */
 
 extern void		pmap_remove(	/* Remove mappings. */
 				pmap_t		map,
-				vm_offset_t	s,
-				vm_offset_t	e);
+				addr64_t	s,
+				addr64_t	e);
+
 
 #endif  /* __APPLE_API_PRIVATE */
 
diff --git a/osfmk/vm/task_working_set.c b/osfmk/vm/task_working_set.c
index 90859e626..540c247e4 100644
--- a/osfmk/vm/task_working_set.c
+++ b/osfmk/vm/task_working_set.c
@@ -4,19 +4,22 @@ int	startup_miss = 0;
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -290,8 +293,8 @@ tws_hash_line_clear(
 							&& (dump_pmap == 1)) {
 						pmap_remove_some_phys((pmap_t)
 							vm_map_pmap(
-								hash_ele->map),
-							p->phys_addr);
+								current_map()),
+							p->phys_page);
 					}
 				   }
 				   local_off += PAGE_SIZE_64;
@@ -322,7 +325,7 @@ tws_hash_line_clear(
 }
 
 kern_return_t
-tws_lookup(
+tws_internal_lookup(
 	tws_hash_t		tws,	
 	vm_object_offset_t	offset, 
 	vm_object_t		object,
@@ -341,10 +344,6 @@ tws_lookup(
 	if(object->private)
 		return KERN_SUCCESS;
 
-	if(!tws_lock_try(tws)) {
-		return KERN_FAILURE;
-	}
-
 	index = do_tws_hash(object, offset, 
 			tws->number_of_elements, tws->number_of_lines);
 	loop = 0;
@@ -357,7 +356,6 @@ tws_lookup(
 		age_of_cache = ((sched_tick 
 			- tws->time_of_creation) >> SCHED_TICK_SHIFT);
        		if (age_of_cache > 35) {
-			tws_unlock(tws); 
 			return KERN_OPERATION_TIMED_OUT;
 		}
 	}
@@ -370,7 +368,6 @@ tws_lookup(
 			age_of_cache = ((sched_tick 
 				- tws->time_of_creation) >> SCHED_TICK_SHIFT);
 	        	if (age_of_cache > 60) {
-				tws_unlock(tws); 
 				return KERN_OPERATION_TIMED_OUT;
 			}
       		}
@@ -385,16 +382,32 @@ tws_lookup(
 		set = cache_ele->element->line/tws->number_of_lines;
 		ele_line = cache_ele->element->line - set;
 		*line = &tws->cache[set][ele_line];
-		tws_unlock(tws);
 		return KERN_SUCCESS;
 	}
 
-	tws_unlock(tws);
 	return KERN_FAILURE;
 
 
 }
 
+kern_return_t
+tws_lookup(
+	tws_hash_t		tws,	
+	vm_object_offset_t	offset, 
+	vm_object_t		object,
+	tws_hash_line_t		 *line) 
+{
+	kern_return_t kr;
+
+	if(!tws_lock_try(tws)) {
+		return KERN_FAILURE;
+	}
+	kr = tws_internal_lookup(tws,
+		offset, object, line);
+	tws_unlock(tws);
+	return kr;
+}
+
 kern_return_t
 tws_expand_working_set(
 	vm_offset_t	tws, 
@@ -569,7 +582,7 @@ printf("cache_lookup, result = 0x%x, addr = 0x%x, object 0x%x, offset 0x%x%x\n",
 			pmap_remove(map->pmap, 0, GLOBAL_SHARED_TEXT_SEGMENT);
 			pmap_remove(map->pmap, 
 				GLOBAL_SHARED_DATA_SEGMENT 
-				+ SHARED_DATA_REGION_SIZE, 0xFFFFF000);
+				+ SHARED_DATA_REGION_SIZE, 0xFFFFFFFFFFFFF000);
 	}
 
 	/* This next bit of code, the and alternate hash */
@@ -1026,8 +1039,8 @@ tws_build_cluster(
 	int			age_of_cache;
 	int			pre_heat_size;
 	unsigned int		ele_cache;
-	unsigned int		end_cache = NULL;
-	unsigned int		start_cache = NULL;
+	unsigned int		end_cache = 0;
+	unsigned int		start_cache = 0;
 
 	if((object->private) || !(object->pager))
 		return;
@@ -1040,6 +1053,10 @@ tws_build_cluster(
 		object_size = object->size;
 	}
 
+	if((!tws) || (!tws_lock_try(tws))) {
+		return;
+	}
+
 	age_of_cache = ((sched_tick 
 			- tws->time_of_creation) >> SCHED_TICK_SHIFT);
 
@@ -1069,7 +1086,7 @@ tws_build_cluster(
 			*start = *start & TWS_HASH_OFF_MASK;
 			*end = *start + (32 * PAGE_SIZE_64);
 			if(*end > object_size) {
-				*end = trunc_page(object_size);
+				*end = trunc_page_64(object_size);
 				max_length = 0;
 				if(before >= *end) {
 					*end = after;
@@ -1092,7 +1109,7 @@ tws_build_cluster(
 					*end = after + 
 						(32 * PAGE_SIZE_64);
 					if(*end > object_size) {
-						*end = trunc_page(object_size);
+						*end = trunc_page_64(object_size);
 						max_length = 0;
 						if(*start >= *end) {
 							*end = after;
@@ -1116,7 +1133,7 @@ tws_build_cluster(
 					break;
 			}
 
-			if(start_cache != NULL) {
+			if(start_cache != 0) {
 				unsigned int mask;
 
 				for (mask = 1; mask != 0; mask = mask << 1) {
@@ -1128,7 +1145,7 @@ tws_build_cluster(
 						break;
 				}
 			}
-			if(end_cache != NULL) {
+			if(end_cache != 0) {
 				unsigned int mask;
 
 				for (mask = 0x80000000; 
@@ -1145,6 +1162,7 @@ tws_build_cluster(
 			if (*start >= *end)
 			  panic("bad clipping occurred\n");
 
+			tws_unlock(tws);
 			return;
 		}
 	}
@@ -1153,12 +1171,12 @@ tws_build_cluster(
 		(object_size >= 
 			(after + PAGE_SIZE_64))) {
 		if(length >= pre_heat_size) {
-		   if(tws_lookup(tws, after, object,
+		   if(tws_internal_lookup(tws, after, object,
 				&line) != KERN_SUCCESS) {
 			vm_object_offset_t	extend;
 				
 			extend = after + PAGE_SIZE_64;
-			if(tws_lookup(tws, extend, object,
+			if(tws_internal_lookup(tws, extend, object,
 						&line) != KERN_SUCCESS) {
 				break;
 			}
@@ -1212,7 +1230,7 @@ tws_build_cluster(
 		before -= PAGE_SIZE_64;
 
 		if(length >= pre_heat_size) {
-		   if(tws_lookup(tws, before, object,
+		   if(tws_internal_lookup(tws, before, object,
 				&line) != KERN_SUCCESS) {
 			vm_object_offset_t	extend;
 				
@@ -1220,7 +1238,7 @@ tws_build_cluster(
 			if (extend == 0)
 				break;
 			extend -= PAGE_SIZE_64;
-			if(tws_lookup(tws, extend, object,
+			if(tws_internal_lookup(tws, extend, object,
 					&line) != KERN_SUCCESS) {
 				break;
 			}
@@ -1266,6 +1284,7 @@ tws_build_cluster(
 		*start -= PAGE_SIZE_64;
 		length += PAGE_SIZE;
 	}
+	tws_unlock(tws);
 }
 
 tws_line_signal(
@@ -1835,6 +1854,39 @@ tws_read_startup_file(
 }
 
 
+void
+tws_hash_ws_flush(tws_hash_t tws) {
+	tws_startup_t 		scache;
+	if(tws == NULL) {
+		return;
+	}
+	tws_lock(tws);
+	if(tws->startup_name != NULL) {
+		scache = tws_create_startup_list(tws);
+		if(scache == NULL) {
+			/* dump the name cache, we'll */
+			/* get it next time */
+			kfree((vm_offset_t) 	
+				tws->startup_name, 
+				tws->startup_name_length);
+			tws->startup_name = NULL;
+			tws_unlock(tws);
+			return;
+		}
+		bsd_write_page_cache_file(tws->uid, tws->startup_name, 
+				scache, scache->tws_hash_size, 
+				tws->mod, tws->fid);
+		kfree((vm_offset_t)scache, 
+				scache->tws_hash_size);
+		kfree((vm_offset_t) 
+				tws->startup_name, 
+				tws->startup_name_length);
+		tws->startup_name = NULL;
+	}
+	tws_unlock(tws);
+	return;
+}
+
 void
 tws_hash_destroy(tws_hash_t	tws)
 {
diff --git a/osfmk/vm/task_working_set.h b/osfmk/vm/task_working_set.h
index 5c9e57f0a..90af7ef03 100644
--- a/osfmk/vm/task_working_set.h
+++ b/osfmk/vm/task_working_set.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -258,6 +261,10 @@ kern_return_t	tws_read_startup_file(
 		tws_startup_t		startup,
 		vm_offset_t		cache_size);
 
+void
+tws_hash_ws_flush(
+	tws_hash_t	tws);
+
 
 
 #endif  /* _VM_TASK_WORKING_SET_H_ */
diff --git a/osfmk/vm/vm_debug.c b/osfmk/vm/vm_debug.c
index bd78d02c4..87b81f23c 100644
--- a/osfmk/vm/vm_debug.c
+++ b/osfmk/vm/vm_debug.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -249,7 +252,7 @@ mach_vm_region_info(
 
 		if (size != 0)
 			kmem_free(ipc_kernel_map, addr, size);
-		size = round_page(2 * used * sizeof(vm_info_object_t));
+		size = round_page_32(2 * used * sizeof(vm_info_object_t));
 
 		kr = vm_allocate(ipc_kernel_map, &addr, size, TRUE);
 		if (kr != KERN_SUCCESS)
@@ -269,7 +272,7 @@ mach_vm_region_info(
 			kmem_free(ipc_kernel_map, addr, size);
 	} else {
 		vm_size_t size_used =
-			round_page(used * sizeof(vm_info_object_t));
+			round_page_32(used * sizeof(vm_info_object_t));
 
 		kr = vm_map_unwire(ipc_kernel_map, addr, addr + size_used, FALSE);
 		assert(kr == KERN_SUCCESS);
@@ -448,7 +451,7 @@ mach_vm_region_info_64(
 
 		if (size != 0)
 			kmem_free(ipc_kernel_map, addr, size);
-		size = round_page(2 * used * sizeof(vm_info_object_t));
+		size = round_page_32(2 * used * sizeof(vm_info_object_t));
 
 		kr = vm_allocate(ipc_kernel_map, &addr, size, TRUE);
 		if (kr != KERN_SUCCESS)
@@ -468,7 +471,7 @@ mach_vm_region_info_64(
 			kmem_free(ipc_kernel_map, addr, size);
 	} else {
 		vm_size_t size_used =
-			round_page(used * sizeof(vm_info_object_t));
+			round_page_32(used * sizeof(vm_info_object_t));
 
 		kr = vm_map_unwire(ipc_kernel_map, addr, addr + size_used, FALSE);
 		assert(kr == KERN_SUCCESS);
@@ -511,7 +514,7 @@ vm_mapped_pages_info(
 
 	pmap = map->pmap;
 	size = pmap_resident_count(pmap) * sizeof(vm_offset_t);
-	size = round_page(size);
+	size = round_page_32(size);
 
 	for (;;) {
 	    (void) vm_allocate(ipc_kernel_map, &addr, size, TRUE);
@@ -534,7 +537,7 @@ vm_mapped_pages_info(
 	    /*
 	     * Try again, doubling the size
 	     */
-	    size = round_page(actual * sizeof(vm_offset_t));
+	    size = round_page_32(actual * sizeof(vm_offset_t));
 	}
 	if (actual == 0) {
 	    *pages = 0;
@@ -543,7 +546,7 @@ vm_mapped_pages_info(
 	}
 	else {
 	    *pages_count = actual;
-	    size_used = round_page(actual * sizeof(vm_offset_t));
+	    size_used = round_page_32(actual * sizeof(vm_offset_t));
 	    (void) vm_map_wire(ipc_kernel_map,
 				addr, addr + size, 
 				VM_PROT_READ|VM_PROT_WRITE, FALSE);
@@ -609,7 +612,7 @@ host_virtual_physical_table_info(
 		if (info != *infop)
 			kmem_free(ipc_kernel_map, addr, size);
 
-		size = round_page(actual * sizeof *info);
+		size = round_page_32(actual * sizeof *info);
 		kr = kmem_alloc_pageable(ipc_kernel_map, &addr, size);
 		if (kr != KERN_SUCCESS)
 			return KERN_RESOURCE_SHORTAGE;
@@ -630,7 +633,7 @@ host_virtual_physical_table_info(
 		vm_map_copy_t copy;
 		vm_size_t used;
 
-		used = round_page(actual * sizeof *info);
+		used = round_page_32(actual * sizeof *info);
 
 		if (used != size)
 			kmem_free(ipc_kernel_map, addr + used, size - used);
diff --git a/osfmk/vm/vm_debug.h b/osfmk/vm/vm_debug.h
index fee86f23a..8a98bb8f2 100644
--- a/osfmk/vm/vm_debug.h
+++ b/osfmk/vm/vm_debug.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/vm/vm_external.c b/osfmk/vm/vm_external.c
index f5eca5ba5..555039930 100644
--- a/osfmk/vm/vm_external.c
+++ b/osfmk/vm/vm_external.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -232,7 +235,7 @@ _vm_external_state_get(
 
 	assert (map != VM_EXTERNAL_NULL);
 
-	bit = atop(offset);
+	bit = atop_32(offset);
 	byte = bit >> 3;
 	if (map[byte] & (1 << (bit & 07))) {
 		return VM_EXTERNAL_STATE_EXISTS;
@@ -252,7 +255,7 @@ vm_external_state_set(
 	if (map == VM_EXTERNAL_NULL)
 		return;
 
-	bit = atop(offset);
+	bit = atop_32(offset);
 	byte = bit >> 3;
 	map[byte] |= (1 << (bit & 07));
 }
@@ -268,7 +271,7 @@ vm_external_state_clr(
 	if (map == VM_EXTERNAL_NULL)
 		return;
 
-	bit = atop(offset);
+	bit = atop_32(offset);
 	byte = bit >> 3;
 	map[byte] &= ~(1 << (bit & 07));
 }
diff --git a/osfmk/vm/vm_external.h b/osfmk/vm/vm_external.h
index 3b189e69e..fd38ce629 100644
--- a/osfmk/vm/vm_external.h
+++ b/osfmk/vm/vm_external.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -79,7 +82,7 @@ typedef int	vm_external_state_t;
 /*
  * Useful macros
  */
-#define stob(s)	((atop((s)) + 07) >> 3)
+#define stob(s)	((atop_32((s)) + 07) >> 3)
 
 /*
  *	Routines exported by this module.
diff --git a/osfmk/vm/vm_fault.c b/osfmk/vm/vm_fault.c
index 14c503dbb..0958f3cf0 100644
--- a/osfmk/vm/vm_fault.c
+++ b/osfmk/vm/vm_fault.c
@@ -1,22 +1,24 @@
-
 /*
  * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -77,7 +79,6 @@ extern int	device_pager_workaround;
 #include <kern/host.h>
 #include <kern/xpr.h>
 #include <ppc/proc_reg.h>
-#include <ppc/pmap_internals.h>
 #include <vm/task_working_set.h>
 #include <vm/vm_map.h>
 #include <vm/vm_object.h>
@@ -616,6 +617,7 @@ vm_fault_page(
 						return(VM_FAULT_MEMORY_SHORTAGE);
 					}
 
+
 					XPR(XPR_VM_FAULT,
 	      "vm_f_page: zero obj 0x%X, off 0x%X, page 0x%X, first_obj 0x%X\n",
 						(integer_t)object, offset,
@@ -661,7 +663,7 @@ vm_fault_page(
     						}
 						vm_object_lock(object);
 					}
-					pmap_clear_modify(m->phys_addr);
+					pmap_clear_modify(m->phys_page);
 					vm_page_lock_queues();
 					VM_PAGE_QUEUES_REMOVE(m);
 					m->page_ticket = vm_page_ticket;
@@ -1300,7 +1302,7 @@ no_clustering:
 			m->inactive = TRUE;
 			vm_page_inactive_count++;
 			vm_page_unlock_queues();
-			pmap_clear_modify(m->phys_addr);
+			pmap_clear_modify(m->phys_page);
 			break;
 		}
 		else {
@@ -1421,7 +1423,7 @@ no_clustering:
 
 			vm_page_lock_queues();
 			assert(!m->cleaning);
-			pmap_page_protect(m->phys_addr, VM_PROT_NONE);
+			pmap_page_protect(m->phys_page, VM_PROT_NONE);
 			vm_page_deactivate(m);
 			copy_m->dirty = TRUE;
 			/*
@@ -1612,7 +1614,7 @@ no_clustering:
 
 			vm_page_lock_queues();
 			assert(!m->cleaning);
-			pmap_page_protect(m->phys_addr, VM_PROT_NONE);
+			pmap_page_protect(m->phys_page, VM_PROT_NONE);
 			copy_m->dirty = TRUE;
 			vm_page_unlock_queues();
 
@@ -1835,7 +1837,6 @@ vm_fault(
 	vm_prot_t		full_fault_type;
 	
 
-
 	KERNEL_DEBUG_CONSTANT((MACHDBG_CODE(DBG_MACH_VM, 0)) | DBG_FUNC_START,
 			      vaddr,
 			      0,
@@ -1843,7 +1844,6 @@ vm_fault(
 			      0,
 			      0);
 
-	cur_thread = current_thread();
 	/* at present we do not fully check for execute permission */
 	/* we generally treat it is read except in certain device  */
 	/* memory settings */
@@ -1868,6 +1868,8 @@ vm_fault(
 	/*
 	 * drop funnel if it is already held. Then restore while returning
 	 */
+	cur_thread = current_thread();
+
 	if ((cur_thread->funnel_state & TH_FN_OWNED) == TH_FN_OWNED) {
 		funnel_set = TRUE;
 		curflock = cur_thread->funnel_lock;
@@ -2044,12 +2046,13 @@ FastPmapEnter:
 					prot &= ~VM_PROT_WRITE;
 #endif	/* MACH_KDB */
 #endif	/* STATIC_CONFIG */
-				if (m->no_isync == TRUE) {
-				        pmap_sync_caches_phys(m->phys_addr);
+				cache_attr = ((unsigned int)m->object->wimg_bits) & VM_WIMG_MASK;
+				if ((m->no_isync == TRUE) || 
+					   (cache_attr != VM_WIMG_DEFAULT)) {
+				        pmap_sync_caches_phys(m->phys_page);
 					m->no_isync = FALSE;
 				}
 
-				cache_attr = ((unsigned int)m->object->wimg_bits) & VM_WIMG_MASK;
 				if(caller_pmap) {
 					PMAP_ENTER(caller_pmap, 
 						caller_pmap_addr, m, 
@@ -2235,7 +2238,7 @@ FastPmapEnter:
 			vm_page_lock_queues();
 			vm_page_deactivate(cur_m);
 			m->dirty = TRUE;
-			pmap_page_protect(cur_m->phys_addr,
+			pmap_page_protect(cur_m->phys_page,
 						  VM_PROT_NONE);
 			vm_page_unlock_queues();
 
@@ -2663,7 +2666,7 @@ FastPmapEnter:
 	 */
 	if (m != VM_PAGE_NULL) {
 		if (m->no_isync == TRUE) {
-		        pmap_sync_caches_phys(m->phys_addr);
+		        pmap_sync_caches_phys(m->phys_page);
 
 		        m->no_isync = FALSE;
 		}
@@ -2729,7 +2732,6 @@ FastPmapEnter:
 
 #ifndef i386
 		int			memattr;
-		struct	phys_entry	*pp;
 		vm_map_entry_t		entry;
 		vm_offset_t		laddr;
 		vm_offset_t		ldelta, hdelta;
@@ -2738,22 +2740,16 @@ FastPmapEnter:
 		 * do a pmap block mapping from the physical address
 		 * in the object 
 		 */
-		if(pp = pmap_find_physentry(
-			(vm_offset_t)object->shadow_offset)) {
-			memattr = ((pp->pte1 & 0x00000078) >> 3); 
-		} else {
-			memattr = VM_WIMG_MASK & (int)object->wimg_bits;
-		}
 
+		/* While we do not worry about execution protection in   */
+		/* general, certian pages may have instruction execution */
+		/* disallowed.  We will check here, and if not allowed   */
+		/* to execute, we return with a protection failure.      */
 
-		/* While we do not worry about execution protection in */
-		/* general, we may be able to read device memory and   */
-		/* still not be able to execute it.  Here we check for */
-		/* the guarded bit.  If its set and we are attempting  */
-		/* to execute, we return with a protection failure.    */
+		if((full_fault_type & VM_PROT_EXECUTE) &&
+			(pmap_canExecute((ppnum_t)
+				(object->shadow_offset >> 12)) < 1)) {
 
-		if((memattr & VM_MEM_GUARDED) &&
-			(full_fault_type & VM_PROT_EXECUTE)) {
 			vm_map_verify_done(map, &version);
 			if(pmap_map != map)
 				vm_map_unlock(pmap_map);
@@ -2763,8 +2759,6 @@ FastPmapEnter:
 			goto done;
 		}
 
-
-
 		if(pmap_map != map) {
 			vm_map_unlock(pmap_map);
 		}
@@ -2809,32 +2803,36 @@ FastPmapEnter:
 
 
 			if(caller_pmap) {
+				/* Set up a block mapped area */
 				pmap_map_block(caller_pmap, 
-					caller_pmap_addr - ldelta, 
-					((vm_offset_t)
+					(addr64_t)(caller_pmap_addr - ldelta), 
+					(((vm_offset_t)
 				    (entry->object.vm_object->shadow_offset)) 
 					+ entry->offset + 
-					(laddr - entry->vme_start) - ldelta, 
+					(laddr - entry->vme_start) 
+							- ldelta)>>12,
 				ldelta + hdelta, prot, 
-				memattr, 0); /* Set up a block mapped area */
-			} else {
-				pmap_map_block(pmap_map->pmap, vaddr - ldelta, 
-				((vm_offset_t)
+				(VM_WIMG_MASK & (int)object->wimg_bits), 0);
+			} else { 
+				/* Set up a block mapped area */
+				pmap_map_block(pmap_map->pmap, 
+				   (addr64_t)(vaddr - ldelta), 
+				   (((vm_offset_t)
 				    (entry->object.vm_object->shadow_offset)) 
-					+ entry->offset + 
-					(laddr - entry->vme_start) - ldelta, 
-				ldelta + hdelta, prot, 
-				memattr, 0); /* Set up a block mapped area */
+				       + entry->offset + 
+				       (laddr - entry->vme_start) - ldelta)>>12,
+				   ldelta + hdelta, prot, 
+				   (VM_WIMG_MASK & (int)object->wimg_bits), 0);
 			}
 		}
 #else
 #ifdef notyet
 		if(caller_pmap) {
                		pmap_enter(caller_pmap, caller_pmap_addr, 
-				object->shadow_offset, prot, 0, TRUE);
+				object->shadow_offset>>12, prot, 0, TRUE);
 		} else {
                		pmap_enter(pmap, vaddr, 
-				object->shadow_offset, prot, 0, TRUE);
+				object->shadow_offset>>12, prot, 0, TRUE);
 		}
         		/* Map it in */
 #endif
@@ -3049,7 +3047,7 @@ vm_fault_unwire(
 			result_object = result_page->object;
 			if (deallocate) {
 				assert(!result_page->fictitious);
-				pmap_page_protect(result_page->phys_addr,
+				pmap_page_protect(result_page->phys_page,
 						VM_PROT_NONE);
 				VM_PAGE_FREE(result_page);
 			} else {
@@ -3229,7 +3227,7 @@ vm_fault_wire_fast(
 	 *	may cause other faults.   
 	 */
 	if (m->no_isync == TRUE) {
-	        pmap_sync_caches_phys(m->phys_addr);
+	        pmap_sync_caches_phys(m->phys_page);
 
 		m->no_isync = FALSE;
 	}
diff --git a/osfmk/vm/vm_fault.h b/osfmk/vm/vm_fault.h
index 8c9bd88f5..65b60936e 100644
--- a/osfmk/vm/vm_fault.h
+++ b/osfmk/vm/vm_fault.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/vm/vm_init.c b/osfmk/vm/vm_init.c
index d066f2f58..26bd959e5 100644
--- a/osfmk/vm/vm_init.c
+++ b/osfmk/vm/vm_init.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -103,8 +106,9 @@ vm_mem_bootstrap(void)
 	if (PE_parse_boot_arg("zsize", &zsize))
 		zsize = zsize * 1024 * 1024;
 	else {
-		zsize = mem_size >> 2;			/* Get target zone size as 1/4 of physical memory */
+		zsize = sane_size >> 2;				/* Get target zone size as 1/4 of physical memory */
 	}
+
 	if(zsize < ZONE_MAP_MIN) zsize = ZONE_MAP_MIN;	/* Clamp to min */
 	if(zsize > ZONE_MAP_MAX) zsize = ZONE_MAP_MAX;	/* Clamp to max */
 	zone_init(zsize);						/* Allocate address space for zones */
diff --git a/osfmk/vm/vm_init.h b/osfmk/vm/vm_init.h
index 98733d845..560b8a35b 100644
--- a/osfmk/vm/vm_init.h
+++ b/osfmk/vm/vm_init.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/vm/vm_kern.c b/osfmk/vm/vm_kern.c
index 4d4ee31cb..8b9cda4d5 100644
--- a/osfmk/vm/vm_kern.c
+++ b/osfmk/vm/vm_kern.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -117,7 +120,7 @@ kmem_alloc_contig(
 		return KERN_INVALID_ARGUMENT;
 	}
 
-	size = round_page(size);
+	size = round_page_32(size);
 	if ((flags & KMA_KOBJECT) == 0) {
 		object = vm_object_allocate(size);
 		kr = vm_map_find_space(map, &addr, size, mask, &entry);
@@ -210,7 +213,7 @@ kernel_memory_allocate(
 	vm_offset_t		i;
 	kern_return_t 		kr;
 
-	size = round_page(size);
+	size = round_page_32(size);
 	if ((flags & KMA_KOBJECT) == 0) {
 		/*
 		 *	Allocate a new object.  We must do this before locking
@@ -353,10 +356,10 @@ kmem_realloc(
 	vm_page_t	mem;
 	kern_return_t	kr;
 
-	oldmin = trunc_page(oldaddr);
-	oldmax = round_page(oldaddr + oldsize);
+	oldmin = trunc_page_32(oldaddr);
+	oldmax = round_page_32(oldaddr + oldsize);
 	oldsize = oldmax - oldmin;
-	newsize = round_page(newsize);
+	newsize = round_page_32(newsize);
 
 
 	/*
@@ -503,7 +506,7 @@ kmem_alloc_pageable(
 #else
 	addr = vm_map_min(map);
 #endif
-	kr = vm_map_enter(map, &addr, round_page(size),
+	kr = vm_map_enter(map, &addr, round_page_32(size),
 			  (vm_offset_t) 0, TRUE,
 			  VM_OBJECT_NULL, (vm_object_offset_t) 0, FALSE,
 			  VM_PROT_DEFAULT, VM_PROT_ALL, VM_INHERIT_DEFAULT);
@@ -530,8 +533,9 @@ kmem_free(
 {
 	kern_return_t kr;
 
-	kr = vm_map_remove(map, trunc_page(addr),
-			   round_page(addr + size), VM_MAP_REMOVE_KUNWIRE);
+	kr = vm_map_remove(map, trunc_page_32(addr),
+				round_page_32(addr + size), 
+				VM_MAP_REMOVE_KUNWIRE);
 	if (kr != KERN_SUCCESS)
 		panic("kmem_free");
 }
@@ -547,7 +551,7 @@ kmem_alloc_pages(
 	register vm_size_t		size)
 {
 
-	size = round_page(size);
+	size = round_page_32(size);
         vm_object_lock(object);
 	while (size) {
 	    register vm_page_t	mem;
@@ -614,7 +618,9 @@ kmem_remap_pages(
 	     *	but this shouldn't be a problem because it is wired.
 	     */
 	    PMAP_ENTER(kernel_pmap, start, mem, protection, 
-				VM_WIMG_USE_DEFAULT, TRUE);
+			((unsigned int)(mem->object->wimg_bits))
+					& VM_WIMG_MASK,
+			TRUE);
 
 	    start += PAGE_SIZE;
 	    offset += PAGE_SIZE;
@@ -648,7 +654,7 @@ kmem_suballoc(
 	vm_map_t map;
 	kern_return_t kr;
 
-	size = round_page(size);
+	size = round_page_32(size);
 
 	/*
 	 *	Need reference on submap object because it is internal
@@ -720,9 +726,9 @@ kmem_init(
         /*
          * Account for kernel memory (text, data, bss, vm shenanigans).
          * This may include inaccessible "holes" as determined by what
-         * the machine-dependent init code includes in mem_size.
+         * the machine-dependent init code includes in max_mem.
          */
-        vm_page_wire_count = (atop(mem_size) - (vm_page_free_count
+        vm_page_wire_count = (atop_64(max_mem) - (vm_page_free_count
                                                 + vm_page_active_count
                                                 + vm_page_inactive_count));
 }
@@ -747,7 +753,7 @@ kmem_io_object_trunc(copy, new_size)
 
 	old_size = (vm_size_t)round_page_64(copy->size);
 	copy->size = new_size;
-	new_size = round_page(new_size);
+	new_size = round_page_32(new_size);
 
         vm_object_lock(copy->cpy_object);
         vm_object_page_remove(copy->cpy_object,
diff --git a/osfmk/vm/vm_kern.h b/osfmk/vm/vm_kern.h
index 247448732..fb14c54b5 100644
--- a/osfmk/vm/vm_kern.h
+++ b/osfmk/vm/vm_kern.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/vm/vm_map.c b/osfmk/vm/vm_map.c
index 87b0b30db..050faad8a 100644
--- a/osfmk/vm/vm_map.c
+++ b/osfmk/vm/vm_map.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -81,6 +84,7 @@
 #include <mach/vm_map_server.h>
 #include <mach/mach_host_server.h>
 #include <ddb/tr.h>
+#include <machine/db_machdep.h>
 #include <kern/xpr.h>
 
 /* Internal prototypes
@@ -332,7 +336,7 @@ void
 vm_map_steal_memory(
 	void)
 {
-	map_data_size = round_page(10 * sizeof(struct vm_map));
+	map_data_size = round_page_32(10 * sizeof(struct vm_map));
 	map_data = pmap_steal_memory(map_data_size);
 
 #if 0
@@ -348,7 +352,7 @@ vm_map_steal_memory(
 
 
 	kentry_data_size =
-		round_page(kentry_count * sizeof(struct vm_map_entry));
+		round_page_32(kentry_count * sizeof(struct vm_map_entry));
 	kentry_data = pmap_steal_memory(kentry_data_size);
 }
 
@@ -474,8 +478,8 @@ first_free_is_valid(
 		
 	entry = vm_map_to_entry(map);
 	next = entry->vme_next;
-	while (trunc_page(next->vme_start) == trunc_page(entry->vme_end) ||
-	       (trunc_page(next->vme_start) == trunc_page(entry->vme_start) &&
+	while (trunc_page_32(next->vme_start) == trunc_page_32(entry->vme_end) ||
+	       (trunc_page_32(next->vme_start) == trunc_page_32(entry->vme_start) &&
 		next != vm_map_to_entry(map))) {
 		entry = next;
 		next = entry->vme_next;
@@ -505,10 +509,10 @@ MACRO_BEGIN 								\
 	UFF_map = (map); 						\
 	UFF_first_free = (new_first_free);				\
 	UFF_next_entry = UFF_first_free->vme_next; 			\
-	while (trunc_page(UFF_next_entry->vme_start) == 		\
-	       trunc_page(UFF_first_free->vme_end) || 			\
-	       (trunc_page(UFF_next_entry->vme_start) == 		\
-		trunc_page(UFF_first_free->vme_start) &&		\
+	while (trunc_page_32(UFF_next_entry->vme_start) == 		\
+	       trunc_page_32(UFF_first_free->vme_end) || 			\
+	       (trunc_page_32(UFF_next_entry->vme_start) == 		\
+		trunc_page_32(UFF_first_free->vme_start) &&		\
 		UFF_next_entry != vm_map_to_entry(UFF_map))) { 		\
 		UFF_first_free = UFF_next_entry; 			\
 		UFF_next_entry = UFF_first_free->vme_next; 		\
@@ -654,7 +658,8 @@ vm_map_destroy(
 			     map->max_offset, VM_MAP_NO_FLAGS);
 	vm_map_unlock(map);
 
-	pmap_destroy(map->pmap);
+	if(map->pmap)
+		pmap_destroy(map->pmap);
 
 	zfree(vm_map_zone, (vm_offset_t) map);
 }
@@ -1109,6 +1114,9 @@ vm_map_pmap_enter(
 {
 	unsigned int		cache_attr;
 
+	if(map->pmap == 0)
+		return;
+
 	while (addr < end_addr) {
 		register vm_page_t	m;
 
@@ -1135,7 +1143,7 @@ vm_map_pmap_enter(
 		m->busy = TRUE;
 
 		if (m->no_isync == TRUE) {
-		        pmap_sync_caches_phys(m->phys_addr);
+		        pmap_sync_caches_phys(m->phys_page);
 			m->no_isync = FALSE;
 		}
 
@@ -1445,14 +1453,14 @@ MACRO_BEGIN 								\
 	   		vm_offset_t	pmap_base_addr;			\
 									\
 	   		pmap_base_addr = 0xF0000000 & entry->vme_start;	\
-   	   		pmap_unnest(map->pmap, pmap_base_addr,		\
-			       				0x10000000);	\
+   	   		pmap_unnest(map->pmap, (addr64_t)pmap_base_addr); \
 			entry->use_pmap = FALSE;			\
 		} else if(entry->object.vm_object			\
 			&& !entry->is_sub_map				\
 			&& entry->object.vm_object->phys_contiguous) {	\
 			pmap_remove(map->pmap,				\
-				entry->vme_start, entry->vme_end);	\
+				(addr64_t)(entry->vme_start),		\
+				(addr64_t)(entry->vme_end));		\
 		}							\
 		_vm_map_clip_start(&VMCS_map->hdr,VMCS_entry,VMCS_startaddr);\
 	}								\
@@ -1537,14 +1545,14 @@ MACRO_BEGIN 								\
 	   		vm_offset_t	pmap_base_addr;			\
 									\
 	   		pmap_base_addr = 0xF0000000 & entry->vme_start;	\
-   	   		pmap_unnest(map->pmap, pmap_base_addr,		\
-			       				0x10000000);	\
+ 	   		pmap_unnest(map->pmap, (addr64_t)pmap_base_addr); \
 			entry->use_pmap = FALSE;			\
 		} else if(entry->object.vm_object			\
 			&& !entry->is_sub_map				\
 			&& entry->object.vm_object->phys_contiguous) {	\
 			pmap_remove(map->pmap,				\
-				entry->vme_start, entry->vme_end);	\
+				(addr64_t)(entry->vme_start),		\
+				(addr64_t)(entry->vme_end));		\
 		}							\
 		_vm_map_clip_end(&VMCE_map->hdr,VMCE_entry,VMCE_endaddr); \
 	}								\
@@ -1738,25 +1746,32 @@ vm_map_submap(
 	    (object->copy == VM_OBJECT_NULL) &&
 	    (object->shadow == VM_OBJECT_NULL) &&
 	    (!object->pager_created)) {
-		entry->offset = (vm_object_offset_t)offset;
-		entry->object.vm_object = VM_OBJECT_NULL;
-		vm_object_deallocate(object);
-		entry->is_sub_map = TRUE;
-		vm_map_reference(entry->object.sub_map = submap);
+			entry->offset = (vm_object_offset_t)offset;
+			entry->object.vm_object = VM_OBJECT_NULL;
+			vm_object_deallocate(object);
+			entry->is_sub_map = TRUE;
+			entry->object.sub_map = submap;
+			vm_map_reference(submap);
 #ifndef i386
-		if ((use_pmap) && (offset == 0)) {
-			/* nest if platform code will allow */
-			result = pmap_nest(map->pmap, (entry->object.sub_map)->pmap, 
-							start, end - start);
-			if(result)
-				panic("pmap_nest failed!");
-			entry->use_pmap = TRUE;
-		}
+			if ((use_pmap) && (offset == 0)) {
+				/* nest if platform code will allow */
+				if(submap->pmap == NULL) {
+					submap->pmap = pmap_create((vm_size_t) 0);
+					if(submap->pmap == PMAP_NULL) {
+						return(KERN_NO_SPACE);
+					}
+				}
+				result = pmap_nest(map->pmap, (entry->object.sub_map)->pmap, 
+								(addr64_t)start, (addr64_t)start, (uint64_t)(end - start));
+				if(result)
+					panic("vm_map_submap: pmap_nest failed, rc = %08X\n", result);
+				entry->use_pmap = TRUE;
+			}
 #endif
 #ifdef i386
-		pmap_remove(map->pmap, start, end);
+			pmap_remove(map->pmap, (addr64_t)start, (addr64_t)end);
 #endif
-		result = KERN_SUCCESS;
+			result = KERN_SUCCESS;
 	}
 	vm_map_unlock(map);
 
@@ -1908,8 +1923,7 @@ vm_map_protect(
 				local_entry->use_pmap = FALSE;
 				local_entry = local_entry->vme_next;
 			   }
-			   pmap_unnest(map->pmap, pmap_base_addr,
-			       		(pmap_end_addr - pmap_base_addr) + 1);
+			   pmap_unnest(map->pmap, (addr64_t)pmap_base_addr);
 #endif
 		   }
 		   if (!(current->protection & VM_PROT_WRITE)) {
@@ -2909,7 +2923,8 @@ vm_map_submap_pmap_clean(
 					VM_PROT_NONE);
 			} else {
 				pmap_remove(map->pmap, 
-					start, start + remove_size);
+					(addr64_t)start, 
+					(addr64_t)(start + remove_size));
 			}
 		}
 	}
@@ -2941,9 +2956,10 @@ vm_map_submap_pmap_clean(
 					VM_PROT_NONE);
 			} else {
 				pmap_remove(map->pmap, 
-				   (start + entry->vme_start) - offset,
-				   ((start + entry->vme_start) 
-					- offset) + remove_size);
+				   (addr64_t)((start + entry->vme_start) 
+								- offset),
+				   (addr64_t)(((start + entry->vme_start) 
+					- offset) + remove_size));
 			}
 		}
 		entry = entry->vme_next;
@@ -3200,8 +3216,7 @@ vm_map_delete(
 			if(entry->is_sub_map) {
 			   if(entry->use_pmap) {
 #ifndef i386
-				pmap_unnest(map->pmap, entry->vme_start,
-				        entry->vme_end - entry->vme_start);
+				pmap_unnest(map->pmap, (addr64_t)entry->vme_start);
 #endif
 				if((map->mapped) && (map->ref_count)) {
 					/* clean up parent map/maps */
@@ -3228,8 +3243,8 @@ vm_map_delete(
 						VM_PROT_NONE);
 				} else {
 					pmap_remove(map->pmap, 
-						entry->vme_start, 
-						entry->vme_end);
+						(addr64_t)(entry->vme_start), 
+						(addr64_t)(entry->vme_end));
 				}
 			}
 		}
@@ -3443,7 +3458,7 @@ vm_map_overwrite_submap_recurse(
 	 *	splitting entries in strange ways.
 	 */
 
-	dst_end = round_page(dst_addr + dst_size);
+	dst_end = round_page_32(dst_addr + dst_size);
 	vm_map_lock(dst_map);
 
 start_pass_1:
@@ -3452,7 +3467,7 @@ start_pass_1:
 		return(KERN_INVALID_ADDRESS);
 	}
 
-	vm_map_clip_start(dst_map, tmp_entry, trunc_page(dst_addr));
+	vm_map_clip_start(dst_map, tmp_entry, trunc_page_32(dst_addr));
 
 	for (entry = tmp_entry;;) {
 		vm_map_entry_t	next;
@@ -3673,7 +3688,7 @@ vm_map_copy_overwrite_nested(
 		!page_aligned (dst_addr))
 	{
 		aligned = FALSE;
-		dst_end = round_page(dst_addr + copy->size);
+		dst_end = round_page_32(dst_addr + copy->size);
 	} else {
 		dst_end = dst_addr + copy->size;
 	}
@@ -3685,7 +3700,7 @@ start_pass_1:
 		vm_map_unlock(dst_map);
 		return(KERN_INVALID_ADDRESS);
 	}
-	vm_map_clip_start(dst_map, tmp_entry, trunc_page(dst_addr));
+	vm_map_clip_start(dst_map, tmp_entry, trunc_page_32(dst_addr));
 	for (entry = tmp_entry;;) {
 		vm_map_entry_t	next = entry->vme_next;
 
@@ -4170,7 +4185,7 @@ start_overwrite:
 				break;
 			}
 		}
-		vm_map_clip_start(dst_map, tmp_entry, trunc_page(base_addr));
+		vm_map_clip_start(dst_map, tmp_entry, trunc_page_32(base_addr));
 
 		entry = tmp_entry;
 	} /* while */
@@ -4571,9 +4586,9 @@ vm_map_copy_overwrite_aligned(
 							entry->vme_start,
 							VM_PROT_NONE);
 					} else {
-						pmap_remove(dst_map->pmap, 
-							entry->vme_start, 
-							entry->vme_end);
+					   pmap_remove(dst_map->pmap, 
+					     (addr64_t)(entry->vme_start), 
+					     (addr64_t)(entry->vme_end));
 					}
 					vm_object_deallocate(old_object);
 			   	}
@@ -4640,7 +4655,10 @@ vm_map_copy_overwrite_aligned(
 					/* No isync here */
 
 					PMAP_ENTER(pmap, va, m, prot, 
-						VM_WIMG_USE_DEFAULT, FALSE);
+						((unsigned int)
+							(m->object->wimg_bits)) 
+							& VM_WIMG_MASK,
+						FALSE);
 		
 					vm_object_lock(object);
 					vm_page_lock_queues();
@@ -4802,8 +4820,8 @@ vm_map_copyin_kernel_buffer(
 		        VM_MAP_REMOVE_INTERRUPTIBLE;
 	}
 	if (src_destroy) {
-		(void) vm_map_remove(src_map, trunc_page(src_addr), 
-				     round_page(src_addr + len),
+		(void) vm_map_remove(src_map, trunc_page_32(src_addr), 
+				     round_page_32(src_addr + len),
 				     flags);
 	}
 	*copy_result = copy;
@@ -4839,7 +4857,7 @@ vm_map_copyout_kernel_buffer(
 		*addr = 0;
 		kr = vm_map_enter(map, 
 				  addr, 
-				  round_page(copy->size),
+				  round_page_32(copy->size),
 				  (vm_offset_t) 0, 
 				  TRUE,
 				  VM_OBJECT_NULL, 
@@ -4963,7 +4981,7 @@ vm_map_copyout(
 		vm_object_offset_t	offset;
 
 		offset = trunc_page_64(copy->offset);
-		size = round_page(copy->size + 
+		size = round_page_32(copy->size + 
 				(vm_size_t)(copy->offset - offset));
 		*dst_addr = 0;
 		kr = vm_map_enter(dst_map, dst_addr, size,
@@ -4994,7 +5012,7 @@ vm_map_copyout(
 	 */
 
 	vm_copy_start = trunc_page_64(copy->offset);
-	size =	round_page((vm_size_t)copy->offset + copy->size) 
+	size =	round_page_32((vm_size_t)copy->offset + copy->size) 
 							- vm_copy_start;
 
  StartAgain: ;
@@ -5145,7 +5163,10 @@ vm_map_copyout(
 			vm_object_unlock(object);
 
 			PMAP_ENTER(dst_map->pmap, va, m, entry->protection, 
-						VM_WIMG_USE_DEFAULT, TRUE);
+						((unsigned int)
+							(m->object->wimg_bits)) 
+							& VM_WIMG_MASK,
+						TRUE);
 
 			vm_object_lock(object);
 			PAGE_WAKEUP_DONE(m);
@@ -5195,7 +5216,9 @@ vm_map_copyout(
 
 						PMAP_ENTER(dst_map->pmap, va, 
 							m, prot, 
-							VM_WIMG_USE_DEFAULT, 
+							((unsigned int)
+						        (m->object->wimg_bits)) 
+							   & VM_WIMG_MASK,
 							FALSE);
 
 						vm_object_lock(object);
@@ -5333,8 +5356,8 @@ vm_map_copyin_common(
 	 *	Compute start and end of region
 	 */
 
-	src_start = trunc_page(src_addr);
-	src_end = round_page(src_addr + len);
+	src_start = trunc_page_32(src_addr);
+	src_end = round_page_32(src_addr + len);
 
 	XPR(XPR_VM_MAP, "vm_map_copyin_common map 0x%x addr 0x%x len 0x%x dest %d\n", (natural_t)src_map, src_addr, len, src_destroy, 0);
 
@@ -5463,13 +5486,14 @@ vm_map_copyin_common(
 			src_entry = tmp_entry;
 		}
 		if ((tmp_entry->object.vm_object != VM_OBJECT_NULL) && 
-		    ((tmp_entry->object.vm_object->wimg_bits != VM_WIMG_DEFAULT) ||
-		    (tmp_entry->object.vm_object->phys_contiguous))) {
-			/* This is not, cannot be supported for now */
-			/* we need a description of the caching mode */
-			/* reflected in the object before we can     */
-			/* support copyin, and then the support will */
-			/* be for direct copy */
+		    (tmp_entry->object.vm_object->phys_contiguous)) {
+			/* This is not, supported for now.In future */
+			/* we will need to detect the phys_contig   */
+			/* condition and then upgrade copy_slowly   */
+			/* to do physical copy from the device mem  */
+			/* based object. We can piggy-back off of   */
+			/* the was wired boolean to set-up the      */
+			/* proper handling */
 			RETURN(KERN_PROTECTION_FAILURE);
 		}
 		/*
@@ -5548,8 +5572,9 @@ RestartCopy:
 		XPR(XPR_VM_MAP, "vm_map_copyin_common src_obj 0x%x ent 0x%x obj 0x%x was_wired %d\n",
 		    src_object, new_entry, new_entry->object.vm_object,
 		    was_wired, 0);
-		if (!was_wired &&
-		    vm_object_copy_quickly(
+		if ((src_object == VM_OBJECT_NULL ||
+			(!was_wired && !map_share && !tmp_entry->is_shared)) &&
+			vm_object_copy_quickly(
 				&new_entry->object.vm_object,
 				src_offset,
 				src_size,
@@ -5563,49 +5588,17 @@ RestartCopy:
 			 */
 
 			if (src_needs_copy && !tmp_entry->needs_copy) {
-				if (tmp_entry->is_shared  || 
-				     tmp_entry->object.vm_object->true_share ||
-				     map_share) {
-					vm_map_unlock(src_map);
-					new_entry->object.vm_object = 
-						vm_object_copy_delayed(
-							src_object,
-							src_offset,	
-							src_size);
-					/* dec ref gained in copy_quickly */
-					vm_object_lock(src_object);
-					src_object->ref_count--;
-					assert(src_object->ref_count > 0);
-					vm_object_res_deallocate(src_object);
-					vm_object_unlock(src_object);
-		    			vm_map_lock(src_map);
-					/* 
-					 * it turns out that we have
-					 * finished our copy. No matter
-					 * what the state of the map
-					 * we will lock it again here
-					 * knowing that if there is
-					 * additional data to copy
-					 * it will be checked at
-					 * the top of the loop
-					 *
-					 * Don't do timestamp check
-					 */
-					
-				} else {
-					vm_object_pmap_protect(
-						src_object,
-						src_offset,
-						src_size,
-			      			(src_entry->is_shared ? 
-							PMAP_NULL
-							: src_map->pmap),
-						src_entry->vme_start,
-						src_entry->protection &
-							~VM_PROT_WRITE);
-
-					tmp_entry->needs_copy = TRUE;
-				}
+				vm_object_pmap_protect(
+					src_object,
+					src_offset,
+					src_size,
+			      		(src_entry->is_shared ? 
+						PMAP_NULL
+						: src_map->pmap),
+					src_entry->vme_start,
+					src_entry->protection &
+						~VM_PROT_WRITE);
+				tmp_entry->needs_copy = TRUE;
 			}
 
 			/*
@@ -5617,8 +5610,6 @@ RestartCopy:
 			goto CopySuccessful;
 		}
 
-		new_entry->needs_copy = FALSE;
-
 		/*
 		 *	Take an object reference, so that we may
 		 *	release the map lock(s).
@@ -5640,6 +5631,7 @@ RestartCopy:
 		 */
 
 		if (was_wired) {
+		CopySlowly:
 			vm_object_lock(src_object);
 			result = vm_object_copy_slowly(
 					src_object,
@@ -5649,6 +5641,24 @@ RestartCopy:
 					&new_entry->object.vm_object);
 			new_entry->offset = 0;
 			new_entry->needs_copy = FALSE;
+
+		}
+		else if (src_object->copy_strategy == MEMORY_OBJECT_COPY_SYMMETRIC &&
+			(tmp_entry->is_shared  || map_share)) {
+		  	vm_object_t new_object;
+
+			vm_object_lock(src_object);
+			new_object = vm_object_copy_delayed(
+					src_object,
+					src_offset,	
+					src_size);
+			if (new_object == VM_OBJECT_NULL)
+			  	goto CopySlowly;
+
+			new_entry->object.vm_object = new_object;
+			new_entry->needs_copy = TRUE;
+			result = KERN_SUCCESS;
+
 		} else {
 			result = vm_object_copy_strategically(src_object,
 				src_offset,
@@ -5658,7 +5668,6 @@ RestartCopy:
 				&new_entry_needs_copy);
 
 			new_entry->needs_copy = new_entry_needs_copy;
-			
 		}
 
 		if (result != KERN_SUCCESS &&
@@ -5797,7 +5806,7 @@ RestartCopy:
 	 */
 	if (src_destroy) {
 		(void) vm_map_delete(src_map,
-				     trunc_page(src_addr),
+				     trunc_page_32(src_addr),
 				     src_end,
 				     (src_map == kernel_map) ?
 					VM_MAP_REMOVE_KUNWIRE :
@@ -5884,8 +5893,9 @@ vm_map_fork_share(
 		if(old_entry->use_pmap) {
 			result = pmap_nest(new_map->pmap, 
 				(old_entry->object.sub_map)->pmap, 
-				old_entry->vme_start,
-				old_entry->vme_end - old_entry->vme_start);
+				(addr64_t)old_entry->vme_start,
+				(addr64_t)old_entry->vme_start,
+				(uint64_t)(old_entry->vme_end - old_entry->vme_start));
 			if(result)
 				panic("vm_map_fork_share: pmap_nest failed!");
 		}
@@ -7631,7 +7641,8 @@ vm_region_look_for_page(
 	        	if (shadow && (max_refcnt == 1))
 		    		extended->pages_shared_now_private++;
 
-			if (p->dirty || pmap_is_modified(p->phys_addr))
+			if (!p->fictitious && 
+				(p->dirty || pmap_is_modified(p->phys_page)))
 		    		extended->pages_dirtied++;
 	        	extended->pages_resident++;
 
@@ -7690,7 +7701,7 @@ vm_region_count_obj_refs(
 	    return(0);
 
         if (entry->is_sub_map)
-	    ref_count = vm_region_count_obj_refs((vm_map_entry_t)entry->object.sub_map, object);
+	    return(0);
 	else {
 	    ref_count = 0;
 
@@ -7853,9 +7864,9 @@ vm_map_machine_attribute(
 	}
 
 	/* Get the starting address */
-	start = trunc_page(address);
+	start = trunc_page_32(address);
 	/* Figure how much memory we need to flush (in page increments) */
-	sync_size = round_page(start + size) - start;	
+	sync_size = round_page_32(start + size) - start;	
 
 
 	ret = KERN_SUCCESS;										/* Assume it all worked */
@@ -7898,7 +7909,7 @@ vm_map_machine_attribute(
 	
 						  ret = 
 						     pmap_attribute_cache_sync(
-							m->phys_addr, 
+							m->phys_page, 	
 							PAGE_SIZE, 
 							attribute, value);
 						} else if (object->shadow) {
@@ -8028,7 +8039,7 @@ void
 vm_map_links_print(
 	struct vm_map_links	*links)
 {
-	iprintf("prev=0x%x, next=0x%x, start=0x%x, end=0x%x\n",
+	iprintf("prev = %08X  next = %08X  start = %08X  end = %08X\n",
 		links->prev,
 		links->next,
 		links->start,
@@ -8043,7 +8054,7 @@ vm_map_header_print(
 	struct vm_map_header	*header)
 {
 	vm_map_links_print(&header->links);
-	iprintf("nentries=0x%x, %sentries_pageable\n",
+	iprintf("nentries = %08X, %sentries_pageable\n",
 		header->nentries,
 		(header->entries_pageable ? "" : "!"));
 }
@@ -8058,7 +8069,7 @@ vm_follow_entry(
 	extern int db_indent;
 	int shadows;
 
-	iprintf("map entry 0x%x:\n", entry);
+	iprintf("map entry %08X\n", entry);
 
 	db_indent += 2;
 
@@ -8079,20 +8090,20 @@ vm_map_entry_print(
 	static char *inheritance_name[4] = { "share", "copy", "none", "?"};
 	static char *behavior_name[4] = { "dflt", "rand", "seqtl", "rseqntl" };
 	
-	iprintf("map entry 0x%x:\n", entry);
+	iprintf("map entry %08X n", entry);
 
 	db_indent += 2;
 
 	vm_map_links_print(&entry->links);
 
-	iprintf("start=0x%x, end=0x%x, prot=%x/%x/%s\n",
+	iprintf("start = %08X  end = %08X, prot=%x/%x/%s\n",
 		entry->vme_start,
 		entry->vme_end,
 		entry->protection,
 		entry->max_protection,
 		inheritance_name[(entry->inheritance & 0x3)]);
 
-	iprintf("behavior=%s, wired_count=%d, user_wired_count=%d\n",
+	iprintf("behavior = %s, wired_count = %d, user_wired_count = %d\n",
 		behavior_name[(entry->behavior & 0x3)],
 		entry->wired_count,
 		entry->user_wired_count);
@@ -8101,11 +8112,11 @@ vm_map_entry_print(
 		(entry->needs_wakeup ? "" : "!"));
 
 	if (entry->is_sub_map) {
-		iprintf("submap=0x%x, offset=0x%x\n",
+		iprintf("submap = %08X - offset=%08X\n",
 		       entry->object.sub_map,
 		       entry->offset);
 	} else {
-		iprintf("object=0x%x, offset=0x%x, ",
+		iprintf("object=%08X, offset=%08X, ",
 			entry->object.vm_object,
 			entry->offset);
 		printf("%sis_shared, %sneeds_copy\n",
@@ -8126,7 +8137,7 @@ vm_follow_map(
 	register vm_map_entry_t	entry;
 	extern int db_indent;
 
-	iprintf("task map 0x%x:\n", map);
+	iprintf("task map %08X\n", map);
 
 	db_indent += 2;
 
@@ -8144,26 +8155,29 @@ vm_follow_map(
  */
 void
 vm_map_print(
-	register vm_map_t	map)
+	db_addr_t inmap)
 {
 	register vm_map_entry_t	entry;
+	vm_map_t map;
 	extern int db_indent;
 	char *swstate;
 
-	iprintf("task map 0x%x:\n", map);
+	map = (vm_map_t)inmap;				/* Make sure we have the right type */
+
+	iprintf("task map %08X\n", map);
 
 	db_indent += 2;
 
 	vm_map_header_print(&map->hdr);
 
-	iprintf("pmap=0x%x, size=%d, ref=%d, hint=0x%x, first_free=0x%x\n",
+	iprintf("pmap = %08X, size = %08X, ref = %d, hint = %08X, first_free = %08X\n",
 		map->pmap,
 		map->size,
 		map->ref_count,
 		map->hint,
 		map->first_free);
 
-	iprintf("%swait_for_space, %swiring_required, timestamp=%d\n",
+	iprintf("%swait_for_space, %swiring_required, timestamp = %d\n",
 		(map->wait_for_space ? "" : "!"),
 		(map->wiring_required ? "" : "!"),
 		map->timestamp);
@@ -8180,7 +8194,7 @@ vm_map_print(
 		swstate = "????";
 		break;
 	}
-	iprintf("res=%d, sw_state=%s\n", map->res_count, swstate);
+	iprintf("res = %d, sw_state = %s\n", map->res_count, swstate);
 #endif	/* TASK_SWAPPER */
 
 	for (entry = vm_map_first_entry(map);
@@ -8200,12 +8214,15 @@ vm_map_print(
 
 void
 vm_map_copy_print(
-	vm_map_copy_t	copy)
+	db_addr_t	incopy)
 {
 	extern int db_indent;
+	vm_map_copy_t copy;
 	int i, npages;
 	vm_map_entry_t entry;
 
+	copy = (vm_map_copy_t)incopy;	/* Make sure we have the right type */
+
 	printf("copy object 0x%x\n", copy);
 
 	db_indent += 2;
@@ -8262,10 +8279,13 @@ vm_map_copy_print(
  */
 vm_size_t
 db_vm_map_total_size(
-	vm_map_t	map)
+	db_addr_t	inmap)
 {
 	vm_map_entry_t	entry;
 	vm_size_t	total;
+	vm_map_t map;
+
+	map = (vm_map_t)inmap;	/* Make sure we have the right type */
 
 	total = 0;
 	for (entry = vm_map_first_entry(map);
@@ -8375,7 +8395,7 @@ vm_remap_extract(
 	boolean_t		new_entry_needs_copy;
 
 	assert(map != VM_MAP_NULL);
-	assert(size != 0 && size == round_page(size));
+	assert(size != 0 && size == round_page_32(size));
 	assert(inheritance == VM_INHERIT_NONE ||
 	       inheritance == VM_INHERIT_COPY ||
 	       inheritance == VM_INHERIT_SHARE);
@@ -8383,8 +8403,8 @@ vm_remap_extract(
 	/*
 	 *	Compute start and end of region.
 	 */
-	src_start = trunc_page(addr);
-	src_end = round_page(src_start + size);
+	src_start = trunc_page_32(addr);
+	src_end = round_page_32(src_start + size);
 
 	/*
 	 *	Initialize map_header.
@@ -8704,7 +8724,7 @@ vm_remap(
 		return KERN_INVALID_ARGUMENT;
 	}
 
-	size = round_page(size);
+	size = round_page_32(size);
 
 	result = vm_remap_extract(src_map, memory_address,
 				  size, copy, &map_header,
@@ -8722,7 +8742,7 @@ vm_remap(
 	 * Allocate/check a range of free virtual address
 	 * space for the target
 	 */
-	*address = trunc_page(*address);
+	*address = trunc_page_32(*address);
 	vm_map_lock(target_map);
 	result = vm_remap_range_allocate(target_map, address, size,
 					 mask, anywhere, &insp_entry);
diff --git a/osfmk/vm/vm_map.h b/osfmk/vm/vm_map.h
index c32c121be..d0f12dacc 100644
--- a/osfmk/vm/vm_map.h
+++ b/osfmk/vm/vm_map.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -865,6 +868,12 @@ extern kern_return_t vm_map_region_replace(
 				vm_offset_t	start,  
 				vm_offset_t	end);
 
+extern boolean_t vm_map_check_protection(
+				vm_map_t	map,
+				vm_offset_t	start,
+				vm_offset_t	end,
+				vm_prot_t	protection);
+
 /*
  *	Macros to invoke vm_map_copyin_common.  vm_map_copyin is the
  *	usual form; it handles a copyin based on the current protection
diff --git a/osfmk/vm/vm_object.c b/osfmk/vm/vm_object.c
index 3e2579dbf..a0f8bff17 100644
--- a/osfmk/vm/vm_object.c
+++ b/osfmk/vm/vm_object.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -406,8 +409,8 @@ vm_object_bootstrap(void)
 	register 	i;
 
 	vm_object_zone = zinit((vm_size_t) sizeof(struct vm_object),
-				round_page(512*1024),
-				round_page(12*1024),
+				round_page_32(512*1024),
+				round_page_32(12*1024),
 				"vm objects");
 
 	queue_init(&vm_object_cached_list);
@@ -415,8 +418,8 @@ vm_object_bootstrap(void)
 
 	vm_object_hash_zone =
 			zinit((vm_size_t) sizeof (struct vm_object_hash_entry),
-			      round_page(512*1024),
-			      round_page(12*1024),
+			      round_page_32(512*1024),
+			      round_page_32(12*1024),
 			      "vm object hash entries");
 
 	for (i = 0; i < VM_OBJECT_HASH_COUNT; i++)
@@ -493,10 +496,17 @@ vm_object_bootstrap(void)
 
 /*
  *	Note that in the following size specifications, we need to add 1 because 
- *	VM_MAX_KERNEL_ADDRESS is a maximum address, not a size.
+ *	VM_MAX_KERNEL_ADDRESS (vm_last_addr) is a maximum address, not a size.
  */
+
+#ifdef ppc
+	_vm_object_allocate((vm_last_addr - VM_MIN_KERNEL_ADDRESS) + 1,
+			kernel_object);
+#else
 	_vm_object_allocate((VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS) + 1,
 			kernel_object);
+#endif
+	kernel_object->copy_strategy = MEMORY_OBJECT_COPY_NONE;
 
 	/*
 	 *	Initialize the "submap object".  Make it as large as the
@@ -504,8 +514,15 @@ vm_object_bootstrap(void)
 	 */
 
 	vm_submap_object = &vm_submap_object_store;
+#ifdef ppc
+	_vm_object_allocate((vm_last_addr - VM_MIN_KERNEL_ADDRESS) + 1,
+			vm_submap_object);
+#else
 	_vm_object_allocate((VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS) + 1,
 			vm_submap_object);
+#endif
+	vm_submap_object->copy_strategy = MEMORY_OBJECT_COPY_NONE;
+
 	/*
 	 * Create an "extra" reference to this object so that we never
 	 * try to deallocate it; zfree doesn't like to be called with
@@ -921,7 +938,7 @@ vm_object_terminate(
 			panic("vm_object_terminate.4 0x%x 0x%x", object, p);
 
 		if (!p->dirty)
-			p->dirty = pmap_is_modified(p->phys_addr);
+			p->dirty = pmap_is_modified(p->phys_page);
 
 		if ((p->dirty || p->precious) && !p->error && object->alive) {
 			p->busy = TRUE;
@@ -1317,12 +1334,12 @@ vm_object_deactivate_pages(
 				if ((m->wire_count == 0) && (!m->private) && (!m->gobbled) && (!m->busy)) {
 
 					m->reference = FALSE;
-					pmap_clear_reference(m->phys_addr);
+					pmap_clear_reference(m->phys_page);
 
 					if ((kill_page) && (object->internal)) {
 				        	m->precious = FALSE;
 					        m->dirty = FALSE;
-						pmap_clear_modify(m->phys_addr);
+						pmap_clear_modify(m->phys_page);
 						vm_external_state_clr(object->existence_map, offset);
 					}
 					VM_PAGE_QUEUES_REMOVE(m);
@@ -1408,10 +1425,8 @@ vm_object_pmap_protect(
 
 	vm_object_lock(object);
 
-	assert(object->copy_strategy == MEMORY_OBJECT_COPY_SYMMETRIC);
-
 	while (TRUE) {
-	    if (object->resident_page_count > atop(size) / 2 &&
+	    if (object->resident_page_count > atop_32(size) / 2 &&
 		    pmap != PMAP_NULL) {
 		vm_object_unlock(object);
 		pmap_protect(pmap, pmap_start, pmap_start + size, prot);
@@ -1421,7 +1436,7 @@ vm_object_pmap_protect(
 	    /* if we are doing large ranges with respect to resident */
 	    /* page count then we should interate over pages otherwise */
 	    /* inverse page look-up will be faster */
-	    if ((object->resident_page_count / 4) <  atop(size)) {
+	    if ((object->resident_page_count / 4) <  atop_32(size)) {
 		vm_page_t		p;
 		vm_object_offset_t	end;
 
@@ -1443,7 +1458,7 @@ vm_object_pmap_protect(
 		    if (!p->fictitious &&
 			(offset <= p->offset) && (p->offset < end)) {
 
-			    pmap_page_protect(p->phys_addr,
+			    pmap_page_protect(p->phys_page,
 					      prot & ~p->page_lock);
 		    }
 		  }
@@ -1469,7 +1484,7 @@ vm_object_pmap_protect(
 			for(target_off = offset; 
 				target_off < end; target_off += PAGE_SIZE) {
 				if(p = vm_page_lookup(object, target_off)) {
-		    			pmap_page_protect(p->phys_addr,
+		    			pmap_page_protect(p->phys_page,
 						      prot & ~p->page_lock);
 				}
 		    	}
@@ -1932,7 +1947,8 @@ static int copy_delayed_protect_lookup_wait = 0;
  *		the asymmetric copy-on-write algorithm.
  *
  *	In/out conditions:
- *		The object must be unlocked on entry.
+ *		The src_object must be locked on entry.  It will be unlocked
+ *		on exit - so the caller must also hold a reference to it.
  *
  *		This routine will not block waiting for user-generated
  *		events.  It is not interruptible.
@@ -1946,7 +1962,7 @@ vm_object_copy_delayed(
 	vm_object_t		new_copy = VM_OBJECT_NULL;
 	vm_object_t		old_copy;
 	vm_page_t		p;
-	vm_object_size_t	copy_size;
+	vm_object_size_t	copy_size = src_offset + size;
 
 	int collisions = 0;
 	/*
@@ -1989,8 +2005,13 @@ vm_object_copy_delayed(
 	 */
 
  Retry:
-	vm_object_lock(src_object);
  
+	/*
+	 * Wait for paging in progress.
+	 */
+	if (!src_object->true_share)
+		vm_object_paging_wait(src_object, THREAD_UNINT);
+
 	/*
 	 *	See whether we can reuse the result of a previous
 	 *	copy operation.
@@ -2013,6 +2034,7 @@ vm_object_copy_delayed(
 			if (collisions > copy_delayed_max_collisions)
 				copy_delayed_max_collisions = collisions;
 
+			vm_object_lock(src_object);
 			goto Retry;
 		}
 
@@ -2027,52 +2049,66 @@ vm_object_copy_delayed(
 			 *	It has not been modified.
 			 *
 			 *	Return another reference to
-			 *	the existing copy-object.
+			 *	the existing copy-object if
+			 *	we can safely grow it (if
+			 *	needed).
 			 */
-			assert(old_copy->ref_count > 0);
-			old_copy->ref_count++;
-
-			if (old_copy->size < src_offset+size)
-				old_copy->size = src_offset+size;
-
-#if	TASK_SWAPPER
-			/*
-			 * We have to reproduce some of the code from
-			 * vm_object_res_reference because we've taken
-			 * the locks out of order here, and deadlock
-			 * would result if we simply called that function.
-			 */
-			if (++old_copy->res_count == 1) {
-				assert(old_copy->shadow == src_object);
-				vm_object_res_reference(src_object);
-			}
-#endif	/* TASK_SWAPPER */
-
-			vm_object_unlock(old_copy);
-			vm_object_unlock(src_object);
 
 			if (new_copy != VM_OBJECT_NULL) {
 				vm_object_unlock(new_copy);
 				vm_object_deallocate(new_copy);
 			}
 
-			return(old_copy);
-		}
-		if (new_copy == VM_OBJECT_NULL) {
+			if (old_copy->size < copy_size) {
+				/*
+				 * We can't perform a delayed copy if any of the
+				 * pages in the extended range are wired (because
+				 * we can't safely take write permission away from
+				 * wired pages).  If the pages aren't wired, then
+				 * go ahead and protect them.
+				 */
+				copy_delayed_protect_iterate++;
+				queue_iterate(&src_object->memq, p, vm_page_t, listq) {
+					if (!p->fictitious && 
+					    p->offset >= old_copy->size && 
+					    p->offset < copy_size) {
+						if (p->wire_count > 0) {
+							vm_object_unlock(old_copy);
+							vm_object_unlock(src_object);
+							return VM_OBJECT_NULL;
+						} else {
+							pmap_page_protect(p->phys_page, 
+								(VM_PROT_ALL & ~VM_PROT_WRITE &
+								 ~p->page_lock));
+						}
+					}
+				}
+				old_copy->size = copy_size;
+			}
+				
+			vm_object_reference_locked(old_copy);
 			vm_object_unlock(old_copy);
 			vm_object_unlock(src_object);
-			new_copy = vm_object_allocate(src_offset + size);
-			vm_object_lock(new_copy);
-			goto Retry;
+			return(old_copy);
 		}
 
 		/*
 		 * Adjust the size argument so that the newly-created 
 		 * copy object will be large enough to back either the
-		 * new old copy object or the new mapping.
+		 * old copy object or the new mapping.
 		 */
-		if (old_copy->size > src_offset+size)
-			size =  old_copy->size - src_offset;
+		if (old_copy->size > copy_size)
+			copy_size = old_copy->size;
+
+		if (new_copy == VM_OBJECT_NULL) {
+			vm_object_unlock(old_copy);
+			vm_object_unlock(src_object);
+			new_copy = vm_object_allocate(copy_size);
+			vm_object_lock(src_object);
+			vm_object_lock(new_copy);
+			goto Retry;
+		}
+		new_copy->size = copy_size;	
 
 		/*
 		 *	The copy-object is always made large enough to
@@ -2084,6 +2120,44 @@ vm_object_copy_delayed(
 		assert((old_copy->shadow == src_object) &&
 		    (old_copy->shadow_offset == (vm_object_offset_t) 0));
 
+	} else if (new_copy == VM_OBJECT_NULL) {
+		vm_object_unlock(src_object);
+		new_copy = vm_object_allocate(copy_size);
+		vm_object_lock(src_object);
+		vm_object_lock(new_copy);
+		goto Retry;
+	}
+
+	/*
+	 * We now have the src object locked, and the new copy object
+	 * allocated and locked (and potentially the old copy locked).
+	 * Before we go any further, make sure we can still perform
+	 * a delayed copy, as the situation may have changed.
+	 *
+	 * Specifically, we can't perform a delayed copy if any of the
+	 * pages in the range are wired (because we can't safely take
+	 * write permission away from wired pages).  If the pages aren't
+	 * wired, then go ahead and protect them.
+	 */
+	copy_delayed_protect_iterate++;
+	queue_iterate(&src_object->memq, p, vm_page_t, listq) {
+		if (!p->fictitious && p->offset < copy_size) {
+			if (p->wire_count > 0) {
+				if (old_copy)
+					vm_object_unlock(old_copy);
+				vm_object_unlock(src_object);
+				vm_object_unlock(new_copy);
+				vm_object_deallocate(new_copy);
+				return VM_OBJECT_NULL;
+			} else {
+				pmap_page_protect(p->phys_page, 
+					(VM_PROT_ALL & ~VM_PROT_WRITE &
+					 ~p->page_lock));
+			}
+		}
+	}
+
+	if (old_copy != VM_OBJECT_NULL) {
 		/*
 		 *	Make the old copy-object shadow the new one.
 		 *	It will receive no more pages from the original
@@ -2104,26 +2178,11 @@ vm_object_copy_delayed(
 #endif
 
 		vm_object_unlock(old_copy);	/* done with old_copy */
-	} else if (new_copy == VM_OBJECT_NULL) {
-		vm_object_unlock(src_object);
-		new_copy = vm_object_allocate(src_offset + size);
-		vm_object_lock(new_copy);
-		goto Retry;
-	}
-
-	/*
-	 * Readjust the copy-object size if necessary.
-	 */
-	copy_size = new_copy->size;
-	if (copy_size < src_offset+size) {
-		copy_size = src_offset+size;
-		new_copy->size = copy_size;
 	}
 
 	/*
 	 *	Point the new copy at the existing object.
 	 */
-
 	new_copy->shadow = src_object;
 	new_copy->shadow_offset = 0;
 	new_copy->shadowed = TRUE;	/* caller must set needs_copy */
@@ -2131,23 +2190,9 @@ vm_object_copy_delayed(
 	src_object->ref_count++;
 	VM_OBJ_RES_INCR(src_object);
 	src_object->copy = new_copy;
+	vm_object_unlock(src_object);
 	vm_object_unlock(new_copy);
 
-	/*
-	 *	Mark all (current) pages of the existing object copy-on-write.
-	 *	This object may have a shadow chain below it, but
-	 *	those pages will already be marked copy-on-write.
-	 */
-
-	vm_object_paging_wait(src_object, THREAD_UNINT);
-	copy_delayed_protect_iterate++;
-	queue_iterate(&src_object->memq, p, vm_page_t, listq) {
-	    if (!p->fictitious)
-		pmap_page_protect(p->phys_addr, 
-				  (VM_PROT_ALL & ~VM_PROT_WRITE &
-				   ~p->page_lock));
-	}
-	vm_object_unlock(src_object);
 	XPR(XPR_VM_OBJECT,
 		"vm_object_copy_delayed: used copy object %X for source %X\n",
 		(integer_t)new_copy, (integer_t)src_object, 0, 0, 0);
@@ -2207,6 +2252,18 @@ vm_object_copy_strategically(
 	 */
 
 	switch (copy_strategy) {
+	    case MEMORY_OBJECT_COPY_DELAY:
+		*dst_object = vm_object_copy_delayed(src_object,
+						     src_offset, size);
+		if (*dst_object != VM_OBJECT_NULL) {
+			*dst_offset = src_offset;
+			*dst_needs_copy = TRUE;
+			result = KERN_SUCCESS;
+			break;
+		}
+		vm_object_lock(src_object);
+		/* fall thru when delayed copy not allowed */
+
 	    case MEMORY_OBJECT_COPY_NONE:
 		result = vm_object_copy_slowly(src_object, src_offset, size,
 					       interruptible, dst_object);
@@ -2225,15 +2282,6 @@ vm_object_copy_strategically(
 		}
 		break;
 
-	    case MEMORY_OBJECT_COPY_DELAY:
-		vm_object_unlock(src_object);
-		*dst_object = vm_object_copy_delayed(src_object,
-						     src_offset, size);
-		*dst_offset = src_offset;
-		*dst_needs_copy = TRUE;
-		result = KERN_SUCCESS;
-		break;
-
 	    case MEMORY_OBJECT_COPY_SYMMETRIC:
 		XPR(XPR_VM_OBJECT, "v_o_c_strategically obj 0x%x off 0x%x size 0x%x\n",(natural_t)src_object, src_offset, size, 0, 0);
 		vm_object_unlock(src_object);
@@ -3430,7 +3478,7 @@ vm_object_page_remove(
 	 *	It balances vm_object_lookup vs iteration.
 	 */
 
-	if (atop(end - start) < (unsigned)object->resident_page_count/16) {
+	if (atop_64(end - start) < (unsigned)object->resident_page_count/16) {
 		vm_object_page_remove_lookup++;
 
 		for (; start < end; start += PAGE_SIZE_64) {
@@ -3438,7 +3486,7 @@ vm_object_page_remove(
 			if (p != VM_PAGE_NULL) {
 				assert(!p->cleaning && !p->pageout);
 				if (!p->fictitious)
-					pmap_page_protect(p->phys_addr,
+					pmap_page_protect(p->phys_page,
 							  VM_PROT_NONE);
 				VM_PAGE_FREE(p);
 			}
@@ -3452,7 +3500,7 @@ vm_object_page_remove(
 			if ((start <= p->offset) && (p->offset < end)) {
 				assert(!p->cleaning && !p->pageout);
 				if (!p->fictitious)
-				    pmap_page_protect(p->phys_addr,
+				    pmap_page_protect(p->phys_page,
 						      VM_PROT_NONE);
 				VM_PAGE_FREE(p);
 			}
@@ -3597,7 +3645,7 @@ vm_object_page_map(
 	vm_page_t	old_page;
 	vm_object_offset_t	addr;
 
-	num_pages = atop(size);
+	num_pages = atop_64(size);
 
 	for (i = 0; i < num_pages; i++, offset += PAGE_SIZE_64) {
 
@@ -3962,27 +4010,24 @@ vm_object_find(
 
 kern_return_t
 vm_object_populate_with_private(
-		vm_object_t	object,
+		vm_object_t		object,
 		vm_object_offset_t	offset,
-		vm_offset_t	phys_addr,
-		vm_size_t	size)
+		ppnum_t			phys_page,
+		vm_size_t		size)
 {
-	vm_offset_t		base_addr;
+	ppnum_t			base_page;
 	vm_object_offset_t	base_offset;
 
 
 	if(!object->private)
 		return KERN_FAILURE;
 
-	if((base_addr = trunc_page(phys_addr)) != phys_addr) {
-		return KERN_FAILURE;
-	}
-
+	base_page = phys_page;
 
 	vm_object_lock(object);
 	if(!object->phys_contiguous) {
 		vm_page_t	m;
-		if((base_offset = trunc_page(offset)) != offset) {
+		if((base_offset = trunc_page_64(offset)) != offset) {
 			vm_object_unlock(object);
 			return KERN_FAILURE;
 		}
@@ -3994,7 +4039,7 @@ vm_object_populate_with_private(
 					vm_page_lock_queues();
 					m->fictitious = FALSE;
 					m->private = TRUE;
-					m->phys_addr = base_addr;
+					m->phys_page = base_page;
 					if(!m->busy) {
 						m->busy = TRUE;
 					}
@@ -4004,11 +4049,11 @@ vm_object_populate_with_private(
 					}
 					m->list_req_pending = TRUE;
 					vm_page_unlock_queues();
-				} else if (m->phys_addr != base_addr) {
+				} else if (m->phys_page != base_page) {
 					/* pmap call to clear old mapping */
-					pmap_page_protect(m->phys_addr,
+					pmap_page_protect(m->phys_page,
 								VM_PROT_NONE);
-					m->phys_addr = base_addr;
+					m->phys_page = base_page;
 				}
 			} else {
 				while ((m = vm_page_grab_fictitious()) 
@@ -4017,7 +4062,7 @@ vm_object_populate_with_private(
 				vm_page_lock_queues();
 				m->fictitious = FALSE;
 				m->private = TRUE;
-				m->phys_addr = base_addr;
+				m->phys_page = base_page;
 				m->list_req_pending = TRUE;
 				m->absent = TRUE;
 				m->unusual = TRUE;
@@ -4025,7 +4070,7 @@ vm_object_populate_with_private(
 				vm_page_unlock_queues();
 	    			vm_page_insert(m, object, base_offset);
 			}
-			base_addr += PAGE_SIZE;
+			base_page++;									/* Go to the next physical page */
 			base_offset += PAGE_SIZE;
 			size -= PAGE_SIZE;
 		}
@@ -4038,7 +4083,7 @@ vm_object_populate_with_private(
 		
 		/* shadows on contiguous memory are not allowed */
 		/* we therefore can use the offset field */
-		object->shadow_offset = (vm_object_offset_t)phys_addr;
+		object->shadow_offset = (vm_object_offset_t)(phys_page << 12);
 		object->size = size;
 	}
 	vm_object_unlock(object);
@@ -4379,7 +4424,7 @@ vm_object_lock_request(
 	if ((prot & ~VM_PROT_ALL) != 0 && prot != VM_PROT_NO_CHANGE)
 		return (KERN_INVALID_ARGUMENT);
 
-	size = round_page(size);
+	size = round_page_64(size);
 
 	/*
 	 *	Lock the object, and acquire a paging reference to
diff --git a/osfmk/vm/vm_object.h b/osfmk/vm/vm_object.h
index 679ea7eb9..dbfc2a85e 100644
--- a/osfmk/vm/vm_object.h
+++ b/osfmk/vm/vm_object.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/osfmk/vm/vm_page.h b/osfmk/vm/vm_page.h
index 7ab8fe83e..a449f5dfa 100644
--- a/osfmk/vm/vm_page.h
+++ b/osfmk/vm/vm_page.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -177,7 +180,7 @@ struct vm_page {
 					   /* a pageout candidate           */
         /* we've used up all 32 bits */
 
-	vm_offset_t	phys_addr;	/* Physical address of page, passed
+	vm_offset_t	phys_page;	/* Physical address of page, passed
 					 *  to pmap_enter (read-only) */
 };
 
@@ -273,8 +276,8 @@ extern void		vm_page_bootstrap(
 extern void		vm_page_module_init(void);
 
 extern void		vm_page_create(
-					vm_offset_t	start,
-					vm_offset_t	end);
+					ppnum_t		start,
+					ppnum_t		end);
 
 extern vm_page_t	vm_page_lookup(
 					vm_object_t		object,
@@ -313,7 +316,7 @@ extern vm_page_t	vm_page_alloc(
 
 extern void		vm_page_init(
 					vm_page_t	page,
-					vm_offset_t	phys_addr);
+					ppnum_t		phys_page);
 
 extern void		vm_page_free(
 					vm_page_t	page);
diff --git a/osfmk/vm/vm_pageout.c b/osfmk/vm/vm_pageout.c
index 3dee3f693..ab64d42ff 100644
--- a/osfmk/vm/vm_pageout.c
+++ b/osfmk/vm/vm_pageout.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -74,6 +77,7 @@
 #include <kern/thread.h>
 #include <kern/xpr.h>
 #include <vm/pmap.h>
+#include <vm/vm_fault.h>
 #include <vm/vm_map.h>
 #include <vm/vm_object.h>
 #include <vm/vm_page.h>
@@ -389,14 +393,14 @@ vm_pageout_object_terminate(
 			 * from being dirtied after the pmap_is_modified() call
 			 * returns.
 			 */
-			pmap_page_protect(m->phys_addr, VM_PROT_NONE);
+			pmap_page_protect(m->phys_page, VM_PROT_NONE);
 
 			/*
 			 * Since the page is left "dirty" but "not modifed", we
 			 * can detect whether the page was redirtied during
 			 * pageout by checking the modify state.
 			 */
-			m->dirty = pmap_is_modified(m->phys_addr);
+			m->dirty = pmap_is_modified(m->phys_page);
 
 			if (m->dirty) {
 				CLUSTER_STAT(vm_pageout_target_page_dirtied++;)
@@ -434,7 +438,7 @@ vm_pageout_object_terminate(
 			/* out the pages but handling outside of this code */
 			/* will take care of resetting dirty. We clear the */
 			/* modify however for the Programmed I/O case.     */ 
-			pmap_clear_modify(m->phys_addr);
+			pmap_clear_modify(m->phys_page);
 			if(m->absent) {
 				m->absent = FALSE;
 				if(shadow_object->absent_count == 1)
@@ -461,7 +465,7 @@ vm_pageout_object_terminate(
 		 * consulted if m->dirty is false.
 		 */
 #if MACH_CLUSTER_STATS
-			m->dirty = pmap_is_modified(m->phys_addr);
+			m->dirty = pmap_is_modified(m->phys_page);
 
 			if (m->dirty)	vm_pageout_cluster_dirtied++;
 			else		vm_pageout_cluster_cleaned++;
@@ -472,7 +476,6 @@ vm_pageout_object_terminate(
 		}
 		m->cleaning = FALSE;
 
-
 		/*
 		 * Wakeup any thread waiting for the page to be un-cleaning.
 		 */
@@ -566,7 +569,7 @@ vm_pageout_setup(
 		/*
 		 * Set up new page to be private shadow of real page.
 		 */
-		new_m->phys_addr = m->phys_addr;
+		new_m->phys_page = m->phys_page;
 		new_m->fictitious = FALSE;
 		new_m->pageout = TRUE;
 
@@ -576,7 +579,7 @@ vm_pageout_setup(
 		 * pageout (indicating that the page should be freed
 		 * when the pageout completes).
 		 */
-		pmap_clear_modify(m->phys_addr);
+		pmap_clear_modify(m->phys_page);
 		vm_page_lock_queues();
 		new_m->private = TRUE;
 		vm_page_wire(new_m);
@@ -674,7 +677,7 @@ vm_pageclean_setup(
 		(integer_t)old_object, m->offset, (integer_t)m, 
 		(integer_t)new_m, new_offset);
 
-	pmap_clear_modify(m->phys_addr);
+	pmap_clear_modify(m->phys_page);
 	vm_object_paging_begin(old_object);
 
 	/*
@@ -699,7 +702,7 @@ vm_pageclean_setup(
 	new_m->fictitious = FALSE;
 	new_m->private = TRUE;
 	new_m->pageout = TRUE;
-	new_m->phys_addr = m->phys_addr;
+	new_m->phys_page = m->phys_page;
 	vm_page_wire(new_m);
 
 	vm_page_insert(new_m, new_object, new_offset);
@@ -722,7 +725,7 @@ vm_pageclean_copy(
 
 	assert(!new_m->private && !new_m->fictitious);
 
-	pmap_clear_modify(m->phys_addr);
+	pmap_clear_modify(m->phys_page);
 
 	m->busy = TRUE;
 	vm_object_paging_begin(m->object);
@@ -813,7 +816,7 @@ vm_pageout_initialize_page(
 	holding_page = NULL;
 	vm_object_lock(m->object);
 	vm_page_lock_queues();
-	pmap_clear_modify(m->phys_addr);
+	pmap_clear_modify(m->phys_page);
 	m->dirty = TRUE;
        	m->busy = TRUE;
        	m->list_req_pending = TRUE;
@@ -1151,7 +1154,7 @@ vm_pageout_cluster_page(
 	assert(!m->private);
 	assert(!m->fictitious);
 
-	if (!m->dirty) m->dirty = pmap_is_modified(m->phys_addr);
+	if (!m->dirty) m->dirty = pmap_is_modified(m->phys_page);
 
 	if (precious_clean) {
 		if (!m->precious || !m->dirty)
@@ -1639,7 +1642,7 @@ vm_pageout_scan(void)
 		 *	(Fictitious pages are either busy or absent.)
 		 */
 
-		if (m->reference || pmap_is_referenced(m->phys_addr)) {
+		if (m->reference || pmap_is_referenced(m->phys_page)) {
 			vm_pageout_inactive_used++;
 		    reactivate_page:
 #if	ADVISORY_PAGEOUT
@@ -1729,10 +1732,10 @@ vm_pageout_scan(void)
 		 */
 
 		m->busy = TRUE;
-		pmap_page_protect(m->phys_addr, VM_PROT_NONE);
+		pmap_page_protect(m->phys_page, VM_PROT_NONE);
 
 		if (!m->dirty)
-			m->dirty = pmap_is_modified(m->phys_addr);
+			m->dirty = pmap_is_modified(m->phys_page);
 		/*
 		 *	If it's clean and not precious, we can free the page.
 		 */
@@ -1951,7 +1954,7 @@ vm_pageout_emergency_availability_request()
 			continue;
 		}
 		if (!m->dirty)
-			m->dirty = pmap_is_modified(m->phys_addr);
+			m->dirty = pmap_is_modified(m->phys_page);
 		if(m->dirty || m->busy || m->wire_count  || m->absent
 				|| m->precious || m->cleaning 
 				|| m->dump_cleaning || m->error
@@ -1971,7 +1974,7 @@ vm_pageout_emergency_availability_request()
 				continue;
 			}
 			m->busy = TRUE;
-			pmap_page_protect(m->phys_addr, VM_PROT_NONE);
+			pmap_page_protect(m->phys_page, VM_PROT_NONE);
 			vm_page_free(m);
 			vm_object_unlock(object);
 			vm_page_unlock_queues();
@@ -1988,7 +1991,7 @@ vm_pageout_emergency_availability_request()
 			continue;
 		}
 		if (!m->dirty)
-			m->dirty = pmap_is_modified(m->phys_addr);
+			m->dirty = pmap_is_modified(m->phys_page);
 		if(m->dirty || m->busy || m->wire_count || m->absent
 				|| m->precious || m->cleaning 
 				|| m->dump_cleaning || m->error
@@ -2008,7 +2011,7 @@ vm_pageout_emergency_availability_request()
 				continue;
 			}
 			m->busy = TRUE;
-			pmap_page_protect(m->phys_addr, VM_PROT_NONE);
+			pmap_page_protect(m->phys_page, VM_PROT_NONE);
 			vm_page_free(m);
 			vm_object_unlock(object);
 			vm_page_unlock_queues();
@@ -2023,16 +2026,23 @@ vm_pageout_emergency_availability_request()
 
 static upl_t
 upl_create(
-	   boolean_t	internal,
+	   int		   flags,
            vm_size_t       size)
 {
 	upl_t	upl;
+	int	page_field_size;  /* bit field in word size buf */
 
-	if(internal) {
+	page_field_size = 0;
+	if (flags & UPL_CREATE_LITE) {
+		page_field_size = ((size/PAGE_SIZE) + 7) >> 3;
+		page_field_size = (page_field_size + 3) & 0xFFFFFFFC;
+	}
+	if(flags & UPL_CREATE_INTERNAL) {
 		upl = (upl_t)kalloc(sizeof(struct upl)
-			+ (sizeof(struct upl_page_info)*(size/page_size)));
+			+ (sizeof(struct upl_page_info)*(size/PAGE_SIZE))
+			+ page_field_size);
 	} else {
-		upl = (upl_t)kalloc(sizeof(struct upl));
+		upl = (upl_t)kalloc(sizeof(struct upl) + page_field_size);
 	}
 	upl->flags = 0;
 	upl->src_object = NULL;
@@ -2052,32 +2062,45 @@ static void
 upl_destroy(
 	upl_t	upl)
 {
+	int	page_field_size;  /* bit field in word size buf */
 
 #ifdef UBC_DEBUG
 	{
 		upl_t	upl_ele;
-		vm_object_lock(upl->map_object->shadow);
-		queue_iterate(&upl->map_object->shadow->uplq, 
-						upl_ele, upl_t, uplq) {
+		vm_object_t	object;
+		if (upl->map_object->pageout) {
+			object = upl->map_object->shadow;
+		} else {
+			object = upl->map_object;
+		}
+		vm_object_lock(object);
+		queue_iterate(&object->uplq, upl_ele, upl_t, uplq) {
 			if(upl_ele == upl) {
-				queue_remove(&upl->map_object->shadow->uplq, 
-					upl_ele, upl_t, uplq);
+				queue_remove(&object->uplq, 
+						upl_ele, upl_t, uplq);
 				break;
 			}
 		}
-		vm_object_unlock(upl->map_object->shadow);
+		vm_object_unlock(object);
 	}
 #endif /* UBC_DEBUG */
-#ifdef notdefcdy
-	if(!(upl->flags & UPL_DEVICE_MEMORY))
-#endif
+	/* drop a reference on the map_object whether or */
+	/* not a pageout object is inserted */
+	if(upl->map_object->pageout)
 		vm_object_deallocate(upl->map_object);
+
+	page_field_size = 0;
+	if (upl->flags & UPL_LITE) {
+		page_field_size = ((upl->size/PAGE_SIZE) + 7) >> 3;
+		page_field_size = (page_field_size + 3) & 0xFFFFFFFC;
+	}
 	if(upl->flags & UPL_INTERNAL) {
 		kfree((vm_offset_t)upl,
 			sizeof(struct upl) + 
-		        (sizeof(struct upl_page_info) * (upl->size/page_size)));
+		        (sizeof(struct upl_page_info) * (upl->size/PAGE_SIZE))
+			+ page_field_size);
 	} else {
-		kfree((vm_offset_t)upl, sizeof(struct upl));
+		kfree((vm_offset_t)upl, sizeof(struct upl) + page_field_size);
 	}
 }
 
@@ -2166,13 +2189,13 @@ vm_object_upl_request(
 
 	vm_page_t		alias_page = NULL;
 	int			page_ticket; 
-
+	wpl_array_t 		lite_list;
 
 	page_ticket = (cntrl_flags & UPL_PAGE_TICKET_MASK)
 					>> UPL_PAGE_TICKET_SHIFT;
 
-	if(((size/page_size) > MAX_UPL_TRANSFER) && !object->phys_contiguous) {
-		size = MAX_UPL_TRANSFER * page_size;
+	if(((size/PAGE_SIZE) > MAX_UPL_TRANSFER) && !object->phys_contiguous) {
+		size = MAX_UPL_TRANSFER * PAGE_SIZE;
 	}
 
 	if(cntrl_flags & UPL_SET_INTERNAL)
@@ -2189,52 +2212,99 @@ vm_object_upl_request(
 	if((cntrl_flags & UPL_COPYOUT_FROM) && (upl_ptr == NULL)) {
 		return KERN_SUCCESS;
 	}
+
 	if(upl_ptr) {
 		if(cntrl_flags & UPL_SET_INTERNAL) {
-			upl = upl_create(TRUE, size);
-			user_page_list = (upl_page_info_t *)
-				(((vm_offset_t)upl) + sizeof(struct upl));
-			upl->flags |= UPL_INTERNAL;
+			if(cntrl_flags & UPL_SET_LITE) {
+				vm_offset_t page_field_size;
+				upl = upl_create(
+					UPL_CREATE_INTERNAL | UPL_CREATE_LITE,
+					size);
+				user_page_list = (upl_page_info_t *)
+				   (((vm_offset_t)upl) + sizeof(struct upl));
+				lite_list = (wpl_array_t)
+					(((vm_offset_t)user_page_list) + 
+					((size/PAGE_SIZE) * 
+						sizeof(upl_page_info_t)));
+				page_field_size = ((size/PAGE_SIZE) + 7) >> 3;
+				page_field_size = 
+					(page_field_size + 3) & 0xFFFFFFFC;
+				bzero((char *)lite_list, page_field_size);
+				upl->flags = 
+					UPL_LITE | UPL_INTERNAL;
+			} else {
+				upl = upl_create(UPL_CREATE_INTERNAL, size);
+				user_page_list = (upl_page_info_t *)
+					(((vm_offset_t)upl) 
+						+ sizeof(struct upl));
+				upl->flags = UPL_INTERNAL;
+			}
 		} else {
-			upl = upl_create(FALSE, size);
+			if(cntrl_flags & UPL_SET_LITE) {
+				vm_offset_t page_field_size;
+				upl = upl_create(UPL_CREATE_LITE, size);
+				lite_list = (wpl_array_t)
+				   (((vm_offset_t)upl) + sizeof(struct upl));
+				page_field_size = ((size/PAGE_SIZE) + 7) >> 3;
+				page_field_size = 
+					(page_field_size + 3) & 0xFFFFFFFC;
+				bzero((char *)lite_list, page_field_size);
+				upl->flags = UPL_LITE;
+			} else {
+				upl = upl_create(UPL_CREATE_EXTERNAL, size);
+				upl->flags = 0;
+			}
 		}
+
 		if(object->phys_contiguous) {
 			upl->size = size;
 			upl->offset = offset + object->paging_offset;
 			*upl_ptr = upl;
 			if(user_page_list) {
 				user_page_list[0].phys_addr = 
-					offset + object->shadow_offset;
+				   (offset + object->shadow_offset)>>12;
 				user_page_list[0].device = TRUE;
 			}
+			upl->map_object = object;
+			/* don't need any shadow mappings for this one */
+			/* since it is already I/O memory */
+			upl->flags |= UPL_DEVICE_MEMORY;
+
+			vm_object_lock(object);
+			vm_object_paging_begin(object);
+			vm_object_unlock(object);
+
+			if(page_list_count != NULL) {
+				if (upl->flags & UPL_INTERNAL) {
+					*page_list_count = 0;
+				} else {
+					*page_list_count = 1;
+				}
+			}
+			return KERN_SUCCESS;
+		}
+
+		if(cntrl_flags & UPL_SET_LITE) {
+			upl->map_object = object;
+		} else {
 			upl->map_object = vm_object_allocate(size);
 			vm_object_lock(upl->map_object);
 			upl->map_object->shadow = object;
-			upl->flags = UPL_DEVICE_MEMORY | UPL_INTERNAL;
 			upl->map_object->pageout = TRUE;
 			upl->map_object->can_persist = FALSE;
-			upl->map_object->copy_strategy
-					= MEMORY_OBJECT_COPY_NONE;
+			upl->map_object->copy_strategy = 
+					MEMORY_OBJECT_COPY_NONE;
 			upl->map_object->shadow_offset = offset;
+			upl->map_object->wimg_bits = object->wimg_bits;
 			vm_object_unlock(upl->map_object);
-			return KERN_SUCCESS;
 		}
-		
-			
-		upl->map_object = vm_object_allocate(size);
-		vm_object_lock(upl->map_object);
-		upl->map_object->shadow = object;
 		upl->size = size;
 		upl->offset = offset + object->paging_offset;
-		upl->map_object->pageout = TRUE;
-		upl->map_object->can_persist = FALSE;
-		upl->map_object->copy_strategy = MEMORY_OBJECT_COPY_NONE;
-		upl->map_object->shadow_offset = offset;
-		upl->map_object->wimg_bits = object->wimg_bits;
-		vm_object_unlock(upl->map_object);
 		*upl_ptr = upl;
 	}
-	VM_PAGE_GRAB_FICTITIOUS(alias_page);
+	if (!(cntrl_flags & UPL_SET_LITE)) {
+		VM_PAGE_GRAB_FICTITIOUS(alias_page);
+	}
 	vm_object_lock(object);
 #ifdef UBC_DEBUG
 	if(upl_ptr)
@@ -2245,7 +2315,8 @@ vm_object_upl_request(
 	if(cntrl_flags & UPL_COPYOUT_FROM) {
 		upl->flags |= UPL_PAGE_SYNC_DONE;
 		while (xfer_size) {
-			if(alias_page == NULL) {
+			if((alias_page == NULL) && 
+				!(cntrl_flags & UPL_SET_LITE)) {
 				vm_object_unlock(object);
 				VM_PAGE_GRAB_FICTITIOUS(alias_page);
 				vm_object_lock(object);
@@ -2258,26 +2329,29 @@ vm_object_upl_request(
 				(dst_page->wire_count != 0 && 
 							!dst_page->pageout) ||
 				((!(dst_page->dirty || dst_page->precious ||
-				      pmap_is_modified(dst_page->phys_addr)))
+				      pmap_is_modified(dst_page->phys_page)))
 				      && (cntrl_flags & UPL_RET_ONLY_DIRTY)) ||
 				((!(dst_page->inactive))
 					&& (dst_page->page_ticket != page_ticket)
 					&& ((dst_page->page_ticket+1) != page_ticket)
-					&& (cntrl_flags & UPL_PAGEOUT)) ||
+					&& (cntrl_flags & UPL_FOR_PAGEOUT)) ||
 				((!dst_page->list_req_pending) && 
 					(cntrl_flags & UPL_RET_ONLY_DIRTY) &&
-					pmap_is_referenced(dst_page->phys_addr))) {
-				if(user_page_list)
+					pmap_is_referenced(dst_page->phys_page))) {
+				if(user_page_list) {
 					user_page_list[entry].phys_addr = 0;
+					user_page_list[entry].device = FALSE;
+				}
 			} else {
 				
 				if(dst_page->busy && 
 					(!(dst_page->list_req_pending && 
 						dst_page->pageout))) {
 					if(cntrl_flags & UPL_NOBLOCK) {
-						if(user_page_list)
-					   		user_page_list[entry]
-								.phys_addr = 0;
+						if(user_page_list) {
+					   		user_page_list[entry].phys_addr = 0;
+					   		user_page_list[entry].device = FALSE;
+						}
 						entry++;
 						dst_offset += PAGE_SIZE_64;
 						xfer_size -= PAGE_SIZE;
@@ -2292,8 +2366,10 @@ vm_object_upl_request(
 				if((dst_page->cleaning || dst_page->absent ||
 					dst_page->wire_count != 0) && 
 					!dst_page->list_req_pending) {
-				   if(user_page_list)
+				   if(user_page_list) {
 					   user_page_list[entry].phys_addr = 0;
+					   user_page_list[entry].device = FALSE;
+				   }
 				   entry++;
 				   dst_offset += PAGE_SIZE_64;
 				   xfer_size -= PAGE_SIZE;
@@ -2304,7 +2380,7 @@ vm_object_upl_request(
 				
 				vm_page_lock_queues();
 				if( !(cntrl_flags & UPL_FILE_IO)) {
-				        pmap_page_protect(dst_page->phys_addr, VM_PROT_NONE);
+				        pmap_page_protect(dst_page->phys_page, VM_PROT_NONE);
 				}
 				/* pageout statistics gathering.  count  */
 				/* all the pages we will page out that   */
@@ -2333,13 +2409,43 @@ vm_object_upl_request(
 				dst_page->busy = FALSE;
 				dst_page->cleaning = FALSE;
 
-				dirty = pmap_is_modified(dst_page->phys_addr);
+				dirty = pmap_is_modified(dst_page->phys_page);
 				dirty = dirty ? TRUE : dst_page->dirty;
 
-				/* use pageclean setup, it is more convenient */
-				/* even for the pageout cases here */
-				vm_pageclean_setup(dst_page, alias_page,
-					upl->map_object, size - xfer_size);
+				if(cntrl_flags & UPL_SET_LITE) {
+					int	pg_num;
+					pg_num = (dst_offset-offset)/PAGE_SIZE;
+					lite_list[pg_num>>5] |= 
+							1 << (pg_num & 31);
+					pmap_clear_modify(dst_page->phys_page);
+					/*
+					 * Record that this page has been 
+					 * written out
+					 */
+#if     MACH_PAGEMAP
+					vm_external_state_set(
+						object->existence_map, 
+						dst_page->offset);
+#endif  /*MACH_PAGEMAP*/
+
+					/*
+					 * Mark original page as cleaning 
+					 * in place.
+					 */
+					dst_page->cleaning = TRUE;
+					dst_page->dirty = TRUE;
+					dst_page->precious = FALSE;
+				} else {
+					/* use pageclean setup, it is more */
+					/* convenient even for the pageout */
+					/* cases here */
+					vm_pageclean_setup(dst_page, 
+						alias_page, upl->map_object, 
+						size - xfer_size);
+
+					alias_page->absent = FALSE;
+					alias_page = NULL;
+				}
 						
 				if(!dirty) {
 					dst_page->dirty = FALSE;
@@ -2349,10 +2455,8 @@ vm_object_upl_request(
 				if(dst_page->pageout)
 					dst_page->busy = TRUE;
 
-				alias_page->absent = FALSE;
-				alias_page = NULL;
 				if((!(cntrl_flags & UPL_CLEAN_IN_PLACE)) 
-					|| (cntrl_flags & UPL_PAGEOUT)) {
+					|| (cntrl_flags & UPL_FOR_PAGEOUT)) {
 					/* deny access to the target page */
 					/* while it is being worked on    */
 					if((!dst_page->pageout) &&
@@ -2364,7 +2468,7 @@ vm_object_upl_request(
 				}
 				if(user_page_list) {
 					user_page_list[entry].phys_addr
-						= dst_page->phys_addr;
+						= dst_page->phys_page;
 					user_page_list[entry].dirty =   
 							dst_page->dirty;
 					user_page_list[entry].pageout =
@@ -2373,6 +2477,8 @@ vm_object_upl_request(
 							dst_page->absent;
 					user_page_list[entry].precious =
 							dst_page->precious;
+					user_page_list[entry].device = 
+							FALSE;
 				}
 
 				vm_page_unlock_queues();
@@ -2383,7 +2489,8 @@ vm_object_upl_request(
 		}
 	} else {
 		while (xfer_size) {
-			if(alias_page == NULL) {
+			if((alias_page == NULL) && 
+				!(cntrl_flags & UPL_SET_LITE)) {
 				vm_object_unlock(object);
 				VM_PAGE_GRAB_FICTITIOUS(alias_page);
 				vm_object_lock(object);
@@ -2397,8 +2504,10 @@ vm_object_upl_request(
 				        /* requests.  we want to grab  */
 				        /* pages around some which are */
 				        /* already present.  */
-				        if(user_page_list)
+				        if(user_page_list) {
 					        user_page_list[entry].phys_addr = 0;
+					        user_page_list[entry].device = FALSE;
+					}
 					entry++;
 					dst_offset += PAGE_SIZE_64;
 					xfer_size -= PAGE_SIZE;
@@ -2439,9 +2548,10 @@ vm_object_upl_request(
 					 * physical page by asking the
 					 * backing device.
 					 */
-					if(user_page_list)
-						user_page_list[entry]
-							.phys_addr = 0;
+					if(user_page_list) {
+						user_page_list[entry].phys_addr = 0;
+						user_page_list[entry].device = FALSE;
+					}
 					entry++;
 					dst_offset += PAGE_SIZE_64;
 					xfer_size -= PAGE_SIZE;
@@ -2492,13 +2602,45 @@ vm_object_upl_request(
 				
 				vm_page_lock_queues();
 				if( !(cntrl_flags & UPL_FILE_IO)) {
-				        pmap_page_protect(dst_page->phys_addr, VM_PROT_NONE);
+				        pmap_page_protect(dst_page->phys_page, VM_PROT_NONE);
 				}
-				dirty = pmap_is_modified(dst_page->phys_addr);
+				dirty = pmap_is_modified(dst_page->phys_page);
 				dirty = dirty ? TRUE : dst_page->dirty;
 
-				vm_pageclean_setup(dst_page, alias_page,
-					upl->map_object, size - xfer_size);
+				if(cntrl_flags & UPL_SET_LITE) {
+					int	pg_num;
+					pg_num = (dst_offset-offset)/PAGE_SIZE;
+					lite_list[pg_num>>5] |= 
+							1 << (pg_num & 31);
+					pmap_clear_modify(dst_page->phys_page);
+					/*
+					 * Record that this page has been 
+					 * written out
+					 */
+#if     MACH_PAGEMAP
+					vm_external_state_set(
+						object->existence_map, 
+						dst_page->offset);
+#endif  /*MACH_PAGEMAP*/
+
+					/*
+					 * Mark original page as cleaning 
+					 * in place.
+					 */
+					dst_page->cleaning = TRUE;
+					dst_page->dirty = TRUE;
+					dst_page->precious = FALSE;
+				} else {
+					/* use pageclean setup, it is more */
+					/* convenient even for the pageout */
+					/* cases here */
+					vm_pageclean_setup(dst_page, 
+						alias_page, upl->map_object, 
+						size - xfer_size);
+
+					alias_page->absent = FALSE;
+					alias_page = NULL;
+				}
 
 				if(cntrl_flags & UPL_CLEAN_IN_PLACE) {
 					/* clean in place for read implies   */
@@ -2528,11 +2670,9 @@ vm_object_upl_request(
 				dst_page->precious = 
 					(cntrl_flags & UPL_PRECIOUS) 
 							? TRUE : FALSE;
-				alias_page->absent = FALSE;
-				alias_page = NULL;
 				if(user_page_list) {
 					user_page_list[entry].phys_addr
-						= dst_page->phys_addr;
+						= dst_page->phys_page;
 					user_page_list[entry].dirty =
 							dst_page->dirty;
 					user_page_list[entry].pageout =
@@ -2541,9 +2681,12 @@ vm_object_upl_request(
 				   			dst_page->absent;
 					user_page_list[entry].precious =
 							dst_page->precious;
+					user_page_list[entry].device = 
+							FALSE;
 				}
 				vm_page_unlock_queues();
 			}
+
 			entry++;
 			dst_offset += PAGE_SIZE_64;
 			xfer_size -= PAGE_SIZE;
@@ -2688,7 +2831,7 @@ vm_object_super_upl_request(
 		return KERN_FAILURE;
 
 	offset = offset - object->paging_offset;
-	if(cntrl_flags & UPL_PAGEOUT) {
+	if(cntrl_flags & UPL_FOR_PAGEOUT) {
 		if((target_page = vm_page_lookup(object, offset))
 							!= VM_PAGE_NULL) {
 			ticket = target_page->page_ticket;
@@ -2756,6 +2899,78 @@ vm_upl_map(
 		return KERN_FAILURE;
 	}
 
+	if((!(upl->map_object->pageout)) && 	
+		!((upl->flags & (UPL_DEVICE_MEMORY | UPL_IO_WIRE)) ||
+					(upl->map_object->phys_contiguous))) {
+		vm_object_t 		object;
+		vm_page_t		alias_page;
+		vm_object_offset_t	new_offset;
+		int			pg_num;
+		wpl_array_t 		lite_list;
+
+		if(upl->flags & UPL_INTERNAL) {
+			lite_list = (wpl_array_t) 
+				((((vm_offset_t)upl) + sizeof(struct upl))
+				+ ((upl->size/PAGE_SIZE) 
+						* sizeof(upl_page_info_t)));
+		} else {
+			lite_list = (wpl_array_t)
+				(((vm_offset_t)upl) + sizeof(struct upl));
+		}
+		object = upl->map_object;
+		upl->map_object = vm_object_allocate(upl->size);
+		vm_object_lock(upl->map_object);
+		upl->map_object->shadow = object;
+		upl->map_object->pageout = TRUE;
+		upl->map_object->can_persist = FALSE;
+		upl->map_object->copy_strategy = 
+				MEMORY_OBJECT_COPY_NONE;
+		upl->map_object->shadow_offset = 
+				upl->offset - object->paging_offset;
+		upl->map_object->wimg_bits = object->wimg_bits;
+		vm_object_unlock(upl->map_object);
+		offset = upl->map_object->shadow_offset;
+		new_offset = 0;
+		size = upl->size;
+		vm_object_lock(object);
+		while(size) {
+		   pg_num = (new_offset)/PAGE_SIZE;
+		   if(lite_list[pg_num>>5] & (1 << (pg_num & 31))) {
+			vm_object_unlock(object);
+			VM_PAGE_GRAB_FICTITIOUS(alias_page);
+			vm_object_lock(object);
+			m = vm_page_lookup(object, offset);
+			if (m == VM_PAGE_NULL) {
+				panic("vm_upl_map: page missing\n");
+			}
+
+			vm_object_paging_begin(object);
+
+			/*
+ 		 	* Convert the fictitious page to a private 
+			 * shadow of the real page.
+			 */
+			assert(alias_page->fictitious);
+			alias_page->fictitious = FALSE;
+			alias_page->private = TRUE;
+			alias_page->pageout = TRUE;
+			alias_page->phys_page = m->phys_page;
+			vm_page_wire(alias_page);
+
+			vm_page_insert(alias_page, 
+					upl->map_object, new_offset);
+			assert(!alias_page->wanted);
+			alias_page->busy = FALSE;
+			alias_page->absent = FALSE;
+		   }
+
+		   size -= PAGE_SIZE;
+		   offset += PAGE_SIZE_64;
+		   new_offset += PAGE_SIZE_64;
+		}
+		vm_object_unlock(object);
+	}
+
 	offset = 0;  /* Always map the entire object */
 	size = upl->size;
 	
@@ -2836,11 +3051,12 @@ upl_commit_range(
 	boolean_t		*empty) 
 {
 	vm_size_t		xfer_size = size;
-	vm_object_t		shadow_object = upl->map_object->shadow;
+	vm_object_t		shadow_object;
 	vm_object_t		object = upl->map_object;
 	vm_object_offset_t	target_offset;
-	vm_object_offset_t	page_offset;
 	int			entry;
+	wpl_array_t 		lite_list;
+	int			occupied;
 
 	*empty = FALSE;
 
@@ -2850,7 +3066,15 @@ upl_commit_range(
 	if (count == 0)
 		page_list = NULL;
 
+	if(object->pageout) {
+		shadow_object = object->shadow;
+	} else {
+		shadow_object = object;
+	}
+
 	upl_lock(upl);
+
+
 	if(upl->flags & UPL_DEVICE_MEMORY) {
 		xfer_size = 0;
 	} else if ((offset + size) > upl->size) {
@@ -2858,6 +3082,15 @@ upl_commit_range(
 		return KERN_FAILURE;
 	}
 
+	if(upl->flags & UPL_INTERNAL) {
+		lite_list = (wpl_array_t) 
+			((((vm_offset_t)upl) + sizeof(struct upl))
+			+ ((upl->size/PAGE_SIZE) * sizeof(upl_page_info_t)));
+	} else {
+		lite_list = (wpl_array_t)
+			(((vm_offset_t)upl) + sizeof(struct upl));
+	}
+
 	vm_object_lock(shadow_object);
 
 	entry = offset/PAGE_SIZE;
@@ -2866,148 +3099,211 @@ upl_commit_range(
 		vm_page_t	t,m;
 		upl_page_info_t *p;
 
-		if((t = vm_page_lookup(object, target_offset)) != NULL) {
-
-			t->pageout = FALSE;
-			page_offset = t->offset;
-			VM_PAGE_FREE(t);
-			t = VM_PAGE_NULL;
-			m = vm_page_lookup(shadow_object, 
-					page_offset + object->shadow_offset);
-			if(m != VM_PAGE_NULL) {
-			   vm_object_paging_end(shadow_object);
-			   vm_page_lock_queues();
-			   if ((upl->flags & UPL_CLEAR_DIRTY) ||
-					(flags & UPL_COMMIT_CLEAR_DIRTY)) {
-				pmap_clear_modify(m->phys_addr);
-				m->dirty = FALSE;
-			   }
-			   if(page_list) {
-				p = &(page_list[entry]);
-				if(p->phys_addr && p->pageout && !m->pageout) {
-					m->busy = TRUE;
-					m->pageout = TRUE;
-					vm_page_wire(m);
-				} else if (page_list[entry].phys_addr &&
-						!p->pageout && m->pageout &&
-						!m->dump_cleaning) {
-					m->pageout = FALSE;
-					m->absent = FALSE;
-					m->overwriting = FALSE;
-					vm_page_unwire(m);
-					PAGE_WAKEUP_DONE(m);
+		m = VM_PAGE_NULL;
+		if(upl->flags & UPL_LITE) {
+			int	pg_num;
+			pg_num = target_offset/PAGE_SIZE;
+			if(lite_list[pg_num>>5] & (1 << (pg_num & 31))) {
+				lite_list[pg_num>>5] &= ~(1 << (pg_num & 31));
+				m = vm_page_lookup(shadow_object,
+					target_offset + (upl->offset - 
+						shadow_object->paging_offset));
+			}
+		}
+		if(object->pageout) {
+			if ((t = vm_page_lookup(object, target_offset))
+								!= NULL) {
+				t->pageout = FALSE;
+				VM_PAGE_FREE(t);
+				if(m == NULL) {
+					m = vm_page_lookup(
+					    shadow_object, 
+					    target_offset + 
+						object->shadow_offset);
 				}
+				if(m != VM_PAGE_NULL)
+					vm_object_paging_end(m->object);
+			}
+		}
+
+		if(m != VM_PAGE_NULL) {
+		   if(upl->flags & UPL_IO_WIRE) {
+			vm_page_lock_queues();
+			vm_page_unwire(m);
+			vm_page_unlock_queues();
+		   	if(page_list) {
 				page_list[entry].phys_addr = 0;
-			   }
-			   m->dump_cleaning = FALSE;
-			   if(m->laundry) {
-			      vm_page_laundry_count--;
-			      m->laundry = FALSE;
-			      if (vm_page_laundry_count < vm_page_laundry_min) {
-			         vm_page_laundry_min = 0;
-			         thread_wakeup((event_t) 
-					     &vm_page_laundry_count);
-			      }
-			   }
-			   if(m->pageout) {
-			      m->cleaning = FALSE;
-			      m->pageout = FALSE;
+			}
+		   	if (flags & UPL_COMMIT_SET_DIRTY) {
+				 m->dirty = TRUE;
+		   	} else if ((upl->flags & UPL_CLEAR_DIRTY) ||
+				(flags & UPL_COMMIT_CLEAR_DIRTY)) {
+				pmap_clear_modify(m->phys_page);
+				m->dirty = FALSE;
+		   	}
+		   	if (flags & UPL_COMMIT_INACTIVATE) {
+              			vm_page_deactivate(m);
+				m->reference = FALSE;
+				pmap_clear_reference(m->phys_page);
+			}
+			target_offset += PAGE_SIZE_64;
+			xfer_size -= PAGE_SIZE;
+			entry++;
+			continue;
+		   }
+		   vm_page_lock_queues();
+		   if ((upl->flags & UPL_CLEAR_DIRTY) ||
+				(flags & UPL_COMMIT_CLEAR_DIRTY)) {
+			pmap_clear_modify(m->phys_page);
+			m->dirty = FALSE;
+		   }
+		   if(page_list) {
+			p = &(page_list[entry]);
+			if(p->phys_addr && p->pageout && !m->pageout) {
+				m->busy = TRUE;
+				m->pageout = TRUE;
+				vm_page_wire(m);
+			} else if (page_list[entry].phys_addr &&
+					!p->pageout && m->pageout &&
+					!m->dump_cleaning) {
+				m->pageout = FALSE;
+				m->absent = FALSE;
+				m->overwriting = FALSE;
+				vm_page_unwire(m);
+				PAGE_WAKEUP_DONE(m);
+			}
+			page_list[entry].phys_addr = 0;
+		   }
+		   m->dump_cleaning = FALSE;
+		   if(m->laundry) {
+		      vm_page_laundry_count--;
+		      m->laundry = FALSE;
+		      if (vm_page_laundry_count < vm_page_laundry_min) {
+		         vm_page_laundry_min = 0;
+		         thread_wakeup((event_t) 
+				     &vm_page_laundry_count);
+		      }
+		   }
+		   if(m->pageout) {
+		      m->cleaning = FALSE;
+		      m->pageout = FALSE;
 #if MACH_CLUSTER_STATS
-			      if (m->wanted) vm_pageout_target_collisions++;
+		      if (m->wanted) vm_pageout_target_collisions++;
 #endif
-			      pmap_page_protect(m->phys_addr, VM_PROT_NONE);
-			      m->dirty = pmap_is_modified(m->phys_addr);
-			      if(m->dirty) {
-			         CLUSTER_STAT(
-			              vm_pageout_target_page_dirtied++;)
-                                 vm_page_unwire(m);/* reactivates */
-                                 VM_STAT(reactivations++);
-                                 PAGE_WAKEUP_DONE(m);
-                       	      } else {
-                                    CLUSTER_STAT(
-				               vm_pageout_target_page_freed++;)
-                                    vm_page_free(m);/* clears busy, etc. */
-				    VM_STAT(pageouts++);
-                        	 }
-                        	 vm_page_unlock_queues();
-				 target_offset += PAGE_SIZE_64;
-				 xfer_size -= PAGE_SIZE;
-				 entry++;
-                                 continue;
-			   }
-			      if (flags & UPL_COMMIT_INACTIVATE) {
-                                      vm_page_deactivate(m);
-				      m->reference = FALSE;
-				      pmap_clear_reference(m->phys_addr);
-			      } else if (!m->active && !m->inactive) {
-                                   if (m->reference)
-                                      vm_page_activate(m);
-                                   else
-                                      vm_page_deactivate(m);
-                              }
+		      pmap_page_protect(m->phys_page, VM_PROT_NONE);
+		      m->dirty = pmap_is_modified(m->phys_page);
+		      if(m->dirty) {
+		         CLUSTER_STAT(
+		              vm_pageout_target_page_dirtied++;)
+                              vm_page_unwire(m);/* reactivates */
+                              VM_STAT(reactivations++);
+                              PAGE_WAKEUP_DONE(m);
+              	      } else {
+                            CLUSTER_STAT(
+			               vm_pageout_target_page_freed++;)
+                            vm_page_free(m);/* clears busy, etc. */
+			    VM_STAT(pageouts++);
+       		      }
+               	      vm_page_unlock_queues();
+		      target_offset += PAGE_SIZE_64;
+		      xfer_size -= PAGE_SIZE;
+		      entry++;
+                      continue;
+		   }
+		   if (flags & UPL_COMMIT_INACTIVATE) {
+              		vm_page_deactivate(m);
+			m->reference = FALSE;
+			pmap_clear_reference(m->phys_page);
+		   } else if (!m->active && !m->inactive) {
+                	if (m->reference)
+				vm_page_activate(m);
+			else
+				vm_page_deactivate(m);
+		   }
 #if MACH_CLUSTER_STATS
-                              m->dirty = pmap_is_modified(m->phys_addr);
+                   m->dirty = pmap_is_modified(m->phys_page);
 
-                              if (m->dirty)   vm_pageout_cluster_dirtied++;
-                              else            vm_pageout_cluster_cleaned++;
-                              if (m->wanted)  vm_pageout_cluster_collisions++;
+                   if (m->dirty)   vm_pageout_cluster_dirtied++;
+                   else            vm_pageout_cluster_cleaned++;
+                   if (m->wanted)  vm_pageout_cluster_collisions++;
 #else
-                              m->dirty = 0;
+                   m->dirty = 0;
 #endif
 
-                              if((m->busy) && (m->cleaning)) {
-                                 /* the request_page_list case */
-				if(m->absent) {
-				   m->absent = FALSE;
-				   if(shadow_object->absent_count == 1)
+                   if((m->busy) && (m->cleaning)) {
+                   	/* the request_page_list case */
+			if(m->absent) {
+				m->absent = FALSE;
+				if(shadow_object->absent_count == 1)
 				      vm_object_absent_release(shadow_object);
-				   else
+				else
 				      shadow_object->absent_count--;
-				}
-				 m->overwriting = FALSE;
-                                 m->busy = FALSE;
-                                 m->dirty = FALSE;
-                              }
-			      else if (m->overwriting) {
-			         /* alternate request page list, write to 
-			         /* page_list case.  Occurs when the original
-			         /* page was wired at the time of the list
-			         /* request */
-			         assert(m->wire_count != 0);
-			         vm_page_unwire(m);/* reactivates */
-			         m->overwriting = FALSE;
-			      }
-                              m->cleaning = FALSE;
-			      /* It is a part of the semantic of COPYOUT_FROM */
-			      /* UPLs that a commit implies cache sync 	      */
-			      /* between the vm page and the backing store    */
-			      /* this can be used to strip the precious bit   */
-			      /* as well as clean */
-			      if (upl->flags & UPL_PAGE_SYNC_DONE)
-			         m->precious = FALSE;
-
-			      if (flags & UPL_COMMIT_SET_DIRTY) {
-				 m->dirty = TRUE;
-			      }
-                              /*
-                               * Wakeup any thread waiting for the page to be un-cleaning.
-                               */
-                              PAGE_WAKEUP(m);
-                              vm_page_unlock_queues();
-
 			}
+			m->overwriting = FALSE;
+                        m->busy = FALSE;
+                        m->dirty = FALSE;
+                   } else if (m->overwriting) {
+		         /* alternate request page list, write to 
+		         /* page_list case.  Occurs when the original
+		         /* page was wired at the time of the list
+		         /* request */
+		         assert(m->wire_count != 0);
+		         vm_page_unwire(m);/* reactivates */
+		         m->overwriting = FALSE;
+		   }
+                   m->cleaning = FALSE;
+		   /* It is a part of the semantic of COPYOUT_FROM */
+		   /* UPLs that a commit implies cache sync 	      */
+		   /* between the vm page and the backing store    */
+		   /* this can be used to strip the precious bit   */
+		   /* as well as clean */
+		   if (upl->flags & UPL_PAGE_SYNC_DONE)
+		         m->precious = FALSE;
+
+		   if (flags & UPL_COMMIT_SET_DIRTY) {
+			 m->dirty = TRUE;
+		   }
+                   /*
+                    * Wakeup any thread waiting for the page to be un-cleaning.
+                    */
+                   PAGE_WAKEUP(m);
+                   vm_page_unlock_queues();
+
 		}
 		target_offset += PAGE_SIZE_64;
 		xfer_size -= PAGE_SIZE;
 		entry++;
 	}
 
-	vm_object_unlock(shadow_object);
-	if(flags & UPL_COMMIT_NOTIFY_EMPTY) {
-		if((upl->flags & UPL_DEVICE_MEMORY) 
-				|| (queue_empty(&upl->map_object->memq)))
+	occupied = 1;
+	if (upl->flags & UPL_DEVICE_MEMORY)  {
+		occupied = 0;
+	} else if (upl->flags & UPL_LITE) {
+		int	pg_num;
+		int	i;
+		pg_num = upl->size/PAGE_SIZE;
+		pg_num = (pg_num + 31) >> 5;
+		occupied = 0;
+		for(i= 0; i<pg_num; i++) {
+			if(lite_list[i] != 0) {
+				occupied = 1;
+				break;
+			}
+		}
+	} else {
+		if(queue_empty(&upl->map_object->memq)) {
+			occupied = 0;
+		}
+	}
+
+	if(occupied == 0) {
+		if(upl->flags & UPL_COMMIT_NOTIFY_EMPTY) {
 			*empty = TRUE;
+		}
+		if(object == shadow_object)
+			vm_object_paging_end(shadow_object);
 	}
+	vm_object_unlock(shadow_object);
 	upl_unlock(upl);
 
 	return KERN_SUCCESS;
@@ -3022,17 +3318,31 @@ upl_abort_range(
 	boolean_t		*empty) 
 {
 	vm_size_t		xfer_size = size;
-	vm_object_t		shadow_object = upl->map_object->shadow;
+	vm_object_t		shadow_object;
 	vm_object_t		object = upl->map_object;
 	vm_object_offset_t	target_offset;
 	vm_object_offset_t	page_offset;
 	int			entry;
+	wpl_array_t 	 	lite_list;
+	int			occupied;
 
 	*empty = FALSE;
 
 	if (upl == UPL_NULL)
 		return KERN_INVALID_ARGUMENT;
 
+	if (upl->flags & UPL_IO_WIRE) {
+		return upl_commit_range(upl, 
+			offset, size, 0, 
+			NULL, 0, empty);
+	}
+
+	if(object->pageout) {
+		shadow_object = object->shadow;
+	} else {
+		shadow_object = object;
+	}
+
 	upl_lock(upl);
 	if(upl->flags & UPL_DEVICE_MEMORY) {
 		xfer_size = 0;
@@ -3043,22 +3353,48 @@ upl_abort_range(
 
 	vm_object_lock(shadow_object);
 
+	if(upl->flags & UPL_INTERNAL) {
+		lite_list = (wpl_array_t) 
+			((((vm_offset_t)upl) + sizeof(struct upl))
+			+ ((upl->size/PAGE_SIZE) * sizeof(upl_page_info_t)));
+	} else {
+		lite_list = (wpl_array_t) 
+			(((vm_offset_t)upl) + sizeof(struct upl));
+	}
+
 	entry = offset/PAGE_SIZE;
 	target_offset = (vm_object_offset_t)offset;
 	while(xfer_size) {
 		vm_page_t	t,m;
 		upl_page_info_t *p;
 
-		if((t = vm_page_lookup(object, target_offset)) != NULL) {
-
-			t->pageout = FALSE;
-			page_offset = t->offset;
-			VM_PAGE_FREE(t);
-			t = VM_PAGE_NULL;
-			m = vm_page_lookup(shadow_object, 
-					page_offset + object->shadow_offset);
-		   if(m != VM_PAGE_NULL) {
-			vm_object_paging_end(m->object);
+		m = VM_PAGE_NULL;
+		if(upl->flags & UPL_LITE) {
+			int	pg_num;
+			pg_num = target_offset/PAGE_SIZE;
+			if(lite_list[pg_num>>5] & (1 << (pg_num & 31))) {
+				lite_list[pg_num>>5] &= ~(1 << (pg_num & 31));
+				m = vm_page_lookup(shadow_object,
+					target_offset + (upl->offset - 
+						shadow_object->paging_offset));
+			}
+		}
+		if(object->pageout) {
+			if ((t = vm_page_lookup(object, target_offset))
+								!= NULL) {
+				t->pageout = FALSE;
+				VM_PAGE_FREE(t);
+				if(m == NULL) {
+					m = vm_page_lookup(
+					    shadow_object, 
+					    target_offset + 
+						object->shadow_offset);
+				}
+				if(m != VM_PAGE_NULL)
+					vm_object_paging_end(m->object);
+			}
+		}
+		if(m != VM_PAGE_NULL) {
 			vm_page_lock_queues();
 			if(m->absent) {
 				/* COPYOUT = FALSE case */
@@ -3103,13 +3439,13 @@ upl_abort_range(
 				continue;
 			}
 			/*                          
-			 * Handle the trusted pager throttle.
-			 */                     
-			if (m->laundry) { 
+		 	* Handle the trusted pager throttle.
+		 	*/                     
+			if (m->laundry) {
     				vm_page_laundry_count--;
     				m->laundry = FALSE;  
     				if (vm_page_laundry_count 
-						< vm_page_laundry_min) {
+					< vm_page_laundry_min) {
 					vm_page_laundry_min = 0;
 					thread_wakeup((event_t) 
 						&vm_page_laundry_count); 
@@ -3131,23 +3467,45 @@ upl_abort_range(
 #endif	/* MACH_PAGEMAP */
 			if(error & UPL_ABORT_DUMP_PAGES) {
 				vm_page_free(m);
-				pmap_page_protect(m->phys_addr, VM_PROT_NONE);
+				pmap_page_protect(m->phys_page, VM_PROT_NONE);
 			} else {
 				PAGE_WAKEUP(m);
 			}
 			vm_page_unlock_queues();
 		}
-	   }
-	   target_offset += PAGE_SIZE_64;
-	   xfer_size -= PAGE_SIZE;
-	   entry++;
+		target_offset += PAGE_SIZE_64;
+		xfer_size -= PAGE_SIZE;
+		entry++;
 	}
-	vm_object_unlock(shadow_object);
-	if(error & UPL_ABORT_NOTIFY_EMPTY) {
-		if((upl->flags & UPL_DEVICE_MEMORY) 
-				|| (queue_empty(&upl->map_object->memq)))
+	occupied = 1;
+	if (upl->flags & UPL_DEVICE_MEMORY)  {
+		occupied = 0;
+	} else if (upl->flags & UPL_LITE) {
+		int	pg_num;
+		int	i;
+		pg_num = upl->size/PAGE_SIZE;
+		pg_num = (pg_num + 31) >> 5;
+		occupied = 0;
+		for(i= 0; i<pg_num; i++) {
+			if(lite_list[i] != 0) {
+				occupied = 1;
+				break;
+			}
+		}
+	} else {
+		if(queue_empty(&upl->map_object->memq)) {
+			occupied = 0;
+		}
+	}
+
+	if(occupied == 0) {
+		if(upl->flags & UPL_COMMIT_NOTIFY_EMPTY) {
 			*empty = TRUE;
+		}
+		if(object == shadow_object)
+			vm_object_paging_end(shadow_object);
 	}
+	vm_object_unlock(shadow_object);
 	upl_unlock(upl);
 	return KERN_SUCCESS;
 }
@@ -3163,11 +3521,20 @@ upl_abort(
 	vm_object_offset_t	shadow_offset;
 	vm_object_offset_t	target_offset;
 	int			i;
+	wpl_array_t		lite_list;
 	vm_page_t		t,m;
+	int			occupied;
 
 	if (upl == UPL_NULL)
 		return KERN_INVALID_ARGUMENT;
 
+	if (upl->flags & UPL_IO_WIRE) {
+		boolean_t	empty;
+		return upl_commit_range(upl, 
+			0, upl->size, 0, 
+			NULL, 0, &empty);
+	}
+
 	upl_lock(upl);
 	if(upl->flags & UPL_DEVICE_MEMORY) {
 		upl_unlock(upl);
@@ -3182,15 +3549,49 @@ upl_abort(
 		return KERN_INVALID_ARGUMENT;
 	}
 
-	shadow_object = upl->map_object->shadow;
-	shadow_offset = upl->map_object->shadow_offset;
+	if(object->pageout) {
+		shadow_object = object->shadow;
+		shadow_offset = object->shadow_offset;
+	} else {
+		shadow_object = object;
+		shadow_offset = upl->offset - object->paging_offset;
+	}
+
+	if(upl->flags & UPL_INTERNAL) {
+		lite_list = (wpl_array_t)
+			((((vm_offset_t)upl) + sizeof(struct upl))
+			+ ((upl->size/PAGE_SIZE) * sizeof(upl_page_info_t)));
+	} else {
+		lite_list = (wpl_array_t)
+			(((vm_offset_t)upl) + sizeof(struct upl));
+	}
 	offset = 0;
 	vm_object_lock(shadow_object);
 	for(i = 0; i<(upl->size); i+=PAGE_SIZE, offset += PAGE_SIZE_64) {
-	    if((t = vm_page_lookup(object,offset)) != NULL) {
-		target_offset = t->offset + shadow_offset;
-		if((m = vm_page_lookup(shadow_object, target_offset)) != NULL) {
-			vm_object_paging_end(m->object);
+		m = VM_PAGE_NULL;
+		target_offset = offset + shadow_offset;
+		if(upl->flags & UPL_LITE) {
+			int	pg_num;
+			pg_num = offset/PAGE_SIZE;
+			if(lite_list[pg_num>>5] & (1 << (pg_num & 31))) {
+				lite_list[pg_num>>5] &= ~(1 << (pg_num & 31));
+				m = vm_page_lookup(
+					shadow_object, target_offset);
+			}
+		}
+		if(object->pageout) {
+			if ((t = vm_page_lookup(object, offset)) != NULL) {
+				t->pageout = FALSE;
+				VM_PAGE_FREE(t);
+				if(m == NULL) {
+					m = vm_page_lookup(
+					    shadow_object, target_offset);
+				}
+				if(m != VM_PAGE_NULL)
+					vm_object_paging_end(m->object);
+			}
+		}
+		if(m != VM_PAGE_NULL) {
 			vm_page_lock_queues();
 			if(m->absent) {
 				/* COPYOUT = FALSE case */
@@ -3258,29 +3659,39 @@ upl_abort(
 #endif	/* MACH_PAGEMAP */
 			if(error & UPL_ABORT_DUMP_PAGES) {
 				vm_page_free(m);
-				pmap_page_protect(m->phys_addr, VM_PROT_NONE);
+				pmap_page_protect(m->phys_page, VM_PROT_NONE);
 			} else {
 				PAGE_WAKEUP(m);
 			}
 			vm_page_unlock_queues();
 		}
-	   }
 	}
-	vm_object_unlock(shadow_object);
-	/* Remove all the pages from the map object so */
-	/* vm_pageout_object_terminate will work properly. */
-	while (!queue_empty(&upl->map_object->memq)) {
-		vm_page_t p;
-
-		p = (vm_page_t) queue_first(&upl->map_object->memq);
-
-		assert(p->private);
-		assert(p->pageout);
-		p->pageout = FALSE;
-		assert(!p->cleaning);
+	occupied = 1;
+	if (upl->flags & UPL_DEVICE_MEMORY)  {
+		occupied = 0;
+	} else if (upl->flags & UPL_LITE) {
+		int	pg_num;
+		int	i;
+		pg_num = upl->size/PAGE_SIZE;
+		pg_num = (pg_num + 31) >> 5;
+		occupied = 0;
+		for(i= 0; i<pg_num; i++) {
+			if(lite_list[i] != 0) {
+				occupied = 1;
+				break;
+			}
+		}
+	} else {
+		if(queue_empty(&upl->map_object->memq)) {
+			occupied = 0;
+		}
+	}
 
-		VM_PAGE_FREE(p);
+	if(occupied == 0) {
+		if(object == shadow_object)
+			vm_object_paging_end(shadow_object);
 	}
+	vm_object_unlock(shadow_object);
 	upl_unlock(upl);
 	return KERN_SUCCESS;
 }
@@ -3295,52 +3706,21 @@ upl_commit(
 	if (upl == UPL_NULL)
 		return KERN_INVALID_ARGUMENT;
 
+	if(upl->flags & (UPL_LITE | UPL_IO_WIRE)) {
+		boolean_t	empty;
+		return upl_commit_range(upl, 0, upl->size, 0, 
+					page_list, count, &empty);
+	}
+
 	if (count == 0)
 		page_list = NULL;
 
 	upl_lock(upl);
 	if (upl->flags & UPL_DEVICE_MEMORY)
 		page_list = NULL;
-	if ((upl->flags & UPL_CLEAR_DIRTY) ||
-		(upl->flags & UPL_PAGE_SYNC_DONE)) {
-		vm_object_t	shadow_object = upl->map_object->shadow;
-		vm_object_t	object = upl->map_object;
-		vm_object_offset_t target_offset;
-		vm_size_t	xfer_end;
-
-		vm_page_t	t,m;
-
-		vm_object_lock(shadow_object);
-
-		target_offset = object->shadow_offset;
-		xfer_end = upl->size + object->shadow_offset;
 
-		while(target_offset < xfer_end) {
-			if ((t = vm_page_lookup(object, 
-				target_offset - object->shadow_offset))
-				!= NULL) {
-				m = vm_page_lookup(
-					shadow_object, target_offset);
-				if(m != VM_PAGE_NULL) {
-					if (upl->flags & UPL_CLEAR_DIRTY) {
-						pmap_clear_modify(m->phys_addr);
-						m->dirty = FALSE;
-					}
-				        /* It is a part of the semantic of */
-					/* COPYOUT_FROM UPLs that a commit */
-					/* implies cache sync between the  */
-					/* vm page and the backing store   */
-					/* this can be used to strip the   */
-					/* precious bit as well as clean   */
-					if (upl->flags & UPL_PAGE_SYNC_DONE)
-						m->precious = FALSE;
-				}
-			}
-			target_offset += PAGE_SIZE_64;
-		}
-		vm_object_unlock(shadow_object);
-	}
-	if (page_list) {
+	if ((upl->flags & UPL_CLEAR_DIRTY) ||
+		(upl->flags & UPL_PAGE_SYNC_DONE) || page_list) {
 		vm_object_t	shadow_object = upl->map_object->shadow;
 		vm_object_t	object = upl->map_object;
 		vm_object_offset_t target_offset;
@@ -3368,15 +3748,29 @@ upl_commit(
 
 			m = vm_page_lookup(shadow_object, target_offset);
 			if(m != VM_PAGE_NULL) {
-			   p = &(page_list[entry]);
-			   if(page_list[entry].phys_addr &&
+			    if (upl->flags & UPL_CLEAR_DIRTY) {
+				pmap_clear_modify(m->phys_page);
+				m->dirty = FALSE;
+			    }
+			    /* It is a part of the semantic of */
+			    /* COPYOUT_FROM UPLs that a commit */
+			    /* implies cache sync between the  */
+			    /* vm page and the backing store   */
+			    /* this can be used to strip the   */
+			    /* precious bit as well as clean   */
+			    if (upl->flags & UPL_PAGE_SYNC_DONE)
+				m->precious = FALSE;
+
+			   if(page_list) {
+			   	p = &(page_list[entry]);
+			   	if(page_list[entry].phys_addr &&
 						p->pageout && !m->pageout) {
 					vm_page_lock_queues();
 					m->busy = TRUE;
 					m->pageout = TRUE;
 					vm_page_wire(m);
 					vm_page_unlock_queues();
-			   } else if (page_list[entry].phys_addr &&
+			   	} else if (page_list[entry].phys_addr &&
 						!p->pageout && m->pageout &&
 						!m->dump_cleaning) {
 					vm_page_lock_queues();
@@ -3386,8 +3780,9 @@ upl_commit(
 					vm_page_unwire(m);
 					PAGE_WAKEUP_DONE(m);
 					vm_page_unlock_queues();
+			   	}
+			   	page_list[entry].phys_addr = 0;
 			   }
-			   page_list[entry].phys_addr = 0;
 			}
 			target_offset += PAGE_SIZE_64;
 			entry++;
@@ -3395,10 +3790,358 @@ upl_commit(
 
 		vm_object_unlock(shadow_object);
 	}
+	if (upl->flags & UPL_DEVICE_MEMORY)  {
+		vm_object_lock(upl->map_object->shadow);
+		if(upl->map_object == upl->map_object->shadow)
+			vm_object_paging_end(upl->map_object->shadow);
+		vm_object_unlock(upl->map_object->shadow);
+	}
 	upl_unlock(upl);
 	return KERN_SUCCESS;
 }
 
+
+
+kern_return_t
+vm_object_iopl_request(
+	vm_object_t		object,
+	vm_object_offset_t	offset,
+	vm_size_t		size,
+	upl_t			*upl_ptr,
+	upl_page_info_array_t	user_page_list,
+	unsigned int		*page_list_count,
+	int			cntrl_flags)
+{
+	vm_page_t		dst_page;
+	vm_object_offset_t	dst_offset = offset;
+	vm_size_t		xfer_size = size;
+	upl_t			upl = NULL;
+	int			entry;
+	wpl_array_t 		lite_list;
+	int			page_field_size;
+
+	vm_page_t		alias_page = NULL;
+	kern_return_t		ret;
+	vm_prot_t		prot;
+
+
+	if(cntrl_flags & UPL_COPYOUT_FROM) {
+		prot = VM_PROT_READ;
+	} else {
+		prot = VM_PROT_READ | VM_PROT_WRITE;
+	}
+
+	if(((size/page_size) > MAX_UPL_TRANSFER) && !object->phys_contiguous) {
+		size = MAX_UPL_TRANSFER * page_size;
+	}
+
+	if(cntrl_flags & UPL_SET_INTERNAL)
+		if(page_list_count != NULL)
+			*page_list_count = MAX_UPL_TRANSFER;
+	if(((cntrl_flags & UPL_SET_INTERNAL) && !(object->phys_contiguous)) &&
+	   ((page_list_count != NULL) && (*page_list_count != 0)
+				&& *page_list_count < (size/page_size)))
+		return KERN_INVALID_ARGUMENT;
+
+	if((!object->internal) && (object->paging_offset != 0))
+		panic("vm_object_upl_request: vnode object with non-zero paging offset\n");
+
+	if(object->phys_contiguous) {
+		/* No paging operations are possible against this memory */
+		/* and so no need for map object, ever */
+		cntrl_flags |= UPL_SET_LITE;
+	}
+
+	if(upl_ptr) {
+		if(cntrl_flags & UPL_SET_INTERNAL) {
+			if(cntrl_flags & UPL_SET_LITE) {
+				upl = upl_create(
+					UPL_CREATE_INTERNAL | UPL_CREATE_LITE,
+					size);
+				user_page_list = (upl_page_info_t *)
+				   (((vm_offset_t)upl) + sizeof(struct upl));
+				lite_list = (wpl_array_t)
+					(((vm_offset_t)user_page_list) + 
+					((size/PAGE_SIZE) * 
+						sizeof(upl_page_info_t)));
+				page_field_size = ((size/PAGE_SIZE) + 7) >> 3;
+				page_field_size = 
+					(page_field_size + 3) & 0xFFFFFFFC;
+				bzero((char *)lite_list, page_field_size);
+				upl->flags = 
+					UPL_LITE | UPL_INTERNAL | UPL_IO_WIRE;
+			} else {
+				upl = upl_create(UPL_CREATE_INTERNAL, size);
+				user_page_list = (upl_page_info_t *)
+					(((vm_offset_t)upl) 
+						+ sizeof(struct upl));
+				upl->flags = UPL_INTERNAL | UPL_IO_WIRE;
+			}
+		} else {
+			if(cntrl_flags & UPL_SET_LITE) {
+				upl = upl_create(UPL_CREATE_LITE, size);
+				lite_list = (wpl_array_t)
+				   (((vm_offset_t)upl) + sizeof(struct upl));
+				page_field_size = ((size/PAGE_SIZE) + 7) >> 3;
+				page_field_size = 
+					(page_field_size + 3) & 0xFFFFFFFC;
+				bzero((char *)lite_list, page_field_size);
+				upl->flags = UPL_LITE | UPL_IO_WIRE;
+			} else {
+				upl = upl_create(UPL_CREATE_EXTERNAL, size);
+				upl->flags = UPL_IO_WIRE;
+			}
+		}
+
+		if(object->phys_contiguous) {
+			upl->size = size;
+			upl->offset = offset + object->paging_offset;
+			*upl_ptr = upl;
+			if(user_page_list) {
+				user_page_list[0].phys_addr = 
+				  (offset + object->shadow_offset)>>12;
+				user_page_list[0].device = TRUE;
+			}
+			upl->map_object = object;
+			/* don't need any shadow mappings for this one */
+			/* since it is already I/O memory */
+			upl->flags |= UPL_DEVICE_MEMORY;
+
+			vm_object_lock(object);
+			vm_object_paging_begin(object);
+			vm_object_unlock(object);
+
+			if(page_list_count != NULL) {
+				if (upl->flags & UPL_INTERNAL) {
+					*page_list_count = 0;
+				} else {
+					*page_list_count = 1;
+				}
+			}
+			return KERN_SUCCESS;
+		}
+
+			
+		if(cntrl_flags & UPL_SET_LITE) {
+			upl->map_object = object;
+		} else {
+			upl->map_object = vm_object_allocate(size);
+			vm_object_lock(upl->map_object);
+			upl->map_object->shadow = object;
+			upl->map_object->pageout = TRUE;
+			upl->map_object->can_persist = FALSE;
+			upl->map_object->copy_strategy = 
+					MEMORY_OBJECT_COPY_NONE;
+			upl->map_object->shadow_offset = offset;
+			upl->map_object->wimg_bits = object->wimg_bits;
+			vm_object_unlock(upl->map_object);
+		}
+		upl->size = size;
+		upl->offset = offset + object->paging_offset;
+		*upl_ptr = upl;
+	}
+	vm_object_lock(object);
+
+	if (!object->phys_contiguous) {
+		/* Protect user space from future COW operations */
+		object->true_share = TRUE;
+		if (object->copy_strategy == MEMORY_OBJECT_COPY_SYMMETRIC)
+			object->copy_strategy = MEMORY_OBJECT_COPY_DELAY;
+	}
+
+#ifdef UBC_DEBUG
+	if(upl_ptr)
+		queue_enter(&object->uplq, upl, upl_t, uplq);
+#endif /* UBC_DEBUG */
+	vm_object_paging_begin(object);
+	entry = 0;
+	while (xfer_size) {
+		if((alias_page == NULL) && !(cntrl_flags & UPL_SET_LITE)) {
+			vm_object_unlock(object);
+			VM_PAGE_GRAB_FICTITIOUS(alias_page);
+			vm_object_lock(object);
+		}
+		dst_page = vm_page_lookup(object, dst_offset);
+		if ((dst_page == VM_PAGE_NULL) || (dst_page->busy) ||
+			(dst_page->unusual && (dst_page->error || 
+				dst_page->restart || dst_page->absent ||
+				dst_page->fictitious ||
+				prot & dst_page->page_lock))) {
+			vm_fault_return_t	result;
+		   do {
+			vm_page_t	top_page;
+			kern_return_t	error_code;
+			int		interruptible;
+
+			vm_object_offset_t	lo_offset = offset;
+			vm_object_offset_t	hi_offset = offset + size;
+
+
+
+			if(cntrl_flags & UPL_SET_INTERRUPTIBLE) {
+				interruptible = THREAD_ABORTSAFE;
+			} else {
+				interruptible = THREAD_UNINT;
+			}
+
+			result = vm_fault_page(object, dst_offset,
+				prot | VM_PROT_WRITE, FALSE, 
+				interruptible,
+				lo_offset, hi_offset,
+				VM_BEHAVIOR_SEQUENTIAL,
+				&prot, &dst_page, &top_page,
+			        (int *)0,
+				&error_code, FALSE, FALSE, NULL, 0);
+
+			switch(result) {
+			case VM_FAULT_SUCCESS:
+
+				PAGE_WAKEUP_DONE(dst_page);
+
+				/*
+				 *	Release paging references and
+				 *	top-level placeholder page, if any.
+				 */
+
+				if(top_page != VM_PAGE_NULL) {
+					vm_object_t local_object;
+					local_object = 
+						top_page->object;
+					if(top_page->object 
+						!= dst_page->object) {
+						vm_object_lock(
+							local_object);
+						VM_PAGE_FREE(top_page);
+						vm_object_paging_end(
+							local_object);
+						vm_object_unlock(
+							local_object);
+					} else {
+						VM_PAGE_FREE(top_page);
+						vm_object_paging_end(
+							local_object);
+					}
+				}
+
+				break;
+			
+				
+			case VM_FAULT_RETRY:
+				vm_object_lock(object);
+				vm_object_paging_begin(object);
+				break;
+
+			case VM_FAULT_FICTITIOUS_SHORTAGE:
+				vm_page_more_fictitious();
+				vm_object_lock(object);
+				vm_object_paging_begin(object);
+				break;
+
+			case VM_FAULT_MEMORY_SHORTAGE:
+				if (vm_page_wait(interruptible)) {
+					vm_object_lock(object);
+					vm_object_paging_begin(object);
+					break;
+				}
+				/* fall thru */
+
+			case VM_FAULT_INTERRUPTED:
+				error_code = MACH_SEND_INTERRUPTED;
+			case VM_FAULT_MEMORY_ERROR:
+				ret = (error_code ? error_code:
+					KERN_MEMORY_ERROR);
+				vm_object_lock(object);
+				for(; offset < dst_offset;
+						offset += PAGE_SIZE) {
+				   dst_page = vm_page_lookup(
+						object, offset);
+				   if(dst_page == VM_PAGE_NULL)
+					panic("vm_object_iopl_request: Wired pages missing. \n");
+				   vm_page_lock_queues();
+				   vm_page_unwire(dst_page);
+				   vm_page_unlock_queues();
+				   VM_STAT(reactivations++);
+				}
+				vm_object_unlock(object);
+				upl_destroy(upl);
+			   	return ret;
+			}
+		   } while ((result != VM_FAULT_SUCCESS) 
+				|| (result == VM_FAULT_INTERRUPTED));
+		}
+
+		vm_page_lock_queues();
+		vm_page_wire(dst_page);
+		vm_page_unlock_queues();
+
+		if(upl_ptr) {
+
+			vm_page_lock_queues();
+			if(cntrl_flags & UPL_SET_LITE) {
+				int	pg_num;
+				pg_num = (dst_offset-offset)/PAGE_SIZE;
+				lite_list[pg_num>>5] |= 1 << (pg_num & 31);
+			} else {
+				/*
+	 			 * Convert the fictitious page to a 
+				 * private shadow of the real page.
+	 			 */
+				assert(alias_page->fictitious);
+				alias_page->fictitious = FALSE;
+				alias_page->private = TRUE;
+				alias_page->pageout = TRUE;
+				alias_page->phys_page = dst_page->phys_page;
+				vm_page_wire(alias_page);
+
+				vm_page_insert(alias_page, 
+					upl->map_object, size - xfer_size);
+				assert(!alias_page->wanted);
+				alias_page->busy = FALSE;
+				alias_page->absent = FALSE;
+			}
+
+			/* expect the page to be used */
+			dst_page->reference = TRUE;
+	   		if (!(cntrl_flags & UPL_COPYOUT_FROM))
+				dst_page->dirty = TRUE;
+			alias_page = NULL;
+
+			if(user_page_list) {
+				user_page_list[entry].phys_addr
+					= dst_page->phys_page;
+				user_page_list[entry].dirty =
+						dst_page->dirty;
+				user_page_list[entry].pageout =
+			   			dst_page->pageout;
+				user_page_list[entry].absent =
+			   			dst_page->absent;
+				user_page_list[entry].precious =
+						dst_page->precious;
+			}
+			vm_page_unlock_queues();
+		}
+		entry++;
+		dst_offset += PAGE_SIZE_64;
+		xfer_size -= PAGE_SIZE;
+	}
+
+	if (upl->flags & UPL_INTERNAL) {
+		if(page_list_count != NULL)
+			*page_list_count = 0;
+	} else if (*page_list_count > entry) {
+		if(page_list_count != NULL)
+			*page_list_count = entry;
+	}
+
+	if(alias_page != NULL) {
+		vm_page_lock_queues();
+		vm_page_free(alias_page);
+		vm_page_unlock_queues();
+	}
+
+	vm_object_unlock(object);
+	return KERN_SUCCESS;
+}
 vm_size_t
 upl_get_internal_pagelist_offset()
 {
diff --git a/osfmk/vm/vm_pageout.h b/osfmk/vm/vm_pageout.h
index 853719b7c..0d3fa62fb 100644
--- a/osfmk/vm/vm_pageout.h
+++ b/osfmk/vm/vm_pageout.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -155,13 +158,23 @@ struct upl {
 #define UPL_PAGE_SYNC_DONE	0x20
 #define UPL_DEVICE_MEMORY	0x40
 #define UPL_PAGEOUT		0x80
+#define UPL_LITE		0x100
+#define UPL_IO_WIRE		0x200
 
 #define	UPL_PAGE_TICKET_MASK	0xF00
 #define UPL_PAGE_TICKET_SHIFT	8
 
 
 
+/* flags for upl_create flags parameter */
+#define UPL_CREATE_EXTERNAL	0
+#define UPL_CREATE_INTERNAL	0x1
+#define UPL_CREATE_LITE		0x2
+
+
 
+/* wired  page list structure */
+typedef unsigned long *wpl_array_t;
 
 	 
 
diff --git a/osfmk/vm/vm_print.h b/osfmk/vm/vm_print.h
index dbb76c48a..6fce7c7bd 100644
--- a/osfmk/vm/vm_print.h
+++ b/osfmk/vm/vm_print.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -27,12 +30,13 @@
 #define	VM_PRINT_H
 
 #include <vm/vm_map.h>
+#include <machine/db_machdep.h>
 
 extern void	vm_map_print(
-			vm_map_t	map);
+			db_addr_t	map);
 
 extern void	vm_map_copy_print(
-			vm_map_copy_t	copy);
+			db_addr_t	copy);
 
 #include <vm/vm_object.h>
 
@@ -61,6 +65,6 @@ extern void vm_external_print(
 extern void	db_vm(void);
 
 extern vm_size_t db_vm_map_total_size(
-			vm_map_t	map);
+			db_addr_t	map);
 
 #endif	/* VM_PRINT_H */
diff --git a/osfmk/vm/vm_resident.c b/osfmk/vm/vm_resident.c
index bf946edce..f3a762d1f 100644
--- a/osfmk/vm/vm_resident.c
+++ b/osfmk/vm/vm_resident.c
@@ -1,21 +1,24 @@
 /*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -74,6 +77,9 @@
 #include <kern/misc_protos.h>
 #include <zone_debug.h>
 #include <vm/cpm.h>
+#include <ppc/mappings.h>		/* (BRINGUP) */
+#include <pexpert/pexpert.h>	/* (BRINGUP) */
+
 
 /*	Variables used to indicate the relative age of pages in the
  *	inactive list
@@ -116,6 +122,7 @@ vm_page_bucket_t *vm_page_buckets;		/* Array of buckets */
 unsigned int	vm_page_bucket_count = 0;	/* How big is array? */
 unsigned int	vm_page_hash_mask;		/* Mask for hash function */
 unsigned int	vm_page_hash_shift;		/* Shift for hash function */
+uint32_t		vm_page_bucket_hash;	/* Basic bucket hash */
 decl_simple_lock_data(,vm_page_bucket_lock)
 
 #if	MACH_PAGE_HASH_STATS
@@ -168,6 +175,10 @@ hash_debug(void)
 vm_size_t	page_size  = 4096;
 vm_size_t	page_mask  = 4095;
 int		page_shift = 12;
+#else
+vm_size_t	page_size  = PAGE_SIZE;
+vm_size_t	page_mask  = PAGE_MASK;
+int		page_shift = PAGE_SHIFT;
 #endif /* PAGE_SIZE_FIXED */
 
 /*
@@ -209,7 +220,7 @@ decl_mutex_data(,vm_page_zero_fill_lock)
 
 /*
  *	Fictitious pages don't have a physical address,
- *	but we must initialize phys_addr to something.
+ *	but we must initialize phys_page to something.
  *	For debugging, this should be a strange value
  *	that the pmap module can recognize in assertions.
  */
@@ -347,7 +358,7 @@ vm_page_bootstrap(
 	m->restart = FALSE;
 	m->zero_fill = FALSE;
 
-	m->phys_addr = 0;		/* reset later */
+	m->phys_page = 0;		/* reset later */
 
 	m->page_lock = VM_PROT_NONE;
 	m->unlock_request = VM_PROT_NONE;
@@ -413,6 +424,10 @@ vm_page_bootstrap(
 	for (log2 = 0; size > 1; log2++) 
 		size /= 2;
 	vm_page_hash_shift = log1/2 - log2 + 1;
+	
+	vm_page_bucket_hash = 1 << ((log1 + 1) >> 1);		/* Get (ceiling of sqrt of table size) */
+	vm_page_bucket_hash |= 1 << ((log1 + 1) >> 2);		/* Get (ceiling of quadroot of table size) */
+	vm_page_bucket_hash |= 1;							/* Set bit and add 1 - always must be 1 to insure unique series */
 
 	if (vm_page_hash_mask & vm_page_bucket_count)
 		printf("vm_page_bootstrap: WARNING -- strange page hash\n");
@@ -440,8 +455,8 @@ vm_page_bootstrap(
 	 */
 
 	pmap_startup(&virtual_space_start, &virtual_space_end);
-	virtual_space_start = round_page(virtual_space_start);
-	virtual_space_end = trunc_page(virtual_space_end);
+	virtual_space_start = round_page_32(virtual_space_start);
+	virtual_space_end = trunc_page_32(virtual_space_end);
 
 	*startp = virtual_space_start;
 	*endp = virtual_space_end;
@@ -453,7 +468,7 @@ vm_page_bootstrap(
 	 *	wired, they nonetheless can't be moved. At this moment,
 	 *	all VM managed pages are "free", courtesy of pmap_startup.
 	 */
-	vm_page_wire_count = atop(mem_size) - vm_page_free_count;	/* initial value */
+	vm_page_wire_count = atop_64(max_mem) - vm_page_free_count;	/* initial value */
 
 	printf("vm_page_bootstrap: %d free pages\n", vm_page_free_count);
 	vm_page_free_count_minimum = vm_page_free_count;
@@ -469,7 +484,8 @@ vm_offset_t
 pmap_steal_memory(
 	vm_size_t size)
 {
-	vm_offset_t addr, vaddr, paddr;
+	vm_offset_t addr, vaddr;
+	ppnum_t	phys_page;
 
 	/*
 	 *	We round the size to a round multiple.
@@ -490,8 +506,8 @@ pmap_steal_memory(
 		 *	we don't trust the pmap module to do it right.
 		 */
 
-		virtual_space_start = round_page(virtual_space_start);
-		virtual_space_end = trunc_page(virtual_space_end);
+		virtual_space_start = round_page_32(virtual_space_start);
+		virtual_space_end = trunc_page_32(virtual_space_end);
 	}
 
 	/*
@@ -507,10 +523,10 @@ pmap_steal_memory(
 	 *	Allocate and map physical pages to back new virtual pages.
 	 */
 
-	for (vaddr = round_page(addr);
+	for (vaddr = round_page_32(addr);
 	     vaddr < addr + size;
 	     vaddr += PAGE_SIZE) {
-		if (!pmap_next_page(&paddr))
+		if (!pmap_next_page(&phys_page))
 			panic("pmap_steal_memory");
 
 		/*
@@ -518,7 +534,7 @@ pmap_steal_memory(
 		 *	but some pmap modules barf if they are.
 		 */
 
-		pmap_enter(kernel_pmap, vaddr, paddr,
+		pmap_enter(kernel_pmap, vaddr, phys_page,
 			   VM_PROT_READ|VM_PROT_WRITE, 
 				VM_WIMG_USE_DEFAULT, FALSE);
 		/*
@@ -536,18 +552,19 @@ pmap_startup(
 	vm_offset_t *startp,
 	vm_offset_t *endp)
 {
-	unsigned int i, npages, pages_initialized;
-	vm_page_t pages;
-	vm_offset_t paddr;
+	unsigned int i, npages, pages_initialized, fill, fillval;
+	vm_page_t	pages;
+	ppnum_t		phys_page;
+	addr64_t	tmpaddr;
 
 	/*
 	 *	We calculate how many page frames we will have
 	 *	and then allocate the page structures in one chunk.
 	 */
 
-	npages = ((PAGE_SIZE * pmap_free_pages() +
-		   (round_page(virtual_space_start) - virtual_space_start)) /
-		  (PAGE_SIZE + sizeof *pages));
+	tmpaddr = (addr64_t)pmap_free_pages() * (addr64_t)PAGE_SIZE;	/* Get the amount of memory left */
+	tmpaddr = tmpaddr + (addr64_t)(round_page_32(virtual_space_start) - virtual_space_start);	/* Account for any slop */
+	npages = (unsigned int)(tmpaddr / (addr64_t)(PAGE_SIZE + sizeof(*pages)));	/* Figure size of all vm_page_ts, including enough to hold the vm_page_ts */
 
 	pages = (vm_page_t) pmap_steal_memory(npages * sizeof *pages);
 
@@ -556,10 +573,10 @@ pmap_startup(
 	 */
 
 	for (i = 0, pages_initialized = 0; i < npages; i++) {
-		if (!pmap_next_page(&paddr))
+		if (!pmap_next_page(&phys_page))
 			break;
 
-		vm_page_init(&pages[i], paddr);
+		vm_page_init(&pages[i], phys_page);
 		vm_page_pages++;
 		pages_initialized++;
 	}
@@ -571,16 +588,60 @@ pmap_startup(
 	 * they require several consecutive pages.
 	 */
 
+/*
+ *		Check if we want to initialize pages to a known value
+ */
+	
+	fill = 0;													/* Assume no fill */
+	if (PE_parse_boot_arg("fill", &fillval)) fill = 1;			/* Set fill */
+	
 	for (i = pages_initialized; i > 0; i--) {
+		extern void fillPage(ppnum_t phys_page, unsigned int fillval);
+		if(fill) fillPage(pages[i - 1].phys_page, fillval);		/* Fill the page with a know value if requested at boot */			
 		vm_page_release(&pages[i - 1]);
 	}
 
+#if 0
+	{
+		vm_page_t xx, xxo, xxl;
+		int j, k, l;
+	
+		j = 0;													/* (BRINGUP) */
+		xxl = 0;
+		
+		for(xx = vm_page_queue_free; xx; xxl = xx, xx = xx->pageq.next) {	/* (BRINGUP) */
+			j++;												/* (BRINGUP) */
+			if(j > vm_page_free_count) {						/* (BRINGUP) */
+				panic("pmap_startup: too many pages, xx = %08X, xxl = %08X\n", xx, xxl);
+			}
+			
+			l = vm_page_free_count - j;							/* (BRINGUP) */
+			k = 0;												/* (BRINGUP) */
+			
+			if(((j - 1) & 0xFFFF) == 0) kprintf("checking number %d of %d\n", j, vm_page_free_count);
+
+			for(xxo = xx->pageq.next; xxo; xxo = xxo->pageq.next) {	/* (BRINGUP) */
+				k++;
+				if(k > l) panic("pmap_startup: too many in secondary check %d %d\n", k, l);
+				if((xx->phys_page & 0xFFFFFFFF) == (xxo->phys_page & 0xFFFFFFFF)) {	/* (BRINGUP) */
+					panic("pmap_startup: duplicate physaddr, xx = %08X, xxo = %08X\n", xx, xxo);
+				}
+			}
+		}
+		
+		if(j != vm_page_free_count) {						/* (BRINGUP) */
+			panic("pmap_startup: vm_page_free_count does not match, calc =  %d, vm_page_free_count = %08X\n", j, vm_page_free_count);
+		}
+	}
+#endif
+
+
 	/*
 	 *	We have to re-align virtual_space_start,
 	 *	because pmap_steal_memory has been using it.
 	 */
 
-	virtual_space_start = round_page(virtual_space_start);
+	virtual_space_start = round_page_32(virtual_space_start);
 
 	*startp = virtual_space_start;
 	*endp = virtual_space_end;
@@ -629,20 +690,20 @@ vm_page_module_init(void)
 
 void
 vm_page_create(
-	vm_offset_t start,
-	vm_offset_t end)
+	ppnum_t start,
+	ppnum_t end)
 {
-	vm_offset_t paddr;
-	vm_page_t m;
+	ppnum_t		phys_page;
+	vm_page_t 	m;
 
-	for (paddr = round_page(start);
-	     paddr < trunc_page(end);
-	     paddr += PAGE_SIZE) {
+	for (phys_page = start;
+	     phys_page < end;
+	     phys_page++) {
 		while ((m = (vm_page_t) vm_page_grab_fictitious())
 			== VM_PAGE_NULL)
 			vm_page_more_fictitious();
 
-		vm_page_init(m, paddr);
+		vm_page_init(m, phys_page);
 		vm_page_pages++;
 		vm_page_release(m);
 	}
@@ -653,11 +714,10 @@ vm_page_create(
  *
  *	Distributes the object/offset key pair among hash buckets.
  *
- *	NOTE:	To get a good hash function, the bucket count should
- *		be a power of two.
+ *	NOTE:	The bucket count must be a power of 2
  */
 #define vm_page_hash(object, offset) (\
-	( ((natural_t)(vm_offset_t)object<<vm_page_hash_shift) + (natural_t)atop(offset))\
+	( (natural_t)((uint32_t)object * vm_page_bucket_hash) + ((uint32_t)atop_64(offset) ^ vm_page_bucket_hash))\
 	 & vm_page_hash_mask)
 
 /*
@@ -908,6 +968,7 @@ vm_page_lookup(
 			break;
 	}
 	simple_unlock(&vm_page_bucket_lock);
+
 	return(mem);
 }
 
@@ -952,10 +1013,10 @@ vm_page_rename(
 void
 vm_page_init(
 	vm_page_t	mem,
-	vm_offset_t	phys_addr)
+	ppnum_t	phys_page)
 {
 	*mem = vm_page_template;
-	mem->phys_addr = phys_addr;
+	mem->phys_page = phys_page;
 }
 
 /*
@@ -996,7 +1057,7 @@ vm_page_release_fictitious(
 	assert(!m->free);
 	assert(m->busy);
 	assert(m->fictitious);
-	assert(m->phys_addr == vm_page_fictitious_addr);
+	assert(m->phys_page == vm_page_fictitious_addr);
 
 	c_vm_page_release_fictitious++;
 
@@ -1121,7 +1182,7 @@ vm_page_convert(
 	if (real_m == VM_PAGE_NULL)
 		return FALSE;
 
-	m->phys_addr = real_m->phys_addr;
+	m->phys_page = real_m->phys_page;
 	m->fictitious = FALSE;
 	m->no_isync = TRUE;
 
@@ -1132,7 +1193,7 @@ vm_page_convert(
 		vm_page_inactive_count++;
 	vm_page_unlock_queues();
 
-	real_m->phys_addr = vm_page_fictitious_addr;
+	real_m->phys_page = vm_page_fictitious_addr;
 	real_m->fictitious = TRUE;
 
 	vm_page_release_fictitious(real_m);
@@ -1231,7 +1292,7 @@ wakeup_pageout:
 	     (vm_page_inactive_count < vm_page_inactive_target)))
 		thread_wakeup((event_t) &vm_page_free_wanted);
 
-//	dbgLog(mem->phys_addr, vm_page_free_count, vm_page_wire_count, 4);	/* (TEST/DEBUG) */
+//	dbgLog(mem->phys_page, vm_page_free_count, vm_page_wire_count, 4);	/* (TEST/DEBUG) */
 
 	return mem;
 }
@@ -1246,9 +1307,21 @@ void
 vm_page_release(
 	register vm_page_t	mem)
 {
+
+#if 0
+	unsigned int pindex;
+	phys_entry *physent;
+
+	physent = mapping_phys_lookup(mem->phys_page, &pindex);		/* (BRINGUP) */
+	if(physent->ppLink & ppN) {											/* (BRINGUP) */
+		panic("vm_page_release: already released - %08X %08X\n", mem, mem->phys_page);
+	}
+	physent->ppLink = physent->ppLink | ppN;							/* (BRINGUP) */
+#endif
+
 	assert(!mem->private && !mem->fictitious);
 
-//	dbgLog(mem->phys_addr, vm_page_free_count, vm_page_wire_count, 5);	/* (TEST/DEBUG) */
+//	dbgLog(mem->phys_page, vm_page_free_count, vm_page_wire_count, 5);	/* (TEST/DEBUG) */
 
 	mutex_lock(&vm_page_queue_free_lock);
 	if (mem->free)
@@ -1398,7 +1471,7 @@ vm_page_free(
 	assert(!mem->free);
 	assert(!mem->cleaning);
 	assert(!mem->pageout);
-	assert(!vm_page_free_verify || pmap_verify_free(mem->phys_addr));
+	assert(!vm_page_free_verify || pmap_verify_free(mem->phys_page));
 
 	if (mem->tabled)
 		vm_page_remove(mem);	/* clears tabled, object, offset */
@@ -1454,7 +1527,7 @@ vm_page_free(
 	if (mem->private) {
 		mem->private = FALSE;
 		mem->fictitious = TRUE;
-		mem->phys_addr = vm_page_fictitious_addr;
+		mem->phys_page = vm_page_fictitious_addr;
 	}
 	if (mem->fictitious) {
 		vm_page_release_fictitious(mem);
@@ -1464,7 +1537,7 @@ vm_page_free(
 			vm_zf_count-=1;
 			mem->zero_fill = FALSE;
 		}
-		vm_page_init(mem, mem->phys_addr);
+		vm_page_init(mem, mem->phys_page);
 		vm_page_release(mem);
 	}
 }
@@ -1573,7 +1646,7 @@ vm_page_deactivate(
 {
 	VM_PAGE_CHECK(m);
 
-//	dbgLog(m->phys_addr, vm_page_free_count, vm_page_wire_count, 6);	/* (TEST/DEBUG) */
+//	dbgLog(m->phys_page, vm_page_free_count, vm_page_wire_count, 6);	/* (TEST/DEBUG) */
 
 	/*
 	 *	This page is no longer very interesting.  If it was
@@ -1593,7 +1666,7 @@ vm_page_deactivate(
 		return;
 	if (m->active || (m->inactive && m->reference)) {
 		if (!m->fictitious && !m->absent)
-			pmap_clear_reference(m->phys_addr);
+			pmap_clear_reference(m->phys_page);
 		m->reference = FALSE;
 		VM_PAGE_QUEUES_REMOVE(m);
 	}
@@ -1684,7 +1757,7 @@ vm_page_part_zero_fill(
 
 	VM_PAGE_CHECK(m);
 #ifdef PMAP_ZERO_PART_PAGE_IMPLEMENTED
-	pmap_zero_part_page(m->phys_addr, m_pa, len);
+	pmap_zero_part_page(m->phys_page, m_pa, len);
 #else
 	while (1) {
        		tmp = vm_page_grab();
@@ -1725,7 +1798,8 @@ vm_page_zero_fill(
 
 	VM_PAGE_CHECK(m);
 
-	pmap_zero_page(m->phys_addr);
+//	dbgTrace(0xAEAEAEAE, m->phys_page, 0);		/* (BRINGUP) */
+	pmap_zero_page(m->phys_page);
 }
 
 /*
@@ -1745,8 +1819,8 @@ vm_page_part_copy(
 	VM_PAGE_CHECK(src_m);
 	VM_PAGE_CHECK(dst_m);
 
-	pmap_copy_part_page(src_m->phys_addr, src_pa,
-			dst_m->phys_addr, dst_pa, len);
+	pmap_copy_part_page(src_m->phys_page, src_pa,
+			dst_m->phys_page, dst_pa, len);
 }
 
 /*
@@ -1769,7 +1843,7 @@ vm_page_copy(
 	VM_PAGE_CHECK(src_m);
 	VM_PAGE_CHECK(dest_m);
 
-	pmap_copy_page(src_m->phys_addr, dest_m->phys_addr);
+	pmap_copy_page(src_m->phys_page, dest_m->phys_page);
 }
 
 /*
@@ -1837,11 +1911,11 @@ vm_page_free_list_sort(void)
 	while (m != VM_PAGE_NULL) {
 		cpm_counter(++vpfls_pages_handled);
 		next_m = NEXT_PAGE(m);
-		if (m->phys_addr < sort_list->phys_addr) {
+		if (m->phys_page < sort_list->phys_page) {
 			cpm_counter(++vpfls_head_insertions);
 			SET_NEXT_PAGE(m, sort_list);
 			sort_list = m;
-		} else if (m->phys_addr > sort_list_end->phys_addr) {
+		} else if (m->phys_page > sort_list_end->phys_page) {
 			cpm_counter(++vpfls_tail_insertions);
 			SET_NEXT_PAGE(sort_list_end, m);
 			SET_NEXT_PAGE(m, VM_PAGE_NULL);
@@ -1851,7 +1925,7 @@ vm_page_free_list_sort(void)
 			/* general sorted list insertion */
 			prev = &sort_list;
 			for (m1=sort_list; m1!=VM_PAGE_NULL; m1=NEXT_PAGE(m1)) {
-				if (m1->phys_addr > m->phys_addr) {
+				if (m1->phys_page > m->phys_page) {
 					if (*prev != m1)
 						panic("vm_sort_free_list: ugh");
 					SET_NEXT_PAGE(m, *prev);
@@ -1870,11 +1944,11 @@ vm_page_free_list_sort(void)
 	 */
 	for (m = sort_list, npages = 0; m != VM_PAGE_NULL; m = NEXT_PAGE(m)) {
 		if (m != sort_list &&
-		    m->phys_addr <= addr) {
+		    m->phys_page <= addr) {
 			printf("m 0x%x addr 0x%x\n", m, addr);
 			panic("vm_sort_free_list");
 		}
-		addr = m->phys_addr;
+		addr = m->phys_page;
 		++npages;
 	}
 	if (old_free_count != vm_page_free_count)
@@ -1903,16 +1977,16 @@ vm_page_verify_contiguous(
 	unsigned int		page_count;
 	vm_offset_t		prev_addr;
 
-	prev_addr = pages->phys_addr;
+	prev_addr = pages->phys_page;
 	page_count = 1;
 	for (m = NEXT_PAGE(pages); m != VM_PAGE_NULL; m = NEXT_PAGE(m)) {
-		if (m->phys_addr != prev_addr + page_size) {
+		if (m->phys_page != prev_addr + 1) {
 			printf("m 0x%x prev_addr 0x%x, current addr 0x%x\n",
-			       m, prev_addr, m->phys_addr);
+			       m, prev_addr, m->phys_page);
 			printf("pages 0x%x page_count %d\n", pages, page_count);
 			panic("vm_page_verify_contiguous:  not contiguous!");
 		}
-		prev_addr = m->phys_addr;
+		prev_addr = m->phys_page;
 		++page_count;
 	}
 	if (page_count != npages) {
@@ -1942,18 +2016,18 @@ vm_page_find_contiguous(
 	int		npages)
 {
 	vm_page_t	m, *contig_prev, *prev_ptr;
-	vm_offset_t	prev_addr;
+	ppnum_t		prev_page;
 	unsigned int	contig_npages;
 	vm_page_t	list;
 
 	if (npages < 1)
 		return VM_PAGE_NULL;
 
-	prev_addr = vm_page_queue_free->phys_addr - (page_size + 1);
+	prev_page = vm_page_queue_free->phys_page - 2;
 	prev_ptr = &vm_page_queue_free;
 	for (m = vm_page_queue_free; m != VM_PAGE_NULL; m = NEXT_PAGE(m)) {
 
-		if (m->phys_addr != prev_addr + page_size) {
+		if (m->phys_page != prev_page + 1) {
 			/*
 			 *	Whoops!  Pages aren't contiguous.  Start over.
 			 */
@@ -1988,7 +2062,7 @@ vm_page_find_contiguous(
 
 		assert(contig_npages < npages);
 		prev_ptr = (vm_page_t *) &m->pageq.next;
-		prev_addr = m->phys_addr;
+		prev_page = m->phys_page;
 	}
 	cpm_counter(++vpfc_failed);
 	return VM_PAGE_NULL;
@@ -2172,7 +2246,7 @@ vm_page_print(
 		(p->restart ? "" : "!"),
 		(p->unusual ? "" : "!"));
 
-	iprintf("phys_addr=0x%x", p->phys_addr);
+	iprintf("phys_page=0x%x", p->phys_page);
 	printf(", page_error=0x%x", p->page_error);
 	printf(", page_lock=0x%x", p->page_lock);
 	printf(", unlock_request=%d\n", p->unlock_request);
diff --git a/osfmk/vm/vm_shared_memory_server.c b/osfmk/vm/vm_shared_memory_server.c
index c685c5418..734fccf2c 100644
--- a/osfmk/vm/vm_shared_memory_server.c
+++ b/osfmk/vm/vm_shared_memory_server.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -52,6 +55,7 @@ static load_struct_t  *
 lsf_hash_lookup(   
         queue_head_t    		*hash_table,
         void    			*file_object,  
+        vm_offset_t                     recognizableOffset,
         int     			size,
 	boolean_t			alternate,
 	shared_region_task_mappings_t	sm_info);
@@ -95,13 +99,34 @@ vm_offset_t		shared_file_data_region;
 ipc_port_t		shared_text_region_handle;
 ipc_port_t		shared_data_region_handle;
 vm_offset_t		shared_file_mapping_array = 0;
-shared_region_mapping_t	system_shared_region = NULL;
+
+shared_region_mapping_t default_environment_shared_regions = NULL;
+static decl_mutex_data(,default_regions_list_lock_data)
+
+#define default_regions_list_lock()		\
+		mutex_lock(&default_regions_list_lock_data)
+#define default_regions_list_lock_try()	\
+		mutex_try(&default_regions_list_lock_data)
+#define default_regions_list_unlock()	\
+		mutex_unlock(&default_regions_list_lock_data)
+
 
 ipc_port_t		sfma_handle = NULL;
 zone_t          	lsf_zone;
 
 int		shared_file_available_hash_ele;
 
+/* com region support */
+ipc_port_t		com_region_handle = NULL;
+vm_map_t		com_region_map = NULL;
+vm_size_t		com_region_size = 0x7000;
+shared_region_mapping_t	com_mapping_resource = NULL;
+
+#define		GLOBAL_COM_REGION_BASE 0xFFFF8000
+
+/* called for the non-default, private branch shared region support */
+/* system default fields for fs_base and system supported are not   */
+/* relevant as the system default flag is not set */
 kern_return_t
 shared_file_create_system_region(
 		shared_region_mapping_t	*shared_region)
@@ -123,20 +148,215 @@ shared_file_create_system_region(
 	kret = shared_region_mapping_create(text_handle,
 			text_size, data_handle, data_size, mapping_array,
 			GLOBAL_SHARED_TEXT_SEGMENT, shared_region, 
-			0x9000000, 0x9000000);
+			SHARED_ALTERNATE_LOAD_BASE, SHARED_ALTERNATE_LOAD_BASE);
 	if(kret)
 		return kret;
 	(*shared_region)->flags = 0;
+	if(com_mapping_resource) {
+        	shared_region_mapping_ref(com_mapping_resource);
+        	(*shared_region)->next = com_mapping_resource;
+	}
+
 	return KERN_SUCCESS;
 }
 
+/*
+ * load a new default for a specified environment into the default share
+ * regions list.  If a previous default exists for the envrionment specification
+ * it is returned along with its reference.  It is expected that the new
+ * sytem region structure passes a reference.
+ */
+
+shared_region_mapping_t
+update_default_shared_region(
+		shared_region_mapping_t new_system_region)
+{
+	shared_region_mapping_t old_system_region;
+	unsigned int fs_base;
+	unsigned int system;
+
+	fs_base = new_system_region->fs_base;
+	system = new_system_region->system;
+	new_system_region->flags |= SHARED_REGION_SYSTEM;
+	default_regions_list_lock();
+	old_system_region = default_environment_shared_regions;
+
+	if((old_system_region != NULL) && 
+		(old_system_region->fs_base == fs_base) &&
+			(old_system_region->system == system)) {
+		new_system_region->default_env_list =
+			old_system_region->default_env_list;
+		default_environment_shared_regions = new_system_region;
+		default_regions_list_unlock();
+		old_system_region->flags |= SHARED_REGION_STALE;
+		return old_system_region;
+	}
+	if (old_system_region) {
+	   while(old_system_region->default_env_list != NULL) {
+		if((old_system_region->default_env_list->fs_base == fs_base) &&
+		      (old_system_region->default_env_list->system == system)) {
+			new_system_region->default_env_list =
+			   		old_system_region->default_env_list
+						->default_env_list;
+			old_system_region->default_env_list = 
+					new_system_region;
+			default_regions_list_unlock();
+			old_system_region->flags |= SHARED_REGION_STALE;
+			return old_system_region;
+		}
+		old_system_region = old_system_region->default_env_list;
+	   }
+	}
+	/* If we get here, we are at the end of the system list and we */
+	/* did not find a pre-existing entry */
+	if(old_system_region) {
+		old_system_region->default_env_list = new_system_region;
+	} else {
+		default_environment_shared_regions = new_system_region;
+	}
+	default_regions_list_unlock();
+	return NULL;
+}
+
+/* 
+ * lookup a system_shared_region for the environment specified.  If one is
+ * found, it is returned along with a reference against the structure
+ */
+
+shared_region_mapping_t
+lookup_default_shared_region(
+		unsigned int fs_base,
+		unsigned int system)
+{
+	shared_region_mapping_t	system_region;
+	default_regions_list_lock();
+	system_region = default_environment_shared_regions;
+
+	while(system_region != NULL) {
+		if((system_region->fs_base == fs_base) &&
+		      	(system_region->system == system)) {
+			break;
+		}
+		system_region = system_region->default_env_list;
+	}
+	if(system_region)
+		shared_region_mapping_ref(system_region);
+	default_regions_list_unlock();
+	return system_region;
+}
+
+/*
+ * remove a system_region default if it appears in the default regions list. 
+ * Drop a reference on removal.
+ */
+
+void
+remove_default_shared_region(
+		shared_region_mapping_t system_region)
+{
+	shared_region_mapping_t old_system_region;
+	unsigned int fs_base;
+	unsigned int system;
+
+	default_regions_list_lock();
+	old_system_region = default_environment_shared_regions;
+
+	if(old_system_region == NULL) {
+		default_regions_list_unlock();
+		return;
+	}
+
+	if (old_system_region == system_region) {
+		default_environment_shared_regions 
+			= old_system_region->default_env_list;
+		old_system_region->flags |= SHARED_REGION_STALE;
+               	shared_region_mapping_dealloc(old_system_region);
+		default_regions_list_unlock();
+		return;
+	}
+
+	while(old_system_region->default_env_list != NULL) {
+		if(old_system_region->default_env_list == system_region) {
+			shared_region_mapping_t dead_region;
+			dead_region = old_system_region->default_env_list;
+			old_system_region->default_env_list = 
+				old_system_region->default_env_list->default_env_list;
+			dead_region->flags |= SHARED_REGION_STALE;
+               		shared_region_mapping_dealloc(dead_region);
+			default_regions_list_unlock();
+			return;
+		}
+		old_system_region = old_system_region->default_env_list;
+	}
+	default_regions_list_unlock();
+}
+
+void
+remove_all_shared_regions()
+{
+	shared_region_mapping_t system_region;
+	shared_region_mapping_t next_system_region;
+
+	default_regions_list_lock();
+	system_region = default_environment_shared_regions;
+
+	if(system_region == NULL) {
+		default_regions_list_unlock();
+		return;
+	}
+
+	while(system_region != NULL) {
+		next_system_region = system_region->default_env_list;
+		system_region->flags |= SHARED_REGION_STALE;
+               	shared_region_mapping_dealloc(system_region);
+		system_region = next_system_region;
+	}
+	default_environment_shared_regions = NULL;
+	default_regions_list_unlock();
+}
+		
+/* shared_com_boot_time_init initializes the common page shared data and */
+/* text region.  This region is semi independent of the split libs       */
+/* and so its policies have to be handled differently by the code that   */
+/* manipulates the mapping of shared region environments.  However,      */
+/* the shared region delivery system supports both */
+shared_com_boot_time_init()
+{
+	kern_return_t		 kret;
+	vm_named_entry_t	named_entry;
+
+	if(com_region_handle) {
+		panic("shared_com_boot_time_init: "
+			"com_region_handle already set\n");
+	}
+
+	/* create com page region */
+	if(kret = vm_region_object_create(kernel_map, 
+			com_region_size, 
+			&com_region_handle)) {
+		panic("shared_com_boot_time_init: "
+				"unable to create comm page\n");
+		return;
+	}
+	/* now set export the underlying region/map */
+	named_entry = (vm_named_entry_t)com_region_handle->ip_kobject;
+	com_region_map = named_entry->backing.map;
+	/* wrap the com region in its own shared file mapping structure */
+	shared_region_mapping_create(com_region_handle,
+		com_region_size, NULL, 0, 0,
+		GLOBAL_COM_REGION_BASE, &com_mapping_resource,
+		0, 0);
+
+}
+
 shared_file_boot_time_init(
-)
+		unsigned int fs_base, 
+		unsigned int system)
 {
 	long			shared_text_region_size;
 	long			shared_data_region_size;
 	shared_region_mapping_t	new_system_region;
-	shared_region_mapping_t	old_system_region;
+	shared_region_mapping_t	old_default_env;
 
 	shared_text_region_size = 0x10000000;
 	shared_data_region_size = 0x10000000;
@@ -148,20 +368,26 @@ shared_file_boot_time_init(
 		shared_text_region_size, shared_data_region_handle,
 		shared_data_region_size, shared_file_mapping_array,
 		GLOBAL_SHARED_TEXT_SEGMENT, &new_system_region,
-		0x9000000, 0x9000000);
-	old_system_region = system_shared_region;
-	system_shared_region = new_system_region;
-	system_shared_region->flags = SHARED_REGION_SYSTEM;
-        /* consume the reference held because this is the  */
-        /* system shared region */
-	if(old_system_region) {
-                shared_region_mapping_dealloc(old_system_region);
-	}
+		SHARED_ALTERNATE_LOAD_BASE, SHARED_ALTERNATE_LOAD_BASE);
+
+	new_system_region->fs_base = fs_base;
+	new_system_region->system = system;
+	new_system_region->flags = SHARED_REGION_SYSTEM;
+
+	/* grab an extra reference for the caller */
+	/* remember to grab before call to update */
+	shared_region_mapping_ref(new_system_region);
+	old_default_env = update_default_shared_region(new_system_region);
 	/* hold an extra reference because these are the system */
 	/* shared regions. */
-	shared_region_mapping_ref(system_shared_region);
-	vm_set_shared_region(current_task(), system_shared_region);
-
+	if(old_default_env)
+        	shared_region_mapping_dealloc(old_default_env);
+	if(com_mapping_resource == NULL) {
+		shared_com_boot_time_init();
+	}
+	shared_region_mapping_ref(com_mapping_resource);
+	new_system_region->next = com_mapping_resource;
+	vm_set_shared_region(current_task(), new_system_region);
 }
 
 
@@ -226,7 +452,7 @@ shared_file_init(
 
 		for (b = *mapping_array, alloced = 0; 
 			   alloced < (hash_size +
-				round_page(sizeof(struct sf_mapping)));
+				round_page_32(sizeof(struct sf_mapping)));
 			   alloced += PAGE_SIZE,  b += PAGE_SIZE) {
 			vm_object_lock(buf_object);
 			p = vm_page_alloc(buf_object, alloced);
@@ -235,9 +461,11 @@ shared_file_init(
 			} 	
 			p->busy = FALSE;
 			vm_object_unlock(buf_object);
-			pmap_enter(kernel_pmap, b, p->phys_addr,
+			pmap_enter(kernel_pmap, b, p->phys_page,
 				VM_PROT_READ | VM_PROT_WRITE, 
-				VM_WIMG_USE_DEFAULT, TRUE);
+				((unsigned int)(p->object->wimg_bits)) 
+							& VM_WIMG_MASK,
+				TRUE);
 		}
 
 
@@ -257,20 +485,24 @@ shared_file_init(
 
 		if (vm_map_wire(kernel_map, *mapping_array, 
 			*mapping_array + 
- 			   (hash_size + round_page(sizeof(struct sf_mapping))),
+ 			   (hash_size + round_page_32(sizeof(struct sf_mapping))),
 		   	VM_PROT_DEFAULT, FALSE) != KERN_SUCCESS) {
 			panic("shared_file_init: No memory for data table");
 		}
 
 		lsf_zone = zinit(sizeof(struct load_file_ele), 
 			data_table_size - 
-			   (hash_size + round_page(sizeof(struct sf_mapping))),
+			   (hash_size + round_page_32(sizeof(struct sf_mapping))),
 			0, "load_file_server"); 
 
 		zone_change(lsf_zone, Z_EXHAUST, TRUE);
 		zone_change(lsf_zone, Z_COLLECT, FALSE);
 		zone_change(lsf_zone, Z_EXPAND, FALSE);
 		zone_change(lsf_zone, Z_FOREIGN, TRUE);
+
+		/* initialize the global default environment lock */
+		mutex_init(&default_regions_list_lock_data, ETAP_NO_TRACE);
+
 	} else {
 		*mapping_array = shared_file_mapping_array;
 	}
@@ -333,7 +565,7 @@ copyin_shared_file(
 		hash_table_size = (shared_file_header->hash_size) 
 						* sizeof(struct queue_entry);
 		hash_table_offset = hash_table_size + 
-					round_page(sizeof(struct sf_mapping));
+					round_page_32(sizeof(struct sf_mapping));
 		for (i = 0; i < shared_file_header->hash_size; i++)
             		queue_init(&shared_file_header->hash[i]);
 
@@ -396,7 +628,7 @@ copyin_shared_file(
 	alternate = (*flags & ALTERNATE_LOAD_SITE) ? TRUE : FALSE;
 
 	if (file_entry = lsf_hash_lookup(shared_file_header->hash, 
-			(void *) file_object, shared_file_header->hash_size, 
+			(void *) file_object, mappings[0].file_offset, shared_file_header->hash_size, 
 			alternate, sm_info)) {
 		/* File is loaded, check the load manifest for exact match */
 		/* we simplify by requiring that the elements be the same  */
@@ -449,18 +681,27 @@ copyin_shared_file(
 		*flags = 0;
 		if(ret == KERN_NO_SPACE) {
 			shared_region_mapping_t	regions;
+			shared_region_mapping_t	system_region;
 			regions = (shared_region_mapping_t)sm_info->self;
 			regions->flags |= SHARED_REGION_FULL;
-			if(regions == system_shared_region) {
+			system_region = lookup_default_shared_region(
+				regions->fs_base, regions->system);
+			if(system_region == regions) {
 				shared_region_mapping_t	new_system_shared_regions;
-				shared_file_boot_time_init();
+				shared_file_boot_time_init(
+					regions->fs_base, regions->system);
 				/* current task must stay with its current */
 				/* regions, drop count on system_shared_region */
 				/* and put back our original set */
-				vm_get_shared_region(current_task(), &new_system_shared_regions);
-                		shared_region_mapping_dealloc(new_system_shared_regions);
+				vm_get_shared_region(current_task(), 
+						&new_system_shared_regions);
+                		shared_region_mapping_dealloc(
+						new_system_shared_regions);
 				vm_set_shared_region(current_task(), regions);
 			}
+			if(system_region != NULL) {
+                		shared_region_mapping_dealloc(system_region);
+			}
 		}
 		mutex_unlock(&shared_file_header->lock);
 		return ret;
@@ -474,6 +715,7 @@ static load_struct_t  *
 lsf_hash_lookup(
 	queue_head_t			*hash_table,
 	void				*file_object,
+  vm_offset_t                           recognizableOffset,
 	int				size,
 	boolean_t			alternate,
 	shared_region_task_mappings_t	sm_info)
@@ -487,7 +729,12 @@ lsf_hash_lookup(
 	for (entry = (load_struct_t *)queue_first(bucket);
 		!queue_end(bucket, &entry->links);
 		entry = (load_struct_t *)queue_next(&entry->links)) {
-		if (entry->file_object == (int)file_object) {
+
+		if ((entry->file_object == (int) file_object) &&
+                    (entry->file_offset != recognizableOffset)) {
+                }
+		if ((entry->file_object == (int)file_object) &&
+                    (entry->file_offset == recognizableOffset)) {
 		   target_region = (shared_region_mapping_t)sm_info->self;
 		   depth = target_region->depth;
 		   while(target_region) {
@@ -641,6 +888,7 @@ lsf_load(
 	entry->links.next = (queue_entry_t) 0;
 	entry->regions_instance = (shared_region_mapping_t)sm_info->self;
 	entry->depth=((shared_region_mapping_t)sm_info->self)->depth;
+        entry->file_offset = mappings[0].file_offset;
 
 	lsf_hash_insert(entry, sm_info);
 	tptr = &(entry->mappings);
@@ -664,12 +912,12 @@ lsf_load(
 						+ mappings[i].size;
 			}
 		}
-		if((alternate_load_next + round_page(max_loadfile_offset)) >=
+		if((alternate_load_next + round_page_32(max_loadfile_offset)) >=
 			(sm_info->data_size - (sm_info->data_size>>9))) {
 
 			return KERN_NO_SPACE;
 		}
-		alternate_load_next += round_page(max_loadfile_offset);
+		alternate_load_next += round_page_32(max_loadfile_offset);
 
 	} else {
 		if (((*base_address) & SHARED_TEXT_REGION_MASK) > 
@@ -683,6 +931,49 @@ lsf_load(
 
 	entry->base_address = (*base_address) & SHARED_TEXT_REGION_MASK;
 
+        // Sanity check the mappings -- make sure we don't stray across the
+        // alternate boundary.  If any bit of a library that we're not trying
+        // to load in the alternate load space strays across that boundary,
+        // return KERN_INVALID_ARGUMENT immediately so that the caller can
+        // try to load it in the alternate shared area.  We do this to avoid
+        // a nasty case: if a library tries to load so that it crosses the
+        // boundary, it'll occupy a bit of the alternate load area without
+        // the kernel being aware.  When loads into the alternate load area
+        // at the first free address are tried, the load will fail.
+        // Thus, a single library straddling the boundary causes all sliding
+        // libraries to fail to load.  This check will avoid such a case.
+        
+        if (!(flags & ALTERNATE_LOAD_SITE)) {
+ 	  for (i = 0; i<map_cnt;i++) {
+            vm_offset_t region_mask;
+            vm_address_t region_start;
+            vm_address_t region_end;
+ 
+            if ((mappings[i].protection & VM_PROT_WRITE) == 0) {
+ // mapping offsets are relative to start of shared segments.
+              region_mask = SHARED_TEXT_REGION_MASK;
+              region_start = (mappings[i].mapping_offset & region_mask)+entry->base_address;
+              region_end = (mappings[i].size + region_start);
+              if (region_end >= SHARED_ALTERNATE_LOAD_BASE) {
+                // No library is permitted to load so any bit of it is in the 
+                // shared alternate space.  If they want it loaded, they can put
+                // it in the alternate space explicitly.
+printf("Library trying to load across alternate shared region boundary -- denied!\n");
+                return KERN_INVALID_ARGUMENT;
+              }
+            } else {
+              // rw section?
+              region_mask = SHARED_DATA_REGION_MASK;
+              region_start = (mappings[i].mapping_offset & region_mask)+entry->base_address;
+              region_end = (mappings[i].size + region_start);
+              if (region_end >= SHARED_ALTERNATE_LOAD_BASE) {
+printf("Library trying to load across alternate shared region boundary-- denied!\n");
+               return KERN_INVALID_ARGUMENT;
+              }
+            } // write?
+          } // for
+        } // if not alternate load site.
+ 
 	/* copyin mapped file data */
 	for(i = 0; i<map_cnt; i++) {
 		vm_offset_t	target_address;
@@ -727,7 +1018,7 @@ lsf_load(
 		if(!(mappings[i].protection & VM_PROT_ZF)) {
 		   if(vm_map_copyin(current_map(), 
 			mapped_file + mappings[i].file_offset, 
-			round_page(mappings[i].size), FALSE, &copy_object)) {
+			round_page_32(mappings[i].size), FALSE, &copy_object)) {
 			vm_deallocate(((vm_named_entry_t)local_map->ip_kobject)
 			      ->backing.map, target_address, mappings[i].size);
 			lsf_unload(file_object, entry->base_address, sm_info);
@@ -744,13 +1035,13 @@ lsf_load(
 		}
 		vm_map_protect(((vm_named_entry_t)local_map->ip_kobject)
 				->backing.map, target_address,
-				round_page(target_address + mappings[i].size),
+				round_page_32(target_address + mappings[i].size),
 				(mappings[i].protection & 
 					(VM_PROT_READ | VM_PROT_EXECUTE)),
 				TRUE);
 		vm_map_protect(((vm_named_entry_t)local_map->ip_kobject)
 				->backing.map, target_address,
-				round_page(target_address + mappings[i].size),
+				round_page_32(target_address + mappings[i].size),
 				(mappings[i].protection & 
 					(VM_PROT_READ | VM_PROT_EXECUTE)),
 				FALSE);
diff --git a/osfmk/vm/vm_shared_memory_server.h b/osfmk/vm/vm_shared_memory_server.h
index 259be7ea1..f831023e2 100644
--- a/osfmk/vm/vm_shared_memory_server.h
+++ b/osfmk/vm/vm_shared_memory_server.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -52,12 +55,21 @@ struct shared_region_task_mappings {
 	vm_offset_t		client_base;
 	vm_offset_t		alternate_base;
 	vm_offset_t		alternate_next;
+	unsigned int		fs_base;
+	unsigned int		system;
 	int			flags;
 	vm_offset_t		self;
 };
 
-#define SHARED_REGION_SYSTEM	0x1
-#define SHARED_REGION_FULL	0x2
+#define SHARED_REGION_SYSTEM	0x1 // Default env for system and fs_root
+#define SHARED_REGION_FULL	0x2 // Shared regions are full
+#define SHARED_REGION_STALE 	0x4 // Indicates no longer in default list
+
+
+/* defines for default environment, and co-resident systems */
+
+#define ENV_DEFAULT_SYSTEM	0
+#define ENV_DEFAULT_ROOT	0
 
 typedef	struct shared_region_task_mappings *shared_region_task_mappings_t;
 typedef struct shared_region_mapping *shared_region_mapping_t;
@@ -90,6 +102,7 @@ struct load_struct {
 	vm_offset_t		base_address;
 	int			mapping_cnt;
 	loaded_mapping_t	*mappings;
+        vm_offset_t             file_offset; // start of file we mapped in
 };
 
 typedef struct load_struct load_struct_t;
@@ -122,6 +135,8 @@ typedef struct shared_region_object_chain *shared_region_object_chain_t;
 struct shared_region_mapping {
         decl_mutex_data(,       Lock)   /* Synchronization */
 	int			ref_count;
+	unsigned int		fs_base;
+	unsigned int		system;
 	mach_port_t		text_region;
 	vm_size_t		text_size;
 	mach_port_t		data_region;
@@ -132,6 +147,7 @@ struct shared_region_mapping {
 	vm_offset_t		alternate_next;
 	int			flags;
 	int			depth;
+	shared_region_mapping_t default_env_list;
 	shared_region_object_chain_t object_chain;
 	shared_region_mapping_t self;
 	shared_region_mapping_t next;
@@ -168,6 +184,8 @@ extern kern_return_t shared_region_mapping_info(
 				vm_offset_t		*client_base,
 				vm_offset_t		*alternate_base,
 				vm_offset_t		*alternate_next,
+				unsigned int		*fs_base,
+				unsigned int		*system,
 				int			*flags,
 				shared_region_mapping_t	*next);
 
@@ -200,6 +218,16 @@ extern kern_return_t vm_set_shared_region(
 				task_t	task,
 				shared_region_mapping_t	shared_region);
 
+extern shared_region_mapping_t update_default_shared_region(
+				shared_region_mapping_t new_system_region);
+
+extern shared_region_mapping_t lookup_default_shared_region(
+				unsigned int fs_base,
+				unsigned int system);
+
+extern void remove_default_shared_region(
+				shared_region_mapping_t system_region);
+
 extern unsigned int lsf_mapping_pool_gauge();
 
 #endif /* __APPLE_API_PRIVATE */
diff --git a/osfmk/vm/vm_user.c b/osfmk/vm/vm_user.c
index ede0d2591..44a32ca17 100644
--- a/osfmk/vm/vm_user.c
+++ b/osfmk/vm/vm_user.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -114,8 +117,8 @@ vm_allocate(
 	if (anywhere)
 		*addr = vm_map_min(map);
 	else
-		*addr = trunc_page(*addr);
-	size = round_page(size);
+		*addr = trunc_page_32(*addr);
+	size = round_page_32(size);
 	if (size == 0) {
 	  return(KERN_INVALID_ARGUMENT);
 	}
@@ -152,8 +155,8 @@ vm_deallocate(
 	if (size == (vm_offset_t) 0)
 		return(KERN_SUCCESS);
 
-	return(vm_map_remove(map, trunc_page(start),
-			     round_page(start+size), VM_MAP_NO_FLAGS));
+	return(vm_map_remove(map, trunc_page_32(start),
+			     round_page_32(start+size), VM_MAP_NO_FLAGS));
 }
 
 /*
@@ -174,8 +177,8 @@ vm_inherit(
                 return(KERN_INVALID_ARGUMENT);
 
 	return(vm_map_inherit(map,
-			      trunc_page(start),
-			      round_page(start+size),
+			      trunc_page_32(start),
+			      round_page_32(start+size),
 			      new_inheritance));
 }
 
@@ -197,8 +200,8 @@ vm_protect(
 		return(KERN_INVALID_ARGUMENT);
 
 	return(vm_map_protect(map,
-			      trunc_page(start),
-			      round_page(start+size),
+			      trunc_page_32(start),
+			      round_page_32(start+size),
 			      new_protection,
 			      set_maximum));
 }
@@ -455,8 +458,8 @@ vm_map_64(
 			vm_map_entry_t		map_entry;
 
 			named_entry_unlock(named_entry);
-			*address = trunc_page(*address);
-			size = round_page(size);
+			*address = trunc_page_32(*address);
+			size = round_page_64(size);
 			vm_object_reference(vm_submap_object);
 			if ((result = vm_map_enter(target_map,
 				address, size, mask, flags,
@@ -501,31 +504,79 @@ vm_map_64(
 			vm_object_reference(named_entry->object);
 			object = named_entry->object;
 		} else {
-			object = vm_object_enter(named_entry->backing.pager, 
-					named_entry->size, 
-					named_entry->internal, 
-					FALSE,
-					FALSE);
+			unsigned int		access;
+			vm_prot_t		protections;
+			unsigned int		wimg_mode;
+			boolean_t	cache_attr;
+
+			protections = named_entry->protection 
+							& VM_PROT_ALL;
+			access = GET_MAP_MEM(named_entry->protection);
+
+			object = vm_object_enter(
+				named_entry->backing.pager, 
+				named_entry->size, 
+				named_entry->internal, 
+				FALSE,
+				FALSE);
 			if (object == VM_OBJECT_NULL) {
 				named_entry_unlock(named_entry);
 				return(KERN_INVALID_OBJECT);
 			}
-			object->true_share = TRUE;
+
+			vm_object_lock(object);
+
+			/* create an extra ref for the named entry */
+			vm_object_reference_locked(object);
 			named_entry->object = object;
 			named_entry_unlock(named_entry);
-			/* create an extra reference for the named entry */
-			vm_object_reference(named_entry->object);
-			/* wait for object (if any) to be ready */
-			if (object != VM_OBJECT_NULL) {
-				vm_object_lock(object);
+
+			wimg_mode = object->wimg_bits;
+			if(access == MAP_MEM_IO) {
+				wimg_mode = VM_WIMG_IO;
+			} else if (access == MAP_MEM_COPYBACK) {
+				wimg_mode = VM_WIMG_USE_DEFAULT;
+			} else if (access == MAP_MEM_WTHRU) {
+				wimg_mode = VM_WIMG_WTHRU;
+			} else if (access == MAP_MEM_WCOMB) {
+				wimg_mode = VM_WIMG_WCOMB;
+			}
+			if ((wimg_mode == VM_WIMG_IO)
+				|| (wimg_mode == VM_WIMG_WCOMB))
+				cache_attr = TRUE;
+			else 
+				cache_attr = FALSE;
+
+			if (named_entry->backing.pager) {
+				/* wait for object (if any) to be ready */
 				while (!object->pager_ready) {
 					vm_object_wait(object,
-						VM_OBJECT_EVENT_PAGER_READY,
-						THREAD_UNINT);
+						   VM_OBJECT_EVENT_PAGER_READY,
+						   THREAD_UNINT);
 					vm_object_lock(object);
 				}
-				vm_object_unlock(object);
 			}
+			if(object->wimg_bits != wimg_mode) {
+				vm_page_t p;
+
+				vm_object_paging_wait(object, THREAD_UNINT);
+
+				object->wimg_bits = wimg_mode;
+				queue_iterate(&object->memq, p, vm_page_t, listq) {
+					if (!p->fictitious) {
+						pmap_page_protect(
+							p->phys_page, 
+							VM_PROT_NONE);
+						if(cache_attr)
+							pmap_sync_caches_phys(
+								p->phys_page);
+					}
+				}
+			}
+			object->true_share = TRUE;
+			if (object->copy_strategy == MEMORY_OBJECT_COPY_SYMMETRIC)
+				object->copy_strategy = MEMORY_OBJECT_COPY_DELAY;
+			vm_object_unlock(object);
 		}
 	} else if (ip_kotype(port) == IKOT_MEMORY_OBJECT) {
 		/*
@@ -562,8 +613,8 @@ vm_map_64(
 		return (KERN_INVALID_OBJECT);
 	}
 
-	*address = trunc_page(*address);
-	size = round_page(size);
+	*address = trunc_page_32(*address);
+	size = round_page_64(size);
 
 	/*
 	 *	Perform the copy if requested
@@ -626,6 +677,7 @@ vm_map_64(
 }
 
 /* temporary, until world build */
+kern_return_t
 vm_map(
 	vm_map_t		target_map,
 	vm_offset_t		*address,
@@ -639,7 +691,7 @@ vm_map(
 	vm_prot_t		max_protection,
 	vm_inherit_t		inheritance)
 {
-	vm_map_64(target_map, address, size, mask, flags, 
+	return vm_map_64(target_map, address, size, mask, flags, 
 			port, (vm_object_offset_t)offset, copy,
 			cur_protection, max_protection, inheritance);
 }
@@ -679,11 +731,11 @@ vm_wire(
 		return KERN_INVALID_ARGUMENT;
 
 	if (access != VM_PROT_NONE) {
-		rc = vm_map_wire(map, trunc_page(start),
-				 round_page(start+size), access, TRUE);
+		rc = vm_map_wire(map, trunc_page_32(start),
+				 round_page_32(start+size), access, TRUE);
 	} else {
-		rc = vm_map_unwire(map, trunc_page(start),
-				   round_page(start+size), TRUE);
+		rc = vm_map_unwire(map, trunc_page_32(start),
+				   round_page_32(start+size), TRUE);
 	}
 	return rc;
 }
@@ -744,8 +796,8 @@ vm_msync(
 	/*
 	 * align address and size on page boundaries
 	 */
-	size = round_page(address + size) - trunc_page(address);
-	address = trunc_page(address);
+	size = round_page_32(address + size) - trunc_page_32(address);
+	address = trunc_page_32(address);
 
         if (map == VM_MAP_NULL)
                 return(KERN_INVALID_TASK);
@@ -1003,8 +1055,8 @@ vm_behavior_set(
 	if (map == VM_MAP_NULL)
 		return(KERN_INVALID_ARGUMENT);
 
-	return(vm_map_behavior_set(map, trunc_page(start), 
-				   round_page(start+size), new_behavior));
+	return(vm_map_behavior_set(map, trunc_page_32(start), 
+				   round_page_32(start+size), new_behavior));
 }
 
 #if	VM_CPM
@@ -1071,8 +1123,8 @@ vm_allocate_cpm(
 	if (anywhere)
 		*addr = vm_map_min(map);
 	else
-		*addr = trunc_page(*addr);
-	size = round_page(size);
+		*addr = trunc_page_32(*addr);
+	size = round_page_32(size);
 
 	if ((kr = cpm_allocate(size, &pages, TRUE)) != KERN_SUCCESS)
 		return kr;
@@ -1100,7 +1152,7 @@ vm_allocate_cpm(
 		assert(!m->pageout);
 		assert(!m->tabled);
 		assert(m->busy);
-		assert(m->phys_addr>=avail_start && m->phys_addr<=avail_end);
+		assert(m->phys_page>=avail_start && m->phys_page<=avail_end);
 
 		m->busy = FALSE;
 		vm_page_insert(m, cpm_obj, offset);
@@ -1175,7 +1227,8 @@ vm_allocate_cpm(
 		vm_object_unlock(cpm_obj);
 		assert(m != VM_PAGE_NULL);
 		PMAP_ENTER(pmap, va, m, VM_PROT_ALL, 	
-						VM_WIMG_USE_DEFAULT, TRUE);
+			((unsigned int)(m->object->wimg_bits)) & VM_WIMG_MASK,
+			TRUE);
 	}
 
 #if	MACH_ASSERT
@@ -1200,7 +1253,7 @@ vm_allocate_cpm(
 		assert(!m->precious);
 		assert(!m->clustered);
 		if (offset != 0) {
-			if (m->phys_addr != prev_addr + PAGE_SIZE) {
+			if (m->phys_page != prev_addr + 1) {
 				printf("start 0x%x end 0x%x va 0x%x\n",
 				       start, end, va);
 				printf("obj 0x%x off 0x%x\n", cpm_obj, offset);
@@ -1209,7 +1262,7 @@ vm_allocate_cpm(
 				panic("vm_allocate_cpm:  pages not contig!");
 			}
 		}
-		prev_addr = m->phys_addr;
+		prev_addr = m->phys_page;
 	}
 #endif	/* MACH_ASSERT */
 
@@ -1249,6 +1302,7 @@ mach_memory_object_memory_entry_64(
  	memory_object_t		pager,
 	ipc_port_t		*entry_handle)
 {
+	unsigned int		access;
 	vm_named_entry_t	user_object;
 	ipc_port_t		user_handle;
 	ipc_port_t		previous;
@@ -1285,7 +1339,9 @@ mach_memory_object_memory_entry_64(
 	user_object->size = size;
 	user_object->offset = 0;
 	user_object->backing.pager = pager;
-	user_object->protection = permission;
+	user_object->protection = permission & VM_PROT_ALL;
+	access = GET_MAP_MEM(permission);
+	SET_MAP_MEM(access, user_object->protection);
 	user_object->internal = internal;
 	user_object->is_sub_map = FALSE;
 	user_object->ref_count = 1;
@@ -1348,10 +1404,85 @@ mach_make_memory_entry_64(
 	vm_object_size_t	mappable_size;
 	vm_object_size_t	total_size;
 
+	unsigned int			access;
+	vm_prot_t			protections;
+	unsigned int			wimg_mode;
+	boolean_t			cache_attr;
+
+	protections = permission & VM_PROT_ALL;
+	access = GET_MAP_MEM(permission);
+
 
 	offset = trunc_page_64(offset);
 	*size = round_page_64(*size);
-	
+
+	if((parent_entry != NULL)
+		&& (permission & MAP_MEM_ONLY)) {
+		vm_named_entry_t	parent_object;
+		if(ip_kotype(parent_entry) != IKOT_NAMED_ENTRY) {
+			return KERN_INVALID_ARGUMENT;
+		}
+		parent_object = (vm_named_entry_t)parent_entry->ip_kobject;
+		object = parent_object->object;
+		if(object != VM_OBJECT_NULL)
+			wimg_mode = object->wimg_bits;
+		if((access != GET_MAP_MEM(parent_object->protection)) &&
+				!(parent_object->protection & VM_PROT_WRITE)) { 
+			return KERN_INVALID_RIGHT;
+		}
+		if(access == MAP_MEM_IO) {
+		   SET_MAP_MEM(access, parent_object->protection);
+		   wimg_mode = VM_WIMG_IO;
+		} else if (access == MAP_MEM_COPYBACK) {
+		   SET_MAP_MEM(access, parent_object->protection);
+		   wimg_mode = VM_WIMG_DEFAULT;
+		} else if (access == MAP_MEM_WTHRU) {
+		   SET_MAP_MEM(access, parent_object->protection);
+		   wimg_mode = VM_WIMG_WTHRU;
+		} else if (access == MAP_MEM_WCOMB) {
+		   SET_MAP_MEM(access, parent_object->protection);
+		   wimg_mode = VM_WIMG_WCOMB;
+		}
+		if(object &&
+			(access != MAP_MEM_NOOP) && 
+			(!(object->nophyscache))) {
+			if(object->wimg_bits != wimg_mode) {
+			   vm_page_t p;
+			   if ((wimg_mode == VM_WIMG_IO)
+				|| (wimg_mode == VM_WIMG_WCOMB))
+				cache_attr = TRUE;
+			   else 
+				cache_attr = FALSE;
+			   vm_object_lock(object);
+			   while(object->paging_in_progress) {
+			        vm_object_unlock(object);
+			   	vm_object_wait(object,
+				   VM_OBJECT_EVENT_PAGING_IN_PROGRESS,
+				   THREAD_UNINT);
+			        vm_object_lock(object);
+			   }
+		           object->wimg_bits = wimg_mode;
+			   queue_iterate(&object->memq, 
+						p, vm_page_t, listq) {
+				if (!p->fictitious) {
+					pmap_page_protect(
+						p->phys_page, 
+						VM_PROT_NONE);
+					 if(cache_attr)
+					    pmap_sync_caches_phys(
+							p->phys_page);
+				}
+			   }
+			   vm_object_unlock(object);
+			}
+		}
+		return KERN_SUCCESS;
+	}
+
+	if(permission & MAP_MEM_ONLY) {
+		return KERN_INVALID_ARGUMENT;
+	}
+
 	user_object = (vm_named_entry_t) 
 			kalloc(sizeof (struct vm_named_entry));
 	if(user_object == NULL)
@@ -1379,11 +1510,28 @@ mach_make_memory_entry_64(
 	user_object->backing.pager = NULL;
 	user_object->ref_count = 1;
 
+	if(permission & MAP_MEM_NAMED_CREATE) {
+		user_object->object = NULL;
+		user_object->internal = TRUE;
+		user_object->is_sub_map = FALSE;
+		user_object->offset = 0;
+		user_object->protection = protections;
+		SET_MAP_MEM(access, user_object->protection);
+		user_object->size = *size;
+
+		/* user_object pager and internal fields are not used */
+		/* when the object field is filled in.		      */
+
+		ipc_kobject_set(user_handle, (ipc_kobject_t) user_object,
+							IKOT_NAMED_ENTRY);
+		*object_handle = user_handle;
+		return KERN_SUCCESS;
+	}
+
 	if(parent_entry == NULL) {
 	/* Create a named object based on address range within the task map */
 	/* Go find the object at given address */
 
-		permission &= VM_PROT_ALL;
 		vm_map_lock_read(target_map);
 
 		/* get the object associated with the target address */
@@ -1391,14 +1539,14 @@ mach_make_memory_entry_64(
 		/* that requested by the caller */
 
 		kr = vm_map_lookup_locked(&target_map, offset, 
-				permission, &version,
+				protections, &version,
 				&object, &obj_off, &prot, &wired, &behavior,
 				&lo_offset, &hi_offset, &pmap_map);
 		if (kr != KERN_SUCCESS) {
 			vm_map_unlock_read(target_map);
 			goto make_mem_done;
 		}
-		if (((prot & permission) != permission) 
+		if (((prot & protections) != protections) 
 					|| (object == kernel_object)) {
 			kr = KERN_INVALID_RIGHT;
 			vm_object_unlock(object);
@@ -1446,6 +1594,7 @@ redo_lookup:
                          goto make_mem_done;
 	              }
 		      if(map_entry->wired_count) {
+			 /* JMM - The check below should be reworked instead. */
 			 object->true_share = TRUE;
 		      }
 		      break;
@@ -1462,7 +1611,7 @@ redo_lookup:
 			local_offset += map_entry->offset;
 		   }
 		}
-		if(((map_entry->max_protection) & permission) != permission) {
+		if(((map_entry->max_protection) & protections) != protections) {
 			 kr = KERN_INVALID_RIGHT;
                          vm_object_unlock(object);
                          vm_map_unlock_read(target_map);
@@ -1489,9 +1638,12 @@ redo_lookup:
 					   (next_entry->vme_prev->vme_end - 
 				 	   next_entry->vme_prev->vme_start))) {
 					if(((next_entry->max_protection) 
-						& permission) != permission) {
+						& protections) != protections) {
 			 			break;
 					}
+					if (next_entry->needs_copy !=
+					    map_entry->needs_copy)
+						break;
 					mappable_size += next_entry->vme_end
 						- next_entry->vme_start;
 					total_size += next_entry->vme_end
@@ -1519,7 +1671,13 @@ redo_lookup:
 		            		goto redo_lookup;
 		   		}
 
-
+				/* 
+				 * JMM - We need to avoid coming here when the object
+				 * is wired by anybody, not just the current map.  Why
+				 * couldn't we use the standard vm_object_copy_quickly()
+				 * approach here?
+				 */
+				 
 		   		/* create a shadow object */
 				vm_object_shadow(&map_entry->object.vm_object,
 						&map_entry->offset, total_size);
@@ -1577,9 +1735,47 @@ redo_lookup:
 		/* target of ipc's, etc.  The code above, protecting    */
 		/* against delayed copy, etc. is mostly defensive.      */
 
-
+		wimg_mode = object->wimg_bits;
+		if(!(object->nophyscache)) {
+			if(access == MAP_MEM_IO) {
+				wimg_mode = VM_WIMG_IO;
+			} else if (access == MAP_MEM_COPYBACK) {
+				wimg_mode = VM_WIMG_USE_DEFAULT;
+			} else if (access == MAP_MEM_WTHRU) {
+				wimg_mode = VM_WIMG_WTHRU;
+			} else if (access == MAP_MEM_WCOMB) {
+				wimg_mode = VM_WIMG_WCOMB;
+			}
+		}
 
 		object->true_share = TRUE;
+		if (object->copy_strategy == MEMORY_OBJECT_COPY_SYMMETRIC)
+			object->copy_strategy = MEMORY_OBJECT_COPY_DELAY;
+
+		/* we now point to this object, hold on to it */
+		vm_object_reference_locked(object);
+		vm_map_unlock_read(target_map);
+		if(pmap_map != target_map)
+			vm_map_unlock_read(pmap_map);
+
+		if(object->wimg_bits != wimg_mode) {
+			vm_page_t p;
+
+			vm_object_paging_wait(object, THREAD_UNINT);
+
+			queue_iterate(&object->memq, 
+						p, vm_page_t, listq) {
+				if (!p->fictitious) {
+					pmap_page_protect(
+						p->phys_page, 
+						VM_PROT_NONE);
+					 if(cache_attr)
+					    pmap_sync_caches_phys(
+							p->phys_page);
+				}
+			}
+			object->wimg_bits = wimg_mode;
+		}
 		user_object->object = object;
 		user_object->internal = object->internal;
 		user_object->is_sub_map = FALSE;
@@ -1600,15 +1796,10 @@ redo_lookup:
 		/* user_object pager and internal fields are not used */
 		/* when the object field is filled in.		      */
 
-		object->ref_count++; /* we now point to this object, hold on */
-		vm_object_res_reference(object);
 		vm_object_unlock(object);
 		ipc_kobject_set(user_handle, (ipc_kobject_t) user_object,
 							IKOT_NAMED_ENTRY);
 		*object_handle = user_handle;
-		vm_map_unlock_read(target_map);
-		if(pmap_map != target_map)
-			vm_map_unlock_read(pmap_map);
 		return KERN_SUCCESS;
 	} else {
 
@@ -1620,10 +1811,6 @@ redo_lookup:
 			goto make_mem_done;
 		}
 		parent_object =  (vm_named_entry_t)parent_entry->ip_kobject;
-		if(permission & parent_object->protection != permission) {
-			kr = KERN_INVALID_ARGUMENT;
-			goto make_mem_done;
-		}
 		if((offset + *size) > parent_object->size) {
 			kr = KERN_INVALID_ARGUMENT;
 			goto make_mem_done;
@@ -1632,7 +1819,12 @@ redo_lookup:
 		user_object->object = parent_object->object;
 		user_object->size = *size;
 		user_object->offset = parent_object->offset + offset;
-		user_object->protection = permission;
+		user_object->protection = parent_object->protection;
+		user_object->protection &= ~VM_PROT_ALL;
+		user_object->protection = permission & VM_PROT_ALL;
+		if(access != MAP_MEM_NOOP) {
+			SET_MAP_MEM(access, user_object->protection);
+		}
 		if(parent_object->is_sub_map) {
 		   user_object->backing.map = parent_object->backing.map;
 		   vm_map_lock(user_object->backing.map);
@@ -1650,6 +1842,10 @@ redo_lookup:
 			vm_object_reference(parent_object->object); 
 			vm_object_lock(parent_object->object);
 			parent_object->object->true_share = TRUE;
+			if (parent_object->object->copy_strategy == 
+			    MEMORY_OBJECT_COPY_SYMMETRIC)
+				parent_object->object->copy_strategy =
+					MEMORY_OBJECT_COPY_DELAY;
 			vm_object_unlock(parent_object->object);
 		}
 		ipc_kobject_set(user_handle, (ipc_kobject_t) user_object,
@@ -1699,16 +1895,12 @@ vm_region_object_create(
 	ipc_port_t		user_handle;
 	kern_return_t		kr;
 
-	pmap_t		new_pmap = pmap_create((vm_size_t) 0);
 	ipc_port_t	previous;
 	vm_map_t	new_map;
 	
-	if(new_pmap == PMAP_NULL)
-		return KERN_FAILURE;
 	user_object = (vm_named_entry_t) 
 			kalloc(sizeof (struct vm_named_entry));
 	if(user_object == NULL) {
-		pmap_destroy(new_pmap);
 		return KERN_FAILURE;
 	}
 	named_entry_lock_init(user_object);
@@ -1735,7 +1927,7 @@ vm_region_object_create(
 
 	/* Create a named object based on a submap of specified size */
 
-	new_map = vm_map_create(new_pmap, 0, size, TRUE);
+	new_map = vm_map_create(0, 0, size, TRUE);
 	user_object->backing.map = new_map;
 
 
@@ -1798,7 +1990,15 @@ kern_return_t vm_map_region_replace(
 			vm_map_unlock(target_map);
 			return KERN_SUCCESS;
 		}
-		vm_map_lookup_entry(target_map, addr, &entry);
+	}
+	if ((entry->use_pmap) && 
+			(new_submap->pmap == NULL)) {
+		new_submap->pmap = pmap_create((vm_size_t) 0);
+		if(new_submap->pmap == PMAP_NULL) {
+			vm_map_unlock(old_submap);
+			vm_map_unlock(target_map);
+			return(KERN_NO_SPACE);
+		}
 	}
 	addr = entry->vme_start;
 	vm_map_reference(old_submap);
@@ -1807,7 +2007,7 @@ kern_return_t vm_map_region_replace(
 		if((entry->is_sub_map) && 
 			(entry->object.sub_map == old_submap)) {
 			if(entry->use_pmap) {
-				if((start & 0xfffffff) || 
+				if((start & 0x0fffffff) || 
 					((end - start) != 0x10000000)) {
 					vm_map_unlock(old_submap);
 					vm_map_deallocate(old_submap);
@@ -1825,14 +2025,15 @@ kern_return_t vm_map_region_replace(
 	}
 	if(nested_pmap) {
 #ifndef i386
-		pmap_unnest(target_map->pmap, start, end - start);
+		pmap_unnest(target_map->pmap, (addr64_t)start);
 		if(target_map->mapped) {
 			vm_map_submap_pmap_clean(target_map,
 				start, end, old_submap, 0);
 		}
 		pmap_nest(target_map->pmap, new_submap->pmap, 
-						start, end - start);
-#endif i386
+				(addr64_t)start, (addr64_t)start, 
+				(addr64_t)(end - start));
+#endif /* i386 */
 	} else {
 		vm_map_submap_pmap_clean(target_map,
 				start, end, old_submap, 0);
@@ -1943,12 +2144,12 @@ restart_page_query:
 
 	if (m->dirty)
 		*disposition |= VM_PAGE_QUERY_PAGE_DIRTY;
-	else if(pmap_is_modified(m->phys_addr))
+	else if(pmap_is_modified(m->phys_page))
 		*disposition |= VM_PAGE_QUERY_PAGE_DIRTY;
 
 	if (m->reference)
 		*disposition |= VM_PAGE_QUERY_PAGE_REF;
-	else if(pmap_is_referenced(m->phys_addr))
+	else if(pmap_is_referenced(m->phys_page))
 		*disposition |= VM_PAGE_QUERY_PAGE_REF;
 
 	vm_object_unlock(object);
@@ -2049,6 +2250,10 @@ REDISCOVER_ENTRY:
 			entry->offset = 0;
 		}
 		if (!(caller_flags & UPL_COPYOUT_FROM)) {
+			if (!(entry->protection & VM_PROT_WRITE)) {
+				vm_map_unlock(map);
+				return KERN_PROTECTION_FAILURE;
+			}
 			if (entry->needs_copy)  {
 				vm_map_t		local_map;
 				vm_object_t		object;
@@ -2208,14 +2413,27 @@ REDISCOVER_ENTRY:
 		local_start = entry->vme_start;
 		vm_object_reference(local_object);
 		vm_map_unlock(map);
-		ret = (vm_object_upl_request(local_object, 
-			(vm_object_offset_t)
-				((offset - local_start) + local_offset),
-			*upl_size,
-			upl,
-			page_list,
-			count,
-			caller_flags));
+		if(caller_flags & UPL_SET_IO_WIRE) {
+			ret = (vm_object_iopl_request(local_object, 
+				(vm_object_offset_t)
+				   ((offset - local_start) 
+						+ local_offset),
+				*upl_size,
+				upl,
+				page_list,
+				count,
+				caller_flags));
+		} else {
+			ret = (vm_object_upl_request(local_object, 
+				(vm_object_offset_t)
+				   ((offset - local_start) 
+						+ local_offset),
+				*upl_size,
+				upl,
+				page_list,
+				count,
+				caller_flags));
+		}
 		vm_object_deallocate(local_object);
 		return(ret);
 	} 
@@ -2344,6 +2562,8 @@ shared_region_mapping_info(
 	vm_offset_t		*client_base,
 	vm_offset_t		*alt_base,
 	vm_offset_t		*alt_next,
+	unsigned int		*fs_base,
+	unsigned int		*system,
 	int			*flags,
 	shared_region_mapping_t	*next)
 {
@@ -2358,6 +2578,8 @@ shared_region_mapping_info(
 	*alt_base = shared_region->alternate_base;
 	*alt_next = shared_region->alternate_next;
 	*flags = shared_region->flags;
+	*fs_base = shared_region->fs_base;
+	*system = shared_region->system;
 	*next = shared_region->next;
 
 	shared_region_mapping_unlock(shared_region);
@@ -2404,6 +2626,8 @@ shared_region_mapping_create(
 	shared_region_mapping_lock_init((*shared_region));
 	(*shared_region)->text_region = text_region;
 	(*shared_region)->text_size = text_size;
+	(*shared_region)->fs_base = ENV_DEFAULT_ROOT;
+	(*shared_region)->system = ENV_DEFAULT_SYSTEM;
 	(*shared_region)->data_region = data_region;
 	(*shared_region)->data_size = data_size;
 	(*shared_region)->region_mappings = region_mappings;
@@ -2414,6 +2638,7 @@ shared_region_mapping_create(
 	(*shared_region)->self = *shared_region;
 	(*shared_region)->flags = 0;
 	(*shared_region)->depth = 0;
+	(*shared_region)->default_env_list = NULL;
 	(*shared_region)->alternate_base = alt_base;
 	(*shared_region)->alternate_next = alt_next;
 	return KERN_SUCCESS;
@@ -2444,9 +2669,11 @@ shared_region_mapping_dealloc(
 {
 	struct shared_region_task_mappings sm_info;
 	shared_region_mapping_t next = NULL;
+	int ref_count;
 
 	while (shared_region) {
-		if (hw_atomic_sub(&shared_region->ref_count, 1) == 0) {
+		if ((ref_count = 
+			  hw_atomic_sub(&shared_region->ref_count, 1)) == 0) {
 			shared_region_mapping_lock(shared_region);
 
 			sm_info.text_region = shared_region->text_region;
@@ -2460,14 +2687,21 @@ shared_region_mapping_dealloc(
 			sm_info.flags = shared_region->flags;
 			sm_info.self = (vm_offset_t)shared_region;
 
-			lsf_remove_regions_mappings(shared_region, &sm_info);
-			pmap_remove(((vm_named_entry_t)
+			if(shared_region->region_mappings) {
+				lsf_remove_regions_mappings(shared_region, &sm_info);
+			}
+			if(((vm_named_entry_t)
+				(shared_region->text_region->ip_kobject))
+                                                        ->backing.map->pmap) {
+			    pmap_remove(((vm_named_entry_t)
 				(shared_region->text_region->ip_kobject))
 							->backing.map->pmap, 
 				sm_info.client_base, 
 				sm_info.client_base + sm_info.text_size);
+			}
 			ipc_port_release_send(shared_region->text_region);
-			ipc_port_release_send(shared_region->data_region);
+			if(shared_region->data_region)
+				ipc_port_release_send(shared_region->data_region);
 			if (shared_region->object_chain) {
 				next = shared_region->object_chain->object_chain_region;
 				kfree((vm_offset_t)shared_region->object_chain,
@@ -2480,13 +2714,20 @@ shared_region_mapping_dealloc(
 				sizeof (struct shared_region_mapping));
 			shared_region = next;
 		} else {
+			/* Stale indicates that a system region is no */
+			/* longer in the default environment list.    */
+			if((ref_count == 1) && 
+			  (shared_region->flags & SHARED_REGION_SYSTEM)
+			  && (shared_region->flags & ~SHARED_REGION_STALE)) {
+				remove_default_shared_region(shared_region);
+			}
 			break;
 		}
 	}
 	return KERN_SUCCESS;
 }
 
-vm_offset_t
+ppnum_t
 vm_map_get_phys_page(
 	vm_map_t	map,
 	vm_offset_t	offset)
@@ -2494,7 +2735,7 @@ vm_map_get_phys_page(
 	vm_map_entry_t	entry;
 	int		ops;
 	int		flags;
-	vm_offset_t	phys_addr = 0;
+	ppnum_t		phys_page = 0;
 	vm_object_t	object;
 
 	vm_map_lock(map);
@@ -2527,7 +2768,9 @@ vm_map_get_phys_page(
 				continue;
 			}
 			offset = entry->offset + (offset - entry->vme_start);
-			phys_addr = entry->object.vm_object->shadow_offset + offset;
+			phys_page = (ppnum_t)
+				((entry->object.vm_object->shadow_offset 
+							+ offset) >> 12);
 			break;
 			
 		}
@@ -2549,7 +2792,7 @@ vm_map_get_phys_page(
 					break;
 				}
 			} else {
-				phys_addr = dst_page->phys_addr;
+				phys_page = (ppnum_t)(dst_page->phys_page);
 				vm_object_unlock(object);
 				break;
 			}
@@ -2559,6 +2802,98 @@ vm_map_get_phys_page(
 	} 
 
 	vm_map_unlock(map);
-	return phys_addr;
+	return phys_page;
+}
+
+kern_return_t
+kernel_object_iopl_request(
+	vm_named_entry_t	named_entry,
+	memory_object_offset_t	offset,
+	vm_size_t		size,
+	upl_t			*upl_ptr,
+	upl_page_info_array_t	user_page_list,
+	unsigned int		*page_list_count,
+	int			cntrl_flags)
+{
+	vm_object_t		object;
+	kern_return_t		ret;
+
+
+	/* a few checks to make sure user is obeying rules */
+	if(size == 0) {
+		if(offset >= named_entry->size)
+			return(KERN_INVALID_RIGHT);
+		size = named_entry->size - offset;
+	}
+	if(cntrl_flags & UPL_COPYOUT_FROM) {
+		if((named_entry->protection & VM_PROT_READ) 
+					!= VM_PROT_READ) {
+			return(KERN_INVALID_RIGHT);
+		}
+	} else {
+		if((named_entry->protection & 
+			(VM_PROT_READ | VM_PROT_WRITE)) 
+			!= (VM_PROT_READ | VM_PROT_WRITE)) {
+			return(KERN_INVALID_RIGHT);
+		}
+	}
+	if(named_entry->size < (offset + size))
+		return(KERN_INVALID_ARGUMENT);
+
+	/* the callers parameter offset is defined to be the */
+	/* offset from beginning of named entry offset in object */
+	offset = offset + named_entry->offset;
+
+	if(named_entry->is_sub_map) 
+		return (KERN_INVALID_ARGUMENT);
+		
+	named_entry_lock(named_entry);
+
+	if(named_entry->object) {
+		/* This is the case where we are going to map */
+		/* an already mapped object.  If the object is */
+		/* not ready it is internal.  An external     */
+		/* object cannot be mapped until it is ready  */
+		/* we can therefore avoid the ready check     */
+		/* in this case.  */
+		vm_object_reference(named_entry->object);
+		object = named_entry->object;
+		named_entry_unlock(named_entry);
+	} else {
+		object = vm_object_enter(named_entry->backing.pager, 
+				named_entry->size, 
+				named_entry->internal, 
+				FALSE,
+				FALSE);
+		if (object == VM_OBJECT_NULL) {
+			named_entry_unlock(named_entry);
+			return(KERN_INVALID_OBJECT);
+		}
+		vm_object_lock(object);
+
+		/* create an extra reference for the named entry */
+		vm_object_reference_locked(object);
+		named_entry->object = object;
+		named_entry_unlock(named_entry);
+
+		/* wait for object (if any) to be ready */
+		while (!object->pager_ready) {
+			vm_object_wait(object,
+				VM_OBJECT_EVENT_PAGER_READY,
+				THREAD_UNINT);
+			vm_object_lock(object);
+		}
+		vm_object_unlock(object);
+	}
+
+	ret = vm_object_iopl_request(object,
+				     offset,
+				     size,
+				     upl_ptr,
+				     user_page_list,
+				     page_list_count,
+				     cntrl_flags);
+	vm_object_deallocate(object);
+	return ret;
 }
 #endif	/* VM_CPM */
diff --git a/pexpert/conf/version.minor b/pexpert/conf/version.minor
index 0cfbf0888..7f8f011eb 100644
--- a/pexpert/conf/version.minor
+++ b/pexpert/conf/version.minor
@@ -1 +1 @@
-2
+7
diff --git a/pexpert/conf/version.variant b/pexpert/conf/version.variant
index e69de29bb..7ed6ff82d 100644
--- a/pexpert/conf/version.variant
+++ b/pexpert/conf/version.variant
@@ -0,0 +1 @@
+5
diff --git a/pexpert/gen/bootargs.c b/pexpert/gen/bootargs.c
index 70463e769..d7311efd8 100644
--- a/pexpert/gen/bootargs.c
+++ b/pexpert/gen/bootargs.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -172,6 +175,12 @@ getval(
 				c -= 'a' - 10;
 			else if ((c >= 'A') && (c <= 'F'))
 				c -= 'A' - 10;
+			else if (c == 'k' || c == 'K')
+				{ sign *= 1024; break; }
+			else if (c == 'm' || c == 'M')
+				{ sign *= 1024 * 1024; break; }
+			else if (c == 'g' || c == 'G')
+				{ sign *= 1024 * 1024 * 1024; break; }
 			else if (isargsep(c))
 				break;
 			else
diff --git a/pexpert/gen/device_tree.c b/pexpert/gen/device_tree.c
index a26878559..eb09004c9 100644
--- a/pexpert/gen/device_tree.c
+++ b/pexpert/gen/device_tree.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/pexpert/gen/pe_gen.c b/pexpert/gen/pe_gen.c
index 2d96feadf..3cab8c578 100644
--- a/pexpert/gen/pe_gen.c
+++ b/pexpert/gen/pe_gen.c
@@ -2,21 +2,24 @@
  * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
- *
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- *
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * 
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
- *
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ * 
  * @APPLE_LICENSE_HEADER_END@
  */
 /*
diff --git a/pexpert/i386/boot_images.h b/pexpert/i386/boot_images.h
index 761c82979..716a4635d 100644
--- a/pexpert/i386/boot_images.h
+++ b/pexpert/i386/boot_images.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/pexpert/i386/fakePPCDeviceTree.c b/pexpert/i386/fakePPCDeviceTree.c
index 93c83ee7b..0fae65b2a 100644
--- a/pexpert/i386/fakePPCDeviceTree.c
+++ b/pexpert/i386/fakePPCDeviceTree.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/pexpert/i386/fakePPCDeviceTree.h b/pexpert/i386/fakePPCDeviceTree.h
index 40300fbb3..7df60ccc5 100644
--- a/pexpert/i386/fakePPCDeviceTree.h
+++ b/pexpert/i386/fakePPCDeviceTree.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/pexpert/i386/fakePPCStructs.h b/pexpert/i386/fakePPCStructs.h
index 2f0fef665..c8fa2320d 100644
--- a/pexpert/i386/fakePPCStructs.h
+++ b/pexpert/i386/fakePPCStructs.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/pexpert/i386/kd.c b/pexpert/i386/kd.c
index 0e8dd758f..e65dc01ca 100644
--- a/pexpert/i386/kd.c
+++ b/pexpert/i386/kd.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/pexpert/i386/kdasm.s b/pexpert/i386/kdasm.s
index 2b9fa2bcd..68421862f 100644
--- a/pexpert/i386/kdasm.s
+++ b/pexpert/i386/kdasm.s
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/pexpert/i386/pe_bootargs.c b/pexpert/i386/pe_bootargs.c
index fa80f5dbf..cbc426cdf 100644
--- a/pexpert/i386/pe_bootargs.c
+++ b/pexpert/i386/pe_bootargs.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/pexpert/i386/pe_identify_machine.c b/pexpert/i386/pe_identify_machine.c
index c8ecface5..83b28849e 100644
--- a/pexpert/i386/pe_identify_machine.c
+++ b/pexpert/i386/pe_identify_machine.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -40,9 +43,18 @@ void pe_identify_machine(boot_args *args)
   bzero((void *)&gPEClockFrequencyInfo, sizeof(clock_frequency_info_t));
   
   // Start with default values.
-  gPEClockFrequencyInfo.bus_clock_rate_hz = 100000000;
-  gPEClockFrequencyInfo.cpu_clock_rate_hz = 300000000;
-  gPEClockFrequencyInfo.dec_clock_rate_hz =  25000000;
+  gPEClockFrequencyInfo.timebase_frequency_hz =  25000000;
+  gPEClockFrequencyInfo.bus_frequency_hz      = 100000000;
+  gPEClockFrequencyInfo.cpu_frequency_hz      = 300000000;
+  
+  gPEClockFrequencyInfo.bus_frequency_min_hz = gPEClockFrequencyInfo.bus_frequency_hz;
+  gPEClockFrequencyInfo.bus_frequency_max_hz = gPEClockFrequencyInfo.bus_frequency_hz;
+  gPEClockFrequencyInfo.cpu_frequency_min_hz = gPEClockFrequencyInfo.cpu_frequency_hz;
+  gPEClockFrequencyInfo.cpu_frequency_max_hz = gPEClockFrequencyInfo.cpu_frequency_hz;
+  
+  gPEClockFrequencyInfo.dec_clock_rate_hz = gPEClockFrequencyInfo.timebase_frequency_hz;
+  gPEClockFrequencyInfo.bus_clock_rate_hz = gPEClockFrequencyInfo.bus_frequency_hz;
+  gPEClockFrequencyInfo.cpu_clock_rate_hz = gPEClockFrequencyInfo.cpu_frequency_hz;
   
   // Get real number from some where.
   
diff --git a/pexpert/i386/pe_init.c b/pexpert/i386/pe_init.c
index 6e8001e6f..dfe65ebaf 100644
--- a/pexpert/i386/pe_init.c
+++ b/pexpert/i386/pe_init.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/pexpert/i386/pe_interrupt.c b/pexpert/i386/pe_interrupt.c
index a3d3a3a64..2040b0e46 100644
--- a/pexpert/i386/pe_interrupt.c
+++ b/pexpert/i386/pe_interrupt.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/pexpert/i386/pe_kprintf.c b/pexpert/i386/pe_kprintf.c
index e7601e780..3d00e68f9 100644
--- a/pexpert/i386/pe_kprintf.c
+++ b/pexpert/i386/pe_kprintf.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/pexpert/i386/pe_misc.s b/pexpert/i386/pe_misc.s
index 0759794a4..6ee731cd1 100644
--- a/pexpert/i386/pe_misc.s
+++ b/pexpert/i386/pe_misc.s
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/pexpert/i386/pe_spl.c b/pexpert/i386/pe_spl.c
index 3e247bc56..2fe7d6ae6 100644
--- a/pexpert/i386/pe_spl.c
+++ b/pexpert/i386/pe_spl.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/pexpert/i386/text_console.c b/pexpert/i386/text_console.c
index e35d50a8d..bbad4ebd6 100644
--- a/pexpert/i386/text_console.c
+++ b/pexpert/i386/text_console.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/pexpert/i386/video_console.h b/pexpert/i386/video_console.h
index ccf059eff..130956005 100644
--- a/pexpert/i386/video_console.h
+++ b/pexpert/i386/video_console.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/pexpert/pexpert/boot.h b/pexpert/pexpert/boot.h
index d703fb7c6..a22a9d509 100644
--- a/pexpert/pexpert/boot.h
+++ b/pexpert/pexpert/boot.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/pexpert/pexpert/device_tree.h b/pexpert/pexpert/device_tree.h
index 8a124e529..c009d596f 100644
--- a/pexpert/pexpert/device_tree.h
+++ b/pexpert/pexpert/device_tree.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/pexpert/pexpert/i386/boot.h b/pexpert/pexpert/i386/boot.h
index f41b3ec8c..8b93ca597 100644
--- a/pexpert/pexpert/i386/boot.h
+++ b/pexpert/pexpert/i386/boot.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/pexpert/pexpert/i386/fb_entries.h b/pexpert/pexpert/i386/fb_entries.h
index b4dc94132..cb97bf45d 100644
--- a/pexpert/pexpert/i386/fb_entries.h
+++ b/pexpert/pexpert/i386/fb_entries.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/pexpert/pexpert/i386/kd_entries.h b/pexpert/pexpert/i386/kd_entries.h
index f3b328a77..685e190c4 100644
--- a/pexpert/pexpert/i386/kd_entries.h
+++ b/pexpert/pexpert/i386/kd_entries.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/pexpert/pexpert/i386/kdsoft.h b/pexpert/pexpert/i386/kdsoft.h
index 2cdfd0aa9..293515749 100644
--- a/pexpert/pexpert/i386/kdsoft.h
+++ b/pexpert/pexpert/i386/kdsoft.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/pexpert/pexpert/i386/protos.h b/pexpert/pexpert/i386/protos.h
index 09857c7db..990c60e72 100644
--- a/pexpert/pexpert/i386/protos.h
+++ b/pexpert/pexpert/i386/protos.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/pexpert/pexpert/machine/boot.h b/pexpert/pexpert/machine/boot.h
index e6e841f65..e633471a9 100644
--- a/pexpert/pexpert/machine/boot.h
+++ b/pexpert/pexpert/machine/boot.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/pexpert/pexpert/machine/protos.h b/pexpert/pexpert/machine/protos.h
index 520daef69..7d005b13e 100644
--- a/pexpert/pexpert/machine/protos.h
+++ b/pexpert/pexpert/machine/protos.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/pexpert/pexpert/pe_images.h b/pexpert/pexpert/pe_images.h
index 8fdab2dea..92c741007 100644
--- a/pexpert/pexpert/pe_images.h
+++ b/pexpert/pexpert/pe_images.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/pexpert/pexpert/pexpert.h b/pexpert/pexpert/pexpert.h
index 6078e3c2c..fcb9435c1 100644
--- a/pexpert/pexpert/pexpert.h
+++ b/pexpert/pexpert/pexpert.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -54,6 +57,8 @@ void PE_init_platform(
 void PE_init_kprintf(
 	boolean_t vm_initialized);
 
+unsigned int PE_init_taproot(vm_offset_t *taddr);
+
 extern void (*PE_kputc)(char c);
 
 void PE_init_printf(
@@ -74,6 +79,15 @@ struct clock_frequency_info_t {
   unsigned long bus_to_cpu_rate_den;
   unsigned long bus_to_dec_rate_num;
   unsigned long bus_to_dec_rate_den;
+  unsigned long timebase_frequency_hz;
+  unsigned long timebase_frequency_num;
+  unsigned long timebase_frequency_den;
+  unsigned long long bus_frequency_hz;
+  unsigned long long bus_frequency_min_hz;
+  unsigned long long bus_frequency_max_hz;
+  unsigned long long cpu_frequency_hz;
+  unsigned long long cpu_frequency_min_hz;
+  unsigned long long cpu_frequency_max_hz;
 };
 
 typedef struct clock_frequency_info_t clock_frequency_info_t;
@@ -101,8 +115,6 @@ void kprintf(
 void init_display_putc(unsigned char *baseaddr, int rowbytes, int height);
 void display_putc(char c);
 
-boolean_t PE_init_ethernet_debugger( void );
-
 enum {
     kPEReadTOD,
     kPEWriteTOD
diff --git a/pexpert/pexpert/ppc/boot.h b/pexpert/pexpert/ppc/boot.h
index 0c74f8eb6..498b4e0f9 100644
--- a/pexpert/pexpert/ppc/boot.h
+++ b/pexpert/pexpert/ppc/boot.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -57,8 +60,9 @@ typedef struct DRAMBank DRAMBank;
 
 /* Boot argument structure - passed into Mach kernel at boot time.
  */
-#define kBootArgsVersion		1
 #define kBootArgsRevision		1
+#define kBootArgsVersion1		1
+#define kBootArgsVersion2		2
 
 typedef struct boot_args {
   unsigned short	Revision;	/* Revision of boot_args structure */
diff --git a/pexpert/pexpert/ppc/dbdma.h b/pexpert/pexpert/ppc/dbdma.h
index eac44d6cd..12c47f241 100644
--- a/pexpert/pexpert/ppc/dbdma.h
+++ b/pexpert/pexpert/ppc/dbdma.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/pexpert/pexpert/ppc/interrupts.h b/pexpert/pexpert/ppc/interrupts.h
index 14a0ea7d5..a54cba183 100644
--- a/pexpert/pexpert/ppc/interrupts.h
+++ b/pexpert/pexpert/ppc/interrupts.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/pexpert/pexpert/ppc/powermac.h b/pexpert/pexpert/ppc/powermac.h
index aed753792..03cfb409e 100644
--- a/pexpert/pexpert/ppc/powermac.h
+++ b/pexpert/pexpert/ppc/powermac.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/pexpert/pexpert/ppc/protos.h b/pexpert/pexpert/ppc/protos.h
index f9bb037c1..668a4ac36 100644
--- a/pexpert/pexpert/ppc/protos.h
+++ b/pexpert/pexpert/ppc/protos.h
@@ -3,36 +3,27 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
 #ifndef _PEXPERT_PPC_PROTOS_H_
 #define _PEXPERT_PPC_PROTOS_H_
-
-#define mtibatu(n, reg) __asm__ volatile("mtibatu " # n ", %0" : : "r" (reg))
-#define mtibatl(n, reg) __asm__ volatile("mtibatl " # n ", %0" : : "r" (reg))
- 
-#define mtdbatu(n, reg) __asm__ volatile("mtdbatu " # n ", %0" : : "r" (reg))
-#define mtdbatl(n, reg) __asm__ volatile("mtdbatl " # n ", %0" : : "r" (reg))
-  
-#define mfibatu(reg, n) __asm__ volatile("mfibatu %0, " # n : "=r" (reg))
-#define mfibatl(reg, n) __asm__ volatile("mfibatl %0, " # n : "=r" (reg))
- 
-#define mfdbatu(reg, n) __asm__ volatile("mfdbatu %0, " # n : "=r" (reg))
-#define mfdbatl(reg, n) __asm__ volatile("mfdbatl %0, " # n : "=r" (reg))
  
 #define mtsprg(n, reg)  __asm__ volatile("mtsprg  " # n ", %0" : : "r" (reg))
 #define mfsprg(reg, n)  __asm__ volatile("mfsprg  %0, " # n : "=r" (reg))
@@ -83,10 +74,6 @@ static __inline__ unsigned int byte_reverse_word(unsigned int word) {
 extern void initialize_serial(void * scc_phys_base);
 
 
-//------------------------------------------------------------------------
-// from ppc/POWERMAC/device_tree.h
-extern void ofw_init(void *);
-
 //------------------------------------------------------------------------
 // from osfmk/ppc/POWERMAC/video_console.c
 
@@ -103,32 +90,6 @@ extern void vc_display_icon( void * desc,
 extern int  switch_to_serial_console(void);
 extern void switch_to_old_console(int old_console);
 
-//------------------------------------------------------------------------
-// from ppc/spl.h
- /* Note also : if any new SPL's are introduced, please add to debugging list*/
-#define SPLOFF          0       /* all interrupts disabled TODO NMGS  */
-#define SPLPOWER        1       /* power failure (unused) */
-#define SPLHIGH         2       /* TODO NMGS any non-zero, non-INTPRI value */
-#define SPLSCHED        SPLHIGH
-#define SPLCLOCK        SPLSCHED /* hard clock */
-#define SPLVM           4       /* pmap manipulations */
-#define SPLBIO          8       /* block I/O */
-#define SPLIMP          8       /* network & malloc */
-#define SPLTTY          16      /* TTY */
-#define SPLNET          24      /* soft net */
-#define SPLSCLK         27      /* soft clock */
-#define SPLLO           32      /* no interrupts masked */
-
-/* internal - masked in to spl level if ok to lower priority (splx, splon)
- * the mask bit is never seen externally
- */
-#define SPL_LOWER_MASK  0x8000
-
-#define SPL_CMP_GT(a, b)        ((unsigned)(a) >  (unsigned)(b))
-#define SPL_CMP_LT(a, b)        ((unsigned)(a) <  (unsigned)(b))
-#define SPL_CMP_GE(a, b)        ((unsigned)(a) >= (unsigned)(b))
-#define SPL_CMP_LE(a, b)        ((unsigned)(a) <= (unsigned)(b))
-
 typedef unsigned spl_t;
 
 //------------------------------------------------------------------------
@@ -144,60 +105,38 @@ extern void            cninit(void);
  *	Temporarily stolen from Firmware.h
  */
 
-void dbgDisp(unsigned int port, unsigned int id, unsigned int data);
-void dbgDispLL(unsigned int port, unsigned int id, unsigned int data);
-void fwSCCinit(unsigned int port);
-
 extern void dbgTrace(unsigned int item1, unsigned int item2, unsigned int item3);
 #if 1		/* (TEST/DEBUG) - eliminate inline */
 extern __inline__ void dbgTrace(unsigned int item1, unsigned int item2, unsigned int item3) {
  
- 		__asm__ volatile("mr   r3,%0" : : "r" (item1) : "r3");
- 		__asm__ volatile("mr   r4,%0" : : "r" (item2) : "r4");
- 		__asm__ volatile("mr   r5,%0" : : "r" (item3) : "r5");
-#ifdef __ELF__
-        __asm__ volatile("lis  r0,CutTrace@h" : : : "r0");
-        __asm__ volatile("ori  r0,r0,CutTrace@l" : : : "r0");
-#else
-        __asm__ volatile("lis  r0,hi16(CutTrace)" : : : "r0");
-        __asm__ volatile("ori  r0,r0,lo16(CutTrace)" : : : "r0");
-#endif
-        __asm__ volatile("sc");
-		return;
+	__asm__ volatile("mr   r3,%0" : : "r" (item1) : "r3");
+	__asm__ volatile("mr   r4,%0" : : "r" (item2) : "r4");
+	__asm__ volatile("mr   r5,%0" : : "r" (item3) : "r5");
+	__asm__ volatile("lis  r0,hi16(CutTrace)" : : : "r0");
+	__asm__ volatile("ori  r0,r0,lo16(CutTrace)" : : : "r0");
+	__asm__ volatile("sc");
+	return;
 }
 #endif
 
 extern void DoPreempt(void);
 extern __inline__ void DoPreempt(void) {
-#ifdef __ELF__
-        __asm__ volatile("lis  r0,DoPreemptCall@h" : : : "r0");
-        __asm__ volatile("ori  r0,r0,DoPreemptCall@l" : : : "r0");
-#else
-        __asm__ volatile("lis  r0,hi16(DoPreemptCall)" : : : "r0");
-        __asm__ volatile("ori  r0,r0,lo16(DoPreemptCall)" : : : "r0");
-#endif
-        __asm__ volatile("sc");
-		return;
+	__asm__ volatile("lis  r0,hi16(DoPreemptCall)" : : : "r0");
+	__asm__ volatile("ori  r0,r0,lo16(DoPreemptCall)" : : : "r0");
+	__asm__ volatile("sc");
+	return;
 }
 
 extern void CreateFakeIO(void);
 extern __inline__ void CreateFakeIO(void) {
-#ifdef __ELF__
-        __asm__ volatile("lis  r0,CreateFakeIOCall@h" : : : "r0");
-        __asm__ volatile("ori  r0,r0,CreateFakeIOCall@l" : : : "r0");
-#else
-        __asm__ volatile("lis  r0,hi16(CreateFakeIOCall)" : : : "r0");
-        __asm__ volatile("ori  r0,r0,lo16(CreateFakeIOCall)" : : : "r0");
-#endif
-         __asm__ volatile("sc");
+	__asm__ volatile("lis  r0,hi16(CreateFakeIOCall)" : : : "r0");
+	__asm__ volatile("ori  r0,r0,lo16(CreateFakeIOCall)" : : : "r0");
+	__asm__ volatile("sc");
 		return;
 }
 
 extern void StoreReal(unsigned int val, unsigned int addr);
 extern void ReadReal(unsigned int raddr, unsigned int *vaddr);
-extern void ClearReal(unsigned int addr, unsigned int lgn);
-extern void LoadDBATs(unsigned int *bat);
-extern void LoadIBATs(unsigned int *bat);
 extern unsigned int LLTraceSet(unsigned int tflags);
 extern void GratefulDebInit(void);
 extern void GratefulDebDisp(unsigned int coord, unsigned int data);
diff --git a/pexpert/pexpert/protos.h b/pexpert/pexpert/protos.h
index 79848c30a..8bd07d0ec 100644
--- a/pexpert/pexpert/protos.h
+++ b/pexpert/pexpert/protos.h
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/pexpert/ppc/pe_bootargs.c b/pexpert/ppc/pe_bootargs.c
index cf67d7205..55a26c7cb 100644
--- a/pexpert/ppc/pe_bootargs.c
+++ b/pexpert/ppc/pe_bootargs.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/pexpert/ppc/pe_clock_speed.c b/pexpert/ppc/pe_clock_speed.c
index 61f6c8dff..92a9d8d87 100644
--- a/pexpert/ppc/pe_clock_speed.c
+++ b/pexpert/ppc/pe_clock_speed.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -23,7 +26,7 @@
  *  pe_clock_speed.c - Determine the best guess for the processor and bus
  *                     speed buy using the values returned by run_clock_test.
  *
- *  (c) Apple Computer, Inc. 1998-2000
+ *  (c) Apple Computer, Inc. 1998-2002
  *
  *  Writen by:   Josh de Cesare
  *
@@ -81,10 +84,22 @@ void PE_Determine_Clock_Speeds(unsigned int via_addr, int num_speeds,
   gPEClockFrequencyInfo.bus_to_dec_rate_num = 1;
   gPEClockFrequencyInfo.bus_to_dec_rate_den = 4;
   
+  // Assume that the timebase frequency is derived from the bus clock.
+  gPEClockFrequencyInfo.timebase_frequency_num = bus_freq_num;
+  gPEClockFrequencyInfo.timebase_frequency_den = bus_freq_den * 4;
+  
   // Set the truncated numbers in gPEClockFrequencyInfo.
   gPEClockFrequencyInfo.bus_clock_rate_hz = tmp_bus_speed;
   gPEClockFrequencyInfo.cpu_clock_rate_hz = tmp_cpu_speed;
   gPEClockFrequencyInfo.dec_clock_rate_hz = tmp_bus_speed / 4;
+  gPEClockFrequencyInfo.timebase_frequency_hz = tmp_bus_speed / 4;
+  
+  gPEClockFrequencyInfo.bus_frequency_hz = tmp_bus_speed;
+  gPEClockFrequencyInfo.bus_frequency_min_hz = tmp_bus_speed;
+  gPEClockFrequencyInfo.bus_frequency_max_hz = tmp_bus_speed;
+  gPEClockFrequencyInfo.cpu_frequency_hz = tmp_cpu_speed;
+  gPEClockFrequencyInfo.cpu_frequency_min_hz = tmp_cpu_speed;
+  gPEClockFrequencyInfo.cpu_frequency_max_hz = tmp_cpu_speed;
   
   PE_call_timebase_callback();
 }
diff --git a/pexpert/ppc/pe_clock_speed_asm.s b/pexpert/ppc/pe_clock_speed_asm.s
index dfcd81a64..7c6054a24 100644
--- a/pexpert/ppc/pe_clock_speed_asm.s
+++ b/pexpert/ppc/pe_clock_speed_asm.s
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
diff --git a/pexpert/ppc/pe_identify_machine.c b/pexpert/ppc/pe_identify_machine.c
index 092d1926f..558d6bd65 100644
--- a/pexpert/ppc/pe_identify_machine.c
+++ b/pexpert/ppc/pe_identify_machine.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -43,32 +46,61 @@ void pe_identify_machine(void)
   bzero((void *)&gPEClockFrequencyInfo, sizeof(clock_frequency_info_t));
   
   // Start with default values.
-  gPEClockFrequencyInfo.bus_clock_rate_hz = 100000000;
-  gPEClockFrequencyInfo.cpu_clock_rate_hz = 300000000;
-  gPEClockFrequencyInfo.dec_clock_rate_hz =  25000000;
-  
+  gPEClockFrequencyInfo.timebase_frequency_hz = 25000000;
+  gPEClockFrequencyInfo.bus_clock_rate_hz     = 100000000;
+  gPEClockFrequencyInfo.cpu_clock_rate_hz     = 300000000;
+
   // Try to get the values from the device tree.
   if (DTFindEntry("device_type", "cpu", &cpu) == kSuccess) {
-    if (DTGetProperty(cpu, "bus-frequency",
-		      (void **)&value, &size) == kSuccess)
-      gPEClockFrequencyInfo.bus_clock_rate_hz = *value;
-    else {
-      if (DTLookupEntry(0, "/", &root) == kSuccess)
-	if (DTGetProperty(root, "clock-frequency",
-			  (void **)&value, &size) == kSuccess)
-	  gPEClockFrequencyInfo.bus_clock_rate_hz = *value;
+    // Find the time base frequency first.
+    if (DTGetProperty(cpu, "timebase-frequency", (void **)&value, &size) == kSuccess) {
+      // timebase_frequency_hz is only 32 bits, and the device tree should never provide 64 bits
+      // so this if should never be taken.
+      if (size == 8) gPEClockFrequencyInfo.timebase_frequency_hz = *(unsigned long long *)value;
+      else gPEClockFrequencyInfo.timebase_frequency_hz = *value;
+    }
+    gPEClockFrequencyInfo.dec_clock_rate_hz = gPEClockFrequencyInfo.timebase_frequency_hz;
+    
+    // Find the bus frequency next.  Try the cpu node, then the root.
+    if (DTGetProperty(cpu, "bus-frequency", (void **)&value, &size) == kSuccess) {
+      if (size == 8) gPEClockFrequencyInfo.bus_frequency_hz = *(unsigned long long *)value;
+      else gPEClockFrequencyInfo.bus_frequency_hz = *value;
+    } else {
+      if (DTLookupEntry(0, "/", &root) == kSuccess) {
+	if (DTGetProperty(root, "clock-frequency", (void **)&value, &size) == kSuccess) {
+	  if (size == 8) gPEClockFrequencyInfo.bus_frequency_hz = *(unsigned long long *)value;
+	  else gPEClockFrequencyInfo.bus_frequency_hz = *value;
+	}
+      }
+    }
+    
+    gPEClockFrequencyInfo.bus_frequency_min_hz = gPEClockFrequencyInfo.bus_frequency_hz;
+    gPEClockFrequencyInfo.bus_frequency_max_hz = gPEClockFrequencyInfo.bus_frequency_hz;
+    
+    if (gPEClockFrequencyInfo.bus_frequency_hz < 0x100000000ULL)
+      gPEClockFrequencyInfo.bus_clock_rate_hz = gPEClockFrequencyInfo.bus_frequency_hz;
+    else
+      gPEClockFrequencyInfo.bus_clock_rate_hz = 0xFFFFFFFF;
+    
+    // Find the cpu frequency last.
+    if (DTGetProperty(cpu, "clock-frequency", (void **)&value, &size) == kSuccess) {
+      if (size == 8) gPEClockFrequencyInfo.cpu_frequency_hz = *(unsigned long long *)value;
+      else gPEClockFrequencyInfo.cpu_frequency_hz = *value;
     }
     
-    if (DTGetProperty(cpu, "clock-frequency",
-		      (void **)&value, &size) == kSuccess)
-      gPEClockFrequencyInfo.cpu_clock_rate_hz = *value;
+    gPEClockFrequencyInfo.cpu_frequency_min_hz = gPEClockFrequencyInfo.cpu_frequency_hz;
+    gPEClockFrequencyInfo.cpu_frequency_max_hz = gPEClockFrequencyInfo.cpu_frequency_hz;
     
-    if (DTGetProperty(cpu, "timebase-frequency",
-		      (void **)&value, &size) == kSuccess)
-      gPEClockFrequencyInfo.dec_clock_rate_hz = *value;
+    if (gPEClockFrequencyInfo.cpu_frequency_hz < 0x100000000ULL)
+      gPEClockFrequencyInfo.cpu_clock_rate_hz = gPEClockFrequencyInfo.cpu_frequency_hz;
+    else
+      gPEClockFrequencyInfo.cpu_clock_rate_hz = 0xFFFFFFFF;
   }
   
   // Set the num / den pairs form the hz values.
+  gPEClockFrequencyInfo.timebase_frequency_num = gPEClockFrequencyInfo.timebase_frequency_hz;
+  gPEClockFrequencyInfo.timebase_frequency_den = 1;
+  
   gPEClockFrequencyInfo.bus_clock_rate_num = gPEClockFrequencyInfo.bus_clock_rate_hz;
   gPEClockFrequencyInfo.bus_clock_rate_den = 1;
   
@@ -106,50 +138,51 @@ vm_offset_t get_io_base_addr(void)
   return 0;
 }
 
-boolean_t PE_init_ethernet_debugger(void)
+vm_offset_t PE_find_scc(void)
 {
-  boolean_t result;
-#if 0
-  DTEntry       entryP;
-  vm_offset_t   *address;
-  unsigned char *netAddr;
-  int           size;
-  vm_offset_t   io;
-  
-  if ((io = get_io_base_addr())
-      && (DTFindEntry("name", "mace", &entryP) == kSuccess)
-      && (DTGetProperty(entryP, "local-mac-address", (void **)&netAddr, &size) == kSuccess)
-      && (DTGetProperty(entryP, "reg", (void **)&address, &size) == kSuccess)
-      && (size == (2 * 3 * sizeof(vm_offset_t)) ))
-    {
-      extern boolean_t kdp_mace_init(void *baseAddresses[3],
-				     unsigned char *netAddr);
-      void *maceAddrs[3];
-      
-      // address calculation not correct
-      maceAddrs[0] = (void *) io_map(io + address[0], address[1]);
-      maceAddrs[1] = (void *) io_map(io + address[2], 0x1000);
-      maceAddrs[2] = (void *) (((vm_offset_t)maceAddrs[1])
-			       + address[4] - address[2]);
-      result = kdp_mace_init( maceAddrs, netAddr );
-      
-    } else
-#endif
-      result = FALSE;
-  
-  return result;
+	vm_offset_t io, sccadd;
+	DTEntry     entryP;
+	vm_offset_t *sccregs;
+	unsigned int sccrsize;
+	
+	if(!(io = get_io_base_addr())) {		/* Get the I/O controller base address */
+		return (vm_offset_t)0;				/* Hmmm, no I/O??? What gives??? How'd we even boot? */
+	}
+
+	
+/*	Note: if we find a escc-legacy, we need to kind of hack because it can be either an offset
+	into the iobase or the actual address itself.  ORint the two should provide the correct 
+	for either */
+
+	sccadd = 0;								/* Assume none for now */
+
+	if(DTFindEntry("name", "escc-legacy", &entryP) == kSuccess)	{	/* Find the old fashioned serial port */
+		if (DTGetProperty(entryP, "reg", (void **)&sccregs, &sccrsize) == kSuccess) {	/* Do we have some registers? */
+			sccadd = ((vm_offset_t)*sccregs | io);	/* Get the address */
+		}
+	}
+	
+	if(DTFindEntry("name", "escc", &entryP) == kSuccess) {	/* Well, see if we just have the new fangled one */
+		sccadd = io + 0x12000; 				/* Yeah, but still return the oldie goldie... */
+	}
+	
+	return sccadd;							/* Return it if you found it */
 }
 
-vm_offset_t PE_find_scc(void)
+unsigned int PE_init_taproot(vm_offset_t *taddr)
 {
-  vm_offset_t io;
-  DTEntry     entryP;
-  
-  if ((io = get_io_base_addr())
-      && (DTFindEntry("name", "escc", &entryP) == kSuccess))
-    io += 0x12000; /* Offset to legacy SCC Registers */
-  else
-    io = 0;
-  
-  return io;
+	DTEntry     entryP;
+	vm_offset_t *tappdata;
+	unsigned int tappsize;
+	
+	
+	if(DTFindEntry("name", "memory-map", &entryP) != kSuccess) return 0;	/* no memory map */
+
+	if (DTGetProperty(entryP, "TapRoot", (void **)&tappdata, &tappsize) != kSuccess) return 0;	/* No TapRoot */
+
+	tappdata[1] = (tappdata[1] + 4095 ) & -4096;	/* Make sure this is a whole page */
+
+	*taddr = io_map_spec(tappdata[0], tappdata[1]);		/* Map it in and return the address */
+	tappdata[0] = *taddr;					/* Also change property */
+	return tappdata[1];						/* And the size */
 }
diff --git a/pexpert/ppc/pe_init.c b/pexpert/ppc/pe_init.c
index afffd30bf..478455a00 100644
--- a/pexpert/ppc/pe_init.c
+++ b/pexpert/ppc/pe_init.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -125,10 +128,6 @@ void PE_init_iokit(void)
     PE_init_kprintf(TRUE);
     PE_init_printf(TRUE);
 
-    // init this now to get mace debugger for iokit startup
-    PE_init_ethernet_debugger();
-
-    
     if( kSuccess == DTLookupEntry(0, "/chosen/memory-map", &entry)) {
 
 	boot_progress_element * bootPict;
@@ -201,6 +200,7 @@ void PE_create_console( void )
 int PE_current_console( PE_Video * info )
 {
     *info = PE_state.video;
+    info->v_baseAddr = 0;
     return( 0);
 }
 
@@ -245,8 +245,8 @@ void PE_call_timebase_callback(void)
   struct timebase_freq_t timebase_freq;
   unsigned long          num, den, cnt;
   
-  num = gPEClockFrequencyInfo.bus_clock_rate_num * gPEClockFrequencyInfo.bus_to_dec_rate_num;
-  den = gPEClockFrequencyInfo.bus_clock_rate_den * gPEClockFrequencyInfo.bus_to_dec_rate_den;
+  num = gPEClockFrequencyInfo.timebase_frequency_num;
+  den = gPEClockFrequencyInfo.timebase_frequency_den;
   
   cnt = 2;
   while (cnt <= den) {
diff --git a/pexpert/ppc/pe_kprintf.c b/pexpert/ppc/pe_kprintf.c
index 6ecfacbe8..02a62efd6 100644
--- a/pexpert/ppc/pe_kprintf.c
+++ b/pexpert/ppc/pe_kprintf.c
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -45,34 +48,28 @@ void (*PE_kputc)(char c) = 0;
 
 unsigned int disableSerialOuput = TRUE;
 
+vm_offset_t	scc = 0;
 
-static struct slock kprintf_lock;
+struct slock kprintf_lock;
 
 void PE_init_kprintf(boolean_t vm_initialized)
 {
-	static vm_offset_t	scc;
 	unsigned int	boot_arg;
 
 	if (PE_state.initialized == FALSE)
 		panic("Platform Expert not initialized");
 
-	if (!vm_initialized)
-	{
-	    if (PE_parse_boot_arg("debug", &boot_arg)) 
-	        if(boot_arg & DB_KPRT) disableSerialOuput = FALSE; 
+	if (PE_parse_boot_arg("debug", &boot_arg)) 
+		if(boot_arg & DB_KPRT) disableSerialOuput = FALSE; 
 
-	    if( (scc = PE_find_scc()))
-            {
-		initialize_serial( (void *) scc );
+	if( (scc = PE_find_scc())) {				/* See if we can find the serial port */
+		scc = io_map_spec(scc, 0x1000);			/* Map it in */
+		initialize_serial((void *)scc);			/* Start up the serial driver */
 		PE_kputc = serial_putc;
 
 		simple_lock_init(&kprintf_lock, 0);
-            } else
-		PE_kputc = cnputc;
-
-	} else if( scc){
-		initialize_serial( (void *) io_map( scc, 0x1000) );
-	}
+	} else
+			PE_kputc = cnputc;
 
 #if 0
 	/*
diff --git a/pexpert/ppc/pe_misc.s b/pexpert/ppc/pe_misc.s
index 8cda8649f..2eb47ad71 100644
--- a/pexpert/ppc/pe_misc.s
+++ b/pexpert/ppc/pe_misc.s
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
-- 
2.47.2